diff --git a/lightrag/api/webui/assets/index-uJ5sfwNq.js b/lightrag/api/webui/assets/index-IDR-_K-N.js similarity index 99% rename from lightrag/api/webui/assets/index-uJ5sfwNq.js rename to lightrag/api/webui/assets/index-IDR-_K-N.js index ff6ed240..8ce93f0a 100644 --- a/lightrag/api/webui/assets/index-uJ5sfwNq.js +++ b/lightrag/api/webui/assets/index-IDR-_K-N.js @@ -1093,7 +1093,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho - \`null\` or \`undefined\` if the progress is indeterminate. Defaulting to \`null\`.`}var Z5=W5,Sie=K5;const Q5=w.forwardRef(({className:e,value:t,...n},r)=>E.jsx(Z5,{ref:r,className:Me("bg-secondary relative h-4 w-full overflow-hidden rounded-full",e),...n,children:E.jsx(Sie,{className:"bg-primary h-full w-full flex-1 transition-all",style:{transform:`translateX(-${100-(t||0)}%)`}})}));Q5.displayName=Z5.displayName;function Eie(e,t){return w.useReducer((n,r)=>t[n][r]??n,e)}var BT="ScrollArea",[J5,cke]=wr(BT),[wie,Tr]=J5(BT),eG=w.forwardRef((e,t)=>{const{__scopeScrollArea:n,type:r="hover",dir:a,scrollHideDelay:o=600,...s}=e,[u,c]=w.useState(null),[d,p]=w.useState(null),[g,m]=w.useState(null),[b,y]=w.useState(null),[v,k]=w.useState(null),[A,x]=w.useState(0),[R,O]=w.useState(0),[_,C]=w.useState(!1),[N,M]=w.useState(!1),I=mt(t,H=>c(H)),D=pp(a);return E.jsx(wie,{scope:n,type:r,dir:D,scrollHideDelay:o,scrollArea:u,viewport:d,onViewportChange:p,content:g,onContentChange:m,scrollbarX:b,onScrollbarXChange:y,scrollbarXEnabled:_,onScrollbarXEnabledChange:C,scrollbarY:v,onScrollbarYChange:k,scrollbarYEnabled:N,onScrollbarYEnabledChange:M,onCornerWidthChange:x,onCornerHeightChange:O,children:E.jsx(Ze.div,{dir:D,...s,ref:I,style:{position:"relative","--radix-scroll-area-corner-width":A+"px","--radix-scroll-area-corner-height":R+"px",...e.style}})})});eG.displayName=BT;var tG="ScrollAreaViewport",nG=w.forwardRef((e,t)=>{const{__scopeScrollArea:n,children:r,nonce:a,...o}=e,s=Tr(tG,n),u=w.useRef(null),c=mt(t,u,s.onViewportChange);return E.jsxs(E.Fragment,{children:[E.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}"},nonce:a}),E.jsx(Ze.div,{"data-radix-scroll-area-viewport":"",...o,ref:c,style:{overflowX:s.scrollbarXEnabled?"scroll":"hidden",overflowY:s.scrollbarYEnabled?"scroll":"hidden",...e.style},children:E.jsx("div",{ref:s.onContentChange,style:{minWidth:"100%",display:"table"},children:r})})]})});nG.displayName=tG;var ca="ScrollAreaScrollbar",UT=w.forwardRef((e,t)=>{const{forceMount:n,...r}=e,a=Tr(ca,e.__scopeScrollArea),{onScrollbarXEnabledChange:o,onScrollbarYEnabledChange:s}=a,u=e.orientation==="horizontal";return w.useEffect(()=>(u?o(!0):s(!0),()=>{u?o(!1):s(!1)}),[u,o,s]),a.type==="hover"?E.jsx(xie,{...r,ref:t,forceMount:n}):a.type==="scroll"?E.jsx(kie,{...r,ref:t,forceMount:n}):a.type==="auto"?E.jsx(rG,{...r,ref:t,forceMount:n}):a.type==="always"?E.jsx(jT,{...r,ref:t}):null});UT.displayName=ca;var xie=w.forwardRef((e,t)=>{const{forceMount:n,...r}=e,a=Tr(ca,e.__scopeScrollArea),[o,s]=w.useState(!1);return w.useEffect(()=>{const u=a.scrollArea;let c=0;if(u){const d=()=>{window.clearTimeout(c),s(!0)},p=()=>{c=window.setTimeout(()=>s(!1),a.scrollHideDelay)};return u.addEventListener("pointerenter",d),u.addEventListener("pointerleave",p),()=>{window.clearTimeout(c),u.removeEventListener("pointerenter",d),u.removeEventListener("pointerleave",p)}}},[a.scrollArea,a.scrollHideDelay]),E.jsx(xr,{present:n||o,children:E.jsx(rG,{"data-state":o?"visible":"hidden",...r,ref:t})})}),kie=w.forwardRef((e,t)=>{const{forceMount:n,...r}=e,a=Tr(ca,e.__scopeScrollArea),o=e.orientation==="horizontal",s=Np(()=>c("SCROLL_END"),100),[u,c]=Eie("hidden",{hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}});return w.useEffect(()=>{if(u==="idle"){const d=window.setTimeout(()=>c("HIDE"),a.scrollHideDelay);return()=>window.clearTimeout(d)}},[u,a.scrollHideDelay,c]),w.useEffect(()=>{const d=a.viewport,p=o?"scrollLeft":"scrollTop";if(d){let g=d[p];const m=()=>{const b=d[p];g!==b&&(c("SCROLL"),s()),g=b};return d.addEventListener("scroll",m),()=>d.removeEventListener("scroll",m)}},[a.viewport,o,c,s]),E.jsx(xr,{present:n||u!=="hidden",children:E.jsx(jT,{"data-state":u==="hidden"?"hidden":"visible",...r,ref:t,onPointerEnter:Ke(e.onPointerEnter,()=>c("POINTER_ENTER")),onPointerLeave:Ke(e.onPointerLeave,()=>c("POINTER_LEAVE"))})})}),rG=w.forwardRef((e,t)=>{const n=Tr(ca,e.__scopeScrollArea),{forceMount:r,...a}=e,[o,s]=w.useState(!1),u=e.orientation==="horizontal",c=Np(()=>{if(n.viewport){const d=n.viewport.offsetWidth{const{orientation:n="vertical",...r}=e,a=Tr(ca,e.__scopeScrollArea),o=w.useRef(null),s=w.useRef(0),[u,c]=w.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),d=lG(u.viewport,u.content),p={...r,sizes:u,onSizesChange:c,hasThumb:d>0&&d<1,onThumbChange:m=>o.current=m,onThumbPointerUp:()=>s.current=0,onThumbPointerDown:m=>s.current=m};function g(m,b){return Nie(m,s.current,u,b)}return n==="horizontal"?E.jsx(Tie,{...p,ref:t,onThumbPositionChange:()=>{if(a.viewport&&o.current){const m=a.viewport.scrollLeft,b=ZO(m,u,a.dir);o.current.style.transform=`translate3d(${b}px, 0, 0)`}},onWheelScroll:m=>{a.viewport&&(a.viewport.scrollLeft=m)},onDragScroll:m=>{a.viewport&&(a.viewport.scrollLeft=g(m,a.dir))}}):n==="vertical"?E.jsx(Aie,{...p,ref:t,onThumbPositionChange:()=>{if(a.viewport&&o.current){const m=a.viewport.scrollTop,b=ZO(m,u);o.current.style.transform=`translate3d(0, ${b}px, 0)`}},onWheelScroll:m=>{a.viewport&&(a.viewport.scrollTop=m)},onDragScroll:m=>{a.viewport&&(a.viewport.scrollTop=g(m))}}):null}),Tie=w.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...a}=e,o=Tr(ca,e.__scopeScrollArea),[s,u]=w.useState(),c=w.useRef(null),d=mt(t,c,o.onScrollbarXChange);return w.useEffect(()=>{c.current&&u(getComputedStyle(c.current))},[c]),E.jsx(oG,{"data-orientation":"horizontal",...a,ref:d,sizes:n,style:{bottom:0,left:o.dir==="rtl"?"var(--radix-scroll-area-corner-width)":0,right:o.dir==="ltr"?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":_p(n)+"px",...e.style},onThumbPointerDown:p=>e.onThumbPointerDown(p.x),onDragScroll:p=>e.onDragScroll(p.x),onWheelScroll:(p,g)=>{if(o.viewport){const m=o.viewport.scrollLeft+p.deltaX;e.onWheelScroll(m),cG(m,g)&&p.preventDefault()}},onResize:()=>{c.current&&o.viewport&&s&&r({content:o.viewport.scrollWidth,viewport:o.viewport.offsetWidth,scrollbar:{size:c.current.clientWidth,paddingStart:Mf(s.paddingLeft),paddingEnd:Mf(s.paddingRight)}})}})}),Aie=w.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...a}=e,o=Tr(ca,e.__scopeScrollArea),[s,u]=w.useState(),c=w.useRef(null),d=mt(t,c,o.onScrollbarYChange);return w.useEffect(()=>{c.current&&u(getComputedStyle(c.current))},[c]),E.jsx(oG,{"data-orientation":"vertical",...a,ref:d,sizes:n,style:{top:0,right:o.dir==="ltr"?0:void 0,left:o.dir==="rtl"?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":_p(n)+"px",...e.style},onThumbPointerDown:p=>e.onThumbPointerDown(p.y),onDragScroll:p=>e.onDragScroll(p.y),onWheelScroll:(p,g)=>{if(o.viewport){const m=o.viewport.scrollTop+p.deltaY;e.onWheelScroll(m),cG(m,g)&&p.preventDefault()}},onResize:()=>{c.current&&o.viewport&&s&&r({content:o.viewport.scrollHeight,viewport:o.viewport.offsetHeight,scrollbar:{size:c.current.clientHeight,paddingStart:Mf(s.paddingTop),paddingEnd:Mf(s.paddingBottom)}})}})}),[Rie,aG]=J5(ca),oG=w.forwardRef((e,t)=>{const{__scopeScrollArea:n,sizes:r,hasThumb:a,onThumbChange:o,onThumbPointerUp:s,onThumbPointerDown:u,onThumbPositionChange:c,onDragScroll:d,onWheelScroll:p,onResize:g,...m}=e,b=Tr(ca,n),[y,v]=w.useState(null),k=mt(t,I=>v(I)),A=w.useRef(null),x=w.useRef(""),R=b.viewport,O=r.content-r.viewport,_=yn(p),C=yn(c),N=Np(g,10);function M(I){if(A.current){const D=I.clientX-A.current.left,H=I.clientY-A.current.top;d({x:D,y:H})}}return w.useEffect(()=>{const I=D=>{const H=D.target;(y==null?void 0:y.contains(H))&&_(D,O)};return document.addEventListener("wheel",I,{passive:!1}),()=>document.removeEventListener("wheel",I,{passive:!1})},[R,y,O,_]),w.useEffect(C,[r,C]),zs(y,N),zs(b.content,N),E.jsx(Rie,{scope:n,scrollbar:y,hasThumb:a,onThumbChange:yn(o),onThumbPointerUp:yn(s),onThumbPositionChange:C,onThumbPointerDown:yn(u),children:E.jsx(Ze.div,{...m,ref:k,style:{position:"absolute",...m.style},onPointerDown:Ke(e.onPointerDown,I=>{I.button===0&&(I.target.setPointerCapture(I.pointerId),A.current=y.getBoundingClientRect(),x.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",b.viewport&&(b.viewport.style.scrollBehavior="auto"),M(I))}),onPointerMove:Ke(e.onPointerMove,M),onPointerUp:Ke(e.onPointerUp,I=>{const D=I.target;D.hasPointerCapture(I.pointerId)&&D.releasePointerCapture(I.pointerId),document.body.style.webkitUserSelect=x.current,b.viewport&&(b.viewport.style.scrollBehavior=""),A.current=null})})})}),Lf="ScrollAreaThumb",iG=w.forwardRef((e,t)=>{const{forceMount:n,...r}=e,a=aG(Lf,e.__scopeScrollArea);return E.jsx(xr,{present:n||a.hasThumb,children:E.jsx(Cie,{ref:t,...r})})}),Cie=w.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:r,...a}=e,o=Tr(Lf,n),s=aG(Lf,n),{onThumbPositionChange:u}=s,c=mt(t,g=>s.onThumbChange(g)),d=w.useRef(void 0),p=Np(()=>{d.current&&(d.current(),d.current=void 0)},100);return w.useEffect(()=>{const g=o.viewport;if(g){const m=()=>{if(p(),!d.current){const b=Oie(g,u);d.current=b,u()}};return u(),g.addEventListener("scroll",m),()=>g.removeEventListener("scroll",m)}},[o.viewport,p,u]),E.jsx(Ze.div,{"data-state":s.hasThumb?"visible":"hidden",...a,ref:c,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...r},onPointerDownCapture:Ke(e.onPointerDownCapture,g=>{const b=g.target.getBoundingClientRect(),y=g.clientX-b.left,v=g.clientY-b.top;s.onThumbPointerDown({x:y,y:v})}),onPointerUp:Ke(e.onPointerUp,s.onThumbPointerUp)})});iG.displayName=Lf;var GT="ScrollAreaCorner",sG=w.forwardRef((e,t)=>{const n=Tr(GT,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&r?E.jsx(_ie,{...e,ref:t}):null});sG.displayName=GT;var _ie=w.forwardRef((e,t)=>{const{__scopeScrollArea:n,...r}=e,a=Tr(GT,n),[o,s]=w.useState(0),[u,c]=w.useState(0),d=!!(o&&u);return zs(a.scrollbarX,()=>{var g;const p=((g=a.scrollbarX)==null?void 0:g.offsetHeight)||0;a.onCornerHeightChange(p),c(p)}),zs(a.scrollbarY,()=>{var g;const p=((g=a.scrollbarY)==null?void 0:g.offsetWidth)||0;a.onCornerWidthChange(p),s(p)}),d?E.jsx(Ze.div,{...r,ref:t,style:{width:o,height:u,position:"absolute",right:a.dir==="ltr"?0:void 0,left:a.dir==="rtl"?0:void 0,bottom:0,...e.style}}):null});function Mf(e){return e?parseInt(e,10):0}function lG(e,t){const n=e/t;return isNaN(n)?0:n}function _p(e){const t=lG(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function Nie(e,t,n,r="ltr"){const a=_p(n),o=a/2,s=t||o,u=a-s,c=n.scrollbar.paddingStart+s,d=n.scrollbar.size-n.scrollbar.paddingEnd-u,p=n.content-n.viewport,g=r==="ltr"?[0,p]:[p*-1,0];return uG([c,d],g)(e)}function ZO(e,t,n="ltr"){const r=_p(t),a=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,o=t.scrollbar.size-a,s=t.content-t.viewport,u=o-r,c=n==="ltr"?[0,s]:[s*-1,0],d=Ik(e,c);return uG([0,s],[0,u])(d)}function uG(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];const r=(t[1]-t[0])/(e[1]-e[0]);return t[0]+r*(n-e[0])}}function cG(e,t){return e>0&&e{})=>{let n={left:e.scrollLeft,top:e.scrollTop},r=0;return function a(){const o={left:e.scrollLeft,top:e.scrollTop},s=n.left!==o.left,u=n.top!==o.top;(s||u)&&t(),n=o,r=window.requestAnimationFrame(a)}(),()=>window.cancelAnimationFrame(r)};function Np(e,t){const n=yn(e),r=w.useRef(0);return w.useEffect(()=>()=>window.clearTimeout(r.current),[]),w.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(n,t)},[n,t])}function zs(e,t){const n=yn(t);Rn(()=>{let r=0;if(e){const a=new ResizeObserver(()=>{cancelAnimationFrame(r),r=window.requestAnimationFrame(n)});return a.observe(e),()=>{window.cancelAnimationFrame(r),a.unobserve(e)}}},[e,n])}var dG=eG,Iie=nG,Die=sG;const fG=w.forwardRef(({className:e,children:t,...n},r)=>E.jsxs(dG,{ref:r,className:Me("relative overflow-hidden",e),...n,children:[E.jsx(Iie,{className:"h-full w-full rounded-[inherit]",children:t}),E.jsx(pG,{}),E.jsx(Die,{})]}));fG.displayName=dG.displayName;const pG=w.forwardRef(({className:e,orientation:t="vertical",...n},r)=>E.jsx(UT,{ref:r,orientation:t,className:Me("flex touch-none transition-colors select-none",t==="vertical"&&"h-full w-2.5 border-l border-l-transparent p-[1px]",t==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",e),...n,children:E.jsx(iG,{className:"bg-border relative flex-1 rounded-full"})}));pG.displayName=UT.displayName;function l0(e,t={}){const{decimals:n=0,sizeType:r="normal"}=t,a=["Bytes","KB","MB","GB","TB"],o=["Bytes","KiB","MiB","GiB","TiB"];if(e===0)return"0 Byte";const s=Math.floor(Math.log(e)/Math.log(1024));return`${(e/Math.pow(1024,s)).toFixed(n)} ${r==="accurate"?o[s]??"Bytes":a[s]??"Bytes"}`}function Lie(e){const{value:t,onValueChange:n,onUpload:r,progresses:a,accept:o=mV,maxSize:s=1024*1024*200,maxFileCount:u=1,multiple:c=!1,disabled:d=!1,description:p,className:g,...m}=e,[b,y]=Ba({prop:t,onChange:n}),v=w.useCallback((x,R)=>{if(!c&&u===1&&x.length>1){Ft.error("Cannot upload more than 1 file at a time");return}if(((b==null?void 0:b.length)??0)+x.length>u){Ft.error(`Cannot upload more than ${u} files`);return}const O=x.map(C=>Object.assign(C,{preview:URL.createObjectURL(C)})),_=b?[...b,...O]:O;if(y(_),R.length>0&&R.forEach(({file:C})=>{Ft.error(`File ${C.name} was rejected`)}),r&&_.length>0&&_.length<=u){const C=_.length>0?`${_.length} files`:"file";Ft.promise(r(_),{loading:`Uploading ${C}...`,success:()=>(y([]),`${C} uploaded`),error:`Failed to upload ${C}`})}},[b,u,c,r,y]);function k(x){if(!b)return;const R=b.filter((O,_)=>_!==x);y(R),n==null||n(R)}w.useEffect(()=>()=>{b&&b.forEach(x=>{gG(x)&&URL.revokeObjectURL(x.preview)})},[]);const A=d||((b==null?void 0:b.length)??0)>=u;return E.jsxs("div",{className:"relative flex flex-col gap-6 overflow-hidden",children:[E.jsx(Cp,{onDrop:v,accept:o,maxSize:s,maxFiles:u,multiple:u>1||c,disabled:A,children:({getRootProps:x,getInputProps:R,isDragActive:O})=>E.jsxs("div",{...x(),className:Me("group border-muted-foreground/25 hover:bg-muted/25 relative grid h-52 w-full cursor-pointer place-items-center rounded-lg border-2 border-dashed px-5 py-2.5 text-center transition","ring-offset-background focus-visible:ring-ring focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none",O&&"border-muted-foreground/50",A&&"pointer-events-none opacity-60",g),...m,children:[E.jsx("input",{...R()}),O?E.jsxs("div",{className:"flex flex-col items-center justify-center gap-4 sm:px-5",children:[E.jsx("div",{className:"rounded-full border border-dashed p-3",children:E.jsx(zk,{className:"text-muted-foreground size-7","aria-hidden":"true"})}),E.jsx("p",{className:"text-muted-foreground font-medium",children:"Drop the files here"})]}):E.jsxs("div",{className:"flex flex-col items-center justify-center gap-4 sm:px-5",children:[E.jsx("div",{className:"rounded-full border border-dashed p-3",children:E.jsx(zk,{className:"text-muted-foreground size-7","aria-hidden":"true"})}),E.jsxs("div",{className:"flex flex-col gap-px",children:[E.jsx("p",{className:"text-muted-foreground font-medium",children:"Drag and drop files here, or click to select files"}),p?E.jsx("p",{className:"text-muted-foreground/70 text-sm",children:p}):E.jsxs("p",{className:"text-muted-foreground/70 text-sm",children:["You can upload",u>1?` ${u===1/0?"multiple":u} - files (up to ${l0(s)} each)`:` a file with ${l0(s)}`,"Supported formats: TXT, MD, DOCX, PDF, PPTX, RTF, ODT, EPUB, HTML, HTM, TEX, JSON, XML, YAML, YML, CSV, LOG, CONF, INI, PROPERTIES, SQL, BAT, SH, C, CPP, PY, JAVA, JS, TS, SWIFT, GO, RB, PHP, CSS, SCSS, LESS"]})]})]})]})}),b!=null&&b.length?E.jsx(fG,{className:"h-fit w-full px-3",children:E.jsx("div",{className:"flex max-h-48 flex-col gap-4",children:b==null?void 0:b.map((x,R)=>E.jsx(Mie,{file:x,onRemove:()=>k(R),progress:a==null?void 0:a[x.name]},R))})}):null]})}function Mie({file:e,progress:t,onRemove:n}){return E.jsxs("div",{className:"relative flex items-center gap-2.5",children:[E.jsxs("div",{className:"flex flex-1 gap-2.5",children:[gG(e)?E.jsx(Pie,{file:e}):null,E.jsxs("div",{className:"flex w-full flex-col gap-2",children:[E.jsxs("div",{className:"flex flex-col gap-px",children:[E.jsx("p",{className:"text-foreground/80 line-clamp-1 text-sm font-medium",children:e.name}),E.jsx("p",{className:"text-muted-foreground text-xs",children:l0(e.size)})]}),t?E.jsx(Q5,{value:t}):null]})]}),E.jsx("div",{className:"flex items-center gap-2",children:E.jsxs(pt,{type:"button",variant:"outline",size:"icon",className:"size-7",onClick:n,children:[E.jsx(N3,{className:"size-4","aria-hidden":"true"}),E.jsx("span",{className:"sr-only",children:"Remove file"})]})})]})}function gG(e){return"preview"in e&&typeof e.preview=="string"}function Pie({file:e}){return e.type.startsWith("image/")?E.jsx("div",{className:"aspect-square shrink-0 rounded-md object-cover"}):E.jsx(KZ,{className:"text-muted-foreground size-10","aria-hidden":"true"})}function Fie(){const{t:e}=Dt(),[t,n]=w.useState(!1),[r,a]=w.useState(!1),[o,s]=w.useState({}),u=w.useCallback(async c=>{a(!0);try{await Promise.all(c.map(async d=>{try{const p=await IV(d,g=>{console.debug(e("documentPanel.uploadDocuments.uploading",{name:d.name,percent:g})),s(m=>({...m,[d.name]:g}))});p.status==="success"?Ft.success(e("documentPanel.uploadDocuments.success",{name:d.name})):Ft.error(e("documentPanel.uploadDocuments.failed",{name:d.name,message:p.message}))}catch(p){Ft.error(e("documentPanel.uploadDocuments.error",{name:d.name,error:tr(p)}))}}))}catch(d){Ft.error(e("documentPanel.uploadDocuments.generalError",{error:tr(d)}))}finally{a(!1)}},[a,s]);return E.jsxs(NT,{open:t,onOpenChange:c=>{r&&!c||n(c)},children:[E.jsx(b5,{asChild:!0,children:E.jsxs(pt,{variant:"default",side:"bottom",tooltip:e("documentPanel.uploadDocuments.tooltip"),size:"sm",children:[E.jsx(zk,{})," ",e("documentPanel.uploadDocuments.button")]})}),E.jsxs(Ep,{className:"sm:max-w-xl",onCloseAutoFocus:c=>c.preventDefault(),children:[E.jsxs(wp,{children:[E.jsx(xp,{children:e("documentPanel.uploadDocuments.title")}),E.jsx(kp,{children:e("documentPanel.uploadDocuments.description")})]}),E.jsx(Lie,{maxFileCount:1/0,maxSize:200*1024*1024,description:e("documentPanel.uploadDocuments.fileTypes"),onUpload:u,progresses:o,disabled:r})]})]})}function zie(){const{t:e}=Dt(),[t,n]=w.useState(!1),r=w.useCallback(async()=>{try{const a=await DV();a.status==="success"?(Ft.success(e("documentPanel.clearDocuments.success")),n(!1)):Ft.error(e("documentPanel.clearDocuments.failed",{message:a.message}))}catch(a){Ft.error(e("documentPanel.clearDocuments.error",{error:tr(a)}))}},[n,e]);return E.jsxs(NT,{open:t,onOpenChange:n,children:[E.jsx(b5,{asChild:!0,children:E.jsxs(pt,{variant:"outline",side:"bottom",tooltip:e("documentPanel.clearDocuments.tooltip"),size:"sm",children:[E.jsx(R3,{})," ",e("documentPanel.clearDocuments.button")]})}),E.jsxs(Ep,{className:"sm:max-w-xl",onCloseAutoFocus:a=>a.preventDefault(),children:[E.jsxs(wp,{children:[E.jsx(xp,{children:e("documentPanel.clearDocuments.title")}),E.jsx(kp,{children:e("documentPanel.clearDocuments.confirm")})]}),E.jsx(pt,{variant:"destructive",onClick:r,children:e("documentPanel.clearDocuments.confirmButton")})]})]})}function Bie({open:e,onOpenChange:t}){var g;const{t:n}=Dt(),[r,a]=w.useState(null),[o,s]=w.useState("center"),[u,c]=w.useState(!1),d=w.useRef(null);w.useEffect(()=>{e&&(s("center"),c(!1))},[e]),w.useEffect(()=>{const m=d.current;!m||u||(m.scrollTop=m.scrollHeight)},[r==null?void 0:r.history_messages,u]);const p=()=>{const m=d.current;if(!m)return;const b=Math.abs(m.scrollHeight-m.scrollTop-m.clientHeight)<1;c(!b)};return w.useEffect(()=>{if(!e)return;const m=async()=>{try{const y=await LV();a(y)}catch(y){Ft.error(n("documentPanel.pipelineStatus.errors.fetchFailed",{error:tr(y)}))}};m();const b=setInterval(m,2e3);return()=>clearInterval(b)},[e,n]),E.jsx(NT,{open:e,onOpenChange:t,children:E.jsxs(Ep,{className:Me("sm:max-w-[600px] transition-all duration-200 fixed",o==="left"&&"!left-[25%] !translate-x-[-50%] !mx-4",o==="center"&&"!left-1/2 !-translate-x-1/2",o==="right"&&"!left-[75%] !translate-x-[-50%] !mx-4"),children:[E.jsx(kp,{className:"sr-only",children:r!=null&&r.job_name?`${n("documentPanel.pipelineStatus.jobName")}: ${r.job_name}, ${n("documentPanel.pipelineStatus.progress")}: ${r.cur_batch}/${r.batchs}`:n("documentPanel.pipelineStatus.noActiveJob")}),E.jsxs(wp,{className:"flex flex-row items-center",children:[E.jsx(xp,{className:"flex-1",children:n("documentPanel.pipelineStatus.title")}),E.jsxs("div",{className:"flex items-center gap-2 mr-8",children:[E.jsx(pt,{variant:"ghost",size:"icon",className:Me("h-6 w-6",o==="left"&&"bg-zinc-200 text-zinc-800 hover:bg-zinc-300 dark:bg-zinc-700 dark:text-zinc-200 dark:hover:bg-zinc-600"),onClick:()=>s("left"),children:E.jsx(FZ,{className:"h-4 w-4"})}),E.jsx(pt,{variant:"ghost",size:"icon",className:Me("h-6 w-6",o==="center"&&"bg-zinc-200 text-zinc-800 hover:bg-zinc-300 dark:bg-zinc-700 dark:text-zinc-200 dark:hover:bg-zinc-600"),onClick:()=>s("center"),children:E.jsx(MZ,{className:"h-4 w-4"})}),E.jsx(pt,{variant:"ghost",size:"icon",className:Me("h-6 w-6",o==="right"&&"bg-zinc-200 text-zinc-800 hover:bg-zinc-300 dark:bg-zinc-700 dark:text-zinc-200 dark:hover:bg-zinc-600"),onClick:()=>s("right"),children:E.jsx(BZ,{className:"h-4 w-4"})})]})]}),E.jsxs("div",{className:"space-y-4 pt-4",children:[E.jsxs("div",{className:"flex items-center gap-4",children:[E.jsxs("div",{className:"flex items-center gap-2",children:[E.jsxs("div",{className:"text-sm font-medium",children:[n("documentPanel.pipelineStatus.busy"),":"]}),E.jsx("div",{className:`h-2 w-2 rounded-full ${r!=null&&r.busy?"bg-green-500":"bg-gray-300"}`})]}),E.jsxs("div",{className:"flex items-center gap-2",children:[E.jsxs("div",{className:"text-sm font-medium",children:[n("documentPanel.pipelineStatus.requestPending"),":"]}),E.jsx("div",{className:`h-2 w-2 rounded-full ${r!=null&&r.request_pending?"bg-green-500":"bg-gray-300"}`})]})]}),E.jsxs("div",{className:"rounded-md border p-3 space-y-2",children:[E.jsxs("div",{children:[n("documentPanel.pipelineStatus.jobName"),": ",(r==null?void 0:r.job_name)||"-"]}),E.jsxs("div",{className:"flex justify-between",children:[E.jsxs("span",{children:[n("documentPanel.pipelineStatus.startTime"),": ",r!=null&&r.job_start?new Date(r.job_start).toLocaleString():"-"]}),E.jsxs("span",{children:[n("documentPanel.pipelineStatus.progress"),": ",r?`${r.cur_batch}/${r.batchs}`:"-"]})]})]}),E.jsxs("div",{className:"space-y-2",children:[E.jsxs("div",{className:"text-sm font-medium",children:[n("documentPanel.pipelineStatus.latestMessage"),":"]}),E.jsx("div",{className:"font-mono text-sm rounded-md bg-zinc-800 text-zinc-100 p-3",children:(r==null?void 0:r.latest_message)||"-"})]}),E.jsxs("div",{className:"space-y-2",children:[E.jsxs("div",{className:"text-sm font-medium",children:[n("documentPanel.pipelineStatus.historyMessages"),":"]}),E.jsx("div",{ref:d,onScroll:p,className:"font-mono text-sm rounded-md bg-zinc-800 text-zinc-100 p-3 overflow-y-auto min-h-[7.5em] max-h-[40vh]",children:((g=r==null?void 0:r.history_messages)==null?void 0:g.map((m,b)=>E.jsx("div",{children:m},b)))||"-"})]})]})]})})}const Uie=(e,t=20)=>{if(!e.file_path||typeof e.file_path!="string"||e.file_path.trim()==="")return e.id;const n=e.file_path.split("/"),r=n[n.length-1];return!r||r.trim()===""?e.id:r.length>t?r.slice(0,t)+"...":r},jie=` + files (up to ${l0(s)} each)`:` a file with ${l0(s)}`,"Supported formats: TXT, MD, DOCX, PDF, PPTX, RTF, ODT, EPUB, HTML, HTM, TEX, JSON, XML, YAML, YML, CSV, LOG, CONF, INI, PROPERTIES, SQL, BAT, SH, C, CPP, PY, JAVA, JS, TS, SWIFT, GO, RB, PHP, CSS, SCSS, LESS"]})]})]})]})}),b!=null&&b.length?E.jsx(fG,{className:"h-fit w-full px-3",children:E.jsx("div",{className:"flex max-h-48 flex-col gap-4",children:b==null?void 0:b.map((x,R)=>E.jsx(Mie,{file:x,onRemove:()=>k(R),progress:a==null?void 0:a[x.name]},R))})}):null]})}function Mie({file:e,progress:t,onRemove:n}){return E.jsxs("div",{className:"relative flex items-center gap-2.5",children:[E.jsxs("div",{className:"flex flex-1 gap-2.5",children:[gG(e)?E.jsx(Pie,{file:e}):null,E.jsxs("div",{className:"flex w-full flex-col gap-2",children:[E.jsxs("div",{className:"flex flex-col gap-px",children:[E.jsx("p",{className:"text-foreground/80 line-clamp-1 text-sm font-medium",children:e.name}),E.jsx("p",{className:"text-muted-foreground text-xs",children:l0(e.size)})]}),t?E.jsx(Q5,{value:t}):null]})]}),E.jsx("div",{className:"flex items-center gap-2",children:E.jsxs(pt,{type:"button",variant:"outline",size:"icon",className:"size-7",onClick:n,children:[E.jsx(N3,{className:"size-4","aria-hidden":"true"}),E.jsx("span",{className:"sr-only",children:"Remove file"})]})})]})}function gG(e){return"preview"in e&&typeof e.preview=="string"}function Pie({file:e}){return e.type.startsWith("image/")?E.jsx("div",{className:"aspect-square shrink-0 rounded-md object-cover"}):E.jsx(KZ,{className:"text-muted-foreground size-10","aria-hidden":"true"})}function Fie(){const{t:e}=Dt(),[t,n]=w.useState(!1),[r,a]=w.useState(!1),[o,s]=w.useState({}),u=w.useCallback(async c=>{a(!0);try{await Promise.all(c.map(async d=>{try{const p=await IV(d,g=>{console.debug(e("documentPanel.uploadDocuments.uploading",{name:d.name,percent:g})),s(m=>({...m,[d.name]:g}))});p.status==="success"?Ft.success(e("documentPanel.uploadDocuments.success",{name:d.name})):Ft.error(e("documentPanel.uploadDocuments.failed",{name:d.name,message:p.message}))}catch(p){Ft.error(e("documentPanel.uploadDocuments.error",{name:d.name,error:tr(p)}))}}))}catch(d){Ft.error(e("documentPanel.uploadDocuments.generalError",{error:tr(d)}))}finally{a(!1)}},[a,s]);return E.jsxs(NT,{open:t,onOpenChange:c=>{r&&!c||n(c)},children:[E.jsx(b5,{asChild:!0,children:E.jsxs(pt,{variant:"default",side:"bottom",tooltip:e("documentPanel.uploadDocuments.tooltip"),size:"sm",children:[E.jsx(zk,{})," ",e("documentPanel.uploadDocuments.button")]})}),E.jsxs(Ep,{className:"sm:max-w-xl",onCloseAutoFocus:c=>c.preventDefault(),children:[E.jsxs(wp,{children:[E.jsx(xp,{children:e("documentPanel.uploadDocuments.title")}),E.jsx(kp,{children:e("documentPanel.uploadDocuments.description")})]}),E.jsx(Lie,{maxFileCount:1/0,maxSize:200*1024*1024,description:e("documentPanel.uploadDocuments.fileTypes"),onUpload:u,progresses:o,disabled:r})]})]})}function zie(){const{t:e}=Dt(),[t,n]=w.useState(!1),r=w.useCallback(async()=>{try{const a=await DV();a.status==="success"?(Ft.success(e("documentPanel.clearDocuments.success")),n(!1)):Ft.error(e("documentPanel.clearDocuments.failed",{message:a.message}))}catch(a){Ft.error(e("documentPanel.clearDocuments.error",{error:tr(a)}))}},[n,e]);return E.jsxs(NT,{open:t,onOpenChange:n,children:[E.jsx(b5,{asChild:!0,children:E.jsxs(pt,{variant:"outline",side:"bottom",tooltip:e("documentPanel.clearDocuments.tooltip"),size:"sm",children:[E.jsx(R3,{})," ",e("documentPanel.clearDocuments.button")]})}),E.jsxs(Ep,{className:"sm:max-w-xl",onCloseAutoFocus:a=>a.preventDefault(),children:[E.jsxs(wp,{children:[E.jsx(xp,{children:e("documentPanel.clearDocuments.title")}),E.jsx(kp,{children:e("documentPanel.clearDocuments.confirm")})]}),E.jsx(pt,{variant:"destructive",onClick:r,children:e("documentPanel.clearDocuments.confirmButton")})]})]})}function Bie({open:e,onOpenChange:t}){var g;const{t:n}=Dt(),[r,a]=w.useState(null),[o,s]=w.useState("center"),[u,c]=w.useState(!1),d=w.useRef(null);w.useEffect(()=>{e&&(s("center"),c(!1))},[e]),w.useEffect(()=>{const m=d.current;!m||u||(m.scrollTop=m.scrollHeight)},[r==null?void 0:r.history_messages,u]);const p=()=>{const m=d.current;if(!m)return;const b=Math.abs(m.scrollHeight-m.scrollTop-m.clientHeight)<1;c(!b)};return w.useEffect(()=>{if(!e)return;const m=async()=>{try{const y=await LV();a(y)}catch(y){Ft.error(n("documentPanel.pipelineStatus.errors.fetchFailed",{error:tr(y)}))}};m();const b=setInterval(m,2e3);return()=>clearInterval(b)},[e,n]),E.jsx(NT,{open:e,onOpenChange:t,children:E.jsxs(Ep,{className:Me("sm:max-w-[600px] transition-all duration-200 fixed",o==="left"&&"!left-[25%] !translate-x-[-50%] !mx-4",o==="center"&&"!left-1/2 !-translate-x-1/2",o==="right"&&"!left-[75%] !translate-x-[-50%] !mx-4"),children:[E.jsx(kp,{className:"sr-only",children:r!=null&&r.job_name?`${n("documentPanel.pipelineStatus.jobName")}: ${r.job_name}, ${n("documentPanel.pipelineStatus.progress")}: ${r.cur_batch}/${r.batchs}`:n("documentPanel.pipelineStatus.noActiveJob")}),E.jsxs(wp,{className:"flex flex-row items-center",children:[E.jsx(xp,{className:"flex-1",children:n("documentPanel.pipelineStatus.title")}),E.jsxs("div",{className:"flex items-center gap-2 mr-8",children:[E.jsx(pt,{variant:"ghost",size:"icon",className:Me("h-6 w-6",o==="left"&&"bg-zinc-200 text-zinc-800 hover:bg-zinc-300 dark:bg-zinc-700 dark:text-zinc-200 dark:hover:bg-zinc-600"),onClick:()=>s("left"),children:E.jsx(FZ,{className:"h-4 w-4"})}),E.jsx(pt,{variant:"ghost",size:"icon",className:Me("h-6 w-6",o==="center"&&"bg-zinc-200 text-zinc-800 hover:bg-zinc-300 dark:bg-zinc-700 dark:text-zinc-200 dark:hover:bg-zinc-600"),onClick:()=>s("center"),children:E.jsx(MZ,{className:"h-4 w-4"})}),E.jsx(pt,{variant:"ghost",size:"icon",className:Me("h-6 w-6",o==="right"&&"bg-zinc-200 text-zinc-800 hover:bg-zinc-300 dark:bg-zinc-700 dark:text-zinc-200 dark:hover:bg-zinc-600"),onClick:()=>s("right"),children:E.jsx(BZ,{className:"h-4 w-4"})})]})]}),E.jsxs("div",{className:"space-y-4 pt-4",children:[E.jsxs("div",{className:"flex items-center gap-4",children:[E.jsxs("div",{className:"flex items-center gap-2",children:[E.jsxs("div",{className:"text-sm font-medium",children:[n("documentPanel.pipelineStatus.busy"),":"]}),E.jsx("div",{className:`h-2 w-2 rounded-full ${r!=null&&r.busy?"bg-green-500":"bg-gray-300"}`})]}),E.jsxs("div",{className:"flex items-center gap-2",children:[E.jsxs("div",{className:"text-sm font-medium",children:[n("documentPanel.pipelineStatus.requestPending"),":"]}),E.jsx("div",{className:`h-2 w-2 rounded-full ${r!=null&&r.request_pending?"bg-green-500":"bg-gray-300"}`})]})]}),E.jsxs("div",{className:"rounded-md border p-3 space-y-2",children:[E.jsxs("div",{children:[n("documentPanel.pipelineStatus.jobName"),": ",(r==null?void 0:r.job_name)||"-"]}),E.jsxs("div",{className:"flex justify-between",children:[E.jsxs("span",{children:[n("documentPanel.pipelineStatus.startTime"),": ",r!=null&&r.job_start?new Date(r.job_start).toLocaleString():"-"]}),E.jsxs("span",{children:[n("documentPanel.pipelineStatus.progress"),": ",r?`${r.cur_batch}/${r.batchs}`:"-"]})]})]}),E.jsxs("div",{className:"space-y-2",children:[E.jsxs("div",{className:"text-sm font-medium",children:[n("documentPanel.pipelineStatus.latestMessage"),":"]}),E.jsx("div",{className:"font-mono text-sm rounded-md bg-zinc-800 text-zinc-100 p-3",children:(r==null?void 0:r.latest_message)||"-"})]}),E.jsxs("div",{className:"space-y-2",children:[E.jsxs("div",{className:"text-sm font-medium",children:[n("documentPanel.pipelineStatus.historyMessages"),":"]}),E.jsx("div",{ref:d,onScroll:p,className:"font-mono text-sm rounded-md bg-zinc-800 text-zinc-100 p-3 overflow-y-auto min-h-[7.5em] max-h-[40vh]",children:(g=r==null?void 0:r.history_messages)!=null&&g.length?r.history_messages.map((m,b)=>E.jsx("div",{children:m},b)):"-"})]})]})]})})}const Uie=(e,t=20)=>{if(!e.file_path||typeof e.file_path!="string"||e.file_path.trim()==="")return e.id;const n=e.file_path.split("/"),r=n[n.length-1];return!r||r.trim()===""?e.id:r.length>t?r.slice(0,t)+"...":r},jie=` @keyframes pulse { 0% { background-color: rgb(255 0 0 / 0.1); diff --git a/lightrag/api/webui/index.html b/lightrag/api/webui/index.html index 96568f4d..dd711bb3 100644 --- a/lightrag/api/webui/index.html +++ b/lightrag/api/webui/index.html @@ -8,7 +8,7 @@ Lightrag - +