texlite 0.9.3 → 0.10.0

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.
Files changed (50) hide show
  1. package/OPERATIONS.md +9 -7
  2. package/README.md +64 -40
  3. package/README.zh-CN.md +56 -34
  4. package/dist/client/assets/{AdminUsers-huwQK7Ly.js → AdminUsers-C7oU_1Y_.js} +1 -1
  5. package/dist/client/assets/{CitationLibraryDialog-C5C3sPdw.js → CitationLibraryDialog-CU2b0xtm.js} +1 -1
  6. package/dist/client/assets/Dashboard-BB4RO4x2.js +2 -0
  7. package/dist/client/assets/{GitDialog-BI7QIMsh.js → GitDialog-C2Np1i8v.js} +1 -1
  8. package/dist/client/assets/{HistoryDialog-DA7O9aF2.js → HistoryDialog-CdoYeLyX.js} +1 -1
  9. package/dist/client/assets/LatexEditor-Dmy6_gqt.js +138 -0
  10. package/dist/client/assets/{PdfPreview-mO9WS01q.js → PdfPreview-fDxKh6hP.js} +1 -1
  11. package/dist/client/assets/{ProjectIconPickerDialog-B0q_r5dX.js → ProjectIconPickerDialog-CsjMKq7h.js} +1 -1
  12. package/dist/client/assets/{ProjectNavigationDialogs-DwWYbB1A.js → ProjectNavigationDialogs-_JY0yVob.js} +1 -1
  13. package/dist/client/assets/{ProjectSettings-BpPFgdoj.js → ProjectSettings-DXGA-lmB.js} +1 -1
  14. package/dist/client/assets/ProjectWorkspace-mCYjyc6e.js +32 -0
  15. package/dist/client/assets/{SelectionHistoryDialog-pWMI5izu.js → SelectionHistoryDialog-D8CeqjLD.js} +1 -1
  16. package/dist/client/assets/{SystemMetricsDialog-BmlO7oNg.js → SystemMetricsDialog-BZx7ZMQt.js} +1 -1
  17. package/dist/client/assets/{TagManagementDialog-h4Ves4FR.js → TagManagementDialog-4R1Gs43j.js} +1 -1
  18. package/dist/client/assets/{WordCountDialog-DlBSP4y7.js → WordCountDialog-C-MCscAu.js} +1 -1
  19. package/dist/client/assets/check-Jf8WBxDX.js +1 -0
  20. package/dist/client/assets/{editor-DZS7-wrd.js → editor-B9HNwtsd.js} +1 -1
  21. package/dist/client/assets/hard-drive-Bsk-RETn.js +1 -0
  22. package/dist/client/assets/{index-teah8iB2.js → index-B6rP7QsM.js} +4 -4
  23. package/dist/client/assets/{index-i5IY_PMw.js → index-Csp5J5aI.js} +1 -1
  24. package/dist/client/assets/index-DGZNAyxW.css +1 -0
  25. package/dist/client/assets/{key-round-D8sCqL2b.js → key-round-DqptHHKC.js} +1 -1
  26. package/dist/client/assets/{minimize-2-6tf519Ts.js → minimize-2-92UqFWI9.js} +1 -1
  27. package/dist/client/assets/{minus-CqvESp9M.js → minus-bx4ZLZnb.js} +1 -1
  28. package/dist/client/assets/{plus-DIrweesj.js → plus-DQg_bV50.js} +1 -1
  29. package/dist/client/assets/{refresh-cw-BDcwKu_d.js → refresh-cw-BoMEkk5J.js} +1 -1
  30. package/dist/client/assets/{search-C9_Jyrnx.js → search-UZspmceH.js} +1 -1
  31. package/dist/client/assets/{sigma-p9-fBP0d.js → sigma-C0IvFdKV.js} +1 -1
  32. package/dist/client/assets/{spellCheck-Y0RlmXbl.js → spellCheck-DyKIHf5C.js} +1 -1
  33. package/dist/client/assets/{tags-DjF3z21M.js → tags-BTUtvaAc.js} +1 -1
  34. package/dist/client/assets/{type-CNrDJnzR.js → type-XvvfEJRs.js} +1 -1
  35. package/dist/client/assets/{user-plus-C7exNawX.js → user-plus-Chr9T97G.js} +1 -1
  36. package/dist/client/assets/x-DlFXD9Vl.js +1 -0
  37. package/dist/client/index.html +2 -2
  38. package/dist/client/pdf-download.svg +2 -0
  39. package/dist/client/pdf-file.svg +19 -0
  40. package/dist/client/tex-file.svg +7 -0
  41. package/dist/server/cli.js +5 -2
  42. package/dist/server/routes/projectFiles.js +6 -1
  43. package/package.json +4 -3
  44. package/dist/client/assets/Dashboard-DtHSc55D.js +0 -2
  45. package/dist/client/assets/LatexEditor-BYWWx5Km.js +0 -138
  46. package/dist/client/assets/ProjectWorkspace-CI2zKon5.js +0 -32
  47. package/dist/client/assets/check-BAdi_Lxq.js +0 -1
  48. package/dist/client/assets/hard-drive-DP2OHKMC.js +0 -1
  49. package/dist/client/assets/index-CBrIrzgg.css +0 -1
  50. package/dist/client/assets/x-BEVz0wdw.js +0 -1
@@ -1 +1 @@
1
- import{u as X,r as s,j as i}from"./react-BVUjbTTn.js";import{P as K,g as J,w as Q,G as ee}from"./pdf-DUYcbPMK.js";import{M as te,a as ne}from"./minus-CqvESp9M.js";import{P as re}from"./plus-DIrweesj.js";import{d as V}from"./index-teah8iB2.js";ee.workerSrc=Q;const Y=new K,O=2,R=new Map;async function fe(){await Y.promise}function _(a,r){const o=`${r}:${a}`,f=R.get(o);if(f)return f.lastUsed=Date.now(),f;const u=J({url:a,worker:Y,disableRange:r==="full"}),c={task:u,promise:u.promise,consumers:0,settled:!1,lastUsed:Date.now()};return R.set(o,c),c.promise.then(()=>{c.settled=!0,q()},()=>{c.settled=!0,R.get(o)===c&&R.delete(o)}),c}function q(){if(R.size<=O)return;const a=[...R.entries()].filter(([,r])=>r.consumers===0&&r.settled).sort((r,o)=>r[1].lastUsed-o[1].lastUsed);for(;R.size>O&&a.length;){const[r,o]=a.shift();R.get(r)===o&&(R.delete(r),o.task.destroy())}}function he(a,r){if(!a)return;_(a,r).promise.catch(()=>{})}function se(a,r){const o=_(a,r);o.consumers+=1,o.lastUsed=Date.now();let f=!1;return{promise:o.promise,release:()=>{f||(f=!0,o.consumers=Math.max(0,o.consumers-1),o.lastUsed=Date.now(),q())}}}function me({url:a,loadingMode:r,target:o,compiling:f=!1,onViewportLocation:u,onDoubleClickLocation:c}){const{t:h}=X(),x=s.useRef(null),[m,D]=s.useState(null),[g,p]=s.useState(0),[d,E]=s.useState(100),[v,N]=s.useState(""),b=s.useRef(new Map),w=s.useRef(null),k=s.useRef(u);k.current=u;const M=s.useCallback((t,e)=>{e?b.current.set(t,e):b.current.delete(t)},[]),C=async t=>{if(!m||t==null)return;let e=t;if(typeof t=="string"&&(e=await m.getDestination(t).catch(()=>null)),!Array.isArray(e)||e.length===0)return;const l=e[0];let n=null;if(typeof l=="number"&&Number.isInteger(l))n=l;else if(l!=null)try{n=await m.getPageIndex(l)}catch{return}n==null||n<0||n>=m.numPages||b.current.get(n+1)?.scrollIntoView({behavior:"smooth",block:"start",inline:"nearest"})},y=s.useCallback(()=>{w.current=null;const t=x.current;if(!t)return;const e=t.getBoundingClientRect(),l=e.left+e.width/2,n=e.top+e.height/2,P=[...t.querySelectorAll(".pdf-page")],S=P.find(F=>{const I=F.getBoundingClientRect();return n>=I.top&&n<=I.bottom})??P.reduce((F,I)=>{if(!F)return I;const H=Math.abs(I.getBoundingClientRect().top-n),G=Math.abs(F.getBoundingClientRect().top-n);return H<G?I:F},null);if(!S)return;const j=S.getBoundingClientRect(),U=Number(S.dataset.scale)||1,T=Number(S.dataset.page),$=Math.max(0,Math.min(j.width,l-j.left))/U,B=Math.max(0,Math.min(j.height,n-j.top))/U;T&&k.current(T,$,B)},[]),A=s.useCallback(()=>{w.current===null&&(w.current=window.requestAnimationFrame(y))},[y]);s.useEffect(()=>()=>{w.current!==null&&window.cancelAnimationFrame(w.current),w.current=null},[]),s.useEffect(()=>{const t=x.current;if(!t)return;const e=()=>p(t.clientWidth);e();const l=new ResizeObserver(e);return l.observe(t),()=>l.disconnect()},[]),s.useEffect(()=>{let t=!1;D(null),N("");const e=se(a,r);return e.promise.then(l=>{t||D(l)}).catch(()=>{t||N(h("editor.pdfLoadFailed"))}),()=>{t=!0,e.release()}},[a,r]),s.useEffect(()=>{d>100||!x.current||(x.current.scrollLeft=0)},[d,g,m]);const z=t=>E(e=>Math.min(200,Math.max(50,e+t))),W=()=>{x.current&&(x.current.scrollLeft=0),E(100)},L=t=>{!t.shiftKey||Math.abs(t.deltaX)>Math.abs(t.deltaY)||(t.preventDefault(),t.currentTarget.scrollLeft+=t.deltaY,A())};return i.jsxs("div",{className:"pdf-viewer",children:[i.jsxs("div",{className:"pdf-toolbar",role:"toolbar","aria-label":h("editor.pdfZoomControls"),children:[i.jsx("button",{disabled:d<=50,title:h("editor.pdfZoomOut"),"aria-label":h("editor.pdfZoomOut"),onClick:()=>z(-10),children:i.jsx(te,{size:14})}),i.jsxs("span",{className:"pdf-zoom-value","aria-live":"polite",children:[d,"%"]}),i.jsx("button",{disabled:d>=200,title:h("editor.pdfZoomIn"),"aria-label":h("editor.pdfZoomIn"),onClick:()=>z(10),children:i.jsx(re,{size:14})}),i.jsxs("button",{className:"pdf-fit-width",title:h("editor.pdfFitWidth"),onClick:W,children:[i.jsx(ne,{size:13}),h("editor.pdfFitWidth")]})]}),f&&i.jsxs("div",{className:"pdf-compiling-overlay",role:"status","aria-live":"polite",children:[i.jsx(V,{className:"spin",size:20}),i.jsx("span",{children:h("editor.compiling")})]}),i.jsx("div",{className:"pdf-document",ref:x,onScroll:A,onWheel:L,children:i.jsxs("div",{className:"pdf-pages",style:{width:`${Math.max(1,g-28)*Math.max(1,d/100)}px`},children:[!m&&!v&&i.jsxs("div",{className:"pdf-loading",role:"status","aria-live":"polite",children:[i.jsx(V,{className:"spin",size:24}),i.jsx("span",{children:h("editor.loadingPdf")})]}),v&&i.jsx("div",{className:"preview-empty",children:i.jsx("strong",{children:v})}),m&&g>0&&Array.from({length:m.numPages},(t,e)=>i.jsx(ie,{document:m,pageNumber:e+1,availableWidth:g-28,zoom:d/100,target:o?.page===e+1?o:null,onReady:A,onPageElement:M,onInternalLink:C,onDoubleClickLocation:c},e+1))]})})]})}function ie({document:a,pageNumber:r,availableWidth:o,zoom:f,target:u,onReady:c,onPageElement:h,onInternalLink:x,onDoubleClickLocation:m}){const D=s.useRef(null),g=s.useRef(null),p=s.useRef(null),[d,E]=s.useState(1),[v,N]=s.useState({width:0,height:0}),[b,w]=s.useState(r===1),[k,M]=s.useState(!1),[C,y]=s.useState(null),[A,z]=s.useState([]);s.useEffect(()=>{const e=D.current;if(!e||b)return;if(!("IntersectionObserver"in window)){w(!0);return}const l=new IntersectionObserver(n=>{n.some(P=>P.isIntersecting)&&(w(!0),l.disconnect())},{rootMargin:"900px 0px"});return l.observe(e),()=>l.disconnect()},[b]),s.useEffect(()=>{u&&w(!0)},[u?.nonce]),s.useEffect(()=>{if(!b)return;let e=!1,l=null;return M(!1),y(null),z([]),a.getPage(r).then(n=>{if(e)return;const P=n.getViewport({scale:1}),S=o/P.width,j=Math.min(3.3,Math.max(.175,S*f)),U=n.getViewport({scale:j});if(E(j),N({width:U.width,height:U.height}),y(U),n.getAnnotations({intent:"display"}).then(B=>{e||z(B)}).catch(()=>{e||z([])}),!g.current)return;const T=Math.max(1,window.devicePixelRatio||1),$=n.getViewport({scale:j*T});return g.current.width=Math.floor($.width),g.current.height=Math.floor($.height),l=n.render({canvas:g.current,viewport:$}),l.promise.then(()=>{e||(M(!0),window.requestAnimationFrame(c))})}).catch(()=>{}),()=>{e=!0,l?.cancel()}},[a,r,o,f,b]),s.useEffect(()=>{!u||!p.current||p.current.scrollIntoView({behavior:"smooth",block:"center",inline:"center"})},[u?.nonce,d]);const W=e=>{if(!m||!k||e.target instanceof HTMLElement&&e.target.closest("a"))return;const l=g.current;if(!l)return;const n=l.getBoundingClientRect();if(e.clientX<n.left||e.clientX>n.right||e.clientY<n.top||e.clientY>n.bottom)return;const P=d||1,S=Math.max(0,Math.min(n.width,e.clientX-n.left))/P,j=Math.max(0,Math.min(n.height,e.clientY-n.top))/P;m(r,S,j)},L=Math.max(1,o*f),t=L*(792/612);return i.jsxs("figure",{ref:e=>{D.current=e,h(r,e)},onDoubleClick:W,className:`pdf-page${k?" rendered":" loading"}`,"data-page":r,"data-scale":d,style:{width:`${v.width||L}px`,minHeight:`${v.height||t}px`},children:[i.jsx("canvas",{ref:g,style:{width:`${v.width||L}px`,height:`${v.height||t}px`}}),k&&C&&i.jsx(oe,{annotations:A,viewport:C,onInternalLink:x}),u&&i.jsx("span",{ref:p,className:"pdf-sync-marker",style:{left:u.x*d,top:u.y*d}}),i.jsx("figcaption",{children:r})]})}function oe({annotations:a,viewport:r,onInternalLink:o}){const{t:f}=X(),u=f("editor.pdfLink");return i.jsx("div",{className:"pdf-annotation-layer","aria-label":f("editor.pdfLinks"),children:a.filter(c=>c.subtype==="Link"&&Array.isArray(c.rect)&&c.rect.length>=4).map((c,h)=>{const[x,m]=r.convertToViewportPoint(c.rect[0],c.rect[1]),[D,g]=r.convertToViewportPoint(c.rect[2],c.rect[3]),p=[x,m,D,g],d=Math.min(p[0],p[2]),E=Math.min(p[1],p[3]),v=Math.abs(p[2]-p[0]),N=Math.abs(p[3]-p[1]),b=typeof c.title=="string"?c.title.trim():"",w=typeof c.unsafeUrl=="string"?c.unsafeUrl.trim():"",k=typeof c.url=="string"?c.url.trim():"",M=Z(k)?k:Z(w)?w:"",C=c.dest;if(!M&&C==null)return null;const y=!!M;return i.jsx("a",{className:"pdf-annotation-link",href:M||"#",target:y?"_blank":void 0,rel:y?"noreferrer":void 0,title:b||(y?M:u),"aria-label":b||(y?M:u),style:{left:d,top:E,width:v,height:N},onClick:y?void 0:A=>{A.preventDefault(),o(C)}},`${h}-${d}-${E}`)})})}function Z(a){return/^(?:https?|mailto|ftp):/i.test(a)}export{me as PdfPreview,he as preloadPdf,fe as preloadPdfRuntime};
1
+ import{u as X,r as s,j as i}from"./react-BVUjbTTn.js";import{P as K,g as J,w as Q,G as ee}from"./pdf-DUYcbPMK.js";import{M as te,a as ne}from"./minus-bx4ZLZnb.js";import{P as re}from"./plus-DQg_bV50.js";import{d as V}from"./index-B6rP7QsM.js";ee.workerSrc=Q;const Y=new K,O=2,R=new Map;async function fe(){await Y.promise}function _(a,r){const o=`${r}:${a}`,f=R.get(o);if(f)return f.lastUsed=Date.now(),f;const u=J({url:a,worker:Y,disableRange:r==="full"}),c={task:u,promise:u.promise,consumers:0,settled:!1,lastUsed:Date.now()};return R.set(o,c),c.promise.then(()=>{c.settled=!0,q()},()=>{c.settled=!0,R.get(o)===c&&R.delete(o)}),c}function q(){if(R.size<=O)return;const a=[...R.entries()].filter(([,r])=>r.consumers===0&&r.settled).sort((r,o)=>r[1].lastUsed-o[1].lastUsed);for(;R.size>O&&a.length;){const[r,o]=a.shift();R.get(r)===o&&(R.delete(r),o.task.destroy())}}function he(a,r){if(!a)return;_(a,r).promise.catch(()=>{})}function se(a,r){const o=_(a,r);o.consumers+=1,o.lastUsed=Date.now();let f=!1;return{promise:o.promise,release:()=>{f||(f=!0,o.consumers=Math.max(0,o.consumers-1),o.lastUsed=Date.now(),q())}}}function me({url:a,loadingMode:r,target:o,compiling:f=!1,onViewportLocation:u,onDoubleClickLocation:c}){const{t:h}=X(),x=s.useRef(null),[m,D]=s.useState(null),[g,p]=s.useState(0),[d,E]=s.useState(100),[v,N]=s.useState(""),b=s.useRef(new Map),w=s.useRef(null),k=s.useRef(u);k.current=u;const M=s.useCallback((t,e)=>{e?b.current.set(t,e):b.current.delete(t)},[]),C=async t=>{if(!m||t==null)return;let e=t;if(typeof t=="string"&&(e=await m.getDestination(t).catch(()=>null)),!Array.isArray(e)||e.length===0)return;const l=e[0];let n=null;if(typeof l=="number"&&Number.isInteger(l))n=l;else if(l!=null)try{n=await m.getPageIndex(l)}catch{return}n==null||n<0||n>=m.numPages||b.current.get(n+1)?.scrollIntoView({behavior:"smooth",block:"start",inline:"nearest"})},y=s.useCallback(()=>{w.current=null;const t=x.current;if(!t)return;const e=t.getBoundingClientRect(),l=e.left+e.width/2,n=e.top+e.height/2,P=[...t.querySelectorAll(".pdf-page")],S=P.find(F=>{const I=F.getBoundingClientRect();return n>=I.top&&n<=I.bottom})??P.reduce((F,I)=>{if(!F)return I;const H=Math.abs(I.getBoundingClientRect().top-n),G=Math.abs(F.getBoundingClientRect().top-n);return H<G?I:F},null);if(!S)return;const j=S.getBoundingClientRect(),U=Number(S.dataset.scale)||1,T=Number(S.dataset.page),$=Math.max(0,Math.min(j.width,l-j.left))/U,B=Math.max(0,Math.min(j.height,n-j.top))/U;T&&k.current(T,$,B)},[]),A=s.useCallback(()=>{w.current===null&&(w.current=window.requestAnimationFrame(y))},[y]);s.useEffect(()=>()=>{w.current!==null&&window.cancelAnimationFrame(w.current),w.current=null},[]),s.useEffect(()=>{const t=x.current;if(!t)return;const e=()=>p(t.clientWidth);e();const l=new ResizeObserver(e);return l.observe(t),()=>l.disconnect()},[]),s.useEffect(()=>{let t=!1;D(null),N("");const e=se(a,r);return e.promise.then(l=>{t||D(l)}).catch(()=>{t||N(h("editor.pdfLoadFailed"))}),()=>{t=!0,e.release()}},[a,r]),s.useEffect(()=>{d>100||!x.current||(x.current.scrollLeft=0)},[d,g,m]);const z=t=>E(e=>Math.min(200,Math.max(50,e+t))),W=()=>{x.current&&(x.current.scrollLeft=0),E(100)},L=t=>{!t.shiftKey||Math.abs(t.deltaX)>Math.abs(t.deltaY)||(t.preventDefault(),t.currentTarget.scrollLeft+=t.deltaY,A())};return i.jsxs("div",{className:"pdf-viewer",children:[i.jsxs("div",{className:"pdf-toolbar",role:"toolbar","aria-label":h("editor.pdfZoomControls"),children:[i.jsx("button",{disabled:d<=50,title:h("editor.pdfZoomOut"),"aria-label":h("editor.pdfZoomOut"),onClick:()=>z(-10),children:i.jsx(te,{size:14})}),i.jsxs("span",{className:"pdf-zoom-value","aria-live":"polite",children:[d,"%"]}),i.jsx("button",{disabled:d>=200,title:h("editor.pdfZoomIn"),"aria-label":h("editor.pdfZoomIn"),onClick:()=>z(10),children:i.jsx(re,{size:14})}),i.jsxs("button",{className:"pdf-fit-width",title:h("editor.pdfFitWidth"),onClick:W,children:[i.jsx(ne,{size:13}),h("editor.pdfFitWidth")]})]}),f&&i.jsxs("div",{className:"pdf-compiling-overlay",role:"status","aria-live":"polite",children:[i.jsx(V,{className:"spin",size:20}),i.jsx("span",{children:h("editor.compiling")})]}),i.jsx("div",{className:"pdf-document",ref:x,onScroll:A,onWheel:L,children:i.jsxs("div",{className:"pdf-pages",style:{width:`${Math.max(1,g-28)*Math.max(1,d/100)}px`},children:[!m&&!v&&i.jsxs("div",{className:"pdf-loading",role:"status","aria-live":"polite",children:[i.jsx(V,{className:"spin",size:24}),i.jsx("span",{children:h("editor.loadingPdf")})]}),v&&i.jsx("div",{className:"preview-empty",children:i.jsx("strong",{children:v})}),m&&g>0&&Array.from({length:m.numPages},(t,e)=>i.jsx(ie,{document:m,pageNumber:e+1,availableWidth:g-28,zoom:d/100,target:o?.page===e+1?o:null,onReady:A,onPageElement:M,onInternalLink:C,onDoubleClickLocation:c},e+1))]})})]})}function ie({document:a,pageNumber:r,availableWidth:o,zoom:f,target:u,onReady:c,onPageElement:h,onInternalLink:x,onDoubleClickLocation:m}){const D=s.useRef(null),g=s.useRef(null),p=s.useRef(null),[d,E]=s.useState(1),[v,N]=s.useState({width:0,height:0}),[b,w]=s.useState(r===1),[k,M]=s.useState(!1),[C,y]=s.useState(null),[A,z]=s.useState([]);s.useEffect(()=>{const e=D.current;if(!e||b)return;if(!("IntersectionObserver"in window)){w(!0);return}const l=new IntersectionObserver(n=>{n.some(P=>P.isIntersecting)&&(w(!0),l.disconnect())},{rootMargin:"900px 0px"});return l.observe(e),()=>l.disconnect()},[b]),s.useEffect(()=>{u&&w(!0)},[u?.nonce]),s.useEffect(()=>{if(!b)return;let e=!1,l=null;return M(!1),y(null),z([]),a.getPage(r).then(n=>{if(e)return;const P=n.getViewport({scale:1}),S=o/P.width,j=Math.min(3.3,Math.max(.175,S*f)),U=n.getViewport({scale:j});if(E(j),N({width:U.width,height:U.height}),y(U),n.getAnnotations({intent:"display"}).then(B=>{e||z(B)}).catch(()=>{e||z([])}),!g.current)return;const T=Math.max(1,window.devicePixelRatio||1),$=n.getViewport({scale:j*T});return g.current.width=Math.floor($.width),g.current.height=Math.floor($.height),l=n.render({canvas:g.current,viewport:$}),l.promise.then(()=>{e||(M(!0),window.requestAnimationFrame(c))})}).catch(()=>{}),()=>{e=!0,l?.cancel()}},[a,r,o,f,b]),s.useEffect(()=>{!u||!p.current||p.current.scrollIntoView({behavior:"smooth",block:"center",inline:"center"})},[u?.nonce,d]);const W=e=>{if(!m||!k||e.target instanceof HTMLElement&&e.target.closest("a"))return;const l=g.current;if(!l)return;const n=l.getBoundingClientRect();if(e.clientX<n.left||e.clientX>n.right||e.clientY<n.top||e.clientY>n.bottom)return;const P=d||1,S=Math.max(0,Math.min(n.width,e.clientX-n.left))/P,j=Math.max(0,Math.min(n.height,e.clientY-n.top))/P;m(r,S,j)},L=Math.max(1,o*f),t=L*(792/612);return i.jsxs("figure",{ref:e=>{D.current=e,h(r,e)},onDoubleClick:W,className:`pdf-page${k?" rendered":" loading"}`,"data-page":r,"data-scale":d,style:{width:`${v.width||L}px`,minHeight:`${v.height||t}px`},children:[i.jsx("canvas",{ref:g,style:{width:`${v.width||L}px`,height:`${v.height||t}px`}}),k&&C&&i.jsx(oe,{annotations:A,viewport:C,onInternalLink:x}),u&&i.jsx("span",{ref:p,className:"pdf-sync-marker",style:{left:u.x*d,top:u.y*d}}),i.jsx("figcaption",{children:r})]})}function oe({annotations:a,viewport:r,onInternalLink:o}){const{t:f}=X(),u=f("editor.pdfLink");return i.jsx("div",{className:"pdf-annotation-layer","aria-label":f("editor.pdfLinks"),children:a.filter(c=>c.subtype==="Link"&&Array.isArray(c.rect)&&c.rect.length>=4).map((c,h)=>{const[x,m]=r.convertToViewportPoint(c.rect[0],c.rect[1]),[D,g]=r.convertToViewportPoint(c.rect[2],c.rect[3]),p=[x,m,D,g],d=Math.min(p[0],p[2]),E=Math.min(p[1],p[3]),v=Math.abs(p[2]-p[0]),N=Math.abs(p[3]-p[1]),b=typeof c.title=="string"?c.title.trim():"",w=typeof c.unsafeUrl=="string"?c.unsafeUrl.trim():"",k=typeof c.url=="string"?c.url.trim():"",M=Z(k)?k:Z(w)?w:"",C=c.dest;if(!M&&C==null)return null;const y=!!M;return i.jsx("a",{className:"pdf-annotation-link",href:M||"#",target:y?"_blank":void 0,rel:y?"noreferrer":void 0,title:b||(y?M:u),"aria-label":b||(y?M:u),style:{left:d,top:E,width:v,height:N},onClick:y?void 0:A=>{A.preventDefault(),o(C)}},`${h}-${d}-${E}`)})})}function Z(a){return/^(?:https?|mailto|ftp):/i.test(a)}export{me as PdfPreview,he as preloadPdf,fe as preloadPdfRuntime};
@@ -1 +1 @@
1
- import{u as E,r as t,j as e}from"./react-BVUjbTTn.js";import{M as $,h as M}from"./index-teah8iB2.js";import{i as z,p as b,P as h,a as L,n as F}from"./Dashboard-DtHSc55D.js";import{S as q}from"./search-C9_Jyrnx.js";import"./hard-drive-DP2OHKMC.js";import"./x-BEVz0wdw.js";import"./sigma-p9-fBP0d.js";import"./tags-DjF3z21M.js";function y(o){return o.trim().toLocaleLowerCase()}function H({project:o,open:l,onOpenChange:d,onSave:g}){const{t:s,i18n:k}=E(),[i,x]=t.useState(""),[n,p]=t.useState(null),[I,u]=t.useState(""),[r,j]=t.useState(!1),[f,m]=t.useState("");t.useEffect(()=>{l&&(x(""),p(o?.icon??null),u(o?.icon&&!z(o.icon)?o.icon:""),j(!1),m(""))},[l,o?.id,o?.icon]);const v=t.useMemo(()=>{const c=y(i);return c?b.filter(({name:a})=>[a,s(`projectIcons.icons.${a}.name`),s(`projectIcons.icons.${a}.keywords`)].some(P=>y(P).includes(c))):b},[k.resolvedLanguage,i,s]),C=async()=>{if(!(!o||r)){j(!0),m("");try{await g(o.id,n),d(!1)}catch(c){m(M(c))}finally{j(!1)}}},S=n!==(o?.icon??null),N=c=>{p(c),u("")},w=c=>{u(c);const a=c.trim();p(a?F(a)??a:null)};return e.jsx($,{open:l,wide:!0,className:"project-icon-picker-modal",title:s("projectIcons.title"),description:o?s("projectIcons.description",{project:o.name}):void 0,onOpenChange:c=>{r||d(c)},footer:e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",disabled:r,onClick:()=>d(!1),children:s("common.cancel")}),e.jsx("button",{type:"button",className:"primary",disabled:r||!S,"aria-busy":r,onClick:()=>{C()},children:s("projectIcons.save")})]}),children:e.jsxs("div",{className:"project-icon-picker",children:[f&&e.jsx("p",{className:"error dialog-error",role:"alert",children:f}),e.jsxs("label",{className:"project-icon-search",children:[e.jsx(q,{"aria-hidden":"true",size:16}),e.jsx("span",{className:"sr-only",children:s("projectIcons.search")}),e.jsx("input",{autoFocus:!0,value:i,placeholder:s("projectIcons.search"),onChange:c=>x(c.target.value)})]}),e.jsxs("div",{className:"project-icon-options","aria-label":s("projectIcons.title"),children:[e.jsxs("button",{type:"button","aria-pressed":n===null,className:`project-icon-option project-icon-reset${n===null?" selected":""}`,title:s("projectIcons.useInitial"),onClick:()=>N(null),children:[e.jsx("span",{className:"project-icon-option-glyph",children:e.jsx(h,{fallback:L(o?.name??"")})}),e.jsx("span",{children:s("projectIcons.useInitial")})]}),v.map(({name:c})=>e.jsxs("button",{type:"button","aria-pressed":n===c,className:`project-icon-option${n===c?" selected":""}`,title:s(`projectIcons.icons.${c}.name`),onClick:()=>N(c),children:[e.jsx("span",{className:"project-icon-option-glyph",children:e.jsx(h,{icon:c,fallback:"?"})}),e.jsx("span",{children:s(`projectIcons.icons.${c}.name`)})]},c))]}),v.length===0&&e.jsx("p",{className:"project-icon-picker-empty",children:s("projectIcons.noMatches",{query:i})}),e.jsxs("div",{className:"project-icon-advanced",children:[e.jsx("label",{htmlFor:"project-icon-advanced-name",children:s("projectIcons.advancedName")}),e.jsxs("div",{className:"project-icon-advanced-input",children:[e.jsx("input",{id:"project-icon-advanced-name",value:I,placeholder:s("projectIcons.advancedNamePlaceholder"),onChange:c=>w(c.target.value),spellCheck:!1,autoCapitalize:"off",autoCorrect:"off"}),I.trim()&&e.jsx("span",{className:"project-icon-advanced-preview","aria-label":s("projectIcons.advancedPreview"),children:e.jsx(h,{icon:n,fallback:"?"})})]}),e.jsxs("p",{children:[s("projectIcons.advancedNameDescription")," ",e.jsx("a",{href:"https://icon-sets.iconify.design/lucide/",target:"_blank",rel:"noreferrer",children:s("projectIcons.browse")})]})]})]})})}export{H as ProjectIconPickerDialog};
1
+ import{u as E,r as t,j as e}from"./react-BVUjbTTn.js";import{M as $,h as M}from"./index-B6rP7QsM.js";import{i as z,p as b,P as h,a as L,n as F}from"./Dashboard-BB4RO4x2.js";import{S as q}from"./search-UZspmceH.js";import"./hard-drive-Bsk-RETn.js";import"./x-DlFXD9Vl.js";import"./sigma-C0IvFdKV.js";import"./tags-BTUtvaAc.js";function y(o){return o.trim().toLocaleLowerCase()}function H({project:o,open:l,onOpenChange:d,onSave:g}){const{t:s,i18n:k}=E(),[i,x]=t.useState(""),[n,p]=t.useState(null),[I,u]=t.useState(""),[r,j]=t.useState(!1),[f,m]=t.useState("");t.useEffect(()=>{l&&(x(""),p(o?.icon??null),u(o?.icon&&!z(o.icon)?o.icon:""),j(!1),m(""))},[l,o?.id,o?.icon]);const v=t.useMemo(()=>{const c=y(i);return c?b.filter(({name:a})=>[a,s(`projectIcons.icons.${a}.name`),s(`projectIcons.icons.${a}.keywords`)].some(P=>y(P).includes(c))):b},[k.resolvedLanguage,i,s]),C=async()=>{if(!(!o||r)){j(!0),m("");try{await g(o.id,n),d(!1)}catch(c){m(M(c))}finally{j(!1)}}},S=n!==(o?.icon??null),N=c=>{p(c),u("")},w=c=>{u(c);const a=c.trim();p(a?F(a)??a:null)};return e.jsx($,{open:l,wide:!0,className:"project-icon-picker-modal",title:s("projectIcons.title"),description:o?s("projectIcons.description",{project:o.name}):void 0,onOpenChange:c=>{r||d(c)},footer:e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",disabled:r,onClick:()=>d(!1),children:s("common.cancel")}),e.jsx("button",{type:"button",className:"primary",disabled:r||!S,"aria-busy":r,onClick:()=>{C()},children:s("projectIcons.save")})]}),children:e.jsxs("div",{className:"project-icon-picker",children:[f&&e.jsx("p",{className:"error dialog-error",role:"alert",children:f}),e.jsxs("label",{className:"project-icon-search",children:[e.jsx(q,{"aria-hidden":"true",size:16}),e.jsx("span",{className:"sr-only",children:s("projectIcons.search")}),e.jsx("input",{autoFocus:!0,value:i,placeholder:s("projectIcons.search"),onChange:c=>x(c.target.value)})]}),e.jsxs("div",{className:"project-icon-options","aria-label":s("projectIcons.title"),children:[e.jsxs("button",{type:"button","aria-pressed":n===null,className:`project-icon-option project-icon-reset${n===null?" selected":""}`,title:s("projectIcons.useInitial"),onClick:()=>N(null),children:[e.jsx("span",{className:"project-icon-option-glyph",children:e.jsx(h,{fallback:L(o?.name??"")})}),e.jsx("span",{children:s("projectIcons.useInitial")})]}),v.map(({name:c})=>e.jsxs("button",{type:"button","aria-pressed":n===c,className:`project-icon-option${n===c?" selected":""}`,title:s(`projectIcons.icons.${c}.name`),onClick:()=>N(c),children:[e.jsx("span",{className:"project-icon-option-glyph",children:e.jsx(h,{icon:c,fallback:"?"})}),e.jsx("span",{children:s(`projectIcons.icons.${c}.name`)})]},c))]}),v.length===0&&e.jsx("p",{className:"project-icon-picker-empty",children:s("projectIcons.noMatches",{query:i})}),e.jsxs("div",{className:"project-icon-advanced",children:[e.jsx("label",{htmlFor:"project-icon-advanced-name",children:s("projectIcons.advancedName")}),e.jsxs("div",{className:"project-icon-advanced-input",children:[e.jsx("input",{id:"project-icon-advanced-name",value:I,placeholder:s("projectIcons.advancedNamePlaceholder"),onChange:c=>w(c.target.value),spellCheck:!1,autoCapitalize:"off",autoCorrect:"off"}),I.trim()&&e.jsx("span",{className:"project-icon-advanced-preview","aria-label":s("projectIcons.advancedPreview"),children:e.jsx(h,{icon:n,fallback:"?"})})]}),e.jsxs("p",{children:[s("projectIcons.advancedNameDescription")," ",e.jsx("a",{href:"https://icon-sets.iconify.design/lucide/",target:"_blank",rel:"noreferrer",children:s("projectIcons.browse")})]})]})]})})}export{H as ProjectIconPickerDialog};
@@ -1 +1 @@
1
- import{u as A,r,j as e}from"./react-BVUjbTTn.js";import{c as U,g as q,M as F,d as V,C as B}from"./index-teah8iB2.js";import{S as $}from"./search-C9_Jyrnx.js";import{F as J,d as K}from"./x-BEVz0wdw.js";import{C as G}from"./check-BAdi_Lxq.js";const T=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 te({open:c,files:h,onOpenChange:u,onOpenFile:p}){const{t:a}=A(),[n,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,n)})).filter(s=>s.score>=0).sort((s,i)=>i.score-s.score||s.entry.path.localeCompare(i.entry.path)).slice(0,100),[h,n]);r.useEffect(()=>{c&&(f(""),o(0),window.setTimeout(()=>m.current?.focus(),0))},[c]),r.useEffect(()=>o(s=>Math.min(s,Math.max(0,l.length-1))),[l.length]),r.useEffect(()=>{c&&y.current?.scrollIntoView({block:"nearest"})},[c,d]);const S=s=>{p(s),u(!1)};return e.jsx(F,{open:c,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:n,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 se({open:c,project:h,onOpenChange:u,onJump:p}){const{t:a}=A(),[n,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(""),[z,w]=r.useState(""),[O,Q]=r.useState(0),v=r.useRef(null);r.useEffect(()=>{if(!c){v.current?.abort();return}if(M(""),w(""),!n.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:n});m&&E.set("caseSensitive","1"),l&&E.set("wholeWord","1"),q(`/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(L(j))}).finally(()=>{v.current===x&&(v.current=null,k(!1))})},250);return()=>window.clearTimeout(t)},[c,h.id,n,m,l,O]);const I=async()=>{N(!1),k(!0),w(""),M("");try{const t=await q(`/api/projects/${h.id}/search/replace`,{method:"POST",body:JSON.stringify({query:n,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(L(t))}finally{k(!1)}};return e.jsxs(e.Fragment,{children:[e.jsx(F,{open:c,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:[z&&e.jsx("p",{className:"error",children:z}),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:n,placeholder:a("navigation.searchPlaceholder"),onChange:t=>f(t.target.value)})]}),h.permission!=="read"&&e.jsxs("label",{className:"project-search-query",children:[e.jsx(T,{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:!n.trim()||g===0||b,onClick:()=>N(!0),children:[e.jsx(T,{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(J,{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&&n.trim()&&s.length===0&&e.jsx("p",{className:"muted padded",children:a("editor.search.noMatches")})]})]})}),e.jsx(B,{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(c,h){const u=c.toLocaleLowerCase(),p=h.trim().toLocaleLowerCase();if(!p)return 1;const a=u.indexOf(p);if(a>=0)return 1e4-a-u.length;let n=0,f=0;for(const d of p){const o=u.indexOf(d,n);if(o<0)return-1;f+=o===n?5:1,n=o+1}return f-u.length/100}function L(c){return c instanceof Error?c.message:String(c)}export{se as ProjectSearchDialog,te as QuickOpenDialog};
1
+ import{u as A,r,j as e}from"./react-BVUjbTTn.js";import{c as U,g as q,M as F,d as V,C as B}from"./index-B6rP7QsM.js";import{S as $}from"./search-UZspmceH.js";import{F as J,e as K}from"./x-DlFXD9Vl.js";import{C as G}from"./check-Jf8WBxDX.js";const T=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 te({open:c,files:h,onOpenChange:u,onOpenFile:p}){const{t:a}=A(),[n,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,n)})).filter(s=>s.score>=0).sort((s,i)=>i.score-s.score||s.entry.path.localeCompare(i.entry.path)).slice(0,100),[h,n]);r.useEffect(()=>{c&&(f(""),o(0),window.setTimeout(()=>m.current?.focus(),0))},[c]),r.useEffect(()=>o(s=>Math.min(s,Math.max(0,l.length-1))),[l.length]),r.useEffect(()=>{c&&y.current?.scrollIntoView({block:"nearest"})},[c,d]);const S=s=>{p(s),u(!1)};return e.jsx(F,{open:c,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:n,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 se({open:c,project:h,onOpenChange:u,onJump:p}){const{t:a}=A(),[n,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(""),[z,w]=r.useState(""),[O,Q]=r.useState(0),v=r.useRef(null);r.useEffect(()=>{if(!c){v.current?.abort();return}if(M(""),w(""),!n.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:n});m&&E.set("caseSensitive","1"),l&&E.set("wholeWord","1"),q(`/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(L(j))}).finally(()=>{v.current===x&&(v.current=null,k(!1))})},250);return()=>window.clearTimeout(t)},[c,h.id,n,m,l,O]);const I=async()=>{N(!1),k(!0),w(""),M("");try{const t=await q(`/api/projects/${h.id}/search/replace`,{method:"POST",body:JSON.stringify({query:n,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(L(t))}finally{k(!1)}};return e.jsxs(e.Fragment,{children:[e.jsx(F,{open:c,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:[z&&e.jsx("p",{className:"error",children:z}),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:n,placeholder:a("navigation.searchPlaceholder"),onChange:t=>f(t.target.value)})]}),h.permission!=="read"&&e.jsxs("label",{className:"project-search-query",children:[e.jsx(T,{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:!n.trim()||g===0||b,onClick:()=>N(!0),children:[e.jsx(T,{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(J,{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&&n.trim()&&s.length===0&&e.jsx("p",{className:"muted padded",children:a("editor.search.noMatches")})]})]})}),e.jsx(B,{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(c,h){const u=c.toLocaleLowerCase(),p=h.trim().toLocaleLowerCase();if(!p)return 1;const a=u.indexOf(p);if(a>=0)return 1e4-a-u.length;let n=0,f=0;for(const d of p){const o=u.indexOf(d,n);if(o<0)return-1;f+=o===n?5:1,n=o+1}return f-u.length/100}function L(c){return c instanceof Error?c.message:String(c)}export{se as ProjectSearchDialog,te as QuickOpenDialog};
@@ -1 +1 @@
1
- import{u as oe,r,j as e}from"./react-BVUjbTTn.js";import{c as m,g as j,h as S,d as le}from"./index-teah8iB2.js";import{D as y,E as pe,S as E,G as U,I as de,J as he,A as xe,K as me}from"./ProjectWorkspace-CI2zKon5.js";import{X as V,h as je,C as ge,c as ue}from"./x-BEVz0wdw.js";import{T as B}from"./type-CNrDJnzR.js";import{S as be}from"./sigma-p9-fBP0d.js";import{R as Q}from"./refresh-cw-BDcwKu_d.js";import"./check-BAdi_Lxq.js";import"./search-C9_Jyrnx.js";import"./user-plus-C7exNawX.js";const ve=m("ChevronsLeft",[["path",{d:"m11 17-5-5 5-5",key:"13zhaf"}],["path",{d:"m18 17-5-5 5-5",key:"h8a8et"}]]);const Se=m("ChevronsRight",[["path",{d:"m6 17 5-5-5-5",key:"xnjwq"}],["path",{d:"m13 17 5-5-5-5",key:"17xmmf"}]]);const ye=m("CircleAlert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);const fe=m("MessageCircleQuestion",[["path",{d:"M7.9 20A9 9 0 1 0 4 16.1L2 22Z",key:"vv11sd"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);const ke=m("PanelsTopLeft",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M9 21V9",key:"1oto5p"}]]);const Ne=m("SpellCheck2",[["path",{d:"m6 16 6-12 6 12",key:"1b4byz"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"M4 21c1.1 0 1.1-1 2.3-1s1.1 1 2.3 1c1.1 0 1.1-1 2.3-1 1.1 0 1.1 1 2.3 1 1.1 0 1.1-1 2.3-1 1.1 0 1.1 1 2.3 1 1.1 0 1.1-1 2.3-1",key:"8mdmtu"}]]);const Ce=m("WrapText",[["line",{x1:"3",x2:"21",y1:"6",y2:"6",key:"4m8b97"}],["path",{d:"M3 12h15a3 3 0 1 1 0 6h-4",key:"1cl7v7"}],["polyline",{points:"16 16 14 18 16 20",key:"1jznyi"}],["line",{x1:"3",x2:"10",y1:"18",y2:"18",key:"1h33wv"}]]);function we({name:f,state:n,label:c,reloadLabel:d,onReload:k,compact:N=!1}){const g=n.status==="loading"?e.jsx(le,{className:"spin",size:14}):n.status==="working"?e.jsx(xe,{size:14}):e.jsx(ye,{size:14}),u=e.jsxs(e.Fragment,{children:[g,e.jsx("strong",{children:f}),e.jsx("span",{children:c}),n.status==="error"&&e.jsxs("button",{type:"button",className:"browser-tool-reload",title:d,"aria-label":d,onClick:k,children:[e.jsx(Q,{size:12}),d]})]});return N?e.jsxs("span",{className:`browser-tool-status compact ${n.status}`,role:"status","aria-live":"polite","aria-label":`${f}: ${c}`,title:n.error||void 0,children:[g,e.jsx("span",{children:c}),n.status==="error"&&e.jsx("button",{type:"button",className:"browser-tool-reload",title:d,"aria-label":d,onClick:k,children:e.jsx(Q,{size:12})})]}):e.jsx("div",{className:`browser-tool-status ${n.status}`,title:n.error||void 0,children:u})}function He({onClose:f,project:n,projectId:c,site:d,files:k,dictionaryWords:N,onDictionaryChange:g,editorPreferences:u,onEditorPreferences:G,spellCheckCount:l,spellCheckUniqueCount:X,spellCheckIndex:h,onSpellCheckNavigate:C,onProject:Z}){const{t:s}=oe(),[O,Y]=r.useState(n.engine),[T,F]=r.useState(""),[D,I]=r.useState(n.name),[b,ee]=r.useState(n.mainFile),[v,$]=r.useState(null),[P,z]=r.useState(""),[M,A]=r.useState(""),[H,w]=r.useState(""),[p,L]=r.useState("appearance"),[i,o]=r.useState(u),R=r.useSyncExternalStore(y.subscribe,y.getSnapshot,y.getSnapshot),x=n.permission==="owner",W=n.permission!=="read",q=n.permission!=="read";r.useEffect(()=>o(u),[u]),r.useEffect(()=>{pe().catch(y.failed)},[c]);const te=()=>{me().catch(y.failed)};r.useEffect(()=>{if(!n.latexmkrc)return F("");j(`/api/projects/${c}/file?path=${encodeURIComponent(n.latexmkrc)}`).then(({content:t})=>F(t)).catch(t=>z(S(t)))},[n.latexmkrc]),r.useEffect(()=>{if(p!=="compiler")return;const t=new AbortController;return $(null),j(`/api/projects/${c}/main-files`,{signal:t.signal}).then(a=>$(a.mainFiles)).catch(a=>{a instanceof Error&&a.name==="AbortError"||z(S(a))}),()=>t.abort()},[c,k,p]);const se=v??[n.mainFile],ie=v!==null&&!v.includes(b),J=async()=>{try{const t=T.trim()&&d.allowProjectLatexmkrc!==!1?".latexmkrc":null;t&&await j(`/api/projects/${c}/file`,{method:"PUT",body:JSON.stringify({path:t,content:T})});const a=await j(`/api/projects/${c}`,{method:"PATCH",body:JSON.stringify({name:D,mainFile:b,engine:O,latexmkrc:t})});Z(a.project)}catch(t){z(S(t))}},_=()=>G(i),ne=()=>{if(p==="appearance")return _();x&&J()},ae=s(p==="appearance"?"projectSettings.saveAppearance":"projectSettings.saveCompiler"),re=p==="appearance"||x,K=async()=>{const t=M.trim();if(t)try{const a=await j(`/api/projects/${c}/dictionary`,{method:"POST",body:JSON.stringify({word:t})});g(a.words),A(""),w("")}catch(a){w(S(a))}},ce=async t=>{try{const a=await j(`/api/projects/${c}/dictionary/${encodeURIComponent(t)}`,{method:"DELETE"});g(a.words),w("")}catch(a){w(S(a))}};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"drawer-title settings-drawer-title",children:[e.jsx("strong",{children:s("editor.projectSettings")}),e.jsxs("div",{className:"drawer-title-actions",children:[re&&e.jsxs("button",{type:"button",className:"drawer-settings-save",onClick:ne,children:[e.jsx(E,{size:14}),e.jsx("span",{children:ae})]}),e.jsx("button",{type:"button","aria-label":s("common.close"),onClick:f,children:e.jsx(V,{size:17})})]})]}),e.jsxs("div",{className:"settings padded",children:[P&&e.jsx("p",{className:"error",children:P}),e.jsxs("div",{className:"settings-tabs",role:"tablist","aria-label":s("common.settings"),children:[e.jsxs("button",{id:"settings-tab-appearance",type:"button",role:"tab","aria-selected":p==="appearance","aria-controls":"settings-panel-appearance",className:`settings-tab${p==="appearance"?" active":""}`,onClick:()=>L("appearance"),children:[e.jsx(B,{size:15}),s("projectSettings.editorTab")]}),e.jsxs("button",{id:"settings-tab-compiler",type:"button",role:"tab","aria-selected":p==="compiler","aria-controls":"settings-panel-compiler",className:`settings-tab${p==="compiler"?" active":""}`,onClick:()=>L("compiler"),children:[e.jsx(U,{size:15}),s("projectSettings.compilerTab")]})]}),p==="appearance"?e.jsxs("section",{id:"settings-panel-appearance",role:"tabpanel","aria-labelledby":"settings-tab-appearance",children:[e.jsxs("div",{className:"settings-section-title",children:[e.jsx(B,{size:15}),e.jsx("strong",{children:s("projectSettings.editorAppearance")})]}),e.jsx("p",{className:"settings-description appearance-description",children:s("projectSettings.editorAppearanceDescription")}),e.jsxs("label",{children:[s("projectSettings.fontFamily"),e.jsx("select",{value:i.font,onChange:t=>o({...i,font:t.target.value}),children:de.map(t=>e.jsx("option",{value:t.id,children:s(t.labelKey)},t.id))})]}),e.jsxs("label",{children:[s("projectSettings.fontSize"),e.jsx("select",{value:i.fontSize,onChange:t=>o({...i,fontSize:Number(t.target.value)}),children:[12,13,14,15,16,18,20].map(t=>e.jsxs("option",{value:t,children:[t," px"]},t))})]}),e.jsxs("label",{children:[s("projectSettings.lineHeight"),e.jsxs("select",{value:i.lineHeight,onChange:t=>o({...i,lineHeight:Number(t.target.value)}),children:[e.jsx("option",{value:1.45,children:s("projectSettings.lineHeightCompact")}),e.jsx("option",{value:1.65,children:s("projectSettings.lineHeightNormal")}),e.jsx("option",{value:1.85,children:s("projectSettings.lineHeightRelaxed")})]})]}),e.jsxs("label",{className:"editor-checkbox",children:[e.jsx("input",{type:"checkbox",checked:i.lineWrapping,onChange:t=>o({...i,lineWrapping:t.target.checked})}),e.jsx(Ce,{size:15}),e.jsx("span",{children:s("projectSettings.lineWrapping")})]}),e.jsxs("div",{className:"editor-preference",children:[e.jsxs("label",{className:"editor-checkbox",children:[e.jsx("input",{type:"checkbox",checked:i.showTooltips,onChange:t=>o({...i,showTooltips:t.target.checked})}),e.jsx(fe,{size:15}),e.jsx("span",{children:s("projectSettings.showTooltips")})]}),e.jsx("p",{className:"field-hint",children:s("projectSettings.showTooltipsDescription")})]}),e.jsxs("div",{className:"editor-preference",children:[e.jsxs("label",{className:"editor-checkbox",children:[e.jsx("input",{type:"checkbox",checked:i.mathPreviewOnHover,onChange:t=>o({...i,mathPreviewOnHover:t.target.checked})}),e.jsx(be,{size:15}),e.jsx("span",{children:s("projectSettings.mathPreviewOnHover")})]}),e.jsx("p",{className:"field-hint",children:s("projectSettings.mathPreviewOnHoverDescription")})]}),e.jsxs("div",{className:"editor-preference",children:[e.jsxs("label",{className:"editor-checkbox",children:[e.jsx("input",{type:"checkbox",checked:i.spellCheck,onChange:t=>o({...i,spellCheck:t.target.checked})}),e.jsx("span",{children:s("projectSettings.spellCheck")})]}),e.jsxs("p",{className:"field-hint",children:[s("projectSettings.writingCheckDescription")," ",e.jsx("a",{href:"https://writewithharper.com/docs/integrations/language-server",target:"_blank",rel:"noreferrer",children:"Harper"})]})]}),e.jsxs("div",{className:"editor-preference",children:[e.jsxs("label",{className:"editor-checkbox",children:[e.jsx("input",{type:"checkbox",checked:i.vimMode,onChange:t=>o({...i,vimMode:t.target.checked})}),e.jsx("span",{children:s("projectSettings.vimMode")})]}),e.jsxs("p",{className:"field-hint",children:[s("projectSettings.vimModeDescription")," ",e.jsx("a",{href:"https://replit-codemirror-vim.mintlify.app/",target:"_blank",rel:"noreferrer",children:s("projectSettings.vimHelp")})]})]}),e.jsxs("div",{className:"editor-preference",children:[e.jsxs("label",{className:"editor-checkbox",children:[e.jsx("input",{type:"checkbox",checked:i.openFilesInTabs,onChange:t=>o({...i,openFilesInTabs:t.target.checked})}),e.jsx(ke,{size:15}),e.jsx("span",{children:s("projectSettings.openFilesInTabs")})]}),e.jsx("p",{className:"field-hint",children:s("projectSettings.openFilesInTabsDescription")})]}),e.jsxs("div",{className:"editor-preference",children:[e.jsxs("label",{className:"editor-checkbox",children:[e.jsx("input",{type:"checkbox",disabled:!W,checked:i.formatOnCompile,onChange:t=>o({...i,formatOnCompile:t.target.checked})}),e.jsx(he,{size:15}),e.jsx("span",{children:s("projectSettings.formatOnCompile")})]}),e.jsxs("p",{className:"field-hint",children:[s(W?"projectSettings.formatOnCompileDescription":"projectSettings.formatRequiresWrite")," ",s("projectSettings.formatterDescription")," ",e.jsx("a",{href:"https://www.npmjs.com/package/tex-fmt",target:"_blank",rel:"noreferrer",children:s("projectSettings.formatterInstall")})," · ",e.jsx("a",{href:"https://github.com/FlamingTempura/bibtex-tidy",target:"_blank",rel:"noreferrer",children:s("projectSettings.bibtexTidyInstall")})]})]}),e.jsxs("div",{className:"editor-preference",children:[e.jsxs("label",{className:"tex-fmt-options-field",children:[e.jsxs("span",{className:"tex-fmt-options-heading",children:[e.jsx("span",{children:s("projectSettings.texFmtOptions")}),e.jsx(we,{compact:!0,name:"tex-fmt",state:R,label:s(`projectSettings.toolStatus.${R.status}`),reloadLabel:s("projectSettings.reloadTool"),onReload:te})]}),e.jsx("textarea",{className:"tex-fmt-options-editor",rows:6,maxLength:16*1024,spellCheck:!1,value:i.texFmtConfig,placeholder:s("projectSettings.texFmtOptionsPlaceholder"),onChange:t=>o({...i,texFmtConfig:t.target.value})})]}),e.jsx("p",{className:"field-hint",children:s("projectSettings.texFmtOptionsDescription")})]}),l!==null&&e.jsxs("div",{className:`spell-check-result${l?" has-issues":""}`,role:"status","aria-live":"polite",children:[e.jsx(Ne,{size:14}),e.jsx("span",{children:l?s("projectSettings.writingIssues",{count:l,uniqueCount:X??0}):s("projectSettings.noWritingIssues")}),l>0&&e.jsxs("span",{className:"spell-check-controls",children:[e.jsx("button",{type:"button",title:s("projectSettings.spellCheckFirst"),"aria-label":s("projectSettings.spellCheckFirst"),disabled:h<=0,onClick:()=>C(0),children:e.jsx(ve,{size:14})}),e.jsx("button",{type:"button",title:s("projectSettings.spellCheckPrevious"),"aria-label":s("projectSettings.spellCheckPrevious"),disabled:h<=0,onClick:()=>C(h-1),children:e.jsx(je,{size:14})}),e.jsx("span",{className:"spell-check-position",children:s("projectSettings.spellCheckPosition",{current:Math.min(h+1,l),total:l})}),e.jsx("button",{type:"button",title:s("projectSettings.spellCheckNext"),"aria-label":s("projectSettings.spellCheckNext"),disabled:h>=l-1,onClick:()=>C(h+1),children:e.jsx(ge,{size:14})}),e.jsx("button",{type:"button",title:s("projectSettings.spellCheckLast"),"aria-label":s("projectSettings.spellCheckLast"),disabled:h>=l-1,onClick:()=>C(l-1),children:e.jsx(Se,{size:14})})]})]}),e.jsxs("div",{className:"settings-section-title",children:[e.jsx(ue,{size:15}),e.jsx("strong",{children:s("projectSettings.dictionary")})]}),e.jsx("p",{className:"settings-description",children:s("projectSettings.dictionaryDescription")}),H&&e.jsx("p",{className:"error dictionary-error",children:H}),q&&e.jsxs("div",{className:"dictionary-add",children:[e.jsx("input",{value:M,placeholder:s("projectSettings.dictionaryPlaceholder"),onChange:t=>A(t.target.value),onKeyDown:t=>{t.key==="Enter"&&(t.preventDefault(),K())}}),e.jsx("button",{type:"button",disabled:!M.trim(),onClick:()=>{K()},children:s("projectSettings.addWord")})]}),e.jsxs("div",{className:"dictionary-words",children:[N.map(t=>e.jsxs("span",{className:"dictionary-word",children:[e.jsx("code",{children:t}),q&&e.jsx("button",{type:"button",title:s("common.delete"),"aria-label":`${s("common.delete")} ${t}`,onClick:()=>{ce(t)},children:e.jsx(V,{size:13})})]},t)),N.length===0&&e.jsx("span",{className:"dictionary-empty",children:s("projectSettings.dictionaryEmpty")})]}),e.jsx("div",{className:"settings-actions",children:e.jsxs("button",{className:"settings-save",onClick:_,children:[e.jsx(E,{size:15}),s("projectSettings.saveAppearance")]})})]}):e.jsxs("section",{id:"settings-panel-compiler",role:"tabpanel","aria-labelledby":"settings-tab-compiler",children:[e.jsxs("div",{className:"settings-section-title",children:[e.jsx(U,{size:15}),e.jsx("strong",{children:s("projectSettings.compilerTab")})]}),e.jsx("p",{className:"settings-description compiler-description",children:s("projectSettings.compilerDescription")}),e.jsxs("label",{children:[s("projects.name"),e.jsx("input",{disabled:!x,value:D,onChange:t=>I(t.target.value)})]}),e.jsxs("label",{children:[s("projectSettings.mainFile"),e.jsxs("select",{disabled:!x||v===null||v.length===0,value:b,onChange:t=>ee(t.target.value),children:[ie&&e.jsx("option",{value:b,disabled:!0,children:s("projectSettings.invalidMainFileOption",{path:b})}),se.map(t=>e.jsx("option",{value:t,children:t},t))]})]}),e.jsxs("label",{children:[s("projectSettings.engine"),e.jsx("select",{disabled:!x,value:O,onChange:t=>Y(t.target.value),children:(d.allowedEngines??["pdflatex","xelatex","lualatex"]).map(t=>e.jsx("option",{children:t},t))})]}),e.jsxs("label",{children:[s("projectSettings.latexmkrc"),e.jsx("textarea",{className:"latexmkrc-editor",rows:10,spellCheck:!1,disabled:!x||d.allowProjectLatexmkrc===!1,value:T,placeholder:s("projectSettings.latexmkrcPlaceholder"),onChange:t=>F(t.target.value)})]}),e.jsx("div",{className:"settings-actions",children:x&&e.jsxs("button",{className:"settings-save",onClick:()=>{J()},children:[e.jsx(E,{size:15}),s("projectSettings.saveCompiler")]})})]})]})]})}export{He as ProjectSettings};
1
+ import{u as oe,r,j as e}from"./react-BVUjbTTn.js";import{c as m,g as j,h as S,d as le}from"./index-B6rP7QsM.js";import{D as y,E as pe,S as E,G as U,I as de,J as he,A as xe,K as me}from"./ProjectWorkspace-mCYjyc6e.js";import{X as V,i as je,C as ge,d as ue}from"./x-DlFXD9Vl.js";import{T as B}from"./type-XvvfEJRs.js";import{S as be}from"./sigma-C0IvFdKV.js";import{R as Q}from"./refresh-cw-BoMEkk5J.js";import"./check-Jf8WBxDX.js";import"./search-UZspmceH.js";import"./user-plus-Chr9T97G.js";const ve=m("ChevronsLeft",[["path",{d:"m11 17-5-5 5-5",key:"13zhaf"}],["path",{d:"m18 17-5-5 5-5",key:"h8a8et"}]]);const Se=m("ChevronsRight",[["path",{d:"m6 17 5-5-5-5",key:"xnjwq"}],["path",{d:"m13 17 5-5-5-5",key:"17xmmf"}]]);const ye=m("CircleAlert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);const fe=m("MessageCircleQuestion",[["path",{d:"M7.9 20A9 9 0 1 0 4 16.1L2 22Z",key:"vv11sd"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);const ke=m("PanelsTopLeft",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M9 21V9",key:"1oto5p"}]]);const Ne=m("SpellCheck2",[["path",{d:"m6 16 6-12 6 12",key:"1b4byz"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"M4 21c1.1 0 1.1-1 2.3-1s1.1 1 2.3 1c1.1 0 1.1-1 2.3-1 1.1 0 1.1 1 2.3 1 1.1 0 1.1-1 2.3-1 1.1 0 1.1 1 2.3 1 1.1 0 1.1-1 2.3-1",key:"8mdmtu"}]]);const Ce=m("WrapText",[["line",{x1:"3",x2:"21",y1:"6",y2:"6",key:"4m8b97"}],["path",{d:"M3 12h15a3 3 0 1 1 0 6h-4",key:"1cl7v7"}],["polyline",{points:"16 16 14 18 16 20",key:"1jznyi"}],["line",{x1:"3",x2:"10",y1:"18",y2:"18",key:"1h33wv"}]]);function we({name:f,state:n,label:c,reloadLabel:d,onReload:k,compact:N=!1}){const g=n.status==="loading"?e.jsx(le,{className:"spin",size:14}):n.status==="working"?e.jsx(xe,{size:14}):e.jsx(ye,{size:14}),u=e.jsxs(e.Fragment,{children:[g,e.jsx("strong",{children:f}),e.jsx("span",{children:c}),n.status==="error"&&e.jsxs("button",{type:"button",className:"browser-tool-reload",title:d,"aria-label":d,onClick:k,children:[e.jsx(Q,{size:12}),d]})]});return N?e.jsxs("span",{className:`browser-tool-status compact ${n.status}`,role:"status","aria-live":"polite","aria-label":`${f}: ${c}`,title:n.error||void 0,children:[g,e.jsx("span",{children:c}),n.status==="error"&&e.jsx("button",{type:"button",className:"browser-tool-reload",title:d,"aria-label":d,onClick:k,children:e.jsx(Q,{size:12})})]}):e.jsx("div",{className:`browser-tool-status ${n.status}`,title:n.error||void 0,children:u})}function He({onClose:f,project:n,projectId:c,site:d,files:k,dictionaryWords:N,onDictionaryChange:g,editorPreferences:u,onEditorPreferences:G,spellCheckCount:l,spellCheckUniqueCount:X,spellCheckIndex:h,onSpellCheckNavigate:C,onProject:Z}){const{t:s}=oe(),[O,Y]=r.useState(n.engine),[T,F]=r.useState(""),[D,I]=r.useState(n.name),[b,ee]=r.useState(n.mainFile),[v,$]=r.useState(null),[P,z]=r.useState(""),[M,A]=r.useState(""),[H,w]=r.useState(""),[p,L]=r.useState("appearance"),[i,o]=r.useState(u),R=r.useSyncExternalStore(y.subscribe,y.getSnapshot,y.getSnapshot),x=n.permission==="owner",W=n.permission!=="read",q=n.permission!=="read";r.useEffect(()=>o(u),[u]),r.useEffect(()=>{pe().catch(y.failed)},[c]);const te=()=>{me().catch(y.failed)};r.useEffect(()=>{if(!n.latexmkrc)return F("");j(`/api/projects/${c}/file?path=${encodeURIComponent(n.latexmkrc)}`).then(({content:t})=>F(t)).catch(t=>z(S(t)))},[n.latexmkrc]),r.useEffect(()=>{if(p!=="compiler")return;const t=new AbortController;return $(null),j(`/api/projects/${c}/main-files`,{signal:t.signal}).then(a=>$(a.mainFiles)).catch(a=>{a instanceof Error&&a.name==="AbortError"||z(S(a))}),()=>t.abort()},[c,k,p]);const se=v??[n.mainFile],ie=v!==null&&!v.includes(b),J=async()=>{try{const t=T.trim()&&d.allowProjectLatexmkrc!==!1?".latexmkrc":null;t&&await j(`/api/projects/${c}/file`,{method:"PUT",body:JSON.stringify({path:t,content:T})});const a=await j(`/api/projects/${c}`,{method:"PATCH",body:JSON.stringify({name:D,mainFile:b,engine:O,latexmkrc:t})});Z(a.project)}catch(t){z(S(t))}},_=()=>G(i),ne=()=>{if(p==="appearance")return _();x&&J()},ae=s(p==="appearance"?"projectSettings.saveAppearance":"projectSettings.saveCompiler"),re=p==="appearance"||x,K=async()=>{const t=M.trim();if(t)try{const a=await j(`/api/projects/${c}/dictionary`,{method:"POST",body:JSON.stringify({word:t})});g(a.words),A(""),w("")}catch(a){w(S(a))}},ce=async t=>{try{const a=await j(`/api/projects/${c}/dictionary/${encodeURIComponent(t)}`,{method:"DELETE"});g(a.words),w("")}catch(a){w(S(a))}};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"drawer-title settings-drawer-title",children:[e.jsx("strong",{children:s("editor.projectSettings")}),e.jsxs("div",{className:"drawer-title-actions",children:[re&&e.jsxs("button",{type:"button",className:"drawer-settings-save",onClick:ne,children:[e.jsx(E,{size:14}),e.jsx("span",{children:ae})]}),e.jsx("button",{type:"button","aria-label":s("common.close"),onClick:f,children:e.jsx(V,{size:17})})]})]}),e.jsxs("div",{className:"settings padded",children:[P&&e.jsx("p",{className:"error",children:P}),e.jsxs("div",{className:"settings-tabs",role:"tablist","aria-label":s("common.settings"),children:[e.jsxs("button",{id:"settings-tab-appearance",type:"button",role:"tab","aria-selected":p==="appearance","aria-controls":"settings-panel-appearance",className:`settings-tab${p==="appearance"?" active":""}`,onClick:()=>L("appearance"),children:[e.jsx(B,{size:15}),s("projectSettings.editorTab")]}),e.jsxs("button",{id:"settings-tab-compiler",type:"button",role:"tab","aria-selected":p==="compiler","aria-controls":"settings-panel-compiler",className:`settings-tab${p==="compiler"?" active":""}`,onClick:()=>L("compiler"),children:[e.jsx(U,{size:15}),s("projectSettings.compilerTab")]})]}),p==="appearance"?e.jsxs("section",{id:"settings-panel-appearance",role:"tabpanel","aria-labelledby":"settings-tab-appearance",children:[e.jsxs("div",{className:"settings-section-title",children:[e.jsx(B,{size:15}),e.jsx("strong",{children:s("projectSettings.editorAppearance")})]}),e.jsx("p",{className:"settings-description appearance-description",children:s("projectSettings.editorAppearanceDescription")}),e.jsxs("label",{children:[s("projectSettings.fontFamily"),e.jsx("select",{value:i.font,onChange:t=>o({...i,font:t.target.value}),children:de.map(t=>e.jsx("option",{value:t.id,children:s(t.labelKey)},t.id))})]}),e.jsxs("label",{children:[s("projectSettings.fontSize"),e.jsx("select",{value:i.fontSize,onChange:t=>o({...i,fontSize:Number(t.target.value)}),children:[12,13,14,15,16,18,20].map(t=>e.jsxs("option",{value:t,children:[t," px"]},t))})]}),e.jsxs("label",{children:[s("projectSettings.lineHeight"),e.jsxs("select",{value:i.lineHeight,onChange:t=>o({...i,lineHeight:Number(t.target.value)}),children:[e.jsx("option",{value:1.45,children:s("projectSettings.lineHeightCompact")}),e.jsx("option",{value:1.65,children:s("projectSettings.lineHeightNormal")}),e.jsx("option",{value:1.85,children:s("projectSettings.lineHeightRelaxed")})]})]}),e.jsxs("label",{className:"editor-checkbox",children:[e.jsx("input",{type:"checkbox",checked:i.lineWrapping,onChange:t=>o({...i,lineWrapping:t.target.checked})}),e.jsx(Ce,{size:15}),e.jsx("span",{children:s("projectSettings.lineWrapping")})]}),e.jsxs("div",{className:"editor-preference",children:[e.jsxs("label",{className:"editor-checkbox",children:[e.jsx("input",{type:"checkbox",checked:i.showTooltips,onChange:t=>o({...i,showTooltips:t.target.checked})}),e.jsx(fe,{size:15}),e.jsx("span",{children:s("projectSettings.showTooltips")})]}),e.jsx("p",{className:"field-hint",children:s("projectSettings.showTooltipsDescription")})]}),e.jsxs("div",{className:"editor-preference",children:[e.jsxs("label",{className:"editor-checkbox",children:[e.jsx("input",{type:"checkbox",checked:i.mathPreviewOnHover,onChange:t=>o({...i,mathPreviewOnHover:t.target.checked})}),e.jsx(be,{size:15}),e.jsx("span",{children:s("projectSettings.mathPreviewOnHover")})]}),e.jsx("p",{className:"field-hint",children:s("projectSettings.mathPreviewOnHoverDescription")})]}),e.jsxs("div",{className:"editor-preference",children:[e.jsxs("label",{className:"editor-checkbox",children:[e.jsx("input",{type:"checkbox",checked:i.spellCheck,onChange:t=>o({...i,spellCheck:t.target.checked})}),e.jsx("span",{children:s("projectSettings.spellCheck")})]}),e.jsxs("p",{className:"field-hint",children:[s("projectSettings.writingCheckDescription")," ",e.jsx("a",{href:"https://writewithharper.com/docs/integrations/language-server",target:"_blank",rel:"noreferrer",children:"Harper"})]})]}),e.jsxs("div",{className:"editor-preference",children:[e.jsxs("label",{className:"editor-checkbox",children:[e.jsx("input",{type:"checkbox",checked:i.vimMode,onChange:t=>o({...i,vimMode:t.target.checked})}),e.jsx("span",{children:s("projectSettings.vimMode")})]}),e.jsxs("p",{className:"field-hint",children:[s("projectSettings.vimModeDescription")," ",e.jsx("a",{href:"https://replit-codemirror-vim.mintlify.app/",target:"_blank",rel:"noreferrer",children:s("projectSettings.vimHelp")})]})]}),e.jsxs("div",{className:"editor-preference",children:[e.jsxs("label",{className:"editor-checkbox",children:[e.jsx("input",{type:"checkbox",checked:i.openFilesInTabs,onChange:t=>o({...i,openFilesInTabs:t.target.checked})}),e.jsx(ke,{size:15}),e.jsx("span",{children:s("projectSettings.openFilesInTabs")})]}),e.jsx("p",{className:"field-hint",children:s("projectSettings.openFilesInTabsDescription")})]}),e.jsxs("div",{className:"editor-preference",children:[e.jsxs("label",{className:"editor-checkbox",children:[e.jsx("input",{type:"checkbox",disabled:!W,checked:i.formatOnCompile,onChange:t=>o({...i,formatOnCompile:t.target.checked})}),e.jsx(he,{size:15}),e.jsx("span",{children:s("projectSettings.formatOnCompile")})]}),e.jsxs("p",{className:"field-hint",children:[s(W?"projectSettings.formatOnCompileDescription":"projectSettings.formatRequiresWrite")," ",s("projectSettings.formatterDescription")," ",e.jsx("a",{href:"https://www.npmjs.com/package/tex-fmt",target:"_blank",rel:"noreferrer",children:s("projectSettings.formatterInstall")})," · ",e.jsx("a",{href:"https://github.com/FlamingTempura/bibtex-tidy",target:"_blank",rel:"noreferrer",children:s("projectSettings.bibtexTidyInstall")})]})]}),e.jsxs("div",{className:"editor-preference",children:[e.jsxs("label",{className:"tex-fmt-options-field",children:[e.jsxs("span",{className:"tex-fmt-options-heading",children:[e.jsx("span",{children:s("projectSettings.texFmtOptions")}),e.jsx(we,{compact:!0,name:"tex-fmt",state:R,label:s(`projectSettings.toolStatus.${R.status}`),reloadLabel:s("projectSettings.reloadTool"),onReload:te})]}),e.jsx("textarea",{className:"tex-fmt-options-editor",rows:6,maxLength:16*1024,spellCheck:!1,value:i.texFmtConfig,placeholder:s("projectSettings.texFmtOptionsPlaceholder"),onChange:t=>o({...i,texFmtConfig:t.target.value})})]}),e.jsx("p",{className:"field-hint",children:s("projectSettings.texFmtOptionsDescription")})]}),l!==null&&e.jsxs("div",{className:`spell-check-result${l?" has-issues":""}`,role:"status","aria-live":"polite",children:[e.jsx(Ne,{size:14}),e.jsx("span",{children:l?s("projectSettings.writingIssues",{count:l,uniqueCount:X??0}):s("projectSettings.noWritingIssues")}),l>0&&e.jsxs("span",{className:"spell-check-controls",children:[e.jsx("button",{type:"button",title:s("projectSettings.spellCheckFirst"),"aria-label":s("projectSettings.spellCheckFirst"),disabled:h<=0,onClick:()=>C(0),children:e.jsx(ve,{size:14})}),e.jsx("button",{type:"button",title:s("projectSettings.spellCheckPrevious"),"aria-label":s("projectSettings.spellCheckPrevious"),disabled:h<=0,onClick:()=>C(h-1),children:e.jsx(je,{size:14})}),e.jsx("span",{className:"spell-check-position",children:s("projectSettings.spellCheckPosition",{current:Math.min(h+1,l),total:l})}),e.jsx("button",{type:"button",title:s("projectSettings.spellCheckNext"),"aria-label":s("projectSettings.spellCheckNext"),disabled:h>=l-1,onClick:()=>C(h+1),children:e.jsx(ge,{size:14})}),e.jsx("button",{type:"button",title:s("projectSettings.spellCheckLast"),"aria-label":s("projectSettings.spellCheckLast"),disabled:h>=l-1,onClick:()=>C(l-1),children:e.jsx(Se,{size:14})})]})]}),e.jsxs("div",{className:"settings-section-title",children:[e.jsx(ue,{size:15}),e.jsx("strong",{children:s("projectSettings.dictionary")})]}),e.jsx("p",{className:"settings-description",children:s("projectSettings.dictionaryDescription")}),H&&e.jsx("p",{className:"error dictionary-error",children:H}),q&&e.jsxs("div",{className:"dictionary-add",children:[e.jsx("input",{value:M,placeholder:s("projectSettings.dictionaryPlaceholder"),onChange:t=>A(t.target.value),onKeyDown:t=>{t.key==="Enter"&&(t.preventDefault(),K())}}),e.jsx("button",{type:"button",disabled:!M.trim(),onClick:()=>{K()},children:s("projectSettings.addWord")})]}),e.jsxs("div",{className:"dictionary-words",children:[N.map(t=>e.jsxs("span",{className:"dictionary-word",children:[e.jsx("code",{children:t}),q&&e.jsx("button",{type:"button",title:s("common.delete"),"aria-label":`${s("common.delete")} ${t}`,onClick:()=>{ce(t)},children:e.jsx(V,{size:13})})]},t)),N.length===0&&e.jsx("span",{className:"dictionary-empty",children:s("projectSettings.dictionaryEmpty")})]}),e.jsx("div",{className:"settings-actions",children:e.jsxs("button",{className:"settings-save",onClick:_,children:[e.jsx(E,{size:15}),s("projectSettings.saveAppearance")]})})]}):e.jsxs("section",{id:"settings-panel-compiler",role:"tabpanel","aria-labelledby":"settings-tab-compiler",children:[e.jsxs("div",{className:"settings-section-title",children:[e.jsx(U,{size:15}),e.jsx("strong",{children:s("projectSettings.compilerTab")})]}),e.jsx("p",{className:"settings-description compiler-description",children:s("projectSettings.compilerDescription")}),e.jsxs("label",{children:[s("projects.name"),e.jsx("input",{disabled:!x,value:D,onChange:t=>I(t.target.value)})]}),e.jsxs("label",{children:[s("projectSettings.mainFile"),e.jsxs("select",{disabled:!x||v===null||v.length===0,value:b,onChange:t=>ee(t.target.value),children:[ie&&e.jsx("option",{value:b,disabled:!0,children:s("projectSettings.invalidMainFileOption",{path:b})}),se.map(t=>e.jsx("option",{value:t,children:t},t))]})]}),e.jsxs("label",{children:[s("projectSettings.engine"),e.jsx("select",{disabled:!x,value:O,onChange:t=>Y(t.target.value),children:(d.allowedEngines??["pdflatex","xelatex","lualatex"]).map(t=>e.jsx("option",{children:t},t))})]}),e.jsxs("label",{children:[s("projectSettings.latexmkrc"),e.jsx("textarea",{className:"latexmkrc-editor",rows:10,spellCheck:!1,disabled:!x||d.allowProjectLatexmkrc===!1,value:T,placeholder:s("projectSettings.latexmkrcPlaceholder"),onChange:t=>F(t.target.value)})]}),e.jsx("div",{className:"settings-actions",children:x&&e.jsxs("button",{className:"settings-save",onClick:()=>{J()},children:[e.jsx(E,{size:15}),s("projectSettings.saveCompiler")]})})]})]})]})}export{He as ProjectSettings};