texlite 0.14.0 → 0.16.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.
- package/DESIGN.md +94 -4
- package/README.md +5 -2
- package/README.zh-CN.md +5 -2
- package/dist/client/assets/AdminUsers-Dyapv-3c.js +1 -0
- package/dist/client/assets/CitationLibraryDialog-CU7Q7r0Z.js +1 -0
- package/dist/client/assets/Dashboard-DsdhFENx.js +2 -0
- package/dist/client/assets/GitDialog-CZpnKw-J.js +3 -0
- package/dist/client/assets/{GitHubAccountDialog-yUPMZj-e.js → GitHubAccountDialog-CZ8O_PjD.js} +1 -1
- package/dist/client/assets/{HistoryDialog-CZK-cFfU.js → HistoryDialog-DWYErBwj.js} +3 -3
- package/dist/client/assets/LatexEditor-CssVgypt.js +141 -0
- package/dist/client/assets/{PdfPreview-BqohZpfh.js → PdfPreview-BjghzUb1.js} +1 -1
- package/dist/client/assets/{ProjectIconPickerDialog-63_apW1i.js → ProjectIconPickerDialog-CqRmgFBM.js} +1 -1
- package/dist/client/assets/{ProjectNavigationDialogs-D8I4OJQB.js → ProjectNavigationDialogs-BZxI3PJO.js} +1 -1
- package/dist/client/assets/ProjectSettings-CZE_xDKn.js +1 -0
- package/dist/client/assets/ProjectWorkspace-CAX3qEYr.js +32 -0
- package/dist/client/assets/{SelectionHistoryDialog-DiYNdIe5.js → SelectionHistoryDialog-CR5c3I8k.js} +2 -2
- package/dist/client/assets/{SystemMetricsDialog-B9cIXfPM.js → SystemMetricsDialog-DDpFwgXh.js} +1 -1
- package/dist/client/assets/{TagManagementDialog-DqGTPckP.js → TagManagementDialog-CXLA9h_j.js} +1 -1
- package/dist/client/assets/WordCountDialog-DUyR24vv.js +1 -0
- package/dist/client/assets/check-CwBYzomT.js +1 -0
- package/dist/client/assets/chevron-up-D5lCNKlk.js +1 -0
- package/dist/client/assets/chktex-CRkLYKcV.js +3 -0
- package/dist/client/assets/{citationLibrary-ZeQPCv5O.js → citationLibrary-C9WnXB-1.js} +2 -2
- package/dist/client/assets/{external-link-DtHz2OWn.js → external-link-C9Td1CCj.js} +1 -1
- package/dist/client/assets/{github-B3ClW0wI.js → github-D-JDXb-w.js} +1 -1
- package/dist/client/assets/{hard-drive-A2DTDrXg.js → hard-drive-Ctj3K_zx.js} +1 -1
- package/dist/client/assets/{index-Bgr9VmTh.js → index-9hnQ8Q9x.js} +1 -1
- package/dist/client/assets/index-C0qg2Ylw.css +1 -0
- package/dist/client/assets/index-DkpU9Fgs.js +10 -0
- package/dist/client/assets/index-_eYe7K9T.js +1 -0
- package/dist/client/assets/{minimize-2-CjavrBs6.js → minimize-2-BiVyoWZA.js} +1 -1
- package/dist/client/assets/{minus-417bfmnF.js → minus-Bl8l4LXq.js} +1 -1
- package/dist/client/assets/{plus-CCRSrXDi.js → plus-CCxK-HNt.js} +1 -1
- package/dist/client/assets/react-CltQJflK.js +49 -0
- package/dist/client/assets/{refresh-cw-0bKWvgVy.js → refresh-cw-BE8IbaHI.js} +1 -1
- package/dist/client/assets/{search-DhHW3xg7.js → search-CPbhRWQE.js} +1 -1
- package/dist/client/assets/{sigma-ggAZwYZs.js → sigma-LxGD9tK2.js} +1 -1
- package/dist/client/assets/spellCheck-hpm8qZTr.js +1 -0
- package/dist/client/assets/{tags-jYRdvWMN.js → tags-DuN89PsZ.js} +1 -1
- package/dist/client/assets/{type-CZnTyitQ.js → type-BiettCiY.js} +1 -1
- package/dist/client/assets/{x-CUwbFgRb.js → x-C_3swJOC.js} +1 -1
- package/dist/client/index.html +4 -4
- package/dist/client/texlite-icon.svg +8 -0
- package/dist/server/anchors.js +57 -96
- package/dist/server/auth.js +0 -3
- package/dist/server/chktex.js +3 -4
- package/dist/server/collaboration.js +34 -1
- package/dist/server/db.js +9 -1
- package/dist/server/i18n.js +4 -0
- package/dist/server/latexCompletion.js +11 -88
- package/dist/server/projectOutline.js +4 -39
- package/dist/server/projectSearch.js +0 -4
- package/dist/server/routes/citations.js +22 -0
- package/dist/server/routes/comments.js +4 -4
- package/dist/server/routes/projectShared.js +11 -2
- package/dist/server/routes/users.js +21 -3
- package/dist/shared/bibtexReferences.js +5 -1
- package/dist/shared/latexCompletion.js +1 -0
- package/dist/shared/latexReferences.js +13 -3
- package/dist/shared/latexSymbols.js +77 -0
- package/dist/shared/sourceCommentAnchors.js +128 -0
- package/package.json +1 -1
- package/dist/client/assets/AdminUsers-BMwfVHyu.js +0 -1
- package/dist/client/assets/CitationLibraryDialog-D_GkXecF.js +0 -1
- package/dist/client/assets/Dashboard-DhKiB4Lp.js +0 -2
- package/dist/client/assets/GitDialog-DHwqaGWR.js +0 -3
- package/dist/client/assets/LatexEditor-BuLjoc1X.js +0 -141
- package/dist/client/assets/ProjectSettings-ChIKBc0N.js +0 -1
- package/dist/client/assets/ProjectWorkspace-D8vBa8aq.js +0 -32
- package/dist/client/assets/WordCountDialog-B0pBzLsg.js +0 -1
- package/dist/client/assets/check-6jrUH-ay.js +0 -1
- package/dist/client/assets/chktex-Cp2H8q1t.js +0 -3
- package/dist/client/assets/index-DNQd-LXW.css +0 -1
- package/dist/client/assets/index-DprUq41V.js +0 -10
- package/dist/client/assets/react-BVUjbTTn.js +0 -49
- package/dist/client/assets/spellCheck-JOkkBKD7.js +0 -1
- package/dist/client/assets/user-plus-DFkFh0mU.js +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import{u as He,r as a,j as e}from"./react-
|
|
1
|
+
import{u as He,r as a,j as e}from"./react-CltQJflK.js";import{c as Be,g as _,M as Ve,d as le,C as Ce,A as we}from"./index-DkpU9Fgs.js";import{d as _e,C as $e}from"./index-9hnQ8Q9x.js";import{H as Ie}from"./hard-drive-Ctj3K_zx.js";import{T as Se,c as Oe,e as ue}from"./x-C_3swJOC.js";import{F as Te,R as Ee,S as Ue,C as We}from"./ProjectWorkspace-CAX3qEYr.js";import{M as Ye,a as qe}from"./minus-Bl8l4LXq.js";import{P as Ge}from"./plus-CCxK-HNt.js";import{M as Je}from"./minimize-2-BiVyoWZA.js";import"./chevron-up-D5lCNKlk.js";import"./check-CwBYzomT.js";import"./search-CPbhRWQE.js";import"./index-_eYe7K9T.js";import"./refresh-cw-BE8IbaHI.js";const Ke=Be("Tag",[["path",{d:"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z",key:"vktsd0"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}]]);function Fe(i,c,C,j="历史版本",s="当前版本",p=3){const S=c.replace(/\r\n/g,`
|
|
2
2
|
`),R=C.replace(/\r\n/g,`
|
|
3
3
|
`);if(S===R)return{diffText:"",additions:0,deletions:0,hasChanges:!1};const h=new _e,k=h.diff_linesToChars_(S,R),b=h.diff_main(k.chars1,k.chars2,!1);h.diff_charsToLines_(b,k.lineArray);const w=[];let n=1,T=1,u=0,z=0;for(const[d,v]of b){if(!v)continue;const f=v.split(`
|
|
4
4
|
`);f[f.length-1]===""&&f.pop();for(const A of f)d===0?w.push({op:0,text:A,oldNum:n++,newNum:T++}):d===-1?(z++,w.push({op:-1,text:A,oldNum:n++,newNum:T})):d===1&&(u++,w.push({op:1,text:A,oldNum:n,newNum:T++}))}if(u===0&&z===0)return{diffText:"",additions:0,deletions:0,hasChanges:!1};const g=[];let y=-1,P=-1;for(let d=0;d<w.length;d++)if(w[d].op!==0){const v=Math.max(0,d-p),f=Math.min(w.length-1,d+p);y===-1?(y=v,P=f):v<=P+1?P=Math.max(P,f):(g.push({start:y,end:P}),y=v,P=f)}y!==-1&&g.push({start:y,end:P});const G=[`--- a/${i} (${j})`,`+++ b/${i} (${s})`];for(const d of g){const v=w.slice(d.start,d.end+1),f=v.filter($=>$.op<=0).length,A=v.filter($=>$.op>=0).length,E=v[0],O=f===0?0:E.oldNum,J=A===0?0:E.newNum;G.push(`@@ -${O},${f} +${J},${A} @@`);for(const $ of v){const U=$.op===-1?"-":$.op===1?"+":" ";G.push(`${U}${$.text}`)}}return{diffText:G.join(`
|
|
5
|
-
`),additions:u,deletions:z,hasChanges:!0}}function me(i,c){try{const C=new Date(i);if(Number.isNaN(C.getTime()))return i;const j=new Date;return C.getFullYear()===j.getFullYear()&&C.getMonth()===j.getMonth()&&C.getDate()===j.getDate()?C.toLocaleTimeString(c,{hour:"2-digit",minute:"2-digit"}):C.toLocaleString(c,{month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit"})}catch{return i}}function fe(i,c,C){if(i.label)return i.label;const j=me(i.createdAt,C);if(i.changedPaths.length===1)return`${i.changedPaths[0].split("/").pop()||i.changedPaths[0]} (${j})`;if(i.changedPaths.length===2){const p=i.changedPaths[0].split("/").pop()||i.changedPaths[0],S=i.changedPaths[1].split("/").pop()||i.changedPaths[1];return`${p}, ${S} (${j})`}if(i.changedPaths.length>2)return`${i.changedPaths[0].split("/").pop()||i.changedPaths[0]} +${i.changedPaths.length-1} (${j})`;const s=i.author?.name||i.author?.username;return s?`${s} @ ${j}`:`${c} (${j})`}function Ze(i){const c=i.split("/").at(-1)??"";return/\.(?:tex|bib|bst|sty|cls|txt|md|rst|dat|csv|tsv|json|ya?ml|toml|xml|html?|css|[cm]?js|tsx?|py|sh|r|log|bbl|aux|idx|ind|gls)$/i.test(c)||/^(?:\.?latexmkrc|readme|licen[cs]e|makefile)$/i.test(c)}const De=100;function ht({open:i,project:c,onOpenChange:C,onBeforeMutation:j}){const{t:s,i18n:p}=He(),[S,R]=a.useState([]),[h,k]=a.useState(null),[b,w]=a.useState(""),[n,T]=a.useState(null),[u,z]=a.useState(""),[g,y]=a.useState(null),[P,G]=a.useState(0),[d,v]=a.useState("commit"),[f,A]=a.useState(11),[E,O]=a.useState(!1),[J,$]=a.useState(""),[U,te]=a.useState(null),[M,se]=a.useState(null),[K,m]=a.useState(""),[pe,re]=a.useState(null),[Z,ie]=a.useState(!1),[ge,x]=a.useState(""),ce=a.useRef(null),F=a.useRef(null),D=a.useRef(null),ye=a.useRef(b),xe=a.useRef(c.id),ne=a.useRef(!1),H=a.useRef(null);ye.current=b,xe.current=c.id;const ae=c.permission!=="read",de=c.permission==="owner",W=!!K||Z;a.useEffect(()=>{if(!i){D.current?.abort(),D.current=null,H.current!==null&&window.clearTimeout(H.current),H.current=null,F.current?.abort(),F.current=null,ie(!1),document.fullscreenElement&&document.exitFullscreen().catch(()=>{}),O(!1);return}F.current?.abort(),F.current=null;const t=new AbortController;return m("load"),x(""),y(null),re(null),ie(!1),_(`/api/projects/${c.id}/history?limit=${De}`,{signal:t.signal}).then(r=>{R(r.versions),k(r.stats),re(r.nextCursor),w(l=>r.versions.some(o=>o.id===l)?l:r.versions[0]?.id??"")}).catch(r=>{q(r)||x(I(r))}).finally(()=>{t.signal.aborted||m("")}),()=>t.abort()},[i,c.id]),a.useEffect(()=>()=>{F.current?.abort(),F.current=null,D.current?.abort(),D.current=null,H.current!==null&&window.clearTimeout(H.current)},[c.id]),a.useEffect(()=>{D.current?.abort(),D.current=null},[b]);const Le=async()=>{const t=pe;if(!t||Z||K)return;F.current?.abort();const r=new AbortController;F.current=r,ie(!0),x("");try{const l=new URLSearchParams({limit:String(De),before:t}),o=await _(`/api/projects/${c.id}/history?${l.toString()}`,{signal:r.signal});if(r.signal.aborted)return;R(N=>{const V=new Set(N.map(L=>L.id));return[...N,...o.versions.filter(L=>!V.has(L.id))]}),k(o.stats),re(o.nextCursor)}catch(l){q(l)||x(I(l))}finally{F.current===r&&(F.current=null,ie(!1))}};a.useEffect(()=>{const t=()=>O(document.fullscreenElement===ce.current);return document.addEventListener("fullscreenchange",t),()=>document.removeEventListener("fullscreenchange",t)},[]),a.useEffect(()=>{if(!E)return;const t=r=>{r.key==="Escape"&&!document.fullscreenElement&&O(!1)};return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[E]),a.useEffect(()=>{if(!i||!b){T(null);return}const t=new AbortController;return m("detail"),y(null),_(`/api/projects/${c.id}/history/${b}`,{signal:t.signal}).then(r=>{if(t.signal.aborted)return;T(r),$(r.version.label??"");const l=r.version.changedPaths.find(o=>r.files.some(N=>N.path===o))??"";z(l)}).catch(r=>{!t.signal.aborted&&!q(r)&&x(I(r))}).finally(()=>{t.signal.aborted||m(r=>r==="detail"?"":r)}),()=>t.abort()},[i,c.id,b]);const Y=g?.previousVersion??null,he=Ze(u),je=n?.files.find(t=>t.path===u)?.deleted===!0;a.useEffect(()=>{if(!i||!b||!u||!he){ne.current=!1,y(null),m(o=>o==="compare"?"":o);return}const t=new AbortController;y(null),m("compare");const r=ne.current;ne.current=!1,r||x("");const l=d==="commit"?"&against=__previous__":"";return _(`/api/projects/${c.id}/history/${b}/file?path=${encodeURIComponent(u)}${l}`,{signal:t.signal}).then(o=>{t.signal.aborted||y(o)}).catch(o=>{!t.signal.aborted&&!q(o)&&x(I(o))}).finally(()=>{t.signal.aborted||m(o=>o==="compare"?"":o)}),()=>t.abort()},[i,c.id,b,u,he,d,P]);const B=a.useMemo(()=>{if(!n)return[];const t=new Set(n.version.changedPaths);return n.files.filter(r=>t.has(r.path))},[n]);a.useEffect(()=>{B.length>0&&!B.some(t=>t.path===u)?z(B[0].path):B.length===0&&u&&z("")},[B,u]);const Re=async()=>{if(E){document.fullscreenElement&&await document.exitFullscreen().catch(()=>{}),O(!1);return}const t=ce.current;if(t?.requestFullscreen)try{await t.requestFullscreen()}catch{}O(!0)},be=async(t,r=!1)=>{const l=c.id;D.current?.abort();const o=new AbortController;D.current=o;try{const N=await _(`/api/projects/${l}/history/${t}`,{signal:o.signal});return o.signal.aborted||xe.current!==l||ye.current!==t?!1:(T(N),$(N.version.label??""),z(V=>V&&N.files.some(L=>L.path===V)?V:N.version.changedPaths.find(L=>N.files.some(Me=>Me.path===L))??""),y(null),r&&(ne.current=!0),G(V=>V+1),R(V=>V.map(L=>L.id===N.version.id?N.version:L)),!0)}finally{D.current===o&&(D.current=null)}},ke=async()=>{if(n){m("label"),x("");try{const t=await _(`/api/projects/${c.id}/history/${n.version.id}`,{method:"PATCH",body:JSON.stringify({label:J.trim()||null,snapshotHash:n.version.snapshotHash})});T(r=>r&&{...r,version:t.version}),R(r=>r.map(l=>l.id===t.version.id?t.version:l)),k(t.stats),t.retentionScheduled&&(H.current!==null&&window.clearTimeout(H.current),H.current=window.setTimeout(()=>{H.current=null,_(`/api/projects/${c.id}/history?limit=1`).then(r=>{k(r.stats)}).catch(()=>{})},t.retentionRefreshAfterMs))}catch(t){if(t instanceof we&&t.code==="HISTORY_VERSION_CHANGED")try{if(!await be(n.version.id,!0))return}catch(r){if(q(r))return;x(I(r));return}x(I(t))}finally{m("")}}},ze=async()=>{const t=M;if(t){se(null),m("delete"),x("");try{if(!await j())throw new Error(s("errors.collaborationUnavailable"));const r=t==="all"?`/api/projects/${c.id}/history`:`/api/projects/${c.id}/history/${t.id}`,l=await _(r,{method:"DELETE"});if(k(l.stats),t==="all")R([]),w(""),T(null),y(null),re(null);else{const o=S.filter(N=>N.id!==t.id);R(o),b===t.id&&(w(o[0]?.id??""),T(null),y(null))}}catch(r){x(I(r))}finally{m("")}}},Pe=async()=>{const t=U;if(!(!t||!n)){te(null),m("restore"),x("");try{if(!await j())throw new Error(s("errors.collaborationUnavailable"));await _(`/api/projects/${c.id}/history/${n.version.id}/restore`,{method:"POST",body:JSON.stringify(t==="project"?{snapshotHash:n.version.snapshotHash}:{path:t,snapshotHash:n.version.snapshotHash})}),window.location.reload()}catch(r){if(r instanceof we&&r.code==="HISTORY_VERSION_CHANGED")try{if(!await be(n.version.id,!0)){m("");return}}catch(l){if(q(l)){m("");return}x(I(l)),m("");return}x(I(r)),m("")}}},oe=n?.version.author?.name||n?.version.author?.username||(n?.version.reason==="autosave"?s("history.reasons.autosave"):s("editor.deletedUser")),Q=n?me(n.version.createdAt,p.resolvedLanguage):"",X=a.useMemo(()=>{if(!g||!n)return{diffText:"",additions:0,deletions:0,hasChanges:!1};if(d==="commit"){const t=g.comparison,r=g.historical,l=Y?`${Y.label||s(`history.reasons.${Y.reason}`)} (${me(Y.createdAt,p.resolvedLanguage)})`:"/dev/null",o=`${oe} @ ${Q}`;return Fe(g.path,t,r,l,o)}else{const t=g.historical,r=g.comparison,l=`${n.version.label||s(`history.reasons.${n.version.reason}`)} (${Q})`,o=s("history.currentVersion");return Fe(g.path,t,r,l,o)}},[g,n,d,Y,oe,Q,s,p.resolvedLanguage]),ve=n?s(`history.reasons.${n.version.reason}`):"",Ne=n?fe(n.version,ve,p.resolvedLanguage):"",Ae=M&&M!=="all"?fe(M,s(`history.reasons.${M.reason}`),p.resolvedLanguage):"";return e.jsxs(e.Fragment,{children:[e.jsx(Ve,{open:i,extraWide:!0,draggable:!0,className:"history-dialog-modal",title:s("history.projectSnapshots"),description:s("history.description"),onOpenChange:C,footer:e.jsx("button",{onClick:()=>C(!1),children:s("common.close")}),children:e.jsxs("div",{className:"history-dialog",children:[ge&&e.jsx("p",{className:"error history-message",children:ge}),K==="load"&&S.length===0?e.jsxs("div",{className:"history-loading",children:[e.jsx(le,{className:"spin",size:22}),s("common.loading")]}):e.jsxs("div",{className:"history-dialog-layout",children:[e.jsxs("aside",{className:"history-timeline",children:[de&&h&&e.jsxs("div",{className:`history-stats${h.storageLimitExceeded?" exceeded":""}`,children:[e.jsxs("header",{children:[e.jsxs("span",{children:[e.jsx(Ie,{size:14}),s("history.storage")]}),e.jsx("button",{type:"button",disabled:W||S.length===0,title:s("history.clearAll"),"aria-label":s("history.clearAll"),onClick:()=>se("all"),children:e.jsx(Se,{size:13})})]}),e.jsx("strong",{children:s("history.storageUsage",{used:ee(h.totalBytes),limit:ee(h.maxStorageBytes)})}),e.jsx("progress",{max:h.maxStorageBytes,value:Math.min(h.totalBytes,h.maxStorageBytes)}),e.jsx("small",{children:s("history.storageBreakdown",{objects:ee(h.objectBytes),metadata:ee(h.metadataBytes),protected:ee(h.protectedBytes)})}),e.jsxs("small",{children:[s("history.versionUsage",{count:h.ordinaryVersionCount,limit:h.maxVersions>0?h.maxVersions:"∞"}),h.labeledVersionCount>0?` · ${s("history.protectedVersions",{count:h.labeledVersionCount})}`:""]}),h.storageLimitExceeded&&e.jsx("small",{className:"history-storage-warning",children:s("history.storageExceeded")})]}),S.map(t=>{const r=s(`history.reasons.${t.reason}`),l=fe(t,r,p.resolvedLanguage),o=t.author?.name||t.author?.username||(t.reason==="autosave"?s("history.reasons.autosave"):s("editor.deletedUser"));return e.jsxs("button",{className:t.id===b?"active":"",onClick:()=>w(t.id),children:[e.jsx(Te,{size:15}),e.jsxs("span",{children:[e.jsxs("div",{className:"history-item-heading",children:[e.jsx("strong",{title:l,children:l}),e.jsx("span",{className:`history-reason-badge reason-${t.reason}`,children:r})]}),e.jsx("small",{children:new Date(t.createdAt).toLocaleString(p.resolvedLanguage)}),e.jsxs("small",{children:[o," · ",s("history.changedCount",{count:t.changedPaths.length})]})]})]},t.id)}),pe&&e.jsx("div",{className:"history-load-more",children:e.jsxs("button",{type:"button",disabled:W,"aria-busy":Z,onClick:()=>{Le()},children:[Z?e.jsx(le,{className:"spin",size:13}):e.jsx($e,{size:13}),s(Z?"common.loading":"history.loadOlder")]})}),S.length===0&&e.jsx("p",{className:"muted padded",children:s("history.empty")})]}),e.jsx("section",{className:"history-detail",children:n&&e.jsxs(e.Fragment,{children:[e.jsx("header",{className:"history-detail-header",children:e.jsxs("div",{children:[e.jsxs("div",{className:"history-detail-title-row",children:[e.jsx("strong",{title:Ne,children:Ne}),e.jsx("span",{className:`history-reason-badge reason-${n.version.reason}`,children:ve})]}),e.jsxs("small",{children:[e.jsx($e,{size:12}),new Date(n.version.createdAt).toLocaleString(p.resolvedLanguage)," · ",oe," · ",s("history.fileCount",{count:n.version.fileCount})]})]})}),(de||ae)&&e.jsxs("div",{className:"history-snapshot-actions",children:[de&&e.jsxs("button",{type:"button",className:"history-delete-action",disabled:W,title:s("history.deleteVersionTitle"),onClick:()=>se(n.version),children:[e.jsx(Se,{size:14}),s("history.deleteVersion")]}),ae&&e.jsxs("button",{type:"button",className:"history-restore-project",disabled:W,title:s("history.restoreProjectTitle"),onClick:()=>te("project"),children:[e.jsx(Ee,{size:14}),s("history.restoreProject")]})]}),ae&&e.jsxs("div",{className:"history-label",children:[e.jsxs("label",{children:[e.jsx(Ke,{size:14}),e.jsx("input",{value:J,maxLength:80,placeholder:s("history.labelPlaceholder"),onChange:t=>$(t.target.value)})]}),e.jsxs("button",{disabled:W||J.trim()===(n.version.label??""),onClick:()=>{ke()},children:[K==="label"?e.jsx(le,{className:"spin",size:13}):e.jsx(Ue,{size:13}),s("history.saveLabel")]})]}),e.jsxs("div",{className:"history-files",children:[e.jsx("div",{className:"history-files-toolbar",children:e.jsxs("div",{className:"history-files-heading",children:[e.jsx(Oe,{size:13}),e.jsx("span",{children:s("history.changedFilesHeading",{count:B.length})})]})}),B.length>0?e.jsxs("div",{className:"history-file-tabs-row",children:[e.jsx("div",{className:"history-file-list",children:B.map(t=>e.jsxs("button",{type:"button",className:t.path===u?"active":"",title:t.path,onClick:()=>z(t.path),children:[e.jsx(ue,{size:13}),e.jsx("span",{children:t.path})]},t.path))}),ae&&e.jsx("div",{className:"history-file-actions",children:e.jsxs("button",{type:"button",disabled:!u||je||W,title:s("history.restoreFileTitle"),onClick:()=>te(u),children:[e.jsx(Ee,{size:13}),s("history.restoreFile")]})})]}):e.jsx("p",{className:"muted padded-small",children:s("history.noChangedFiles")})]}),u&&!he?e.jsxs("p",{className:"history-attachment-change",children:[e.jsx(ue,{size:14}),e.jsx("span",{children:s(je?"history.nonTextFileDeleted":"history.nonTextFileChanged",{path:u})})]}):e.jsx("div",{ref:ce,className:`history-comparison${E?" is-fullscreen":""}`,children:u?e.jsxs(e.Fragment,{children:[e.jsxs("header",{children:[e.jsxs("div",{className:"history-comparison-meta",children:[e.jsx("strong",{children:u}),e.jsxs("small",{className:"history-commit-summary",children:[d==="commit"?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"history-commit-author",children:oe}),e.jsx("span",{children:Y?s("history.changedAt",{time:Q}):s("history.createdAt",{time:Q})})]}):e.jsx("span",{children:s("history.comparingCurrent")}),X.hasChanges&&e.jsxs("span",{className:"history-diff-stats",children:[e.jsxs("span",{className:"addition",children:["+",X.additions]})," ",e.jsxs("span",{className:"deletion",children:["-",X.deletions]})]})]})]}),e.jsxs("div",{className:"history-diff-controls",children:[e.jsx("div",{className:"history-diff-control-group",children:e.jsxs("div",{className:"history-mode-toggle",role:"group","aria-label":s("history.diffMode"),children:[e.jsx("button",{type:"button",className:d==="commit"?"active":"","aria-pressed":d==="commit",onClick:()=>v("commit"),title:s("history.diffModeCommitHint"),children:e.jsx("span",{children:s("history.diffModeCommit")})}),e.jsx("button",{type:"button",className:d==="current"?"active":"","aria-pressed":d==="current",onClick:()=>v("current"),title:s("history.diffModeCurrentHint"),children:e.jsx("span",{children:s("history.diffModeCurrent")})})]})}),e.jsx("span",{className:"history-diff-control-divider","aria-hidden":"true"}),e.jsx("div",{className:"history-diff-control-group",children:e.jsxs("div",{className:"git-diff-font-controls",role:"group","aria-label":s("git.diffFontSize"),children:[e.jsx("button",{type:"button",className:"git-diff-font-button",disabled:f<=8,title:s("git.diffFontDecrease"),"aria-label":s("git.diffFontDecrease"),onClick:()=>A(t=>Math.max(8,t-1)),children:e.jsx(Ye,{size:14})}),e.jsxs("span",{className:"git-diff-font-value","aria-live":"polite",children:[f,"px"]}),e.jsx("button",{type:"button",className:"git-diff-font-button",disabled:f>=24,title:s("git.diffFontIncrease"),"aria-label":s("git.diffFontIncrease"),onClick:()=>A(t=>Math.min(24,t+1)),children:e.jsx(Ge,{size:14})})]})}),e.jsx("span",{className:"history-diff-control-divider","aria-hidden":"true"}),e.jsx("div",{className:"history-diff-control-group",children:e.jsx("button",{type:"button",className:"git-diff-fullscreen",title:s(E?"git.exitFullscreenDiff":"git.fullscreenDiff"),"aria-label":s(E?"git.exitFullscreenDiff":"git.fullscreenDiff"),onClick:()=>{Re()},children:E?e.jsx(Je,{size:15}):e.jsx(qe,{size:15})})})]})]}),K==="compare"&&!g?e.jsxs("div",{className:"history-comparison-empty",children:[e.jsx(le,{className:"spin",size:24}),e.jsx("span",{children:s("common.loading")})]}):g?X.hasChanges?e.jsx("pre",{className:"git-diff history-git-diff",style:{fontSize:`${f}px`},children:X.diffText.split(`
|
|
5
|
+
`),additions:u,deletions:z,hasChanges:!0}}function me(i,c){try{const C=new Date(i);if(Number.isNaN(C.getTime()))return i;const j=new Date;return C.getFullYear()===j.getFullYear()&&C.getMonth()===j.getMonth()&&C.getDate()===j.getDate()?C.toLocaleTimeString(c,{hour:"2-digit",minute:"2-digit"}):C.toLocaleString(c,{month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit"})}catch{return i}}function fe(i,c,C){if(i.label)return i.label;const j=me(i.createdAt,C);if(i.changedPaths.length===1)return`${i.changedPaths[0].split("/").pop()||i.changedPaths[0]} (${j})`;if(i.changedPaths.length===2){const p=i.changedPaths[0].split("/").pop()||i.changedPaths[0],S=i.changedPaths[1].split("/").pop()||i.changedPaths[1];return`${p}, ${S} (${j})`}if(i.changedPaths.length>2)return`${i.changedPaths[0].split("/").pop()||i.changedPaths[0]} +${i.changedPaths.length-1} (${j})`;const s=i.author?.name||i.author?.username;return s?`${s} @ ${j}`:`${c} (${j})`}function Ze(i){const c=i.split("/").at(-1)??"";return/\.(?:tex|bib|bst|sty|cls|txt|md|rst|dat|csv|tsv|json|ya?ml|toml|xml|html?|css|[cm]?js|tsx?|py|sh|r|log|bbl|aux|idx|ind|gls)$/i.test(c)||/^(?:\.?latexmkrc|readme|licen[cs]e|makefile)$/i.test(c)}const De=100;function ut({open:i,project:c,onOpenChange:C,onBeforeMutation:j}){const{t:s,i18n:p}=He(),[S,R]=a.useState([]),[h,k]=a.useState(null),[b,w]=a.useState(""),[n,T]=a.useState(null),[u,z]=a.useState(""),[g,y]=a.useState(null),[P,G]=a.useState(0),[d,v]=a.useState("commit"),[f,A]=a.useState(11),[E,O]=a.useState(!1),[J,$]=a.useState(""),[U,te]=a.useState(null),[M,se]=a.useState(null),[K,m]=a.useState(""),[pe,re]=a.useState(null),[Z,ie]=a.useState(!1),[ge,x]=a.useState(""),ce=a.useRef(null),F=a.useRef(null),D=a.useRef(null),ye=a.useRef(b),xe=a.useRef(c.id),ne=a.useRef(!1),H=a.useRef(null);ye.current=b,xe.current=c.id;const ae=c.permission!=="read",de=c.permission==="owner",W=!!K||Z;a.useEffect(()=>{if(!i){D.current?.abort(),D.current=null,H.current!==null&&window.clearTimeout(H.current),H.current=null,F.current?.abort(),F.current=null,ie(!1),document.fullscreenElement&&document.exitFullscreen().catch(()=>{}),O(!1);return}F.current?.abort(),F.current=null;const t=new AbortController;return m("load"),x(""),y(null),re(null),ie(!1),_(`/api/projects/${c.id}/history?limit=${De}`,{signal:t.signal}).then(r=>{R(r.versions),k(r.stats),re(r.nextCursor),w(l=>r.versions.some(o=>o.id===l)?l:r.versions[0]?.id??"")}).catch(r=>{q(r)||x(I(r))}).finally(()=>{t.signal.aborted||m("")}),()=>t.abort()},[i,c.id]),a.useEffect(()=>()=>{F.current?.abort(),F.current=null,D.current?.abort(),D.current=null,H.current!==null&&window.clearTimeout(H.current)},[c.id]),a.useEffect(()=>{D.current?.abort(),D.current=null},[b]);const Le=async()=>{const t=pe;if(!t||Z||K)return;F.current?.abort();const r=new AbortController;F.current=r,ie(!0),x("");try{const l=new URLSearchParams({limit:String(De),before:t}),o=await _(`/api/projects/${c.id}/history?${l.toString()}`,{signal:r.signal});if(r.signal.aborted)return;R(N=>{const V=new Set(N.map(L=>L.id));return[...N,...o.versions.filter(L=>!V.has(L.id))]}),k(o.stats),re(o.nextCursor)}catch(l){q(l)||x(I(l))}finally{F.current===r&&(F.current=null,ie(!1))}};a.useEffect(()=>{const t=()=>O(document.fullscreenElement===ce.current);return document.addEventListener("fullscreenchange",t),()=>document.removeEventListener("fullscreenchange",t)},[]),a.useEffect(()=>{if(!E)return;const t=r=>{r.key==="Escape"&&!document.fullscreenElement&&O(!1)};return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[E]),a.useEffect(()=>{if(!i||!b){T(null);return}const t=new AbortController;return m("detail"),y(null),_(`/api/projects/${c.id}/history/${b}`,{signal:t.signal}).then(r=>{if(t.signal.aborted)return;T(r),$(r.version.label??"");const l=r.version.changedPaths.find(o=>r.files.some(N=>N.path===o))??"";z(l)}).catch(r=>{!t.signal.aborted&&!q(r)&&x(I(r))}).finally(()=>{t.signal.aborted||m(r=>r==="detail"?"":r)}),()=>t.abort()},[i,c.id,b]);const Y=g?.previousVersion??null,he=Ze(u),je=n?.files.find(t=>t.path===u)?.deleted===!0;a.useEffect(()=>{if(!i||!b||!u||!he){ne.current=!1,y(null),m(o=>o==="compare"?"":o);return}const t=new AbortController;y(null),m("compare");const r=ne.current;ne.current=!1,r||x("");const l=d==="commit"?"&against=__previous__":"";return _(`/api/projects/${c.id}/history/${b}/file?path=${encodeURIComponent(u)}${l}`,{signal:t.signal}).then(o=>{t.signal.aborted||y(o)}).catch(o=>{!t.signal.aborted&&!q(o)&&x(I(o))}).finally(()=>{t.signal.aborted||m(o=>o==="compare"?"":o)}),()=>t.abort()},[i,c.id,b,u,he,d,P]);const B=a.useMemo(()=>{if(!n)return[];const t=new Set(n.version.changedPaths);return n.files.filter(r=>t.has(r.path))},[n]);a.useEffect(()=>{B.length>0&&!B.some(t=>t.path===u)?z(B[0].path):B.length===0&&u&&z("")},[B,u]);const Re=async()=>{if(E){document.fullscreenElement&&await document.exitFullscreen().catch(()=>{}),O(!1);return}const t=ce.current;if(t?.requestFullscreen)try{await t.requestFullscreen()}catch{}O(!0)},be=async(t,r=!1)=>{const l=c.id;D.current?.abort();const o=new AbortController;D.current=o;try{const N=await _(`/api/projects/${l}/history/${t}`,{signal:o.signal});return o.signal.aborted||xe.current!==l||ye.current!==t?!1:(T(N),$(N.version.label??""),z(V=>V&&N.files.some(L=>L.path===V)?V:N.version.changedPaths.find(L=>N.files.some(Me=>Me.path===L))??""),y(null),r&&(ne.current=!0),G(V=>V+1),R(V=>V.map(L=>L.id===N.version.id?N.version:L)),!0)}finally{D.current===o&&(D.current=null)}},ke=async()=>{if(n){m("label"),x("");try{const t=await _(`/api/projects/${c.id}/history/${n.version.id}`,{method:"PATCH",body:JSON.stringify({label:J.trim()||null,snapshotHash:n.version.snapshotHash})});T(r=>r&&{...r,version:t.version}),R(r=>r.map(l=>l.id===t.version.id?t.version:l)),k(t.stats),t.retentionScheduled&&(H.current!==null&&window.clearTimeout(H.current),H.current=window.setTimeout(()=>{H.current=null,_(`/api/projects/${c.id}/history?limit=1`).then(r=>{k(r.stats)}).catch(()=>{})},t.retentionRefreshAfterMs))}catch(t){if(t instanceof we&&t.code==="HISTORY_VERSION_CHANGED")try{if(!await be(n.version.id,!0))return}catch(r){if(q(r))return;x(I(r));return}x(I(t))}finally{m("")}}},ze=async()=>{const t=M;if(t){se(null),m("delete"),x("");try{if(!await j())throw new Error(s("errors.collaborationUnavailable"));const r=t==="all"?`/api/projects/${c.id}/history`:`/api/projects/${c.id}/history/${t.id}`,l=await _(r,{method:"DELETE"});if(k(l.stats),t==="all")R([]),w(""),T(null),y(null),re(null);else{const o=S.filter(N=>N.id!==t.id);R(o),b===t.id&&(w(o[0]?.id??""),T(null),y(null))}}catch(r){x(I(r))}finally{m("")}}},Pe=async()=>{const t=U;if(!(!t||!n)){te(null),m("restore"),x("");try{if(!await j())throw new Error(s("errors.collaborationUnavailable"));await _(`/api/projects/${c.id}/history/${n.version.id}/restore`,{method:"POST",body:JSON.stringify(t==="project"?{snapshotHash:n.version.snapshotHash}:{path:t,snapshotHash:n.version.snapshotHash})}),window.location.reload()}catch(r){if(r instanceof we&&r.code==="HISTORY_VERSION_CHANGED")try{if(!await be(n.version.id,!0)){m("");return}}catch(l){if(q(l)){m("");return}x(I(l)),m("");return}x(I(r)),m("")}}},oe=n?.version.author?.name||n?.version.author?.username||(n?.version.reason==="autosave"?s("history.reasons.autosave"):s("editor.deletedUser")),Q=n?me(n.version.createdAt,p.resolvedLanguage):"",X=a.useMemo(()=>{if(!g||!n)return{diffText:"",additions:0,deletions:0,hasChanges:!1};if(d==="commit"){const t=g.comparison,r=g.historical,l=Y?`${Y.label||s(`history.reasons.${Y.reason}`)} (${me(Y.createdAt,p.resolvedLanguage)})`:"/dev/null",o=`${oe} @ ${Q}`;return Fe(g.path,t,r,l,o)}else{const t=g.historical,r=g.comparison,l=`${n.version.label||s(`history.reasons.${n.version.reason}`)} (${Q})`,o=s("history.currentVersion");return Fe(g.path,t,r,l,o)}},[g,n,d,Y,oe,Q,s,p.resolvedLanguage]),ve=n?s(`history.reasons.${n.version.reason}`):"",Ne=n?fe(n.version,ve,p.resolvedLanguage):"",Ae=M&&M!=="all"?fe(M,s(`history.reasons.${M.reason}`),p.resolvedLanguage):"";return e.jsxs(e.Fragment,{children:[e.jsx(Ve,{open:i,extraWide:!0,draggable:!0,className:"history-dialog-modal",title:s("history.projectSnapshots"),description:s("history.description"),onOpenChange:C,footer:e.jsx("button",{onClick:()=>C(!1),children:s("common.close")}),children:e.jsxs("div",{className:"history-dialog",children:[ge&&e.jsx("p",{className:"error history-message",children:ge}),K==="load"&&S.length===0?e.jsxs("div",{className:"history-loading",children:[e.jsx(le,{className:"spin",size:22}),s("common.loading")]}):e.jsxs("div",{className:"history-dialog-layout",children:[e.jsxs("aside",{className:"history-timeline",children:[de&&h&&e.jsxs("div",{className:`history-stats${h.storageLimitExceeded?" exceeded":""}`,children:[e.jsxs("header",{children:[e.jsxs("span",{children:[e.jsx(Ie,{size:14}),s("history.storage")]}),e.jsx("button",{type:"button",disabled:W||S.length===0,title:s("history.clearAll"),"aria-label":s("history.clearAll"),onClick:()=>se("all"),children:e.jsx(Se,{size:13})})]}),e.jsx("strong",{children:s("history.storageUsage",{used:ee(h.totalBytes),limit:ee(h.maxStorageBytes)})}),e.jsx("progress",{max:h.maxStorageBytes,value:Math.min(h.totalBytes,h.maxStorageBytes)}),e.jsx("small",{children:s("history.storageBreakdown",{objects:ee(h.objectBytes),metadata:ee(h.metadataBytes),protected:ee(h.protectedBytes)})}),e.jsxs("small",{children:[s("history.versionUsage",{count:h.ordinaryVersionCount,limit:h.maxVersions>0?h.maxVersions:"∞"}),h.labeledVersionCount>0?` · ${s("history.protectedVersions",{count:h.labeledVersionCount})}`:""]}),h.storageLimitExceeded&&e.jsx("small",{className:"history-storage-warning",children:s("history.storageExceeded")})]}),S.map(t=>{const r=s(`history.reasons.${t.reason}`),l=fe(t,r,p.resolvedLanguage),o=t.author?.name||t.author?.username||(t.reason==="autosave"?s("history.reasons.autosave"):s("editor.deletedUser"));return e.jsxs("button",{className:t.id===b?"active":"",onClick:()=>w(t.id),children:[e.jsx(Te,{size:15}),e.jsxs("span",{children:[e.jsxs("div",{className:"history-item-heading",children:[e.jsx("strong",{title:l,children:l}),e.jsx("span",{className:`history-reason-badge reason-${t.reason}`,children:r})]}),e.jsx("small",{children:new Date(t.createdAt).toLocaleString(p.resolvedLanguage)}),e.jsxs("small",{children:[o," · ",s("history.changedCount",{count:t.changedPaths.length})]})]})]},t.id)}),pe&&e.jsx("div",{className:"history-load-more",children:e.jsxs("button",{type:"button",disabled:W,"aria-busy":Z,onClick:()=>{Le()},children:[Z?e.jsx(le,{className:"spin",size:13}):e.jsx($e,{size:13}),s(Z?"common.loading":"history.loadOlder")]})}),S.length===0&&e.jsx("p",{className:"muted padded",children:s("history.empty")})]}),e.jsx("section",{className:"history-detail",children:n&&e.jsxs(e.Fragment,{children:[e.jsx("header",{className:"history-detail-header",children:e.jsxs("div",{children:[e.jsxs("div",{className:"history-detail-title-row",children:[e.jsx("strong",{title:Ne,children:Ne}),e.jsx("span",{className:`history-reason-badge reason-${n.version.reason}`,children:ve})]}),e.jsxs("small",{children:[e.jsx($e,{size:12}),new Date(n.version.createdAt).toLocaleString(p.resolvedLanguage)," · ",oe," · ",s("history.fileCount",{count:n.version.fileCount})]})]})}),(de||ae)&&e.jsxs("div",{className:"history-snapshot-actions",children:[de&&e.jsxs("button",{type:"button",className:"history-delete-action",disabled:W,title:s("history.deleteVersionTitle"),onClick:()=>se(n.version),children:[e.jsx(Se,{size:14}),s("history.deleteVersion")]}),ae&&e.jsxs("button",{type:"button",className:"history-restore-project",disabled:W,title:s("history.restoreProjectTitle"),onClick:()=>te("project"),children:[e.jsx(Ee,{size:14}),s("history.restoreProject")]})]}),ae&&e.jsxs("div",{className:"history-label",children:[e.jsxs("label",{children:[e.jsx(Ke,{size:14}),e.jsx("input",{value:J,maxLength:80,placeholder:s("history.labelPlaceholder"),onChange:t=>$(t.target.value)})]}),e.jsxs("button",{disabled:W||J.trim()===(n.version.label??""),onClick:()=>{ke()},children:[K==="label"?e.jsx(le,{className:"spin",size:13}):e.jsx(Ue,{size:13}),s("history.saveLabel")]})]}),e.jsxs("div",{className:"history-files",children:[e.jsx("div",{className:"history-files-toolbar",children:e.jsxs("div",{className:"history-files-heading",children:[e.jsx(Oe,{size:13}),e.jsx("span",{children:s("history.changedFilesHeading",{count:B.length})})]})}),B.length>0?e.jsxs("div",{className:"history-file-tabs-row",children:[e.jsx("div",{className:"history-file-list",children:B.map(t=>e.jsxs("button",{type:"button",className:t.path===u?"active":"",title:t.path,onClick:()=>z(t.path),children:[e.jsx(ue,{size:13}),e.jsx("span",{children:t.path})]},t.path))}),ae&&e.jsx("div",{className:"history-file-actions",children:e.jsxs("button",{type:"button",disabled:!u||je||W,title:s("history.restoreFileTitle"),onClick:()=>te(u),children:[e.jsx(Ee,{size:13}),s("history.restoreFile")]})})]}):e.jsx("p",{className:"muted padded-small",children:s("history.noChangedFiles")})]}),u&&!he?e.jsxs("p",{className:"history-attachment-change",children:[e.jsx(ue,{size:14}),e.jsx("span",{children:s(je?"history.nonTextFileDeleted":"history.nonTextFileChanged",{path:u})})]}):e.jsx("div",{ref:ce,className:`history-comparison${E?" is-fullscreen":""}`,children:u?e.jsxs(e.Fragment,{children:[e.jsxs("header",{children:[e.jsxs("div",{className:"history-comparison-meta",children:[e.jsx("strong",{children:u}),e.jsxs("small",{className:"history-commit-summary",children:[d==="commit"?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"history-commit-author",children:oe}),e.jsx("span",{children:Y?s("history.changedAt",{time:Q}):s("history.createdAt",{time:Q})})]}):e.jsx("span",{children:s("history.comparingCurrent")}),X.hasChanges&&e.jsxs("span",{className:"history-diff-stats",children:[e.jsxs("span",{className:"addition",children:["+",X.additions]})," ",e.jsxs("span",{className:"deletion",children:["-",X.deletions]})]})]})]}),e.jsxs("div",{className:"history-diff-controls",children:[e.jsx("div",{className:"history-diff-control-group",children:e.jsxs("div",{className:"history-mode-toggle",role:"group","aria-label":s("history.diffMode"),children:[e.jsx("button",{type:"button",className:d==="commit"?"active":"","aria-pressed":d==="commit",onClick:()=>v("commit"),title:s("history.diffModeCommitHint"),children:e.jsx("span",{children:s("history.diffModeCommit")})}),e.jsx("button",{type:"button",className:d==="current"?"active":"","aria-pressed":d==="current",onClick:()=>v("current"),title:s("history.diffModeCurrentHint"),children:e.jsx("span",{children:s("history.diffModeCurrent")})})]})}),e.jsx("span",{className:"history-diff-control-divider","aria-hidden":"true"}),e.jsx("div",{className:"history-diff-control-group",children:e.jsxs("div",{className:"git-diff-font-controls",role:"group","aria-label":s("git.diffFontSize"),children:[e.jsx("button",{type:"button",className:"git-diff-font-button",disabled:f<=8,title:s("git.diffFontDecrease"),"aria-label":s("git.diffFontDecrease"),onClick:()=>A(t=>Math.max(8,t-1)),children:e.jsx(Ye,{size:14})}),e.jsxs("span",{className:"git-diff-font-value","aria-live":"polite",children:[f,"px"]}),e.jsx("button",{type:"button",className:"git-diff-font-button",disabled:f>=24,title:s("git.diffFontIncrease"),"aria-label":s("git.diffFontIncrease"),onClick:()=>A(t=>Math.min(24,t+1)),children:e.jsx(Ge,{size:14})})]})}),e.jsx("span",{className:"history-diff-control-divider","aria-hidden":"true"}),e.jsx("div",{className:"history-diff-control-group",children:e.jsx("button",{type:"button",className:"git-diff-fullscreen",title:s(E?"git.exitFullscreenDiff":"git.fullscreenDiff"),"aria-label":s(E?"git.exitFullscreenDiff":"git.fullscreenDiff"),onClick:()=>{Re()},children:E?e.jsx(Je,{size:15}):e.jsx(qe,{size:15})})})]})]}),K==="compare"&&!g?e.jsxs("div",{className:"history-comparison-empty",children:[e.jsx(le,{className:"spin",size:24}),e.jsx("span",{children:s("common.loading")})]}):g?X.hasChanges?e.jsx("pre",{className:"git-diff history-git-diff",style:{fontSize:`${f}px`},children:X.diffText.split(`
|
|
6
6
|
`).map((t,r)=>{const l=t.startsWith("+")&&!t.startsWith("+++")?"addition":t.startsWith("-")&&!t.startsWith("---")?"deletion":t.startsWith("@@")?"hunk":t.startsWith("diff ")||t.startsWith("---")||t.startsWith("+++")?"header":"";return e.jsxs("span",{className:l,children:[t,`
|
|
7
|
-
`]},r)})}):e.jsxs("div",{className:"git-diff-empty history-diff-empty",children:[e.jsx(We,{size:24}),e.jsx("span",{children:s(d==="commit"?"history.noDifferencesInCommit":"history.noDifferences")})]}):e.jsxs("div",{className:"history-comparison-empty",children:[e.jsx(ue,{size:24}),e.jsx("span",{children:s("apiErrors.historyPreviewUnsupported")})]})]}):e.jsxs("div",{className:"history-comparison-empty",children:[e.jsx(Te,{size:25}),e.jsx("span",{children:B.length===0?s("history.noChangedFiles"):s("history.chooseFile")})]})})]})})]})]})}),e.jsx(Ce,{open:!!U,title:s(U==="project"?"history.restoreProjectTitle":"history.restoreFileTitle"),description:U==="project"?s("history.restoreProjectDescription"):s("history.restoreFileDescription",{path:U??""}),confirmLabel:s("history.restore"),danger:!0,onCancel:()=>te(null),onConfirm:()=>{Pe()}}),e.jsx(Ce,{open:!!M,title:s(M==="all"?"history.clearAllTitle":"history.deleteVersionTitle"),description:M==="all"?s("history.clearAllDescription"):s("history.deleteVersionDescription",{name:Ae}),confirmLabel:s(M==="all"?"history.clearAll":"history.deleteVersion"),danger:!0,onCancel:()=>se(null),onConfirm:()=>{ze()}})]})}function ee(i){return i<1024?`${i} B`:i<1024*1024?`${Math.round(i/102.4)/10} KB`:i<1024*1024*1024?`${Math.round(i/(1024*1024)*10)/10} MB`:`${Math.round(i/(1024*1024*1024)*10)/10} GB`}function I(i){return i instanceof Error?i.message:String(i)}function q(i){return i instanceof Error&&i.name==="AbortError"}export{
|
|
7
|
+
`]},r)})}):e.jsxs("div",{className:"git-diff-empty history-diff-empty",children:[e.jsx(We,{size:24}),e.jsx("span",{children:s(d==="commit"?"history.noDifferencesInCommit":"history.noDifferences")})]}):e.jsxs("div",{className:"history-comparison-empty",children:[e.jsx(ue,{size:24}),e.jsx("span",{children:s("apiErrors.historyPreviewUnsupported")})]})]}):e.jsxs("div",{className:"history-comparison-empty",children:[e.jsx(Te,{size:25}),e.jsx("span",{children:B.length===0?s("history.noChangedFiles"):s("history.chooseFile")})]})})]})})]})]})}),e.jsx(Ce,{open:!!U,title:s(U==="project"?"history.restoreProjectTitle":"history.restoreFileTitle"),description:U==="project"?s("history.restoreProjectDescription"):s("history.restoreFileDescription",{path:U??""}),confirmLabel:s("history.restore"),danger:!0,onCancel:()=>te(null),onConfirm:()=>{Pe()}}),e.jsx(Ce,{open:!!M,title:s(M==="all"?"history.clearAllTitle":"history.deleteVersionTitle"),description:M==="all"?s("history.clearAllDescription"):s("history.deleteVersionDescription",{name:Ae}),confirmLabel:s(M==="all"?"history.clearAll":"history.deleteVersion"),danger:!0,onCancel:()=>se(null),onConfirm:()=>{ze()}})]})}function ee(i){return i<1024?`${i} B`:i<1024*1024?`${Math.round(i/102.4)/10} KB`:i<1024*1024*1024?`${Math.round(i/(1024*1024)*10)/10} MB`:`${Math.round(i/(1024*1024*1024)*10)/10} GB`}function I(i){return i instanceof Error?i.message:String(i)}function q(i){return i instanceof Error&&i.name==="AbortError"}export{ut as HistoryDialog};
|