texlite 0.9.3 → 0.9.4

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 (48) hide show
  1. package/OPERATIONS.md +9 -7
  2. package/dist/client/assets/{AdminUsers-huwQK7Ly.js → AdminUsers-B12FJUMy.js} +1 -1
  3. package/dist/client/assets/{CitationLibraryDialog-C5C3sPdw.js → CitationLibraryDialog-BTmnCP4V.js} +1 -1
  4. package/dist/client/assets/Dashboard-JA5_M3TK.js +2 -0
  5. package/dist/client/assets/{GitDialog-BI7QIMsh.js → GitDialog--MoUIW0n.js} +1 -1
  6. package/dist/client/assets/{HistoryDialog-DA7O9aF2.js → HistoryDialog-LgKbjsTZ.js} +1 -1
  7. package/dist/client/assets/LatexEditor-Dj2zIaQm.js +138 -0
  8. package/dist/client/assets/{PdfPreview-mO9WS01q.js → PdfPreview-C_W7w360.js} +1 -1
  9. package/dist/client/assets/{ProjectIconPickerDialog-B0q_r5dX.js → ProjectIconPickerDialog-GzRuM0oQ.js} +1 -1
  10. package/dist/client/assets/{ProjectNavigationDialogs-DwWYbB1A.js → ProjectNavigationDialogs-BiArHmQ9.js} +1 -1
  11. package/dist/client/assets/{ProjectSettings-BpPFgdoj.js → ProjectSettings-DgJohWUv.js} +1 -1
  12. package/dist/client/assets/ProjectWorkspace-C6sYiBF2.js +32 -0
  13. package/dist/client/assets/{SelectionHistoryDialog-pWMI5izu.js → SelectionHistoryDialog-Bpv6nvrC.js} +1 -1
  14. package/dist/client/assets/{SystemMetricsDialog-BmlO7oNg.js → SystemMetricsDialog-hJQATmd4.js} +1 -1
  15. package/dist/client/assets/{TagManagementDialog-h4Ves4FR.js → TagManagementDialog-BHC8qULq.js} +1 -1
  16. package/dist/client/assets/{WordCountDialog-DlBSP4y7.js → WordCountDialog-DZhhO94k.js} +1 -1
  17. package/dist/client/assets/check-C1db8iNn.js +1 -0
  18. package/dist/client/assets/{editor-DZS7-wrd.js → editor-B9HNwtsd.js} +1 -1
  19. package/dist/client/assets/hard-drive-BWZnOgnm.js +1 -0
  20. package/dist/client/assets/index-BiwJj0Np.css +1 -0
  21. package/dist/client/assets/{index-i5IY_PMw.js → index-kTamGfTl.js} +1 -1
  22. package/dist/client/assets/{index-teah8iB2.js → index-p1NHkGGG.js} +4 -4
  23. package/dist/client/assets/{key-round-D8sCqL2b.js → key-round-CoDwyVJc.js} +1 -1
  24. package/dist/client/assets/{minimize-2-6tf519Ts.js → minimize-2-D100opW2.js} +1 -1
  25. package/dist/client/assets/{minus-CqvESp9M.js → minus-DDTYB-Oz.js} +1 -1
  26. package/dist/client/assets/{plus-DIrweesj.js → plus-BVXOlQXP.js} +1 -1
  27. package/dist/client/assets/{refresh-cw-BDcwKu_d.js → refresh-cw-LtwnqlWh.js} +1 -1
  28. package/dist/client/assets/{search-C9_Jyrnx.js → search-DXo_aAp0.js} +1 -1
  29. package/dist/client/assets/{sigma-p9-fBP0d.js → sigma-BgvHGPto.js} +1 -1
  30. package/dist/client/assets/{spellCheck-Y0RlmXbl.js → spellCheck-BtRppKcC.js} +1 -1
  31. package/dist/client/assets/{tags-DjF3z21M.js → tags-m9kppdi0.js} +1 -1
  32. package/dist/client/assets/{type-CNrDJnzR.js → type-YO4aprqE.js} +1 -1
  33. package/dist/client/assets/{user-plus-C7exNawX.js → user-plus-MRmKeDtX.js} +1 -1
  34. package/dist/client/assets/x-eisRQJv_.js +1 -0
  35. package/dist/client/index.html +2 -2
  36. package/dist/client/pdf-download.svg +2 -0
  37. package/dist/client/pdf-file.svg +19 -0
  38. package/dist/client/tex-file.svg +7 -0
  39. package/dist/server/cli.js +5 -2
  40. package/dist/server/routes/projectFiles.js +6 -1
  41. package/package.json +4 -3
  42. package/dist/client/assets/Dashboard-DtHSc55D.js +0 -2
  43. package/dist/client/assets/LatexEditor-BYWWx5Km.js +0 -138
  44. package/dist/client/assets/ProjectWorkspace-CI2zKon5.js +0 -32
  45. package/dist/client/assets/check-BAdi_Lxq.js +0 -1
  46. package/dist/client/assets/hard-drive-DP2OHKMC.js +0 -1
  47. package/dist/client/assets/index-CBrIrzgg.css +0 -1
  48. package/dist/client/assets/x-BEVz0wdw.js +0 -1
package/OPERATIONS.md CHANGED
@@ -305,20 +305,22 @@ distribution changes the environment used by subsequent compiles.
305
305
 
306
306
  ## Development and verification
307
307
 
308
- Run the API/server watcher and Vite in separate terminals:
308
+ Run the API/server watcher and Vite in separate terminals. Development uses a
309
+ dedicated `.texlite-dev/` directory in this repository and port `3001`, so it
310
+ does not reuse or lock the normal user configuration, database, or port `3000`:
309
311
 
310
312
  ~~~bash
311
- npm run dev # API/server: http://127.0.0.1:3000
313
+ npm run dev:init # once: create the development config and administrator
314
+ npm run dev # API/server: http://127.0.0.1:3001
312
315
  npm run dev:web # Vite UI: http://127.0.0.1:5173
313
316
  ~~~
314
317
 
315
- When testing a configured `server.basePath`, export the same configuration path
316
- in both terminals. Vite reads it, serves the matching prefix, and proxies the
317
- prefixed API and WebSocket endpoints:
318
+ To test a configured `server.basePath`, edit `.texlite-dev/texlite.config.json`
319
+ and restart both terminals. Vite reads this development configuration, serves
320
+ the matching prefix, and proxies the prefixed API and WebSocket endpoints:
318
321
 
319
322
  ~~~bash
320
- export TEXLITE_CONFIG="$PWD/texlite.config.json"
321
- npm run dev # API/server, for example http://127.0.0.1:3000/texlite/
323
+ npm run dev # API/server, for example http://127.0.0.1:3001/texlite/
322
324
  npm run dev:web # Vite UI, for example http://127.0.0.1:5173/texlite/
323
325
  ~~~
324
326
 
@@ -1 +1 @@
1
- import{u as Y,r as n,j as e}from"./react-BVUjbTTn.js";import{c as m,M as D,d as _,C as ee,g as u,h}from"./index-teah8iB2.js";import{U as se,T as R,X as O}from"./x-BEVz0wdw.js";import{U as $}from"./user-plus-C7exNawX.js";import{S as ae}from"./Dashboard-DtHSc55D.js";import{K as B}from"./key-round-D8sCqL2b.js";import"./hard-drive-DP2OHKMC.js";import"./sigma-p9-fBP0d.js";import"./tags-DjF3z21M.js";const re=m("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 ne=m("FolderCheck",[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 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 2Z",key:"1kt360"}],["path",{d:"m9 13 2 2 4-4",key:"6343dt"}]]);const te=m("FolderX",[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 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 2Z",key:"1kt360"}],["path",{d:"m9.5 10.5 5 5",key:"ra9qjz"}],["path",{d:"m14.5 10.5-5 5",key:"l2rkpq"}]]);const ie=m("ShieldOff",[["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M5 5a1 1 0 0 0-1 1v7c0 5 3.5 7.5 7.67 8.94a1 1 0 0 0 .67.01c2.35-.82 4.48-1.97 5.9-3.71",key:"1jlk70"}],["path",{d:"M9.309 3.652A12.252 12.252 0 0 0 11.24 2.28a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1v7a9.784 9.784 0 0 1-.08 1.264",key:"18rp1v"}]]);const oe=m("UserCheck",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["polyline",{points:"16 11 18 13 22 9",key:"1pwet4"}]]);const le=m("UserX",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"17",x2:"22",y1:"8",y2:"13",key:"3nzzx3"}],["line",{x1:"22",x2:"17",y1:"8",y2:"13",key:"1swrse"}]]);function de(p=10){const t="ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz23456789!@#$%",a=crypto.getRandomValues(new Uint8Array(p));return Array.from(a,S=>t[S%t.length]).join("")}function be({currentUser:p,minPasswordLength:t}){const{t:a}=Y(),[S,J]=n.useState([]),[E,d]=n.useState(""),[V,C]=n.useState(!1),[r,o]=n.useState({username:"",displayName:"",password:"",role:"user",canCreateProjects:!1}),[k,g]=n.useState(null),[j,P]=n.useState(""),[x,w]=n.useState(null),[z,N]=n.useState(!1),[i,F]=n.useState(!1),[U,y]=n.useState(""),[l,f]=n.useState(null),[A,H]=n.useState(!1),[X,c]=n.useState(""),b=()=>u("/api/admin/users").then(({users:s})=>J(s)).catch(s=>d(h(s)));n.useEffect(()=>{b()},[]);const q=async()=>{if(r.password.length<t)return d(a("auth.passwordMinimum",{count:t}));try{await u("/api/admin/users",{method:"POST",body:JSON.stringify({username:r.username,displayName:r.displayName||r.username,password:r.password,role:r.role,canCreateProjects:r.canCreateProjects})}),C(!1),o({username:"",displayName:"",password:"",role:"user",canCreateProjects:!1}),await b()}catch(s){d(h(s))}},M=async(s,v)=>{try{await u(`/api/admin/users/${s.id}`,{method:"PATCH",body:JSON.stringify(v)}),await b()}catch(T){d(h(T))}},K=async s=>{if(!s.disabled){f({target:s,setting:"disable"}),c("");return}await M(s,{disabled:!1})},Z=async s=>{if(s.role==="admin"){f({target:s,setting:"demote"}),c("");return}await M(s,{role:"admin"})},G=async s=>{if(s.canCreateProjects){f({target:s,setting:"denyProjectCreation"}),c("");return}await M(s,{canCreateProjects:!0})},I=async()=>{if(!l)return;const{target:s,setting:v}=l,T=v==="disable"?{disabled:!0}:v==="demote"?{role:"user"}:{canCreateProjects:!1};H(!0),c("");try{await u(`/api/admin/users/${s.id}`,{method:"PATCH",body:JSON.stringify(T)}),await b(),f(null)}catch(W){c(h(W))}finally{H(!1)}},L=async()=>{if(!(!k||!j)){if(j.length<t)return d(a("auth.passwordMinimum",{count:t}));try{await u(`/api/admin/users/${k.id}`,{method:"PATCH",body:JSON.stringify({password:j})}),g(null),P("")}catch(s){d(h(s))}}},Q=async()=>{if(!(!x||i)){F(!0),y("");try{await u(`/api/admin/users/${x.id}`,{method:"DELETE",body:JSON.stringify({deleteProjects:z})}),w(null),N(!1),await b()}catch(s){y(h(s))}finally{F(!1)}}};return e.jsxs("main",{className:"dashboard",children:[e.jsxs("div",{className:"section-title",children:[e.jsxs("div",{children:[e.jsxs("h1",{children:[e.jsx(se,{"aria-hidden":!0,size:25}),a("users.manage")]}),e.jsx("p",{className:"muted",children:a("users.onlyAdmin")})]}),e.jsxs("button",{className:"primary icon-button",onClick:()=>C(!0),children:[e.jsx($,{"aria-hidden":!0,size:15}),a("users.add")]})]}),E&&e.jsx("p",{className:"error",children:E}),e.jsx("div",{className:"table-card",children:e.jsxs("table",{children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:a("common.user")}),e.jsx("th",{children:a("users.role")}),e.jsx("th",{children:a("users.createProjects")}),e.jsx("th",{children:a("users.ownedProjects")}),e.jsx("th",{children:a("users.status")}),e.jsx("th",{children:a("users.actions")})]})}),e.jsx("tbody",{children:S.map(s=>e.jsxs("tr",{children:[e.jsxs("td",{children:[e.jsx("strong",{children:s.displayName}),e.jsxs("small",{children:["@",s.username]})]}),e.jsx("td",{children:s.role==="admin"?a("common.admin"):a("common.user")}),e.jsx("td",{children:s.canCreateProjects?a("users.allow"):a("users.deny")}),e.jsx("td",{children:s.ownedProjects}),e.jsx("td",{children:s.disabled?a("common.disabled"):a("common.normal")}),e.jsxs("td",{children:[e.jsxs("button",{className:"icon-button",disabled:s.id===p.id,onClick:()=>K(s),children:[s.disabled?e.jsx(oe,{"aria-hidden":!0,size:13}):e.jsx(le,{"aria-hidden":!0,size:13}),s.disabled?a("users.enable"):a("users.disable")]}),e.jsxs("button",{className:"icon-button",disabled:s.id===p.id,onClick:()=>Z(s),children:[s.role==="admin"?e.jsx(ie,{"aria-hidden":!0,size:13}):e.jsx(ae,{"aria-hidden":!0,size:13}),s.role==="admin"?a("users.demote"):a("users.promote")]}),e.jsxs("button",{className:"icon-button",disabled:s.role==="admin",onClick:()=>G(s),children:[s.canCreateProjects?e.jsx(te,{"aria-hidden":!0,size:13}):e.jsx(ne,{"aria-hidden":!0,size:13}),s.canCreateProjects?a("users.denyCreate"):a("users.allowCreate")]}),e.jsxs("button",{className:"icon-button",onClick:()=>{g(s),P("")},children:[e.jsx(B,{"aria-hidden":!0,size:13}),a("users.resetPassword")]}),e.jsxs("button",{className:"icon-button danger-text",disabled:s.id===p.id,onClick:()=>{w(s),N(!1),y("")},children:[e.jsx(R,{"aria-hidden":!0,size:13}),a("common.delete")]})]})]},s.id))})]})}),e.jsx(D,{open:V,title:a("users.add"),description:a("users.addDescription"),onOpenChange:C,footer:e.jsxs(e.Fragment,{children:[e.jsxs("button",{className:"icon-button",onClick:()=>C(!1),children:[e.jsx(O,{"aria-hidden":!0,size:14}),a("common.cancel")]}),e.jsxs("button",{className:"primary icon-button",disabled:r.password.length<t,onClick:()=>{q()},children:[e.jsx($,{"aria-hidden":!0,size:14}),a("users.createUser")]})]}),children:e.jsxs("div",{className:"form-stack",children:[e.jsxs("label",{className:"form-field",children:[a("auth.username"),e.jsx("input",{value:r.username,onChange:s=>o({...r,username:s.target.value})})]}),e.jsxs("label",{className:"form-field",children:[a("users.displayName"),e.jsx("input",{value:r.displayName,onChange:s=>o({...r,displayName:s.target.value})})]}),e.jsxs("label",{className:"form-field",children:[a("users.initialPassword"),e.jsxs("span",{className:"password-generator",children:[e.jsx("input",{minLength:t,autoComplete:"new-password",value:r.password,onChange:s=>o({...r,password:s.target.value})}),e.jsxs("button",{type:"button",title:a("users.generatePassword"),onClick:()=>o({...r,password:de()}),children:[e.jsx(re,{size:15}),a("users.randomPassword")]})]}),e.jsx("small",{className:"field-hint",children:a("auth.passwordMinimum",{count:t})})]}),e.jsxs("label",{className:"form-field",children:[a("users.role"),e.jsxs("select",{value:r.role,onChange:s=>o({...r,role:s.target.value}),children:[e.jsx("option",{value:"user",children:a("common.user")}),e.jsx("option",{value:"admin",children:a("common.admin")})]})]}),e.jsxs("label",{className:"checkbox-field",children:[e.jsx("input",{type:"checkbox",checked:r.canCreateProjects||r.role==="admin",disabled:r.role==="admin",onChange:s=>o({...r,canCreateProjects:s.target.checked})})," ",a("users.allowCreate")]})]})}),e.jsx(D,{open:!!k,title:a("users.resetPassword"),description:a("users.resetDescription",{username:k?.username??""}),onOpenChange:s=>{s||g(null)},footer:e.jsxs(e.Fragment,{children:[e.jsxs("button",{className:"icon-button",onClick:()=>g(null),children:[e.jsx(O,{"aria-hidden":!0,size:14}),a("common.cancel")]}),e.jsxs("button",{className:"primary icon-button",disabled:j.length<t,onClick:()=>{L()},children:[e.jsx(B,{"aria-hidden":!0,size:14}),a("users.reset")]})]}),children:e.jsxs("label",{className:"form-field",children:[a("auth.newPassword"),e.jsx("input",{autoFocus:!0,type:"password",minLength:t,autoComplete:"new-password",value:j,onChange:s=>P(s.target.value)}),e.jsx("small",{className:"field-hint",children:a("auth.passwordMinimum",{count:t})})]})}),e.jsx(D,{open:!!x,title:a("users.deleteTitle"),description:a("users.deleteDescription",{username:x?.username??""}),onOpenChange:s=>{!s&&!i&&(w(null),y(""))},footer:e.jsxs(e.Fragment,{children:[e.jsxs("button",{className:"icon-button",disabled:i,onClick:()=>{w(null),y("")},children:[e.jsx(O,{"aria-hidden":!0,size:14}),a("common.cancel")]}),e.jsxs("button",{className:"danger icon-button",disabled:i,"aria-busy":i,onClick:()=>{Q()},children:[i?e.jsx(_,{className:"spin","aria-hidden":!0,size:14}):e.jsx(R,{"aria-hidden":!0,size:14}),a(i?"common.loading":"users.deleteTitle")]})]}),children:e.jsxs(e.Fragment,{children:[U&&e.jsx("p",{className:"error dialog-error",children:U}),e.jsxs("fieldset",{className:"choice-group",disabled:i,children:[e.jsx("legend",{children:a("users.ownedChoice",{count:x?.ownedProjects??0})}),e.jsxs("label",{children:[e.jsx("input",{type:"radio",checked:!z,onChange:()=>N(!1)})," ",a("users.transferProjects")]}),e.jsxs("label",{children:[e.jsx("input",{type:"radio",checked:z,onChange:()=>N(!0)})," ",a("users.deleteProjects")]})]})]})}),e.jsx(ee,{open:!!l,title:a(`userConfirmations.${l?.setting??"disable"}Title`),description:a(`userConfirmations.${l?.setting??"disable"}Description`,{username:l?.target.username??""}),confirmLabel:a(`userConfirmations.${l?.setting??"disable"}Confirm`),danger:!0,busy:A,error:X,onCancel:()=>{A||(f(null),c(""))},onConfirm:()=>{I()}})]})}export{be as AdminUsers};
1
+ import{u as Y,r as n,j as e}from"./react-BVUjbTTn.js";import{c as m,M as D,d as _,C as ee,g as u,h}from"./index-p1NHkGGG.js";import{U as se,T as R,X as O}from"./x-eisRQJv_.js";import{U as $}from"./user-plus-MRmKeDtX.js";import{S as ae}from"./Dashboard-JA5_M3TK.js";import{K as B}from"./key-round-CoDwyVJc.js";import"./hard-drive-BWZnOgnm.js";import"./sigma-BgvHGPto.js";import"./tags-m9kppdi0.js";const re=m("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 ne=m("FolderCheck",[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 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 2Z",key:"1kt360"}],["path",{d:"m9 13 2 2 4-4",key:"6343dt"}]]);const te=m("FolderX",[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 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 2Z",key:"1kt360"}],["path",{d:"m9.5 10.5 5 5",key:"ra9qjz"}],["path",{d:"m14.5 10.5-5 5",key:"l2rkpq"}]]);const ie=m("ShieldOff",[["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M5 5a1 1 0 0 0-1 1v7c0 5 3.5 7.5 7.67 8.94a1 1 0 0 0 .67.01c2.35-.82 4.48-1.97 5.9-3.71",key:"1jlk70"}],["path",{d:"M9.309 3.652A12.252 12.252 0 0 0 11.24 2.28a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1v7a9.784 9.784 0 0 1-.08 1.264",key:"18rp1v"}]]);const oe=m("UserCheck",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["polyline",{points:"16 11 18 13 22 9",key:"1pwet4"}]]);const le=m("UserX",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"17",x2:"22",y1:"8",y2:"13",key:"3nzzx3"}],["line",{x1:"22",x2:"17",y1:"8",y2:"13",key:"1swrse"}]]);function de(p=10){const t="ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz23456789!@#$%",a=crypto.getRandomValues(new Uint8Array(p));return Array.from(a,S=>t[S%t.length]).join("")}function be({currentUser:p,minPasswordLength:t}){const{t:a}=Y(),[S,J]=n.useState([]),[E,d]=n.useState(""),[V,C]=n.useState(!1),[r,o]=n.useState({username:"",displayName:"",password:"",role:"user",canCreateProjects:!1}),[k,g]=n.useState(null),[j,P]=n.useState(""),[x,w]=n.useState(null),[z,N]=n.useState(!1),[i,F]=n.useState(!1),[U,y]=n.useState(""),[l,f]=n.useState(null),[A,H]=n.useState(!1),[X,c]=n.useState(""),b=()=>u("/api/admin/users").then(({users:s})=>J(s)).catch(s=>d(h(s)));n.useEffect(()=>{b()},[]);const q=async()=>{if(r.password.length<t)return d(a("auth.passwordMinimum",{count:t}));try{await u("/api/admin/users",{method:"POST",body:JSON.stringify({username:r.username,displayName:r.displayName||r.username,password:r.password,role:r.role,canCreateProjects:r.canCreateProjects})}),C(!1),o({username:"",displayName:"",password:"",role:"user",canCreateProjects:!1}),await b()}catch(s){d(h(s))}},M=async(s,v)=>{try{await u(`/api/admin/users/${s.id}`,{method:"PATCH",body:JSON.stringify(v)}),await b()}catch(T){d(h(T))}},K=async s=>{if(!s.disabled){f({target:s,setting:"disable"}),c("");return}await M(s,{disabled:!1})},Z=async s=>{if(s.role==="admin"){f({target:s,setting:"demote"}),c("");return}await M(s,{role:"admin"})},G=async s=>{if(s.canCreateProjects){f({target:s,setting:"denyProjectCreation"}),c("");return}await M(s,{canCreateProjects:!0})},I=async()=>{if(!l)return;const{target:s,setting:v}=l,T=v==="disable"?{disabled:!0}:v==="demote"?{role:"user"}:{canCreateProjects:!1};H(!0),c("");try{await u(`/api/admin/users/${s.id}`,{method:"PATCH",body:JSON.stringify(T)}),await b(),f(null)}catch(W){c(h(W))}finally{H(!1)}},L=async()=>{if(!(!k||!j)){if(j.length<t)return d(a("auth.passwordMinimum",{count:t}));try{await u(`/api/admin/users/${k.id}`,{method:"PATCH",body:JSON.stringify({password:j})}),g(null),P("")}catch(s){d(h(s))}}},Q=async()=>{if(!(!x||i)){F(!0),y("");try{await u(`/api/admin/users/${x.id}`,{method:"DELETE",body:JSON.stringify({deleteProjects:z})}),w(null),N(!1),await b()}catch(s){y(h(s))}finally{F(!1)}}};return e.jsxs("main",{className:"dashboard",children:[e.jsxs("div",{className:"section-title",children:[e.jsxs("div",{children:[e.jsxs("h1",{children:[e.jsx(se,{"aria-hidden":!0,size:25}),a("users.manage")]}),e.jsx("p",{className:"muted",children:a("users.onlyAdmin")})]}),e.jsxs("button",{className:"primary icon-button",onClick:()=>C(!0),children:[e.jsx($,{"aria-hidden":!0,size:15}),a("users.add")]})]}),E&&e.jsx("p",{className:"error",children:E}),e.jsx("div",{className:"table-card",children:e.jsxs("table",{children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:a("common.user")}),e.jsx("th",{children:a("users.role")}),e.jsx("th",{children:a("users.createProjects")}),e.jsx("th",{children:a("users.ownedProjects")}),e.jsx("th",{children:a("users.status")}),e.jsx("th",{children:a("users.actions")})]})}),e.jsx("tbody",{children:S.map(s=>e.jsxs("tr",{children:[e.jsxs("td",{children:[e.jsx("strong",{children:s.displayName}),e.jsxs("small",{children:["@",s.username]})]}),e.jsx("td",{children:s.role==="admin"?a("common.admin"):a("common.user")}),e.jsx("td",{children:s.canCreateProjects?a("users.allow"):a("users.deny")}),e.jsx("td",{children:s.ownedProjects}),e.jsx("td",{children:s.disabled?a("common.disabled"):a("common.normal")}),e.jsxs("td",{children:[e.jsxs("button",{className:"icon-button",disabled:s.id===p.id,onClick:()=>K(s),children:[s.disabled?e.jsx(oe,{"aria-hidden":!0,size:13}):e.jsx(le,{"aria-hidden":!0,size:13}),s.disabled?a("users.enable"):a("users.disable")]}),e.jsxs("button",{className:"icon-button",disabled:s.id===p.id,onClick:()=>Z(s),children:[s.role==="admin"?e.jsx(ie,{"aria-hidden":!0,size:13}):e.jsx(ae,{"aria-hidden":!0,size:13}),s.role==="admin"?a("users.demote"):a("users.promote")]}),e.jsxs("button",{className:"icon-button",disabled:s.role==="admin",onClick:()=>G(s),children:[s.canCreateProjects?e.jsx(te,{"aria-hidden":!0,size:13}):e.jsx(ne,{"aria-hidden":!0,size:13}),s.canCreateProjects?a("users.denyCreate"):a("users.allowCreate")]}),e.jsxs("button",{className:"icon-button",onClick:()=>{g(s),P("")},children:[e.jsx(B,{"aria-hidden":!0,size:13}),a("users.resetPassword")]}),e.jsxs("button",{className:"icon-button danger-text",disabled:s.id===p.id,onClick:()=>{w(s),N(!1),y("")},children:[e.jsx(R,{"aria-hidden":!0,size:13}),a("common.delete")]})]})]},s.id))})]})}),e.jsx(D,{open:V,title:a("users.add"),description:a("users.addDescription"),onOpenChange:C,footer:e.jsxs(e.Fragment,{children:[e.jsxs("button",{className:"icon-button",onClick:()=>C(!1),children:[e.jsx(O,{"aria-hidden":!0,size:14}),a("common.cancel")]}),e.jsxs("button",{className:"primary icon-button",disabled:r.password.length<t,onClick:()=>{q()},children:[e.jsx($,{"aria-hidden":!0,size:14}),a("users.createUser")]})]}),children:e.jsxs("div",{className:"form-stack",children:[e.jsxs("label",{className:"form-field",children:[a("auth.username"),e.jsx("input",{value:r.username,onChange:s=>o({...r,username:s.target.value})})]}),e.jsxs("label",{className:"form-field",children:[a("users.displayName"),e.jsx("input",{value:r.displayName,onChange:s=>o({...r,displayName:s.target.value})})]}),e.jsxs("label",{className:"form-field",children:[a("users.initialPassword"),e.jsxs("span",{className:"password-generator",children:[e.jsx("input",{minLength:t,autoComplete:"new-password",value:r.password,onChange:s=>o({...r,password:s.target.value})}),e.jsxs("button",{type:"button",title:a("users.generatePassword"),onClick:()=>o({...r,password:de()}),children:[e.jsx(re,{size:15}),a("users.randomPassword")]})]}),e.jsx("small",{className:"field-hint",children:a("auth.passwordMinimum",{count:t})})]}),e.jsxs("label",{className:"form-field",children:[a("users.role"),e.jsxs("select",{value:r.role,onChange:s=>o({...r,role:s.target.value}),children:[e.jsx("option",{value:"user",children:a("common.user")}),e.jsx("option",{value:"admin",children:a("common.admin")})]})]}),e.jsxs("label",{className:"checkbox-field",children:[e.jsx("input",{type:"checkbox",checked:r.canCreateProjects||r.role==="admin",disabled:r.role==="admin",onChange:s=>o({...r,canCreateProjects:s.target.checked})})," ",a("users.allowCreate")]})]})}),e.jsx(D,{open:!!k,title:a("users.resetPassword"),description:a("users.resetDescription",{username:k?.username??""}),onOpenChange:s=>{s||g(null)},footer:e.jsxs(e.Fragment,{children:[e.jsxs("button",{className:"icon-button",onClick:()=>g(null),children:[e.jsx(O,{"aria-hidden":!0,size:14}),a("common.cancel")]}),e.jsxs("button",{className:"primary icon-button",disabled:j.length<t,onClick:()=>{L()},children:[e.jsx(B,{"aria-hidden":!0,size:14}),a("users.reset")]})]}),children:e.jsxs("label",{className:"form-field",children:[a("auth.newPassword"),e.jsx("input",{autoFocus:!0,type:"password",minLength:t,autoComplete:"new-password",value:j,onChange:s=>P(s.target.value)}),e.jsx("small",{className:"field-hint",children:a("auth.passwordMinimum",{count:t})})]})}),e.jsx(D,{open:!!x,title:a("users.deleteTitle"),description:a("users.deleteDescription",{username:x?.username??""}),onOpenChange:s=>{!s&&!i&&(w(null),y(""))},footer:e.jsxs(e.Fragment,{children:[e.jsxs("button",{className:"icon-button",disabled:i,onClick:()=>{w(null),y("")},children:[e.jsx(O,{"aria-hidden":!0,size:14}),a("common.cancel")]}),e.jsxs("button",{className:"danger icon-button",disabled:i,"aria-busy":i,onClick:()=>{Q()},children:[i?e.jsx(_,{className:"spin","aria-hidden":!0,size:14}):e.jsx(R,{"aria-hidden":!0,size:14}),a(i?"common.loading":"users.deleteTitle")]})]}),children:e.jsxs(e.Fragment,{children:[U&&e.jsx("p",{className:"error dialog-error",children:U}),e.jsxs("fieldset",{className:"choice-group",disabled:i,children:[e.jsx("legend",{children:a("users.ownedChoice",{count:x?.ownedProjects??0})}),e.jsxs("label",{children:[e.jsx("input",{type:"radio",checked:!z,onChange:()=>N(!1)})," ",a("users.transferProjects")]}),e.jsxs("label",{children:[e.jsx("input",{type:"radio",checked:z,onChange:()=>N(!0)})," ",a("users.deleteProjects")]})]})]})}),e.jsx(ee,{open:!!l,title:a(`userConfirmations.${l?.setting??"disable"}Title`),description:a(`userConfirmations.${l?.setting??"disable"}Description`,{username:l?.target.username??""}),confirmLabel:a(`userConfirmations.${l?.setting??"disable"}Confirm`),danger:!0,busy:A,error:X,onCancel:()=>{A||(f(null),c(""))},onConfirm:()=>{I()}})]})}export{be as AdminUsers};
@@ -1 +1 @@
1
- import{u as Yt,r,j as t}from"./react-BVUjbTTn.js";import{c as At,g as S,h as k,d as H,C as Bt,M as ut}from"./index-teah8iB2.js";import{parseBibEntriesResult as Qt,citationBibtexLimitLabel as Xt,parseSingleBibEntry as Kt,citationVenue as Gt}from"./citationLibrary-ZeQPCv5O.js";import{B as tt,X as et,h as bt,C as Zt,j as zt,T as ti}from"./x-BEVz0wdw.js";import{P as it}from"./plus-DIrweesj.js";import{C as J}from"./check-BAdi_Lxq.js";import{S as ii}from"./search-C9_Jyrnx.js";import{T as ei}from"./tags-DjF3z21M.js";const ai=At("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 ni=At("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"}]]),si=[],ri={status:"empty",entries:si};function mi({open:o,onOpenChange:j,page:u=!1,onBack:b,currentFile:v="",currentSource:p="",readOnly:E=!1,currentUserId:h,maxBibtexBytes:l,onInsert:f}){const{t:e}=Yt(),[K,A]=r.useState("library"),[z,d]=r.useState(""),[L,P]=r.useState(""),[I,N]=r.useState([]),[at,C]=r.useState(1),[g,mt]=r.useState({page:1,pageSize:60,total:0,totalPages:0}),[Ft,U]=r.useState(0),[q,pt]=r.useState([]),[Y,gt]=r.useState(""),[xt,_t]=r.useState("green"),[m,x]=r.useState(null),[B,F]=r.useState([]),[nt,jt]=r.useState(!1),[Rt,vt]=r.useState(!1),[V,O]=r.useState(null),[y,T]=r.useState(null),[st,rt]=r.useState(""),[Dt,_]=r.useState(!1),[Q,ot]=r.useState(""),[ft,ct]=r.useState(null),[lt,X]=r.useState(null),[It,W]=r.useState(""),[$,c]=r.useState(""),[Lt,M]=r.useState(""),[Ct,w]=r.useState(new Map),[Ot,G]=r.useState(!1),[$t,Ht]=r.useState(0),R=!!(/\.bib$/i.test(v)&&f),dt=r.useMemo(()=>o&&R?Qt(p,l):ri,[o,p,R,l]),Nt=dt.status==="too-large",Tt=dt.status==="invalid",D=dt.entries,Jt=r.useMemo(()=>new Set(D.map(i=>i.citationKey.toLowerCase())),[D]);r.useEffect(()=>{if(!o)return;const i=new AbortController,a=window.setTimeout(()=>{vt(!0),c("");const n=new URLSearchParams;z.trim()&&n.set("q",z.trim()),L&&n.set("tag",L),n.set("page",String(at)),n.set("pageSize","60"),S(`/api/citations?${n.toString()}`,{signal:i.signal}).then(s=>{N(s.entries),mt(s.pagination),s.pagination.page!==at&&C(s.pagination.page)}).catch(s=>{s instanceof Error&&s.name==="AbortError"||c(k(s))}).finally(()=>{i.signal.aborted||vt(!1)})},z.trim()?180:0);return()=>{window.clearTimeout(a),i.abort()}},[o,z,L,at,Ft]),r.useEffect(()=>{if(!o)return;const i=new AbortController;return S("/api/citations/tags",{signal:i.signal}).then(a=>pt(a.tags)).catch(a=>{a instanceof Error&&a.name==="AbortError"||c(k(a))}),()=>i.abort()},[o]),r.useEffect(()=>{if(!o||!R){w(new Map),G(!1);return}const i=new AbortController,a=[...new Set(D.map(n=>n.citationKey))];return a.length?(G(!0),S("/api/citations/lookup",{method:"POST",body:JSON.stringify({keys:a}),signal:i.signal}).then(n=>{w(new Map(n.matches.map(s=>[s.citationKey.toLowerCase(),s])))}).catch(n=>{n instanceof Error&&n.name==="AbortError"||c(k(n))}).finally(()=>{i.signal.aborted||G(!1)}),()=>i.abort()):(w(new Map),G(!1),()=>i.abort())},[o,R,D,$t]),r.useEffect(()=>{o&&(A("library"),d(""),P(""),C(1),mt({page:1,pageSize:60,total:0,totalPages:0}),T(null),_(!1),ot(""),x(null),ct(null),X(null),W(""),c(""),M(""),w(new Map))},[o,R]);const Ut=async i=>{O(i.citationKey),c("");try{const a=Ct.get(i.citationKey.toLowerCase()),n=await S("/api/citations",{method:"POST",body:JSON.stringify({bibtex:i.bibtex,citationKey:i.citationKey,entryType:i.entryType,title:i.title,authors:i.authors,year:i.year,overwrite:!!a,expectedRevision:a?.revision})});N(s=>[n.entry,...s.filter(Z=>Z.id!==n.entry.id&&Z.citationKey.toLowerCase()!==n.entry.citationKey.toLowerCase())]),w(s=>new Map(s).set(n.entry.citationKey.toLowerCase(),{id:n.entry.id,citationKey:n.entry.citationKey,revision:n.entry.revision})),x(n.entry),F(n.entry.tags.map(s=>s.id)),M(n.updated?e("citationLibrary.updated"):e("citationLibrary.saved")),C(1),U(s=>s+1)}catch(a){c(k(a)),Ht(n=>n+1)}finally{O(null)}},wt=async()=>{if(y){O(y.citationKey),c("");try{const i=Kt(st,l);if(!i){c(e("citationErrors.invalid"));return}const a=await S(`/api/citations/${encodeURIComponent(y.id)}`,{method:"PATCH",body:JSON.stringify({bibtex:i.bibtex,citationKey:i.citationKey,entryType:i.entryType,title:i.title,authors:i.authors,year:i.year,expectedRevision:y.revision})});N(n=>[a.entry,...n.filter(s=>s.id!==a.entry.id)]),w(n=>{const s=new Map(n);return s.delete(y.citationKey.toLowerCase()),s.set(a.entry.citationKey.toLowerCase(),{id:a.entry.id,citationKey:a.entry.citationKey,revision:a.entry.revision}),s}),T(null),M(e("citationLibrary.updated")),C(1),U(n=>n+1)}catch(i){c(k(i))}finally{O(null)}}},qt=async()=>{if(Q.trim()){O("__new__"),c("");try{const i=Kt(Q,l);if(!i){c(e("citationErrors.invalid"));return}const a=await S("/api/citations",{method:"POST",body:JSON.stringify({bibtex:i.bibtex,citationKey:i.citationKey,entryType:i.entryType,title:i.title,authors:i.authors,year:i.year})});N(n=>[a.entry,...n.filter(s=>s.id!==a.entry.id&&s.citationKey.toLowerCase()!==a.entry.citationKey.toLowerCase())]),w(n=>new Map(n).set(a.entry.citationKey.toLowerCase(),{id:a.entry.id,citationKey:a.entry.citationKey,revision:a.entry.revision})),_(!1),ot(""),M(a.updated?e("citationLibrary.updated"):e("citationLibraryActions.added")),x(a.entry),F(a.entry.tags.map(n=>n.id)),C(1),U(n=>n+1)}catch(i){c(k(i))}finally{O(null)}}},St=async()=>{if(Y.trim()){c("");try{const i=await S("/api/citations/tags",{method:"POST",body:JSON.stringify({name:Y.trim(),color:xt})});pt(a=>[...a.filter(n=>n.id!==i.tag.id),i.tag].sort((n,s)=>n.name.localeCompare(s.name))),gt(""),M(e("citationLibrary.tagCreated"))}catch(i){c(k(i))}}},Vt=i=>{T(null),_(!1),x(i),F(i.tags.map(a=>a.id))},yt=async()=>{if(m){jt(!0),c("");try{const i=await S(`/api/citations/${encodeURIComponent(m.id)}/tags`,{method:"PATCH",body:JSON.stringify({tagIds:B,expectedRevision:m.revision})});N(a=>a.map(n=>n.id===i.entry.id?i.entry:n)),w(a=>new Map(a).set(i.entry.citationKey.toLowerCase(),{id:i.entry.id,citationKey:i.entry.citationKey,revision:i.entry.revision})),x(i.entry),F(i.entry.tags.map(a=>a.id)),M(e("citationLibrary.tagsUpdated")),U(a=>a+1)}catch(i){c(k(i))}finally{jt(!1)}}},Wt=async i=>{ct(i.id),W("");try{await S(`/api/citations/${encodeURIComponent(i.id)}`,{method:"DELETE"}),N(a=>a.filter(n=>n.id!==i.id)),w(a=>{const n=new Map(a);return n.delete(i.citationKey.toLowerCase()),n}),y?.id===i.id&&T(null),m?.id===i.id&&x(null),M(e("citationLibrary.deleted")),C(1),U(a=>a+1),X(null)}catch(a){W(k(a))}finally{ct(null)}},kt=t.jsxs("div",{className:"citation-library-dialog",children:[t.jsxs("div",{className:"citation-library-tabs",role:"tablist","aria-label":e("citationLibrary.title"),children:[t.jsxs("button",{type:"button",role:"tab","aria-selected":K==="library",className:K==="library"?"active":"",onClick:()=>A("library"),children:[t.jsx(tt,{size:15}),e("citationLibrary.myLibrary"),t.jsx("span",{children:g.total})]}),R&&t.jsxs("button",{type:"button",role:"tab","aria-selected":K==="current",className:K==="current"?"active":"",onClick:()=>A("current"),children:[t.jsx(it,{size:15}),e("citationLibrary.currentFile"),t.jsx("span",{children:D.length})]})]}),$&&!(u&&(m||y))&&t.jsx("p",{className:"error dialog-error",children:$}),Lt&&t.jsxs("p",{className:"citation-library-notice",role:"status",children:[t.jsx(J,{size:14}),Lt,t.jsx("button",{type:"button","aria-label":e("common.close"),onClick:()=>M(""),children:t.jsx(et,{size:13})})]}),K==="library"?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"citation-library-search-row",children:[t.jsxs("label",{className:"citation-library-search",children:[t.jsx(ii,{size:15}),t.jsx("input",{autoFocus:!0,placeholder:e("citationLibrary.searchPlaceholder"),value:z,onChange:i=>{d(i.target.value),C(1)}}),t.jsx("span",{children:e("citationLibrary.searchHint")})]}),t.jsxs("button",{type:"button",className:"citation-add-entry-button",onClick:()=>{_(!0),T(null),x(null)},children:[t.jsx(it,{size:14}),e("citationLibraryActions.addEntry")]})]}),t.jsxs("div",{className:"citation-tag-bar",children:[t.jsxs("div",{className:"citation-tag-filters",children:[t.jsx("button",{type:"button",className:L?"":"active",onClick:()=>{P(""),C(1)},children:e("citationLibrary.allTags")}),q.map(i=>t.jsxs("button",{type:"button",className:L===i.id?"active":"",onClick:()=>{P(L===i.id?"":i.id),C(1)},children:[t.jsx("span",{className:`citation-tag-dot tag-${i.color}`}),i.name]},i.id)),q.length===0&&t.jsx("span",{className:"muted",children:e("citationLibrary.noTags")})]}),t.jsxs("div",{className:"citation-tag-create",children:[t.jsx("input",{value:Y,placeholder:e("citationLibrary.newTagPlaceholder"),onChange:i=>gt(i.target.value),onKeyDown:i=>{i.key==="Enter"&&(i.preventDefault(),St())}}),t.jsx("select",{"aria-label":e("citationLibrary.tagColor"),value:xt,onChange:i=>_t(i.target.value),children:["red","orange","yellow","green","blue","purple","gray"].map(i=>t.jsx("option",{value:i,children:e(`tags.${i}`)},i))}),t.jsxs("button",{type:"button",disabled:!Y.trim(),title:e("citationLibrary.createTag"),onClick:()=>{St()},children:[t.jsx(it,{size:13}),e("citationLibrary.createTag")]})]})]}),Dt&&t.jsxs("div",{className:"citation-edit-panel",children:[t.jsxs("div",{className:"citation-edit-header",children:[t.jsxs("div",{children:[t.jsx("strong",{children:e("citationLibraryActions.addEntryTitle")}),t.jsx("small",{children:e("citationLibraryActions.addEntryDescription")})]}),t.jsx("button",{type:"button","aria-label":e("common.close"),onClick:()=>_(!1),children:t.jsx(et,{size:15})})]}),t.jsx("textarea",{autoFocus:!0,value:Q,onChange:i=>ot(i.target.value),placeholder:e("citationLibraryActions.addEntryPlaceholder"),spellCheck:!1,rows:9}),t.jsxs("div",{className:"citation-edit-actions",children:[t.jsx("button",{type:"button",onClick:()=>_(!1),children:e("common.cancel")}),t.jsxs("button",{type:"button",className:"primary",disabled:!Q.trim()||V==="__new__",onClick:()=>{qt()},children:[V==="__new__"?t.jsx(H,{className:"spin",size:14}):t.jsx(J,{size:14}),e("citationLibraryActions.addEntry")]})]})]}),Rt?t.jsxs("div",{className:"citation-library-empty",children:[t.jsx(H,{className:"spin",size:22}),t.jsx("span",{children:e("common.loading")})]}):I.length===0?t.jsxs("div",{className:"citation-library-empty",children:[t.jsx(tt,{size:28}),t.jsx("strong",{children:e("citationLibrary.emptyTitle")}),t.jsx("span",{children:e(L?"citationLibrary.noTagMatches":"citationLibrary.emptyDescription")})]}):t.jsx("div",{className:"citation-entry-list",children:I.map(i=>t.jsxs("div",{className:"citation-entry-item",children:[t.jsx(Pt,{entry:i,currentUserId:h,selected:m?.id===i.id||y?.id===i.id,alreadyInFile:!u&&Jt.has(i.citationKey.toLowerCase()),importDisabled:E,deleting:ft===i.id,onImport:f?async()=>{await f(i)&&j(!1)}:void 0,onEdit:i.ownerId===h?()=>{x(null),_(!1),T(i),rt(i.bibtex)}:void 0,onTags:i.ownerId===h?()=>Vt(i):void 0,onDelete:i.ownerId===h?()=>{X(i),W("")}:void 0,t:e}),!u&&m?.id===i.id&&t.jsx(ht,{entry:m,tags:q,selectedIds:B,saving:nt,onClose:()=>x(null),onToggle:a=>F(n=>n.includes(a)?n.filter(s=>s!==a):[...n,a]),onSave:()=>{yt()},t:e}),!u&&y?.id===i.id&&t.jsx(Mt,{title:e("citationLibrary.editTitle",{key:y.citationKey}),value:st,saving:V===y.citationKey,onChange:rt,onClose:()=>T(null),onSave:()=>{wt()},t:e})]},i.id))}),g.totalPages>1&&t.jsxs("nav",{className:"citation-library-pagination","aria-label":e("citationLibraryPagination.pageOf",{page:g.page,totalPages:g.totalPages,count:g.total}),children:[t.jsxs("button",{type:"button",disabled:g.page<=1,onClick:()=>C(i=>Math.max(1,i-1)),children:[t.jsx(bt,{size:14}),e("citationLibraryPagination.previous")]}),t.jsx("span",{children:e("citationLibraryPagination.pageOf",{page:g.page,totalPages:g.totalPages,count:g.total})}),t.jsxs("button",{type:"button",disabled:g.page>=g.totalPages,onClick:()=>C(i=>Math.min(g.totalPages,i+1)),children:[e("citationLibraryPagination.next"),t.jsx(Zt,{size:14})]})]})]}):t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"citation-current-heading",children:[t.jsxs("div",{children:[t.jsx("strong",{children:e("citationLibrary.currentFileTitle")}),t.jsx("span",{children:e("citationLibrary.currentFileDescription")})]}),t.jsxs("button",{type:"button",onClick:()=>A("library"),children:[t.jsx(bt,{size:14}),e("citationLibrary.backToLibrary")]})]}),Nt&&t.jsxs("p",{className:"warning citation-library-warning",children:[t.jsx(zt,{size:15}),e("citationLibrary.fileTooLarge",{size:Xt(l)})]}),Tt&&t.jsxs("p",{className:"warning citation-library-warning",children:[t.jsx(zt,{size:15}),e("citationLibrary.fileInvalid")]}),D.length===0?t.jsxs("div",{className:"citation-library-empty",children:[t.jsx(tt,{size:28}),t.jsx("strong",{children:e("citationLibrary.noEntries")}),t.jsx("span",{children:e(Nt?"citationLibrary.fileTooLargeHint":Tt?"citationLibrary.fileInvalidHint":"citationLibrary.noEntriesDescription")})]}):t.jsx("div",{className:"citation-entry-list",children:D.map((i,a)=>t.jsxs("div",{className:"citation-entry-item",children:[t.jsx(Pt,{entry:i,saved:Ct.has(i.citationKey.toLowerCase()),saving:V===i.citationKey,saveDisabled:Ot,onSave:()=>{Ut(i)},t:e}),!u&&m?.citationKey.toLowerCase()===i.citationKey.toLowerCase()&&t.jsx(ht,{entry:m,tags:q,selectedIds:B,saving:nt,onClose:()=>x(null),onToggle:n=>F(s=>s.includes(n)?s.filter(Z=>Z!==n):[...s,n]),onSave:()=>{yt()},t:e})]},`${i.citationKey}-${a}`))})]})]}),Et=t.jsx(Bt,{open:!!lt,title:e("citationLibrary.deleteTitle"),description:e("citationLibrary.deleteDescription",{key:lt?.citationKey??""}),confirmLabel:e("common.delete"),danger:!0,error:It,busy:!!ft,onCancel:()=>{X(null),W("")},onConfirm:()=>{const i=lt;i&&Wt(i)}});return u?t.jsxs(t.Fragment,{children:[t.jsxs("section",{className:"citation-library-page",children:[t.jsxs("header",{className:"citation-library-page-header",children:[t.jsxs("div",{children:[t.jsxs("h1",{children:[t.jsx(tt,{"aria-hidden":!0,size:26}),e("citationLibrary.title")]}),t.jsx("p",{children:e("citationLibraryHomeDescription")})]}),b&&t.jsxs("button",{type:"button",onClick:b,children:[t.jsx(bt,{size:15}),e("projects.title")]})]}),kt]}),m&&t.jsx(ut,{open:!0,title:e("citationLibrary.tagsTitle",{key:m.citationKey}),description:e("citationLibrary.tags"),onOpenChange:i=>{i||(x(null),c(""))},children:t.jsxs(t.Fragment,{children:[$&&t.jsx("p",{className:"error dialog-error",children:$}),t.jsx(ht,{entry:m,tags:q,selectedIds:B,saving:nt,modal:!0,onClose:()=>{x(null),c("")},onToggle:i=>F(a=>a.includes(i)?a.filter(n=>n!==i):[...a,i]),onSave:()=>{yt()},t:e})]})}),y&&t.jsx(ut,{open:!0,extraWide:!0,title:e("citationLibrary.editTitle",{key:y.citationKey}),description:e("citationLibrary.title"),onOpenChange:i=>{i||(T(null),c(""))},children:t.jsxs(t.Fragment,{children:[$&&t.jsx("p",{className:"error dialog-error",children:$}),t.jsx(Mt,{title:e("citationLibrary.editTitle",{key:y.citationKey}),value:st,saving:V===y.citationKey,modal:!0,onChange:rt,onClose:()=>{T(null),c("")},onSave:()=>{wt()},t:e})]})}),Et]}):t.jsxs(t.Fragment,{children:[t.jsx(ut,{open:o,extraWide:!0,className:"citation-library-modal",title:e("citationLibrary.title"),description:e(R?"citationLibrary.description":"citationLibraryHomeDescription",{file:v}),onOpenChange:j,footer:t.jsx("button",{onClick:()=>j(!1),children:e("common.close")}),children:kt}),Et]})}function Pt({entry:o,currentUserId:j,selected:u,alreadyInFile:b,saved:v,saving:p,saveDisabled:E,importDisabled:h,deleting:l,onSave:f,onImport:e,onEdit:K,onTags:A,onDelete:z,t:d}){const L="id"in o,P=L?o:null,I=Gt(o);return t.jsxs("article",{className:`citation-entry-card${u?" selected":""}${b?" already-in-file":""}`,title:b?d("citationErrors.alreadyInFile",{key:o.citationKey}):void 0,children:[t.jsxs("div",{className:"citation-entry-main",children:[t.jsxs("div",{className:"citation-entry-heading",children:[t.jsx("code",{children:o.citationKey}),t.jsxs("span",{children:["@",o.entryType]}),I&&t.jsx("span",{className:"citation-entry-venue",title:I,children:I}),v&&t.jsxs("em",{children:[t.jsx(J,{size:11}),d("citationLibrary.savedLabel")]})]}),t.jsx("strong",{children:o.title||d("citationLibrary.untitled")}),t.jsxs("p",{children:[o.authors||d("citationLibrary.authorUnknown"),o.year&&t.jsxs("span",{children:[" · ",o.year]})]}),P&&P.tags.length>0&&t.jsx("div",{className:"citation-entry-tags",children:P.tags.map(N=>t.jsxs("span",{className:`citation-tag-pill tag-${N.color}`,children:[t.jsx("span",{className:"citation-tag-dot"}),N.name]},N.id))})]}),t.jsxs("div",{className:"citation-entry-actions",children:[f&&t.jsxs("button",{type:"button",className:v?"saved":"primary",disabled:p||E,onClick:f,children:[p||E?t.jsx(H,{className:"spin",size:13}):v?t.jsx(J,{size:13}):t.jsx(it,{size:13}),d(p?"citationLibrary.saving":v?"citationLibrary.update":"citationLibrary.save")]}),e&&t.jsxs("button",{type:"button",disabled:h||b,title:b?d("citationErrors.alreadyInFile",{key:o.citationKey}):d(h?"citationLibrary.importRequiresWrite":"citationLibrary.importToFile"),onClick:()=>{e()},children:[t.jsx(ai,{size:13}),d("citationLibrary.import")]}),P&&A&&t.jsxs("button",{type:"button",onClick:A,children:[t.jsx(ei,{size:13}),d("citationLibrary.tags")]}),L&&K&&t.jsxs("button",{type:"button",onClick:K,children:[t.jsx(ni,{size:13}),d("common.edit")]}),L&&z&&t.jsxs("button",{type:"button",className:"danger-text",disabled:l,onClick:z,children:[l?t.jsx(H,{className:"spin",size:13}):t.jsx(ti,{size:13}),d("common.delete")]})]})]})}function ht({entry:o,tags:j,selectedIds:u,saving:b,modal:v=!1,onClose:p,onToggle:E,onSave:h,t:l}){const f=t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"citation-tag-choice-list",children:j.length===0?t.jsx("span",{className:"muted",children:l("citationLibrary.noTagsToAssign")}):j.map(e=>t.jsxs("label",{children:[t.jsx("input",{type:"checkbox",checked:u.includes(e.id),onChange:()=>E(e.id)}),t.jsx("span",{className:`citation-tag-dot tag-${e.color}`}),e.name]},e.id))}),t.jsxs("div",{className:"citation-edit-actions",children:[t.jsx("button",{type:"button",onClick:p,children:l("common.cancel")}),t.jsxs("button",{type:"button",className:"primary",disabled:b||j.length===0,onClick:h,children:[b?t.jsx(H,{className:"spin",size:14}):t.jsx(J,{size:14}),l("citationLibrary.saveTags")]})]})]});return v?t.jsx("div",{className:"citation-modal-form",children:f}):t.jsxs("div",{className:"citation-tag-editor",children:[t.jsxs("div",{className:"citation-edit-header",children:[t.jsx("strong",{children:l("citationLibrary.tagsTitle",{key:o.citationKey})}),t.jsx("button",{type:"button","aria-label":l("common.close"),onClick:p,children:t.jsx(et,{size:15})})]}),f]})}function Mt({title:o,value:j,saving:u,modal:b=!1,onChange:v,onClose:p,onSave:E,t:h}){const l=t.jsxs(t.Fragment,{children:[t.jsx("textarea",{autoFocus:!b,value:j,onChange:f=>v(f.target.value),spellCheck:!1,rows:12}),t.jsxs("div",{className:"citation-edit-actions",children:[t.jsx("button",{type:"button",onClick:p,children:h("common.cancel")}),t.jsxs("button",{type:"button",className:"primary",disabled:!j.trim()||u,onClick:E,children:[u?t.jsx(H,{className:"spin",size:14}):t.jsx(J,{size:14}),h("common.save")]})]})]});return b?t.jsx("div",{className:"citation-modal-form citation-edit-panel",children:l}):t.jsxs("div",{className:"citation-edit-panel",children:[t.jsxs("div",{className:"citation-edit-header",children:[t.jsx("strong",{children:o}),t.jsx("button",{type:"button","aria-label":h("common.close"),onClick:p,children:t.jsx(et,{size:15})})]}),l]})}export{mi as CitationLibraryDialog};
1
+ import{u as Yt,r,j as t}from"./react-BVUjbTTn.js";import{c as At,g as S,h as k,d as H,C as Bt,M as ut}from"./index-p1NHkGGG.js";import{parseBibEntriesResult as Qt,citationBibtexLimitLabel as Xt,parseSingleBibEntry as Kt,citationVenue as Gt}from"./citationLibrary-ZeQPCv5O.js";import{B as tt,X as et,i as bt,C as Zt,k as zt,T as ti}from"./x-eisRQJv_.js";import{P as it}from"./plus-BVXOlQXP.js";import{C as J}from"./check-C1db8iNn.js";import{S as ii}from"./search-DXo_aAp0.js";import{T as ei}from"./tags-m9kppdi0.js";const ai=At("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 ni=At("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"}]]),si=[],ri={status:"empty",entries:si};function hi({open:o,onOpenChange:j,page:u=!1,onBack:b,currentFile:v="",currentSource:p="",readOnly:E=!1,currentUserId:m,maxBibtexBytes:l,onInsert:f}){const{t:e}=Yt(),[K,A]=r.useState("library"),[z,d]=r.useState(""),[L,P]=r.useState(""),[I,N]=r.useState([]),[at,C]=r.useState(1),[g,ht]=r.useState({page:1,pageSize:60,total:0,totalPages:0}),[Ft,U]=r.useState(0),[q,pt]=r.useState([]),[Y,gt]=r.useState(""),[xt,_t]=r.useState("green"),[h,x]=r.useState(null),[B,F]=r.useState([]),[nt,jt]=r.useState(!1),[Rt,vt]=r.useState(!1),[V,O]=r.useState(null),[y,T]=r.useState(null),[st,rt]=r.useState(""),[Dt,_]=r.useState(!1),[Q,ot]=r.useState(""),[ft,ct]=r.useState(null),[lt,X]=r.useState(null),[It,W]=r.useState(""),[$,c]=r.useState(""),[Lt,M]=r.useState(""),[Ct,w]=r.useState(new Map),[Ot,G]=r.useState(!1),[$t,Ht]=r.useState(0),R=!!(/\.bib$/i.test(v)&&f),dt=r.useMemo(()=>o&&R?Qt(p,l):ri,[o,p,R,l]),Nt=dt.status==="too-large",Tt=dt.status==="invalid",D=dt.entries,Jt=r.useMemo(()=>new Set(D.map(i=>i.citationKey.toLowerCase())),[D]);r.useEffect(()=>{if(!o)return;const i=new AbortController,a=window.setTimeout(()=>{vt(!0),c("");const n=new URLSearchParams;z.trim()&&n.set("q",z.trim()),L&&n.set("tag",L),n.set("page",String(at)),n.set("pageSize","60"),S(`/api/citations?${n.toString()}`,{signal:i.signal}).then(s=>{N(s.entries),ht(s.pagination),s.pagination.page!==at&&C(s.pagination.page)}).catch(s=>{s instanceof Error&&s.name==="AbortError"||c(k(s))}).finally(()=>{i.signal.aborted||vt(!1)})},z.trim()?180:0);return()=>{window.clearTimeout(a),i.abort()}},[o,z,L,at,Ft]),r.useEffect(()=>{if(!o)return;const i=new AbortController;return S("/api/citations/tags",{signal:i.signal}).then(a=>pt(a.tags)).catch(a=>{a instanceof Error&&a.name==="AbortError"||c(k(a))}),()=>i.abort()},[o]),r.useEffect(()=>{if(!o||!R){w(new Map),G(!1);return}const i=new AbortController,a=[...new Set(D.map(n=>n.citationKey))];return a.length?(G(!0),S("/api/citations/lookup",{method:"POST",body:JSON.stringify({keys:a}),signal:i.signal}).then(n=>{w(new Map(n.matches.map(s=>[s.citationKey.toLowerCase(),s])))}).catch(n=>{n instanceof Error&&n.name==="AbortError"||c(k(n))}).finally(()=>{i.signal.aborted||G(!1)}),()=>i.abort()):(w(new Map),G(!1),()=>i.abort())},[o,R,D,$t]),r.useEffect(()=>{o&&(A("library"),d(""),P(""),C(1),ht({page:1,pageSize:60,total:0,totalPages:0}),T(null),_(!1),ot(""),x(null),ct(null),X(null),W(""),c(""),M(""),w(new Map))},[o,R]);const Ut=async i=>{O(i.citationKey),c("");try{const a=Ct.get(i.citationKey.toLowerCase()),n=await S("/api/citations",{method:"POST",body:JSON.stringify({bibtex:i.bibtex,citationKey:i.citationKey,entryType:i.entryType,title:i.title,authors:i.authors,year:i.year,overwrite:!!a,expectedRevision:a?.revision})});N(s=>[n.entry,...s.filter(Z=>Z.id!==n.entry.id&&Z.citationKey.toLowerCase()!==n.entry.citationKey.toLowerCase())]),w(s=>new Map(s).set(n.entry.citationKey.toLowerCase(),{id:n.entry.id,citationKey:n.entry.citationKey,revision:n.entry.revision})),x(n.entry),F(n.entry.tags.map(s=>s.id)),M(n.updated?e("citationLibrary.updated"):e("citationLibrary.saved")),C(1),U(s=>s+1)}catch(a){c(k(a)),Ht(n=>n+1)}finally{O(null)}},wt=async()=>{if(y){O(y.citationKey),c("");try{const i=Kt(st,l);if(!i){c(e("citationErrors.invalid"));return}const a=await S(`/api/citations/${encodeURIComponent(y.id)}`,{method:"PATCH",body:JSON.stringify({bibtex:i.bibtex,citationKey:i.citationKey,entryType:i.entryType,title:i.title,authors:i.authors,year:i.year,expectedRevision:y.revision})});N(n=>[a.entry,...n.filter(s=>s.id!==a.entry.id)]),w(n=>{const s=new Map(n);return s.delete(y.citationKey.toLowerCase()),s.set(a.entry.citationKey.toLowerCase(),{id:a.entry.id,citationKey:a.entry.citationKey,revision:a.entry.revision}),s}),T(null),M(e("citationLibrary.updated")),C(1),U(n=>n+1)}catch(i){c(k(i))}finally{O(null)}}},qt=async()=>{if(Q.trim()){O("__new__"),c("");try{const i=Kt(Q,l);if(!i){c(e("citationErrors.invalid"));return}const a=await S("/api/citations",{method:"POST",body:JSON.stringify({bibtex:i.bibtex,citationKey:i.citationKey,entryType:i.entryType,title:i.title,authors:i.authors,year:i.year})});N(n=>[a.entry,...n.filter(s=>s.id!==a.entry.id&&s.citationKey.toLowerCase()!==a.entry.citationKey.toLowerCase())]),w(n=>new Map(n).set(a.entry.citationKey.toLowerCase(),{id:a.entry.id,citationKey:a.entry.citationKey,revision:a.entry.revision})),_(!1),ot(""),M(a.updated?e("citationLibrary.updated"):e("citationLibraryActions.added")),x(a.entry),F(a.entry.tags.map(n=>n.id)),C(1),U(n=>n+1)}catch(i){c(k(i))}finally{O(null)}}},St=async()=>{if(Y.trim()){c("");try{const i=await S("/api/citations/tags",{method:"POST",body:JSON.stringify({name:Y.trim(),color:xt})});pt(a=>[...a.filter(n=>n.id!==i.tag.id),i.tag].sort((n,s)=>n.name.localeCompare(s.name))),gt(""),M(e("citationLibrary.tagCreated"))}catch(i){c(k(i))}}},Vt=i=>{T(null),_(!1),x(i),F(i.tags.map(a=>a.id))},yt=async()=>{if(h){jt(!0),c("");try{const i=await S(`/api/citations/${encodeURIComponent(h.id)}/tags`,{method:"PATCH",body:JSON.stringify({tagIds:B,expectedRevision:h.revision})});N(a=>a.map(n=>n.id===i.entry.id?i.entry:n)),w(a=>new Map(a).set(i.entry.citationKey.toLowerCase(),{id:i.entry.id,citationKey:i.entry.citationKey,revision:i.entry.revision})),x(i.entry),F(i.entry.tags.map(a=>a.id)),M(e("citationLibrary.tagsUpdated")),U(a=>a+1)}catch(i){c(k(i))}finally{jt(!1)}}},Wt=async i=>{ct(i.id),W("");try{await S(`/api/citations/${encodeURIComponent(i.id)}`,{method:"DELETE"}),N(a=>a.filter(n=>n.id!==i.id)),w(a=>{const n=new Map(a);return n.delete(i.citationKey.toLowerCase()),n}),y?.id===i.id&&T(null),h?.id===i.id&&x(null),M(e("citationLibrary.deleted")),C(1),U(a=>a+1),X(null)}catch(a){W(k(a))}finally{ct(null)}},kt=t.jsxs("div",{className:"citation-library-dialog",children:[t.jsxs("div",{className:"citation-library-tabs",role:"tablist","aria-label":e("citationLibrary.title"),children:[t.jsxs("button",{type:"button",role:"tab","aria-selected":K==="library",className:K==="library"?"active":"",onClick:()=>A("library"),children:[t.jsx(tt,{size:15}),e("citationLibrary.myLibrary"),t.jsx("span",{children:g.total})]}),R&&t.jsxs("button",{type:"button",role:"tab","aria-selected":K==="current",className:K==="current"?"active":"",onClick:()=>A("current"),children:[t.jsx(it,{size:15}),e("citationLibrary.currentFile"),t.jsx("span",{children:D.length})]})]}),$&&!(u&&(h||y))&&t.jsx("p",{className:"error dialog-error",children:$}),Lt&&t.jsxs("p",{className:"citation-library-notice",role:"status",children:[t.jsx(J,{size:14}),Lt,t.jsx("button",{type:"button","aria-label":e("common.close"),onClick:()=>M(""),children:t.jsx(et,{size:13})})]}),K==="library"?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"citation-library-search-row",children:[t.jsxs("label",{className:"citation-library-search",children:[t.jsx(ii,{size:15}),t.jsx("input",{autoFocus:!0,placeholder:e("citationLibrary.searchPlaceholder"),value:z,onChange:i=>{d(i.target.value),C(1)}}),t.jsx("span",{children:e("citationLibrary.searchHint")})]}),t.jsxs("button",{type:"button",className:"citation-add-entry-button",onClick:()=>{_(!0),T(null),x(null)},children:[t.jsx(it,{size:14}),e("citationLibraryActions.addEntry")]})]}),t.jsxs("div",{className:"citation-tag-bar",children:[t.jsxs("div",{className:"citation-tag-filters",children:[t.jsx("button",{type:"button",className:L?"":"active",onClick:()=>{P(""),C(1)},children:e("citationLibrary.allTags")}),q.map(i=>t.jsxs("button",{type:"button",className:L===i.id?"active":"",onClick:()=>{P(L===i.id?"":i.id),C(1)},children:[t.jsx("span",{className:`citation-tag-dot tag-${i.color}`}),i.name]},i.id)),q.length===0&&t.jsx("span",{className:"muted",children:e("citationLibrary.noTags")})]}),t.jsxs("div",{className:"citation-tag-create",children:[t.jsx("input",{value:Y,placeholder:e("citationLibrary.newTagPlaceholder"),onChange:i=>gt(i.target.value),onKeyDown:i=>{i.key==="Enter"&&(i.preventDefault(),St())}}),t.jsx("select",{"aria-label":e("citationLibrary.tagColor"),value:xt,onChange:i=>_t(i.target.value),children:["red","orange","yellow","green","blue","purple","gray"].map(i=>t.jsx("option",{value:i,children:e(`tags.${i}`)},i))}),t.jsxs("button",{type:"button",disabled:!Y.trim(),title:e("citationLibrary.createTag"),onClick:()=>{St()},children:[t.jsx(it,{size:13}),e("citationLibrary.createTag")]})]})]}),Dt&&t.jsxs("div",{className:"citation-edit-panel",children:[t.jsxs("div",{className:"citation-edit-header",children:[t.jsxs("div",{children:[t.jsx("strong",{children:e("citationLibraryActions.addEntryTitle")}),t.jsx("small",{children:e("citationLibraryActions.addEntryDescription")})]}),t.jsx("button",{type:"button","aria-label":e("common.close"),onClick:()=>_(!1),children:t.jsx(et,{size:15})})]}),t.jsx("textarea",{autoFocus:!0,value:Q,onChange:i=>ot(i.target.value),placeholder:e("citationLibraryActions.addEntryPlaceholder"),spellCheck:!1,rows:9}),t.jsxs("div",{className:"citation-edit-actions",children:[t.jsx("button",{type:"button",onClick:()=>_(!1),children:e("common.cancel")}),t.jsxs("button",{type:"button",className:"primary",disabled:!Q.trim()||V==="__new__",onClick:()=>{qt()},children:[V==="__new__"?t.jsx(H,{className:"spin",size:14}):t.jsx(J,{size:14}),e("citationLibraryActions.addEntry")]})]})]}),Rt?t.jsxs("div",{className:"citation-library-empty",children:[t.jsx(H,{className:"spin",size:22}),t.jsx("span",{children:e("common.loading")})]}):I.length===0?t.jsxs("div",{className:"citation-library-empty",children:[t.jsx(tt,{size:28}),t.jsx("strong",{children:e("citationLibrary.emptyTitle")}),t.jsx("span",{children:e(L?"citationLibrary.noTagMatches":"citationLibrary.emptyDescription")})]}):t.jsx("div",{className:"citation-entry-list",children:I.map(i=>t.jsxs("div",{className:"citation-entry-item",children:[t.jsx(Pt,{entry:i,currentUserId:m,selected:h?.id===i.id||y?.id===i.id,alreadyInFile:!u&&Jt.has(i.citationKey.toLowerCase()),importDisabled:E,deleting:ft===i.id,onImport:f?async()=>{await f(i)&&j(!1)}:void 0,onEdit:i.ownerId===m?()=>{x(null),_(!1),T(i),rt(i.bibtex)}:void 0,onTags:i.ownerId===m?()=>Vt(i):void 0,onDelete:i.ownerId===m?()=>{X(i),W("")}:void 0,t:e}),!u&&h?.id===i.id&&t.jsx(mt,{entry:h,tags:q,selectedIds:B,saving:nt,onClose:()=>x(null),onToggle:a=>F(n=>n.includes(a)?n.filter(s=>s!==a):[...n,a]),onSave:()=>{yt()},t:e}),!u&&y?.id===i.id&&t.jsx(Mt,{title:e("citationLibrary.editTitle",{key:y.citationKey}),value:st,saving:V===y.citationKey,onChange:rt,onClose:()=>T(null),onSave:()=>{wt()},t:e})]},i.id))}),g.totalPages>1&&t.jsxs("nav",{className:"citation-library-pagination","aria-label":e("citationLibraryPagination.pageOf",{page:g.page,totalPages:g.totalPages,count:g.total}),children:[t.jsxs("button",{type:"button",disabled:g.page<=1,onClick:()=>C(i=>Math.max(1,i-1)),children:[t.jsx(bt,{size:14}),e("citationLibraryPagination.previous")]}),t.jsx("span",{children:e("citationLibraryPagination.pageOf",{page:g.page,totalPages:g.totalPages,count:g.total})}),t.jsxs("button",{type:"button",disabled:g.page>=g.totalPages,onClick:()=>C(i=>Math.min(g.totalPages,i+1)),children:[e("citationLibraryPagination.next"),t.jsx(Zt,{size:14})]})]})]}):t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"citation-current-heading",children:[t.jsxs("div",{children:[t.jsx("strong",{children:e("citationLibrary.currentFileTitle")}),t.jsx("span",{children:e("citationLibrary.currentFileDescription")})]}),t.jsxs("button",{type:"button",onClick:()=>A("library"),children:[t.jsx(bt,{size:14}),e("citationLibrary.backToLibrary")]})]}),Nt&&t.jsxs("p",{className:"warning citation-library-warning",children:[t.jsx(zt,{size:15}),e("citationLibrary.fileTooLarge",{size:Xt(l)})]}),Tt&&t.jsxs("p",{className:"warning citation-library-warning",children:[t.jsx(zt,{size:15}),e("citationLibrary.fileInvalid")]}),D.length===0?t.jsxs("div",{className:"citation-library-empty",children:[t.jsx(tt,{size:28}),t.jsx("strong",{children:e("citationLibrary.noEntries")}),t.jsx("span",{children:e(Nt?"citationLibrary.fileTooLargeHint":Tt?"citationLibrary.fileInvalidHint":"citationLibrary.noEntriesDescription")})]}):t.jsx("div",{className:"citation-entry-list",children:D.map((i,a)=>t.jsxs("div",{className:"citation-entry-item",children:[t.jsx(Pt,{entry:i,saved:Ct.has(i.citationKey.toLowerCase()),saving:V===i.citationKey,saveDisabled:Ot,onSave:()=>{Ut(i)},t:e}),!u&&h?.citationKey.toLowerCase()===i.citationKey.toLowerCase()&&t.jsx(mt,{entry:h,tags:q,selectedIds:B,saving:nt,onClose:()=>x(null),onToggle:n=>F(s=>s.includes(n)?s.filter(Z=>Z!==n):[...s,n]),onSave:()=>{yt()},t:e})]},`${i.citationKey}-${a}`))})]})]}),Et=t.jsx(Bt,{open:!!lt,title:e("citationLibrary.deleteTitle"),description:e("citationLibrary.deleteDescription",{key:lt?.citationKey??""}),confirmLabel:e("common.delete"),danger:!0,error:It,busy:!!ft,onCancel:()=>{X(null),W("")},onConfirm:()=>{const i=lt;i&&Wt(i)}});return u?t.jsxs(t.Fragment,{children:[t.jsxs("section",{className:"citation-library-page",children:[t.jsxs("header",{className:"citation-library-page-header",children:[t.jsxs("div",{children:[t.jsxs("h1",{children:[t.jsx(tt,{"aria-hidden":!0,size:26}),e("citationLibrary.title")]}),t.jsx("p",{children:e("citationLibraryHomeDescription")})]}),b&&t.jsxs("button",{type:"button",onClick:b,children:[t.jsx(bt,{size:15}),e("projects.title")]})]}),kt]}),h&&t.jsx(ut,{open:!0,title:e("citationLibrary.tagsTitle",{key:h.citationKey}),description:e("citationLibrary.tags"),onOpenChange:i=>{i||(x(null),c(""))},children:t.jsxs(t.Fragment,{children:[$&&t.jsx("p",{className:"error dialog-error",children:$}),t.jsx(mt,{entry:h,tags:q,selectedIds:B,saving:nt,modal:!0,onClose:()=>{x(null),c("")},onToggle:i=>F(a=>a.includes(i)?a.filter(n=>n!==i):[...a,i]),onSave:()=>{yt()},t:e})]})}),y&&t.jsx(ut,{open:!0,extraWide:!0,title:e("citationLibrary.editTitle",{key:y.citationKey}),description:e("citationLibrary.title"),onOpenChange:i=>{i||(T(null),c(""))},children:t.jsxs(t.Fragment,{children:[$&&t.jsx("p",{className:"error dialog-error",children:$}),t.jsx(Mt,{title:e("citationLibrary.editTitle",{key:y.citationKey}),value:st,saving:V===y.citationKey,modal:!0,onChange:rt,onClose:()=>{T(null),c("")},onSave:()=>{wt()},t:e})]})}),Et]}):t.jsxs(t.Fragment,{children:[t.jsx(ut,{open:o,extraWide:!0,className:"citation-library-modal",title:e("citationLibrary.title"),description:e(R?"citationLibrary.description":"citationLibraryHomeDescription",{file:v}),onOpenChange:j,footer:t.jsx("button",{onClick:()=>j(!1),children:e("common.close")}),children:kt}),Et]})}function Pt({entry:o,currentUserId:j,selected:u,alreadyInFile:b,saved:v,saving:p,saveDisabled:E,importDisabled:m,deleting:l,onSave:f,onImport:e,onEdit:K,onTags:A,onDelete:z,t:d}){const L="id"in o,P=L?o:null,I=Gt(o);return t.jsxs("article",{className:`citation-entry-card${u?" selected":""}${b?" already-in-file":""}`,title:b?d("citationErrors.alreadyInFile",{key:o.citationKey}):void 0,children:[t.jsxs("div",{className:"citation-entry-main",children:[t.jsxs("div",{className:"citation-entry-heading",children:[t.jsx("code",{children:o.citationKey}),t.jsxs("span",{children:["@",o.entryType]}),I&&t.jsx("span",{className:"citation-entry-venue",title:I,children:I}),v&&t.jsxs("em",{children:[t.jsx(J,{size:11}),d("citationLibrary.savedLabel")]})]}),t.jsx("strong",{children:o.title||d("citationLibrary.untitled")}),t.jsxs("p",{children:[o.authors||d("citationLibrary.authorUnknown"),o.year&&t.jsxs("span",{children:[" · ",o.year]})]}),P&&P.tags.length>0&&t.jsx("div",{className:"citation-entry-tags",children:P.tags.map(N=>t.jsxs("span",{className:`citation-tag-pill tag-${N.color}`,children:[t.jsx("span",{className:"citation-tag-dot"}),N.name]},N.id))})]}),t.jsxs("div",{className:"citation-entry-actions",children:[f&&t.jsxs("button",{type:"button",className:v?"saved":"primary",disabled:p||E,onClick:f,children:[p||E?t.jsx(H,{className:"spin",size:13}):v?t.jsx(J,{size:13}):t.jsx(it,{size:13}),d(p?"citationLibrary.saving":v?"citationLibrary.update":"citationLibrary.save")]}),e&&t.jsxs("button",{type:"button",disabled:m||b,title:b?d("citationErrors.alreadyInFile",{key:o.citationKey}):d(m?"citationLibrary.importRequiresWrite":"citationLibrary.importToFile"),onClick:()=>{e()},children:[t.jsx(ai,{size:13}),d("citationLibrary.import")]}),P&&A&&t.jsxs("button",{type:"button",onClick:A,children:[t.jsx(ei,{size:13}),d("citationLibrary.tags")]}),L&&K&&t.jsxs("button",{type:"button",onClick:K,children:[t.jsx(ni,{size:13}),d("common.edit")]}),L&&z&&t.jsxs("button",{type:"button",className:"danger-text",disabled:l,onClick:z,children:[l?t.jsx(H,{className:"spin",size:13}):t.jsx(ti,{size:13}),d("common.delete")]})]})]})}function mt({entry:o,tags:j,selectedIds:u,saving:b,modal:v=!1,onClose:p,onToggle:E,onSave:m,t:l}){const f=t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"citation-tag-choice-list",children:j.length===0?t.jsx("span",{className:"muted",children:l("citationLibrary.noTagsToAssign")}):j.map(e=>t.jsxs("label",{children:[t.jsx("input",{type:"checkbox",checked:u.includes(e.id),onChange:()=>E(e.id)}),t.jsx("span",{className:`citation-tag-dot tag-${e.color}`}),e.name]},e.id))}),t.jsxs("div",{className:"citation-edit-actions",children:[t.jsx("button",{type:"button",onClick:p,children:l("common.cancel")}),t.jsxs("button",{type:"button",className:"primary",disabled:b||j.length===0,onClick:m,children:[b?t.jsx(H,{className:"spin",size:14}):t.jsx(J,{size:14}),l("citationLibrary.saveTags")]})]})]});return v?t.jsx("div",{className:"citation-modal-form",children:f}):t.jsxs("div",{className:"citation-tag-editor",children:[t.jsxs("div",{className:"citation-edit-header",children:[t.jsx("strong",{children:l("citationLibrary.tagsTitle",{key:o.citationKey})}),t.jsx("button",{type:"button","aria-label":l("common.close"),onClick:p,children:t.jsx(et,{size:15})})]}),f]})}function Mt({title:o,value:j,saving:u,modal:b=!1,onChange:v,onClose:p,onSave:E,t:m}){const l=t.jsxs(t.Fragment,{children:[t.jsx("textarea",{autoFocus:!b,value:j,onChange:f=>v(f.target.value),spellCheck:!1,rows:12}),t.jsxs("div",{className:"citation-edit-actions",children:[t.jsx("button",{type:"button",onClick:p,children:m("common.cancel")}),t.jsxs("button",{type:"button",className:"primary",disabled:!j.trim()||u,onClick:E,children:[u?t.jsx(H,{className:"spin",size:14}):t.jsx(J,{size:14}),m("common.save")]})]})]});return b?t.jsx("div",{className:"citation-modal-form citation-edit-panel",children:l}):t.jsxs("div",{className:"citation-edit-panel",children:[t.jsxs("div",{className:"citation-edit-header",children:[t.jsx("strong",{children:o}),t.jsx("button",{type:"button","aria-label":m("common.close"),onClick:p,children:t.jsx(et,{size:15})})]}),l]})}export{hi as CitationLibraryDialog};
@@ -0,0 +1,2 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./SystemMetricsDialog-hJQATmd4.js","./react-BVUjbTTn.js","./index-p1NHkGGG.js","./index-BiwJj0Np.css","./refresh-cw-LtwnqlWh.js","./hard-drive-BWZnOgnm.js","./x-eisRQJv_.js","./sigma-BgvHGPto.js","./tags-m9kppdi0.js","./CitationLibraryDialog-BTmnCP4V.js","./citationLibrary-ZeQPCv5O.js","./plus-BVXOlQXP.js","./check-C1db8iNn.js","./search-DXo_aAp0.js","./AdminUsers-B12FJUMy.js","./user-plus-MRmKeDtX.js","./key-round-CoDwyVJc.js","./TagManagementDialog-BHC8qULq.js","./ProjectIconPickerDialog-GzRuM0oQ.js"])))=>i.map(i=>d[i]);
2
+ import{c as r,a as Je,s as Fe,S as ha,L as ma,b as Tt,M as se,d as _e,e as Ze,C as ua,f as ya,g as C,h as D,_ as me,i as Ke}from"./index-p1NHkGGG.js";import{j as e,r as i,u as ka}from"./react-BVUjbTTn.js";import{H as ga}from"./hard-drive-BWZnOgnm.js";import{G as ja,F as xa,L as fa,N as va,a as ba,b as Ma,c as Ca,S as wa,B as Et,d as Na,e as za,P as Sa,D as Ta,T as Pa,M as Ft,A as It,f as Pt,U as Aa,g as At,h as La,C as Lt,i as Da,j as Ea,X as Fa,k as Ia}from"./x-eisRQJv_.js";import{S as qa}from"./sigma-BgvHGPto.js";import{T as We}from"./tags-m9kppdi0.js";const $a=r("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 Ba=r("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 Qe=r("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 Va=r("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 qt=r("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 Oa=r("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 Ua=r("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 Ha=r("Bookmark",[["path",{d:"m19 21-7-4-7 4V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v16z",key:"1fy3hk"}]]);const Ra=r("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 _a=r("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 Za=r("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 Ka=r("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 Wa=r("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 $t=r("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 Ga=r("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 Ja=r("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 Qa=r("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 Xa=r("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 Ya=r("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 es=r("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 ts=r("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 as=r("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 ss=r("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 ns=r("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 rs=r("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 os=r("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 is=r("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 cs=r("Ellipsis",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]]);const ls=r("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 ds=r("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 ps=r("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 hs=r("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 ms=r("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 us=r("FolderGit2",[["path",{d:"M9 20H4a2 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.9H20a2 2 0 0 1 2 2v5",key:"1w6njk"}],["circle",{cx:"13",cy:"12",r:"2",key:"1j92g6"}],["path",{d:"M18 19c-2.8 0-5-2.2-5-5v8",key:"pkpw2h"}],["circle",{cx:"20",cy:"19",r:"2",key:"1obnsp"}]]);const ys=r("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 Ge=r("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 ks=r("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 gs=r("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 js=r("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 xs=r("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 fs=r("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 vs=r("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 bs=r("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 Ms=r("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 Cs=r("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 ws=r("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 Ns=r("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 zs=r("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 Ss=r("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 Ts=r("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 Ps=r("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 As=r("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 Ls=r("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 Ds=r("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 Bt=r("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 Es=r("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 Fs=r("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 Is=r("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 qs=r("Terminal",[["polyline",{points:"4 17 10 11 4 5",key:"akl6gq"}],["line",{x1:"12",x2:"20",y1:"19",y2:"19",key:"q2wloq"}]]);const $s=r("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 Bs=r("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 Vs=r("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 Os=r("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 Us=r("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"}]]),Vt=["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"],Hs=new Set(Vt);function Rs(s){return typeof s=="string"&&Hs.has(s)}function _s(s){if(typeof s!="string")return null;const p=s.trim().replace(/^lucide:/i,"");return!p||p.length>96?null:/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(p)?p:null}const Zs={"file-text":za,"book-open":Na,"notebook-pen":Ns,"book-marked":Et,"scroll-text":wa,library:fs,"graduation-cap":ks,presentation:Ss,image:js,"folder-kanban":ys,microscope:Ms,"flask-conical":hs,"test-tube-diagonal":$s,atom:Oa,dna:os,telescope:Is,earth:is,map:bs,languages:xs,university:Vs,"code-2":as,"file-code-2":Ca,database:rs,server:Ls,network:Cs,"circuit-board":es,brain:Ka,"brain-circuit":Za,bot:Ra,"shield-check":Ds,workflow:Us,sigma:qa,calculator:Wa,"chart-no-axes-combined":Qa,"line-chart":Ja,"bar-chart-3":Ga,"pie-chart":Xa,"chart-scatter":Ya,"file-spreadsheet":Ma,"file-chart-column-increasing":ls,lightbulb:vs,rocket:As,target:Fs,sparkles:Bt,"file-pen-line":ds,"file-stack":ps,folder:ba,"folder-open":Ge,"folder-archive":ms,archive:Qe,bookmark:Ha,newspaper:ws,"notepad-text":va,"sticky-note":Es,"pen-tool":zs,quote:Ts,"list-tree":fa,"file-search":xa,beaker:Ua,"test-tubes":Bs,"folder-git-2":us,"git-branch":ja,terminal:qs,braces:_a,regex:Ps,cpu:ns,"hard-drive":ga,cloud:ts,"users-round":Os,"calendar-days":$t},hn=Vt.map(s=>({name:s}));function Ks(s){const p=Array.from(s.trim())[0];return p?p.toLocaleUpperCase():"?"}function Ws({icon:s,fallback:p,size:x=18}){const f=Rs(s)?Zs[s]:null;if(f)return e.jsx(f,{"aria-hidden":"true",size:x,strokeWidth:1.9});const v=_s(s);if(v){const a=`url(${Je(`/api/project-icons/${encodeURIComponent(v)}`)})`,k={maskImage:a,WebkitMaskImage:a};return e.jsx("span",{"aria-hidden":"true",className:"project-icon-external-glyph",style:k})}return e.jsx("span",{"aria-hidden":"true",children:p})}function Ot({icon:s,projectName:p,editable:x=!1,onEdit:f,editLabel:v,title:c,className:a=""}){const k=e.jsx(Ws,{icon:s,fallback:Ks(p)}),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:k}):e.jsx("span",{className:m,title:c,"aria-hidden":"true",children:k})}function Ut({project:s,currentUser:p,showArchived:x,archiveBusy:f,menuOpen:v,t:c,variant:a,onToggleMenu:k,onCloseMenu:m,onAssignTags:y,onRename:E,onDuplicate:d,onArchive:z,onTransfer:B,onDelete:S}){const b=i.useRef(null),T=s.permission==="owner",F=p.role==="admin"||p.canCreateProjects,R=s.ownerId===p.id,V=s.permission==="owner";i.useEffect(()=>{if(!v)return;const l=L=>{L.target instanceof Node&&!b.current?.contains(L.target)&&m()},A=L=>{L.key==="Escape"&&m()};return document.addEventListener("pointerdown",l),document.addEventListener("keydown",A),()=>{document.removeEventListener("pointerdown",l),document.removeEventListener("keydown",A)}},[v,m]);const P=[{id:"tags",label:c("tags.assign"),icon:e.jsx(We,{"aria-hidden":!0,size:15}),section:"main",onSelect:y},...T?[{id:"rename",label:c("projects.rename"),icon:e.jsx(Sa,{"aria-hidden":!0,size:15}),section:"main",onSelect:E}]:[],...F?[{id:"duplicate",label:c("projects.duplicate"),icon:e.jsx(ss,{"aria-hidden":!0,size:15}),section:"main",onSelect:d}]:[],{id:"download",label:c("projects.download"),icon:e.jsx(Ta,{"aria-hidden":!0,size:15}),section:"main",href:Je(`/api/projects/${s.id}/download`)},{id:"archive",label:c(x?"projects.unarchive":"projects.archive"),icon:x?e.jsx(Ba,{"aria-hidden":!0,size:15}):e.jsx(Qe,{"aria-hidden":!0,size:15}),section:"main",disabled:f,onSelect:z},...R?[{id:"transfer",label:c("projects.transfer"),icon:e.jsx(qt,{"aria-hidden":!0,size:15}),section:"main",onSelect:B}]:[],...V?[{id:"delete",label:c("common.delete"),icon:e.jsx(Pa,{"aria-hidden":!0,size:15}),section:"danger",onSelect:S}]:[]],_=P.filter(l=>l.section==="main"),M=P.filter(l=>l.section==="danger"),ne=l=>{l.disabled||(m(),l.onSelect?.())};return e.jsxs("div",{ref:b,className:`project-action-menu-root project-action-menu-${a}`,onClick:l=>l.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:l=>{l.stopPropagation(),k()},children:e.jsx(cs,{"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:[_.map(l=>l.href?e.jsxs("a",{href:l.href,download:!0,onClick:A=>{A.stopPropagation(),m()},children:[l.icon,l.label]},l.id):e.jsxs("button",{type:"button",disabled:l.disabled,onClick:A=>{A.stopPropagation(),ne(l)},children:[l.icon,l.label]},l.id)),M.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"project-action-menu-separator","aria-hidden":"true"}),M.map(l=>e.jsxs("button",{type:"button",className:"danger",onClick:A=>{A.stopPropagation(),ne(l)},children:[l.icon,l.label]},l.id))]})]})]})}function Gs({project:s,currentUser:p,showArchived:x,archiveBusy:f,menuOpen:v,t:c,formatCreatedDate:a,formatUpdatedTime:k,formatExactTime:m,onOpenProject:y,onOpenMention:E,onToggleMenu:d,onCloseMenu:z,onAssignTags:B,onRename:S,onDuplicate:b,onArchive:T,onTransfer:F,onDelete:R,onChooseIcon:V}){const P=s.ownerDisplayName??s.ownerUsername??c("projects.deletedUser"),_=s.lastModifiedDisplayName??s.lastModifiedUsername??c("projects.deletedUser");return e.jsxs("article",{className:`project-card project-list-row${s.ownerId===p.id?" owned-project":""}${v?" project-list-menu-open":""}`,onClick:M=>{M.target===M.currentTarget&&y()},children:[e.jsx(Ot,{icon:s.icon,projectName:s.name,title:s.name,editable:s.permission==="owner",editLabel:c("projectIcons.change"),onEdit:V,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(Ft,{"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(M=>e.jsx("span",{className:`tag tag-${M.color} project-list-tag`,title:M.name,children:M.name},M.id))})]})})}),e.jsxs("button",{type:"button",className:"project-list-cell-open project-list-owner",onClick:y,title:P,"aria-label":c("projects.openProject",{project:s.name}),children:[e.jsxs("span",{className:"sr-only",children:[c("projects.owner"),": "]}),P]}),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:_}),"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:k(s.updatedAt)}),e.jsx("small",{children:c("projects.byUser",{user:_})})]}),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(It,{"aria-hidden":!0,size:10}),e.jsx("span",{children:s.unreadMentionCount})]}):e.jsx("span",{className:"project-list-mentions"}),e.jsx(Ut,{variant:"list",project:s,currentUser:p,showArchived:x,archiveBusy:f,menuOpen:v,t:c,onToggleMenu:d,onCloseMenu:z,onAssignTags:B,onRename:S,onDuplicate:b,onArchive:T,onTransfer:F,onDelete:R})]})}const Js=i.lazy(()=>me(()=>import("./SystemMetricsDialog-hJQATmd4.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8]),import.meta.url).then(s=>({default:s.SystemMetricsDialog}))),Qs=i.lazy(()=>me(()=>import("./CitationLibraryDialog-BTmnCP4V.js"),__vite__mapDeps([9,1,2,3,10,6,11,12,13,8]),import.meta.url).then(s=>({default:s.CitationLibraryDialog}))),Xs=i.lazy(()=>me(()=>import("./AdminUsers-B12FJUMy.js"),__vite__mapDeps([14,1,2,3,6,15,16,5,7,8]),import.meta.url).then(s=>({default:s.AdminUsers}))),Ys=i.lazy(()=>me(()=>import("./TagManagementDialog-BHC8qULq.js"),__vite__mapDeps([17,1,2,3,11,6,12]),import.meta.url).then(s=>({default:s.TagManagementDialog}))),en=i.lazy(()=>me(()=>import("./ProjectIconPickerDialog-GzRuM0oQ.js"),__vite__mapDeps([18,1,2,3,13,5,6,7,8]),import.meta.url).then(s=>({default:s.ProjectIconPickerDialog})));function tn(s){return s instanceof Error&&s.name==="AbortError"}function an(s,p,x,f){const v=new Date(s).getTime();if(!Number.isFinite(v))return s;const c=v-x,a=Math.abs(c),k=60*1e3,m=60*k,y=24*m,E=3*y;if(a>E){const S=Math.floor(a/y),b=c<0?"Past":"Future";return f(`projects.relativeDays${b}`,{days:S,hours:0,minutes:0})}if(a>=y){const S=Math.floor(a/y),b=Math.floor(a%y/m),T=c<0?"Past":"Future",F=b>0?"DaysHours":"Days";return f(`projects.relative${F}${T}`,{days:S,hours:b,minutes:0})}if(a>=m){const S=Math.floor(a/m),b=Math.floor(a%m/k),T=c<0?"Past":"Future",F=b>0?"HoursMinutes":"Hours";return f(`projects.relative${F}${T}`,{days:0,hours:S,minutes:b})}const d="minute",z=k,B=Math.sign(c)*Math.max(1,Math.floor(a/z));return new Intl.RelativeTimeFormat(p,{numeric:"always"}).format(B,d)}function sn(s){return s<1024?`${s} B`:s<1024*1024?`${(s/1024).toFixed(1)} KB`:`${(s/1024/1024).toFixed(1)} MB`}function nn({site:s,user:p,initialData:x,onDataChange:f,onUser:v,onOpenProject:c}){const{t:a}=ka(),[k,m]=i.useState(()=>x?.projects??[]),[y,E]=i.useState(()=>x?.tags??[]),[d,z]=i.useState(()=>x?.pagination??{page:1,pageSize:20,total:x?.projects.length??0,totalPages:x?.projects.length?1:0}),[B,S]=i.useState(!!x),[b,T]=i.useState(!1),[F,R]=i.useState(!1),[V,P]=i.useState(!1),[_,M]=i.useState(""),[ne,l]=i.useState(""),[A,L]=i.useState(""),[Xe,Z]=i.useState(""),[Ye,K]=i.useState(""),[Ht,re]=i.useState(""),[Rt,ue]=i.useState(!1),[ye,et]=i.useState(""),[W,tt]=i.useState(!1),[_t,ke]=i.useState(!1),[Ie,qe]=i.useState(""),[I,at]=i.useState(null),[st,O]=i.useState(""),ge=i.useRef(null),nt=i.useRef(null),[rt,ot]=i.useState(!1),[U,Zt]=i.useState(""),[w,it]=i.useState(""),[je,$e]=i.useState(!1),[Kt,Be]=i.useState(!1),[G,J]=i.useState(null),[ct,xe]=i.useState(null),[Ve,oe]=i.useState(null),[fe,ve]=i.useState(""),[Q,lt]=i.useState(!1),[be,ie]=i.useState(null),[Me,Y]=i.useState(""),[Ce,dt]=i.useState(!1),[ce,we]=i.useState(null),[Ne,pt]=i.useState(!1),[ze,Se]=i.useState(null),[Oe,ht]=i.useState([]),[Te,le]=i.useState(""),[ee,Pe]=i.useState(!1),[mt,te]=i.useState(""),[de,Wt]=i.useState(()=>localStorage.getItem(Fe("texlite-project-view"))==="list"?"list":"grid"),[q,Gt]=i.useState(()=>localStorage.getItem(Fe("texlite-project-sort"))==="created"?"created":"updated"),[u,Jt]=i.useState(!1),[ut,yt]=i.useState(""),[Ae,H]=i.useState(null),[N,$]=i.useState(1),[Qt,Xt]=i.useState(()=>Date.now()),[kt,Yt]=i.useState(""),Ue=i.useRef(0),pe=i.useRef(null),gt=(t,n,o,h,g)=>`${t?"archived":"active"}|${n}|${o}|${h}|${g}`,jt=gt(u,N,U,w,q),he=(t,n,o,h,g)=>{const j=new URLSearchParams({page:String(n),pageSize:"20",sort:g});t&&j.set("archived","1"),o.trim()&&j.set("search",o.trim()),h&&j.set("tag",h);const X=gt(t,n,o,h,g),De=++Ue.current;pe.current?.abort();const Ee=new AbortController;return pe.current=Ee,Promise.all([C(`/api/projects?${j.toString()}`,{signal:Ee.signal}),C("/api/tags",{signal:Ee.signal})]).then(([ae,pa])=>{De===Ue.current&&(m(ae.projects),E(pa.tags),z(ae.pagination),$(ae.pagination.page),S(!0),Yt(X))}).catch(ae=>{!tn(ae)&&De===Ue.current&&M(D(ae))}).finally(()=>{pe.current===Ee&&(pe.current=null)})};i.useEffect(()=>(he(u,N,U,w,q),()=>pe.current?.abort()),[u,N,U,w,q]),i.useEffect(()=>{B&&!u&&kt===jt&&f(k,y,d)},[k,y,d,B,kt,jt,u]),i.useEffect(()=>{const t=window.setInterval(()=>Xt(Date.now()),6e4);return()=>window.clearInterval(t)},[]),i.useEffect(()=>{if(!je)return;const t=o=>{o.target instanceof Node&&!nt.current?.contains(o.target)&&$e(!1)},n=o=>{o.key==="Escape"&&$e(!1)};return document.addEventListener("pointerdown",t),document.addEventListener("keydown",n),()=>{document.removeEventListener("pointerdown",t),document.removeEventListener("keydown",n)}},[je]);const xt=t=>{H(null),Wt(t),localStorage.setItem(Fe("texlite-project-view"),t)},ea=t=>{Gt(t),$(1),localStorage.setItem(Fe("texlite-project-sort"),t)},ft=t=>{Jt(t),$(1)},vt=t=>{it(t),$(1)},bt=async()=>{if(!(!ye.trim()||W)){tt(!0),l("");try{const{project:t}=await C("/api/projects",{method:"POST",body:JSON.stringify({name:ye})});ue(!1),et("");const n=u||N!==1?k:[t,...k].slice(0,d.pageSize),o=u?d:{...d,total:d.total+1,totalPages:Math.ceil((d.total+1)/d.pageSize)};m(n),z(o),u||f(n,y,o),c(t.id)}catch(t){l(D(t))}finally{tt(!1)}}},ta=async()=>{if(!I)return;const t=s.maxUploadSizeMB;if(I.size>t*1024*1024)return O(a("errors.fileTooLarge",{size:t}));ot(!0),O("");const n=new FormData;n.append("file",I);try{const{project:o}=await C(`/api/projects/import?name=${encodeURIComponent(Ie.trim())}`,{method:"POST",body:n}),h=u||N!==1?k:[o,...k].slice(0,d.pageSize),g=u?d:{...d,total:d.total+1,totalPages:Math.ceil((d.total+1)/d.pageSize)};m(h),z(g),u||f(h,y,g),ke(!1),at(null),qe(""),c(o.id)}catch(o){O(D(o))}finally{ot(!1)}},He=t=>{if(t&&!t.name.toLocaleLowerCase().endsWith(".zip")){O(a("errors.zipOnly"));return}O(""),at(t),t&&!Ie&&qe(t.name.replace(/\.zip$/i,""))},aa=async()=>{await C("/api/auth/logout",{method:"POST"}),v(null)},sa=async t=>{if(!G)return;const n=G.tags.some(o=>o.id===t.id);L("");try{const h=(await C(n?`/api/projects/${G.id}/tags/${t.id}`:`/api/projects/${G.id}/tags`,n?{method:"DELETE"}:{method:"POST",body:JSON.stringify({tagId:t.id})})).project;J(h),m(g=>g.map(j=>j.id===h.id?h:j))}catch(o){L(D(o))}},na=t=>{E(n=>[...n,t].sort((o,h)=>o.name.localeCompare(h.name)))},ra=t=>{const n=o=>o.map(h=>h.id===t.id?t:h);E(o=>n(o).sort((h,g)=>h.name.localeCompare(g.name))),m(o=>o.map(h=>({...h,tags:n(h.tags)}))),J(o=>o?{...o,tags:n(o.tags)}:null)},oa=t=>{E(n=>n.filter(o=>o.id!==t)),m(n=>n.map(o=>({...o,tags:o.tags.filter(h=>h.id!==t)}))),J(n=>n?{...n,tags:n.tags.filter(o=>o.id!==t)}:null),it(n=>n===t?"":n)},ia=async(t,n)=>{const o=await C(`/api/projects/${t}/icon`,{method:"PATCH",body:JSON.stringify({icon:n})});m(h=>{const g=h.map(j=>j.id===o.project.id?o.project:j);return q==="updated"?g.sort((j,X)=>X.updatedAt.localeCompare(j.updatedAt)||j.name.localeCompare(X.name)):g})},Mt=async()=>{if(!(!Ve||!fe.trim()||Q)){lt(!0),Z("");try{const t=await C(`/api/projects/${Ve.id}`,{method:"PATCH",body:JSON.stringify({name:fe})});m(n=>n.map(o=>o.id===t.project.id?t.project:o)),oe(null),ve("")}catch(t){Z(D(t))}finally{lt(!1)}}},Ct=async()=>{if(!(!be||!Me.trim())){dt(!0),K("");try{await C(`/api/projects/${be.id}/duplicate`,{method:"POST",body:JSON.stringify({name:Me})}),ie(null),Y(""),he(u,N,U,w,q)}catch(t){K(D(t))}finally{dt(!1)}}},ca=async()=>{if(!(!ce||Ne)){pt(!0),re("");try{await C(`/api/projects/${ce.id}`,{method:"DELETE"}),m(g=>g.filter(j=>j.id!==ce.id));const t=Math.max(0,d.total-1),n=Math.ceil(t/d.pageSize),o=n===0?1:Math.min(N,n),h={...d,page:o,total:t,totalPages:n};z(h),we(null),o!==N?$(o):he(u,N,U,w,q)}catch(t){re(D(t))}finally{pt(!1)}}},wt=async t=>{Se(t),le(""),ht([]),te(""),Pe(!0);try{const n=await C("/api/users");ht(n.users.filter(o=>o.id!==t.ownerId))}catch(n){te(D(n))}finally{Pe(!1)}},la=async()=>{if(!(!ze||!Te)){Pe(!0),te("");try{await C(`/api/projects/${ze.id}/owner`,{method:"PUT",body:JSON.stringify({userId:Te})}),Se(null),le(""),he(u,N,U,w,q)}catch(t){te(D(t))}finally{Pe(!1)}}},Nt=async t=>{const n=!u;yt(t.id),M("");try{await C(`/api/projects/${t.id}/archive`,{method:n?"PUT":"DELETE"});const o=k.filter(De=>De.id!==t.id);m(o);const h=Math.max(0,d.total-1),g=Math.ceil(h/d.pageSize),j=g===0?1:Math.min(N,g),X={...d,page:j,total:h,totalPages:g};z(X),u||f(o,y,X),j!==N?$(j):he(u,N,U,w,q)}catch(o){M(D(o))}finally{yt("")}},zt=async t=>{try{const o=(await C(`/api/projects/${t.id}/mentions?unread=1&limit=1`)).mentions[0];c(t.id,o?.id)}catch(n){M(D(n))}},Le=k,Re=t=>new Date(t).toLocaleString(Ke.resolvedLanguage),da=t=>{const n=new Date(t);return Number.isFinite(n.getTime())?new Intl.DateTimeFormat(Ke.resolvedLanguage??"en",{year:"numeric",month:"2-digit",day:"2-digit"}).format(n):t},St=t=>an(t,Ke.resolvedLanguage??"en",Qt,(n,o)=>a(n,o));return e.jsxs("div",{className:"page",children:[e.jsxs("header",{className:"topbar",children:[e.jsxs("a",{className:"brand-link",href:Je("/"),"aria-label":s.siteName,children:[e.jsx("span",{className:"site-title",children:s.siteName}),e.jsx(ha,{siteName:s.siteName})]}),e.jsxs("div",{className:"top-actions",children:[p.role==="admin"&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{className:"ghost",onClick:()=>R(!0),children:[e.jsx($a,{"aria-hidden":!0,size:14}),a("metrics.title")]}),e.jsxs("button",{className:`ghost${b?" top-return-action":""}`,onClick:()=>{T(t=>!t),P(!1)},children:[b?e.jsx(Pt,{"aria-hidden":!0,size:14}):e.jsx(Aa,{"aria-hidden":!0,size:14}),a(b?"users.back":"users.manage")]})]}),e.jsxs("button",{className:`ghost${V?" top-return-action":""}`,onClick:()=>{T(!1),P(t=>!t)},children:[V?e.jsx(Pt,{"aria-hidden":!0,size:14}):e.jsx(Et,{"aria-hidden":!0,size:14}),a(V?"users.back":"citationLibrary.title")]}),e.jsx(ma,{compact:!0}),e.jsxs("span",{className:"top-user-identity",children:[e.jsx("strong",{children:p.displayName}),e.jsxs("small",{children:["@",p.username]})]}),e.jsx("button",{className:"ghost",onClick:aa,children:a("auth.logout")})]})]}),b?e.jsx("main",{className:"dashboard",children:e.jsx(Tt,{onClose:()=>T(!1),children:e.jsx(Xs,{currentUser:p,minPasswordLength:s.minPasswordLength})})}):V?e.jsx("main",{className:"dashboard citation-library-page-shell",children:e.jsx(Tt,{onClose:()=>P(!1),children:e.jsx(Qs,{page:!0,open:!0,onOpenChange:P,onBack:()=>P(!1),currentUserId:p.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(Ge,{"aria-hidden":!0,size:25}),a("projects.title")]}),e.jsx("p",{className:"muted",children:p.canCreateProjects?a("projects.subtitle"):a("projects.restricted")})]}),e.jsxs("div",{className:"section-actions",children:[e.jsxs("button",{onClick:()=>Be(!0),children:[e.jsx(We,{"aria-hidden":!0,size:15}),a("tags.manage")]}),p.canCreateProjects&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:()=>{O(""),ke(!0)},children:[e.jsx(At,{"aria-hidden":!0,size:15}),a("projects.upload")]}),e.jsxs("button",{className:"primary",onClick:()=>{l(""),ue(!0)},children:[e.jsx(La,{"aria-hidden":!0,size:15}),a("projects.new")]})]})]})]}),_&&e.jsx("p",{className:"error",children:_}),e.jsxs("div",{className:"project-catalog-layout",children:[e.jsxs("aside",{ref:nt,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":je,"aria-controls":"dashboard-tag-filters",onClick:()=>$e(t=>!t),children:[e.jsxs("span",{className:"project-tag-toggle-copy",children:[e.jsx(We,{"aria-hidden":!0,size:15}),e.jsx("span",{children:a("projects.filterTags")})]}),e.jsx(Lt,{className:"project-tag-toggle-chevron","aria-hidden":!0,size:15})]}),je&&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:()=>vt(""),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:()=>vt(w===t.id?"":t.id),children:[e.jsx(Dt,{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:U,onChange:t=>{Zt(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:()=>ft(!1),role:"tab","aria-selected":!u,children:[e.jsx(Ge,{size:14}),a("projects.active")]}),e.jsxs("button",{className:u?"active":"",onClick:()=>ft(!0),role:"tab","aria-selected":u,children:[e.jsx(Qe,{size:14}),a("projects.archived")]})]}),e.jsxs("label",{className:"project-sort",children:[e.jsx(Va,{size:14}),e.jsx("span",{children:a("projects.sortBy")}),e.jsxs("select",{value:q,onChange:t=>ea(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:de==="grid"?"active":"",onClick:()=>xt("grid"),title:a("projects.grid"),children:"▦"}),e.jsx("button",{className:de==="list"?"active":"",onClick:()=>xt("list"),title:a("projects.list"),children:"☷"})]})]}),e.jsxs("div",{className:`project-grid ${de==="list"?"list-view":""}${Ae?" project-list-menu-active":""}`,children:[de==="list"&&Le.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")})]}),de==="list"?Le.map(t=>e.jsx(Gs,{project:t,currentUser:p,showArchived:u,archiveBusy:ut===t.id,menuOpen:Ae===t.id,t:a,formatCreatedDate:da,formatUpdatedTime:St,formatExactTime:Re,onOpenProject:()=>{H(null),c(t.id)},onOpenMention:()=>{zt(t)},onToggleMenu:()=>H(n=>n===t.id?null:t.id),onCloseMenu:()=>H(n=>n===t.id?null:n),onAssignTags:()=>{L(""),J(t)},onRename:()=>{Z(""),oe(t),ve(t.name)},onDuplicate:()=>{K(""),ie(t),Y(`${t.name} (1)`)},onArchive:()=>{Nt(t)},onTransfer:()=>{wt(t)},onDelete:()=>{we(t),re("")},onChooseIcon:()=>xe(t)},t.id)):Le.map(t=>e.jsxs("article",{className:`project-card project-grid-card${t.ownerId===p.id?" owned-project":""}${Ae===t.id?" project-card-menu-open":""}`,role:"button",tabIndex:0,"aria-label":a("projects.openProject",{project:t.name}),onClick:()=>{H(null),c(t.id)},onKeyDown:n=>{n.target!==n.currentTarget||n.key!=="Enter"&&n.key!==" "||(n.preventDefault(),H(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(),zt(t)},children:[e.jsx(It,{"aria-hidden":!0,size:11}),e.jsx("span",{children:t.unreadMentionCount})]})]}),e.jsx(Ut,{variant:"grid",project:t,currentUser:p,showArchived:u,archiveBusy:ut===t.id,menuOpen:Ae===t.id,t:a,onToggleMenu:()=>H(n=>n===t.id?null:t.id),onCloseMenu:()=>H(n=>n===t.id?null:n),onAssignTags:()=>{L(""),J(t)},onRename:()=>{Z(""),oe(t),ve(t.name)},onDuplicate:()=>{K(""),ie(t),Y(`${t.name} (1)`)},onArchive:()=>{Nt(t)},onTransfer:()=>{wt(t)},onDelete:()=>{we(t),re("")}})]}),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(Ot,{icon:t.icon,projectName:t.name,title:t.name,editable:t.permission==="owner",editLabel:a("projectIcons.change"),onEdit:()=>xe(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($t,{"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(Ft,{"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:Re(t.createdAt)})})]}),e.jsxs("div",{children:[e.jsxs("dt",{children:[e.jsx(gs,{"aria-hidden":!0,size:13}),a("projects.modified")]}),e.jsxs("dd",{title:a("projects.modifiedByUser",{time:Re(t.updatedAt),user:t.lastModifiedDisplayName??t.lastModifiedUsername??a("projects.deletedUser")}),children:[e.jsx("time",{dateTime:t.updatedAt,children:St(t.updatedAt)}),e.jsxs("span",{className:"project-modified-by",children:[" · ",a("projects.byUser",{user:t.lastModifiedDisplayName??t.lastModifiedUsername??a("projects.deletedUser")})]})]})]})]})]},t.id)),Le.length===0&&(k.length===0?u?e.jsx("div",{className:"empty",children:a("projects.noArchived")}):e.jsxs("div",{className:"project-empty",children:[e.jsx("span",{className:"project-empty-icon",children:e.jsx(Bt,{size:28})}),e.jsx("h2",{children:a("projects.emptyTitle")}),e.jsx("p",{children:p.canCreateProjects?a("projects.emptyDescription"):a("projects.emptyRestricted")})]}):e.jsx("div",{className:"empty",children:a("projects.noMatches")}))]}),d.totalPages>1&&e.jsxs("nav",{className:"project-pagination","aria-label":a("projects.pagination"),children:[e.jsxs("button",{disabled:d.page<=1,onClick:()=>$(t=>Math.max(1,t-1)),title:a("projects.previousPage"),children:[e.jsx(Da,{size:15}),a("projects.previousPage")]}),e.jsx("span",{children:a("projects.pageOf",{page:d.page,totalPages:d.totalPages,count:d.total})}),e.jsxs("button",{disabled:d.page>=d.totalPages,onClick:()=>$(t=>Math.min(d.totalPages,t+1)),title:a("projects.nextPage"),children:[e.jsx(Lt,{size:15}),a("projects.nextPage")]})]})]})]}),e.jsx(se,{open:Rt,title:a("projects.new"),description:a("projects.newDescription"),onOpenChange:t=>{!t&&W||(ue(t),t||l(""))},footer:e.jsxs(e.Fragment,{children:[e.jsx("button",{disabled:W,onClick:()=>ue(!1),children:a("common.cancel")}),e.jsxs("button",{className:"primary",disabled:W||!ye.trim(),"aria-busy":W,onClick:()=>{bt()},children:[W&&e.jsx(_e,{className:"spin",size:14}),a(W?"common.loading":"common.create")]})]}),children:e.jsxs(e.Fragment,{children:[ne&&e.jsx("p",{className:"error dialog-error",children:ne}),e.jsxs("label",{className:"form-field",children:[a("projects.name"),e.jsx("input",{autoFocus:!0,value:ye,onChange:t=>{et(t.target.value),l("")},onKeyDown:t=>{t.key==="Enter"&&bt()}})]})]})}),e.jsx(se,{open:_t,title:a("projects.upload"),description:a("projects.uploadDescription",{size:s.maxUploadSizeMB}),onOpenChange:t=>{ke(t),t||O("")},footer:e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>{ke(!1),O("")},children:a("common.cancel")}),e.jsx("button",{className:"primary",disabled:!I||rt,onClick:()=>{ta()},children:a(rt?"projects.importing":"projects.import")})]}),children:e.jsxs("div",{className:"form-stack",children:[st&&e.jsx("p",{className:"error import-error",children:st}),e.jsxs("div",{className:`upload-picker${I?" has-file":""}`,onDragOver:t=>{t.preventDefault(),t.dataTransfer.dropEffect="copy"},onDrop:t=>{t.preventDefault(),He(t.dataTransfer.files[0]??null)},children:[e.jsx("input",{ref:ge,className:"sr-only",type:"file",accept:".zip,application/zip",onChange:t=>He(t.target.files?.[0]??null)}),e.jsx(Ea,{size:34}),e.jsxs("div",{className:"upload-picker-copy",children:[e.jsx("strong",{children:I?.name??a("projects.chooseZip")}),e.jsx("span",{children:I?a("projects.selectedFileSize",{size:sn(I.size)}):a("projects.dropZip")})]}),e.jsxs("button",{type:"button",onClick:()=>ge.current?.click(),children:[e.jsx(At,{size:15}),a("projects.browse")]}),I&&e.jsx("button",{className:"upload-clear",type:"button",title:a("projects.clearFile"),"aria-label":a("projects.clearFile"),onClick:()=>{He(null),ge.current&&(ge.current.value="")},children:e.jsx(Fa,{size:14})})]}),e.jsxs("label",{className:"form-field",children:[a("projects.name"),e.jsx("input",{value:Ie,onChange:t=>qe(t.target.value)})]})]})}),Kt&&e.jsx(Ze,{title:a("tags.manage"),onClose:()=>Be(!1),children:e.jsx(Ys,{open:!0,onOpenChange:Be,onTagCreated:na,onTagUpdated:ra,onTagDeleted:oa})}),ct&&e.jsx(Ze,{title:a("projectIcons.title"),onClose:()=>xe(null),children:e.jsx(en,{project:ct,open:!0,onOpenChange:t=>{t||xe(null)},onSave:ia})}),e.jsx(se,{open:!!G,title:a("tags.assignTitle",{project:G?.name??""}),description:a("tags.assignDescription"),onOpenChange:t=>{t||(J(null),L(""))},footer:e.jsx("button",{onClick:()=>{J(null),L("")},children:a("common.close")}),children:e.jsxs("div",{className:"tag-assignment-list",children:[A&&e.jsx("p",{className:"error dialog-error",children:A}),y.map(t=>e.jsxs("label",{children:[e.jsx("input",{type:"checkbox",checked:!!G?.tags.some(n=>n.id===t.id),onChange:()=>{sa(t)}}),e.jsx(Dt,{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(se,{open:!!Ve,title:a("projects.renameTitle"),onOpenChange:t=>{!t&&Q||t||(oe(null),Z(""))},footer:e.jsxs(e.Fragment,{children:[e.jsx("button",{disabled:Q,onClick:()=>{oe(null),Z("")},children:a("common.cancel")}),e.jsxs("button",{className:"primary",disabled:Q||!fe.trim(),"aria-busy":Q,onClick:()=>{Mt()},children:[Q&&e.jsx(_e,{className:"spin",size:14}),a(Q?"common.loading":"projects.rename")]})]}),children:e.jsxs(e.Fragment,{children:[Xe&&e.jsx("p",{className:"error dialog-error",children:Xe}),e.jsxs("label",{className:"form-field",children:[a("projects.name"),e.jsx("input",{autoFocus:!0,value:fe,onChange:t=>{ve(t.target.value),Z("")},onKeyDown:t=>{t.key==="Enter"&&Mt()}})]})]})}),e.jsx(se,{open:!!be,title:a("projects.duplicateTitle"),description:a("projects.duplicateDescription",{project:be?.name??""}),onOpenChange:t=>{!t&&!Ce&&(ie(null),Y(""),K(""))},footer:e.jsxs(e.Fragment,{children:[e.jsx("button",{disabled:Ce,onClick:()=>{ie(null),Y(""),K("")},children:a("common.cancel")}),e.jsx("button",{className:"primary",disabled:Ce||!Me.trim(),onClick:()=>{Ct()},children:a(Ce?"projects.duplicating":"projects.duplicate")})]}),children:e.jsxs(e.Fragment,{children:[Ye&&e.jsx("p",{className:"error dialog-error",children:Ye}),e.jsxs("label",{className:"form-field",children:[a("projects.name"),e.jsx("input",{autoFocus:!0,value:Me,onChange:t=>{Y(t.target.value),K("")},onKeyDown:t=>{t.key==="Enter"&&Ct()}})]})]})}),e.jsx(se,{open:!!ze,title:a("projects.transferOwnership"),description:a("projects.transferDescription",{project:ze?.name??""}),onOpenChange:t=>{!t&&!ee&&(Se(null),le(""),te(""))},footer:e.jsxs(e.Fragment,{children:[e.jsx("button",{disabled:ee,onClick:()=>{Se(null),le(""),te("")},children:a("common.cancel")}),e.jsxs("button",{className:"primary",disabled:ee||!Te,onClick:()=>{la()},children:[ee?e.jsx(_e,{className:"spin",size:14}):e.jsx(qt,{size:14}),a("projects.transfer")]})]}),children:e.jsxs("div",{className:"form-stack",children:[mt&&e.jsx("p",{className:"error dialog-error",children:mt}),e.jsxs("label",{className:"form-field",children:[a("projects.newOwner"),e.jsxs("select",{disabled:ee||Oe.length===0,value:Te,onChange:t=>le(t.target.value),children:[e.jsx("option",{value:"",children:ee?a("common.loading"):Oe.length>0?a("projects.chooseNewOwner"):a("projects.noTransferUsers")}),Oe.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(Ia,{size:15}),a("projects.transferWarning")]})]})}),e.jsx(ua,{open:!!ce,title:a("projects.deleteTitle"),description:a("projects.deleteDescription",{project:ce?.name??""}),confirmLabel:a(Ne?"common.loading":"common.delete"),danger:!0,busy:Ne,error:Ht,onCancel:()=>{Ne||(we(null),re(""))},onConfirm:()=>{ca()}})]}),F&&e.jsx(Ze,{title:a("metrics.title"),onClose:()=>R(!1),children:e.jsx(Js,{open:!0,onOpenChange:R})}),e.jsx(ya,{})]})}function Dt({color:s}){return e.jsx("span",{className:`tag-dot tag-${s}`})}const mn=Object.freeze(Object.defineProperty({__proto__:null,Dashboard:nn},Symbol.toStringTag,{value:"Module"}));export{$a as A,mn as D,Ws as P,Ds as S,Ks as a,Rs as i,_s as n,hn as p};
@@ -1,3 +1,3 @@
1
- import{u as ye,r as n,j as e}from"./react-BVUjbTTn.js";import{c as u,M as H,d as p,g as l}from"./index-teah8iB2.js";import{G as q,C as ie,T as ke}from"./x-BEVz0wdw.js";import{K as be}from"./key-round-D8sCqL2b.js";import{C as ne,R as ve}from"./ProjectWorkspace-CI2zKon5.js";import{M as Ce,a as Ne}from"./minus-CqvESp9M.js";import{P as we}from"./plus-DIrweesj.js";import{M as ze}from"./minimize-2-6tf519Ts.js";import"./check-BAdi_Lxq.js";import"./search-C9_Jyrnx.js";import"./user-plus-C7exNawX.js";import"./refresh-cw-BDcwKu_d.js";const Se=u("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 ae=u("ExternalLink",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]);const G=u("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 oe=u("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 W=u("Github",[["path",{d:"M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4",key:"tonef"}],["path",{d:"M9 18c-4.51 2-5-2-7-2",key:"9comsn"}]]);const Ee=u("RefreshCcw",[["path",{d:"M21 12a9 9 0 0 0-9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"14sxne"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M3 12a9 9 0 0 0 9 9 9.75 9.75 0 0 0 6.74-2.74L21 16",key:"1hlbsb"}],["path",{d:"M16 16h5v5",key:"ccwih5"}]]);const Te=u("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 Ge({open:h,project:o,onOpenChange:y,onBeforeMutation:r}){const{t:s,i18n:E}=ye(),[i,m]=n.useState(null),[J,K]=n.useState([]),[T,k]=n.useState(""),[F,V]=n.useState(()=>re(o.name)),[_,ce]=n.useState(!0),[D,Z]=n.useState(""),[b,M]=n.useState(null),[f,j]=n.useState(null),[U,R]=n.useState(!1),[le,v]=n.useState(!1),[$,L]=n.useState(!0),[P,A]=n.useState(!0),[a,C]=n.useState(""),[Q,N]=n.useState(""),[X,B]=n.useState(""),[g,x]=n.useState(!1),[w,Y]=n.useState(10),O=n.useRef(null),z=async(t=!1)=>{const c=await l(`/api/projects/${o.id}/git`);if(m(c.status),t&&(L(!c.status.tokenConfigured),A(!c.status.remoteUrl)),c.status.initialized&&c.status.latestCommit){const S=await l(`/api/projects/${o.id}/git/history`);K(S.commits)}else K([])};n.useEffect(()=>{if(!h){document.fullscreenElement&&document.exitFullscreen().catch(()=>{}),x(!1),k("");return}N(""),B(""),M(null),x(!1),V(re(o.name)),C("load"),r().then(()=>z(!0)).catch(t=>N(t instanceof Error?t.message:s("errors.generic"))).finally(()=>C(""))},[h,o.id]),n.useEffect(()=>{const t=()=>x(document.fullscreenElement===O.current);return document.addEventListener("fullscreenchange",t),()=>document.removeEventListener("fullscreenchange",t)},[]),n.useEffect(()=>{if(!g)return;const t=c=>{c.key==="Escape"&&!document.fullscreenElement&&x(!1)};return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[g]);const d=async(t,c,S,ee)=>{C(t),N(""),B("");try{await c(),S&&B(S)}catch(se){const te=se instanceof Error?se.message:s("errors.generic");N(ee?`${ee}: ${te}`:te)}finally{C("")}},de=()=>d("token",async()=>{const t=await l(`/api/projects/${o.id}/git/token`,{method:"PUT",body:JSON.stringify({token:T})});m(t.status),k(""),L(!1)},s("git.tokenSaved")),he=()=>d("remove-token",async()=>{const t=await l(`/api/projects/${o.id}/git/token`,{method:"DELETE"});m(t.status),k("")},s("git.tokenRemoved")),ge=()=>d("repository",async()=>{const t=await l(`/api/projects/${o.id}/git/repository`,{method:"POST",body:JSON.stringify({name:F,private:_})});m(t.status),A(!1)},s("git.repositoryCreated")),ue=()=>d("commit",async()=>{if(!await r())throw new Error(s("errors.collaborationUnavailable"));const t=await l(`/api/projects/${o.id}/git/commit`,{method:"POST",body:JSON.stringify({message:D})});m(t.status),Z(""),M(null),await z()},s("git.committed")),me=()=>d("push",async()=>{if(!await r())throw new Error(s("errors.collaborationUnavailable"));const t=await l(`/api/projects/${o.id}/git/push`,{method:"POST"});m(t.status),await z()},s("git.pushed"),s("git.pushFailed")),I=t=>d("diff",async()=>{if(!await r())throw new Error(s("errors.collaborationUnavailable"));const c=t?`?revision=${encodeURIComponent(t)}`:"";M(await l(`/api/projects/${o.id}/git/diff${c}`))}),fe=async()=>{if(g){document.fullscreenElement&&await document.exitFullscreen().catch(()=>{}),x(!1);return}const t=O.current;if(t?.requestFullscreen)try{await t.requestFullscreen()}catch{}x(!0)},xe=()=>{const t=f;t&&(j(null),d("checkout",async()=>{if(!await r())throw new Error(s("errors.collaborationUnavailable"));await l(`/api/projects/${o.id}/git/checkout`,{method:"POST",body:JSON.stringify({revision:t==="branch"?null:t.sha,force:U})}),window.location.reload()}))},pe=()=>{v(!1),d("discard",async()=>{if(!await r())throw new Error(s("errors.collaborationUnavailable"));await l(`/api/projects/${o.id}/git/discard`,{method:"POST"}),window.location.reload()})},je=a==="load"&&!i;return e.jsxs(e.Fragment,{children:[e.jsx(H,{open:h,extraWide:!0,className:g?"git-dialog-modal-fullscreen":void 0,title:s("git.title"),description:s("git.description"),onOpenChange:y,footer:e.jsx("button",{onClick:()=>y(!1),children:s("common.close")}),children:e.jsxs("div",{className:"git-dialog",children:[je&&e.jsxs("div",{className:"git-loading",children:[e.jsx(p,{className:"spin",size:22}),s("common.loading")]}),Q&&e.jsx("p",{className:"git-message error",children:Q}),X&&e.jsxs("p",{className:"git-message success",children:[e.jsx(q,{size:14}),X]}),i&&e.jsxs(e.Fragment,{children:[e.jsxs("section",{className:"git-section",children:[e.jsxs("button",{className:"git-section-toggle",type:"button","aria-expanded":$,onClick:()=>L(t=>!t),children:[e.jsxs("span",{className:"git-section-heading",children:[e.jsx(be,{size:16}),e.jsxs("span",{children:[e.jsx("strong",{children:s("git.authentication")}),e.jsx("small",{children:i.tokenConfigured?s("git.connectedAs",{login:i.githubLogin}):s("git.authenticationHint")})]})]}),$?e.jsx(ne,{size:16}):e.jsx(ie,{size:16})]}),$&&e.jsxs("div",{className:"git-section-content",children:[e.jsxs("div",{className:"git-token-guidance",children:[e.jsx("strong",{children:s("git.recommendedAccessTitle")}),e.jsx("span",{children:s("git.recommendedAccess")})]}),i.tokenConfigured&&e.jsxs("div",{className:"git-account",children:[e.jsx(W,{size:17}),e.jsx("span",{children:s("git.connectedAs",{login:i.githubLogin})}),e.jsxs("button",{className:"danger-text",disabled:!!a,onClick:he,children:[e.jsx(ke,{size:14}),s("git.removeToken")]})]}),e.jsxs("label",{className:"form-field",children:[i.tokenConfigured?s("git.replaceToken"):s("git.token"),e.jsx("input",{type:"password",autoComplete:"new-password",spellCheck:!1,autoCapitalize:"none",autoCorrect:"off",value:T,placeholder:s("git.tokenPlaceholder"),onChange:t=>k(t.target.value)})]}),e.jsxs("div",{className:"git-inline-actions",children:[e.jsxs("a",{href:"https://github.com/settings/personal-access-tokens/new",target:"_blank",rel:"noreferrer",children:[s("git.createToken"),e.jsx(ae,{size:12})]}),e.jsxs("button",{disabled:!!a||T.trim().length<20,onClick:de,children:[a==="token"&&e.jsx(p,{className:"spin",size:13}),s("git.saveToken")]})]})]})]}),e.jsxs("section",{className:"git-section",children:[e.jsxs("button",{className:"git-section-toggle",type:"button","aria-expanded":P,onClick:()=>A(t=>!t),children:[e.jsxs("span",{className:"git-section-heading",children:[e.jsx(W,{size:16}),e.jsxs("span",{children:[e.jsx("strong",{children:s("git.repository")}),e.jsx("small",{children:i.remoteUrl?i.repositoryName??i.remoteUrl:i.initialized?s("git.localReady"):s("git.localPending")})]})]}),P?e.jsx(ne,{size:16}):e.jsx(ie,{size:16})]}),P&&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??s("git.origin")}),e.jsxs("small",{children:[i.branch??s("git.detachedAt",{revision:i.latestCommit?.shortSha??"HEAD"})," · ",i.dirty?s("git.changedFiles",{count:i.changedFiles}):s("git.clean")]})]}),i.repositoryHtmlUrl&&e.jsxs("a",{href:i.repositoryHtmlUrl,target:"_blank",rel:"noreferrer",children:[e.jsx(ae,{size:14}),s("git.openGitHub")]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"form-field",children:[s("git.repositoryName"),e.jsx("input",{value:F,onChange:t=>V(t.target.value)})]}),e.jsxs("label",{className:"checkbox-field",children:[e.jsx("input",{type:"checkbox",checked:_,onChange:t=>ce(t.target.checked)}),s("git.privateRepository")]}),e.jsxs("button",{className:"git-primary-action",disabled:!!a||!i.tokenConfigured||!F.trim(),onClick:ge,children:[a==="repository"?e.jsx(p,{className:"spin",size:14}):e.jsx(W,{size:14}),s("git.createRepository")]})]})})]}),i.initialized&&e.jsxs("section",{className:"git-section",children:[e.jsxs("div",{className:"git-section-heading",children:[e.jsx(oe,{size:16}),e.jsxs("div",{children:[e.jsx("strong",{children:s("git.commitAndPush")}),e.jsx("small",{children:i.branch?s("git.identity",{username:o.ownerUsername}):s("git.detachedHead")})]})]}),e.jsxs("label",{className:"form-field",children:[s("git.commitMessage"),e.jsx("textarea",{rows:3,value:D,placeholder:s("git.commitPlaceholder"),onChange:t=>Z(t.target.value)})]}),e.jsxs("div",{className:"git-action-row",children:[e.jsxs("button",{title:i.dirty?void 0:s("git.noChangesToCommit"),disabled:!!a||!i.branch||!i.dirty||!D.trim(),onClick:ue,children:[a==="commit"?e.jsx(p,{className:"spin",size:14}):e.jsx(oe,{size:14}),s("git.commit")]}),e.jsxs("button",{disabled:!!a||!i.branch||!i.tokenConfigured||!i.remoteUrl||!i.latestCommit,onClick:me,children:[a==="push"?e.jsx(p,{className:"spin",size:14}):e.jsx(Se,{size:14}),s("git.push"),i.ahead>0&&e.jsx("span",{className:"git-count",children:i.ahead})]}),e.jsxs("button",{disabled:!!a||!i.latestCommit,onClick:()=>{I()},children:[a==="diff"?e.jsx(p,{className:"spin",size:14}):e.jsx(G,{size:14}),s("git.workingDiff")]}),e.jsxs("button",{className:"git-discard-button",title:i.restorable?s("git.discardChanges"):s("git.noChangesToDiscard"),disabled:!!a||!i.latestCommit||!i.restorable,onClick:()=>v(!0),children:[e.jsx(ve,{size:14}),s("git.discardChanges")]}),!i.branch&&e.jsxs("button",{disabled:!!a,onClick:()=>{R(!1),j("branch")},children:[e.jsx(q,{size:14}),s("git.returnToBranch",{branch:i.defaultBranch})]}),e.jsxs("button",{disabled:!!a,onClick:()=>{d("refresh",z)},children:[e.jsx(Ee,{className:a==="refresh"?"spin":"",size:14}),s("git.refresh")]})]})]}),b&&e.jsxs("section",{ref:O,className:`git-section git-diff-section${g?" is-fullscreen":""}`,children:[e.jsxs("div",{className:"git-diff-heading",children:[e.jsxs("div",{className:"git-section-heading",children:[e.jsx(G,{size:16}),e.jsxs("div",{children:[e.jsx("strong",{children:s("git.diffTitle")}),e.jsxs("small",{children:[b.title,b.truncated?` · ${s("git.diffTruncated")}`:""]})]})]}),e.jsxs("div",{className:"git-diff-controls",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:w<=8,title:s("git.diffFontDecrease"),"aria-label":s("git.diffFontDecrease"),onClick:()=>Y(t=>Math.max(8,t-1)),children:e.jsx(Ce,{size:14})}),e.jsxs("span",{className:"git-diff-font-value","aria-live":"polite",children:[w,"px"]}),e.jsx("button",{type:"button",className:"git-diff-font-button",disabled:w>=24,title:s("git.diffFontIncrease"),"aria-label":s("git.diffFontIncrease"),onClick:()=>Y(t=>Math.min(24,t+1)),children:e.jsx(we,{size:14})})]}),e.jsx("button",{type:"button",className:"git-diff-fullscreen",title:s(g?"git.exitFullscreenDiff":"git.fullscreenDiff"),"aria-label":s(g?"git.exitFullscreenDiff":"git.fullscreenDiff"),onClick:()=>{fe()},children:g?e.jsx(ze,{size:15}):e.jsx(Ne,{size:15})})]})]}),e.jsx(Fe,{content:b.diff,empty:s("git.noChanges"),fontSize:w})]}),i.initialized&&e.jsxs("section",{className:"git-section",children:[e.jsxs("div",{className:"git-section-heading",children:[e.jsx(q,{size:16}),e.jsxs("div",{children:[e.jsx("strong",{children:s("git.history")}),e.jsx("small",{children:s("git.historyHint")})]})]}),e.jsxs("div",{className:"git-history",children:[J.map(t=>e.jsxs("article",{children:[e.jsx("code",{children:t.shortSha}),e.jsxs("div",{children:[e.jsx("strong",{children:t.message}),e.jsxs("small",{children:[t.authorName," · ",new Date(t.authoredAt).toLocaleString(E.resolvedLanguage)]})]}),e.jsxs("span",{children:[e.jsx("button",{title:s("git.viewCommitDiff"),disabled:!!a,onClick:()=>{I(t.sha)},children:e.jsx(G,{size:14})}),e.jsx("button",{title:s("git.checkoutVersion"),disabled:!!a,onClick:()=>{R(!1),j(t)},children:e.jsx(Te,{size:14})})]})]},t.sha)),J.length===0&&e.jsx("p",{className:"muted",children:s("git.noCommits")})]})]})]})]})}),e.jsx(H,{open:!!f,title:s(f==="branch"?"git.returnTitle":"git.checkoutTitle"),description:f==="branch"?s("git.returnDescription",{branch:i?.defaultBranch??"main"}):s("git.checkoutDescription",{revision:f?.shortSha??"",message:f?.message??""}),onOpenChange:t=>{t||j(null)},footer:e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>j(null),children:s("common.cancel")}),e.jsx("button",{className:U?"danger":"primary",onClick:xe,children:s("git.checkout")})]}),children:e.jsxs("label",{className:"git-force-checkout",children:[e.jsx("input",{type:"checkbox",checked:U,onChange:t=>R(t.target.checked)}),e.jsxs("span",{children:[e.jsx("strong",{children:s("git.forceCheckout")}),e.jsx("small",{children:s("git.forceCheckoutDescription")})]})]})}),e.jsx(H,{open:le,title:s("git.discardTitle"),description:s("git.discardDescription"),onOpenChange:v,footer:e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>v(!1),children:s("common.cancel")}),e.jsx("button",{className:"danger",onClick:pe,children:s("git.discardConfirm")})]}),children:e.jsx(e.Fragment,{})})]})}function Fe({content:h,empty:o,fontSize:y}){return h.trim()?e.jsx("pre",{className:"git-diff",style:{fontSize:`${y}px`},children:h.split(`
1
+ import{u as ye,r as n,j as e}from"./react-BVUjbTTn.js";import{c as u,M as H,d as p,g as l}from"./index-p1NHkGGG.js";import{G as q,C as ie,T as ke}from"./x-eisRQJv_.js";import{K as be}from"./key-round-CoDwyVJc.js";import{C as ne,R as ve}from"./ProjectWorkspace-C6sYiBF2.js";import{M as Ce,a as Ne}from"./minus-DDTYB-Oz.js";import{P as we}from"./plus-BVXOlQXP.js";import{M as ze}from"./minimize-2-D100opW2.js";import"./check-C1db8iNn.js";import"./search-DXo_aAp0.js";import"./user-plus-MRmKeDtX.js";import"./refresh-cw-LtwnqlWh.js";const Se=u("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 ae=u("ExternalLink",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]);const G=u("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 oe=u("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 W=u("Github",[["path",{d:"M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4",key:"tonef"}],["path",{d:"M9 18c-4.51 2-5-2-7-2",key:"9comsn"}]]);const Ee=u("RefreshCcw",[["path",{d:"M21 12a9 9 0 0 0-9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"14sxne"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M3 12a9 9 0 0 0 9 9 9.75 9.75 0 0 0 6.74-2.74L21 16",key:"1hlbsb"}],["path",{d:"M16 16h5v5",key:"ccwih5"}]]);const Te=u("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 Ge({open:h,project:o,onOpenChange:y,onBeforeMutation:r}){const{t:s,i18n:E}=ye(),[i,m]=n.useState(null),[J,K]=n.useState([]),[T,k]=n.useState(""),[F,V]=n.useState(()=>re(o.name)),[_,ce]=n.useState(!0),[D,Z]=n.useState(""),[b,M]=n.useState(null),[f,j]=n.useState(null),[U,R]=n.useState(!1),[le,v]=n.useState(!1),[$,L]=n.useState(!0),[P,A]=n.useState(!0),[a,C]=n.useState(""),[Q,N]=n.useState(""),[X,B]=n.useState(""),[g,x]=n.useState(!1),[w,Y]=n.useState(10),O=n.useRef(null),z=async(t=!1)=>{const c=await l(`/api/projects/${o.id}/git`);if(m(c.status),t&&(L(!c.status.tokenConfigured),A(!c.status.remoteUrl)),c.status.initialized&&c.status.latestCommit){const S=await l(`/api/projects/${o.id}/git/history`);K(S.commits)}else K([])};n.useEffect(()=>{if(!h){document.fullscreenElement&&document.exitFullscreen().catch(()=>{}),x(!1),k("");return}N(""),B(""),M(null),x(!1),V(re(o.name)),C("load"),r().then(()=>z(!0)).catch(t=>N(t instanceof Error?t.message:s("errors.generic"))).finally(()=>C(""))},[h,o.id]),n.useEffect(()=>{const t=()=>x(document.fullscreenElement===O.current);return document.addEventListener("fullscreenchange",t),()=>document.removeEventListener("fullscreenchange",t)},[]),n.useEffect(()=>{if(!g)return;const t=c=>{c.key==="Escape"&&!document.fullscreenElement&&x(!1)};return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[g]);const d=async(t,c,S,ee)=>{C(t),N(""),B("");try{await c(),S&&B(S)}catch(se){const te=se instanceof Error?se.message:s("errors.generic");N(ee?`${ee}: ${te}`:te)}finally{C("")}},de=()=>d("token",async()=>{const t=await l(`/api/projects/${o.id}/git/token`,{method:"PUT",body:JSON.stringify({token:T})});m(t.status),k(""),L(!1)},s("git.tokenSaved")),he=()=>d("remove-token",async()=>{const t=await l(`/api/projects/${o.id}/git/token`,{method:"DELETE"});m(t.status),k("")},s("git.tokenRemoved")),ge=()=>d("repository",async()=>{const t=await l(`/api/projects/${o.id}/git/repository`,{method:"POST",body:JSON.stringify({name:F,private:_})});m(t.status),A(!1)},s("git.repositoryCreated")),ue=()=>d("commit",async()=>{if(!await r())throw new Error(s("errors.collaborationUnavailable"));const t=await l(`/api/projects/${o.id}/git/commit`,{method:"POST",body:JSON.stringify({message:D})});m(t.status),Z(""),M(null),await z()},s("git.committed")),me=()=>d("push",async()=>{if(!await r())throw new Error(s("errors.collaborationUnavailable"));const t=await l(`/api/projects/${o.id}/git/push`,{method:"POST"});m(t.status),await z()},s("git.pushed"),s("git.pushFailed")),I=t=>d("diff",async()=>{if(!await r())throw new Error(s("errors.collaborationUnavailable"));const c=t?`?revision=${encodeURIComponent(t)}`:"";M(await l(`/api/projects/${o.id}/git/diff${c}`))}),fe=async()=>{if(g){document.fullscreenElement&&await document.exitFullscreen().catch(()=>{}),x(!1);return}const t=O.current;if(t?.requestFullscreen)try{await t.requestFullscreen()}catch{}x(!0)},xe=()=>{const t=f;t&&(j(null),d("checkout",async()=>{if(!await r())throw new Error(s("errors.collaborationUnavailable"));await l(`/api/projects/${o.id}/git/checkout`,{method:"POST",body:JSON.stringify({revision:t==="branch"?null:t.sha,force:U})}),window.location.reload()}))},pe=()=>{v(!1),d("discard",async()=>{if(!await r())throw new Error(s("errors.collaborationUnavailable"));await l(`/api/projects/${o.id}/git/discard`,{method:"POST"}),window.location.reload()})},je=a==="load"&&!i;return e.jsxs(e.Fragment,{children:[e.jsx(H,{open:h,extraWide:!0,className:g?"git-dialog-modal-fullscreen":void 0,title:s("git.title"),description:s("git.description"),onOpenChange:y,footer:e.jsx("button",{onClick:()=>y(!1),children:s("common.close")}),children:e.jsxs("div",{className:"git-dialog",children:[je&&e.jsxs("div",{className:"git-loading",children:[e.jsx(p,{className:"spin",size:22}),s("common.loading")]}),Q&&e.jsx("p",{className:"git-message error",children:Q}),X&&e.jsxs("p",{className:"git-message success",children:[e.jsx(q,{size:14}),X]}),i&&e.jsxs(e.Fragment,{children:[e.jsxs("section",{className:"git-section",children:[e.jsxs("button",{className:"git-section-toggle",type:"button","aria-expanded":$,onClick:()=>L(t=>!t),children:[e.jsxs("span",{className:"git-section-heading",children:[e.jsx(be,{size:16}),e.jsxs("span",{children:[e.jsx("strong",{children:s("git.authentication")}),e.jsx("small",{children:i.tokenConfigured?s("git.connectedAs",{login:i.githubLogin}):s("git.authenticationHint")})]})]}),$?e.jsx(ne,{size:16}):e.jsx(ie,{size:16})]}),$&&e.jsxs("div",{className:"git-section-content",children:[e.jsxs("div",{className:"git-token-guidance",children:[e.jsx("strong",{children:s("git.recommendedAccessTitle")}),e.jsx("span",{children:s("git.recommendedAccess")})]}),i.tokenConfigured&&e.jsxs("div",{className:"git-account",children:[e.jsx(W,{size:17}),e.jsx("span",{children:s("git.connectedAs",{login:i.githubLogin})}),e.jsxs("button",{className:"danger-text",disabled:!!a,onClick:he,children:[e.jsx(ke,{size:14}),s("git.removeToken")]})]}),e.jsxs("label",{className:"form-field",children:[i.tokenConfigured?s("git.replaceToken"):s("git.token"),e.jsx("input",{type:"password",autoComplete:"new-password",spellCheck:!1,autoCapitalize:"none",autoCorrect:"off",value:T,placeholder:s("git.tokenPlaceholder"),onChange:t=>k(t.target.value)})]}),e.jsxs("div",{className:"git-inline-actions",children:[e.jsxs("a",{href:"https://github.com/settings/personal-access-tokens/new",target:"_blank",rel:"noreferrer",children:[s("git.createToken"),e.jsx(ae,{size:12})]}),e.jsxs("button",{disabled:!!a||T.trim().length<20,onClick:de,children:[a==="token"&&e.jsx(p,{className:"spin",size:13}),s("git.saveToken")]})]})]})]}),e.jsxs("section",{className:"git-section",children:[e.jsxs("button",{className:"git-section-toggle",type:"button","aria-expanded":P,onClick:()=>A(t=>!t),children:[e.jsxs("span",{className:"git-section-heading",children:[e.jsx(W,{size:16}),e.jsxs("span",{children:[e.jsx("strong",{children:s("git.repository")}),e.jsx("small",{children:i.remoteUrl?i.repositoryName??i.remoteUrl:i.initialized?s("git.localReady"):s("git.localPending")})]})]}),P?e.jsx(ne,{size:16}):e.jsx(ie,{size:16})]}),P&&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??s("git.origin")}),e.jsxs("small",{children:[i.branch??s("git.detachedAt",{revision:i.latestCommit?.shortSha??"HEAD"})," · ",i.dirty?s("git.changedFiles",{count:i.changedFiles}):s("git.clean")]})]}),i.repositoryHtmlUrl&&e.jsxs("a",{href:i.repositoryHtmlUrl,target:"_blank",rel:"noreferrer",children:[e.jsx(ae,{size:14}),s("git.openGitHub")]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"form-field",children:[s("git.repositoryName"),e.jsx("input",{value:F,onChange:t=>V(t.target.value)})]}),e.jsxs("label",{className:"checkbox-field",children:[e.jsx("input",{type:"checkbox",checked:_,onChange:t=>ce(t.target.checked)}),s("git.privateRepository")]}),e.jsxs("button",{className:"git-primary-action",disabled:!!a||!i.tokenConfigured||!F.trim(),onClick:ge,children:[a==="repository"?e.jsx(p,{className:"spin",size:14}):e.jsx(W,{size:14}),s("git.createRepository")]})]})})]}),i.initialized&&e.jsxs("section",{className:"git-section",children:[e.jsxs("div",{className:"git-section-heading",children:[e.jsx(oe,{size:16}),e.jsxs("div",{children:[e.jsx("strong",{children:s("git.commitAndPush")}),e.jsx("small",{children:i.branch?s("git.identity",{username:o.ownerUsername}):s("git.detachedHead")})]})]}),e.jsxs("label",{className:"form-field",children:[s("git.commitMessage"),e.jsx("textarea",{rows:3,value:D,placeholder:s("git.commitPlaceholder"),onChange:t=>Z(t.target.value)})]}),e.jsxs("div",{className:"git-action-row",children:[e.jsxs("button",{title:i.dirty?void 0:s("git.noChangesToCommit"),disabled:!!a||!i.branch||!i.dirty||!D.trim(),onClick:ue,children:[a==="commit"?e.jsx(p,{className:"spin",size:14}):e.jsx(oe,{size:14}),s("git.commit")]}),e.jsxs("button",{disabled:!!a||!i.branch||!i.tokenConfigured||!i.remoteUrl||!i.latestCommit,onClick:me,children:[a==="push"?e.jsx(p,{className:"spin",size:14}):e.jsx(Se,{size:14}),s("git.push"),i.ahead>0&&e.jsx("span",{className:"git-count",children:i.ahead})]}),e.jsxs("button",{disabled:!!a||!i.latestCommit,onClick:()=>{I()},children:[a==="diff"?e.jsx(p,{className:"spin",size:14}):e.jsx(G,{size:14}),s("git.workingDiff")]}),e.jsxs("button",{className:"git-discard-button",title:i.restorable?s("git.discardChanges"):s("git.noChangesToDiscard"),disabled:!!a||!i.latestCommit||!i.restorable,onClick:()=>v(!0),children:[e.jsx(ve,{size:14}),s("git.discardChanges")]}),!i.branch&&e.jsxs("button",{disabled:!!a,onClick:()=>{R(!1),j("branch")},children:[e.jsx(q,{size:14}),s("git.returnToBranch",{branch:i.defaultBranch})]}),e.jsxs("button",{disabled:!!a,onClick:()=>{d("refresh",z)},children:[e.jsx(Ee,{className:a==="refresh"?"spin":"",size:14}),s("git.refresh")]})]})]}),b&&e.jsxs("section",{ref:O,className:`git-section git-diff-section${g?" is-fullscreen":""}`,children:[e.jsxs("div",{className:"git-diff-heading",children:[e.jsxs("div",{className:"git-section-heading",children:[e.jsx(G,{size:16}),e.jsxs("div",{children:[e.jsx("strong",{children:s("git.diffTitle")}),e.jsxs("small",{children:[b.title,b.truncated?` · ${s("git.diffTruncated")}`:""]})]})]}),e.jsxs("div",{className:"git-diff-controls",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:w<=8,title:s("git.diffFontDecrease"),"aria-label":s("git.diffFontDecrease"),onClick:()=>Y(t=>Math.max(8,t-1)),children:e.jsx(Ce,{size:14})}),e.jsxs("span",{className:"git-diff-font-value","aria-live":"polite",children:[w,"px"]}),e.jsx("button",{type:"button",className:"git-diff-font-button",disabled:w>=24,title:s("git.diffFontIncrease"),"aria-label":s("git.diffFontIncrease"),onClick:()=>Y(t=>Math.min(24,t+1)),children:e.jsx(we,{size:14})})]}),e.jsx("button",{type:"button",className:"git-diff-fullscreen",title:s(g?"git.exitFullscreenDiff":"git.fullscreenDiff"),"aria-label":s(g?"git.exitFullscreenDiff":"git.fullscreenDiff"),onClick:()=>{fe()},children:g?e.jsx(ze,{size:15}):e.jsx(Ne,{size:15})})]})]}),e.jsx(Fe,{content:b.diff,empty:s("git.noChanges"),fontSize:w})]}),i.initialized&&e.jsxs("section",{className:"git-section",children:[e.jsxs("div",{className:"git-section-heading",children:[e.jsx(q,{size:16}),e.jsxs("div",{children:[e.jsx("strong",{children:s("git.history")}),e.jsx("small",{children:s("git.historyHint")})]})]}),e.jsxs("div",{className:"git-history",children:[J.map(t=>e.jsxs("article",{children:[e.jsx("code",{children:t.shortSha}),e.jsxs("div",{children:[e.jsx("strong",{children:t.message}),e.jsxs("small",{children:[t.authorName," · ",new Date(t.authoredAt).toLocaleString(E.resolvedLanguage)]})]}),e.jsxs("span",{children:[e.jsx("button",{title:s("git.viewCommitDiff"),disabled:!!a,onClick:()=>{I(t.sha)},children:e.jsx(G,{size:14})}),e.jsx("button",{title:s("git.checkoutVersion"),disabled:!!a,onClick:()=>{R(!1),j(t)},children:e.jsx(Te,{size:14})})]})]},t.sha)),J.length===0&&e.jsx("p",{className:"muted",children:s("git.noCommits")})]})]})]})]})}),e.jsx(H,{open:!!f,title:s(f==="branch"?"git.returnTitle":"git.checkoutTitle"),description:f==="branch"?s("git.returnDescription",{branch:i?.defaultBranch??"main"}):s("git.checkoutDescription",{revision:f?.shortSha??"",message:f?.message??""}),onOpenChange:t=>{t||j(null)},footer:e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>j(null),children:s("common.cancel")}),e.jsx("button",{className:U?"danger":"primary",onClick:xe,children:s("git.checkout")})]}),children:e.jsxs("label",{className:"git-force-checkout",children:[e.jsx("input",{type:"checkbox",checked:U,onChange:t=>R(t.target.checked)}),e.jsxs("span",{children:[e.jsx("strong",{children:s("git.forceCheckout")}),e.jsx("small",{children:s("git.forceCheckoutDescription")})]})]})}),e.jsx(H,{open:le,title:s("git.discardTitle"),description:s("git.discardDescription"),onOpenChange:v,footer:e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>v(!1),children:s("common.cancel")}),e.jsx("button",{className:"danger",onClick:pe,children:s("git.discardConfirm")})]}),children:e.jsx(e.Fragment,{})})]})}function Fe({content:h,empty:o,fontSize:y}){return h.trim()?e.jsx("pre",{className:"git-diff",style:{fontSize:`${y}px`},children:h.split(`
2
2
  `).map((r,s)=>{const E=r.startsWith("+")&&!r.startsWith("+++")?"addition":r.startsWith("-")&&!r.startsWith("---")?"deletion":r.startsWith("@@")?"hunk":r.startsWith("diff ")?"header":"";return e.jsxs("span",{className:E,children:[r,`
3
3
  `]},s)})}):e.jsx("div",{className:"git-diff-empty",children:o})}function re(h){return h.trim().replace(/\s+/g,"-").replace(/[^A-Za-z0-9._-]/g,"-").replace(/-+/g,"-").replace(/^[.-]+|[.-]+$/g,"").slice(0,100)||"texlite-project"}export{Ge as GitDialog};
@@ -1,4 +1,4 @@
1
- import{u as Ae,r as o,j as e}from"./react-BVUjbTTn.js";import{c as Pe,g as _,M as Me,d as le,C as be,A as ve}from"./index-teah8iB2.js";import{d as He,C as Ne}from"./index-i5IY_PMw.js";import{H as Be,F as Ve}from"./hard-drive-DP2OHKMC.js";import{T as Ce,d as _e}from"./x-BEVz0wdw.js";import{F as we,R as $e,S as Ie,A as Oe}from"./ProjectWorkspace-CI2zKon5.js";import{M as Ue,a as We}from"./minus-CqvESp9M.js";import{P as Ye}from"./plus-DIrweesj.js";import{M as qe}from"./minimize-2-6tf519Ts.js";import"./check-BAdi_Lxq.js";import"./search-C9_Jyrnx.js";import"./user-plus-C7exNawX.js";import"./refresh-cw-BDcwKu_d.js";const Ge=Pe("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 Se(i,c,C,y="历史版本",s="当前版本",f=3){const S=c.replace(/\r\n/g,`
1
+ import{u as Ae,r as o,j as e}from"./react-BVUjbTTn.js";import{c as Pe,g as _,M as Me,d as le,C as be,A as ve}from"./index-p1NHkGGG.js";import{d as He,C as Ne}from"./index-kTamGfTl.js";import{H as Be}from"./hard-drive-BWZnOgnm.js";import{T as Ce,c as Ve,e as _e}from"./x-eisRQJv_.js";import{F as we,R as $e,S as Ie,A as Oe}from"./ProjectWorkspace-C6sYiBF2.js";import{M as Ue,a as We}from"./minus-DDTYB-Oz.js";import{P as Ye}from"./plus-BVXOlQXP.js";import{M as qe}from"./minimize-2-D100opW2.js";import"./check-C1db8iNn.js";import"./search-DXo_aAp0.js";import"./user-plus-MRmKeDtX.js";import"./refresh-cw-LtwnqlWh.js";const Ge=Pe("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 Se(i,c,C,y="历史版本",s="当前版本",f=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 He,k=h.diff_linesToChars_(S,R),x=h.diff_main(k.chars1,k.chars2,!1);h.diff_charsToLines_(x,k.lineArray);const w=[];let n=1,T=1,m=0,z=0;for(const[d,v]of x){if(!v)continue;const u=v.split(`
4
4
  `);u[u.length-1]===""&&u.pop();for(const P of u)d===0?w.push({op:0,text:P,oldNum:n++,newNum:T++}):d===-1?(z++,w.push({op:-1,text:P,oldNum:n++,newNum:T})):d===1&&(m++,w.push({op:1,text:P,oldNum:n,newNum:T++}))}if(m===0&&z===0)return{diffText:"",additions:0,deletions:0,hasChanges:!1};const j=[];let b=-1,A=-1;for(let d=0;d<w.length;d++)if(w[d].op!==0){const v=Math.max(0,d-f),u=Math.min(w.length-1,d+f);b===-1?(b=v,A=u):v<=A+1?A=Math.max(A,u):(j.push({start:b,end:A}),b=v,A=u)}b!==-1&&j.push({start:b,end:A});const G=[`--- a/${i} (${y})`,`+++ b/${i} (${s})`];for(const d of j){const v=w.slice(d.start,d.end+1),u=v.filter($=>$.op<=0).length,P=v.filter($=>$.op>=0).length,E=v[0],O=u===0?0:E.oldNum,J=P===0?0:E.newNum;G.push(`@@ -${O},${u} +${J},${P} @@`);for(const $ of v){const U=$.op===-1?"-":$.op===1?"+":" ";G.push(`${U}${$.text}`)}}return{diffText:G.join(`