texlite 0.7.6 → 0.7.8

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 +1 @@
1
- import{u as Z,r as c,j as s}from"./react-BoEjKzFZ.js";import{P as H,g as q,w as G,G as K}from"./pdf-BB1XvBIF.js";import{M as J,a as Q}from"./minus-BfqMIeUg.js";import{P as ee,L as B}from"./index-DRShM2ob.js";K.workerSrc=G;const F=new H,O=2,S=new Map;async function le(){await F.promise}function X(a,t){const n=`${t}:${a}`,f=S.get(n);if(f)return f.lastUsed=Date.now(),f;const h=q({url:a,worker:F,disableRange:t==="full"}),r={task:h,promise:h.promise,consumers:0,settled:!1,lastUsed:Date.now()};return S.set(n,r),r.promise.then(()=>{r.settled=!0,Y()},()=>{r.settled=!0,S.get(n)===r&&S.delete(n)}),r}function Y(){if(S.size<=O)return;const a=[...S.entries()].filter(([,t])=>t.consumers===0&&t.settled).sort((t,n)=>t[1].lastUsed-n[1].lastUsed);for(;S.size>O&&a.length;){const[t,n]=a.shift();S.get(t)===n&&(S.delete(t),n.task.destroy())}}function ae(a,t){if(!a)return;X(a,t).promise.catch(()=>{})}function te(a,t){const n=X(a,t);n.consumers+=1,n.lastUsed=Date.now();let f=!1;return{promise:n.promise,release:()=>{f||(f=!0,n.consumers=Math.max(0,n.consumers-1),n.lastUsed=Date.now(),Y())}}}function de({url:a,loadingMode:t,target:n,compiling:f=!1,onViewportLocation:h,onDoubleClickLocation:r}){const{t:g}=Z(),v=c.useRef(null),[x,N]=c.useState(null),[b,w]=c.useState(0),[d,z]=c.useState(100),[j,I]=c.useState(""),M=c.useRef(new Map),D=c.useCallback((e,i)=>{i?M.current.set(e,i):M.current.delete(e)},[]),E=async e=>{if(!x||e==null)return;let i=e;if(typeof e=="string"&&(i=await x.getDestination(e).catch(()=>null)),!Array.isArray(i)||i.length===0)return;const u=i[0];let p=null;if(typeof u=="number"&&Number.isInteger(u))p=u;else if(u!=null)try{p=await x.getPageIndex(u)}catch{return}p==null||p<0||p>=x.numPages||M.current.get(p+1)?.scrollIntoView({behavior:"smooth",block:"start",inline:"nearest"})},y=()=>{const e=v.current;if(!e)return;const i=e.getBoundingClientRect(),u=i.left+i.width/2,p=i.top+i.height/2,o=[...e.querySelectorAll(".pdf-page")],m=o.find(U=>{const P=U.getBoundingClientRect();return p>=P.top&&p<=P.bottom})??o.reduce((U,P)=>{if(!U)return P;const W=Math.abs(P.getBoundingClientRect().top-p),_=Math.abs(U.getBoundingClientRect().top-p);return W<_?P:U},null);if(!m)return;const l=m.getBoundingClientRect(),R=Number(m.dataset.scale)||1,L=Number(m.dataset.page),A=Math.max(0,Math.min(l.width,u-l.left))/R,T=Math.max(0,Math.min(l.height,p-l.top))/R;L&&h(L,A,T)};c.useEffect(()=>{const e=v.current;if(!e)return;const i=()=>w(e.clientWidth);i();const u=new ResizeObserver(i);return u.observe(e),()=>u.disconnect()},[]),c.useEffect(()=>{let e=!1;N(null),I("");const i=te(a,t);return i.promise.then(u=>{e||N(u)}).catch(()=>{e||I(g("editor.pdfLoadFailed"))}),()=>{e=!0,i.release()}},[a,t]),c.useEffect(()=>{d>100||!v.current||(v.current.scrollLeft=0)},[d,b,x]);const C=e=>z(i=>Math.min(200,Math.max(50,i+e))),k=()=>{v.current&&(v.current.scrollLeft=0),z(100)},$=e=>{!e.shiftKey||Math.abs(e.deltaX)>Math.abs(e.deltaY)||(e.preventDefault(),e.currentTarget.scrollLeft+=e.deltaY,y())};return s.jsxs("div",{className:"pdf-viewer",children:[s.jsxs("div",{className:"pdf-toolbar",role:"toolbar","aria-label":g("editor.pdfZoomControls"),children:[s.jsx("button",{disabled:d<=50,title:g("editor.pdfZoomOut"),"aria-label":g("editor.pdfZoomOut"),onClick:()=>C(-10),children:s.jsx(J,{size:14})}),s.jsxs("span",{className:"pdf-zoom-value","aria-live":"polite",children:[d,"%"]}),s.jsx("button",{disabled:d>=200,title:g("editor.pdfZoomIn"),"aria-label":g("editor.pdfZoomIn"),onClick:()=>C(10),children:s.jsx(ee,{size:14})}),s.jsxs("button",{className:"pdf-fit-width",title:g("editor.pdfFitWidth"),onClick:k,children:[s.jsx(Q,{size:13}),g("editor.pdfFitWidth")]})]}),f&&s.jsxs("div",{className:"pdf-compiling-overlay",role:"status","aria-live":"polite",children:[s.jsx(B,{className:"spin",size:20}),s.jsx("span",{children:g("editor.compiling")})]}),s.jsx("div",{className:"pdf-document",ref:v,onScroll:y,onWheel:$,children:s.jsxs("div",{className:"pdf-pages",style:{width:`${Math.max(1,b-28)*Math.max(1,d/100)}px`},children:[!x&&!j&&s.jsxs("div",{className:"pdf-loading",role:"status","aria-live":"polite",children:[s.jsx(B,{className:"spin",size:24}),s.jsx("span",{children:g("editor.loadingPdf")})]}),j&&s.jsx("div",{className:"preview-empty",children:s.jsx("strong",{children:j})}),x&&b>0&&Array.from({length:x.numPages},(e,i)=>s.jsx(se,{document:x,pageNumber:i+1,availableWidth:b-28,zoom:d/100,target:n?.page===i+1?n:null,onReady:y,onPageElement:D,onInternalLink:E,onDoubleClickLocation:r},i+1))]})})]})}function se({document:a,pageNumber:t,availableWidth:n,zoom:f,target:h,onReady:r,onPageElement:g,onInternalLink:v,onDoubleClickLocation:x}){const N=c.useRef(null),b=c.useRef(null),w=c.useRef(null),[d,z]=c.useState(1),[j,I]=c.useState({width:0,height:0}),[M,D]=c.useState(t===1),[E,y]=c.useState(!1),[C,k]=c.useState(null),[$,e]=c.useState([]);c.useEffect(()=>{const o=N.current;if(!o||M)return;if(!("IntersectionObserver"in window)){D(!0);return}const m=new IntersectionObserver(l=>{l.some(R=>R.isIntersecting)&&(D(!0),m.disconnect())},{rootMargin:"900px 0px"});return m.observe(o),()=>m.disconnect()},[M]),c.useEffect(()=>{h&&D(!0)},[h?.nonce]),c.useEffect(()=>{if(!M)return;let o=!1,m=null;return y(!1),k(null),e([]),a.getPage(t).then(l=>{if(o)return;const R=l.getViewport({scale:1}),L=n/R.width,A=Math.min(3.3,Math.max(.175,L*f)),T=l.getViewport({scale:A});if(z(A),I({width:T.width,height:T.height}),k(T),l.getAnnotations({intent:"display"}).then(W=>{o||e(W)}).catch(()=>{o||e([])}),!b.current)return;const U=Math.max(1,window.devicePixelRatio||1),P=l.getViewport({scale:A*U});return b.current.width=Math.floor(P.width),b.current.height=Math.floor(P.height),m=l.render({canvas:b.current,viewport:P}),m.promise.then(()=>{o||(y(!0),window.requestAnimationFrame(r))})}).catch(()=>{}),()=>{o=!0,m?.cancel()}},[a,t,n,f,M]),c.useEffect(()=>{!h||!w.current||w.current.scrollIntoView({behavior:"smooth",block:"center",inline:"center"})},[h?.nonce,d]);const i=o=>{if(!x||!E||o.target instanceof HTMLElement&&o.target.closest("a"))return;const m=b.current;if(!m)return;const l=m.getBoundingClientRect();if(o.clientX<l.left||o.clientX>l.right||o.clientY<l.top||o.clientY>l.bottom)return;const R=d||1,L=Math.max(0,Math.min(l.width,o.clientX-l.left))/R,A=Math.max(0,Math.min(l.height,o.clientY-l.top))/R;x(t,L,A)},u=Math.max(1,n*f),p=u*(792/612);return s.jsxs("figure",{ref:o=>{N.current=o,g(t,o)},onDoubleClick:i,className:`pdf-page${E?" rendered":" loading"}`,"data-page":t,"data-scale":d,style:{width:`${j.width||u}px`,minHeight:`${j.height||p}px`},children:[s.jsx("canvas",{ref:b,style:{width:`${j.width||u}px`,height:`${j.height||p}px`}}),E&&C&&s.jsx(ne,{annotations:$,viewport:C,onInternalLink:v}),h&&s.jsx("span",{ref:w,className:"pdf-sync-marker",style:{left:h.x*d,top:h.y*d}}),s.jsx("figcaption",{children:t})]})}function ne({annotations:a,viewport:t,onInternalLink:n}){const{t:f}=Z(),h=f("editor.pdfLink");return s.jsx("div",{className:"pdf-annotation-layer","aria-label":f("editor.pdfLinks"),children:a.filter(r=>r.subtype==="Link"&&Array.isArray(r.rect)&&r.rect.length>=4).map((r,g)=>{const[v,x]=t.convertToViewportPoint(r.rect[0],r.rect[1]),[N,b]=t.convertToViewportPoint(r.rect[2],r.rect[3]),w=[v,x,N,b],d=Math.min(w[0],w[2]),z=Math.min(w[1],w[3]),j=Math.abs(w[2]-w[0]),I=Math.abs(w[3]-w[1]),M=typeof r.title=="string"?r.title.trim():"",D=typeof r.unsafeUrl=="string"?r.unsafeUrl.trim():"",E=typeof r.url=="string"?r.url.trim():"",y=V(E)?E:V(D)?D:"",C=r.dest;if(!y&&C==null)return null;const k=!!y;return s.jsx("a",{className:"pdf-annotation-link",href:y||"#",target:k?"_blank":void 0,rel:k?"noreferrer":void 0,title:M||(k?y:h),"aria-label":M||(k?y:h),style:{left:d,top:z,width:j,height:I},onClick:k?void 0:$=>{$.preventDefault(),n(C)}},`${g}-${d}-${z}`)})})}function V(a){return/^(?:https?|mailto|ftp):/i.test(a)}export{de as PdfPreview,ae as preloadPdf,le as preloadPdfRuntime};
1
+ import{u as Z,r as c,j as s}from"./react-BoEjKzFZ.js";import{P as H,g as q,w as G,G as K}from"./pdf-BB1XvBIF.js";import{M as J,a as Q}from"./minus-BwzSZenU.js";import{P as ee,L as B}from"./index-B9n8hfV0.js";K.workerSrc=G;const F=new H,O=2,S=new Map;async function le(){await F.promise}function X(a,t){const n=`${t}:${a}`,f=S.get(n);if(f)return f.lastUsed=Date.now(),f;const h=q({url:a,worker:F,disableRange:t==="full"}),r={task:h,promise:h.promise,consumers:0,settled:!1,lastUsed:Date.now()};return S.set(n,r),r.promise.then(()=>{r.settled=!0,Y()},()=>{r.settled=!0,S.get(n)===r&&S.delete(n)}),r}function Y(){if(S.size<=O)return;const a=[...S.entries()].filter(([,t])=>t.consumers===0&&t.settled).sort((t,n)=>t[1].lastUsed-n[1].lastUsed);for(;S.size>O&&a.length;){const[t,n]=a.shift();S.get(t)===n&&(S.delete(t),n.task.destroy())}}function ae(a,t){if(!a)return;X(a,t).promise.catch(()=>{})}function te(a,t){const n=X(a,t);n.consumers+=1,n.lastUsed=Date.now();let f=!1;return{promise:n.promise,release:()=>{f||(f=!0,n.consumers=Math.max(0,n.consumers-1),n.lastUsed=Date.now(),Y())}}}function de({url:a,loadingMode:t,target:n,compiling:f=!1,onViewportLocation:h,onDoubleClickLocation:r}){const{t:g}=Z(),v=c.useRef(null),[x,N]=c.useState(null),[b,w]=c.useState(0),[d,z]=c.useState(100),[j,I]=c.useState(""),M=c.useRef(new Map),D=c.useCallback((e,i)=>{i?M.current.set(e,i):M.current.delete(e)},[]),E=async e=>{if(!x||e==null)return;let i=e;if(typeof e=="string"&&(i=await x.getDestination(e).catch(()=>null)),!Array.isArray(i)||i.length===0)return;const u=i[0];let p=null;if(typeof u=="number"&&Number.isInteger(u))p=u;else if(u!=null)try{p=await x.getPageIndex(u)}catch{return}p==null||p<0||p>=x.numPages||M.current.get(p+1)?.scrollIntoView({behavior:"smooth",block:"start",inline:"nearest"})},y=()=>{const e=v.current;if(!e)return;const i=e.getBoundingClientRect(),u=i.left+i.width/2,p=i.top+i.height/2,o=[...e.querySelectorAll(".pdf-page")],m=o.find(U=>{const P=U.getBoundingClientRect();return p>=P.top&&p<=P.bottom})??o.reduce((U,P)=>{if(!U)return P;const W=Math.abs(P.getBoundingClientRect().top-p),_=Math.abs(U.getBoundingClientRect().top-p);return W<_?P:U},null);if(!m)return;const l=m.getBoundingClientRect(),R=Number(m.dataset.scale)||1,L=Number(m.dataset.page),A=Math.max(0,Math.min(l.width,u-l.left))/R,T=Math.max(0,Math.min(l.height,p-l.top))/R;L&&h(L,A,T)};c.useEffect(()=>{const e=v.current;if(!e)return;const i=()=>w(e.clientWidth);i();const u=new ResizeObserver(i);return u.observe(e),()=>u.disconnect()},[]),c.useEffect(()=>{let e=!1;N(null),I("");const i=te(a,t);return i.promise.then(u=>{e||N(u)}).catch(()=>{e||I(g("editor.pdfLoadFailed"))}),()=>{e=!0,i.release()}},[a,t]),c.useEffect(()=>{d>100||!v.current||(v.current.scrollLeft=0)},[d,b,x]);const C=e=>z(i=>Math.min(200,Math.max(50,i+e))),k=()=>{v.current&&(v.current.scrollLeft=0),z(100)},$=e=>{!e.shiftKey||Math.abs(e.deltaX)>Math.abs(e.deltaY)||(e.preventDefault(),e.currentTarget.scrollLeft+=e.deltaY,y())};return s.jsxs("div",{className:"pdf-viewer",children:[s.jsxs("div",{className:"pdf-toolbar",role:"toolbar","aria-label":g("editor.pdfZoomControls"),children:[s.jsx("button",{disabled:d<=50,title:g("editor.pdfZoomOut"),"aria-label":g("editor.pdfZoomOut"),onClick:()=>C(-10),children:s.jsx(J,{size:14})}),s.jsxs("span",{className:"pdf-zoom-value","aria-live":"polite",children:[d,"%"]}),s.jsx("button",{disabled:d>=200,title:g("editor.pdfZoomIn"),"aria-label":g("editor.pdfZoomIn"),onClick:()=>C(10),children:s.jsx(ee,{size:14})}),s.jsxs("button",{className:"pdf-fit-width",title:g("editor.pdfFitWidth"),onClick:k,children:[s.jsx(Q,{size:13}),g("editor.pdfFitWidth")]})]}),f&&s.jsxs("div",{className:"pdf-compiling-overlay",role:"status","aria-live":"polite",children:[s.jsx(B,{className:"spin",size:20}),s.jsx("span",{children:g("editor.compiling")})]}),s.jsx("div",{className:"pdf-document",ref:v,onScroll:y,onWheel:$,children:s.jsxs("div",{className:"pdf-pages",style:{width:`${Math.max(1,b-28)*Math.max(1,d/100)}px`},children:[!x&&!j&&s.jsxs("div",{className:"pdf-loading",role:"status","aria-live":"polite",children:[s.jsx(B,{className:"spin",size:24}),s.jsx("span",{children:g("editor.loadingPdf")})]}),j&&s.jsx("div",{className:"preview-empty",children:s.jsx("strong",{children:j})}),x&&b>0&&Array.from({length:x.numPages},(e,i)=>s.jsx(se,{document:x,pageNumber:i+1,availableWidth:b-28,zoom:d/100,target:n?.page===i+1?n:null,onReady:y,onPageElement:D,onInternalLink:E,onDoubleClickLocation:r},i+1))]})})]})}function se({document:a,pageNumber:t,availableWidth:n,zoom:f,target:h,onReady:r,onPageElement:g,onInternalLink:v,onDoubleClickLocation:x}){const N=c.useRef(null),b=c.useRef(null),w=c.useRef(null),[d,z]=c.useState(1),[j,I]=c.useState({width:0,height:0}),[M,D]=c.useState(t===1),[E,y]=c.useState(!1),[C,k]=c.useState(null),[$,e]=c.useState([]);c.useEffect(()=>{const o=N.current;if(!o||M)return;if(!("IntersectionObserver"in window)){D(!0);return}const m=new IntersectionObserver(l=>{l.some(R=>R.isIntersecting)&&(D(!0),m.disconnect())},{rootMargin:"900px 0px"});return m.observe(o),()=>m.disconnect()},[M]),c.useEffect(()=>{h&&D(!0)},[h?.nonce]),c.useEffect(()=>{if(!M)return;let o=!1,m=null;return y(!1),k(null),e([]),a.getPage(t).then(l=>{if(o)return;const R=l.getViewport({scale:1}),L=n/R.width,A=Math.min(3.3,Math.max(.175,L*f)),T=l.getViewport({scale:A});if(z(A),I({width:T.width,height:T.height}),k(T),l.getAnnotations({intent:"display"}).then(W=>{o||e(W)}).catch(()=>{o||e([])}),!b.current)return;const U=Math.max(1,window.devicePixelRatio||1),P=l.getViewport({scale:A*U});return b.current.width=Math.floor(P.width),b.current.height=Math.floor(P.height),m=l.render({canvas:b.current,viewport:P}),m.promise.then(()=>{o||(y(!0),window.requestAnimationFrame(r))})}).catch(()=>{}),()=>{o=!0,m?.cancel()}},[a,t,n,f,M]),c.useEffect(()=>{!h||!w.current||w.current.scrollIntoView({behavior:"smooth",block:"center",inline:"center"})},[h?.nonce,d]);const i=o=>{if(!x||!E||o.target instanceof HTMLElement&&o.target.closest("a"))return;const m=b.current;if(!m)return;const l=m.getBoundingClientRect();if(o.clientX<l.left||o.clientX>l.right||o.clientY<l.top||o.clientY>l.bottom)return;const R=d||1,L=Math.max(0,Math.min(l.width,o.clientX-l.left))/R,A=Math.max(0,Math.min(l.height,o.clientY-l.top))/R;x(t,L,A)},u=Math.max(1,n*f),p=u*(792/612);return s.jsxs("figure",{ref:o=>{N.current=o,g(t,o)},onDoubleClick:i,className:`pdf-page${E?" rendered":" loading"}`,"data-page":t,"data-scale":d,style:{width:`${j.width||u}px`,minHeight:`${j.height||p}px`},children:[s.jsx("canvas",{ref:b,style:{width:`${j.width||u}px`,height:`${j.height||p}px`}}),E&&C&&s.jsx(ne,{annotations:$,viewport:C,onInternalLink:v}),h&&s.jsx("span",{ref:w,className:"pdf-sync-marker",style:{left:h.x*d,top:h.y*d}}),s.jsx("figcaption",{children:t})]})}function ne({annotations:a,viewport:t,onInternalLink:n}){const{t:f}=Z(),h=f("editor.pdfLink");return s.jsx("div",{className:"pdf-annotation-layer","aria-label":f("editor.pdfLinks"),children:a.filter(r=>r.subtype==="Link"&&Array.isArray(r.rect)&&r.rect.length>=4).map((r,g)=>{const[v,x]=t.convertToViewportPoint(r.rect[0],r.rect[1]),[N,b]=t.convertToViewportPoint(r.rect[2],r.rect[3]),w=[v,x,N,b],d=Math.min(w[0],w[2]),z=Math.min(w[1],w[3]),j=Math.abs(w[2]-w[0]),I=Math.abs(w[3]-w[1]),M=typeof r.title=="string"?r.title.trim():"",D=typeof r.unsafeUrl=="string"?r.unsafeUrl.trim():"",E=typeof r.url=="string"?r.url.trim():"",y=V(E)?E:V(D)?D:"",C=r.dest;if(!y&&C==null)return null;const k=!!y;return s.jsx("a",{className:"pdf-annotation-link",href:y||"#",target:k?"_blank":void 0,rel:k?"noreferrer":void 0,title:M||(k?y:h),"aria-label":M||(k?y:h),style:{left:d,top:z,width:j,height:I},onClick:k?void 0:$=>{$.preventDefault(),n(C)}},`${g}-${d}-${z}`)})})}function V(a){return/^(?:https?|mailto|ftp):/i.test(a)}export{de as PdfPreview,ae as preloadPdf,le as preloadPdfRuntime};
@@ -0,0 +1 @@
1
+ import{u as A,r,j as e}from"./react-BoEjKzFZ.js";import{j as U,a as z,M as F,o as $,L as V,p as B,n as J,F as K,q as G}from"./index-B9n8hfV0.js";const L=U("Replace",[["path",{d:"M14 4a2 2 0 0 1 2-2",key:"1w2hp7"}],["path",{d:"M16 10a2 2 0 0 1-2-2",key:"shjach"}],["path",{d:"M20 2a2 2 0 0 1 2 2",key:"188mtx"}],["path",{d:"M22 8a2 2 0 0 1-2 2",key:"ddf4tu"}],["path",{d:"m3 7 3 3 3-3",key:"x25e72"}],["path",{d:"M6 10V5a3 3 0 0 1 3-3h1",key:"3y3t5z"}],["rect",{x:"2",y:"14",width:"8",height:"8",rx:"2",key:"4rksxw"}]]);function Z({open:n,files:h,onOpenChange:u,onOpenFile:p}){const{t:a}=A(),[c,f]=r.useState(""),[d,o]=r.useState(0),m=r.useRef(null),y=r.useRef(null),l=r.useMemo(()=>h.filter(s=>s.type==="file").map(s=>({entry:s,score:H(s.path,c)})).filter(s=>s.score>=0).sort((s,i)=>i.score-s.score||s.entry.path.localeCompare(i.entry.path)).slice(0,100),[h,c]);r.useEffect(()=>{n&&(f(""),o(0),window.setTimeout(()=>m.current?.focus(),0))},[n]),r.useEffect(()=>o(s=>Math.min(s,Math.max(0,l.length-1))),[l.length]),r.useEffect(()=>{n&&y.current?.scrollIntoView({block:"nearest"})},[n,d]);const S=s=>{p(s),u(!1)};return e.jsx(F,{open:n,wide:!0,title:a("navigation.quickOpen"),description:a("navigation.quickOpenDescription"),onOpenChange:u,children:e.jsxs("div",{className:"quick-open-dialog",children:[e.jsxs("label",{children:[e.jsx($,{size:16}),e.jsx("input",{ref:m,value:c,placeholder:a("navigation.filePlaceholder"),onChange:s=>{f(s.target.value),o(0)},onKeyDown:s=>{s.key==="ArrowDown"&&(s.preventDefault(),o(i=>Math.min(l.length-1,i+1))),s.key==="ArrowUp"&&(s.preventDefault(),o(i=>Math.max(0,i-1))),s.key==="Enter"&&l[d]&&(s.preventDefault(),S(l[d].entry.path))}})]}),e.jsxs("div",{className:"quick-open-results",children:[l.map(({entry:s},i)=>e.jsxs("button",{ref:i===d?y:void 0,className:i===d?"active":"",onMouseEnter:()=>o(i),onClick:()=>S(s.path),children:[e.jsx(K,{size:14}),e.jsx("span",{children:s.path}),i===d&&e.jsx(G,{size:13})]},s.path)),l.length===0&&e.jsx("p",{className:"muted padded",children:a("navigation.noFiles")})]})]})})}function _({open:n,project:h,onOpenChange:u,onJump:p}){const{t:a}=A(),[c,f]=r.useState(""),[d,o]=r.useState(""),[m,y]=r.useState(!1),[l,S]=r.useState(!1),[s,i]=r.useState([]),[g,C]=r.useState(0),[P,D]=r.useState(!1),[b,k]=r.useState(!1),[W,N]=r.useState(!1),[R,M]=r.useState(""),[q,w]=r.useState(""),[O,Q]=r.useState(0),v=r.useRef(null);r.useEffect(()=>{if(!n){v.current?.abort();return}if(M(""),w(""),!c.trim()){i([]),C(0),D(!1);return}const t=window.setTimeout(()=>{v.current?.abort();const x=new AbortController;v.current=x,k(!0);const E=new URLSearchParams({q:c});m&&E.set("caseSensitive","1"),l&&E.set("wholeWord","1"),z(`/api/projects/${h.id}/search?${E}`,{signal:x.signal}).then(j=>{i(j.matches),C(j.total),D(j.truncated)}).catch(j=>{j instanceof DOMException&&j.name==="AbortError"||w(T(j))}).finally(()=>{v.current===x&&(v.current=null,k(!1))})},250);return()=>window.clearTimeout(t)},[n,h.id,c,m,l,O]);const I=async()=>{N(!1),k(!0),w(""),M("");try{const t=await z(`/api/projects/${h.id}/search/replace`,{method:"POST",body:JSON.stringify({query:c,replacement:d,caseSensitive:m,wholeWord:l})});M(a("navigation.replaced",{count:t.replacements,files:t.files.length})),i([]),C(0),Q(x=>x+1)}catch(t){w(T(t))}finally{k(!1)}};return e.jsxs(e.Fragment,{children:[e.jsx(F,{open:n,extraWide:!0,title:a("navigation.projectSearch"),description:a("navigation.projectSearchDescription"),onOpenChange:u,footer:e.jsx("button",{onClick:()=>u(!1),children:a("common.close")}),children:e.jsxs("div",{className:"project-search-dialog",children:[q&&e.jsx("p",{className:"error",children:q}),R&&e.jsx("p",{className:"success",children:R}),e.jsxs("div",{className:"project-search-form",children:[e.jsxs("label",{className:"project-search-query",children:[e.jsx($,{size:16}),e.jsx("input",{autoFocus:!0,value:c,placeholder:a("navigation.searchPlaceholder"),onChange:t=>f(t.target.value)})]}),h.permission!=="read"&&e.jsxs("label",{className:"project-search-query",children:[e.jsx(L,{size:16}),e.jsx("input",{value:d,placeholder:a("navigation.replacePlaceholder"),onChange:t=>o(t.target.value)})]}),e.jsxs("div",{className:"project-search-options",children:[e.jsxs("label",{children:[e.jsx("input",{type:"checkbox",checked:m,onChange:t=>y(t.target.checked)}),a("editor.search.matchCase")]}),e.jsxs("label",{children:[e.jsx("input",{type:"checkbox",checked:l,onChange:t=>S(t.target.checked)}),a("editor.search.wholeWord")]}),h.permission!=="read"&&e.jsxs("button",{className:"danger-text",disabled:!c.trim()||g===0||b,onClick:()=>N(!0),children:[e.jsx(L,{size:13}),a("navigation.replaceAll",{count:g})]})]})]}),e.jsxs("div",{className:"project-search-summary",children:[e.jsx("span",{children:b?e.jsxs(e.Fragment,{children:[e.jsx(V,{className:"spin",size:13}),a("common.loading")]}):a("navigation.matchSummary",{count:g})}),P&&e.jsx("small",{children:a("navigation.truncated",{count:s.length})})]}),e.jsxs("div",{className:"project-search-results",children:[s.map((t,x)=>e.jsxs("button",{onClick:()=>{p(t.path,t.line,t.column),u(!1)},children:[e.jsx(B,{size:14}),e.jsxs("span",{children:[e.jsxs("strong",{children:[t.path,e.jsxs("small",{children:[":",t.line,":",t.column]})]}),e.jsxs("code",{children:[t.preview.slice(0,t.matchStart),e.jsx("mark",{children:t.preview.slice(t.matchStart,t.matchEnd)}),t.preview.slice(t.matchEnd)]})]})]},`${t.path}-${t.line}-${t.column}-${x}`)),!b&&c.trim()&&s.length===0&&e.jsx("p",{className:"muted padded",children:a("editor.search.noMatches")})]})]})}),e.jsx(J,{open:W,title:a("navigation.replaceConfirmTitle"),description:a("navigation.replaceConfirmDescription",{count:g}),confirmLabel:a("navigation.replaceAll",{count:g}),danger:!0,onCancel:()=>N(!1),onConfirm:()=>{I()}})]})}function H(n,h){const u=n.toLocaleLowerCase(),p=h.trim().toLocaleLowerCase();if(!p)return 1;const a=u.indexOf(p);if(a>=0)return 1e4-a-u.length;let c=0,f=0;for(const d of p){const o=u.indexOf(d,c);if(o<0)return-1;f+=o===c?5:1,c=o+1}return f-u.length/100}function T(n){return n instanceof Error?n.message:String(n)}export{_ as ProjectSearchDialog,Z as QuickOpenDialog};
@@ -1 +1 @@
1
- import{u as f,r as a,j as e}from"./react-BoEjKzFZ.js";import{a as y,M as b,A as M,R as $}from"./index-DRShM2ob.js";function w({open:t,onOpenChange:c}){const{t:s}=f(),[r,p]=a.useState(null),[u,x]=a.useState(!1),[m,j]=a.useState(""),o=a.useCallback(async()=>{x(!0);try{p(await y("/api/health/metrics")),j("")}catch(i){j(i instanceof Error?i.message:s("errors.generic"))}finally{x(!1)}},[s]);return a.useEffect(()=>{if(!t)return;o();const i=window.setInterval(()=>{o()},5e3);return()=>window.clearInterval(i)},[t,o]),e.jsxs(b,{open:t,onOpenChange:c,wide:!0,title:s("metrics.title"),description:s("metrics.description"),footer:e.jsxs("button",{onClick:()=>{o()},disabled:u,children:[e.jsx($,{size:14,className:u?"spin":""}),s("metrics.refresh")]}),children:[m&&e.jsx("p",{className:"error",children:m}),!r&&!m&&e.jsx("p",{className:"muted",children:s("common.loading")}),r&&e.jsxs("div",{className:"system-metrics",children:[e.jsxs("div",{className:"metric-summary-grid",children:[e.jsx(l,{label:s("metrics.uptime"),value:v(r.uptimeSeconds)}),e.jsx(l,{label:s("metrics.memory"),value:`${h(r.memory.rssBytes)} RSS`,detail:`${h(r.memory.heapUsedBytes)} / ${h(r.memory.heapTotalBytes)} ${s("metrics.heap")}`}),e.jsx(l,{label:s("metrics.compileQueue"),value:`${r.compileQueue.running} / ${r.compileQueue.concurrency}`,detail:s("metrics.pending",{count:r.compileQueue.pending})}),e.jsx(l,{label:s("metrics.collaboration"),value:s("metrics.sessions",{count:r.collaboration.sessions}),detail:s("metrics.roomsAndDirty",{rooms:r.collaboration.rooms,dirty:r.collaboration.dirtyFiles})})]}),e.jsxs("section",{className:"metric-section",children:[e.jsxs("h3",{children:[e.jsx(M,{size:15}),s("metrics.eventLoop")]}),e.jsx("p",{children:s("metrics.latencySummary",r.eventLoopDelay)})]}),e.jsxs("section",{className:"metric-section",children:[e.jsx("h3",{children:s("metrics.operationDurations")}),Object.keys(r.durationsMs).length===0?e.jsx("p",{className:"muted",children:s("metrics.noSamples")}):e.jsx("div",{className:"metric-table-wrap",children:e.jsxs("table",{className:"metric-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:s("metrics.operation")}),e.jsx("th",{children:s("metrics.samples")}),e.jsx("th",{children:s("metrics.last")}),e.jsx("th",{children:"P50"}),e.jsx("th",{children:"P95"}),e.jsx("th",{children:s("metrics.max")})]})}),e.jsx("tbody",{children:Object.entries(r.durationsMs).sort(([i],[n])=>i.localeCompare(n)).map(([i,n])=>e.jsxs("tr",{children:[e.jsx("td",{children:g(i,s)}),e.jsx("td",{children:n.count}),e.jsx("td",{children:d(n.last)}),e.jsx("td",{children:d(n.p50)}),e.jsx("td",{children:d(n.p95)}),e.jsx("td",{children:d(n.max)})]},i))})]})})]})]})]})}function l({label:t,value:c,detail:s}){return e.jsxs("article",{className:"metric-card",children:[e.jsx("span",{children:t}),e.jsx("strong",{children:c}),s&&e.jsx("small",{children:s})]})}function h(t){return`${Math.round(t/1024/1024*10)/10} MB`}function v(t){const c=Math.floor(t/86400),s=Math.floor(t%86400/3600),r=Math.floor(t%3600/60);return c?`${c}d ${s}h`:s?`${s}h ${r}m`:`${r}m`}function d(t){return t>=1e3?`${Math.round(t/100)/10}s`:`${Math.round(t*10)/10}ms`}function g(t,c){return c(`metrics.operations.${t}`,{defaultValue:t})}export{w as SystemMetricsDialog};
1
+ import{u as f,r as a,j as e}from"./react-BoEjKzFZ.js";import{a as y,M as b,A as M,R as $}from"./index-B9n8hfV0.js";function w({open:t,onOpenChange:c}){const{t:s}=f(),[r,p]=a.useState(null),[u,x]=a.useState(!1),[m,j]=a.useState(""),o=a.useCallback(async()=>{x(!0);try{p(await y("/api/health/metrics")),j("")}catch(i){j(i instanceof Error?i.message:s("errors.generic"))}finally{x(!1)}},[s]);return a.useEffect(()=>{if(!t)return;o();const i=window.setInterval(()=>{o()},5e3);return()=>window.clearInterval(i)},[t,o]),e.jsxs(b,{open:t,onOpenChange:c,wide:!0,title:s("metrics.title"),description:s("metrics.description"),footer:e.jsxs("button",{onClick:()=>{o()},disabled:u,children:[e.jsx($,{size:14,className:u?"spin":""}),s("metrics.refresh")]}),children:[m&&e.jsx("p",{className:"error",children:m}),!r&&!m&&e.jsx("p",{className:"muted",children:s("common.loading")}),r&&e.jsxs("div",{className:"system-metrics",children:[e.jsxs("div",{className:"metric-summary-grid",children:[e.jsx(l,{label:s("metrics.uptime"),value:v(r.uptimeSeconds)}),e.jsx(l,{label:s("metrics.memory"),value:`${h(r.memory.rssBytes)} RSS`,detail:`${h(r.memory.heapUsedBytes)} / ${h(r.memory.heapTotalBytes)} ${s("metrics.heap")}`}),e.jsx(l,{label:s("metrics.compileQueue"),value:`${r.compileQueue.running} / ${r.compileQueue.concurrency}`,detail:s("metrics.pending",{count:r.compileQueue.pending})}),e.jsx(l,{label:s("metrics.collaboration"),value:s("metrics.sessions",{count:r.collaboration.sessions}),detail:s("metrics.roomsAndDirty",{rooms:r.collaboration.rooms,dirty:r.collaboration.dirtyFiles})})]}),e.jsxs("section",{className:"metric-section",children:[e.jsxs("h3",{children:[e.jsx(M,{size:15}),s("metrics.eventLoop")]}),e.jsx("p",{children:s("metrics.latencySummary",r.eventLoopDelay)})]}),e.jsxs("section",{className:"metric-section",children:[e.jsx("h3",{children:s("metrics.operationDurations")}),Object.keys(r.durationsMs).length===0?e.jsx("p",{className:"muted",children:s("metrics.noSamples")}):e.jsx("div",{className:"metric-table-wrap",children:e.jsxs("table",{className:"metric-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:s("metrics.operation")}),e.jsx("th",{children:s("metrics.samples")}),e.jsx("th",{children:s("metrics.last")}),e.jsx("th",{children:"P50"}),e.jsx("th",{children:"P95"}),e.jsx("th",{children:s("metrics.max")})]})}),e.jsx("tbody",{children:Object.entries(r.durationsMs).sort(([i],[n])=>i.localeCompare(n)).map(([i,n])=>e.jsxs("tr",{children:[e.jsx("td",{children:g(i,s)}),e.jsx("td",{children:n.count}),e.jsx("td",{children:d(n.last)}),e.jsx("td",{children:d(n.p50)}),e.jsx("td",{children:d(n.p95)}),e.jsx("td",{children:d(n.max)})]},i))})]})})]})]})]})}function l({label:t,value:c,detail:s}){return e.jsxs("article",{className:"metric-card",children:[e.jsx("span",{children:t}),e.jsx("strong",{children:c}),s&&e.jsx("small",{children:s})]})}function h(t){return`${Math.round(t/1024/1024*10)/10} MB`}function v(t){const c=Math.floor(t/86400),s=Math.floor(t%86400/3600),r=Math.floor(t%3600/60);return c?`${c}d ${s}h`:s?`${s}h ${r}m`:`${r}m`}function d(t){return t>=1e3?`${Math.round(t/100)/10}s`:`${Math.round(t*10)/10}ms`}function g(t,c){return c(`metrics.operations.${t}`,{defaultValue:t})}export{w as SystemMetricsDialog};