texlite 0.10.0 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/DESIGN.md +44 -26
  2. package/OPERATIONS.md +12 -6
  3. package/README.md +9 -4
  4. package/README.zh-CN.md +7 -4
  5. package/dist/client/assets/AdminUsers-DMsBqC48.js +1 -0
  6. package/dist/client/assets/{CitationLibraryDialog-CU2b0xtm.js → CitationLibraryDialog-C_333dTc.js} +1 -1
  7. package/dist/client/assets/Dashboard-EOaNnS1A.js +2 -0
  8. package/dist/client/assets/GitDialog-DU-sVP-o.js +3 -0
  9. package/dist/client/assets/GitHubAccountDialog-IrB3M7nt.js +1 -0
  10. package/dist/client/assets/HistoryDialog-CDUbT7yG.js +7 -0
  11. package/dist/client/assets/LatexEditor-BYgW2otE.js +138 -0
  12. package/dist/client/assets/PdfPreview--HsIb8Fn.js +1 -0
  13. package/dist/client/assets/ProjectIconPickerDialog-CaF7Kkda.js +1 -0
  14. package/dist/client/assets/{ProjectNavigationDialogs-_JY0yVob.js → ProjectNavigationDialogs-3Ce7-tVp.js} +1 -1
  15. package/dist/client/assets/ProjectSettings-9hYSUKDo.js +1 -0
  16. package/dist/client/assets/ProjectWorkspace-D9zmy0KR.js +32 -0
  17. package/dist/client/assets/{SelectionHistoryDialog-D8CeqjLD.js → SelectionHistoryDialog-COpXO4kL.js} +2 -2
  18. package/dist/client/assets/SystemMetricsDialog-D9dthbAB.js +1 -0
  19. package/dist/client/assets/{TagManagementDialog-4R1Gs43j.js → TagManagementDialog-S8zDQAaB.js} +1 -1
  20. package/dist/client/assets/{WordCountDialog-C-MCscAu.js → WordCountDialog-CMsFa_pM.js} +1 -1
  21. package/dist/client/assets/check-Hv1kodh8.js +1 -0
  22. package/dist/client/assets/chktex-BFELQm91.js +3 -0
  23. package/dist/client/assets/{editor-B9HNwtsd.js → editor-taw1iptB.js} +1 -1
  24. package/dist/client/assets/external-link-C2GCFJxP.js +1 -0
  25. package/dist/client/assets/github-B_Eh2y6s.js +1 -0
  26. package/dist/client/assets/{hard-drive-Bsk-RETn.js → hard-drive-bzz70DQ5.js} +1 -1
  27. package/dist/client/assets/{index-Csp5J5aI.js → index-CXtmuEUm.js} +1 -1
  28. package/dist/client/assets/index-CxrDisif.css +1 -0
  29. package/dist/client/assets/index-Dik-2GCl.js +10 -0
  30. package/dist/client/assets/{minimize-2-92UqFWI9.js → minimize-2-CmPZ9Iwp.js} +1 -1
  31. package/dist/client/assets/{minus-bx4ZLZnb.js → minus-Dzy8rgfA.js} +1 -1
  32. package/dist/client/assets/{plus-DQg_bV50.js → plus-DlX82JCl.js} +1 -1
  33. package/dist/client/assets/{refresh-cw-BoMEkk5J.js → refresh-cw-BWndInnG.js} +1 -1
  34. package/dist/client/assets/{search-UZspmceH.js → search-DMqOy-Ex.js} +1 -1
  35. package/dist/client/assets/{sigma-C0IvFdKV.js → sigma-B0zOJKVj.js} +1 -1
  36. package/dist/client/assets/{spellCheck-DyKIHf5C.js → spellCheck-BjkrQxRU.js} +1 -1
  37. package/dist/client/assets/{tags-BTUtvaAc.js → tags-XvdXg-yc.js} +1 -1
  38. package/dist/client/assets/{type-XvvfEJRs.js → type-DsGlKUKR.js} +1 -1
  39. package/dist/client/assets/{user-plus-Chr9T97G.js → user-plus-Bcq_EsqH.js} +1 -1
  40. package/dist/client/assets/{x-DlFXD9Vl.js → x-BJOMjm8Z.js} +1 -1
  41. package/dist/client/index.html +3 -3
  42. package/dist/server/app.js +8 -0
  43. package/dist/server/chktex.js +377 -0
  44. package/dist/server/collaboration.js +6 -0
  45. package/dist/server/db.js +35 -1
  46. package/dist/server/environment.js +1 -0
  47. package/dist/server/git.js +64 -29
  48. package/dist/server/harper.js +14 -0
  49. package/dist/server/history.js +18 -9
  50. package/dist/server/i18n.js +14 -4
  51. package/dist/server/projectImportUploads.js +133 -0
  52. package/dist/server/routes/projectFiles.js +3 -0
  53. package/dist/server/routes/projectGit.js +10 -11
  54. package/dist/server/routes/projectHistory.js +32 -5
  55. package/dist/server/routes/projectMembers.js +0 -5
  56. package/dist/server/routes/projectShared.js +1 -0
  57. package/dist/server/routes/projects.js +97 -15
  58. package/dist/server/routes/users.js +0 -2
  59. package/dist/shared/historyFiles.js +6 -0
  60. package/dist/shared/writingChecks.js +4 -0
  61. package/package.json +1 -1
  62. package/dist/client/assets/AdminUsers-C7oU_1Y_.js +0 -1
  63. package/dist/client/assets/Dashboard-BB4RO4x2.js +0 -2
  64. package/dist/client/assets/GitDialog-C2Np1i8v.js +0 -3
  65. package/dist/client/assets/HistoryDialog-CdoYeLyX.js +0 -7
  66. package/dist/client/assets/LatexEditor-Dmy6_gqt.js +0 -138
  67. package/dist/client/assets/PdfPreview-fDxKh6hP.js +0 -1
  68. package/dist/client/assets/ProjectIconPickerDialog-CsjMKq7h.js +0 -1
  69. package/dist/client/assets/ProjectSettings-DXGA-lmB.js +0 -1
  70. package/dist/client/assets/ProjectWorkspace-mCYjyc6e.js +0 -32
  71. package/dist/client/assets/SystemMetricsDialog-BZx7ZMQt.js +0 -1
  72. package/dist/client/assets/check-Jf8WBxDX.js +0 -1
  73. package/dist/client/assets/index-B6rP7QsM.js +0 -12
  74. package/dist/client/assets/index-DGZNAyxW.css +0 -1
  75. package/dist/client/assets/key-round-DqptHHKC.js +0 -1
package/DESIGN.md CHANGED
@@ -25,7 +25,7 @@ and day-to-day operation.
25
25
  | Browser UI | React, Vite, CodeMirror, PDF.js |
26
26
  | Localization | Frontend JSON resources plus a server-side error-code catalog, selected from `Accept-Language` |
27
27
  | Editor language features | CodeMirror LaTeX syntax/folding, auto-pairs, project completion index, optional Vim mode |
28
- | Writing assistance | Optional host `harper-cli`, with a linear server-side LaTeX mask and native browser spellcheck fallback; project dictionary stored by the server |
28
+ | Writing assistance | Optional host `harper-cli` plus opt-in host `chktex`; Harper provides spelling/grammar suggestions, ChkTeX provides LaTeX writing diagnostics, and the project dictionary is stored by the server |
29
29
  | API and static server | Fastify, WebSocket |
30
30
  | Collaboration | Yjs, y-websocket, awareness messages, y-codemirror.next |
31
31
  | Database | SQLite through better-sqlite3, foreign keys, WAL mode, and `synchronous=NORMAL` |
@@ -119,7 +119,7 @@ Startup checks Node.js, `latexmk`, and every configured LaTeX engine.
119
119
  default host commands, requiring Node.js, `latexmk`, and at least one supported
120
120
  LaTeX engine. `texlite doctor` also reports optional host tools in a
121
121
  requirement/status/version table: Git, TeXcount, bibliography/index tools,
122
- Harper CLI, and `harper-ls`. A host without Git can run the editor and compiler;
122
+ ChkTeX, Harper CLI, and `harper-ls`. A host without Git can run the editor and compiler;
123
123
  Git is checked on demand when an owner opens or uses Git integration. Formatting is also optional: the browser loads
124
124
  the bundled npm `tex-fmt` WASM module and `bibtex-tidy` only when formatting is
125
125
  requested. TexLite never installs or updates TeX packages.
@@ -196,6 +196,22 @@ was intentionally held in memory. If a collaborative text edit exceeds the
196
196
  configured limit, it is restored to the last durable content and the flush
197
197
  receipt identifies the rejected path.
198
198
 
199
+ The workspace toolbar exposes project snapshots as a single button. Selecting
200
+ source text reveals comment and selection-history actions in the line-number
201
+ column; their tooltips remain enabled independently of the interface-tooltip
202
+ preference. Opening selection history captures the file, selected range, and
203
+ source together, including before the lazily loaded dialog mounts.
204
+
205
+ Recovery snapshots are created only for actual file additions, changes, or
206
+ deletions. Settings-only changes update the persistence baseline without adding
207
+ a timeline entry; effective compiler settings are captured with the next file
208
+ change. Older zero-file-change entries are excluded from timeline pagination and
209
+ previous-version comparisons, but are not automatically purged. Non-text
210
+ attachments remain in snapshots for recovery and are shown as a compact change
211
+ notice, without requesting or decoding their contents for a diff. Source and
212
+ ordinary text/data formats support bounded UTF-8 comparisons, including file
213
+ deletions; invalid or oversized text is reported as unavailable, not as unchanged.
214
+
199
215
  After a source write succeeds, connection-originated Yjs text deltas are also
200
216
  stored as ordered edit segments. Each segment belongs to exactly one user, one
201
217
  file, and one operation type (`edit` or `format`). The edit records store only
@@ -273,18 +289,16 @@ Editor tab remounts therefore preserve Ctrl/Cmd+Z and Vim undo history without
273
289
  leaving obsolete CodeMirror/Yjs observers behind. Managers are released when
274
290
  the collaboration object is destroyed or loses edit permission.
275
291
 
276
- TexLite probes the optional host `harper-cli` command at startup. It runs each
277
- check in a private temporary TeX file after a narrow, linear server-side LaTeX
278
- mask has removed comments, commands, references, math, tables, option syntax,
279
- and code-like environments. This avoids browser/WASM startup work and keeps
280
- malformed delimiters bounded. The service serializes checks, coalesces identical
281
- source inputs for a short window, and returns Harper's safe replacement
282
- suggestions. Spelling uses a red wavy underline and grammar uses yellow; a
283
- context menu offers suggestions, while read-only members can inspect but cannot
284
- apply them. The shared project dictionary is kept in SQLite and filters
285
- project-specific spelling results in the browser. If the command is absent or
286
- fails, CodeMirror enables the browser's built-in English spellchecker until it
287
- retries.
292
+ TexLite probes the optional host `harper-cli` command at startup. Harper uses
293
+ its native LaTeX-aware parser and returns safe replacement suggestions. The
294
+ project dictionary is kept in SQLite and filters project-specific spelling
295
+ results in the browser. If Harper is absent or fails, CodeMirror enables the
296
+ browser's built-in English spellchecker until it retries. A project owner may
297
+ also enable the optional host `chktex` compiler setting. ChkTeX starts only
298
+ after two seconds of editor idle time, coalesces identical source inputs, and
299
+ uses a process-wide queue capped at eight checks across projects and users. Its
300
+ LaTeX writing diagnostics use a blue-gray wavy underline and never replace
301
+ the compile diagnostics; the setting is off by default.
288
302
 
289
303
  Formatting is independent from the editor's local appearance. A user can
290
304
  manually format a selection or enable the per-user/per-project “format before
@@ -432,9 +446,12 @@ data directory.
432
446
  ## GitHub backup
433
447
 
434
448
  The Git panel is project-owner-only. Git is optional at startup and is checked
435
- when Git integration is used. A per-project GitHub token is encrypted in
436
- SQLite; it is never placed in a remote URL or command-line argument. The local
437
- repository lives in the project source directory, with temporary identity:
449
+ when Git integration is used. Each user's GitHub token is configured from the
450
+ account menu and encrypted in SQLite; it is never placed in a remote URL or
451
+ command-line argument. A project's current owner supplies the credential for
452
+ creating its GitHub repository and pushing. The remote URL and repository
453
+ metadata remain project-specific. The local repository lives in the project
454
+ source directory, with temporary identity:
438
455
 
439
456
  ~~~text
440
457
  user.name = project owner's username
@@ -445,11 +462,12 @@ For a fine-grained GitHub token in a trusted deployment, grant repository
445
462
  Administration and Contents read/write permissions. “All repositories” is the
446
463
  practical choice when a repository may be created after token configuration.
447
464
  Only the owner can commit, push, checkout, restore, or configure the project
448
- repository. Commit messages are entered explicitly. Normal checkout preserves
449
- local changes and refuses conflicts; only the explicit force option discards
450
- tracked, untracked, and ignored working-tree files. The Git operations use the
451
- same project coordination and durable-flush boundary as other source
452
- replacements.
465
+ repository. Transferring ownership changes which account credential is used;
466
+ the former owner's personal token remains with that account. Commit messages
467
+ are entered explicitly. Normal checkout preserves local changes and refuses
468
+ conflicts; only the explicit force option discards tracked, untracked, and
469
+ ignored working-tree files. Git operations use the same project coordination
470
+ and durable-flush boundary as other source replacements.
453
471
 
454
472
  ## Data, backup, tags, and deletion
455
473
 
@@ -503,10 +521,10 @@ reaper cleans abandoned trash/temp entries. Deleting a user removes sessions,
503
521
  memberships, private tags, and comments remain attributable as “Deleted User”.
504
522
  An administrator can transfer the user's owned projects to the current
505
523
  administrator or delete them with their files. Project transfer keeps the old
506
- owner as an editor and clears the project GitHub token so the new owner must
507
- configure their own credential. Administrators do not otherwise receive
508
- implicit access to another user's projects; they see a project only when they
509
- own it or it has been explicitly shared with them. The last active
524
+ owner as an editor; GitHub credentials remain account-specific, so the new
525
+ owner's token is used for project operations. Administrators do not otherwise
526
+ receive implicit access to another user's projects; they see a project only
527
+ when they own it or it has been explicitly shared with them. The last active
510
528
  administrator cannot be removed or disabled.
511
529
 
512
530
  ## Known limitations and TODO
package/OPERATIONS.md CHANGED
@@ -206,7 +206,7 @@ preferred.
206
206
  | `latex.extraArgs` | `[]` | Additional configured compiler arguments. |
207
207
  | `latex.compileTimeoutSeconds` | `600` | Per-job time limit. |
208
208
  | `latex.maxCompileJobs` | `10` | Global concurrent LaTeX-process limit. |
209
- | `latex.allowProjectLatexmkrc` | `true` | Enables an owner-configured, multi-line `latexmkrc`. |
209
+ | `latex.allowProjectLatexmkrc` | `true` | Allows project owners to opt into an existing project `latexmkrc`; the per-project selection starts off. Edit the file in the project editor. |
210
210
  | `git.binary` / `git.operationTimeoutSeconds` | `git` / `120` seconds | Used only by optional Git integration. |
211
211
  | `git.githubApiBaseUrl` | `https://api.github.com` | GitHub REST API endpoint. |
212
212
 
@@ -294,11 +294,17 @@ Valid base paths start with `/`, contain URL-safe path segments, and have no
294
294
  query, fragment, `.` or `..` segment. A trailing slash in configuration is
295
295
  accepted and normalized. Restart TexLite after changing this setting.
296
296
 
297
- Before every compile TexLite passes `-norc` to `latexmk`. A `.latexmkrc` found
298
- in a ZIP upload, Git checkout, or project file tree is ignored. It is used only
299
- when the owner explicitly saves it through Project Settings, which passes it
300
- with `-r`. An `latexmkrc` is executable Perl configuration and should remain
301
- disabled for users you do not trust.
297
+ Before every compile TexLite passes `-norc` to `latexmk`. A `.latexmkrc` or
298
+ `latexmkrc` found in a ZIP upload, Git checkout, or project file tree is ignored
299
+ until the owner enables it in Project Settings. TexLite then passes that file
300
+ with `-r`. The setting appears only when an rc file exists; the file is edited
301
+ in the project editor, not in settings. For an unconfigured project, a root
302
+ `latexmkrc` is preferred over a root `.latexmkrc` when both exist; an existing
303
+ selection is preserved. Removing an active rc file disables it. A `latexmkrc`
304
+ is executable Perl configuration; it may override the selected engine and
305
+ other compiler options, and collaborators who can edit the file can change
306
+ subsequent builds. Keep the server-level option off when project editors are
307
+ not trusted.
302
308
 
303
309
  TexLite never runs `tlmgr` or installs TeX packages. Updating the host TeX
304
310
  distribution changes the environment used by subsequent compiles.
package/README.md CHANGED
@@ -59,12 +59,15 @@ texlite logs
59
59
  `start`, `stop`, `restart`, `status`, and `logs` use the PM2 runtime bundled
60
60
  with the npm package. Run `texlite help` for the complete command list.
61
61
 
62
- ## How to access TexLite publicly
62
+ <details>
63
+ <summary>How to access TexLite publicly</summary>
63
64
 
64
65
  Keep TexLite bound to `127.0.0.1` and use
65
66
  [TexLite Share](https://share.zhongpu.info/) when you need convenient,
66
- HTTPS-protected public access. With TexLite running locally on its default
67
- port, install and launch the tunnel client with:
67
+ HTTPS-protected public access. TexLite Share is currently hosted in Hong Kong,
68
+ so access from mainland China or regions outside Southeast Asia may be slower.
69
+ With TexLite running locally on its default port, install and launch the tunnel
70
+ client with:
68
71
 
69
72
  ```bash
70
73
  curl -fsSL https://raw.githubusercontent.com/ChenZhongPu/TexLite-Share/main/install-client.sh | bash
@@ -79,6 +82,8 @@ For a non-default local port, specify the address explicitly:
79
82
  --local-addr 127.0.0.1:8080
80
83
  ```
81
84
 
85
+ </details>
86
+
82
87
  ## A practical distinction from Overleaf
83
88
 
84
89
  [Overleaf](https://www.overleaf.com/about/features-overview) is a strong choice
@@ -105,7 +110,7 @@ shared browser writing, not a replacement for a personal IDE.
105
110
  - Projects with folders, ZIP import/export, tags, sharing, ownership transfer,
106
111
  archiving, and a private per-user citation library.
107
112
  - CodeMirror editing with LaTeX/BibTeX highlighting, folding, completion,
108
- optional Vim mode, formatting, spelling/grammar assistance, search/replace,
113
+ optional Vim mode, formatting, spelling/grammar/ChkTeX assistance, search/replace,
109
114
  and source/PDF SyncTeX navigation.
110
115
  - Yjs-based collaborative source editing, active-session presence, comments
111
116
  anchored to source text, replies, resolution, and permissions that let
package/README.zh-CN.md CHANGED
@@ -56,11 +56,12 @@ texlite logs
56
56
  `restart`、`status`、`logs` 使用 npm 包内置的 PM2 运行时;完整命令请执行
57
57
  `texlite help`。
58
58
 
59
- ## 如何公开访问 TexLite
59
+ <details>
60
+ <summary>如何公开访问 TexLite</summary>
60
61
 
61
62
  建议让 TexLite 继续监听 `127.0.0.1`。如果需要方便、安全地公开访问,请使用
62
- [TexLite Share](https://share.zhongpu.info/)。确保 TexLite 已在默认端口启动,然后安装并
63
- 运行隧道客户端:
63
+ [TexLite Share](https://share.zhongpu.info/)。TexLite Share 目前部署在香港,来自中国大陆或
64
+ 东南亚以外地区的访问可能较慢。确保 TexLite 已在默认端口启动,然后安装并运行隧道客户端:
64
65
 
65
66
  ```bash
66
67
  curl -fsSL https://raw.githubusercontent.com/ChenZhongPu/TexLite-Share/main/install-client.sh | bash
@@ -75,6 +76,8 @@ curl -fsSL https://raw.githubusercontent.com/ChenZhongPu/TexLite-Share/main/inst
75
76
  --local-addr 127.0.0.1:8080
76
77
  ```
77
78
 
79
+ </details>
80
+
78
81
  ## 与 Overleaf 的实际区别
79
82
 
80
83
  [Overleaf](https://www.overleaf.com/about/features-overview) 在团队需要其托管产品或更完整生态时
@@ -96,7 +99,7 @@ TeX 更新、数据位置与协作工作流的掌控。
96
99
 
97
100
  - 项目支持文件夹、ZIP 导入/导出、标签、分享、所有权转让、归档和私有的个人引用库。
98
101
  - 基于 CodeMirror 的编辑器提供 LaTeX/BibTeX 高亮、折叠、补全、可选 Vim 模式、格式化、
99
- 拼写/语法辅助、搜索替换及源码/PDF SyncTeX 跳转。
102
+ 拼写/语法/ChkTeX 辅助、搜索替换及源码/PDF SyncTeX 跳转。
100
103
  - 基于 Yjs 的协同源码编辑支持活动会话、源码锚定批注、回复、解决状态,以及让审阅者
101
104
  可批注但不能修改源码的权限模型。
102
105
  - 使用 `latexmk` 和可选择引擎进行编译,提供项目设置、结构化诊断、缓存的成功 PDF、
@@ -0,0 +1 @@
1
+ import{u as Y,r as n,j as e}from"./react-BVUjbTTn.js";import{c as d,M as D,d as _,C as ee,g as h,h as m}from"./index-Dik-2GCl.js";import{U as se,T as H,X as O}from"./x-BJOMjm8Z.js";import{U as $}from"./user-plus-Bcq_EsqH.js";import{S as ae}from"./Dashboard-EOaNnS1A.js";import"./hard-drive-bzz70DQ5.js";import"./github-B_Eh2y6s.js";import"./sigma-B0zOJKVj.js";import"./tags-XvdXg-yc.js";const re=d("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=d("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=d("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 V=d("KeyRound",[["path",{d:"M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z",key:"1s6t7t"}],["circle",{cx:"16.5",cy:"7.5",r:".5",fill:"currentColor",key:"w0ekpg"}]]);const ie=d("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=d("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=d("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,B]=n.useState([]),[A,c]=n.useState(""),[J,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,E]=n.useState(!1),[F,y]=n.useState(""),[l,f]=n.useState(null),[U,R]=n.useState(!1),[X,u]=n.useState(""),b=()=>h("/api/admin/users").then(({users:s})=>B(s)).catch(s=>c(m(s)));n.useEffect(()=>{b()},[]);const q=async()=>{if(r.password.length<t)return c(a("auth.passwordMinimum",{count:t}));try{await h("/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){c(m(s))}},M=async(s,v)=>{try{await h(`/api/admin/users/${s.id}`,{method:"PATCH",body:JSON.stringify(v)}),await b()}catch(T){c(m(T))}},K=async s=>{if(!s.disabled){f({target:s,setting:"disable"}),u("");return}await M(s,{disabled:!1})},Z=async s=>{if(s.role==="admin"){f({target:s,setting:"demote"}),u("");return}await M(s,{role:"admin"})},G=async s=>{if(s.canCreateProjects){f({target:s,setting:"denyProjectCreation"}),u("");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};R(!0),u("");try{await h(`/api/admin/users/${s.id}`,{method:"PATCH",body:JSON.stringify(T)}),await b(),f(null)}catch(W){u(m(W))}finally{R(!1)}},L=async()=>{if(!(!k||!j)){if(j.length<t)return c(a("auth.passwordMinimum",{count:t}));try{await h(`/api/admin/users/${k.id}`,{method:"PATCH",body:JSON.stringify({password:j})}),g(null),P("")}catch(s){c(m(s))}}},Q=async()=>{if(!(!x||i)){E(!0),y("");try{await h(`/api/admin/users/${x.id}`,{method:"DELETE",body:JSON.stringify({deleteProjects:z})}),w(null),N(!1),await b()}catch(s){y(m(s))}finally{E(!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")]})]}),A&&e.jsx("p",{className:"error",children:A}),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(V,{"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(H,{"aria-hidden":!0,size:13}),a("common.delete")]})]})]},s.id))})]})}),e.jsx(D,{open:J,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(V,{"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(H,{"aria-hidden":!0,size:14}),a(i?"common.loading":"users.deleteTitle")]})]}),children:e.jsxs(e.Fragment,{children:[F&&e.jsx("p",{className:"error dialog-error",children:F}),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:U,error:X,onCancel:()=>{U||(f(null),u(""))},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-B6rP7QsM.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-DlFXD9Vl.js";import{P as it}from"./plus-DQg_bV50.js";import{C as J}from"./check-Jf8WBxDX.js";import{S as ii}from"./search-UZspmceH.js";import{T as ei}from"./tags-BTUtvaAc.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};
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-Dik-2GCl.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-BJOMjm8Z.js";import{P as it}from"./plus-DlX82JCl.js";import{C as J}from"./check-Hv1kodh8.js";import{S as ii}from"./search-DMqOy-Ex.js";import{T as ei}from"./tags-XvdXg-yc.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-D9dthbAB.js","./react-BVUjbTTn.js","./index-Dik-2GCl.js","./index-CxrDisif.css","./refresh-cw-BWndInnG.js","./hard-drive-bzz70DQ5.js","./x-BJOMjm8Z.js","./github-B_Eh2y6s.js","./sigma-B0zOJKVj.js","./tags-XvdXg-yc.js","./CitationLibraryDialog-C_333dTc.js","./citationLibrary-ZeQPCv5O.js","./plus-DlX82JCl.js","./check-Hv1kodh8.js","./search-DMqOy-Ex.js","./AdminUsers-DMsBqC48.js","./user-plus-Bcq_EsqH.js","./TagManagementDialog-S8zDQAaB.js","./ProjectIconPickerDialog-CaF7Kkda.js","./GitHubAccountDialog-IrB3M7nt.js","./external-link-C2GCFJxP.js"])))=>i.map(i=>d[i]);
2
+ import{c as o,a as at,s as Oe,S as ka,L as xa,b as It,M as oe,d as Be,e as Ue,C as fa,f as va,g as S,h as L,_ as ie,i as Ye,j as ba}from"./index-Dik-2GCl.js";import{j as e,r,u as Ma}from"./react-BVUjbTTn.js";import{H as Ca}from"./hard-drive-bzz70DQ5.js";import{G as wa,F as Na,L as Sa,N as za,a as Ta,b as Pa,c as Aa,S as Da,B as Bt,d as La,e as Ea,P as Ia,D as Fa,T as qa,M as Ut,A as Vt,f as Ft,U as $a,g as qt,h as Oa,C as $t,i as Ba,j as Ua,X as Va,k as Ha}from"./x-BJOMjm8Z.js";import{F as Ra,G as _a}from"./github-B_Eh2y6s.js";import{S as Za}from"./sigma-B0zOJKVj.js";import{T as et}from"./tags-XvdXg-yc.js";const Ga=o("Activity",[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]]);const Ka=o("ArchiveRestore",[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h2",key:"tvwodi"}],["path",{d:"M20 8v11a2 2 0 0 1-2 2h-2",key:"1gkqxj"}],["path",{d:"m9 15 3-3 3 3",key:"1pd0qc"}],["path",{d:"M12 12v9",key:"192myk"}]]);const st=o("Archive",[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8",key:"1s80jp"}],["path",{d:"M10 12h4",key:"a56b0p"}]]);const Wa=o("ArrowDownUp",[["path",{d:"m3 16 4 4 4-4",key:"1co6wj"}],["path",{d:"M7 20V4",key:"1yoxec"}],["path",{d:"m21 8-4-4-4 4",key:"1c9v7m"}],["path",{d:"M17 4v16",key:"7dpous"}]]);const Ht=o("ArrowRightLeft",[["path",{d:"m16 3 4 4-4 4",key:"1x1c3m"}],["path",{d:"M20 7H4",key:"zbl0bi"}],["path",{d:"m8 21-4-4 4-4",key:"h9nckh"}],["path",{d:"M4 17h16",key:"g4d7ey"}]]);const Ja=o("Atom",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["path",{d:"M20.2 20.2c2.04-2.03.02-7.36-4.5-11.9-4.54-4.52-9.87-6.54-11.9-4.5-2.04 2.03-.02 7.36 4.5 11.9 4.54 4.52 9.87 6.54 11.9 4.5Z",key:"1l2ple"}],["path",{d:"M15.7 15.7c4.52-4.54 6.54-9.87 4.5-11.9-2.03-2.04-7.36-.02-11.9 4.5-4.52 4.54-6.54 9.87-4.5 11.9 2.03 2.04 7.36.02 11.9-4.5Z",key:"1wam0m"}]]);const Qa=o("Beaker",[["path",{d:"M4.5 3h15",key:"c7n0jr"}],["path",{d:"M6 3v16a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V3",key:"m1uhx7"}],["path",{d:"M6 14h12",key:"4cwo0f"}]]);const Xa=o("Bookmark",[["path",{d:"m19 21-7-4-7 4V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v16z",key:"1fy3hk"}]]);const Ya=o("Bot",[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]]);const es=o("Braces",[["path",{d:"M8 3H7a2 2 0 0 0-2 2v5a2 2 0 0 1-2 2 2 2 0 0 1 2 2v5c0 1.1.9 2 2 2h1",key:"ezmyqa"}],["path",{d:"M16 21h1a2 2 0 0 0 2-2v-5c0-1.1.9-2 2-2a2 2 0 0 1-2-2V5a2 2 0 0 0-2-2h-1",key:"e1hn23"}]]);const ts=o("BrainCircuit",[["path",{d:"M12 5a3 3 0 1 0-5.997.125 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z",key:"l5xja"}],["path",{d:"M9 13a4.5 4.5 0 0 0 3-4",key:"10igwf"}],["path",{d:"M6.003 5.125A3 3 0 0 0 6.401 6.5",key:"105sqy"}],["path",{d:"M3.477 10.896a4 4 0 0 1 .585-.396",key:"ql3yin"}],["path",{d:"M6 18a4 4 0 0 1-1.967-.516",key:"2e4loj"}],["path",{d:"M12 13h4",key:"1ku699"}],["path",{d:"M12 18h6a2 2 0 0 1 2 2v1",key:"105ag5"}],["path",{d:"M12 8h8",key:"1lhi5i"}],["path",{d:"M16 8V5a2 2 0 0 1 2-2",key:"u6izg6"}],["circle",{cx:"16",cy:"13",r:".5",key:"ry7gng"}],["circle",{cx:"18",cy:"3",r:".5",key:"1aiba7"}],["circle",{cx:"20",cy:"21",r:".5",key:"yhc1fs"}],["circle",{cx:"20",cy:"8",r:".5",key:"1e43v0"}]]);const as=o("Brain",[["path",{d:"M12 5a3 3 0 1 0-5.997.125 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z",key:"l5xja"}],["path",{d:"M12 5a3 3 0 1 1 5.997.125 4 4 0 0 1 2.526 5.77 4 4 0 0 1-.556 6.588A4 4 0 1 1 12 18Z",key:"ep3f8r"}],["path",{d:"M15 13a4.5 4.5 0 0 1-3-4 4.5 4.5 0 0 1-3 4",key:"1p4c4q"}],["path",{d:"M17.599 6.5a3 3 0 0 0 .399-1.375",key:"tmeiqw"}],["path",{d:"M6.003 5.125A3 3 0 0 0 6.401 6.5",key:"105sqy"}],["path",{d:"M3.477 10.896a4 4 0 0 1 .585-.396",key:"ql3yin"}],["path",{d:"M19.938 10.5a4 4 0 0 1 .585.396",key:"1qfode"}],["path",{d:"M6 18a4 4 0 0 1-1.967-.516",key:"2e4loj"}],["path",{d:"M19.967 17.484A4 4 0 0 1 18 18",key:"159ez6"}]]);const ss=o("Calculator",[["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",key:"1nb95v"}],["line",{x1:"8",x2:"16",y1:"6",y2:"6",key:"x4nwl0"}],["line",{x1:"16",x2:"16",y1:"14",y2:"18",key:"wjye3r"}],["path",{d:"M16 10h.01",key:"1m94wz"}],["path",{d:"M12 10h.01",key:"1nrarc"}],["path",{d:"M8 10h.01",key:"19clt8"}],["path",{d:"M12 14h.01",key:"1etili"}],["path",{d:"M8 14h.01",key:"6423bh"}],["path",{d:"M12 18h.01",key:"mhygvu"}],["path",{d:"M8 18h.01",key:"lrp35t"}]]);const Rt=o("CalendarDays",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"M8 14h.01",key:"6423bh"}],["path",{d:"M12 14h.01",key:"1etili"}],["path",{d:"M16 14h.01",key:"1gbofw"}],["path",{d:"M8 18h.01",key:"lrp35t"}],["path",{d:"M12 18h.01",key:"mhygvu"}],["path",{d:"M16 18h.01",key:"kzsmim"}]]);const ns=o("ChartColumn",[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M18 17V9",key:"2bz60n"}],["path",{d:"M13 17V5",key:"1frdt8"}],["path",{d:"M8 17v-3",key:"17ska0"}]]);const rs=o("ChartLine",[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"m19 9-5 5-4-4-3 3",key:"2osh9i"}]]);const os=o("ChartNoAxesCombined",[["path",{d:"M12 16v5",key:"zza2cw"}],["path",{d:"M16 14v7",key:"1g90b9"}],["path",{d:"M20 10v11",key:"1iqoj0"}],["path",{d:"m22 3-8.646 8.646a.5.5 0 0 1-.708 0L9.354 8.354a.5.5 0 0 0-.707 0L2 15",key:"1fw8x9"}],["path",{d:"M4 18v3",key:"1yp0dc"}],["path",{d:"M8 14v7",key:"n3cwzv"}]]);const is=o("ChartPie",[["path",{d:"M21 12c.552 0 1.005-.449.95-.998a10 10 0 0 0-8.953-8.951c-.55-.055-.998.398-.998.95v8a1 1 0 0 0 1 1z",key:"pzmjnu"}],["path",{d:"M21.21 15.89A10 10 0 1 1 8 2.83",key:"k2fpak"}]]);const cs=o("ChartScatter",[["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}],["circle",{cx:"18.5",cy:"5.5",r:".5",fill:"currentColor",key:"lysivs"}],["circle",{cx:"11.5",cy:"11.5",r:".5",fill:"currentColor",key:"byv1b8"}],["circle",{cx:"7.5",cy:"16.5",r:".5",fill:"currentColor",key:"nkw3mc"}],["circle",{cx:"17.5",cy:"14.5",r:".5",fill:"currentColor",key:"1gjh6j"}],["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}]]);const ls=o("CircuitBoard",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M11 9h4a2 2 0 0 0 2-2V3",key:"1ve2rv"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"M7 21v-4a2 2 0 0 1 2-2h4",key:"1fwkro"}],["circle",{cx:"15",cy:"15",r:"2",key:"3i40o0"}]]);const ds=o("Cloud",[["path",{d:"M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z",key:"p7xjir"}]]);const ps=o("CodeXml",[["path",{d:"m18 16 4-4-4-4",key:"1inbqp"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}],["path",{d:"m14.5 4-5 16",key:"e7oirm"}]]);const hs=o("Copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);const ms=o("Cpu",[["rect",{width:"16",height:"16",x:"4",y:"4",rx:"2",key:"14l7u7"}],["rect",{width:"6",height:"6",x:"9",y:"9",rx:"1",key:"5aljv4"}],["path",{d:"M15 2v2",key:"13l42r"}],["path",{d:"M15 20v2",key:"15mkzm"}],["path",{d:"M2 15h2",key:"1gxd5l"}],["path",{d:"M2 9h2",key:"1bbxkp"}],["path",{d:"M20 15h2",key:"19e6y8"}],["path",{d:"M20 9h2",key:"19tzq7"}],["path",{d:"M9 2v2",key:"165o2o"}],["path",{d:"M9 20v2",key:"i2bqo8"}]]);const us=o("Database",[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]]);const ys=o("Dna",[["path",{d:"m10 16 1.5 1.5",key:"11lckj"}],["path",{d:"m14 8-1.5-1.5",key:"1ohn8i"}],["path",{d:"M15 2c-1.798 1.998-2.518 3.995-2.807 5.993",key:"80uv8i"}],["path",{d:"m16.5 10.5 1 1",key:"696xn5"}],["path",{d:"m17 6-2.891-2.891",key:"xu6p2f"}],["path",{d:"M2 15c6.667-6 13.333 0 20-6",key:"1pyr53"}],["path",{d:"m20 9 .891.891",key:"3xwk7g"}],["path",{d:"M3.109 14.109 4 15",key:"q76aoh"}],["path",{d:"m6.5 12.5 1 1",key:"cs35ky"}],["path",{d:"m7 18 2.891 2.891",key:"1sisit"}],["path",{d:"M9 22c1.798-1.998 2.518-3.995 2.807-5.993",key:"q3hbxp"}]]);const gs=o("Earth",[["path",{d:"M21.54 15H17a2 2 0 0 0-2 2v4.54",key:"1djwo0"}],["path",{d:"M7 3.34V5a3 3 0 0 0 3 3a2 2 0 0 1 2 2c0 1.1.9 2 2 2a2 2 0 0 0 2-2c0-1.1.9-2 2-2h3.17",key:"1tzkfa"}],["path",{d:"M11 21.95V18a2 2 0 0 0-2-2a2 2 0 0 1-2-2v-1a2 2 0 0 0-2-2H2.05",key:"14pb5j"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);const js=o("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 ks=o("FileChartColumnIncreasing",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M8 18v-2",key:"qcmpov"}],["path",{d:"M12 18v-4",key:"q1q25u"}],["path",{d:"M16 18v-6",key:"15y0np"}]]);const xs=o("FilePenLine",[["path",{d:"m18 5-2.414-2.414A2 2 0 0 0 14.172 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2",key:"142zxg"}],["path",{d:"M21.378 12.626a1 1 0 0 0-3.004-3.004l-4.01 4.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z",key:"2t3380"}],["path",{d:"M8 18h1",key:"13wk12"}]]);const fs=o("FileStack",[["path",{d:"M21 7h-3a2 2 0 0 1-2-2V2",key:"9rb54x"}],["path",{d:"M21 6v6.5c0 .8-.7 1.5-1.5 1.5h-7c-.8 0-1.5-.7-1.5-1.5v-9c0-.8.7-1.5 1.5-1.5H17Z",key:"1059l0"}],["path",{d:"M7 8v8.8c0 .3.2.6.4.8.2.2.5.4.8.4H15",key:"16874u"}],["path",{d:"M3 12v8.8c0 .3.2.6.4.8.2.2.5.4.8.4H11",key:"k2ox98"}]]);const vs=o("FlaskConical",[["path",{d:"M14 2v6a2 2 0 0 0 .245.96l5.51 10.08A2 2 0 0 1 18 22H6a2 2 0 0 1-1.755-2.96l5.51-10.08A2 2 0 0 0 10 8V2",key:"18mbvz"}],["path",{d:"M6.453 15h11.094",key:"3shlmq"}],["path",{d:"M8.5 2h7",key:"csnxdl"}]]);const bs=o("FolderArchive",[["circle",{cx:"15",cy:"19",r:"2",key:"u2pros"}],["path",{d:"M20.9 19.8A2 2 0 0 0 22 18V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2h5.1",key:"1jj40k"}],["path",{d:"M15 11v-1",key:"cntcp"}],["path",{d:"M15 17v-2",key:"1279jj"}]]);const Ms=o("FolderKanban",[["path",{d:"M4 20h16a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.93a2 2 0 0 1-1.66-.9l-.82-1.2A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13c0 1.1.9 2 2 2Z",key:"1fr9dc"}],["path",{d:"M8 10v4",key:"tgpxqk"}],["path",{d:"M12 10v2",key:"hh53o1"}],["path",{d:"M16 10v6",key:"1d6xys"}]]);const tt=o("FolderOpen",[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]]);const Cs=o("GraduationCap",[["path",{d:"M21.42 10.922a1 1 0 0 0-.019-1.838L12.83 5.18a2 2 0 0 0-1.66 0L2.6 9.08a1 1 0 0 0 0 1.832l8.57 3.908a2 2 0 0 0 1.66 0z",key:"j76jl0"}],["path",{d:"M22 10v6",key:"1lu8f3"}],["path",{d:"M6 12.5V16a6 3 0 0 0 12 0v-3.5",key:"1r8lef"}]]);const ws=o("History",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]]);const Ns=o("Image",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]]);const Ss=o("Languages",[["path",{d:"m5 8 6 6",key:"1wu5hv"}],["path",{d:"m4 14 6-6 2-3",key:"1k1g8d"}],["path",{d:"M2 5h12",key:"or177f"}],["path",{d:"M7 2h1",key:"1t2jsx"}],["path",{d:"m22 22-5-10-5 10",key:"don7ne"}],["path",{d:"M14 18h6",key:"1m8k6r"}]]);const zs=o("Library",[["path",{d:"m16 6 4 14",key:"ji33uf"}],["path",{d:"M12 6v14",key:"1n7gus"}],["path",{d:"M8 8v12",key:"1gg7y9"}],["path",{d:"M4 4v16",key:"6qkkli"}]]);const Ts=o("Lightbulb",[["path",{d:"M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5",key:"1gvzjb"}],["path",{d:"M9 18h6",key:"x1upvd"}],["path",{d:"M10 22h4",key:"ceow96"}]]);const Ps=o("Map",[["path",{d:"M14.106 5.553a2 2 0 0 0 1.788 0l3.659-1.83A1 1 0 0 1 21 4.619v12.764a1 1 0 0 1-.553.894l-4.553 2.277a2 2 0 0 1-1.788 0l-4.212-2.106a2 2 0 0 0-1.788 0l-3.659 1.83A1 1 0 0 1 3 19.381V6.618a1 1 0 0 1 .553-.894l4.553-2.277a2 2 0 0 1 1.788 0z",key:"169xi5"}],["path",{d:"M15 5.764v15",key:"1pn4in"}],["path",{d:"M9 3.236v15",key:"1uimfh"}]]);const As=o("Microscope",[["path",{d:"M6 18h8",key:"1borvv"}],["path",{d:"M3 22h18",key:"8prr45"}],["path",{d:"M14 22a7 7 0 1 0 0-14h-1",key:"1jwaiy"}],["path",{d:"M9 14h2",key:"197e7h"}],["path",{d:"M9 12a2 2 0 0 1-2-2V6h6v4a2 2 0 0 1-2 2Z",key:"1bmzmy"}],["path",{d:"M12 6V3a1 1 0 0 0-1-1H9a1 1 0 0 0-1 1v3",key:"1drr47"}]]);const Ds=o("Network",[["rect",{x:"16",y:"16",width:"6",height:"6",rx:"1",key:"4q2zg0"}],["rect",{x:"2",y:"16",width:"6",height:"6",rx:"1",key:"8cvhb9"}],["rect",{x:"9",y:"2",width:"6",height:"6",rx:"1",key:"1egb70"}],["path",{d:"M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3",key:"1jsf9p"}],["path",{d:"M12 12V8",key:"2874zd"}]]);const Ls=o("Newspaper",[["path",{d:"M4 22h16a2 2 0 0 0 2-2V4a2 2 0 0 0-2-2H8a2 2 0 0 0-2 2v16a2 2 0 0 1-2 2Zm0 0a2 2 0 0 1-2-2v-9c0-1.1.9-2 2-2h2",key:"7pis2x"}],["path",{d:"M18 14h-8",key:"sponae"}],["path",{d:"M15 18h-5",key:"95g1m2"}],["path",{d:"M10 6h8v4h-8V6Z",key:"smlsk5"}]]);const Es=o("NotebookPen",[["path",{d:"M13.4 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-7.4",key:"re6nr2"}],["path",{d:"M2 6h4",key:"aawbzj"}],["path",{d:"M2 10h4",key:"l0bgd4"}],["path",{d:"M2 14h4",key:"1gsvsf"}],["path",{d:"M2 18h4",key:"1bu2t1"}],["path",{d:"M21.378 5.626a1 1 0 1 0-3.004-3.004l-5.01 5.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z",key:"pqwjuv"}]]);const Is=o("PenTool",[["path",{d:"M15.707 21.293a1 1 0 0 1-1.414 0l-1.586-1.586a1 1 0 0 1 0-1.414l5.586-5.586a1 1 0 0 1 1.414 0l1.586 1.586a1 1 0 0 1 0 1.414z",key:"nt11vn"}],["path",{d:"m18 13-1.375-6.874a1 1 0 0 0-.746-.776L3.235 2.028a1 1 0 0 0-1.207 1.207L5.35 15.879a1 1 0 0 0 .776.746L13 18",key:"15qc1e"}],["path",{d:"m2.3 2.3 7.286 7.286",key:"1wuzzi"}],["circle",{cx:"11",cy:"11",r:"2",key:"xmgehs"}]]);const Fs=o("Presentation",[["path",{d:"M2 3h20",key:"91anmk"}],["path",{d:"M21 3v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V3",key:"2k9sn8"}],["path",{d:"m7 21 5-5 5 5",key:"bip4we"}]]);const qs=o("Quote",[["path",{d:"M16 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z",key:"rib7q0"}],["path",{d:"M5 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z",key:"1ymkrd"}]]);const $s=o("Regex",[["path",{d:"M17 3v10",key:"15fgeh"}],["path",{d:"m12.67 5.5 8.66 5",key:"1gpheq"}],["path",{d:"m12.67 10.5 8.66-5",key:"1dkfa6"}],["path",{d:"M9 17a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v2a2 2 0 0 0 2 2h2a2 2 0 0 0 2-2v-2z",key:"swwfx4"}]]);const Os=o("Rocket",[["path",{d:"M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09z",key:"m3kijz"}],["path",{d:"m12 15-3-3a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.35 22.35 0 0 1-4 2z",key:"1fmvmk"}],["path",{d:"M9 12H4s.55-3.03 2-4c1.62-1.08 5 0 5 0",key:"1f8sc4"}],["path",{d:"M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5",key:"qeys4"}]]);const Bs=o("Server",[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]]);const Us=o("ShieldCheck",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);const _t=o("Sparkles",[["path",{d:"M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .963 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.581a.5.5 0 0 1 0 .964L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.963 0z",key:"4pj2yx"}],["path",{d:"M20 3v4",key:"1olli1"}],["path",{d:"M22 5h-4",key:"1gvqau"}],["path",{d:"M4 17v2",key:"vumght"}],["path",{d:"M5 18H3",key:"zchphs"}]]);const Vs=o("StickyNote",[["path",{d:"M16 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V8Z",key:"qazsjp"}],["path",{d:"M15 3v4a2 2 0 0 0 2 2h4",key:"40519r"}]]);const Hs=o("Target",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"6",key:"1vlfrh"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]]);const Rs=o("Telescope",[["path",{d:"m10.065 12.493-6.18 1.318a.934.934 0 0 1-1.108-.702l-.537-2.15a1.07 1.07 0 0 1 .691-1.265l13.504-4.44",key:"k4qptu"}],["path",{d:"m13.56 11.747 4.332-.924",key:"19l80z"}],["path",{d:"m16 21-3.105-6.21",key:"7oh9d"}],["path",{d:"M16.485 5.94a2 2 0 0 1 1.455-2.425l1.09-.272a1 1 0 0 1 1.212.727l1.515 6.06a1 1 0 0 1-.727 1.213l-1.09.272a2 2 0 0 1-2.425-1.455z",key:"m7xp4m"}],["path",{d:"m6.158 8.633 1.114 4.456",key:"74o979"}],["path",{d:"m8 21 3.105-6.21",key:"1fvxut"}],["circle",{cx:"12",cy:"13",r:"2",key:"1c1ljs"}]]);const _s=o("Terminal",[["polyline",{points:"4 17 10 11 4 5",key:"akl6gq"}],["line",{x1:"12",x2:"20",y1:"19",y2:"19",key:"q2wloq"}]]);const Zs=o("TestTubeDiagonal",[["path",{d:"M21 7 6.82 21.18a2.83 2.83 0 0 1-3.99-.01a2.83 2.83 0 0 1 0-4L17 3",key:"1ub6xw"}],["path",{d:"m16 2 6 6",key:"1gw87d"}],["path",{d:"M12 16H4",key:"1cjfip"}]]);const Gs=o("TestTubes",[["path",{d:"M9 2v17.5A2.5 2.5 0 0 1 6.5 22A2.5 2.5 0 0 1 4 19.5V2",key:"1hjrqt"}],["path",{d:"M20 2v17.5a2.5 2.5 0 0 1-2.5 2.5a2.5 2.5 0 0 1-2.5-2.5V2",key:"16lc8n"}],["path",{d:"M3 2h7",key:"7s29d5"}],["path",{d:"M14 2h7",key:"7sicin"}],["path",{d:"M9 16H4",key:"1bfye3"}],["path",{d:"M20 16h-5",key:"ddnjpe"}]]);const Ks=o("University",[["circle",{cx:"12",cy:"10",r:"1",key:"1gnqs8"}],["path",{d:"M22 20V8h-4l-6-4-6 4H2v12a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2",key:"1qj5sn"}],["path",{d:"M6 17v.01",key:"roodi6"}],["path",{d:"M6 13v.01",key:"67c122"}],["path",{d:"M18 17v.01",key:"12ktxm"}],["path",{d:"M18 13v.01",key:"tn1rt1"}],["path",{d:"M14 22v-5a2 2 0 0 0-2-2a2 2 0 0 0-2 2v5",key:"11g7fi"}]]);const Ws=o("UsersRound",[["path",{d:"M18 21a8 8 0 0 0-16 0",key:"3ypg7q"}],["circle",{cx:"10",cy:"8",r:"5",key:"o932ke"}],["path",{d:"M22 20c0-3.37-2-6.5-4-8a5 5 0 0 0-.45-8.3",key:"10s06x"}]]);const Js=o("Workflow",[["rect",{width:"8",height:"8",x:"3",y:"3",rx:"2",key:"by2w9f"}],["path",{d:"M7 11v4a2 2 0 0 0 2 2h4",key:"xkn7yn"}],["rect",{width:"8",height:"8",x:"13",y:"13",rx:"2",key:"1cgmvn"}]]),Zt=["file-text","book-open","notebook-pen","book-marked","scroll-text","library","graduation-cap","presentation","image","folder-kanban","microscope","flask-conical","test-tube-diagonal","atom","dna","telescope","earth","map","languages","university","code-2","file-code-2","database","server","network","circuit-board","brain","brain-circuit","bot","shield-check","workflow","sigma","calculator","chart-no-axes-combined","line-chart","bar-chart-3","pie-chart","chart-scatter","file-spreadsheet","file-chart-column-increasing","lightbulb","rocket","target","sparkles","file-pen-line","file-stack","folder","folder-open","folder-archive","archive","bookmark","newspaper","notepad-text","sticky-note","pen-tool","quote","list-tree","file-search","beaker","test-tubes","folder-git-2","git-branch","terminal","braces","regex","cpu","hard-drive","cloud","users-round","calendar-days"],Qs=new Set(Zt);function Xs(s){return typeof s=="string"&&Qs.has(s)}function Ys(s){if(typeof s!="string")return null;const h=s.trim().replace(/^lucide:/i,"");return!h||h.length>96?null:/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(h)?h:null}const en={"file-text":Ea,"book-open":La,"notebook-pen":Es,"book-marked":Bt,"scroll-text":Da,library:zs,"graduation-cap":Cs,presentation:Fs,image:Ns,"folder-kanban":Ms,microscope:As,"flask-conical":vs,"test-tube-diagonal":Zs,atom:Ja,dna:ys,telescope:Rs,earth:gs,map:Ps,languages:Ss,university:Ks,"code-2":ps,"file-code-2":Aa,database:us,server:Bs,network:Ds,"circuit-board":ls,brain:as,"brain-circuit":ts,bot:Ya,"shield-check":Us,workflow:Js,sigma:Za,calculator:ss,"chart-no-axes-combined":os,"line-chart":rs,"bar-chart-3":ns,"pie-chart":is,"chart-scatter":cs,"file-spreadsheet":Pa,"file-chart-column-increasing":ks,lightbulb:Ts,rocket:Os,target:Hs,sparkles:_t,"file-pen-line":xs,"file-stack":fs,folder:Ta,"folder-open":tt,"folder-archive":bs,archive:st,bookmark:Xa,newspaper:Ls,"notepad-text":za,"sticky-note":Vs,"pen-tool":Is,quote:qs,"list-tree":Sa,"file-search":Na,beaker:Qa,"test-tubes":Gs,"folder-git-2":Ra,"git-branch":wa,terminal:_s,braces:es,regex:$s,cpu:ms,"hard-drive":Ca,cloud:ds,"users-round":Ws,"calendar-days":Rt},bn=Zt.map(s=>({name:s}));function tn(s){const h=Array.from(s.trim())[0];return h?h.toLocaleUpperCase():"?"}function an({icon:s,fallback:h,size:x=18}){const f=Xs(s)?en[s]:null;if(f)return e.jsx(f,{"aria-hidden":"true",size:x,strokeWidth:1.9});const v=Ys(s);if(v){const a=`url(${at(`/api/project-icons/${encodeURIComponent(v)}`)})`,g={maskImage:a,WebkitMaskImage:a};return e.jsx("span",{"aria-hidden":"true",className:"project-icon-external-glyph",style:g})}return e.jsx("span",{"aria-hidden":"true",children:h})}function Gt({icon:s,projectName:h,editable:x=!1,onEdit:f,editLabel:v,title:c,className:a=""}){const g=e.jsx(an,{icon:s,fallback:tn(h)}),m=`project-icon-avatar${x?" editable":""}${a?` ${a}`:""}`;return x&&f?e.jsx("button",{type:"button",className:m,title:v,"aria-label":v,onClick:f,children:g}):e.jsx("span",{className:m,title:c,"aria-hidden":"true",children:g})}function Kt({project:s,currentUser:h,showArchived:x,archiveBusy:f,menuOpen:v,t:c,variant:a,onToggleMenu:g,onCloseMenu:m,onAssignTags:y,onRename:E,onDuplicate:l,onArchive:z,onTransfer:B,onDelete:T}){const b=r.useRef(null),P=s.permission==="owner",F=h.role==="admin"||h.canCreateProjects,Z=s.ownerId===h.id,U=s.permission==="owner";r.useEffect(()=>{if(!v)return;const d=I=>{I.target instanceof Node&&!b.current?.contains(I.target)&&m()},D=I=>{I.key==="Escape"&&m()};return document.addEventListener("pointerdown",d),document.addEventListener("keydown",D),()=>{document.removeEventListener("pointerdown",d),document.removeEventListener("keydown",D)}},[v,m]);const A=[{id:"tags",label:c("tags.assign"),icon:e.jsx(et,{"aria-hidden":!0,size:15}),section:"main",onSelect:y},...P?[{id:"rename",label:c("projects.rename"),icon:e.jsx(Ia,{"aria-hidden":!0,size:15}),section:"main",onSelect:E}]:[],...F?[{id:"duplicate",label:c("projects.duplicate"),icon:e.jsx(hs,{"aria-hidden":!0,size:15}),section:"main",onSelect:l}]:[],{id:"download",label:c("projects.download"),icon:e.jsx(Fa,{"aria-hidden":!0,size:15}),section:"main",href:at(`/api/projects/${s.id}/download`)},{id:"archive",label:c(x?"projects.unarchive":"projects.archive"),icon:x?e.jsx(Ka,{"aria-hidden":!0,size:15}):e.jsx(st,{"aria-hidden":!0,size:15}),section:"main",disabled:f,onSelect:z},...Z?[{id:"transfer",label:c("projects.transfer"),icon:e.jsx(Ht,{"aria-hidden":!0,size:15}),section:"main",onSelect:B}]:[],...U?[{id:"delete",label:c("common.delete"),icon:e.jsx(qa,{"aria-hidden":!0,size:15}),section:"danger",onSelect:T}]:[]],ee=A.filter(d=>d.section==="main"),C=A.filter(d=>d.section==="danger"),ce=d=>{d.disabled||(m(),d.onSelect?.())};return e.jsxs("div",{ref:b,className:`project-action-menu-root project-action-menu-${a}`,onClick:d=>d.stopPropagation(),children:[e.jsx("button",{type:"button",className:"project-action-menu-trigger","aria-label":c("projects.projectActions",{project:s.name}),"aria-expanded":v,"aria-controls":`project-actions-${s.id}`,onClick:d=>{d.stopPropagation(),g()},children:e.jsx(js,{"aria-hidden":!0,size:19})}),v&&e.jsxs("div",{id:`project-actions-${s.id}`,className:"project-action-menu",role:"group","aria-label":c("projects.projectActions",{project:s.name}),children:[ee.map(d=>d.href?e.jsxs("a",{href:d.href,download:!0,onClick:D=>{D.stopPropagation(),m()},children:[d.icon,d.label]},d.id):e.jsxs("button",{type:"button",disabled:d.disabled,onClick:D=>{D.stopPropagation(),ce(d)},children:[d.icon,d.label]},d.id)),C.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"project-action-menu-separator","aria-hidden":"true"}),C.map(d=>e.jsxs("button",{type:"button",className:"danger",onClick:D=>{D.stopPropagation(),ce(d)},children:[d.icon,d.label]},d.id))]})]})]})}function sn({project:s,currentUser:h,showArchived:x,archiveBusy:f,menuOpen:v,t:c,formatCreatedDate:a,formatUpdatedTime:g,formatExactTime:m,onOpenProject:y,onOpenMention:E,onToggleMenu:l,onCloseMenu:z,onAssignTags:B,onRename:T,onDuplicate:b,onArchive:P,onTransfer:F,onDelete:Z,onChooseIcon:U}){const A=s.ownerDisplayName??s.ownerUsername??c("projects.deletedUser"),ee=s.lastModifiedDisplayName??s.lastModifiedUsername??c("projects.deletedUser");return e.jsxs("article",{className:`project-card project-list-row${s.ownerId===h.id?" owned-project":""}${v?" project-list-menu-open":""}`,onClick:C=>{C.target===C.currentTarget&&y()},children:[e.jsx(Gt,{icon:s.icon,projectName:s.name,title:s.name,editable:s.permission==="owner",editLabel:c("projectIcons.change"),onEdit:U,className:"project-list-avatar"}),e.jsx("span",{className:"project-list-summary",children:e.jsx("button",{type:"button",className:"project-list-cell-open project-list-summary-open",onClick:y,"aria-label":c("projects.openProject",{project:s.name}),children:e.jsxs("span",{className:"project-list-title-line",children:[e.jsx("strong",{className:"project-list-title",title:s.name,children:s.name}),!!(s.unresolvedCommentCount&&s.unresolvedCommentCount>0)&&e.jsxs("span",{className:"project-comments-badge unresolved",title:c("projects.unresolvedCommentsTooltip",{unresolved:s.unresolvedCommentCount,total:s.commentCount??s.unresolvedCommentCount}),children:[e.jsx(Ut,{"aria-hidden":!0,size:10}),e.jsx("span",{children:c("projects.unresolvedCount",{count:s.unresolvedCommentCount})})]}),s.tags?.length>0&&e.jsx("span",{className:"project-list-tags",children:s.tags.map(C=>e.jsx("span",{className:`tag tag-${C.color} project-list-tag`,title:C.name,children:C.name},C.id))})]})})}),e.jsxs("button",{type:"button",className:"project-list-cell-open project-list-owner",onClick:y,title:A,"aria-label":c("projects.openProject",{project:s.name}),children:[e.jsxs("span",{className:"sr-only",children:[c("projects.owner"),": "]}),A]}),e.jsxs("button",{type:"button",className:"project-list-cell-open project-list-created",onClick:y,title:m(s.createdAt),"aria-label":c("projects.openProject",{project:s.name}),children:[e.jsxs("span",{className:"sr-only",children:[c("projects.created"),": "]}),e.jsx("time",{dateTime:s.createdAt,children:a(s.createdAt)})]}),e.jsxs("button",{type:"button",className:"project-list-cell-open project-list-modified",onClick:y,title:c("projects.modifiedByUser",{time:m(s.updatedAt),user:ee}),"aria-label":c("projects.openProject",{project:s.name}),children:[e.jsxs("span",{className:"sr-only",children:[c("projects.modified"),": "]}),e.jsx("time",{dateTime:s.updatedAt,children:g(s.updatedAt)}),e.jsx("small",{children:c("projects.byUser",{user:ee})})]}),s.unreadMentionCount&&s.unreadMentionCount>0?e.jsxs("button",{className:"project-mentions-badge project-list-mentions",type:"button",title:c("projects.unreadMentionsTooltip",{count:s.unreadMentionCount}),onClick:E,children:[e.jsx(Vt,{"aria-hidden":!0,size:10}),e.jsx("span",{children:s.unreadMentionCount})]}):e.jsx("span",{className:"project-list-mentions"}),e.jsx(Kt,{variant:"list",project:s,currentUser:h,showArchived:x,archiveBusy:f,menuOpen:v,t:c,onToggleMenu:l,onCloseMenu:z,onAssignTags:B,onRename:T,onDuplicate:b,onArchive:P,onTransfer:F,onDelete:Z})]})}const nn=r.lazy(()=>ie(()=>import("./SystemMetricsDialog-D9dthbAB.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9]),import.meta.url).then(s=>({default:s.SystemMetricsDialog}))),rn=r.lazy(()=>ie(()=>import("./CitationLibraryDialog-C_333dTc.js"),__vite__mapDeps([10,1,2,3,11,6,12,13,14,9]),import.meta.url).then(s=>({default:s.CitationLibraryDialog}))),on=r.lazy(()=>ie(()=>import("./AdminUsers-DMsBqC48.js"),__vite__mapDeps([15,1,2,3,6,16,5,7,8,9]),import.meta.url).then(s=>({default:s.AdminUsers}))),cn=r.lazy(()=>ie(()=>import("./TagManagementDialog-S8zDQAaB.js"),__vite__mapDeps([17,1,2,3,12,6,13]),import.meta.url).then(s=>({default:s.TagManagementDialog}))),ln=r.lazy(()=>ie(()=>import("./ProjectIconPickerDialog-CaF7Kkda.js"),__vite__mapDeps([18,1,2,3,14,5,6,7,8,9]),import.meta.url).then(s=>({default:s.ProjectIconPickerDialog}))),dn=r.lazy(()=>ie(()=>import("./GitHubAccountDialog-IrB3M7nt.js"),__vite__mapDeps([19,1,2,3,7,6,20]),import.meta.url).then(s=>({default:s.GitHubAccountDialog})));function pn(s){return s instanceof Error&&s.name==="AbortError"}function hn(s,h,x,f){const v=new Date(s).getTime();if(!Number.isFinite(v))return s;const c=v-x,a=Math.abs(c),g=60*1e3,m=60*g,y=24*m,E=3*y;if(a>E){const T=Math.floor(a/y),b=c<0?"Past":"Future";return f(`projects.relativeDays${b}`,{days:T,hours:0,minutes:0})}if(a>=y){const T=Math.floor(a/y),b=Math.floor(a%y/m),P=c<0?"Past":"Future",F=b>0?"DaysHours":"Days";return f(`projects.relative${F}${P}`,{days:T,hours:b,minutes:0})}if(a>=m){const T=Math.floor(a/m),b=Math.floor(a%m/g),P=c<0?"Past":"Future",F=b>0?"HoursMinutes":"Hours";return f(`projects.relative${F}${P}`,{days:0,hours:T,minutes:b})}const l="minute",z=g,B=Math.sign(c)*Math.max(1,Math.floor(a/z));return new Intl.RelativeTimeFormat(h,{numeric:"always"}).format(B,l)}function mn(s){return s<1024?`${s} B`:s<1024*1024?`${(s/1024).toFixed(1)} KB`:`${(s/1024/1024).toFixed(1)} MB`}function un({site:s,user:h,initialData:x,onDataChange:f,onUser:v,onOpenProject:c}){const{t:a}=Ma(),[g,m]=r.useState(()=>x?.projects??[]),[y,E]=r.useState(()=>x?.tags??[]),[l,z]=r.useState(()=>x?.pagination??{page:1,pageSize:20,total:x?.projects.length??0,totalPages:x?.projects.length?1:0}),[B,T]=r.useState(!!x),[b,P]=r.useState(!1),[F,Z]=r.useState(!1),[U,A]=r.useState(!1),[ee,C]=r.useState(!1),[ce,d]=r.useState(""),[D,I]=r.useState(""),[nt,te]=r.useState(""),[rt,G]=r.useState(""),[ot,K]=r.useState(""),[Wt,le]=r.useState(""),[Jt,ke]=r.useState(!1),[xe,it]=r.useState(""),[W,ct]=r.useState(!1),[Qt,fe]=r.useState(!1),[Ve,He]=r.useState(""),[V,lt]=r.useState(null),[dt,H]=r.useState(""),[de,Re]=r.useState(null),[_e,ve]=r.useState(null),be=r.useRef(null),pt=r.useRef(null),[M,ht]=r.useState(!1),[R,Xt]=r.useState(""),[w,mt]=r.useState(""),[Me,Ze]=r.useState(!1),[Yt,Ge]=r.useState(!1),[J,Q]=r.useState(null),[ut,Ce]=r.useState(null),[Ke,pe]=r.useState(null),[we,Ne]=r.useState(""),[X,yt]=r.useState(!1),[Se,he]=r.useState(null),[ze,ae]=r.useState(""),[Te,gt]=r.useState(!1),[me,Pe]=r.useState(null),[Ae,jt]=r.useState(!1),[De,Le]=r.useState(null),[We,kt]=r.useState([]),[Ee,ue]=r.useState(""),[se,Ie]=r.useState(!1),[xt,ne]=r.useState(""),[ye,ea]=r.useState(()=>localStorage.getItem(Oe("texlite-project-view"))==="list"?"list":"grid"),[q,ta]=r.useState(()=>localStorage.getItem(Oe("texlite-project-sort"))==="created"?"created":"updated"),[u,aa]=r.useState(!1),[ft,vt]=r.useState(""),[Fe,_]=r.useState(null),[N,$]=r.useState(1),[sa,na]=r.useState(()=>Date.now()),[bt,ra]=r.useState(""),Je=r.useRef(0),ge=r.useRef(null),Mt=(t,n,i,p,k)=>`${t?"archived":"active"}|${n}|${i}|${p}|${k}`,Ct=Mt(u,N,R,w,q),je=(t,n,i,p,k)=>{const j=new URLSearchParams({page:String(n),pageSize:"20",sort:k});t&&j.set("archived","1"),i.trim()&&j.set("search",i.trim()),p&&j.set("tag",p);const O=Mt(t,n,i,p,k),Y=++Je.current;ge.current?.abort();const $e=new AbortController;return ge.current=$e,Promise.all([S(`/api/projects?${j.toString()}`,{signal:$e.signal}),S("/api/tags",{signal:$e.signal})]).then(([re,ja])=>{Y===Je.current&&(m(re.projects),E(ja.tags),z(re.pagination),$(re.pagination.page),T(!0),ra(O))}).catch(re=>{!pn(re)&&Y===Je.current&&d(L(re))}).finally(()=>{ge.current===$e&&(ge.current=null)})};r.useEffect(()=>(je(u,N,R,w,q),()=>ge.current?.abort()),[u,N,R,w,q]),r.useEffect(()=>{B&&!u&&bt===Ct&&f(g,y,l)},[g,y,l,B,bt,Ct,u]),r.useEffect(()=>{const t=window.setInterval(()=>na(Date.now()),6e4);return()=>window.clearInterval(t)},[]),r.useEffect(()=>{if(!Me)return;const t=i=>{i.target instanceof Node&&!pt.current?.contains(i.target)&&Ze(!1)},n=i=>{i.key==="Escape"&&Ze(!1)};return document.addEventListener("pointerdown",t),document.addEventListener("keydown",n),()=>{document.removeEventListener("pointerdown",t),document.removeEventListener("keydown",n)}},[Me]);const wt=t=>{_(null),ea(t),localStorage.setItem(Oe("texlite-project-view"),t)},oa=t=>{ta(t),$(1),localStorage.setItem(Oe("texlite-project-sort"),t)},Nt=t=>{aa(t),$(1)},St=t=>{mt(t),$(1)},zt=async()=>{if(!(!xe.trim()||W)){ct(!0),I("");try{const{project:t}=await S("/api/projects",{method:"POST",body:JSON.stringify({name:xe})});ke(!1),it("");const n=u||N!==1?g:[t,...g].slice(0,l.pageSize),i=u?l:{...l,total:l.total+1,totalPages:Math.ceil((l.total+1)/l.pageSize)};m(n),z(i),u||f(n,y,i),c(t.id)}catch(t){I(L(t))}finally{ct(!1)}}},ia=async()=>{if(!V)return;const t=V,n=s.maxUploadSizeMB;if(t.size>n*1024*1024)return H(a("errors.fileTooLarge",{size:n}));ht(!0),H(""),Re("uploading"),ve(0);const i=new FormData;i.append("file",t);try{const{project:p}=await ba(`/api/projects/import?name=${encodeURIComponent(Ve.trim())}`,i,{onProgress:(O,Y)=>{ve(Y?Math.min(99,Math.floor(O/Y*100)):null)},onUploadComplete:()=>{ve(null),Re("processing")}}),k=u||N!==1?g:[p,...g].slice(0,l.pageSize),j=u?l:{...l,total:l.total+1,totalPages:Math.ceil((l.total+1)/l.pageSize)};m(k),z(j),u||f(k,y,j),fe(!1),lt(null),He(""),c(p.id)}catch(p){H(L(p))}finally{ht(!1),Re(null),ve(null)}},Qe=t=>{if(!M){if(t&&!t.name.toLocaleLowerCase().endsWith(".zip")){H(a("errors.zipOnly"));return}H(""),lt(t),t&&!Ve&&He(t.name.replace(/\.zip$/i,""))}},ca=async()=>{await S("/api/auth/logout",{method:"POST"}),v(null)},la=async t=>{if(!J)return;const n=J.tags.some(i=>i.id===t.id);te("");try{const p=(await S(n?`/api/projects/${J.id}/tags/${t.id}`:`/api/projects/${J.id}/tags`,n?{method:"DELETE"}:{method:"POST",body:JSON.stringify({tagId:t.id})})).project;Q(p),m(k=>k.map(j=>j.id===p.id?p:j))}catch(i){te(L(i))}},da=t=>{E(n=>[...n,t].sort((i,p)=>i.name.localeCompare(p.name)))},pa=t=>{const n=i=>i.map(p=>p.id===t.id?t:p);E(i=>n(i).sort((p,k)=>p.name.localeCompare(k.name))),m(i=>i.map(p=>({...p,tags:n(p.tags)}))),Q(i=>i?{...i,tags:n(i.tags)}:null)},ha=t=>{E(n=>n.filter(i=>i.id!==t)),m(n=>n.map(i=>({...i,tags:i.tags.filter(p=>p.id!==t)}))),Q(n=>n?{...n,tags:n.tags.filter(i=>i.id!==t)}:null),mt(n=>n===t?"":n)},ma=async(t,n)=>{const i=await S(`/api/projects/${t}/icon`,{method:"PATCH",body:JSON.stringify({icon:n})});m(p=>{const k=p.map(j=>j.id===i.project.id?i.project:j);return q==="updated"?k.sort((j,O)=>O.updatedAt.localeCompare(j.updatedAt)||j.name.localeCompare(O.name)):k})},Tt=async()=>{if(!(!Ke||!we.trim()||X)){yt(!0),G("");try{const t=await S(`/api/projects/${Ke.id}`,{method:"PATCH",body:JSON.stringify({name:we})});m(n=>n.map(i=>i.id===t.project.id?t.project:i)),pe(null),Ne("")}catch(t){G(L(t))}finally{yt(!1)}}},Pt=async()=>{if(!(!Se||!ze.trim())){gt(!0),K("");try{await S(`/api/projects/${Se.id}/duplicate`,{method:"POST",body:JSON.stringify({name:ze})}),he(null),ae(""),je(u,N,R,w,q)}catch(t){K(L(t))}finally{gt(!1)}}},ua=async()=>{if(!(!me||Ae)){jt(!0),le("");try{await S(`/api/projects/${me.id}`,{method:"DELETE"}),m(k=>k.filter(j=>j.id!==me.id));const t=Math.max(0,l.total-1),n=Math.ceil(t/l.pageSize),i=n===0?1:Math.min(N,n),p={...l,page:i,total:t,totalPages:n};z(p),Pe(null),i!==N?$(i):je(u,N,R,w,q)}catch(t){le(L(t))}finally{jt(!1)}}},At=async t=>{Le(t),ue(""),kt([]),ne(""),Ie(!0);try{const n=await S("/api/users");kt(n.users.filter(i=>i.id!==t.ownerId))}catch(n){ne(L(n))}finally{Ie(!1)}},ya=async()=>{if(!(!De||!Ee)){Ie(!0),ne("");try{await S(`/api/projects/${De.id}/owner`,{method:"PUT",body:JSON.stringify({userId:Ee})}),Le(null),ue(""),je(u,N,R,w,q)}catch(t){ne(L(t))}finally{Ie(!1)}}},Dt=async t=>{const n=!u;vt(t.id),d("");try{await S(`/api/projects/${t.id}/archive`,{method:n?"PUT":"DELETE"});const i=g.filter(Y=>Y.id!==t.id);m(i);const p=Math.max(0,l.total-1),k=Math.ceil(p/l.pageSize),j=k===0?1:Math.min(N,k),O={...l,page:j,total:p,totalPages:k};z(O),u||f(i,y,O),j!==N?$(j):je(u,N,R,w,q)}catch(i){d(L(i))}finally{vt("")}},Lt=async t=>{try{const i=(await S(`/api/projects/${t.id}/mentions?unread=1&limit=1`)).mentions[0];c(t.id,i?.id)}catch(n){d(L(n))}},qe=g,Xe=t=>new Date(t).toLocaleString(Ye.resolvedLanguage),ga=t=>{const n=new Date(t);return Number.isFinite(n.getTime())?new Intl.DateTimeFormat(Ye.resolvedLanguage??"en",{year:"numeric",month:"2-digit",day:"2-digit"}).format(n):t},Et=t=>hn(t,Ye.resolvedLanguage??"en",sa,(n,i)=>a(n,i));return e.jsxs("div",{className:"page",children:[e.jsxs("header",{className:"topbar",children:[e.jsxs("a",{className:"brand-link",href:at("/"),"aria-label":s.siteName,children:[e.jsx("span",{className:"site-title",children:s.siteName}),e.jsx(ka,{siteName:s.siteName})]}),e.jsxs("div",{className:"top-actions",children:[h.role==="admin"&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{className:"ghost",onClick:()=>Z(!0),children:[e.jsx(Ga,{"aria-hidden":!0,size:14}),a("metrics.title")]}),e.jsxs("button",{className:`ghost${b?" top-return-action":""}`,onClick:()=>{P(t=>!t),A(!1)},children:[b?e.jsx(Ft,{"aria-hidden":!0,size:14}):e.jsx($a,{"aria-hidden":!0,size:14}),a(b?"users.back":"users.manage")]})]}),e.jsxs("button",{className:`ghost${U?" top-return-action":""}`,onClick:()=>{P(!1),A(t=>!t)},children:[U?e.jsx(Ft,{"aria-hidden":!0,size:14}):e.jsx(Bt,{"aria-hidden":!0,size:14}),a(U?"users.back":"citationLibrary.title")]}),e.jsx(xa,{compact:!0}),e.jsxs("button",{type:"button",className:"top-user-identity",title:a("account.openGithubSettings"),"aria-label":a("account.openGithubSettings"),onClick:()=>C(!0),children:[e.jsx("strong",{children:h.displayName}),e.jsxs("small",{children:[e.jsx(_a,{"aria-hidden":!0,size:11}),"@",h.username]})]}),e.jsx("button",{className:"ghost",onClick:ca,children:a("auth.logout")})]})]}),b?e.jsx("main",{className:"dashboard",children:e.jsx(It,{onClose:()=>P(!1),children:e.jsx(on,{currentUser:h,minPasswordLength:s.minPasswordLength})})}):U?e.jsx("main",{className:"dashboard citation-library-page-shell",children:e.jsx(It,{onClose:()=>A(!1),children:e.jsx(rn,{page:!0,open:!0,onOpenChange:A,onBack:()=>A(!1),currentUserId:h.id,maxBibtexBytes:s.maxCitationBibtexBytes})})}):e.jsxs("main",{className:"dashboard",children:[e.jsxs("div",{className:"section-title",children:[e.jsxs("div",{children:[e.jsxs("h1",{children:[e.jsx(tt,{"aria-hidden":!0,size:25}),a("projects.title")]}),e.jsx("p",{className:"muted",children:h.canCreateProjects?a("projects.subtitle"):a("projects.restricted")})]}),e.jsxs("div",{className:"section-actions",children:[e.jsxs("button",{onClick:()=>Ge(!0),children:[e.jsx(et,{"aria-hidden":!0,size:15}),a("tags.manage")]}),h.canCreateProjects&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:()=>{H(""),fe(!0)},children:[e.jsx(qt,{"aria-hidden":!0,size:15}),a("projects.upload")]}),e.jsxs("button",{className:"primary",onClick:()=>{I(""),ke(!0)},children:[e.jsx(Oa,{"aria-hidden":!0,size:15}),a("projects.new")]})]})]})]}),ce&&e.jsx("p",{className:"error",children:ce}),e.jsxs("div",{className:"project-catalog-layout",children:[e.jsxs("aside",{ref:pt,className:`project-tag-sidebar${w?" has-active-filter":""}`,children:[e.jsxs("button",{type:"button",className:"project-tag-toggle",title:a("projects.filterTags"),"aria-label":a("projects.filterTags"),"aria-expanded":Me,"aria-controls":"dashboard-tag-filters",onClick:()=>Ze(t=>!t),children:[e.jsxs("span",{className:"project-tag-toggle-copy",children:[e.jsx(et,{"aria-hidden":!0,size:15}),e.jsx("span",{children:a("projects.filterTags")})]}),e.jsx($t,{className:"project-tag-toggle-chevron","aria-hidden":!0,size:15})]}),Me&&e.jsxs("div",{id:"dashboard-tag-filters",className:"project-tag-filters",role:"group","aria-label":a("projects.filterTags"),children:[e.jsx("button",{type:"button",className:w?"":"active","aria-pressed":!w,onClick:()=>St(""),children:a("projects.allTags")}),y.length>0?y.map(t=>e.jsxs("button",{type:"button",className:w===t.id?"active":"",title:t.name,"aria-pressed":w===t.id,onClick:()=>St(w===t.id?"":t.id),children:[e.jsx(Ot,{color:t.color}),e.jsx("span",{children:t.name})]},t.id)):e.jsx("p",{className:"project-tag-empty",children:a("tags.none")})]})]}),e.jsxs("div",{className:"project-catalog-content",children:[e.jsxs("div",{className:"project-toolbar",children:[e.jsx("input",{type:"search",placeholder:a("projects.search"),value:R,onChange:t=>{Xt(t.target.value),$(1)}}),e.jsxs("div",{className:"project-scope",role:"tablist","aria-label":a("projects.scope"),children:[e.jsxs("button",{className:u?"":"active",onClick:()=>Nt(!1),role:"tab","aria-selected":!u,children:[e.jsx(tt,{size:14}),a("projects.active")]}),e.jsxs("button",{className:u?"active":"",onClick:()=>Nt(!0),role:"tab","aria-selected":u,children:[e.jsx(st,{size:14}),a("projects.archived")]})]}),e.jsxs("label",{className:"project-sort",children:[e.jsx(Wa,{size:14}),e.jsx("span",{children:a("projects.sortBy")}),e.jsxs("select",{value:q,onChange:t=>oa(t.target.value),children:[e.jsx("option",{value:"updated",children:a("projects.sortModified")}),e.jsx("option",{value:"created",children:a("projects.sortCreated")})]})]}),e.jsxs("div",{className:"view-toggle",children:[e.jsx("button",{className:ye==="grid"?"active":"",onClick:()=>wt("grid"),title:a("projects.grid"),children:"▦"}),e.jsx("button",{className:ye==="list"?"active":"",onClick:()=>wt("list"),title:a("projects.list"),children:"☷"})]})]}),e.jsxs("div",{className:`project-grid ${ye==="list"?"list-view":""}${Fe?" project-list-menu-active":""}`,children:[ye==="list"&&qe.length>0&&e.jsxs("div",{className:"project-list-header","aria-hidden":"true",children:[e.jsx("span",{className:"project-list-header-avatar"}),e.jsx("span",{children:a("projects.title")}),e.jsx("span",{children:a("projects.owner")}),e.jsx("span",{className:"project-list-header-created",children:a("projects.created")}),e.jsx("span",{children:a("projects.modified")}),e.jsx("span",{className:"project-list-header-mentions",children:a("projects.mentionsColumn")}),e.jsx("span",{className:"project-list-header-actions",children:a("projects.actions")})]}),ye==="list"?qe.map(t=>e.jsx(sn,{project:t,currentUser:h,showArchived:u,archiveBusy:ft===t.id,menuOpen:Fe===t.id,t:a,formatCreatedDate:ga,formatUpdatedTime:Et,formatExactTime:Xe,onOpenProject:()=>{_(null),c(t.id)},onOpenMention:()=>{Lt(t)},onToggleMenu:()=>_(n=>n===t.id?null:t.id),onCloseMenu:()=>_(n=>n===t.id?null:n),onAssignTags:()=>{te(""),Q(t)},onRename:()=>{G(""),pe(t),Ne(t.name)},onDuplicate:()=>{K(""),he(t),ae(`${t.name} (1)`)},onArchive:()=>{Dt(t)},onTransfer:()=>{At(t)},onDelete:()=>{Pe(t),le("")},onChooseIcon:()=>Ce(t)},t.id)):qe.map(t=>e.jsxs("article",{className:`project-card project-grid-card${t.ownerId===h.id?" owned-project":""}${Fe===t.id?" project-card-menu-open":""}`,role:"button",tabIndex:0,"aria-label":a("projects.openProject",{project:t.name}),onClick:()=>{_(null),c(t.id)},onKeyDown:n=>{n.target!==n.currentTarget||n.key!=="Enter"&&n.key!==" "||(n.preventDefault(),_(null),c(t.id))},children:[e.jsxs("div",{className:"project-card-meta-row",children:[e.jsxs("div",{className:"project-card-badges",children:[e.jsx("span",{className:"owner-badge",title:t.ownerDisplayName??t.ownerUsername??a("projects.deletedUser"),children:t.ownerDisplayName??t.ownerUsername??a("projects.deletedUser")}),!!(t.unreadMentionCount&&t.unreadMentionCount>0)&&e.jsxs("button",{className:"project-mentions-badge",type:"button",title:a("projects.unreadMentionsTooltip",{count:t.unreadMentionCount}),"aria-label":a("projects.unreadMentionsTooltip",{count:t.unreadMentionCount}),onClick:n=>{n.stopPropagation(),Lt(t)},children:[e.jsx(Vt,{"aria-hidden":!0,size:11}),e.jsx("span",{children:t.unreadMentionCount})]})]}),e.jsx(Kt,{variant:"grid",project:t,currentUser:h,showArchived:u,archiveBusy:ft===t.id,menuOpen:Fe===t.id,t:a,onToggleMenu:()=>_(n=>n===t.id?null:t.id),onCloseMenu:()=>_(n=>n===t.id?null:n),onAssignTags:()=>{te(""),Q(t)},onRename:()=>{G(""),pe(t),Ne(t.name)},onDuplicate:()=>{K(""),he(t),ae(`${t.name} (1)`)},onArchive:()=>{Dt(t)},onTransfer:()=>{At(t)},onDelete:()=>{Pe(t),le("")}})]}),e.jsxs("div",{className:"project-card-title-row",children:[e.jsx("span",{className:"project-card-icon-control",onClick:t.permission==="owner"?n=>n.stopPropagation():void 0,children:e.jsx(Gt,{icon:t.icon,projectName:t.name,title:t.name,editable:t.permission==="owner",editLabel:a("projectIcons.change"),onEdit:()=>Ce(t),className:"project-card-icon"})}),e.jsx("strong",{className:"project-card-title",title:t.name,children:t.name})]}),e.jsx("div",{className:"project-card-tags","aria-label":a("tags.assignTitle",{project:t.name}),title:t.tags?.map(n=>n.name).join(", ")||void 0,children:t.tags?.map(n=>e.jsx("span",{className:`tag tag-${n.color}`,title:n.name,children:n.name},n.id))}),e.jsxs("dl",{className:"project-meta",children:[e.jsxs("div",{children:[e.jsxs("dt",{className:"project-meta-created-label",children:[e.jsxs("span",{children:[e.jsx(Rt,{"aria-hidden":!0,size:13}),a("projects.created")]}),!!(t.unresolvedCommentCount&&t.unresolvedCommentCount>0)&&e.jsxs("span",{className:"project-comments-badge unresolved",title:a("projects.unresolvedCommentsTooltip",{unresolved:t.unresolvedCommentCount,total:t.commentCount??t.unresolvedCommentCount}),children:[e.jsx(Ut,{"aria-hidden":!0,size:11}),e.jsx("span",{children:a("projects.unresolvedCount",{count:t.unresolvedCommentCount})})]})]}),e.jsx("dd",{children:e.jsx("time",{dateTime:t.createdAt,children:Xe(t.createdAt)})})]}),e.jsxs("div",{children:[e.jsxs("dt",{children:[e.jsx(ws,{"aria-hidden":!0,size:13}),a("projects.modified")]}),e.jsxs("dd",{title:a("projects.modifiedByUser",{time:Xe(t.updatedAt),user:t.lastModifiedDisplayName??t.lastModifiedUsername??a("projects.deletedUser")}),children:[e.jsx("time",{dateTime:t.updatedAt,children:Et(t.updatedAt)}),e.jsxs("span",{className:"project-modified-by",children:[" · ",a("projects.byUser",{user:t.lastModifiedDisplayName??t.lastModifiedUsername??a("projects.deletedUser")})]})]})]})]})]},t.id)),qe.length===0&&(g.length===0?u?e.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(_t,{size:28})}),e.jsx("h2",{children:a("projects.emptyTitle")}),e.jsx("p",{children:h.canCreateProjects?a("projects.emptyDescription"):a("projects.emptyRestricted")})]}):e.jsx("div",{className:"empty",children:a("projects.noMatches")}))]}),l.totalPages>1&&e.jsxs("nav",{className:"project-pagination","aria-label":a("projects.pagination"),children:[e.jsxs("button",{disabled:l.page<=1,onClick:()=>$(t=>Math.max(1,t-1)),title:a("projects.previousPage"),children:[e.jsx(Ba,{size:15}),a("projects.previousPage")]}),e.jsx("span",{children:a("projects.pageOf",{page:l.page,totalPages:l.totalPages,count:l.total})}),e.jsxs("button",{disabled:l.page>=l.totalPages,onClick:()=>$(t=>Math.min(l.totalPages,t+1)),title:a("projects.nextPage"),children:[e.jsx($t,{size:15}),a("projects.nextPage")]})]})]})]}),e.jsx(oe,{open:Jt,title:a("projects.new"),description:a("projects.newDescription"),onOpenChange:t=>{!t&&W||(ke(t),t||I(""))},footer:e.jsxs(e.Fragment,{children:[e.jsx("button",{disabled:W,onClick:()=>ke(!1),children:a("common.cancel")}),e.jsxs("button",{className:"primary",disabled:W||!xe.trim(),"aria-busy":W,onClick:()=>{zt()},children:[W&&e.jsx(Be,{className:"spin",size:14}),a(W?"common.loading":"common.create")]})]}),children:e.jsxs(e.Fragment,{children:[D&&e.jsx("p",{className:"error dialog-error",children:D}),e.jsxs("label",{className:"form-field",children:[a("projects.name"),e.jsx("input",{autoFocus:!0,value:xe,onChange:t=>{it(t.target.value),I("")},onKeyDown:t=>{t.key==="Enter"&&zt()}})]})]})}),e.jsx(oe,{open:Qt,title:a("projects.upload"),description:a("projects.uploadDescription",{size:s.maxUploadSizeMB}),onOpenChange:t=>{!t&&M||(fe(t),t||H(""))},footer:e.jsxs(e.Fragment,{children:[e.jsx("button",{disabled:M,onClick:()=>{fe(!1),H("")},children:a("common.cancel")}),e.jsxs("button",{className:"primary",disabled:!V||M,"aria-busy":M,onClick:()=>{ia()},children:[M&&e.jsx(Be,{className:"spin",size:14}),a(M?de==="processing"?"projects.processing":"projects.uploading":"projects.import")]})]}),children:e.jsxs("div",{className:"form-stack",children:[dt&&e.jsx("p",{className:"error import-error",children:dt}),e.jsxs("div",{className:`upload-picker${V?" has-file":""}${M?" is-disabled":""}`,onDragOver:t=>{t.preventDefault(),M||(t.dataTransfer.dropEffect="copy")},onDrop:t=>{t.preventDefault(),M||Qe(t.dataTransfer.files[0]??null)},children:[e.jsx("input",{ref:be,className:"sr-only",type:"file",accept:".zip,application/zip",disabled:M,onChange:t=>Qe(t.target.files?.[0]??null)}),e.jsx(Ua,{size:34}),e.jsxs("div",{className:"upload-picker-copy",children:[e.jsx("strong",{children:V?.name??a("projects.chooseZip")}),e.jsx("span",{children:V?a("projects.selectedFileSize",{size:mn(V.size)}):a("projects.dropZip")})]}),e.jsxs("button",{type:"button",disabled:M,onClick:()=>be.current?.click(),children:[e.jsx(qt,{size:15}),a("projects.browse")]}),V&&e.jsx("button",{className:"upload-clear",type:"button",disabled:M,title:a("projects.clearFile"),"aria-label":a("projects.clearFile"),onClick:()=>{Qe(null),be.current&&(be.current.value="")},children:e.jsx(Va,{size:14})})]}),e.jsxs("label",{className:"form-field",children:[a("projects.name"),e.jsx("input",{disabled:M,value:Ve,onChange:t=>He(t.target.value)})]}),M&&e.jsxs("div",{className:"project-import-progress",role:"status","aria-live":"polite",children:[e.jsxs("div",{className:"project-import-progress-label",children:[e.jsx("span",{children:a(de==="processing"?"projects.processing":"projects.uploading")}),de==="uploading"&&_e!==null&&e.jsxs("small",{"aria-hidden":"true",children:[_e,"%"]})]}),e.jsx("progress",{"aria-label":a("projects.uploadProgress"),max:100,value:de==="uploading"?_e??void 0:void 0}),de==="processing"&&e.jsx("small",{className:"import-progress-hint",children:a("projects.processingHint")})]})]})}),Yt&&e.jsx(Ue,{title:a("tags.manage"),onClose:()=>Ge(!1),children:e.jsx(cn,{open:!0,onOpenChange:Ge,onTagCreated:da,onTagUpdated:pa,onTagDeleted:ha})}),ut&&e.jsx(Ue,{title:a("projectIcons.title"),onClose:()=>Ce(null),children:e.jsx(ln,{project:ut,open:!0,onOpenChange:t=>{t||Ce(null)},onSave:ma})}),e.jsx(oe,{open:!!J,title:a("tags.assignTitle",{project:J?.name??""}),description:a("tags.assignDescription"),onOpenChange:t=>{t||(Q(null),te(""))},footer:e.jsx("button",{onClick:()=>{Q(null),te("")},children:a("common.close")}),children:e.jsxs("div",{className:"tag-assignment-list",children:[nt&&e.jsx("p",{className:"error dialog-error",children:nt}),y.map(t=>e.jsxs("label",{children:[e.jsx("input",{type:"checkbox",checked:!!J?.tags.some(n=>n.id===t.id),onChange:()=>{la(t)}}),e.jsx(Ot,{color:t.color}),e.jsx("span",{children:t.name})]},t.id)),y.length===0&&e.jsx("p",{className:"muted",children:a("tags.empty")})]})}),e.jsx(oe,{open:!!Ke,title:a("projects.renameTitle"),onOpenChange:t=>{!t&&X||t||(pe(null),G(""))},footer:e.jsxs(e.Fragment,{children:[e.jsx("button",{disabled:X,onClick:()=>{pe(null),G("")},children:a("common.cancel")}),e.jsxs("button",{className:"primary",disabled:X||!we.trim(),"aria-busy":X,onClick:()=>{Tt()},children:[X&&e.jsx(Be,{className:"spin",size:14}),a(X?"common.loading":"projects.rename")]})]}),children:e.jsxs(e.Fragment,{children:[rt&&e.jsx("p",{className:"error dialog-error",children:rt}),e.jsxs("label",{className:"form-field",children:[a("projects.name"),e.jsx("input",{autoFocus:!0,value:we,onChange:t=>{Ne(t.target.value),G("")},onKeyDown:t=>{t.key==="Enter"&&Tt()}})]})]})}),e.jsx(oe,{open:!!Se,title:a("projects.duplicateTitle"),description:a("projects.duplicateDescription",{project:Se?.name??""}),onOpenChange:t=>{!t&&!Te&&(he(null),ae(""),K(""))},footer:e.jsxs(e.Fragment,{children:[e.jsx("button",{disabled:Te,onClick:()=>{he(null),ae(""),K("")},children:a("common.cancel")}),e.jsx("button",{className:"primary",disabled:Te||!ze.trim(),onClick:()=>{Pt()},children:a(Te?"projects.duplicating":"projects.duplicate")})]}),children:e.jsxs(e.Fragment,{children:[ot&&e.jsx("p",{className:"error dialog-error",children:ot}),e.jsxs("label",{className:"form-field",children:[a("projects.name"),e.jsx("input",{autoFocus:!0,value:ze,onChange:t=>{ae(t.target.value),K("")},onKeyDown:t=>{t.key==="Enter"&&Pt()}})]})]})}),e.jsx(oe,{open:!!De,title:a("projects.transferOwnership"),description:a("projects.transferDescription",{project:De?.name??""}),onOpenChange:t=>{!t&&!se&&(Le(null),ue(""),ne(""))},footer:e.jsxs(e.Fragment,{children:[e.jsx("button",{disabled:se,onClick:()=>{Le(null),ue(""),ne("")},children:a("common.cancel")}),e.jsxs("button",{className:"primary",disabled:se||!Ee,onClick:()=>{ya()},children:[se?e.jsx(Be,{className:"spin",size:14}):e.jsx(Ht,{size:14}),a("projects.transfer")]})]}),children:e.jsxs("div",{className:"form-stack",children:[xt&&e.jsx("p",{className:"error dialog-error",children:xt}),e.jsxs("label",{className:"form-field",children:[a("projects.newOwner"),e.jsxs("select",{disabled:se||We.length===0,value:Ee,onChange:t=>ue(t.target.value),children:[e.jsx("option",{value:"",children:se?a("common.loading"):We.length>0?a("projects.chooseNewOwner"):a("projects.noTransferUsers")}),We.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(Ha,{size:15}),a("projects.transferWarning")]})]})}),e.jsx(fa,{open:!!me,title:a("projects.deleteTitle"),description:a("projects.deleteDescription",{project:me?.name??""}),confirmLabel:a(Ae?"common.loading":"common.delete"),danger:!0,busy:Ae,error:Wt,onCancel:()=>{Ae||(Pe(null),le(""))},onConfirm:()=>{ua()}})]}),F&&e.jsx(Ue,{title:a("metrics.title"),onClose:()=>Z(!1),children:e.jsx(nn,{open:!0,onOpenChange:Z})}),ee&&e.jsx(Ue,{title:a("account.githubTitle"),onClose:()=>C(!1),children:e.jsx(dn,{open:!0,onOpenChange:C})}),e.jsx(va,{})]})}function Ot({color:s}){return e.jsx("span",{className:`tag-dot tag-${s}`})}const Mn=Object.freeze(Object.defineProperty({__proto__:null,Dashboard:un},Symbol.toStringTag,{value:"Module"}));export{Ga as A,Mn as D,an as P,Us as S,tn as a,Xs as i,Ys as n,bn as p};
@@ -0,0 +1,3 @@
1
+ import{u as fe,r as a,j as e}from"./react-BVUjbTTn.js";import{c as y,M as L,d as j,g}from"./index-Dik-2GCl.js";import{G,C as I}from"./x-BJOMjm8Z.js";import{G as ee,F as xe}from"./github-B_Eh2y6s.js";import{C as te,R as pe}from"./ProjectWorkspace-D9zmy0KR.js";import{E as je}from"./external-link-C2GCFJxP.js";import{M as ye,a as be}from"./minus-Dzy8rgfA.js";import{P as Ce}from"./plus-DlX82JCl.js";import{M as ke}from"./minimize-2-CmPZ9Iwp.js";import"./check-Hv1kodh8.js";import"./search-DMqOy-Ex.js";import"./user-plus-Bcq_EsqH.js";import"./refresh-cw-BWndInnG.js";const ve=y("CloudUpload",[["path",{d:"M12 13v8",key:"1l5pq0"}],["path",{d:"M4 14.899A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.242",key:"1pljnt"}],["path",{d:"m8 17 4-4 4 4",key:"1quai1"}]]);const Ne=y("EyeOff",[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);const H=y("Eye",[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);const se=y("GitCommitHorizontal",[["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}],["line",{x1:"3",x2:"9",y1:"12",y2:"12",key:"1dyftd"}],["line",{x1:"15",x2:"21",y1:"12",y2:"12",key:"oup4p8"}]]);const we=y("Undo2",[["path",{d:"M9 14 4 9l5-5",key:"102s5s"}],["path",{d:"M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11",key:"f3b9sd"}]]);function He({open:l,project:o,onOpenChange:b,onBeforeMutation:r}){const{t,i18n:S}=fe(),[i,C]=a.useState(null),[B,E]=a.useState([]),[F,A]=a.useState(()=>ie(o.name)),[W,ae]=a.useState(!0),[D,q]=a.useState(""),[u,k]=a.useState(null),[f,p]=a.useState(null),[U,T]=a.useState(!1),[ne,v]=a.useState(!1),[M,J]=a.useState(!0),[$,O]=a.useState(!0),[c,N]=a.useState(""),[V,w]=a.useState(""),[_,R]=a.useState(""),[d,m]=a.useState(!1),[z,K]=a.useState(10),P=a.useRef(null),oe=async(s=!1)=>{const n=await g(`/api/projects/${o.id}/git`);if(C(n.status),s&&(J(!n.status.tokenConfigured),O(!n.status.remoteUrl)),n.status.initialized&&n.status.latestCommit){const h=await g(`/api/projects/${o.id}/git/history`);E(h.commits)}else E([])};a.useEffect(()=>{if(!l){document.fullscreenElement&&document.exitFullscreen().catch(()=>{}),m(!1);return}w(""),R(""),k(null),m(!1),A(ie(o.name)),N("load"),r().then(()=>oe(!0)).catch(s=>w(s instanceof Error?s.message:t("errors.generic"))).finally(()=>N(""))},[l,o.id]),a.useEffect(()=>{const s=()=>m(document.fullscreenElement===P.current);return document.addEventListener("fullscreenchange",s),()=>document.removeEventListener("fullscreenchange",s)},[]),a.useEffect(()=>{if(!d)return;const s=n=>{n.key==="Escape"&&!document.fullscreenElement&&m(!1)};return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[d]);const x=async(s,n,h,Q)=>{N(s),w(""),R("");try{await n(),h&&R(h)}catch(X){const Y=X instanceof Error?X.message:t("errors.generic");w(Q?`${Q}: ${Y}`:Y)}finally{N("")}},re=()=>x("repository",async()=>{const s=await g(`/api/projects/${o.id}/git/repository`,{method:"POST",body:JSON.stringify({name:F,private:W})});C(s.status),O(!1)},t("git.repositoryCreated")),ce=()=>x("commit",async()=>{if(!await r())throw new Error(t("errors.collaborationUnavailable"));const s=await g(`/api/projects/${o.id}/git/commit`,{method:"POST",body:JSON.stringify({message:D})});C(s.status),E(n=>[s.commit,...n.filter(h=>h.sha!==s.commit.sha)].slice(0,100)),q(""),k(null)},t("git.committed"),t("git.commitFailed")),le=()=>x("push",async()=>{if(!await r())throw new Error(t("errors.collaborationUnavailable"));const s=await g(`/api/projects/${o.id}/git/push`,{method:"POST"});C(s.status)},t("git.pushed"),t("git.pushFailed")),Z=s=>x("diff",async()=>{if(!await r())throw new Error(t("errors.collaborationUnavailable"));const n=s?`?revision=${encodeURIComponent(s)}`:"",h=await g(`/api/projects/${o.id}/git/diff${n}`);k({...h,revision:s})}),de=s=>{if(u?.revision===s){k(null),m(!1),document.fullscreenElement&&document.exitFullscreen().catch(()=>{});return}Z(s)},he=async()=>{if(d){document.fullscreenElement&&await document.exitFullscreen().catch(()=>{}),m(!1);return}const s=P.current;if(s?.requestFullscreen)try{await s.requestFullscreen()}catch{}m(!0)},ge=()=>{const s=f;s&&(p(null),x("checkout",async()=>{if(!await r())throw new Error(t("errors.collaborationUnavailable"));await g(`/api/projects/${o.id}/git/checkout`,{method:"POST",body:JSON.stringify({revision:s==="branch"?null:s.sha,force:U})}),window.location.reload()}))},me=()=>{v(!1),x("discard",async()=>{if(!await r())throw new Error(t("errors.collaborationUnavailable"));await g(`/api/projects/${o.id}/git/discard`,{method:"POST"}),window.location.reload()})},ue=c==="load"&&!i;return e.jsxs(e.Fragment,{children:[e.jsx(L,{open:l,extraWide:!0,className:d?"git-dialog-modal-fullscreen":void 0,title:t("git.title"),description:t("git.description"),onOpenChange:b,footer:e.jsx("button",{onClick:()=>b(!1),children:t("common.close")}),children:e.jsxs("div",{className:"git-dialog",children:[ue&&e.jsxs("div",{className:"git-loading",children:[e.jsx(j,{className:"spin",size:22}),t("common.loading")]}),V&&e.jsx("p",{className:"git-message error",role:"alert",children:V}),_&&e.jsxs("p",{className:"git-message success",role:"status",children:[e.jsx(G,{size:14}),_]}),i&&e.jsxs(e.Fragment,{children:[e.jsxs("section",{className:"git-section",children:[e.jsxs("button",{className:"git-section-toggle",type:"button","aria-expanded":M,onClick:()=>J(s=>!s),children:[e.jsxs("span",{className:"git-section-heading",children:[e.jsx(ee,{size:16}),e.jsxs("span",{children:[e.jsx("strong",{children:t("git.authentication")}),e.jsx("small",{children:i.tokenConfigured?t("git.connectedAs",{login:i.githubLogin}):t("git.authenticationHint")})]})]}),M?e.jsx(te,{size:16}):e.jsx(I,{size:16})]}),M&&e.jsx("div",{className:"git-section-content",children:e.jsx("p",{className:"git-account-guidance",children:i.tokenConfigured?t("git.accountTokenManaged",{login:i.githubLogin}):t("git.accountTokenMissing")})})]}),e.jsxs("section",{className:"git-section",children:[e.jsxs("button",{className:"git-section-toggle",type:"button","aria-expanded":$,onClick:()=>O(s=>!s),children:[e.jsxs("span",{className:"git-section-heading",children:[e.jsx(xe,{size:16}),e.jsxs("span",{children:[e.jsx("strong",{children:t("git.repository")}),e.jsx("small",{children:i.remoteUrl?i.repositoryName??i.remoteUrl:i.initialized?t("git.localReady"):t("git.localPending")})]})]}),$?e.jsx(te,{size:16}):e.jsx(I,{size:16})]}),$&&e.jsx("div",{className:"git-section-content",children:i.remoteUrl?e.jsxs("div",{className:"git-repository-card",children:[e.jsxs("div",{children:[e.jsx("strong",{children:i.repositoryName??t("git.origin")}),e.jsxs("small",{children:[i.branch??t("git.detachedAt",{revision:i.latestCommit?.shortSha??"HEAD"})," · ",i.dirty?t("git.changedFiles",{count:i.changedFiles}):t("git.clean")]})]}),i.repositoryHtmlUrl&&e.jsxs("a",{href:i.repositoryHtmlUrl,target:"_blank",rel:"noreferrer",children:[e.jsx(je,{size:14}),t("git.openGitHub")]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"form-field",children:[t("git.repositoryName"),e.jsx("input",{value:F,onChange:s=>A(s.target.value)})]}),e.jsxs("label",{className:"checkbox-field",children:[e.jsx("input",{type:"checkbox",checked:W,onChange:s=>ae(s.target.checked)}),t("git.privateRepository")]}),e.jsxs("button",{className:"git-primary-action",disabled:!!c||!i.tokenConfigured||!F.trim(),onClick:re,children:[c==="repository"?e.jsx(j,{className:"spin",size:14}):e.jsx(ee,{size:14}),t("git.createRepository")]})]})})]}),i.initialized&&e.jsxs("section",{className:"git-section",children:[e.jsxs("div",{className:"git-section-heading",children:[e.jsx(se,{size:16}),e.jsxs("div",{children:[e.jsx("strong",{children:t("git.commitAndPush")}),e.jsx("small",{children:i.branch?t("git.identity",{username:o.ownerUsername}):t("git.detachedHead")})]})]}),e.jsxs("label",{className:"form-field",children:[t("git.commitMessage"),e.jsx("textarea",{rows:3,value:D,placeholder:t("git.commitPlaceholder"),onChange:s=>q(s.target.value)})]}),e.jsxs("div",{className:"git-action-row",children:[e.jsxs("button",{title:i.dirty?void 0:t("git.noChangesToCommit"),disabled:!!c||!i.branch||!i.dirty||!D.trim(),onClick:ce,children:[c==="commit"?e.jsx(j,{className:"spin",size:14}):e.jsx(se,{size:14}),t("git.commit")]}),e.jsxs("button",{title:i.ahead===0&&i.branch&&i.remoteUrl&&i.tokenConfigured&&i.latestCommit?t("git.noUnpushedCommits"):void 0,disabled:!!c||!i.branch||!i.tokenConfigured||!i.remoteUrl||!i.latestCommit||i.ahead===0,onClick:le,children:[c==="push"?e.jsx(j,{className:"spin",size:14}):e.jsx(ve,{size:14}),t("git.push"),i.ahead>0&&e.jsx("span",{className:"git-count",children:i.ahead})]}),e.jsxs("button",{disabled:!!c||!i.latestCommit,onClick:()=>{Z()},children:[c==="diff"?e.jsx(j,{className:"spin",size:14}):e.jsx(H,{size:14}),t("git.workingDiff")]}),e.jsxs("button",{className:"git-discard-button",title:i.restorable?t("git.discardChanges"):t("git.noChangesToDiscard"),disabled:!!c||!i.latestCommit||!i.restorable,onClick:()=>v(!0),children:[e.jsx(pe,{size:14}),t("git.discardChanges")]}),!i.branch&&e.jsxs("button",{disabled:!!c,onClick:()=>{T(!1),p("branch")},children:[e.jsx(G,{size:14}),t("git.returnToBranch",{branch:i.defaultBranch})]})]})]}),u&&e.jsxs("section",{ref:P,className:`git-section git-diff-section${d?" is-fullscreen":""}`,children:[e.jsxs("div",{className:"git-diff-heading",children:[e.jsxs("div",{className:"git-section-heading",children:[e.jsx(H,{size:16}),e.jsxs("div",{children:[e.jsx("strong",{children:t("git.diffTitle")}),e.jsxs("small",{children:[u.title,u.truncated?` · ${t("git.diffTruncated")}`:""]})]})]}),e.jsxs("div",{className:"git-diff-controls",children:[e.jsxs("div",{className:"git-diff-font-controls",role:"group","aria-label":t("git.diffFontSize"),children:[e.jsx("button",{type:"button",className:"git-diff-font-button",disabled:z<=8,title:t("git.diffFontDecrease"),"aria-label":t("git.diffFontDecrease"),onClick:()=>K(s=>Math.max(8,s-1)),children:e.jsx(ye,{size:14})}),e.jsxs("span",{className:"git-diff-font-value","aria-live":"polite",children:[z,"px"]}),e.jsx("button",{type:"button",className:"git-diff-font-button",disabled:z>=24,title:t("git.diffFontIncrease"),"aria-label":t("git.diffFontIncrease"),onClick:()=>K(s=>Math.min(24,s+1)),children:e.jsx(Ce,{size:14})})]}),e.jsx("button",{type:"button",className:"git-diff-fullscreen",title:t(d?"git.exitFullscreenDiff":"git.fullscreenDiff"),"aria-label":t(d?"git.exitFullscreenDiff":"git.fullscreenDiff"),onClick:()=>{he()},children:d?e.jsx(ke,{size:15}):e.jsx(be,{size:15})})]})]}),e.jsx(ze,{content:u.diff,empty:t("git.noChanges"),fontSize:z})]}),i.initialized&&e.jsxs("section",{className:"git-section",children:[e.jsxs("div",{className:"git-section-heading",children:[e.jsx(G,{size:16}),e.jsxs("div",{children:[e.jsx("strong",{children:t("git.history")}),e.jsx("small",{children:t("git.historyHint")})]})]}),e.jsxs("div",{className:"git-history",children:[B.map(s=>{const n=u?.revision===s.sha;return e.jsxs("article",{children:[e.jsx("code",{children:s.shortSha}),e.jsxs("div",{children:[e.jsx("strong",{children:s.message}),e.jsxs("small",{children:[s.authorName," · ",new Date(s.authoredAt).toLocaleString(S.resolvedLanguage)]})]}),e.jsxs("span",{"data-texlite-tooltip-always":!0,children:[e.jsx("button",{type:"button",className:n?"is-active":void 0,title:t(n?"git.hideCommitDiff":"git.viewCommitDiff"),"aria-label":t(n?"git.hideCommitDiff":"git.viewCommitDiff"),"aria-pressed":n,disabled:!!c,onClick:()=>de(s.sha),children:n?e.jsx(Ne,{size:14}):e.jsx(H,{size:14})}),e.jsx("button",{type:"button",title:t("git.checkoutVersion"),disabled:!!c,onClick:()=>{T(!1),p(s)},children:e.jsx(we,{size:14})})]})]},s.sha)}),B.length===0&&e.jsx("p",{className:"muted",children:t("git.noCommits")})]})]})]})]})}),e.jsx(L,{open:!!f,title:t(f==="branch"?"git.returnTitle":"git.checkoutTitle"),description:f==="branch"?t("git.returnDescription",{branch:i?.defaultBranch??"main"}):t("git.checkoutDescription",{revision:f?.shortSha??"",message:f?.message??""}),onOpenChange:s=>{s||p(null)},footer:e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>p(null),children:t("common.cancel")}),e.jsx("button",{className:U?"danger":"primary",onClick:ge,children:t("git.checkout")})]}),children:e.jsxs("label",{className:"git-force-checkout",children:[e.jsx("input",{type:"checkbox",checked:U,onChange:s=>T(s.target.checked)}),e.jsxs("span",{children:[e.jsx("strong",{children:t("git.forceCheckout")}),e.jsx("small",{children:t("git.forceCheckoutDescription")})]})]})}),e.jsx(L,{open:ne,title:t("git.discardTitle"),description:t("git.discardDescription"),onOpenChange:v,footer:e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>v(!1),children:t("common.cancel")}),e.jsx("button",{className:"danger",onClick:me,children:t("git.discardConfirm")})]}),children:e.jsx(e.Fragment,{})})]})}function ze({content:l,empty:o,fontSize:b}){return l.trim()?e.jsx("pre",{className:"git-diff",style:{fontSize:`${b}px`},children:l.split(`
2
+ `).map((r,t)=>{const S=r.startsWith("+")&&!r.startsWith("+++")?"addition":r.startsWith("-")&&!r.startsWith("---")?"deletion":r.startsWith("@@")?"hunk":r.startsWith("diff ")?"header":"";return e.jsxs("span",{className:S,children:[r,`
3
+ `]},t)})}):e.jsx("div",{className:"git-diff-empty",children:o})}function ie(l){return l.trim().replace(/\s+/g,"-").replace(/[^A-Za-z0-9._-]/g,"-").replace(/-+/g,"-").replace(/^[.-]+|[.-]+$/g,"").slice(0,100)||"texlite-project"}export{He as GitDialog};