texlite 0.15.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.
Files changed (69) hide show
  1. package/DESIGN.md +11 -0
  2. package/README.md +6 -0
  3. package/README.zh-CN.md +6 -0
  4. package/dist/client/assets/AdminUsers-Dyapv-3c.js +1 -0
  5. package/dist/client/assets/CitationLibraryDialog-CU7Q7r0Z.js +1 -0
  6. package/dist/client/assets/Dashboard-DsdhFENx.js +2 -0
  7. package/dist/client/assets/GitDialog-CZpnKw-J.js +3 -0
  8. package/dist/client/assets/{GitHubAccountDialog-Cqcezf6G.js → GitHubAccountDialog-CZ8O_PjD.js} +1 -1
  9. package/dist/client/assets/{HistoryDialog-IurkSJuU.js → HistoryDialog-DWYErBwj.js} +3 -3
  10. package/dist/client/assets/LatexEditor-CssVgypt.js +141 -0
  11. package/dist/client/assets/{PdfPreview-BTmvQDCV.js → PdfPreview-BjghzUb1.js} +1 -1
  12. package/dist/client/assets/{ProjectIconPickerDialog-Cbm-0YQW.js → ProjectIconPickerDialog-CqRmgFBM.js} +1 -1
  13. package/dist/client/assets/{ProjectNavigationDialogs-CozcEa2v.js → ProjectNavigationDialogs-BZxI3PJO.js} +1 -1
  14. package/dist/client/assets/ProjectSettings-CZE_xDKn.js +1 -0
  15. package/dist/client/assets/ProjectWorkspace-CAX3qEYr.js +32 -0
  16. package/dist/client/assets/{SelectionHistoryDialog-DiRKiMEt.js → SelectionHistoryDialog-CR5c3I8k.js} +2 -2
  17. package/dist/client/assets/{SystemMetricsDialog-DJJZueSr.js → SystemMetricsDialog-DDpFwgXh.js} +1 -1
  18. package/dist/client/assets/{TagManagementDialog-3c-WAWQd.js → TagManagementDialog-CXLA9h_j.js} +1 -1
  19. package/dist/client/assets/WordCountDialog-DUyR24vv.js +1 -0
  20. package/dist/client/assets/check-CwBYzomT.js +1 -0
  21. package/dist/client/assets/chevron-up-D5lCNKlk.js +1 -0
  22. package/dist/client/assets/chktex-CRkLYKcV.js +3 -0
  23. package/dist/client/assets/{citationLibrary-ZeQPCv5O.js → citationLibrary-C9WnXB-1.js} +2 -2
  24. package/dist/client/assets/{external-link-DGfNJFKy.js → external-link-C9Td1CCj.js} +1 -1
  25. package/dist/client/assets/{github-DJezB5ef.js → github-D-JDXb-w.js} +1 -1
  26. package/dist/client/assets/{hard-drive-B9h-a7KY.js → hard-drive-Ctj3K_zx.js} +1 -1
  27. package/dist/client/assets/{index-DmBKxZf9.js → index-9hnQ8Q9x.js} +1 -1
  28. package/dist/client/assets/index-C0qg2Ylw.css +1 -0
  29. package/dist/client/assets/index-DkpU9Fgs.js +10 -0
  30. package/dist/client/assets/index-_eYe7K9T.js +1 -0
  31. package/dist/client/assets/{minimize-2-Crq_SyYM.js → minimize-2-BiVyoWZA.js} +1 -1
  32. package/dist/client/assets/{minus-Dn3USloe.js → minus-Bl8l4LXq.js} +1 -1
  33. package/dist/client/assets/{plus-BwKRQJHI.js → plus-CCxK-HNt.js} +1 -1
  34. package/dist/client/assets/{refresh-cw-C5yVKb1r.js → refresh-cw-BE8IbaHI.js} +1 -1
  35. package/dist/client/assets/{search-CDyQWr9H.js → search-CPbhRWQE.js} +1 -1
  36. package/dist/client/assets/{sigma-9fiQHdlo.js → sigma-LxGD9tK2.js} +1 -1
  37. package/dist/client/assets/spellCheck-hpm8qZTr.js +1 -0
  38. package/dist/client/assets/{tags-C_3BvsxV.js → tags-DuN89PsZ.js} +1 -1
  39. package/dist/client/assets/{type-CnT0mBxu.js → type-BiettCiY.js} +1 -1
  40. package/dist/client/assets/{x-DN0Ol4Ya.js → x-C_3swJOC.js} +1 -1
  41. package/dist/client/index.html +3 -3
  42. package/dist/client/texlite-icon.svg +8 -0
  43. package/dist/server/auth.js +0 -3
  44. package/dist/server/chktex.js +3 -4
  45. package/dist/server/i18n.js +4 -0
  46. package/dist/server/latexCompletion.js +11 -88
  47. package/dist/server/projectOutline.js +4 -39
  48. package/dist/server/projectSearch.js +0 -4
  49. package/dist/server/routes/citations.js +22 -0
  50. package/dist/server/routes/users.js +21 -3
  51. package/dist/shared/bibtexReferences.js +5 -1
  52. package/dist/shared/latexCompletion.js +1 -0
  53. package/dist/shared/latexReferences.js +13 -3
  54. package/dist/shared/latexSymbols.js +77 -0
  55. package/package.json +1 -1
  56. package/dist/client/assets/AdminUsers-Cau9nlv9.js +0 -1
  57. package/dist/client/assets/CitationLibraryDialog-Cf_bbSq3.js +0 -1
  58. package/dist/client/assets/Dashboard-JQ8pJe2d.js +0 -2
  59. package/dist/client/assets/GitDialog-BcqqWKr-.js +0 -3
  60. package/dist/client/assets/LatexEditor-msdbtTyG.js +0 -141
  61. package/dist/client/assets/ProjectSettings-BlthcpdA.js +0 -1
  62. package/dist/client/assets/ProjectWorkspace-DUPLJCQ3.js +0 -32
  63. package/dist/client/assets/WordCountDialog-BqlX2s36.js +0 -1
  64. package/dist/client/assets/check-EZ2H-iDj.js +0 -1
  65. package/dist/client/assets/chktex-CZIYuMLb.js +0 -3
  66. package/dist/client/assets/index-BgeOKYIx.js +0 -10
  67. package/dist/client/assets/index-CMBalIBd.css +0 -1
  68. package/dist/client/assets/spellCheck-BCpcq-VN.js +0 -1
  69. package/dist/client/assets/user-plus-pxz36w4w.js +0 -1
package/DESIGN.md CHANGED
@@ -389,6 +389,17 @@ explicitly enabled, and completion items from built-in LaTeX plus project
389
389
  outlines are metadata-keyed and coalesced; a source-tree change invalidates the
390
390
  corresponding cache.
391
391
 
392
+ The live editor and server project index share the pure symbol extractor in
393
+ `src/shared/latexSymbols.ts` and the completion data types in
394
+ `src/shared/latexCompletion.ts`. It extracts command argument snippets,
395
+ environments and theorems, packages, classes, source-file references, labels,
396
+ and in-file `\bibitem` definitions using the same comment/literal masking and
397
+ reference rules. The editor owns its document-identity cache and gives current
398
+ unsaved definitions precedence over server candidates. The server owns file
399
+ I/O, metadata caches, built-in candidates, source attribution, and root-scoped
400
+ BibTeX selection; it does not promote in-file `\bibitem` entries to project-wide
401
+ citations. This extractor does not expand TeX macros or load the editor parser.
402
+
392
403
  Opening `.tex`, `.bib`, `.sty`, or `.cls` files in editor tabs is an optional
393
404
  per-user/per-project preference and is off by default. The active tab is
394
405
  highlighted and keyboard accessible. PDF/SyncTeX synchronization is available
package/README.md CHANGED
@@ -1,3 +1,7 @@
1
+ <div align="center">
2
+
3
+ <img src="https://raw.githubusercontent.com/SWUFE-DB-Group/TexLite/main/src/client/public/texlite-icon.svg" width="72" height="72" alt="TexLite logo" />
4
+
1
5
  # TexLite
2
6
 
3
7
  A lightweight self-hosted alternative to Overleaf for _small, trusted_ research
@@ -11,6 +15,8 @@ teams. Use your existing LaTeX distribution, with no heavyweight service stack.
11
15
 
12
16
  **Website:** [TexLite GitHub Pages](https://swufe-db-group.github.io/TexLite/)
13
17
 
18
+ </div>
19
+
14
20
  ![TexLite workspace](preview-1.png)
15
21
  ![TexLite project view](preview-2.png)
16
22
 
package/README.zh-CN.md CHANGED
@@ -1,3 +1,7 @@
1
+ <div align="center">
2
+
3
+ <img src="https://raw.githubusercontent.com/SWUFE-DB-Group/TexLite/main/src/client/public/texlite-icon.svg" width="72" height="72" alt="TexLite 标志" />
4
+
1
5
  # TexLite
2
6
 
3
7
  面向*小型、可信*研究团队的轻量自托管 Overleaf 替代方案。直接使用现有的 LaTeX
@@ -11,6 +15,8 @@
11
15
 
12
16
  **网站:** [TexLite GitHub Pages](https://swufe-db-group.github.io/TexLite/)
13
17
 
18
+ </div>
19
+
14
20
  ![TexLite 工作区](preview-1.png)
15
21
  ![TexLite 项目视图](preview-2.png)
16
22
 
@@ -0,0 +1 @@
1
+ import{u as be,r,j as e}from"./react-CltQJflK.js";import{U as ee,D as ye,a as Ce,b as Ne,c as we,d as Se}from"./index-_eYe7K9T.js";import{c as q,g as N,h as w,d as se,M as L,C as ve}from"./index-DkpU9Fgs.js";import{U as Pe,X as $,E as ke,T as ae,i as ze,C as Me}from"./x-C_3swJOC.js";import{S as Te}from"./search-CPbhRWQE.js";const re=q("Dices",[["rect",{width:"12",height:"12",x:"2",y:"10",rx:"2",ry:"2",key:"6agr2n"}],["path",{d:"m17.92 14 3.5-3.5a2.24 2.24 0 0 0 0-3l-5-4.92a2.24 2.24 0 0 0-3 0L10 6",key:"1o487t"}],["path",{d:"M6 18h.01",key:"uhywen"}],["path",{d:"M10 14h.01",key:"ssrbsk"}],["path",{d:"M15 6h.01",key:"cblpky"}],["path",{d:"M18 9h.01",key:"2061c0"}]]);const te=q("KeyRound",[["path",{d:"M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z",key:"1s6t7t"}],["circle",{cx:"16.5",cy:"7.5",r:".5",fill:"currentColor",key:"w0ekpg"}]]);const ne=q("LockKeyhole",[["circle",{cx:"12",cy:"16",r:"1",key:"1au0dj"}],["rect",{x:"3",y:"10",width:"18",height:"12",rx:"2",key:"6s8ecr"}],["path",{d:"M7 10V7a5 5 0 0 1 10 0v3",key:"1pqi11"}]]);function ie(V=10){const n="ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz23456789!@#$%",s=crypto.getRandomValues(new Uint8Array(V));return Array.from(s,S=>n[S%n.length]).join("")}function Ue({currentUser:V,minPasswordLength:n}){const{t:s}=be(),[S,oe]=r.useState([]),[J,H]=r.useState(""),[I,j]=r.useState(1),[o,le]=r.useState({page:1,pageSize:20,total:0,totalPages:0}),[x,Q]=r.useState(!0),[v,X]=r.useState(!1),[ce,de]=r.useState(0),[G,W]=r.useState(""),[P,k]=r.useState(""),[i,z]=r.useState(!1),[M,d]=r.useState("");r.useEffect(()=>{if(!P)return;const a=window.setTimeout(()=>k(""),3e3);return()=>window.clearTimeout(a)},[P]);const[ue,T]=r.useState(!1),[t,h]=r.useState({username:"",displayName:"",password:"",role:"user",canCreateProjects:!1}),[D,E]=r.useState(null),[g,F]=r.useState(""),[f,O]=r.useState(null),[K,R]=r.useState(!1),[u,Y]=r.useState(!1),[Z,b]=r.useState(""),[l,U]=r.useState(null),[A,_]=r.useState(!1),[me,y]=r.useState(""),C=J.trim(),B=()=>de(a=>a+1);r.useEffect(()=>{const a=new AbortController;Q(!0),X(!1),W("");const m=window.setTimeout(()=>{const c=new URLSearchParams({page:String(I)});C&&c.set("q",C),N(`/api/admin/users?${c}`,{signal:a.signal}).then(p=>{a.signal.aborted||(oe(p.users),le(p.pagination),j(p.pagination.page))}).catch(p=>{a.signal.aborted||(W(w(p)),X(!0))}).finally(()=>{a.signal.aborted||Q(!1)})},C?200:0);return()=>{window.clearTimeout(m),a.abort()}},[C,I,ce]);const he=async()=>{if(!i){if(t.password.length<n)return d(s("auth.passwordMinimum",{count:n}));z(!0),d("");try{await N("/api/admin/users",{method:"POST",body:JSON.stringify({username:t.username,displayName:t.displayName||t.username,password:t.password,role:t.role,canCreateProjects:t.canCreateProjects})}),T(!1),h({username:"",displayName:"",password:"",role:"user",canCreateProjects:!1}),B(),k(s("users.saved"))}catch(a){d(w(a))}finally{z(!1)}}},pe=async a=>{U({target:a,setting:a.role==="admin"?"demote":"promote"}),y("")},je=async a=>{U({target:a,setting:a.canCreateProjects?"denyProjectCreation":"allowProjectCreation"}),y("")},xe=async()=>{if(!l||A)return;const{target:a,setting:m}=l,c=m==="demote"?{role:"user"}:m==="promote"?{role:"admin"}:{canCreateProjects:m==="allowProjectCreation"};_(!0),y("");try{await N(`/api/admin/users/${a.id}`,{method:"PATCH",body:JSON.stringify(c)}),B(),U(null),k(s("users.saved"))}catch(p){y(w(p))}finally{_(!1)}},ge=async()=>{if(!(!D||!g||i)){if(g.length<n)return d(s("auth.passwordMinimum",{count:n}));z(!0),d("");try{await N(`/api/admin/users/${D.id}`,{method:"PATCH",body:JSON.stringify({password:g})}),E(null),F(""),k(s("users.saved"))}catch(a){d(w(a))}finally{z(!1)}}},fe=async()=>{if(!(!f||u)){Y(!0),b("");try{await N(`/api/admin/users/${f.id}`,{method:"DELETE",body:JSON.stringify({deleteProjects:K})}),O(null),R(!1),B()}catch(a){b(w(a))}finally{Y(!1)}}};return e.jsxs("main",{className:"dashboard",children:[e.jsx("div",{className:"section-title",children:e.jsxs("div",{children:[e.jsxs("h1",{children:[e.jsx(Pe,{"aria-hidden":!0,size:25}),s("users.manage")]}),e.jsx("p",{className:"muted",children:s("users.onlyAdmin")})]})}),e.jsxs("div",{className:"admin-user-toolbar",children:[e.jsxs("div",{className:"admin-user-filters",children:[e.jsxs("div",{className:"admin-user-search",role:"search",children:[e.jsx(Te,{"aria-hidden":!0,size:16}),e.jsx("input",{role:"searchbox","aria-label":s("users.searchPlaceholder"),placeholder:s("users.searchPlaceholder"),value:J,onChange:a=>{H(a.target.value),j(1)}}),J&&e.jsx("button",{type:"button","aria-label":s("users.clearSearch"),title:s("users.clearSearch"),onClick:()=>{H(""),j(1)},children:e.jsx($,{"aria-hidden":!0,size:14})})]}),!x&&!v&&e.jsx("span",{className:"admin-user-count",role:"status",children:s("users.total",{count:o.total})})]}),e.jsxs("button",{className:"primary icon-button admin-user-add",onClick:()=>{d(""),T(!0)},children:[e.jsx(ee,{"aria-hidden":!0,size:15}),s("users.add")]})]}),P&&e.jsx("p",{className:"admin-user-notice",role:"status",children:P}),G&&e.jsx("p",{className:"error",role:"alert",children:G}),e.jsx("div",{className:"table-card admin-user-table","aria-busy":x,children:e.jsxs("table",{children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:s("common.user")}),e.jsx("th",{children:s("users.role")}),e.jsx("th",{children:s("users.createProjects")}),e.jsx("th",{children:s("users.ownedProjects")}),e.jsx("th",{children:s("users.actions")})]})}),e.jsx("tbody",{children:x?e.jsx("tr",{children:e.jsx("td",{colSpan:5,className:"admin-user-list-state",children:e.jsxs("span",{role:"status",children:[e.jsx(se,{className:"spin",size:16}),s("common.loading")]})})}):v?e.jsx("tr",{children:e.jsxs("td",{colSpan:5,className:"admin-user-list-state",children:[e.jsx("span",{children:s("users.loadFailed")}),e.jsx("button",{type:"button",onClick:B,children:s("common.retry")})]})}):S.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:5,className:"admin-user-list-state",children:s(C?"users.noMatches":"users.empty")})}):S.map(a=>{const m=a.id===V.id,c=i||A;return e.jsxs("tr",{children:[e.jsxs("td",{className:"admin-user-identity",children:[e.jsx("strong",{children:a.displayName}),e.jsxs("small",{children:["@",a.username]})]}),e.jsx("td",{children:m?e.jsxs("span",{className:"admin-user-badge",title:s("users.selfProtected"),children:[e.jsx(ne,{size:12,"aria-hidden":!0}),s("common.admin")]}):e.jsxs("select",{className:"admin-user-role","aria-label":s("users.roleFor",{username:a.username}),value:a.role,disabled:c,onChange:()=>{pe(a)},children:[e.jsx("option",{value:"user",children:s("common.user")}),e.jsx("option",{value:"admin",children:s("common.admin")})]})}),e.jsx("td",{children:a.role==="admin"?e.jsxs("span",{className:"admin-user-locked",title:s("users.adminCreation"),children:[e.jsx(ne,{size:12,"aria-hidden":!0}),s("users.allow")]}):e.jsx("button",{type:"button",className:"admin-user-switch",role:"switch","aria-checked":a.canCreateProjects,"aria-label":s("users.creationFor",{username:a.username}),disabled:c,onClick:()=>{je(a)},children:e.jsx("span",{})})}),e.jsx("td",{children:a.ownedProjects??0}),e.jsx("td",{children:e.jsxs("div",{className:"admin-user-actions",children:[e.jsxs("button",{className:"icon-button",disabled:c,onClick:()=>{E(a),F(""),d("")},children:[e.jsx(te,{"aria-hidden":!0,size:13}),s("users.resetPassword")]}),!m&&e.jsxs(ye,{modal:!1,children:[e.jsx(Ce,{asChild:!0,children:e.jsx("button",{className:"icon-button",disabled:c,"aria-label":s("users.actionsFor",{username:a.username}),children:e.jsx(ke,{size:17,"aria-hidden":!0})})}),e.jsx(Ne,{children:e.jsx(we,{className:"comment-actions-menu-content",align:"end",sideOffset:5,children:e.jsxs(Se,{className:"danger-text",onSelect:()=>{O(a),R(!1),b("")},children:[e.jsx(ae,{size:14,"aria-hidden":!0}),s("users.deleteTitle")]})})})]})]})})]},a.id)})})]})}),o.totalPages>1&&e.jsxs("nav",{className:"project-pagination admin-user-pagination","aria-label":s("users.pagination"),children:[e.jsxs("button",{type:"button",disabled:x||v||o.page<=1,onClick:()=>j(o.page-1),children:[e.jsx(ze,{size:15}),s("users.previousPage")]}),e.jsx("span",{children:s("users.pageOf",{page:o.page,totalPages:o.totalPages})}),e.jsxs("button",{type:"button",disabled:x||v||o.page>=o.totalPages,onClick:()=>j(o.page+1),children:[s("users.nextPage"),e.jsx(Me,{size:15})]})]}),e.jsxs(L,{open:ue,title:s("users.add"),description:s("users.addDescription"),onOpenChange:a=>{i||T(a)},footer:e.jsxs(e.Fragment,{children:[e.jsxs("button",{className:"icon-button",disabled:i,onClick:()=>T(!1),children:[e.jsx($,{"aria-hidden":!0,size:14}),s("common.cancel")]}),e.jsxs("button",{className:"primary icon-button",disabled:i||!t.username.trim()||t.password.length<n,onClick:()=>{he()},children:[e.jsx(ee,{"aria-hidden":!0,size:14}),s("users.createUser")]})]}),children:[M&&e.jsx("p",{className:"error",role:"alert",children:M}),e.jsxs("fieldset",{className:"admin-user-form form-stack",disabled:i,children:[e.jsxs("label",{className:"form-field",children:[s("auth.username"),e.jsx("input",{value:t.username,onChange:a=>h({...t,username:a.target.value})})]}),e.jsxs("label",{className:"form-field",children:[s("users.displayName"),e.jsx("input",{value:t.displayName,onChange:a=>h({...t,displayName:a.target.value})})]}),e.jsxs("label",{className:"form-field",children:[s("users.initialPassword"),e.jsxs("span",{className:"password-generator",children:[e.jsx("input",{minLength:n,autoComplete:"new-password",value:t.password,onChange:a=>h({...t,password:a.target.value})}),e.jsxs("button",{type:"button",title:s("users.generatePassword"),onClick:()=>h({...t,password:ie()}),children:[e.jsx(re,{size:15}),s("users.randomPassword")]})]}),e.jsx("small",{className:"field-hint",children:s("auth.passwordMinimum",{count:n})})]}),e.jsxs("label",{className:"form-field",children:[s("users.role"),e.jsxs("select",{value:t.role,onChange:a=>h({...t,role:a.target.value}),children:[e.jsx("option",{value:"user",children:s("common.user")}),e.jsx("option",{value:"admin",children:s("common.admin")})]})]}),e.jsxs("label",{className:"checkbox-field",children:[e.jsx("input",{type:"checkbox",checked:t.canCreateProjects||t.role==="admin",disabled:t.role==="admin",onChange:a=>h({...t,canCreateProjects:a.target.checked})})," ",s("users.allowCreate")]})]})]}),e.jsxs(L,{open:!!D,title:s("users.resetPassword"),description:s("users.resetDescription",{username:D?.username??""}),onOpenChange:a=>{!a&&!i&&E(null)},footer:e.jsxs(e.Fragment,{children:[e.jsxs("button",{className:"icon-button",disabled:i,onClick:()=>E(null),children:[e.jsx($,{"aria-hidden":!0,size:14}),s("common.cancel")]}),e.jsxs("button",{className:"primary icon-button",disabled:i||g.length<n,onClick:()=>{ge()},children:[e.jsx(te,{"aria-hidden":!0,size:14}),s("users.reset")]})]}),children:[M&&e.jsx("p",{className:"error",role:"alert",children:M}),e.jsxs("label",{className:"form-field",children:[s("auth.newPassword"),e.jsxs("span",{className:"password-generator",children:[e.jsx("input",{disabled:i,autoFocus:!0,minLength:n,autoComplete:"new-password",value:g,onChange:a=>F(a.target.value)}),e.jsxs("button",{type:"button",disabled:i,onClick:()=>F(ie()),children:[e.jsx(re,{size:15}),s("users.randomPassword")]})]}),e.jsx("small",{className:"field-hint",children:s("auth.passwordMinimum",{count:n})})]})]}),e.jsx(L,{open:!!f,title:s("users.deleteTitle"),description:s("users.deleteDescription",{username:f?.username??""}),onOpenChange:a=>{!a&&!u&&(O(null),b(""))},footer:e.jsxs(e.Fragment,{children:[e.jsxs("button",{className:"icon-button",disabled:u,onClick:()=>{O(null),b("")},children:[e.jsx($,{"aria-hidden":!0,size:14}),s("common.cancel")]}),e.jsxs("button",{className:"danger icon-button",disabled:u,"aria-busy":u,onClick:()=>{fe()},children:[u?e.jsx(se,{className:"spin","aria-hidden":!0,size:14}):e.jsx(ae,{"aria-hidden":!0,size:14}),s(u?"common.loading":"users.deleteTitle")]})]}),children:e.jsxs(e.Fragment,{children:[Z&&e.jsx("p",{className:"error dialog-error",children:Z}),e.jsxs("fieldset",{className:"choice-group",disabled:u,children:[e.jsx("legend",{children:s("users.ownedChoice",{count:f?.ownedProjects??0})}),e.jsxs("label",{children:[e.jsx("input",{type:"radio",checked:!K,onChange:()=>R(!1)})," ",s("users.transferProjects")]}),e.jsxs("label",{children:[e.jsx("input",{type:"radio",checked:K,onChange:()=>R(!0)})," ",s("users.deleteProjects")]})]})]})}),e.jsx(ve,{open:!!l,title:s(`userConfirmations.${l?.setting??"demote"}Title`),description:s(`userConfirmations.${l?.setting??"demote"}Description`,{username:l?.target.username??""}),confirmLabel:s(`userConfirmations.${l?.setting??"demote"}Confirm`),danger:l?.setting!=="promote"&&l?.setting!=="allowProjectCreation",busy:A,error:me,onCancel:()=>{A||(U(null),y(""))},onConfirm:()=>{xe()}})]})}export{Ue as AdminUsers};
@@ -0,0 +1 @@
1
+ import{u as fe,r as s,j as e}from"./react-CltQJflK.js";import{c as De,M as re,d as q,C as Fe,g as A,h as D}from"./index-DkpU9Fgs.js";import{a as Ge,C as Ze}from"./chevron-up-D5lCNKlk.js";import{T as Re}from"./tags-DuN89PsZ.js";import{C as I}from"./check-CwBYzomT.js";import{X as Z,P as et,T as Oe,B as oe,i as xe,C as tt,k as Ke}from"./x-C_3swJOC.js";import{P as le}from"./plus-CCxK-HNt.js";import{parseBibEntriesResult as it,citationBibtexLimitLabel as at,parseSingleBibEntry as Me,citationVenue as nt}from"./citationLibrary-C9WnXB-1.js";import{S as st}from"./search-CPbhRWQE.js";const ot=De("Import",[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m8 11 4 4 4-4",key:"1dohi6"}],["path",{d:"M8 5H4a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V7a2 2 0 0 0-2-2h-4",key:"1ywtjm"}]]);const rt=De("PenLine",[["path",{d:"M12 20h9",key:"t2du7b"}],["path",{d:"M16.376 3.622a1 1 0 0 1 3.002 3.002L7.368 18.635a2 2 0 0 1-.855.506l-2.872.838a.5.5 0 0 1-.62-.62l.838-2.872a2 2 0 0 1 .506-.854z",key:"1ykcvy"}]]);function lt({tags:l,selectedId:y,onSelect:b,onManage:L}){const{t:c}=fe(),[x,k]=s.useState(!1),[N,j]=s.useState(Number.POSITIVE_INFINITY),[T,a]=s.useState(),w=s.useRef(null),K=y?[...l.filter(d=>d.id===y),...l.filter(d=>d.id!==y)]:l;s.useLayoutEffect(()=>{const d=w.current;if(!d)return;const g=()=>{const z=Array.from(d.querySelectorAll("button")),M=[...new Set(z.map(u=>u.offsetTop))][2],h=M===void 0?z:z.filter(u=>u.offsetTop<M);j(h.length),a(h.length?Math.max(...h.map(u=>u.offsetTop+u.offsetHeight)):void 0)};g();const C=new ResizeObserver(g);return C.observe(d),()=>C.disconnect()},[l,y]);const m=N<l.length+1;return e.jsxs("div",{className:"citation-tag-bar",children:[e.jsxs("div",{className:"citation-tag-filter-catalog",children:[e.jsx("div",{className:"citation-tag-filter-clip",style:!x&&m?{maxHeight:T}:void 0,children:e.jsxs("div",{className:"citation-tag-filters",ref:w,children:[e.jsx("button",{type:"button",className:y?"":"active","aria-pressed":!y,onClick:()=>b(""),children:c("citationLibrary.allTags")}),K.map((d,g)=>{const C=!x&&g+1>=N;return e.jsxs("button",{type:"button",className:y===d.id?"active":"","aria-pressed":y===d.id,"aria-hidden":C||void 0,tabIndex:C?-1:0,title:d.name,onClick:()=>b(y===d.id?"":d.id),children:[e.jsx("span",{className:`citation-tag-dot tag-${d.color}`}),e.jsx("span",{className:"citation-tag-name",children:d.name})]},d.id)})]})}),l.length===0&&e.jsx("span",{className:"muted",children:c("citationLibrary.noTags")}),m&&e.jsxs("button",{type:"button",className:"citation-tag-expand","aria-expanded":x,onClick:()=>k(d=>!d),children:[x?e.jsx(Ge,{size:13}):e.jsx(Ze,{size:13}),c(x?"citationTagManagement.collapse":"citationTagManagement.expand")]})]}),e.jsxs("button",{type:"button",className:"citation-tag-manage",onClick:L,children:[e.jsx(Re,{size:14}),c("citationTagManagement.title")]})]})}const ct=["red","orange","yellow","green","blue","purple","gray"];function dt({tags:l,onClose:y,onUpdated:b,onDeleted:L}){const{t:c}=fe(),[x,k]=s.useState(""),[N,j]=s.useState("green"),[T,a]=s.useState(null),[w,K]=s.useState(""),[m,d]=s.useState("green"),[g,C]=s.useState(!1),[z,E]=s.useState(""),[M,h]=s.useState(""),[u,V]=s.useState(null),[ce,F]=s.useState("");s.useEffect(()=>{if(!M)return;const r=window.setTimeout(()=>h(""),2e3);return()=>window.clearTimeout(r)},[M]);const O=async r=>{const p=(r?w:x).trim();if(!(g||!p)){C(!0),E(""),h("");try{const f=await A(r?`/api/citations/tags/${encodeURIComponent(r.id)}`:"/api/citations/tags",{method:r?"PATCH":"POST",body:JSON.stringify({name:p,color:r?m:N})});b(f.tag),r?a(null):k(""),h(c(r?"citationLibrary.tagsUpdated":f.created===!1?"citationTagManagement.exists":"citationLibrary.tagCreated"))}catch(f){E(D(f))}finally{C(!1)}}},Q=async()=>{if(!(!u||g)){C(!0),F(""),h("");try{await A(`/api/citations/tags/${encodeURIComponent(u.id)}`,{method:"DELETE"}),L(u.id),T?.id===u.id&&a(null),V(null),h(c("citationTagManagement.deleted"))}catch(r){F(D(r))}finally{C(!1)}}},ee=ct.map(r=>e.jsx("option",{value:r,children:c(`tags.${r}`)},r));return e.jsxs(e.Fragment,{children:[e.jsx(re,{open:!0,wide:!0,className:"tag-management-modal",title:c("citationTagManagement.title"),description:c("citationTagManagement.description"),onOpenChange:r=>{!r&&!g&&y()},footer:e.jsx("button",{disabled:g,onClick:y,children:c("common.close")}),children:e.jsxs("div",{className:"tag-management",children:[z&&e.jsx("p",{className:"error dialog-error",role:"alert",children:z}),M&&e.jsxs("p",{className:"citation-library-notice",role:"status",children:[e.jsx(I,{size:14}),M,e.jsx("button",{"aria-label":c("common.close"),onClick:()=>h(""),children:e.jsx(Z,{size:13})})]}),e.jsxs("fieldset",{disabled:g,className:"citation-tag-management-fields",children:[e.jsxs("form",{className:"tag-management-create",onSubmit:r=>{r.preventDefault(),O()},children:[e.jsxs("label",{className:"tag-management-field",children:[e.jsx("span",{children:c("tags.name")}),e.jsx("input",{autoFocus:!0,maxLength:32,value:x,placeholder:c("citationLibrary.newTagPlaceholder"),onChange:r=>k(r.target.value)})]}),e.jsxs("label",{className:"tag-management-field tag-management-color",children:[e.jsx("span",{children:c("tags.color")}),e.jsx("select",{value:N,onChange:r=>j(r.target.value),children:ee})]}),e.jsxs("button",{type:"submit",className:"primary",disabled:!x.trim(),children:[g?e.jsx(q,{className:"spin",size:14}):e.jsx(le,{size:14}),c("citationLibrary.createTag")]})]}),l.length===0?e.jsx("p",{className:"tag-management-empty",children:c("citationLibrary.noTags")}):e.jsx("div",{className:"tag-management-list",children:l.map(r=>e.jsxs("article",{className:`tag-management-item${T?.id===r.id?" editing":""}`,children:[e.jsxs("div",{className:"tag-management-item-main",children:[e.jsx("span",{className:`tag-dot tag-${r.color}`,"aria-hidden":!0}),e.jsx("strong",{title:r.name,children:r.name})]}),e.jsxs("div",{className:"tag-management-item-actions",children:[e.jsx("button",{type:"button","aria-label":c("citationTagManagement.edit",{tag:r.name}),onClick:()=>{a(r),K(r.name),d(r.color),E("")},children:e.jsx(et,{size:14})}),e.jsx("button",{type:"button",className:"danger-text","aria-label":c("citationTagManagement.delete",{tag:r.name}),onClick:()=>{V(r),F("")},children:e.jsx(Oe,{size:14})})]}),T?.id===r.id&&e.jsxs("form",{className:"tag-management-edit",onSubmit:p=>{p.preventDefault(),O(r)},children:[e.jsxs("label",{className:"tag-management-field",children:[e.jsx("span",{children:c("tags.rename")}),e.jsx("input",{maxLength:32,value:w,onChange:p=>K(p.target.value)})]}),e.jsxs("label",{className:"tag-management-field tag-management-color",children:[e.jsx("span",{children:c("tags.color")}),e.jsx("select",{value:m,onChange:p=>d(p.target.value),children:ee})]}),e.jsxs("div",{className:"tag-management-edit-actions",children:[e.jsx("button",{type:"button",onClick:()=>{a(null),E("")},children:c("common.cancel")}),e.jsxs("button",{type:"submit",className:"primary",disabled:!w.trim(),children:[e.jsx(I,{size:14}),c("common.save")]})]})]})]},r.id))})]})]})}),e.jsx(Fe,{open:!!u,title:c("tags.deleteTitle"),description:c("citationTagManagement.deleteDescription",{tag:u?.name??""}),confirmLabel:c("common.delete"),danger:!0,busy:g,error:ce,onCancel:()=>{g||V(null)},onConfirm:()=>{Q()}})]})}const mt=[],ut={status:"empty",entries:mt};function Nt({open:l,onOpenChange:y,page:b=!1,onBack:L,currentFile:c="",currentSource:x="",readOnly:k=!1,currentUserId:N,maxBibtexBytes:j,onInsert:T}){const{t:a}=fe(),[w,K]=s.useState("library"),[m,d]=s.useState(""),[g,C]=s.useState(""),[z,E]=s.useState([]),[M,h]=s.useState(1),[u,V]=s.useState({page:1,pageSize:60,total:0,totalPages:0}),[ce,F]=s.useState(0),[O,Q]=s.useState([]),[ee,r]=s.useState(!1),[p,f]=s.useState(null),[te,_]=s.useState([]),[de,ve]=s.useState(!1),[_e,Ne]=s.useState(!1),[X,B]=s.useState(null),[S,P]=s.useState(null),[me,ue]=s.useState(""),[$e,H]=s.useState(!1),[ie,ye]=s.useState(""),[Ce,ge]=s.useState(null),[he,ae]=s.useState(null),[Ie,G]=s.useState(""),[W,v]=s.useState(""),[ne,$]=s.useState("");s.useEffect(()=>{if(!ne)return;const t=window.setTimeout(()=>$(""),2e3);return()=>window.clearTimeout(t)},[ne]),s.useEffect(()=>{l||r(!1)},[l]);const[Le,R]=s.useState(new Map),[He,se]=s.useState(!1),[Ue,Je]=s.useState(0),U=!!(/\.bib$/i.test(c)&&T),pe=s.useMemo(()=>l&&U?it(x,j):ut,[l,x,U,j]),Te=pe.status==="too-large",we=pe.status==="invalid",J=pe.entries,qe=s.useMemo(()=>new Set(J.map(t=>t.citationKey.toLowerCase())),[J]);s.useEffect(()=>{if(!l)return;const t=new AbortController,n=window.setTimeout(()=>{Ne(!0),v("");const i=new URLSearchParams;m.trim()&&i.set("q",m.trim()),g&&i.set("tag",g),i.set("page",String(M)),i.set("pageSize","60"),A(`/api/citations?${i.toString()}`,{signal:t.signal}).then(o=>{E(o.entries),V(o.pagination),o.pagination.page!==M&&h(o.pagination.page)}).catch(o=>{o instanceof Error&&o.name==="AbortError"||v(D(o))}).finally(()=>{t.signal.aborted||Ne(!1)})},m.trim()?180:0);return()=>{window.clearTimeout(n),t.abort()}},[l,m,g,M,ce]),s.useEffect(()=>{if(!l)return;const t=new AbortController;return A("/api/citations/tags",{signal:t.signal}).then(n=>Q(n.tags)).catch(n=>{n instanceof Error&&n.name==="AbortError"||v(D(n))}),()=>t.abort()},[l]),s.useEffect(()=>{if(!l||!U){R(new Map),se(!1);return}const t=new AbortController,n=[...new Set(J.map(i=>i.citationKey))];return n.length?(se(!0),A("/api/citations/lookup",{method:"POST",body:JSON.stringify({keys:n}),signal:t.signal}).then(i=>{R(new Map(i.matches.map(o=>[o.citationKey.toLowerCase(),o])))}).catch(i=>{i instanceof Error&&i.name==="AbortError"||v(D(i))}).finally(()=>{t.signal.aborted||se(!1)}),()=>t.abort()):(R(new Map),se(!1),()=>t.abort())},[l,U,J,Ue]),s.useEffect(()=>{l&&(K("library"),d(""),C(""),h(1),V({page:1,pageSize:60,total:0,totalPages:0}),P(null),H(!1),ye(""),f(null),ge(null),ae(null),G(""),v(""),$(""),R(new Map))},[l,U]);const Ve=async t=>{B(t.citationKey),v("");try{const n=Le.get(t.citationKey.toLowerCase()),i=await A("/api/citations",{method:"POST",body:JSON.stringify({bibtex:t.bibtex,citationKey:t.citationKey,entryType:t.entryType,title:t.title,authors:t.authors,year:t.year,overwrite:!!n,expectedRevision:n?.revision})});E(o=>[i.entry,...o.filter(Y=>Y.id!==i.entry.id&&Y.citationKey.toLowerCase()!==i.entry.citationKey.toLowerCase())]),R(o=>new Map(o).set(i.entry.citationKey.toLowerCase(),{id:i.entry.id,citationKey:i.entry.citationKey,revision:i.entry.revision})),f(i.entry),_(i.entry.tags.map(o=>o.id)),$(i.updated?a("citationLibrary.updated"):a("citationLibrary.saved")),h(1),F(o=>o+1)}catch(n){v(D(n)),Je(i=>i+1)}finally{B(null)}},Se=async()=>{if(S){B(S.citationKey),v("");try{const t=Me(me,j);if(!t){v(a("citationErrors.invalid"));return}const n=await A(`/api/citations/${encodeURIComponent(S.id)}`,{method:"PATCH",body:JSON.stringify({bibtex:t.bibtex,citationKey:t.citationKey,entryType:t.entryType,title:t.title,authors:t.authors,year:t.year,expectedRevision:S.revision})});E(i=>[n.entry,...i.filter(o=>o.id!==n.entry.id)]),R(i=>{const o=new Map(i);return o.delete(S.citationKey.toLowerCase()),o.set(n.entry.citationKey.toLowerCase(),{id:n.entry.id,citationKey:n.entry.citationKey,revision:n.entry.revision}),o}),P(null),$(a("citationLibrary.updated")),h(1),F(i=>i+1)}catch(t){v(D(t))}finally{B(null)}}},Be=async()=>{if(ie.trim()){B("__new__"),v("");try{const t=Me(ie,j);if(!t){v(a("citationErrors.invalid"));return}const n=await A("/api/citations",{method:"POST",body:JSON.stringify({bibtex:t.bibtex,citationKey:t.citationKey,entryType:t.entryType,title:t.title,authors:t.authors,year:t.year})});E(i=>[n.entry,...i.filter(o=>o.id!==n.entry.id&&o.citationKey.toLowerCase()!==n.entry.citationKey.toLowerCase())]),R(i=>new Map(i).set(n.entry.citationKey.toLowerCase(),{id:n.entry.id,citationKey:n.entry.citationKey,revision:n.entry.revision})),H(!1),ye(""),$(n.updated?a("citationLibrary.updated"):a("citationLibraryActions.added")),f(n.entry),_(n.entry.tags.map(i=>i.id)),h(1),F(i=>i+1)}catch(t){v(D(t))}finally{B(null)}}},We=t=>{Q(i=>[...i.filter(o=>o.id!==t.id),t].sort((o,Y)=>o.name.localeCompare(Y.name)));const n=i=>({...i,tags:i.tags.map(o=>o.id===t.id?t:o)});E(i=>i.map(n)),f(i=>i?n(i):null),P(i=>i?n(i):null)},Ye=t=>{Q(i=>i.filter(o=>o.id!==t));const n=i=>({...i,tags:i.tags.filter(o=>o.id!==t)});E(i=>i.map(n)),f(i=>i?n(i):null),P(i=>i?n(i):null),_(i=>i.filter(o=>o!==t)),g===t&&(C(""),h(1))},Qe=t=>{P(null),H(!1),f(t),_(t.tags.map(n=>n.id))},be=async()=>{if(p){ve(!0),v("");try{const t=await A(`/api/citations/${encodeURIComponent(p.id)}/tags`,{method:"PATCH",body:JSON.stringify({tagIds:te,expectedRevision:p.revision})});E(n=>n.map(i=>i.id===t.entry.id?t.entry:i)),R(n=>new Map(n).set(t.entry.citationKey.toLowerCase(),{id:t.entry.id,citationKey:t.entry.citationKey,revision:t.entry.revision})),f(t.entry),_(t.entry.tags.map(n=>n.id)),$(a("citationLibrary.tagsUpdated")),F(n=>n+1)}catch(t){v(D(t))}finally{ve(!1)}}},Xe=async t=>{ge(t.id),G("");try{await A(`/api/citations/${encodeURIComponent(t.id)}`,{method:"DELETE"}),E(n=>n.filter(i=>i.id!==t.id)),R(n=>{const i=new Map(n);return i.delete(t.citationKey.toLowerCase()),i}),S?.id===t.id&&P(null),p?.id===t.id&&f(null),$(a("citationLibrary.deleted")),h(1),F(n=>n+1),ae(null)}catch(n){G(D(n))}finally{ge(null)}},Ee=e.jsxs("div",{className:"citation-library-dialog",children:[e.jsxs("div",{className:"citation-library-tabs",role:"tablist","aria-label":a("citationLibrary.title"),children:[e.jsxs("button",{type:"button",role:"tab","aria-selected":w==="library",className:w==="library"?"active":"",onClick:()=>K("library"),children:[e.jsx(oe,{size:15}),a("citationLibrary.myLibrary"),e.jsx("span",{children:u.total})]}),U&&e.jsxs("button",{type:"button",role:"tab","aria-selected":w==="current",className:w==="current"?"active":"",onClick:()=>K("current"),children:[e.jsx(le,{size:15}),a("citationLibrary.currentFile"),e.jsx("span",{children:J.length})]})]}),W&&!(b&&(p||S))&&e.jsx("p",{className:"error dialog-error",children:W}),ne&&e.jsxs("p",{className:"citation-library-notice",role:"status",children:[e.jsx(I,{size:14}),ne,e.jsx("button",{type:"button","aria-label":a("common.close"),onClick:()=>$(""),children:e.jsx(Z,{size:13})})]}),w==="library"?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"citation-library-search-row",children:[e.jsxs("label",{className:"citation-library-search",children:[e.jsx(st,{size:15}),e.jsx("input",{autoFocus:!0,placeholder:a("citationLibrary.searchPlaceholder"),value:m,onChange:t=>{d(t.target.value),h(1)}}),e.jsx("span",{children:a("citationLibrary.searchHint")})]}),e.jsxs("button",{type:"button",className:"citation-add-entry-button",onClick:()=>{H(!0),P(null),f(null)},children:[e.jsx(le,{size:14}),a("citationLibraryActions.addEntry")]})]}),e.jsx(lt,{tags:O,selectedId:g,onSelect:t=>{C(t),h(1)},onManage:()=>r(!0)}),$e&&e.jsxs("div",{className:"citation-edit-panel",children:[e.jsxs("div",{className:"citation-edit-header",children:[e.jsxs("div",{children:[e.jsx("strong",{children:a("citationLibraryActions.addEntryTitle")}),e.jsx("small",{children:a("citationLibraryActions.addEntryDescription")})]}),e.jsx("button",{type:"button","aria-label":a("common.close"),onClick:()=>H(!1),children:e.jsx(Z,{size:15})})]}),e.jsx("textarea",{autoFocus:!0,value:ie,onChange:t=>ye(t.target.value),placeholder:a("citationLibraryActions.addEntryPlaceholder"),spellCheck:!1,rows:9}),e.jsxs("div",{className:"citation-edit-actions",children:[e.jsx("button",{type:"button",onClick:()=>H(!1),children:a("common.cancel")}),e.jsxs("button",{type:"button",className:"primary",disabled:!ie.trim()||X==="__new__",onClick:()=>{Be()},children:[X==="__new__"?e.jsx(q,{className:"spin",size:14}):e.jsx(I,{size:14}),a("citationLibraryActions.addEntry")]})]})]}),_e?e.jsxs("div",{className:"citation-library-empty",children:[e.jsx(q,{className:"spin",size:22}),e.jsx("span",{children:a("common.loading")})]}):z.length===0?e.jsxs("div",{className:"citation-library-empty",children:[e.jsx(oe,{size:28}),e.jsx("strong",{children:a("citationLibrary.emptyTitle")}),e.jsx("span",{children:a(g?"citationLibrary.noTagMatches":"citationLibrary.emptyDescription")})]}):e.jsx("div",{className:"citation-entry-list",children:z.map(t=>e.jsxs("div",{className:"citation-entry-item",children:[e.jsx(Pe,{entry:t,selected:p?.id===t.id||S?.id===t.id,alreadyInFile:!b&&qe.has(t.citationKey.toLowerCase()),importDisabled:k,deleting:Ce===t.id,onImport:T?async()=>{await T(t)&&y(!1)}:void 0,onEdit:t.ownerId===N?()=>{f(null),H(!1),P(t),ue(t.bibtex)}:void 0,onTags:t.ownerId===N?()=>Qe(t):void 0,onDelete:t.ownerId===N?()=>{ae(t),G("")}:void 0,t:a}),!b&&p?.id===t.id&&e.jsx(je,{entry:p,tags:O,selectedIds:te,saving:de,onClose:()=>f(null),onToggle:n=>_(i=>i.includes(n)?i.filter(o=>o!==n):[...i,n]),onSave:()=>{be()},t:a}),!b&&S?.id===t.id&&e.jsx(Ae,{title:a("citationLibrary.editTitle",{key:S.citationKey}),value:me,saving:X===S.citationKey,onChange:ue,onClose:()=>P(null),onSave:()=>{Se()},t:a})]},t.id))}),u.totalPages>1&&e.jsxs("nav",{className:"citation-library-pagination","aria-label":a("citationLibraryPagination.pageOf",{page:u.page,totalPages:u.totalPages,count:u.total}),children:[e.jsxs("button",{type:"button",disabled:u.page<=1,onClick:()=>h(t=>Math.max(1,t-1)),children:[e.jsx(xe,{size:14}),a("citationLibraryPagination.previous")]}),e.jsx("span",{children:a("citationLibraryPagination.pageOf",{page:u.page,totalPages:u.totalPages,count:u.total})}),e.jsxs("button",{type:"button",disabled:u.page>=u.totalPages,onClick:()=>h(t=>Math.min(u.totalPages,t+1)),children:[a("citationLibraryPagination.next"),e.jsx(tt,{size:14})]})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"citation-current-heading",children:[e.jsxs("div",{children:[e.jsx("strong",{children:a("citationLibrary.currentFileTitle")}),e.jsx("span",{children:a("citationLibrary.currentFileDescription")})]}),e.jsxs("button",{type:"button",onClick:()=>K("library"),children:[e.jsx(xe,{size:14}),a("citationLibrary.backToLibrary")]})]}),Te&&e.jsxs("p",{className:"warning citation-library-warning",children:[e.jsx(Ke,{size:15}),a("citationLibrary.fileTooLarge",{size:at(j)})]}),we&&e.jsxs("p",{className:"warning citation-library-warning",children:[e.jsx(Ke,{size:15}),a("citationLibrary.fileInvalid")]}),J.length===0?e.jsxs("div",{className:"citation-library-empty",children:[e.jsx(oe,{size:28}),e.jsx("strong",{children:a("citationLibrary.noEntries")}),e.jsx("span",{children:a(Te?"citationLibrary.fileTooLargeHint":we?"citationLibrary.fileInvalidHint":"citationLibrary.noEntriesDescription")})]}):e.jsx("div",{className:"citation-entry-list",children:J.map((t,n)=>e.jsxs("div",{className:"citation-entry-item",children:[e.jsx(Pe,{entry:t,saved:Le.has(t.citationKey.toLowerCase()),saving:X===t.citationKey,saveDisabled:He,onSave:()=>{Ve(t)},t:a}),!b&&p?.citationKey.toLowerCase()===t.citationKey.toLowerCase()&&e.jsx(je,{entry:p,tags:O,selectedIds:te,saving:de,onClose:()=>f(null),onToggle:i=>_(o=>o.includes(i)?o.filter(Y=>Y!==i):[...o,i]),onSave:()=>{be()},t:a})]},`${t.citationKey}-${n}`))})]})]}),ke=e.jsx(Fe,{open:!!he,title:a("citationLibrary.deleteTitle"),description:a("citationLibrary.deleteDescription",{key:he?.citationKey??""}),confirmLabel:a("common.delete"),danger:!0,error:Ie,busy:!!Ce,onCancel:()=>{ae(null),G("")},onConfirm:()=>{const t=he;t&&Xe(t)}}),ze=l&&ee&&e.jsx(dt,{tags:O,onClose:()=>r(!1),onUpdated:We,onDeleted:Ye});return b?e.jsxs(e.Fragment,{children:[e.jsxs("section",{className:"citation-library-page",children:[e.jsxs("header",{className:"citation-library-page-header",children:[e.jsxs("div",{children:[e.jsxs("h1",{children:[e.jsx(oe,{"aria-hidden":!0,size:26}),a("citationLibrary.title")]}),e.jsx("p",{children:a("citationLibraryHomeDescription")})]}),L&&e.jsxs("button",{type:"button",onClick:L,children:[e.jsx(xe,{size:15}),a("projects.title")]})]}),Ee]}),p&&e.jsx(re,{open:!0,title:a("citationLibrary.tagsTitle",{key:p.citationKey}),description:a("citationLibrary.tags"),onOpenChange:t=>{t||(f(null),v(""))},children:e.jsxs(e.Fragment,{children:[W&&e.jsx("p",{className:"error dialog-error",children:W}),e.jsx(je,{entry:p,tags:O,selectedIds:te,saving:de,modal:!0,onClose:()=>{f(null),v("")},onToggle:t=>_(n=>n.includes(t)?n.filter(i=>i!==t):[...n,t]),onSave:()=>{be()},t:a})]})}),S&&e.jsx(re,{open:!0,extraWide:!0,title:a("citationLibrary.editTitle",{key:S.citationKey}),description:a("citationLibrary.title"),onOpenChange:t=>{t||(P(null),v(""))},children:e.jsxs(e.Fragment,{children:[W&&e.jsx("p",{className:"error dialog-error",children:W}),e.jsx(Ae,{title:a("citationLibrary.editTitle",{key:S.citationKey}),value:me,saving:X===S.citationKey,modal:!0,onChange:ue,onClose:()=>{P(null),v("")},onSave:()=>{Se()},t:a})]})}),ke,ze]}):e.jsxs(e.Fragment,{children:[e.jsx(re,{open:l,extraWide:!0,className:"citation-library-modal",title:a("citationLibrary.title"),description:a(U?"citationLibrary.description":"citationLibraryHomeDescription",{file:c}),onOpenChange:y,footer:e.jsx("button",{onClick:()=>y(!1),children:a("common.close")}),children:Ee}),ke,ze]})}function Pe({entry:l,selected:y,alreadyInFile:b,saved:L,saving:c,saveDisabled:x,importDisabled:k,deleting:N,onSave:j,onImport:T,onEdit:a,onTags:w,onDelete:K,t:m}){const d="id"in l,g=d?l:null,C=nt(l);return e.jsxs("article",{className:`citation-entry-card${y?" selected":""}${b?" already-in-file":""}`,title:b?m("citationErrors.alreadyInFile",{key:l.citationKey}):void 0,children:[e.jsxs("div",{className:"citation-entry-main",children:[e.jsxs("div",{className:"citation-entry-heading",children:[e.jsx("code",{children:l.citationKey}),e.jsxs("span",{children:["@",l.entryType]}),C&&e.jsx("span",{className:"citation-entry-venue",title:C,children:C}),L&&e.jsxs("em",{children:[e.jsx(I,{size:11}),m("citationLibrary.savedLabel")]})]}),e.jsx("strong",{children:l.title||m("citationLibrary.untitled")}),e.jsxs("p",{children:[l.authors||m("citationLibrary.authorUnknown"),l.year&&e.jsxs("span",{children:[" · ",l.year]})]}),g&&g.tags.length>0&&e.jsx("div",{className:"citation-entry-tags",children:g.tags.map(z=>e.jsxs("span",{className:`citation-tag-pill tag-${z.color}`,children:[e.jsx("span",{className:"citation-tag-dot"}),z.name]},z.id))})]}),e.jsxs("div",{className:"citation-entry-actions",children:[j&&e.jsxs("button",{type:"button",className:L?"saved":"primary",disabled:c||x,onClick:j,children:[c||x?e.jsx(q,{className:"spin",size:13}):L?e.jsx(I,{size:13}):e.jsx(le,{size:13}),m(c?"citationLibrary.saving":L?"citationLibrary.update":"citationLibrary.save")]}),T&&e.jsxs("button",{type:"button",disabled:k||b,title:b?m("citationErrors.alreadyInFile",{key:l.citationKey}):m(k?"citationLibrary.importRequiresWrite":"citationLibrary.importToFile"),onClick:()=>{T()},children:[e.jsx(ot,{size:13}),m("citationLibrary.import")]}),g&&w&&e.jsxs("button",{type:"button",onClick:w,children:[e.jsx(Re,{size:13}),m("citationLibrary.tags")]}),d&&a&&e.jsxs("button",{type:"button",onClick:a,children:[e.jsx(rt,{size:13}),m("common.edit")]}),d&&K&&e.jsxs("button",{type:"button",className:"danger-text",disabled:N,onClick:K,children:[N?e.jsx(q,{className:"spin",size:13}):e.jsx(Oe,{size:13}),m("common.delete")]})]})]})}function je({entry:l,tags:y,selectedIds:b,saving:L,modal:c=!1,onClose:x,onToggle:k,onSave:N,t:j}){const T=e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"citation-tag-choice-list",children:y.length===0?e.jsx("span",{className:"muted",children:j("citationLibrary.noTagsToAssign")}):y.map(a=>e.jsxs("label",{children:[e.jsx("input",{type:"checkbox",checked:b.includes(a.id),onChange:()=>k(a.id)}),e.jsx("span",{className:`citation-tag-dot tag-${a.color}`}),a.name]},a.id))}),e.jsxs("div",{className:"citation-edit-actions",children:[e.jsx("button",{type:"button",onClick:x,children:j("common.cancel")}),e.jsxs("button",{type:"button",className:"primary",disabled:L||y.length===0,onClick:N,children:[L?e.jsx(q,{className:"spin",size:14}):e.jsx(I,{size:14}),j("citationLibrary.saveTags")]})]})]});return c?e.jsx("div",{className:"citation-modal-form",children:T}):e.jsxs("div",{className:"citation-tag-editor",children:[e.jsxs("div",{className:"citation-edit-header",children:[e.jsx("strong",{children:j("citationLibrary.tagsTitle",{key:l.citationKey})}),e.jsx("button",{type:"button","aria-label":j("common.close"),onClick:x,children:e.jsx(Z,{size:15})})]}),T]})}function Ae({title:l,value:y,saving:b,modal:L=!1,onChange:c,onClose:x,onSave:k,t:N}){const j=e.jsxs(e.Fragment,{children:[e.jsx("textarea",{autoFocus:!L,value:y,onChange:T=>c(T.target.value),spellCheck:!1,rows:12}),e.jsxs("div",{className:"citation-edit-actions",children:[e.jsx("button",{type:"button",onClick:x,children:N("common.cancel")}),e.jsxs("button",{type:"button",className:"primary",disabled:!y.trim()||b,onClick:k,children:[b?e.jsx(q,{className:"spin",size:14}):e.jsx(I,{size:14}),N("common.save")]})]})]});return L?e.jsx("div",{className:"citation-modal-form citation-edit-panel",children:j}):e.jsxs("div",{className:"citation-edit-panel",children:[e.jsxs("div",{className:"citation-edit-header",children:[e.jsx("strong",{children:l}),e.jsx("button",{type:"button","aria-label":N("common.close"),onClick:x,children:e.jsx(Z,{size:15})})]}),j]})}export{Nt as CitationLibraryDialog};
@@ -0,0 +1,2 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./SystemMetricsDialog-DDpFwgXh.js","./react-CltQJflK.js","./index-DkpU9Fgs.js","./index-C0qg2Ylw.css","./refresh-cw-BE8IbaHI.js","./hard-drive-Ctj3K_zx.js","./x-C_3swJOC.js","./github-D-JDXb-w.js","./sigma-LxGD9tK2.js","./tags-DuN89PsZ.js","./CitationLibraryDialog-CU7Q7r0Z.js","./chevron-up-D5lCNKlk.js","./check-CwBYzomT.js","./plus-CCxK-HNt.js","./citationLibrary-C9WnXB-1.js","./search-CPbhRWQE.js","./AdminUsers-Dyapv-3c.js","./index-_eYe7K9T.js","./TagManagementDialog-CXLA9h_j.js","./ProjectIconPickerDialog-CqRmgFBM.js","./GitHubAccountDialog-CZ8O_PjD.js","./external-link-C9Td1CCj.js"])))=>i.map(i=>d[i]);
2
+ import{c as o,a as rt,s as Oe,S as ka,L as xa,b as Ft,M as oe,d as Be,e as Ue,C as fa,f as va,g as z,h as L,_ as ie,i as tt,j as ba}from"./index-DkpU9Fgs.js";import{j as e,r,u as Ma}from"./react-CltQJflK.js";import{H as Ca}from"./hard-drive-Ctj3K_zx.js";import{G as wa,F as Na,L as za,N as Sa,a as Ta,b as Pa,c as Aa,S as Da,B as Bt,d as La,e as Ea,P as Ia,D as Fa,T as qa,E as $a,M as Ut,A as Vt,f as at,U as Oa,g as qt,h as Ba,C as $t,i as Ua,j as Va,X as Ha,k as Ra}from"./x-C_3swJOC.js";import{F as _a,G as Za}from"./github-D-JDXb-w.js";import{S as Ga}from"./sigma-LxGD9tK2.js";import{T as st}from"./tags-DuN89PsZ.js";const Ka=o("Activity",[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]]);const Wa=o("ArchiveRestore",[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h2",key:"tvwodi"}],["path",{d:"M20 8v11a2 2 0 0 1-2 2h-2",key:"1gkqxj"}],["path",{d:"m9 15 3-3 3 3",key:"1pd0qc"}],["path",{d:"M12 12v9",key:"192myk"}]]);const Ve=o("Archive",[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8",key:"1s80jp"}],["path",{d:"M10 12h4",key:"a56b0p"}]]);const Ja=o("ArrowDownUp",[["path",{d:"m3 16 4 4 4-4",key:"1co6wj"}],["path",{d:"M7 20V4",key:"1yoxec"}],["path",{d:"m21 8-4-4-4 4",key:"1c9v7m"}],["path",{d:"M17 4v16",key:"7dpous"}]]);const Ht=o("ArrowRightLeft",[["path",{d:"m16 3 4 4-4 4",key:"1x1c3m"}],["path",{d:"M20 7H4",key:"zbl0bi"}],["path",{d:"m8 21-4-4 4-4",key:"h9nckh"}],["path",{d:"M4 17h16",key:"g4d7ey"}]]);const Qa=o("Atom",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["path",{d:"M20.2 20.2c2.04-2.03.02-7.36-4.5-11.9-4.54-4.52-9.87-6.54-11.9-4.5-2.04 2.03-.02 7.36 4.5 11.9 4.54 4.52 9.87 6.54 11.9 4.5Z",key:"1l2ple"}],["path",{d:"M15.7 15.7c4.52-4.54 6.54-9.87 4.5-11.9-2.03-2.04-7.36-.02-11.9 4.5-4.52 4.54-6.54 9.87-4.5 11.9 2.03 2.04 7.36.02 11.9-4.5Z",key:"1wam0m"}]]);const Xa=o("Beaker",[["path",{d:"M4.5 3h15",key:"c7n0jr"}],["path",{d:"M6 3v16a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V3",key:"m1uhx7"}],["path",{d:"M6 14h12",key:"4cwo0f"}]]);const Ya=o("Bookmark",[["path",{d:"m19 21-7-4-7 4V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v16z",key:"1fy3hk"}]]);const es=o("Bot",[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]]);const ts=o("Braces",[["path",{d:"M8 3H7a2 2 0 0 0-2 2v5a2 2 0 0 1-2 2 2 2 0 0 1 2 2v5c0 1.1.9 2 2 2h1",key:"ezmyqa"}],["path",{d:"M16 21h1a2 2 0 0 0 2-2v-5c0-1.1.9-2 2-2a2 2 0 0 1-2-2V5a2 2 0 0 0-2-2h-1",key:"e1hn23"}]]);const as=o("BrainCircuit",[["path",{d:"M12 5a3 3 0 1 0-5.997.125 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z",key:"l5xja"}],["path",{d:"M9 13a4.5 4.5 0 0 0 3-4",key:"10igwf"}],["path",{d:"M6.003 5.125A3 3 0 0 0 6.401 6.5",key:"105sqy"}],["path",{d:"M3.477 10.896a4 4 0 0 1 .585-.396",key:"ql3yin"}],["path",{d:"M6 18a4 4 0 0 1-1.967-.516",key:"2e4loj"}],["path",{d:"M12 13h4",key:"1ku699"}],["path",{d:"M12 18h6a2 2 0 0 1 2 2v1",key:"105ag5"}],["path",{d:"M12 8h8",key:"1lhi5i"}],["path",{d:"M16 8V5a2 2 0 0 1 2-2",key:"u6izg6"}],["circle",{cx:"16",cy:"13",r:".5",key:"ry7gng"}],["circle",{cx:"18",cy:"3",r:".5",key:"1aiba7"}],["circle",{cx:"20",cy:"21",r:".5",key:"yhc1fs"}],["circle",{cx:"20",cy:"8",r:".5",key:"1e43v0"}]]);const ss=o("Brain",[["path",{d:"M12 5a3 3 0 1 0-5.997.125 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z",key:"l5xja"}],["path",{d:"M12 5a3 3 0 1 1 5.997.125 4 4 0 0 1 2.526 5.77 4 4 0 0 1-.556 6.588A4 4 0 1 1 12 18Z",key:"ep3f8r"}],["path",{d:"M15 13a4.5 4.5 0 0 1-3-4 4.5 4.5 0 0 1-3 4",key:"1p4c4q"}],["path",{d:"M17.599 6.5a3 3 0 0 0 .399-1.375",key:"tmeiqw"}],["path",{d:"M6.003 5.125A3 3 0 0 0 6.401 6.5",key:"105sqy"}],["path",{d:"M3.477 10.896a4 4 0 0 1 .585-.396",key:"ql3yin"}],["path",{d:"M19.938 10.5a4 4 0 0 1 .585.396",key:"1qfode"}],["path",{d:"M6 18a4 4 0 0 1-1.967-.516",key:"2e4loj"}],["path",{d:"M19.967 17.484A4 4 0 0 1 18 18",key:"159ez6"}]]);const ns=o("Calculator",[["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",key:"1nb95v"}],["line",{x1:"8",x2:"16",y1:"6",y2:"6",key:"x4nwl0"}],["line",{x1:"16",x2:"16",y1:"14",y2:"18",key:"wjye3r"}],["path",{d:"M16 10h.01",key:"1m94wz"}],["path",{d:"M12 10h.01",key:"1nrarc"}],["path",{d:"M8 10h.01",key:"19clt8"}],["path",{d:"M12 14h.01",key:"1etili"}],["path",{d:"M8 14h.01",key:"6423bh"}],["path",{d:"M12 18h.01",key:"mhygvu"}],["path",{d:"M8 18h.01",key:"lrp35t"}]]);const Rt=o("CalendarDays",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"M8 14h.01",key:"6423bh"}],["path",{d:"M12 14h.01",key:"1etili"}],["path",{d:"M16 14h.01",key:"1gbofw"}],["path",{d:"M8 18h.01",key:"lrp35t"}],["path",{d:"M12 18h.01",key:"mhygvu"}],["path",{d:"M16 18h.01",key:"kzsmim"}]]);const rs=o("ChartColumn",[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M18 17V9",key:"2bz60n"}],["path",{d:"M13 17V5",key:"1frdt8"}],["path",{d:"M8 17v-3",key:"17ska0"}]]);const os=o("ChartLine",[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"m19 9-5 5-4-4-3 3",key:"2osh9i"}]]);const is=o("ChartNoAxesCombined",[["path",{d:"M12 16v5",key:"zza2cw"}],["path",{d:"M16 14v7",key:"1g90b9"}],["path",{d:"M20 10v11",key:"1iqoj0"}],["path",{d:"m22 3-8.646 8.646a.5.5 0 0 1-.708 0L9.354 8.354a.5.5 0 0 0-.707 0L2 15",key:"1fw8x9"}],["path",{d:"M4 18v3",key:"1yp0dc"}],["path",{d:"M8 14v7",key:"n3cwzv"}]]);const cs=o("ChartPie",[["path",{d:"M21 12c.552 0 1.005-.449.95-.998a10 10 0 0 0-8.953-8.951c-.55-.055-.998.398-.998.95v8a1 1 0 0 0 1 1z",key:"pzmjnu"}],["path",{d:"M21.21 15.89A10 10 0 1 1 8 2.83",key:"k2fpak"}]]);const ls=o("ChartScatter",[["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}],["circle",{cx:"18.5",cy:"5.5",r:".5",fill:"currentColor",key:"lysivs"}],["circle",{cx:"11.5",cy:"11.5",r:".5",fill:"currentColor",key:"byv1b8"}],["circle",{cx:"7.5",cy:"16.5",r:".5",fill:"currentColor",key:"nkw3mc"}],["circle",{cx:"17.5",cy:"14.5",r:".5",fill:"currentColor",key:"1gjh6j"}],["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}]]);const ds=o("CircuitBoard",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M11 9h4a2 2 0 0 0 2-2V3",key:"1ve2rv"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"M7 21v-4a2 2 0 0 1 2-2h4",key:"1fwkro"}],["circle",{cx:"15",cy:"15",r:"2",key:"3i40o0"}]]);const ps=o("Cloud",[["path",{d:"M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z",key:"p7xjir"}]]);const hs=o("CodeXml",[["path",{d:"m18 16 4-4-4-4",key:"1inbqp"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}],["path",{d:"m14.5 4-5 16",key:"e7oirm"}]]);const ms=o("Copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);const us=o("Cpu",[["rect",{width:"16",height:"16",x:"4",y:"4",rx:"2",key:"14l7u7"}],["rect",{width:"6",height:"6",x:"9",y:"9",rx:"1",key:"5aljv4"}],["path",{d:"M15 2v2",key:"13l42r"}],["path",{d:"M15 20v2",key:"15mkzm"}],["path",{d:"M2 15h2",key:"1gxd5l"}],["path",{d:"M2 9h2",key:"1bbxkp"}],["path",{d:"M20 15h2",key:"19e6y8"}],["path",{d:"M20 9h2",key:"19tzq7"}],["path",{d:"M9 2v2",key:"165o2o"}],["path",{d:"M9 20v2",key:"i2bqo8"}]]);const ys=o("Database",[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]]);const gs=o("Dna",[["path",{d:"m10 16 1.5 1.5",key:"11lckj"}],["path",{d:"m14 8-1.5-1.5",key:"1ohn8i"}],["path",{d:"M15 2c-1.798 1.998-2.518 3.995-2.807 5.993",key:"80uv8i"}],["path",{d:"m16.5 10.5 1 1",key:"696xn5"}],["path",{d:"m17 6-2.891-2.891",key:"xu6p2f"}],["path",{d:"M2 15c6.667-6 13.333 0 20-6",key:"1pyr53"}],["path",{d:"m20 9 .891.891",key:"3xwk7g"}],["path",{d:"M3.109 14.109 4 15",key:"q76aoh"}],["path",{d:"m6.5 12.5 1 1",key:"cs35ky"}],["path",{d:"m7 18 2.891 2.891",key:"1sisit"}],["path",{d:"M9 22c1.798-1.998 2.518-3.995 2.807-5.993",key:"q3hbxp"}]]);const js=o("Earth",[["path",{d:"M21.54 15H17a2 2 0 0 0-2 2v4.54",key:"1djwo0"}],["path",{d:"M7 3.34V5a3 3 0 0 0 3 3a2 2 0 0 1 2 2c0 1.1.9 2 2 2a2 2 0 0 0 2-2c0-1.1.9-2 2-2h3.17",key:"1tzkfa"}],["path",{d:"M11 21.95V18a2 2 0 0 0-2-2a2 2 0 0 1-2-2v-1a2 2 0 0 0-2-2H2.05",key:"14pb5j"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);const ks=o("FileChartColumnIncreasing",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M8 18v-2",key:"qcmpov"}],["path",{d:"M12 18v-4",key:"q1q25u"}],["path",{d:"M16 18v-6",key:"15y0np"}]]);const xs=o("FilePenLine",[["path",{d:"m18 5-2.414-2.414A2 2 0 0 0 14.172 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2",key:"142zxg"}],["path",{d:"M21.378 12.626a1 1 0 0 0-3.004-3.004l-4.01 4.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z",key:"2t3380"}],["path",{d:"M8 18h1",key:"13wk12"}]]);const fs=o("FileStack",[["path",{d:"M21 7h-3a2 2 0 0 1-2-2V2",key:"9rb54x"}],["path",{d:"M21 6v6.5c0 .8-.7 1.5-1.5 1.5h-7c-.8 0-1.5-.7-1.5-1.5v-9c0-.8.7-1.5 1.5-1.5H17Z",key:"1059l0"}],["path",{d:"M7 8v8.8c0 .3.2.6.4.8.2.2.5.4.8.4H15",key:"16874u"}],["path",{d:"M3 12v8.8c0 .3.2.6.4.8.2.2.5.4.8.4H11",key:"k2ox98"}]]);const vs=o("FlaskConical",[["path",{d:"M14 2v6a2 2 0 0 0 .245.96l5.51 10.08A2 2 0 0 1 18 22H6a2 2 0 0 1-1.755-2.96l5.51-10.08A2 2 0 0 0 10 8V2",key:"18mbvz"}],["path",{d:"M6.453 15h11.094",key:"3shlmq"}],["path",{d:"M8.5 2h7",key:"csnxdl"}]]);const bs=o("FolderArchive",[["circle",{cx:"15",cy:"19",r:"2",key:"u2pros"}],["path",{d:"M20.9 19.8A2 2 0 0 0 22 18V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2h5.1",key:"1jj40k"}],["path",{d:"M15 11v-1",key:"cntcp"}],["path",{d:"M15 17v-2",key:"1279jj"}]]);const Ms=o("FolderKanban",[["path",{d:"M4 20h16a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.93a2 2 0 0 1-1.66-.9l-.82-1.2A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13c0 1.1.9 2 2 2Z",key:"1fr9dc"}],["path",{d:"M8 10v4",key:"tgpxqk"}],["path",{d:"M12 10v2",key:"hh53o1"}],["path",{d:"M16 10v6",key:"1d6xys"}]]);const nt=o("FolderOpen",[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]]);const Cs=o("GraduationCap",[["path",{d:"M21.42 10.922a1 1 0 0 0-.019-1.838L12.83 5.18a2 2 0 0 0-1.66 0L2.6 9.08a1 1 0 0 0 0 1.832l8.57 3.908a2 2 0 0 0 1.66 0z",key:"j76jl0"}],["path",{d:"M22 10v6",key:"1lu8f3"}],["path",{d:"M6 12.5V16a6 3 0 0 0 12 0v-3.5",key:"1r8lef"}]]);const ws=o("History",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]]);const Ns=o("Image",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]]);const zs=o("Languages",[["path",{d:"m5 8 6 6",key:"1wu5hv"}],["path",{d:"m4 14 6-6 2-3",key:"1k1g8d"}],["path",{d:"M2 5h12",key:"or177f"}],["path",{d:"M7 2h1",key:"1t2jsx"}],["path",{d:"m22 22-5-10-5 10",key:"don7ne"}],["path",{d:"M14 18h6",key:"1m8k6r"}]]);const Ss=o("Library",[["path",{d:"m16 6 4 14",key:"ji33uf"}],["path",{d:"M12 6v14",key:"1n7gus"}],["path",{d:"M8 8v12",key:"1gg7y9"}],["path",{d:"M4 4v16",key:"6qkkli"}]]);const Ts=o("Lightbulb",[["path",{d:"M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5",key:"1gvzjb"}],["path",{d:"M9 18h6",key:"x1upvd"}],["path",{d:"M10 22h4",key:"ceow96"}]]);const Ps=o("Map",[["path",{d:"M14.106 5.553a2 2 0 0 0 1.788 0l3.659-1.83A1 1 0 0 1 21 4.619v12.764a1 1 0 0 1-.553.894l-4.553 2.277a2 2 0 0 1-1.788 0l-4.212-2.106a2 2 0 0 0-1.788 0l-3.659 1.83A1 1 0 0 1 3 19.381V6.618a1 1 0 0 1 .553-.894l4.553-2.277a2 2 0 0 1 1.788 0z",key:"169xi5"}],["path",{d:"M15 5.764v15",key:"1pn4in"}],["path",{d:"M9 3.236v15",key:"1uimfh"}]]);const As=o("Microscope",[["path",{d:"M6 18h8",key:"1borvv"}],["path",{d:"M3 22h18",key:"8prr45"}],["path",{d:"M14 22a7 7 0 1 0 0-14h-1",key:"1jwaiy"}],["path",{d:"M9 14h2",key:"197e7h"}],["path",{d:"M9 12a2 2 0 0 1-2-2V6h6v4a2 2 0 0 1-2 2Z",key:"1bmzmy"}],["path",{d:"M12 6V3a1 1 0 0 0-1-1H9a1 1 0 0 0-1 1v3",key:"1drr47"}]]);const Ds=o("Network",[["rect",{x:"16",y:"16",width:"6",height:"6",rx:"1",key:"4q2zg0"}],["rect",{x:"2",y:"16",width:"6",height:"6",rx:"1",key:"8cvhb9"}],["rect",{x:"9",y:"2",width:"6",height:"6",rx:"1",key:"1egb70"}],["path",{d:"M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3",key:"1jsf9p"}],["path",{d:"M12 12V8",key:"2874zd"}]]);const Ls=o("Newspaper",[["path",{d:"M4 22h16a2 2 0 0 0 2-2V4a2 2 0 0 0-2-2H8a2 2 0 0 0-2 2v16a2 2 0 0 1-2 2Zm0 0a2 2 0 0 1-2-2v-9c0-1.1.9-2 2-2h2",key:"7pis2x"}],["path",{d:"M18 14h-8",key:"sponae"}],["path",{d:"M15 18h-5",key:"95g1m2"}],["path",{d:"M10 6h8v4h-8V6Z",key:"smlsk5"}]]);const Es=o("NotebookPen",[["path",{d:"M13.4 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-7.4",key:"re6nr2"}],["path",{d:"M2 6h4",key:"aawbzj"}],["path",{d:"M2 10h4",key:"l0bgd4"}],["path",{d:"M2 14h4",key:"1gsvsf"}],["path",{d:"M2 18h4",key:"1bu2t1"}],["path",{d:"M21.378 5.626a1 1 0 1 0-3.004-3.004l-5.01 5.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z",key:"pqwjuv"}]]);const Is=o("PenTool",[["path",{d:"M15.707 21.293a1 1 0 0 1-1.414 0l-1.586-1.586a1 1 0 0 1 0-1.414l5.586-5.586a1 1 0 0 1 1.414 0l1.586 1.586a1 1 0 0 1 0 1.414z",key:"nt11vn"}],["path",{d:"m18 13-1.375-6.874a1 1 0 0 0-.746-.776L3.235 2.028a1 1 0 0 0-1.207 1.207L5.35 15.879a1 1 0 0 0 .776.746L13 18",key:"15qc1e"}],["path",{d:"m2.3 2.3 7.286 7.286",key:"1wuzzi"}],["circle",{cx:"11",cy:"11",r:"2",key:"xmgehs"}]]);const Fs=o("Presentation",[["path",{d:"M2 3h20",key:"91anmk"}],["path",{d:"M21 3v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V3",key:"2k9sn8"}],["path",{d:"m7 21 5-5 5 5",key:"bip4we"}]]);const qs=o("Quote",[["path",{d:"M16 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z",key:"rib7q0"}],["path",{d:"M5 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z",key:"1ymkrd"}]]);const $s=o("Regex",[["path",{d:"M17 3v10",key:"15fgeh"}],["path",{d:"m12.67 5.5 8.66 5",key:"1gpheq"}],["path",{d:"m12.67 10.5 8.66-5",key:"1dkfa6"}],["path",{d:"M9 17a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v2a2 2 0 0 0 2 2h2a2 2 0 0 0 2-2v-2z",key:"swwfx4"}]]);const Os=o("Rocket",[["path",{d:"M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09z",key:"m3kijz"}],["path",{d:"m12 15-3-3a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.35 22.35 0 0 1-4 2z",key:"1fmvmk"}],["path",{d:"M9 12H4s.55-3.03 2-4c1.62-1.08 5 0 5 0",key:"1f8sc4"}],["path",{d:"M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5",key:"qeys4"}]]);const Bs=o("Server",[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]]);const Us=o("ShieldCheck",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);const _t=o("Sparkles",[["path",{d:"M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .963 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.581a.5.5 0 0 1 0 .964L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.963 0z",key:"4pj2yx"}],["path",{d:"M20 3v4",key:"1olli1"}],["path",{d:"M22 5h-4",key:"1gvqau"}],["path",{d:"M4 17v2",key:"vumght"}],["path",{d:"M5 18H3",key:"zchphs"}]]);const Vs=o("StickyNote",[["path",{d:"M16 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V8Z",key:"qazsjp"}],["path",{d:"M15 3v4a2 2 0 0 0 2 2h4",key:"40519r"}]]);const Hs=o("Target",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"6",key:"1vlfrh"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]]);const Rs=o("Telescope",[["path",{d:"m10.065 12.493-6.18 1.318a.934.934 0 0 1-1.108-.702l-.537-2.15a1.07 1.07 0 0 1 .691-1.265l13.504-4.44",key:"k4qptu"}],["path",{d:"m13.56 11.747 4.332-.924",key:"19l80z"}],["path",{d:"m16 21-3.105-6.21",key:"7oh9d"}],["path",{d:"M16.485 5.94a2 2 0 0 1 1.455-2.425l1.09-.272a1 1 0 0 1 1.212.727l1.515 6.06a1 1 0 0 1-.727 1.213l-1.09.272a2 2 0 0 1-2.425-1.455z",key:"m7xp4m"}],["path",{d:"m6.158 8.633 1.114 4.456",key:"74o979"}],["path",{d:"m8 21 3.105-6.21",key:"1fvxut"}],["circle",{cx:"12",cy:"13",r:"2",key:"1c1ljs"}]]);const _s=o("Terminal",[["polyline",{points:"4 17 10 11 4 5",key:"akl6gq"}],["line",{x1:"12",x2:"20",y1:"19",y2:"19",key:"q2wloq"}]]);const Zs=o("TestTubeDiagonal",[["path",{d:"M21 7 6.82 21.18a2.83 2.83 0 0 1-3.99-.01a2.83 2.83 0 0 1 0-4L17 3",key:"1ub6xw"}],["path",{d:"m16 2 6 6",key:"1gw87d"}],["path",{d:"M12 16H4",key:"1cjfip"}]]);const Gs=o("TestTubes",[["path",{d:"M9 2v17.5A2.5 2.5 0 0 1 6.5 22A2.5 2.5 0 0 1 4 19.5V2",key:"1hjrqt"}],["path",{d:"M20 2v17.5a2.5 2.5 0 0 1-2.5 2.5a2.5 2.5 0 0 1-2.5-2.5V2",key:"16lc8n"}],["path",{d:"M3 2h7",key:"7s29d5"}],["path",{d:"M14 2h7",key:"7sicin"}],["path",{d:"M9 16H4",key:"1bfye3"}],["path",{d:"M20 16h-5",key:"ddnjpe"}]]);const Ks=o("University",[["circle",{cx:"12",cy:"10",r:"1",key:"1gnqs8"}],["path",{d:"M22 20V8h-4l-6-4-6 4H2v12a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2",key:"1qj5sn"}],["path",{d:"M6 17v.01",key:"roodi6"}],["path",{d:"M6 13v.01",key:"67c122"}],["path",{d:"M18 17v.01",key:"12ktxm"}],["path",{d:"M18 13v.01",key:"tn1rt1"}],["path",{d:"M14 22v-5a2 2 0 0 0-2-2a2 2 0 0 0-2 2v5",key:"11g7fi"}]]);const Ws=o("UsersRound",[["path",{d:"M18 21a8 8 0 0 0-16 0",key:"3ypg7q"}],["circle",{cx:"10",cy:"8",r:"5",key:"o932ke"}],["path",{d:"M22 20c0-3.37-2-6.5-4-8a5 5 0 0 0-.45-8.3",key:"10s06x"}]]);const Js=o("Workflow",[["rect",{width:"8",height:"8",x:"3",y:"3",rx:"2",key:"by2w9f"}],["path",{d:"M7 11v4a2 2 0 0 0 2 2h4",key:"xkn7yn"}],["rect",{width:"8",height:"8",x:"13",y:"13",rx:"2",key:"1cgmvn"}]]),Zt=["file-text","book-open","notebook-pen","book-marked","scroll-text","library","graduation-cap","presentation","image","folder-kanban","microscope","flask-conical","test-tube-diagonal","atom","dna","telescope","earth","map","languages","university","code-2","file-code-2","database","server","network","circuit-board","brain","brain-circuit","bot","shield-check","workflow","sigma","calculator","chart-no-axes-combined","line-chart","bar-chart-3","pie-chart","chart-scatter","file-spreadsheet","file-chart-column-increasing","lightbulb","rocket","target","sparkles","file-pen-line","file-stack","folder","folder-open","folder-archive","archive","bookmark","newspaper","notepad-text","sticky-note","pen-tool","quote","list-tree","file-search","beaker","test-tubes","folder-git-2","git-branch","terminal","braces","regex","cpu","hard-drive","cloud","users-round","calendar-days"],Qs=new Set(Zt);function Xs(s){return typeof s=="string"&&Qs.has(s)}function Ys(s){if(typeof s!="string")return null;const h=s.trim().replace(/^lucide:/i,"");return!h||h.length>96?null:/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(h)?h:null}const en={"file-text":Ea,"book-open":La,"notebook-pen":Es,"book-marked":Bt,"scroll-text":Da,library:Ss,"graduation-cap":Cs,presentation:Fs,image:Ns,"folder-kanban":Ms,microscope:As,"flask-conical":vs,"test-tube-diagonal":Zs,atom:Qa,dna:gs,telescope:Rs,earth:js,map:Ps,languages:zs,university:Ks,"code-2":hs,"file-code-2":Aa,database:ys,server:Bs,network:Ds,"circuit-board":ds,brain:ss,"brain-circuit":as,bot:es,"shield-check":Us,workflow:Js,sigma:Ga,calculator:ns,"chart-no-axes-combined":is,"line-chart":os,"bar-chart-3":rs,"pie-chart":cs,"chart-scatter":ls,"file-spreadsheet":Pa,"file-chart-column-increasing":ks,lightbulb:Ts,rocket:Os,target:Hs,sparkles:_t,"file-pen-line":xs,"file-stack":fs,folder:Ta,"folder-open":nt,"folder-archive":bs,archive:Ve,bookmark:Ya,newspaper:Ls,"notepad-text":Sa,"sticky-note":Vs,"pen-tool":Is,quote:qs,"list-tree":za,"file-search":Na,beaker:Xa,"test-tubes":Gs,"folder-git-2":_a,"git-branch":wa,terminal:_s,braces:ts,regex:$s,cpu:us,"hard-drive":Ca,cloud:ps,"users-round":Ws,"calendar-days":Rt},bn=Zt.map(s=>({name:s}));function tn(s){const h=Array.from(s.trim())[0];return h?h.toLocaleUpperCase():"?"}function an({icon:s,fallback:h,size:x=18}){const f=Xs(s)?en[s]:null;if(f)return e.jsx(f,{"aria-hidden":"true",size:x,strokeWidth:1.9});const v=Ys(s);if(v){const a=`url(${rt(`/api/project-icons/${encodeURIComponent(v)}`)})`,g={maskImage:a,WebkitMaskImage:a};return e.jsx("span",{"aria-hidden":"true",className:"project-icon-external-glyph",style:g})}return e.jsx("span",{"aria-hidden":"true",children:h})}function Gt({icon:s,projectName:h,editable:x=!1,onEdit:f,editLabel:v,title:c,className:a=""}){const g=e.jsx(an,{icon:s,fallback:tn(h)}),m=`project-icon-avatar${x?" editable":""}${a?` ${a}`:""}`;return x&&f?e.jsx("button",{type:"button",className:m,title:v,"aria-label":v,onClick:f,children:g}):e.jsx("span",{className:m,title:c,"aria-hidden":"true",children:g})}function Kt({project:s,currentUser:h,showArchived:x,archiveBusy:f,menuOpen:v,t:c,variant:a,onToggleMenu:g,onCloseMenu:m,onAssignTags:y,onRename:E,onDuplicate:l,onArchive:S,onTransfer:B,onDelete:T}){const b=r.useRef(null),P=s.permission==="owner",F=h.role==="admin"||h.canCreateProjects,Z=s.ownerId===h.id,U=s.permission==="owner";r.useEffect(()=>{if(!v)return;const d=I=>{I.target instanceof Node&&!b.current?.contains(I.target)&&m()},D=I=>{I.key==="Escape"&&m()};return document.addEventListener("pointerdown",d),document.addEventListener("keydown",D),()=>{document.removeEventListener("pointerdown",d),document.removeEventListener("keydown",D)}},[v,m]);const A=[{id:"tags",label:c("tags.assign"),icon:e.jsx(st,{"aria-hidden":!0,size:15}),section:"main",onSelect:y},...P?[{id:"rename",label:c("projects.rename"),icon:e.jsx(Ia,{"aria-hidden":!0,size:15}),section:"main",onSelect:E}]:[],...F?[{id:"duplicate",label:c("projects.duplicate"),icon:e.jsx(ms,{"aria-hidden":!0,size:15}),section:"main",onSelect:l}]:[],{id:"download",label:c("projects.download"),icon:e.jsx(Fa,{"aria-hidden":!0,size:15}),section:"main",href:rt(`/api/projects/${s.id}/download`)},{id:"archive",label:c(x?"projects.unarchive":"projects.archive"),icon:x?e.jsx(Wa,{"aria-hidden":!0,size:15}):e.jsx(Ve,{"aria-hidden":!0,size:15}),section:"main",disabled:f,onSelect:S},...Z?[{id:"transfer",label:c("projects.transfer"),icon:e.jsx(Ht,{"aria-hidden":!0,size:15}),section:"main",onSelect:B}]:[],...U?[{id:"delete",label:c("common.delete"),icon:e.jsx(qa,{"aria-hidden":!0,size:15}),section:"danger",onSelect:T}]:[]],ee=A.filter(d=>d.section==="main"),C=A.filter(d=>d.section==="danger"),ce=d=>{d.disabled||(m(),d.onSelect?.())};return e.jsxs("div",{ref:b,className:`project-action-menu-root project-action-menu-${a}`,onClick:d=>d.stopPropagation(),children:[e.jsx("button",{type:"button",className:"project-action-menu-trigger","aria-label":c("projects.projectActions",{project:s.name}),"aria-expanded":v,"aria-controls":`project-actions-${s.id}`,onClick:d=>{d.stopPropagation(),g()},children:e.jsx($a,{"aria-hidden":!0,size:19})}),v&&e.jsxs("div",{id:`project-actions-${s.id}`,className:"project-action-menu",role:"group","aria-label":c("projects.projectActions",{project:s.name}),children:[ee.map(d=>d.href?e.jsxs("a",{href:d.href,download:!0,onClick:D=>{D.stopPropagation(),m()},children:[d.icon,d.label]},d.id):e.jsxs("button",{type:"button",disabled:d.disabled,onClick:D=>{D.stopPropagation(),ce(d)},children:[d.icon,d.label]},d.id)),C.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"project-action-menu-separator","aria-hidden":"true"}),C.map(d=>e.jsxs("button",{type:"button",className:"danger",onClick:D=>{D.stopPropagation(),ce(d)},children:[d.icon,d.label]},d.id))]})]})]})}function sn({project:s,currentUser:h,showArchived:x,archiveBusy:f,menuOpen:v,t:c,formatCreatedDate:a,formatUpdatedTime:g,formatExactTime:m,onOpenProject:y,onOpenMention:E,onToggleMenu:l,onCloseMenu:S,onAssignTags:B,onRename:T,onDuplicate:b,onArchive:P,onTransfer:F,onDelete:Z,onChooseIcon:U}){const A=s.ownerDisplayName??s.ownerUsername??c("projects.deletedUser"),ee=s.lastModifiedDisplayName??s.lastModifiedUsername??c("projects.deletedUser");return e.jsxs("article",{className:`project-card project-list-row${s.ownerId===h.id?" owned-project":""}${v?" project-list-menu-open":""}`,onClick:C=>{C.target===C.currentTarget&&y()},children:[e.jsx(Gt,{icon:s.icon,projectName:s.name,title:s.name,editable:s.permission==="owner",editLabel:c("projectIcons.change"),onEdit:U,className:"project-list-avatar"}),e.jsx("span",{className:"project-list-summary",children:e.jsx("button",{type:"button",className:"project-list-cell-open project-list-summary-open",onClick:y,"aria-label":c("projects.openProject",{project:s.name}),children:e.jsxs("span",{className:"project-list-title-line",children:[e.jsx("strong",{className:"project-list-title",title:s.name,children:s.name}),!!(s.unresolvedCommentCount&&s.unresolvedCommentCount>0)&&e.jsxs("span",{className:"project-comments-badge unresolved",title:c("projects.unresolvedCommentsTooltip",{unresolved:s.unresolvedCommentCount,total:s.commentCount??s.unresolvedCommentCount}),children:[e.jsx(Ut,{"aria-hidden":!0,size:10}),e.jsx("span",{children:c("projects.unresolvedCount",{count:s.unresolvedCommentCount})})]}),s.tags?.length>0&&e.jsx("span",{className:"project-list-tags",children:s.tags.map(C=>e.jsx("span",{className:`tag tag-${C.color} project-list-tag`,title:C.name,children:C.name},C.id))})]})})}),e.jsxs("button",{type:"button",className:"project-list-cell-open project-list-owner",onClick:y,title:A,"aria-label":c("projects.openProject",{project:s.name}),children:[e.jsxs("span",{className:"sr-only",children:[c("projects.owner"),": "]}),A]}),e.jsxs("button",{type:"button",className:"project-list-cell-open project-list-created",onClick:y,title:m(s.createdAt),"aria-label":c("projects.openProject",{project:s.name}),children:[e.jsxs("span",{className:"sr-only",children:[c("projects.created"),": "]}),e.jsx("time",{dateTime:s.createdAt,children:a(s.createdAt)})]}),e.jsxs("button",{type:"button",className:"project-list-cell-open project-list-modified",onClick:y,title:c("projects.modifiedByUser",{time:m(s.updatedAt),user:ee}),"aria-label":c("projects.openProject",{project:s.name}),children:[e.jsxs("span",{className:"sr-only",children:[c("projects.modified"),": "]}),e.jsx("time",{dateTime:s.updatedAt,children:g(s.updatedAt)}),e.jsx("small",{children:c("projects.byUser",{user:ee})})]}),s.unreadMentionCount&&s.unreadMentionCount>0?e.jsxs("button",{className:"project-mentions-badge project-list-mentions",type:"button",title:c("projects.unreadMentionsTooltip",{count:s.unreadMentionCount}),onClick:E,children:[e.jsx(Vt,{"aria-hidden":!0,size:10}),e.jsx("span",{children:s.unreadMentionCount})]}):e.jsx("span",{className:"project-list-mentions"}),e.jsx(Kt,{variant:"list",project:s,currentUser:h,showArchived:x,archiveBusy:f,menuOpen:v,t:c,onToggleMenu:l,onCloseMenu:S,onAssignTags:B,onRename:T,onDuplicate:b,onArchive:P,onTransfer:F,onDelete:Z})]})}const nn=r.lazy(()=>ie(()=>import("./SystemMetricsDialog-DDpFwgXh.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9]),import.meta.url).then(s=>({default:s.SystemMetricsDialog}))),rn=r.lazy(()=>ie(()=>import("./CitationLibraryDialog-CU7Q7r0Z.js"),__vite__mapDeps([10,1,2,3,11,9,12,6,13,14,15]),import.meta.url).then(s=>({default:s.CitationLibraryDialog}))),on=r.lazy(()=>ie(()=>import("./AdminUsers-Dyapv-3c.js"),__vite__mapDeps([16,1,17,2,3,6,15]),import.meta.url).then(s=>({default:s.AdminUsers}))),cn=r.lazy(()=>ie(()=>import("./TagManagementDialog-CXLA9h_j.js"),__vite__mapDeps([18,1,2,3,13,6,12]),import.meta.url).then(s=>({default:s.TagManagementDialog}))),ln=r.lazy(()=>ie(()=>import("./ProjectIconPickerDialog-CqRmgFBM.js"),__vite__mapDeps([19,1,2,3,15,5,6,7,8,9]),import.meta.url).then(s=>({default:s.ProjectIconPickerDialog}))),dn=r.lazy(()=>ie(()=>import("./GitHubAccountDialog-CZ8O_PjD.js"),__vite__mapDeps([20,1,2,3,7,6,21]),import.meta.url).then(s=>({default:s.GitHubAccountDialog})));function pn(s){return s instanceof Error&&s.name==="AbortError"}function hn(s,h,x,f){const v=new Date(s).getTime();if(!Number.isFinite(v))return s;const c=v-x,a=Math.abs(c),g=60*1e3,m=60*g,y=24*m,E=3*y;if(a>E){const T=Math.floor(a/y),b=c<0?"Past":"Future";return f(`projects.relativeDays${b}`,{days:T,hours:0,minutes:0})}if(a>=y){const T=Math.floor(a/y),b=Math.floor(a%y/m),P=c<0?"Past":"Future",F=b>0?"DaysHours":"Days";return f(`projects.relative${F}${P}`,{days:T,hours:b,minutes:0})}if(a>=m){const T=Math.floor(a/m),b=Math.floor(a%m/g),P=c<0?"Past":"Future",F=b>0?"HoursMinutes":"Hours";return f(`projects.relative${F}${P}`,{days:0,hours:T,minutes:b})}const l="minute",S=g,B=Math.sign(c)*Math.max(1,Math.floor(a/S));return new Intl.RelativeTimeFormat(h,{numeric:"always"}).format(B,l)}function mn(s){return s<1024?`${s} B`:s<1024*1024?`${(s/1024).toFixed(1)} KB`:`${(s/1024/1024).toFixed(1)} MB`}function un({site:s,user:h,initialData:x,onDataChange:f,onUser:v,onOpenProject:c}){const{t:a}=Ma(),[g,m]=r.useState(()=>x?.projects??[]),[y,E]=r.useState(()=>x?.tags??[]),[l,S]=r.useState(()=>x?.pagination??{page:1,pageSize:20,total:x?.projects.length??0,totalPages:x?.projects.length?1:0}),[B,T]=r.useState(!!x),[b,P]=r.useState(!1),[F,Z]=r.useState(!1),[U,A]=r.useState(!1),[ee,C]=r.useState(!1),[ce,d]=r.useState(""),[D,I]=r.useState(""),[ot,te]=r.useState(""),[it,G]=r.useState(""),[ct,K]=r.useState(""),[Wt,le]=r.useState(""),[Jt,ke]=r.useState(!1),[xe,lt]=r.useState(""),[W,dt]=r.useState(!1),[Qt,fe]=r.useState(!1),[He,Re]=r.useState(""),[V,pt]=r.useState(null),[ht,H]=r.useState(""),[de,_e]=r.useState(null),[Ze,ve]=r.useState(null),be=r.useRef(null),mt=r.useRef(null),[M,ut]=r.useState(!1),[R,Xt]=r.useState(""),[w,yt]=r.useState(""),[Me,Ge]=r.useState(!1),[Yt,Ke]=r.useState(!1),[J,Q]=r.useState(null),[gt,Ce]=r.useState(null),[We,pe]=r.useState(null),[we,Ne]=r.useState(""),[X,jt]=r.useState(!1),[ze,he]=r.useState(null),[Se,ae]=r.useState(""),[Te,kt]=r.useState(!1),[me,Pe]=r.useState(null),[Ae,xt]=r.useState(!1),[De,Le]=r.useState(null),[Je,ft]=r.useState([]),[Ee,ue]=r.useState(""),[se,Ie]=r.useState(!1),[vt,ne]=r.useState(""),[ye,ea]=r.useState(()=>localStorage.getItem(Oe("texlite-project-view"))==="list"?"list":"grid"),[q,ta]=r.useState(()=>localStorage.getItem(Oe("texlite-project-sort"))==="created"?"created":"updated"),[u,aa]=r.useState(!1),[bt,Mt]=r.useState(""),[Fe,_]=r.useState(null),[N,$]=r.useState(1),[sa,na]=r.useState(()=>Date.now()),[Ct,ra]=r.useState(""),Qe=r.useRef(0),ge=r.useRef(null),wt=(t,n,i,p,k)=>`${t?"archived":"active"}|${n}|${i}|${p}|${k}`,Nt=wt(u,N,R,w,q),je=(t,n,i,p,k)=>{const j=new URLSearchParams({page:String(n),pageSize:"20",sort:k});t&&j.set("archived","1"),i.trim()&&j.set("search",i.trim()),p&&j.set("tag",p);const O=wt(t,n,i,p,k),Y=++Qe.current;ge.current?.abort();const $e=new AbortController;return ge.current=$e,Promise.all([z(`/api/projects?${j.toString()}`,{signal:$e.signal}),z("/api/tags",{signal:$e.signal})]).then(([re,ja])=>{Y===Qe.current&&(m(re.projects),E(ja.tags),S(re.pagination),$(re.pagination.page),T(!0),ra(O))}).catch(re=>{!pn(re)&&Y===Qe.current&&d(L(re))}).finally(()=>{ge.current===$e&&(ge.current=null)})};r.useEffect(()=>(je(u,N,R,w,q),()=>ge.current?.abort()),[u,N,R,w,q]),r.useEffect(()=>{B&&!u&&Ct===Nt&&f(g,y,l)},[g,y,l,B,Ct,Nt,u]),r.useEffect(()=>{const t=window.setInterval(()=>na(Date.now()),6e4);return()=>window.clearInterval(t)},[]),r.useEffect(()=>{if(!Me)return;const t=i=>{i.target instanceof Node&&!mt.current?.contains(i.target)&&Ge(!1)},n=i=>{i.key==="Escape"&&Ge(!1)};return document.addEventListener("pointerdown",t),document.addEventListener("keydown",n),()=>{document.removeEventListener("pointerdown",t),document.removeEventListener("keydown",n)}},[Me]);const zt=t=>{_(null),ea(t),localStorage.setItem(Oe("texlite-project-view"),t)},oa=t=>{ta(t),$(1),localStorage.setItem(Oe("texlite-project-sort"),t)},Xe=t=>{aa(t),$(1)},St=t=>{yt(t),$(1)},Tt=async()=>{if(!(!xe.trim()||W)){dt(!0),I("");try{const{project:t}=await z("/api/projects",{method:"POST",body:JSON.stringify({name:xe})});ke(!1),lt("");const n=u||N!==1?g:[t,...g].slice(0,l.pageSize),i=u?l:{...l,total:l.total+1,totalPages:Math.ceil((l.total+1)/l.pageSize)};m(n),S(i),u||f(n,y,i),c(t.id)}catch(t){I(L(t))}finally{dt(!1)}}},ia=async()=>{if(!V)return;const t=V,n=s.maxUploadSizeMB;if(t.size>n*1024*1024)return H(a("errors.fileTooLarge",{size:n}));ut(!0),H(""),_e("uploading"),ve(0);const i=new FormData;i.append("file",t);try{const{project:p}=await ba(`/api/projects/import?name=${encodeURIComponent(He.trim())}`,i,{onProgress:(O,Y)=>{ve(Y?Math.min(99,Math.floor(O/Y*100)):null)},onUploadComplete:()=>{ve(null),_e("processing")}}),k=u||N!==1?g:[p,...g].slice(0,l.pageSize),j=u?l:{...l,total:l.total+1,totalPages:Math.ceil((l.total+1)/l.pageSize)};m(k),S(j),u||f(k,y,j),fe(!1),pt(null),Re(""),c(p.id)}catch(p){H(L(p))}finally{ut(!1),_e(null),ve(null)}},Ye=t=>{if(!M){if(t&&!t.name.toLocaleLowerCase().endsWith(".zip")){H(a("errors.zipOnly"));return}H(""),pt(t),t&&!He&&Re(t.name.replace(/\.zip$/i,""))}},ca=async()=>{await z("/api/auth/logout",{method:"POST"}),v(null)},la=async t=>{if(!J)return;const n=J.tags.some(i=>i.id===t.id);te("");try{const p=(await z(n?`/api/projects/${J.id}/tags/${t.id}`:`/api/projects/${J.id}/tags`,n?{method:"DELETE"}:{method:"POST",body:JSON.stringify({tagId:t.id})})).project;Q(p),m(k=>k.map(j=>j.id===p.id?p:j))}catch(i){te(L(i))}},da=t=>{E(n=>[...n,t].sort((i,p)=>i.name.localeCompare(p.name)))},pa=t=>{const n=i=>i.map(p=>p.id===t.id?t:p);E(i=>n(i).sort((p,k)=>p.name.localeCompare(k.name))),m(i=>i.map(p=>({...p,tags:n(p.tags)}))),Q(i=>i?{...i,tags:n(i.tags)}:null)},ha=t=>{E(n=>n.filter(i=>i.id!==t)),m(n=>n.map(i=>({...i,tags:i.tags.filter(p=>p.id!==t)}))),Q(n=>n?{...n,tags:n.tags.filter(i=>i.id!==t)}:null),yt(n=>n===t?"":n)},ma=async(t,n)=>{const i=await z(`/api/projects/${t}/icon`,{method:"PATCH",body:JSON.stringify({icon:n})});m(p=>{const k=p.map(j=>j.id===i.project.id?i.project:j);return q==="updated"?k.sort((j,O)=>O.updatedAt.localeCompare(j.updatedAt)||j.name.localeCompare(O.name)):k})},Pt=async()=>{if(!(!We||!we.trim()||X)){jt(!0),G("");try{const t=await z(`/api/projects/${We.id}`,{method:"PATCH",body:JSON.stringify({name:we})});m(n=>n.map(i=>i.id===t.project.id?t.project:i)),pe(null),Ne("")}catch(t){G(L(t))}finally{jt(!1)}}},At=async()=>{if(!(!ze||!Se.trim())){kt(!0),K("");try{await z(`/api/projects/${ze.id}/duplicate`,{method:"POST",body:JSON.stringify({name:Se})}),he(null),ae(""),je(u,N,R,w,q)}catch(t){K(L(t))}finally{kt(!1)}}},ua=async()=>{if(!(!me||Ae)){xt(!0),le("");try{await z(`/api/projects/${me.id}`,{method:"DELETE"}),m(k=>k.filter(j=>j.id!==me.id));const t=Math.max(0,l.total-1),n=Math.ceil(t/l.pageSize),i=n===0?1:Math.min(N,n),p={...l,page:i,total:t,totalPages:n};S(p),Pe(null),i!==N?$(i):je(u,N,R,w,q)}catch(t){le(L(t))}finally{xt(!1)}}},Dt=async t=>{Le(t),ue(""),ft([]),ne(""),Ie(!0);try{const n=await z("/api/users");ft(n.users.filter(i=>i.id!==t.ownerId))}catch(n){ne(L(n))}finally{Ie(!1)}},ya=async()=>{if(!(!De||!Ee)){Ie(!0),ne("");try{await z(`/api/projects/${De.id}/owner`,{method:"PUT",body:JSON.stringify({userId:Ee})}),Le(null),ue(""),je(u,N,R,w,q)}catch(t){ne(L(t))}finally{Ie(!1)}}},Lt=async t=>{const n=!u;Mt(t.id),d("");try{await z(`/api/projects/${t.id}/archive`,{method:n?"PUT":"DELETE"});const i=g.filter(Y=>Y.id!==t.id);m(i);const p=Math.max(0,l.total-1),k=Math.ceil(p/l.pageSize),j=k===0?1:Math.min(N,k),O={...l,page:j,total:p,totalPages:k};S(O),u||f(i,y,O),j!==N?$(j):je(u,N,R,w,q)}catch(i){d(L(i))}finally{Mt("")}},Et=async t=>{try{const i=(await z(`/api/projects/${t.id}/mentions?unread=1&limit=1`)).mentions[0];c(t.id,i?.id)}catch(n){d(L(n))}},qe=g,et=t=>new Date(t).toLocaleString(tt.resolvedLanguage),ga=t=>{const n=new Date(t);return Number.isFinite(n.getTime())?new Intl.DateTimeFormat(tt.resolvedLanguage??"en",{year:"numeric",month:"2-digit",day:"2-digit"}).format(n):t},It=t=>hn(t,tt.resolvedLanguage??"en",sa,(n,i)=>a(n,i));return e.jsxs("div",{className:"page",children:[e.jsxs("header",{className:"topbar",children:[e.jsxs("a",{className:"brand-link",href:rt("/"),"aria-label":s.siteName,children:[e.jsx(ka,{siteName:s.siteName}),e.jsx("span",{className:"site-title",children:s.siteName})]}),e.jsxs("div",{className:"top-actions",children:[h.role==="admin"&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{className:"ghost",onClick:()=>Z(!0),children:[e.jsx(Ka,{"aria-hidden":!0,size:14}),a("metrics.title")]}),e.jsxs("button",{className:`ghost${b?" top-return-action":""}`,onClick:()=>{P(t=>!t),A(!1)},children:[b?e.jsx(at,{"aria-hidden":!0,size:14}):e.jsx(Oa,{"aria-hidden":!0,size:14}),a(b?"users.back":"users.manage")]})]}),e.jsxs("button",{className:`ghost${U?" top-return-action":""}`,onClick:()=>{P(!1),A(t=>!t)},children:[U?e.jsx(at,{"aria-hidden":!0,size:14}):e.jsx(Bt,{"aria-hidden":!0,size:14}),a(U?"users.back":"citationLibrary.title")]}),e.jsx(xa,{compact:!0}),e.jsxs("button",{type:"button",className:"top-user-identity",title:a("account.openGithubSettings"),"aria-label":a("account.openGithubSettings"),onClick:()=>C(!0),children:[e.jsx("strong",{children:h.displayName}),e.jsxs("small",{children:[e.jsx(Za,{"aria-hidden":!0,size:11}),"@",h.username]})]}),e.jsx("button",{className:"ghost",onClick:ca,children:a("auth.logout")})]})]}),b?e.jsx("main",{className:"dashboard",children:e.jsx(Ft,{onClose:()=>P(!1),children:e.jsx(on,{currentUser:h,minPasswordLength:s.minPasswordLength})})}):U?e.jsx("main",{className:"dashboard citation-library-page-shell",children:e.jsx(Ft,{onClose:()=>A(!1),children:e.jsx(rn,{page:!0,open:!0,onOpenChange:A,onBack:()=>A(!1),currentUserId:h.id,maxBibtexBytes:s.maxCitationBibtexBytes})})}):e.jsxs("main",{className:"dashboard",children:[e.jsxs("div",{className:"section-title",children:[e.jsxs("div",{children:[e.jsxs("h1",{children:[e.jsx(nt,{"aria-hidden":!0,size:25}),a("projects.title")]}),e.jsx("p",{className:"muted",children:h.canCreateProjects?a("projects.subtitle"):a("projects.restricted")})]}),e.jsxs("div",{className:"section-actions",children:[e.jsxs("button",{onClick:()=>Ke(!0),children:[e.jsx(st,{"aria-hidden":!0,size:15}),a("tags.manage")]}),h.canCreateProjects&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:()=>{H(""),fe(!0)},children:[e.jsx(qt,{"aria-hidden":!0,size:15}),a("projects.upload")]}),e.jsxs("button",{className:"primary",onClick:()=>{I(""),ke(!0)},children:[e.jsx(Ba,{"aria-hidden":!0,size:15}),a("projects.new")]})]})]})]}),ce&&e.jsx("p",{className:"error",children:ce}),e.jsxs("div",{className:"project-catalog-layout",children:[e.jsxs("aside",{ref:mt,className:`project-tag-sidebar${w?" has-active-filter":""}`,children:[e.jsxs("button",{type:"button",className:"project-tag-toggle",title:a("projects.filterTags"),"aria-label":a("projects.filterTags"),"aria-expanded":Me,"aria-controls":"dashboard-tag-filters",onClick:()=>Ge(t=>!t),children:[e.jsxs("span",{className:"project-tag-toggle-copy",children:[e.jsx(st,{"aria-hidden":!0,size:15}),e.jsx("span",{children:a("projects.filterTags")})]}),e.jsx($t,{className:"project-tag-toggle-chevron","aria-hidden":!0,size:15})]}),Me&&e.jsxs("div",{id:"dashboard-tag-filters",className:"project-tag-filters",role:"group","aria-label":a("projects.filterTags"),children:[e.jsx("button",{type:"button",className:w?"":"active","aria-pressed":!w,onClick:()=>St(""),children:a("projects.allTags")}),y.length>0?y.map(t=>e.jsxs("button",{type:"button",className:w===t.id?"active":"",title:t.name,"aria-pressed":w===t.id,onClick:()=>St(w===t.id?"":t.id),children:[e.jsx(Ot,{color:t.color}),e.jsx("span",{children:t.name})]},t.id)):e.jsx("p",{className:"project-tag-empty",children:a("tags.none")})]})]}),e.jsxs("div",{className:"project-catalog-content",children:[e.jsxs("div",{className:"project-toolbar",children:[e.jsx("input",{type:"search",placeholder:a("projects.search"),value:R,onChange:t=>{Xt(t.target.value),$(1)}}),e.jsxs("div",{className:"project-scope",role:"tablist","aria-label":a("projects.scope"),children:[e.jsxs("button",{className:u?"":"active",onClick:()=>Xe(!1),role:"tab","aria-selected":!u,children:[e.jsx(nt,{size:14}),a("projects.active")]}),e.jsxs("button",{className:u?"active":"",onClick:()=>Xe(!0),role:"tab","aria-selected":u,children:[e.jsx(Ve,{size:14}),a("projects.archived")]})]}),e.jsxs("label",{className:"project-sort",children:[e.jsx(Ja,{size:14}),e.jsx("span",{children:a("projects.sortBy")}),e.jsxs("select",{value:q,onChange:t=>oa(t.target.value),children:[e.jsx("option",{value:"updated",children:a("projects.sortModified")}),e.jsx("option",{value:"created",children:a("projects.sortCreated")})]})]}),e.jsxs("div",{className:"view-toggle",children:[e.jsx("button",{className:ye==="grid"?"active":"",onClick:()=>zt("grid"),title:a("projects.grid"),children:"▦"}),e.jsx("button",{className:ye==="list"?"active":"",onClick:()=>zt("list"),title:a("projects.list"),children:"☷"})]})]}),e.jsxs("div",{className:`project-grid ${ye==="list"?"list-view":""}${Fe?" project-list-menu-active":""}`,children:[ye==="list"&&qe.length>0&&e.jsxs("div",{className:"project-list-header","aria-hidden":"true",children:[e.jsx("span",{className:"project-list-header-avatar"}),e.jsx("span",{children:a("projects.title")}),e.jsx("span",{children:a("projects.owner")}),e.jsx("span",{className:"project-list-header-created",children:a("projects.created")}),e.jsx("span",{children:a("projects.modified")}),e.jsx("span",{className:"project-list-header-mentions",children:a("projects.mentionsColumn")}),e.jsx("span",{className:"project-list-header-actions",children:a("projects.actions")})]}),ye==="list"?qe.map(t=>e.jsx(sn,{project:t,currentUser:h,showArchived:u,archiveBusy:bt===t.id,menuOpen:Fe===t.id,t:a,formatCreatedDate:ga,formatUpdatedTime:It,formatExactTime:et,onOpenProject:()=>{_(null),c(t.id)},onOpenMention:()=>{Et(t)},onToggleMenu:()=>_(n=>n===t.id?null:t.id),onCloseMenu:()=>_(n=>n===t.id?null:n),onAssignTags:()=>{te(""),Q(t)},onRename:()=>{G(""),pe(t),Ne(t.name)},onDuplicate:()=>{K(""),he(t),ae(`${t.name} (1)`)},onArchive:()=>{Lt(t)},onTransfer:()=>{Dt(t)},onDelete:()=>{Pe(t),le("")},onChooseIcon:()=>Ce(t)},t.id)):qe.map(t=>e.jsxs("article",{className:`project-card project-grid-card${t.ownerId===h.id?" owned-project":""}${Fe===t.id?" project-card-menu-open":""}`,role:"button",tabIndex:0,"aria-label":a("projects.openProject",{project:t.name}),onClick:()=>{_(null),c(t.id)},onKeyDown:n=>{n.target!==n.currentTarget||n.key!=="Enter"&&n.key!==" "||(n.preventDefault(),_(null),c(t.id))},children:[e.jsxs("div",{className:"project-card-meta-row",children:[e.jsxs("div",{className:"project-card-badges",children:[e.jsx("span",{className:"owner-badge",title:t.ownerDisplayName??t.ownerUsername??a("projects.deletedUser"),children:t.ownerDisplayName??t.ownerUsername??a("projects.deletedUser")}),!!(t.unreadMentionCount&&t.unreadMentionCount>0)&&e.jsxs("button",{className:"project-mentions-badge",type:"button",title:a("projects.unreadMentionsTooltip",{count:t.unreadMentionCount}),"aria-label":a("projects.unreadMentionsTooltip",{count:t.unreadMentionCount}),onClick:n=>{n.stopPropagation(),Et(t)},children:[e.jsx(Vt,{"aria-hidden":!0,size:11}),e.jsx("span",{children:t.unreadMentionCount})]})]}),e.jsx(Kt,{variant:"grid",project:t,currentUser:h,showArchived:u,archiveBusy:bt===t.id,menuOpen:Fe===t.id,t:a,onToggleMenu:()=>_(n=>n===t.id?null:t.id),onCloseMenu:()=>_(n=>n===t.id?null:n),onAssignTags:()=>{te(""),Q(t)},onRename:()=>{G(""),pe(t),Ne(t.name)},onDuplicate:()=>{K(""),he(t),ae(`${t.name} (1)`)},onArchive:()=>{Lt(t)},onTransfer:()=>{Dt(t)},onDelete:()=>{Pe(t),le("")}})]}),e.jsxs("div",{className:"project-card-title-row",children:[e.jsx("span",{className:"project-card-icon-control",onClick:t.permission==="owner"?n=>n.stopPropagation():void 0,children:e.jsx(Gt,{icon:t.icon,projectName:t.name,title:t.name,editable:t.permission==="owner",editLabel:a("projectIcons.change"),onEdit:()=>Ce(t),className:"project-card-icon"})}),e.jsx("strong",{className:"project-card-title",title:t.name,children:t.name})]}),e.jsx("div",{className:"project-card-tags","aria-label":a("tags.assignTitle",{project:t.name}),title:t.tags?.map(n=>n.name).join(", ")||void 0,children:t.tags?.map(n=>e.jsx("span",{className:`tag tag-${n.color}`,title:n.name,children:n.name},n.id))}),e.jsxs("dl",{className:"project-meta",children:[e.jsxs("div",{children:[e.jsxs("dt",{className:"project-meta-created-label",children:[e.jsxs("span",{children:[e.jsx(Rt,{"aria-hidden":!0,size:13}),a("projects.created")]}),!!(t.unresolvedCommentCount&&t.unresolvedCommentCount>0)&&e.jsxs("span",{className:"project-comments-badge unresolved",title:a("projects.unresolvedCommentsTooltip",{unresolved:t.unresolvedCommentCount,total:t.commentCount??t.unresolvedCommentCount}),children:[e.jsx(Ut,{"aria-hidden":!0,size:11}),e.jsx("span",{children:a("projects.unresolvedCount",{count:t.unresolvedCommentCount})})]})]}),e.jsx("dd",{children:e.jsx("time",{dateTime:t.createdAt,children:et(t.createdAt)})})]}),e.jsxs("div",{children:[e.jsxs("dt",{children:[e.jsx(ws,{"aria-hidden":!0,size:13}),a("projects.modified")]}),e.jsxs("dd",{title:a("projects.modifiedByUser",{time:et(t.updatedAt),user:t.lastModifiedDisplayName??t.lastModifiedUsername??a("projects.deletedUser")}),children:[e.jsx("time",{dateTime:t.updatedAt,children:It(t.updatedAt)}),e.jsxs("span",{className:"project-modified-by",children:[" · ",a("projects.byUser",{user:t.lastModifiedDisplayName??t.lastModifiedUsername??a("projects.deletedUser")})]})]})]})]})]},t.id)),qe.length===0&&(g.length===0?u?e.jsxs("div",{className:"project-empty project-empty-archived",children:[e.jsx("span",{className:"project-empty-icon",children:e.jsx(Ve,{"aria-hidden":"true",size:25,strokeWidth:1.5})}),e.jsx("h2",{children:a("projects.noArchived")}),e.jsx("p",{children:a("projects.noArchivedDescription")}),e.jsxs("button",{type:"button",className:"project-empty-action",onClick:()=>Xe(!1),children:[e.jsx(at,{"aria-hidden":"true",size:14}),a("projects.backToActive")]})]}):e.jsxs("div",{className:"project-empty",children:[e.jsx("span",{className:"project-empty-icon",children:e.jsx(_t,{size:28})}),e.jsx("h2",{children:a("projects.emptyTitle")}),e.jsx("p",{children:h.canCreateProjects?a("projects.emptyDescription"):a("projects.emptyRestricted")})]}):e.jsx("div",{className:"empty",children:a("projects.noMatches")}))]}),l.totalPages>1&&e.jsxs("nav",{className:"project-pagination","aria-label":a("projects.pagination"),children:[e.jsxs("button",{disabled:l.page<=1,onClick:()=>$(t=>Math.max(1,t-1)),title:a("projects.previousPage"),children:[e.jsx(Ua,{size:15}),a("projects.previousPage")]}),e.jsx("span",{children:a("projects.pageOf",{page:l.page,totalPages:l.totalPages,count:l.total})}),e.jsxs("button",{disabled:l.page>=l.totalPages,onClick:()=>$(t=>Math.min(l.totalPages,t+1)),title:a("projects.nextPage"),children:[e.jsx($t,{size:15}),a("projects.nextPage")]})]})]})]}),e.jsx(oe,{open:Jt,title:a("projects.new"),description:a("projects.newDescription"),onOpenChange:t=>{!t&&W||(ke(t),t||I(""))},footer:e.jsxs(e.Fragment,{children:[e.jsx("button",{disabled:W,onClick:()=>ke(!1),children:a("common.cancel")}),e.jsxs("button",{className:"primary",disabled:W||!xe.trim(),"aria-busy":W,onClick:()=>{Tt()},children:[W&&e.jsx(Be,{className:"spin",size:14}),a(W?"common.loading":"common.create")]})]}),children:e.jsxs(e.Fragment,{children:[D&&e.jsx("p",{className:"error dialog-error",children:D}),e.jsxs("label",{className:"form-field",children:[a("projects.name"),e.jsx("input",{autoFocus:!0,value:xe,onChange:t=>{lt(t.target.value),I("")},onKeyDown:t=>{t.key==="Enter"&&Tt()}})]})]})}),e.jsx(oe,{open:Qt,title:a("projects.upload"),description:a("projects.uploadDescription",{size:s.maxUploadSizeMB}),onOpenChange:t=>{!t&&M||(fe(t),t||H(""))},footer:e.jsxs(e.Fragment,{children:[e.jsx("button",{disabled:M,onClick:()=>{fe(!1),H("")},children:a("common.cancel")}),e.jsxs("button",{className:"primary",disabled:!V||M,"aria-busy":M,onClick:()=>{ia()},children:[M&&e.jsx(Be,{className:"spin",size:14}),a(M?de==="processing"?"projects.processing":"projects.uploading":"projects.import")]})]}),children:e.jsxs("div",{className:"form-stack",children:[ht&&e.jsx("p",{className:"error import-error",children:ht}),e.jsxs("div",{className:`upload-picker${V?" has-file":""}${M?" is-disabled":""}`,onDragOver:t=>{t.preventDefault(),M||(t.dataTransfer.dropEffect="copy")},onDrop:t=>{t.preventDefault(),M||Ye(t.dataTransfer.files[0]??null)},children:[e.jsx("input",{ref:be,className:"sr-only",type:"file",accept:".zip,application/zip",disabled:M,onChange:t=>Ye(t.target.files?.[0]??null)}),e.jsx(Va,{size:34}),e.jsxs("div",{className:"upload-picker-copy",children:[e.jsx("strong",{children:V?.name??a("projects.chooseZip")}),e.jsx("span",{children:V?a("projects.selectedFileSize",{size:mn(V.size)}):a("projects.dropZip")})]}),e.jsxs("button",{type:"button",disabled:M,onClick:()=>be.current?.click(),children:[e.jsx(qt,{size:15}),a("projects.browse")]}),V&&e.jsx("button",{className:"upload-clear",type:"button",disabled:M,title:a("projects.clearFile"),"aria-label":a("projects.clearFile"),onClick:()=>{Ye(null),be.current&&(be.current.value="")},children:e.jsx(Ha,{size:14})})]}),e.jsxs("label",{className:"form-field",children:[a("projects.name"),e.jsx("input",{disabled:M,value:He,onChange:t=>Re(t.target.value)})]}),M&&e.jsxs("div",{className:"project-import-progress",role:"status","aria-live":"polite",children:[e.jsxs("div",{className:"project-import-progress-label",children:[e.jsx("span",{children:a(de==="processing"?"projects.processing":"projects.uploading")}),de==="uploading"&&Ze!==null&&e.jsxs("small",{"aria-hidden":"true",children:[Ze,"%"]})]}),e.jsx("progress",{"aria-label":a("projects.uploadProgress"),max:100,value:de==="uploading"?Ze??void 0:void 0}),de==="processing"&&e.jsx("small",{className:"import-progress-hint",children:a("projects.processingHint")})]})]})}),Yt&&e.jsx(Ue,{title:a("tags.manage"),onClose:()=>Ke(!1),children:e.jsx(cn,{open:!0,onOpenChange:Ke,onTagCreated:da,onTagUpdated:pa,onTagDeleted:ha})}),gt&&e.jsx(Ue,{title:a("projectIcons.title"),onClose:()=>Ce(null),children:e.jsx(ln,{project:gt,open:!0,onOpenChange:t=>{t||Ce(null)},onSave:ma})}),e.jsx(oe,{open:!!J,title:a("tags.assignTitle",{project:J?.name??""}),description:a("tags.assignDescription"),onOpenChange:t=>{t||(Q(null),te(""))},footer:e.jsx("button",{onClick:()=>{Q(null),te("")},children:a("common.close")}),children:e.jsxs("div",{className:"tag-assignment-list",children:[ot&&e.jsx("p",{className:"error dialog-error",children:ot}),y.map(t=>e.jsxs("label",{children:[e.jsx("input",{type:"checkbox",checked:!!J?.tags.some(n=>n.id===t.id),onChange:()=>{la(t)}}),e.jsx(Ot,{color:t.color}),e.jsx("span",{children:t.name})]},t.id)),y.length===0&&e.jsx("p",{className:"muted",children:a("tags.empty")})]})}),e.jsx(oe,{open:!!We,title:a("projects.renameTitle"),onOpenChange:t=>{!t&&X||t||(pe(null),G(""))},footer:e.jsxs(e.Fragment,{children:[e.jsx("button",{disabled:X,onClick:()=>{pe(null),G("")},children:a("common.cancel")}),e.jsxs("button",{className:"primary",disabled:X||!we.trim(),"aria-busy":X,onClick:()=>{Pt()},children:[X&&e.jsx(Be,{className:"spin",size:14}),a(X?"common.loading":"projects.rename")]})]}),children:e.jsxs(e.Fragment,{children:[it&&e.jsx("p",{className:"error dialog-error",children:it}),e.jsxs("label",{className:"form-field",children:[a("projects.name"),e.jsx("input",{autoFocus:!0,value:we,onChange:t=>{Ne(t.target.value),G("")},onKeyDown:t=>{t.key==="Enter"&&Pt()}})]})]})}),e.jsx(oe,{open:!!ze,title:a("projects.duplicateTitle"),description:a("projects.duplicateDescription",{project:ze?.name??""}),onOpenChange:t=>{!t&&!Te&&(he(null),ae(""),K(""))},footer:e.jsxs(e.Fragment,{children:[e.jsx("button",{disabled:Te,onClick:()=>{he(null),ae(""),K("")},children:a("common.cancel")}),e.jsx("button",{className:"primary",disabled:Te||!Se.trim(),onClick:()=>{At()},children:a(Te?"projects.duplicating":"projects.duplicate")})]}),children:e.jsxs(e.Fragment,{children:[ct&&e.jsx("p",{className:"error dialog-error",children:ct}),e.jsxs("label",{className:"form-field",children:[a("projects.name"),e.jsx("input",{autoFocus:!0,value:Se,onChange:t=>{ae(t.target.value),K("")},onKeyDown:t=>{t.key==="Enter"&&At()}})]})]})}),e.jsx(oe,{open:!!De,title:a("projects.transferOwnership"),description:a("projects.transferDescription",{project:De?.name??""}),onOpenChange:t=>{!t&&!se&&(Le(null),ue(""),ne(""))},footer:e.jsxs(e.Fragment,{children:[e.jsx("button",{disabled:se,onClick:()=>{Le(null),ue(""),ne("")},children:a("common.cancel")}),e.jsxs("button",{className:"primary",disabled:se||!Ee,onClick:()=>{ya()},children:[se?e.jsx(Be,{className:"spin",size:14}):e.jsx(Ht,{size:14}),a("projects.transfer")]})]}),children:e.jsxs("div",{className:"form-stack",children:[vt&&e.jsx("p",{className:"error dialog-error",children:vt}),e.jsxs("label",{className:"form-field",children:[a("projects.newOwner"),e.jsxs("select",{disabled:se||Je.length===0,value:Ee,onChange:t=>ue(t.target.value),children:[e.jsx("option",{value:"",children:se?a("common.loading"):Je.length>0?a("projects.chooseNewOwner"):a("projects.noTransferUsers")}),Je.map(t=>e.jsxs("option",{value:t.id,children:[t.displayName??t.username," (@",t.username,")"]},t.id))]})]}),e.jsxs("p",{className:"warning",children:[e.jsx(Ra,{size:15}),a("projects.transferWarning")]})]})}),e.jsx(fa,{open:!!me,title:a("projects.deleteTitle"),description:a("projects.deleteDescription",{project:me?.name??""}),confirmLabel:a(Ae?"common.loading":"common.delete"),danger:!0,busy:Ae,error:Wt,onCancel:()=>{Ae||(Pe(null),le(""))},onConfirm:()=>{ua()}})]}),F&&e.jsx(Ue,{title:a("metrics.title"),onClose:()=>Z(!1),children:e.jsx(nn,{open:!0,onOpenChange:Z})}),ee&&e.jsx(Ue,{title:a("account.githubTitle"),onClose:()=>C(!1),children:e.jsx(dn,{open:!0,onOpenChange:C})}),e.jsx(va,{})]})}function Ot({color:s}){return e.jsx("span",{className:`tag-dot tag-${s}`})}const Mn=Object.freeze(Object.defineProperty({__proto__:null,Dashboard:un},Symbol.toStringTag,{value:"Module"}));export{Ka as A,Mn as D,an as P,tn as a,Xs as i,Ys as n,bn as p};
@@ -0,0 +1,3 @@
1
+ import{u as fe,r as a,j as e}from"./react-CltQJflK.js";import{c as y,M as L,d as j,g}from"./index-DkpU9Fgs.js";import{G,C as I}from"./x-C_3swJOC.js";import{G as ee,F as xe}from"./github-D-JDXb-w.js";import{C as te}from"./chevron-up-D5lCNKlk.js";import{E as pe}from"./external-link-C9Td1CCj.js";import{R as je}from"./ProjectWorkspace-CAX3qEYr.js";import{M as ye,a as be}from"./minus-Bl8l4LXq.js";import{P as Ce}from"./plus-CCxK-HNt.js";import{M as ke}from"./minimize-2-BiVyoWZA.js";import"./check-CwBYzomT.js";import"./search-CPbhRWQE.js";import"./index-_eYe7K9T.js";import"./refresh-cw-BE8IbaHI.js";const ve=y("CloudUpload",[["path",{d:"M12 13v8",key:"1l5pq0"}],["path",{d:"M4 14.899A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.242",key:"1pljnt"}],["path",{d:"m8 17 4-4 4 4",key:"1quai1"}]]);const Ne=y("EyeOff",[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);const H=y("Eye",[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);const se=y("GitCommitHorizontal",[["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}],["line",{x1:"3",x2:"9",y1:"12",y2:"12",key:"1dyftd"}],["line",{x1:"15",x2:"21",y1:"12",y2:"12",key:"oup4p8"}]]);const we=y("Undo2",[["path",{d:"M9 14 4 9l5-5",key:"102s5s"}],["path",{d:"M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11",key:"f3b9sd"}]]);function Be({open:l,project:o,onOpenChange:b,onBeforeMutation:r}){const{t,i18n:S}=fe(),[i,C]=a.useState(null),[B,E]=a.useState([]),[F,A]=a.useState(()=>ie(o.name)),[W,ae]=a.useState(!0),[D,q]=a.useState(""),[u,k]=a.useState(null),[f,p]=a.useState(null),[U,T]=a.useState(!1),[ne,v]=a.useState(!1),[M,J]=a.useState(!0),[$,O]=a.useState(!0),[c,N]=a.useState(""),[V,w]=a.useState(""),[_,R]=a.useState(""),[d,m]=a.useState(!1),[z,K]=a.useState(10),P=a.useRef(null),oe=async(s=!1)=>{const n=await g(`/api/projects/${o.id}/git`);if(C(n.status),s&&(J(!n.status.tokenConfigured),O(!n.status.remoteUrl)),n.status.initialized&&n.status.latestCommit){const h=await g(`/api/projects/${o.id}/git/history`);E(h.commits)}else E([])};a.useEffect(()=>{if(!l){document.fullscreenElement&&document.exitFullscreen().catch(()=>{}),m(!1);return}w(""),R(""),k(null),m(!1),A(ie(o.name)),N("load"),r().then(()=>oe(!0)).catch(s=>w(s instanceof Error?s.message:t("errors.generic"))).finally(()=>N(""))},[l,o.id]),a.useEffect(()=>{const s=()=>m(document.fullscreenElement===P.current);return document.addEventListener("fullscreenchange",s),()=>document.removeEventListener("fullscreenchange",s)},[]),a.useEffect(()=>{if(!d)return;const s=n=>{n.key==="Escape"&&!document.fullscreenElement&&m(!1)};return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[d]);const x=async(s,n,h,Q)=>{N(s),w(""),R("");try{await n(),h&&R(h)}catch(X){const Y=X instanceof Error?X.message:t("errors.generic");w(Q?`${Q}: ${Y}`:Y)}finally{N("")}},re=()=>x("repository",async()=>{const s=await g(`/api/projects/${o.id}/git/repository`,{method:"POST",body:JSON.stringify({name:F,private:W})});C(s.status),O(!1)},t("git.repositoryCreated")),ce=()=>x("commit",async()=>{if(!await r())throw new Error(t("errors.collaborationUnavailable"));const s=await g(`/api/projects/${o.id}/git/commit`,{method:"POST",body:JSON.stringify({message:D})});C(s.status),E(n=>[s.commit,...n.filter(h=>h.sha!==s.commit.sha)].slice(0,100)),q(""),k(null)},t("git.committed"),t("git.commitFailed")),le=()=>x("push",async()=>{if(!await r())throw new Error(t("errors.collaborationUnavailable"));const s=await g(`/api/projects/${o.id}/git/push`,{method:"POST"});C(s.status)},t("git.pushed"),t("git.pushFailed")),Z=s=>x("diff",async()=>{if(!await r())throw new Error(t("errors.collaborationUnavailable"));const n=s?`?revision=${encodeURIComponent(s)}`:"",h=await g(`/api/projects/${o.id}/git/diff${n}`);k({...h,revision:s})}),de=s=>{if(u?.revision===s){k(null),m(!1),document.fullscreenElement&&document.exitFullscreen().catch(()=>{});return}Z(s)},he=async()=>{if(d){document.fullscreenElement&&await document.exitFullscreen().catch(()=>{}),m(!1);return}const s=P.current;if(s?.requestFullscreen)try{await s.requestFullscreen()}catch{}m(!0)},ge=()=>{const s=f;s&&(p(null),x("checkout",async()=>{if(!await r())throw new Error(t("errors.collaborationUnavailable"));await g(`/api/projects/${o.id}/git/checkout`,{method:"POST",body:JSON.stringify({revision:s==="branch"?null:s.sha,force:U})}),window.location.reload()}))},me=()=>{v(!1),x("discard",async()=>{if(!await r())throw new Error(t("errors.collaborationUnavailable"));await g(`/api/projects/${o.id}/git/discard`,{method:"POST"}),window.location.reload()})},ue=c==="load"&&!i;return e.jsxs(e.Fragment,{children:[e.jsx(L,{open:l,extraWide:!0,className:d?"git-dialog-modal-fullscreen":void 0,title:t("git.title"),description:t("git.description"),onOpenChange:b,footer:e.jsx("button",{onClick:()=>b(!1),children:t("common.close")}),children:e.jsxs("div",{className:"git-dialog",children:[ue&&e.jsxs("div",{className:"git-loading",children:[e.jsx(j,{className:"spin",size:22}),t("common.loading")]}),V&&e.jsx("p",{className:"git-message error",role:"alert",children:V}),_&&e.jsxs("p",{className:"git-message success",role:"status",children:[e.jsx(G,{size:14}),_]}),i&&e.jsxs(e.Fragment,{children:[e.jsxs("section",{className:"git-section",children:[e.jsxs("button",{className:"git-section-toggle",type:"button","aria-expanded":M,onClick:()=>J(s=>!s),children:[e.jsxs("span",{className:"git-section-heading",children:[e.jsx(ee,{size:16}),e.jsxs("span",{children:[e.jsx("strong",{children:t("git.authentication")}),e.jsx("small",{children:i.tokenConfigured?t("git.connectedAs",{login:i.githubLogin}):t("git.authenticationHint")})]})]}),M?e.jsx(te,{size:16}):e.jsx(I,{size:16})]}),M&&e.jsx("div",{className:"git-section-content",children:e.jsx("p",{className:"git-account-guidance",children:i.tokenConfigured?t("git.accountTokenManaged",{login:i.githubLogin}):t("git.accountTokenMissing")})})]}),e.jsxs("section",{className:"git-section",children:[e.jsxs("button",{className:"git-section-toggle",type:"button","aria-expanded":$,onClick:()=>O(s=>!s),children:[e.jsxs("span",{className:"git-section-heading",children:[e.jsx(xe,{size:16}),e.jsxs("span",{children:[e.jsx("strong",{children:t("git.repository")}),e.jsx("small",{children:i.remoteUrl?i.repositoryName??i.remoteUrl:i.initialized?t("git.localReady"):t("git.localPending")})]})]}),$?e.jsx(te,{size:16}):e.jsx(I,{size:16})]}),$&&e.jsx("div",{className:"git-section-content",children:i.remoteUrl?e.jsxs("div",{className:"git-repository-card",children:[e.jsxs("div",{children:[e.jsx("strong",{children:i.repositoryName??t("git.origin")}),e.jsxs("small",{children:[i.branch??t("git.detachedAt",{revision:i.latestCommit?.shortSha??"HEAD"})," · ",i.dirty?t("git.changedFiles",{count:i.changedFiles}):t("git.clean")]})]}),i.repositoryHtmlUrl&&e.jsxs("a",{href:i.repositoryHtmlUrl,target:"_blank",rel:"noreferrer",children:[e.jsx(pe,{size:14}),t("git.openGitHub")]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"form-field",children:[t("git.repositoryName"),e.jsx("input",{value:F,onChange:s=>A(s.target.value)})]}),e.jsxs("label",{className:"checkbox-field",children:[e.jsx("input",{type:"checkbox",checked:W,onChange:s=>ae(s.target.checked)}),t("git.privateRepository")]}),e.jsxs("button",{className:"git-primary-action",disabled:!!c||!i.tokenConfigured||!F.trim(),onClick:re,children:[c==="repository"?e.jsx(j,{className:"spin",size:14}):e.jsx(ee,{size:14}),t("git.createRepository")]})]})})]}),i.initialized&&e.jsxs("section",{className:"git-section",children:[e.jsxs("div",{className:"git-section-heading",children:[e.jsx(se,{size:16}),e.jsxs("div",{children:[e.jsx("strong",{children:t("git.commitAndPush")}),e.jsx("small",{children:i.branch?t("git.identity",{username:o.ownerUsername}):t("git.detachedHead")})]})]}),e.jsxs("label",{className:"form-field",children:[t("git.commitMessage"),e.jsx("textarea",{rows:3,value:D,placeholder:t("git.commitPlaceholder"),onChange:s=>q(s.target.value)})]}),e.jsxs("div",{className:"git-action-row",children:[e.jsxs("button",{title:i.dirty?void 0:t("git.noChangesToCommit"),disabled:!!c||!i.branch||!i.dirty||!D.trim(),onClick:ce,children:[c==="commit"?e.jsx(j,{className:"spin",size:14}):e.jsx(se,{size:14}),t("git.commit")]}),e.jsxs("button",{title:i.ahead===0&&i.branch&&i.remoteUrl&&i.tokenConfigured&&i.latestCommit?t("git.noUnpushedCommits"):void 0,disabled:!!c||!i.branch||!i.tokenConfigured||!i.remoteUrl||!i.latestCommit||i.ahead===0,onClick:le,children:[c==="push"?e.jsx(j,{className:"spin",size:14}):e.jsx(ve,{size:14}),t("git.push"),i.ahead>0&&e.jsx("span",{className:"git-count",children:i.ahead})]}),e.jsxs("button",{disabled:!!c||!i.latestCommit,onClick:()=>{Z()},children:[c==="diff"?e.jsx(j,{className:"spin",size:14}):e.jsx(H,{size:14}),t("git.workingDiff")]}),e.jsxs("button",{className:"git-discard-button",title:i.restorable?t("git.discardChanges"):t("git.noChangesToDiscard"),disabled:!!c||!i.latestCommit||!i.restorable,onClick:()=>v(!0),children:[e.jsx(je,{size:14}),t("git.discardChanges")]}),!i.branch&&e.jsxs("button",{disabled:!!c,onClick:()=>{T(!1),p("branch")},children:[e.jsx(G,{size:14}),t("git.returnToBranch",{branch:i.defaultBranch})]})]})]}),u&&e.jsxs("section",{ref:P,className:`git-section git-diff-section${d?" is-fullscreen":""}`,children:[e.jsxs("div",{className:"git-diff-heading",children:[e.jsxs("div",{className:"git-section-heading",children:[e.jsx(H,{size:16}),e.jsxs("div",{children:[e.jsx("strong",{children:t("git.diffTitle")}),e.jsxs("small",{children:[u.title,u.truncated?` · ${t("git.diffTruncated")}`:""]})]})]}),e.jsxs("div",{className:"git-diff-controls",children:[e.jsxs("div",{className:"git-diff-font-controls",role:"group","aria-label":t("git.diffFontSize"),children:[e.jsx("button",{type:"button",className:"git-diff-font-button",disabled:z<=8,title:t("git.diffFontDecrease"),"aria-label":t("git.diffFontDecrease"),onClick:()=>K(s=>Math.max(8,s-1)),children:e.jsx(ye,{size:14})}),e.jsxs("span",{className:"git-diff-font-value","aria-live":"polite",children:[z,"px"]}),e.jsx("button",{type:"button",className:"git-diff-font-button",disabled:z>=24,title:t("git.diffFontIncrease"),"aria-label":t("git.diffFontIncrease"),onClick:()=>K(s=>Math.min(24,s+1)),children:e.jsx(Ce,{size:14})})]}),e.jsx("button",{type:"button",className:"git-diff-fullscreen",title:t(d?"git.exitFullscreenDiff":"git.fullscreenDiff"),"aria-label":t(d?"git.exitFullscreenDiff":"git.fullscreenDiff"),onClick:()=>{he()},children:d?e.jsx(ke,{size:15}):e.jsx(be,{size:15})})]})]}),e.jsx(ze,{content:u.diff,empty:t("git.noChanges"),fontSize:z})]}),i.initialized&&e.jsxs("section",{className:"git-section",children:[e.jsxs("div",{className:"git-section-heading",children:[e.jsx(G,{size:16}),e.jsxs("div",{children:[e.jsx("strong",{children:t("git.history")}),e.jsx("small",{children:t("git.historyHint")})]})]}),e.jsxs("div",{className:"git-history",children:[B.map(s=>{const n=u?.revision===s.sha;return e.jsxs("article",{children:[e.jsx("code",{children:s.shortSha}),e.jsxs("div",{children:[e.jsx("strong",{children:s.message}),e.jsxs("small",{children:[s.authorName," · ",new Date(s.authoredAt).toLocaleString(S.resolvedLanguage)]})]}),e.jsxs("span",{"data-texlite-tooltip-always":!0,children:[e.jsx("button",{type:"button",className:n?"is-active":void 0,title:t(n?"git.hideCommitDiff":"git.viewCommitDiff"),"aria-label":t(n?"git.hideCommitDiff":"git.viewCommitDiff"),"aria-pressed":n,disabled:!!c,onClick:()=>de(s.sha),children:n?e.jsx(Ne,{size:14}):e.jsx(H,{size:14})}),e.jsx("button",{type:"button",title:t("git.checkoutVersion"),disabled:!!c,onClick:()=>{T(!1),p(s)},children:e.jsx(we,{size:14})})]})]},s.sha)}),B.length===0&&e.jsx("p",{className:"muted",children:t("git.noCommits")})]})]})]})]})}),e.jsx(L,{open:!!f,title:t(f==="branch"?"git.returnTitle":"git.checkoutTitle"),description:f==="branch"?t("git.returnDescription",{branch:i?.defaultBranch??"main"}):t("git.checkoutDescription",{revision:f?.shortSha??"",message:f?.message??""}),onOpenChange:s=>{s||p(null)},footer:e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>p(null),children:t("common.cancel")}),e.jsx("button",{className:U?"danger":"primary",onClick:ge,children:t("git.checkout")})]}),children:e.jsxs("label",{className:"git-force-checkout",children:[e.jsx("input",{type:"checkbox",checked:U,onChange:s=>T(s.target.checked)}),e.jsxs("span",{children:[e.jsx("strong",{children:t("git.forceCheckout")}),e.jsx("small",{children:t("git.forceCheckoutDescription")})]})]})}),e.jsx(L,{open:ne,title:t("git.discardTitle"),description:t("git.discardDescription"),onOpenChange:v,footer:e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>v(!1),children:t("common.cancel")}),e.jsx("button",{className:"danger",onClick:me,children:t("git.discardConfirm")})]}),children:e.jsx(e.Fragment,{})})]})}function ze({content:l,empty:o,fontSize:b}){return l.trim()?e.jsx("pre",{className:"git-diff",style:{fontSize:`${b}px`},children:l.split(`
2
+ `).map((r,t)=>{const S=r.startsWith("+")&&!r.startsWith("+++")?"addition":r.startsWith("-")&&!r.startsWith("---")?"deletion":r.startsWith("@@")?"hunk":r.startsWith("diff ")?"header":"";return e.jsxs("span",{className:S,children:[r,`
3
+ `]},t)})}):e.jsx("div",{className:"git-diff-empty",children:o})}function ie(l){return l.trim().replace(/\s+/g,"-").replace(/[^A-Za-z0-9._-]/g,"-").replace(/-+/g,"-").replace(/^[.-]+|[.-]+$/g,"").slice(0,100)||"texlite-project"}export{Be as GitDialog};
@@ -1 +1 @@
1
- import{u as k,j as e,r as c}from"./react-CltQJflK.js";import{g as u,h,M as y,d as x}from"./index-BgeOKYIx.js";import{G as b}from"./github-DJezB5ef.js";import{T}from"./x-DN0Ol4Ya.js";import{E as A}from"./external-link-DGfNJFKy.js";function C(){const{t:i}=k();return e.jsxs("div",{className:"git-token-guidance",children:[e.jsx("strong",{children:i("git.recommendedAccessTitle")}),e.jsxs("span",{children:[i("git.recommendedAccessBeforeAll"),e.jsx("em",{className:"git-token-highlight",children:"All repositories"}),i("git.recommendedAccessBeforeAdministration"),e.jsx("em",{className:"git-token-highlight",children:"Administration"}),i("git.recommendedAccessBetweenPermissions"),e.jsx("em",{className:"git-token-highlight",children:"Contents"}),i("git.recommendedAccessAfterPermissions")]})]})}function G({open:i,onOpenChange:p}){const{t}=k(),[r,m]=c.useState(null),[g,d]=c.useState(""),[a,n]=c.useState(""),[j,o]=c.useState(""),[f,l]=c.useState("");c.useEffect(()=>{i&&(n("load"),o(""),l(""),d(""),u("/api/account/github").then(s=>m(s.status)).catch(s=>o(h(s))).finally(()=>n(s=>s==="load"?"":s)))},[i]);const v=async()=>{n("save"),o(""),l("");try{const s=await u("/api/account/github",{method:"PUT",body:JSON.stringify({token:g})});m(s.status),d(""),l(t("account.githubSaved"))}catch(s){o(h(s))}finally{n("")}},N=async()=>{n("remove"),o(""),l("");try{const s=await u("/api/account/github",{method:"DELETE"});m(s.status),d(""),l(t("account.githubRemoved"))}catch(s){o(h(s))}finally{n("")}};return e.jsx(y,{open:i,title:t("account.githubTitle"),description:t("account.githubDescription"),onOpenChange:s=>{a||p(s)},footer:e.jsxs(e.Fragment,{children:[e.jsx("button",{disabled:!!a,onClick:()=>p(!1),children:t("common.close")}),e.jsxs("button",{className:"primary",disabled:!!a||g.trim().length<20,onClick:()=>{v()},children:[a==="save"&&e.jsx(x,{className:"spin",size:14}),t("git.saveToken")]})]}),children:e.jsxs("div",{className:"git-dialog account-github-dialog",children:[a==="load"&&!r&&e.jsxs("div",{className:"git-loading",children:[e.jsx(x,{className:"spin",size:20}),t("common.loading")]}),j&&e.jsx("p",{className:"git-message error dialog-error",children:j}),f&&e.jsxs("p",{className:"git-message success",children:[e.jsx(b,{size:14}),f]}),r&&e.jsxs(e.Fragment,{children:[e.jsx(C,{}),r.tokenConfigured&&e.jsxs("div",{className:"git-account",children:[e.jsx(b,{size:17}),e.jsx("span",{children:t("git.connectedAs",{login:r.githubLogin})}),e.jsxs("button",{className:"danger-text",disabled:!!a,onClick:()=>{N()},children:[a==="remove"?e.jsx(x,{className:"spin",size:14}):e.jsx(T,{size:14}),t("git.removeToken")]})]}),e.jsxs("label",{className:"form-field",children:[r.tokenConfigured?t("git.replaceToken"):t("git.token"),e.jsx("input",{type:"password",autoComplete:"new-password",spellCheck:!1,autoCapitalize:"none",autoCorrect:"off",value:g,placeholder:t("git.tokenPlaceholder"),onChange:s=>d(s.target.value)})]}),e.jsx("div",{className:"git-inline-actions",children:e.jsxs("a",{href:"https://github.com/settings/personal-access-tokens/new",target:"_blank",rel:"noreferrer",children:[t("git.createToken"),e.jsx(A,{size:12})]})}),e.jsx("p",{className:"muted account-github-encryption-note",children:t("account.githubEncryption")})]})]})})}export{G as GitHubAccountDialog};
1
+ import{u as k,j as e,r as c}from"./react-CltQJflK.js";import{g as u,h,M as y,d as x}from"./index-DkpU9Fgs.js";import{G as b}from"./github-D-JDXb-w.js";import{T}from"./x-C_3swJOC.js";import{E as A}from"./external-link-C9Td1CCj.js";function C(){const{t:i}=k();return e.jsxs("div",{className:"git-token-guidance",children:[e.jsx("strong",{children:i("git.recommendedAccessTitle")}),e.jsxs("span",{children:[i("git.recommendedAccessBeforeAll"),e.jsx("em",{className:"git-token-highlight",children:"All repositories"}),i("git.recommendedAccessBeforeAdministration"),e.jsx("em",{className:"git-token-highlight",children:"Administration"}),i("git.recommendedAccessBetweenPermissions"),e.jsx("em",{className:"git-token-highlight",children:"Contents"}),i("git.recommendedAccessAfterPermissions")]})]})}function G({open:i,onOpenChange:p}){const{t}=k(),[r,m]=c.useState(null),[g,d]=c.useState(""),[a,n]=c.useState(""),[j,o]=c.useState(""),[f,l]=c.useState("");c.useEffect(()=>{i&&(n("load"),o(""),l(""),d(""),u("/api/account/github").then(s=>m(s.status)).catch(s=>o(h(s))).finally(()=>n(s=>s==="load"?"":s)))},[i]);const v=async()=>{n("save"),o(""),l("");try{const s=await u("/api/account/github",{method:"PUT",body:JSON.stringify({token:g})});m(s.status),d(""),l(t("account.githubSaved"))}catch(s){o(h(s))}finally{n("")}},N=async()=>{n("remove"),o(""),l("");try{const s=await u("/api/account/github",{method:"DELETE"});m(s.status),d(""),l(t("account.githubRemoved"))}catch(s){o(h(s))}finally{n("")}};return e.jsx(y,{open:i,title:t("account.githubTitle"),description:t("account.githubDescription"),onOpenChange:s=>{a||p(s)},footer:e.jsxs(e.Fragment,{children:[e.jsx("button",{disabled:!!a,onClick:()=>p(!1),children:t("common.close")}),e.jsxs("button",{className:"primary",disabled:!!a||g.trim().length<20,onClick:()=>{v()},children:[a==="save"&&e.jsx(x,{className:"spin",size:14}),t("git.saveToken")]})]}),children:e.jsxs("div",{className:"git-dialog account-github-dialog",children:[a==="load"&&!r&&e.jsxs("div",{className:"git-loading",children:[e.jsx(x,{className:"spin",size:20}),t("common.loading")]}),j&&e.jsx("p",{className:"git-message error dialog-error",children:j}),f&&e.jsxs("p",{className:"git-message success",children:[e.jsx(b,{size:14}),f]}),r&&e.jsxs(e.Fragment,{children:[e.jsx(C,{}),r.tokenConfigured&&e.jsxs("div",{className:"git-account",children:[e.jsx(b,{size:17}),e.jsx("span",{children:t("git.connectedAs",{login:r.githubLogin})}),e.jsxs("button",{className:"danger-text",disabled:!!a,onClick:()=>{N()},children:[a==="remove"?e.jsx(x,{className:"spin",size:14}):e.jsx(T,{size:14}),t("git.removeToken")]})]}),e.jsxs("label",{className:"form-field",children:[r.tokenConfigured?t("git.replaceToken"):t("git.token"),e.jsx("input",{type:"password",autoComplete:"new-password",spellCheck:!1,autoCapitalize:"none",autoCorrect:"off",value:g,placeholder:t("git.tokenPlaceholder"),onChange:s=>d(s.target.value)})]}),e.jsx("div",{className:"git-inline-actions",children:e.jsxs("a",{href:"https://github.com/settings/personal-access-tokens/new",target:"_blank",rel:"noreferrer",children:[t("git.createToken"),e.jsx(A,{size:12})]})}),e.jsx("p",{className:"muted account-github-encryption-note",children:t("account.githubEncryption")})]})]})})}export{G as GitHubAccountDialog};
@@ -1,7 +1,7 @@
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-BgeOKYIx.js";import{d as _e,C as $e}from"./index-DmBKxZf9.js";import{H as Ie}from"./hard-drive-B9h-a7KY.js";import{T as Se,c as Oe,e as ue}from"./x-DN0Ol4Ya.js";import{F as Te,R as Ee,S as Ue,D as We}from"./ProjectWorkspace-DUPLJCQ3.js";import{M as Ye,a as qe}from"./minus-Dn3USloe.js";import{P as Ge}from"./plus-BwKRQJHI.js";import{M as Je}from"./minimize-2-Crq_SyYM.js";import"./check-EZ2H-iDj.js";import"./search-CDyQWr9H.js";import"./user-plus-pxz36w4w.js";import"./refresh-cw-C5yVKb1r.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,`
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{ht as HistoryDialog};
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};