most-box 0.1.9 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (157) hide show
  1. package/README.md +16 -3
  2. package/out/admin/index.html +0 -0
  3. package/out/app/index.html +0 -0
  4. package/out/assets/AppShell-CQhg6DJU.js +1 -0
  5. package/out/assets/ChatUi-BepWs-ZU.js +1 -0
  6. package/out/assets/LanguageToggle-CtzCCAYv.js +1 -0
  7. package/out/assets/{LogoIcon-CYQ7cHd5.js → LogoIcon-Dxto3Sb4.js} +1 -1
  8. package/out/assets/{MarketingLayout-BTIbv4fW.js → MarketingLayout-BQw0IS2i.js} +1 -1
  9. package/out/assets/MarketingThemeToggle-DBaC9bjz.js +1 -0
  10. package/out/assets/MilkdownEditor-BqJzntYE.js +1054 -0
  11. package/out/assets/MoveModal-4D9n11Kw.js +1 -0
  12. package/out/assets/Nav-9MDdvgNs.js +1 -0
  13. package/out/assets/NoteSidebar-C-rIt32H.js +1 -0
  14. package/out/assets/OpenSidebarButton-Dd0JmKuE.js +1 -0
  15. package/out/assets/PemBlock-C8dEIzu-.js +1 -0
  16. package/out/assets/SidebarAccount-ClS-N0lq.js +1 -0
  17. package/out/assets/arrow-right-urE9Rd7j.js +1 -0
  18. package/out/assets/channelApi-BwQU0-h1.js +1 -0
  19. package/out/assets/check-DUNsD2t6.js +1 -0
  20. package/out/assets/chevron-down-D6mpsfv4.js +1 -0
  21. package/out/assets/{circle-alert-CqEQz6P4.js → circle-alert-W0iyN4sC.js} +1 -1
  22. package/out/assets/cloud-BMyOoC2x.js +1 -0
  23. package/out/assets/code-B1Cb_Icm.js +1 -0
  24. package/out/assets/{copy-CM-qWlbv.js → copy-C1MttOli.js} +1 -1
  25. package/out/assets/{dist-CvatM4u8.js → dist-8QDHqrPN.js} +1 -1
  26. package/out/assets/{dist-BmtYO1GG.js → dist-B0JrbG7f.js} +5 -5
  27. package/out/assets/{dist-DBpw-A8y.js → dist-BFSyuOuw.js} +1 -1
  28. package/out/assets/{dist-D5Cf0hK8.js → dist-BPs0Xns9.js} +2 -2
  29. package/out/assets/{dist-BQV5zYG_.js → dist-Br_5lLVO.js} +9 -9
  30. package/out/assets/{dist-CrzjJUOw.js → dist-BzqqCPi2.js} +1 -1
  31. package/out/assets/dist-C3lbe8SW.js +9 -0
  32. package/out/assets/{dist-CWJ3323z.js → dist-CfU9fwWz.js} +1 -1
  33. package/out/assets/{dist-BdmTLuCI.js → dist-DCX0ws1K.js} +1 -1
  34. package/out/assets/{dist-DrumcFOX.js → dist-DJdv-Ma3.js} +1 -1
  35. package/out/assets/{dist-C5HibLEW.js → dist-chOCTzB2.js} +1 -1
  36. package/out/assets/{download-0rM8xVCe.js → download-y7SZXu6E.js} +1 -1
  37. package/out/assets/downloadValidation-B0p9Ai_9.js +1 -0
  38. package/out/assets/filePreview-UI9NH34f.js +1 -0
  39. package/out/assets/format-CR8oUWq6.js +1 -0
  40. package/out/assets/game-CdU3xnZo.js +1 -0
  41. package/out/assets/{hard-drive-CCdIvSap.js → hard-drive-D13Qbobu.js} +1 -1
  42. package/out/assets/image-DJCA16l_.js +1 -0
  43. package/out/assets/index-BdaFEQG-.css +1 -0
  44. package/out/assets/index-QxXZzOUL.js +33 -0
  45. package/out/assets/index.lazy-BBTTFanX.js +1 -0
  46. package/out/assets/index.lazy-BG4ZylHD.js +2 -0
  47. package/out/assets/index.lazy-Bi-6ZXZX.js +1 -0
  48. package/out/assets/index.lazy-BixWVr0B.js +1 -0
  49. package/out/assets/index.lazy-BjFwNYy5.js +3 -0
  50. package/out/assets/index.lazy-C8EIQsXY.js +2 -0
  51. package/out/assets/index.lazy-CarNe2uu.js +1 -0
  52. package/out/assets/index.lazy-DEuGu3H3.js +1 -0
  53. package/out/assets/index.lazy-GPyILCA7.js +3 -0
  54. package/out/assets/index.lazy-I8ofndXl.js +1 -0
  55. package/out/assets/index.lazy-TxhWsA7y.js +1 -0
  56. package/out/assets/index.lazy-azfky8k7.js +1 -0
  57. package/out/assets/{key-round-tIqGrtt_.js → key-round-CZniN9lv.js} +1 -1
  58. package/out/assets/lock-D5OSNhep.js +1 -0
  59. package/out/assets/log-out-B6phyZ5z.js +1 -0
  60. package/out/assets/{music-BkZKq879.js → music-CbUskKgg.js} +1 -1
  61. package/out/assets/{notebook-pen-B4VSbweh.js → notebook-pen-DqKDQ6MJ.js} +1 -1
  62. package/out/assets/play-BIl8q9eU.js +1 -0
  63. package/out/assets/plus-BxxbpH6Q.js +1 -0
  64. package/out/assets/{save-BzjzC3eV.js → save-DkH1n_Ov.js} +1 -1
  65. package/out/assets/search-BQi5Z0E-.js +1 -0
  66. package/out/assets/{send-DtQInX0y.js → send-Cl6NtD2T.js} +1 -1
  67. package/out/assets/{trash-2-BhMrUgGM.js → trash-2-BBjpgK_f.js} +1 -1
  68. package/out/assets/triangle-alert-l98G8u9O.js +1 -0
  69. package/out/assets/upload-ByP6Ydde.js +1 -0
  70. package/out/assets/{useChannelMessages-Bs1hEJyd.js → useChannelMessages-BgbYfF2c.js} +2 -2
  71. package/out/assets/useGameRoom-DPmweWwe.js +1 -0
  72. package/out/assets/{wallet-YxbxCi7C.js → wallet-c7zIhNSM.js} +1 -1
  73. package/out/assets/{wifi-v3JpPCNm.js → wifi-Bm4biAjc.js} +1 -1
  74. package/out/chat/index.html +0 -0
  75. package/out/chat/join/index.html +0 -0
  76. package/out/demo/index.html +0 -0
  77. package/out/download/index.html +6 -2
  78. package/out/game/gandengyan/index.html +0 -0
  79. package/out/game/index.html +0 -0
  80. package/out/game/zhajinhua/index.html +0 -0
  81. package/out/index.html +6 -2
  82. package/out/note/index.html +0 -0
  83. package/out/ping/index.html +6 -2
  84. package/out/web3/index.html +0 -0
  85. package/package.json +2 -2
  86. package/server/index.js +9 -0
  87. package/server/src/core/channelAttachment.js +7 -3
  88. package/server/src/core/channelIdentity.js +50 -0
  89. package/server/src/core/cid.js +6 -1
  90. package/server/src/core/cidTopic.js +18 -4
  91. package/server/src/core/displayPath.js +10 -0
  92. package/server/src/core/gameRoom.js +2 -2
  93. package/server/src/core/mostLink.js +45 -25
  94. package/server/src/core/ownerMetadata.js +34 -0
  95. package/server/src/core/userSyncKeys.js +36 -0
  96. package/server/src/http/app.js +71 -149
  97. package/server/src/http/dataPath.js +26 -0
  98. package/server/src/http/errors.js +8 -4
  99. package/server/src/http/nodeStatus.js +13 -13
  100. package/server/src/http/rateLimit.js +39 -0
  101. package/server/src/http/routePolicy.js +43 -0
  102. package/server/src/index.js +1909 -759
  103. package/server/src/node/offlineSwarm.js +20 -0
  104. package/server/src/utils/api.js +1 -15
  105. package/server/src/utils/downloadMessages.js +17 -18
  106. package/server/src/utils/errors.js +3 -1
  107. package/server/src/utils/noteUtils.js +27 -3
  108. package/out/assets/AppShell-DmZQwVA9.js +0 -1
  109. package/out/assets/ChatUi-CVGqjFdx.js +0 -1
  110. package/out/assets/MilkdownEditor-BL8xE7u9.js +0 -1054
  111. package/out/assets/MoveModal-BKkVBvrS.js +0 -1
  112. package/out/assets/Nav-BDGeJnbC.js +0 -1
  113. package/out/assets/NoteSidebar-BIJ8_m5K.js +0 -1
  114. package/out/assets/OpenSidebarButton-Di62DGiu.js +0 -1
  115. package/out/assets/PemBlock-Dxx6k9MH.js +0 -1
  116. package/out/assets/SidebarAccount-CCHZLGdP.js +0 -1
  117. package/out/assets/admin-BepWGXWG.js +0 -2
  118. package/out/assets/app-3D79fY3w.js +0 -1
  119. package/out/assets/arrow-right-D0sGC8QA.js +0 -1
  120. package/out/assets/channelApi-CL7YsIQ-.js +0 -1
  121. package/out/assets/chat-B56sk6od.js +0 -1
  122. package/out/assets/check-DdfnsLKm.js +0 -1
  123. package/out/assets/chevron-down-Xlb3wTxd.js +0 -1
  124. package/out/assets/circle-check-CwAH4dgJ.js +0 -1
  125. package/out/assets/cloud-CcPRoob1.js +0 -1
  126. package/out/assets/code-Dr6STnCn.js +0 -1
  127. package/out/assets/database-DQ7ZtUT9.js +0 -1
  128. package/out/assets/dateTime-D1koKRQU.js +0 -1
  129. package/out/assets/demo-B_6rlIjn.js +0 -3
  130. package/out/assets/dist-BGtXa07s.js +0 -9
  131. package/out/assets/download-BLPU-Kzq.js +0 -1
  132. package/out/assets/downloadMessages-7Xbd-HhS.js +0 -1
  133. package/out/assets/ed25519-BEctXF0E.js +0 -1
  134. package/out/assets/filePreview-BvbHWUTG.js +0 -1
  135. package/out/assets/folder-CcbCxm-k.js +0 -1
  136. package/out/assets/game-B0zuqnOh.js +0 -1
  137. package/out/assets/gandengyan-DbQC7hCK.js +0 -1
  138. package/out/assets/index-BLhmAher.css +0 -1
  139. package/out/assets/index-Cf23WD2V.js +0 -29
  140. package/out/assets/join-DQHXjlfH.js +0 -1
  141. package/out/assets/note-DmWqGSS2.js +0 -2
  142. package/out/assets/ping-JILckfMu.js +0 -1
  143. package/out/assets/play-BIl5vwqS.js +0 -1
  144. package/out/assets/plus-DHvLpuuw.js +0 -1
  145. package/out/assets/routes-Dyckj88f.js +0 -1
  146. package/out/assets/search-C-EpsDNl.js +0 -1
  147. package/out/assets/sun-C3IUQTpa.js +0 -1
  148. package/out/assets/tools-BEctXF0E.js +0 -1
  149. package/out/assets/triangle-alert-DUODU79n.js +0 -1
  150. package/out/assets/upload-CpDM23UH.js +0 -1
  151. package/out/assets/useGameRoom-C6UgmIGG.js +0 -1
  152. package/out/assets/web3-CRX1YFmw.js +0 -3
  153. package/out/assets/zhajinhua-QDmSZbOp.js +0 -1
  154. package/out/web3/ed25519/index.html +0 -0
  155. package/out/web3/tools/index.html +0 -0
  156. /package/out/assets/{gandengyan-8eWJAjpY.css → index-8eWJAjpY.css} +0 -0
  157. /package/out/assets/{zhajinhua-BZc4blbW.css → index-BZc4blbW.css} +0 -0
@@ -0,0 +1,20 @@
1
+ import crypto from 'node:crypto'
2
+
3
+ export function createOfflineSwarm() {
4
+ return {
5
+ connections: new Set(),
6
+ keyPair: {
7
+ publicKey: crypto.randomBytes(32),
8
+ },
9
+ on() {},
10
+ join() {
11
+ return {}
12
+ },
13
+ leave() {
14
+ return Promise.resolve()
15
+ },
16
+ destroy() {
17
+ return Promise.resolve()
18
+ },
19
+ }
20
+ }
@@ -130,7 +130,7 @@ function createApiInstance() {
130
130
  headers.set(key, value)
131
131
  }
132
132
  } catch {
133
- // Ignore invalid legacy identity data for public/backend probes.
133
+ // Keep public/backend probes usable when stored identity data is invalid.
134
134
  }
135
135
  }
136
136
  return new Request(request, { headers })
@@ -410,20 +410,6 @@ export async function checkBackendConnectionTarget({ url, invite = '' }) {
410
410
  return { ok: true }
411
411
  }
412
412
 
413
- export async function detectSameOriginBackend() {
414
- if (isLocalFrontendOrigin()) return false
415
-
416
- try {
417
- const res = await fetch('/api/node-id', {
418
- method: 'GET',
419
- signal: AbortSignal.timeout(2000),
420
- })
421
- return res.ok
422
- } catch {
423
- return false
424
- }
425
- }
426
-
427
413
  export async function detectLocalhostBackend() {
428
414
  try {
429
415
  const res = await fetch(`${LOCALHOST_BACKEND_URL}/api/node-id`, {
@@ -1,4 +1,4 @@
1
- import { parseMostLink } from '../core/mostLink.js'
1
+ import { MOST_LINK_ERROR_CODES, parseMostLink } from '../core/mostLink.js'
2
2
 
3
3
  const DOWNLOAD_CHECK_MESSAGES = {
4
4
  timeout:
@@ -17,17 +17,21 @@ const DOWNLOAD_CHECK_MESSAGES = {
17
17
  }
18
18
 
19
19
  const LINK_VALIDATION_MESSAGES = {
20
- 'Link must be a valid most:// URL':
20
+ [MOST_LINK_ERROR_CODES.INVALID_URL]:
21
21
  '链接无法解析,请粘贴完整的 most://<cid>?filename=... 分享链接。',
22
- 'Link must use most:// protocol': '链接协议不正确,应以 most:// 开头。',
23
- 'Link path is not supported':
22
+ [MOST_LINK_ERROR_CODES.INVALID_PROTOCOL]:
23
+ '链接协议不正确,应以 most:// 开头。',
24
+ [MOST_LINK_ERROR_CODES.UNSUPPORTED_PATH]:
24
25
  '链接里不应包含路径,请使用 most://<cid>?filename=... 格式。',
25
- 'Invalid CID format': 'CID 无效,请确认 most:// 后面的内容没有缺失或被截断。',
26
- 'Invalid CID format: CID v1 required':
26
+ [MOST_LINK_ERROR_CODES.CID_EMPTY]:
27
+ 'CID 无效,请确认 most:// 后面的内容没有缺失或被截断。',
28
+ [MOST_LINK_ERROR_CODES.INVALID_CID_FORMAT]:
29
+ 'CID 无效,请确认 most:// 后面的内容没有缺失或被截断。',
30
+ [MOST_LINK_ERROR_CODES.CID_V1_REQUIRED]:
27
31
  'CID 格式不符合 MostBox 要求,请确认分享链接完整。',
28
- 'CID digest must be 32 bytes':
32
+ [MOST_LINK_ERROR_CODES.CID_DIGEST_LENGTH]:
29
33
  'CID 格式不符合 MostBox 要求,请确认分享链接完整。',
30
- 'filename is required':
34
+ [MOST_LINK_ERROR_CODES.FILENAME_REQUIRED]:
31
35
  '链接缺少 filename 参数,请复制完整分享链接后再检测。',
32
36
  }
33
37
 
@@ -70,20 +74,15 @@ export function getDownloadLinkValidationMessage(link = '') {
70
74
  if (!value) return '请先粘贴 most:// 分享链接。'
71
75
 
72
76
  const result = parseMostLink(value)
73
- if (!result.error) {
74
- return result.fileName?.trim()
75
- ? null
76
- : LINK_VALIDATION_MESSAGES['filename is required']
77
- }
77
+ if (!result.errorCode) return null
78
78
 
79
- if (result.error.startsWith('Unsupported query parameter: ')) {
80
- const unsupportedParam = result.error.slice(
81
- 'Unsupported query parameter: '.length
82
- )
79
+ if (result.errorCode === MOST_LINK_ERROR_CODES.UNSUPPORTED_QUERY_PARAM) {
80
+ const unsupportedParam = result.details?.param || ''
83
81
  return `链接包含暂不支持的参数 ${unsupportedParam},请只保留 filename。`
84
82
  }
85
83
 
86
84
  return (
87
- LINK_VALIDATION_MESSAGES[result.error] || DOWNLOAD_CHECK_MESSAGES.validation
85
+ LINK_VALIDATION_MESSAGES[result.errorCode] ||
86
+ DOWNLOAD_CHECK_MESSAGES.validation
88
87
  )
89
88
  }
@@ -12,9 +12,11 @@ export class AppError extends Error {
12
12
  }
13
13
 
14
14
  export class ValidationError extends AppError {
15
- constructor(message) {
15
+ constructor(message, errorCode = '', details = undefined) {
16
16
  super(message, 'VALIDATION_ERROR')
17
17
  this.name = 'ValidationError'
18
+ if (errorCode) this.errorCode = errorCode
19
+ if (details) this.details = details
18
20
  }
19
21
  }
20
22
 
@@ -18,11 +18,35 @@ export function getNoteFullPath(note) {
18
18
  return path ? `${path}/${name}` : name
19
19
  }
20
20
 
21
+ export const NOTE_NAME_ERROR_CODES = {
22
+ EMPTY: 'empty',
23
+ SLASH: 'slash',
24
+ BACKSLASH: 'backslash',
25
+ }
26
+
21
27
  export function validateNoteName(name) {
22
28
  const value = String(name || '').trim()
23
- if (!value) return { valid: false, error: '请输入名称' }
24
- if (value.includes('/')) return { valid: false, error: '名称不能包含 /' }
25
- if (value.includes('\\')) return { valid: false, error: '名称不能包含 \\' }
29
+ if (!value) {
30
+ return {
31
+ valid: false,
32
+ errorCode: NOTE_NAME_ERROR_CODES.EMPTY,
33
+ error: 'Name is required',
34
+ }
35
+ }
36
+ if (value.includes('/')) {
37
+ return {
38
+ valid: false,
39
+ errorCode: NOTE_NAME_ERROR_CODES.SLASH,
40
+ error: 'Name cannot contain /',
41
+ }
42
+ }
43
+ if (value.includes('\\')) {
44
+ return {
45
+ valid: false,
46
+ errorCode: NOTE_NAME_ERROR_CODES.BACKSLASH,
47
+ error: 'Name cannot contain \\',
48
+ }
49
+ }
26
50
  return { valid: true, name: value }
27
51
  }
28
52
 
@@ -1 +0,0 @@
1
- import{n as e,o as t,t as n}from"./jsx-runtime-Bt-cYkS5.js";import{W as r}from"./index-Cf23WD2V.js";var i=r(`menu`,[[`path`,{d:`M4 5h16`,key:`1tepv9`}],[`path`,{d:`M4 12h16`,key:`1lakjw`}],[`path`,{d:`M4 19h16`,key:`1djgab`}]]),a=t(e(),1);function o(e,t){return typeof t==`boolean`?t:typeof window<`u`&&`matchMedia`in window?window.matchMedia(e).matches:!1}function s(e,t,{getInitialValueInEffect:n}={getInitialValueInEffect:!0}){let[r,i]=(0,a.useState)(n?t:o(e));return(0,a.useEffect)(()=>{try{if(`matchMedia`in window){let t=window.matchMedia(e);i(t.matches);let n=e=>i(e.matches);return t.addEventListener(`change`,n),()=>{t.removeEventListener(`change`,n)}}}catch{return}},[e]),r||!1}function c(e=!1,t={}){let[n,r]=(0,a.useState)(e),i=(0,a.useCallback)(()=>{r(e=>e||(t.onOpen?.(),!0))},[t.onOpen]),o=(0,a.useCallback)(()=>{r(e=>e&&(t.onClose?.(),!1))},[t.onClose]);return[n,{open:i,close:o,toggle:(0,a.useCallback)(()=>{n?o():i()},[o,i,n]),set:r}]}var l=n(),u=(0,a.createContext)(null);function d(){let e=(0,a.useContext)(u);if(!e)throw Error(`useAppShell must be used within AppShell`);return e}function f({sidebar:e,className:t=``,headerTitle:n,headerRight:r,sidebarToggleReplacement:o,defaultHide:d=!1,children:f}){let[p,m]=c(!1),[h,g]=(0,a.useState)(d),_=(0,a.useRef)(d),v=s(`(max-width: 768px)`),y=(0,a.useCallback)((e={})=>{m.close(),e.collapse&&g(!0)},[m]);(0,a.useEffect)(()=>{d!==_.current&&(d?y({collapse:!0}):g(!1),_.current=d)},[d,y]);let b=()=>{v?m.toggle():g(!h)},x=()=>{v?m.open():g(!1)},S=v?p:!h;return(0,l.jsx)(u.Provider,{value:{closeSidebar:y,openSidebar:x,isSidebarVisible:S},children:(0,l.jsxs)(`div`,{className:[`app-layout`,t].filter(Boolean).join(` `),children:[(0,l.jsx)(`div`,{className:`sidebar-overlay ${p?`visible`:``}`,onClick:()=>y()}),(0,l.jsx)(`div`,{className:`sidebar ${p?`open`:``} ${h?`collapsed`:``}`,children:e({closeSidebar:y,openSidebar:x})}),(0,l.jsxs)(`div`,{className:`main-content`,children:[(0,l.jsxs)(`header`,{className:`app-header`,children:[(0,l.jsxs)(`div`,{className:`header-left`,children:[o??(0,l.jsx)(`button`,{onClick:b,className:`btn btn-icon sidebar-toggle-btn`,"aria-label":v?`打开菜单`:h?`展开侧边栏`:`收起侧边栏`,children:(0,l.jsx)(i,{size:16})}),n]}),(0,l.jsx)(`div`,{className:`header-right`,children:r})]}),f]})]})})}export{d as n,c as r,f as t};
@@ -1 +0,0 @@
1
- import{t as e}from"./jsx-runtime-Bt-cYkS5.js";import{t}from"./arrow-right-D0sGC8QA.js";import{t as n}from"./circle-alert-CqEQz6P4.js";import{t as r}from"./download-0rM8xVCe.js";import{n as i}from"./SidebarAccount-CCHZLGdP.js";import{n as a,t as o}from"./trash-2-BhMrUgGM.js";import{a as s,i as c,n as l,r as u}from"./filePreview-BvbHWUTG.js";import{n as d}from"./LogoIcon-CYQ7cHd5.js";import{t as f}from"./music-BkZKq879.js";import{t as p}from"./plus-DHvLpuuw.js";import{V as m,W as h,a as g}from"./index-Cf23WD2V.js";var _=h(`pin`,[[`path`,{d:`M12 17v5`,key:`bb1du9`}],[`path`,{d:`M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z`,key:`1nkz8b`}]]),v=h(`pin-off`,[[`path`,{d:`M12 17v5`,key:`bb1du9`}],[`path`,{d:`M15 9.34V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H7.89`,key:`znwnzq`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M9 9v1.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h11`,key:`c9qhm2`}]]),y=e();function b(e){return!e||e<=0?``:e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:e<1024*1024*1024?`${(e/(1024*1024)).toFixed(1)} MB`:`${(e/(1024*1024*1024)).toFixed(2)} GB`}function x(e){let t=String(e||``).split(`/`);return t[t.length-1]||e}function S(e){return e===`image`?(0,y.jsx)(c,{size:20}):e===`video`?(0,y.jsx)(s,{size:20}):e===`audio`?(0,y.jsx)(f,{size:20}):(0,y.jsx)(a,{size:20})}function C({attachment:e,status:t=`idle`,pending:i=!1,onOpen:a}){let o=t===`checking`,s=[`ui-file-action`,`chat-attachment-action`,t===`error`?`error`:``,t===`available`?`available`:``].filter(Boolean).join(` `),c=b(e.size)||`MostBox 文件`;return(0,y.jsxs)(`button`,{type:`button`,className:`ui-file-card chat-attachment-card`,onClick:()=>a?.(e),disabled:i||o,title:e.link,children:[(0,y.jsx)(`span`,{className:`ui-file-icon chat-attachment-icon ${e.kind}`,children:o?(0,y.jsx)(u,{size:20,className:`ui-spinner chat-attachment-spinner`}):S(e.kind)}),(0,y.jsxs)(`span`,{className:`ui-file-info chat-attachment-info`,children:[(0,y.jsx)(`span`,{className:`ui-file-name chat-attachment-name`,children:x(e.fileName)}),(0,y.jsx)(`span`,{className:`ui-file-meta chat-attachment-meta`,children:i?`发送中...`:c})]}),(0,y.jsx)(`span`,{className:s,children:o?`检测中`:t===`available`?(0,y.jsx)(m,{size:16}):t===`error`?(0,y.jsx)(n,{size:17}):(0,y.jsx)(r,{size:16})})]})}var w=[{key:`image`,label:`图片`,accept:`image/*`,icon:c},{key:`video`,label:`视频`,accept:`video/*`,icon:s},{key:`file`,label:`文件`,accept:``,icon:a}],T=w.map(e=>e.accept).join(`,`);function E({children:e}){return(0,y.jsx)(`div`,{className:`message-bubble`,children:e})}function D({children:e}){return(0,y.jsx)(`div`,{className:`message-bubble has-attachment`,children:e})}function O({variant:e,pending:t=!1,avatarSrc:n,author:r,time:i,children:a}){return(0,y.jsxs)(`div`,{className:[`chat-message`,e,t?`pending`:``].filter(Boolean).join(` `),children:[(0,y.jsx)(`img`,{className:`msg-avatar`,src:n,alt:`avatar`}),(0,y.jsxs)(`div`,{className:`msg-content`,children:[(0,y.jsx)(`span`,{className:`message-author`,children:r}),a,(0,y.jsx)(`span`,{className:`message-time`,children:i})]})]})}function k({active:e=!1,pinned:t=!1,unread:n=!1,title:r,onSelect:a,onTogglePin:s,onRename:c,onLeave:u}){let f=!!(s||c||u);return(0,y.jsxs)(`div`,{className:[`sidebar-nav-btn`,e?`active`:``,t?`pinned`:``,n?`unread`:``].filter(Boolean).join(` `),onClick:a,role:`button`,tabIndex:0,onKeyDown:e=>{e.target===e.currentTarget&&e.key===`Enter`&&a?.()},children:[(0,y.jsxs)(`span`,{className:`chat-channel-icon-wrap`,children:[(0,y.jsx)(d,{size:16}),n&&(0,y.jsx)(`span`,{className:`chat-channel-unread-dot`,title:`有新消息`,"aria-hidden":`true`})]}),(0,y.jsx)(`span`,{className:`chat-channel-title`,children:(0,y.jsx)(`span`,{className:`chat-channel-title-text`,children:r})}),f&&(0,y.jsx)(g,{ariaLabel:`频道操作`,className:`channel-actions-anchor`,placement:`bottom-end`,items:[{key:`pin`,label:t?`取消置顶`:`置顶`,icon:t?(0,y.jsx)(v,{size:16}):(0,y.jsx)(_,{size:16}),onSelect:()=>s?.()},{key:`rename`,label:`重命名`,icon:(0,y.jsx)(l,{size:16}),onSelect:()=>c?.()},{key:`delete`,label:`删除`,icon:(0,y.jsx)(o,{size:16}),onSelect:()=>u?.()}],renderTrigger:e=>(0,y.jsx)(`button`,{...e,className:`leave-channel-btn channel-actions-trigger`,title:`更多操作`,"aria-label":`更多操作`,children:(0,y.jsx)(i,{size:16})})})]})}function A({members:e,isLoading:t=!1}){return t&&e.length===0?(0,y.jsx)(`div`,{className:`ui-empty-inline channel-members-empty`,children:`正在读取成员...`}):e.length===0?(0,y.jsx)(`div`,{className:`ui-empty-inline channel-members-empty`,children:`暂无成员`}):(0,y.jsx)(`div`,{className:`channel-members-grid`,children:e.map(e=>(0,y.jsxs)(`div`,{className:`channel-member`,children:[(0,y.jsx)(`img`,{className:`channel-member-avatar`,src:e.avatarSrc,alt:`avatar`}),(0,y.jsx)(`span`,{className:`channel-member-name`,children:e.name})]},e.id))})}function j({message:e,placeholder:n,disabled:r=!1,isPublishingAttachment:i=!1,attachmentButtonTitle:a=`添加附件`,attachmentInputRef:o,onMessageChange:s,onSend:c,onSelectAttachmentFiles:l}){let d=r||i,f=r||!e.trim();function m(e,t){t?.(e.currentTarget.files),e.currentTarget.value=``}function h(t){t.key===`Enter`&&e.trim()&&c()}function _(e){if(d)return;let t=o?.current;t&&(t.accept=e,t.click())}return(0,y.jsxs)(`div`,{className:`chat-input-area`,children:[(0,y.jsx)(`input`,{ref:o,type:`file`,accept:T,className:`chat-file-input`,onChange:e=>m(e,l)}),(0,y.jsx)(g,{ariaLabel:`附件类型`,placement:`top-start`,disabled:d,items:w.map(e=>{let t=e.icon;return{key:e.key,label:e.label,icon:(0,y.jsx)(t,{size:16}),onSelect:()=>_(e.accept)}}),renderTrigger:e=>(0,y.jsx)(`button`,{...e,className:`btn btn-circle chat-tool-btn`,"aria-label":a,children:i?(0,y.jsx)(u,{size:18,className:`ui-spinner chat-attachment-spinner`}):(0,y.jsx)(p,{size:18})})}),(0,y.jsx)(`input`,{type:`text`,className:`input input-pill`,placeholder:n,value:e,disabled:r,onChange:e=>s(e.target.value),onKeyDown:h}),(0,y.jsx)(`button`,{type:`button`,className:`btn btn-circle btn-primary send-btn`,onClick:c,disabled:f,title:`发送消息`,children:(0,y.jsx)(t,{size:18})})]})}export{O as a,x as c,j as i,D as n,E as o,k as r,C as s,A as t};