@vessel-agent/file-refs 0.0.0-stage → 2.3.0-beta.2
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/README.md +67 -2
- package/package.json +133 -4
- package/src/index.ts +24 -0
- package/web/embed/index.css +3 -0
- package/web/embed/index.mjs +879 -0
package/README.md
CHANGED
|
@@ -1,3 +1,68 @@
|
|
|
1
|
-
#
|
|
1
|
+
# file-refs(file-ux 插件 · composer 三槽 + toolbar action 贡献)
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
输入框文件引用 UX 的插件面:refs 槽原子卡片(`FileRefCard`)、link 槽消息卡片
|
|
4
|
+
(`FileRefLinkCard`)、drop 槽 OS 文件处理器(`onFilesDropped`)、toolbar action 档
|
|
5
|
+
「引用文件」入口(`onAttachClick` → 插件自持弹层:上传 / 粘贴 / 浏览)。设计冻结稿见外层仓
|
|
6
|
+
`docs/dev/design/file-ref-ux-plugin-design.md`(v2 A1–A9);本文档是插件侧文档叶,
|
|
7
|
+
只记实现口径,不改冻结稿。
|
|
8
|
+
|
|
9
|
+
## 归属口径(ADR-099 / main 裁定)
|
|
10
|
+
|
|
11
|
+
- staging 上传 / preview / TTL GC / 目录浏览是**宿主 attachments 域通用能力**
|
|
12
|
+
(`attachments.stage` / `attachments.preview` / `attachments.list`,
|
|
13
|
+
`src/data/attachment-staging.ts`),不在本插件注册 RPC;插件 node 侧是空安装面。
|
|
14
|
+
- refs 尾注 hook(`src/data/refs-notice-hook.ts`)留宿主(refs 数据链路红线)。
|
|
15
|
+
- 宿主保留 vessel-ref 渲染(用户气泡 token 原位 chip + 剩余 refs 尾部 chip 行 =
|
|
16
|
+
宿主原生,blocks.md §3.2 裁示①③);**attach 入口归插件**(file-ref P3 D4:
|
|
17
|
+
宿主 ComposerAttach / AttachDialog / attach-file 动作 id 已原子删除,A7 无断入口窗)。
|
|
18
|
+
|
|
19
|
+
## P3 入口链路(G9/G10 + GAP-1 裁 (a))
|
|
20
|
+
|
|
21
|
+
- toolbar 贡献:`contributes.toolbar[{slot:composer, id:attach, icon:attach, action:onAttachClick}]`
|
|
22
|
+
(0.51 declarative 闭集的 additive `action` 档:embed 具名导出,宿主点击时注入
|
|
23
|
+
`ComposerEditorPort` + `VesselPluginHost`;无导出 / 无端口 ⇒ 不渲染死按钮)。
|
|
24
|
+
GAP-4 图标对等:`icon:attach` = 回形针图标按钮(宿主 `Icon` 字形,读屏名 / 悬浮
|
|
25
|
+
说明仍是 `attach.label` 文案);无 icon 的条目照旧文本按钮。
|
|
26
|
+
- 上传档:原生选择框(`showOpenFilePicker` 能力探测,非 Chromium / 非安全上下文
|
|
27
|
+
降级 `input[type=file]`;AbortError 静默、取消不留占位卡)→ 共享暂存链路
|
|
28
|
+
`staging.ts`(与 drop 槽同一条:瞬态占位卡 → `port.stage` → `addRef` → token 落定),
|
|
29
|
+
插入位 = 光标位。
|
|
30
|
+
- 粘贴 / 浏览档:节点路径引用模式(无 TTL、不复制);产物 = `addRef` + `insertAtomic`
|
|
31
|
+
(token 同形,消灭「粘贴 ref 无 token」态)。形状校验 `attach-paths.ts` 自宿主迁入
|
|
32
|
+
(宿主只留发送闸 `ATTACH_PATH_MAX`);浏览经 `port.listAttachments`(additive 能力
|
|
33
|
+
探测;数据源 = 页面所在节点:会话页当前节点 / 团队页团队节点);旧 gateway 无
|
|
34
|
+
`attachments.list` ⇒ 降级提示换粘贴。
|
|
35
|
+
- 弹层焦点圈 / Esc / 归还焦点 / body 滚动锁插件侧重建(宿主 ModalShell 不可 import);
|
|
36
|
+
文案走插件私有 i18n(`attach.*`)。
|
|
37
|
+
|
|
38
|
+
## A1 逐卡「随消息发送图像」开关(inline 生产者链路)
|
|
39
|
+
|
|
40
|
+
图片卡片落定态带小开关(`role="switch"`,默认**关**):
|
|
41
|
+
|
|
42
|
+
```
|
|
43
|
+
FileRefCard 开关 → port.updateRef(index, { inline: true }) [sdk additive 契约]
|
|
44
|
+
→ 宿主草稿 store 按下标回写(只写 true 键 / false 删键)
|
|
45
|
+
→ 发送时 refs[] 随 runs.start / teams.post 透传
|
|
46
|
+
→ readRefsParam(只认 inline === true)→ attachment-ingest(inline === true 才入池)
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
- **只写 true 键**:缺省 / false ≡ 不内联(路径-only),与 P1a 契约闸逐字节同口径。
|
|
50
|
+
- **图片 ref 不携带 sha256**(staging.ts,drop / picker 共用):stager 落 blob 去重保留,但 ref 带 sha
|
|
51
|
+
会被 vision plan 直接内联、绕过 inline 闸。开开关 ⇒ 发送时 ingest 读暂存路径入池
|
|
52
|
+
(TTL 60min + 1h 宽限内有效;过期诚实降级 `not_ingested`)。
|
|
53
|
+
- chip 无 sha256 ⇒ 宿主 `use-ref-preview` 走 path 寻址 preview 路(既有回落)。
|
|
54
|
+
- 能力探测:旧宿主端口无 `updateRef` ⇒ 不渲染开关;过期 / 瞬态态不渲染。
|
|
55
|
+
- 已知局限:同路径双引用取 `findIndex` 首条(与 remove 同口径)。
|
|
56
|
+
|
|
57
|
+
## 兼容
|
|
58
|
+
|
|
59
|
+
- 历史消息只读渲染(link 槽卡片无开关);已带 sha256 的历史 refs 幂等透传继续内联,
|
|
60
|
+
前缀逐字节不变。
|
|
61
|
+
- 旧草稿无 inline 键 ⇒ 缺省关;草稿恢复保留 inline(`parseRefs` 只认 true 键)。
|
|
62
|
+
- 旧 gateway 不识别 inline ⇒ 丢键 ⇒ 不内联(fail-safe 与缺省同向)。
|
|
63
|
+
|
|
64
|
+
## 构建
|
|
65
|
+
|
|
66
|
+
```sh
|
|
67
|
+
bun run --cwd plugins/tools/file-refs build:ui # tsc web + vite embed(产物提交)
|
|
68
|
+
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,135 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vessel-agent/file-refs",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "2.3.0-beta.2",
|
|
4
|
+
"description": "File reference UX — drag/paste auto-staging refs, in-composer icon cards, vessel-ref link cards (toggleable/removable)",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "src/index.ts",
|
|
7
|
+
"types": "src/index.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": "./src/index.ts"
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"src",
|
|
13
|
+
"web"
|
|
14
|
+
],
|
|
15
|
+
"license": "MIT",
|
|
16
|
+
"repository": {
|
|
17
|
+
"type": "git",
|
|
18
|
+
"url": "git+https://github.com/egg-rolls/Vessel.git",
|
|
19
|
+
"directory": "plugins/tools/file-refs"
|
|
20
|
+
},
|
|
21
|
+
"engines": {
|
|
22
|
+
"bun": ">=1.3.9"
|
|
23
|
+
},
|
|
24
|
+
"scripts": {
|
|
25
|
+
"typecheck": "tsc --noEmit",
|
|
26
|
+
"build:ui": "tsc -p tsconfig.web.json --noEmit && vite build --config vite.config.embed.ts",
|
|
27
|
+
"typecheck:ui": "tsc -p tsconfig.web.json --noEmit"
|
|
28
|
+
},
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"@vessel-agent/core": "2.3.0-beta.2",
|
|
31
|
+
"@vessel-agent/plugin-sdk": "1.0.0",
|
|
32
|
+
"react": "^19.1.0",
|
|
33
|
+
"react-dom": "^19.1.0"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"@types/react": "^19.1.0",
|
|
37
|
+
"@types/react-dom": "^19.1.0",
|
|
38
|
+
"@vitejs/plugin-react": "^4.6.0",
|
|
39
|
+
"typescript": "^7.0.2",
|
|
40
|
+
"vite": "^7.0.0"
|
|
41
|
+
},
|
|
42
|
+
"vessel": {
|
|
43
|
+
"id": "file-refs",
|
|
44
|
+
"name": "File References",
|
|
45
|
+
"version": "2.3.0-beta.2",
|
|
46
|
+
"description": "文件引用 UX:OS 文件拖拽 / 截图粘贴自动上传暂存并在指针位置插入引用卡片;消息 vessel-ref 链接渲染为卡片。可开关 / 可删除剥离(A7/A9)。",
|
|
47
|
+
"side": "ui",
|
|
48
|
+
"ui": {
|
|
49
|
+
"dir": "web",
|
|
50
|
+
"embed": {
|
|
51
|
+
"entry": "embed/index.mjs",
|
|
52
|
+
"css": "embed/index.css",
|
|
53
|
+
"runtime": {
|
|
54
|
+
"react": "^19",
|
|
55
|
+
"sdk": "^1"
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
"contributes": {
|
|
60
|
+
"i18n": {
|
|
61
|
+
"en": {
|
|
62
|
+
"card.temporary": "temp",
|
|
63
|
+
"card.expired": "expired",
|
|
64
|
+
"card.uploading": "Uploading…",
|
|
65
|
+
"card.failed": "Upload failed",
|
|
66
|
+
"card.retry": "Retry",
|
|
67
|
+
"card.remove": "Remove {name}",
|
|
68
|
+
"card.preview": "Enlarge {name}",
|
|
69
|
+
"card.preview-failed": "Preview unavailable",
|
|
70
|
+
"card.inline": "Send image with message: {name}",
|
|
71
|
+
"card.copy-path": "Copy path",
|
|
72
|
+
"card.path-copied": "Path copied",
|
|
73
|
+
"drop.limit": "Reference limit reached (32)",
|
|
74
|
+
"drop.failed": "Could not upload {name}",
|
|
75
|
+
"attach.label": "Reference files"
|
|
76
|
+
},
|
|
77
|
+
"zh-CN": {
|
|
78
|
+
"card.temporary": "临时",
|
|
79
|
+
"card.expired": "已过期",
|
|
80
|
+
"card.uploading": "上传中…",
|
|
81
|
+
"card.failed": "上传失败",
|
|
82
|
+
"card.retry": "重试",
|
|
83
|
+
"card.remove": "移除 {name}",
|
|
84
|
+
"card.preview": "放大查看 {name}",
|
|
85
|
+
"card.preview-failed": "预览不可用",
|
|
86
|
+
"card.inline": "随消息发送图像:{name}",
|
|
87
|
+
"card.copy-path": "复制路径",
|
|
88
|
+
"card.path-copied": "路径已复制",
|
|
89
|
+
"drop.limit": "引用已达上限(32 条)",
|
|
90
|
+
"drop.failed": "无法上传 {name}",
|
|
91
|
+
"attach.label": "引用文件"
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
"toolbar": [
|
|
95
|
+
{
|
|
96
|
+
"slot": "composer",
|
|
97
|
+
"id": "attach",
|
|
98
|
+
"label": "Reference files",
|
|
99
|
+
"titleKey": "attach.label",
|
|
100
|
+
"icon": "attach",
|
|
101
|
+
"action": "onAttachClick",
|
|
102
|
+
"order": 10
|
|
103
|
+
}
|
|
104
|
+
],
|
|
105
|
+
"composer": [
|
|
106
|
+
{
|
|
107
|
+
"slot": "refs",
|
|
108
|
+
"scheme": "vessel-ref",
|
|
109
|
+
"component": "FileRefCard",
|
|
110
|
+
"order": 10
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
"slot": "drop",
|
|
114
|
+
"handler": "onFilesDropped",
|
|
115
|
+
"order": 10
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
"slot": "link",
|
|
119
|
+
"scheme": "vessel-ref",
|
|
120
|
+
"component": "FileRefLinkCard",
|
|
121
|
+
"order": 10
|
|
122
|
+
}
|
|
123
|
+
]
|
|
124
|
+
},
|
|
125
|
+
"permissions": {
|
|
126
|
+
"fs": [],
|
|
127
|
+
"net": [],
|
|
128
|
+
"process": false,
|
|
129
|
+
"secrets": false,
|
|
130
|
+
"events": [],
|
|
131
|
+
"rpc": [],
|
|
132
|
+
"ports": []
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* file-refs 插件的 node 侧(最小 in-process 面)。
|
|
3
|
+
*
|
|
4
|
+
* 引用 UX 的主体在 web embed(composer 接缝:refs / drop / link 槽);
|
|
5
|
+
* 暂存上传 / 预览是宿主 attachments 域的通用能力(attachments.stage /
|
|
6
|
+
* attachments.preview),不在本插件注册 RPC。node 侧只保留一个空安装面,
|
|
7
|
+
* 让插件经既有声明式加载机制被发现 / 开关 / 删除(A7/A9)。
|
|
8
|
+
*
|
|
9
|
+
* `[refs]` 尾注 hook 留在宿主(refs 数据链路红线:addRef / runs.start 闸门不变)。
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import type { Plugin } from '@vessel-agent/core';
|
|
13
|
+
|
|
14
|
+
export const fileRefsPlugin: Plugin = {
|
|
15
|
+
name: 'file-refs',
|
|
16
|
+
version: '2.1.23',
|
|
17
|
+
description:
|
|
18
|
+
'File reference UX (composer embed contributions; staging via host attachments domain)',
|
|
19
|
+
install() {
|
|
20
|
+
// 无 node 侧工具 / hook:UX 全部经 contributes.composer 声明式贡献。
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export default fileRefsPlugin;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
/* biome-ignore-all lint format assist: generated by `bun run build:ui` */
|
|
2
|
+
@layer properties, theme, base, legacy, plugin.file-refs, utilities;
|
|
3
|
+
@layer plugin.file-refs{.file-ref-card,.file-ref-link{display:inline-flex;align-items:center;gap:5px;max-width:260px;padding:2px 6px;border:1px solid var(--line);border-radius:6px;background:var(--surface-raised, var(--raised));color:var(--ink);font-size:12px;line-height:1.4;vertical-align:middle;cursor:default}.file-ref-link{cursor:pointer;font:inherit;font-size:12px;text-align:left}.file-ref-link:hover{border-color:var(--accent)}.file-ref-card.is-uploading{opacity:.75}.file-ref-card.is-error{border-color:var(--danger)}.file-ref-card.is-expired,.file-ref-link.is-expired{opacity:.6}.file-ref-thumb{width:36px;height:36px;object-fit:cover;border-radius:4px;flex:none}.file-ref-icon{display:inline-flex;align-items:center;justify-content:center;width:20px;height:20px;flex:none;color:var(--muted)}.file-ref-icon.is-spin{animation:file-ref-pulse 1.2s ease-in-out infinite}@keyframes file-ref-pulse{0%,to{opacity:.4}50%{opacity:1}}.file-ref-name{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:140px}.file-ref-badge{flex:none;padding:0 4px;border-radius:4px;background:var(--line);color:var(--muted);font-size:10px;line-height:1.6;white-space:nowrap}.file-ref-badge.is-temp{background:var(--accent-soft, var(--line));color:var(--accent)}.file-ref-badge.is-expired{background:var(--danger-soft, var(--line));color:var(--danger)}.file-ref-action{flex:none;border:0;background:transparent;color:var(--accent);font-size:11px;cursor:pointer;padding:0 2px}.file-ref-remove{flex:none;display:inline-flex;align-items:center;justify-content:center;width:16px;height:16px;border:0;border-radius:4px;background:transparent;color:var(--muted);cursor:pointer;padding:0}.file-ref-remove:hover{color:var(--danger);background:var(--line)}.file-ref-card{gap:4px;padding:1px 5px}.file-ref-card .file-ref-thumb{width:1em;height:1em;border-radius:3px}.file-ref-card .file-ref-icon{width:12px;height:12px}.file-ref-body{display:inline-flex;align-items:center;gap:4px;min-width:0;padding:0;border:0;border-radius:4px;background:transparent;color:inherit;font:inherit;text-align:left;cursor:pointer}.file-ref-body:hover .file-ref-name{color:var(--accent)}.file-ref-body:focus-visible{outline:2px solid var(--accent);outline-offset:1px}.file-ref-inline{flex:none;display:inline-flex;align-items:center;padding:0;border:0;background:transparent;cursor:pointer}.file-ref-inline-track{display:inline-flex;align-items:center;width:18px;height:10px;padding:1px;border-radius:6px;background:var(--line);transition:background .15s ease}.file-ref-inline-knob{width:8px;height:8px;border-radius:50%;background:var(--muted);transition:transform .15s ease,background .15s ease}.file-ref-inline.is-on .file-ref-inline-track{background:var(--accent)}.file-ref-inline.is-on .file-ref-inline-knob{transform:translate(8px);background:var(--surface-raised, var(--raised))}.file-ref-inline:focus-visible{outline:2px solid var(--accent);outline-offset:1px;border-radius:6px}}@layer plugin.file-refs{.fr-attach-backdrop{position:fixed;inset:0;z-index:1200;display:flex;align-items:center;justify-content:center;padding:16px;background:var(--scrim, rgb(0 0 0 / .45));overflow-y:auto}.fr-attach-sheet{position:relative;display:flex;flex-direction:column;gap:12px;width:100%;max-width:760px;max-height:min(86dvh,720px);padding:20px;border-radius:10px;background:var(--surface-raised, var(--raised));color:var(--ink);box-shadow:var(--elev-4, 0 12px 40px rgb(0 0 0 / .3));overflow:hidden}.fr-attach-title{margin:0;font-size:15px;font-weight:600}.fr-attach-sr{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}.fr-attach-tabs{display:flex;gap:6px;margin:0;padding:0;border:0}.fr-attach-tab{padding:4px 10px;border:1px solid var(--line);border-radius:6px;background:transparent;color:var(--ink);font-size:12px;cursor:pointer}.fr-attach-tab.is-active{border-color:var(--accent);background:var(--accent);color:var(--on-accent, #fff)}.fr-attach-tab:focus-visible,.fr-attach-plain:focus-visible,.fr-attach-primary:focus-visible,.fr-attach-crumb:focus-visible,.fr-attach-row:focus-visible,.fr-attach-close:focus-visible{outline:2px solid var(--accent);outline-offset:1px}.fr-attach-upload,.fr-attach-paste,.fr-attach-browse{display:flex;flex-direction:column;gap:8px;min-height:0;overflow-y:auto}.fr-attach-note{margin:0;font-size:12px;color:var(--muted)}.fr-attach-error{color:var(--danger)}.fr-attach-ok{color:var(--accent)}.fr-attach-label{font-size:12px;color:var(--muted)}.fr-attach-textarea{width:100%;resize:none;padding:8px;border:1px solid var(--line);border-radius:6px;background:var(--surface-sunken, var(--sunken));color:var(--ink);font-family:var(--font-mono, monospace);font-size:12px}.fr-attach-textarea[aria-invalid=true]{border-color:var(--danger)}.fr-attach-issues{margin:0;padding:0;list-style:none;display:flex;flex-direction:column;gap:4px;font-family:var(--font-mono, monospace);font-size:11px;color:var(--danger);word-break:break-all}.fr-attach-bar{display:flex;align-items:center;gap:10px}.fr-attach-hidden{display:inline-flex;align-items:center;gap:5px;font-size:12px;color:var(--muted)}.fr-attach-crumbs{display:flex;flex-wrap:wrap;align-items:center;gap:2px;font-size:12px}.fr-attach-crumb-item{display:inline-flex;align-items:center;gap:2px}.fr-attach-crumb-sep{color:var(--muted)}.fr-attach-crumb{padding:2px 4px;border:0;border-radius:4px;background:transparent;color:var(--accent);font-size:12px;cursor:pointer}.fr-attach-crumb:hover{background:var(--surface-sunken, var(--sunken))}.fr-attach-list{margin:0;padding:0;list-style:none;display:flex;flex-direction:column;gap:2px}.fr-attach-row{display:flex;align-items:center;gap:8px;width:100%;padding:5px 8px;border:0;border-radius:6px;background:transparent;color:var(--ink);font-size:12px;text-align:left;cursor:pointer}.fr-attach-row:hover{background:var(--surface-sunken, var(--sunken))}.fr-attach-row-icon{display:inline-flex;color:var(--muted)}.fr-attach-row-name{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.fr-attach-row-meta{color:var(--muted);font-size:11px}.fr-attach-actions{display:flex;align-items:center;gap:8px}.fr-attach-count{margin-right:auto;font-size:11px;color:var(--muted)}.fr-attach-plain{padding:5px 12px;border:1px solid var(--line);border-radius:6px;background:transparent;color:var(--ink);font-size:12px;cursor:pointer}.fr-attach-primary{padding:5px 12px;border:1px solid var(--accent);border-radius:6px;background:var(--accent);color:var(--on-accent, #fff);font-size:12px;cursor:pointer}.fr-attach-primary:disabled{opacity:.5;cursor:default}.fr-attach-close{position:absolute;top:8px;right:8px;width:24px;height:24px;border:0;border-radius:6px;background:transparent;color:var(--muted);font-size:14px;cursor:pointer}.fr-attach-close:hover{background:var(--surface-sunken, var(--sunken));color:var(--ink)}}
|
|
@@ -0,0 +1,879 @@
|
|
|
1
|
+
/* biome-ignore-all lint format assist: generated by `bun run build:ui` */
|
|
2
|
+
import { jsxs as f, jsx as t, Fragment as oe } from "react/jsx-runtime";
|
|
3
|
+
import { createRoot as ge } from "react-dom/client";
|
|
4
|
+
import { useMemo as Z, useState as v, useRef as q, useEffect as T } from "react";
|
|
5
|
+
const M = 32, se = 4096, ve = /^(?:[\\/]|[A-Za-z]:[\\/])/;
|
|
6
|
+
function we(a, e, r = M) {
|
|
7
|
+
const s = [], o = [], n = Math.max(0, r - Math.max(0, Math.floor(e))), u = a.split(/\r?\n/);
|
|
8
|
+
for (let i = 0; i < u.length; i += 1) {
|
|
9
|
+
const l = (u[i] ?? "").trim();
|
|
10
|
+
if (l.length === 0) continue;
|
|
11
|
+
const d = i + 1;
|
|
12
|
+
if (l.length > se) {
|
|
13
|
+
o.push({ line: d, path: l, reason: "tooLong" });
|
|
14
|
+
continue;
|
|
15
|
+
}
|
|
16
|
+
if (!ve.test(l)) {
|
|
17
|
+
o.push({ line: d, path: l, reason: "absolute" });
|
|
18
|
+
continue;
|
|
19
|
+
}
|
|
20
|
+
if (s.length >= n) {
|
|
21
|
+
o.push({ line: d, path: l, reason: "tooMany" });
|
|
22
|
+
continue;
|
|
23
|
+
}
|
|
24
|
+
s.push({ line: d, path: l });
|
|
25
|
+
}
|
|
26
|
+
return { accepted: s, issues: o };
|
|
27
|
+
}
|
|
28
|
+
const te = {
|
|
29
|
+
"card.temporary": "temp",
|
|
30
|
+
"card.expired": "expired",
|
|
31
|
+
"card.uploading": "Uploading…",
|
|
32
|
+
"card.failed": "Upload failed",
|
|
33
|
+
"card.retry": "Retry",
|
|
34
|
+
"card.remove": "Remove {name}",
|
|
35
|
+
"card.preview": "Enlarge {name}",
|
|
36
|
+
"card.preview-failed": "Preview unavailable",
|
|
37
|
+
"card.inline": "Send image with message: {name}",
|
|
38
|
+
"card.copy-path": "Copy path",
|
|
39
|
+
"card.path-copied": "Path copied",
|
|
40
|
+
"card.kind.image": "Image",
|
|
41
|
+
"card.kind.document": "Document",
|
|
42
|
+
"card.kind.file": "File",
|
|
43
|
+
"drop.limit": "Reference limit reached (32)",
|
|
44
|
+
"drop.failed": "Could not upload {name}",
|
|
45
|
+
"attach.title": "Add attachment references",
|
|
46
|
+
"attach.tab.upload": "Upload files",
|
|
47
|
+
"attach.tab.browse": "Browse folders",
|
|
48
|
+
"attach.tab.paste": "Paste path",
|
|
49
|
+
"attach.upload.hint": "Pick files from this computer; they are uploaded to the node staging area and inserted as reference cards at the caret.",
|
|
50
|
+
"attach.upload.choose": "Choose files…",
|
|
51
|
+
"attach.crumbs": "Folder path",
|
|
52
|
+
"attach.roots": "Allowed roots on the node (paths are resolved there)",
|
|
53
|
+
"attach.up": "Up",
|
|
54
|
+
"attach.hidden": "Show hidden entries",
|
|
55
|
+
"attach.dir": "folder",
|
|
56
|
+
"attach.empty": "Nothing referenceable in this folder",
|
|
57
|
+
"attach.truncated": "Showing the first {limit} entries; open a narrower folder for more",
|
|
58
|
+
"attach.selected": "Selected {count} of {max}",
|
|
59
|
+
"attach.add": "Add reference",
|
|
60
|
+
"attach.addCount": "Add {count} references",
|
|
61
|
+
"attach.added": "Added {count} reference(s)",
|
|
62
|
+
"attach.paste.label": "Absolute path on the node",
|
|
63
|
+
"attach.paste.hint": "The path is resolved on the machine that runs the agent; out-of-bounds paths are rejected when sending.",
|
|
64
|
+
"attach.paste.placeholder": "One absolute path per line, e.g. /home/me/a.ts or D:\\work\\b.md",
|
|
65
|
+
"attach.paste.input": "File paths to reference",
|
|
66
|
+
"attach.paste.keys": "One path per line · Ctrl/⌘+Enter to add · Esc to cancel · at most {max}",
|
|
67
|
+
"attach.count": "{used}/{max} referenced",
|
|
68
|
+
"attach.addedCount": "Added {count}",
|
|
69
|
+
"attach.rejected": "These {count} line(s) were not added:",
|
|
70
|
+
"attach.reason.invalid": "This folder cannot be opened (missing or unreadable)",
|
|
71
|
+
"attach.reason.denied": "This folder is protected and cannot be browsed",
|
|
72
|
+
"attach.reason.outside": "This folder is outside the browsable roots",
|
|
73
|
+
"attach.error": "Failed to read the folder: {message}",
|
|
74
|
+
"attach.unavailable": "This gateway version has no folder browsing (attachments.list); paste the path instead",
|
|
75
|
+
"attach.error.absolute": "Line {line} is not an absolute path: {path}",
|
|
76
|
+
"attach.error.tooLong": "Line {line} is longer than {max} characters",
|
|
77
|
+
"attach.error.tooMany": "Line {line} exceeds the limit: at most {max} references per message",
|
|
78
|
+
"attach.close": "Close",
|
|
79
|
+
"attach.cancel": "Cancel",
|
|
80
|
+
"attach.loading": "Loading…"
|
|
81
|
+
}, ye = {
|
|
82
|
+
"card.temporary": "临时",
|
|
83
|
+
"card.expired": "已过期",
|
|
84
|
+
"card.uploading": "上传中…",
|
|
85
|
+
"card.failed": "上传失败",
|
|
86
|
+
"card.retry": "重试",
|
|
87
|
+
"card.remove": "移除 {name}",
|
|
88
|
+
"card.preview": "放大查看 {name}",
|
|
89
|
+
"card.preview-failed": "预览不可用",
|
|
90
|
+
"card.inline": "随消息发送图像:{name}",
|
|
91
|
+
"card.copy-path": "复制路径",
|
|
92
|
+
"card.path-copied": "路径已复制",
|
|
93
|
+
"card.kind.image": "图片",
|
|
94
|
+
"card.kind.document": "文档",
|
|
95
|
+
"card.kind.file": "文件",
|
|
96
|
+
"drop.limit": "引用已达上限(32 条)",
|
|
97
|
+
"drop.failed": "无法上传 {name}",
|
|
98
|
+
"attach.title": "添加附件引用",
|
|
99
|
+
"attach.tab.upload": "上传文件",
|
|
100
|
+
"attach.tab.browse": "浏览目录",
|
|
101
|
+
"attach.tab.paste": "粘贴路径",
|
|
102
|
+
"attach.upload.hint": "从本机选择文件,上传到 node 暂存区并在光标位插入引用卡片。",
|
|
103
|
+
"attach.upload.choose": "选择文件…",
|
|
104
|
+
"attach.crumbs": "目录路径",
|
|
105
|
+
"attach.roots": "node 上允许浏览的根(路径按跑 agent 的那台机器解析)",
|
|
106
|
+
"attach.up": "上级",
|
|
107
|
+
"attach.hidden": "显示隐藏项",
|
|
108
|
+
"attach.dir": "目录",
|
|
109
|
+
"attach.empty": "这个目录里没有可引用的条目",
|
|
110
|
+
"attach.truncated": "只显示前 {limit} 项;要看更多请进入更具体的目录",
|
|
111
|
+
"attach.selected": "已选 {count} / {max}",
|
|
112
|
+
"attach.add": "添加引用",
|
|
113
|
+
"attach.addCount": "添加 {count} 个引用",
|
|
114
|
+
"attach.added": "已添加 {count} 个引用",
|
|
115
|
+
"attach.paste.label": "node 上的绝对路径",
|
|
116
|
+
"attach.paste.hint": "路径按跑 agent 的那台机器解析;越界路径在发送时会被拒。",
|
|
117
|
+
"attach.paste.placeholder": "一行一个绝对路径,例如 /home/me/a.ts 或 D:\\work\\b.md",
|
|
118
|
+
"attach.paste.input": "要引用的文件路径",
|
|
119
|
+
"attach.paste.keys": "一行一个路径 · Ctrl/⌘+Enter 添加 · Esc 取消 · 最多 {max} 条",
|
|
120
|
+
"attach.count": "已引用 {used}/{max}",
|
|
121
|
+
"attach.addedCount": "已添加 {count} 条引用",
|
|
122
|
+
"attach.rejected": "以下 {count} 行没有添加:",
|
|
123
|
+
"attach.reason.invalid": "这个目录打不开(不存在或不可读)",
|
|
124
|
+
"attach.reason.denied": "这个目录属于受保护目录,不能浏览",
|
|
125
|
+
"attach.reason.outside": "这个目录在允许浏览的根之外",
|
|
126
|
+
"attach.error": "读取目录失败:{message}",
|
|
127
|
+
"attach.unavailable": "这个 gateway 版本没有目录浏览(attachments.list),请改用粘贴路径",
|
|
128
|
+
"attach.error.absolute": "第 {line} 行不是绝对路径:{path}",
|
|
129
|
+
"attach.error.tooLong": "第 {line} 行的路径超过 {max} 个字符",
|
|
130
|
+
"attach.error.tooMany": "第 {line} 行超出上限:单条消息最多 {max} 个引用",
|
|
131
|
+
"attach.close": "关闭",
|
|
132
|
+
"attach.cancel": "取消",
|
|
133
|
+
"attach.loading": "加载中…"
|
|
134
|
+
};
|
|
135
|
+
function G(a) {
|
|
136
|
+
const e = a.startsWith("zh") ? ye : te;
|
|
137
|
+
return (r, s) => {
|
|
138
|
+
let o = e[r] ?? te[r] ?? r;
|
|
139
|
+
if (s !== void 0)
|
|
140
|
+
for (const [n, u] of Object.entries(s))
|
|
141
|
+
o = o.replaceAll(`{${n}}`, String(u));
|
|
142
|
+
return o;
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
function W({ kind: a, size: e = 14 }) {
|
|
146
|
+
const r = {
|
|
147
|
+
width: e,
|
|
148
|
+
height: e,
|
|
149
|
+
viewBox: "0 0 20 20",
|
|
150
|
+
fill: "none",
|
|
151
|
+
stroke: "currentColor",
|
|
152
|
+
strokeWidth: 1.5,
|
|
153
|
+
strokeLinecap: "round",
|
|
154
|
+
strokeLinejoin: "round",
|
|
155
|
+
"aria-hidden": !0,
|
|
156
|
+
focusable: "false"
|
|
157
|
+
};
|
|
158
|
+
return a === "image" ? /* @__PURE__ */ f("svg", { ...r, children: [
|
|
159
|
+
/* @__PURE__ */ t("rect", { x: "3", y: "4", width: "14", height: "12", rx: "2" }),
|
|
160
|
+
/* @__PURE__ */ t("circle", { cx: "7.5", cy: "8", r: "1.3" }),
|
|
161
|
+
/* @__PURE__ */ t("path", { d: "M4 14.5 8.5 10l3 3 2-2 2.5 2.5" })
|
|
162
|
+
] }) : a === "document" ? /* @__PURE__ */ f("svg", { ...r, children: [
|
|
163
|
+
/* @__PURE__ */ t("path", { d: "M5 3.5h6.5L15.5 8v8.5H5z" }),
|
|
164
|
+
/* @__PURE__ */ t("path", { d: "M11.5 3.5V8h4" }),
|
|
165
|
+
/* @__PURE__ */ t("path", { d: "M7.5 11h5M7.5 13.5h3.5" })
|
|
166
|
+
] }) : /* @__PURE__ */ f("svg", { ...r, children: [
|
|
167
|
+
/* @__PURE__ */ t("path", { d: "M5 3.5h6.5L15.5 8v8.5H5z" }),
|
|
168
|
+
/* @__PURE__ */ t("path", { d: "M11.5 3.5V8h4" })
|
|
169
|
+
] });
|
|
170
|
+
}
|
|
171
|
+
function ae() {
|
|
172
|
+
return /* @__PURE__ */ t(
|
|
173
|
+
"svg",
|
|
174
|
+
{
|
|
175
|
+
width: 10,
|
|
176
|
+
height: 10,
|
|
177
|
+
viewBox: "0 0 20 20",
|
|
178
|
+
fill: "none",
|
|
179
|
+
stroke: "currentColor",
|
|
180
|
+
strokeWidth: 1.8,
|
|
181
|
+
strokeLinecap: "round",
|
|
182
|
+
"aria-hidden": "true",
|
|
183
|
+
focusable: "false",
|
|
184
|
+
children: /* @__PURE__ */ t("path", { d: "M5.5 5.5l9 9M14.5 5.5l-9 9" })
|
|
185
|
+
}
|
|
186
|
+
);
|
|
187
|
+
}
|
|
188
|
+
const Ne = /* @__PURE__ */ new Set([
|
|
189
|
+
"png",
|
|
190
|
+
"jpg",
|
|
191
|
+
"jpeg",
|
|
192
|
+
"gif",
|
|
193
|
+
"webp",
|
|
194
|
+
"bmp",
|
|
195
|
+
"svg",
|
|
196
|
+
"ico",
|
|
197
|
+
"avif",
|
|
198
|
+
"tiff",
|
|
199
|
+
"tif"
|
|
200
|
+
]), xe = /* @__PURE__ */ new Set([
|
|
201
|
+
"pdf",
|
|
202
|
+
"doc",
|
|
203
|
+
"docx",
|
|
204
|
+
"xls",
|
|
205
|
+
"xlsx",
|
|
206
|
+
"ppt",
|
|
207
|
+
"pptx",
|
|
208
|
+
"md",
|
|
209
|
+
"txt",
|
|
210
|
+
"csv",
|
|
211
|
+
"rtf",
|
|
212
|
+
"odt",
|
|
213
|
+
"ods",
|
|
214
|
+
"odp",
|
|
215
|
+
"json",
|
|
216
|
+
"yaml",
|
|
217
|
+
"yml",
|
|
218
|
+
"xml",
|
|
219
|
+
"log"
|
|
220
|
+
]);
|
|
221
|
+
function F(a) {
|
|
222
|
+
const e = a.split(/[\\/]/).pop() ?? "", r = e.lastIndexOf("."), s = r >= 0 ? e.slice(r + 1).toLowerCase() : "";
|
|
223
|
+
return Ne.has(s) ? "image" : xe.has(s) ? "document" : "file";
|
|
224
|
+
}
|
|
225
|
+
function ke(a) {
|
|
226
|
+
const e = a.split(/[\\/]/).pop() ?? "", r = e.lastIndexOf(".");
|
|
227
|
+
return r >= 0 && e.slice(r + 1).toLowerCase() === "pdf";
|
|
228
|
+
}
|
|
229
|
+
function j(a) {
|
|
230
|
+
const e = a.split(/[\\/]/).filter((r) => r.length > 0);
|
|
231
|
+
return e[e.length - 1] ?? a;
|
|
232
|
+
}
|
|
233
|
+
function le(a, e) {
|
|
234
|
+
return `[${a.replace(/[[\]\n]/g, "").trim() || e}](<vessel-ref:${e}>)`;
|
|
235
|
+
}
|
|
236
|
+
async function de(a, e, r, s, o, n) {
|
|
237
|
+
const u = (h) => {
|
|
238
|
+
if (!e.addRef({
|
|
239
|
+
kind: h.kind,
|
|
240
|
+
path: h.path,
|
|
241
|
+
name: h.name,
|
|
242
|
+
...h.mime !== void 0 ? { mime: h.mime } : {},
|
|
243
|
+
bytes: h.bytes,
|
|
244
|
+
...h.kind !== "image" ? { sha256: h.sha256 } : {}
|
|
245
|
+
})) {
|
|
246
|
+
s?.remove(), o("error", n("drop.limit"));
|
|
247
|
+
return;
|
|
248
|
+
}
|
|
249
|
+
const b = le(h.name, h.path);
|
|
250
|
+
s !== null ? s.settle(b) : e.insertAtomic(b, r.offset ?? void 0);
|
|
251
|
+
}, [i] = await e.stage([a]);
|
|
252
|
+
if (i !== void 0 && i.ok) {
|
|
253
|
+
u(i);
|
|
254
|
+
return;
|
|
255
|
+
}
|
|
256
|
+
const l = i !== void 0 && !i.ok ? i.error : "empty result", d = {
|
|
257
|
+
status: "error",
|
|
258
|
+
name: a.name,
|
|
259
|
+
error: l,
|
|
260
|
+
retry: () => {
|
|
261
|
+
s?.update({ status: "uploading", name: a.name }), de(a, e, r, s, o, n).catch(() => {
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
};
|
|
265
|
+
s !== null && s.update(d), o("error", n("drop.failed", { name: a.name }));
|
|
266
|
+
}
|
|
267
|
+
function he(a, e, r) {
|
|
268
|
+
const s = (n, u) => {
|
|
269
|
+
let l = n === "drop.limit" ? "Reference limit reached (32)" : "Could not upload {name}";
|
|
270
|
+
if (u !== void 0)
|
|
271
|
+
for (const [d, h] of Object.entries(u))
|
|
272
|
+
l = l.replaceAll(`{${d}}`, String(h));
|
|
273
|
+
return l;
|
|
274
|
+
}, o = (n, u) => {
|
|
275
|
+
};
|
|
276
|
+
for (const n of a) {
|
|
277
|
+
const u = e.insertTransient(
|
|
278
|
+
"vessel-ref",
|
|
279
|
+
{
|
|
280
|
+
status: "uploading",
|
|
281
|
+
name: n.name
|
|
282
|
+
},
|
|
283
|
+
r.offset ?? void 0
|
|
284
|
+
);
|
|
285
|
+
de(n, e, r, u, o, s).catch(() => {
|
|
286
|
+
});
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
const E = globalThis, Ce = 'button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';
|
|
290
|
+
function Ee(a) {
|
|
291
|
+
const e = q(null), r = q(a);
|
|
292
|
+
return r.current = a, T(() => {
|
|
293
|
+
const s = E.document.activeElement, o = e.current, n = E.document.body.style.overflow;
|
|
294
|
+
E.document.body.style.overflow = "hidden";
|
|
295
|
+
const u = () => o === null ? [] : Array.from(o.querySelectorAll(Ce)).filter((h) => h.offsetParent !== null || h === E.document.activeElement);
|
|
296
|
+
(o?.querySelector("[data-autofocus]") ?? null ?? u()[0] ?? o)?.focus();
|
|
297
|
+
const l = (d) => {
|
|
298
|
+
if (d.key === "Escape") {
|
|
299
|
+
d.preventDefault(), r.current();
|
|
300
|
+
return;
|
|
301
|
+
}
|
|
302
|
+
if (d.key !== "Tab") return;
|
|
303
|
+
const h = u();
|
|
304
|
+
if (h.length === 0) return;
|
|
305
|
+
const w = h[0], b = h[h.length - 1];
|
|
306
|
+
w === void 0 || b === void 0 || (d.shiftKey && E.document.activeElement === w ? (d.preventDefault(), b.focus()) : !d.shiftKey && E.document.activeElement === b && (d.preventDefault(), w.focus()));
|
|
307
|
+
};
|
|
308
|
+
return E.document.addEventListener("keydown", l), () => {
|
|
309
|
+
E.document.removeEventListener("keydown", l), E.document.body.style.overflow = n, s?.focus?.();
|
|
310
|
+
};
|
|
311
|
+
}, []), e;
|
|
312
|
+
}
|
|
313
|
+
function Ae(a) {
|
|
314
|
+
const [e, r] = v(() => a.theme.get());
|
|
315
|
+
return T(() => a.theme.subscribe(r), [a]), e.lang;
|
|
316
|
+
}
|
|
317
|
+
function Me(a) {
|
|
318
|
+
return a === void 0 ? "" : a < 1024 ? `${a} B` : a < 1024 * 1024 ? `${(a / 1024).toFixed(1)} KB` : `${(a / (1024 * 1024)).toFixed(1)} MB`;
|
|
319
|
+
}
|
|
320
|
+
function Te(a, e) {
|
|
321
|
+
const r = a.replace(/\\/g, "/"), s = e.find((i) => {
|
|
322
|
+
const l = i.replace(/\\/g, "/");
|
|
323
|
+
return r === l || r.startsWith(l.endsWith("/") ? l : `${l}/`);
|
|
324
|
+
});
|
|
325
|
+
if (s === void 0) return [];
|
|
326
|
+
const o = [{ label: j(s) || s, path: s }];
|
|
327
|
+
let n = s;
|
|
328
|
+
const u = a.slice(s.length).split(/[\\/]+/).filter((i) => i.length > 0);
|
|
329
|
+
for (const i of u) {
|
|
330
|
+
const l = n.endsWith("\\") || n.endsWith("/") ? "" : "/";
|
|
331
|
+
n = `${n}${l}${i}`, o.push({ label: i, path: n });
|
|
332
|
+
}
|
|
333
|
+
return o;
|
|
334
|
+
}
|
|
335
|
+
function Le(a, e) {
|
|
336
|
+
switch (a) {
|
|
337
|
+
case "refs_denied":
|
|
338
|
+
return e("attach.reason.denied");
|
|
339
|
+
case "refs_outside_roots":
|
|
340
|
+
return e("attach.reason.outside");
|
|
341
|
+
default:
|
|
342
|
+
return e("attach.reason.invalid");
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
function Pe(a, e) {
|
|
346
|
+
const r = a?.code;
|
|
347
|
+
return r === "not_found" || r === "not_supported" ? e("attach.unavailable") : e("attach.error", {
|
|
348
|
+
message: a instanceof Error ? a.message : String(a)
|
|
349
|
+
});
|
|
350
|
+
}
|
|
351
|
+
function Ie(a, e) {
|
|
352
|
+
return a.reason === "tooLong" ? e("attach.error.tooLong", { line: a.line, max: se }) : a.reason === "tooMany" ? e("attach.error.tooMany", { line: a.line, max: M }) : e("attach.error.absolute", { line: a.line, path: a.path });
|
|
353
|
+
}
|
|
354
|
+
function ne() {
|
|
355
|
+
return /* @__PURE__ */ t(
|
|
356
|
+
"svg",
|
|
357
|
+
{
|
|
358
|
+
width: "13",
|
|
359
|
+
height: "13",
|
|
360
|
+
viewBox: "0 0 20 20",
|
|
361
|
+
fill: "none",
|
|
362
|
+
stroke: "currentColor",
|
|
363
|
+
strokeWidth: 1.5,
|
|
364
|
+
strokeLinecap: "round",
|
|
365
|
+
strokeLinejoin: "round",
|
|
366
|
+
"aria-hidden": "true",
|
|
367
|
+
focusable: "false",
|
|
368
|
+
children: /* @__PURE__ */ t("path", { d: "M3 6.5A1.5 1.5 0 0 1 4.5 5h3l1.5 2h6.5A1.5 1.5 0 0 1 17 8.5v6A1.5 1.5 0 0 1 15.5 16h-11A1.5 1.5 0 0 1 3 14.5z" })
|
|
369
|
+
}
|
|
370
|
+
);
|
|
371
|
+
}
|
|
372
|
+
function Se({ port: a, host: e, onClose: r, pickFiles: s }) {
|
|
373
|
+
const o = Ae(e), n = Z(() => G(o), [o]), u = Ee(r), [i, l] = v("upload"), [d, h] = v(void 0), [w, b] = v(!1), [L, y] = v(void 0), [m, x] = v(!1), [N, U] = v([]), [P, D] = v(""), [I, z] = v([]), [B, _] = v(0), g = q(null), A = typeof a.listAttachments == "function", C = a.refs().length;
|
|
374
|
+
T(() => {
|
|
375
|
+
i === "paste" && g.current?.focus();
|
|
376
|
+
}, [i]);
|
|
377
|
+
const S = d?.dir, J = d?.roots ?? [], K = d?.entries ?? [], X = d?.reason, R = async (c, p) => {
|
|
378
|
+
if (typeof a.listAttachments == "function") {
|
|
379
|
+
b(!0), y(void 0);
|
|
380
|
+
try {
|
|
381
|
+
h(
|
|
382
|
+
await a.listAttachments({
|
|
383
|
+
limit: 200,
|
|
384
|
+
...c !== void 0 ? { dir: c } : {},
|
|
385
|
+
...p ? { include_hidden: !0 } : {}
|
|
386
|
+
})
|
|
387
|
+
);
|
|
388
|
+
} catch ($) {
|
|
389
|
+
h(void 0), y(Pe($, n));
|
|
390
|
+
} finally {
|
|
391
|
+
b(!1);
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
};
|
|
395
|
+
T(() => {
|
|
396
|
+
i !== "browse" || !A || R(void 0, !1);
|
|
397
|
+
}, [i, A]);
|
|
398
|
+
const Q = (c) => a.addRef(c) ? (a.insertAtomic(le(c.name ?? j(c.path), c.path)), !0) : !1, fe = (c) => {
|
|
399
|
+
const p = N.findIndex((k) => k.path === c.path);
|
|
400
|
+
if (p !== -1) {
|
|
401
|
+
U(N.filter((k, H) => H !== p));
|
|
402
|
+
return;
|
|
403
|
+
}
|
|
404
|
+
if (N.length >= M) {
|
|
405
|
+
e.toast({ kind: "error", text: n("attach.error.tooMany", { line: 0, max: M }) });
|
|
406
|
+
return;
|
|
407
|
+
}
|
|
408
|
+
const $ = {
|
|
409
|
+
kind: F(c.path),
|
|
410
|
+
path: c.path,
|
|
411
|
+
name: c.name,
|
|
412
|
+
...c.bytes !== void 0 ? { bytes: c.bytes } : {}
|
|
413
|
+
};
|
|
414
|
+
U([...N, $]);
|
|
415
|
+
}, pe = () => {
|
|
416
|
+
let c = 0;
|
|
417
|
+
for (const p of N) {
|
|
418
|
+
if (!Q(p)) break;
|
|
419
|
+
c += 1;
|
|
420
|
+
}
|
|
421
|
+
c !== 0 && (e.toast({ kind: "success", text: n("attach.added", { count: c }) }), r());
|
|
422
|
+
}, Y = () => {
|
|
423
|
+
if (P.trim().length === 0) return;
|
|
424
|
+
const c = we(P, C, M), p = [...c.issues];
|
|
425
|
+
let $ = 0;
|
|
426
|
+
for (const k of c.accepted) {
|
|
427
|
+
const H = {
|
|
428
|
+
kind: F(k.path),
|
|
429
|
+
path: k.path,
|
|
430
|
+
name: j(k.path)
|
|
431
|
+
};
|
|
432
|
+
Q(H) ? $ += 1 : p.push({ line: k.line, path: k.path, reason: "tooMany" });
|
|
433
|
+
}
|
|
434
|
+
if (p.length === 0) {
|
|
435
|
+
r();
|
|
436
|
+
return;
|
|
437
|
+
}
|
|
438
|
+
p.sort((k, H) => k.line - H.line), _($), z(p), D(p.map((k) => k.path).join(`
|
|
439
|
+
`));
|
|
440
|
+
}, me = (c) => {
|
|
441
|
+
c.nativeEvent.isComposing || c.key === "Enter" && (c.ctrlKey || c.metaKey) && (c.preventDefault(), Y());
|
|
442
|
+
}, be = async () => {
|
|
443
|
+
const c = await s();
|
|
444
|
+
c.length !== 0 && (he(c, a, { offset: a.getCaretOffset() }), r());
|
|
445
|
+
}, ee = S === void 0 ? [] : Te(S, J);
|
|
446
|
+
return (
|
|
447
|
+
// biome-ignore lint/a11y/noStaticElementInteractions: backdrop mousedown closes the sheet(与宿主 ModalShell 同口径)
|
|
448
|
+
/* @__PURE__ */ t(
|
|
449
|
+
"div",
|
|
450
|
+
{
|
|
451
|
+
className: "fr-attach-backdrop",
|
|
452
|
+
onMouseDown: (c) => {
|
|
453
|
+
c.target === c.currentTarget && r();
|
|
454
|
+
},
|
|
455
|
+
children: /* @__PURE__ */ f(
|
|
456
|
+
"div",
|
|
457
|
+
{
|
|
458
|
+
ref: u,
|
|
459
|
+
className: "fr-attach-sheet",
|
|
460
|
+
role: "dialog",
|
|
461
|
+
"aria-modal": "true",
|
|
462
|
+
"aria-label": n("attach.title"),
|
|
463
|
+
tabIndex: -1,
|
|
464
|
+
children: [
|
|
465
|
+
/* @__PURE__ */ t("h2", { className: "fr-attach-title", children: n("attach.title") }),
|
|
466
|
+
/* @__PURE__ */ f("fieldset", { className: "fr-attach-tabs", children: [
|
|
467
|
+
/* @__PURE__ */ t("legend", { className: "fr-attach-sr", children: n("attach.title") }),
|
|
468
|
+
/* @__PURE__ */ t(
|
|
469
|
+
"button",
|
|
470
|
+
{
|
|
471
|
+
type: "button",
|
|
472
|
+
className: i === "upload" ? "fr-attach-tab is-active" : "fr-attach-tab",
|
|
473
|
+
"aria-pressed": i === "upload",
|
|
474
|
+
"data-autofocus": !0,
|
|
475
|
+
onClick: () => l("upload"),
|
|
476
|
+
children: n("attach.tab.upload")
|
|
477
|
+
}
|
|
478
|
+
),
|
|
479
|
+
/* @__PURE__ */ t(
|
|
480
|
+
"button",
|
|
481
|
+
{
|
|
482
|
+
type: "button",
|
|
483
|
+
className: i === "browse" ? "fr-attach-tab is-active" : "fr-attach-tab",
|
|
484
|
+
"aria-pressed": i === "browse",
|
|
485
|
+
onClick: () => l("browse"),
|
|
486
|
+
children: n("attach.tab.browse")
|
|
487
|
+
}
|
|
488
|
+
),
|
|
489
|
+
/* @__PURE__ */ t(
|
|
490
|
+
"button",
|
|
491
|
+
{
|
|
492
|
+
type: "button",
|
|
493
|
+
className: i === "paste" ? "fr-attach-tab is-active" : "fr-attach-tab",
|
|
494
|
+
"aria-pressed": i === "paste",
|
|
495
|
+
onClick: () => l("paste"),
|
|
496
|
+
children: n("attach.tab.paste")
|
|
497
|
+
}
|
|
498
|
+
)
|
|
499
|
+
] }),
|
|
500
|
+
i === "upload" ? /* @__PURE__ */ f("div", { className: "fr-attach-upload", children: [
|
|
501
|
+
/* @__PURE__ */ t("p", { className: "fr-attach-note", children: n("attach.upload.hint") }),
|
|
502
|
+
/* @__PURE__ */ t("button", { type: "button", className: "fr-attach-primary", onClick: () => {
|
|
503
|
+
be();
|
|
504
|
+
}, children: n("attach.upload.choose") })
|
|
505
|
+
] }) : i === "paste" ? /* @__PURE__ */ f("div", { className: "fr-attach-paste", children: [
|
|
506
|
+
/* @__PURE__ */ t("label", { className: "fr-attach-label", htmlFor: "fr-attach-paste-input", children: n("attach.paste.label") }),
|
|
507
|
+
/* @__PURE__ */ t(
|
|
508
|
+
"textarea",
|
|
509
|
+
{
|
|
510
|
+
ref: g,
|
|
511
|
+
id: "fr-attach-paste-input",
|
|
512
|
+
rows: 3,
|
|
513
|
+
value: P,
|
|
514
|
+
onChange: (c) => {
|
|
515
|
+
D(c.target.value), _(0);
|
|
516
|
+
},
|
|
517
|
+
placeholder: n("attach.paste.placeholder"),
|
|
518
|
+
"aria-label": n("attach.paste.input"),
|
|
519
|
+
"aria-describedby": "fr-attach-paste-hint",
|
|
520
|
+
"aria-invalid": I.length > 0,
|
|
521
|
+
spellCheck: !1,
|
|
522
|
+
className: "fr-attach-textarea",
|
|
523
|
+
onKeyDown: me
|
|
524
|
+
}
|
|
525
|
+
),
|
|
526
|
+
/* @__PURE__ */ t("p", { id: "fr-attach-paste-hint", className: "fr-attach-note", children: n("attach.paste.keys", { max: M }) }),
|
|
527
|
+
/* @__PURE__ */ t("p", { className: "fr-attach-note", children: n("attach.paste.hint") }),
|
|
528
|
+
B > 0 && /* @__PURE__ */ t("p", { className: "fr-attach-note fr-attach-ok", role: "status", children: n("attach.addedCount", { count: B }) }),
|
|
529
|
+
I.length > 0 && /* @__PURE__ */ f("div", { role: "alert", children: [
|
|
530
|
+
/* @__PURE__ */ t("p", { className: "fr-attach-note fr-attach-error", children: n("attach.rejected", { count: I.length }) }),
|
|
531
|
+
/* @__PURE__ */ t("ul", { className: "fr-attach-issues", children: I.map((c) => /* @__PURE__ */ t("li", { children: Ie(c, n) }, `${c.line}:${c.path}`)) })
|
|
532
|
+
] })
|
|
533
|
+
] }) : /* @__PURE__ */ t("div", { className: "fr-attach-browse", children: A ? /* @__PURE__ */ f(oe, { children: [
|
|
534
|
+
/* @__PURE__ */ f("div", { className: "fr-attach-bar", children: [
|
|
535
|
+
d?.parent !== void 0 ? /* @__PURE__ */ t(
|
|
536
|
+
"button",
|
|
537
|
+
{
|
|
538
|
+
type: "button",
|
|
539
|
+
className: "fr-attach-plain",
|
|
540
|
+
onClick: () => {
|
|
541
|
+
R(d?.parent, m);
|
|
542
|
+
},
|
|
543
|
+
children: n("attach.up")
|
|
544
|
+
}
|
|
545
|
+
) : null,
|
|
546
|
+
/* @__PURE__ */ f("label", { className: "fr-attach-hidden", children: [
|
|
547
|
+
/* @__PURE__ */ t(
|
|
548
|
+
"input",
|
|
549
|
+
{
|
|
550
|
+
type: "checkbox",
|
|
551
|
+
checked: m,
|
|
552
|
+
onChange: (c) => {
|
|
553
|
+
const p = c.target.checked;
|
|
554
|
+
x(p), R(S, p);
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
),
|
|
558
|
+
n("attach.hidden")
|
|
559
|
+
] }),
|
|
560
|
+
w ? /* @__PURE__ */ t("span", { className: "fr-attach-note", children: n("attach.loading") }) : null
|
|
561
|
+
] }),
|
|
562
|
+
ee.length > 0 ? /* @__PURE__ */ t("nav", { className: "fr-attach-crumbs", "aria-label": n("attach.crumbs"), children: ee.map((c, p) => /* @__PURE__ */ f("span", { className: "fr-attach-crumb-item", children: [
|
|
563
|
+
p > 0 ? /* @__PURE__ */ t("span", { className: "fr-attach-crumb-sep", "aria-hidden": "true", children: "/" }) : null,
|
|
564
|
+
/* @__PURE__ */ t(
|
|
565
|
+
"button",
|
|
566
|
+
{
|
|
567
|
+
type: "button",
|
|
568
|
+
className: "fr-attach-crumb",
|
|
569
|
+
onClick: () => {
|
|
570
|
+
R(c.path, m);
|
|
571
|
+
},
|
|
572
|
+
children: c.label
|
|
573
|
+
}
|
|
574
|
+
)
|
|
575
|
+
] }, c.path)) }) : null,
|
|
576
|
+
L !== void 0 ? /* @__PURE__ */ t("p", { className: "fr-attach-note fr-attach-error", children: L }) : null,
|
|
577
|
+
X !== void 0 ? /* @__PURE__ */ t("p", { className: "fr-attach-note fr-attach-error", children: Le(X, n) }) : null,
|
|
578
|
+
S === void 0 && L === void 0 && d !== void 0 ? /* @__PURE__ */ f("div", { children: [
|
|
579
|
+
/* @__PURE__ */ t("p", { className: "fr-attach-note", children: n("attach.roots") }),
|
|
580
|
+
/* @__PURE__ */ t("ul", { className: "fr-attach-list", children: J.map((c) => /* @__PURE__ */ t("li", { children: /* @__PURE__ */ f(
|
|
581
|
+
"button",
|
|
582
|
+
{
|
|
583
|
+
type: "button",
|
|
584
|
+
className: "fr-attach-row fr-attach-row-dir",
|
|
585
|
+
onClick: () => {
|
|
586
|
+
R(c, m);
|
|
587
|
+
},
|
|
588
|
+
children: [
|
|
589
|
+
/* @__PURE__ */ t("span", { className: "fr-attach-row-icon", children: /* @__PURE__ */ t(ne, {}) }),
|
|
590
|
+
/* @__PURE__ */ t("span", { className: "fr-attach-row-name", children: c }),
|
|
591
|
+
/* @__PURE__ */ t("span", { className: "fr-attach-row-meta", children: n("attach.dir") })
|
|
592
|
+
]
|
|
593
|
+
}
|
|
594
|
+
) }, c)) })
|
|
595
|
+
] }) : null,
|
|
596
|
+
S !== void 0 && K.length === 0 && X === void 0 ? /* @__PURE__ */ t("p", { className: "fr-attach-note", children: n("attach.empty") }) : null,
|
|
597
|
+
K.length > 0 ? /* @__PURE__ */ t("ul", { className: "fr-attach-list", children: K.map(
|
|
598
|
+
(c) => c.kind === "dir" ? /* @__PURE__ */ t("li", { children: /* @__PURE__ */ f(
|
|
599
|
+
"button",
|
|
600
|
+
{
|
|
601
|
+
type: "button",
|
|
602
|
+
className: "fr-attach-row fr-attach-row-dir",
|
|
603
|
+
onClick: () => {
|
|
604
|
+
R(c.path, m);
|
|
605
|
+
},
|
|
606
|
+
children: [
|
|
607
|
+
/* @__PURE__ */ t("span", { className: "fr-attach-row-icon", children: /* @__PURE__ */ t(ne, {}) }),
|
|
608
|
+
/* @__PURE__ */ t("span", { className: "fr-attach-row-name", children: c.name }),
|
|
609
|
+
/* @__PURE__ */ t("span", { className: "fr-attach-row-meta", children: n("attach.dir") })
|
|
610
|
+
]
|
|
611
|
+
}
|
|
612
|
+
) }, c.path) : /* @__PURE__ */ t("li", { children: /* @__PURE__ */ f("label", { className: "fr-attach-row fr-attach-row-file", children: [
|
|
613
|
+
/* @__PURE__ */ t(
|
|
614
|
+
"input",
|
|
615
|
+
{
|
|
616
|
+
type: "checkbox",
|
|
617
|
+
checked: N.some((p) => p.path === c.path),
|
|
618
|
+
onChange: () => fe(c)
|
|
619
|
+
}
|
|
620
|
+
),
|
|
621
|
+
/* @__PURE__ */ t("span", { className: "fr-attach-row-name", children: c.name }),
|
|
622
|
+
/* @__PURE__ */ t("span", { className: "fr-attach-row-meta", children: Me(c.bytes) })
|
|
623
|
+
] }) }, c.path)
|
|
624
|
+
) }) : null,
|
|
625
|
+
d?.truncated === !0 ? /* @__PURE__ */ t("p", { className: "fr-attach-note", children: n("attach.truncated", { limit: 200 }) }) : null
|
|
626
|
+
] }) : /* @__PURE__ */ t("p", { className: "fr-attach-note fr-attach-error", children: n("attach.unavailable") }) }),
|
|
627
|
+
/* @__PURE__ */ f("div", { className: "fr-attach-actions", children: [
|
|
628
|
+
/* @__PURE__ */ t("span", { className: "fr-attach-count", children: i === "paste" ? n("attach.count", { used: C, max: M }) : i === "browse" ? n("attach.selected", { count: N.length, max: M }) : "" }),
|
|
629
|
+
/* @__PURE__ */ t("button", { type: "button", className: "fr-attach-plain", onClick: r, children: n("attach.cancel") }),
|
|
630
|
+
i === "paste" ? /* @__PURE__ */ t(
|
|
631
|
+
"button",
|
|
632
|
+
{
|
|
633
|
+
type: "button",
|
|
634
|
+
className: "fr-attach-primary",
|
|
635
|
+
onClick: Y,
|
|
636
|
+
disabled: P.trim().length === 0,
|
|
637
|
+
children: n("attach.add")
|
|
638
|
+
}
|
|
639
|
+
) : i === "browse" ? /* @__PURE__ */ t(
|
|
640
|
+
"button",
|
|
641
|
+
{
|
|
642
|
+
type: "button",
|
|
643
|
+
className: "fr-attach-primary",
|
|
644
|
+
onClick: pe,
|
|
645
|
+
disabled: N.length === 0,
|
|
646
|
+
children: N.length > 0 ? n("attach.addCount", { count: N.length }) : n("attach.add")
|
|
647
|
+
}
|
|
648
|
+
) : null
|
|
649
|
+
] }),
|
|
650
|
+
/* @__PURE__ */ t(
|
|
651
|
+
"button",
|
|
652
|
+
{
|
|
653
|
+
type: "button",
|
|
654
|
+
className: "fr-attach-close",
|
|
655
|
+
"aria-label": n("attach.close"),
|
|
656
|
+
onClick: r,
|
|
657
|
+
children: "×"
|
|
658
|
+
}
|
|
659
|
+
)
|
|
660
|
+
]
|
|
661
|
+
}
|
|
662
|
+
)
|
|
663
|
+
}
|
|
664
|
+
)
|
|
665
|
+
);
|
|
666
|
+
}
|
|
667
|
+
const O = globalThis;
|
|
668
|
+
function re() {
|
|
669
|
+
return new Promise((a) => {
|
|
670
|
+
const e = O.document.createElement("input");
|
|
671
|
+
e.type = "file", e.multiple = !0, e.style.display = "none";
|
|
672
|
+
let r = !1;
|
|
673
|
+
const s = (o) => {
|
|
674
|
+
r || (r = !0, e.remove(), a(o));
|
|
675
|
+
};
|
|
676
|
+
e.addEventListener("change", () => s(Array.from(e.files ?? []))), e.addEventListener("cancel", () => s([])), O.addEventListener(
|
|
677
|
+
"focus",
|
|
678
|
+
() => {
|
|
679
|
+
O.setTimeout(() => s(Array.from(e.files ?? [])), 500);
|
|
680
|
+
},
|
|
681
|
+
{ once: !0 }
|
|
682
|
+
), O.document.body.appendChild(e), e.click();
|
|
683
|
+
});
|
|
684
|
+
}
|
|
685
|
+
async function Oe() {
|
|
686
|
+
const a = O.showOpenFilePicker;
|
|
687
|
+
if (typeof a == "function")
|
|
688
|
+
try {
|
|
689
|
+
const e = await a({ multiple: !0 });
|
|
690
|
+
return Promise.all(e.map((r) => r.getFile()));
|
|
691
|
+
} catch (e) {
|
|
692
|
+
return e instanceof DOMException && e.name === "AbortError" ? [] : re();
|
|
693
|
+
}
|
|
694
|
+
return re();
|
|
695
|
+
}
|
|
696
|
+
let V = !1;
|
|
697
|
+
const He = (a, e) => {
|
|
698
|
+
if (V) return;
|
|
699
|
+
V = !0;
|
|
700
|
+
const r = O.document.createElement("div");
|
|
701
|
+
O.document.body.appendChild(r);
|
|
702
|
+
const s = ge(r), o = () => {
|
|
703
|
+
s.unmount(), r.remove(), V = !1;
|
|
704
|
+
};
|
|
705
|
+
s.render(/* @__PURE__ */ t(Se, { port: a, host: e, onClose: o, pickFiles: Oe }));
|
|
706
|
+
}, je = (a, e, r) => {
|
|
707
|
+
he(a, e, r);
|
|
708
|
+
}, ce = 40;
|
|
709
|
+
async function ue(a) {
|
|
710
|
+
try {
|
|
711
|
+
const e = new Image();
|
|
712
|
+
e.decoding = "async";
|
|
713
|
+
const r = new Promise((h, w) => {
|
|
714
|
+
e.onload = () => h(), e.onerror = () => w(new Error("image decode failed"));
|
|
715
|
+
});
|
|
716
|
+
e.src = a, await r;
|
|
717
|
+
const s = e.naturalWidth, o = e.naturalHeight;
|
|
718
|
+
if (s === 0 || o === 0) return;
|
|
719
|
+
const n = Math.min(ce / s, ce / o, 1), u = Math.max(1, Math.round(s * n)), i = Math.max(1, Math.round(o * n)), l = document.createElement("canvas");
|
|
720
|
+
l.width = u, l.height = i;
|
|
721
|
+
const d = l.getContext("2d");
|
|
722
|
+
return d === null ? void 0 : (d.drawImage(e, 0, 0, u, i), l.toDataURL("image/webp", 0.8));
|
|
723
|
+
} catch {
|
|
724
|
+
return;
|
|
725
|
+
}
|
|
726
|
+
}
|
|
727
|
+
function Re(a) {
|
|
728
|
+
const [e, r] = v(() => a.theme.get());
|
|
729
|
+
return T(() => a.theme.subscribe(r), [a]), e.lang;
|
|
730
|
+
}
|
|
731
|
+
function Ue({ name: a, target: e, data: r, onRemove: s, port: o, host: n }) {
|
|
732
|
+
const u = Re(n), i = Z(() => G(u), [u]), l = r, d = e === "", [h, w] = v(null), [b, L] = v(void 0);
|
|
733
|
+
T(() => {
|
|
734
|
+
if (d) return;
|
|
735
|
+
let g = !0;
|
|
736
|
+
return (o !== void 0 ? o.preview(e) : n.attachments.preview(e)).then((C) => {
|
|
737
|
+
g && (w(C), C.status === "ok" && C.dataUrl !== void 0 && F(e) === "image" && ue(C.dataUrl).then((S) => {
|
|
738
|
+
g && L(S);
|
|
739
|
+
}));
|
|
740
|
+
}).catch(() => {
|
|
741
|
+
g && w({ status: "denied" });
|
|
742
|
+
}), () => {
|
|
743
|
+
g = !1;
|
|
744
|
+
};
|
|
745
|
+
}, [d, e, o, n]);
|
|
746
|
+
const y = d ? l?.name ?? a : a || j(e), m = F(d ? l?.name ?? "" : e), x = h?.status === "gone", N = h?.staging === !0, U = () => {
|
|
747
|
+
if (o !== void 0 && !d) {
|
|
748
|
+
const g = o.refs().findIndex((A) => A.path === e);
|
|
749
|
+
g >= 0 && o.removeRef(g);
|
|
750
|
+
}
|
|
751
|
+
s();
|
|
752
|
+
}, P = !d && !x && m === "image" && o !== void 0 && typeof o.updateRef == "function", D = P ? o.refs().findIndex((g) => g.path === e) : -1, I = D >= 0 && o?.refs()[D]?.inline === !0, z = () => {
|
|
753
|
+
if (o === void 0) return;
|
|
754
|
+
const g = o.refs().findIndex((C) => C.path === e);
|
|
755
|
+
if (g < 0) return;
|
|
756
|
+
const A = o.refs()[g]?.inline === !0;
|
|
757
|
+
o.updateRef(g, { inline: !A });
|
|
758
|
+
}, B = () => {
|
|
759
|
+
n.attachments.openPreview(e).catch(() => {
|
|
760
|
+
n.toast({ kind: "error", text: i("card.preview-failed") });
|
|
761
|
+
});
|
|
762
|
+
};
|
|
763
|
+
if (d && l?.status === "error")
|
|
764
|
+
return /* @__PURE__ */ f("span", { className: "file-ref-card is-error", title: l.error ?? i("card.failed"), children: [
|
|
765
|
+
/* @__PURE__ */ t("span", { className: "file-ref-icon", children: /* @__PURE__ */ t(W, { kind: m, size: 12 }) }),
|
|
766
|
+
/* @__PURE__ */ t("span", { className: "file-ref-name", children: y }),
|
|
767
|
+
/* @__PURE__ */ t("span", { className: "file-ref-badge is-expired", children: i("card.failed") }),
|
|
768
|
+
l.retry !== void 0 && /* @__PURE__ */ t("button", { type: "button", className: "file-ref-action", onClick: l.retry, children: i("card.retry") }),
|
|
769
|
+
/* @__PURE__ */ t(
|
|
770
|
+
"button",
|
|
771
|
+
{
|
|
772
|
+
type: "button",
|
|
773
|
+
className: "file-ref-remove",
|
|
774
|
+
"aria-label": i("card.remove", { name: y }),
|
|
775
|
+
onClick: s,
|
|
776
|
+
children: /* @__PURE__ */ t(ae, {})
|
|
777
|
+
}
|
|
778
|
+
)
|
|
779
|
+
] });
|
|
780
|
+
if (d)
|
|
781
|
+
return /* @__PURE__ */ f("span", { className: "file-ref-card is-uploading", title: i("card.uploading"), children: [
|
|
782
|
+
/* @__PURE__ */ t("span", { className: "file-ref-icon is-spin", "aria-hidden": "true", children: /* @__PURE__ */ t(W, { kind: m, size: 12 }) }),
|
|
783
|
+
/* @__PURE__ */ t("span", { className: "file-ref-name", children: y }),
|
|
784
|
+
/* @__PURE__ */ t("span", { className: "file-ref-badge", children: i("card.uploading") })
|
|
785
|
+
] });
|
|
786
|
+
const _ = /* @__PURE__ */ f(oe, { children: [
|
|
787
|
+
b !== void 0 && !x ? /* @__PURE__ */ t("img", { className: "file-ref-thumb", src: b, alt: "", width: 12, height: 12 }) : /* @__PURE__ */ t("span", { className: "file-ref-icon", children: /* @__PURE__ */ t(W, { kind: m, size: 12 }) }),
|
|
788
|
+
/* @__PURE__ */ t("span", { className: "file-ref-name", children: y }),
|
|
789
|
+
x ? /* @__PURE__ */ t("span", { className: "file-ref-badge is-expired", children: i("card.expired") }) : N && /* @__PURE__ */ t("span", { className: "file-ref-badge is-temp", children: i("card.temporary") })
|
|
790
|
+
] });
|
|
791
|
+
return /* @__PURE__ */ f(
|
|
792
|
+
"span",
|
|
793
|
+
{
|
|
794
|
+
className: `file-ref-card${x ? " is-expired" : ""}`,
|
|
795
|
+
title: e,
|
|
796
|
+
"data-kind": m,
|
|
797
|
+
children: [
|
|
798
|
+
(m === "image" || ke(e)) && !x ? /* @__PURE__ */ t(
|
|
799
|
+
"button",
|
|
800
|
+
{
|
|
801
|
+
type: "button",
|
|
802
|
+
className: "file-ref-body",
|
|
803
|
+
onClick: B,
|
|
804
|
+
"aria-label": i("card.preview", { name: y }),
|
|
805
|
+
children: _
|
|
806
|
+
}
|
|
807
|
+
) : _,
|
|
808
|
+
P && /* @__PURE__ */ t(
|
|
809
|
+
"button",
|
|
810
|
+
{
|
|
811
|
+
type: "button",
|
|
812
|
+
role: "switch",
|
|
813
|
+
"aria-checked": I,
|
|
814
|
+
className: `file-ref-inline${I ? " is-on" : ""}`,
|
|
815
|
+
"aria-label": i("card.inline", { name: y }),
|
|
816
|
+
title: i("card.inline", { name: y }),
|
|
817
|
+
onClick: z,
|
|
818
|
+
children: /* @__PURE__ */ t("span", { className: "file-ref-inline-track", "aria-hidden": "true", children: /* @__PURE__ */ t("span", { className: "file-ref-inline-knob" }) })
|
|
819
|
+
}
|
|
820
|
+
),
|
|
821
|
+
/* @__PURE__ */ t(
|
|
822
|
+
"button",
|
|
823
|
+
{
|
|
824
|
+
type: "button",
|
|
825
|
+
className: "file-ref-remove",
|
|
826
|
+
"aria-label": i("card.remove", { name: y }),
|
|
827
|
+
title: i("card.remove", { name: y }),
|
|
828
|
+
onClick: U,
|
|
829
|
+
children: /* @__PURE__ */ t(ae, {})
|
|
830
|
+
}
|
|
831
|
+
)
|
|
832
|
+
]
|
|
833
|
+
}
|
|
834
|
+
);
|
|
835
|
+
}
|
|
836
|
+
const ie = "vessel-ref:";
|
|
837
|
+
function $e(a) {
|
|
838
|
+
const [e, r] = v(() => a.theme.get());
|
|
839
|
+
return T(() => a.theme.subscribe(r), [a]), e.lang;
|
|
840
|
+
}
|
|
841
|
+
function Be({ href: a, text: e, host: r }) {
|
|
842
|
+
const s = $e(r), o = Z(() => G(s), [s]), n = a.startsWith(ie) ? a.slice(ie.length) : a, [u, i] = v(null), [l, d] = v(void 0), h = F(n), w = e || j(n);
|
|
843
|
+
T(() => {
|
|
844
|
+
let m = !0;
|
|
845
|
+
return r.attachments.preview(n).then((x) => {
|
|
846
|
+
m && (i(x), x.status === "ok" && x.dataUrl !== void 0 && F(n) === "image" && ue(x.dataUrl).then((N) => {
|
|
847
|
+
m && d(N);
|
|
848
|
+
}));
|
|
849
|
+
}).catch(() => {
|
|
850
|
+
m && i({ status: "denied" });
|
|
851
|
+
}), () => {
|
|
852
|
+
m = !1;
|
|
853
|
+
};
|
|
854
|
+
}, [n, r]);
|
|
855
|
+
const b = u?.status === "gone", L = u?.staging === !0, y = () => {
|
|
856
|
+
navigator.clipboard.writeText(n).then(() => r.toast({ kind: "success", text: o("card.path-copied") })).catch(() => r.toast({ kind: "error", text: o("card.copy-path") }));
|
|
857
|
+
};
|
|
858
|
+
return /* @__PURE__ */ f(
|
|
859
|
+
"button",
|
|
860
|
+
{
|
|
861
|
+
type: "button",
|
|
862
|
+
className: `file-ref-link${b ? " is-expired" : ""}`,
|
|
863
|
+
title: n,
|
|
864
|
+
"aria-label": `${w} — ${o("card.copy-path")}`,
|
|
865
|
+
onClick: y,
|
|
866
|
+
children: [
|
|
867
|
+
l !== void 0 && !b ? /* @__PURE__ */ t("img", { className: "file-ref-thumb", src: l, alt: "", width: 36, height: 36 }) : /* @__PURE__ */ t("span", { className: "file-ref-icon", children: /* @__PURE__ */ t(W, { kind: h }) }),
|
|
868
|
+
/* @__PURE__ */ t("span", { className: "file-ref-name", children: w }),
|
|
869
|
+
b ? /* @__PURE__ */ t("span", { className: "file-ref-badge is-expired", children: o("card.expired") }) : L && /* @__PURE__ */ t("span", { className: "file-ref-badge is-temp", children: o("card.temporary") })
|
|
870
|
+
]
|
|
871
|
+
}
|
|
872
|
+
);
|
|
873
|
+
}
|
|
874
|
+
export {
|
|
875
|
+
Ue as FileRefCard,
|
|
876
|
+
Be as FileRefLinkCard,
|
|
877
|
+
He as onAttachClick,
|
|
878
|
+
je as onFilesDropped
|
|
879
|
+
};
|