@maxbill/dsh-file-explorer 0.0.0-stage → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/client.js ADDED
@@ -0,0 +1,4492 @@
1
+ window.__ModuleLoader__.load({
2
+ id: "@maxbill/dsh-file-explorer",
3
+ factory: (require) => {
4
+ var module = { exports: {} };
5
+ var exports = module.exports;
6
+ "use strict";
7
+
8
+ var React = require("react");
9
+ var h = React.createElement;
10
+ var Fragment = React.Fragment;
11
+ var useCallback = React.useCallback;
12
+ var useEffect = React.useEffect;
13
+ var useMemo = React.useMemo;
14
+ var useRef = React.useRef;
15
+ var useState = React.useState;
16
+
17
+ /** Identity shared by the sidebar entry and the main panel it opens. */
18
+ var PANEL_ID = "dsh-file-explorer";
19
+ /** Host route prefix served by lib/index.js. */
20
+ var API = "/api/file-explorer";
21
+ var STYLE_ID = "dsh-file-explorer-style";
22
+
23
+ /** Remembered navigation, clipboard and view so switching panels does not lose them. */
24
+ var remembered = { path: null, clipboard: null, view: null };
25
+
26
+ /** DSH workspace service (from ctx.workspaces), filled in by apply(). */
27
+ var workspacesRef = { current: null };
28
+
29
+ /** DSH layout service (from ctx.layout), used to go back to the conversation. */
30
+ var layoutRef = { current: null };
31
+
32
+ /** File kinds the conversation can take as an attachment. */
33
+ var ATTACH_KINDS = { image: 1, text: 1, pdf: 1, word: 1, excel: 1, ppt: 1 };
34
+
35
+ /** localStorage key holding the list column widths. */
36
+ var COLUMNS_KEY = "dsh-file-explorer:columns";
37
+
38
+ /** Default widths for the fixed columns (名称 shares whatever is left). */
39
+ var COLUMN_DEFAULT = { type: 104, size: 92, mtime: 148 };
40
+
41
+ /** localStorage key holding the chosen view mode. */
42
+ var VIEW_KEY = "dsh-file-explorer:view";
43
+
44
+ /** The ways a folder can be shown, in switcher order (icons is the default). */
45
+ var VIEW_MODES = ["icons", "list", "grouped"];
46
+
47
+ /** localStorage key holding the grouped-view look. */
48
+ var GROUP_KEY = "dsh-file-explorer:groupstyle";
49
+
50
+ /** The looks offered for the 分类 view. */
51
+ var GROUP_STYLES = [
52
+ { id: "card", label: "卡片" },
53
+ { id: "grid", label: "网格" },
54
+ ];
55
+
56
+ /** Labels and icons for the view switcher. */
57
+ var VIEW_OPTIONS = [
58
+ { id: "icons", label: "图标", icon: "viewGrid" },
59
+ { id: "list", label: "列表", icon: "viewList" },
60
+ { id: "grouped", label: "分类", icon: "squares" },
61
+ ];
62
+
63
+
64
+ /** localStorage key holding the interface language preference. */
65
+ var LANG_KEY = "dsh-file-explorer:lang";
66
+
67
+ /** Language choices offered in 选项. */
68
+ var LANGUAGES = [
69
+ { id: "auto", label: "自动" },
70
+ { id: "zh", label: "中文" },
71
+ { id: "en", label: "英文" },
72
+ ];
73
+
74
+ /** English copy, keyed by the Chinese source string. */
75
+ var EN = {
76
+ "图标": "Icons",
77
+ "列表": "List",
78
+ "分类": "Grouped",
79
+ "远程访问 · 本机操作已隐藏": "Remote access · desktop actions hidden",
80
+ "这些操作会作用在运行 DSH 的那台机器上,已隐藏": "These act on the machine running DSH, so they are hidden here",
81
+ "分类视图": "Grouped view",
82
+ "分组外观": "Group look",
83
+ "卡片": "Cards",
84
+ "网格": "Grid",
85
+ "滑动": "Slide",
86
+ "淡入": "Fade",
87
+ "缩放": "Zoom",
88
+ "上浮": "Rise",
89
+ "回弹": "Bounce",
90
+ "文件夹": "Folder",
91
+ "文本文件": "Text",
92
+ "图片": "Image",
93
+ "PDF 文档": "PDF",
94
+ "Word 文档": "Word",
95
+ "Excel 表格": "Excel",
96
+ "PPT 演示": "PowerPoint",
97
+ "压缩包": "Archive",
98
+ "音频": "Audio",
99
+ "视频": "Video",
100
+ "二进制文件": "Binary",
101
+ "文件": "File",
102
+ "响应无法解析": "Unreadable response",
103
+ "取消": "Cancel",
104
+ "确定": "OK",
105
+ "作者": "Author",
106
+ "版本": "Version",
107
+ "仓库地址": "Repository",
108
+ "关于 文件管理器": "About File Explorer",
109
+ "关闭关于": "Close about",
110
+ "文件管理器": "File Explorer",
111
+ "轻量级本地文件管理:浏览、预览、批量选择与常用操作。": "A lightweight local file manager: browse, preview, multi-select and the usual operations.",
112
+ "预览": "Preview",
113
+ "详情": "Details",
114
+ "隐藏": "Hidden",
115
+ "选项": "Options",
116
+ "关闭选项": "Close options",
117
+ "显示": "Display",
118
+ "显示隐藏文件": "Show hidden files",
119
+ "视图": "View",
120
+ "文件显示方式": "Files shown as",
121
+ "右侧面板": "Right pane",
122
+ "显示内容": "Showing",
123
+ "切换动画": "Transitions",
124
+ "进入 / 退出文件夹时的动画": "Animation when entering or leaving a folder",
125
+ "系统开启「减弱动态效果」时自动关闭动画。": "Turned off automatically when the system asks for reduced motion.",
126
+ "完成": "Done",
127
+ "无法读取目录": "Cannot read the folder",
128
+ "无法读取文件": "Cannot read the file",
129
+ "无法读取详情": "Cannot read the details",
130
+ "操作失败": "The operation failed",
131
+ "剪贴板不可用": "Clipboard unavailable",
132
+ "复制失败": "Copy failed",
133
+ "先选择文件或文件夹": "Select a file or folder first",
134
+ "请求失败": "Request failed",
135
+ "移到废纸篓": "Move to Trash",
136
+ "无法显示": "Cannot reveal",
137
+ "已在访达中显示": "Revealed in Finder",
138
+ "此平台不支持显示": "Revealing is not supported on this platform",
139
+ "无法在访达中显示": "Cannot reveal in Finder",
140
+ "无法打开": "Cannot open",
141
+ "剪贴板是空的": "The clipboard is empty",
142
+ "已拷贝到当前文件夹": "Copied into this folder",
143
+ "新建文件夹": "New folder",
144
+ "文件夹名称": "Folder name",
145
+ "未命名文件夹": "untitled folder",
146
+ "创建": "Create",
147
+ "已新建文件夹": "Folder created",
148
+ "新建文件": "New file",
149
+ "文件名称": "File name",
150
+ "未命名.txt": "untitled.txt",
151
+ "已新建文件": "File created",
152
+ "重新命名": "Rename",
153
+ "新名称": "New name",
154
+ "已重新命名": "Renamed",
155
+ "已复制路径": "Path copied",
156
+ "已复制名称": "Name copied",
157
+ "已复制副本": "Copy created",
158
+ "复制副本": "Duplicate",
159
+ "重命名只针对单个条目": "Rename works on one entry at a time",
160
+ "新建文件夹…": "New folder…",
161
+ "新建文件…": "New file…",
162
+ "名称": "Name",
163
+ "大小": "Size",
164
+ "修改时间": "Modified",
165
+ "全部选择": "Select all",
166
+ "全部取消": "Deselect all",
167
+ "反向选择": "Invert selection",
168
+ "撤销": "Undo",
169
+ "关于": "About",
170
+ "打开": "Open",
171
+ "显示详情": "Show details",
172
+ "用默认应用打开": "Open with default app",
173
+ "在访达中显示": "Reveal in Finder",
174
+ "重新命名…": "Rename…",
175
+ "拷贝": "Copy",
176
+ "剪切": "Cut",
177
+ "复制路径": "Copy path",
178
+ "复制名称": "Copy name",
179
+ "添加到会话": "Add to conversation",
180
+ "引用到输入框": "Mention in the composer",
181
+ "[dsh-file-explorer] 引用到输入框失败:": "Could not reference the file in the composer:",
182
+ "添加为工作区": "Add as workspace",
183
+ "粘贴": "Paste",
184
+ "在访达中显示当前文件夹": "Reveal this folder in Finder",
185
+ "刷新": "Refresh",
186
+ "没有找到会话输入框": "The conversation composer was not found",
187
+ "当前版本没有工作区服务": "This DSH build has no workspace service",
188
+ "添加": "Add",
189
+ "添加失败": "Could not add it",
190
+ "调整列宽": "Resize column",
191
+ "拖动调整列宽,双击恢复默认": "Drag to resize, double-click to reset",
192
+ "未知错误": "Unknown error",
193
+ "正在加载…": "Loading…",
194
+ "没有匹配的条目": "Nothing matches",
195
+ "此目录为空": "This folder is empty",
196
+ "类型": "Type",
197
+ "位置": "Location",
198
+ "创建时间": "Created",
199
+ "权限": "Permissions",
200
+ "符号链接": "Symlink",
201
+ "是": "yes",
202
+ "正在读取详情…": "Reading details…",
203
+ "正在打开…": "Opening…",
204
+ "文件过大,未生成预览": "Too large to preview",
205
+ "二进制文件,不支持预览": "Binary file — no preview",
206
+ "此格式不支持内嵌预览": "This format has no inline preview",
207
+ "在新窗口打开": "Open in a new window",
208
+ "仅显示前 {n} 行": "Only the first {n} rows are shown",
209
+ "仅显示前 {n} 段": "Only the first {n} blocks are shown",
210
+ "上一级 (Backspace)": "Up (Backspace)",
211
+ "主目录": "Home",
212
+ "(双击输入路径)": "Double-click to type a path",
213
+ "路径": "Path",
214
+ "筛选当前目录": "Filter this folder",
215
+ "文件操作": "File actions",
216
+ "新建文件夹或文件": "New folder or file",
217
+ "新建": "New",
218
+ "复制": "Copy",
219
+ "重命名": "Rename",
220
+ "删除": "Delete",
221
+ "隐藏以点开头的条目": "Hide dotfiles",
222
+ "显示以点开头的条目": "Show dotfiles",
223
+ "隐藏文件": "Hidden files",
224
+ "排序方式": "Sort by",
225
+ "排序": "Sort",
226
+ "更多操作": "More actions",
227
+ "更多": "More",
228
+ "显示视图": "View mode",
229
+ "隐藏右侧预览": "Hide the right pane",
230
+ "显示右侧预览": "Show the right pane",
231
+ "预览面板": "Preview pane",
232
+ "已截断,仅列出前 2000 项": "Truncated — only the first 2000 entries",
233
+ "处理中…": "Working…",
234
+ "图标视图": "Icons",
235
+ "列表视图": "List",
236
+ "已移动": "Moved",
237
+ "已撤销": "Undone",
238
+ "语言": "Language",
239
+ "自动": "Automatic",
240
+ "界面语言": "Interface language",
241
+ "跟随系统语言": "Follow the system language",
242
+ "中文": "Chinese",
243
+ "英文": "English",
244
+ "确认要将 ": "Add ",
245
+ " 添加为 DSH 工作区?": " as a DSH workspace?",
246
+ "已剪切 {n} 项": "Cut {n} items",
247
+ "已拷贝 {n} 项": "Copied {n} items",
248
+ "已撤销:{label}": "Undone: {label}",
249
+ "撤销失败:{reason}": "Undo failed: {reason}",
250
+ "“{name}”将被移到废纸篓,可以从废纸篓找回。": "“{name}” will move to the Trash; you can restore it from there.",
251
+ "选中的 {n} 项将被移到废纸篓,可以从废纸篓找回。": "The {n} selected items will move to the Trash; you can restore them from there.",
252
+ "删除 {n} 项": "Delete {n} items",
253
+ "移动 {n} 项": "Move {n} items",
254
+ "重命名 {name}": "Rename {name}",
255
+ "撤销 {label}": "Undo {label}",
256
+ "读取文件失败({status})": "Could not read the file ({status})",
257
+ "已添加为工作区:{name}": "Added as a workspace: {name}",
258
+ "工作区": "Workspace",
259
+ "切换工作区": "Switch workspace",
260
+ "还没有工作区": "No workspaces yet",
261
+ "把当前文件夹添加为工作区": "Add this folder as a workspace",
262
+ "已切换到工作区:{name}": "Switched to workspace: {name}",
263
+ "工作区:{name}": "Workspace: {name}",
264
+ "已添加到会话:{n} 项": "Added {n} items to the conversation",
265
+ "松手加入当前会话({n} 项)": "Drop to add {n} items to the conversation",
266
+ "文件作为附件,文件夹作为引用": "Files attach, folders are mentioned",
267
+ "从本机上传": "From this browser",
268
+ "读取失败:{reason}": "Failed to read: {reason}",
269
+ "无法读取详情:{reason}": "Cannot read the details: {reason}",
270
+ "无法预览:{reason}": "Cannot preview: {reason}",
271
+ "{n} 项": "{n} items",
272
+ "已选 {n} 项": "{n} selected",
273
+ "{view} · 按{sort}排序": "{view} · sorted by {sort}",
274
+ "读取失败:": "Failed to read: ",
275
+ "已添加为工作区:": "Added as a workspace: ",
276
+ "同名项已存在": "An entry with that name already exists",
277
+ "没有要处理的项目": "Nothing to work on",
278
+ "目标不是文件夹": "The target is not a folder",
279
+ "不能把文件夹移动到它自己里面": "A folder cannot be moved inside itself",
280
+ "已在目标文件夹": "Already in that folder",
281
+ "文件超过 64 MB": "The file is larger than 64 MB",
282
+ "请求内容过大": "The request body is too large",
283
+ "请求内容无法解析": "The request body could not be parsed",
284
+ "上传": "Upload",
285
+ "上传失败": "Upload failed",
286
+ "上传文件…": "Upload files…",
287
+ "上传文件夹…": "Upload a folder…",
288
+ "把文件上传到这个目录": "Upload files into this folder",
289
+ "已上传 {count} 个文件": function (vars) { return "Uploaded " + vars.count + " files"; },
290
+ "上传完成:{done} 个成功,{failed} 个失败": function (vars) { return "Upload finished: " + vars.done + " succeeded, " + vars.failed + " failed"; },
291
+ "下载": "Download",
292
+ "压缩为 ZIP": "Compress to ZIP",
293
+ "解压到此处": "Extract here",
294
+ "压缩失败": "Compression failed",
295
+ "解压失败": "Extraction failed",
296
+ "已生成 {name}": function (vars) { return "Created " + vars.name; },
297
+ "已解压 {count} 个文件": function (vars) { return "Extracted " + vars.count + " files"; },
298
+ "复制相对路径": "Copy relative path",
299
+ "已复制相对路径": "Relative path copied",
300
+ "编辑": "Edit",
301
+ "保存": "Save",
302
+ "未保存": "Unsaved",
303
+ "已保存": "Saved",
304
+ "保存失败": "Save failed",
305
+ "文件已被修改": "File changed on disk",
306
+ "这个文件在打开之后被外部修改了。仍要用当前内容覆盖吗?": "This file changed on disk while it was open. Overwrite it with your edits?",
307
+ "覆盖保存": "Overwrite",
308
+ "已修改": "Modified",
309
+ "已暂存": "Staged",
310
+ "已删除": "Deleted",
311
+ "已重命名": "Renamed",
312
+ "未跟踪": "Untracked",
313
+ "合并冲突": "Merge conflict",
314
+ "此文件夹内有改动": "Changes inside this folder",
315
+ "已移到废纸篓": "Moved to Trash",
316
+ };
317
+
318
+ /** Resolved language for the current render ("zh" or "en"). */
319
+ var currentLang = "zh";
320
+
321
+ /**
322
+ * Turn a language preference into a concrete language.
323
+ * @param {string} pref - "auto", "zh" or "en"
324
+ * @returns {string} "zh" or "en"
325
+ */
326
+ function resolveLang(pref) {
327
+ if (pref === "zh" || pref === "en") return pref;
328
+ try {
329
+ var tag = (typeof navigator !== "undefined" && navigator.language) || "zh";
330
+ return /^zh/i.test(tag) ? "zh" : "en";
331
+ } catch (error) {
332
+ return "zh";
333
+ }
334
+ }
335
+
336
+ /**
337
+ * Read the stored language preference, tolerating unavailable storage.
338
+ * @returns {string} "auto", "zh" or "en"
339
+ */
340
+ function readStoredLang() {
341
+ try {
342
+ var stored = window.localStorage ? window.localStorage.getItem(LANG_KEY) : null;
343
+ return LANGUAGES.some(function (item) { return item.id === stored; }) ? stored : "auto";
344
+ } catch (error) {
345
+ return "auto";
346
+ }
347
+ }
348
+
349
+ /**
350
+ * Persist the language preference.
351
+ * @param {string} pref - "auto", "zh" or "en"
352
+ */
353
+ function storeLang(pref) {
354
+ try {
355
+ if (window.localStorage) window.localStorage.setItem(LANG_KEY, pref);
356
+ } catch (error) {
357
+ // Storage can be unavailable; the in-memory value still applies.
358
+ }
359
+ }
360
+
361
+ /**
362
+ * Translate a fixed string into the current language.
363
+ * @param {string} text - Chinese source text
364
+ * @returns {string} localised text
365
+ */
366
+ function t(text) {
367
+ if (currentLang !== "en") return text;
368
+ return Object.prototype.hasOwnProperty.call(EN, text) ? EN[text] : text;
369
+ }
370
+
371
+ /**
372
+ * Translate a template and fill in its placeholders.
373
+ * @param {string} template - Chinese source template with {name} holes
374
+ * @param {object} values - hole values
375
+ * @returns {string} localised text
376
+ */
377
+ function tf(template, values) {
378
+ var text = t(template);
379
+ return text.replace(/\{([a-zA-Z0-9_]+)\}/g, function (match, key) {
380
+ return values && Object.prototype.hasOwnProperty.call(values, key) ? String(values[key]) : match;
381
+ });
382
+ }
383
+
384
+ /** localStorage key holding the folder-transition animation settings. */
385
+ var ANIM_KEY = "dsh-file-explorer:anim";
386
+
387
+ /** The folder-transition effects offered in 选项. */
388
+ var NAV_EFFECTS = [
389
+ { id: "slide", label: "滑动" },
390
+ { id: "fade", label: "淡入" },
391
+ { id: "zoom", label: "缩放" },
392
+ { id: "rise", label: "上浮" },
393
+ { id: "bounce", label: "回弹" },
394
+ ];
395
+
396
+ /** Default animation settings. */
397
+ var ANIM_DEFAULT = { enabled: true, effect: "slide" };
398
+
399
+ /** Settings read once at module load, so both panels agree. */
400
+ var storedAnim = null;
401
+
402
+ /** Language preference read once at module load. */
403
+ var storedLang = null;
404
+
405
+ /** localStorage key holding the hidden-file switch. */
406
+ var HIDDEN_KEY = "dsh-file-explorer:hidden";
407
+
408
+ /** localStorage key holding the right pane's visibility and mode. */
409
+ var PANE_KEY = "dsh-file-explorer:pane";
410
+
411
+ /**
412
+ * Read the remembered hidden-file switch.
413
+ * @returns {boolean} true when dotfiles are shown
414
+ */
415
+ function readStoredHidden() {
416
+ try {
417
+ return window.localStorage ? window.localStorage.getItem(HIDDEN_KEY) === "1" : false;
418
+ } catch (error) {
419
+ return false;
420
+ }
421
+ }
422
+
423
+ /**
424
+ * Remember the hidden-file switch.
425
+ * @param {boolean} shown - whether dotfiles are shown
426
+ */
427
+ function storeHidden(shown) {
428
+ try {
429
+ if (window.localStorage) window.localStorage.setItem(HIDDEN_KEY, shown ? "1" : "0");
430
+ } catch (error) {
431
+ // Storage can be unavailable; the in-memory value still applies.
432
+ }
433
+ }
434
+
435
+ /**
436
+ * Read the remembered right-pane state.
437
+ * @returns {object} { visible, mode }
438
+ */
439
+ function readStoredPane() {
440
+ try {
441
+ var raw = window.localStorage ? window.localStorage.getItem(PANE_KEY) : null;
442
+ var stored = raw ? JSON.parse(raw) : null;
443
+ if (stored && typeof stored === "object") {
444
+ return {
445
+ visible: stored.visible !== false && stored.visible !== undefined,
446
+ mode: stored.mode === "info" ? "info" : "preview",
447
+ };
448
+ }
449
+ } catch (error) {
450
+ // Corrupt or unavailable storage falls back to the defaults.
451
+ }
452
+ return { visible: false, mode: "preview" };
453
+ }
454
+
455
+ /**
456
+ * Remember the right-pane state.
457
+ * @param {boolean} visible - whether the pane is open
458
+ * @param {string} mode - "preview" or "info"
459
+ */
460
+ function storePane(visible, mode) {
461
+ try {
462
+ if (window.localStorage) {
463
+ window.localStorage.setItem(PANE_KEY, JSON.stringify({ visible: !!visible, mode: mode === "info" ? "info" : "preview" }));
464
+ }
465
+ } catch (error) {
466
+ // Storage can be unavailable; the in-memory value still applies.
467
+ }
468
+ }
469
+
470
+ /**
471
+ * Read the remembered animation settings, tolerating unavailable storage.
472
+ * @returns {object} { enabled, effect }
473
+ */
474
+ function readStoredAnim() {
475
+ try {
476
+ var raw = window.localStorage ? window.localStorage.getItem(ANIM_KEY) : null;
477
+ var stored = raw ? JSON.parse(raw) : null;
478
+ if (stored && typeof stored === "object") {
479
+ var effect = NAV_EFFECTS.some(function (item) { return item.id === stored.effect; })
480
+ ? stored.effect
481
+ : ANIM_DEFAULT.effect;
482
+ return { enabled: stored.enabled !== false, effect: effect };
483
+ }
484
+ } catch (error) {
485
+ // Corrupt or unavailable storage falls back to the defaults.
486
+ }
487
+ return { enabled: ANIM_DEFAULT.enabled, effect: ANIM_DEFAULT.effect };
488
+ }
489
+
490
+ /**
491
+ * Persist the animation settings.
492
+ * @param {object} anim - { enabled, effect }
493
+ */
494
+ function storeAnim(anim) {
495
+ try {
496
+ if (window.localStorage) window.localStorage.setItem(ANIM_KEY, JSON.stringify(anim));
497
+ } catch (error) {
498
+ // Storage can be unavailable; the in-memory value still applies.
499
+ }
500
+ }
501
+
502
+ /**
503
+ * Read the remembered view mode, tolerating unavailable storage.
504
+ * @returns {string|null} a valid mode, or null
505
+ */
506
+ function readStoredView() {
507
+ try {
508
+ var stored = window.localStorage ? window.localStorage.getItem(VIEW_KEY) : null;
509
+ return VIEW_MODES.indexOf(stored) === -1 ? null : stored;
510
+ } catch (error) {
511
+ return null;
512
+ }
513
+ }
514
+
515
+ /**
516
+ * Persist the view mode for the next session.
517
+ * @param {string} view - one of VIEW_MODES
518
+ */
519
+ /**
520
+ * Read the remembered grouped-view style.
521
+ * @returns {string} one of GROUP_STYLES, defaults to "card"
522
+ */
523
+ function readStoredGroupStyle() {
524
+ try {
525
+ var stored = window.localStorage ? window.localStorage.getItem(GROUP_KEY) : null;
526
+ return GROUP_STYLES.some(function (option) { return option.id === stored; }) ? stored : "card";
527
+ } catch (error) {
528
+ return "card";
529
+ }
530
+ }
531
+
532
+ /**
533
+ * Remember the grouped-view style.
534
+ * @param {string} style - one of GROUP_STYLES
535
+ * @returns {void}
536
+ */
537
+ function storeGroupStyle(style) {
538
+ try {
539
+ if (window.localStorage) window.localStorage.setItem(GROUP_KEY, style);
540
+ } catch (error) { /* private mode without storage: the session still works */ }
541
+ }
542
+
543
+ function storeView(view) {
544
+ try {
545
+ if (window.localStorage) window.localStorage.setItem(VIEW_KEY, view);
546
+ } catch (error) {
547
+ // Storage can be unavailable; the in-memory value still applies.
548
+ }
549
+ }
550
+
551
+
552
+ var CSS = `
553
+ .dfx-root {
554
+ position: relative;
555
+ display: flex;
556
+ flex-direction: column;
557
+ height: 100%;
558
+ min-height: 0;
559
+ background: var(--dsw-alias-bg-layer-1, #fff);
560
+ color: var(--dsw-alias-label-primary, #1b1b1b);
561
+ font-size: 13px;
562
+ line-height: 1.45;
563
+ --dfx-brand: var(--dsw-alias-bg-brand, #3b6cf6);
564
+ --dfx-col-name: minmax(0, 1fr);
565
+ --dfx-col-type: 104px;
566
+ --dfx-col-size: 92px;
567
+ --dfx-col-mtime: 148px;
568
+ }
569
+ .dfx-bar {
570
+ display: flex; align-items: center; gap: 8px; padding: 10px 14px 8px; flex: 0 0 auto;
571
+ box-shadow: inset 0 -1px 0 var(--dfx-rule, rgba(127, 127, 127, .13));
572
+ }
573
+ .dfx-bar-actions { display: flex; align-items: center; gap: 2px; flex: 0 0 auto; }
574
+ .dfx-navbtn {
575
+ display: inline-flex; align-items: center; justify-content: center;
576
+ width: 28px; height: 28px; padding: 0; border: 0; border-radius: 8px;
577
+ background: transparent; color: var(--dsw-alias-label-secondary, #5c5c5c);
578
+ cursor: pointer; flex: 0 0 auto;
579
+ }
580
+ .dfx-navbtn > span { display: inline-flex; align-items: center; justify-content: center; }
581
+ .dfx-navbtn svg { width: 16px; height: 16px; }
582
+ .dfx-navbtn:hover:not(:disabled) { background: var(--dsw-alias-bg-layer-3, rgba(0, 0, 0, .06)); color: var(--dsw-alias-label-primary, #1b1b1b); }
583
+ .dfx-navbtn:disabled { opacity: .35; cursor: default; }
584
+ .dfx-crumbs {
585
+ display: flex; align-items: center; gap: 1px; flex: 1 1 auto; min-width: 0; overflow: hidden;
586
+ height: 28px; padding: 0 6px; border-radius: 8px;
587
+ background: rgba(127, 127, 127, .04);
588
+ transition: background-color 120ms ease, box-shadow 120ms ease;
589
+ }
590
+ .dfx-crumbs:hover { background: rgba(127, 127, 127, .07); }
591
+ .dfx-crumbs--edit, .dfx-crumbs--edit:hover {
592
+ background: var(--dsw-alias-bg-layer-1, #fff);
593
+ box-shadow: inset 0 0 0 1.5px var(--dsw-alias-border-brand, #3b6cf6);
594
+ }
595
+ .dfx-address {
596
+ flex: 1 1 auto; min-width: 0; height: 22px; padding: 0 3px; border: 0; outline: none;
597
+ background: transparent; color: var(--dsw-alias-label-primary, #1b1b1b);
598
+ font: inherit; font-size: 12px; letter-spacing: .01em;
599
+ }
600
+ .dfx-crumb {
601
+ flex: 0 0 auto; max-width: 180px; padding: 3px 7px; border: 0; border-radius: 7px;
602
+ background: transparent; color: var(--dsw-alias-label-secondary, #5c5c5c);
603
+ font: inherit; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer;
604
+ }
605
+ .dfx-crumb:hover { background: var(--dsw-alias-bg-layer-3, rgba(0, 0, 0, .06)); color: var(--dsw-alias-label-primary, #1b1b1b); }
606
+ .dfx-crumb--last { color: var(--dsw-alias-label-primary, #1b1b1b); font-weight: 600; cursor: default; }
607
+ .dfx-crumb--last:hover { background: transparent; }
608
+ .dfx-sep { flex: 0 0 auto; color: var(--dsw-alias-label-tertiary, #9a9a9a); display: inline-flex; }
609
+ .dfx-search {
610
+ display: flex; align-items: center; gap: 6px; flex: 0 1 260px; min-width: 140px; height: 28px; padding: 0 9px; box-sizing: border-box;
611
+ border-radius: 8px; border: 1px solid var(--dsw-alias-border-l1, rgba(0, 0, 0, .12));
612
+ background: var(--dsw-alias-bg-layer-2, #fafafa); color: var(--dsw-alias-label-secondary, #5c5c5c);
613
+ }
614
+ .dfx-search input { flex: 1 1 auto; min-width: 0; border: 0; outline: 0; background: transparent; color: inherit; font: inherit; }
615
+ .dfx-search input::-webkit-search-cancel-button { display: none; }
616
+ .dfx-dropzone {
617
+ position: absolute; left: 14px; right: 14px; bottom: 40px; z-index: 40;
618
+ display: flex; align-items: center; gap: 8px;
619
+ padding: 10px 12px;
620
+ border: 1px dashed var(--dfx-brand, #3b6cf6); border-radius: 10px;
621
+ background: var(--dsw-alias-bg-layer-1, #fff);
622
+ color: var(--dsw-alias-label-secondary, #5c5c5c); font-size: 12px;
623
+ box-shadow: 0 8px 24px rgba(0, 0, 0, .14), 0 0 0 1px rgba(127, 127, 127, .06);
624
+ transition: background-color 120ms ease, border-color 120ms ease;
625
+ }
626
+ .dfx-dropzone-icon { display: inline-flex; color: var(--dfx-brand, #3b6cf6); }
627
+ .dfx-dropzone-text { color: var(--dsw-alias-label-primary, #1b1b1b); font-weight: 500; }
628
+ .dfx-dropzone-hint { margin-left: auto; color: var(--dsw-alias-label-tertiary, #8f8f8f); }
629
+ .dfx-dropzone--hot {
630
+ background: color-mix(in srgb, var(--dfx-brand, #3b6cf6) 12%, var(--dsw-alias-bg-layer-1, #fff));
631
+ border-style: solid;
632
+ }
633
+ .dfx-tool--ws { gap: 6px; max-width: 190px; }
634
+ .dfx-ws-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 130px; }
635
+ .dfx-toolbar {
636
+ display: flex; align-items: center; gap: 2px; padding: 7px 10px; flex: 0 0 auto;
637
+ box-shadow: inset 0 -1px 0 var(--dfx-rule, rgba(127, 127, 127, .13));
638
+ }
639
+ .dfx-tool {
640
+ display: inline-flex; align-items: center; gap: 5px; height: 26px; padding: 0 9px;
641
+ border: 0; border-radius: 7px; background: transparent; font: inherit; font-size: 12px;
642
+ color: var(--dsw-alias-label-secondary, #5c5c5c); cursor: pointer; white-space: nowrap;
643
+ }
644
+ .dfx-tool:hover:not(:disabled) { background: rgba(127, 127, 127, .13); color: var(--dsw-alias-label-primary, #1b1b1b); }
645
+ .dfx-tool:disabled { opacity: .38; cursor: default; }
646
+ .dfx-tool--open { background: rgba(127, 127, 127, .16); color: var(--dsw-alias-label-primary, #1b1b1b); }
647
+ .dfx-tool-label { line-height: 1; }
648
+ .dfx-root svg { display: block; flex: 0 0 auto; }
649
+ .dfx-rows--in, .dfx-head--in, .dfx-opt-sample--in { animation: dfx-nav-in 340ms cubic-bezier(.25, .8, .25, 1) both; }
650
+ .dfx-rows--out, .dfx-head--out, .dfx-opt-sample--out { animation: dfx-nav-out 340ms cubic-bezier(.25, .8, .25, 1) both; }
651
+ .dfx-rows--neutral, .dfx-head--neutral, .dfx-opt-sample--neutral { animation: dfx-nav-fade 180ms ease-out both; }
652
+ .dfx-rows--fade, .dfx-head--fade, .dfx-opt-sample--fade { animation: dfx-nav-fade 260ms ease-out both; }
653
+ .dfx-rows--zoom, .dfx-head--zoom, .dfx-opt-sample--zoom { animation: dfx-nav-zoom 300ms cubic-bezier(.2, .8, .3, 1) both; }
654
+ .dfx-rows--rise, .dfx-head--rise, .dfx-opt-sample--rise { animation: dfx-nav-rise 320ms cubic-bezier(.2, .8, .3, 1) both; }
655
+ .dfx-rows--bounce, .dfx-head--bounce, .dfx-opt-sample--bounce { animation: dfx-nav-bounce 520ms cubic-bezier(.16, 1.3, .3, 1) both; }
656
+ @keyframes dfx-nav-zoom {
657
+ 0% { opacity: 0; transform: scale(.9); }
658
+ 45% { opacity: 1; }
659
+ 100% { opacity: 1; transform: scale(1); }
660
+ }
661
+ @keyframes dfx-nav-rise {
662
+ 0% { opacity: 0; transform: translate3d(0, 26px, 0); }
663
+ 45% { opacity: 1; }
664
+ 100% { opacity: 1; transform: translate3d(0, 0, 0); }
665
+ }
666
+ @keyframes dfx-nav-bounce {
667
+ 0% { opacity: 0; transform: translate3d(58px, 0, 0) scale(.95); }
668
+ 40% { opacity: 1; }
669
+ 100% { opacity: 1; transform: translate3d(0, 0, 0) scale(1); }
670
+ }
671
+ @keyframes dfx-nav-in {
672
+ 0% { opacity: 0; transform: translate3d(60px, 0, 0) scale(.972); }
673
+ 45% { opacity: 1; }
674
+ 100% { opacity: 1; transform: translate3d(0, 0, 0) scale(1); }
675
+ }
676
+ @keyframes dfx-nav-out {
677
+ 0% { opacity: 0; transform: translate3d(-60px, 0, 0) scale(.972); }
678
+ 45% { opacity: 1; }
679
+ 100% { opacity: 1; transform: translate3d(0, 0, 0) scale(1); }
680
+ }
681
+ @keyframes dfx-nav-fade {
682
+ from { opacity: 0; }
683
+ to { opacity: 1; }
684
+ }
685
+ @media (prefers-reduced-motion: reduce) {
686
+ .dfx-rows--in, .dfx-rows--out, .dfx-rows--neutral, .dfx-rows--fade,
687
+ .dfx-rows--zoom, .dfx-rows--rise, .dfx-rows--bounce,
688
+ .dfx-head--in, .dfx-head--out, .dfx-head--neutral, .dfx-head--fade,
689
+ .dfx-head--zoom, .dfx-head--rise, .dfx-head--bounce,
690
+ .dfx-opt-sample--in, .dfx-opt-sample--out, .dfx-opt-sample--fade,
691
+ .dfx-opt-sample--zoom, .dfx-opt-sample--rise, .dfx-opt-sample--bounce { animation: none; }
692
+ }
693
+ .dfx-toolbar-sep { width: 1px; height: 15px; margin: 0 6px; background: var(--dsw-alias-border-l1, rgba(0, 0, 0, .1)); flex: 0 0 auto; }
694
+ /* icon-only controls: the hint shows up on hover instead of waiting for the
695
+ browser's native title bubble */
696
+ .dfx-tip { position: relative; }
697
+ .dfx-tip::after {
698
+ content: attr(data-tip);
699
+ position: absolute; top: calc(100% + 7px); left: 50%;
700
+ transform: translateX(-50%) translateY(-2px);
701
+ padding: 5px 8px; border-radius: 6px; white-space: nowrap;
702
+ font-size: 11px; line-height: 1.2; font-weight: 500;
703
+ color: #fff; background: rgba(38, 38, 44, .92);
704
+ box-shadow: 0 2px 8px rgba(16, 32, 64, .18);
705
+ opacity: 0; pointer-events: none; z-index: 40;
706
+ transition: opacity 110ms ease 150ms, transform 110ms ease 150ms;
707
+ }
708
+ .dfx-tip:hover::after, .dfx-tip:focus-visible::after { opacity: 1; transform: translateX(-50%) translateY(0); }
709
+ .dfx-tip--right::after { left: auto; right: 0; transform: translateY(-2px); }
710
+ .dfx-tip--right:hover::after, .dfx-tip--right:focus-visible::after { transform: translateY(0); }
711
+ .dfx-popup { min-width: 190px; }
712
+ .dfx-body { display: flex; flex: 1 1 auto; min-height: 0; }
713
+ .dfx-listpane { display: flex; flex-direction: column; flex: 1 1 auto; min-width: 0; min-height: 0; }
714
+ .dfx-head {
715
+ display: grid;
716
+ grid-template-columns: var(--dfx-col-name) var(--dfx-col-type) var(--dfx-col-size) var(--dfx-col-mtime);
717
+ align-items: center; gap: 12px;
718
+ height: 26px; padding: 0 14px; flex: 0 0 auto; color: var(--dsw-alias-label-tertiary, #8f8f8f); font-size: 12px;
719
+ box-shadow: inset 0 -1px 0 var(--dfx-rule, rgba(127, 127, 127, .13));
720
+ }
721
+ .dfx-headcell { position: relative; }
722
+ .dfx-col-resizer {
723
+ position: absolute; top: -6px; right: -8px; width: 12px; height: 26px; margin: 0;
724
+ border: 0; background: transparent; cursor: col-resize; padding: 0;
725
+ display: flex; align-items: center; justify-content: center; touch-action: none;
726
+ }
727
+ .dfx-col-resizer::after {
728
+ content: ""; width: 1px; height: 13px; border-radius: 1px;
729
+ background: var(--dsw-alias-border-l2, rgba(0, 0, 0, .14));
730
+ transition: background-color .12s ease, height .12s ease;
731
+ }
732
+ .dfx-col-resizer:hover::after,
733
+ .dfx-col-resizer--active::after {
734
+ height: 20px; background: var(--dfx-brand);
735
+ }
736
+ .dfx-col-resizer:focus-visible { outline: 2px solid var(--dfx-brand); outline-offset: 0; border-radius: 3px; }
737
+ .dfx-listpane--resizing, .dfx-listpane--resizing * { cursor: col-resize !important; user-select: none !important; }
738
+ .dfx-headcell {
739
+ display: inline-flex; align-items: center; gap: 4px; border: 0; background: transparent; padding: 0;
740
+ font: inherit; color: inherit; cursor: pointer; text-align: left;
741
+ }
742
+ .dfx-headcell:hover { color: var(--dsw-alias-label-primary, #1b1b1b); }
743
+ .dfx-headcell--static { cursor: default; }
744
+ .dfx-headcell--static:hover { color: inherit; }
745
+ .dfx-rows { flex: 1 1 auto; min-height: 0; overflow: auto; padding: 6px 0 10px; outline: none;
746
+ /* the reserve keeps a scrollbar from re-flowing the grid mid-animation */
747
+ scrollbar-gutter: stable; contain: layout paint style; }
748
+ /* ── grouped view: type sections, each with its own accent colour ──────── */
749
+ .dfx-groupsum {
750
+ display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
751
+ margin: 4px 14px 8px;
752
+ }
753
+ .dfx-groupsum-label { font-size: 11px; color: var(--dsw-alias-label-tertiary, #8f8f8f); margin-right: 2px; }
754
+ .dfx-groupsum-chip {
755
+ display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px;
756
+ border: 1px solid var(--dfx-rule, rgba(127, 127, 127, .14)); border-radius: 999px;
757
+ background: var(--dsw-alias-bg-layer-1, #fff); font-size: 11px;
758
+ color: var(--dsw-alias-label-secondary, #6f6f6f);
759
+ }
760
+ .dfx-groupsum-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--dfx-kind); }
761
+ .dfx-groupsum-chip b { color: var(--dsw-alias-label-primary, #1b1b1b); font-weight: 600; font-variant-numeric: tabular-nums; }
762
+
763
+ .dfx-group {
764
+ display: block; margin: 0 14px 10px; overflow: hidden;
765
+ --dfx-group-inset: 15px;
766
+ border: 1px solid var(--dfx-rule, rgba(127, 127, 127, .14));
767
+ border-left: 3px solid var(--dfx-kind); border-radius: 12px;
768
+ background: var(--dsw-alias-bg-layer-1, #fff);
769
+ box-shadow: 0 1px 2px rgba(16, 32, 64, .04);
770
+ }
771
+ /* Each style sets --dfx-group-inset to body padding + row padding + row border,
772
+ so the parent's icon lands exactly above the children's icons. */
773
+ .dfx-group-head {
774
+ display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 12px 0 var(--dfx-group-inset, 15px);
775
+ cursor: pointer; user-select: none; list-style: none;
776
+ background: var(--dfx-kind-soft);
777
+ box-shadow: inset 0 -1px 0 var(--dfx-rule, rgba(127, 127, 127, .1));
778
+ }
779
+ .dfx-group-head::-webkit-details-marker { display: none; }
780
+ .dfx-group-head::marker { content: ""; }
781
+ .dfx-group-head:hover { background: var(--dfx-kind-tint); }
782
+ .dfx-group-icon {
783
+ display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto;
784
+ width: 16px; height: 16px; color: var(--dfx-kind);
785
+ }
786
+ /* the label carries the hierarchy: no tile behind the parent icon */
787
+ .dfx-group-label { font-size: 12.5px; font-weight: 700; letter-spacing: .01em; color: var(--dsw-alias-label-primary, #1b1b1b); }
788
+ .dfx-group-count {
789
+ padding: 0 2px; font-size: 11px; line-height: 16px; font-weight: 600;
790
+ color: var(--dfx-kind); background: transparent;
791
+ font-variant-numeric: tabular-nums;
792
+ }
793
+ .dfx-group-tail { margin-left: auto; display: inline-flex; align-items: center; gap: 10px; }
794
+ .dfx-group-total { font-size: 11px; color: var(--dsw-alias-label-tertiary, #8f8f8f); font-variant-numeric: tabular-nums; }
795
+ .dfx-group-caret { display: inline-flex; color: var(--dsw-alias-label-tertiary, #8f8f8f); transition: transform 140ms ease; }
796
+ .dfx-group:not([open]) .dfx-group-caret { transform: rotate(-90deg); }
797
+ .dfx-group-body { padding: 5px 7px 7px; }
798
+ .dfx-group .dfx-row--grouped { grid-template-columns: minmax(0, 1fr) 84px 132px; gap: 10px; height: 30px; padding: 0 8px; border-radius: 7px; }
799
+ .dfx-group .dfx-row--grouped:hover { background: var(--dfx-kind-soft); }
800
+ .dfx-group .dfx-row--grouped .dfx-name-icon { color: var(--dfx-kind); }
801
+ .dfx-group .dfx-cell { font-size: 12px; }
802
+
803
+ /* ── grid: compact chips wrapped under each type ───────────────────────── */
804
+ .dfx-group--grid { --dfx-group-inset: 21px; }
805
+ .dfx-group--grid .dfx-group-body {
806
+ display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
807
+ gap: 6px; padding: 6px 10px 8px;
808
+ }
809
+ .dfx-rows .dfx-group--grid .dfx-row--grouped {
810
+ height: 36px; padding: 0 10px; grid-template-columns: minmax(0, 1fr) auto;
811
+ border: 1px solid var(--dfx-rule, rgba(127, 127, 127, .14)); border-radius: 9px;
812
+ background: var(--dsw-alias-bg-layer-1, #fff);
813
+ }
814
+ .dfx-rows .dfx-group--grid .dfx-row--grouped .dfx-cell + .dfx-cell { display: none; }
815
+ .dfx-rows .dfx-group--grid .dfx-row--grouped .dfx-cell { font-size: 11px; }
816
+ .dfx-git { width: 6px; height: 6px; border-radius: 50%; flex: 0 0 auto; margin-left: 6px; display: inline-block; background: #d29a16; }
817
+ .dfx-git--untracked { background: #2f9e44; }
818
+ .dfx-git--D { background: #e03131; }
819
+ .dfx-git--R { background: #3b82f6; }
820
+ .dfx-git--conflict { background: #f03e3e; }
821
+ .dfx-git--A, .dfx-git--dir { background: #868e96; }
822
+ .dfx-upload { display: flex; align-items: center; gap: 8px; padding: 4px 12px; font-size: 12px; color: var(--dsw-alias-label-secondary, #6b6b6b); }
823
+ .dfx-upload-bar { flex: 1 1 auto; height: 3px; border-radius: 2px; background: rgba(127, 127, 127, .2); overflow: hidden; }
824
+ .dfx-upload-fill { height: 100%; background: #5b5bd6; transition: width 120ms linear; }
825
+ .dfx-editor { display: flex; flex-direction: column; gap: 6px; height: 100%; }
826
+ .dfx-editor textarea {
827
+ flex: 1 1 auto; min-height: 240px; resize: none; width: 100%;
828
+ font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; line-height: 1.6;
829
+ border: 1px solid var(--dsw-alias-border-l1, rgba(0, 0, 0, .1)); border-radius: 10px;
830
+ padding: 10px 12px; background: var(--dsw-alias-bg-layer-1, #fff); color: inherit;
831
+ outline: none; tab-size: 4;
832
+ }
833
+ .dfx-editor-bar {
834
+ display: flex; align-items: center; gap: 8px; min-height: 34px; padding: 0 2px;
835
+ font-size: 12px; color: var(--dsw-alias-label-tertiary, #8f8f8f);
836
+ flex-wrap: nowrap; white-space: nowrap; overflow: hidden;
837
+ }
838
+ .dfx-editor-state { font-weight: 500; flex: 0 0 auto; }
839
+ .dfx-editor-stat { font-variant-numeric: tabular-nums; flex: 0 1 auto; overflow: hidden; text-overflow: ellipsis; }
840
+ .dfx-editor-bar .dfx-kbd { flex: 0 0 auto; }
841
+ .dfx-editor-bar .dfx-pill { flex: 0 0 auto; }
842
+ /* a narrow pane keeps the two actions readable instead of wrapping every word */
843
+ .dfx-editor-bar .dfx-dirty, .dfx-editor-bar .dfx-meta-sep { flex: 0 0 auto; }
844
+ .dfx-kbd {
845
+ display: inline-flex; align-items: center; height: 18px; padding: 0 5px;
846
+ border-radius: 4px; font-size: 11px; line-height: 1;
847
+ color: var(--dsw-alias-label-secondary, #6b6b6b);
848
+ background: rgba(127, 127, 127, .12);
849
+ }
850
+
851
+ .dfx-dirty { width: 6px; height: 6px; border-radius: 50%; background: #d29a16; }
852
+ .dfx-row {
853
+ display: grid; grid-template-columns: minmax(0, 1fr) 92px 148px; align-items: center; gap: 12px;
854
+ height: 30px; padding: 0 14px; cursor: pointer; user-select: none;
855
+ transition: background-color 120ms ease;
856
+ contain: layout paint style;
857
+ }
858
+ .dfx-row:hover { background: rgba(127, 127, 127, .13); }
859
+ .dfx-row:hover .dfx-name-text--dim { color: var(--dsw-alias-label-primary, #1b1b1b); }
860
+ .dfx-row--sel, .dfx-row--sel:hover { background: var(--dsw-alias-bg-brand-weak, rgba(64, 110, 255, .12)); }
861
+ .dfx-name { display: flex; align-items: center; gap: 8px; min-width: 0; }
862
+ .dfx-name-icon { flex: 0 0 auto; display: inline-flex; color: var(--dsw-alias-label-tertiary, #8b8b8b); }
863
+ .dfx-name-icon--folder { color: var(--dsw-alias-label-brand, #4b7bec); }
864
+ .dfx-name-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
865
+ .dfx-name-text--dim { color: var(--dsw-alias-label-tertiary, #8f8f8f); }
866
+ .dfx-cell { color: var(--dsw-alias-label-secondary, #6f6f6f); font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
867
+ .dfx-empty { padding: 28px 16px; color: var(--dsw-alias-label-tertiary, #8f8f8f); text-align: center; }
868
+ .dfx-notice { margin: 14px; padding: 12px 14px; border-radius: 10px; background: var(--dsw-alias-bg-layer-2, #f7f7f7); border: 1px solid var(--dsw-alias-border-l1, rgba(0, 0, 0, .08)); color: var(--dsw-alias-label-secondary, #5c5c5c); }
869
+ .dfx-notice--error { border-color: var(--dsw-alias-border-danger, rgba(220, 60, 60, .35)); color: var(--dsw-alias-label-danger, #c0392b); }
870
+ .dfx-preview { display: flex; flex-direction: column; flex: 0 0 auto; width: 42%; min-width: 260px; max-width: 620px; min-height: 0; border-left: 1px solid var(--dsw-alias-border-l1, rgba(0, 0, 0, .08)); background: var(--dsw-alias-bg-layer-2, #fbfbfb); }
871
+ .dfx-preview-head {
872
+ display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 12px;
873
+ flex: 0 0 auto; border-bottom: 1px solid var(--dfx-rule, rgba(127, 127, 127, .12));
874
+ }
875
+ .dfx-preview-title { flex: 1 1 auto; min-width: 0; font-weight: 600; font-size: 13px; letter-spacing: -.005em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
876
+ /* one line: size · date · mime, with the edit action pinned to the right edge */
877
+ .dfx-preview-meta {
878
+ display: flex; align-items: center; gap: 8px; height: 34px; padding: 0 12px;
879
+ flex: 0 0 auto; color: var(--dsw-alias-label-tertiary, #8f8f8f); font-size: 12px;
880
+ border-bottom: 1px solid var(--dfx-rule, rgba(127, 127, 127, .1));
881
+ white-space: nowrap; overflow: hidden;
882
+ }
883
+ .dfx-meta-item { font-variant-numeric: tabular-nums; }
884
+ .dfx-meta-item--mime { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
885
+ .dfx-meta-sep { width: 3px; height: 3px; border-radius: 50%; background: currentColor; opacity: .45; flex: 0 0 auto; }
886
+ .dfx-preview-meta .dfx-pill { margin-left: auto; height: 24px; padding: 0 9px; flex: 0 0 auto; white-space: nowrap; }
887
+ .dfx-meta-empty { flex: 1 1 auto; }
888
+ .dfx-preview-body { flex: 1 1 auto; min-height: 0; overflow: auto; padding: 10px 12px 12px; }
889
+ .dfx-pre { margin: 0; padding: 10px 12px; border-radius: 10px; background: var(--dsw-alias-bg-layer-1, #fff); border: 1px solid var(--dsw-alias-border-l1, rgba(0, 0, 0, .08)); font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; line-height: 1.55; white-space: pre-wrap; word-break: break-word; color: var(--dsw-alias-label-primary, #1b1b1b); }
890
+ .dfx-image { display: block; max-width: 100%; border-radius: 10px; background: var(--dsw-alias-bg-layer-1, #fff); border: 1px solid var(--dsw-alias-border-l1, rgba(0, 0, 0, .08)); }
891
+ .dfx-md { font-size: 13px; line-height: 1.65; color: var(--dsw-alias-label-primary, #1b1b1b); }
892
+ .dfx-md-h { margin: 12px 0 6px; font-size: 14px; font-weight: 600; line-height: 1.4; }
893
+ .dfx-md-h:first-child { margin-top: 2px; }
894
+ .dfx-md-p { margin: 6px 0; }
895
+ .dfx-md-list { margin: 6px 0; padding-left: 18px; }
896
+ .dfx-md-list li { margin: 2px 0; }
897
+ .dfx-md-quote {
898
+ margin: 8px 0; padding: 4px 10px; border-left: 3px solid var(--dsw-alias-border-l2, rgba(0, 0, 0, .14));
899
+ color: var(--dsw-alias-label-secondary, #5c5c5c);
900
+ }
901
+ .dfx-md-code {
902
+ padding: 1px 5px; border-radius: 5px; font-size: 12px;
903
+ background: var(--dsw-alias-bg-layer-2, #f4f4f4); font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
904
+ }
905
+ .dfx-md-pre { margin: 8px 0; }
906
+ .dfx-tablewrap { overflow: auto; border-radius: 10px; border: 1px solid var(--dsw-alias-border-l1, rgba(0, 0, 0, .1)); }
907
+ .dfx-table { border-collapse: collapse; font-size: 12px; min-width: 100%; }
908
+ .dfx-table th, .dfx-table td {
909
+ padding: 5px 9px; text-align: left; white-space: nowrap;
910
+ border-bottom: 1px solid var(--dsw-alias-border-l1, rgba(0, 0, 0, .07));
911
+ }
912
+ .dfx-table th { position: sticky; top: 0; background: var(--dsw-alias-bg-layer-2, #f7f7f7); font-weight: 600; }
913
+ .dfx-table tr:last-child td { border-bottom: 0; }
914
+ .dfx-doc { font-size: 13px; line-height: 1.7; color: var(--dsw-alias-label-primary, #1b1b1b); }
915
+ .dfx-doc-p { margin: 6px 0; }
916
+ .dfx-doc-li { margin: 3px 0 3px 14px; position: relative; }
917
+ .dfx-doc-li::before { content: "•"; position: absolute; left: -12px; color: var(--dsw-alias-label-tertiary, #8f8f8f); }
918
+ .dfx-doc-h { margin: 12px 0 6px; font-weight: 600; line-height: 1.4; }
919
+ .dfx-doc-h:first-child { margin-top: 2px; }
920
+ .dfx-doc-h1 { font-size: 16px; }
921
+ .dfx-doc-h2 { font-size: 14.5px; }
922
+ .dfx-doc-h3 { font-size: 13.5px; }
923
+ .dfx-doc-h4 { font-size: 13px; }
924
+ .dfx-doc .dfx-tablewrap { margin: 8px 0; }
925
+ .dfx-sheet { display: flex; flex-direction: column; gap: 8px; }
926
+ .dfx-sheet-tabs { display: flex; flex-wrap: wrap; gap: 4px; }
927
+ .dfx-sheet-tab {
928
+ padding: 4px 10px; border-radius: 8px; border: 1px solid var(--dsw-alias-border-l1, rgba(0, 0, 0, .12));
929
+ background: transparent; font: inherit; font-size: 12px; color: inherit; cursor: pointer;
930
+ }
931
+ .dfx-sheet-tab:hover { background: var(--dsw-alias-bg-layer-3, rgba(0, 0, 0, .05)); }
932
+ .dfx-sheet-tab--active {
933
+ border-color: transparent; background: color-mix(in srgb, var(--dfx-brand) 13%, transparent);
934
+ color: var(--dfx-brand); font-weight: 600;
935
+ }
936
+ .dfx-preview-hint { font-size: 11.5px; color: var(--dsw-alias-label-tertiary, #8f8f8f); }
937
+ .dfx-embed { display: flex; flex-direction: column; gap: 8px; height: 100%; min-height: 320px; }
938
+ .dfx-embed embed { flex: 1 1 auto; width: 100%; min-height: 300px; border: 0; border-radius: 10px; background: var(--dsw-alias-bg-layer-2, #f7f7f7); }
939
+ .dfx-embed-link { font-size: 12px; color: var(--dfx-brand); text-decoration: none; }
940
+ .dfx-embed-link:hover { text-decoration: underline; }
941
+ .dfx-media { width: 100%; border-radius: 10px; background: var(--dsw-alias-bg-layer-2, #f7f7f7); }
942
+ .dfx-html { width: 100%; height: 360px; border: 1px solid var(--dsw-alias-border-l1, rgba(0, 0, 0, .1)); border-radius: 10px; background: #fff; }
943
+ .dfx-preview-foot { display: flex; align-items: center; gap: 6px; padding: 8px 12px; flex: 0 0 auto; border-top: 1px solid var(--dsw-alias-border-l1, rgba(0, 0, 0, .07)); }
944
+ .dfx-panemode { display: flex; align-items: center; gap: 1px; padding: 2px; margin-left: auto; border-radius: 8px; background: var(--dsw-alias-bg-layer-2, #f2f2f2); flex: 0 0 auto; }
945
+ .dfx-panemode button {
946
+ height: 22px; padding: 0 9px; border: 0; border-radius: 6px; background: transparent;
947
+ color: var(--dsw-alias-label-secondary, #5c5c5c); font: inherit; font-size: 11px; cursor: pointer;
948
+ }
949
+ .dfx-panemode button[aria-pressed="true"] { background: var(--dsw-alias-bg-layer-1, #fff); color: var(--dsw-alias-label-primary, #1b1b1b); box-shadow: 0 1px 2px rgba(0, 0, 0, .1); }
950
+ .dfx-panemode button:disabled { opacity: .38; cursor: default; box-shadow: none; background: transparent; }
951
+ .dfx-info { display: flex; flex-direction: column; padding: 2px 0 6px; }
952
+ .dfx-info-row {
953
+ display: grid; grid-template-columns: 66px minmax(0, 1fr); gap: 10px; align-items: baseline;
954
+ padding: 8px 2px; border-bottom: 1px solid var(--dsw-alias-border-l1, rgba(0, 0, 0, .06)); font-size: 12px;
955
+ }
956
+ .dfx-info-row:last-child { border-bottom: 0; }
957
+ .dfx-info-label { color: var(--dsw-alias-label-tertiary, #8f8f8f); }
958
+ .dfx-info-value { color: var(--dsw-alias-label-primary, #1b1b1b); word-break: break-all; font-variant-numeric: tabular-nums; user-select: text; }
959
+ .dfx-pill {
960
+ display: inline-flex; align-items: center; gap: 5px; height: 26px; padding: 0 10px;
961
+ border-radius: 999px; border: 1px solid var(--dsw-alias-border-l1, rgba(0, 0, 0, .12));
962
+ background: transparent; color: var(--dsw-alias-label-secondary, #5c5c5c); font: inherit; font-size: 12px; cursor: pointer;
963
+ }
964
+ .dfx-pill:hover { background: var(--dsw-alias-bg-layer-3, rgba(0, 0, 0, .06)); color: var(--dsw-alias-label-primary, #1b1b1b); }
965
+ .dfx-pill.dfx-pill--primary {
966
+ border-color: transparent; color: #fff;
967
+ background: var(--dfx-brand, #3b6cf6);
968
+ }
969
+ .dfx-pill.dfx-pill--primary:hover { background: var(--dfx-brand, #3b6cf6); color: #fff; filter: brightness(1.08); }
970
+ .dfx-foot-strong { color: var(--dsw-alias-label-primary, #1b1b1b); font-variant-numeric: tabular-nums; }
971
+ .dfx-foot-meta { font-variant-numeric: tabular-nums; }
972
+ .dfx-foot { display: flex; align-items: center; gap: 12px; height: 26px; padding: 0 14px; flex: 0 0 auto; color: var(--dsw-alias-label-tertiary, #8f8f8f); font-size: 12px; border-top: 1px solid var(--dsw-alias-border-l1, rgba(0, 0, 0, .07)); }
973
+ .dfx-foot-dot { width: 3px; height: 3px; border-radius: 50%; background: currentColor; opacity: .5; }
974
+ .dfx-foot-remote { display: inline-flex; align-items: center; gap: 4px; color: var(--dsw-alias-label-tertiary, #8f8f8f); }
975
+ .dfx-foot-error { color: var(--dsw-alias-label-danger, #c0392b); }
976
+ .dfx-spin { animation: dfx-spin 1s linear infinite; }
977
+ @keyframes dfx-spin { to { transform: rotate(360deg); } }
978
+ @media (prefers-reduced-motion: reduce) { .dfx-spin { animation: none; } }
979
+ .dfx-viewswitch {
980
+ display: flex; align-items: center; gap: 1px; padding: 2px; margin-left: auto;
981
+ border-radius: 10px; background: var(--dsw-alias-bg-layer-2, #f4f4f4); flex: 0 0 auto;
982
+ }
983
+ .dfx-panebtn { flex: 0 0 auto; }
984
+ .dfx-navbtn--active { background: var(--dsw-alias-bg-layer-1, #fff); color: var(--dsw-alias-label-primary, #1b1b1b); box-shadow: 0 1px 2px rgba(0, 0, 0, .1); }
985
+ .dfx-row { grid-template-columns: var(--dfx-col-name) var(--dfx-col-type) var(--dfx-col-size) var(--dfx-col-mtime); }
986
+ .dfx-rows--grid {
987
+ display: grid;
988
+ /* fixed cells rather than 1fr: while the panel grows during its open
989
+ transition the tiles keep their size and only the wrap point moves */
990
+ grid-template-columns: repeat(auto-fill, 104px);
991
+ grid-auto-rows: 92px;
992
+ justify-content: start;
993
+ gap: 2px; padding: 8px 12px 14px; align-content: start;
994
+ }
995
+ .dfx-tile {
996
+ display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 6px;
997
+ padding: 10px 6px 8px; border-radius: 10px; cursor: pointer; user-select: none;
998
+ transition: background-color 120ms ease;
999
+ contain: layout paint style;
1000
+ content-visibility: auto; contain-intrinsic-size: 108px 92px;
1001
+ }
1002
+ .dfx-tile:hover { background: rgba(127, 127, 127, .13); }
1003
+ .dfx-tile:hover .dfx-name-text--dim { color: var(--dsw-alias-label-primary, #1b1b1b); }
1004
+ .dfx-tile--sel, .dfx-tile--sel:hover { background: var(--dsw-alias-bg-brand-weak, rgba(64, 110, 255, .12)); }
1005
+ .dfx-tile-icon { display: flex; align-items: center; justify-content: center; width: 52px; height: 52px; color: var(--dsw-alias-label-tertiary, #8b8b8b); }
1006
+ .dfx-tile-icon--folder { color: var(--dsw-alias-label-brand, #4b7bec); }
1007
+ .dfx-tile-name {
1008
+ max-width: 100%; font-size: 12px; line-height: 1.35; text-align: center;
1009
+ /* two lines are reserved so every tile lines up; past that a single … */
1010
+ min-height: 32px;
1011
+ overflow-wrap: anywhere;
1012
+ word-break: normal;
1013
+ color: var(--dsw-alias-label-primary, #1b1b1b);
1014
+ display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
1015
+ }
1016
+ .dfx-menu {
1017
+ position: fixed; z-index: 90; min-width: 220px; max-height: calc(100vh - 16px); overflow: auto;
1018
+ padding: 6px; display: flex; flex-direction: column; gap: 1px; border-radius: 14px;
1019
+ background: var(--dsw-alias-bg-layer-1, #fff);
1020
+ border: 1px solid var(--dsw-alias-border-l1, rgba(0, 0, 0, .1));
1021
+ box-shadow: 0 2px 6px rgba(16, 32, 64, .10), 0 18px 44px rgba(16, 32, 64, .22);
1022
+ animation: dfx-menu-in .12s ease-out;
1023
+ }
1024
+ @keyframes dfx-menu-in {
1025
+ from { opacity: 0; transform: translateY(-3px) scale(.99); }
1026
+ to { opacity: 1; transform: none; }
1027
+ }
1028
+ .dfx-menu-item {
1029
+ display: flex; align-items: center; gap: 10px; height: 32px; padding: 0 10px;
1030
+ border: 0; border-radius: 9px; background: transparent; color: var(--dsw-alias-label-primary, #1b1b1b);
1031
+ font: inherit; font-size: 12.5px; text-align: left; cursor: pointer;
1032
+ transition: background .1s ease, color .1s ease;
1033
+ }
1034
+ .dfx-menu-item:hover:not(:disabled) { background: var(--dsw-alias-bg-layer-3, rgba(0, 0, 0, .06)); }
1035
+ .dfx-menu-item:active:not(:disabled) { background: var(--dsw-alias-bg-layer-3, rgba(0, 0, 0, .09)); }
1036
+ .dfx-menu-item:focus-visible { outline: 2px solid var(--dsw-alias-border-brand, #3b6cf6); outline-offset: -2px; }
1037
+ .dfx-menu-item:disabled { opacity: .38; cursor: default; }
1038
+ .dfx-menu-item--danger { color: var(--dsw-alias-label-danger, #c0392b); }
1039
+ .dfx-menu-item--danger:hover:not(:disabled) { background: var(--dsw-alias-bg-danger-weak, rgba(220, 60, 60, .1)); }
1040
+ .dfx-menu-icon {
1041
+ display: inline-flex; justify-content: center; align-items: center; width: 16px; flex: none;
1042
+ color: var(--dsw-alias-label-tertiary, #8b8b8b); transition: color .1s ease;
1043
+ }
1044
+ .dfx-menu-item:hover:not(:disabled) .dfx-menu-icon { color: var(--dfx-brand); }
1045
+ .dfx-menu-item--danger .dfx-menu-icon,
1046
+ .dfx-menu-item--danger:hover:not(:disabled) .dfx-menu-icon { color: inherit; }
1047
+ .dfx-menu-label { flex: 1 1 auto; white-space: nowrap; }
1048
+ .dfx-menu-hint {
1049
+ flex: none; color: var(--dsw-alias-label-tertiary, #9a9a9a); font-size: 10.5px;
1050
+ font-variant-numeric: tabular-nums; letter-spacing: .02em;
1051
+ }
1052
+ .dfx-menu-sep {
1053
+ height: 1px; margin: 5px 4px;
1054
+ background: var(--dsw-alias-border-l1, rgba(0, 0, 0, .08));
1055
+ }
1056
+ .dfx-overlay { position: fixed; inset: 0; z-index: 95; display: flex; align-items: center; justify-content: center; background: rgba(0, 0, 0, .28); }
1057
+ .dfx-dialog {
1058
+ width: min(420px, calc(100vw - 48px)); padding: 18px 18px 14px; display: flex; flex-direction: column; gap: 10px;
1059
+ border-radius: 14px; background: var(--dsw-alias-bg-layer-1, #fff);
1060
+ border: 1px solid var(--dsw-alias-border-l1, rgba(0, 0, 0, .1));
1061
+ box-shadow: 0 24px 64px rgba(0, 0, 0, .24);
1062
+ }
1063
+ .dfx-dialog-title { font-size: 15px; font-weight: 600; }
1064
+ .dfx-dialog-label { font-size: 12px; color: var(--dsw-alias-label-tertiary, #8f8f8f); }
1065
+ .dfx-dialog-message { font-size: 13px; line-height: 1.6; color: var(--dsw-alias-label-secondary, #5c5c5c); }
1066
+ .dfx-dialog-em { font-weight: 600; color: var(--dsw-alias-label-primary, #1b1b1b); word-break: break-all; }
1067
+ .dfx-dialog-input {
1068
+ height: 34px; padding: 0 10px; border-radius: 9px; font: inherit; outline: none;
1069
+ border: 1px solid var(--dsw-alias-border-l2, rgba(0, 0, 0, .16));
1070
+ background: var(--dsw-alias-bg-layer-2, #fafafa); color: inherit;
1071
+ }
1072
+ .dfx-dialog-input:focus { border-color: var(--dsw-alias-border-brand, #4b7bec); }
1073
+ .dfx-dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 2px; }
1074
+ .dfx-btn {
1075
+ height: 30px; padding: 0 14px; border-radius: 9px; font: inherit; cursor: pointer;
1076
+ border: 1px solid var(--dsw-alias-border-l1, rgba(0, 0, 0, .14));
1077
+ background: transparent; color: inherit;
1078
+ }
1079
+ .dfx-btn:hover:not(:disabled):not(.dfx-btn--primary):not(.dfx-btn--danger) { background: var(--dsw-alias-bg-layer-3, rgba(0, 0, 0, .05)); }
1080
+ .dfx-btn:focus-visible { outline: 2px solid var(--dsw-alias-border-brand, #3b6cf6); outline-offset: 1px; }
1081
+ .dfx-btn--primary { border-color: transparent; background: var(--dsw-alias-bg-brand, #3b6cf6); color: #fff; }
1082
+ .dfx-btn--primary:hover:not(:disabled) { background: var(--dsw-alias-bg-brand-hover, #2f5ce0); }
1083
+ .dfx-btn--primary:active:not(:disabled) { background: var(--dsw-alias-bg-brand-hover, #2f5ce0); filter: brightness(.94); }
1084
+ .dfx-btn--danger { border-color: transparent; background: var(--dsw-alias-bg-danger, #d9534f); color: #fff; }
1085
+ .dfx-btn--danger:hover:not(:disabled) { background: var(--dsw-alias-bg-danger-hover, #c5433f); }
1086
+ .dfx-btn--danger:active:not(:disabled) { background: var(--dsw-alias-bg-danger-hover, #c5433f); filter: brightness(.92); }
1087
+ .dfx-btn:disabled { opacity: .5; cursor: default; }
1088
+ .dfx-opt {
1089
+ width: min(430px, calc(100vw - 40px)); padding: 0; gap: 0; overflow: hidden; border-radius: 20px;
1090
+ border: 1px solid var(--dsw-alias-border-l1, rgba(0, 0, 0, .08));
1091
+ background: var(--dsw-alias-bg-layer-1, #fff);
1092
+ box-shadow: 0 1px 2px rgba(16, 32, 64, .06), 0 18px 48px rgba(16, 32, 64, .18);
1093
+ animation: dfx-about-in .18s cubic-bezier(.2, .8, .3, 1);
1094
+ }
1095
+ .dfx-opt-head {
1096
+ position: relative; display: flex; align-items: center; gap: 10px; padding: 16px 18px 14px;
1097
+ background: linear-gradient(180deg, color-mix(in srgb, var(--dfx-brand) 9%, transparent), transparent);
1098
+ box-shadow: inset 0 -1px 0 var(--dfx-rule, rgba(127, 127, 127, .13));
1099
+ }
1100
+ .dfx-opt-badge {
1101
+ width: 30px; height: 30px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center;
1102
+ background: color-mix(in srgb, var(--dfx-brand) 13%, transparent); color: var(--dfx-brand); flex: 0 0 auto;
1103
+ }
1104
+ .dfx-opt-title { font-size: 14px; font-weight: 600; letter-spacing: .01em; }
1105
+ .dfx-opt-close {
1106
+ margin-left: auto; width: 28px; height: 28px; display: inline-flex; align-items: center; justify-content: center;
1107
+ border: 0; border-radius: 8px; background: transparent; color: var(--dsw-alias-label-tertiary, #8f8f8f); cursor: pointer;
1108
+ }
1109
+ .dfx-opt-close:hover { background: var(--dsw-alias-bg-layer-3, rgba(0, 0, 0, .06)); color: var(--dsw-alias-label-primary, #1b1b1b); }
1110
+ .dfx-opt-body { padding: 2px 18px 4px; }
1111
+ .dfx-opt-section { display: flex; flex-direction: column; gap: 10px; padding: 13px 0; }
1112
+ .dfx-opt-section + .dfx-opt-section { box-shadow: inset 0 1px 0 var(--dfx-rule, rgba(127, 127, 127, .12)); }
1113
+ .dfx-opt-heading { font-size: 10.5px; letter-spacing: .05em; color: var(--dsw-alias-label-tertiary, #8f8f8f); }
1114
+ .dfx-opt-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; min-height: 26px; }
1115
+ .dfx-opt-label { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--dsw-alias-label-primary, #1b1b1b); }
1116
+ .dfx-opt-label svg { color: var(--dsw-alias-label-tertiary, #8f8f8f); }
1117
+ .dfx-opt-hint { font-size: 11.5px; color: var(--dsw-alias-label-tertiary, #8f8f8f); }
1118
+ .dfx-switch {
1119
+ position: relative; width: 38px; height: 22px; flex: 0 0 auto; padding: 0; border: 0; border-radius: 999px;
1120
+ cursor: pointer; background: rgba(127, 127, 127, .3); transition: background-color .16s ease;
1121
+ }
1122
+ .dfx-switch[aria-checked="true"] { background: var(--dfx-brand); }
1123
+ .dfx-switch span {
1124
+ position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff;
1125
+ box-shadow: 0 1px 2px rgba(0, 0, 0, .26); transition: transform .16s ease;
1126
+ }
1127
+ .dfx-switch[aria-checked="true"] span { transform: translateX(16px); }
1128
+ .dfx-switch:disabled { opacity: .45; cursor: default; }
1129
+ .dfx-switch:focus-visible { outline: 2px solid var(--dfx-brand); outline-offset: 2px; }
1130
+ .dfx-seg { display: inline-flex; gap: 1px; padding: 2px; border-radius: 9px; background: var(--dsw-alias-bg-layer-2, #f4f4f4); }
1131
+ .dfx-seg button {
1132
+ display: inline-flex; align-items: center; gap: 5px; padding: 5px 10px; border: 0; border-radius: 7px;
1133
+ background: transparent; font: inherit; font-size: 12px; color: inherit; cursor: pointer;
1134
+ }
1135
+ .dfx-seg button[aria-pressed="true"] {
1136
+ background: var(--dsw-alias-bg-layer-1, #fff); font-weight: 600;
1137
+ box-shadow: 0 1px 2px rgba(0, 0, 0, .12);
1138
+ }
1139
+ .dfx-effects { display: flex; flex-wrap: wrap; gap: 6px; }
1140
+ .dfx-opt-sample { display: flex; gap: 6px; margin-top: 2px; }
1141
+ .dfx-opt-sample span {
1142
+ height: 20px; flex: 1 1 0; border-radius: 6px;
1143
+ background: color-mix(in srgb, var(--dfx-brand) 12%, transparent);
1144
+ }
1145
+ .dfx-opt-sample::after { content: ""; flex: 1 1 0; }
1146
+ .dfx-effect {
1147
+ padding: 6px 12px; border-radius: 999px; font: inherit; font-size: 12px; cursor: pointer;
1148
+ border: 1px solid var(--dsw-alias-border-l1, rgba(0, 0, 0, .12)); background: transparent; color: inherit;
1149
+ }
1150
+ .dfx-effect:hover { background: var(--dsw-alias-bg-layer-3, rgba(0, 0, 0, .05)); }
1151
+ .dfx-effect[aria-pressed="true"] {
1152
+ border-color: transparent; background: color-mix(in srgb, var(--dfx-brand) 13%, transparent);
1153
+ color: var(--dfx-brand); font-weight: 600;
1154
+ }
1155
+ .dfx-effect:disabled { opacity: .45; cursor: default; }
1156
+ .dfx-opt-foot { display: flex; justify-content: flex-end; padding: 12px 18px 16px; }
1157
+ .dfx-about {
1158
+ width: min(400px, calc(100vw - 40px)); padding: 0; gap: 0; overflow: hidden; border-radius: 22px;
1159
+ border: 1px solid var(--dsw-alias-border-l1, rgba(0, 0, 0, .08));
1160
+ background: var(--dsw-alias-bg-layer-1, #fff);
1161
+ box-shadow: 0 1px 2px rgba(16, 32, 64, .06), 0 18px 48px rgba(16, 32, 64, .18);
1162
+ animation: dfx-about-in .18s cubic-bezier(.2, .8, .3, 1);
1163
+ }
1164
+ @keyframes dfx-about-in {
1165
+ from { opacity: 0; transform: translateY(6px) scale(.985); }
1166
+ to { opacity: 1; transform: none; }
1167
+ }
1168
+ .dfx-about-head {
1169
+ position: relative; padding: 26px 22px 22px; text-align: center;
1170
+ background:
1171
+ linear-gradient(180deg, rgba(59, 108, 246, .10), rgba(59, 108, 246, 0)),
1172
+ radial-gradient(120% 90% at 50% 0%, rgba(59, 108, 246, .14), transparent 62%);
1173
+ background:
1174
+ linear-gradient(180deg, color-mix(in srgb, var(--dfx-brand) 9%, transparent), transparent),
1175
+ radial-gradient(120% 90% at 50% 0%, color-mix(in srgb, var(--dfx-brand) 16%, transparent), transparent 62%);
1176
+ }
1177
+ .dfx-about-close {
1178
+ position: absolute; top: 14px; right: 14px; width: 28px; height: 28px; padding: 0;
1179
+ display: grid; place-items: center; border: 0; border-radius: 8px; cursor: pointer;
1180
+ background: transparent; color: var(--dsw-alias-label-secondary, #5c5c5c);
1181
+ transition: background .12s ease, color .12s ease;
1182
+ }
1183
+ .dfx-about-close:hover {
1184
+ background: rgba(127, 127, 127, .16);
1185
+ color: var(--dsw-alias-label-primary, #1b1b1b);
1186
+ }
1187
+ .dfx-about-badge {
1188
+ width: 72px; height: 72px; margin: 0 auto 14px; display: grid; place-items: center; border-radius: 18px;
1189
+ background: rgba(255, 255, 255, .96);
1190
+ border: 1px solid rgba(255, 255, 255, .9);
1191
+ box-shadow: 0 1px 0 rgba(255, 255, 255, .9) inset, 0 6px 14px rgba(24, 44, 92, .10), 0 18px 32px -12px rgba(24, 44, 92, .30);
1192
+ }
1193
+ .dfx-about-name {
1194
+ margin: 0 0 10px; font-size: 22px; font-weight: 680; line-height: 1.15; letter-spacing: -.01em;
1195
+ color: #16327a;
1196
+ color: color-mix(in srgb, var(--dfx-brand) 62%, var(--dsw-alias-label-primary, #10233f));
1197
+ }
1198
+ .dfx-about-version {
1199
+ display: inline-flex; align-items: center; justify-content: center; padding: 7.5px 11px 6.5px;
1200
+ border-radius: 999px; line-height: 1;
1201
+ font-size: 12px; font-weight: 600; letter-spacing: .01em; font-variant-numeric: tabular-nums;
1202
+ color: var(--dfx-brand);
1203
+ background: rgba(255, 255, 255, .72);
1204
+ background: color-mix(in srgb, var(--dsw-alias-bg-layer-1, #fff) 78%, transparent);
1205
+ border: 1px solid rgba(59, 108, 246, .16);
1206
+ border: 1px solid color-mix(in srgb, var(--dfx-brand) 18%, transparent);
1207
+ }
1208
+ .dfx-about-body {
1209
+ display: flex; flex-direction: column; gap: 16px; padding: 18px 20px 16px;
1210
+ }
1211
+ .dfx-about-blurb {
1212
+ margin: 0; text-align: center; font-size: 12.5px; line-height: 1.6;
1213
+ color: var(--dsw-alias-label-secondary, #5c5c5c);
1214
+ }
1215
+ .dfx-about-rows {
1216
+ display: flex; flex-direction: column; overflow: hidden; border-radius: 14px;
1217
+ background: rgba(127, 127, 127, .045);
1218
+ border: 1px solid var(--dsw-alias-border-l1, rgba(0, 0, 0, .07));
1219
+ }
1220
+ .dfx-about-row {
1221
+ display: grid; grid-template-columns: 30px minmax(0, 1fr); gap: 11px; align-items: center; padding: 10px 12px;
1222
+ }
1223
+ .dfx-about-row + .dfx-about-row { border-top: 1px solid var(--dsw-alias-border-l1, rgba(0, 0, 0, .06)); }
1224
+ .dfx-about-ico {
1225
+ width: 30px; height: 30px; display: grid; place-items: center; border-radius: 9px;
1226
+ background: rgba(59, 108, 246, .12);
1227
+ background: color-mix(in srgb, var(--dfx-brand) 12%, transparent);
1228
+ color: var(--dfx-brand);
1229
+ }
1230
+ .dfx-about-text { min-width: 0; display: flex; flex-direction: column; gap: 1px; }
1231
+ .dfx-about-label { font-size: 10.5px; letter-spacing: .02em; color: var(--dsw-alias-label-tertiary, #8f8f8f); }
1232
+ .dfx-about-value {
1233
+ font-size: 12.5px; line-height: 1.4; color: var(--dsw-alias-label-primary, #1b1b1b);
1234
+ word-break: break-all; user-select: text;
1235
+ font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
1236
+ }
1237
+ .dfx-about-value--text { font-family: inherit; font-size: 13px; }
1238
+ .dfx-about-link {
1239
+ color: var(--dfx-brand); text-decoration: none; cursor: pointer;
1240
+ border-bottom: 1px solid transparent; transition: border-color .12s ease;
1241
+ }
1242
+ .dfx-about-link:hover { border-bottom-color: currentColor; }
1243
+ .dfx-about-foot {
1244
+ padding: 12px 20px 14px; text-align: center; font-size: 11px; letter-spacing: .02em;
1245
+ color: var(--dsw-alias-label-tertiary, #9a9a9a);
1246
+ border-top: 1px solid var(--dsw-alias-border-l1, rgba(0, 0, 0, .06));
1247
+ }
1248
+ `;
1249
+
1250
+ /**
1251
+ * Build one icon element. Two kinds of artwork are supported:
1252
+ * - a 24x24 stroke outline: an array of path data strings
1253
+ * - supplied artwork: { viewBox, parts: [{ d, fill }] }, every part painted
1254
+ * @param {Array|object} artwork - path list, or { viewBox, parts }
1255
+ * @param {number|string} size - square edge in pixels ("100%" fills the box)
1256
+ * @returns {object} svg element
1257
+ */
1258
+ function icon(artwork, size) {
1259
+ if (Array.isArray(artwork)) {
1260
+ return h("svg", {
1261
+ width: size, height: size, viewBox: "0 0 24 24", fill: "none",
1262
+ stroke: "currentColor", strokeWidth: 1.6, strokeLinecap: "round", strokeLinejoin: "round",
1263
+ "aria-hidden": "true", focusable: "false",
1264
+ }, artwork.map(function (d, index) { return h("path", { key: index, d: d }); }));
1265
+ }
1266
+ return h("svg", {
1267
+ width: size, height: size, viewBox: artwork.viewBox || "0 0 24 24",
1268
+ fill: "none", stroke: "none",
1269
+ "aria-hidden": "true", focusable: "false",
1270
+ }, (artwork.parts || []).map(function (part, index) {
1271
+ return h("path", {
1272
+ key: index,
1273
+ d: part.d,
1274
+ fill: part.fill || "currentColor",
1275
+ opacity: part.opacity,
1276
+ fillRule: part.fillRule,
1277
+ });
1278
+ }));
1279
+ }
1280
+
1281
+ /** Named icon shapes (arrays of SVG path data). */
1282
+ var SHAPES = {
1283
+ folder: ["M3 7.5A1.5 1.5 0 0 1 4.5 6h4l1.8 2.2h8.2A1.5 1.5 0 0 1 20 9.7v7.8A1.5 1.5 0 0 1 18.5 19h-14A1.5 1.5 0 0 1 3 17.5z"],
1284
+ // Supplied artwork: 1024-grid, one translucent body behind the solid tab.
1285
+ folderFilled: {
1286
+ viewBox: "26.8 26.8 969.3 969.3",
1287
+ parts: [
1288
+ { d: "M85.333333 296.533333c0-37.688889 0-56.490667 2.986667-72.192a170.666667 170.666667 0 0 1 135.964444-136.021333C240.071111 85.333333 258.929778 85.333333 296.533333 85.333333c16.469333 0 24.746667 0 32.682667 0.739556a170.666667 170.666667 0 0 1 93.013333 38.570667c6.144 5.063111 11.946667 10.865778 23.637334 22.556444L469.333333 170.666667c34.816 34.816 52.224 52.224 73.045334 63.772444 11.434667 6.4 23.608889 11.434667 36.181333 15.018667 22.954667 6.542222 47.559111 6.542222 96.768 6.542222h15.957333c112.298667 0 168.504889 0 204.970667 32.853333 3.384889 2.986667 6.570667 6.200889 9.557333 9.557334C938.666667 334.904889 938.666667 391.082667 938.666667 503.381333V597.333333c0 160.910222 0 241.351111-50.005334 291.328C838.684444 938.666667 758.243556 938.666667 597.333333 938.666667h-170.666666c-160.881778 0-241.379556 0-291.328-50.005334C85.333333 838.684444 85.333333 758.243556 85.333333 597.333333V296.533333z", fill: "#4096FF", opacity: ".5" },
1289
+ { d: "M853.333333 266.154667c0-12.714667-0.227556-20.252444-1.080889-26.88a128 128 0 0 0-110.193777-110.165334c-8.334222-1.109333-18.204444-1.109333-38.058667-1.109333h-277.845333c4.949333 4.437333 10.524444 9.984 19.712 19.2L469.333333 170.666667c34.816 34.816 52.224 52.224 73.045334 63.772444 11.463111 6.4 23.608889 11.434667 36.209777 15.018667 22.926222 6.542222 47.530667 6.542222 96.768 6.542222h15.928889c75.946667 0 126.151111 0 162.048 10.154667zM522.666667 426.666667a32 32 0 0 1 32-32H768a32 32 0 1 1 0 64h-213.333333A32 32 0 0 1 522.666667 426.666667z", fill: "#4096FF" },
1290
+ ],
1291
+ },
1292
+ // The supplied app icon (purple folder), normalised like the rest: long edge at 88%.
1293
+ appIcon: {
1294
+ viewBox: "26.8 26.8 969.3 969.3",
1295
+ parts: [
1296
+ { d: "M566.8864 236.288C464.4352 178.944 480.768 112.64 412.5184 112.64H293.376c-106.7008 0-193.1776 86.4768-193.1776 193.1776v236.3392h466.688V236.288z", fill: "#7A7AF9" },
1297
+ { d: "M737.4848 911.2064H302.1312c-111.5648 0-201.984-90.4192-201.984-201.984V438.272c0-111.5648 90.4192-201.984 201.984-201.984h435.3024c111.5648 0 201.984 90.4192 201.984 201.984v270.9504c0 111.5136-90.4192 201.984-201.9328 201.984z", fill: "#CCDAFF" },
1298
+ { d: "M713.6768 674.1504H321.3824c-26.5216 0-47.9744-21.504-47.9744-47.9744 0-26.5216 21.504-47.9744 47.9744-47.9744h392.2944c26.5216 0 47.9744 21.504 47.9744 47.9744 0 26.4704-21.504 47.9744-47.9744 47.9744z", fill: "#7A7AF9" },
1299
+ ],
1300
+ },
1301
+ // Anything the classifier does not recognise.
1302
+ fileOther: {
1303
+ viewBox: "-27.8 -27.8 1080.7 1080.7",
1304
+ parts: [
1305
+ { d: "M109.735331 854.410158A132.966758 132.966758 0 0 0 242.702089 987.376916h538.595822A132.966758 132.966758 0 0 0 914.264669 854.373588V307.183929L643.650255 36.569515H242.702089A132.966758 132.966758 0 0 0 109.735331 169.536273v684.873885z", fill: "#CCCDD2" },
1306
+ { d: "M643.650255 240.70055c0 36.715793 29.767586 66.483379 66.483379 66.483379H914.264669L643.650255 36.569515v204.131035z", fill: "#ABAEB8" },
1307
+ { d: "M658.278062 431.556851h-292.556124a29.255612 29.255612 0 0 1 0-58.511224h292.556124a29.255612 29.255612 0 0 1 0 58.511224z m0 146.278062h-292.556124a29.255612 29.255612 0 0 1 0-58.511225h292.556124a29.255612 29.255612 0 0 1 0 58.511225z m0 146.278062h-292.556124a29.255612 29.255612 0 0 1 0-58.511225h292.556124a29.255612 29.255612 0 0 1 0 58.511225z", fill: "#91949E" },
1308
+ ],
1309
+ },
1310
+ fileText: {
1311
+ viewBox: "-16.5 -14.5 1058 1058",
1312
+ parts: [
1313
+ { d: "M221.77 49.09c-64.496 0-116.51 52.014-116.51 116.51v698.01c0 64.496 52.014 116.51 116.51 116.51h582.02c63.975 0 115.99-52.014 115.99-116.51V339.84l-0.27-0.27H744.75c-4.031 0-8.016-0.203-11.94-0.6a116.896 116.896 0 0 1-11.59-1.76 115.992 115.992 0 0 1-21.89-6.78 115.838 115.838 0 0 1-10.19-4.89 116.129 116.129 0 0 1-9.6-5.83 116.626 116.626 0 0 1-24.75-22.48 116.456 116.456 0 0 1-6.7-8.96 116.206 116.206 0 0 1-5.82-9.61 115.923 115.923 0 0 1-8.81-20.9 116.698 116.698 0 0 1-4.62-22.76c-0.397-3.924-0.6-7.91-0.6-11.94l0.52-173.97H221.77z m442.15 0l-0.45 149.53c-0.044 18.255 4.672 36.507 13.69 52.39 11.504 20.48 30.028 36.915 51.75 45.86 13.318 5.547 27.781 8.254 42.2 8.08h148.67L663.92 49.09zM308.13 509.9c0.9 0.049 1.964-0.166 2.76 0.05l403.18-0.01c4.388-0.047 8.816-0.146 13.14 0.75 10.273 1.907 19.527 8.327 25.11 17.13 4.27 6.6 6.197 14.53 6.02 22.35 0.302 7.946-1.705 16.004-5.95 22.75-6.647 10.776-18.965 17.694-31.6 17.95-134.025 0.035-268.057 0.03-402.08 0.03-5.054-0.08-10.113 0.188-15.16-0.14-10.508-0.655-20.546-5.992-27.14-14.17-5.893-7.138-8.795-16.486-8.58-25.69-0.296-7.598 1.5-15.3 5.4-21.85 6.717-11.5 19.678-19.09 33.02-19.11l1.88-0.04z m0 222.62c0.9 0.049 1.964-0.176 2.76 0.04l399.81-0.01c5.371 0.09 10.791-0.369 16.1 0.68 10.249 1.788 19.551 8.05 25.22 16.75 4.48 6.68 6.501 14.804 6.32 22.8 0.299 7.921-1.69 15.947-5.91 22.68-6.647 10.82-19.005 17.778-31.68 18.02-133.97 0.035-267.941 0.03-401.91 0.03-5.084-0.079-10.175 0.182-15.25-0.14-10.594-0.645-20.704-6.054-27.31-14.33-5.8-7.123-8.664-16.39-8.45-25.53-0.298-7.617 1.511-15.348 5.43-21.91 6.723-11.462 19.66-19.024 32.97-19.05l1.9-0.03z", fill: "#72A9FE" },
1314
+ ],
1315
+ },
1316
+ filePdf: {
1317
+ viewBox: "-15.8 -6.3 1055.7 1055.7",
1318
+ parts: [
1319
+ { d: "M663.950222 56.888889H260.323556A146.545778 146.545778 0 0 0 113.777778 203.434667v635.505777a146.545778 146.545778 0 0 0 146.545778 146.545778h503.352888A146.545778 146.545778 0 0 0 910.222222 838.940444V303.104c0-32.995556-13.084444-64.625778-36.408889-87.950222L751.900444 93.297778c-23.324444-23.324444-55.011556-36.408889-88.007111-36.408889z", fill: "#FF7878" },
1320
+ { d: "M873.813333 215.153778L751.900444 93.297778a124.416 124.416 0 0 0-64.056888-34.133334v136.760889c0 43.463111 35.214222 78.620444 78.620444 78.620445h140.344889a124.472889 124.472889 0 0 0-33.109333-59.392z m-219.591111 350.435555c-23.665778 0-47.104 3.413333-70.712889 7.907556a338.488889 338.488889 0 0 1-69.404444-89.770667c19.114667-62.862222 20.138667-105.528889 5.632-125.724444a36.977778 36.977778 0 0 0-29.127111-14.563556 35.84 35.84 0 0 0-34.702222 17.976889c-20.195556 33.792 9.102222 100.124444 22.584888 126.976-15.530667 48.298667-34.702222 94.378667-59.335111 139.264-106.609778 46.08-108.828444 74.183111-108.828444 84.252445 0 12.344889 6.656 24.689778 19.000889 30.321777a29.752889 29.752889 0 0 0 16.725333 4.437334c28.046222 0 60.586667-31.516444 95.288889-93.297778 43.804444-18.033778 87.438222-32.597333 133.518222-42.666667 23.608889 20.195556 52.679111 31.516444 82.944 33.735111 19.228444 0 56.149333 0 55.751111-38.4 1.194667-14.563556-6.656-39.253333-59.392-40.391111z m-306.631111 147.114667l-3.413333 1.194667c9.955556-14.563556 23.096889-25.941333 39.822222-32.824889a70.542222 70.542222 0 0 1-36.408889 31.630222z m137.443556-334.279111c1.080889-1.137778 3.299556-2.389333 4.551111-2.389333l3.754666 1.194666c5.688889 19.114667 5.688889 39.253333-1.308444 58.083556-8.248889-17.863111-11.605333-37.944889-6.997333-56.888889z m58.254222 217.656889c-24.462222 5.688889-51.370667 13.653333-75.889778 22.641778l-2.503111 0.967111 0.284444-1.991111c12.288-24.860444 23.495111-50.972444 33.564445-77.027556l1.137778-2.56 1.251555 1.536c12.458667 19.171556 28.216889 38.912 45.056 55.808l-2.901333 0.625778z m115.256889 14.108444a92.330667 92.330667 0 0 1-33.564445-8.647111c10.012444-2.218667 18.887111-2.218667 28.899556-2.218667 22.357333 0 26.737778 5.518222 26.965333 8.704-6.656 2.161778-14.449778 3.356444-22.300444 2.161778z", fill: "#F25555" },
1321
+ { d: "M653.880889 586.922667c-10.069333 0-18.887111 0-28.956445 2.161777 11.264 5.518222 22.357333 7.68 33.564445 8.647112 7.907556 1.137778 15.701333 0 22.357333-2.161778-0.170667-3.128889-4.608-8.647111-26.965333-8.647111zM501.191111 527.189333l-1.194667-1.479111-1.251555 2.503111c-10.012444 26.112-21.276444 52.167111-33.507556 77.027556l-0.284444 2.048 2.503111-1.024c24.462222-8.988444 51.370667-16.896 75.889778-22.584889l2.844444-0.682667a355.896889 355.896889 0 0 1-44.999111-55.751111z m-7.793778-162.417777l-3.697777-1.194667c-1.308444 0-3.527111 1.194667-4.551112 2.446222-4.664889 18.887111-1.308444 38.968889 6.997334 56.888889 6.940444-18.944 6.940444-39.025778 1.251555-58.140444zM344.177778 701.44l3.413333-1.194667c15.530667-5.688889 27.648-16.782222 36.408889-31.573333-16.725333 6.826667-29.866667 18.204444-39.822222 32.768z m313.628444-69.404444a143.075556 143.075556 0 0 1-82.944-33.792c-46.08 10.069333-89.656889 24.632889-133.518222 42.666666-34.702222 61.838222-67.242667 93.297778-95.288889 93.297778a29.752889 29.752889 0 0 1-16.725333-4.380444 33.109333 33.109333 0 0 1-19.000889-30.321778c0-10.126222 2.218667-38.229333 108.828444-84.309334 24.632889-44.885333 43.804444-90.965333 59.335111-139.264-13.482667-26.908444-42.780444-93.184-22.584888-126.919111a35.84 35.84 0 0 1 34.702222-18.033777c11.377778 0 22.414222 5.688889 29.127111 14.563555 14.506667 20.252444 13.482667 62.862222-5.688889 125.724445a338.488889 338.488889 0 0 0 69.461333 89.770666 382.179556 382.179556 0 0 1 70.656-7.850666c52.736 1.137778 60.586667 25.827556 59.392 40.391111 0.398222 38.4-36.522667 38.4-55.751111 38.4z", fill: "#FFFFFF" },
1322
+ ],
1323
+ },
1324
+ fileWord: {
1325
+ viewBox: "2.9 2.9 1018.2 1018.2",
1326
+ parts: [
1327
+ { d: "M658.78 64.39H269.46c-78.06 0-141.33 63.28-141.33 141.33v612.95c0 78.06 63.28 141.33 141.33 141.33h485.49c78.06 0 141.33-63.28 141.33-141.33V301.88c0-31.83-12.64-62.35-35.15-84.85l-117.5-117.5a120.008 120.008 0 0 0-84.85-35.14z", fill: "#53B7F4" },
1328
+ { d: "M647.85 360.65c-13.25 0-24 10.75-24 24v226.26l-94.35-93.29c-9.33-9.22-24.34-9.25-33.69-0.05l-95.26 93.6V383.99c0-13.25-10.75-24-24-24s-24 10.75-24 24V668.4c0 9.67 5.8 18.39 14.72 22.13a24.002 24.002 0 0 0 26.1-5.01L512.58 568.4l118.4 117.07a23.993 23.993 0 0 0 16.88 6.93c3.11 0 6.25-0.61 9.24-1.85a24 24 0 0 0 14.75-22.15V384.65c0-13.25-10.74-24-24-24z m213.28-143.62l-117.5-117.5a120.001 120.001 0 0 0-61.75-32.9v131.88c0 41.87 33.94 75.81 75.81 75.81h135.37a119.975 119.975 0 0 0-31.93-57.29z", fill: "#29A3D3" },
1329
+ { d: "M647.86 680.4c-6.2 0-12.3-2.4-16.88-6.93L512.58 556.4 393.37 673.52a23.99 23.99 0 0 1-26.1 5.01 23.992 23.992 0 0 1-14.72-22.13V371.99c0-13.25 10.75-24 24-24s24 10.75 24 24v227.19l95.26-93.6c9.36-9.19 24.37-9.17 33.69 0.05l94.35 93.29V372.65c0-13.25 10.75-24 24-24s24 10.75 24 24V656.4c0 9.68-5.82 18.42-14.75 22.15a24.112 24.112 0 0 1-9.24 1.85z", fill: "#FFFFFF" },
1330
+ ],
1331
+ },
1332
+ fileExcel: {
1333
+ viewBox: "-21.5 -21 1067 1067",
1334
+ parts: [
1335
+ { d: "M174.08 42.666667c-11.52 0-23.808 4.693333-32.256 14.08-8.448 9.386667-13.824 21.12-13.824 32.853333v844.8c0 11.733333 4.608 24.234667 13.824 32.853333 9.216 9.386667 20.736 14.08 32.256 14.08h675.84c11.52 0 23.808-4.693333 32.256-14.08 9.216-9.386667 13.824-21.12 13.824-32.853333V308.608L634.88 42.666667H174.08z", fill: "#3DC188" },
1336
+ { d: "M896 308.608h-215.04c-11.52 0-23.808-4.693333-32.256-14.08a45.44 45.44 0 0 1-13.824-32.853333V42.666667L896 308.608z", fill: "#B4EBD3" },
1337
+ { d: "M476.672 537.045333L372.224 388.394667h72.192l68.352 106.410666 71.424-106.410666h69.888l-106.752 148.650666 112.128 157.994667h-72.96l-75.264-112.64-75.264 113.408H364.544z", fill: "#FFFFFF" },
1338
+ ],
1339
+ },
1340
+ filePpt: {
1341
+ viewBox: "2.9 2.9 1018.2 1018.2",
1342
+ parts: [
1343
+ { d: "M658.56 63.914667H269.269333A141.312 141.312 0 0 0 127.914667 205.226667v612.992a141.312 141.312 0 0 0 141.354666 141.312h485.461334a141.312 141.312 0 0 0 141.354666-141.354667V301.44c0-31.829333-12.629333-62.293333-35.157333-84.821333l-117.504-117.504a120.021333 120.021333 0 0 0-84.864-35.157334z", fill: "#F98950" },
1344
+ { d: "M860.928 216.576l-117.504-117.504a119.978667 119.978667 0 0 0-61.738667-32.896v131.84c0 41.898667 33.92 75.861333 75.818667 75.861333h135.338667a119.893333 119.893333 0 0 0-31.914667-57.301333z m-304.896 131.797333H380.373333a24.021333 24.021333 0 0 0-24.021333 23.978667v302.762667a24.021333 24.021333 0 0 0 48 0v-79.530667h151.68a123.733333 123.733333 0 0 0 123.605333-123.605333 123.733333 123.733333 0 0 0-123.605333-123.605334z m0 199.210667H404.352V396.373333h151.68c41.685333 0 75.605333 33.92 75.605333 75.605334s-33.92 75.605333-75.605333 75.605333z", fill: "#F26C38" },
1345
+ { d: "M556.032 336.426667H380.373333a24.021333 24.021333 0 0 0-24.021333 23.978666v302.762667a24.021333 24.021333 0 0 0 48 0v-79.530667h151.68a123.733333 123.733333 0 0 0 123.605333-123.605333 123.733333 123.733333 0 0 0-123.605333-123.605333z m0 199.210666H404.352V384.426667h151.68c41.685333 0 75.605333 33.92 75.605333 75.605333s-33.92 75.605333-75.605333 75.605333z", fill: "#FFFFFF" },
1346
+ ],
1347
+ },
1348
+ fileArchive: {
1349
+ viewBox: "-21.5 -21 1067 1067",
1350
+ parts: [
1351
+ { d: "M640 42.666667l256 256v597.333333c0 46.933333-38.4 85.333333-85.333333 85.333333H213.333333c-46.933333 0-85.333333-38.4-85.333333-85.333333V128c0-46.933333 38.4-85.333333 85.333333-85.333333h426.666667z", fill: "#FFB133" },
1352
+ { d: "M640 42.666667v170.666666c0 46.933333 38.4 85.333333 85.333333 85.333334h170.666667l-256-256z", fill: "#FFC878" },
1353
+ { d: "M554.666667 597.333333v140.8c0 8.533333-4.266667 17.066667-8.533334 21.333334-4.266667 4.266667-12.8 8.533333-21.333333 8.533333h-64c-8.533333 0-17.066667-4.266667-21.333333-8.533333-4.266667-4.266667-8.533333-12.8-8.533334-21.333334V597.333333H554.666667z m-29.866667 85.333334h-64v64h64V682.666667z m29.866667-196.266667v64h-64v-64H554.666667zM490.666667 42.666667v64H554.666667V170.666667h-64v59.733333H554.666667v64h-64v64H554.666667v64h-64v64H426.666667V418.133333h64V354.133333H426.666667V294.4h64V230.4H426.666667V166.4h64V106.666667H426.666667V42.666667h64z", fill: "#FFFFFF" },
1354
+ ],
1355
+ },
1356
+ fileImage: {
1357
+ viewBox: "10.6 13.1 997.7 997.7",
1358
+ parts: [
1359
+ { d: "M897.463 314.514v538.82a97.524 97.524 0 0 1-97.524 97.523H214.796a97.524 97.524 0 0 1-97.524-97.524V170.667a97.524 97.524 0 0 1 97.524-97.524h441.295z", fill: "#85BCFF" },
1360
+ { d: "M660.724 216.99V73.143l241.371 241.371H758.248a97.524 97.524 0 0 1-97.524-97.524z", fill: "#529EE0" },
1361
+ { d: "M336.701 372.785h341.333q48.762 0 48.762 48.762V700.22q0 48.762-48.762 48.762H336.701q-48.762 0-48.762-48.762V421.547q0-48.762 48.762-48.762z", fill: "#FFFFFF" },
1362
+ { d: "M375.954 460.069a29.013 29.013 0 1 0 58.027 0 29.013 29.013 0 1 0-58.027 0zM487.619 641.463l-73.143-56.32-83.383 85.577v28.526a19.992 19.992 0 0 0 20.724 19.017h312.32a20.236 20.236 0 0 0 20.968-19.017V585.143l-73.143-75.825z", fill: "#85BCFF" },
1363
+ ],
1364
+ },
1365
+ fileAudio: {
1366
+ viewBox: "-15.8 -6.3 1055.7 1055.7",
1367
+ parts: [
1368
+ { d: "M663.950222 56.888889H260.323556A146.545778 146.545778 0 0 0 113.777778 203.434667v635.505777a146.545778 146.545778 0 0 0 146.545778 146.545778h503.352888A146.545778 146.545778 0 0 0 910.222222 838.940444V303.217778c0-32.995556-13.084444-64.682667-36.408889-88.007111l-121.856-121.799111C728.632889 69.973333 696.888889 56.888889 663.893333 56.888889z", fill: "#FF9640" },
1369
+ { d: "M873.813333 215.153778l-121.856-121.799111a124.416 124.416 0 0 0-64.056889-34.133334v136.760889c0 43.406222 35.214222 78.563556 78.620445 78.563556h140.344889a124.359111 124.359111 0 0 0-33.109334-59.392z", fill: "#F9C499" },
1370
+ { d: "M718.563556 489.130667a56.263111 56.263111 0 0 1-8.419556 20.252444c-3.356444 5.12-6.712889 8.533333-10.126222 6.826667-3.356444 0-5.12-22.016-6.712889-25.429334a65.592889 65.592889 0 0 1-5.063111-18.545777c-1.706667-13.539556-6.712889-25.429333-15.189334-30.435556-8.419556-6.826667-20.195556-11.889778-35.384888-15.303111a111.104 111.104 0 0 1-45.568-20.195556c-13.482667-10.183111-28.672-18.602667-37.091556-28.785777-8.476444-8.419556-15.189333-10.183111-18.545778-8.419556-5.063111 1.706667-6.712889 6.769778-6.712889 11.832889v314.424889c0 8.533333-1.706667 18.602667-5.12 28.785778-3.299556 10.183111-5.063111 20.252444-13.482666 30.378666-8.419556 10.24-20.195556 16.952889-35.384889 23.722667s-33.735111 10.183111-54.044445 11.832889a122.311111 122.311111 0 0 1-60.643555-11.832889 121.059556 121.059556 0 0 1-42.154667-32.142222 69.461333 69.461333 0 0 1-15.246222-43.975111c0-15.189333 6.826667-30.378667 21.959111-43.918223a109.795556 109.795556 0 0 1 45.511111-28.785777c16.896-5.12 32.085333-8.419556 47.217778-8.419556 15.246222 0 38.855111 0 50.631111 3.413333 11.776 3.356444 20.252444 5.063111 27.022222 6.712889v-299.235555c0-10.24 3.356444-18.602667 8.419556-25.315556 5.063111-6.826667 13.482667-10.24 21.902222-11.889778 8.476444-1.706667 15.189333 0 20.252444 5.12 5.12 3.356444 0 10.126222 6.712889 16.839112 5.12 6.826667 11.832889 15.303111 20.309334 25.372444 8.419556 10.24 18.488889 18.602667 31.971555 27.079111 11.832889 8.419556 21.959111 13.482667 30.378667 18.602667 8.419556 3.356444 16.896 6.769778 23.665778 10.183111 6.712889 3.356444 15.132444 6.712889 21.902222 11.776 6.712889 5.12 15.189333 11.832889 23.552 22.016 8.476444 10.183111 13.482667 18.545778 15.246222 28.728889 0 10.183111 0 20.252444-1.706667 28.728889z", fill: "#FFFFFF" },
1371
+ ],
1372
+ },
1373
+ fileVideo: {
1374
+ viewBox: "3.9 2.9 1018.2 1018.2",
1375
+ parts: [
1376
+ { d: "M928 310.3v550.3c0 55-44.6 99.6-99.6 99.6H197.6c-55 0-99.6-44.6-99.6-99.6V163.4c0-55 44.6-99.6 99.6-99.6h483.9L928 310.3z", fill: "#C386F0" },
1377
+ { d: "M592.1 412.4H330.6c-24.9 0-37.3 12.4-37.3 37.3v205.4c0 24.9 12.4 37.3 37.3 37.3H592c24.9 0 37.3-12.4 37.3-37.3V449.8c0.1-24.9-12.3-37.4-37.2-37.4zM728.9 474.8c-7.8-13.4-24.9-17.9-38.3-10.2l-47.3 27.2V621l47.3 27.3c18.7 10.8 42-2.7 42-24.3V488.8c0.1-4.9-1.2-9.8-3.7-14z", fill: "#FFFFFF" },
1378
+ { d: "M681.5 210.7V63.8L928 310.3H781.1c-55 0-99.6-44.5-99.6-99.6", fill: "#A15FDE" },
1379
+ ],
1380
+ },
1381
+ file: ["M6 3.5h7l5 5v12a1 1 0 0 1-1 1H6a1 1 0 0 1-1-1v-16a1 1 0 0 1 1-1z", "M13 3.5v5h5"],
1382
+ up: ["M12 19.6V5", "M4.8 11.6l7.2-6.6 7.2 6.6"],
1383
+ home: ["M3.6 10.6l8.4-7 8.4 7", "M6 9.4V20.6h12V9.4"],
1384
+ refresh: ["M20.4 12a8.4 8.4 0 1 1-2.6-6.05", "M20.4 3.8v5.6h-5.6"],
1385
+ search: ["M11 18a7 7 0 1 0 0-14 7 7 0 0 0 0 14z", "M16.2 16.2L21 21"],
1386
+ chevron: ["M9 5l7 7-7 7"],
1387
+ upload: ["M12 16V4m0 0L7.5 8.5M12 4l4.5 4.5", "M5 15.5v2A2.5 2.5 0 0 0 7.5 20h9a2.5 2.5 0 0 0 2.5-2.5v-2"],
1388
+ download: ["M12 4v12m0 0l4.5-4.5M12 16l-4.5-4.5", "M5 15.5v2A2.5 2.5 0 0 0 7.5 20h9a2.5 2.5 0 0 0 2.5-2.5v-2"],
1389
+ archive: ["M4 4h16v5H4z", "M5.5 9v9.5A1.5 1.5 0 0 0 7 20h10a1.5 1.5 0 0 0 1.5-1.5V9", "M10.5 13h3"],
1390
+ copy: ["M9 9h9.5A1.5 1.5 0 0 1 20 10.5V20a1 1 0 0 1-1 1H9a1 1 0 0 1-1-1V10a1 1 0 0 1 1-1z", "M5 15H4.5A.5.5 0 0 1 4 14.5V4a1 1 0 0 1 1-1h9.5a.5.5 0 0 1 .5.5V5"],
1391
+ reveal: ["M4 7.5A1.5 1.5 0 0 1 5.5 6h4l1.8 2.2h7.2A1.5 1.5 0 0 1 20 9.7v7.8A1.5 1.5 0 0 1 18.5 19h-13A1.5 1.5 0 0 1 4 17.5z", "M14 4l3 3-3 3", "M9 7h8"],
1392
+ eye: ["M2.5 12S6 6.5 12 6.5 21.5 12 21.5 12 18 17.5 12 17.5 2.5 12 2.5 12z", "M12 15a3 3 0 1 0 0-6 3 3 0 0 0 0 6z"],
1393
+ hidden: ["M4 4l16 16", "M9.9 5.1A9.9 9.9 0 0 1 12 4.9c6 0 10.5 7.1 10.5 7.1a17 17 0 0 1-3.4 4.1", "M6.6 6.6A17.4 17.4 0 0 0 1.5 12S6 19.1 12 19.1a10 10 0 0 0 3.5-.6"],
1394
+ pencil: ["M4.5 19.5l.9-3.7L16.1 5.1a1.6 1.6 0 0 1 2.3 0l.5.5a1.6 1.6 0 0 1 0 2.3L8.2 18.6l-3.7.9z", "M14.6 6.6l2.8 2.8"],
1395
+ scissors: ["M7 4.5l9.5 11.5", "M17 4.5L7.5 16", "M9.4 15.6a2.4 2.4 0 1 1-3.4 3.4 2.4 2.4 0 0 1 3.4-3.4z", "M14.6 15.6a2.4 2.4 0 1 0 3.4 3.4 2.4 2.4 0 0 0-3.4-3.4z"],
1396
+ trash: ["M4 7h16", "M9.5 7V5.4A1.4 1.4 0 0 1 10.9 4h2.2a1.4 1.4 0 0 1 1.4 1.4V7", "M6.5 7l.9 12.1a1.5 1.5 0 0 0 1.5 1.4h6.2a1.5 1.5 0 0 0 1.5-1.4L17.5 7", "M10.5 11v6", "M13.5 11v6"],
1397
+ folderPlus: ["M3 7.5A1.5 1.5 0 0 1 4.5 6h4l1.8 2.2h8.2A1.5 1.5 0 0 1 20 9.7v7.8A1.5 1.5 0 0 1 18.5 19h-14A1.5 1.5 0 0 1 3 17.5z", "M12 11.5v5", "M9.5 14h5"],
1398
+ filePlus: ["M6 3.5h7l5 5v12a1 1 0 0 1-1 1H6a1 1 0 0 1-1-1v-16a1 1 0 0 1 1-1z", "M13 3.5v5h5", "M12 13v5", "M9.5 15.5h5"],
1399
+ paste: ["M9 5.5h6", "M8 5.5H6.5A1.5 1.5 0 0 0 5 7v12.5A1.5 1.5 0 0 0 6.5 21h11a1.5 1.5 0 0 0 1.5-1.5V7a1.5 1.5 0 0 0-1.5-1.5H16"],
1400
+ link: ["M10.2 13.8a4 4 0 0 1 0-5.6l1.9-1.9a4 4 0 1 1 5.6 5.6l-1.1 1.1", "M13.8 10.2a4 4 0 0 1 0 5.6l-1.9 1.9a4 4 0 1 1-5.6-5.6l1.1-1.1"],
1401
+ text: ["M5 6h14", "M12 6v12", "M9 18h6"],
1402
+ external: ["M14 4h6v6", "M20 4l-8 8", "M18.5 14v5.5A1.5 1.5 0 0 1 17 21H5.5A1.5 1.5 0 0 1 4 19.5V8a1.5 1.5 0 0 1 1.5-1.5H11"],
1403
+ squares: ["M4 5.5A1.5 1.5 0 0 1 5.5 4h6A1.5 1.5 0 0 1 13 5.5v6A1.5 1.5 0 0 1 11.5 13h-6A1.5 1.5 0 0 1 4 11.5z", "M11 15.5A1.5 1.5 0 0 1 12.5 14h6a1.5 1.5 0 0 1 1.5 1.5v4a1.5 1.5 0 0 1-1.5 1.5h-6a1.5 1.5 0 0 1-1.5-1.5z"],
1404
+ viewList: ["M4 7h.01", "M8 7h12", "M4 12h.01", "M8 12h12", "M4 17h.01", "M8 17h12"],
1405
+ viewGrid: ["M4 4.5h6v6H4z", "M14 4.5h6v6h-6z", "M4 13.5h6v6H4z", "M14 13.5h6v6h-6z"],
1406
+ info: ["M12 21a9 9 0 1 0 0-18 9 9 0 0 0 0 18z", "M12 11v5.5", "M12 7.6h.01"],
1407
+ chevronDown: ["M6 9.5l6 6 6-6"],
1408
+ plus: ["M12 5v14", "M5 12h14"],
1409
+ check: ["M5 12.5l4.5 4.5L19 7"],
1410
+ undo: ["M4 9h9.5a5 5 0 0 1 0 10H8", "M7.5 5.5L4 9l3.5 3.5"],
1411
+ sortIcon: ["M4 7h9", "M4 12h6", "M4 17h3", "M18 5.5v13", "M15 15.5l3 3 3-3"],
1412
+ moreIcon: ["M6 12h.01", "M12 12h.01", "M18 12h.01"],
1413
+ pane: ["M3.5 5.5h17v13h-17z", "M15 5.5v13"],
1414
+ close: ["M7 7l10 10", "M17 7L7 17"],
1415
+ user: ["M12 12.2a3.7 3.7 0 1 0 0-7.4 3.7 3.7 0 0 0 0 7.4", "M4.8 19.6c.7-3.3 3.7-5.2 7.2-5.2s6.5 1.9 7.2 5.2"],
1416
+ tag: ["M4.2 12.6V5.7A1.5 1.5 0 0 1 5.7 4.2h6.9l7.2 7.2a1.5 1.5 0 0 1 0 2.1l-6.3 6.3a1.5 1.5 0 0 1-2.1 0z", "M8.1 8.1h.01"],
1417
+ shield: ["M12 3.6 4.8 6.2v5.9c0 4.2 3 7.3 7.2 8.4 4.2-1.1 7.2-4.2 7.2-8.4V6.2z", "M8.9 12.2l2.1 2.1 4.1-4.2"],
1418
+ clip: ["M15.6 8.4l-6.1 6.1a2.1 2.1 0 1 0 3 3l6.1-6.1a4.2 4.2 0 0 0-6-6l-6.1 6.1a6.3 6.3 0 0 0 9 9l5.1-5.1"],
1419
+ at: ["M16 12a4 4 0 1 0-8 0 4 4 0 0 0 8 0z", "M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8"],
1420
+ briefcase: [
1421
+ "M4 9.2A1.6 1.6 0 0 1 5.6 7.6h12.8A1.6 1.6 0 0 1 20 9.2V17a1.6 1.6 0 0 1-1.6 1.6H5.6A1.6 1.6 0 0 1 4 17z",
1422
+ "M9 7.6V6.1a1.2 1.2 0 0 1 1.2-1.2h3.6A1.2 1.2 0 0 1 15 6.1v1.5",
1423
+ ],
1424
+ sliders: [
1425
+ "M4 7h4.6", "M13.4 7H20", "M11 5.6a1.4 1.4 0 1 0 0 2.8 1.4 1.4 0 0 0 0-2.8",
1426
+ "M4 12h8.6", "M17.4 12H20", "M15 10.6a1.4 1.4 0 1 0 0 2.8 1.4 1.4 0 0 0 0-2.8",
1427
+ "M4 17h2.6", "M11.4 17H20", "M9 15.6a1.4 1.4 0 1 0 0 2.8 1.4 1.4 0 0 0 0-2.8",
1428
+ ],
1429
+ };
1430
+
1431
+ /**
1432
+ * Render a named icon.
1433
+ * @param {string} name - shape name
1434
+ * @param {number} size - square edge
1435
+ * @returns {object} svg element
1436
+ */
1437
+ function glyph(name, size) {
1438
+ return icon(SHAPES[name] || SHAPES.file, size);
1439
+ }
1440
+
1441
+ /**
1442
+ * The icon shape an entry should use.
1443
+ * @param {object} entry - listing row
1444
+ * @returns {string} shape name
1445
+ */
1446
+ function entryShape(entry) {
1447
+ if (!entry) return "file";
1448
+ if (entry.dir) return "folderFilled";
1449
+ var byKind = {
1450
+ text: "fileText",
1451
+ image: "fileImage",
1452
+ pdf: "filePdf",
1453
+ word: "fileWord",
1454
+ excel: "fileExcel",
1455
+ ppt: "filePpt",
1456
+ archive: "fileArchive",
1457
+ audio: "fileAudio",
1458
+ video: "fileVideo",
1459
+ };
1460
+ return byKind[entry.kind] || "fileOther";
1461
+ }
1462
+
1463
+ /**
1464
+ * Human label for an entry's kind, shown in the list view.
1465
+ * @param {object} entry - listing row
1466
+ * @returns {string} label
1467
+ */
1468
+ function kindLabel(entry) {
1469
+ if (!entry) return "";
1470
+ if (entry.dir) return t("文件夹");
1471
+ var byKind = {
1472
+ text: t("文本文件"),
1473
+ image: t("图片"),
1474
+ pdf: t("PDF 文档"),
1475
+ word: t("Word 文档"),
1476
+ excel: t("Excel 表格"),
1477
+ ppt: t("PPT 演示"),
1478
+ archive: t("压缩包"),
1479
+ audio: t("音频"),
1480
+ video: t("视频"),
1481
+ binary: t("二进制文件"),
1482
+ };
1483
+ return byKind[entry.kind] || t("文件");
1484
+ }
1485
+
1486
+ /**
1487
+ * Accent colour used by a grouped-view section.
1488
+ * @param {string} kind - entry kind
1489
+ * @param {boolean} dir - whether the section holds folders
1490
+ * @returns {string} hex colour
1491
+ */
1492
+ function kindColor(kind, dir) {
1493
+ if (dir) return "#3b82f6";
1494
+ var byKind = {
1495
+ text: "#64748b", image: "#a855f7", pdf: "#ef4444", word: "#2563eb",
1496
+ excel: "#16a34a", ppt: "#f97316", archive: "#d97706", audio: "#db2777",
1497
+ video: "#7c3aed", binary: "#6b7280",
1498
+ };
1499
+ return byKind[kind] || "#6b7280";
1500
+ }
1501
+
1502
+ /**
1503
+ * Human-readable byte size.
1504
+ * @param {number} bytes - raw size
1505
+ * @returns {string} formatted size
1506
+ */
1507
+ /**
1508
+ * Cut a name to the two lines a tile can show, measuring CJK as two cells.
1509
+ * @param {string} name - full name
1510
+ * @param {number} max - width budget in half-cells
1511
+ * @returns {string} name with an ellipsis when it had to be cut
1512
+ */
1513
+ function clampLabel(name, max) {
1514
+ if (typeof name !== "string") return "";
1515
+ var used = 0;
1516
+ for (var index = 0; index < name.length; index += 1) {
1517
+ used += name.charCodeAt(index) > 0x2e80 ? 2 : 1;
1518
+ if (used > max) return name.slice(0, index) + "…";
1519
+ }
1520
+ return name;
1521
+ }
1522
+
1523
+ /** Lines in a text payload; a trailing newline does not add an empty line. */
1524
+ function lineCountOf(text) {
1525
+ if (typeof text !== "string" || text === "") return 0;
1526
+ var count = text.split("\n").length;
1527
+ if (text.charAt(text.length - 1) === "\n") count -= 1;
1528
+ return count > 0 ? count : 1;
1529
+ }
1530
+
1531
+ function formatSize(bytes) {
1532
+ if (typeof bytes !== "number" || !isFinite(bytes) || bytes < 0) return "";
1533
+ if (bytes === 0) return "0 B";
1534
+ if (bytes < 1024) return bytes + " B";
1535
+ var units = ["KB", "MB", "GB", "TB"];
1536
+ var value = bytes / 1024;
1537
+ var unit = 0;
1538
+ while (value >= 1024 && unit < units.length - 1) { value /= 1024; unit += 1; }
1539
+ return (value >= 10 ? Math.round(value) : Math.round(value * 10) / 10) + " " + units[unit];
1540
+ }
1541
+
1542
+ /**
1543
+ * Compact local timestamp.
1544
+ * @param {number} ms - epoch milliseconds
1545
+ * @returns {string} formatted date
1546
+ */
1547
+ function formatDate(ms) {
1548
+ if (!ms) return "";
1549
+ var date = new Date(ms);
1550
+ if (isNaN(date.getTime())) return "";
1551
+ var pad = function (value) { return String(value).padStart(2, "0"); };
1552
+ return date.getFullYear() + "-" + pad(date.getMonth() + 1) + "-" + pad(date.getDate()) + " " + pad(date.getHours()) + ":" + pad(date.getMinutes());
1553
+ }
1554
+
1555
+ /**
1556
+ * Compare two entry names in the user's locale.
1557
+ * @param {string} a - left name
1558
+ * @param {string} b - right name
1559
+ * @returns {number} sort order
1560
+ */
1561
+ function compareNames(a, b) {
1562
+ try {
1563
+ return a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" });
1564
+ } catch (error) {
1565
+ return a < b ? -1 : a > b ? 1 : 0;
1566
+ }
1567
+ }
1568
+
1569
+ /**
1570
+ * Parent directory of a POSIX or Windows path.
1571
+ * @param {string} target - absolute path
1572
+ * @returns {string} parent path
1573
+ */
1574
+ function parentOf(target) {
1575
+ if (!target) return "";
1576
+ var cut = Math.max(target.lastIndexOf("/"), target.lastIndexOf("\\"));
1577
+ return cut > 0 ? target.slice(0, cut) : target;
1578
+ }
1579
+
1580
+ /**
1581
+ * Split an absolute path into breadcrumb segments from the root.
1582
+ * @param {object} listing - current listing
1583
+ * @returns {Array} crumbs
1584
+ */
1585
+ function crumbsOf(listing) {
1586
+ if (!listing) return [];
1587
+ var rootPath = listing.root || "";
1588
+ var current = listing.path || "";
1589
+ if (!rootPath || current.indexOf(rootPath) !== 0) {
1590
+ return [{ label: current.split(/[\\/]/).pop() || current, path: current }];
1591
+ }
1592
+ var suffix = current.slice(rootPath.length).split(/[\\/]/).filter(Boolean);
1593
+ var out = [{ label: rootPath.split(/[\\/]/).pop() || rootPath, path: rootPath }];
1594
+ var walked = rootPath;
1595
+ suffix.forEach(function (part) {
1596
+ walked = walked + "/" + part;
1597
+ out.push({ label: part, path: walked });
1598
+ });
1599
+ return out;
1600
+ }
1601
+
1602
+ /** Renderers the preview pane knows, keyed by lower-case extension. */
1603
+ var PREVIEW_BY_EXT = {
1604
+ png: "image", jpg: "image", jpeg: "image", gif: "image", webp: "image",
1605
+ bmp: "image", ico: "image", svg: "image",
1606
+ pdf: "pdf",
1607
+ md: "markdown", markdown: "markdown",
1608
+ html: "html", htm: "html",
1609
+ csv: "csv", tsv: "csv",
1610
+ xlsx: "sheet", xlsm: "sheet",
1611
+ docx: "doc", docm: "doc",
1612
+ mp3: "audio", wav: "audio", m4a: "audio", aac: "audio", flac: "audio",
1613
+ ogg: "audio", oga: "audio", opus: "audio", aiff: "audio", aif: "audio",
1614
+ mp4: "video", m4v: "video", mov: "video", webm: "video", ogv: "video",
1615
+ };
1616
+
1617
+ /** Preview kinds that need the file's text before they can render. */
1618
+ var TEXT_PREVIEW_KINDS = { text: 1, markdown: 1, csv: 1 };
1619
+
1620
+ /**
1621
+ * Pick a renderer for one entry, mirroring what DSH's own document preview
1622
+ * supports (images, PDF, markdown, HTML, CSV/TSV) and falling back to text.
1623
+ * @param {object} entry - file entry
1624
+ * @returns {string|null} preview kind, or null for folders
1625
+ */
1626
+ function previewKindOf(entry) {
1627
+ if (!entry || entry.dir) return null;
1628
+ var name = String(entry.name || "");
1629
+ var dot = name.lastIndexOf(".");
1630
+ var ext = dot < 0 ? "" : name.slice(dot + 1).toLowerCase();
1631
+ return PREVIEW_BY_EXT[ext] || "text";
1632
+ }
1633
+
1634
+ /**
1635
+ * Split one line into markdown inline nodes (bold, italic, code, links).
1636
+ * @param {string} line - source line
1637
+ * @param {object} h - element factory
1638
+ * @returns {Array} nodes
1639
+ */
1640
+ function markdownInline(line, h) {
1641
+ var nodes = [];
1642
+ var pattern = /(\*\*[^*]+\*\*|\x60[^\x60]+\x60|\[[^\]]+\]\([^)]+\)|\*[^*]+\*)/g;
1643
+ var last = 0;
1644
+ var match = pattern.exec(line);
1645
+ var key = 0;
1646
+ while (match) {
1647
+ if (match.index > last) nodes.push(line.slice(last, match.index));
1648
+ var token = match[0];
1649
+ if (token.slice(0, 2) === "**") {
1650
+ nodes.push(h("strong", { key: "md" + key }, token.slice(2, -2)));
1651
+ } else if (token.charCodeAt(0) === 96) {
1652
+ nodes.push(h("code", { key: "md" + key, className: "dfx-md-code" }, token.slice(1, -1)));
1653
+ } else if (token.charAt(0) === "[") {
1654
+ var split = token.slice(1, -1).split("](");
1655
+ nodes.push(h("a", { key: "md" + key, href: split[1], target: "_blank", rel: "noreferrer noopener" }, split[0]));
1656
+ } else {
1657
+ nodes.push(h("em", { key: "md" + key }, token.slice(1, -1)));
1658
+ }
1659
+ key += 1;
1660
+ last = match.index + token.length;
1661
+ match = pattern.exec(line);
1662
+ }
1663
+ if (last < line.length) nodes.push(line.slice(last));
1664
+ return nodes;
1665
+ }
1666
+
1667
+ /**
1668
+ * Render markdown into a small element tree (headings, lists, quotes, code).
1669
+ * @param {string} text - markdown source
1670
+ * @param {object} h - element factory
1671
+ * @returns {Array} nodes
1672
+ */
1673
+ function renderMarkdown(text, h) {
1674
+ var lines = String(text || "").split(/\r?\n/);
1675
+ var out = [];
1676
+ var list = null;
1677
+ var fence = null;
1678
+ var fenceLines = [];
1679
+ lines.forEach(function (line, index) {
1680
+ if (line.slice(0, 3) === "\x60\x60\x60") {
1681
+ if (fence === null) {
1682
+ fence = line.slice(3).trim();
1683
+ fenceLines = [];
1684
+ } else {
1685
+ out.push(h("pre", { key: "md" + index, className: "dfx-pre dfx-md-pre" }, fenceLines.join("\n")));
1686
+ fence = null;
1687
+ fenceLines = [];
1688
+ }
1689
+ return;
1690
+ }
1691
+ if (fence !== null) { fenceLines.push(line); return; }
1692
+ var head = line.match(/^(#{1,6})\s+(.*)$/);
1693
+ if (head) {
1694
+ if (list) { out.push(h("ul", { key: "mdl" + index, className: "dfx-md-list" }, list)); list = null; }
1695
+ out.push(h("h" + (head[1].length + 2), { key: "md" + index, className: "dfx-md-h" }, markdownInline(head[2], h)));
1696
+ return;
1697
+ }
1698
+ var bullet = line.match(/^\s*[-*+]\s+(.*)$/);
1699
+ if (bullet) {
1700
+ if (!list) list = [];
1701
+ list.push(h("li", { key: "mdi" + index }, markdownInline(bullet[1], h)));
1702
+ return;
1703
+ }
1704
+ if (list) { out.push(h("ul", { key: "mdl" + index, className: "dfx-md-list" }, list)); list = null; }
1705
+ var quote = line.match(/^>\s?(.*)$/);
1706
+ if (quote) {
1707
+ out.push(h("blockquote", { key: "md" + index, className: "dfx-md-quote" }, markdownInline(quote[1], h)));
1708
+ return;
1709
+ }
1710
+ if (line.trim() === "") return;
1711
+ out.push(h("p", { key: "md" + index, className: "dfx-md-p" }, markdownInline(line, h)));
1712
+ });
1713
+ if (list) out.push(h("ul", { key: "mdl-end", className: "dfx-md-list" }, list));
1714
+ if (fenceLines.length > 0) out.push(h("pre", { key: "md-fence", className: "dfx-pre dfx-md-pre" }, fenceLines.join("\n")));
1715
+ return out;
1716
+ }
1717
+
1718
+ /**
1719
+ * Parse delimited text into a capped table of cells.
1720
+ * @param {string} text - csv/tsv source
1721
+ * @param {string} delimiter - "," or a tab
1722
+ * @returns {Array<Array<string>>} rows
1723
+ */
1724
+ function parseDelimited(text, delimiter) {
1725
+ var rows = [];
1726
+ var cell = "";
1727
+ var row = [];
1728
+ var quoted = false;
1729
+ var source = String(text || "");
1730
+ for (var i = 0; i < source.length; i += 1) {
1731
+ var ch = source.charAt(i);
1732
+ if (quoted) {
1733
+ if (ch === '"') {
1734
+ if (source.charAt(i + 1) === '"') { cell += '"'; i += 1; }
1735
+ else quoted = false;
1736
+ } else cell += ch;
1737
+ continue;
1738
+ }
1739
+ if (ch === '"') { quoted = true; continue; }
1740
+ if (ch === delimiter) { row.push(cell); cell = ""; continue; }
1741
+ if (ch === "\n") {
1742
+ row.push(cell);
1743
+ rows.push(row);
1744
+ row = [];
1745
+ cell = "";
1746
+ if (rows.length >= 200) return rows;
1747
+ continue;
1748
+ }
1749
+ if (ch === "\r") continue;
1750
+ cell += ch;
1751
+ }
1752
+ if (cell.length > 0 || row.length > 0) { row.push(cell); rows.push(row); }
1753
+ return rows.slice(0, 200);
1754
+ }
1755
+
1756
+ /**
1757
+ * GET a host route and decode JSON.
1758
+ * @param {string} route - route suffix
1759
+ * @param {object} params - query parameters
1760
+ * @returns {Promise<object>} { ok, body }
1761
+ */
1762
+ function apiGet(route, params) {
1763
+ var search = new URLSearchParams(params || {}).toString();
1764
+ return fetch(API + route + (search ? "?" + search : ""), { headers: { accept: "application/json" } })
1765
+ .then(function (response) {
1766
+ return response.json().then(function (body) { return { ok: response.ok, body: body }; }, function () {
1767
+ return { ok: false, body: { message: t("响应无法解析") } };
1768
+ });
1769
+ });
1770
+ }
1771
+
1772
+ /**
1773
+ * POST a host route, with an optional JSON body.
1774
+ * @param {string} route - route suffix
1775
+ * @param {object} params - query parameters
1776
+ * @param {object} body - JSON body
1777
+ * @returns {Promise<object>} { ok, body }
1778
+ */
1779
+ function apiPost(route, params, body) {
1780
+ var search = new URLSearchParams(params || {}).toString();
1781
+ return fetch(API + route + (search ? "?" + search : ""), {
1782
+ method: "POST",
1783
+ headers: body ? { "content-type": "application/json" } : undefined,
1784
+ body: body ? JSON.stringify(body) : undefined,
1785
+ }).then(function (response) {
1786
+ return response.json().then(function (payload) { return { ok: response.ok, body: payload }; }, function () {
1787
+ return { ok: false, body: { message: t("响应无法解析") } };
1788
+ });
1789
+ });
1790
+ }
1791
+
1792
+ /**
1793
+ * Upload one File into a folder, streaming it through the host.
1794
+ * @param {string} dirPath - destination directory
1795
+ * @param {File} file - browser file
1796
+ * @param {(loaded: number, total: number) => void} onProgress - byte callback
1797
+ * @returns {Promise<object>} { ok, body }
1798
+ */
1799
+ function apiUpload(dirPath, file, onProgress) {
1800
+ return new Promise(function (resolve) {
1801
+ var url = API + "/upload?path=" + encodeURIComponent(dirPath) + "&name=" + encodeURIComponent(file.name);
1802
+ var xhr = new XMLHttpRequest();
1803
+ xhr.open("POST", url);
1804
+ if (onProgress) {
1805
+ xhr.upload.onprogress = function (event) {
1806
+ if (event.lengthComputable) onProgress(event.loaded, event.total);
1807
+ };
1808
+ }
1809
+ xhr.onload = function () {
1810
+ var body;
1811
+ try { body = JSON.parse(xhr.responseText); } catch (error) { body = { message: t("响应无法解析") }; }
1812
+ resolve({ ok: xhr.status >= 200 && xhr.status < 300, body: body });
1813
+ };
1814
+ xhr.onerror = function () { resolve({ ok: false, body: { message: t("上传失败") } }); };
1815
+ xhr.send(file);
1816
+ });
1817
+ }
1818
+
1819
+ /**
1820
+ * Save the editor's text back to the host.
1821
+ * @param {string} targetPath - file path
1822
+ * @param {string} text - new contents
1823
+ * @returns {Promise<object>} { ok, body }
1824
+ */
1825
+ function apiWrite(targetPath, text) {
1826
+ return apiPost("/write", { path: targetPath }, { text: text });
1827
+ }
1828
+
1829
+ /**
1830
+ * Ask the host to zip a set of paths beside themselves.
1831
+ * @param {string[]} sources - absolute paths
1832
+ * @returns {Promise<object>} { ok, body }
1833
+ */
1834
+ function apiArchive(sources) {
1835
+ return apiPost("/archive", {}, { sources: sources });
1836
+ }
1837
+
1838
+ /**
1839
+ * Ask the host to unpack a .zip beside itself.
1840
+ * @param {string} targetPath - archive path
1841
+ * @returns {Promise<object>} { ok, body }
1842
+ */
1843
+ function apiExtract(targetPath) {
1844
+ return apiPost("/extract", {}, { path: targetPath });
1845
+ }
1846
+
1847
+ /**
1848
+ * Read git decorations for a folder.
1849
+ * @param {string} dirPath - directory
1850
+ * @returns {Promise<object>} { ok, body }
1851
+ */
1852
+ function apiGit(dirPath) {
1853
+ return apiGet("/git", { path: dirPath });
1854
+ }
1855
+
1856
+ /**
1857
+ * Send a file to the browser's download shelf through an anchor click.
1858
+ * @param {string} targetPath - file path
1859
+ * @returns {void}
1860
+ */
1861
+ function downloadFile(targetPath) {
1862
+ var link = document.createElement("a");
1863
+ link.href = API + "/download?path=" + encodeURIComponent(targetPath);
1864
+ link.rel = "noopener";
1865
+ link.download = "";
1866
+ document.body.appendChild(link);
1867
+ link.click();
1868
+ link.remove();
1869
+ }
1870
+
1871
+ /**
1872
+ * Shorten an absolute path against the browsing root.
1873
+ * @param {string} targetPath - absolute path
1874
+ * @param {string} rootPath - root to strip
1875
+ * @returns {string} relative path
1876
+ */
1877
+ function relativeTo(targetPath, rootPath) {
1878
+ if (!rootPath) return targetPath;
1879
+ if (targetPath === rootPath) return ".";
1880
+ var prefix = rootPath.endsWith("/") ? rootPath : rootPath + "/";
1881
+ return targetPath.startsWith(prefix) ? targetPath.slice(prefix.length) : targetPath;
1882
+ }
1883
+
1884
+ /**
1885
+ * Sidebar entry icon: the folder glyph at the size the sidebar asks for.
1886
+ * @param {object} props - sidebar icon share
1887
+ * @returns {object} svg element
1888
+ */
1889
+ function PanelIcon(props) {
1890
+ return glyph("folder", props && typeof props.size === "number" ? props.size : 18);
1891
+ }
1892
+
1893
+ /**
1894
+ * Single-line input dialog used for rename / new folder / new file.
1895
+ * @param {object} props - title, label, value, confirmLabel, busy, onCancel, onSubmit
1896
+ * @returns {object} dialog element
1897
+ */
1898
+ function PromptDialog(props) {
1899
+ var [value, setValue] = useState(props.value || "");
1900
+ var inputRef = useRef(null);
1901
+
1902
+ useEffect(function () {
1903
+ var node = inputRef.current;
1904
+ if (!node) return;
1905
+ node.focus();
1906
+ var dot = value.lastIndexOf(".");
1907
+ if (dot > 0) node.setSelectionRange(0, dot);
1908
+ else node.select();
1909
+ }, []);
1910
+
1911
+ var submit = function () {
1912
+ var text = String(value).trim();
1913
+ if (!text || props.busy) return;
1914
+ props.onSubmit(text);
1915
+ };
1916
+
1917
+ return h("div", {
1918
+ className: "dfx-overlay",
1919
+ onMouseDown: function (event) { if (event.target === event.currentTarget) props.onCancel(); },
1920
+ },
1921
+ h("div", { className: "dfx-dialog", role: "dialog", "aria-modal": "true", "aria-label": props.title },
1922
+ h("div", { className: "dfx-dialog-title" }, props.title),
1923
+ props.label ? h("div", { className: "dfx-dialog-label" }, props.label) : null,
1924
+ h("input", {
1925
+ ref: inputRef,
1926
+ className: "dfx-dialog-input",
1927
+ value: value,
1928
+ spellCheck: false,
1929
+ autoComplete: "off",
1930
+ onChange: function (event) { setValue(event.target.value); },
1931
+ onKeyDown: function (event) {
1932
+ if (event.key === "Enter") { event.preventDefault(); submit(); }
1933
+ else if (event.key === "Escape") { event.preventDefault(); props.onCancel(); }
1934
+ },
1935
+ }),
1936
+ h("div", { className: "dfx-dialog-actions" },
1937
+ h("button", { type: "button", className: "dfx-btn", onClick: props.onCancel }, t("取消")),
1938
+ h("button", {
1939
+ type: "button",
1940
+ className: "dfx-btn dfx-btn--primary",
1941
+ disabled: props.busy || String(value).trim().length === 0,
1942
+ onClick: submit,
1943
+ }, props.confirmLabel || t("确定")))));
1944
+ }
1945
+
1946
+ /**
1947
+ * About dialog: what the plugin is, which version, who made it.
1948
+ * @param {object} props - meta, onClose
1949
+ * @returns {object} dialog element
1950
+ */
1951
+ function AboutDialog(props) {
1952
+ var meta = props.meta || {};
1953
+ var author = meta.author && typeof meta.author === "object" ? meta.author : null;
1954
+ var repoHref = String((meta.repository && meta.repository.url) || "git+https://github.com/MaxBill/dsh-file-explorer.git")
1955
+ .replace(/^git\+/, "").replace(/\.git$/, "");
1956
+ var repoShort = repoHref.replace(/^https?:\/\//, "");
1957
+ var authorName = (author && author.name) || (typeof meta.author === "string" ? meta.author : "MaxBill");
1958
+ var version = meta.version || "—";
1959
+ var build = meta.build ? "(build " + meta.build + ")" : "";
1960
+ var rows = [
1961
+ { label: t("作者"), glyph: "user", value: authorName, text: true },
1962
+ { label: t("版本"), glyph: "tag", value: version + build },
1963
+ { label: t("仓库地址"), glyph: "link", value: repoShort, href: repoHref },
1964
+ ];
1965
+ return h("div", {
1966
+ className: "dfx-overlay",
1967
+ onMouseDown: function (event) { if (event.target === event.currentTarget) props.onClose(); },
1968
+ },
1969
+ h("div", { className: "dfx-dialog dfx-about", role: "dialog", "aria-modal": "true", "aria-label": t("关于 文件管理器") },
1970
+ h("div", { className: "dfx-about-head" },
1971
+ h("button", {
1972
+ type: "button",
1973
+ className: "dfx-about-close",
1974
+ "aria-label": t("关闭关于"),
1975
+ onClick: props.onClose,
1976
+ }, glyph("close", 16)),
1977
+ h("div", { className: "dfx-about-badge" }, icon(SHAPES.appIcon, 54)),
1978
+ h("h2", { className: "dfx-about-name" }, t("文件管理器")),
1979
+ h("span", { className: "dfx-about-version" }, "v" + version)),
1980
+ h("div", { className: "dfx-about-body" },
1981
+ h("p", { className: "dfx-about-blurb" }, t("轻量级本地文件管理:浏览、预览、批量选择与常用操作。")),
1982
+ h("div", { className: "dfx-about-rows" }, rows.map(function (row) {
1983
+ var valueNode = row.href
1984
+ ? h("a", {
1985
+ className: "dfx-about-value dfx-about-link",
1986
+ href: row.href,
1987
+ title: row.href,
1988
+ target: "_blank",
1989
+ rel: "noreferrer noopener",
1990
+ onMouseDown: function (event) { event.stopPropagation(); },
1991
+ }, row.value)
1992
+ : h("span", { className: "dfx-about-value" + (row.text ? " dfx-about-value--text" : "") }, row.value);
1993
+ return h("div", { key: row.label, className: "dfx-about-row" },
1994
+ h("span", { className: "dfx-about-ico" }, glyph(row.glyph, 16)),
1995
+ h("div", { className: "dfx-about-text" },
1996
+ h("span", { className: "dfx-about-label" }, row.label),
1997
+ valueNode));
1998
+ }))),
1999
+ h("div", { className: "dfx-about-foot" },
2000
+ "© " + new Date().getFullYear() + " " + authorName + " · " + (meta.license || "Apache-2.0"))));
2001
+ }
2002
+
2003
+ /**
2004
+ * Settings window opened from 更多 → 选项: display toggles plus the
2005
+ * folder-transition animation switch and effect picker.
2006
+ * @param {object} props - showHidden, view, paneVisible, paneMode, anim, callbacks
2007
+ * @returns {object} dialog element
2008
+ */
2009
+ function OptionsDialog(props) {
2010
+ var anim = props.anim || ANIM_DEFAULT;
2011
+ var paneCurrent = props.paneVisible ? props.paneMode : "hidden";
2012
+ // 隐藏 leads, matching the default: the pane starts closed.
2013
+ var paneChoices = [
2014
+ { id: "hidden", label: t("隐藏"), icon: "close" },
2015
+ { id: "preview", label: t("预览"), icon: "eye" },
2016
+ { id: "info", label: t("详情"), icon: "info" },
2017
+ ];
2018
+ return h("div", {
2019
+ className: "dfx-overlay",
2020
+ onMouseDown: function (event) { if (event.target === event.currentTarget) props.onClose(); },
2021
+ },
2022
+ h("div", { className: "dfx-dialog dfx-opt", role: "dialog", "aria-modal": "true", "aria-label": t("选项") },
2023
+ h("div", { className: "dfx-opt-head" },
2024
+ h("span", { className: "dfx-opt-badge" }, glyph("sliders", 17)),
2025
+ h("span", { className: "dfx-opt-title" }, t("选项")),
2026
+ h("button", {
2027
+ type: "button",
2028
+ className: "dfx-opt-close dfx-tip dfx-tip--right",
2029
+ "aria-label": t("关闭选项"),
2030
+ "data-tip": t("关闭选项"),
2031
+ onClick: props.onClose,
2032
+ }, glyph("close", 16))),
2033
+ h("div", { className: "dfx-opt-body" },
2034
+ h("div", { className: "dfx-opt-section" },
2035
+ h("div", { className: "dfx-opt-heading" }, t("显示")),
2036
+ h("div", { className: "dfx-opt-row" },
2037
+ h("span", { className: "dfx-opt-label" }, glyph("hidden", 15), t("显示隐藏文件")),
2038
+ h("button", {
2039
+ type: "button",
2040
+ className: "dfx-switch",
2041
+ role: "switch",
2042
+ "aria-checked": props.showHidden ? "true" : "false",
2043
+ "aria-label": t("显示隐藏文件"),
2044
+ onClick: function () { props.onHidden(!props.showHidden); },
2045
+ }, h("span", null)))),
2046
+ h("div", { className: "dfx-opt-section" },
2047
+ h("div", { className: "dfx-opt-heading" }, t("视图")),
2048
+ h("div", { className: "dfx-opt-row" },
2049
+ h("span", { className: "dfx-opt-label" }, glyph("viewGrid", 15), t("文件显示方式")),
2050
+ h("div", { className: "dfx-seg" }, VIEW_OPTIONS.map(function (option) {
2051
+ return h("button", {
2052
+ key: option.id,
2053
+ type: "button",
2054
+ "aria-pressed": props.view === option.id ? "true" : "false",
2055
+ onClick: function () { props.onView(option.id); },
2056
+ }, glyph(option.icon, 13), t(option.label));
2057
+ })))),
2058
+ h("div", { className: "dfx-opt-section" },
2059
+ h("div", { className: "dfx-opt-heading" }, t("分类视图")),
2060
+ h("div", { className: "dfx-opt-row" },
2061
+ h("span", { className: "dfx-opt-label" }, glyph("squares", 15), t("分组外观")),
2062
+ h("div", { className: "dfx-seg" }, GROUP_STYLES.map(function (option) {
2063
+ return h("button", {
2064
+ key: option.id,
2065
+ type: "button",
2066
+ "aria-pressed": props.groupStyle === option.id ? "true" : "false",
2067
+ onClick: function () { props.onGroupStyle(option.id); },
2068
+ }, t(option.label));
2069
+ })))),
2070
+ h("div", { className: "dfx-opt-section" },
2071
+ h("div", { className: "dfx-opt-heading" }, t("右侧面板")),
2072
+ h("div", { className: "dfx-opt-row" },
2073
+ h("span", { className: "dfx-opt-label" }, glyph("pane", 15), t("显示内容")),
2074
+ h("div", { className: "dfx-seg" }, paneChoices.map(function (option) {
2075
+ return h("button", {
2076
+ key: option.id,
2077
+ type: "button",
2078
+ "aria-pressed": paneCurrent === option.id ? "true" : "false",
2079
+ onClick: function () { props.onPane(option.id); },
2080
+ }, glyph(option.icon, 13), t(option.label));
2081
+ })))),
2082
+ h("div", { className: "dfx-opt-section" },
2083
+ h("div", { className: "dfx-opt-heading" }, t("语言")),
2084
+ h("div", { className: "dfx-opt-row" },
2085
+ h("span", { className: "dfx-opt-label" }, glyph("tag", 15), t("界面语言")),
2086
+ h("div", { className: "dfx-seg" }, LANGUAGES.map(function (item) {
2087
+ return h("button", {
2088
+ key: item.id,
2089
+ type: "button",
2090
+ "aria-pressed": props.langPref === item.id ? "true" : "false",
2091
+ onClick: function () { props.onLang(item.id); },
2092
+ }, t(item.label));
2093
+ }))),
2094
+ h("span", { className: "dfx-opt-hint" }, t("跟随系统语言"))),
2095
+ h("div", { className: "dfx-opt-section" },
2096
+ h("div", { className: "dfx-opt-heading" }, t("切换动画")),
2097
+ h("div", { className: "dfx-opt-row" },
2098
+ h("span", { className: "dfx-opt-label" }, glyph("refresh", 15), t("进入 / 退出文件夹时的动画")),
2099
+ h("button", {
2100
+ type: "button",
2101
+ className: "dfx-switch",
2102
+ role: "switch",
2103
+ "aria-checked": anim.enabled ? "true" : "false",
2104
+ "aria-label": t("切换动画"),
2105
+ onClick: function () {
2106
+ props.onAnim({ enabled: !anim.enabled, effect: anim.effect });
2107
+ },
2108
+ }, h("span", null))),
2109
+ h("div", { className: "dfx-effects" }, NAV_EFFECTS.map(function (effect) {
2110
+ return h("button", {
2111
+ key: effect.id,
2112
+ type: "button",
2113
+ className: "dfx-effect",
2114
+ "aria-pressed": anim.effect === effect.id ? "true" : "false",
2115
+ onClick: function () {
2116
+ // Picking an effect is also a way to switch the animation on.
2117
+ props.onAnim({ enabled: true, effect: effect.id });
2118
+ },
2119
+ }, t(effect.label));
2120
+ })),
2121
+ h("div", {
2122
+ key: "sample-" + anim.effect + "-" + (anim.enabled ? "on" : "off"),
2123
+ className: "dfx-opt-sample" + (anim.enabled ? " dfx-opt-sample--" + (anim.effect === "slide" ? "in" : anim.effect) : ""),
2124
+ "aria-hidden": "true",
2125
+ }, h("span", null), h("span", null), h("span", null)),
2126
+ h("span", { className: "dfx-opt-hint" }, t("系统开启「减弱动态效果」时自动关闭动画。")))),
2127
+ h("div", { className: "dfx-opt-foot" },
2128
+ h("button", { type: "button", className: "dfx-btn dfx-btn--primary", onClick: props.onClose }, t("完成")))));
2129
+ }
2130
+
2131
+ /**
2132
+ * Confirmation dialog for destructive actions.
2133
+ * @param {object} props - title, message, confirmLabel, danger, busy, onCancel, onConfirm
2134
+ * @returns {object} dialog element
2135
+ */
2136
+ function ConfirmDialog(props) {
2137
+ return h("div", {
2138
+ className: "dfx-overlay",
2139
+ onMouseDown: function (event) { if (event.target === event.currentTarget) props.onCancel(); },
2140
+ },
2141
+ h("div", { className: "dfx-dialog", role: "dialog", "aria-modal": "true", "aria-label": props.title },
2142
+ h("div", { className: "dfx-dialog-title" }, props.title),
2143
+ h("div", { className: "dfx-dialog-message" }, props.message),
2144
+ h("div", { className: "dfx-dialog-actions" },
2145
+ h("button", { type: "button", className: "dfx-btn", onClick: props.onCancel }, t("取消")),
2146
+ h("button", {
2147
+ type: "button",
2148
+ className: "dfx-btn " + (props.danger ? "dfx-btn--danger" : "dfx-btn--primary"),
2149
+ disabled: props.busy,
2150
+ onClick: props.onConfirm,
2151
+ }, props.confirmLabel || t("确定")))));
2152
+ }
2153
+
2154
+ /** macOS shows ⌘ accelerators, every other platform shows Ctrl. */
2155
+ var IS_MAC = (function () {
2156
+ try { return /mac|iphone|ipad/i.test(navigator.platform || navigator.userAgent || ""); } catch (error) { return true; }
2157
+ })();
2158
+
2159
+ /**
2160
+ * Platform accelerator label.
2161
+ * @param {string} key - key name
2162
+ * @returns {string} hint text
2163
+ */
2164
+ function accel(key) {
2165
+ return IS_MAC ? "⌘" + key : "Ctrl+" + key;
2166
+ }
2167
+
2168
+ /**
2169
+ * The 文件管理器 panel: browse the home tree, filter, preview, and run the
2170
+ * context-menu file operations.
2171
+ * @returns {object} panel element
2172
+ */
2173
+ /**
2174
+ * Put text into the conversation composer, keeping whatever is already
2175
+ * there. Uses the paste channel the editor itself listens to.
2176
+ * @param {Element} card - composer card
2177
+ * @param {string} text - text to insert
2178
+ * @returns {boolean} whether the text was handed to the editor
2179
+ */
2180
+ function insertComposerText(card, text) {
2181
+ if (!card || !text) return false;
2182
+ var field = typeof card.querySelector === "function"
2183
+ ? card.querySelector('[contenteditable="true"]') || card.querySelector("textarea")
2184
+ : null;
2185
+ if (!field) return false;
2186
+ try { field.focus(); } catch (error) { /* focus is best effort */ }
2187
+ if (field.tagName === "TEXTAREA") {
2188
+ var at = typeof field.selectionStart === "number" ? field.selectionStart : field.value.length;
2189
+ var value = String(field.value || "");
2190
+ field.value = value.slice(0, at) + text + value.slice(at);
2191
+ field.dispatchEvent(new Event("input", { bubbles: true }));
2192
+ return true;
2193
+ }
2194
+ try {
2195
+ var transfer = new DataTransfer();
2196
+ transfer.setData("text/plain", text);
2197
+ field.dispatchEvent(new ClipboardEvent("paste", { bubbles: true, cancelable: true, clipboardData: transfer }));
2198
+ return true;
2199
+ } catch (error) {
2200
+ try { return document.execCommand("insertText", false, text); } catch (ignored) { return false; }
2201
+ }
2202
+ }
2203
+
2204
+ /**
2205
+ * Keep only the tail of a path, for a popup hint that never overflows.
2206
+ * @param {string} path - absolute path
2207
+ * @returns {string} shortened path
2208
+ */
2209
+ function shortPath(path) {
2210
+ if (typeof path !== "string" || path === "") return "";
2211
+ var parts = path.split(/[\\/]/).filter(function (part) { return part !== ""; });
2212
+ if (parts.length <= 2) return path;
2213
+ return "…/" + parts.slice(-2).join("/");
2214
+ }
2215
+
2216
+ /**
2217
+ * Read the workspace list out of the client workspace service.
2218
+ * @param {object|null} service - ctx.workspaces
2219
+ * @returns {Array} workspace rows carrying workspaceId, title and path
2220
+ */
2221
+ function readWorkspaces(service) {
2222
+ if (!service || !service.list) return [];
2223
+ var store = service.list;
2224
+ var snapshot = null;
2225
+ try {
2226
+ snapshot = typeof store.getSnapshot === "function" ? store.getSnapshot() : store;
2227
+ } catch (error) {
2228
+ return [];
2229
+ }
2230
+ var items = snapshot && Array.isArray(snapshot.items) ? snapshot.items : Array.isArray(snapshot) ? snapshot : [];
2231
+ return items.filter(function (item) {
2232
+ return item && typeof item.path === "string" && typeof item.workspaceId === "string";
2233
+ });
2234
+ }
2235
+
2236
+ /**
2237
+ * Wait for the conversation composer to mount.
2238
+ * @param {number} timeout - milliseconds to wait
2239
+ * @returns {Promise<Element|null>} composer card, or null on timeout
2240
+ */
2241
+ function waitForComposer(timeout) {
2242
+ var deadline = Date.now() + timeout;
2243
+ var query = typeof document !== "undefined" && typeof document.querySelector === "function"
2244
+ ? function () { return document.querySelector("[data-composer-card]"); }
2245
+ : function () { return null; };
2246
+ var later = typeof setTimeout === "function" ? setTimeout : null;
2247
+ return new Promise(function (resolvePromise) {
2248
+ function tick() {
2249
+ var card = query();
2250
+ if (card) { resolvePromise(card); return; }
2251
+ if (later === null || Date.now() > deadline) { resolvePromise(null); return; }
2252
+ later(tick, 60);
2253
+ }
2254
+ tick();
2255
+ });
2256
+ }
2257
+
2258
+ function FileExplorerPanel() {
2259
+ // Resolve the language before anything renders, so every t() call in this
2260
+ // pass uses it.
2261
+ var langRef = useRef(readStoredLang());
2262
+ currentLang = resolveLang(langRef.current);
2263
+ var [listing, setListing] = useState(null);
2264
+ var [status, setStatus] = useState("loading");
2265
+ var [error, setError] = useState(null);
2266
+ var [query, setQuery] = useState("");
2267
+ var [showHidden, setShowHiddenState] = useState(readStoredHidden);
2268
+ /** Show or hide dotfiles, and remember it. */
2269
+ var setShowHidden = function (next) {
2270
+ storeHidden(next);
2271
+ setShowHiddenState(next);
2272
+ };
2273
+ var [sort, setSort] = useState("name");
2274
+ var [view, setView] = useState(function () { return remembered.view || readStoredView() || VIEW_MODES[0]; });
2275
+ var [groupStyle, setGroupStyleState] = useState(readStoredGroupStyle);
2276
+ /** Change the grouped-view look, and remember it. */
2277
+ var setGroupStyle = function (next) {
2278
+ storeGroupStyle(next);
2279
+ setGroupStyleState(next);
2280
+ };
2281
+ var [selected, setSelected] = useState(null);
2282
+ var [selectedPaths, setSelectedPaths] = useState([]);
2283
+ var [anchorPath, setAnchorPath] = useState(null);
2284
+ var [undoStack, setUndoStack] = useState([]);
2285
+ var [popup, setPopup] = useState(null);
2286
+ /** Workspace rows, read when the switcher opens. */
2287
+ var [wsItems, setWsItems] = useState([]);
2288
+ /** Entries being dragged out of the list, while a drag is in flight. */
2289
+ var [dragEntries, setDragEntries] = useState(null);
2290
+ /** Whether the drag is hovering the "drop into the conversation" strip. */
2291
+ var [dropHot, setDropHot] = useState(false);
2292
+ // The right pane starts hidden; the toolbar toggle or 选项 brings it back.
2293
+ var [paneState, setPaneState] = useState(readStoredPane);
2294
+ var paneVisible = paneState.visible;
2295
+ var paneMode = paneState.mode;
2296
+ /**
2297
+ * Change the pane's visibility and mode together, so the stored value and
2298
+ * the new state always agree.
2299
+ * @param {boolean} visible - whether the pane is open
2300
+ * @param {string} mode - "preview" or "info"
2301
+ */
2302
+ function setPaneBoth(visible, mode) {
2303
+ var next = { visible: !!visible, mode: mode === "info" ? "info" : "preview" };
2304
+ storePane(next.visible, next.mode);
2305
+ setPaneState(next);
2306
+ }
2307
+ function setPaneVisible(next) { setPaneBoth(next, paneMode); }
2308
+ function setPaneMode(next) { setPaneBoth(paneVisible, next); }
2309
+ var [addressDraft, setAddressDraft] = useState(null);
2310
+ var addressRef = useRef(null);
2311
+ var rootRef = useRef(null);
2312
+ var [preview, setPreview] = useState(null);
2313
+ var [previewStatus, setPreviewStatus] = useState("idle");
2314
+ var [activeSheet, setActiveSheet] = useState(0);
2315
+
2316
+ var [details, setDetails] = useState(null);
2317
+ var [detailsStatus, setDetailsStatus] = useState("idle");
2318
+ var [notice, setNotice] = useState(null);
2319
+ var [menu, setMenu] = useState(null);
2320
+ var [dialog, setDialog] = useState(null);
2321
+ var [about, setAbout] = useState(null);
2322
+ var [clipboard, setClipboard] = useState(remembered.clipboard);
2323
+ /** In-flight upload progress: { name, loaded, total } or null. */
2324
+ var [upload, setUpload] = useState(null);
2325
+ /** Git decorations for the folder on screen: { repo, entries }. */
2326
+ var [gitMap, setGitMap] = useState(null);
2327
+ /** True when the browser runs on another machine than the host. */
2328
+ var [remoteMode, setRemoteMode] = useState(false);
2329
+ /** Editor state when a text file is being edited in the pane. */
2330
+ var [editor, setEditor] = useState(null);
2331
+ var [busy, setBusy] = useState(false);
2332
+ var [navMotion, setNavMotion] = useState({ dir: null, seq: 0 });
2333
+ var [anim, setAnimState] = useState(readStoredAnim);
2334
+ /** Change the transition settings, and remember them. */
2335
+ var setAnim = function (next) {
2336
+ storeAnim(next);
2337
+ setAnimState(next);
2338
+ };
2339
+ var [langPref, setLangPref] = useState(langRef.current);
2340
+ langRef.current = langPref;
2341
+ var navSeqRef = useRef(0);
2342
+ var requestSeq = useRef(0);
2343
+ var rowsRef = useRef(null);
2344
+ var searchRef = useRef(null);
2345
+ var previewRef = useRef(null);
2346
+ var detailsRef = useRef(null);
2347
+ var listingRef = useRef(null);
2348
+ var uploadInputRef = useRef(null);
2349
+ var folderInputRef = useRef(null);
2350
+
2351
+ listingRef.current = listing;
2352
+
2353
+ var notify = useCallback(function (text, tone) {
2354
+ setNotice({ text: text, tone: tone || "info" });
2355
+ }, []);
2356
+
2357
+ var changeView = useCallback(function (next) {
2358
+ if (VIEW_MODES.indexOf(next) === -1) return;
2359
+ remembered.view = next;
2360
+ storeView(next);
2361
+ setView(next);
2362
+ }, []);
2363
+
2364
+ var load = useCallback(function (target, focusPath, direction) {
2365
+ var seq = requestSeq.current + 1;
2366
+ requestSeq.current = seq;
2367
+ if (direction) setNavMotion({ dir: direction, seq: navSeqRef.current + 1 });
2368
+ navSeqRef.current += 1;
2369
+ setStatus("loading");
2370
+ setError(null);
2371
+ setMenu(null);
2372
+ apiGet("/list", target ? { path: target } : {}).then(function (result) {
2373
+ if (requestSeq.current !== seq) return;
2374
+ if (!result.ok) throw new Error(t((result.body && result.body.message) || "无法读取目录"));
2375
+ setListing(result.body);
2376
+ remembered.path = result.body.path;
2377
+ setStatus("ready");
2378
+ setGitMap(null);
2379
+ apiGit(result.body.path).then(function (decorations) {
2380
+ if (requestSeq.current !== seq) return;
2381
+ if (decorations.ok) setGitMap(decorations.body);
2382
+ }).catch(function () { /* a folder outside git simply has no badges */ });
2383
+ var focus = focusPath
2384
+ ? result.body.entries.filter(function (entry) { return entry.path === focusPath; })[0] || null
2385
+ : null;
2386
+ setDetails(null);
2387
+ setDetailsStatus("idle");
2388
+ setSelected(focus);
2389
+ setSelectedPaths(focus ? [focus.path] : []);
2390
+ setAnchorPath(focus ? focus.path : null);
2391
+ if (focus && focus.dir) detailsRef.current(focus);
2392
+ else if (focus) previewRef.current(focus);
2393
+ else { setPreview(null); setPreviewStatus("idle"); }
2394
+ }).catch(function (failure) {
2395
+ if (requestSeq.current !== seq) return;
2396
+ setError(String((failure && failure.message) || failure));
2397
+ setStatus("error");
2398
+ });
2399
+ }, []);
2400
+
2401
+ useEffect(function () { load(remembered.path); }, [load]);
2402
+
2403
+ // the workspace chip shows the workspace the folder belongs to, so the
2404
+ // list is read once on mount and refreshed whenever the switcher opens
2405
+ useEffect(function () { setWsItems(readWorkspaces(workspacesRef.current)); }, []);
2406
+
2407
+ useEffect(function () {
2408
+ if (!notice) return undefined;
2409
+ var timer = setTimeout(function () { setNotice(null); }, 2400);
2410
+ return function () { clearTimeout(timer); };
2411
+ }, [notice]);
2412
+
2413
+ // Dismiss the context menu on any click, scroll, resize or Escape outside it.
2414
+ useEffect(function () {
2415
+ if (!menu) return undefined;
2416
+ // A press inside the menu belongs to the menu; anything else dismisses it.
2417
+ var close = function (event) {
2418
+ var target = event && event.target;
2419
+ if (target && target.closest && target.closest(".dfx-menu")) return;
2420
+ setMenu(null);
2421
+ };
2422
+ var onKey = function (event) { if (event.key === "Escape") setMenu(null); };
2423
+ window.addEventListener("mousedown", close);
2424
+ window.addEventListener("keydown", onKey);
2425
+ window.addEventListener("scroll", close, true);
2426
+ window.addEventListener("resize", close);
2427
+ return function () {
2428
+ window.removeEventListener("mousedown", close);
2429
+ window.removeEventListener("keydown", onKey);
2430
+ window.removeEventListener("scroll", close, true);
2431
+ window.removeEventListener("resize", close);
2432
+ };
2433
+ }, [menu]);
2434
+
2435
+ var openPreview = useCallback(function (entry) {
2436
+ if (!entry || entry.dir) {
2437
+ setPreview(null);
2438
+ setPreviewStatus("idle");
2439
+ return;
2440
+ }
2441
+ var kind = previewKindOf(entry);
2442
+ setActiveSheet(0);
2443
+ if (kind === "doc") {
2444
+ setPreviewStatus("loading");
2445
+ setPreview(null);
2446
+ apiGet("/document", { path: entry.path }).then(function (result) {
2447
+ if (!result.ok) throw new Error(t((result.body && result.body.message) || "无法读取文件"));
2448
+ setPreview({
2449
+ entry: entry,
2450
+ kind: kind,
2451
+ doc: result.body,
2452
+ body: { kind: kind, size: entry.size, mtime: entry.mtime, mime: null },
2453
+ });
2454
+ setPreviewStatus("ready");
2455
+ }).catch(function (failure) {
2456
+ setPreview({ entry: entry, error: String((failure && failure.message) || failure) });
2457
+ setPreviewStatus("error");
2458
+ });
2459
+ return;
2460
+ }
2461
+ if (kind === "sheet") {
2462
+ setPreviewStatus("loading");
2463
+ setPreview(null);
2464
+ apiGet("/sheet", { path: entry.path }).then(function (result) {
2465
+ if (!result.ok) throw new Error(t((result.body && result.body.message) || "无法读取文件"));
2466
+ setPreview({
2467
+ entry: entry,
2468
+ kind: kind,
2469
+ sheet: result.body,
2470
+ body: { kind: kind, size: entry.size, mtime: entry.mtime, mime: null },
2471
+ });
2472
+ setPreviewStatus("ready");
2473
+ }).catch(function (failure) {
2474
+ setPreview({ entry: entry, error: String((failure && failure.message) || failure) });
2475
+ setPreviewStatus("error");
2476
+ });
2477
+ return;
2478
+ }
2479
+ // Images, PDFs, media and HTML are streamed from /raw; only text-like
2480
+ // kinds need a request up front.
2481
+ if (!TEXT_PREVIEW_KINDS[kind]) {
2482
+ setPreviewStatus("ready");
2483
+ setPreview({ entry: entry, kind: kind, body: { kind: kind, size: entry.size, mtime: entry.mtime, mime: null } });
2484
+ return;
2485
+ }
2486
+ setPreviewStatus("loading");
2487
+ setPreview(null);
2488
+ apiGet("/read", { path: entry.path }).then(function (result) {
2489
+ if (!result.ok) throw new Error(t((result.body && result.body.message) || "无法读取文件"));
2490
+ // The host sniffs the bytes, so it says "text" for markdown and CSV too;
2491
+ // the renderer the client picked is the one that matters.
2492
+ setPreview({ entry: entry, kind: kind, body: result.body });
2493
+ setPreviewStatus("ready");
2494
+ }).catch(function (failure) {
2495
+ setPreview({ entry: entry, error: String((failure && failure.message) || failure) });
2496
+ setPreviewStatus("error");
2497
+ });
2498
+ }, []);
2499
+ previewRef.current = openPreview;
2500
+
2501
+ var openDetails = useCallback(function (entry) {
2502
+ if (!entry) { setDetails(null); setDetailsStatus("idle"); return; }
2503
+ setDetailsStatus("loading");
2504
+ setDetails(null);
2505
+ apiGet("/stat", { path: entry.path }).then(function (result) {
2506
+ if (!result.ok) throw new Error(t((result.body && result.body.message) || "无法读取详情"));
2507
+ setDetails({ entry: entry, body: result.body });
2508
+ setDetailsStatus("ready");
2509
+ }).catch(function (failure) {
2510
+ setDetails({ entry: entry, error: String((failure && failure.message) || failure) });
2511
+ setDetailsStatus("error");
2512
+ });
2513
+ }, []);
2514
+ detailsRef.current = openDetails;
2515
+
2516
+ /** Open the details pane for one entry and remember the choice. */
2517
+ var openInfo = useCallback(function (entry) {
2518
+ if (!entry) return;
2519
+ setPaneBoth(true, "info");
2520
+ openDetails(entry);
2521
+ }, [openDetails]);
2522
+
2523
+ /** Fill the right pane for an entry according to the current mode. */
2524
+ var fillPane = useCallback(function (entry) {
2525
+ if (!entry) {
2526
+ setPreview(null);
2527
+ setPreviewStatus("idle");
2528
+ setDetails(null);
2529
+ setDetailsStatus("idle");
2530
+ return;
2531
+ }
2532
+ if (entry.dir || paneMode === "info") openDetails(entry);
2533
+ else openPreview(entry);
2534
+ }, [paneMode, openDetails, openPreview]);
2535
+
2536
+ /** Select one entry, replacing the selection. */
2537
+ var selectEntry = useCallback(function (entry) {
2538
+ setSelected(entry);
2539
+ setSelectedPaths(entry ? [entry.path] : []);
2540
+ setAnchorPath(entry ? entry.path : null);
2541
+ fillPane(entry);
2542
+ }, [fillPane]);
2543
+
2544
+ /**
2545
+ * The workspace the current folder lives in, deepest match first.
2546
+ * @returns {object|null} workspace row
2547
+ */
2548
+ function currentWorkspace() {
2549
+ var path = listing && listing.path;
2550
+ if (typeof path !== "string") return null;
2551
+ var best = null;
2552
+ wsItems.forEach(function (workspace) {
2553
+ var prefix = workspace.path.replace(/[\\/]+$/, "");
2554
+ if (prefix === "") return;
2555
+ if (path === prefix || path.indexOf(prefix + "/") === 0 || path.indexOf(prefix + "\\") === 0) {
2556
+ if (!best || prefix.length > best.path.length) best = workspace;
2557
+ }
2558
+ });
2559
+ return best;
2560
+ }
2561
+
2562
+ /** The entries the bulk actions apply to. */
2563
+ function selectionEntries() {
2564
+ var paths = selectedPaths.length > 0 ? selectedPaths : (selected ? [selected.path] : []);
2565
+ return rows.filter(function (row) { return paths.indexOf(row.path) !== -1; });
2566
+ }
2567
+
2568
+ /** Select every visible row. */
2569
+ function selectAllRows() {
2570
+ var paths = rows.map(function (row) { return row.path; });
2571
+ setSelectedPaths(paths);
2572
+ setPopup(null);
2573
+ if (!selected && rows.length > 0) {
2574
+ setSelected(rows[0]);
2575
+ fillPane(rows[0]);
2576
+ }
2577
+ }
2578
+
2579
+ /** Drop the whole selection. */
2580
+ function clearSelection() {
2581
+ setSelectedPaths([]);
2582
+ setAnchorPath(null);
2583
+ setSelected(null);
2584
+ setPreview(null);
2585
+ setPreviewStatus("idle");
2586
+ setDetails(null);
2587
+ setDetailsStatus("idle");
2588
+ setPopup(null);
2589
+ }
2590
+
2591
+ /** Select the rows that are not selected yet. */
2592
+ function invertSelection() {
2593
+ var next = rows.filter(function (row) { return selectedPaths.indexOf(row.path) === -1; });
2594
+ setPopup(null);
2595
+ if (next.length === 0) { clearSelection(); return; }
2596
+ setSelectedPaths(next.map(function (row) { return row.path; }));
2597
+ setSelected(next[0]);
2598
+ fillPane(next[0]);
2599
+ }
2600
+
2601
+ /** Apply a row click, honouring Cmd/Ctrl (toggle) and Shift (range). */
2602
+ function applyClick(entry, event) {
2603
+ if (!entry) return;
2604
+ var meta = !!(event && (event.metaKey || event.ctrlKey));
2605
+ var shift = !!(event && event.shiftKey);
2606
+ if (shift && anchorPath) {
2607
+ var order = rows.map(function (row) { return row.path; });
2608
+ var from = order.indexOf(anchorPath);
2609
+ var to = order.indexOf(entry.path);
2610
+ if (from !== -1 && to !== -1) {
2611
+ var slice = from <= to ? order.slice(from, to + 1) : order.slice(to, from + 1);
2612
+ setSelectedPaths(slice);
2613
+ setSelected(entry);
2614
+ fillPane(entry);
2615
+ return;
2616
+ }
2617
+ }
2618
+ if (meta) {
2619
+ setSelected(entry);
2620
+ setAnchorPath(entry.path);
2621
+ setSelectedPaths(function (current) {
2622
+ return current.indexOf(entry.path) === -1
2623
+ ? current.concat([entry.path])
2624
+ : current.filter(function (path) { return path !== entry.path; });
2625
+ });
2626
+ fillPane(entry);
2627
+ return;
2628
+ }
2629
+ selectEntry(entry);
2630
+ }
2631
+
2632
+ var openEntry = useCallback(function (entry) {
2633
+ if (!entry) return;
2634
+ if (entry.dir) { load(entry.path, undefined, "in"); return; }
2635
+ setPaneMode("preview");
2636
+ openPreview(entry);
2637
+ }, [load, openPreview]);
2638
+
2639
+ var mutate = useCallback(function (options) {
2640
+ setBusy(true);
2641
+ setMenu(null);
2642
+ apiPost(options.route, options.params || {}, options.body).then(function (result) {
2643
+ setBusy(false);
2644
+ if (!result.ok) {
2645
+ notify(t((result.body && result.body.message) || "操作失败"), "error");
2646
+ return;
2647
+ }
2648
+ var current = listingRef.current;
2649
+ var produced = result.body && typeof result.body.path === "string" ? result.body.path : null;
2650
+ var focus = produced && current && parentOf(produced) === current.path ? produced : null;
2651
+ if (options.onDone) options.onDone(result.body);
2652
+ notify(options.success, "info");
2653
+ load(current ? current.path : null, focus, "neutral");
2654
+ }, function (failure) {
2655
+ setBusy(false);
2656
+ notify(String((failure && failure.message) || failure), "error");
2657
+ });
2658
+ }, [load, notify]);
2659
+
2660
+ var copyText = useCallback(function (text, success) {
2661
+ var write = navigator.clipboard && navigator.clipboard.writeText
2662
+ ? navigator.clipboard.writeText(text)
2663
+ : Promise.reject(new Error(t("剪贴板不可用")));
2664
+ write.then(function () { notify(success, "info"); }, function () { notify(t("复制失败"), "error"); });
2665
+ }, [notify]);
2666
+
2667
+ /** Put the whole selection on the panel clipboard. */
2668
+ function clipboardFromSelection(mode) {
2669
+ var entries = selectionEntries();
2670
+ if (entries.length === 0) { notify(t("先选择文件或文件夹"), "error"); return; }
2671
+ var next = { paths: entries.map(function (entry) { return entry.path; }), mode: mode };
2672
+ remembered.clipboard = next;
2673
+ setClipboard(next);
2674
+ notify(tf(mode === "cut" ? "已剪切 {n} 项" : "已拷贝 {n} 项", { n: entries.length }), "info");
2675
+ }
2676
+
2677
+ /** POST that rejects unless the host answers ok. */
2678
+ function postOk(route, params, body) {
2679
+ return apiPost(route, params, body).then(function (result) {
2680
+ if (!result.ok) throw new Error(t((result.body && result.body.message) || "请求失败"));
2681
+ return result.body;
2682
+ });
2683
+ }
2684
+
2685
+ /** Remember one reversible step so 撤销 can replay it. */
2686
+ function pushUndo(step) {
2687
+ setUndoStack(function (current) { return [step].concat(current).slice(0, 20); });
2688
+ }
2689
+
2690
+ /** Undo the most recent reversible step. */
2691
+ function runUndo() {
2692
+ var step = undoStack[0];
2693
+ setPopup(null);
2694
+ if (!step) return;
2695
+ setUndoStack(function (current) { return current.slice(1); });
2696
+ setBusy(true);
2697
+ Promise.resolve().then(step.run).then(function () {
2698
+ setBusy(false);
2699
+ notify(tf("已撤销:{label}", { label: step.label }), "info");
2700
+ var current = listingRef.current;
2701
+ load(current ? current.path : null, undefined, "neutral");
2702
+ }, function (failure) {
2703
+ setBusy(false);
2704
+ notify(tf("撤销失败:{reason}", { reason: String((failure && failure.message) || failure) }), "error");
2705
+ });
2706
+ }
2707
+
2708
+ /** Ask, then move the selection to the Trash. */
2709
+ function askDeleteSelection() {
2710
+ var entries = selectionEntries();
2711
+ if (entries.length === 0) { notify(t("先选择文件或文件夹"), "error"); return; }
2712
+ setDialog({
2713
+ kind: "confirm", title: t("移到废纸篓"), danger: true, confirmLabel: t("移到废纸篓"),
2714
+ message: entries.length === 1
2715
+ ? tf("“{name}”将被移到废纸篓,可以从废纸篓找回。", { name: entries[0].name })
2716
+ : tf("选中的 {n} 项将被移到废纸篓,可以从废纸篓找回。", { n: entries.length }),
2717
+ onConfirm: function () { moveSelectionToTrash(entries); },
2718
+ });
2719
+ }
2720
+
2721
+ /** Move several entries to the Trash and remember how to restore them. */
2722
+ function moveSelectionToTrash(entries) {
2723
+ setBusy(true);
2724
+ var moved = [];
2725
+ var chain = Promise.resolve();
2726
+ entries.forEach(function (entry) {
2727
+ chain = chain.then(function () {
2728
+ return postOk("/trash", { path: entry.path }).then(function (body) {
2729
+ moved.push({ from: body.from || entry.path, to: body.path });
2730
+ });
2731
+ });
2732
+ });
2733
+ chain.then(function () {
2734
+ setBusy(false);
2735
+ if (moved.length > 0) {
2736
+ pushUndo({
2737
+ label: tf("删除 {n} 项", { n: moved.length }),
2738
+ run: function () {
2739
+ return Promise.all(moved.map(function (item) {
2740
+ return postOk("/transfer", {}, { sources: [item.to], target: parentOf(item.from), mode: "move" });
2741
+ }));
2742
+ },
2743
+ });
2744
+ notify(t("已移到废纸篓"), "info");
2745
+ }
2746
+ var current = listingRef.current;
2747
+ load(current ? current.path : null, undefined, "neutral");
2748
+ }, function (failure) {
2749
+ setBusy(false);
2750
+ notify(String((failure && failure.message) || failure), "error");
2751
+ });
2752
+ }
2753
+
2754
+ // Desktop-bound actions (reveal, open with an app, trash) only make sense
2755
+ // when the browser is on the host machine; ask once and hide them otherwise.
2756
+ useEffect(function () {
2757
+ var alive = true;
2758
+ apiGet("/env").then(function (result) {
2759
+ if (!alive || !result.ok || !result.body) return;
2760
+ var env = result.body;
2761
+ var remote = env.local === false;
2762
+ if (!remote && env.platform) {
2763
+ var hostOs = env.platform === "darwin" ? "mac" : env.platform === "win32" ? "win" : env.platform === "linux" ? "linux" : "";
2764
+ var ua = "";
2765
+ try { ua = String((navigator && (navigator.platform || navigator.userAgent)) || "").toLowerCase(); } catch (error) { ua = ""; }
2766
+ var browserOs = ua.indexOf("mac") !== -1 ? "mac" : ua.indexOf("win") !== -1 ? "win" : ua.indexOf("linux") !== -1 ? "linux" : "";
2767
+ // an ssh tunnel keeps the loopback host but crosses the OS boundary
2768
+ if (hostOs && browserOs && hostOs !== browserOs) remote = true;
2769
+ }
2770
+ setRemoteMode(remote);
2771
+ }).catch(function () { /* keep the desktop actions when unsure */ });
2772
+ return function () { alive = false; };
2773
+ }, []);
2774
+
2775
+ var revealPath = useCallback(function (target) {
2776
+ apiPost("/reveal", { path: target }).then(function (result) {
2777
+ if (!result.ok) { notify(t((result.body && result.body.message) || "无法显示"), "error"); return; }
2778
+ if (result.body && result.body.ok) notify(t("已在访达中显示"), "info");
2779
+ else notify(t("此平台不支持显示"), "error");
2780
+ }, function () { notify(t("无法在访达中显示"), "error"); });
2781
+ }, [notify]);
2782
+
2783
+ var openWithApp = useCallback(function (target) {
2784
+ apiPost("/open", { path: target }).then(function (result) {
2785
+ if (!result.ok) notify(t((result.body && result.body.message) || "无法打开"), "error");
2786
+ }, function () { notify(t("无法打开"), "error"); });
2787
+ }, [notify]);
2788
+
2789
+ /**
2790
+ * Zip one or more paths beside themselves, then refresh.
2791
+ * @param {string[]} sources - absolute paths
2792
+ * @returns {void}
2793
+ */
2794
+ function archivePaths(sources) {
2795
+ if (!sources || sources.length === 0) return;
2796
+ setBusy(true);
2797
+ apiArchive(sources).then(function (result) {
2798
+ setBusy(false);
2799
+ if (!result.ok) { notify(t((result.body && result.body.message) || "压缩失败"), "error"); return; }
2800
+ notify(tf("已生成 {name}", { name: result.body.name }), "info");
2801
+ var current = listingRef.current;
2802
+ load(current ? current.path : null, result.body.path, "neutral");
2803
+ }, function () { setBusy(false); notify(t("压缩失败"), "error"); });
2804
+ }
2805
+
2806
+ /**
2807
+ * Unpack a .zip beside itself, then refresh.
2808
+ * @param {object} entry - archive entry
2809
+ * @returns {void}
2810
+ */
2811
+ function extractArchive(entry) {
2812
+ setBusy(true);
2813
+ apiExtract(entry.path).then(function (result) {
2814
+ setBusy(false);
2815
+ if (!result.ok) { notify(t((result.body && result.body.message) || "解压失败"), "error"); return; }
2816
+ notify(tf("已解压 {count} 个文件", { count: result.body.files }), "info");
2817
+ var current = listingRef.current;
2818
+ load(current ? current.path : null, result.body.path, "neutral");
2819
+ }, function () { setBusy(false); notify(t("解压失败"), "error"); });
2820
+ }
2821
+
2822
+ /**
2823
+ * Push a set of browser files into the folder on screen.
2824
+ * @param {FileList | File[]} files - chosen files
2825
+ * @returns {void}
2826
+ */
2827
+ function uploadFiles(files) {
2828
+ var list = Array.prototype.slice.call(files || []);
2829
+ var current = listingRef.current;
2830
+ if (list.length === 0 || !current) return;
2831
+ setBusy(true);
2832
+ var done = 0;
2833
+ var failed = 0;
2834
+ var step = function () {
2835
+ if (done + failed < list.length) return;
2836
+ setBusy(false);
2837
+ setUpload(null);
2838
+ if (failed === 0) notify(tf("已上传 {count} 个文件", { count: done }), "info");
2839
+ else notify(tf("上传完成:{done} 个成功,{failed} 个失败", { done: done, failed: failed }), failed === list.length ? "error" : "info");
2840
+ load(current.path, undefined, "neutral");
2841
+ };
2842
+ list.forEach(function (file) {
2843
+ setUpload({ name: file.name, loaded: 0, total: file.size });
2844
+ apiUpload(current.path, file, function (loaded, total) { setUpload({ name: file.name, loaded: loaded, total: total }); })
2845
+ .then(function (result) {
2846
+ if (result.ok) done += 1;
2847
+ else failed += 1;
2848
+ step();
2849
+ }, function () { failed += 1; step(); });
2850
+ });
2851
+ }
2852
+
2853
+ var paste = useCallback(function () {
2854
+ var clip = remembered.clipboard;
2855
+ var current = listingRef.current;
2856
+ if (!clip || !clip.paths || clip.paths.length === 0 || !current) {
2857
+ notify(t("剪贴板是空的"), "error");
2858
+ return;
2859
+ }
2860
+ var mode = clip.mode === "cut" ? "move" : "copy";
2861
+ mutate({
2862
+ route: "/transfer",
2863
+ body: { sources: clip.paths, target: current.path, mode: mode },
2864
+ success: mode === "move" ? t("已移动") : t("已拷贝到当前文件夹"),
2865
+ onDone: mode === "move" ? function (body) {
2866
+ var results = (body && body.results) || [];
2867
+ if (results.length === 0) return;
2868
+ pushUndo({
2869
+ label: tf("移动 {n} 项", { n: results.length }),
2870
+ run: function () {
2871
+ return Promise.all(results.map(function (item) {
2872
+ return postOk("/transfer", {}, {
2873
+ sources: [item.path],
2874
+ target: parentOf(item.from && item.from !== item.path ? item.from : item.path),
2875
+ mode: "move",
2876
+ });
2877
+ }));
2878
+ },
2879
+ });
2880
+ } : null,
2881
+ });
2882
+ if (mode === "move") {
2883
+ remembered.clipboard = null;
2884
+ setClipboard(null);
2885
+ }
2886
+ }, [mutate, notify]);
2887
+
2888
+ /** Ask for a name, then create a folder in the current directory. */
2889
+ function askNewFolder() {
2890
+ var current = listingRef.current;
2891
+ if (!current) return;
2892
+ setDialog({
2893
+ kind: "prompt", title: t("新建文件夹"), label: t("文件夹名称"), value: t("未命名文件夹"), confirmLabel: t("创建"),
2894
+ onSubmit: function (name) {
2895
+ mutate({
2896
+ route: "/mkdir", params: { path: current.path, name: name }, success: t("已新建文件夹"),
2897
+ onDone: function (body) {
2898
+ pushUndo({ label: t("新建文件夹"), run: function () { return postOk("/trash", { path: body.path }); } });
2899
+ },
2900
+ });
2901
+ },
2902
+ });
2903
+ }
2904
+
2905
+ /** Ask for a name, then create an empty file in the current directory. */
2906
+ function askNewFile() {
2907
+ var current = listingRef.current;
2908
+ if (!current) return;
2909
+ setDialog({
2910
+ kind: "prompt", title: t("新建文件"), label: t("文件名称"), value: t("未命名.txt"), confirmLabel: t("创建"),
2911
+ onSubmit: function (name) {
2912
+ mutate({
2913
+ route: "/newfile", params: { path: current.path, name: name }, success: t("已新建文件"),
2914
+ onDone: function (body) {
2915
+ pushUndo({ label: t("新建文件"), run: function () { return postOk("/trash", { path: body.path }); } });
2916
+ },
2917
+ });
2918
+ },
2919
+ });
2920
+ }
2921
+
2922
+ /** Open the rename dialog for one entry. */
2923
+ function askRename(entry) {
2924
+ setDialog({
2925
+ kind: "prompt", title: t("重新命名"), label: t("新名称"), value: entry.name, confirmLabel: t("重新命名"),
2926
+ onSubmit: function (name) {
2927
+ var original = entry.name;
2928
+ mutate({
2929
+ route: "/rename", params: { path: entry.path, name: name }, success: t("已重新命名"),
2930
+ onDone: function (body) {
2931
+ pushUndo({
2932
+ label: t("重命名 ") + original,
2933
+ run: function () { return postOk("/rename", { path: body.path, name: original }); },
2934
+ });
2935
+ },
2936
+ });
2937
+ },
2938
+ });
2939
+ }
2940
+
2941
+ /** Ask before moving one entry to the Trash. */
2942
+ function askTrash(entry) {
2943
+ setDialog({
2944
+ kind: "confirm", title: t("移到废纸篓"), danger: true, confirmLabel: t("移到废纸篓"),
2945
+ message: tf("“{name}”将被移到废纸篓,可以从废纸篓找回。", { name: entry.name }),
2946
+ onConfirm: function () { moveSelectionToTrash([entry]); },
2947
+ });
2948
+ }
2949
+
2950
+ /** Run one context-menu command. */
2951
+ function menuAction(id) {
2952
+ var entry = menu && menu.entry;
2953
+ var current = listingRef.current;
2954
+ setMenu(null);
2955
+ if (!id) return;
2956
+ if (id === "refresh") { load(current ? current.path : null, undefined, "neutral"); return; }
2957
+ if (id === "revealHere") { if (current) revealPath(current.path); return; }
2958
+ if (id === "paste") { paste(); return; }
2959
+ if (id === "mkdir") { askNewFolder(); return; }
2960
+ if (id === "newfile") { askNewFile(); return; }
2961
+ if (!entry) return;
2962
+ if (id === "open") { openEntry(entry); return; }
2963
+ if (id === "info") { setSelected(entry); openInfo(entry); return; }
2964
+ if (id === "openApp") { openWithApp(entry.path); return; }
2965
+ if (id === "reveal") { revealPath(entry.path); return; }
2966
+ if (id === "copy") { clipboardFromSelection("copy"); return; }
2967
+ if (id === "cut") { clipboardFromSelection("cut"); return; }
2968
+ if (id === "copyPath") { copyText(entry.path, t("已复制路径")); return; }
2969
+ if (id === "copyRel") { copyText(relativeTo(entry.path, current ? current.root : null), t("已复制相对路径")); return; }
2970
+ if (id === "copyName") { copyText(entry.name, t("已复制名称")); return; }
2971
+ if (id === "download") { downloadFile(entry.path); return; }
2972
+ if (id === "archive") { archivePaths([entry.path]); return; }
2973
+ if (id === "extract") { extractArchive(entry); return; }
2974
+ if (id === "duplicate") {
2975
+ mutate({
2976
+ route: "/duplicate", params: { path: entry.path }, success: t("已复制副本"),
2977
+ onDone: function (body) {
2978
+ pushUndo({ label: t("复制副本"), run: function () { return postOk("/trash", { path: body.path }); } });
2979
+ },
2980
+ });
2981
+ return;
2982
+ }
2983
+ if (id === "rename") { askRename(entry); return; }
2984
+ if (id === "attach") { attachToSession(entry); return; }
2985
+ if (id === "quote") { quoteToSession(entry); return; }
2986
+ if (id === "addWorkspace") { askAddWorkspace(entry); return; }
2987
+ if (id === "trash") { askDeleteSelection(); return; }
2988
+ }
2989
+
2990
+ /** Open the About dialog and fetch the manifest once. */
2991
+ function openAbout() {
2992
+ setDialog({ kind: "about" });
2993
+ if (about) return;
2994
+ apiGet("/meta").then(function (result) {
2995
+ if (result.ok) setAbout(result.body);
2996
+ }).catch(function () { /* the dialog still shows its fallbacks */ });
2997
+ }
2998
+
2999
+ /** Open the workspace switcher with a freshly read list. */
3000
+ function openWorkspacePopup(event) {
3001
+ setWsItems(readWorkspaces(workspacesRef.current));
3002
+ openPopup("workspace", event);
3003
+ }
3004
+
3005
+ /** Open one of the toolbar popups under its button. */
3006
+ function openPopup(kind, event) {
3007
+ var rect = event && event.currentTarget ? event.currentTarget.getBoundingClientRect() : null;
3008
+ setPopup({
3009
+ kind: kind,
3010
+ x: rect ? rect.left : 40,
3011
+ y: rect ? rect.bottom + 6 : 90,
3012
+ });
3013
+ }
3014
+
3015
+ /** Run one toolbar command. */
3016
+ function toolAction(id) {
3017
+ if (id === "cut") { clipboardFromSelection("cut"); return; }
3018
+ if (id === "copy") { clipboardFromSelection("copy"); return; }
3019
+ if (id === "paste") { paste(); return; }
3020
+ if (id === "rename") {
3021
+ var entries = selectionEntries();
3022
+ if (entries.length !== 1) { notify(t("重命名只针对单个条目"), "error"); return; }
3023
+ askRename(entries[0]);
3024
+ return;
3025
+ }
3026
+ if (id === "trash") { askDeleteSelection(); return; }
3027
+ }
3028
+
3029
+ /** Run one popup command. */
3030
+ function popupAction(id) {
3031
+ var origin = popup;
3032
+ setPopup(null);
3033
+ if (id.indexOf("ws:") === 0) {
3034
+ if (id === "ws:add") { if (listing) askAddWorkspace({ path: listing.path, name: listing.name, dir: true }); return; }
3035
+ if (id === "ws:none") return;
3036
+ var chosen = wsItems.filter(function (workspace) { return "ws:" + workspace.workspaceId === id; })[0];
3037
+ if (!chosen) return;
3038
+ load(chosen.path, undefined, "neutral");
3039
+ notify(tf("已切换到工作区:{name}", { name: chosen.title || chosen.path }), "info");
3040
+ return;
3041
+ }
3042
+ if (id === "new:folder") { askNewFolder(); return; }
3043
+ if (id === "new:file") { askNewFile(); return; }
3044
+ if (id === "upload:file") { if (uploadInputRef.current) uploadInputRef.current.click(); return; }
3045
+ if (id === "upload:folder") { if (folderInputRef.current) folderInputRef.current.click(); return; }
3046
+ if (id === "archive:selection") { archivePaths(selectionEntries().map(function (entry) { return entry.path; })); return; }
3047
+ if (id.indexOf("sort:") === 0) { setSort(id.slice(5)); return; }
3048
+ if (id === "undo") { runUndo(); return; }
3049
+ if (id === "all") { selectAllRows(); return; }
3050
+ if (id === "none") { clearSelection(); return; }
3051
+ if (id === "invert") { invertSelection(); return; }
3052
+ if (id === "options") { setDialog({ kind: "options" }); return; }
3053
+ if (id === "about") { openAbout(); return; }
3054
+ }
3055
+
3056
+ /** Turn the breadcrumb bar into an editable path field. */
3057
+ function startAddressEdit() {
3058
+ if (!listing) return;
3059
+ setAddressDraft(listing.path);
3060
+ }
3061
+
3062
+ /** Resolve a typed path against the current folder, the home root and "~". */
3063
+ function resolveAddress(text, base, root) {
3064
+ var raw = String(text || "").trim();
3065
+ if (!raw) return null;
3066
+ if (raw === "~") raw = root || "/";
3067
+ else if (/^~[\\/]/.test(raw)) raw = (root || "") + raw.slice(1);
3068
+ var drive = /^([A-Za-z]:)/.exec(raw);
3069
+ var unc = raw.indexOf("\\\\") === 0;
3070
+ if (!drive && !unc && !/^[\\/]/.test(raw)) raw = (base || root || "/") + "/" + raw;
3071
+ var parts = raw.split(/[\\/]+/).filter(Boolean);
3072
+ var out = [];
3073
+ parts.forEach(function (part) {
3074
+ if (part === ".") return;
3075
+ if (part === "..") { out.pop(); return; }
3076
+ out.push(part);
3077
+ });
3078
+ // C:\Users\me / \\server\share\dir / /Users/me
3079
+ if (drive) return drive[1] + "\\" + out.slice(1).join("\\");
3080
+ if (unc) return "\\\\" + out.join("\\");
3081
+ return "/" + out.join("/");
3082
+ }
3083
+
3084
+ /** Leave edit mode and jump to the typed path. */
3085
+ function commitAddress(text) {
3086
+ var base = listing ? listing.path : null;
3087
+ var root = listing ? listing.root : null;
3088
+ setAddressDraft(null);
3089
+ var next = resolveAddress(text, base, root);
3090
+ if (next) load(next, undefined, "in");
3091
+ }
3092
+
3093
+ // ⌘L focuses the address bar, the way a browser does.
3094
+ useEffect(function () {
3095
+ if (typeof window === "undefined" || !window.addEventListener) return undefined;
3096
+ var onKey = function (event) {
3097
+ if (!(event.metaKey || event.ctrlKey) || (event.key !== "l" && event.key !== "L")) return;
3098
+ var node = rootRef.current;
3099
+ if (!node || !node.contains || !node.contains(document.activeElement)) return;
3100
+ event.preventDefault();
3101
+ startAddressEdit();
3102
+ };
3103
+ window.addEventListener("keydown", onKey);
3104
+ return function () { window.removeEventListener("keydown", onKey); };
3105
+ }, [listing]);
3106
+
3107
+ useEffect(function () {
3108
+ if (addressDraft === null) return;
3109
+ var node = addressRef.current;
3110
+ if (node && node.focus) {
3111
+ node.focus();
3112
+ if (node.select) node.select();
3113
+ }
3114
+ }, [addressDraft]);
3115
+
3116
+ var rows = useMemo(function () {
3117
+ if (!listing) return [];
3118
+ var needle = query.trim().toLowerCase();
3119
+ var filtered = listing.entries.filter(function (entry) {
3120
+ if (!showHidden && entry.hidden) return false;
3121
+ if (!needle) return true;
3122
+ return entry.name.toLowerCase().indexOf(needle) !== -1;
3123
+ });
3124
+ var sorted = filtered.slice();
3125
+ sorted.sort(function (left, right) {
3126
+ if (left.dir !== right.dir) return left.dir ? -1 : 1;
3127
+ if (sort === "mtime") return (right.mtime || 0) - (left.mtime || 0) || compareNames(left.name, right.name);
3128
+ if (sort === "size") return (right.size || 0) - (left.size || 0) || compareNames(left.name, right.name);
3129
+ return compareNames(left.name, right.name);
3130
+ });
3131
+ return sorted;
3132
+ }, [listing, query, showHidden, sort]);
3133
+
3134
+ var crumbs = useMemo(function () { return crumbsOf(listing); }, [listing]);
3135
+
3136
+ useEffect(function () {
3137
+ if (!popup) return undefined;
3138
+ var close = function (event) {
3139
+ var target = event && event.target;
3140
+ if (target && target.closest && target.closest(".dfx-menu")) return;
3141
+ setPopup(null);
3142
+ };
3143
+ var onKey = function (event) { if (event.key === "Escape") setPopup(null); };
3144
+ window.addEventListener("mousedown", close);
3145
+ window.addEventListener("keydown", onKey);
3146
+ window.addEventListener("resize", close);
3147
+ return function () {
3148
+ window.removeEventListener("mousedown", close);
3149
+ window.removeEventListener("keydown", onKey);
3150
+ window.removeEventListener("resize", close);
3151
+ };
3152
+ }, [popup]);
3153
+
3154
+ var popupItems = useMemo(function () {
3155
+ if (!popup) return [];
3156
+ if (popup.kind === "new") {
3157
+ return [
3158
+ { id: "new:folder", label: t("新建文件夹…"), icon: "folder" },
3159
+ { id: "new:file", label: t("新建文件…"), icon: "file" },
3160
+ ];
3161
+ }
3162
+ if (popup.kind === "upload") {
3163
+ if (!remoteMode) return [];
3164
+ return [
3165
+ { id: "upload:file", label: t("上传文件…"), icon: "upload", hint: t("从本机上传") },
3166
+ { id: "upload:folder", label: t("上传文件夹…"), icon: "folderPlus", hint: t("从本机上传") },
3167
+ ];
3168
+ }
3169
+ if (popup.kind === "workspace") {
3170
+ var activeWorkspace = currentWorkspace();
3171
+ var rows = wsItems.map(function (workspace) {
3172
+ return {
3173
+ id: "ws:" + workspace.workspaceId,
3174
+ label: workspace.title || workspace.path,
3175
+ hint: shortPath(workspace.path),
3176
+ checked: !!activeWorkspace && activeWorkspace.workspaceId === workspace.workspaceId,
3177
+ };
3178
+ });
3179
+ if (rows.length === 0) rows.push({ id: "ws:none", label: t("还没有工作区"), icon: "briefcase", disabled: true });
3180
+ rows.push({ separator: true });
3181
+ rows.push({ id: "ws:add", label: t("把当前文件夹添加为工作区"), icon: "briefcase", disabled: !listing });
3182
+ return rows;
3183
+ }
3184
+ if (popup.kind === "sort") {
3185
+ return [
3186
+ { id: "sort:name", label: t("名称"), checked: sort === "name" },
3187
+ { id: "sort:size", label: t("大小"), checked: sort === "size" },
3188
+ { id: "sort:mtime", label: t("修改时间"), checked: sort === "mtime" },
3189
+ ];
3190
+ }
3191
+ // From the host's own browser the file picker is a detour through the
3192
+ // network to the disk sitting next to you: the row only exists remotely.
3193
+ var uploadRows = remoteMode
3194
+ ? [
3195
+ { id: "upload:file", label: t("上传文件…"), icon: "upload", disabled: !listing, hint: t("从本机上传") },
3196
+ { id: "upload:folder", label: t("上传文件夹…"), icon: "folderPlus", disabled: !listing, hint: t("从本机上传") },
3197
+ { separator: true },
3198
+ ]
3199
+ : [];
3200
+ return uploadRows.concat([
3201
+ { separator: true },
3202
+ { id: "undo", label: undoStack.length > 0 ? t("撤销 ") + undoStack[0].label : t("撤销"), icon: "undo", disabled: undoStack.length === 0 },
3203
+ { separator: true },
3204
+ { id: "all", label: t("全部选择"), icon: "check", hint: accel("A") },
3205
+ { id: "none", label: t("全部取消"), icon: "close", hint: IS_MAC ? "⌘⇧A" : "Ctrl+Shift+A" },
3206
+ { id: "invert", label: t("反向选择"), icon: "squares", hint: IS_MAC ? "⌘⌥A" : "Ctrl+Alt+A" },
3207
+ { separator: true },
3208
+ { id: "options", label: t("选项"), icon: "sliders" },
3209
+ { id: "about", label: t("关于"), icon: "info" },
3210
+ ]);
3211
+ }, [popup, sort, showHidden, view, paneMode, undoStack, wsItems, listing, remoteMode]);
3212
+
3213
+ var menuItems = useMemo(function () {
3214
+ if (!menu) return [];
3215
+ var entry = menu.entry;
3216
+ if (entry) {
3217
+ return [
3218
+ { id: "open", label: entry.dir ? t("打开") : t("预览"), icon: entry.dir ? "folder" : "file" },
3219
+ { id: "info", label: t("显示详情"), icon: "info" },
3220
+ remoteMode ? null : { id: "openApp", label: t("用默认应用打开"), icon: "external" },
3221
+ remoteMode ? null : { id: "reveal", label: t("在访达中显示"), icon: "reveal" },
3222
+ { separator: true },
3223
+ { id: "rename", label: t("重新命名…"), icon: "pencil" },
3224
+ { id: "duplicate", label: t("复制副本"), icon: "squares" },
3225
+ { id: "copy", label: t("拷贝"), icon: "copy", hint: accel("C") },
3226
+ { id: "cut", label: t("剪切"), icon: "scissors", hint: accel("X") },
3227
+ { separator: true },
3228
+ { id: "copyPath", label: t("复制路径"), icon: "link" },
3229
+ { id: "copyRel", label: t("复制相对路径"), icon: "link" },
3230
+ { id: "copyName", label: t("复制名称"), icon: "text" },
3231
+ entry.dir ? null : { id: "download", label: t("下载"), icon: "download" },
3232
+ { id: "archive", label: t("压缩为 ZIP"), icon: "archive" },
3233
+ entry.dir || !/\.zip$/i.test(entry.name) ? null : { id: "extract", label: t("解压到此处"), icon: "archive" },
3234
+ entry.dir ? null : { separator: true },
3235
+ ATTACH_KINDS[entry.kind] ? { id: "attach", label: t("添加到会话"), icon: "clip" } : null,
3236
+ entry.dir ? null : { id: "quote", label: t("引用到输入框"), icon: "at" },
3237
+ entry.dir && workspacesRef.current ? { separator: true } : null,
3238
+ entry.dir && workspacesRef.current ? { id: "addWorkspace", label: t("添加为工作区"), icon: "briefcase" } : null,
3239
+ remoteMode ? null : { separator: true },
3240
+ remoteMode ? null : { id: "trash", label: t("移到废纸篓"), icon: "trash", danger: true },
3241
+ ];
3242
+ }
3243
+ return [
3244
+ { id: "mkdir", label: t("新建文件夹…"), icon: "folderPlus" },
3245
+ { id: "newfile", label: t("新建文件…"), icon: "filePlus" },
3246
+ { id: "paste", label: t("粘贴"), icon: "paste", hint: accel("V"), disabled: !clipboard },
3247
+ { separator: true },
3248
+ remoteMode ? null : { id: "revealHere", label: t("在访达中显示当前文件夹"), icon: "reveal" },
3249
+ { id: "refresh", label: t("刷新"), icon: "refresh" },
3250
+ ];
3251
+ }, [menu, clipboard]);
3252
+
3253
+ /**
3254
+ * Hand a document to the current conversation by dropping it on the
3255
+ * composer — the same path DSH's attach button and OS drag-and-drop use.
3256
+ * @param {object} entry - file entry
3257
+ * @returns {void}
3258
+ */
3259
+ function attachToSession(entry) {
3260
+ sendToSession([entry]);
3261
+ }
3262
+
3263
+ /**
3264
+ * Hand one or more entries to the conversation: files ride in as
3265
+ * attachments, folders are mentioned by path (the composer has no way to
3266
+ * attach a folder).
3267
+ * @param {Array} entries - selected entries, in list order
3268
+ * @returns {void}
3269
+ */
3270
+ function sendToSession(entries) {
3271
+ var files = entries.filter(function (entry) { return !entry.dir; });
3272
+ var folders = entries.filter(function (entry) { return !!entry.dir; });
3273
+ if (files.length === 0 && folders.length === 0) return;
3274
+ setBusy(true);
3275
+ Promise.all(files.map(function (entry) {
3276
+ return fetch(API + "/raw?path=" + encodeURIComponent(entry.path)).then(function (response) {
3277
+ if (!response.ok) throw new Error(tf("读取文件失败({status})", { status: response.status }));
3278
+ return response.blob().then(function (blob) {
3279
+ return new File([blob], entry.name, { type: blob.type || "application/octet-stream" });
3280
+ });
3281
+ });
3282
+ })).then(function (made) {
3283
+ var layout = layoutRef.current;
3284
+ if (layout && typeof layout.selectPanel === "function") layout.selectPanel(null);
3285
+ return waitForComposer(4000).then(function (card) {
3286
+ if (!card) throw new Error(t("没有找到会话输入框"));
3287
+ if (made.length > 0) {
3288
+ var transfer = new DataTransfer();
3289
+ made.forEach(function (file) { transfer.items.add(file); });
3290
+ card.dispatchEvent(new DragEvent("dragover", { bubbles: true, cancelable: true, dataTransfer: transfer }));
3291
+ card.dispatchEvent(new DragEvent("drop", { bubbles: true, cancelable: true, dataTransfer: transfer }));
3292
+ }
3293
+ folders.forEach(function (folder) { insertComposerText(card, "@" + folder.path + "/ "); });
3294
+ notify(tf("已添加到会话:{n} 项", { n: String(entries.length) }), "info");
3295
+ });
3296
+ }).catch(function (error) {
3297
+ var message = (error && error.message) || String(error);
3298
+ try { console.error(t("[dsh-file-explorer] 添加到会话失败:"), message); } catch (ignored) {}
3299
+ }).then(function () { setBusy(false); });
3300
+ }
3301
+
3302
+ /**
3303
+ * Reference a file by path in the composer instead of uploading it, so the
3304
+ * agent reads it only when it needs to.
3305
+ * @param {object} entry - file entry
3306
+ * @returns {void}
3307
+ */
3308
+ function quoteToSession(entry) {
3309
+ var layout = layoutRef.current;
3310
+ if (layout && typeof layout.selectPanel === "function") layout.selectPanel(null);
3311
+ waitForComposer(4000).then(function (card) {
3312
+ if (!card) throw new Error(t("没有找到会话输入框"));
3313
+ insertComposerText(card, "@" + entry.path + " ");
3314
+ }).catch(function (error) {
3315
+ var message = (error && error.message) || String(error);
3316
+ try { console.error(t("[dsh-file-explorer] 引用到输入框失败:"), message); } catch (ignored) {}
3317
+ });
3318
+ }
3319
+
3320
+ /**
3321
+ * Register a folder as a DSH workspace through the client workspace service.
3322
+ * @param {object} entry - folder entry carrying an absolute path
3323
+ * @returns {void}
3324
+ */
3325
+ function askAddWorkspace(entry) {
3326
+ var service = workspacesRef.current;
3327
+ if (!service || typeof service.create !== "function") {
3328
+ notify(t("当前版本没有工作区服务"), "error");
3329
+ return;
3330
+ }
3331
+ setDialog({
3332
+ kind: "confirm",
3333
+ title: t("添加为工作区"),
3334
+ confirmLabel: t("添加"),
3335
+ message: [
3336
+ t("确认要将 "),
3337
+ h("strong", { key: "name", className: "dfx-dialog-em" }, entry.name),
3338
+ t(" 添加为 DSH 工作区?"),
3339
+ ],
3340
+ onConfirm: function () { addWorkspace(entry, service); },
3341
+ });
3342
+ }
3343
+
3344
+ /**
3345
+ * Create the workspace and report the outcome.
3346
+ * @param {object} entry - folder entry
3347
+ * @param {object} service - ctx.workspaces
3348
+ * @returns {void}
3349
+ */
3350
+ function addWorkspace(entry, service) {
3351
+ setBusy(true);
3352
+ service.create({ path: entry.path }).then(
3353
+ function () {
3354
+ setBusy(false);
3355
+ setWsItems(readWorkspaces(service));
3356
+ notify(tf("已添加为工作区:{name}", { name: entry.name }), "info");
3357
+ },
3358
+ function (error) {
3359
+ setBusy(false);
3360
+ var message = (error && (error.message || error.code)) || t("添加失败");
3361
+ notify(String(message).slice(0, 120), "error");
3362
+ },
3363
+ );
3364
+ }
3365
+
3366
+ /** Open the empty-area context menu at the pointer. */
3367
+ function openAreaMenu(event) {
3368
+ event.preventDefault();
3369
+ if (event.target && event.target.closest && event.target.closest(".dfx-row, .dfx-tile")) return;
3370
+ setMenu({ x: event.clientX, y: event.clientY, entry: null });
3371
+ }
3372
+
3373
+ /** Select a row and open its context menu. */
3374
+ function openRowMenu(event, entry) {
3375
+ event.preventDefault();
3376
+ event.stopPropagation();
3377
+ if (selectedPaths.indexOf(entry.path) === -1) {
3378
+ setSelected(entry);
3379
+ setSelectedPaths([entry.path]);
3380
+ setAnchorPath(entry.path);
3381
+ fillPane(entry);
3382
+ }
3383
+ setMenu({ x: event.clientX, y: event.clientY, entry: entry });
3384
+ if (rowsRef.current && rowsRef.current.focus) rowsRef.current.focus({ preventScroll: true });
3385
+ }
3386
+
3387
+ /** Keyboard navigation and file shortcuts on the list. */
3388
+ function onKeyDown(event) {
3389
+ var meta = event.metaKey || event.ctrlKey;
3390
+ // ⌘S / Ctrl+S saves the editor draft; the textarea keeps focus.
3391
+ if (meta && (event.key === "s" || event.key === "S") && editor) {
3392
+ saveEditing(false);
3393
+ event.preventDefault();
3394
+ return;
3395
+ }
3396
+ if (meta && (event.key === "1" || event.key === "2")) {
3397
+ changeView(VIEW_MODES[Number(event.key) - 1]);
3398
+ event.preventDefault();
3399
+ return;
3400
+ }
3401
+ if (meta && (event.key === "a" || event.key === "A")) {
3402
+ if (event.shiftKey) { clearSelection(); } else if (event.altKey) { invertSelection(); } else { selectAllRows(); }
3403
+ event.preventDefault();
3404
+ return;
3405
+ }
3406
+ if (event.key === "Escape" && !meta) {
3407
+ clearSelection();
3408
+ return;
3409
+ }
3410
+ if (meta && (event.key === "c" || event.key === "C")) {
3411
+ clipboardFromSelection("copy");
3412
+ event.preventDefault();
3413
+ return;
3414
+ }
3415
+ if (meta && (event.key === "x" || event.key === "X")) {
3416
+ clipboardFromSelection("cut");
3417
+ event.preventDefault();
3418
+ return;
3419
+ }
3420
+ if (meta && (event.key === "v" || event.key === "V")) {
3421
+ paste();
3422
+ event.preventDefault();
3423
+ return;
3424
+ }
3425
+ if ((event.key === "Delete" || (meta && event.key === "Backspace")) && !remoteMode) {
3426
+ askDeleteSelection();
3427
+ event.preventDefault();
3428
+ return;
3429
+ }
3430
+ if (event.key === "F2" && selected) {
3431
+ askRename(selected);
3432
+ event.preventDefault();
3433
+ return;
3434
+ }
3435
+ if (event.key === "ArrowDown" || event.key === "ArrowUp") {
3436
+ if (rows.length === 0) return;
3437
+ event.preventDefault();
3438
+ var index = selected ? rows.findIndex(function (row) { return row.path === selected.path; }) : -1;
3439
+ var next = event.key === "ArrowDown" ? Math.min(index + 1, rows.length - 1) : Math.max(index - 1, 0);
3440
+ var entry = rows[next];
3441
+ if (!entry) return;
3442
+ selectEntry(entry);
3443
+ return;
3444
+ }
3445
+ if (event.key === "Enter" && selected) {
3446
+ event.preventDefault();
3447
+ openEntry(selected);
3448
+ return;
3449
+ }
3450
+ if (event.key === "Backspace" && listing && listing.parent) {
3451
+ event.preventDefault();
3452
+ load(listing.parent, undefined, "out");
3453
+ }
3454
+ }
3455
+
3456
+ /** One draggable column edge in the list header. */
3457
+ var colResizer = function (key) {
3458
+ return h("button", {
3459
+ type: "button",
3460
+ className: "dfx-col-resizer" + (resizing === key ? " dfx-col-resizer--active" : ""),
3461
+ "aria-label": t("调整列宽"),
3462
+ title: t("拖动调整列宽,双击恢复默认"),
3463
+ tabIndex: -1,
3464
+ onMouseDown: function (event) { startColumnResize(key, event); },
3465
+ onDoubleClick: function (event) { event.preventDefault(); event.stopPropagation(); resetColumn(key); },
3466
+ onClick: function (event) { event.stopPropagation(); },
3467
+ });
3468
+ };
3469
+
3470
+ /** One clickable column label in the list header. */
3471
+ var headCell = function (key, label) {
3472
+ return h("button", {
3473
+ type: "button",
3474
+ className: "dfx-headcell",
3475
+ onClick: function () { setSort(key); },
3476
+ }, label, sort === key ? glyph("chevron", 11) : null, colResizer(key));
3477
+ };
3478
+
3479
+ /** Column widths for the list header: null means "share the rest". */
3480
+ var COLUMN_KEYS = ["name", "type", "size", "mtime"];
3481
+ var COL_MIN = { name: 160, type: 64, size: 64, mtime: 96 };
3482
+
3483
+ var columnsState = useState(function () {
3484
+ try {
3485
+ var stored = JSON.parse(window.localStorage.getItem(COLUMNS_KEY) || "null");
3486
+ if (stored && typeof stored === "object") {
3487
+ var clean = {};
3488
+ COLUMN_KEYS.forEach(function (key) {
3489
+ var value = Number(stored[key]);
3490
+ if (Number.isFinite(value) && value >= COL_MIN[key]) clean[key] = Math.round(value);
3491
+ });
3492
+ return clean;
3493
+ }
3494
+ } catch (error) { /* fall through to the defaults */ }
3495
+ return {};
3496
+ });
3497
+ var columnWidths = columnsState[0];
3498
+ var setColumnWidths = columnsState[1];
3499
+ var [resizing, setResizing] = useState(null);
3500
+
3501
+ /**
3502
+ * The transition class for the current navigation, honouring the effect
3503
+ * picked in 选项 and the "no animation" switch.
3504
+ * @param {string} base - "dfx-rows" or "dfx-head"
3505
+ * @returns {string} a leading-space class list, or an empty string
3506
+ */
3507
+ function motionClass(base) {
3508
+ if (!navMotion.dir || !anim.enabled) return "";
3509
+ var effect = navMotion.dir === "neutral"
3510
+ ? "neutral"
3511
+ : anim.effect === "slide" ? navMotion.dir : anim.effect;
3512
+ return " " + base + "--" + effect;
3513
+ }
3514
+
3515
+ var columnStyle = useMemo(function () {
3516
+ var style = {};
3517
+ COLUMN_KEYS.forEach(function (key) {
3518
+ if (key === "name") {
3519
+ style["--dfx-col-name"] = columnWidths.name ? columnWidths.name + "px" : "minmax(0, 1fr)";
3520
+ } else {
3521
+ style["--dfx-col-" + key] = (columnWidths[key] || COLUMN_DEFAULT[key]) + "px";
3522
+ }
3523
+ });
3524
+ return style;
3525
+ }, [columnWidths]);
3526
+
3527
+ /** Persist the widths after a drag. */
3528
+ var saveColumns = useCallback(function (next) {
3529
+ try { window.localStorage.setItem(COLUMNS_KEY, JSON.stringify(next)); } catch (error) { /* ignore */ }
3530
+ }, []);
3531
+
3532
+ /**
3533
+ * Start dragging one column's right edge.
3534
+ * @param {string} key - column id
3535
+ * @param {object} event - pointer/mouse event
3536
+ * @returns {void}
3537
+ */
3538
+ function startColumnResize(key, event) {
3539
+ if (event.button !== undefined && event.button !== 0) return;
3540
+ event.preventDefault();
3541
+ event.stopPropagation();
3542
+ var handle = event.currentTarget;
3543
+ var header = handle && handle.parentElement ? handle.parentElement : null;
3544
+ var startWidth = header && typeof header.getBoundingClientRect === "function"
3545
+ ? Math.round(header.getBoundingClientRect().width)
3546
+ : (columnWidths[key] || COLUMN_DEFAULT[key]);
3547
+ if (key === "name" && !columnWidths.name) {
3548
+ startWidth = startWidth || 240;
3549
+ }
3550
+ var startX = event.clientX;
3551
+ setResizing(key);
3552
+ var next = Object.assign({}, columnWidths);
3553
+ function onMove(moveEvent) {
3554
+ var width = Math.max(COL_MIN[key], Math.round(startWidth + (moveEvent.clientX - startX)));
3555
+ next[key] = width;
3556
+ setColumnWidths(Object.assign({}, next));
3557
+ }
3558
+ function onUp() {
3559
+ window.removeEventListener("mousemove", onMove);
3560
+ window.removeEventListener("mouseup", onUp);
3561
+ setResizing(null);
3562
+ saveColumns(next);
3563
+ }
3564
+ window.addEventListener("mousemove", onMove);
3565
+ window.addEventListener("mouseup", onUp);
3566
+ }
3567
+
3568
+ /** Restore one column to its default width. */
3569
+ function resetColumn(key) {
3570
+ var next = Object.assign({}, columnWidths);
3571
+ delete next[key];
3572
+ setColumnWidths(next);
3573
+ saveColumns(next);
3574
+ }
3575
+
3576
+ var body = null;
3577
+ if (status === "error") {
3578
+ body = h("div", { className: "dfx-notice dfx-notice--error" }, tf("读取失败:{reason}", { reason: error || t("未知错误") }));
3579
+ } else if (status === "loading" && !listing) {
3580
+ body = h("div", { className: "dfx-empty" }, t("正在加载…"));
3581
+ } else if (rows.length === 0) {
3582
+ body = h("div", { className: "dfx-empty" }, query ? t("没有匹配的条目") : t("此目录为空"));
3583
+ } else if (view === "icons") {
3584
+ body = rows.map(function (entry) {
3585
+ return h("div", {
3586
+ key: entry.path,
3587
+ className: "dfx-tile" + (selectedPaths.indexOf(entry.path) !== -1 ? " dfx-tile--sel" : ""),
3588
+ title: gitTitle(entry) || entry.name,
3589
+ draggable: true,
3590
+ onDragStart: function (event) { startDrag(event, entry); },
3591
+ onClick: function (event) { applyClick(entry, event); },
3592
+ onDoubleClick: function () { openEntry(entry); },
3593
+ onContextMenu: function (event) { openRowMenu(event, entry); },
3594
+ },
3595
+ h("span", { className: "dfx-tile-icon" + (entry.dir ? " dfx-tile-icon--folder" : "") }, glyph(entryShape(entry), 44)),
3596
+ h("span", {
3597
+ className: "dfx-tile-name" + (entry.hidden ? " dfx-name-text--dim" : ""),
3598
+ title: entry.name,
3599
+ }, clampLabel(entry.name, 30), gitBadge(entry)));
3600
+ });
3601
+ } else if (view === "grouped") {
3602
+ var groups = [];
3603
+ var byKind = {};
3604
+ rows.forEach(function (entry) {
3605
+ var key = entry.dir ? "folder" : entry.kind || "other";
3606
+ if (!byKind[key]) {
3607
+ byKind[key] = { kind: key, dir: !!entry.dir, entries: [], total: 0 };
3608
+ groups.push(byKind[key]);
3609
+ }
3610
+ byKind[key].entries.push(entry);
3611
+ if (!entry.dir && typeof entry.size === "number") byKind[key].total += entry.size;
3612
+ });
3613
+ var styleName = GROUP_STYLES.some(function (option) { return option.id === groupStyle; }) ? groupStyle : "card";
3614
+ body = h(Fragment, null,
3615
+ h("div", { className: "dfx-groupsum" },
3616
+ h("span", { className: "dfx-groupsum-label" }, t("分类")),
3617
+ groups.map(function (group) {
3618
+ return h("span", {
3619
+ key: "sum-" + group.kind,
3620
+ className: "dfx-groupsum-chip",
3621
+ style: { "--dfx-kind": kindColor(group.kind, group.dir) },
3622
+ },
3623
+ h("span", { className: "dfx-groupsum-dot" }),
3624
+ kindLabel({ dir: group.dir, kind: group.kind }),
3625
+ h("b", null, String(group.entries.length)));
3626
+ })),
3627
+ groups.map(function (group) {
3628
+ var color = kindColor(group.kind, group.dir);
3629
+ return h("details", {
3630
+ key: "group-" + group.kind,
3631
+ open: true,
3632
+ className: "dfx-group dfx-group--" + styleName,
3633
+ style: {
3634
+ "--dfx-kind": color,
3635
+ "--dfx-kind-soft": color + "14",
3636
+ "--dfx-kind-tint": color + "24",
3637
+ },
3638
+ },
3639
+ h("summary", { className: "dfx-group-head" },
3640
+ h("span", { className: "dfx-group-icon" }, glyph(entryShape({ dir: group.dir, kind: group.kind }), 16)),
3641
+ h("span", { className: "dfx-group-label" }, kindLabel({ dir: group.dir, kind: group.kind })),
3642
+ h("span", { className: "dfx-group-count" }, String(group.entries.length)),
3643
+ h("span", { className: "dfx-group-tail" },
3644
+ group.total ? h("span", { className: "dfx-group-total" }, formatSize(group.total)) : null,
3645
+ h("span", { className: "dfx-group-caret" }, glyph("chevronDown", 12)))),
3646
+ h("div", { className: "dfx-group-body" },
3647
+ group.entries.map(function (entry) {
3648
+ return h("div", {
3649
+ key: entry.path,
3650
+ className: "dfx-row dfx-row--grouped" + (selectedPaths.indexOf(entry.path) !== -1 ? " dfx-row--sel" : ""),
3651
+ title: gitTitle(entry) || entry.name,
3652
+ draggable: true,
3653
+ onDragStart: function (event) { startDrag(event, entry); },
3654
+ onClick: function (event) { applyClick(entry, event); },
3655
+ onDoubleClick: function () { openEntry(entry); },
3656
+ onContextMenu: function (event) { openRowMenu(event, entry); },
3657
+ },
3658
+ h("div", { className: "dfx-name" },
3659
+ h("span", { className: "dfx-name-icon" + (entry.dir ? " dfx-name-icon--folder" : "") }, glyph(entryShape(entry), 16)),
3660
+ h("span", { className: "dfx-name-text" + (entry.hidden ? " dfx-name-text--dim" : ""), title: entry.name }, entry.name, gitBadge(entry))),
3661
+ h("div", { className: "dfx-cell" }, entry.dir ? "" : formatSize(entry.size)),
3662
+ h("div", { className: "dfx-cell" }, formatDate(entry.mtime)));
3663
+ })));
3664
+ }));
3665
+ } else {
3666
+ body = rows.map(function (entry) {
3667
+ return h("div", {
3668
+ key: entry.path,
3669
+ className: "dfx-row" + (selectedPaths.indexOf(entry.path) !== -1 ? " dfx-row--sel" : ""),
3670
+ title: gitTitle(entry) || entry.name,
3671
+ draggable: true,
3672
+ onDragStart: function (event) { startDrag(event, entry); },
3673
+ onClick: function (event) { applyClick(entry, event); },
3674
+ onDoubleClick: function () { openEntry(entry); },
3675
+ onContextMenu: function (event) { openRowMenu(event, entry); },
3676
+ },
3677
+ h("div", { className: "dfx-name" },
3678
+ h("span", { className: "dfx-name-icon" + (entry.dir ? " dfx-name-icon--folder" : "") }, glyph(entryShape(entry), 16)),
3679
+ h("span", { className: "dfx-name-text" + (entry.hidden ? " dfx-name-text--dim" : ""), title: entry.name }, entry.name, gitBadge(entry))),
3680
+ h("div", { className: "dfx-cell" }, kindLabel(entry)),
3681
+ h("div", { className: "dfx-cell" }, entry.dir ? "" : formatSize(entry.size)),
3682
+ h("div", { className: "dfx-cell" }, formatDate(entry.mtime)));
3683
+ });
3684
+ }
3685
+
3686
+ /**
3687
+ * Git letter for one entry, when the folder belongs to a repository.
3688
+ * @param {object} entry - listing entry
3689
+ * @returns {string | null} decoration letter
3690
+ */
3691
+ function gitLetter(entry) {
3692
+ var map = gitMap && gitMap.entries;
3693
+ if (!map) return null;
3694
+ var letter = map[entry.path];
3695
+ if (!letter) {
3696
+ // a folder counts as changed when anything below it is
3697
+ var prefix = entry.path + "/";
3698
+ var inside = Object.keys(map).some(function (key) { return key.indexOf(prefix) === 0; });
3699
+ return inside ? "dir" : null;
3700
+ }
3701
+ return letter;
3702
+ }
3703
+
3704
+ /**
3705
+ * Tooltip text explaining the git decoration.
3706
+ * @param {object} entry - listing entry
3707
+ * @returns {string} title
3708
+ */
3709
+ function gitTitle(entry) {
3710
+ var letter = gitLetter(entry);
3711
+ if (!letter) return "";
3712
+ var names = { M: t("已修改"), A: t("已暂存"), D: t("已删除"), R: t("已重命名"), untracked: t("未跟踪"), conflict: t("合并冲突"), dir: t("此文件夹内有改动") };
3713
+ return names[letter] || t("已修改");
3714
+ }
3715
+
3716
+ /**
3717
+ * Small coloured dot that carries the git decoration.
3718
+ * @param {object} entry - listing entry
3719
+ * @returns {object | null} element
3720
+ */
3721
+ function gitBadge(entry) {
3722
+ var letter = gitLetter(entry);
3723
+ if (!letter) return null;
3724
+ return h("span", { className: "dfx-git dfx-git--" + letter, "aria-hidden": "true" });
3725
+ }
3726
+
3727
+ /**
3728
+ * Start dragging one entry: pasting its path as text is what the composer
3729
+ * understands, so a drop lands as an @ mention.
3730
+ * @param {DragEvent} event - drag start
3731
+ * @param {object} entry - listing entry
3732
+ * @returns {void}
3733
+ */
3734
+ function startDrag(event, entry) {
3735
+ if (!event || !event.dataTransfer) return;
3736
+ // dragging one row of a multi-selection carries the whole selection
3737
+ var chosen = selectionEntries();
3738
+ var inSelection = chosen.some(function (row) { return row.path === entry.path; });
3739
+ if (!inSelection) chosen = [entry];
3740
+ setDragEntries(chosen);
3741
+ setDropHot(false);
3742
+ var mention = "@" + entry.path + (entry.dir ? "/" : "") + " ";
3743
+ event.dataTransfer.effectAllowed = "copy";
3744
+ event.dataTransfer.setData("text/plain", mention);
3745
+ event.dataTransfer.setData("application/x-dsh-file-explorer", JSON.stringify({
3746
+ path: entry.path,
3747
+ dir: !!entry.dir,
3748
+ name: entry.name,
3749
+ entries: chosen.map(function (row) { return { path: row.path, dir: !!row.dir, name: row.name }; }),
3750
+ }));
3751
+ }
3752
+
3753
+ /** End a drag: the strip and its highlight go away. */
3754
+ function endDrag() {
3755
+ setDragEntries(null);
3756
+ setDropHot(false);
3757
+ }
3758
+
3759
+ /**
3760
+ * Enter edit mode for a text preview.
3761
+ * @param {object} entry - file entry
3762
+ * @param {object} payload - preview payload (text + stat fields)
3763
+ * @returns {void}
3764
+ */
3765
+ function startEditing(entry, payload) {
3766
+ setEditor({ entry: entry, text: payload.text || "", mtime: payload.mtime, size: payload.size });
3767
+ }
3768
+
3769
+ /**
3770
+ * Leave edit mode, discarding the draft.
3771
+ * @returns {void}
3772
+ */
3773
+ function cancelEditing() {
3774
+ setEditor(null);
3775
+ }
3776
+
3777
+ /**
3778
+ * Save the draft. If the file changed on disk since it was opened, ask
3779
+ * before overwriting it.
3780
+ * @param {boolean} overwrite - skip the out-of-date check
3781
+ * @returns {void}
3782
+ */
3783
+ function saveEditing(overwrite) {
3784
+ if (!editor) return;
3785
+ var current = editor;
3786
+ var run = function () {
3787
+ apiWrite(current.entry.path, current.text).then(function (result) {
3788
+ if (!result.ok) { notify(t((result.body && result.body.message) || "保存失败"), "error"); return; }
3789
+ notify(t("已保存"), "info");
3790
+ setEditor(null);
3791
+ openPreview(current.entry);
3792
+ var listingNow = listingRef.current;
3793
+ if (listingNow) load(listingNow.path, current.entry.path, "neutral");
3794
+ }, function () { notify(t("保存失败"), "error"); });
3795
+ };
3796
+ if (overwrite) { run(); return; }
3797
+ apiGet("/stat", { path: current.entry.path }).then(function (result) {
3798
+ var info = result.body || {};
3799
+ if (result.ok && (info.mtime !== current.mtime || info.size !== current.size)) {
3800
+ setDialog({
3801
+ kind: "confirm",
3802
+ title: t("文件已被修改"),
3803
+ message: t("这个文件在打开之后被外部修改了。仍要用当前内容覆盖吗?"),
3804
+ confirmLabel: t("覆盖保存"),
3805
+ onSubmit: function () { saveEditing(true); },
3806
+ });
3807
+ return;
3808
+ }
3809
+ run();
3810
+ }, run);
3811
+ }
3812
+
3813
+ /** The editor pane: textarea plus dirty marker and save controls. */
3814
+ function editorPane() {
3815
+ if (!editor) return null;
3816
+ var dirty = editor.text !== (preview && preview.body && preview.body.text !== undefined ? preview.body.text : editor.text);
3817
+ return h("div", { className: "dfx-editor" },
3818
+ h("textarea", {
3819
+ value: editor.text,
3820
+ spellCheck: false,
3821
+ onKeyDown: function (event) {
3822
+ if ((event.metaKey || event.ctrlKey) && (event.key === "s" || event.key === "S")) {
3823
+ event.preventDefault();
3824
+ event.stopPropagation();
3825
+ saveEditing(false);
3826
+ }
3827
+ },
3828
+ onChange: function (event) {
3829
+ var next = event.target.value;
3830
+ setEditor(function (previous) { return previous ? { entry: previous.entry, text: next, mtime: previous.mtime, size: previous.size } : previous; });
3831
+ },
3832
+ }),
3833
+ h("div", { className: "dfx-editor-bar" },
3834
+ dirty ? h("span", { className: "dfx-dirty" }) : null,
3835
+ h("span", { className: "dfx-editor-state" }, dirty ? t("未保存") : t("已保存")),
3836
+ h("span", { className: "dfx-meta-sep" }),
3837
+ h("span", { className: "dfx-editor-stat" }, tf("{n} 行", { n: String(lineCountOf(editor.text)) })),
3838
+ h("span", { className: "dfx-kbd" }, IS_MAC ? "⌘S" : "Ctrl+S"),
3839
+ h("span", { style: { flex: "1 1 auto" } }),
3840
+ h("button", { type: "button", className: "dfx-pill", onClick: cancelEditing }, t("取消")),
3841
+ h("button", { type: "button", className: "dfx-pill dfx-pill--primary", onClick: function () { saveEditing(false); } }, t("保存"))));
3842
+ }
3843
+
3844
+ /** Header shared by both right-hand panes, with the preview/details switch. */
3845
+ var paneHeader = function (entry) {
3846
+ var modeButton = function (id, label, disabled) {
3847
+ return h("button", {
3848
+ key: id,
3849
+ type: "button",
3850
+ "aria-pressed": paneMode === id ? "true" : "false",
3851
+ disabled: !!disabled,
3852
+ onClick: function () {
3853
+ if (!entry || disabled) return;
3854
+ if (id === "info") { openInfo(entry); return; }
3855
+ setPaneMode("preview");
3856
+ openPreview(entry);
3857
+ },
3858
+ }, label);
3859
+ };
3860
+ return h("div", { className: "dfx-preview-head" },
3861
+ h("span", { className: "dfx-name-icon" }, glyph(entry ? entryShape(entry) : "file", 16)),
3862
+ h("span", { className: "dfx-preview-title" }, entry ? entry.name : t("详情")),
3863
+ h("div", { className: "dfx-panemode", role: "group", "aria-label": t("右侧面板") },
3864
+ modeButton("preview", t("预览"), !!entry && entry.dir),
3865
+ modeButton("info", t("详情"), !entry)));
3866
+ };
3867
+
3868
+ /** Definition list rendered by the details pane. */
3869
+ var infoRows = function (data) {
3870
+ var rows = [
3871
+ [t("名称"), data.name],
3872
+ [t("类型"), kindLabel({ dir: data.dir, kind: data.kind })],
3873
+ [t("大小"), data.dir ? (data.items === null ? "—" : tf("{n} 项", { n: data.items })) : formatSize(data.size)],
3874
+ [t("位置"), data.parent],
3875
+ [t("创建时间"), formatDate(data.birthtime)],
3876
+ [t("修改时间"), formatDate(data.mtime)],
3877
+ [t("权限"), data.mode + " · " + data.modeOctal],
3878
+ ];
3879
+ if (data.link) rows.push([t("符号链接"), t("是")]);
3880
+ return h("div", { className: "dfx-info" }, rows.map(function (row) {
3881
+ return h("div", { key: row[0], className: "dfx-info-row" },
3882
+ h("span", { className: "dfx-info-label" }, row[0]),
3883
+ h("span", { className: "dfx-info-value" }, row[1]));
3884
+ }));
3885
+ };
3886
+
3887
+ /** Copy-path and reveal actions, identical in both panes. */
3888
+ var paneFooter = function (entry) {
3889
+ if (!entry) return null;
3890
+ return h("div", { className: "dfx-preview-foot" },
3891
+ h("button", { type: "button", className: "dfx-pill", onClick: function () { copyText(entry.path, t("已复制路径")); } },
3892
+ glyph("copy", 12), t("复制路径")),
3893
+ remoteMode ? null : h("button", { type: "button", className: "dfx-pill", onClick: function () { revealPath(entry.path); } },
3894
+ glyph("reveal", 12), t("在访达中显示")));
3895
+ };
3896
+
3897
+ var selectionEntriesNow = selectionEntries();
3898
+ var selectionCount = selectionEntriesNow.length;
3899
+ var hasSelection = selectionCount > 0;
3900
+ var selectionBytes = selectionEntriesNow.reduce(function (total, entry) {
3901
+ return entry.dir ? total : total + (entry.size || 0);
3902
+ }, 0);
3903
+ var sortName = sort === "size" ? t("大小") : sort === "mtime" ? t("修改时间") : t("名称");
3904
+
3905
+ var showInfoPane = paneVisible && !!selected && (selected.dir || paneMode === "info");
3906
+ var previewPane = null;
3907
+ if (!paneVisible) {
3908
+ previewPane = null;
3909
+ } else if (showInfoPane) {
3910
+ var infoInner = null;
3911
+ if (detailsStatus === "loading") {
3912
+ infoInner = h("div", { className: "dfx-empty" }, t("正在读取详情…"));
3913
+ } else if (details && details.error) {
3914
+ infoInner = h("div", { className: "dfx-notice dfx-notice--error" }, tf("无法读取详情:{reason}", { reason: details.error }));
3915
+ } else if (details && details.body) {
3916
+ infoInner = infoRows(details.body);
3917
+ }
3918
+ previewPane = h("div", { className: "dfx-preview" },
3919
+ paneHeader(selected),
3920
+ h("div", { className: "dfx-preview-body" }, infoInner),
3921
+ paneFooter(selected));
3922
+ } else if (preview || previewStatus === "loading") {
3923
+ var meta = null;
3924
+ var inner = null;
3925
+ if (previewStatus === "loading") {
3926
+ inner = h("div", { className: "dfx-empty" }, t("正在打开…"));
3927
+ } else if (previewStatus === "error" || (preview && preview.error)) {
3928
+ inner = h("div", { className: "dfx-notice dfx-notice--error" }, tf("无法预览:{reason}", { reason: preview && preview.error ? preview.error : t("未知错误") }));
3929
+ } else if (preview && preview.body) {
3930
+ var payload = preview.body;
3931
+ var rawUrl = API + "/raw?path=" + encodeURIComponent(preview.entry.path);
3932
+ var renderAs = preview.kind || payload.kind;
3933
+ // Binary files also land in the "text" fallback; never let the editor
3934
+ // write them back, it would corrupt the bytes it cannot round-trip.
3935
+ var BINARY_NAME = /\.(zip|gz|tgz|tar|bz2|xz|7z|rar|dmg|pkg|exe|bin|iso|class|jar|woff2?|ttf|otf|eot|ico|icns|mp[34]|m4a|wav|flac|ogg|mov|avi|mkv|psd|ai|sketch|sqlite|db)$/i;
3936
+ var canEdit = (renderAs === "text" || renderAs === "markdown" || renderAs === "csv") && !BINARY_NAME.test(preview.entry.name);
3937
+ var textKind = renderAs === "text" || renderAs === "markdown" || renderAs === "csv";
3938
+ var lineCount = textKind ? lineCountOf(payload.text) : 0;
3939
+ var metaFacts = [{ text: formatSize(payload.size) }];
3940
+ if (lineCount) metaFacts.push({ text: tf("{n} 行", { n: String(lineCount) }) });
3941
+ metaFacts.push({ text: formatDate(payload.mtime) });
3942
+ if (payload.mime) metaFacts.push({ text: payload.mime, mime: true });
3943
+ meta = h("div", { className: "dfx-preview-meta" },
3944
+ metaFacts.map(function (fact, index) {
3945
+ return [
3946
+ index ? h("span", { key: "sep" + index, className: "dfx-meta-sep" }) : null,
3947
+ h("span", {
3948
+ key: "fact" + index,
3949
+ className: "dfx-meta-item" + (fact.mime ? " dfx-meta-item--mime" : ""),
3950
+ title: fact.mime ? fact.text : undefined,
3951
+ }, fact.text),
3952
+ ];
3953
+ }),
3954
+ canEdit && !(editor && editor.entry.path === preview.entry.path)
3955
+ ? h("button", {
3956
+ type: "button",
3957
+ className: "dfx-pill",
3958
+ title: IS_MAC ? "⌘E" : "Ctrl+E",
3959
+ onClick: function () { startEditing(preview.entry, payload); },
3960
+ }, glyph("pencil", 12), t("编辑"))
3961
+ : null);
3962
+ if (canEdit && editor && editor.entry.path === preview.entry.path) {
3963
+ inner = editorPane();
3964
+ } else if (renderAs === "text") {
3965
+ inner = h("pre", { className: "dfx-pre" }, payload.text);
3966
+ } else if (renderAs === "markdown") {
3967
+ inner = h("div", { className: "dfx-md" }, renderMarkdown(payload.text, h));
3968
+ } else if (renderAs === "csv") {
3969
+ var tableRows = parseDelimited(payload.text, preview.entry.name.slice(-4).toLowerCase() === ".tsv" ? "\t" : ",");
3970
+ inner = tableRows.length === 0
3971
+ ? h("div", { className: "dfx-empty" }, t("此目录为空"))
3972
+ : h("div", { className: "dfx-tablewrap" }, h("table", { className: "dfx-table" },
3973
+ h("tbody", null, tableRows.map(function (cells, rowIndex) {
3974
+ return h("tr", { key: "row" + rowIndex }, cells.map(function (cell, cellIndex) {
3975
+ return rowIndex === 0
3976
+ ? h("th", { key: "c" + cellIndex }, cell)
3977
+ : h("td", { key: "c" + cellIndex }, cell);
3978
+ }));
3979
+ }))));
3980
+ } else if (renderAs === "doc") {
3981
+ var document = preview.doc || { blocks: [] };
3982
+ inner = h("div", { className: "dfx-doc" },
3983
+ document.blocks.map(function (block, index) {
3984
+ if (block.type === "table") {
3985
+ return h("div", { key: "doc" + index, className: "dfx-tablewrap" },
3986
+ h("table", { className: "dfx-table" },
3987
+ h("tbody", null, (block.rows || []).map(function (cells, rowIndex) {
3988
+ return h("tr", { key: "drow" + rowIndex }, (cells || []).map(function (cell, cellIndex) {
3989
+ return rowIndex === 0
3990
+ ? h("th", { key: "dc" + cellIndex }, cell)
3991
+ : h("td", { key: "dc" + cellIndex }, cell);
3992
+ }));
3993
+ }))));
3994
+ }
3995
+ if (block.type === "li") {
3996
+ return h("div", { key: "doc" + index, className: "dfx-doc-li" }, block.text);
3997
+ }
3998
+ if (block.type === "h1" || block.type === "h2" || block.type === "h3" || block.type === "h4") {
3999
+ var level = block.type.charAt(1);
4000
+ return h("div", { key: "doc" + index, className: "dfx-doc-h dfx-doc-h" + level }, block.text);
4001
+ }
4002
+ return h("p", { key: "doc" + index, className: "dfx-doc-p" }, block.text);
4003
+ }),
4004
+ document.truncated ? h("div", { className: "dfx-preview-hint" }, tf("仅显示前 {n} 段", { n: document.maxBlocks })) : null);
4005
+ } else if (renderAs === "sheet") {
4006
+ var book = preview.sheet || { sheets: [] };
4007
+ var sheet = book.sheets[activeSheet] || book.sheets[0] || { name: "", rows: [] };
4008
+ inner = h("div", { className: "dfx-sheet" },
4009
+ book.sheets.length > 1
4010
+ ? h("div", { className: "dfx-sheet-tabs" }, book.sheets.map(function (item, index) {
4011
+ return h("button", {
4012
+ key: "sheet" + index,
4013
+ type: "button",
4014
+ className: "dfx-sheet-tab" + (index === activeSheet ? " dfx-sheet-tab--active" : ""),
4015
+ "aria-pressed": index === activeSheet ? "true" : "false",
4016
+ onClick: function () { setActiveSheet(index); },
4017
+ }, item.name);
4018
+ }))
4019
+ : null,
4020
+ h("div", { className: "dfx-tablewrap" },
4021
+ h("table", { className: "dfx-table" },
4022
+ h("tbody", null, sheet.rows.map(function (cells, rowIndex) {
4023
+ return h("tr", { key: "srow" + rowIndex }, cells.map(function (cell, cellIndex) {
4024
+ return rowIndex === 0
4025
+ ? h("th", { key: "sc" + cellIndex }, cell)
4026
+ : h("td", { key: "sc" + cellIndex }, cell);
4027
+ }));
4028
+ })))),
4029
+ book.truncated ? h("div", { className: "dfx-preview-hint" }, tf("仅显示前 {n} 行", { n: book.maxRows })) : null);
4030
+ } else if (renderAs === "image") {
4031
+ inner = h("img", { className: "dfx-image", src: rawUrl, alt: preview.entry.name });
4032
+ } else if (renderAs === "pdf") {
4033
+ inner = h("div", { className: "dfx-embed" },
4034
+ h("embed", { type: "application/pdf", src: rawUrl }),
4035
+ h("a", { className: "dfx-embed-link", href: rawUrl, target: "_blank", rel: "noreferrer noopener" }, t("在新窗口打开")));
4036
+ } else if (renderAs === "audio") {
4037
+ inner = h("audio", { className: "dfx-media", controls: true, src: rawUrl }, null);
4038
+ } else if (renderAs === "video") {
4039
+ inner = h("video", { className: "dfx-media", controls: true, src: rawUrl }, null);
4040
+ } else if (renderAs === "html") {
4041
+ inner = h("iframe", { className: "dfx-html", src: rawUrl, sandbox: "", title: preview.entry.name });
4042
+ } else if (payload.kind === "too-large") {
4043
+ inner = h("div", { className: "dfx-empty" }, t("文件过大,未生成预览"));
4044
+ } else {
4045
+ inner = h("div", { className: "dfx-empty" }, t("此格式不支持内嵌预览"));
4046
+ }
4047
+ }
4048
+ var paneEntry = preview && preview.entry ? preview.entry : selected;
4049
+ previewPane = h("div", { className: "dfx-preview" },
4050
+ paneHeader(paneEntry),
4051
+ meta,
4052
+ h("div", { className: "dfx-preview-body" }, inner),
4053
+ paneFooter(paneEntry));
4054
+ }
4055
+
4056
+ var menuNode = null;
4057
+ if (menu) {
4058
+ var estimated = 12;
4059
+ menuItems.filter(Boolean).forEach(function (item) { estimated += item.separator ? 9 : 30; });
4060
+ var viewportWidth = (typeof window !== "undefined" && window.innerWidth) || 1280;
4061
+ var viewportHeight = (typeof window !== "undefined" && window.innerHeight) || 800;
4062
+ var left = Math.max(8, Math.min(menu.x, viewportWidth - 238));
4063
+ var top = Math.max(8, Math.min(menu.y, viewportHeight - estimated - 8));
4064
+ menuNode = h("div", {
4065
+ className: "dfx-menu",
4066
+ role: "menu",
4067
+ style: { left: left + "px", top: top + "px" },
4068
+ onMouseDown: function (event) { event.stopPropagation(); },
4069
+ onContextMenu: function (event) { event.preventDefault(); },
4070
+ }, menuItems.filter(Boolean).map(function (item, index) {
4071
+ if (item.separator) return h("div", { key: "sep-" + index, className: "dfx-menu-sep" });
4072
+ return h("button", {
4073
+ key: item.id,
4074
+ type: "button",
4075
+ role: "menuitem",
4076
+ className: "dfx-menu-item" + (item.danger ? " dfx-menu-item--danger" : ""),
4077
+ disabled: !!item.disabled,
4078
+ onClick: function () { menuAction(item.id); },
4079
+ },
4080
+ h("span", { className: "dfx-menu-icon" }, glyph(item.icon, 14)),
4081
+ h("span", { className: "dfx-menu-label" }, item.label),
4082
+ item.hint ? h("span", { className: "dfx-menu-hint" }, item.hint) : null);
4083
+ }));
4084
+ }
4085
+
4086
+ var popupNode = null;
4087
+ if (popup && popupItems.length > 0) {
4088
+ var popupHeight = 12;
4089
+ popupItems.forEach(function (item) { popupHeight += item.separator ? 9 : 30; });
4090
+ var popupWidth = (typeof window !== "undefined" && window.innerWidth) || 1280;
4091
+ var popupViewHeight = (typeof window !== "undefined" && window.innerHeight) || 800;
4092
+ var popupLeft = Math.max(8, Math.min(popup.x, popupWidth - 230));
4093
+ var popupTop = Math.max(8, Math.min(popup.y, popupViewHeight - popupHeight - 8));
4094
+ popupNode = h("div", {
4095
+ className: "dfx-menu dfx-popup",
4096
+ role: "menu",
4097
+ style: { left: popupLeft + "px", top: popupTop + "px" },
4098
+ onMouseDown: function (event) { event.stopPropagation(); },
4099
+ onContextMenu: function (event) { event.preventDefault(); },
4100
+ }, popupItems.map(function (item, index) {
4101
+ if (item.separator) return h("div", { key: "psep-" + index, className: "dfx-menu-sep" });
4102
+ return h("button", {
4103
+ key: item.id,
4104
+ type: "button",
4105
+ role: "menuitem",
4106
+ className: "dfx-menu-item",
4107
+ disabled: !!item.disabled,
4108
+ onClick: function () { popupAction(item.id); },
4109
+ },
4110
+ h("span", { className: "dfx-menu-icon" }, item.checked ? glyph("check", 13) : item.icon ? glyph(item.icon, 14) : null),
4111
+ h("span", { className: "dfx-menu-label" }, item.label),
4112
+ item.hint ? h("span", { className: "dfx-menu-hint" }, item.hint) : null);
4113
+ }));
4114
+ }
4115
+
4116
+ var dialogNode = null;
4117
+ if (dialog) {
4118
+ var close = function () { setDialog(null); };
4119
+ if (dialog.kind === "about") {
4120
+ dialogNode = h(AboutDialog, { meta: about, onClose: close });
4121
+ } else if (dialog.kind === "options") {
4122
+ dialogNode = h(OptionsDialog, {
4123
+ showHidden: showHidden,
4124
+ view: view,
4125
+ groupStyle: groupStyle,
4126
+ onGroupStyle: setGroupStyle,
4127
+ paneVisible: paneVisible,
4128
+ paneMode: paneMode,
4129
+ anim: anim,
4130
+ langPref: langPref,
4131
+ onHidden: function (next) { setShowHidden(next); },
4132
+ onLang: function (next) {
4133
+ setLangPref(next);
4134
+ langRef.current = next;
4135
+ currentLang = resolveLang(next);
4136
+ storedLang = next;
4137
+ storeLang(next);
4138
+ },
4139
+ onView: function (next) { changeView(next); },
4140
+ onPane: function (next) {
4141
+ if (next === "hidden") { setPaneBoth(false, paneMode); return; }
4142
+ setPaneBoth(true, next);
4143
+ if (!selected) return;
4144
+ if (next === "preview" && !selected.dir) openPreview(selected);
4145
+ if (next === "info") openDetails(selected);
4146
+ },
4147
+ onAnim: function (next) { setAnim(next); },
4148
+ onClose: close,
4149
+ });
4150
+ } else if (dialog.kind === "confirm") {
4151
+ dialogNode = h(ConfirmDialog, {
4152
+ title: dialog.title,
4153
+ message: dialog.message,
4154
+ confirmLabel: dialog.confirmLabel,
4155
+ danger: !!dialog.danger,
4156
+ busy: busy,
4157
+ onCancel: close,
4158
+ onConfirm: function () { var run = dialog.onConfirm; setDialog(null); run(); },
4159
+ });
4160
+ } else {
4161
+ dialogNode = h(PromptDialog, {
4162
+ title: dialog.title,
4163
+ label: dialog.label,
4164
+ value: dialog.value,
4165
+ confirmLabel: dialog.confirmLabel,
4166
+ busy: busy,
4167
+ onCancel: close,
4168
+ onSubmit: function (value) { var run = dialog.onSubmit; setDialog(null); run(value); },
4169
+ });
4170
+ }
4171
+ }
4172
+
4173
+ var dropStrip = dragEntries && dragEntries.length > 0
4174
+ ? h("div", {
4175
+ className: "dfx-dropzone" + (dropHot ? " dfx-dropzone--hot" : ""),
4176
+ role: "presentation",
4177
+ onDragOver: function (event) {
4178
+ if (!event || !event.dataTransfer) return;
4179
+ event.preventDefault();
4180
+ event.stopPropagation();
4181
+ event.dataTransfer.dropEffect = "copy";
4182
+ setDropHot(true);
4183
+ },
4184
+ onDragLeave: function (event) {
4185
+ if (event && event.stopPropagation) event.stopPropagation();
4186
+ setDropHot(false);
4187
+ },
4188
+ onDrop: function (event) {
4189
+ if (!event) return;
4190
+ event.preventDefault();
4191
+ event.stopPropagation();
4192
+ var list = dragEntries;
4193
+ endDrag();
4194
+ sendToSession(list);
4195
+ },
4196
+ },
4197
+ h("span", { className: "dfx-dropzone-icon" }, glyph("clip", 16)),
4198
+ h("span", { className: "dfx-dropzone-text" }, tf("松手加入当前会话({n} 项)", { n: String(dragEntries.length) })),
4199
+ h("span", { className: "dfx-dropzone-hint" }, t("文件作为附件,文件夹作为引用")))
4200
+ : null;
4201
+
4202
+ return h("div", { className: "dfx-root", ref: rootRef, onDragEnd: endDrag },
4203
+ h("div", { className: "dfx-bar" },
4204
+ h("div", { className: "dfx-bar-actions" },
4205
+ h("button", {
4206
+ type: "button", className: "dfx-navbtn dfx-tip", title: t("上一级 (Backspace)"), "data-tip": t("上一级"),
4207
+ disabled: !listing || !listing.parent,
4208
+ onClick: function () { if (listing && listing.parent) load(listing.parent, undefined, "out"); },
4209
+ }, glyph("up", 16)),
4210
+ h("button", {
4211
+ type: "button", className: "dfx-navbtn dfx-tip", title: t("主目录"), "data-tip": t("主目录"),
4212
+ onClick: function () { load(null, undefined, "out"); },
4213
+ }, glyph("home", 16)),
4214
+ h("button", {
4215
+ type: "button", className: "dfx-navbtn dfx-tip", title: t("刷新"), "data-tip": t("刷新"),
4216
+ onClick: function () { load(listing ? listing.path : null, undefined, "neutral"); },
4217
+ }, h("span", { className: status === "loading" ? "dfx-spin" : undefined }, glyph("refresh", 16)))),
4218
+ h("div", {
4219
+ className: "dfx-crumbs" + (addressDraft === null ? "" : " dfx-crumbs--edit"),
4220
+ title: addressDraft === null ? (listing ? listing.path + t("(双击输入路径)") : "") : "",
4221
+ onDoubleClick: function () { startAddressEdit(); },
4222
+ }, addressDraft === null
4223
+ ? crumbs.map(function (crumb, index) {
4224
+ var last = index === crumbs.length - 1;
4225
+ return h(Fragment, { key: crumb.path },
4226
+ index > 0 ? h("span", { className: "dfx-sep" }, glyph("chevron", 11)) : null,
4227
+ h("button", {
4228
+ type: "button",
4229
+ className: "dfx-crumb" + (last ? " dfx-crumb--last" : ""),
4230
+ title: crumb.path,
4231
+ onClick: function () { if (!last) load(crumb.path, undefined, listing && crumb.path.length < listing.path.length ? "out" : "in"); },
4232
+ }, crumb.label));
4233
+ })
4234
+ : h("input", {
4235
+ ref: addressRef,
4236
+ className: "dfx-address",
4237
+ value: addressDraft,
4238
+ spellCheck: false,
4239
+ autoComplete: "off",
4240
+ "aria-label": t("路径"),
4241
+ onChange: function (event) { setAddressDraft(event.target.value); },
4242
+ onKeyDown: function (event) {
4243
+ event.stopPropagation();
4244
+ if (event.key === "Enter") {
4245
+ event.preventDefault();
4246
+ commitAddress(addressDraft);
4247
+ } else if (event.key === "Escape") {
4248
+ event.preventDefault();
4249
+ setAddressDraft(null);
4250
+ }
4251
+ },
4252
+ onBlur: function () { setAddressDraft(null); },
4253
+ })),
4254
+ h("label", { className: "dfx-search" },
4255
+ glyph("search", 13),
4256
+ h("input", {
4257
+ ref: searchRef,
4258
+ type: "search",
4259
+ value: query,
4260
+ placeholder: t("筛选当前目录"),
4261
+ onChange: function (event) { setQuery(event.target.value); },
4262
+ }))),
4263
+ h("div", { className: "dfx-toolbar", role: "toolbar", "aria-label": t("文件操作") },
4264
+ workspacesRef.current
4265
+ ? h("button", {
4266
+ type: "button",
4267
+ className: "dfx-tool dfx-tool--ws" + (popup && popup.kind === "workspace" ? " dfx-tool--open" : ""),
4268
+ title: currentWorkspace() ? tf("工作区:{name}", { name: (currentWorkspace() || {}).title || "" }) : t("工作区"),
4269
+ "aria-label": t("切换工作区"),
4270
+ "data-tip": t("切换工作区"),
4271
+ onClick: function (event) { event.stopPropagation(); openWorkspacePopup(event); },
4272
+ },
4273
+ glyph("briefcase", 14),
4274
+ h("span", { className: "dfx-tool-label dfx-ws-label" }, (currentWorkspace() && ((currentWorkspace() || {}).title || (currentWorkspace() || {}).path)) || t("工作区")),
4275
+ glyph("chevronDown", 12))
4276
+ : null,
4277
+ h("button", {
4278
+ type: "button",
4279
+ className: "dfx-tool" + (popup && popup.kind === "new" ? " dfx-tool--open" : ""),
4280
+ title: t("新建文件夹或文件"),
4281
+ disabled: !listing,
4282
+ onClick: function (event) { openPopup("new", event); },
4283
+ }, glyph("plus", 14), h("span", { className: "dfx-tool-label" }, t("新建")), glyph("chevronDown", 12)),
4284
+ h("input", {
4285
+ ref: uploadInputRef,
4286
+ type: "file",
4287
+ multiple: true,
4288
+ hidden: true,
4289
+ onChange: function (event) {
4290
+ // clearing the input empties its FileList, so snapshot it first
4291
+ var files = Array.prototype.slice.call(event.target.files || []);
4292
+ event.target.value = "";
4293
+ uploadFiles(files);
4294
+ },
4295
+ }),
4296
+ h("input", {
4297
+ ref: folderInputRef,
4298
+ type: "file",
4299
+ multiple: true,
4300
+ hidden: true,
4301
+ webkitdirectory: "",
4302
+ directory: "",
4303
+ onChange: function (event) {
4304
+ var files = Array.prototype.slice.call(event.target.files || []);
4305
+ event.target.value = "";
4306
+ uploadFiles(files);
4307
+ },
4308
+ }),
4309
+ h("span", { className: "dfx-toolbar-sep" }),
4310
+ [
4311
+ ["cut", t("剪切"), "scissors", !hasSelection, null],
4312
+ ["copy", t("复制"), "copy", !hasSelection, null],
4313
+ ["paste", t("粘贴"), "paste", !clipboard, null],
4314
+ null,
4315
+ ["rename", t("重命名"), "pencil", selectionCount !== 1, null],
4316
+ remoteMode ? null : ["trash", t("删除"), "trash", !hasSelection, null],
4317
+ null,
4318
+ ].map(function (item, index) {
4319
+ if (!item) return h("span", { key: "sep-" + index, className: "dfx-toolbar-sep" });
4320
+ return h("button", {
4321
+ key: item[0],
4322
+ type: "button",
4323
+ className: "dfx-tool",
4324
+ disabled: item[3],
4325
+ title: item[1],
4326
+ onClick: function () { toolAction(item[0]); },
4327
+ }, glyph(item[2], 14), h("span", { className: "dfx-tool-label" }, item[1]));
4328
+ }),
4329
+ h("button", {
4330
+ type: "button",
4331
+ className: "dfx-tool" + (showHidden ? " dfx-tool--open" : ""),
4332
+ title: showHidden ? t("隐藏以点开头的条目") : t("显示以点开头的条目"),
4333
+ "aria-pressed": showHidden ? "true" : "false",
4334
+ onClick: function () { setShowHidden(!showHidden); },
4335
+ }, glyph(showHidden ? "eye" : "hidden", 14), h("span", { className: "dfx-tool-label" }, t("隐藏文件"))),
4336
+ h("span", { className: "dfx-toolbar-sep" }),
4337
+ h("button", {
4338
+ type: "button",
4339
+ className: "dfx-tool" + (popup && popup.kind === "sort" ? " dfx-tool--open" : ""),
4340
+ title: t("排序方式"),
4341
+ onClick: function (event) { openPopup("sort", event); },
4342
+ }, glyph("sortIcon", 14), h("span", { className: "dfx-tool-label" }, t("排序")), glyph("chevronDown", 12)),
4343
+ h("button", {
4344
+ type: "button",
4345
+ className: "dfx-tool" + (popup && popup.kind === "more" ? " dfx-tool--open" : ""),
4346
+ title: t("更多操作"),
4347
+ onClick: function (event) { openPopup("more", event); },
4348
+ }, glyph("moreIcon", 14), h("span", { className: "dfx-tool-label" }, t("更多")), glyph("chevronDown", 12)),
4349
+ h("div", { className: "dfx-viewswitch", role: "group", "aria-label": t("显示视图") },
4350
+ VIEW_OPTIONS.map(function (option) {
4351
+ var active = view === option.id;
4352
+ return h("button", {
4353
+ key: option.id,
4354
+ type: "button",
4355
+ className: "dfx-navbtn dfx-tip" + (active ? " dfx-navbtn--active" : ""),
4356
+ title: t(option.label) + "(" + accel(String(VIEW_MODES.indexOf(option.id) + 1)) + ")",
4357
+ "data-tip": t(option.label) + "(" + accel(String(VIEW_MODES.indexOf(option.id) + 1)) + ")",
4358
+ "aria-label": t(option.label) + t("视图"),
4359
+ "aria-pressed": active ? "true" : "false",
4360
+ onClick: function () { changeView(option.id); },
4361
+ }, glyph(option.icon, 16));
4362
+ }),
4363
+ h("button", {
4364
+ type: "button",
4365
+ className: "dfx-navbtn dfx-panebtn dfx-tip dfx-tip--right" + (paneVisible ? " dfx-navbtn--active" : ""),
4366
+ title: paneVisible ? t("隐藏右侧预览") : t("显示右侧预览"),
4367
+ "data-tip": paneVisible ? t("隐藏右侧预览") : t("显示右侧预览"),
4368
+ "aria-label": t("预览面板"),
4369
+ "aria-pressed": paneVisible ? "true" : "false",
4370
+ onClick: function () { setPaneVisible(!paneVisible); },
4371
+ }, glyph("pane", 16)))),
4372
+ h("div", { className: "dfx-body" },
4373
+ h("div", { className: "dfx-listpane" + (resizing ? " dfx-listpane--resizing" : ""), style: columnStyle },
4374
+ view === "icons" || view === "grouped" ? null : h("div", {
4375
+ key: "head-" + navMotion.seq,
4376
+ className: "dfx-head" + motionClass("dfx-head"),
4377
+ },
4378
+ headCell("name", t("名称")),
4379
+ h("span", { className: "dfx-headcell dfx-headcell--static" }, t("类型"), colResizer("type")),
4380
+ headCell("size", t("大小")),
4381
+ headCell("mtime", t("修改时间"))),
4382
+
4383
+ upload
4384
+ ? h("div", { className: "dfx-upload" },
4385
+ glyph("upload", 12),
4386
+ h("span", null, upload.name),
4387
+ h("div", { className: "dfx-upload-bar" },
4388
+ h("div", {
4389
+ className: "dfx-upload-fill",
4390
+ style: { width: (upload.total > 0 ? Math.round((upload.loaded / upload.total) * 100) : 0) + "%" },
4391
+ })),
4392
+ h("span", null, upload.total > 0 ? Math.round((upload.loaded / upload.total) * 100) + "%" : ""))
4393
+ : null,
4394
+ h("div", {
4395
+ key: "rows-" + navMotion.seq,
4396
+ className: "dfx-rows" + (view === "icons" ? " dfx-rows--grid" : "") + motionClass("dfx-rows"),
4397
+ ref: rowsRef,
4398
+ tabIndex: 0,
4399
+ onKeyDown: onKeyDown,
4400
+ onContextMenu: openAreaMenu,
4401
+ onScroll: function () { if (menu) setMenu(null); },
4402
+ }, body)),
4403
+ previewPane),
4404
+ dropStrip,
4405
+ h("div", { className: "dfx-foot" },
4406
+ h("span", null, tf("{n} 项", { n: rows.length })),
4407
+ listing && listing.truncated ? h(Fragment, null,
4408
+ h("span", { className: "dfx-foot-dot" }),
4409
+ h("span", null, t("已截断,仅列出前 2000 项"))) : null,
4410
+ selectionCount > 0 ? h(Fragment, null,
4411
+ h("span", { className: "dfx-foot-dot" }),
4412
+ h("span", { className: "dfx-foot-strong" }, tf("已选 {n} 项", { n: selectionCount }))) : null,
4413
+ selectionBytes > 0 ? h(Fragment, null,
4414
+ h("span", { className: "dfx-foot-dot" }),
4415
+ h("span", null, formatSize(selectionBytes))) : null,
4416
+ clipboard ? h(Fragment, null,
4417
+ h("span", { className: "dfx-foot-dot" }),
4418
+ h("span", null, tf(clipboard.mode === "cut" ? "已剪切 {n} 项" : "已拷贝 {n} 项", { n: clipboard.paths.length }))) : null,
4419
+ h("span", { style: { flex: "1 1 auto" } }),
4420
+ remoteMode ? h("span", { className: "dfx-foot-remote", title: t("这些操作会作用在运行 DSH 的那台机器上,已隐藏") },
4421
+ glyph("shield", 11), t("远程访问 · 本机操作已隐藏")) : null,
4422
+ busy ? h("span", null, t("处理中…")) : null,
4423
+ notice ? h("span", { className: notice.tone === "error" ? "dfx-foot-error" : undefined }, notice.text) : null,
4424
+ showHidden ? h(Fragment, null,
4425
+ h("span", { className: "dfx-foot-dot" }),
4426
+ h("span", null, t("显示隐藏文件")),
4427
+ h("span", { className: "dfx-foot-dot" })) : null,
4428
+ h("span", { className: "dfx-foot-meta" },
4429
+ tf("{view} · 按{sort}排序", { view: view === "icons" ? t("图标视图") : t("列表视图"), sort: sortName }))),
4430
+ menuNode,
4431
+ popupNode,
4432
+ dialogNode);
4433
+ }
4434
+
4435
+ /**
4436
+ * Register the sidebar entry and the panel it opens.
4437
+ * @param {object} ctx - client plugin context
4438
+ */
4439
+ function apply(ctx) {
4440
+ if (storedAnim === null) storedAnim = readStoredAnim();
4441
+ if (storedLang === null) {
4442
+ storedLang = readStoredLang();
4443
+ currentLang = resolveLang(storedLang);
4444
+ }
4445
+ workspacesRef.current = (ctx && ctx.workspaces) || null;
4446
+ layoutRef.current = (ctx && ctx.layout) || null;
4447
+
4448
+ ctx.effect(function () {
4449
+ var style = document.createElement("style");
4450
+ style.id = STYLE_ID;
4451
+ style.textContent = CSS;
4452
+ document.head.appendChild(style);
4453
+ return function () { style.remove(); };
4454
+ }, "dsh-file-explorer: styles");
4455
+
4456
+ ctx.slots.inject("main", function () {
4457
+ return ctx.slots.register({ name: "main", key: PANEL_ID }, FileExplorerPanel);
4458
+ });
4459
+
4460
+ ctx.slots.inject("sidebar.panellist", function () {
4461
+ return ctx.slots.register({
4462
+ name: "sidebar.panellist",
4463
+ id: PANEL_ID,
4464
+ order: 20,
4465
+ label: t("文件管理器"),
4466
+ }, PanelIcon);
4467
+ });
4468
+ }
4469
+
4470
+ exports.SHAPES = SHAPES;
4471
+ exports.entryShape = entryShape;
4472
+ exports.kindLabel = kindLabel;
4473
+ exports.PANEL_ID = PANEL_ID;
4474
+ /** Test seam: hand the panel a workspace service without a live DSH context. */
4475
+ exports.__setWorkspaceService = function (service) { workspacesRef.current = service || null; };
4476
+ /** Test seam: hand the panel a layout service (panel switching) without DSH. */
4477
+ exports.__setLayoutService = function (service) { layoutRef.current = service || null; };
4478
+ exports.FileExplorerPanel = FileExplorerPanel;
4479
+ /** Test seam: render the settings window on its own. */
4480
+ exports.__OptionsDialog = OptionsDialog;
4481
+ /** Test seam: insert composer text without a live conversation. */
4482
+ exports.__insertComposerText = insertComposerText;
4483
+ /** Test seams for the preview renderers. */
4484
+ exports.__previewKindOf = previewKindOf;
4485
+ exports.__renderMarkdown = renderMarkdown;
4486
+ exports.__parseDelimited = parseDelimited;
4487
+ exports.PanelIcon = PanelIcon;
4488
+ exports.inject = ["slots", "workspaces", "layout"];
4489
+ exports.apply = apply;
4490
+ return module.exports;
4491
+ }
4492
+ });