most-box 0.3.2 → 0.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -6
- package/out/admin/index.html +0 -0
- package/out/app/index.html +0 -0
- package/out/assets/{AccountMenu-BgbcUc0m.js → AccountMenu-ptQklqvD.js} +1 -1
- package/out/assets/{AppTop-DZFTO9-m.js → AppTop-Cy0ZOCxO.js} +1 -1
- package/out/assets/{CopyButton-B03fpFFc.js → CopyButton-C8PIDSJZ.js} +1 -1
- package/out/assets/{FilePreviewOverlay-CA04_Ved.js → FilePreviewOverlay-faaTnmlN.js} +1 -1
- package/out/assets/{MarketingHeader-BVJy8hXd.js → MarketingHeader-CxJ_OVOW.js} +1 -1
- package/out/assets/MarketingLayout-CiN5KYcE.js +1 -0
- package/out/assets/{MilkdownEditor-Dw_ze7EE.js → MilkdownEditor-BzbYt-xb.js} +1 -1
- package/out/assets/{OpenSidebarButton-C2UJYXKh.js → OpenSidebarButton-CGhXxQ5Z.js} +1 -1
- package/out/assets/arrow-up-down-B-677ip8.js +1 -0
- package/out/assets/{chatJoinInvite-BcPz_IV5.js → chatJoinInvite-B-ucvYdg.js} +1 -1
- package/out/assets/chevron-right-D75NRNNs.js +1 -0
- package/out/assets/downloadValidation-UPgpJbKz.js +1 -0
- package/out/assets/folder-BS_GbpPQ.js +1 -0
- package/out/assets/index-D0Uk9-58.js +31 -0
- package/out/assets/index-FV6RZlVI.css +1 -0
- package/out/assets/{index.lazy-Cd0znkpY.js → index.lazy-B6XDJ8fg.js} +1 -1
- package/out/assets/{index.lazy-CtUrBLS0.js → index.lazy-BFdWbm3R.js} +1 -1
- package/out/assets/{index.lazy-Bdh8QUOx.js → index.lazy-BzIt7fP4.js} +1 -1
- package/out/assets/index.lazy-CLkb32nv.js +1 -0
- package/out/assets/{index.lazy-CNQbNKyf.js → index.lazy-CNmqW4-r.js} +1 -1
- package/out/assets/index.lazy-Cnkj-gAd.js +3 -0
- package/out/assets/index.lazy-Cx1bp84f.js +5 -0
- package/out/assets/index.lazy-CxLzR674.js +2 -0
- package/out/assets/{index.lazy-C9-w4fAF.js → index.lazy-D4RjTGu-.js} +1 -1
- package/out/assets/{index.lazy-BfAHB94y.js → index.lazy-D9xLqvqW.js} +1 -1
- package/out/assets/{index.lazy-BUODxlbz.js → index.lazy-DNCF6MTJ.js} +1 -1
- package/out/assets/index.lazy-MY-mUG5Z.js +1 -0
- package/out/assets/index.lazy-erUKA2rI.js +1 -0
- package/out/assets/index.lazy-qTjgLKhY.js +1 -0
- package/out/assets/notebook-pen-BzrCXQJE.js +1 -0
- package/out/assets/{useGameRoom-B1_r6bc7.js → useGameRoom-CS1w4IqP.js} +1 -1
- package/out/chat/index.html +0 -0
- package/out/chat/join/demo/index.html +0 -0
- package/out/chat/join/index.html +0 -0
- package/out/download/index.html +2 -2
- package/out/game/gandengyan/index.html +0 -0
- package/out/game/index.html +0 -0
- package/out/game/zhajinhua/index.html +0 -0
- package/out/index.html +2 -2
- package/out/note/index.html +0 -0
- package/out/ping/index.html +2 -2
- package/out/profile/index.html +0 -0
- package/out/web3/index.html +0 -0
- package/package.json +4 -3
- package/server/src/core/channelAttachment.js +2 -2
- package/server/src/core/releaseManifest.js +10 -3
- package/server/src/index.js +8 -8
- package/out/assets/MarketingLayout-Cltu-DRw.js +0 -1
- package/out/assets/downloadValidation-Zvllo2SZ.js +0 -1
- package/out/assets/folder-DAcox9xz.js +0 -1
- package/out/assets/folder-open-Di0oALaC.js +0 -1
- package/out/assets/index-B6acG3-t.css +0 -1
- package/out/assets/index-DjBN7bZV.js +0 -31
- package/out/assets/index.lazy-Ba2rqd32.js +0 -3
- package/out/assets/index.lazy-Bo0LfJNK.js +0 -2
- package/out/assets/index.lazy-CyNgk0ta.js +0 -1
- package/out/assets/index.lazy-D3HxQTg_.js +0 -1
- package/out/assets/index.lazy-DSsE3iyf.js +0 -1
- package/out/assets/index.lazy-DWXndrGa.js +0 -1
- package/out/assets/index.lazy-Dk7cmQ-j.js +0 -2
- package/out/assets/notebook-pen-SWT-zZ4v.js +0 -1
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{n as e,o as t,t as n}from"./jsx-runtime-Bt-cYkS5.js";import{B as r,E as i,H as a,n as o,o as s,t as c}from"./useAppStore-DOnk608w.js";import{t as l}from"./circle-alert-dfN4T6Nq.js";import{a as u,o as d,r as ee,t as te}from"./chatNoteDraft-CYbvcEvC.js";import{t as ne}from"./OpenSidebarButton-C2UJYXKh.js";import{a as re,i as f,n as ie,r as p,t as ae}from"./FilePreviewOverlay-CA04_Ved.js";import{t as m}from"./arrow-right-CXzRt0Fp.js";import{t as h}from"./download-COQOcPqI.js";import{t as oe}from"./external-link-D6tHlYgS.js";import{t as g}from"./file-text-DiyIGL1I.js";import{t as se}from"./loader-CwyHYZdX.js";import{i as ce,n as le,t as ue}from"./AppTop-DZFTO9-m.js";import{t as de}from"./message-square-BgsNXPft.js";import{t as fe}from"./music-Dn9nm9Qb.js";import{t as pe}from"./notebook-pen-SWT-zZ4v.js";import{t as me}from"./search-HW4oPOBP.js";import{t as _}from"./trash-2-BLwoM0ME.js";import{A as v,S as he,_ as ge,f as _e,g as ve,v as ye,w as be,y as xe}from"./index-DjBN7bZV.js";import{t as Se}from"./format-CR8oUWq6.js";import{n as Ce,r as we,t as Te}from"./downloadValidation-Zvllo2SZ.js";import{t as Ee}from"./LogoIcon-B2fFe0l1.js";import{i as y,t as De}from"./userProfile-BZvkCuet.js";import{t as Oe}from"./useChannelMessages-CDvw-f_x.js";var ke=r(`calendar`,[[`path`,{d:`M8 2v4`,key:`1cmpym`}],[`path`,{d:`M16 2v4`,key:`4m81vk`}],[`rect`,{width:`18`,height:`18`,x:`3`,y:`4`,rx:`2`,key:`1hopcy`}],[`path`,{d:`M3 10h18`,key:`8toen8`}]]),Ae=r(`hash`,[[`line`,{x1:`4`,x2:`20`,y1:`9`,y2:`9`,key:`4lhtct`}],[`line`,{x1:`4`,x2:`20`,y1:`15`,y2:`15`,key:`vyu0kd`}],[`line`,{x1:`10`,x2:`8`,y1:`3`,y2:`21`,key:`1ggp8o`}],[`line`,{x1:`16`,x2:`14`,y1:`3`,y2:`21`,key:`weycgp`}]]),je=r(`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`}]]),Me=r(`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`}]]),Ne=r(`settings`,[[`path`,{d:`M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915`,key:`1i5ecw`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),b=t(e(),1),x=n();function Pe(e){return String(e||``).split(`/`).pop()||e}function Fe(e){return e===`image`?(0,x.jsx)(p,{size:20}):e===`video`?(0,x.jsx)(f,{size:20}):e===`audio`?(0,x.jsx)(fe,{size:20}):(0,x.jsx)(g,{size:20})}function Ie({attachment:e,status:t=`idle`,message:n,pending:r=!1,onOpen:i}){let{t:a}=v(),o=t===`checking`,s=t===`downloading`,c=r||o||s,u=`ui-file-action chat-attachment-action ${t===`error`?`error`:t===`available`?`available`:``}`.trim(),d=Number.isFinite(e.size)&&e.size>0?Se(e.size):a(`chat.mostboxFile`),ee=r?a(`chat.sending`):n||d,te=a(r?`chat.sending`:o?`chat.checking`:s?`chat.attachment.downloading`:t===`available`?`chat.attachment.preview`:t===`error`?`chat.attachment.retry`:`chat.attachment.download`);return(0,x.jsxs)(`button`,{type:`button`,className:`ui-file-card chat-attachment-card`,onClick:()=>i?.(e),disabled:c,title:e.link,translate:`no`,children:[(0,x.jsx)(`span`,{className:`ui-file-icon chat-attachment-icon ${e.kind}`,children:c?(0,x.jsx)(se,{size:20,className:`ui-spinner chat-attachment-spinner`}):Fe(e.kind)}),(0,x.jsxs)(`span`,{className:`ui-file-info chat-attachment-info`,children:[(0,x.jsx)(`span`,{className:`ui-file-name chat-attachment-name`,translate:`no`,children:Pe(e.fileName)}),(0,x.jsx)(`span`,{className:`ui-file-meta chat-attachment-meta`,translate:`yes`,children:ee})]}),(0,x.jsxs)(`span`,{className:u,translate:`yes`,children:[c?(0,x.jsx)(se,{size:15,className:`ui-spinner chat-attachment-spinner`}):t===`available`?(0,x.jsx)(be,{size:16}):t===`error`?(0,x.jsx)(l,{size:17}):(0,x.jsx)(h,{size:16}),(0,x.jsx)(`span`,{className:`chat-attachment-action-label`,children:te})]})]})}var Le=[{key:`image`,labelKey:`chat.attachment.image`,accept:`image/*`,icon:p},{key:`video`,labelKey:`chat.attachment.video`,accept:`video/*`,icon:f},{key:`file`,labelKey:`chat.attachment.file`,accept:``,icon:g}],Re=Le.map(e=>e.accept).join(`,`);function ze({children:e}){return(0,x.jsx)(`div`,{className:`message-bubble`,translate:`no`,children:e})}function Be({children:e}){return(0,x.jsx)(`div`,{className:`message-bubble has-attachment`,children:e})}function Ve({variant:e,pending:t=!1,avatarSrc:n,isOnline:r=!1,author:i,time:a,children:o}){return(0,x.jsxs)(`div`,{className:[`chat-message`,e,t?`pending`:``].filter(Boolean).join(` `),children:[(0,x.jsxs)(`span`,{className:`chat-avatar-wrap`,children:[(0,x.jsx)(`img`,{className:`msg-avatar`,src:n,alt:`avatar`}),r&&(0,x.jsx)(`span`,{className:`chat-online-dot`,"aria-hidden":`true`})]}),(0,x.jsxs)(`div`,{className:`msg-content`,children:[(0,x.jsx)(`span`,{className:`message-header`,children:(0,x.jsx)(`span`,{className:`message-author`,translate:`no`,children:i})}),o,(0,x.jsx)(`span`,{className:`message-time`,children:a})]})]})}function He({active:e=!1,pinned:t=!1,unread:n=!1,title:r,onSelect:i,onTogglePin:a,onRename:o,onLeave:s}){let{t:c}=v(),l=!!(a||o||s);return(0,x.jsxs)(`div`,{className:[`sidebar-nav-btn`,e?`active`:``,t?`pinned`:``,n?`unread`:``].filter(Boolean).join(` `),onClick:i,role:`button`,tabIndex:0,onKeyDown:e=>{e.target===e.currentTarget&&e.key===`Enter`&&i?.()},children:[(0,x.jsxs)(`span`,{className:`chat-channel-icon-wrap`,children:[(0,x.jsx)(de,{size:16}),n&&(0,x.jsx)(`span`,{className:`chat-channel-unread-dot`,title:c(`chat.unread`),"aria-hidden":`true`})]}),(0,x.jsx)(`span`,{className:`chat-channel-title`,children:(0,x.jsx)(`span`,{className:`chat-channel-title-text`,translate:`no`,children:r})}),l&&(0,x.jsx)(ve,{ariaLabel:c(`chat.channelActions`),className:`channel-actions-anchor`,placement:`bottom-end`,items:[{key:`pin`,label:c(t?`chat.unpin`:`chat.pin`),icon:t?(0,x.jsx)(je,{size:16}):(0,x.jsx)(Me,{size:16}),onSelect:()=>a?.()},{key:`rename`,label:c(`chat.rename`),icon:(0,x.jsx)(re,{size:16}),onSelect:()=>o?.()},{key:`delete`,label:c(`chat.delete`),icon:(0,x.jsx)(_,{size:16}),onSelect:()=>s?.()}],renderTrigger:e=>(0,x.jsx)(`button`,{...e,className:`leave-channel-btn channel-actions-trigger`,title:c(`common.moreActions`),"aria-label":c(`common.moreActions`),children:(0,x.jsx)(d,{size:16})})})]})}function Ue({members:e}){let{t}=v();return e.length===0?(0,x.jsx)(`div`,{className:`ui-empty-inline channel-members-empty`,children:t(`chat.noMembers`)}):(0,x.jsx)(`div`,{className:`channel-members-grid`,children:e.map(e=>(0,x.jsxs)(`div`,{className:`channel-member`,children:[(0,x.jsxs)(`span`,{className:`channel-member-avatar-wrap`,children:[(0,x.jsx)(`img`,{className:`channel-member-avatar`,src:e.avatarSrc,alt:`avatar`}),e.online&&(0,x.jsx)(`span`,{className:`chat-online-dot`,"aria-hidden":`true`})]}),(0,x.jsx)(`span`,{className:`channel-member-name`,translate:`no`,children:e.name})]},e.id))})}function We({message:e,placeholder:t,disabled:n=!1,isPublishingAttachment:r=!1,attachmentButtonTitle:i,attachmentInputRef:a,onMessageChange:o,onSend:s,onSelectAttachmentFiles:c}){let{t:l}=v(),d=n||r,ee=n||!e.trim(),te=i||l(`chat.attachment.add`);function ne(e,t){t?.(e.currentTarget.files),e.currentTarget.value=``}function re(t){t.key===`Enter`&&(t.shiftKey||t.nativeEvent.isComposing||(t.preventDefault(),e.trim()&&s()))}function f(e){if(d)return;let t=a?.current;t&&(t.accept=e,t.click())}return(0,x.jsxs)(`div`,{className:`chat-input-area`,children:[(0,x.jsx)(`input`,{ref:a,type:`file`,accept:Re,className:`chat-file-input`,onChange:e=>ne(e,c)}),(0,x.jsx)(ve,{ariaLabel:l(`chat.attachmentType`),placement:`top-start`,disabled:d,items:Le.map(e=>{let t=e.icon;return{key:e.key,label:l(e.labelKey),icon:(0,x.jsx)(t,{size:16}),onSelect:()=>f(e.accept)}}),renderTrigger:e=>(0,x.jsx)(`button`,{...e,className:`btn btn-circle chat-tool-btn`,"aria-label":te,children:r?(0,x.jsx)(se,{size:18,className:`ui-spinner chat-attachment-spinner`}):(0,x.jsx)(u,{size:18})})}),(0,x.jsx)(`textarea`,{className:`textarea chat-composer-input`,placeholder:t,value:e,disabled:n,rows:1,onChange:e=>o(e.target.value),onKeyDown:re}),(0,x.jsx)(`button`,{type:`button`,className:`btn btn-circle btn-primary send-btn`,onClick:s,disabled:ee,title:l(`chat.sendMessage`),children:(0,x.jsx)(m,{size:18})})]})}var S=`mostbox.chat.lastReadAt`;function C(e){return Date.parse(e?.lastMessageAt||``)||Date.parse(e?.createdAt||``)||0}function Ge(e){let t=String(e||``).trim().toLowerCase();return t?`${S}:${t}`:``}function w(e,t=Date.now()){let n=Number(e);return Math.max(0,Math.floor(Number.isFinite(n)&&n>0?n:t))}function Ke(e,t=T()){if(!e||!t)return{};try{let n=t.getItem(e);if(!n)return{};let r=JSON.parse(n);return!r||typeof r!=`object`?{}:Object.entries(r).reduce((e,[t,n])=>{let r=Number(n);return t&&Number.isFinite(r)&&r>=0&&(e[t]=r),e},{})}catch{return{}}}function qe(e,t,n=T()){if(!(!e||!n))try{n.setItem(e,JSON.stringify(t))}catch{}}function Je(e,t,n=Date.now(),r=Date.now()){if(!t)return{changed:!1,value:e};let i=w(n,r);return(e[t]||0)>=i?{changed:!1,value:e}:{changed:!0,value:{...e,[t]:i}}}function Ye(e,t,n=Date.now()){let r=!1,i={...e};for(let e of t){let t=e?.channelKey||e?.name;!t||i[t]!==void 0||(i[t]=w(C(e),n),r=!0)}return{changed:r,value:r?i:e}}function Xe(e,{channelName:t,messageTime:n,activeChannelName:r=``,messageAuthor:i=``,userAddress:a=``,now:o=Date.now()}){if(!t)return{changed:!1,notify:!1,value:e};let s=w(n,o),c=t===r;if(String(i||``).toLowerCase()===String(a||``).toLowerCase())return{...Je(e,t,s,o),notify:!1};if(c)return{...Je(e,t,s,o),notify:!0};let l=e[t]||0;if(l<s)return{changed:!1,notify:!0,value:e};let u=Math.max(0,s-1);return l===u?{changed:!1,notify:!0,value:e}:{changed:!0,notify:!0,value:{...e,[t]:u}}}function Ze(e,t){let n=e?.channelKey||e?.name;return C(e)>(t[n]||0)}function T(){if(!(typeof window>`u`))return window.localStorage}var Qe=3,$e=30,et=/^[a-zA-Z0-9_-]+$/,tt=1e4,nt=12e3,rt=1200,it=800;function E(e){return e?.channelKey||e?.name||``}function D(e){return e?.channelId||e?.name||``}function at(e){return e&&typeof e==`object`?e:{}}function ot(e){let t=at(e),n=new Set,r=e=>{let t=String(e||``).trim();t&&n.add(t)};return r(t.channelKey),r(t.channel),Array.isArray(t.channels)&&t.channels.forEach(e=>{let t=at(e);r(t.channelKey),r(t.channel),r(t.name)}),[...n]}function O(e){return e?.remark||D(e)}function st(){return typeof window>`u`?``:(new URLSearchParams(window.location.search).get(`channel`)||``).trim()}function ct(e){let t=new Date(e||Date.now());return Number.isNaN(t.getTime())?String(Date.now()):t.toISOString().slice(0,16).replace(`T`,` `).replace(`:`,`-`)}function lt(e){return e.replace(/\\/g,`\\\\`).replace(/\[/g,`\\[`).replace(/\]/g,`\\]`)}function ut(e,t){return`[${lt(e)}](<${t.replace(/>/g,`%3E`)}>)`}function dt(e){let t=String(e||``).trim().split(/\r?\n/);return t.length>0?t.map(e=>`> ${e}`).join(`
|
|
2
|
-
`):`> `}var ft=`chat-file`;function pt(e,t){return e.type.startsWith(`image/`)?`image`:e.type.startsWith(`video/`)?`video`:e.type.startsWith(`audio/`)?`audio`:e.type.startsWith(`text/`)?`text`:ie(t)}function mt(e){return e?`${e.slice(0,6)}...${e.slice(-4)}`:`Unknown`}function ht(e){return/#[a-fA-F0-9]{4}$/.test(String(e||``).trim())}function k(e){return String(e||``).trim().toLowerCase()}function gt(){if(typeof window>`u`)return;let e=window;return e.AudioContext||e.webkitAudioContext}function A(){let e=c(e=>e.hasBackend),t=c(e=>e.isDarkMode),n=c(e=>e.addToast),r=c(e=>e.openConnectModal),a=i(e=>e.identity),l=i(e=>e.openLoginModal),[d,f]=(0,b.useState)([]),[p,m]=(0,b.useState)(null),[h,g]=(0,b.useState)(``),[fe,_]=(0,b.useState)(!1),[ve,be]=(0,b.useState)(``),[Se,je]=(0,b.useState)(``),[Me,Fe]=ce(!1),[Le,Re]=(0,b.useState)(``),[S,w]=(0,b.useState)(!1),[T,at]=(0,b.useState)(!1),[lt,A]=ce(!1),[_t,j]=(0,b.useState)(null),[vt,yt]=(0,b.useState)(null),[bt,M]=(0,b.useState)(!1),[xt,St]=(0,b.useState)(``),[Ct,wt]=(0,b.useState)(!1),[Tt,Et]=(0,b.useState)(null),[Dt,Ot]=(0,b.useState)(!1),[N,P]=(0,b.useState)({}),[F,I]=(0,b.useState)(null),[kt,At]=(0,b.useState)(!1),[jt,Mt]=(0,b.useState)(!1),[Nt,Pt]=(0,b.useState)(!1),[Ft,L]=(0,b.useState)({}),[It,Lt]=(0,b.useState)([]),R=a?.theme===`sparkbit`,Rt=R&&a?.data?a.data:``,zt=R&&a?.logo||``,Bt=R&&t&&a?.logo_dark||``,Vt=Bt||zt,Ht=Bt&&zt&&Bt!==zt?zt:``,Ut=Vt&&!jt?Vt:Ht&&!Nt?Ht:``,Wt=(0,b.useRef)(null),Gt=(0,b.useRef)(null),z=(0,b.useRef)(``),Kt=(0,b.useRef)(new Set),qt=(0,b.useRef)(new Set),B=(0,b.useRef)(null),Jt=(0,b.useRef)(!1),Yt=(0,b.useRef)(0),Xt=(0,b.useRef)(async()=>[]),Zt=(0,b.useRef)(new Map),V=(0,b.useRef)(new Map),H=(0,b.useRef)(new Set),U=e===!0,{t:W,compareStrings:Qt,formatDate:$t,formatTime:en}=v(),G=(0,b.useCallback)(async(e,t)=>{n(await s(e,t),`error`)},[n]),K=(0,b.useMemo)(()=>Ge(a?.address),[a?.address]),tn=(0,b.useCallback)((e,t=Date.now())=>{e&&L(n=>{let r=Je(n,e,t);return r.changed?(qe(K,r.value),r.value):n})},[K]),q=(0,b.useCallback)(()=>{if(Jt.current||typeof window>`u`)return;let e=gt();if(e)try{let t=B.current||new e;B.current=t,t.state===`suspended`&&t.resume().catch(()=>{}),Jt.current=!0}catch{}},[]),nn=(0,b.useCallback)(()=>{if(!Jt.current)return;let e=Date.now();if(e-Yt.current<rt)return;Yt.current=e;let t=gt();if(t)try{let e=B.current||new t;if(B.current=e,e.state===`suspended`){e.resume().catch(()=>{});return}let n=e.createGain();n.gain.setValueAtTime(1e-4,e.currentTime),n.gain.exponentialRampToValueAtTime(.08,e.currentTime+.015),n.gain.exponentialRampToValueAtTime(1e-4,e.currentTime+.18),n.connect(e.destination),[740,980].forEach((t,r)=>{let i=e.createOscillator();i.type=`sine`,i.frequency.setValueAtTime(t,e.currentTime),i.connect(n),i.start(e.currentTime+r*.035),i.stop(e.currentTime+.16+r*.035)})}catch{}},[]),J=(0,b.useCallback)(async(e=p)=>{let t=E(e);if(!t||!U){Lt([]);return}try{let e=await y.getChannelPresence(t);if(z.current!==t)return;Lt(e)}catch(e){console.warn(`[Chat] Failed to fetch channel presence:`,e instanceof Error?e.message:e)}},[p,U]),rn=(0,b.useCallback)((e=``)=>{let t=z.current;if(!e||e!==t||!U)return;let n=Zt.current,r=n.get(e);r&&window.clearTimeout(r);let i=window.setTimeout(()=>{n.delete(e),Xt.current(e)},it);n.set(e,i)},[U]);function an(e,t){switch(e){case`channel:message`:{let e=t?.channelKey||t?.channel,n=t?.message,r=Number(n?.timestamp)||Date.now();if(e){f(t=>t.map(t=>E(t)===e?{...t,lastMessageAt:new Date(r).toISOString()}:t));let t=e===z.current;L(i=>{let o=Xe(i,{channelName:e,messageTime:r,activeChannelName:t?e:``,messageAuthor:n?.author,userAddress:a?.address});return o.changed&&qe(K,o.value),o.notify&&nn(),o.changed?o.value:i})}break}case`channel:peer:online`:case`channel:sync:available`:{let e=ot(t),n=z.current;$(),e.includes(n)&&(rn(n),p&&J(p));break}case`channel:presence`:{let e=t?.channelKey||t?.channel;p&&(!e||e===E(p))&&J(p);break}case`channel:joined`:case`channel:left`:$();break;case`user:metadata:updated`:t?.scope===`channels`&&$();break;case`download:success`:{let e=V.current.get(t.taskId);e&&(V.current.delete(t.taskId),H.current.delete(e.cid),P(t=>({...t,[e.cid]:{status:`available`,message:W(`chat.attachment.previewAvailable`)}})),n(W(`chat.attachment.downloadCompleted`,{fileName:t.fileName||Pe(e.fileName)}),`success`),gn(e,t.fileName||e.fileName));break}case`download:error`:case`download:cancelled`:{let r=V.current.get(t.taskId);r&&(V.current.delete(t.taskId),H.current.delete(r.cid),P(n=>({...n,[r.cid]:{status:`error`,message:e===`download:cancelled`?W(`chat.attachment.downloadCancelled`):t.error||W(`chat.attachment.downloadFailed`)}})),n(e===`download:cancelled`?W(`chat.attachment.downloadCancelled`):t.error||W(`chat.attachment.downloadFailed`),`error`));break}}}let on=(0,b.useMemo)(()=>d.map(e=>E(e)),[d]),sn=(0,b.useMemo)(()=>a?{...De(a),profileUpdatedAt:a.profileUpdatedAt}:{},[a?.avatar,a?.displayName,a?.profileUpdatedAt,a?.username]),{clearMessages:cn,messages:Y,sendMessage:ln,syncMessages:un}=Oe({isReady:U,enabled:!!a,channelName:E(p),extraSubscribedChannelNames:on,peerId:Le,waitForPeerId:!0,onSyncError:e=>G(e,W(`chat.error.messages`)),onSocketEvent:an,onReconnect:()=>{$(),p&&J(p)},presenceEnabled:!!(p&&a),presenceProfile:sn});(0,b.useEffect)(()=>{Xt.current=un},[un]),(0,b.useEffect)(()=>{let e=Zt.current;return()=>{for(let t of e.values())window.clearTimeout(t);e.clear()}},[]);let dn=(0,b.useMemo)(()=>{let e=new Map;return Y.forEach((t,n)=>{let r=String(t.author||``).trim();if(!r)return;let i=r.toLowerCase(),a=Number(t.timestamp)||0,o=String(t.authorName||``).trim(),s=String(t.avatar||``).trim(),c=e.get(i);if(!c){e.set(i,{address:r,displayName:o,...s?{avatar:s}:{},firstSeenAt:a,lastSeenAt:a,index:n});return}a>=c.lastSeenAt&&(c.lastSeenAt=a,o&&(c.displayName=o),s&&(c.avatar=s))}),[...e.values()].sort((e,t)=>e.firstSeenAt-t.firstSeenAt||e.index-t.index)},[Y]),fn=(0,b.useMemo)(()=>new Map(dn.map(e=>[k(e.address),e])),[dn]),X=(0,b.useMemo)(()=>{let e=new Map;return It.forEach(t=>{let n=k(t.address);!n||!t.online||e.set(n,t)}),e},[It]),pn=(0,b.useMemo)(()=>{let e=new Map(fn);return It.forEach((t,n)=>{let r=k(t.address);!r||e.has(r)||e.set(r,{address:t.address,displayName:t.displayName||``,...t.avatar?{avatar:t.avatar}:{},firstSeenAt:t.lastSeen||Date.now(),lastSeenAt:t.lastSeen||Date.now(),index:dn.length+n})}),[...e.values()]},[dn,It,fn]),mn=(0,b.useMemo)(()=>new Set(X.keys()),[X]);function Z(){return U?!0:(r(),!1)}function Q(){return a?!0:(l(),!1)}(0,b.useEffect)(()=>{let e=()=>{g(st())};return e(),window.addEventListener(`popstate`,e),()=>window.removeEventListener(`popstate`,e)},[]),(0,b.useEffect)(()=>{a&&g(st())},[a?.address]),(0,b.useEffect)(()=>{Mt(!1),Pt(!1)},[Vt,Ht]),(0,b.useEffect)(()=>{z.current=E(p)},[p]),(0,b.useEffect)(()=>{L(Ke(K))},[K]),(0,b.useEffect)(()=>{!K||d.length===0||L(e=>{let t=Ye(e,d);return t.changed&&qe(K,t.value),t.changed?t.value:e})},[K,d]),(0,b.useEffect)(()=>(window.addEventListener(`pointerdown`,q,{passive:!0}),window.addEventListener(`keydown`,q),()=>{window.removeEventListener(`pointerdown`,q),window.removeEventListener(`keydown`,q)}),[q]),(0,b.useEffect)(()=>()=>{B.current?.close().catch(()=>{}),B.current=null,Jt.current=!1},[]),(0,b.useEffect)(()=>{Wt.current?.scrollIntoView({behavior:`smooth`})},[Y]),(0,b.useEffect)(()=>{if(!U){Re(``);return}o.get(`/api/node-id`).json().then(e=>Re(e.id)).catch(e=>{console.warn(`[Chat] Failed to fetch node ID:`,e.message),G(e,W(`chat.error.nodeId`))})},[U,G,W]),(0,b.useEffect)(()=>{U&&a?(_(!1),$()):_(!1)},[e,U,a?.address]),(0,b.useEffect)(()=>{if(p){if(U){let e=E(p);Lt([]),un(e,{replace:!0}),J(p)}}else Lt([])},[p,U,J,un]),(0,b.useEffect)(()=>{if(!h)return;if(!a){qt.current.has(h)||(qt.current.add(h),l());return}if(!U||!fe)return;let e=d.find(e=>E(e)===h)||d.find(e=>D(e)===h);if(e&&(!p||E(p)!==E(e))){bn(e);return}if(e&&p&&E(p)===E(e)&&(p.createdAt!==e.createdAt||p.coreKey!==e.coreKey||p.lastMessageAt!==e.lastMessageAt||p.pinned!==e.pinned||p.remark!==e.remark||p.type!==e.type)){m(e);return}if(e)return;let t=`${a.address}:${h}`;if(Kt.current.has(t)||S)return;let r=hn(h);if(Kt.current.add(t),r){n(r,`error`);return}Cn(h)},[d,p,h,fe,U,S,a?.address]),(0,b.useEffect)(()=>{a||(f([]),_(!1),m(null),g(st()),yt(null),cn(),je(``),Re(``),M(!1),Et(null),P({}),L({}),H.current.clear(),V.current.clear())},[cn,a?.address]);function hn(e){return e.length<Qe?W(`chat.validation.nameMin`,{count:Qe}):e.length>$e?W(`chat.validation.nameMax`,{count:$e}):e.includes(`.`)?W(`chat.validation.dotReserved`):et.test(e)?``:W(`chat.validation.allowedChars`)}async function $(){if(!U){_(!1);return}try{f(await y.getChannels()),_(!0)}catch(e){f([]),_(!1),await G(e,W(`chat.error.channelList`))}}function gn(e,t=e.fileName){let n=ie(t);Et({cid:e.cid,fileName:t,subtype:n===`file`?e.kind:n})}async function _n(e){let t=Te(e.link,W);if(t)return P(n=>({...n,[e.cid]:{status:`error`,message:t}})),!1;try{P(t=>({...t,[e.cid]:{status:`checking`}}));let t=await Ce.checkDownload(e.link,{timeout:tt,requestTimeout:nt});return P(n=>({...n,[e.cid]:{status:t.alreadyExists?`available`:`ready`,message:t.alreadyExists?W(`chat.attachment.localAvailable`):W(`chat.attachment.downloadAvailable`)}})),!0}catch(t){let n=await we(t);return P(t=>({...t,[e.cid]:{status:`error`,message:n}})),!1}}async function vn(e){I(null),await _n(e)&&await yn(e)}async function yn(e){if(!H.current.has(e.cid)){H.current.add(e.cid),P(t=>({...t,[e.cid]:{status:`downloading`,message:W(`chat.attachment.downloading`)}}));try{let t=await Ce.downloadFile(e.link);if(t.alreadyExists||t.fileName){H.current.delete(e.cid),P(t=>({...t,[e.cid]:{status:`available`,message:W(`chat.attachment.previewAvailable`)}})),gn({...e,fileName:t.fileName||e.fileName},t.fileName||e.fileName);return}t.taskId&&(V.current.set(t.taskId,e),n(W(`chat.attachment.downloadStarted`),`success`))}catch(t){let n=await we(t);H.current.delete(e.cid),P(t=>({...t,[e.cid]:{status:`error`,message:n}}))}}}async function bn(e){if(!Q()||!Z())return;let t=E(e);tn(t,Math.max(C(e),Date.now())),m(e),g(t),window.history.pushState({},``,`?channel=${encodeURIComponent(t)}`)}async function xn(e,t){if(t&&t.stopPropagation(),Q()&&Z()&&!T){at(!0);try{if(await y.leaveChannel(e),E(p)===e){m(null),g(``),cn();let e=new URL(window.location.href);e.searchParams.delete(`channel`),window.history.pushState({},``,e.pathname)}$(),A.close(),j(null)}catch(e){await G(e,W(`chat.error.leave`))}finally{at(!1)}}}async function Sn(e){if(!Q()||!Z())return;let t=!e.pinned,n=E(e);try{let e=await y.setChannelPinned(n,t);f(t=>t.map(t=>E(t)===n?{...t,pinned:e.pinned}:t)),m(t=>t&&E(t)===n?{...t,pinned:e.pinned}:t)}catch(e){await G(e,W(t?`chat.error.pin`:`chat.error.unpin`))}}async function Cn(e){let t=e.trim();if(!t||S)return;let r=hn(t);if(r){n(r,`error`);return}if(Q()&&Z()){w(!0);try{let e=await y.createChannel(t,`public`,De(a)),n=e.channelKey||e.key||e.name||t,r=d.find(e=>E(e)===n),i={...r,name:e.name||t,channelId:e.channelId||e.name||t,channelKey:e.channelKey||e.key||r?.channelKey,type:e.type||r?.type||`public`,createdAt:e.createdAt||r?.createdAt,coreKey:e.coreKey||e.key||r?.coreKey,localWriterCoreKey:e.localWriterCoreKey||r?.localWriterCoreKey,writerCoreKeys:e.writerCoreKeys||r?.writerCoreKeys,remark:e.remark||r?.remark},o=E(i);f(e=>e.some(e=>E(e)===o)?e.map(e=>E(e)===o?{...e,...i}:e):[...e,i]),Fe.close(),await bn(i),$()}catch(e){await G(e,W(`chat.error.join`))}finally{w(!1)}}}async function wn(e,t){if(!e.trim()||!p||!Q()||!Z())return!1;let n=e.trim(),r=E(p);try{let e=await ln({channelName:r,content:n,attachment:t});return f(t=>t.map(t=>E(t)===r?{...t,lastMessageAt:new Date(Number(e?.timestamp)||Date.now()).toISOString()}:t)),e&&tn(r,Number(e.timestamp)||Date.now()),!0}catch(e){return await G(e,W(`chat.error.send`)),!1}}async function Tn(){if(!Se.trim())return;let e=Se.trim();je(``),await wn(e)}function En(e,t){return`${ft}/${e}/${t}`}async function Dn(e){if(!(!e||e.length===0||!p)&&Q()&&Z()&&!Dt){Ot(!0);try{for(let t of Array.from(e)){let e=En(D(p),t.name),r=await Ce.publishFile(t,e),i=r.fileName||e,a=r.link||`most://${r.cid}?filename=${encodeURIComponent(i)}`;await wn(a,{kind:pt(t,i),cid:r.cid,fileName:i,link:a,mimeType:t.type||void 0,size:t.size})&&n(W(`chat.attachment.published`,{fileName:Pe(i)}),`success`)}}catch(e){await G(e,W(`chat.error.attachmentSend`))}finally{Ot(!1)}}}async function On(e){if(!Q()||!Z())return;let t=N[e.cid];if(!(t?.status===`checking`||t?.status===`downloading`)){if(t?.status===`error`){I(e);return}if(t?.status===`ready`||t?.status===`available`){await yn(e);return}if(!t){await _n(e)&&await yn(e);return}}}function kn(e){let t=k(e.author),n=X.get(t),r=fn.get(t);return Rn(n?.displayName||r?.displayName||e.authorName,e.author)}function An(e){return!e.pending&&(!!e.attachment||!!e.content.trim())}function jn(e,t){let n=kn(t),r=`${$t(t.timestamp)} ${en(t.timestamp)}`,i=t.content.trim();e.push(`## ${r} ${n}`,``),i&&(!t.attachment||i!==t.attachment.link)&&e.push(dt(i),``),t.attachment&&e.push(`**${W(`chat.noteDraft.attachment`)}**`,``,`- ${W(`chat.noteDraft.file`)}: ${ut(Pe(t.attachment.fileName),t.attachment.link)}`,`- CID: \`${t.attachment.cid}\``,``)}function Mn(e){let t=p?O(p):``,n=`${$t(Date.now())} ${en(Date.now())}`,r=[`# ${W(`chat.noteDraft.heading`)}`,``,`- ${W(`chat.noteDraft.room`)}: ${t}`,`- ${W(`chat.noteDraft.exportedAt`)}: ${n}`,`- ${W(`chat.noteDraft.messageCount`)}: ${e.length}`,``];return e.forEach(e=>jn(r,e)),`${r.join(`
|
|
3
|
-
`).trimEnd()}\n`}function Nn(){let e=Y.filter(An);if(e.length===0){n(W(`chat.noteDraft.empty`),`warning`);return}let t=te({title:W(`chat.noteDraft.historyTitle`,{room:p?O(p):W(`chat.title`),time:ct()}),content:Mn(e)});if(!t){n(W(`chat.noteDraft.saveFailed`),`error`);return}M(!1),window.location.assign(ee(t.id))}async function Pn(e,t){if(!Q()||!Z())return;let n=E(e),r=await y.setChannelRemark(n,t);return f(e=>e.map(e=>E(e)===n?{...e,remark:r.remark}:e)),m(e=>e&&E(e)===n?{...e,remark:r.remark}:e),r.remark}async function Fn(){if(p)try{await Pn(p,xt)}catch(e){await G(e,W(`chat.error.remark`))}}async function In(e){if(!(!vt||Ct)){wt(!0);try{await Pn(vt,e),yt(null)}catch(e){await G(e,W(`chat.error.rename`))}finally{wt(!1)}}}function Ln(e){if(!e.attachment)return(0,x.jsx)(ze,{children:e.content});let t=e.attachment,n=N[t.cid],r=n?.status;return(0,x.jsx)(Be,{children:(0,x.jsx)(Ie,{attachment:t,status:r,message:n?.message,pending:e.pending,onOpen:On})})}function Rn(e,t){let n=String(e||``).trim();return n?kt?ht(n)?n:t?`${n}#${t.slice(-4).toUpperCase()}`:n:n.replace(/#[a-fA-F0-9]{4}$/,``):mt(t)}function zn(){return(0,x.jsx)(Ue,{members:pn.map(e=>{let t=X.get(k(e.address)),n=t?.displayName||e.displayName,r=t?.avatar||e.avatar;return{id:e.address,name:Rn(n,e.address),avatarSrc:_e(e.address,r),online:mn.has(k(e.address))}})})}let Bn=R&&!!h&&!p,Vn=p?(0,x.jsx)(`h2`,{className:`header-title`,translate:`no`,children:O(p)}):(0,x.jsx)(`h2`,{className:`header-title`,children:W(`chat.title`)}),Hn=ve.trim().toLowerCase(),Un=(0,b.useMemo)(()=>[...d].sort((e,t)=>{let n=Number(!!t.pinned)-Number(!!e.pinned);if(n!==0)return n;let r=C(t)-C(e);return r===0?Qt(O(e),O(t)):r}),[d,Qt]),Wn=Hn?Un.filter(e=>[O(e),D(e),E(e)].some(e=>e.toLowerCase().includes(Hn))):Un;return(0,x.jsxs)(le,{className:`chat-app-layout`,defaultHide:R,hideAccountMenu:R,sidebar:({closeSidebar:e})=>(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(ue,{onNavigate:e}),(0,x.jsx)(`div`,{className:`chat-channel-search`,children:(0,x.jsxs)(`div`,{className:`ui-input-control`,children:[(0,x.jsx)(me,{className:`ui-input-icon`,size:15}),(0,x.jsx)(`input`,{type:`search`,className:`input input-compact`,placeholder:W(`chat.search.placeholder`),value:ve,onChange:e=>be(e.target.value),"aria-label":W(`chat.search.placeholder`)})]})}),(0,x.jsx)(`nav`,{className:`sidebar-nav`,children:d.length===0?(0,x.jsx)(`div`,{className:`sidebar-empty-state`,children:(0,x.jsx)(`p`,{children:W(`chat.empty.noChannels`)})}):Wn.length===0?(0,x.jsx)(`div`,{className:`sidebar-empty-state`,children:(0,x.jsx)(`p`,{children:W(`chat.empty.noMatches`)})}):Wn.map(t=>(0,x.jsx)(He,{active:E(p)===E(t),pinned:!!t.pinned,unread:Ze(t,Ft),title:O(t),onSelect:()=>{bn(t),e()},onTogglePin:()=>void Sn(t),onRename:()=>yt(t),onLeave:()=>{j(t),A.open()}},E(t)))}),(0,x.jsxs)(`button`,{className:`ui-action-dashed create-channel-btn`,onClick:()=>{!Q()||!Z()||Fe.open()},children:[(0,x.jsx)(u,{size:16}),W(`chat.joinChannel`)]})]}),headerTitle:Vn,sidebarToggleReplacement:R?(0,x.jsx)(`span`,{className:`sidebar-toggle-static-logo`,"aria-hidden":`true`,children:Ut?(0,x.jsx)(`img`,{className:`sidebar-toggle-static-logo-img`,src:Ut,alt:``,onError:()=>{if(Ut===Ht){Pt(!0);return}Mt(!0)}}):(0,x.jsx)(Ee,{size:18})}):void 0,headerRight:(0,x.jsx)(`div`,{className:`header-right-actions`,children:p&&(0,x.jsx)(`button`,{className:`btn btn-icon`,onClick:()=>M(!0),title:W(`chat.channelSettings`),children:(0,x.jsx)(Ne,{size:16})})}),children:[p?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(`div`,{className:`chat-messages`,children:[Y.length===0?(0,x.jsxs)(`div`,{className:`ui-empty-state chat-messages-empty`,children:[(0,x.jsx)(`div`,{className:`ui-empty-icon empty-icon`,children:(0,x.jsx)(de,{size:28})}),(0,x.jsx)(`p`,{children:W(`chat.empty.noMessages`)})]}):Y.map(e=>{let t=e.author?.toLowerCase()===a?.address.toLowerCase(),n=X.get(k(e.author)),r=fn.get(k(e.author)),i=mn.has(k(e.author)),o=n?.avatar||r?.avatar||e.avatar||(t?a.avatar:void 0),s=kn(e);return(0,x.jsx)(Ve,{variant:t?`self`:`other`,pending:e.pending,isOnline:i,avatarSrc:_e(e.author,o),author:s,time:en(e.timestamp),children:Ln(e)},e.id||`${e.author}-${e.timestamp}`)}),(0,x.jsx)(`div`,{ref:Wt})]}),(0,x.jsx)(We,{message:Se,placeholder:W(a?`chat.composer.placeholder`:`chat.composer.signInPlaceholder`),disabled:!a,isPublishingAttachment:Dt,attachmentInputRef:Gt,onMessageChange:je,onSend:Tn,onSelectAttachmentFiles:e=>{Dn(e)}})]}):Bn?(0,x.jsxs)(`div`,{className:`ui-empty-state chat-welcome`,children:[(0,x.jsx)(`div`,{className:`ui-empty-icon ui-empty-icon-lg welcome-icon`,children:(0,x.jsx)(se,{size:36,className:`ui-spinner`})}),(0,x.jsx)(`h2`,{className:`ui-empty-title`,children:W(`chat.restoring.title`)}),(0,x.jsx)(`p`,{className:`ui-empty-desc`,children:W(`chat.restoring.desc`)})]}):(0,x.jsx)(x.Fragment,{children:(0,x.jsxs)(`div`,{className:`ui-empty-state chat-welcome`,children:[(0,x.jsx)(`div`,{className:`ui-empty-icon ui-empty-icon-lg welcome-icon`,children:(0,x.jsx)(de,{size:36})}),(0,x.jsx)(`h2`,{className:`ui-empty-title`,children:W(`chat.select.title`)}),(0,x.jsx)(`p`,{className:`ui-empty-desc`,children:W(`chat.select.desc`)}),(0,x.jsx)(ne,{label:W(`chat.openChannelList`)})]})}),Me&&(0,x.jsx)(ge,{title:W(`chat.joinChannel`),placeholder:W(`chat.join.placeholder`),confirmText:W(`chat.join.confirm`),validate:hn,onConfirm:Cn,onClose:()=>Fe.close(),isLoading:S,loadingText:W(`chat.join.joining`)}),vt&&(0,x.jsx)(ge,{title:W(`chat.renameChannel`),placeholder:W(`chat.remark.placeholder`),defaultValue:vt.remark||``,confirmText:W(`chat.remark.save`),onConfirm:In,onClose:()=>{Ct||yt(null)},isLoading:Ct,loadingText:W(`chat.remark.saving`),allowEmpty:!0,validate:e=>e.length>50?W(`chat.remark.tooLong`):``}),lt&&_t&&(0,x.jsx)(ye,{title:W(`chat.leaveChannel`),message:W(`chat.leaveConfirm`,{channel:O(_t)}),confirmText:W(T?`chat.leaving`:`chat.leaveChannel`),onConfirm:()=>xn(E(_t),void 0),danger:!0,onClose:()=>{A.close(),j(null)}}),F&&(0,x.jsx)(xe,{onClose:()=>I(null),children:(0,x.jsxs)(`div`,{className:`confirm-modal`,onClick:e=>e.stopPropagation(),children:[(0,x.jsxs)(`div`,{className:`modal-header`,children:[(0,x.jsx)(`h3`,{children:W(`chat.attachment.noSeedsTitle`)}),(0,x.jsx)(`button`,{type:`button`,className:`btn btn-icon`,onClick:()=>I(null),"aria-label":W(`common.close`),children:(0,x.jsx)(he,{size:18})})]}),(0,x.jsx)(`p`,{children:N[F.cid]?.message||W(`chat.attachment.noSeedsFallback`)}),(0,x.jsxs)(`div`,{className:`modal-actions`,children:[(0,x.jsx)(`button`,{type:`button`,className:`btn btn-secondary`,onClick:()=>I(null),children:W(`common.cancel`)}),(0,x.jsx)(`button`,{type:`button`,className:`btn btn-primary`,onClick:()=>vn(F),disabled:N[F.cid]?.status===`checking`,children:N[F.cid]?.status===`checking`?W(`app.checking`):W(`chat.attachment.retryCheck`)})]})]})}),Tt&&(0,x.jsx)(ae,{item:Tt,isBackendReady:U,getFileDownloadUrl:Ce.getFileDownloadUrl,onClose:()=>Et(null)}),bt&&p&&(0,x.jsx)(`div`,{className:`channel-detail-overlay`,onClick:()=>M(!1),children:(0,x.jsxs)(`div`,{className:`channel-detail-drawer`,onClick:e=>e.stopPropagation(),children:[(0,x.jsxs)(`div`,{className:`channel-detail-header`,children:[(0,x.jsx)(`h3`,{children:W(`chat.details.title`)}),(0,x.jsx)(`button`,{className:`btn btn-icon`,onClick:()=>M(!1),children:(0,x.jsx)(he,{size:18})})]}),(0,x.jsxs)(`div`,{className:`channel-detail-body`,children:[(0,x.jsxs)(`div`,{className:`channel-detail-section channel-members-section`,children:[(0,x.jsx)(`div`,{className:`channel-detail-label`,children:(0,x.jsx)(`span`,{children:W(`chat.details.members`,{count:pn.length})})}),zn()]}),Rt&&(0,x.jsx)(`div`,{className:`channel-detail-section`,children:(0,x.jsxs)(`a`,{className:`btn btn-primary btn-block`,href:Rt,target:`_blank`,rel:`noreferrer`,children:[(0,x.jsx)(oe,{size:16}),W(`chat.ticket.create`)]})}),!R&&(0,x.jsxs)(`div`,{className:`channel-detail-section`,children:[(0,x.jsxs)(`div`,{className:`channel-detail-label`,children:[(0,x.jsx)(pe,{size:14}),(0,x.jsx)(`span`,{children:W(`chat.noteDraft.settingsTitle`)})]}),(0,x.jsx)(`p`,{className:`channel-detail-hint`,children:W(`chat.noteDraft.saveAllDesc`)}),(0,x.jsxs)(`button`,{className:`btn btn-secondary btn-block`,onClick:Nn,children:[(0,x.jsx)(pe,{size:16}),W(`chat.noteDraft.saveAll`)]})]}),!R&&(0,x.jsx)(`div`,{className:`channel-detail-section`,children:(0,x.jsxs)(`label`,{className:`setting-switch`,children:[(0,x.jsx)(`span`,{children:W(`chat.details.showAddressSuffix`)}),(0,x.jsx)(`input`,{type:`checkbox`,checked:kt,onChange:e=>At(e.target.checked)})]})}),!R&&(0,x.jsxs)(`div`,{className:`channel-detail-section`,children:[(0,x.jsxs)(`div`,{className:`channel-detail-label`,children:[(0,x.jsx)(Ae,{size:14}),(0,x.jsx)(`span`,{children:W(`chat.details.channelId`)})]}),(0,x.jsx)(`div`,{className:`ui-meta-box channel-detail-value channel-detail-mono`,translate:`no`,children:D(p)})]}),!R&&(0,x.jsxs)(`div`,{className:`channel-detail-section`,children:[(0,x.jsxs)(`div`,{className:`channel-detail-label`,children:[(0,x.jsx)(re,{size:14}),(0,x.jsx)(`span`,{children:W(`chat.remark.placeholder`)})]}),(0,x.jsx)(`input`,{type:`text`,className:`input input-compact`,placeholder:W(`chat.remark.placeholder`),value:xt,onChange:e=>St(e.target.value),onFocus:()=>St(p.remark||``),onBlur:()=>Fn(),onKeyDown:e=>{e.key===`Enter`&&e.currentTarget.blur()},maxLength:50})]}),(0,x.jsxs)(`div`,{className:`channel-detail-section`,children:[(0,x.jsxs)(`div`,{className:`channel-detail-label`,children:[(0,x.jsx)(ke,{size:14}),(0,x.jsx)(`span`,{children:W(`chat.channel.createdAt`)})]}),(0,x.jsx)(`div`,{className:`ui-meta-box channel-detail-value`,children:p.createdAt?$t(p.createdAt):`-`})]})]}),!R&&(0,x.jsx)(`div`,{className:`channel-detail-footer`,children:(0,x.jsx)(`button`,{className:`btn btn-secondary btn-block`,onClick:()=>{M(!1),j(p),A.open()},children:W(`chat.leaveChannel`)})})]})})]})}var _t=a(`/chat/`)({component:A});export{_t as Route};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{n as e,o as t,r as n,t as r}from"./jsx-runtime-Bt-cYkS5.js";import{B as i,H as a,d as o,n as s,o as c,t as l,u}from"./useAppStore-DOnk608w.js";import{t as d}from"./triangle-alert-B9sMiA9l.js";import{t as f}from"./download-COQOcPqI.js";import{t as p}from"./file-text-DiyIGL1I.js";import{t as m}from"./hard-drive-Cqa7Rstj.js";import{t as h}from"./refresh-cw-D4BsHvhi.js";import{t as g}from"./save-B02sbO9Y.js";import{t as _}from"./shield-check-Boae7Nc6.js";import{t as v}from"./trash-2-BLwoM0ME.js";import{t as ee}from"./wifi-ljEI_ySA.js";import{A as te,C as y,D as ne}from"./index-DjBN7bZV.js";import{t as b}from"./dayjs.min-Dcc0B6Je.js";import{t as x}from"./MarketingHeader-BVJy8hXd.js";import{t as S}from"./format-CR8oUWq6.js";var re=i(`activity`,[[`path`,{d:`M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2`,key:`169zse`}]]),ie=i(`clipboard`,[[`rect`,{width:`8`,height:`4`,x:`8`,y:`2`,rx:`1`,ry:`1`,key:`tgr4d6`}],[`path`,{d:`M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2`,key:`116196`}]]),C=i(`database`,[[`ellipse`,{cx:`12`,cy:`5`,rx:`9`,ry:`3`,key:`msslwz`}],[`path`,{d:`M3 5V19A9 3 0 0 0 21 19V5`,key:`1wlel7`}],[`path`,{d:`M3 12A9 3 0 0 0 21 12`,key:`mv7ke4`}]]),w=n(((e,t)=>{(function(n,r){typeof e==`object`&&t!==void 0?t.exports=r():typeof define==`function`&&define.amd?define(r):(n=typeof globalThis<`u`?globalThis:n||self).dayjs_plugin_relativeTime=r()})(e,(function(){return function(e,t,n){e||={};var r=t.prototype,i={future:`in %s`,past:`%s ago`,s:`a few seconds`,m:`a minute`,mm:`%d minutes`,h:`an hour`,hh:`%d hours`,d:`a day`,dd:`%d days`,M:`a month`,MM:`%d months`,y:`a year`,yy:`%d years`};function a(e,t,n,i){return r.fromToBase(e,t,n,i)}n.en.relativeTime=i,r.fromToBase=function(t,r,a,o,s){for(var c,l,u,d=a.$locale().relativeTime||i,f=e.thresholds||[{l:`s`,r:44,d:`second`},{l:`m`,r:89},{l:`mm`,r:44,d:`minute`},{l:`h`,r:89},{l:`hh`,r:21,d:`hour`},{l:`d`,r:35},{l:`dd`,r:25,d:`day`},{l:`M`,r:45},{l:`MM`,r:10,d:`month`},{l:`y`,r:17},{l:`yy`,d:`year`}],p=f.length,m=0;m<p;m+=1){var h=f[m];h.d&&(c=o?n(t).diff(a,h.d,!0):a.diff(t,h.d,!0));var g=(e.rounding||Math.round)(Math.abs(c));if(u=c>0,g<=h.r||!h.r){g<=1&&m>0&&(h=f[m-1]);var _=d[h.l];s&&(g=s(``+g)),l=typeof _==`string`?_.replace(`%d`,g):_(g,r,h.l,u);break}}if(r)return l;var v=u?d.future:d.past;return typeof v==`function`?v(l):v.replace(`%s`,l)},r.to=function(e,t){return a(e,t,this,!0)},r.from=function(e,t){return a(e,t,this)};var o=function(e){return e.$u?n.utc():n()};r.toNow=function(e){return this.to(o(this),e)},r.fromNow=function(e){return this.from(o(this),e)}}}))})),T=n(((e,t)=>{(function(n,r){typeof e==`object`&&t!==void 0?t.exports=r(b()):typeof define==`function`&&define.amd?define([`dayjs`],r):(n=typeof globalThis<`u`?globalThis:n||self).dayjs_locale_zh_cn=r(n.dayjs)})(e,(function(e){function t(e){return e&&typeof e==`object`&&`default`in e?e:{default:e}}var n=t(e),r={name:`zh-cn`,weekdays:`星期日_星期一_星期二_星期三_星期四_星期五_星期六`.split(`_`),weekdaysShort:`周日_周一_周二_周三_周四_周五_周六`.split(`_`),weekdaysMin:`日_一_二_三_四_五_六`.split(`_`),months:`一月_二月_三月_四月_五月_六月_七月_八月_九月_十月_十一月_十二月`.split(`_`),monthsShort:`1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月`.split(`_`),ordinal:function(e,t){return t===`W`?e+`周`:e+`日`},weekStart:1,yearStart:4,formats:{LT:`HH:mm`,LTS:`HH:mm:ss`,L:`YYYY/MM/DD`,LL:`YYYY年M月D日`,LLL:`YYYY年M月D日Ah点mm分`,LLLL:`YYYY年M月D日ddddAh点mm分`,l:`YYYY/M/D`,ll:`YYYY年M月D日`,lll:`YYYY年M月D日 HH:mm`,llll:`YYYY年M月D日dddd HH:mm`},relativeTime:{future:`%s内`,past:`%s前`,s:`几秒`,m:`1 分钟`,mm:`%d 分钟`,h:`1 小时`,hh:`%d 小时`,d:`1 天`,dd:`%d 天`,M:`1 个月`,MM:`%d 个月`,y:`1 年`,yy:`%d 年`},meridiem:function(e,t){var n=100*e+t;return n<600?`凌晨`:n<900?`早上`:n<1100?`上午`:n<1300?`中午`:n<1800?`下午`:`晚上`}};return n.default.locale(r,null,!0),r}))})),E=n(((e,t)=>{(function(n,r){typeof e==`object`&&t!==void 0?t.exports=r(b()):typeof define==`function`&&define.amd?define([`dayjs`],r):(n=typeof globalThis<`u`?globalThis:n||self).dayjs_locale_zh_tw=r(n.dayjs)})(e,(function(e){function t(e){return e&&typeof e==`object`&&`default`in e?e:{default:e}}var n=t(e),r={name:`zh-tw`,weekdays:`星期日_星期一_星期二_星期三_星期四_星期五_星期六`.split(`_`),weekdaysShort:`週日_週一_週二_週三_週四_週五_週六`.split(`_`),weekdaysMin:`日_一_二_三_四_五_六`.split(`_`),months:`一月_二月_三月_四月_五月_六月_七月_八月_九月_十月_十一月_十二月`.split(`_`),monthsShort:`1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月`.split(`_`),ordinal:function(e,t){return t===`W`?e+`週`:e+`日`},formats:{LT:`HH:mm`,LTS:`HH:mm:ss`,L:`YYYY/MM/DD`,LL:`YYYY年M月D日`,LLL:`YYYY年M月D日 HH:mm`,LLLL:`YYYY年M月D日dddd HH:mm`,l:`YYYY/M/D`,ll:`YYYY年M月D日`,lll:`YYYY年M月D日 HH:mm`,llll:`YYYY年M月D日dddd HH:mm`},relativeTime:{future:`%s內`,past:`%s前`,s:`幾秒`,m:`1 分鐘`,mm:`%d 分鐘`,h:`1 小時`,hh:`%d 小時`,d:`1 天`,dd:`%d 天`,M:`1 個月`,MM:`%d 個月`,y:`1 年`,yy:`%d 年`},meridiem:function(e,t){var n=100*e+t;return n<600?`凌晨`:n<900?`早上`:n<1100?`上午`:n<1300?`中午`:n<1800?`下午`:`晚上`}};return n.default.locale(r,null,!0),r}))})),D=t(e(),1),O=t(b(),1),k=t(w(),1);T(),E();var A=r();O.default.extend(k.default);var ae=null;function oe(e,t){let n=Math.max(0,Number(e)||0),r=Math.floor(n/86400),i=Math.floor(n%86400/3600),a=Math.floor(n%3600/60);return r>0?t(`admin.uptime.daysHours`,{days:r,hours:i}):i>0?t(`admin.uptime.hoursMinutes`,{hours:i,minutes:a}):t(`admin.uptime.minutes`,{minutes:a})}function j(e){return Number.isFinite(e)?String(Math.round(e/(1024*1024*1024)*100)/100):`0`}function M(e){let t=Number(e);return!Number.isFinite(t)||t<0?0:Math.round(t*1024*1024*1024)}function se(e){return Array.from(new Set(String(e||``).split(/[\n,]/).map(e=>e.trim()).filter(Boolean)))}function N(e,t=12,n=8){return e?e.length<=t+n+3?e:`${e.slice(0,t)}...${e.slice(-n)}`:`-`}function ce(e,t){switch(e.seedStatus){case`queued`:return t(`admin.seedStatus.queued`);case`joining`:return t(`admin.seedStatus.joining`);case`active`:return t(`admin.seedStatus.active`);case`paused`:return t(`admin.seedStatus.paused`);case`error`:return e.seedError?t(`admin.seedStatus.errorWithMessage`,{message:e.seedError}):t(`admin.seedStatus.error`);default:return e.joined?t(`admin.seedStatus.active`):t(`admin.seedStatus.notJoined`)}}function P(e){return{"zh-CN":`zh-cn`,"zh-TW":`zh-tw`,en:`en`}[e]}function le(e,t,n){if(!e)return t(`admin.time.never`);let r=(0,O.default)(e);if(!r.isValid())return t(`admin.time.never`);if(r.isAfter((0,O.default)()))return t(`admin.time.justNow`);let i=P(n);return r.locale(i).from((0,O.default)().locale(i))}var ue=[{labelKey:`admin.seedHelp.active.label`,tone:`active`,descKey:`admin.seedHelp.active.desc`},{labelKey:`admin.seedHelp.pending.label`,tone:`pending`,descKey:`admin.seedHelp.pending.desc`},{labelKey:`admin.seedHelp.paused.label`,tone:`muted`,descKey:`admin.seedHelp.paused.desc`},{labelKey:`admin.seedHelp.error.label`,tone:`error`,descKey:`admin.seedHelp.error.desc`}],de=[{value:`all`,labelKey:`admin.logFilter.all`},{value:`join`,labelKey:`admin.logFilter.join`},{value:`pull`,labelKey:`admin.logFilter.pull`},{value:`verify`,labelKey:`admin.logFilter.verify`},{value:`serve`,labelKey:`admin.logFilter.serve`},{value:`error`,labelKey:`admin.logFilter.error`}],F={join:[`join`,`joined`,`topic`],pull:[`pull`,`p2p`],verify:[`verify`,`verified`,`integrity`,`download:success`],serve:[`seed`,`seeding`,`holding`,`publish:success`,`topic:joined`],error:[`error`,`failed`,`fail`]};function I(e){let t=``;try{t=JSON.stringify(e.data||{})}catch{}return[e.level,e.event,e.message,t].map(e=>String(e||``).toLowerCase()).join(` `)}function fe(e,t){let n=String(t||`all`).trim().toLowerCase();if(!n||n===`all`)return!0;let r=I(e);return n===`error`?e.level===`error`||F.error.some(e=>r.includes(e)):(F[n]||[n]).some(e=>r.includes(e))}function L(){let{t:e,locale:t,formatNumber:n,formatTime:r}=te(),i=l(e=>e.hasBackend),a=l(e=>e.addToast),[b,w]=(0,D.useState)(ae),[T,E]=(0,D.useState)([]),[O,k]=(0,D.useState)(``),[P,F]=(0,D.useState)(!1),[I,L]=(0,D.useState)(!1),[R,z]=(0,D.useState)(!1),[B,pe]=(0,D.useState)(`all`),[V,me]=(0,D.useState)([]),[he,H]=(0,D.useState)(``),[U,W]=(0,D.useState)({dataPath:``,capacityGiB:`100`,maxFileSizeGiB:`10`,remoteInvites:``}),G=i===!0;function K(){return G?!0:(a(e(i===null?`admin.toast.backendChecking`:`admin.toast.backendDisconnected`),`warning`),!1)}let q=(0,D.useMemo)(()=>!b||b.capacity.configuredBytes<=0?0:Math.min(100,Math.round(b.capacity.usedBytes/b.capacity.configuredBytes*100)),[b]),ge=(0,D.useMemo)(()=>(b?.holdings||[]).slice(0,100),[b]),J=Math.max(0,(b?.holdings.length||0)-100),Y=o(),X=!!Y&&!Y.includes(`localhost`)&&!Y.includes(`127.0.0.1`),Z=async()=>{if(!G)return!1;try{let e=await s.get(`/api/node/status`).json(),t=await s.get(`/api/node/config`).json();return w(e),W({dataPath:t.dataPath||e.dataPath||``,capacityGiB:j(t.capacityBytes),maxFileSizeGiB:j(t.maxFileSizeBytes),remoteInvites:(t.remoteInvites||[]).join(`
|
|
2
|
-
`)}),k(``),!0}catch(t){let n=await c(t,e(`admin.error.readStatus`));return k(n),a(n,`error`),!1}},_e=async()=>{K()&&await Z()&&a(e(`admin.toast.statusRefreshed`),`success`)},Q=async(e=B)=>{if(G)try{let t=new URLSearchParams({limit:`80`,filter:e});E((await s.get(`/api/node/logs?${t.toString()}`).json()).logs||[])}catch{}},$=async()=>{if(G)try{me((await s.get(`/api/admin/users`).json()).users||[])}catch{}},ve=async()=>{if(K()){F(!0);try{await s.post(`/api/node/config`,{json:{dataPath:U.dataPath,capacityBytes:M(U.capacityGiB),maxFileSizeBytes:M(U.maxFileSizeGiB),remoteInvites:se(U.remoteInvites)}}).json(),a(U.dataPath===(b?.dataPath||``)?e(`admin.toast.configSaved`):e(`admin.toast.configSavedRestart`),`success`),await Z(),await Q()}catch(t){let n=await c(t,e(`admin.error.saveConfig`));a(n,`error`),k(n)}finally{F(!1)}}},ye=async()=>{b?.nodeId&&(await navigator.clipboard.writeText(b.nodeId),a(e(`admin.toast.nodeIdCopied`),`success`))},be=async()=>{if(K()){L(!0);try{await s.delete(`/api/node/logs`).json(),E([]),a(e(`admin.toast.logsCleared`),`success`)}catch(t){let n=await c(t,e(`admin.error.clearLogs`));a(n,`error`),k(n)}finally{L(!1)}}},xe=async()=>{if(K()){z(!0);try{let t=await s.get(`/api/node/diagnostics`).json(),n=new Blob([JSON.stringify(t,null,2)],{type:`application/json`}),r=URL.createObjectURL(n),i=document.createElement(`a`),o=new Date().toISOString().replace(/[:.]/g,`-`);i.href=r,i.download=`mostbox-diagnostics-${o}.json`,document.body.appendChild(i),i.click(),i.remove(),URL.revokeObjectURL(r),a(e(`admin.toast.diagnosticsExported`),`success`)}catch(t){let n=await c(t,e(`admin.error.exportDiagnostics`));a(n,`error`),k(n)}finally{z(!1)}}},Se=async t=>{if(K()&&window.confirm(e(`admin.confirm.clearUserData`,{address:`${t.slice(0,6)}...${t.slice(-4)}`}))){H(t);try{await s.delete(`/api/admin/users/${t}/data`).json(),a(e(`admin.toast.userDataCleared`),`success`),await $(),await Z()}catch(t){let n=await c(t,e(`admin.error.clearUserData`));a(n,`error`),k(n)}finally{H(``)}}};return(0,D.useEffect)(()=>{if(!G||X)return;Z(),Q(),$();let e=null,t=!1;return(async()=>{if(e=new WebSocket(await u(`/ws`)),t){e.close();return}e.onmessage=e=>{try{let t=JSON.parse(e.data);t.event===`node:status`&&w(t.data),t.event===`node:log`&&fe(t.data,B)&&E(e=>[t.data,...e].slice(0,80)),t.event===`node:logs:cleared`&&E([]),(t.event===`publish:success`||t.event===`download:success`||t.event===`network:status`)&&Z()}catch{}}})(),()=>{t=!0,e?.close()}},[G,X,B]),(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(x,{}),(0,A.jsxs)(`main`,{className:`admin-page`,children:[(0,A.jsxs)(`header`,{className:`admin-topbar`,children:[(0,A.jsx)(`div`,{className:`admin-title-group`,children:(0,A.jsx)(`h1`,{children:e(`admin.title`)})}),(0,A.jsxs)(`div`,{className:`admin-topbar-actions`,children:[(0,A.jsxs)(`span`,{className:`admin-status-pill ${b?.status===`online`?`online`:``}`,children:[(0,A.jsx)(re,{size:14}),b?.status===`online`?e(`admin.status.online`):e(`admin.status.waiting`)]}),(0,A.jsxs)(`button`,{className:`btn btn-secondary`,onClick:_e,children:[(0,A.jsx)(h,{size:16}),e(`admin.action.refresh`)]})]})]}),i===!1&&(0,A.jsxs)(`section`,{className:`admin-panel admin-error`,children:[(0,A.jsx)(y,{size:20}),(0,A.jsx)(`span`,{children:e(`admin.error.localDaemonDisconnected`)})]}),X&&(0,A.jsxs)(`section`,{className:`admin-panel admin-error`,children:[(0,A.jsx)(d,{size:18}),(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`h2`,{children:e(`admin.remoteUnavailable.title`)}),(0,A.jsx)(`p`,{children:e(`admin.remoteUnavailable.desc`)})]})]}),!X&&O&&(0,A.jsxs)(`section`,{className:`admin-panel admin-error`,children:[(0,A.jsx)(p,{size:20}),(0,A.jsx)(`span`,{children:O})]}),!X&&(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(`section`,{className:`admin-overview`,children:[(0,A.jsxs)(`div`,{className:`admin-metric`,children:[(0,A.jsx)(`div`,{className:`admin-metric-icon`,children:(0,A.jsx)(_,{size:18})}),(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`span`,{children:e(`admin.metric.nodeId`)}),(0,A.jsx)(`strong`,{translate:`no`,children:N(b?.nodeId||``)})]}),(0,A.jsx)(`button`,{className:`btn btn-icon admin-metric-action`,onClick:ye,"aria-label":e(`admin.action.copyNodeId`),children:(0,A.jsx)(ie,{size:15})})]}),(0,A.jsxs)(`div`,{className:`admin-metric`,children:[(0,A.jsx)(`div`,{className:`admin-metric-icon`,children:(0,A.jsx)(ee,{size:18})}),(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`span`,{children:e(`admin.metric.connections`)}),(0,A.jsx)(`strong`,{children:b?e(`admin.metric.peers`,{count:b.network.peers}):`-`})]})]}),(0,A.jsxs)(`div`,{className:`admin-metric`,children:[(0,A.jsx)(`div`,{className:`admin-metric-icon`,children:(0,A.jsx)(m,{size:18})}),(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`span`,{children:e(`admin.metric.capacity`)}),(0,A.jsxs)(`strong`,{children:[q,`%`]})]})]}),(0,A.jsxs)(`div`,{className:`admin-metric`,children:[(0,A.jsx)(`div`,{className:`admin-metric-icon`,children:(0,A.jsx)(y,{size:18})}),(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`span`,{children:e(`admin.metric.uptime`)}),(0,A.jsx)(`strong`,{children:b?oe(b.uptimeSeconds,e):`-`})]})]})]}),(0,A.jsxs)(`section`,{className:`admin-grid`,children:[(0,A.jsxs)(`div`,{className:`admin-panel admin-span-2`,children:[(0,A.jsxs)(`div`,{className:`admin-panel-header`,children:[(0,A.jsx)(`div`,{children:(0,A.jsx)(`h2`,{children:e(`admin.nodeStatus.title`)})}),(0,A.jsx)(ne,{size:18})]}),(0,A.jsxs)(`div`,{className:`admin-status-grid`,children:[(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`span`,{children:e(`admin.nodeStatus.version`)}),(0,A.jsx)(`strong`,{translate:`no`,children:b?.version||`-`})]}),(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`span`,{children:e(`admin.nodeStatus.listen`)}),(0,A.jsx)(`strong`,{translate:`no`,children:b?`${b.host}:${b.port}`:`-`})]}),(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`span`,{children:e(`admin.nodeStatus.dataPath`)}),(0,A.jsx)(`strong`,{translate:`no`,children:b?.dataPath||`-`})]})]}),(0,A.jsx)(`div`,{className:`admin-address-list`,children:(b?.listen.addresses||[]).map(e=>(0,A.jsxs)(`span`,{translate:`no`,children:[e.label,`: `,e.ip,`:`,b?.port]},`${e.type}-${e.ip}`))})]}),(0,A.jsxs)(`div`,{className:`admin-panel admin-span-2`,children:[(0,A.jsxs)(`div`,{className:`admin-panel-header`,children:[(0,A.jsx)(`div`,{children:(0,A.jsx)(`h2`,{children:e(`admin.userData.title`)})}),(0,A.jsx)(C,{size:18})]}),(0,A.jsxs)(`div`,{className:`admin-table`,children:[(0,A.jsxs)(`div`,{className:`admin-table-row admin-table-head`,children:[(0,A.jsx)(`span`,{children:e(`admin.userData.user`)}),(0,A.jsx)(`span`,{children:e(`admin.userData.files`)}),(0,A.jsx)(`span`,{children:e(`admin.userData.trash`)}),(0,A.jsx)(`span`,{children:e(`admin.userData.actions`)})]}),V.map(t=>(0,A.jsxs)(`div`,{className:`admin-table-row`,children:[(0,A.jsx)(`span`,{title:t.address,translate:`no`,children:N(t.address)}),(0,A.jsx)(`span`,{children:n(t.fileCount)}),(0,A.jsx)(`span`,{children:n(t.trashCount)}),(0,A.jsx)(`span`,{children:(0,A.jsxs)(`button`,{className:`btn btn-ghost`,onClick:()=>Se(t.address),disabled:he===t.address,children:[(0,A.jsx)(v,{size:16}),e(`admin.action.clear`)]})})]},t.address)),V.length===0&&(0,A.jsx)(`div`,{className:`admin-empty-row`,children:e(`admin.userData.empty`)})]})]}),(0,A.jsxs)(`div`,{className:`admin-panel admin-span-2`,children:[(0,A.jsxs)(`div`,{className:`admin-panel-header`,children:[(0,A.jsx)(`div`,{children:(0,A.jsx)(`h2`,{children:e(`admin.settings.title`)})}),(0,A.jsx)(C,{size:18})]}),(0,A.jsxs)(`div`,{className:`admin-settings-fields`,children:[(0,A.jsxs)(`label`,{className:`admin-field admin-field-wide`,children:[(0,A.jsx)(`span`,{children:e(`admin.settings.dataPath`)}),(0,A.jsx)(`input`,{className:`input`,value:U.dataPath,onChange:e=>W(t=>({...t,dataPath:e.target.value}))})]}),(0,A.jsxs)(`label`,{className:`admin-field`,children:[(0,A.jsx)(`span`,{children:e(`admin.settings.capacityGiB`)}),(0,A.jsx)(`input`,{className:`input`,type:`number`,min:`0`,step:`1`,value:U.capacityGiB,onChange:e=>W(t=>({...t,capacityGiB:e.target.value}))})]}),(0,A.jsxs)(`label`,{className:`admin-field`,children:[(0,A.jsx)(`span`,{children:e(`admin.settings.maxFileSizeGiB`)}),(0,A.jsx)(`input`,{className:`input`,type:`number`,min:`0`,step:`1`,value:U.maxFileSizeGiB,onChange:e=>W(t=>({...t,maxFileSizeGiB:e.target.value}))})]}),(0,A.jsxs)(`label`,{className:`admin-field admin-field-wide`,children:[(0,A.jsx)(`span`,{children:e(`admin.settings.remoteInvites`)}),(0,A.jsx)(`textarea`,{className:`input admin-textarea`,value:U.remoteInvites,placeholder:e(`admin.settings.remoteInvitesPlaceholder`),onChange:e=>W(t=>({...t,remoteInvites:e.target.value}))})]})]}),(0,A.jsx)(`p`,{className:`admin-field-hint`,children:e(`admin.settings.hint`)}),(0,A.jsxs)(`button`,{className:`btn btn-primary btn-full`,onClick:ve,disabled:P,children:[(0,A.jsx)(g,{size:16}),e(`admin.action.saveConfig`)]})]}),(0,A.jsxs)(`div`,{className:`admin-panel admin-span-2`,children:[(0,A.jsxs)(`div`,{className:`admin-panel-header`,children:[(0,A.jsx)(`div`,{children:(0,A.jsx)(`h2`,{children:e(`admin.holdings.title`)})}),(0,A.jsx)(m,{size:18})]}),(0,A.jsxs)(`div`,{className:`admin-capacity-row`,children:[(0,A.jsx)(`progress`,{value:q,max:`100`}),(0,A.jsxs)(`span`,{children:[S(b?.capacity.usedBytes||0),` /`,` `,S(b?.capacity.configuredBytes||0)]})]}),(0,A.jsx)(`div`,{className:`admin-seed-help`,"aria-label":e(`admin.seedHelp.label`),children:ue.map(t=>(0,A.jsxs)(`div`,{className:`admin-seed-help-item`,children:[(0,A.jsx)(`span`,{className:`admin-seed-dot ${t.tone}`}),(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`strong`,{children:e(t.labelKey)}),(0,A.jsx)(`span`,{children:e(t.descKey)})]})]},t.labelKey))}),J>0&&(0,A.jsx)(`p`,{className:`admin-table-note`,children:e(`admin.holdings.hiddenCount`,{count:n(J)})}),(0,A.jsxs)(`div`,{className:`admin-table`,children:[(0,A.jsxs)(`div`,{className:`admin-table-row admin-table-head admin-holdings-row`,children:[(0,A.jsx)(`span`,{children:e(`admin.holdings.file`)}),(0,A.jsx)(`span`,{children:`CID`}),(0,A.jsx)(`span`,{children:e(`admin.holdings.size`)}),(0,A.jsx)(`span`,{children:e(`admin.holdings.peers`)}),(0,A.jsx)(`span`,{children:e(`admin.holdings.topicJoined`)}),(0,A.jsx)(`span`,{children:e(`admin.holdings.lastServed`)}),(0,A.jsx)(`span`,{children:e(`admin.holdings.totalServed`)}),(0,A.jsx)(`span`,{children:e(`admin.holdings.status`)})]}),ge.map(r=>(0,A.jsxs)(`div`,{className:`admin-table-row admin-holdings-row`,children:[(0,A.jsx)(`span`,{translate:`no`,children:r.fileName||`-`}),(0,A.jsx)(`span`,{title:r.cid,translate:`no`,children:N(r.cid)}),(0,A.jsx)(`span`,{children:S(r.size)}),(0,A.jsx)(`span`,{children:n(r.peerCount??0)}),(0,A.jsx)(`span`,{className:`admin-seed-pill ${r.joined?`active`:``}`,children:r.joined?e(`admin.holdings.joinedYes`):e(`admin.holdings.joinedNo`)}),(0,A.jsx)(`span`,{title:r.lastServedAt||``,children:le(r.lastServedAt,e,t)}),(0,A.jsx)(`span`,{children:S(r.totalServedBytes||0)}),(0,A.jsx)(`span`,{className:`admin-seed-pill ${r.seedStatus===`error`?`error`:r.seedStatus===`active`||r.joined?`active`:``}`,children:ce(r,e)})]},r.cid)),(!b||b.holdings.length===0)&&(0,A.jsx)(`div`,{className:`admin-empty-row`,children:e(`admin.holdings.empty`)})]})]}),(0,A.jsxs)(`div`,{className:`admin-panel admin-span-2`,children:[(0,A.jsxs)(`div`,{className:`admin-panel-header`,children:[(0,A.jsx)(`div`,{children:(0,A.jsx)(`h2`,{children:e(`admin.logs.title`)})}),(0,A.jsxs)(`div`,{className:`admin-panel-actions`,children:[(0,A.jsxs)(`button`,{className:`btn btn-secondary`,onClick:xe,disabled:R,children:[(0,A.jsx)(f,{size:16}),e(`admin.action.exportDiagnostics`)]}),(0,A.jsxs)(`button`,{className:`btn btn-ghost`,onClick:be,disabled:I||T.length===0,children:[(0,A.jsx)(v,{size:16}),e(`admin.action.clearLogs`)]}),(0,A.jsx)(p,{size:18})]})]}),(0,A.jsx)(`div`,{className:`admin-log-filter`,"aria-label":e(`admin.logs.filterLabel`),children:de.map(t=>(0,A.jsx)(`button`,{type:`button`,className:B===t.value?`active`:``,onClick:()=>{pe(t.value),Q(t.value)},children:e(t.labelKey)},t.value))}),(0,A.jsxs)(`div`,{className:`admin-log-list`,children:[T.map(e=>(0,A.jsxs)(`div`,{className:`admin-log-row`,children:[(0,A.jsx)(`time`,{children:r(e.ts)}),(0,A.jsx)(`span`,{className:`admin-log-level ${e.level}`,translate:`no`,children:e.level}),(0,A.jsx)(`strong`,{translate:`no`,children:e.event}),(0,A.jsx)(`span`,{translate:`no`,children:e.message})]},e.id)),T.length===0&&(0,A.jsx)(`div`,{className:`admin-empty-row`,children:e(`admin.logs.empty`)})]})]})]})]})]})]})}var R=a(`/admin/`)({component:L});export{R as Route};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{n as e,o as t,t as n}from"./jsx-runtime-Bt-cYkS5.js";import{B as r,E as i,H as a,O as ee,W as o,n as s,o as te,t as c}from"./useAppStore-DOnk608w.js";import{n as ne,r as re}from"./mp-Dv12gDTx.js";import{t as l}from"./circle-alert-dfN4T6Nq.js";import{t as u}from"./check-iBCQl0yr.js";import{t as d}from"./download-COQOcPqI.js";import{t as f}from"./external-link-D6tHlYgS.js";import{t as p}from"./key-round-JR8M3aHl.js";import{i as m}from"./AccountMenu-BgbcUc0m.js";import{t as h}from"./loader-CwyHYZdX.js";import{t as g}from"./save-B02sbO9Y.js";import{t as _}from"./shield-check-Boae7Nc6.js";import{t as ie}from"./upload-DVuXJt_o.js";import{A as ae,D as v,S as y,d as b,f as x,h as S,m as C,n as oe,p as w,v as se,y as ce}from"./index-DjBN7bZV.js";import{t as le}from"./MarketingHeader-BVJy8hXd.js";import{t as T}from"./CopyButton-B03fpFFc.js";import{t as E}from"./MarketingLayout-Cltu-DRw.js";var ue=r(`cloud-download`,[[`path`,{d:`M12 13v8l-4-4`,key:`1f5nwf`}],[`path`,{d:`m12 21 4-4`,key:`1lfcce`}],[`path`,{d:`M4.393 15.269A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.436 8.284`,key:`ui1hmy`}]]),D=r(`cloud-upload`,[[`path`,{d:`M12 13v8`,key:`1l5pq0`}],[`path`,{d:`M4 14.899A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.242`,key:`1pljnt`}],[`path`,{d:`m8 17 4-4 4 4`,key:`1quai1`}]]),de=r(`log-out`,[[`path`,{d:`m16 17 5-5-5-5`,key:`1bji2h`}],[`path`,{d:`M21 12H9`,key:`dn1m92`}],[`path`,{d:`M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4`,key:`1uf3rs`}]]),fe=r(`wallet-cards`,[[`path`,{d:`M3 11h3.75a2 2 0 0 1 1.6.8l.45.6a4 4 0 0 0 6.4 0l.45-.6a2 2 0 0 1 1.6-.8H21`,key:`1vwh6y`}],[`path`,{d:`M3 7h18`,key:`1uiuf2`}],[`rect`,{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`,key:`h1oib`}]]),O=t(e(),1),k=n(),pe=[{value:``,labelKey:`profile.avatar.address`},...b.map(e=>({value:w(e),labelKey:`profile.avatar.${e}`}))];function A(e){if(C(e))return!0;try{let t=new URL(e);return t.protocol===`http:`||t.protocol===`https:`}catch{return!1}}function j(e){return e===`disabled`?`is-disabled`:e===`working`?`is-working`:e===`synced`?`is-synced`:e===`error`?`is-error`:`is-idle`}function M({status:e,busy:t}){return t||e===`working`?(0,k.jsx)(h,{size:16,className:`ui-spinner`}):e===`synced`?(0,k.jsx)(v,{size:16}):e===`error`?(0,k.jsx)(l,{size:16}):(0,k.jsx)(_,{size:16})}function N(){let{formatNumber:e,t}=ae(),n=c(e=>e.addToast),r=c(e=>e.hasBackend),a=i(e=>e.identity),l=i(e=>e.openLoginModal),v=i(e=>e.setUserIdentity),b=i(e=>e.logoutUser),C=oe(),[w,N]=(0,O.useState)(``),[I,L]=(0,O.useState)(``),[R,z]=(0,O.useState)(``),[B,V]=(0,O.useState)(!1),[H,U]=(0,O.useState)(null),W=(0,k.jsx)(le,{});(0,O.useEffect)(()=>{if(!a){N(``),L(``),z(``);return}N(a.displayName||a.username),L(S(a.avatar)||a.avatar||``),z(``)},[a]),(0,O.useEffect)(()=>{a&&C.refreshBackupSummary()},[C.refreshBackupSummary,r,a]);let G=(0,O.useMemo)(()=>a?ee(a.danger):null,[a]),me=(0,O.useMemo)(()=>G?ne(G.private_key,G.ed_public_key):``,[G]);if(!a)return(0,k.jsx)(E,{header:W,children:(0,k.jsx)(`section`,{className:`profile-page`,children:(0,k.jsx)(`div`,{className:`profile-container narrow`,children:(0,k.jsxs)(`div`,{className:`profile-empty glass`,children:[(0,k.jsx)(`div`,{className:`profile-empty-icon`,children:(0,k.jsx)(m,{size:34})}),(0,k.jsx)(`h1`,{children:t(`profile.signedOut.title`)}),(0,k.jsx)(`p`,{children:t(`profile.signedOut.desc`)}),(0,k.jsxs)(`button`,{type:`button`,className:`btn btn-primary`,onClick:l,children:[(0,k.jsx)(m,{size:16}),t(`account.signIn`)]})]})})})});let he=S(a.avatar)||a.avatar||``,ge=x(a.address,a.avatar),K=a.address.toLowerCase(),_e=I.trim().length>0,ve=j(C.status),q=C.action===`backup`,J=C.action===`restore`,Y=C.action===`export`,X=C.action===`import`,ye=[{key:`notes`,label:t(`profile.backup.summary.notes`),value:C.notesCount},{key:`files`,label:t(`profile.backup.summary.files`),value:C.backupSummary.filesCount},{key:`trash`,label:t(`profile.backup.summary.trash`),value:C.backupSummary.trashFilesCount},{key:`channels`,label:t(`profile.backup.summary.channels`),value:C.backupSummary.channelsCount}];function be(){U({title:t(`profile.backup.confirm.backupTitle`),message:t(`profile.backup.confirm.backupMessage`),confirmText:t(`profile.backup.action.cloudBackup`),onConfirm:async()=>{U(null),await C.backupToCloud()}})}function xe(){U({title:t(`profile.backup.confirm.restoreTitle`),message:t(`profile.backup.confirm.restoreMessage`),confirmText:t(`profile.backup.action.cloudRestore`),onConfirm:async()=>{U(null),await C.restoreFromCloud({confirm:!1})}})}function Se(){return new Promise(e=>{let n=t=>{U(null),e(t)};U({title:t(`profile.backup.confirm.importTitle`),message:t(`profile.backup.confirm.restore`),confirmText:t(`profile.backup.action.importLocal`),onConfirm:()=>n(!0),onClose:()=>n(!1)})})}function Z(){C.importLocalBackup({requestConfirm:Se})}let Ce=[{key:`cloud-backup`,tone:`cloud-backup`,label:t(q?`profile.backup.status.backingUp`:`profile.backup.action.cloudBackup`),icon:q?(0,k.jsx)(h,{size:16,className:`ui-spinner`}):(0,k.jsx)(D,{size:16}),onClick:be},{key:`cloud-restore`,tone:`cloud-restore`,label:t(J?`profile.backup.status.restoring`:`profile.backup.action.cloudRestore`),icon:J?(0,k.jsx)(h,{size:16,className:`ui-spinner`}):(0,k.jsx)(ue,{size:16}),onClick:xe},{key:`export-local`,tone:`export-local`,label:t(Y?`profile.backup.status.exporting`:`profile.backup.action.exportLocal`),icon:Y?(0,k.jsx)(h,{size:16,className:`ui-spinner`}):(0,k.jsx)(d,{size:16}),onClick:C.exportLocalBackup},{key:`import-local`,tone:`import-local`,label:t(X?`profile.backup.status.importing`:`profile.backup.action.importLocal`),icon:X?(0,k.jsx)(h,{size:16,className:`ui-spinner`}):(0,k.jsx)(ie,{size:16}),onClick:Z}];async function Q(e){if(r===!0)try{await s.put(`/api/user/profile`,{json:{displayName:e.displayName||e.username,avatar:e.avatar||``,updatedAt:e.profileUpdatedAt||Date.now()}}).json()}catch(e){n(await te(e,t(`profile.backup.error.profileSaveFailed`)),`error`)}}function $(e){if(!a)return;let r={...a,avatar:e||void 0,profileUpdatedAt:Date.now()};v(r),Q(r),z(``),n(t(`profile.toast.avatarUpdated`),`success`)}function we(){if(!a)return;let e=w.trim()||a.username,r={...a,displayName:e,profileUpdatedAt:Date.now()};v(r),Q(r),N(e),n(t(`profile.toast.saved`),`success`)}function Te(){let e=I.trim();if(!e){$(void 0);return}if(!A(e)){z(t(`nav.avatarUrlInvalid`));return}$(e)}function Ee(){b(),V(!1)}return(0,k.jsxs)(E,{header:W,children:[(0,k.jsx)(`section`,{className:`profile-page`,children:(0,k.jsxs)(`div`,{className:`profile-container`,children:[(0,k.jsxs)(`section`,{className:`profile-panel profile-backup-card`,children:[(0,k.jsxs)(`div`,{className:`profile-panel-header profile-backup-header`,children:[(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`h2`,{children:t(`profile.section.backup`)}),(0,k.jsx)(`p`,{children:t(`profile.section.backup.desc`)})]}),(0,k.jsxs)(`span`,{className:`profile-backup-status ${ve}`,children:[(0,k.jsx)(M,{status:C.status,busy:C.busy}),C.statusLabel]})]}),(0,k.jsx)(`div`,{className:`profile-backup-summary`,"aria-label":t(`profile.backup.summary.label`),children:ye.map(t=>(0,k.jsxs)(`div`,{className:`profile-backup-stat`,children:[(0,k.jsx)(`span`,{className:`profile-backup-stat-value`,children:t.value===null?C.backupSummary.loading?`...`:`-`:e(t.value)}),(0,k.jsx)(`span`,{className:`profile-backup-stat-label`,children:t.label})]},t.key))}),(0,k.jsx)(`div`,{className:`profile-backup-actions`,children:Ce.map(e=>(0,k.jsxs)(`button`,{type:`button`,className:[`btn`,`profile-backup-action`,`is-${e.tone}`].join(` `),disabled:C.busy,onClick:e.onClick,children:[e.icon,e.label]},e.key))})]}),(0,k.jsxs)(`header`,{className:`profile-header`,children:[(0,k.jsx)(`img`,{className:`profile-avatar-large`,src:ge,alt:``}),(0,k.jsxs)(`div`,{className:`profile-heading`,children:[(0,k.jsx)(`p`,{className:`profile-kicker`,children:t(`profile.kicker`)}),(0,k.jsx)(`h1`,{children:a.displayName||a.username}),(0,k.jsxs)(`div`,{className:`profile-address-line`,children:[(0,k.jsx)(`code`,{translate:`no`,children:K}),(0,k.jsx)(T,{text:K}),(0,k.jsxs)(`a`,{href:`https://debank.com/profile/${a.address}`,target:`_blank`,rel:`noopener noreferrer`,className:`btn btn-secondary btn-sm`,children:[(0,k.jsx)(f,{size:14}),t(`web3.action.view`)]})]})]}),(0,k.jsxs)(`button`,{type:`button`,className:`btn btn-secondary profile-logout-btn`,onClick:()=>V(!0),children:[(0,k.jsx)(de,{size:16}),t(`account.logout`)]})]}),(0,k.jsxs)(`div`,{className:`profile-grid`,children:[(0,k.jsxs)(`section`,{className:`profile-panel`,children:[(0,k.jsx)(`div`,{className:`profile-panel-header`,children:(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`h2`,{children:t(`profile.section.account`)}),(0,k.jsx)(`p`,{children:t(`profile.section.account.desc`)})]})}),(0,k.jsxs)(`label`,{className:`profile-field`,children:[(0,k.jsx)(`span`,{children:t(`profile.label.displayName`)}),(0,k.jsxs)(`div`,{className:`profile-field-row`,children:[(0,k.jsx)(`input`,{className:`input`,value:w,onChange:e=>N(e.target.value),placeholder:t(`nav.displayNamePlaceholder`)}),(0,k.jsxs)(`button`,{type:`button`,className:`btn btn-primary`,onClick:we,children:[(0,k.jsx)(g,{size:16}),t(`profile.action.save`)]})]})]}),(0,k.jsx)(`div`,{className:`profile-facts`,children:(0,k.jsx)(P,{label:t(`profile.label.username`),value:a.username})})]}),(0,k.jsxs)(`section`,{className:`profile-panel`,children:[(0,k.jsx)(`div`,{className:`profile-panel-header`,children:(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`h2`,{children:t(`profile.section.avatar`)}),(0,k.jsx)(`p`,{children:t(`profile.section.avatar.desc`)})]})}),(0,k.jsx)(`div`,{className:`profile-avatar-grid`,role:`list`,children:pe.map(e=>{let n=he===e.value;return(0,k.jsxs)(`button`,{type:`button`,className:[`profile-avatar-option`,n?`selected`:``].filter(Boolean).join(` `),onClick:()=>$(e.value),"aria-pressed":n,title:t(e.labelKey),children:[(0,k.jsx)(`img`,{src:x(a.address,e.value),alt:``,"aria-hidden":`true`}),(0,k.jsx)(`span`,{children:t(e.labelKey)}),n&&(0,k.jsx)(`span`,{className:`profile-avatar-check`,children:(0,k.jsx)(u,{size:14})})]},e.value||`address`)})}),(0,k.jsxs)(`div`,{className:`profile-avatar-url`,children:[(0,k.jsxs)(`label`,{className:`profile-field`,htmlFor:`profile-avatar-url`,children:[(0,k.jsx)(`span`,{children:t(`profile.label.customAvatar`)}),(0,k.jsxs)(`div`,{className:`profile-field-row`,children:[(0,k.jsx)(`input`,{id:`profile-avatar-url`,className:`input`,value:I,onChange:e=>{L(e.target.value),z(``)},placeholder:t(`nav.avatarUrlPlaceholder`)}),(0,k.jsxs)(`button`,{type:`button`,className:`btn btn-secondary`,onClick:Te,disabled:!_e,children:[(0,k.jsx)(g,{size:16}),t(`profile.action.save`)]})]})]}),R&&(0,k.jsx)(`p`,{className:`profile-error`,children:R})]})]})]}),(0,k.jsxs)(`section`,{className:`profile-panel profile-identity-panel`,children:[(0,k.jsxs)(`div`,{className:`profile-panel-header`,children:[(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`h2`,{children:t(`profile.section.identity`)}),(0,k.jsx)(`p`,{children:t(`profile.section.identity.desc`)})]}),(0,k.jsxs)(o,{to:`/web3/`,hash:`wallet`,className:`btn btn-secondary`,children:[(0,k.jsx)(fe,{size:16}),t(`profile.action.openWallet`)]})]}),(0,k.jsxs)(`div`,{className:`profile-key-grid`,children:[G&&(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(F,{title:t(`web3.label.ed25519Public`),icon:(0,k.jsx)(re,{size:18}),value:G.ed_public_key}),(0,k.jsx)(F,{title:t(`web3.label.x25519Public`),icon:(0,k.jsx)(p,{size:18}),value:G.public_key})]}),(0,k.jsx)(F,{title:`IPNS ID`,icon:(0,k.jsx)(_,{size:18}),value:me||`-`})]})]})]})}),H&&(0,k.jsx)(se,{title:H.title,message:H.message,confirmText:H.confirmText,danger:H.danger,onConfirm:H.onConfirm,onClose:H.onClose||(()=>U(null))}),B&&(0,k.jsx)(ce,{className:`profile-logout-overlay`,onClose:()=>V(!1),children:(0,k.jsxs)(`div`,{className:`confirm-modal profile-logout-modal`,onClick:e=>e.stopPropagation(),children:[(0,k.jsxs)(`div`,{className:`modal-header`,children:[(0,k.jsx)(`h3`,{children:t(`account.logoutTitle`)}),(0,k.jsx)(`button`,{type:`button`,className:`btn btn-icon`,onClick:()=>V(!1),"aria-label":t(`common.close`),children:(0,k.jsx)(y,{size:18})})]}),(0,k.jsx)(`p`,{className:`profile-logout-reminder`,children:t(`profile.logout.backupReminder`)}),(0,k.jsxs)(`div`,{className:`profile-logout-backup-actions`,children:[(0,k.jsxs)(`button`,{type:`button`,className:`btn btn-secondary`,disabled:C.busy,onClick:()=>void C.backupToCloud(),children:[C.action===`backup`?(0,k.jsx)(h,{size:16,className:`ui-spinner`}):(0,k.jsx)(D,{size:16}),t(`profile.backup.action.cloudBackup`)]}),(0,k.jsxs)(`button`,{type:`button`,className:`btn btn-secondary`,disabled:C.busy,onClick:()=>void C.exportLocalBackup(),children:[C.action===`export`?(0,k.jsx)(h,{size:16,className:`ui-spinner`}):(0,k.jsx)(d,{size:16}),t(`profile.backup.action.exportLocal`)]})]}),(0,k.jsxs)(`div`,{className:`modal-actions`,children:[(0,k.jsx)(`button`,{type:`button`,className:`btn btn-secondary`,onClick:()=>V(!1),children:t(`common.cancel`)}),(0,k.jsx)(`button`,{type:`button`,className:`btn btn-danger`,onClick:Ee,children:t(`account.logout`)})]})]})})]})}function P({label:e,value:t,copy:n=!1}){return(0,k.jsxs)(`div`,{className:`profile-fact`,children:[(0,k.jsx)(`span`,{children:e}),(0,k.jsxs)(`div`,{className:`profile-fact-value`,children:[(0,k.jsx)(`code`,{translate:`no`,children:t}),n&&(0,k.jsx)(T,{text:t})]})]})}function F({title:e,icon:t,value:n}){return(0,k.jsxs)(`div`,{className:`profile-key-card`,children:[(0,k.jsxs)(`div`,{className:`profile-key-card-header`,children:[(0,k.jsx)(`span`,{className:`profile-key-card-icon`,children:t}),(0,k.jsx)(`span`,{children:e})]}),(0,k.jsxs)(`div`,{className:`mono-row`,children:[(0,k.jsx)(`code`,{className:`mono`,translate:`no`,children:n}),(0,k.jsx)(T,{text:n})]})]})}var I=a(`/profile/`)({component:N});export{I as Route};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{n as e,o as t,t as n}from"./jsx-runtime-Bt-cYkS5.js";import{B as r,E as i,H as a,c as o,o as s,t as c,u as l}from"./useAppStore-DOnk608w.js";import{t as u}from"./OpenSidebarButton-C2UJYXKh.js";import{a as ee,i as d,n as f,r as p,t as te}from"./FilePreviewOverlay-CA04_Ved.js";import{t as ne}from"./check-iBCQl0yr.js";import{n as re,t as m}from"./folder-DAcox9xz.js";import{t as ie}from"./copy-B7pPZ2MP.js";import{t as ae}from"./download-COQOcPqI.js";import{t as oe}from"./file-text-DiyIGL1I.js";import{t as se}from"./loader-CwyHYZdX.js";import{i as ce,n as le,t as ue}from"./AppTop-DZFTO9-m.js";import{t as h}from"./music-Dn9nm9Qb.js";import{t as de}from"./search-HW4oPOBP.js";import{t as fe}from"./trash-2-BLwoM0ME.js";import{t as pe}from"./upload-DVuXJt_o.js";import{A as me,S as g,_ as he,v as ge,y as _}from"./index-DjBN7bZV.js";import{t as _e}from"./format-CR8oUWq6.js";import{n as v,r as ve,t as ye}from"./downloadValidation-Zvllo2SZ.js";var be=r(`arrow-up-down`,[[`path`,{d:`m21 16-4 4-4-4`,key:`f6ql7i`}],[`path`,{d:`M17 20V4`,key:`1ejh1v`}],[`path`,{d:`m3 8 4-4 4 4`,key:`11wl7u`}],[`path`,{d:`M7 4v16`,key:`1glfcx`}]]),xe=r(`files`,[[`path`,{d:`M15 2h-4a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V8`,key:`14sh0y`}],[`path`,{d:`M16.706 2.706A2.4 2.4 0 0 0 15 2v5a1 1 0 0 0 1 1h5a2.4 2.4 0 0 0-.706-1.706z`,key:`1970lx`}],[`path`,{d:`M5 7a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 1.732-1`,key:`l4dndm`}]]),Se=r(`info`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 16v-4`,key:`1dtifu`}],[`path`,{d:`M12 8h.01`,key:`e9boi3`}]]),Ce=r(`star`,[[`path`,{d:`M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z`,key:`r04s7s`}]]),y=t(e(),1);function we(e={}){let t=e.timeout??2e3,[n,r]=(0,y.useState)(null),[i,a]=(0,y.useState)(!1),o=(0,y.useRef)(null);(0,y.useEffect)(()=>()=>{window.clearTimeout(o.current)},[]);let s=e=>{window.clearTimeout(o.current),o.current=window.setTimeout(()=>a(!1),t),a(e)};return{copy:e=>{`clipboard`in navigator?navigator.clipboard.writeText(e).then(()=>{r(null),s(!0)}).catch(e=>r(e)):r(Error(`useClipboard: navigator.clipboard is not supported`))},reset:()=>{a(!1),r(null),window.clearTimeout(o.current)},error:n,copied:i}}var b=n();function x(e){let t=e.lastIndexOf(`/`);return t===-1?{folder:``,name:e}:{folder:e.substring(0,t),name:e.substring(t+1)}}function Te({file:e,isSelected:t,onSelect:n,onPreview:r}){let i=f(e.fileName),a=(0,b.jsx)(oe,{size:24,color:`#fff`});return i===`image`?a=(0,b.jsx)(p,{size:24,color:`#fff`}):i===`video`?a=(0,b.jsx)(d,{size:24,color:`#fff`}):i===`audio`&&(a=(0,b.jsx)(h,{size:24,color:`#fff`})),(0,b.jsxs)(`div`,{"data-id":e.cid,onClick:()=>n(e.cid),onDoubleClick:()=>r(e),className:`card ${t?`selected`:``}`,children:[(0,b.jsx)(`div`,{className:`card-icon ${e.starred?`starred`:`file`}`,children:a}),(0,b.jsx)(`p`,{className:`card-name`,translate:`no`,children:x(e.fileName).name})]})}function Ee({folder:e,onClick:t}){return(0,b.jsxs)(`div`,{onClick:t,className:`card`,children:[(0,b.jsx)(`div`,{className:`card-icon folder`,children:(0,b.jsx)(m,{size:28,color:`#fff`})}),(0,b.jsx)(`p`,{className:`card-name`,translate:`no`,children:e.name})]})}function S(e,t){return e?[{path:``,name:t},...e.split(`/`).filter(Boolean).map((e,t,n)=>({path:n.slice(0,t+1).join(`/`),name:e}))]:[]}function De({items:e,allFolders:t,currentPath:n,onMove:r,onClose:i}){let[a,o]=(0,y.useState)(``),[s,c]=(0,y.useState)(n),{t:l}=me(),u=S(a,l(`move.root`));function ee(){r(a||s.trim())}let d=t.filter(e=>{if(a===``)return!e.path.includes(`/`);let t=a+`/`;return e.path.startsWith(t)?!e.path.substring(t.length).includes(`/`):!1});return(0,b.jsx)(_,{onClose:i,children:(0,b.jsxs)(`div`,{className:`move-modal`,onClick:e=>e.stopPropagation(),children:[(0,b.jsxs)(`div`,{className:`modal-header`,children:[(0,b.jsx)(`h3`,{children:l(`move.title`)}),(0,b.jsx)(`button`,{type:`button`,onClick:i,className:`btn btn-icon`,children:(0,b.jsx)(g,{size:18})})]}),(0,b.jsx)(`p`,{className:`move-modal-desc`,children:l(`move.selectedCount`,{count:e.length})}),(0,b.jsx)(`div`,{className:`move-new-folder`,children:(0,b.jsx)(`input`,{type:`text`,className:`input`,value:s,onChange:e=>c(e.target.value),placeholder:l(`move.pathPlaceholder`),translate:`no`})}),(0,b.jsx)(`p`,{className:`move-modal-hint`,children:l(`move.pathExample`)}),(0,b.jsx)(`div`,{className:`move-breadcrumb`,children:u.map((e,t)=>(0,b.jsxs)(y.Fragment,{children:[t>0&&(0,b.jsx)(`span`,{className:`breadcrumb-separator`,children:`/`}),(0,b.jsx)(`button`,{type:`button`,onClick:()=>{o(e.path),c(e.path)},className:`move-breadcrumb-btn ${a===e.path&&!s?`active`:``}`,children:(0,b.jsx)(`span`,{translate:e.path?`no`:`yes`,children:e.name})})]},e.path))}),(0,b.jsxs)(`div`,{className:`move-folder-list`,children:[d.length===0&&(0,b.jsx)(`p`,{className:`move-modal-empty`,children:l(`move.noSubfolders`)}),d.map(e=>(0,b.jsxs)(`button`,{type:`button`,onClick:()=>o(e.path),className:`move-folder-item ${a===e.path&&!s?`selected`:``}`,children:[(0,b.jsx)(m,{size:16}),(0,b.jsx)(`span`,{translate:`no`,children:e.name})]},e.path))]}),(0,b.jsxs)(`div`,{className:`modal-actions`,children:[(0,b.jsx)(`button`,{type:`button`,onClick:i,className:`btn btn-secondary`,children:l(`common.cancel`)}),(0,b.jsx)(`button`,{type:`button`,onClick:ee,className:`btn btn-primary`,children:l(`move.action`)})]})]})})}var C=`https://most.box`;function Oe(e,t){let n=String(t||``).trim(),r=`${C}/cid/${encodeURIComponent(e)}`;return n?`${r}?filename=${encodeURIComponent(n)}`:r}function w(e){return x(e)}function ke(e){let t=new Set;return e.forEach(e=>{let{folder:n}=w(e.fileName),r=n.split(`/`).filter(Boolean),i=``;for(let e of r)i+=(i?`/`:``)+e,t.add(i)}),[...t].sort()}function Ae(e,t){let n=t?t+`/`:``;return e.filter(e=>{let t=e.toLowerCase().startsWith(n.toLowerCase()),r=e.substring(n.length);return t&&!r.includes(`/`)}).map(e=>({name:e.substring(n.length),path:e}))}function je(e,t,n){return{folders:Ae(t,n),files:e.filter(e=>w(e.fileName).folder===n)}}function Me(e,t){return e?[{path:``,name:t},...e.split(`/`).filter(Boolean).map((e,t,n)=>({path:n.slice(0,t+1).join(`/`),name:e}))]:[]}function Ne(){let e=c(e=>e.addToast),t=c(e=>e.hasBackend),n=c(e=>e.openConnectModal),r=i(e=>e.identity),a=i(e=>e.openLoginModal),[d,p]=(0,y.useState)([]),[m,h]=(0,y.useState)([]),[x,S]=(0,y.useState)(null),[C,Ae]=(0,y.useState)(`all`),[Ne,T]=(0,y.useState)(!1),[E,D]=(0,y.useState)([]),[Pe,O]=(0,y.useState)(null),[k,A]=(0,y.useState)(null),[Fe,Ie]=ce(!1),[Le,Re]=(0,y.useState)(``),[j,M]=(0,y.useState)(null),[N,ze]=(0,y.useState)(!1),[Be,P]=(0,y.useState)([]),[Ve,F]=ce(!1),[I,L]=(0,y.useState)(``),{copy:He,copied:Ue}=we({timeout:2e3}),[We,Ge]=ce(!1),[R,z]=(0,y.useState)(null),[B,Ke]=(0,y.useState)(null),[qe,Je]=(0,y.useState)(!1),{t:V,formatDate:Ye}=me(),H=t===!0,Xe=e=>e?Ye(e):``,U=x||``,Ze=ke(d),{folders:Qe,files:$e}=je(d,Ze,U);function W(){return H?!0:(n(),!1)}function G(){return r?!0:(a(),!1)}let et=I?d.filter(e=>w(e.fileName).name.toLowerCase().includes(I.toLowerCase())):$e,K=async()=>{if(!H||!r){p([]);return}try{p(await v.listPublishedFiles()||[])}catch{p([])}},q=async()=>{if(!H||!r){h([]);return}try{h(await v.listTrashFiles()||[])}catch{h([])}},tt=e=>{D(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},nt=async t=>{if(G()&&W())try{await v.restoreTrashFile(t),e(V(`app.toast.restored`),`success`),K(),q()}catch(t){e(await s(t,V(`app.toast.restoreFailed`)),`error`)}},rt=async()=>{G()&&W()&&z({title:V(`app.clearTrash.title`),message:V(`app.clearTrash.message`),confirmText:V(`app.clear`),danger:!0,onConfirm:async()=>{z(null);try{await v.emptyTrash(),e(V(`app.toast.trashEmptied`),`success`),q()}catch(t){e(await s(t,V(`app.toast.emptyFailed`)),`error`)}}})},it=async t=>{if(G()&&W())try{let n=await v.toggleStar(t);p(e=>e.map(e=>e.cid===t?{...e,starred:n.starred}:e)),e(n.starred?V(`app.toast.favorited`):V(`app.toast.unfavorited`),`success`)}catch(t){e(await s(t,V(`app.toast.actionFailed`)),`error`)}},at=async()=>{if(!G()||!W())return;let t=C===`trash`;z({title:V(t?`app.permanentDelete`:`app.batchDelete`),message:V(t?`app.deleteSelectedPermanent`:`app.deleteSelected`,{count:E.length}),confirmText:V(t?`app.permanentDelete`:`app.delete`),danger:!0,onConfirm:async()=>{z(null);try{for(let e of E)t?await v.permanentDeleteTrashFile(e):e.startsWith(`__`)||await v.deletePublishedFile(e);D([]),e(V(t?`app.toast.deletedPermanently`:`app.toast.deleted`),`success`),K(),q()}catch(t){e(await s(t,V(`app.toast.deleteFailed`)),`error`)}}})},ot=async t=>{if(G()&&W())try{for(let e of E){let n=d.find(t=>t.cid===e);if(!n)continue;let{name:r}=w(n.fileName),i=t?`${t}/${r}`:r;n.fileName!==i&&await v.moveFile(e,i)}D([]),Ge.close(),e(V(`app.toast.moved`),`success`),K()}catch(t){e(await s(t,V(`app.toast.moveFailed`)),`error`)}},st=t=>{let n=!!t.path,r=n?t.name:w(t.fileName).name;Ke({title:V(n?`app.renameFolder`:`app.renameFile`),placeholder:V(`app.enterNewName`),defaultValue:r,confirmText:V(`app.rename`),onConfirm:async i=>{if(i!==r&&G()&&W()){Je(!0);try{if(n){let n=t.path.lastIndexOf(`/`),r=n===-1?``:t.path.substring(0,n),a=r?`${r}/${i}`:i;await v.renameFolder(t.path,a),e(V(`app.toast.renamed`),`success`),K(),Z(a)}else{let{folder:n}=w(t.fileName),r=n?`${n}/${i}`:i;await v.moveFile(t.cid,r),e(V(`app.toast.renamed`),`success`),K()}Ke(null)}catch(t){e(await s(t,V(`app.toast.renameFailed`)),`error`)}finally{Je(!1)}}}})},ct=async t=>{if(!r){a(),e(V(`app.toast.signInBeforePublish`),`warning`);return}if(!W())return;let n=U?U+`/`:``,i=[];for(let r of Array.from(t)){let t=n+r.name;if(d.some(e=>e.fileName===t)){e(V(`app.fileAlreadyExists`,{fileName:r.name}),`warning`);continue}let a=`upload_${Date.now()}_${Math.random().toString(36).slice(2,8)}`,o={id:a,fileName:r.name,progress:0,type:`upload`,status:`uploading`};i.push(o),P(e=>[...e,o]),i.length>0&&F.open();try{(await v.publishFile(r,t)).alreadyExists?(P(e=>e.map(e=>e.id===a?{...e,status:`completed`}:e)),e(V(`app.fileAlreadyExists`,{fileName:r.name}),`warning`)):(P(e=>e.map(e=>e.id===a?{...e,progress:100,status:`completed`}:e)),e(V(`app.fileAddedLocal`,{fileName:r.name}),`success`))}catch(t){P(e=>e.map(e=>e.id===a?{...e,status:`error`}:e)),e(await s(t,V(`app.publishFailedWithFile`,{fileName:r.name})),`error`)}}setTimeout(()=>{P(e=>e.filter(e=>e.status!==`completed`&&e.status!==`error`&&e.status!==`cancelled`))},3e3),K()},lt=k?Oe(k.cid,k.fileName):``,ut=()=>{lt&&He(lt)},[J,dt]=(0,y.useState)(!1),Y=Le.trim(),X=j?.status===`success`&&j.link===Y,ft=()=>{Ie.close(),M(null)},pt=e=>{Re(e.target.value),M(null)},mt=async()=>{let t=ye(Y,V);if(t){M({status:`error`,link:Y,message:t}),e(t,`warning`);return}if(!(N||J)&&G()&&W()){ze(!0),M(null);try{let t=await v.checkDownload(Y);M({status:`success`,link:Y,message:t.alreadyExists?V(`app.fileAlreadyLocal`,{fileName:t.fileName}):V(`app.fileAvailable`,{fileName:t.fileName})}),e(t.alreadyExists?V(`app.fileAlreadyExists`,{fileName:t.fileName}):V(`app.toast.checkPassed`),t.alreadyExists?`warning`:`success`)}catch(t){let n=await ve(t);M({status:`error`,link:Y,message:n}),e(n,`error`)}finally{ze(!1)}}},ht=async()=>{if(!r){a(),e(V(`app.toast.signInBeforeDownload`),`warning`);return}if(!W())return;let t=ye(Y,V);if(t){e(t,`warning`);return}if(!X){e(V(`app.toast.checkLinkFirst`),`warning`);return}if(!J){dt(!0);try{let t=await v.downloadFile(Y);if(Re(``),M(null),ft(),t.alreadyExists)e(V(`app.fileAlreadyExists`,{fileName:t.fileName}),`warning`);else{let n={id:t.taskId,fileName:V(`app.downloadFallbackName`),progress:0,type:`download`,status:`downloading`};P(e=>[...e,n]),F.open(),e(V(`app.toast.downloadStarted`),`info`)}}catch(t){e(await s(t,V(`app.toast.downloadFailed`)),`error`)}finally{dt(!1)}}},gt=async t=>{if(G()&&W()&&t.type===`download`&&t.status===`downloading`){P(e=>e.map(e=>e.id===t.id?{...e,status:`cancelling`}:e));try{await v.cancelDownload(t.id)}catch(n){P(e=>e.map(e=>e.id===t.id?{...e,status:`downloading`}:e)),e(await s(n,V(`app.toast.cancelFailed`)),`error`)}}},_t=async t=>{if(G()&&W()){if(t.localAvailable===!1){e(V(`app.toast.fileNotLocal`),`warning`);return}try{let n=await fetch(v.getFileDownloadUrl(t.cid),{headers:await o(`GET`,`/api/files/${t.cid}/download`)});if(!n.ok)throw Error(V(`app.toast.getFileFailed`));let r=await n.blob(),i=window.showSaveFilePicker;if(i){let n=await(await i({suggestedName:t.fileName})).createWritable();await n.write(r),await n.close(),e(V(`app.toast.fileSaved`),`success`)}else{let n=URL.createObjectURL(r),i=document.createElement(`a`);i.href=n,i.download=t.fileName,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(n),e(V(`app.toast.fileDownloaded`),`success`)}}catch(t){t.name!==`AbortError`&&e(V(`app.saveFailedWithError`,{error:t.message}),`error`)}}},vt=async t=>{if(G()&&W())try{e(V(`app.toast.startPullLocal`),`info`),await v.cacheFile(t.cid),e(V(`app.toast.pulledAndSeeding`),`success`),K()}catch(t){e(await s(t,V(`app.toast.pullFailed`)),`error`)}},Z=e=>{S(e||null),D([])};(0,y.useEffect)(()=>{if(t!==!0)return;let n=null,r=!1;return(async()=>{if(n=new WebSocket(await l(`/ws`)),r){n.close();return}n.onmessage=t=>{try{let{event:n,data:r}=JSON.parse(t.data);if(n===`publish:success`||n===`download:success`){K();let t=r.taskId||r.fileName;P(e=>e.map(e=>e.id===t||e.fileName===r.fileName?{...e,progress:100,status:`completed`}:e)),n===`download:success`&&(r.alreadyExists?e(V(`app.fileAlreadyExists`,{fileName:r.fileName}),`warning`):e(V(`app.fileDownloadCompleted`,{fileName:r.fileName}),`success`),setTimeout(()=>{P(e=>e.filter(e=>!(e.id===t&&e.status===`completed`)))},3e3))}n===`publish:progress`&&P(e=>e.map(e=>{if(r.file&&e.fileName===r.file&&e.type===`upload`){let t=50;return r.stage===`calculating-cid`?t=25:r.stage===`uploading`?t=75:r.stage===`complete`&&(t=100),{...e,progress:t}}return e})),n===`download:progress`&&P(e=>e.map(e=>e.id===r.taskId?{...e,progress:r.percent||0,loaded:r.loaded,total:r.total}:e)),n===`download:error`&&(P(e=>e.map(e=>e.id===r.taskId?{...e,status:`error`}:e)),e(V(`app.downloadFailedWithError`,{error:r.error}),`error`)),n===`download:status`&&P(e=>e.map(e=>e.id===r.taskId?{...e,fileName:r.file||e.fileName}:e)),n===`download:cancelled`&&(P(e=>e.map(e=>e.id===r.taskId?{...e,status:`cancelled`}:e)),e(V(`app.toast.downloadCancelled`),`warning`)),n===`user:metadata:updated`&&(K(),q())}catch(e){console.warn(`[App WS] Failed to parse message:`,e.message)}}})(),()=>{r=!0,n?.close()}},[t,r?.address]),(0,y.useEffect)(()=>{if(t===!0&&r){K(),q();return}t===!1&&(p([]),h([]))},[t,r?.address]),(0,y.useEffect)(()=>{r||(D([]),O(null),A(null),Re(``),M(null),P([]),L(``),S(null),Ae(`all`))},[r?.address]);let yt=V(C===`all`?`app.nav.local`:C===`starred`?`app.nav.favorites`:`app.nav.trash`),Q=C===`all`?et:C===`starred`?d.filter(e=>e.starred&&w(e.fileName).name.toLowerCase().includes(I.toLowerCase())):m.filter(e=>w(e.fileName).name.toLowerCase().includes(I.toLowerCase())),bt=C===`starred`?[]:Qe.filter(e=>e.name.toLowerCase().includes(I.toLowerCase())),$=Me(U,V(`app.allContent`));return(0,b.jsxs)(le,{sidebar:({closeSidebar:e})=>(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(ue,{onNavigate:e}),(0,b.jsx)(`nav`,{className:`sidebar-nav`,children:[{id:`all`,icon:(0,b.jsx)(xe,{size:18}),label:V(`app.nav.local`)},{id:`starred`,icon:(0,b.jsx)(Ce,{size:18}),label:V(`app.nav.favorites`)},{id:`trash`,icon:(0,b.jsx)(fe,{size:18}),label:V(`app.nav.trash`)}].map(t=>(0,b.jsxs)(`button`,{onClick:()=>{Ae(t.id),S(null),D([]),L(``),e()},className:`sidebar-nav-btn ${C===t.id?`active`:``}`,children:[t.icon,(0,b.jsx)(`span`,{children:t.label})]},t.id))})]}),headerTitle:(0,b.jsx)(`h2`,{className:`header-title`,children:yt}),headerRight:(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(`div`,{className:`search-box`,children:[(0,b.jsx)(de,{size:14}),(0,b.jsx)(`input`,{type:`text`,value:I,onChange:e=>L(e.target.value),placeholder:V(`app.search.placeholder`)}),I&&(0,b.jsx)(`button`,{onClick:()=>L(``),children:(0,b.jsx)(g,{size:12})})]}),C===`trash`&&m.length>0&&(0,b.jsx)(`button`,{onClick:rt,className:`btn btn-sm btn-empty-trash`,children:V(`app.emptyTrash`)}),(0,b.jsx)(`button`,{onClick:()=>F.open(),className:`btn btn-icon`,children:(0,b.jsx)(be,{size:16})})]}),children:[C===`all`&&(0,b.jsxs)(`div`,{className:`action-grid`,children:[(0,b.jsxs)(`div`,{className:`action-card upload ${Ne?`drag-over`:``}`,onDragOver:e=>{e.preventDefault(),T(!0)},onDragLeave:()=>T(!1),onDrop:e=>{e.preventDefault(),T(!1),!(!G()||!W())&&ct(e.dataTransfer.files)},children:[(0,b.jsx)(`input`,{type:`file`,multiple:!0,onClick:e=>{(!G()||!W())&&e.preventDefault()},onChange:e=>ct(e.target.files),className:`action-card-input`}),(0,b.jsx)(pe,{size:20,className:`action-grid-icon`}),(0,b.jsx)(`p`,{children:V(`app.publishFile`)})]}),(0,b.jsxs)(`div`,{className:`action-card action-card-download`,onClick:()=>{!G()||!W()||Ie.open()},children:[(0,b.jsx)(ae,{size:20,className:`action-grid-icon`}),(0,b.jsx)(`p`,{children:V(`app.downloadFile`)})]})]}),C===`all`&&(0,b.jsx)(`div`,{className:`breadcrumb`,children:U?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(`button`,{onClick:()=>Z(``),children:V(`app.allContent`)}),$.slice(1).map((e,t)=>(0,b.jsxs)(y.Fragment,{children:[(0,b.jsx)(re,{size:12}),(0,b.jsx)(`button`,{onClick:()=>Z(e.path),className:t===$.length-2?`current`:``,children:(0,b.jsx)(`span`,{translate:`no`,children:e.name})}),t===$.length-2&&(0,b.jsx)(`button`,{onClick:()=>st(e),className:`breadcrumb-edit-btn`,children:(0,b.jsx)(ee,{size:12})})]},e.path))]}):null}),(0,b.jsxs)(`div`,{className:`content-grid`,children:[C===`trash`&&(Q.length===0?(0,b.jsxs)(`div`,{className:`empty-state app-empty-state`,children:[(0,b.jsx)(`p`,{children:V(I?`app.noMatches`:`app.trashEmpty`)}),(0,b.jsx)(u,{label:V(`app.openFileNavigation`)})]}):(0,b.jsx)(`div`,{className:`file-grid`,children:Q.map(e=>(0,b.jsxs)(`div`,{onClick:()=>D(t=>t.includes(e.cid)?t.filter(t=>t!==e.cid):[...t,e.cid]),onDoubleClick:()=>nt(e.cid),className:`card ${E.includes(e.cid)?`selected`:``}`,children:[(0,b.jsx)(`div`,{className:`card-icon trash`,children:(0,b.jsx)(oe,{size:24,color:`#fff`})}),(0,b.jsx)(`p`,{className:`card-name`,translate:`no`,children:w(e.fileName).name}),(0,b.jsx)(`p`,{className:`card-date`,children:V(`app.deletedOn`,{date:Xe(e.deletedAt)})})]},e.cid))})),C!==`trash`&&(Q.length===0&&bt.length===0?(0,b.jsxs)(`div`,{className:`empty-state app-empty-state`,children:[(0,b.jsx)(`p`,{children:V(I?`app.noMatches`:C===`starred`?`app.noFavorites`:`app.noLocalFiles`)}),(0,b.jsx)(u,{label:V(`app.openFileNavigation`)})]}):(0,b.jsxs)(`div`,{className:`file-grid`,children:[bt.map(e=>(0,b.jsx)(Ee,{folder:e,onClick:()=>Z(e.path)},e.path)),Q.map(t=>(0,b.jsx)(Te,{file:t,isSelected:E.includes(t.cid),onSelect:tt,onPreview:t=>{if(t.localAvailable===!1){e(V(`app.toast.fileNotLocal`),`warning`);return}O({...t,subtype:f(t.fileName)})}},t.cid))]}))]}),R&&(0,b.jsx)(ge,{title:R.title,message:R.message,confirmText:R.confirmText,danger:R.danger,onConfirm:R.onConfirm,onClose:()=>z(null)}),B&&(0,b.jsx)(he,{title:B.title,placeholder:B.placeholder,defaultValue:B.defaultValue,confirmText:B.confirmText,isLoading:qe,onConfirm:B.onConfirm,onClose:()=>Ke(null)}),We&&(0,b.jsx)(De,{items:E.map(e=>d.find(t=>t.cid===e)).filter(Boolean),allFolders:Ze.map(e=>({path:e,name:e.split(`/`).pop()})),currentPath:U,onMove:ot,onClose:()=>Ge.close()}),k&&(0,b.jsx)(_,{onClose:()=>A(null),children:(0,b.jsxs)(`div`,{className:`share-modal`,onClick:e=>e.stopPropagation(),children:[(0,b.jsxs)(`div`,{className:`modal-header`,children:[(0,b.jsx)(`h3`,{children:V(`app.shareLink`)}),(0,b.jsx)(`button`,{onClick:()=>A(null),className:`btn btn-icon`,children:(0,b.jsx)(g,{size:18})})]}),(0,b.jsxs)(`div`,{className:`share-link-box`,children:[(0,b.jsx)(`div`,{className:`share-link-text`,translate:`no`,children:lt}),(0,b.jsx)(`button`,{onClick:ut,className:`btn btn-circle btn-primary ${Ue?`copied`:``}`,children:Ue?(0,b.jsx)(ne,{size:18}):(0,b.jsx)(ie,{size:18})})]}),(0,b.jsx)(`div`,{className:`share-storage-note`,children:(0,b.jsx)(`span`,{children:V(`app.shareSeedNote`)})})]})}),Fe&&(0,b.jsx)(_,{onClose:ft,children:(0,b.jsxs)(`div`,{className:`download-modal`,onClick:e=>e.stopPropagation(),children:[(0,b.jsxs)(`div`,{className:`modal-header`,children:[(0,b.jsx)(`h3`,{children:V(`app.downloadFile`)}),(0,b.jsx)(`button`,{onClick:ft,className:`btn btn-icon`,children:(0,b.jsx)(g,{size:18})})]}),(0,b.jsxs)(`div`,{className:`download-link-row`,children:[(0,b.jsx)(`input`,{type:`text`,className:`input`,value:Le,onChange:pt,placeholder:V(`app.downloadLink.placeholder`)}),(0,b.jsxs)(`button`,{type:`button`,onClick:mt,disabled:!Y||N||J,className:`btn btn-secondary download-check-btn`,children:[N?(0,b.jsx)(se,{size:14,className:`spin`}):X?(0,b.jsx)(ne,{size:14}):(0,b.jsx)(de,{size:14}),V(N?`app.checking`:X?`app.passed`:`app.check`)]})]}),j&&(0,b.jsxs)(`div`,{className:`download-check-status ${j.status}`,children:[j.status===`success`?(0,b.jsx)(ne,{size:14}):(0,b.jsx)(Se,{size:14}),(0,b.jsx)(`span`,{children:j.message})]}),(0,b.jsxs)(`button`,{onClick:ht,disabled:!X||J||N,className:`btn btn-info btn-full`,children:[J?(0,b.jsx)(se,{size:14,className:`spin`}):(0,b.jsx)(ae,{size:14}),V(J?`app.downloading`:`app.startDownload`)]})]})}),Pe&&(0,b.jsx)(te,{item:Pe,isBackendReady:H,getFileDownloadUrl:v.getFileDownloadUrl,onClose:()=>O(null)}),E.length>0&&(0,b.jsxs)(`div`,{className:`batch-bar`,children:[(0,b.jsx)(`span`,{className:`batch-info`,children:V(`app.selectedItems`,{count:E.length})}),(0,b.jsx)(`button`,{onClick:()=>D([]),className:`batch-dismiss`,children:(0,b.jsx)(g,{size:16})}),(0,b.jsx)(`div`,{className:`batch-divider`}),C===`trash`?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(`button`,{onClick:async()=>{G()&&W()&&(await Promise.all(E.map(e=>v.restoreTrashFile(e))),D([]),e(V(`app.toast.restored`),`success`),K(),q())},className:`btn btn-sm`,children:V(`app.restore`)}),(0,b.jsx)(`button`,{onClick:at,className:`btn btn-sm btn-danger`,children:V(`app.permanentDelete`)})]}):(0,b.jsxs)(b.Fragment,{children:[E.length===1&&(()=>{let e=d.find(e=>e.cid===E[0]);return e&&f(e.fileName)!==`file`})()&&(0,b.jsx)(`button`,{onClick:()=>{let t=d.find(e=>e.cid===E[0]);if(t){if(t.localAvailable===!1){e(V(`app.toast.fileNotLocal`),`warning`);return}let n=f(t.fileName);O({...t,subtype:n})}},className:`btn btn-sm`,children:V(`app.preview`)}),(0,b.jsx)(`button`,{onClick:()=>{let e=E.some(e=>{let t=d.find(t=>t.cid===e);return t&&!t.starred});E.forEach(t=>{let n=d.find(e=>e.cid===t);n&&(e?!n.starred:n.starred)&&it(t)})},className:`btn btn-sm btn-star`,children:V(`app.favorite`)}),E.length===1&&(0,b.jsx)(`button`,{onClick:()=>{let e=d.find(e=>e.cid===E[0]);e&&st(e)},className:`btn btn-sm`,children:V(`app.rename`)}),(0,b.jsx)(`button`,{onClick:()=>Ge.open(),className:`btn btn-sm btn-move`,children:V(`app.move`)}),(0,b.jsx)(`button`,{onClick:at,className:`btn btn-sm btn-danger`,children:V(`app.delete`)}),E.length===1&&(()=>{let e=d.find(e=>e.cid===E[0]);return e&&e.localAvailable===!1})()&&(0,b.jsx)(`button`,{onClick:()=>{let e=d.find(e=>e.cid===E[0]);e&&vt(e)},className:`btn btn-sm`,children:V(`app.pullToLocal`)}),E.length===1&&(0,b.jsx)(`button`,{onClick:()=>A(d.find(e=>e.cid===E[0])),className:`btn btn-sm`,children:V(`app.share`)}),E.length===1&&(0,b.jsx)(`button`,{onClick:()=>{let e=d.find(e=>e.cid===E[0]);e&&_t(e)},className:`btn btn-sm`,children:V(`app.saveAs`)})]})]}),Ve&&(0,b.jsx)(_,{onClose:()=>F.close(),children:(0,b.jsxs)(`div`,{className:`transfer-modal`,onClick:e=>e.stopPropagation(),children:[(0,b.jsxs)(`div`,{className:`modal-header`,children:[(0,b.jsx)(`h3`,{children:V(`app.transfers`)}),(0,b.jsx)(`button`,{onClick:()=>F.close(),className:`btn btn-icon`,children:(0,b.jsx)(g,{size:18})})]}),Be.length===0?(0,b.jsx)(`div`,{className:`empty-transfer`,children:V(`app.noTransfers`)}):Be.map(e=>(0,b.jsxs)(`div`,{className:`transfer-item`,children:[(0,b.jsxs)(`div`,{className:`transfer-item-header`,children:[e.type===`upload`?(0,b.jsx)(pe,{size:14}):(0,b.jsx)(ae,{size:14}),(0,b.jsx)(`span`,{className:`transfer-item-name`,translate:`no`,children:e.fileName}),e.status===`downloading`&&e.type===`download`&&(0,b.jsx)(`button`,{onClick:()=>gt(e),className:`transfer-item-cancel`,children:(0,b.jsx)(g,{size:14})})]}),(0,b.jsxs)(`div`,{className:`transfer-progress-row`,children:[(0,b.jsx)(`progress`,{className:`transfer-progress-meter ${e.type===`download`?`download`:``} ${e.status===`error`?`error`:``} ${e.status===`cancelled`?`cancelled`:``}`,value:Math.max(0,Math.min(100,e.progress)),max:100,"aria-label":V(`app.transferProgress`,{fileName:e.fileName})}),(0,b.jsx)(`span`,{className:`transfer-progress-text`,children:e.status===`completed`?V(`app.completed`):e.status===`error`?V(`app.failed`):e.status===`cancelled`?V(`app.cancelled`):e.status===`cancelling`?V(`app.cancelling`):e.loaded&&e.total?`${_e(e.loaded)}/${_e(e.total)}`:`${e.progress}%`})]})]},e.id))]})})]})}var T=a(`/app/`)({component:Ne});export{T as Route};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{n as e,o as t,t as n}from"./jsx-runtime-Bt-cYkS5.js";import{B as r,H as i,W as a}from"./useAppStore-DOnk608w.js";import{n as o,t as s}from"./smartphone-JXH-zQXB.js";import{t as c}from"./download-COQOcPqI.js";import{A as l,D as u}from"./index-DjBN7bZV.js";import{t as d}from"./MarketingHeader-BVJy8hXd.js";import{n as f}from"./format-CR8oUWq6.js";var p=r(`apple`,[[`path`,{d:`M12 6.528V3a1 1 0 0 1 1-1h0`,key:`11qiee`}],[`path`,{d:`M18.237 21A15 15 0 0 0 22 11a6 6 0 0 0-10-4.472A6 6 0 0 0 2 11a15.1 15.1 0 0 0 3.763 10 3 3 0 0 0 3.648.648 5.5 5.5 0 0 1 5.178 0A3 3 0 0 0 18.237 21`,key:`110c12`}]]),m=r(`code`,[[`path`,{d:`m16 18 6-6-6-6`,key:`eg8j8`}],[`path`,{d:`m8 6-6 6 6 6`,key:`ppft3o`}]]),h=r(`laptop`,[[`path`,{d:`M18 5a2 2 0 0 1 2 2v8.526a2 2 0 0 0 .212.897l1.068 2.127a1 1 0 0 1-.9 1.45H3.62a1 1 0 0 1-.9-1.45l1.068-2.127A2 2 0 0 0 4 15.526V7a2 2 0 0 1 2-2z`,key:`1pdavp`}],[`path`,{d:`M20.054 15.987H3.946`,key:`14rxg9`}]]),g=r(`monitor`,[[`rect`,{width:`20`,height:`14`,x:`2`,y:`3`,rx:`2`,key:`48i651`}],[`line`,{x1:`8`,x2:`16`,y1:`21`,y2:`21`,key:`1svkeh`}],[`line`,{x1:`12`,x2:`12`,y1:`17`,y2:`21`,key:`vw1qmm`}]]),_=r(`tablet-smartphone`,[[`rect`,{width:`10`,height:`14`,x:`3`,y:`8`,rx:`2`,key:`1vrsiq`}],[`path`,{d:`M5 4a2 2 0 0 1 2-2h12a2 2 0 0 1 2 2v16a2 2 0 0 1-2 2h-2.4`,key:`1j4zmg`}],[`path`,{d:`M8 18h.01`,key:`lrp35t`}]]),v=t(e(),1),y=[`windows`,`macos`,`linux`],b=[`x64`,`arm64`],x=[`installer`];Object.freeze([{platform:`windows`,arch:`x64`},{platform:`windows`,arch:`arm64`},{platform:`macos`,arch:`x64`},{platform:`macos`,arch:`arm64`},{platform:`linux`,arch:`x64`},{platform:`linux`,arch:`arm64`}]);var S=new Set(y),C=new Set(b),w=new Set(x);function T(e){return typeof e==`object`&&!!e}function E(e){return typeof e==`string`&&e.trim().length>0}function D(e){return Number.isFinite(e)&&e>0}function O(e){return e===void 0||E(e)}function k(e){return T(e)?S.has(e.platform)&&C.has(e.arch)&&w.has(e.kind)&&E(e.filename)&&D(e.size)&&E(e.cid)&&E(e.githubUrl)&&O(e.r2Url):!1}function A(e){return!T(e)||!E(e.version)||!E(e.publishedAt)||!Array.isArray(e.assets)?!1:e.assets.every(k)}function j(e){return`${e.platform}:${e.arch}`}function M(e){return A(e)?e.assets.filter(e=>e.kind===`installer`):[]}function N(e){return Array.isArray(e)?e.some(e=>T(e)&&E(e.r2Url)):!1}function P(e,t=`r2`){return t===`r2`&&T(e)&&E(e.r2Url)?{source:`r2`,url:e.r2Url}:{source:`github`,url:T(e)&&E(e.githubUrl)?e.githubUrl:``}}var F=`https://github.com/most-people/most/releases/latest`,I=[{platform:`windows`,arch:`x64`,kind:`installer`,filename:`GitHub Releases`,githubUrl:F},{platform:`windows`,arch:`arm64`,kind:`installer`,filename:`GitHub Releases`,githubUrl:F},{platform:`macos`,arch:`x64`,kind:`installer`,filename:`GitHub Releases`,githubUrl:F},{platform:`macos`,arch:`arm64`,kind:`installer`,filename:`GitHub Releases`,githubUrl:F},{platform:`linux`,arch:`x64`,kind:`installer`,filename:`GitHub Releases`,githubUrl:F},{platform:`linux`,arch:`arm64`,kind:`installer`,filename:`GitHub Releases`,githubUrl:F}];function L(e){return e.VITE_RELEASE_MANIFEST_URL||`${(e.VITE_R2_PUBLIC_BASE_URL||`https://download.most.box`).replace(/\/+$/,``)}/releases/latest.json`}function R({manifest:e,currentKey:t,requestedSource:n}){let r=e?M(e):[],i=r.length?r:I,a=N(i),o=n===`r2`&&a?`r2`:`github`,s=i.find(e=>j(e)===t)||null;return{assets:i,currentAsset:s,otherAssets:s?i.filter(e=>j(e)!==t):i,hasR2Assets:a,activeSource:o,currentDownload:s?P(s,o):null}}function z(e,t){return P(e,t)}var B=n(),V=L({VITE_RELEASE_MANIFEST_URL:void 0,VITE_R2_PUBLIC_BASE_URL:void 0}),H={windows:{name:`Windows`,ext:`.exe`,descKey:`download.platform.windows.desc`,icon:g},macos:{name:`macOS`,ext:`.dmg`,descKey:`download.platform.macos.desc`,icon:p},linux:{name:`Linux`,ext:`.AppImage`,descKey:`download.platform.linux.desc`,icon:h}},U=[{key:`ios`,nameKey:`download.platform.ios.name`,descKey:`download.platform.ios.desc`,icon:s},{key:`android`,nameKey:`download.platform.android.name`,descKey:`download.platform.android.desc`,icon:_}];function W(){return[navigator.userAgentData?.platform,navigator.platform,navigator.userAgent].filter(Boolean).join(` `).toLowerCase()}function G(){if(typeof navigator>`u`)return`windows:x64`;let e=W(),t=/arm|aarch64/.test(e)?`arm64`:`x64`;return/mac|darwin/.test(e)?`macos:${t}`:/linux/.test(e)?`linux:${t}`:`windows:${t}`}function K(){let{t:e}=l(),[t,n]=(0,v.useState)(null),[r,i]=(0,v.useState)(V?`loading`:`fallback`),[a,s]=(0,v.useState)(`windows:x64`),[d,p]=(0,v.useState)(`r2`);(0,v.useEffect)(()=>{s(G())},[]),(0,v.useEffect)(()=>{if(!V)return;let e=new AbortController;return fetch(V,{cache:`no-store`,signal:e.signal}).then(e=>{if(!e.ok)throw Error(`Manifest request failed: ${e.status}`);return e.json()}).then(e=>{if(!A(e))throw Error(`Invalid download manifest`);n(e),i(`ready`)}).catch(e=>{e instanceof DOMException&&e.name===`AbortError`||(n(null),i(`fallback`))}),()=>e.abort()},[]),(0,v.useEffect)(()=>{r===`fallback`&&p(`github`)},[r]);let{currentAsset:h,otherAssets:g,hasR2Assets:_,activeSource:y}=R({manifest:t,currentKey:a,requestedSource:d}),b=t=>z(t,y).source===`r2`?e(`download.source.r2Mirror`):`GitHub Releases`,x=e=>z(e,y).url,S=t=>{let n=H[t.platform],r=n.icon;return(0,B.jsxs)(`article`,{className:`download-current-card`,children:[(0,B.jsxs)(`div`,{className:`download-current-main`,children:[(0,B.jsx)(`div`,{className:`download-current-icon`,children:(0,B.jsx)(r,{size:34})}),(0,B.jsxs)(`div`,{className:`download-current-copy`,children:[(0,B.jsxs)(`div`,{className:`download-current-labels`,children:[(0,B.jsxs)(`span`,{className:`download-current-kicker`,children:[(0,B.jsx)(u,{size:14}),e(`download.platform.currentSystem`)]}),(0,B.jsx)(`span`,{className:`download-current-recommended`,children:e(`download.platform.recommended`)})]}),(0,B.jsxs)(`div`,{className:`download-current-heading`,children:[(0,B.jsx)(`h3`,{children:n.name}),(0,B.jsx)(`span`,{children:t.arch})]}),(0,B.jsx)(`p`,{children:e(n.descKey)}),(0,B.jsxs)(`dl`,{className:`download-current-meta`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`dt`,{children:e(`download.platform.source`)}),(0,B.jsx)(`dd`,{children:b(t)})]}),t.size?(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`dt`,{children:e(`download.platform.size`)}),(0,B.jsx)(`dd`,{children:f(t.size)})]}):null,t.cid?(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`dt`,{children:`CID`}),(0,B.jsx)(`dd`,{children:t.cid.slice(0,12)})]}):null]})]})]}),(0,B.jsxs)(`div`,{className:`download-current-actions`,children:[(0,B.jsx)(`span`,{children:e(`download.platform.matchedSystem`)}),(0,B.jsxs)(`a`,{href:x(t),className:`btn btn-primary`,children:[(0,B.jsx)(c,{size:17}),e(`download.platform.action`,{ext:n.ext})]}),(0,B.jsx)(`p`,{children:b(t)})]})]})},C=t=>{let n=H[t.platform],r=n.icon,i=j(t),o=i===a;return(0,B.jsxs)(`article`,{className:[`download-platform-card`,o?`is-recommended`:``].filter(Boolean).join(` `),children:[(0,B.jsx)(`div`,{className:`download-platform-icon`,children:(0,B.jsx)(r,{size:32})}),(0,B.jsxs)(`div`,{className:`download-platform-content`,children:[(0,B.jsxs)(`div`,{className:`download-platform-heading`,children:[(0,B.jsx)(`h3`,{children:n.name}),(0,B.jsx)(`span`,{children:t.arch})]}),(0,B.jsx)(`p`,{children:e(n.descKey)}),(0,B.jsxs)(`dl`,{className:`download-platform-meta`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`dt`,{children:e(`download.platform.source`)}),(0,B.jsx)(`dd`,{children:b(t)})]}),t.size?(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`dt`,{children:e(`download.platform.size`)}),(0,B.jsx)(`dd`,{children:f(t.size)})]}):null,t.cid?(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`dt`,{children:`CID`}),(0,B.jsx)(`dd`,{children:t.cid.slice(0,12)})]}):null]}),(0,B.jsx)(`div`,{className:`download-platform-actions`,children:(0,B.jsxs)(`a`,{href:x(t),className:`btn btn-primary`,children:[(0,B.jsx)(c,{size:16}),e(`download.platform.action`,{ext:n.ext})]})})]}),o?(0,B.jsx)(`span`,{className:`download-recommended-badge`,children:e(`download.platform.current`)}):null]},i)},w=t=>{let n=t.icon;return(0,B.jsxs)(`article`,{className:`download-coming-soon-card`,children:[(0,B.jsx)(`div`,{className:`download-platform-icon download-coming-soon-icon`,children:(0,B.jsx)(n,{size:32})}),(0,B.jsxs)(`div`,{className:`download-platform-content`,children:[(0,B.jsxs)(`div`,{className:`download-platform-heading`,children:[(0,B.jsx)(`h3`,{children:e(t.nameKey)}),(0,B.jsx)(`span`,{children:e(`download.platform.comingSoon`)})]}),(0,B.jsx)(`p`,{children:e(t.descKey)})]})]},t.key)};return(0,B.jsxs)(`div`,{className:`download-options`,children:[(0,B.jsxs)(`div`,{className:`ui-segmented-control download-source-tabs`,role:`tablist`,"aria-label":e(`download.source.label`),children:[(0,B.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":y===`r2`,disabled:!_,className:y===`r2`?`ui-segmented-option download-source-tab is-active`:`ui-segmented-option download-source-tab`,onClick:()=>p(`r2`),children:[(0,B.jsx)(o,{size:15}),`Cloudflare R2`]}),(0,B.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":y===`github`,className:y===`github`?`ui-segmented-option download-source-tab is-active`:`ui-segmented-option download-source-tab`,onClick:()=>p(`github`),children:[(0,B.jsx)(m,{size:15}),`GitHub Releases`]})]}),(0,B.jsx)(`p`,{className:`download-source-note`,children:r===`loading`?e(`download.source.loading`):r===`ready`&&t?e(`download.source.ready`,{version:t.version}):e(`download.source.fallback`)}),h?(0,B.jsx)(`div`,{className:`download-current-platform`,"aria-label":e(`download.platform.currentSystem`),children:S(h)}):null,g.length?(0,B.jsxs)(`div`,{className:`download-other-platforms`,children:[(0,B.jsx)(`p`,{className:`download-other-platforms-title`,children:e(`download.platform.otherPlatforms`)}),(0,B.jsx)(`div`,{className:`download-platform-grid`,children:g.map(e=>C(e))}),(0,B.jsxs)(`div`,{className:`download-coming-soon`,children:[(0,B.jsx)(`p`,{className:`download-coming-soon-title`,children:e(`download.platform.mobilePlatforms`)}),(0,B.jsx)(`div`,{className:`download-coming-soon-grid`,children:U.map(e=>w(e))})]})]}):null]})}var q=[{featureKey:`download.comparison.node`,webKey:`download.comparison.webConnectsNode`,desktopKey:`download.comparison.desktopBuiltinNode`},{featureKey:`download.comparison.fileSharing`,webKey:`download.comparison.webDependsNode`,desktopKey:`download.comparison.desktopFull`},{featureKey:`download.comparison.verification`,webKey:`download.comparison.webDependsNode`,desktopKey:`download.comparison.desktopFull`},{featureKey:`download.comparison.seeding`,webKey:`download.comparison.webDependsNode`,desktopKey:`download.comparison.desktopDefaultOn`},{featureKey:`download.comparison.largeFiles`,webKey:`download.comparison.webDependsNode`,desktopKey:`download.comparison.desktop10gb`}];function J(){let{t:e}=l();return(0,v.useEffect)(()=>{document.title=e(`download.meta.title`)},[e]),(0,B.jsxs)(`div`,{className:`download-page`,children:[(0,B.jsx)(d,{}),(0,B.jsx)(`section`,{className:`download-hero`,children:(0,B.jsxs)(`div`,{className:`mkt-container`,children:[(0,B.jsx)(`div`,{className:`download-hero-icon`,children:(0,B.jsx)(c,{size:40})}),(0,B.jsx)(`h1`,{className:`download-hero-title`,children:e(`download.hero.title`)}),(0,B.jsx)(`p`,{className:`download-hero-desc`,children:e(`download.hero.desc`)})]})}),(0,B.jsx)(`section`,{className:`download-platforms`,children:(0,B.jsxs)(`div`,{className:`mkt-container`,children:[(0,B.jsx)(`h2`,{className:`download-section-title`,children:e(`download.platforms.title`)}),(0,B.jsx)(K,{})]})}),(0,B.jsx)(`section`,{className:`download-comparison`,children:(0,B.jsxs)(`div`,{className:`mkt-container`,children:[(0,B.jsx)(`h2`,{className:`download-section-title`,children:e(`download.comparison.title`)}),(0,B.jsx)(`div`,{className:`download-table-wrap`,children:(0,B.jsxs)(`table`,{className:`download-table`,children:[(0,B.jsx)(`thead`,{children:(0,B.jsxs)(`tr`,{children:[(0,B.jsx)(`th`,{children:e(`download.comparison.feature`)}),(0,B.jsx)(`th`,{children:e(`download.comparison.web`)}),(0,B.jsx)(`th`,{children:e(`download.comparison.desktop`)})]})}),(0,B.jsx)(`tbody`,{children:q.map(t=>(0,B.jsxs)(`tr`,{children:[(0,B.jsx)(`td`,{children:e(t.featureKey)}),(0,B.jsx)(`td`,{className:`col-web`,children:e(t.webKey)}),(0,B.jsx)(`td`,{className:`col-desktop`,children:e(t.desktopKey)})]},t.featureKey))})]})})]})}),(0,B.jsx)(`section`,{className:`download-cta`,children:(0,B.jsx)(`div`,{className:`mkt-container`,children:(0,B.jsx)(`p`,{className:`download-hero-desc`,children:e(`download.npmNote`)})})}),(0,B.jsx)(`section`,{className:`download-cta`,children:(0,B.jsx)(`div`,{className:`mkt-container`,children:(0,B.jsx)(a,{to:`/`,className:`btn btn-primary`,children:e(`common.backHome`)})})}),(0,B.jsx)(`footer`,{className:`mkt-footer`,children:(0,B.jsx)(`div`,{className:`mkt-container`,children:(0,B.jsx)(`div`,{className:`mkt-footer-inner`,children:(0,B.jsx)(`p`,{className:`mkt-footer-copy`,children:`MostBox`})})})})]})}var Y=i(`/download/`)({component:J});export{Y as Route};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{n as e,o as t,t as n}from"./jsx-runtime-Bt-cYkS5.js";import{B as r,H as i,W as a,t as o}from"./useAppStore-DOnk608w.js";import{t as s}from"./arrow-right-CXzRt0Fp.js";import{t as c}from"./check-iBCQl0yr.js";import{t as l}from"./download-COQOcPqI.js";import{t as u}from"./external-link-D6tHlYgS.js";import{t as d}from"./folder-open-Di0oALaC.js";import{t as f}from"./hard-drive-Cqa7Rstj.js";import{t as p}from"./message-square-BgsNXPft.js";import{t as m}from"./notebook-pen-SWT-zZ4v.js";import{t as h}from"./wallet-D9Iw4YWE.js";import{A as g,C as _,b as v}from"./index-DjBN7bZV.js";import{t as y}from"./MarketingLayout-Cltu-DRw.js";var b=r(`arrow-up-right`,[[`path`,{d:`M7 7h10v10`,key:`1tivn9`}],[`path`,{d:`M7 17 17 7`,key:`1vkiza`}]]),x=r(`gamepad-2`,[[`line`,{x1:`6`,x2:`10`,y1:`11`,y2:`11`,key:`1gktln`}],[`line`,{x1:`8`,x2:`8`,y1:`9`,y2:`13`,key:`qnk9ow`}],[`line`,{x1:`15`,x2:`15.01`,y1:`12`,y2:`12`,key:`krot7o`}],[`line`,{x1:`18`,x2:`18.01`,y1:`10`,y2:`10`,key:`1lcuu1`}],[`path`,{d:`M17.32 5H6.68a4 4 0 0 0-3.978 3.59c-.006.052-.01.101-.017.152C2.604 9.416 2 14.456 2 16a3 3 0 0 0 3 3c1 0 1.5-.5 2-1l1.414-1.414A2 2 0 0 1 9.828 16h4.344a2 2 0 0 1 1.414.586L17 18c.5.5 1 1 2 1a3 3 0 0 0 3-3c0-1.545-.604-6.584-.685-7.258-.007-.05-.011-.1-.017-.151A4 4 0 0 0 17.32 5z`,key:`mfqc10`}]]),S=t(e(),1),C=n(),w=[{id:`app`,titleKey:`portal.feature.app.title`,subtitleKey:`portal.feature.app.subtitle`,icon:(0,C.jsx)(d,{size:28}),path:`/app/`,requiresBackend:!0,heroKey:`portal.feature.app.hero`,descKey:`portal.feature.app.desc`,featureKeys:[`portal.feature.app.bullet.localIdentity`,`portal.feature.app.bullet.hyperswarm`,`portal.feature.app.bullet.largeFiles`,`portal.feature.app.bullet.cid`,`portal.feature.app.bullet.seedAfterDownload`,`portal.feature.app.bullet.noCloud`,`portal.feature.app.bullet.desktop`,`portal.feature.app.bullet.openSource`],steps:[{num:`1`,titleKey:`portal.feature.app.step.download.title`,descKey:`portal.feature.app.step.download.desc`,link:`/download/`,linkTextKey:`portal.feature.app.step.download.link`,hideInDesktopClient:!0},{num:`2`,titleKey:`portal.feature.app.step.install.title`,descKey:`portal.feature.app.step.install.desc`,hideInDesktopClient:!0},{num:`3`,titleKey:`portal.feature.app.step.share.title`,descKey:`portal.feature.app.step.share.desc`}]},{id:`chat`,titleKey:`portal.feature.chat.title`,subtitleKey:`portal.feature.chat.subtitle`,icon:(0,C.jsx)(p,{size:28}),path:`/chat/`,requiresBackend:!0,heroKey:`portal.feature.chat.hero`,descKey:`portal.feature.chat.desc`,featureKeys:[`portal.feature.chat.bullet.encrypted`,`portal.feature.chat.bullet.identity`,`portal.feature.chat.bullet.sync`,`portal.feature.chat.bullet.offline`,`portal.feature.chat.bullet.noAccount`],steps:[{num:`1`,titleKey:`portal.feature.chat.step.download.title`,descKey:`portal.feature.chat.step.download.desc`,link:`/download/`,linkTextKey:`portal.feature.chat.step.download.link`,hideInDesktopClient:!0},{num:`2`,titleKey:`portal.feature.chat.step.create.title`,descKey:`portal.feature.chat.step.create.desc`},{num:`3`,titleKey:`portal.feature.chat.step.send.title`,descKey:`portal.feature.chat.step.send.desc`}]},{id:`note`,titleKey:`portal.feature.note.title`,subtitleKey:`portal.feature.note.subtitle`,icon:(0,C.jsx)(m,{size:28}),path:`/note/`,requiresBackend:!1,heroKey:`portal.feature.note.hero`,descKey:`portal.feature.note.desc`,featureKeys:[`portal.feature.note.bullet.markdown`,`portal.feature.note.bullet.privacy`,`portal.feature.note.bullet.folders`,`portal.feature.note.bullet.web3`,`portal.feature.note.bullet.backup`,`portal.feature.note.bullet.independent`],steps:[{num:`1`,titleKey:`portal.feature.note.step.account.title`,descKey:`portal.feature.note.step.account.desc`},{num:`2`,titleKey:`portal.feature.note.step.create.title`,descKey:`portal.feature.note.step.create.desc`},{num:`3`,titleKey:`portal.feature.note.step.backup.title`,descKey:`portal.feature.note.step.backup.desc`}]},{id:`gandengyan`,titleKey:`portal.feature.game.title`,subtitleKey:`portal.feature.game.subtitle`,icon:(0,C.jsx)(x,{size:28}),path:`/game/gandengyan/`,requiresBackend:!0,heroKey:`portal.feature.game.hero`,descKey:`portal.feature.game.desc`,featureKeys:[`portal.feature.game.bullet.account`,`portal.feature.game.bullet.channel`,`portal.feature.game.bullet.link`,`portal.feature.game.bullet.rules`,`portal.feature.game.bullet.maintain`],steps:[{num:`1`,titleKey:`portal.feature.game.step.login.title`,descKey:`portal.feature.game.step.login.desc`},{num:`2`,titleKey:`portal.feature.game.step.create.title`,descKey:`portal.feature.game.step.create.desc`},{num:`3`,titleKey:`portal.feature.game.step.test.title`,descKey:`portal.feature.game.step.test.desc`}]},{id:`web3`,titleKey:`portal.feature.web3.title`,subtitleKey:`portal.feature.web3.subtitle`,icon:(0,C.jsx)(h,{size:28}),path:`/web3/`,requiresBackend:!1,heroKey:`portal.feature.web3.hero`,descKey:`portal.feature.web3.desc`,featureKeys:[`portal.feature.web3.bullet.frontend`,`portal.feature.web3.bullet.keys`,`portal.feature.web3.bullet.mnemonic`,`portal.feature.web3.bullet.eth`,`portal.feature.web3.bullet.pem`,`portal.feature.web3.bullet.qr`],steps:[{num:`1`,titleKey:`portal.feature.web3.step.username.title`,descKey:`portal.feature.web3.step.username.desc`},{num:`2`,titleKey:`portal.feature.web3.step.keys.title`,descKey:`portal.feature.web3.step.keys.desc`},{num:`3`,titleKey:`portal.feature.web3.step.export.title`,descKey:`portal.feature.web3.step.export.desc`}]}],T=[`chat`,`app`,`note`,`gandengyan`,`web3`];function E(){let e=o(e=>e.hasBackend),t=o(e=>e.openConnectModal),[n,r]=(0,S.useState)(`chat`),{t:i}=g(),d=v(),p=T.map(e=>w.find(t=>t.id===e)).filter(e=>!!e),m=p.find(e=>e.id===n)||p[0],h=i(m.titleKey),y=m.steps.filter(e=>!(d&&e.hideInDesktopClient));return(0,C.jsxs)(`div`,{className:`portal-page`,children:[(0,C.jsx)(`section`,{className:`portal-hero`,children:(0,C.jsxs)(`div`,{className:`mkt-container`,children:[(0,C.jsx)(`h1`,{className:`portal-hero-title`,children:i(`common.brand`)}),(0,C.jsx)(`p`,{className:`portal-hero-subtitle`,children:i(`portal.hero.subtitle`)})]})}),(0,C.jsx)(`section`,{className:`portal-cards-section`,children:(0,C.jsxs)(`div`,{className:`mkt-container`,children:[(0,C.jsx)(`div`,{className:`portal-cards`,children:p.map(t=>{let o=n===t.id,s=t.requiresBackend,c=s?e===!0?`connected`:e===!1?`disconnected`:`checking`:`none`,l=i(t.titleKey);return(0,C.jsxs)(`button`,{className:`portal-card ${o?`active`:``}`,onClick:()=>r(t.id),children:[(0,C.jsx)(a,{to:t.path,className:`btn btn-icon portal-card-open-btn`,onClick:e=>e.stopPropagation(),title:i(`portal.openFeature`,{title:l}),children:(0,C.jsx)(b,{size:16})}),(0,C.jsx)(`div`,{className:`portal-card-icon`,children:t.icon}),(0,C.jsx)(`div`,{className:`portal-card-title`,children:l}),(0,C.jsx)(`div`,{className:`portal-card-subtitle`,children:i(t.subtitleKey)}),s?(0,C.jsxs)(`div`,{className:`ui-badge portal-card-status ${c}`,children:[c===`checking`&&(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(`span`,{className:`status-dot checking`}),i(`common.status.checking`)]}),c===`connected`&&(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(`span`,{className:`status-dot connected`}),i(`common.status.connected`)]}),c===`disconnected`&&(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(`span`,{className:`status-dot disconnected`}),i(`common.status.needsConnection`)]})]}):(0,C.jsxs)(`div`,{className:`ui-badge portal-card-status ready`,children:[(0,C.jsx)(`span`,{className:`status-dot ready`}),i(`common.status.ready`)]})]},t.id)})}),(0,C.jsxs)(`div`,{className:`portal-node-actions`,"aria-label":i(`portal.nodeEntry`),children:[(0,C.jsxs)(`button`,{onClick:t,className:`btn btn-secondary`,children:[(0,C.jsx)(_,{size:16}),i(`portal.webConnectNode`)]}),(0,C.jsxs)(a,{to:`/admin/`,className:`btn btn-secondary`,children:[(0,C.jsx)(f,{size:16}),i(`portal.nodeAdmin`)]})]})]})}),(0,C.jsx)(`section`,{className:`portal-marketing`,children:(0,C.jsx)(`div`,{className:`mkt-container`,children:(0,C.jsxs)(`div`,{className:`portal-marketing-inner`,children:[(0,C.jsxs)(`div`,{className:`portal-marketing-header`,children:[(0,C.jsx)(`h2`,{children:i(m.heroKey)}),(0,C.jsx)(`p`,{children:i(m.descKey)})]}),(0,C.jsx)(`div`,{className:`portal-marketing-features`,children:m.featureKeys.map(e=>(0,C.jsxs)(`div`,{className:`portal-feature-item`,children:[(0,C.jsx)(`span`,{className:`portal-feature-icon`,children:(0,C.jsx)(c,{size:14,strokeWidth:3})}),(0,C.jsx)(`span`,{children:i(e)})]},e))}),(0,C.jsx)(`div`,{className:`portal-marketing-steps`,children:y.map((e,t)=>(0,C.jsxs)(`div`,{className:`portal-step`,children:[(0,C.jsx)(`span`,{className:`portal-step-num`,children:t+1}),(0,C.jsxs)(`div`,{className:`portal-step-content`,children:[(0,C.jsx)(`strong`,{children:i(e.titleKey)}),(0,C.jsx)(`p`,{children:i(e.descKey)}),e.code&&(0,C.jsx)(`code`,{className:`portal-step-code`,translate:`no`,children:e.code}),e.link&&e.linkTextKey&&(0,C.jsx)(`p`,{className:`portal-step-link`,children:(0,C.jsxs)(a,{to:e.link,children:[i(e.linkTextKey),` `,(0,C.jsx)(u,{size:12})]})})]})]},e.num))}),(0,C.jsxs)(`div`,{className:`portal-actions`,children:[(0,C.jsxs)(a,{to:m.path,className:`btn btn-primary`,children:[i(`portal.enterFeature`,{title:h}),(0,C.jsx)(s,{size:16})]}),m.requiresBackend&&e===!1&&(0,C.jsxs)(C.Fragment,{children:[(0,C.jsxs)(`button`,{onClick:t,className:`btn btn-secondary`,children:[(0,C.jsx)(_,{size:16}),i(`portal.webConnectNode`)]}),!d&&(0,C.jsxs)(a,{to:`/download/`,className:`btn btn-secondary`,children:[(0,C.jsx)(l,{size:16}),i(`nav.downloadClient`)]})]})]})]})})})]})}function D(){return(0,C.jsx)(y,{children:(0,C.jsx)(E,{})})}var O=i(`/`)({component:D});export{O as Route};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/MilkdownEditor-Dw_ze7EE.js","assets/jsx-runtime-Bt-cYkS5.js","assets/index-DjBN7bZV.js","assets/useAppStore-DOnk608w.js","assets/useNavigate-DWlBD_-b.js","assets/index-B6acG3-t.css","assets/dist-CSyRxrry.js","assets/dist-RU_cpjXQ.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{n as e,o as t,t as n}from"./jsx-runtime-Bt-cYkS5.js";import{B as r,C as i,E as a,H as o,M as s,d as c,j as l,o as u,t as d,w as f}from"./useAppStore-DOnk608w.js";import{n as ee}from"./useNavigate-DWlBD_-b.js";import{a as te,i as ne,n as re,o as p}from"./chatNoteDraft-CYbvcEvC.js";import{t as ie}from"./OpenSidebarButton-C2UJYXKh.js";import{n as m,t as h}from"./lock-CuwwlXlx.js";import{n as g,t as _}from"./folder-DAcox9xz.js";import{t as v}from"./folder-open-Di0oALaC.js";import{n as ae,t as y}from"./AppTop-DZFTO9-m.js";import{t as b}from"./notebook-pen-SWT-zZ4v.js";import{t as oe}from"./save-B02sbO9Y.js";import{t as se}from"./search-HW4oPOBP.js";import{t as ce}from"./trash-2-BLwoM0ME.js";import{A as le,N as ue,S as de,_ as fe,a as pe,b as x,c as S,g as C,i as w,l as me,o as T,r as he,s as ge,t as E,u as _e,v as ve,w as D,y as O}from"./index-DjBN7bZV.js";var ye=r(`move`,[[`path`,{d:`M12 2v20`,key:`t6zp3m`}],[`path`,{d:`m15 19-3 3-3-3`,key:`11eu04`}],[`path`,{d:`m19 9 3 3-3 3`,key:`1mg7y2`}],[`path`,{d:`M2 12h20`,key:`9i4pu4`}],[`path`,{d:`m5 9-3 3 3 3`,key:`j64kie`}],[`path`,{d:`m9 5 3-3 3 3`,key:`l8vdw6`}]]),be=r(`pencil-ruler`,[[`path`,{d:`M13 7 8.7 2.7a2.41 2.41 0 0 0-3.4 0L2.7 5.3a2.41 2.41 0 0 0 0 3.4L7 13`,key:`orapub`}],[`path`,{d:`m8 6 2-2`,key:`115y1s`}],[`path`,{d:`m18 16 2-2`,key:`ee94s4`}],[`path`,{d:`m17 11 4.3 4.3c.94.94.94 2.46 0 3.4l-2.6 2.6c-.94.94-2.46.94-3.4 0L11 17`,key:`cfq27r`}],[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}],[`path`,{d:`m15 5 4 4`,key:`1mk7zo`}]]),k=t(e(),1),A=n();function j(e){return e.type===`directory`?f(e.path?`${e.path}/${e.name}`:e.name):i(e)}function xe({target:e,targetLabel:t,directories:n,onMove:r,onClose:i}){let{t:a}=le(),o=f(e.path||``),s=j(e),c=n.filter(t=>e.type===`directory`?t.path!==s&&!t.path.startsWith(`${s}/`):!0),[l,u]=(0,k.useState)(o),[d,ee]=(0,k.useState)(``),[te,ne]=(0,k.useState)(new Set),re=f(d),p=d.trim()?re:l,ie=f(p)===o,h=a(`note.move.rootDirectory`),v=new Map;for(let e of c){let t=v.get(e.parentPath)||[];t.push(e),v.set(e.parentPath,t)}let ae=c.filter(e=>{if(!e.parentPath)return!0;let t=e.parentPath.split(`/`).filter(Boolean);return t.every((e,n)=>te.has(t.slice(0,n+1).join(`/`)))}),y=[{label:h,path:``},...l.split(`/`).filter(Boolean).map((e,t,n)=>({label:e,path:n.slice(0,t+1).join(`/`)}))];function b(e){u(f(e)),ee(``)}function oe(e){b(e),v.has(e)&&ne(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}function se(){ie||r(p)}return(0,A.jsx)(O,{onClose:i,children:(0,A.jsxs)(`div`,{className:`note-move-modal`,onClick:e=>e.stopPropagation(),children:[(0,A.jsxs)(`div`,{className:`modal-header`,children:[(0,A.jsx)(`h3`,{children:a(`note.move.title`)}),(0,A.jsx)(`button`,{className:`btn btn-icon`,onClick:i,children:(0,A.jsx)(de,{size:18})})]}),(0,A.jsxs)(`div`,{className:`note-move-target`,children:[(0,A.jsx)(`span`,{children:a(`note.move.moving`)}),(0,A.jsx)(`strong`,{translate:`no`,children:t||e.name})]}),(0,A.jsx)(`div`,{className:`note-move-path`,children:y.map((e,t)=>(0,A.jsxs)(k.Fragment,{children:[t>0&&(0,A.jsx)(`span`,{children:`/`}),(0,A.jsx)(`button`,{type:`button`,onClick:()=>b(e.path),children:(0,A.jsx)(`span`,{translate:e.path?`no`:`yes`,children:e.label})})]},e.path||`root`))}),(0,A.jsxs)(`div`,{className:`note-move-folder-list`,children:[(0,A.jsxs)(`button`,{type:`button`,className:`note-move-folder-item ${l===``?`selected`:``}`,onClick:()=>b(``),children:[(0,A.jsx)(`span`,{className:`note-move-folder-spacer`}),(0,A.jsx)(_,{className:`note-move-folder-icon`,size:16}),(0,A.jsx)(`span`,{children:h})]}),c.length===0?(0,A.jsx)(`p`,{className:`note-move-empty`,children:a(`note.move.noFolders`)}):ae.map(e=>{let t=v.has(e.path),n=te.has(e.path);return(0,A.jsxs)(`button`,{type:`button`,className:`note-move-folder-item note-move-depth-${Math.min(e.depth,4)} ${l===e.path?`selected`:``}`,onClick:()=>oe(e.path),children:[t?n?(0,A.jsx)(m,{className:`note-move-expander`,size:14}):(0,A.jsx)(g,{className:`note-move-expander`,size:14}):(0,A.jsx)(`span`,{className:`note-move-folder-spacer`}),(0,A.jsx)(_,{className:`note-move-folder-icon`,size:16}),(0,A.jsx)(`span`,{translate:`no`,children:e.name}),e.parentPath&&(0,A.jsx)(`small`,{translate:`no`,children:e.parentPath})]},e.path)})]}),(0,A.jsx)(`input`,{className:`input input-compact`,value:d,onChange:e=>ee(e.target.value),placeholder:a(`note.move.pathPlaceholder`),translate:`no`}),(0,A.jsxs)(`div`,{className:`note-move-destination`,children:[(0,A.jsx)(`span`,{children:a(`note.move.destinationLabel`)}),(0,A.jsx)(`span`,{translate:p?`no`:`yes`,children:p||h})]}),(0,A.jsxs)(`div`,{className:`modal-actions`,children:[(0,A.jsx)(`button`,{className:`btn btn-secondary`,onClick:i,children:a(`common.cancel`)}),(0,A.jsx)(`button`,{className:`btn btn-primary`,onClick:se,disabled:ie,children:a(`note.action.move`)})]})]})})}function Se({children:e}){return(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(y,{}),e]})}var Ce=(0,k.lazy)(async()=>({default:(await E(()=>import(`./MilkdownEditor-Dw_ze7EE.js`),__vite__mapDeps([0,1,2,3,4,5,6,7]))).MilkdownEditor})),M=/\[\[([^\]\n]+?)\]\]/g,we=/(```[\s\S]*?```)/g;function Te(e){let t=new URLSearchParams(e),n=t.get(`mode`);return{cid:t.get(`cid`)||void 0,file:t.get(`file`)||void 0,path:t.get(`path`)||void 0,chatDraft:t.get(`chatDraft`)||void 0,mode:n===`edit`?`edit`:void 0}}function N(e={}){let t=new URLSearchParams;e.cid&&t.set(`cid`,e.cid),e.file&&t.set(`file`,e.file),e.path&&t.set(`path`,e.path),e.chatDraft&&t.set(`chatDraft`,e.chatDraft),e.mode&&t.set(`mode`,e.mode);let n=t.toString();return n?`/note/?${n}`:`/note/`}function Ee(e){let t=e.indexOf(`?`),n=t>=0?e.slice(t):``;if(typeof window>`u`)return Te(n);try{return Te(new URL(e,window.location.origin).search)}catch{return Te(n)}}var P={"note.error.nameRequired":`note.error.nameRequired`,"note.error.nameNoSlash":`note.error.nameNoSlash`,"note.error.nameNoBackslash":`note.error.nameNoBackslash`,"note.error.nameInvalid":`note.error.nameInvalid`,"note.error.nameConflict":`note.error.nameConflict`,"note.error.moveIntoSelf":`note.error.moveIntoSelf`};function De(e,t,n){let r=e instanceof Error?e.message:``,i=P[r];return i?n(i):r||t}function Oe(e){return e.type===`directory`?f(e.path?`${e.path}/${e.name}`:e.name):i(e)}function F(e=``){return String(e).trim().replace(/\.md$/i,``)}function I(e){let t=F(e);return t?`${t}.md`:``}function ke(e,t,n){let r=F(e)||t;for(let e=0;e<1e3;e+=1){let t=I(e===0?r:`${r} ${e+1}`);if(t&&!n(t))return t}return I(`${r} ${Date.now()}`)}function Ae(e=``){let t=f(e).split(`/`).filter(Boolean);if(t.length===0)return``;let n=t.length-1;return t[n]=I(t[n]),t.join(`/`)}function je(e=``){let t=f(e).split(`/`).filter(Boolean);if(t.length===0)return``;let n=t.length-1;return t[n]=F(t[n]),t.join(`/`)}function Me(e){return je(i(e))}function L(e){let t=e.trim().replace(/^\/+/,``),n=t.search(/[#^]/);return je(n>=0?t.slice(0,n):t)}function Ne(e,t){let n=t?.trim();if(n)return n;let r=e.split(`/`).filter(Boolean);return r[r.length-1]||e}function R(e){return e.replace(/\\/g,`\\\\`).replace(/\[/g,`\\[`).replace(/\]/g,`\\]`)}function Pe(e,t){return`[${R(e)}](<${t.replace(/>/g,`%3E`)}>)`}function Fe(e,t,n=``){let r=L(t);if(!r)return null;let i=r.toLowerCase(),a=e=>Me(e).toLowerCase();if(r.includes(`/`))return e.find(e=>a(e)===i)||null;let o=f(n);if(o){let t=f(`${o}/${r}`).toLowerCase(),n=e.find(e=>a(e)===t);if(n)return n}return e.find(e=>F(e.name).toLowerCase()===i)||null}function Ie(e,t,n,r=``,i){let a=e.indexOf(`|`),o=a>=0?e.slice(0,a):e,s=a>=0?e.slice(a+1):void 0,c=L(o);if(!c)return null;let l=Fe(t,o,r),u=l?n(l):i?.(c);return u?{label:Ne(c,s),href:u}:null}function Le(e,t,n,r=``,i){return e.includes(`[[`)?e.split(we).map(e=>e.startsWith("```")?e:e.replace(M,(e,a)=>{let o=Ie(a,t,n,r,i);return o?Pe(o.label,o.href):e})).join(``):e}function z(e){return e.type===`file`?F(e.name):e.name}function B(e){return e.type===`file`?je(e.fullPath):e.fullPath}function Re(e){return e.type===`file`?F(e.name):e.name}function ze(e=``){let t=f(e).split(`/`).filter(Boolean);return t.map((e,n)=>t.slice(0,n+1).join(`/`))}function Be(e,t){let n=new Set(e);return n.has(t)?n.delete(t):n.add(t),n}function Ve(e,t){if(t.length===0)return e;let n=!1,r=new Set(e);for(let e of t)r.has(e)||(r.add(e),n=!0);return n?r:e}function He(e){return{name:e.name,cid:`__dir__${e.fullPath}`,path:e.path,type:`directory`,size:0,created_at:e.updatedAt,updated_at:e.updatedAt}}function Ue(e,t){let n=[],r=new Map;function a(e){return e&&r.get(e)?.children||n}function o(e,t,n){let i=f(t?`${t}/${e}`:e),o=r.get(i);if(o)return o.updatedAt=Math.max(o.updatedAt,n),o;let s={id:`directory:${i}`,type:`directory`,name:e,path:t,fullPath:i,updatedAt:n,children:[]};return r.set(i,s),a(t).push(s),s}for(let t of e){let e=f(t.path||``),n=e.split(`/`).filter(Boolean),r=t.updated_at||t.created_at||0,s=``;for(let e of n)s=o(e,s,r).fullPath;a(s).push({id:`file:${t.cid}:${i(t)}`,type:`file`,name:t.name,path:e,fullPath:i(t),updatedAt:r,note:t,children:[]})}function s(e){e.sort((e,n)=>{if(e.type!==n.type)return e.type===`directory`?-1:1;let r=t(z(e),z(n));return r===0?t(B(e),B(n)):r});for(let t of e)t.type===`directory`&&s(t.children)}return s(n),n}function We(e,t){let n=t.trim().toLowerCase();return n?e.flatMap(e=>{let t=z(e).toLowerCase(),r=B(e).toLowerCase(),i=t.includes(n)||r.includes(n);if(e.type===`file`)return i?[e]:[];let a=i?e.children:We(e.children,n);return!i&&a.length===0?[]:[{...e,children:a}]}):e}function Ge({nodes:e,searchQuery:t,expandedPaths:n,activeFileId:r,activeFolderPath:i,onToggleDirectory:a,onOpenFile:o,renderActions:s}){let c=t.trim().length>0;return(0,A.jsx)(`div`,{className:`note-tree`,role:`tree`,children:e.map(e=>(0,A.jsx)(V,{node:e,forceExpanded:c,expandedPaths:n,activeFileId:r,activeFolderPath:i,onToggleDirectory:a,onOpenFile:o,renderActions:s},e.id))})}function V({node:e,forceExpanded:t,expandedPaths:n,activeFileId:r,activeFolderPath:i,onToggleDirectory:a,onOpenFile:o,renderActions:s}){let c=e.type===`directory`,l=c&&(t||n.has(e.fullPath)),u=e.type===`file`&&e.note?.cid===r,d=c&&f(i)===e.fullPath,ee=c?He(e):e.note||null,te=ee&&s?s(ee):null;return(0,A.jsxs)(`div`,{className:`note-tree-node`,role:`none`,children:[(0,A.jsxs)(`div`,{className:`note-tree-row ${c?`is-directory`:`is-file`} ${u?`is-active`:``} ${d?`is-folder-active`:``} ${te?`has-actions`:``}`,children:[(0,A.jsxs)(`button`,{type:`button`,className:`note-tree-item`,role:`treeitem`,"aria-expanded":c?l:void 0,onClick:()=>{if(c){a(e);return}e.note&&o(e.note)},children:[(0,A.jsx)(`span`,{className:`note-tree-toggle`,"aria-hidden":`true`,children:c?l?(0,A.jsx)(m,{size:16}):(0,A.jsx)(g,{size:16}):(0,A.jsx)(`span`,{className:`note-tree-toggle-placeholder`})}),(0,A.jsx)(`span`,{className:`note-tree-label`,translate:`no`,children:z(e)}),e.note?.isSecret&&(0,A.jsx)(h,{className:`note-tree-lock`,size:14,"aria-hidden":`true`})]}),te]}),c&&l&&e.children.length>0&&(0,A.jsx)(`div`,{className:`note-tree-children`,role:`group`,children:e.children.map(e=>(0,A.jsx)(V,{node:e,forceExpanded:t,expandedPaths:n,activeFileId:r,activeFolderPath:i,onToggleDirectory:a,onOpenFile:o,renderActions:s},e.id))})]})}function Ke(e,t){let n=new Set;for(let t of e){let e=f(t.path).split(`/`).filter(Boolean);for(let t=0;t<e.length;t+=1)n.add(e.slice(0,t+1).join(`/`))}return Array.from(n).sort(t).map(e=>{let t=e.split(`/`);return{path:e,name:t[t.length-1]||e,parentPath:t.slice(0,-1).join(`/`),depth:Math.max(t.length-1,0)}})}function H(e){return e.map(e=>({name:e.name,cid:e.path,path:f(e.directory),content:``,size:e.size,type:`file`,created_at:Number(e.mtimeMs)||Date.now(),updated_at:Number(e.mtimeMs)||Date.now(),isSecret:!1}))}function U(e,t){let n=I(t);return f(e?`${e}/${n}`:n)}function qe(e){let t=e||typeof window<`u`&&window.location.origin||``;if(!t)return!1;try{let e=new URL(t).hostname.toLowerCase();return e===`localhost`||e===`127.0.0.1`||e===`::1`||e===`[::1]`||e.startsWith(`127.`)}catch{return!1}}function W(e,t=``){let[n,r]=(0,k.useState)(!1);return(0,k.useEffect)(()=>{let n=!1;return!e||!t?(r(!1),()=>{n=!0}):(T().then(e=>{n||r(e.configured===!0)}).catch(()=>{n||r(!1)}),()=>{n=!0})},[e,t]),n}function G(){let{t:e,formatDate:t,compareStrings:n}=le(),r=ee(),i=ue({select:e=>e.searchStr}),o=(0,k.useMemo)(()=>Te(i),[i]),c=(0,k.useRef)(null),u=d(e=>e.addToast),p=a(e=>e.wallet),m=a(e=>e.openLoginModal),g=d(e=>e.notes),_=d(e=>e.notesPath),v=d(e=>e.setNotesPath),y=d(e=>e.saveNote),pe=d(e=>e.deleteNote),x=d(e=>e.renameNote),S=d(e=>e.localDataReady),C=o.cid||``,w=g.find(e=>e.cid===C),me=!!C,T=me&&o.mode===`edit`,[he,ge]=(0,k.useState)(``),[E,_e]=(0,k.useState)(null),[O,j]=(0,k.useState)(null),[M,we]=(0,k.useState)(null),P=(0,k.useRef)(``),je=(0,k.useRef)(``),[Me,L]=(0,k.useState)(``),[Ne,R]=(0,k.useState)(``),[Pe,z]=(0,k.useState)(``),[B,He]=(0,k.useState)(``),[V,H]=(0,k.useState)(``),[U,qe]=(0,k.useState)(!1),[W,G]=(0,k.useState)(``),[K,q]=(0,k.useState)(!1),[Je,Ye]=(0,k.useState)(()=>new Set(ze(_)));(0,k.useEffect)(()=>{if(!C){L(``),R(``);return}if(!w){L(``),R(S?e(`note.error.notFound`):``);return}if(w.content.startsWith(`mp://1`)){if(!p){L(``),R(e(`note.error.loginToDecrypt`));return}let t=l(w.content,p.danger);if(!t){L(``),R(e(`note.error.decryptFailed`));return}L(t),R(``);return}L(w.content||``),R(``)},[C,S,w,e,p]),(0,k.useEffect)(()=>{if(!T){q(!1);return}if(!C||!w){z(``),He(``),H(``),qe(!1),G(S?e(`note.error.notFound`):``);return}if(z(F(w.name)),He(w.path||``),qe(w.isSecret===!0||w.content.startsWith(`mp://1`)),w.content.startsWith(`mp://1`)){if(!p){H(``),G(e(`note.error.loginToDecrypt`));return}let t=l(w.content,p.danger);if(!t){H(``),G(e(`note.error.decryptFailed`));return}H(t),G(``);return}H(w.content||``),G(``)},[C,T,S,w,e,p]);let Xe=(0,k.useMemo)(()=>Ue(g,n),[n,g]),Ze=(0,k.useMemo)(()=>We(Xe,he),[Xe,he]),Qe=w?.isSecret===!0||w?.content.startsWith(`mp://1`)===!0,J=e(T?U?`note.privacy.secret`:`note.privacy.public`:Qe?`note.privacy.secret`:`note.privacy.public`),$e=(0,k.useMemo)(()=>Ke(g,n),[n,g]),et=(0,k.useMemo)(()=>Le(Me,g,e=>N({cid:e.cid}),w?.path||``,e=>N({path:Ae(e)})),[g,Me,w?.path]),tt=(0,k.useCallback)(e=>Ie(e,g,e=>N({cid:e.cid}),w?.path||``,e=>N({path:Ae(e)})),[g,w?.path]);(0,k.useEffect)(()=>{w?.path&&Ye(e=>Ve(e,ze(w.path)))},[w?.path]),(0,k.useEffect)(()=>{if(!o.path||C||g.length===0)return;let e=Fe(g,o.path);e&&(v(f(e.path||``)),r({href:N({cid:e.cid}),replace:!0}))},[C,r,g,o.path,v]),(0,k.useEffect)(()=>{let t=o.chatDraft||``;if(!t||P.current===t||!S)return;if(!p){let e=`${t}:auth`;je.current!==e&&(je.current=e,m());return}let n=ne(t);if(!n){P.current=t,u(e(`note.chatDraft.missing`),`warning`),Y({},!0);return}P.current=t,at(n)},[u,S,o.chatDraft,e,p]);function Y(e={},t=!1){r({href:N(e),replace:t})}function nt(e){Y(Ee(e))}function rt(e){v(f(e.path||``)),Y({cid:e.cid})}function it(e){v(e.fullPath),Ye(t=>Be(t,e.fullPath))}function X(e){Y({cid:e.cid,mode:`edit`})}function Z(){return p?!0:(m(),!1)}async function at(t){if(p)try{let n=await y({name:ke(t.title,e(`note.chatDraft.defaultTitle`),e=>g.some(t=>f(t.path||``)===f(_)&&t.name===e)),path:_,content:t.content,isSecret:!1});re(t.id),u(e(`note.chatDraft.created`),`success`),Y({cid:n,mode:`edit`},!0)}catch(t){P.current=``,u(De(t,e(`note.toast.createFailed`),e),`error`)}}function ot(){Y(w?{cid:w.cid}:{})}async function st(){if(!Z())return;if(!w){u(e(`note.toast.notFound`),`error`);return}let t=I(Pe);if(!t){u(e(`note.toast.nameRequired`),`warning`);return}q(!0);try{let n=c.current?.getMarkdown()??V,r=U?s(n,p.danger):n,i=await y({cid:w.cid,name:t,path:B,content:r,isSecret:U});H(n),Y({cid:i},!0),u(e(`note.toast.saved`),`success`)}catch(t){u(De(t,e(`note.toast.saveFailed`),e),`error`)}finally{q(!1)}}function ct(){Z()&&_e({title:e(`note.create.title`),placeholder:e(`note.namePlaceholder`),confirmText:e(`note.create.action`),onConfirm:async t=>{if(Z())try{let n=await y({name:I(t),path:_,content:``,isSecret:!1});_e(null),u(e(`note.toast.created`),`success`),Y({cid:n,mode:`edit`})}catch(t){u(De(t,e(`note.toast.createFailed`),e),`error`)}}})}function lt(e){Z()&&we(e)}async function Q(t){if(M)try{x(Oe(M),t,M.name),we(null),u(e(`note.toast.moved`),`success`)}catch(t){u(De(t,e(`note.toast.moveFailed`),e),`error`)}}function $(t){if(!Z())return;let n=t.type===`directory`;j({title:e(n?`note.delete.folderTitle`:`note.delete.noteTitle`),message:e(`note.delete.message`,{name:Re(t)}),confirmText:e(`note.action.delete`),onConfirm:async()=>{pe(n?void 0:t.cid,t.path,t.name),j(null),u(e(`note.toast.deleted`),`success`),t.type===`file`&&t.cid===C&&Y()}})}let ut=(0,A.jsxs)(`div`,{className:`note-header-title`,children:[(0,A.jsx)(`h2`,{className:`header-title`,children:e(`note.title`)}),(0,A.jsx)(`span`,{children:e(`note.count`,{count:g.length})})]}),dt=(0,A.jsx)(`div`,{className:`note-theme-wrap`}),ft=(0,A.jsxs)(`section`,{className:`note-list-panel note-sidebar-list`,"aria-label":e(`note.listLabel`),children:[(0,A.jsxs)(`div`,{className:`note-search`,children:[(0,A.jsx)(se,{size:16}),(0,A.jsx)(`input`,{className:`input input-flex`,value:he,onChange:e=>ge(e.target.value),placeholder:e(`note.search.placeholder`)})]}),Ze.length===0?(0,A.jsxs)(`div`,{className:`ui-empty-state note-empty-state`,children:[(0,A.jsx)(b,{size:32}),(0,A.jsx)(`p`,{children:e(he?`note.empty.noMatches`:`note.empty.noNotes`)})]}):(0,A.jsx)(Ge,{nodes:Ze,searchQuery:he,expandedPaths:Je,activeFileId:C,activeFolderPath:C?``:_,onToggleDirectory:it,onOpenFile:rt}),(0,A.jsx)(`div`,{className:`note-create-btn`,children:(0,A.jsxs)(`button`,{className:`btn`,onClick:ct,children:[(0,A.jsx)(te,{size:16}),e(`note.newNote`)]})})]});return(0,A.jsxs)(ae,{sidebar:()=>(0,A.jsx)(Se,{children:ft}),headerTitle:ut,headerRight:dt,children:[(0,A.jsx)(`main`,{className:`note-page note-browser-page ${me?`has-editor`:``}`,children:(0,A.jsx)(`section`,{className:`note-workspace`,children:(0,A.jsx)(`section`,{className:`note-editor-panel`,"aria-label":e(T?`note.editorLabel.edit`:`note.editorLabel.read`),children:me?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(`div`,{className:`note-editor-panel-header`,children:[(0,A.jsxs)(`div`,{className:`note-editor-title-area`,children:[T?(0,A.jsx)(`input`,{className:`note-title-input`,value:Pe,onChange:e=>z(e.target.value),placeholder:e(`note.namePlaceholder`),translate:`no`,disabled:!w}):w?(0,A.jsx)(`h3`,{translate:`no`,children:F(w.name)}):(0,A.jsx)(`h3`,{children:e(`note.untitled`)}),w&&(0,A.jsxs)(`div`,{className:`note-editor-info`,children:[(0,A.jsx)(`span`,{children:e(T?`note.mode.edit`:`note.mode.read`)}),(0,A.jsx)(`span`,{children:J}),(0,A.jsx)(`span`,{children:t(w.updated_at)})]})]}),(0,A.jsxs)(`div`,{className:`note-editor-actions`,children:[(0,A.jsx)(`button`,{type:`button`,className:`btn btn-icon`,onClick:T?ot:()=>Y(),title:e(T?`common.cancel`:`common.close`),"aria-label":e(T?`common.cancel`:`common.close`),children:(0,A.jsx)(de,{size:16})}),T?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(`button`,{className:`btn btn-sm ${U?`btn-warning`:`btn-secondary`}`,onClick:()=>qe(!U),disabled:!w,children:[U?(0,A.jsx)(h,{size:16}):(0,A.jsx)(D,{size:16}),e(U?`note.privacy.secret`:`note.privacy.public`)]}),(0,A.jsxs)(`button`,{className:`btn btn-sm btn-primary`,onClick:st,disabled:K||!!W||!w,children:[(0,A.jsx)(oe,{size:16}),e(K?`note.action.saving`:`note.action.save`)]})]}):w&&(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(`button`,{type:`button`,className:`btn btn-icon`,onClick:()=>lt(w),title:e(`note.action.move`),"aria-label":e(`note.action.move`),children:(0,A.jsx)(ye,{size:16})}),(0,A.jsx)(`button`,{type:`button`,className:`btn btn-icon note-editor-action-danger`,onClick:()=>$(w),title:e(`note.action.delete`),"aria-label":e(`note.action.delete`),children:(0,A.jsx)(ce,{size:16})}),(0,A.jsxs)(`button`,{type:`button`,className:`btn btn-sm btn-primary`,onClick:()=>X(w),disabled:!!Ne,title:e(`note.action.edit`),"aria-label":e(`note.action.edit`),children:[(0,A.jsx)(be,{size:16}),e(`note.action.edit`)]})]})]})]}),T?W?(0,A.jsxs)(`div`,{className:`note-empty-state editor-error`,children:[(0,A.jsx)(h,{size:36}),(0,A.jsx)(`p`,{children:W})]}):w?(0,A.jsx)(`div`,{className:`note-editor-frame editing`,children:(0,A.jsx)(Ce,{ref:c,content:V,onChange:H,className:`milkdown-editor`})}):(0,A.jsxs)(`div`,{className:`note-empty-state editor-error`,children:[(0,A.jsx)(b,{size:36}),(0,A.jsx)(`p`,{children:e(S?`note.error.notFound`:`note.loading`)})]}):Ne?(0,A.jsxs)(`div`,{className:`ui-empty-state note-empty-state editor-error`,children:[(0,A.jsx)(h,{size:36}),(0,A.jsx)(`p`,{children:Ne})]}):w?(0,A.jsx)(`div`,{className:`note-editor-frame reading`,children:(0,A.jsx)(Ce,{content:et,readOnly:!0,onInternalNoteLinkOpen:nt,resolveWikiNoteLink:tt,className:`milkdown-editor`})}):(0,A.jsxs)(`div`,{className:`ui-empty-state note-empty-state editor-error`,children:[(0,A.jsx)(b,{size:36}),(0,A.jsx)(`p`,{children:e(S?`note.error.notFound`:`note.loading`)})]})]}):(0,A.jsxs)(`div`,{className:`ui-empty-state note-editor-empty`,children:[(0,A.jsx)(`div`,{className:`ui-empty-icon note-editor-empty-icon`,children:(0,A.jsx)(b,{size:32})}),(0,A.jsx)(`h3`,{className:`ui-empty-title`,children:e(`note.noOpen.title`)}),(0,A.jsx)(`p`,{className:`ui-empty-desc`,children:g.length>0?e(`note.noOpen.select`):e(`note.noOpen.createFirst`)}),(0,A.jsx)(ie,{label:e(`note.openList`),variant:`default`})]})})})}),E&&(0,A.jsx)(fe,{title:E.title,placeholder:E.placeholder,defaultValue:E.defaultValue,confirmText:E.confirmText,onConfirm:E.onConfirm,onClose:()=>_e(null)}),O&&(0,A.jsx)(ve,{title:O.title,message:O.message,confirmText:O.confirmText,danger:!0,onConfirm:O.onConfirm,onClose:()=>j(null)}),M&&(0,A.jsx)(xe,{target:M,targetLabel:Re(M),directories:$e,onMove:Q,onClose:()=>we(null)})]})}function K(){let{t:e,formatDate:t,compareStrings:n}=le(),r=ee(),i=ue({select:e=>e.searchStr}),o=(0,k.useMemo)(()=>Te(i),[i]),s=(0,k.useRef)(null),c=d(e=>e.addToast),l=a(e=>e.wallet),m=a(e=>e.openLoginModal),g=o.file||``,_=!!g,y=_&&o.mode===`edit`,[x,E]=(0,k.useState)(null),[D,O]=(0,k.useState)([]),[j,M]=(0,k.useState)(``),[we,P]=(0,k.useState)(!0),[De,Me]=(0,k.useState)(``),[L,Ne]=(0,k.useState)(``),[R,Pe]=(0,k.useState)(!1),[z,B]=(0,k.useState)(null),[He,V]=(0,k.useState)(``),[qe,W]=(0,k.useState)(``),[G,K]=(0,k.useState)(!1),[q,Je]=(0,k.useState)(``),[Ye,Xe]=(0,k.useState)(!1),[Ze,Qe]=(0,k.useState)(()=>new Set(ze(j))),[J,$e]=(0,k.useState)(null),[et,tt]=(0,k.useState)(null),[Y,nt]=(0,k.useState)(null),rt=(0,k.useRef)(``),it=(0,k.useRef)(``),X=(0,k.useMemo)(()=>H(D),[D]),Z=X.find(e=>e.cid===g),at=(0,k.useMemo)(()=>Ke(X,n),[n,X]),ot=(0,k.useMemo)(()=>Ue(X,n),[n,X]),st=(0,k.useMemo)(()=>We(ot,L),[ot,L]),ct=(0,k.useMemo)(()=>Le(z?.content||``,X,e=>N({file:e.cid}),Z?.path||z?.directory||``,e=>N({path:Ae(e)})),[z?.content,z?.directory,Z?.path,X]),lt=(0,k.useCallback)(e=>Ie(e,X,e=>N({file:e.cid}),Z?.path||z?.directory||``,e=>N({path:Ae(e)})),[z?.directory,Z?.path,X]);(0,k.useEffect)(()=>{Z?.path&&Qe(e=>Ve(e,ze(Z.path)))},[Z?.path]),(0,k.useEffect)(()=>{if(!o.path||g||X.length===0)return;let e=Fe(X,o.path);e&&(M(f(e.path||``)),r({href:N({file:e.cid}),replace:!0}))},[g,r,o.path,X]),(0,k.useEffect)(()=>{let t=o.chatDraft||``;if(!t||rt.current===t||we)return;if(!l){let e=`${t}:auth`;it.current!==e&&(it.current=e,m());return}if(x?.configured!==!0){let n=`${t}:vault`;it.current!==n&&(it.current=n,c(e(`note.chatDraft.openVaultFirst`),`warning`));return}let n=ne(t);if(!n){rt.current=t,c(e(`note.chatDraft.missing`),`warning`),$({},!0);return}rt.current=t,_t(n)},[c,o.chatDraft,e,we,x?.configured,l]);let Q=(0,k.useCallback)(async()=>{if(!l){E(null),O([]),Me(e(`note.vault.loginRequired`)),P(!1);return}P(!0),Me(``);try{let e=await T();E(e),e.configured?O(await ge()):O([])}catch(t){E(null),O([]),Me(await u(t,e(`note.vault.loadFailed`)))}finally{P(!1)}},[e,l]);(0,k.useEffect)(()=>{Q()},[Q]),(0,k.useEffect)(()=>{V(F(z?.name||Z?.name||``))},[z?.name,Z?.name]),(0,k.useEffect)(()=>{let t=!1;async function n(){if(!g){B(null),W(``),Je(``),K(!1);return}if(!l){B(null),W(``),Je(e(`note.vault.loginRequired`)),K(!1);return}if(x?.configured!==!0){B(null),W(``),Je(``),K(!1);return}K(!0),Je(``);try{let e=await me(g);if(t)return;B(e),W(e.content)}catch(n){if(t)return;B(null),W(``),Je(await u(n,e(`note.error.notFound`)))}finally{t||K(!1)}}return n(),()=>{t=!0}},[g,e,x?.configured,l]);function $(e={},t=!1){r({href:N(e),replace:t})}function ut(e){$(Ee(e))}function dt(e){M(f(e.path||``)),$({file:e.cid})}function ft(e){M(e.fullPath),Qe(t=>Be(t,e.fullPath))}function pt(){g&&$({file:g,mode:`edit`})}function mt(){V(F(z?.name||Z?.name||``)),$(g?{file:g}:{})}async function ht(){if(!l){m();return}let t=window.electronAPI?.selectNoteVaultDirectory;if(!t){c(e(`note.vault.selectFailed`),`error`);return}Pe(!0);try{let n=await t();if(!n)return;await he(n),await Q(),$({},!0),c(e(`note.vault.opened`),`success`)}catch(t){c(await u(t,e(`note.vault.selectFailed`)),`error`)}finally{Pe(!1)}}function gt(){return l?x?.configured===!0?!0:(c(e(`note.vault.emptyPrompt`),`warning`),!1):(m(),!1)}async function _t(t){if(gt())try{let n=ke(t.title,e(`note.chatDraft.defaultTitle`),e=>D.some(t=>f(t.directory)===f(j)&&t.name===e)),r=await w(f(j?`${j}/${n}`:n),t.content);re(t.id),await Q(),c(e(`note.chatDraft.created`),`success`),$({file:r.path,mode:`edit`},!0)}catch(t){rt.current=``,c(await u(t,e(`note.toast.createFailed`)),`error`)}}function vt(){gt()&&$e({title:e(`note.create.title`),placeholder:e(`note.namePlaceholder`),confirmText:e(`note.create.action`),onConfirm:async t=>{if(!gt())return;let n=U(j,t);if(!n){c(e(`note.toast.nameRequired`),`warning`);return}try{let t=await w(n,``);$e(null),await Q(),$({file:t.path,mode:`edit`}),c(e(`note.toast.created`),`success`)}catch(t){c(await u(t,e(`note.toast.createFailed`)),`error`)}}})}function yt(e){gt()&&nt(e)}async function bt(t){if(!(!Y||!gt()))try{let n=g;if(Y.type===`directory`){let e=Oe(Y),r=f(t?`${t}/${Y.name}`:Y.name),i=D.filter(t=>t.path.startsWith(`${e}/`));for(let t of i){let i=f(`${r}/${t.path.slice(e.length+1)}`);await S(t.path,i),g===t.path&&(n=i)}}else{let e=f(t?`${t}/${Y.name}`:Y.name),r=await S(Y.cid,e);g===Y.cid&&(n=r.path)}nt(null),await Q(),$(n?{file:n}:{},!0),c(e(`note.toast.moved`),`success`)}catch(t){c(await u(t,e(`note.toast.moveFailed`)),`error`)}}function xt(t){gt()&&tt({title:t.type===`directory`?e(`note.delete.folderTitle`):e(`note.delete.noteTitle`),message:e(`note.delete.message`,{name:Re(t)}),confirmText:e(`note.action.delete`),onConfirm:async()=>{try{if(t.type===`directory`){let e=Oe(t),n=D.filter(t=>t.path.startsWith(`${e}/`));for(let e of n)await pe(e.path);g.startsWith(`${e}/`)&&$({},!0)}else await pe(t.cid),g===t.cid&&$({},!0);tt(null),await Q(),c(e(`note.toast.deleted`),`success`)}catch(t){c(await u(t,e(`note.toast.deleteFailed`)),`error`)}}})}async function St(){if(!l){m();return}if(!g||!z){c(e(`note.toast.notFound`),`error`);return}let t=I(He);if(!t){c(e(`note.toast.nameRequired`),`warning`);return}Xe(!0);try{let n=s.current?.getMarkdown()??qe,r=z.path;if(t!==z.name){r=f(z.directory?`${z.directory}/${t}`:t);let e=await S(z.path,r);B(e),V(F(e.name)),r=e.path}let i=await _e(r,n);B(i),V(F(i.name)),W(i.content),await Q(),$({file:i.path},!0),c(e(`note.toast.saved`),`success`)}catch(t){c(await u(t,e(`note.toast.saveFailed`)),`error`)}finally{Xe(!1)}}let Ct=(0,A.jsxs)(`div`,{className:`note-header-title`,children:[(0,A.jsx)(`h2`,{className:`header-title`,children:e(`note.title`)}),(0,A.jsx)(`span`,{children:e(`note.count`,{count:D.length})})]}),wt=(0,A.jsx)(`div`,{className:`note-theme-wrap`,children:(0,A.jsxs)(`button`,{className:`btn btn-sm`,onClick:ht,disabled:R,title:e(`note.vault.open`),"aria-label":e(`note.vault.open`),children:[(0,A.jsx)(v,{size:16}),e(R?`note.vault.opening`:`note.vault.open`)]})}),Tt=(0,A.jsxs)(`section`,{className:`note-list-panel note-sidebar-list`,"aria-label":e(`note.listLabel`),children:[(0,A.jsxs)(`div`,{className:`note-search`,children:[(0,A.jsx)(se,{size:16}),(0,A.jsx)(`input`,{className:`input input-flex`,value:L,onChange:e=>Ne(e.target.value),placeholder:e(`note.search.placeholder`)})]}),we?(0,A.jsxs)(`div`,{className:`ui-empty-state note-empty-state`,children:[(0,A.jsx)(b,{size:32}),(0,A.jsx)(`p`,{children:e(`note.loading`)})]}):De?(0,A.jsxs)(`div`,{className:`ui-empty-state note-empty-state`,children:[(0,A.jsx)(h,{size:32}),(0,A.jsx)(`p`,{children:De})]}):x?.configured===!0?st.length===0?(0,A.jsxs)(`div`,{className:`ui-empty-state note-empty-state`,children:[(0,A.jsx)(b,{size:32}),(0,A.jsx)(`p`,{children:e(L?`note.empty.noMatches`:`note.vault.noFiles`)})]}):(0,A.jsx)(Ge,{nodes:st,searchQuery:L,expandedPaths:Ze,activeFileId:g,activeFolderPath:g?``:j,onToggleDirectory:ft,onOpenFile:dt,renderActions:t=>(0,A.jsx)(C,{ariaLabel:e(`common.moreActions`),className:`note-list-actions-anchor`,placement:`bottom-end`,items:[{key:`move`,label:e(`note.action.move`),icon:(0,A.jsx)(ye,{size:16}),onSelect:()=>yt(t)},{key:`delete`,label:e(`note.action.delete`),icon:(0,A.jsx)(ce,{size:16}),danger:!0,onSelect:()=>xt(t)}],renderTrigger:t=>(0,A.jsx)(`button`,{...t,className:`note-list-actions-trigger`,title:e(`common.moreActions`),"aria-label":e(`common.moreActions`),children:(0,A.jsx)(p,{size:16})})})}):(0,A.jsxs)(`div`,{className:`ui-empty-state note-empty-state`,children:[(0,A.jsx)(v,{size:32}),(0,A.jsxs)(`button`,{className:`btn btn-primary`,onClick:ht,disabled:R,children:[(0,A.jsx)(v,{size:16}),e(R?`note.vault.opening`:`note.vault.open`)]})]}),x?.configured===!0&&(0,A.jsx)(`div`,{className:`note-create-btn`,children:(0,A.jsxs)(`button`,{className:`btn`,onClick:vt,children:[(0,A.jsx)(te,{size:16}),e(`note.newNote`)]})})]}),Et=z?.mtimeMs||Z?.updated_at||Date.now(),Dt=F(z?.name||Z?.name||``)||e(`note.untitled`);return(0,A.jsxs)(ae,{sidebar:()=>(0,A.jsx)(Se,{children:Tt}),headerTitle:Ct,headerRight:wt,children:[(0,A.jsx)(`main`,{className:`note-page note-browser-page ${_?`has-editor`:``}`,children:(0,A.jsx)(`section`,{className:`note-workspace`,children:(0,A.jsx)(`section`,{className:`note-editor-panel`,"aria-label":e(y?`note.editorLabel.edit`:`note.editorLabel.read`),children:_?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(`div`,{className:`note-editor-panel-header`,children:[(0,A.jsxs)(`div`,{className:`note-editor-title-area`,children:[y&&z?(0,A.jsx)(`input`,{className:`note-title-input`,value:He,onChange:e=>V(e.target.value),onKeyDown:e=>{if(e.key===`Enter`){e.currentTarget.blur();return}e.key===`Escape`&&(V(F(z.name)),e.currentTarget.blur())},placeholder:e(`note.namePlaceholder`),translate:`no`}):(0,A.jsx)(`h3`,{translate:`no`,children:Dt}),(0,A.jsxs)(`div`,{className:`note-editor-info`,children:[(0,A.jsx)(`span`,{children:e(y?`note.mode.edit`:`note.mode.read`)}),(0,A.jsx)(`span`,{translate:`no`,children:je(g)}),(0,A.jsx)(`span`,{children:t(Et)})]})]}),(0,A.jsxs)(`div`,{className:`note-editor-actions`,children:[(0,A.jsx)(`button`,{type:`button`,className:`btn btn-icon`,onClick:y?mt:()=>$(),title:e(y?`common.cancel`:`common.close`),"aria-label":e(y?`common.cancel`:`common.close`),children:(0,A.jsx)(de,{size:16})}),y?(0,A.jsxs)(`button`,{className:`btn btn-sm btn-primary`,onClick:St,disabled:Ye||!!q||!z,children:[(0,A.jsx)(oe,{size:16}),e(Ye?`note.action.saving`:`note.action.save`)]}):Z&&(0,A.jsxs)(`button`,{type:`button`,className:`btn btn-sm btn-primary`,onClick:pt,disabled:!!q||!z,title:e(`note.action.edit`),"aria-label":e(`note.action.edit`),children:[(0,A.jsx)(be,{size:16}),e(`note.action.edit`)]})]})]}),G?(0,A.jsxs)(`div`,{className:`ui-empty-state note-empty-state editor-error`,children:[(0,A.jsx)(b,{size:36}),(0,A.jsx)(`p`,{children:e(`note.loading`)})]}):q?(0,A.jsxs)(`div`,{className:`ui-empty-state note-empty-state editor-error`,children:[(0,A.jsx)(h,{size:36}),(0,A.jsx)(`p`,{children:q})]}):y?(0,A.jsx)(`div`,{className:`note-editor-frame editing`,children:(0,A.jsx)(Ce,{ref:s,content:qe,onChange:W,className:`milkdown-editor`})}):z?(0,A.jsx)(`div`,{className:`note-editor-frame reading`,children:(0,A.jsx)(Ce,{content:ct,readOnly:!0,onInternalNoteLinkOpen:ut,resolveWikiNoteLink:lt,className:`milkdown-editor`})}):(0,A.jsxs)(`div`,{className:`ui-empty-state note-empty-state editor-error`,children:[(0,A.jsx)(b,{size:36}),(0,A.jsx)(`p`,{children:e(`note.error.notFound`)})]})]}):(0,A.jsxs)(`div`,{className:`ui-empty-state note-editor-empty`,children:[(0,A.jsx)(`div`,{className:`ui-empty-icon note-editor-empty-icon`,children:(0,A.jsx)(b,{size:32})}),(0,A.jsx)(`h3`,{className:`ui-empty-title`,children:x?.configured?e(`note.noOpen.title`):e(`note.vault.open`)}),(0,A.jsx)(`p`,{className:`ui-empty-desc`,children:x?.configured?e(`note.noOpen.select`):e(`note.vault.emptyPrompt`)}),x?.configured?(0,A.jsx)(ie,{label:e(`note.openList`),variant:`default`}):(0,A.jsxs)(`button`,{className:`btn btn-primary`,onClick:ht,disabled:R,children:[(0,A.jsx)(v,{size:16}),e(R?`note.vault.opening`:`note.vault.open`)]})]})})})}),J&&(0,A.jsx)(fe,{title:J.title,placeholder:J.placeholder,defaultValue:J.defaultValue,confirmText:J.confirmText,onConfirm:J.onConfirm,onClose:()=>$e(null)}),et&&(0,A.jsx)(ve,{title:et.title,message:et.message,confirmText:et.confirmText,danger:!0,onConfirm:et.onConfirm,onClose:()=>tt(null)}),Y&&(0,A.jsx)(xe,{target:Y,targetLabel:Re(Y),directories:at,onMove:bt,onClose:()=>nt(null)})]})}function q(){let{t:e}=le(),t=d(e=>e.hasBackend),n=a(e=>e.wallet),r=x(),i=t===!0&&qe(c()),o=W(i,n?.address||``),s=i&&(r||o);return(0,A.jsx)(k.Suspense,{fallback:(0,A.jsx)(`div`,{className:`note-editor-loading`,children:e(`note.loading`)}),children:s?(0,A.jsx)(K,{}):(0,A.jsx)(G,{})})}var Je=o(`/note/`)({component:q});export{Je as Route};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{B as e}from"./useAppStore-DOnk608w.js";var t=e(`notebook-pen`,[[`path`,{d:`M13.4 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-7.4`,key:`re6nr2`}],[`path`,{d:`M2 6h4`,key:`aawbzj`}],[`path`,{d:`M2 10h4`,key:`l0bgd4`}],[`path`,{d:`M2 14h4`,key:`1gsvsf`}],[`path`,{d:`M2 18h4`,key:`1bu2t1`}],[`path`,{d:`M21.378 5.626a1 1 0 1 0-3.004-3.004l-5.01 5.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z`,key:`pqwjuv`}]]);export{t};
|