most-box 0.2.6 → 0.2.8
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 +15 -1
- package/electron/main.js +30 -420
- package/electron/preload.js +1 -16
- package/electron/updateChecker.js +12 -30
- package/electron/updateChecker.test.js +14 -55
- package/out/admin/index.html +0 -0
- package/out/app/index.html +0 -0
- package/out/assets/{FilePreviewOverlay-DqH7uKb7.js → FilePreviewOverlay-D8H61qbp.js} +1 -1
- package/out/assets/LanguageToggle-CSQtRZ3A.js +1 -0
- package/out/assets/MarketingHeader-CrYsQsQ5.js +1 -0
- package/out/assets/MarketingLayout-CQurMOSD.js +1 -0
- package/out/assets/{MarketingThemeToggle-BLuQ_uE-.js → MarketingThemeToggle-CIKP8x9W.js} +1 -1
- package/out/assets/{MilkdownEditor-f2vRIY21.js → MilkdownEditor-DrsyaR4h.js} +1 -1
- package/out/assets/{OpenSidebarButton-BKX4B_yG.js → OpenSidebarButton-DnEgqP0S.js} +1 -1
- package/out/assets/{SidebarAccount-D6wj_ijc.js → SidebarAccount-B4OAl0as.js} +1 -1
- package/out/assets/SidebarHomeLink-BdsUM4Kt.js +1 -0
- package/out/assets/arrow-right-BU9c_SL4.js +1 -0
- package/out/assets/{circle-alert-Dyc-4wje.js → circle-alert-iuHzciph.js} +1 -1
- package/out/assets/{copy-D8HSH5Ki.js → copy-DEzFUzeX.js} +1 -1
- package/out/assets/{download-Q6jKMPIG.js → download-jEPn2njL.js} +1 -1
- package/out/assets/{downloadValidation-B-w8D_0W.js → downloadValidation-DbVOwdmC.js} +1 -1
- package/out/assets/{external-link-GQcZwDTT.js → external-link-BFaoZeK0.js} +1 -1
- package/out/assets/{file-text-CVl5SZPJ.js → file-text-DPA1riJ_.js} +1 -1
- package/out/assets/{folder-BtIdk-YN.js → folder-Cfgc70_F.js} +1 -1
- package/out/assets/{hard-drive-Cew_LD0N.js → hard-drive-Dar_AZEq.js} +1 -1
- package/out/assets/i18n-NjvOSuV6.js +1 -0
- package/out/assets/index-BZ-f0CZd.js +31 -0
- package/out/assets/index-Cde4g_dk.css +1 -0
- package/out/assets/index.lazy-B7AbDiMU.js +3 -0
- package/out/assets/{index.lazy-DujygWms.js → index.lazy-BsciBHf_.js} +1 -1
- package/out/assets/index.lazy-BxoGfWEW.js +1 -0
- package/out/assets/index.lazy-CKbrHko5.js +1 -0
- package/out/assets/index.lazy-CgKPe02l.js +1 -0
- package/out/assets/index.lazy-Citucq1G.js +1 -0
- package/out/assets/index.lazy-CvKEcWlH.js +2 -0
- package/out/assets/{index.lazy-WXDn5r_l.js → index.lazy-DB9Ht9LJ.js} +1 -1
- package/out/assets/index.lazy-DVeqmqaA.js +1 -0
- package/out/assets/index.lazy-hF807bh0.js +1 -0
- package/out/assets/index.lazy-oFaoa4qT.js +1 -0
- package/out/assets/index.lazy-rfgjFZNH.js +1 -0
- package/out/assets/index.lazy-zpQXhgmn.js +2 -0
- package/out/assets/{key-round-D1zfZzvP.js → key-round-DNcpSuMw.js} +1 -1
- package/out/assets/{loader-BSclU8WE.js → loader-BXQtdens.js} +1 -1
- package/out/assets/{lock-C9VP0ezG.js → lock-CLIE8cct.js} +1 -1
- package/out/assets/{message-square-Dg3YjjmO.js → message-square-Dp09WY1I.js} +1 -1
- package/out/assets/{mp-FQvFEcYM.js → mp-B6kdA94c.js} +1 -1
- package/out/assets/{music-BeCPak70.js → music-B19Tg557.js} +1 -1
- package/out/assets/{notebook-pen-DO1CJiqn.js → notebook-pen-C8TlK5sB.js} +1 -1
- package/out/assets/play-B-BjsTZz.js +1 -0
- package/out/assets/plus-4hygj-1Z.js +1 -0
- package/out/assets/{save-BVeMjaW1.js → save-BjrbPwhJ.js} +1 -1
- package/out/assets/search-DSkiWdvX.js +1 -0
- package/out/assets/{send-C1J-eGNs.js → send-BL4d5iOt.js} +1 -1
- package/out/assets/{shield-check-CZYDVJoh.js → shield-check-DzDuWO8r.js} +1 -1
- package/out/assets/smartphone-tRRFFO0a.js +1 -0
- package/out/assets/{trash-2-C_LtCiNh.js → trash-2-V12tJ8lI.js} +1 -1
- package/out/assets/triangle-alert-DGWc8ZHu.js +1 -0
- package/out/assets/{ui-PnUvY9zL.js → ui-BpDGD3IR.js} +2 -2
- package/out/assets/{upload-DgxxldtV.js → upload-CoCptKya.js} +1 -1
- package/out/assets/{useChannelMessages-CZHmH5n-.js → useChannelMessages-B6RMaNDH.js} +1 -1
- package/out/assets/useGameRoom-CRJL0kcm.js +1 -0
- package/out/assets/userProfile-DBkH4s29.js +1 -0
- package/out/assets/{wallet-DBTWBi6K.js → wallet-T7ONZ3Kg.js} +1 -1
- package/out/assets/{wifi-pP6SJLcu.js → wifi-Bgo8eHY0.js} +1 -1
- package/out/chat/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 +5 -8
- package/server/src/core/channelIdentity.js +3 -5
- package/server/src/core/gameRoom.js +18 -43
- package/server/src/core/ownerMetadata.js +3 -4
- package/server/src/core/releaseManifest.js +91 -0
- package/server/src/core/shared.js +50 -0
- package/server/src/core/zhajinhua.js +12 -33
- package/server/src/games/gandengyan.js +7 -14
- package/server/src/http/nodeStatus.js +0 -6
- package/server/src/http/routes/channelRoutes.js +1 -13
- package/server/src/http/routes/nodeRoutes.js +1 -1
- package/server/src/index.js +44 -298
- package/server/src/utils/api.js +47 -0
- package/server/src/utils/auth.js +2 -5
- package/server/src/utils/dateTime.js +1 -3
- package/out/assets/LanguageToggle-BoBNesNU.js +0 -1
- package/out/assets/MarketingHeader-Derv67Vs.js +0 -1
- package/out/assets/MarketingLayout-fc2mymJm.js +0 -1
- package/out/assets/SidebarHomeLink-ByOHwlH8.js +0 -1
- package/out/assets/arrow-right-BCi9KXDX.js +0 -1
- package/out/assets/cloud-DfaFxhLj.js +0 -1
- package/out/assets/i18n--maTEG0d.js +0 -1
- package/out/assets/index-B2-kpfu5.css +0 -1
- package/out/assets/index-Cg4kEvx8.js +0 -31
- package/out/assets/index.lazy-BAq__8ON.js +0 -2
- package/out/assets/index.lazy-BPh8D_H9.js +0 -1
- package/out/assets/index.lazy-Bn4kDToA.js +0 -1
- package/out/assets/index.lazy-BqHgW5fE.js +0 -1
- package/out/assets/index.lazy-CLYRM_kh.js +0 -1
- package/out/assets/index.lazy-CMSCQucz.js +0 -1
- package/out/assets/index.lazy-Cut4XkPH.js +0 -1
- package/out/assets/index.lazy-DKOSJyaQ.js +0 -2
- package/out/assets/index.lazy-DjPbRI_L.js +0 -1
- package/out/assets/index.lazy-DxAGUwlf.js +0 -3
- package/out/assets/index.lazy-ghLI7p1x.js +0 -1
- package/out/assets/play-CnhsLC5C.js +0 -1
- package/out/assets/plus-BpjwXzbO.js +0 -1
- package/out/assets/search-CsAnnJyH.js +0 -1
- package/out/assets/triangle-alert-DOwc-41Y.js +0 -1
- package/out/assets/useGameRoom-B8Ds_PKe.js +0 -1
- package/out/assets/userProfile-CRGZ8PUF.js +0 -1
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{n as e,o as t,t as n}from"./jsx-runtime-Bt-cYkS5.js";import{C as r,T as i,_ as a,d as o,g as s,l as c,m as l,s as u,u as d,y as f}from"./ui-BpDGD3IR.js";import{a as p}from"./i18n-NjvOSuV6.js";import{n as m,r as h}from"./LanguageToggle-CSQtRZ3A.js";import{n as g,t as _}from"./lock-CLIE8cct.js";import{t as v}from"./download-jEPn2njL.js";import{t as y}from"./external-link-BFaoZeK0.js";import{a as b,i as x,n as S,r as C,t as w}from"./mp-B6kdA94c.js";import{t as T}from"./key-round-DNcpSuMw.js";import{n as ee,t as te}from"./SidebarHomeLink-BdsUM4Kt.js";import{t as ne}from"./wallet-T7ONZ3Kg.js";import{N as E,P as D,c as re,i as ie}from"./index-BZ-f0CZd.js";var O=r(`chevron-up`,[[`path`,{d:`m18 15-6-6-6 6`,key:`153udz`}]]),ae=r(`globe`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20`,key:`13o1zl`}],[`path`,{d:`M2 12h20`,key:`9i4pu4`}]]),oe=r(`qr-code`,[[`rect`,{width:`5`,height:`5`,x:`3`,y:`3`,rx:`1`,key:`1tu5fj`}],[`rect`,{width:`5`,height:`5`,x:`16`,y:`3`,rx:`1`,key:`1v8r4q`}],[`rect`,{width:`5`,height:`5`,x:`3`,y:`16`,rx:`1`,key:`1x03jg`}],[`path`,{d:`M21 16h-3a2 2 0 0 0-2 2v3`,key:`177gqh`}],[`path`,{d:`M21 21v.01`,key:`ents32`}],[`path`,{d:`M12 7v3a2 2 0 0 1-2 2H7`,key:`8crl2c`}],[`path`,{d:`M3 12h.01`,key:`nlz23k`}],[`path`,{d:`M12 3h.01`,key:`n36tog`}],[`path`,{d:`M12 16v.01`,key:`133mhm`}],[`path`,{d:`M16 12h1`,key:`1slzba`}],[`path`,{d:`M21 12v.01`,key:`1lwtk9`}],[`path`,{d:`M12 21v-1`,key:`1880an`}]]),se=r(`shield-alert`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`M12 8v4`,key:`1got3b`}],[`path`,{d:`M12 16h.01`,key:`1drbdi`}]]),ce=r(`shield`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}]]),k=t(e()),A=n();function le(e){return e?`•`.repeat(Math.min(e.length,32)):`-`}function ue({title:e,username:t,password:n,showPassword:r,showPrivateKey:i,account:a,onUsernameChange:o,onPasswordChange:s,onTogglePassword:c,onTogglePrivateKey:l,onGenerate:u}){let{t:d}=p();return(0,A.jsxs)(`div`,{className:`web3-box-account`,children:[(0,A.jsx)(`div`,{className:`web3-box-account-header`,children:(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`h2`,{children:e}),(0,A.jsx)(`p`,{children:d(`web3.box.account.desc`)})]})}),(0,A.jsxs)(`div`,{className:`web3-box-login`,children:[(0,A.jsx)(`input`,{type:`text`,placeholder:d(`login.username.placeholder`),value:t,onChange:e=>o(e.target.value),className:`input`,autoCapitalize:`off`,autoCorrect:`off`,spellCheck:`false`}),(0,A.jsxs)(`div`,{className:`input-wrap`,children:[(0,A.jsx)(`input`,{type:r?`text`:`password`,placeholder:d(`web3.login.passwordOptional`),value:n,onChange:e=>s(e.target.value),className:`input`,autoCapitalize:`off`,autoCorrect:`off`,spellCheck:`false`}),(0,A.jsx)(`button`,{className:`input-eye`,onClick:c,type:`button`,children:r?(0,A.jsx)(D,{size:16}):(0,A.jsx)(E,{size:16})})]}),(0,A.jsxs)(`button`,{className:`btn btn-primary btn-full`,onClick:u,disabled:!t.trim(),type:`button`,children:[(0,A.jsx)(T,{size:16}),d(`web3.box.account.generate`)]})]}),a?(0,A.jsxs)(`div`,{className:`web3-box-key-list`,children:[(0,A.jsxs)(`div`,{className:`web3-box-key-row`,children:[(0,A.jsx)(`span`,{children:d(`web3.label.address`)}),(0,A.jsxs)(`div`,{className:`mono-row`,children:[(0,A.jsx)(`code`,{className:`mono`,translate:`no`,children:a.address.toLowerCase()}),(0,A.jsx)(C,{text:a.address.toLowerCase()})]})]}),(0,A.jsxs)(`div`,{className:`web3-box-key-row`,children:[(0,A.jsx)(`span`,{children:d(`web3.label.x25519Public`)}),(0,A.jsxs)(`div`,{className:`mono-row`,children:[(0,A.jsx)(`code`,{className:`mono`,translate:`no`,children:a.publicKey}),(0,A.jsx)(C,{text:a.publicKey})]})]}),(0,A.jsxs)(`div`,{className:`web3-box-key-row`,children:[(0,A.jsx)(`span`,{children:d(`web3.label.x25519Private`)}),(0,A.jsxs)(`div`,{className:`mono-row danger`,children:[(0,A.jsx)(`code`,{className:`mono`,translate:`no`,children:i?a.privateKey:le(a.privateKey)}),(0,A.jsx)(`button`,{className:`btn btn-icon`,onClick:l,title:d(i?`web3.action.hidePrivateKey`:`web3.action.showPrivateKey`),type:`button`,children:i?(0,A.jsx)(E,{size:14}):(0,A.jsx)(D,{size:14})})]})]})]}):null]})}function de(e,t){return Number.isFinite(e)?t(e):`-`}function fe({title:e,description:t,message:n,cipherText:r,decryptedText:i,error:o,encryptLabel:s,decryptLabel:c,messagePlaceholder:l,cipherPlaceholder:u,onMessageChange:d,onCipherTextChange:f,onEncrypt:m,onDecrypt:h}){let{t:g,formatDateTime:v}=p(),y=`box-message-${e.replaceAll(/\s+/g,`-`)}`,b=a(r);return(0,A.jsxs)(`section`,{className:`web3-box-flow`,children:[(0,A.jsx)(`div`,{className:`web3-box-flow-header`,children:(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`h2`,{children:e}),(0,A.jsx)(`p`,{children:t})]})}),(0,A.jsx)(`label`,{className:`web3-box-label`,htmlFor:y,children:g(`web3.box.plaintext`)}),(0,A.jsx)(`textarea`,{id:y,className:`textarea`,value:n,onChange:e=>d(e.target.value),rows:4,placeholder:l,translate:`no`}),(0,A.jsxs)(`div`,{className:`web3-box-actions`,children:[(0,A.jsxs)(`button`,{className:`btn btn-primary`,onClick:m,type:`button`,children:[(0,A.jsx)(_,{size:16}),s]}),(0,A.jsxs)(`button`,{className:`btn btn-secondary`,onClick:h,type:`button`,children:[(0,A.jsx)(T,{size:16}),c]})]}),o&&(0,A.jsx)(`p`,{className:`web3-tools-danger`,children:o}),(0,A.jsxs)(`div`,{className:`web3-box-result-grid`,children:[(0,A.jsxs)(`div`,{className:`web3-box-result`,children:[(0,A.jsx)(`label`,{className:`web3-box-result-header`,children:(0,A.jsx)(`span`,{children:g(`web3.box.ciphertext`)})}),(0,A.jsx)(`textarea`,{className:`textarea mono`,value:r,onChange:e=>f(e.target.value),rows:5,placeholder:u,translate:`no`})]}),(0,A.jsxs)(`div`,{className:`web3-box-result`,children:[(0,A.jsx)(`label`,{className:`web3-box-result-header`,children:(0,A.jsx)(`span`,{children:g(`web3.box.decryptResult`)})}),(0,A.jsx)(`textarea`,{className:`textarea mono`,value:i,readOnly:!0,rows:5,placeholder:g(`web3.box.decryptResultPlaceholder`),translate:`no`})]})]}),b&&(0,A.jsxs)(`div`,{className:`web3-box-token-meta`,children:[(0,A.jsxs)(`div`,{className:`web3-box-token-meta-row`,children:[(0,A.jsx)(`span`,{children:g(`web3.box.timestamp`)}),(0,A.jsx)(`code`,{translate:`no`,children:de(b.timestampMs,v)})]}),(0,A.jsxs)(`div`,{className:`web3-box-token-meta-row`,children:[(0,A.jsx)(`span`,{children:g(`web3.box.nonce`)}),(0,A.jsx)(`code`,{translate:`no`,children:b.nonce})]})]})]})}function pe(e){let{t}=p();return(0,A.jsxs)(`div`,{className:`web3-box-workspace`,children:[(0,A.jsxs)(`div`,{className:`web3-box-grid`,children:[(0,A.jsx)(ue,{title:t(`web3.box.accountA`),username:e.boxAUsername,password:e.boxAPassword,showPassword:e.boxAShowPassword,showPrivateKey:e.boxAShowPrivateKey,account:e.boxAAccount,onUsernameChange:e.onBoxAUsernameChange,onPasswordChange:e.onBoxAPasswordChange,onTogglePassword:e.onBoxAShowPasswordToggle,onTogglePrivateKey:e.onBoxAShowPrivateKeyToggle,onGenerate:e.onGenerateBoxA}),(0,A.jsx)(ue,{title:t(`web3.box.accountB`),username:e.boxBUsername,password:e.boxBPassword,showPassword:e.boxBShowPassword,showPrivateKey:e.boxBShowPrivateKey,account:e.boxBAccount,onUsernameChange:e.onBoxBUsernameChange,onPasswordChange:e.onBoxBPasswordChange,onTogglePassword:e.onBoxBShowPasswordToggle,onTogglePrivateKey:e.onBoxBShowPrivateKeyToggle,onGenerate:e.onGenerateBoxB})]}),(0,A.jsxs)(`div`,{className:`web3-box-flow-grid`,children:[(0,A.jsx)(fe,{title:`A → B`,description:t(`web3.box.flowAB.desc`),message:e.boxABMessage,cipherText:e.boxABCipherText,decryptedText:e.boxABDecryptedText,error:e.boxABError,encryptLabel:t(`web3.box.flowAB.encrypt`),decryptLabel:t(`web3.box.flowAB.decrypt`),messagePlaceholder:t(`web3.box.flowAB.messagePlaceholder`),cipherPlaceholder:t(`web3.box.cipherPlaceholder`),onMessageChange:e.onBoxABMessageChange,onCipherTextChange:e.onBoxABCipherTextChange,onEncrypt:e.onEncryptBoxAB,onDecrypt:e.onDecryptBoxAB}),(0,A.jsx)(fe,{title:`B → A`,description:t(`web3.box.flowBA.desc`),message:e.boxBAMessage,cipherText:e.boxBACipherText,decryptedText:e.boxBADecryptedText,error:e.boxBAError,encryptLabel:t(`web3.box.flowBA.encrypt`),decryptLabel:t(`web3.box.flowBA.decrypt`),messagePlaceholder:t(`web3.box.flowBA.messagePlaceholder`),cipherPlaceholder:t(`web3.box.cipherPlaceholder`),onMessageChange:e.onBoxBAMessageChange,onCipherTextChange:e.onBoxBACipherTextChange,onEncrypt:e.onEncryptBoxBA,onDecrypt:e.onDecryptBoxBA})]}),(0,A.jsxs)(`div`,{className:`web3-box-flow-grid`,children:[(0,A.jsxs)(`section`,{className:`web3-box-flow`,children:[(0,A.jsx)(`div`,{className:`web3-box-flow-header`,children:(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`h2`,{children:t(`web3.box.encryptTitle`)}),(0,A.jsx)(`p`,{children:t(`web3.box.encryptDesc`)})]})}),(0,A.jsx)(`label`,{className:`web3-box-result-header`,children:(0,A.jsx)(`span`,{children:t(`web3.box.sender`)})}),(0,A.jsxs)(`div`,{className:`input-wrap`,children:[(0,A.jsx)(`input`,{type:e.boxEncryptShowPrivateKey?`text`:`password`,placeholder:t(`web3.box.senderPrivatePlaceholder`),value:e.boxEncryptSenderPrivateKey,onChange:t=>e.onBoxEncryptSenderPrivateKeyChange(t.target.value),className:`input`,autoCapitalize:`off`,autoCorrect:`off`,spellCheck:`false`}),(0,A.jsx)(`button`,{className:`input-eye`,onClick:e.onBoxEncryptShowPrivateKeyToggle,type:`button`,children:e.boxEncryptShowPrivateKey?(0,A.jsx)(D,{size:16}):(0,A.jsx)(E,{size:16})})]}),(0,A.jsx)(`label`,{className:`web3-box-result-header`,children:(0,A.jsx)(`span`,{children:t(`web3.box.recipient`)})}),(0,A.jsx)(`input`,{type:`text`,placeholder:t(`web3.box.recipientPublicPlaceholder`),value:e.boxEncryptRecipientPublicKey,onChange:t=>e.onBoxEncryptRecipientPublicKeyChange(t.target.value),className:`input`,autoCapitalize:`off`,autoCorrect:`off`,spellCheck:`false`}),(0,A.jsx)(`label`,{className:`web3-box-result-header`,children:(0,A.jsx)(`span`,{children:t(`web3.box.plaintext`)})}),(0,A.jsx)(`textarea`,{className:`textarea`,value:e.boxEncryptMessage,onChange:t=>e.onBoxEncryptMessageChange(t.target.value),rows:4,placeholder:t(`web3.box.messagePlaceholder`),translate:`no`}),(0,A.jsx)(`div`,{className:`web3-box-actions`,children:(0,A.jsxs)(`button`,{className:`btn btn-primary`,onClick:e.onEncryptOnly,type:`button`,children:[(0,A.jsx)(_,{size:16}),t(`web3.box.encryptTitle`)]})}),e.boxEncryptError&&(0,A.jsx)(`p`,{className:`web3-tools-danger`,children:e.boxEncryptError}),(0,A.jsxs)(`div`,{className:`web3-box-result`,children:[(0,A.jsx)(`label`,{className:`web3-box-result-header`,children:(0,A.jsx)(`span`,{children:t(`web3.box.ciphertext`)})}),(0,A.jsx)(`textarea`,{className:`textarea mono`,value:e.boxEncryptCipherText,readOnly:!0,rows:5,placeholder:t(`web3.box.encryptResultPlaceholder`),translate:`no`})]})]}),(0,A.jsxs)(`section`,{className:`web3-box-flow`,children:[(0,A.jsx)(`div`,{className:`web3-box-flow-header`,children:(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`h2`,{children:t(`web3.box.decryptTitle`)}),(0,A.jsx)(`p`,{children:t(`web3.box.decryptDesc`)})]})}),(0,A.jsx)(`label`,{className:`web3-box-result-header`,children:(0,A.jsx)(`span`,{children:t(`web3.box.sender`)})}),(0,A.jsx)(`input`,{type:`text`,placeholder:t(`web3.box.senderPublicPlaceholder`),value:e.boxDecryptSenderPublicKey,onChange:t=>e.onBoxDecryptSenderPublicKeyChange(t.target.value),className:`input`,autoCapitalize:`off`,autoCorrect:`off`,spellCheck:`false`}),(0,A.jsx)(`label`,{className:`web3-box-result-header`,children:(0,A.jsx)(`span`,{children:t(`web3.box.recipient`)})}),(0,A.jsxs)(`div`,{className:`input-wrap`,children:[(0,A.jsx)(`input`,{type:e.boxDecryptShowPrivateKey?`text`:`password`,placeholder:t(`web3.box.recipientPrivatePlaceholder`),value:e.boxDecryptRecipientPrivateKey,onChange:t=>e.onBoxDecryptRecipientPrivateKeyChange(t.target.value),className:`input`,autoCapitalize:`off`,autoCorrect:`off`,spellCheck:`false`}),(0,A.jsx)(`button`,{className:`input-eye`,onClick:e.onBoxDecryptShowPrivateKeyToggle,type:`button`,children:e.boxDecryptShowPrivateKey?(0,A.jsx)(D,{size:16}):(0,A.jsx)(E,{size:16})})]}),(0,A.jsx)(`label`,{className:`web3-box-result-header`,children:(0,A.jsx)(`span`,{children:t(`web3.box.ciphertext`)})}),(0,A.jsx)(`textarea`,{className:`textarea mono`,value:e.boxDecryptCipherText,onChange:t=>e.onBoxDecryptCipherTextChange(t.target.value),rows:5,placeholder:t(`web3.box.cipherDecryptPlaceholder`),translate:`no`}),(0,A.jsx)(`div`,{className:`web3-box-actions`,children:(0,A.jsxs)(`button`,{className:`btn btn-secondary`,onClick:e.onDecryptOnly,type:`button`,children:[(0,A.jsx)(T,{size:16}),t(`web3.box.decryptTitle`)]})}),e.boxDecryptError&&(0,A.jsx)(`p`,{className:`web3-tools-danger`,children:e.boxDecryptError}),(0,A.jsxs)(`div`,{className:`web3-box-result`,children:[(0,A.jsx)(`label`,{className:`web3-box-result-header`,children:(0,A.jsx)(`span`,{children:t(`web3.box.decryptResult`)})}),(0,A.jsx)(`textarea`,{className:`textarea mono`,value:e.boxDecryptResult,readOnly:!0,rows:5,placeholder:t(`web3.box.decryptResultPlaceholder`),translate:`no`})]})]})]})]})}function j({icon:e,message:t,className:n=`empty-state glass`}){return(0,A.jsxs)(`div`,{className:n,children:[(0,A.jsx)(`div`,{className:`empty-state-icon`,children:e}),(0,A.jsx)(`p`,{children:t})]})}function M({label:e,pem:t,filename:n}){let{t:r}=p();function i(){let e=new Blob([t],{type:`text/plain`}),r=URL.createObjectURL(e),i=document.createElement(`a`);i.href=r,i.download=n,i.click(),URL.revokeObjectURL(r)}return(0,A.jsxs)(`div`,{className:`web3-pem-block`,children:[(0,A.jsxs)(`div`,{className:`web3-pem-header`,children:[(0,A.jsx)(`span`,{className:`web3-pem-label`,children:e}),(0,A.jsxs)(`div`,{className:`web3-pem-actions`,children:[(0,A.jsx)(C,{text:t,label:r(`common.copy`),className:`btn btn-sm`,iconSize:14}),(0,A.jsxs)(`button`,{type:`button`,className:`btn btn-sm btn-primary`,onClick:i,title:r(`common.download`),children:[(0,A.jsx)(v,{size:14}),r(`common.download`)]})]})]}),(0,A.jsx)(`textarea`,{className:`textarea mono`,value:t,readOnly:!0,rows:6,translate:`no`})]})}function me({walletResult:e,publicPem:t,privatePem:n}){let{t:r}=p();if(!t||!n)return(0,A.jsx)(j,{icon:(0,A.jsx)(_,{size:36}),message:r(`web3.empty.pem`)});let i=e?.username||`wallet`;return(0,A.jsxs)(`div`,{className:`web3-pem-list`,children:[(0,A.jsx)(M,{label:`${i}.pub`,pem:t,filename:`${i}.pub`}),(0,A.jsx)(M,{label:`${i}.pem`,pem:n,filename:`${i}.pem`})]})}var he=Object.defineProperty,N=Object.getOwnPropertySymbols,P=Object.prototype.hasOwnProperty,F=Object.prototype.propertyIsEnumerable,I=(e,t,n)=>t in e?he(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,L=(e,t)=>{for(var n in t||={})P.call(t,n)&&I(e,n,t[n]);if(N)for(var n of N(t))F.call(t,n)&&I(e,n,t[n]);return e},R=(e,t)=>{var n={};for(var r in e)P.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&N)for(var r of N(e))t.indexOf(r)<0&&F.call(e,r)&&(n[r]=e[r]);return n},z;(e=>{let t=class t{constructor(e,n,r,a){if(this.version=e,this.errorCorrectionLevel=n,this.modules=[],this.isFunction=[],e<t.MIN_VERSION||e>t.MAX_VERSION)throw RangeError(`Version value out of range`);if(a<-1||a>7)throw RangeError(`Mask value out of range`);this.size=e*4+17;let o=[];for(let e=0;e<this.size;e++)o.push(!1);for(let e=0;e<this.size;e++)this.modules.push(o.slice()),this.isFunction.push(o.slice());this.drawFunctionPatterns();let s=this.addEccAndInterleave(r);if(this.drawCodewords(s),a==-1){let e=1e9;for(let t=0;t<8;t++){this.applyMask(t),this.drawFormatBits(t);let n=this.getPenaltyScore();n<e&&(a=t,e=n),this.applyMask(t)}}i(0<=a&&a<=7),this.mask=a,this.applyMask(a),this.drawFormatBits(a),this.isFunction=[]}static encodeText(n,r){let i=e.QrSegment.makeSegments(n);return t.encodeSegments(i,r)}static encodeBinary(n,r){let i=e.QrSegment.makeBytes(n);return t.encodeSegments([i],r)}static encodeSegments(e,r,a=1,s=40,c=-1,l=!0){if(!(t.MIN_VERSION<=a&&a<=s&&s<=t.MAX_VERSION)||c<-1||c>7)throw RangeError(`Invalid value`);let u,d;for(u=a;;u++){let n=t.getNumDataCodewords(u,r)*8,i=o.getTotalBits(e,u);if(i<=n){d=i;break}if(u>=s)throw RangeError(`Data too long`)}for(let e of[t.Ecc.MEDIUM,t.Ecc.QUARTILE,t.Ecc.HIGH])l&&d<=t.getNumDataCodewords(u,e)*8&&(r=e);let f=[];for(let t of e){n(t.mode.modeBits,4,f),n(t.numChars,t.mode.numCharCountBits(u),f);for(let e of t.getData())f.push(e)}i(f.length==d);let p=t.getNumDataCodewords(u,r)*8;i(f.length<=p),n(0,Math.min(4,p-f.length),f),n(0,(8-f.length%8)%8,f),i(f.length%8==0);for(let e=236;f.length<p;e^=253)n(e,8,f);let m=[];for(;m.length*8<f.length;)m.push(0);return f.forEach((e,t)=>m[t>>>3]|=e<<7-(t&7)),new t(u,r,m,c)}getModule(e,t){return 0<=e&&e<this.size&&0<=t&&t<this.size&&this.modules[t][e]}getModules(){return this.modules}drawFunctionPatterns(){for(let e=0;e<this.size;e++)this.setFunctionModule(6,e,e%2==0),this.setFunctionModule(e,6,e%2==0);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);let e=this.getAlignmentPatternPositions(),t=e.length;for(let n=0;n<t;n++)for(let r=0;r<t;r++)n==0&&r==0||n==0&&r==t-1||n==t-1&&r==0||this.drawAlignmentPattern(e[n],e[r]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(e){let t=this.errorCorrectionLevel.formatBits<<3|e,n=t;for(let e=0;e<10;e++)n=n<<1^(n>>>9)*1335;let a=(t<<10|n)^21522;i(a>>>15==0);for(let e=0;e<=5;e++)this.setFunctionModule(8,e,r(a,e));this.setFunctionModule(8,7,r(a,6)),this.setFunctionModule(8,8,r(a,7)),this.setFunctionModule(7,8,r(a,8));for(let e=9;e<15;e++)this.setFunctionModule(14-e,8,r(a,e));for(let e=0;e<8;e++)this.setFunctionModule(this.size-1-e,8,r(a,e));for(let e=8;e<15;e++)this.setFunctionModule(8,this.size-15+e,r(a,e));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let e=this.version;for(let t=0;t<12;t++)e=e<<1^(e>>>11)*7973;let t=this.version<<12|e;i(t>>>18==0);for(let e=0;e<18;e++){let n=r(t,e),i=this.size-11+e%3,a=Math.floor(e/3);this.setFunctionModule(i,a,n),this.setFunctionModule(a,i,n)}}drawFinderPattern(e,t){for(let n=-4;n<=4;n++)for(let r=-4;r<=4;r++){let i=Math.max(Math.abs(r),Math.abs(n)),a=e+r,o=t+n;0<=a&&a<this.size&&0<=o&&o<this.size&&this.setFunctionModule(a,o,i!=2&&i!=4)}}drawAlignmentPattern(e,t){for(let n=-2;n<=2;n++)for(let r=-2;r<=2;r++)this.setFunctionModule(e+r,t+n,Math.max(Math.abs(r),Math.abs(n))!=1)}setFunctionModule(e,t,n){this.modules[t][e]=n,this.isFunction[t][e]=!0}addEccAndInterleave(e){let n=this.version,r=this.errorCorrectionLevel;if(e.length!=t.getNumDataCodewords(n,r))throw RangeError(`Invalid argument`);let a=t.NUM_ERROR_CORRECTION_BLOCKS[r.ordinal][n],o=t.ECC_CODEWORDS_PER_BLOCK[r.ordinal][n],s=Math.floor(t.getNumRawDataModules(n)/8),c=a-s%a,l=Math.floor(s/a),u=[],d=t.reedSolomonComputeDivisor(o);for(let n=0,r=0;n<a;n++){let i=e.slice(r,r+l-o+(n<c?0:1));r+=i.length;let a=t.reedSolomonComputeRemainder(i,d);n<c&&i.push(0),u.push(i.concat(a))}let f=[];for(let e=0;e<u[0].length;e++)u.forEach((t,n)=>{(e!=l-o||n>=c)&&f.push(t[e])});return i(f.length==s),f}drawCodewords(e){if(e.length!=Math.floor(t.getNumRawDataModules(this.version)/8))throw RangeError(`Invalid argument`);let n=0;for(let t=this.size-1;t>=1;t-=2){t==6&&(t=5);for(let i=0;i<this.size;i++)for(let a=0;a<2;a++){let o=t-a,s=t+1&2?i:this.size-1-i;!this.isFunction[s][o]&&n<e.length*8&&(this.modules[s][o]=r(e[n>>>3],7-(n&7)),n++)}}i(n==e.length*8)}applyMask(e){if(e<0||e>7)throw RangeError(`Mask value out of range`);for(let t=0;t<this.size;t++)for(let n=0;n<this.size;n++){let r;switch(e){case 0:r=(n+t)%2==0;break;case 1:r=t%2==0;break;case 2:r=n%3==0;break;case 3:r=(n+t)%3==0;break;case 4:r=(Math.floor(n/3)+Math.floor(t/2))%2==0;break;case 5:r=n*t%2+n*t%3==0;break;case 6:r=(n*t%2+n*t%3)%2==0;break;case 7:r=((n+t)%2+n*t%3)%2==0;break;default:throw Error(`Unreachable`)}!this.isFunction[t][n]&&r&&(this.modules[t][n]=!this.modules[t][n])}}getPenaltyScore(){let e=0;for(let n=0;n<this.size;n++){let r=!1,i=0,a=[0,0,0,0,0,0,0];for(let o=0;o<this.size;o++)this.modules[n][o]==r?(i++,i==5?e+=t.PENALTY_N1:i>5&&e++):(this.finderPenaltyAddHistory(i,a),r||(e+=this.finderPenaltyCountPatterns(a)*t.PENALTY_N3),r=this.modules[n][o],i=1);e+=this.finderPenaltyTerminateAndCount(r,i,a)*t.PENALTY_N3}for(let n=0;n<this.size;n++){let r=!1,i=0,a=[0,0,0,0,0,0,0];for(let o=0;o<this.size;o++)this.modules[o][n]==r?(i++,i==5?e+=t.PENALTY_N1:i>5&&e++):(this.finderPenaltyAddHistory(i,a),r||(e+=this.finderPenaltyCountPatterns(a)*t.PENALTY_N3),r=this.modules[o][n],i=1);e+=this.finderPenaltyTerminateAndCount(r,i,a)*t.PENALTY_N3}for(let n=0;n<this.size-1;n++)for(let r=0;r<this.size-1;r++){let i=this.modules[n][r];i==this.modules[n][r+1]&&i==this.modules[n+1][r]&&i==this.modules[n+1][r+1]&&(e+=t.PENALTY_N2)}let n=0;for(let e of this.modules)n=e.reduce((e,t)=>e+ +!!t,n);let r=this.size*this.size,a=Math.ceil(Math.abs(n*20-r*10)/r)-1;return i(0<=a&&a<=9),e+=a*t.PENALTY_N4,i(0<=e&&e<=2568888),e}getAlignmentPatternPositions(){if(this.version==1)return[];{let e=Math.floor(this.version/7)+2,t=this.version==32?26:Math.ceil((this.version*4+4)/(e*2-2))*2,n=[6];for(let r=this.size-7;n.length<e;r-=t)n.splice(1,0,r);return n}}static getNumRawDataModules(e){if(e<t.MIN_VERSION||e>t.MAX_VERSION)throw RangeError(`Version number out of range`);let n=(16*e+128)*e+64;if(e>=2){let t=Math.floor(e/7)+2;n-=(25*t-10)*t-55,e>=7&&(n-=36)}return i(208<=n&&n<=29648),n}static getNumDataCodewords(e,n){return Math.floor(t.getNumRawDataModules(e)/8)-t.ECC_CODEWORDS_PER_BLOCK[n.ordinal][e]*t.NUM_ERROR_CORRECTION_BLOCKS[n.ordinal][e]}static reedSolomonComputeDivisor(e){if(e<1||e>255)throw RangeError(`Degree out of range`);let n=[];for(let t=0;t<e-1;t++)n.push(0);n.push(1);let r=1;for(let i=0;i<e;i++){for(let e=0;e<n.length;e++)n[e]=t.reedSolomonMultiply(n[e],r),e+1<n.length&&(n[e]^=n[e+1]);r=t.reedSolomonMultiply(r,2)}return n}static reedSolomonComputeRemainder(e,n){let r=n.map(e=>0);for(let i of e){let e=i^r.shift();r.push(0),n.forEach((n,i)=>r[i]^=t.reedSolomonMultiply(n,e))}return r}static reedSolomonMultiply(e,t){if(e>>>8||t>>>8)throw RangeError(`Byte out of range`);let n=0;for(let r=7;r>=0;r--)n=n<<1^(n>>>7)*285,n^=(t>>>r&1)*e;return i(n>>>8==0),n}finderPenaltyCountPatterns(e){let t=e[1];i(t<=this.size*3);let n=t>0&&e[2]==t&&e[3]==t*3&&e[4]==t&&e[5]==t;return(n&&e[0]>=t*4&&e[6]>=t?1:0)+(n&&e[6]>=t*4&&e[0]>=t?1:0)}finderPenaltyTerminateAndCount(e,t,n){return e&&(this.finderPenaltyAddHistory(t,n),t=0),t+=this.size,this.finderPenaltyAddHistory(t,n),this.finderPenaltyCountPatterns(n)}finderPenaltyAddHistory(e,t){t[0]==0&&(e+=this.size),t.pop(),t.unshift(e)}};t.MIN_VERSION=1,t.MAX_VERSION=40,t.PENALTY_N1=3,t.PENALTY_N2=3,t.PENALTY_N3=40,t.PENALTY_N4=10,t.ECC_CODEWORDS_PER_BLOCK=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],t.NUM_ERROR_CORRECTION_BLOCKS=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],e.QrCode=t;function n(e,t,n){if(t<0||t>31||e>>>t)throw RangeError(`Value out of range`);for(let r=t-1;r>=0;r--)n.push(e>>>r&1)}function r(e,t){return(e>>>t&1)!=0}function i(e){if(!e)throw Error(`Assertion error`)}let a=class e{constructor(e,t,n){if(this.mode=e,this.numChars=t,this.bitData=n,t<0)throw RangeError(`Invalid argument`);this.bitData=n.slice()}static makeBytes(t){let r=[];for(let e of t)n(e,8,r);return new e(e.Mode.BYTE,t.length,r)}static makeNumeric(t){if(!e.isNumeric(t))throw RangeError(`String contains non-numeric characters`);let r=[];for(let e=0;e<t.length;){let i=Math.min(t.length-e,3);n(parseInt(t.substring(e,e+i),10),i*3+1,r),e+=i}return new e(e.Mode.NUMERIC,t.length,r)}static makeAlphanumeric(t){if(!e.isAlphanumeric(t))throw RangeError(`String contains unencodable characters in alphanumeric mode`);let r=[],i;for(i=0;i+2<=t.length;i+=2){let a=e.ALPHANUMERIC_CHARSET.indexOf(t.charAt(i))*45;a+=e.ALPHANUMERIC_CHARSET.indexOf(t.charAt(i+1)),n(a,11,r)}return i<t.length&&n(e.ALPHANUMERIC_CHARSET.indexOf(t.charAt(i)),6,r),new e(e.Mode.ALPHANUMERIC,t.length,r)}static makeSegments(t){return t==``?[]:e.isNumeric(t)?[e.makeNumeric(t)]:e.isAlphanumeric(t)?[e.makeAlphanumeric(t)]:[e.makeBytes(e.toUtf8ByteArray(t))]}static makeEci(t){let r=[];if(t<0)throw RangeError(`ECI assignment value out of range`);if(t<128)n(t,8,r);else if(t<16384)n(2,2,r),n(t,14,r);else if(t<1e6)n(6,3,r),n(t,21,r);else throw RangeError(`ECI assignment value out of range`);return new e(e.Mode.ECI,0,r)}static isNumeric(t){return e.NUMERIC_REGEX.test(t)}static isAlphanumeric(t){return e.ALPHANUMERIC_REGEX.test(t)}getData(){return this.bitData.slice()}static getTotalBits(e,t){let n=0;for(let r of e){let e=r.mode.numCharCountBits(t);if(r.numChars>=1<<e)return 1/0;n+=4+e+r.bitData.length}return n}static toUtf8ByteArray(e){e=encodeURI(e);let t=[];for(let n=0;n<e.length;n++)e.charAt(n)==`%`?(t.push(parseInt(e.substring(n+1,n+3),16)),n+=2):t.push(e.charCodeAt(n));return t}};a.NUMERIC_REGEX=/^[0-9]*$/,a.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,a.ALPHANUMERIC_CHARSET=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:`;let o=a;e.QrSegment=a})(z||={}),(e=>{(e=>{let t=class{constructor(e,t){this.ordinal=e,this.formatBits=t}};t.LOW=new t(0,1),t.MEDIUM=new t(1,0),t.QUARTILE=new t(2,3),t.HIGH=new t(3,2),e.Ecc=t})(e.QrCode||={})})(z||={}),(e=>{(e=>{let t=class{constructor(e,t){this.modeBits=e,this.numBitsCharCount=t}numCharCountBits(e){return this.numBitsCharCount[Math.floor((e+7)/17)]}};t.NUMERIC=new t(1,[10,12,14]),t.ALPHANUMERIC=new t(2,[9,11,13]),t.BYTE=new t(4,[8,16,16]),t.KANJI=new t(8,[8,10,12]),t.ECI=new t(7,[0,0,0]),e.Mode=t})(e.QrSegment||={})})(z||={});var B=z,ge={L:B.QrCode.Ecc.LOW,M:B.QrCode.Ecc.MEDIUM,Q:B.QrCode.Ecc.QUARTILE,H:B.QrCode.Ecc.HIGH},_e=128,V=`L`,H=`#FFFFFF`,U=`#000000`,W=!1,G=1,ve=4,ye=0,be=.1;function xe(e,t=0){let n=[];return e.forEach(function(e,r){let i=null;e.forEach(function(a,o){if(!a&&i!==null){n.push(`M${i+t} ${r+t}h${o-i}v1H${i+t}z`),i=null;return}if(o===e.length-1){if(!a)return;i===null?n.push(`M${o+t},${r+t} h1v1H${o+t}z`):n.push(`M${i+t},${r+t} h${o+1-i}v1H${i+t}z`);return}a&&i===null&&(i=o)})}),n.join(``)}function K(e,t){return e.slice().map((e,n)=>n<t.y||n>=t.y+t.h?e:e.map((e,n)=>n<t.x||n>=t.x+t.w?e:!1))}function Se(e,t,n,r){if(r==null)return null;let i=e.length+n*2,a=Math.floor(t*be),o=i/t,s=(r.width||a)*o,c=(r.height||a)*o,l=r.x==null?e.length/2-s/2:r.x*o,u=r.y==null?e.length/2-c/2:r.y*o,d=r.opacity==null?1:r.opacity,f=null;if(r.excavate){let e=Math.floor(l),t=Math.floor(u);f={x:e,y:t,w:Math.ceil(s+l-e),h:Math.ceil(c+u-t)}}let p=r.crossOrigin;return{x:l,y:u,h:c,w:s,excavation:f,opacity:d,crossOrigin:p}}function Ce(e,t){return t==null?e?ve:ye:Math.max(Math.floor(t),0)}function q({value:e,level:t,minVersion:n,includeMargin:r,marginSize:i,imageSettings:a,size:o,boostLevel:s}){let c=k.useMemo(()=>{let r=(Array.isArray(e)?e:[e]).reduce((e,t)=>(e.push(...B.QrSegment.makeSegments(t)),e),[]);return B.QrCode.encodeSegments(r,ge[t],n,void 0,void 0,s)},[e,t,n,s]),{cells:l,margin:u,numCells:d,calculatedImageSettings:f}=k.useMemo(()=>{let e=c.getModules(),t=Ce(r,i);return{cells:e,margin:t,numCells:e.length+t*2,calculatedImageSettings:Se(e,o,t,a)}},[c,o,a,r,i]);return{qrcode:c,margin:u,cells:l,numCells:d,calculatedImageSettings:f}}var we=function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0}(),Te=k.forwardRef(function(e,t){let n=e,{value:r,size:i=_e,level:a=V,bgColor:o=H,fgColor:s=U,includeMargin:c=W,minVersion:l=G,boostLevel:u,marginSize:d,imageSettings:f}=n,p=R(n,[`value`,`size`,`level`,`bgColor`,`fgColor`,`includeMargin`,`minVersion`,`boostLevel`,`marginSize`,`imageSettings`]),{style:m}=p,h=R(p,[`style`]),g=f?.src,_=k.useRef(null),v=k.useRef(null),y=k.useCallback(e=>{_.current=e,typeof t==`function`?t(e):t&&(t.current=e)},[t]),[b,x]=k.useState(!1),{margin:S,cells:C,numCells:w,calculatedImageSettings:T}=q({value:r,level:a,minVersion:l,boostLevel:u,includeMargin:c,marginSize:d,imageSettings:f,size:i});k.useEffect(()=>{if(_.current!=null){let e=_.current,t=e.getContext(`2d`);if(!t)return;let n=C,r=v.current,a=T!=null&&r!==null&&r.complete&&r.naturalHeight!==0&&r.naturalWidth!==0;a&&T.excavation!=null&&(n=K(C,T.excavation));let c=window.devicePixelRatio||1;e.height=e.width=i*c;let l=i/w*c;t.scale(l,l),t.fillStyle=o,t.fillRect(0,0,w,w),t.fillStyle=s,we?t.fill(new Path2D(xe(n,S))):C.forEach(function(e,n){e.forEach(function(e,r){e&&t.fillRect(r+S,n+S,1,1)})}),T&&(t.globalAlpha=T.opacity),a&&t.drawImage(r,T.x+S,T.y+S,T.w,T.h)}}),k.useEffect(()=>{x(!1)},[g]);let ee=L({height:i,width:i},m),te=null;return g!=null&&(te=k.createElement(`img`,{src:g,key:g,style:{display:`none`},onLoad:()=>{x(!0)},ref:v,crossOrigin:T?.crossOrigin})),k.createElement(k.Fragment,null,k.createElement(`canvas`,L({style:ee,height:i,width:i,ref:y,role:`img`},h)),te)});Te.displayName=`QRCodeCanvas`;var J=k.forwardRef(function(e,t){let n=e,{value:r,size:i=_e,level:a=V,bgColor:o=H,fgColor:s=U,includeMargin:c=W,minVersion:l=G,boostLevel:u,title:d,marginSize:f,imageSettings:p}=n,m=R(n,[`value`,`size`,`level`,`bgColor`,`fgColor`,`includeMargin`,`minVersion`,`boostLevel`,`title`,`marginSize`,`imageSettings`]),{margin:h,cells:g,numCells:_,calculatedImageSettings:v}=q({value:r,level:a,minVersion:l,boostLevel:u,includeMargin:c,marginSize:f,imageSettings:p,size:i}),y=g,b=null;p!=null&&v!=null&&(v.excavation!=null&&(y=K(g,v.excavation)),b=k.createElement(`image`,{href:p.src,height:v.h,width:v.w,x:v.x+h,y:v.y+h,preserveAspectRatio:`none`,opacity:v.opacity,crossOrigin:v.crossOrigin}));let x=xe(y,h);return k.createElement(`svg`,L({height:i,width:i,viewBox:`0 0 ${_} ${_}`,ref:t,role:`img`},m),!!d&&k.createElement(`title`,null,d),k.createElement(`path`,{fill:o,d:`M0,0 h${_}v${_}H0z`,shapeRendering:`crispEdges`}),k.createElement(`path`,{fill:s,d:x,shapeRendering:`crispEdges`}),b)});J.displayName=`QRCodeSVG`;function Ee({walletResult:e,mnemonicPhrase:t,deriveBatch:n,deriveList:r,deriveShowIndex:i,deriveShowAddress:a,deriveShowPrivateKey:o,showAddressQr:s,showMnemonicReveal:c,showMnemonicQr:l,onToggleAddressQr:u,onToggleMnemonicReveal:d,onToggleMnemonicQr:f,onToggleDeriveIndex:m,onToggleDeriveAddress:h,onToggleDerivePrivateKey:_,onDerive:v}){let{t:y}=p(),b=e?.address||``;return!e||!b?(0,A.jsx)(j,{icon:(0,A.jsx)(ne,{size:36}),message:y(`web3.empty.walletTools`)}):(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(`div`,{className:`web3-tools-section`,children:[(0,A.jsxs)(`button`,{className:`web3-tools-toggle`,onClick:u,children:[(0,A.jsx)(oe,{size:14}),y(s?`web3.action.hideAddressQr`:`web3.action.showAddressQr`),s?(0,A.jsx)(O,{size:14}):(0,A.jsx)(g,{size:14})]}),s&&(0,A.jsxs)(`div`,{className:`web3-mnemonic-reveal`,children:[(0,A.jsxs)(`div`,{className:`web3-mnemonic-card`,children:[(0,A.jsx)(`p`,{className:`web3-mnemonic-text`,translate:`no`,children:b}),(0,A.jsx)(C,{text:b})]}),(0,A.jsx)(`div`,{className:`qr-wrap`,children:(0,A.jsx)(J,{value:b,size:200})})]})]}),t&&(0,A.jsxs)(`div`,{className:`web3-tools-section`,children:[(0,A.jsxs)(`button`,{className:`web3-tools-toggle`,onClick:d,children:[(0,A.jsx)(T,{size:14}),y(c?`web3.action.hideMnemonic`:`web3.action.showMnemonic`),c?(0,A.jsx)(O,{size:14}):(0,A.jsx)(g,{size:14})]}),c&&(0,A.jsxs)(`div`,{className:`web3-mnemonic-reveal`,children:[(0,A.jsxs)(`div`,{className:`web3-mnemonic-card`,children:[(0,A.jsx)(`p`,{className:`web3-mnemonic-text`,translate:`no`,children:t}),(0,A.jsx)(C,{text:t})]}),(0,A.jsxs)(`p`,{className:`web3-tools-danger`,children:[(0,A.jsx)(se,{size:14}),y(`web3.warning.mnemonic`)]}),(0,A.jsx)(`button`,{className:`web3-tools-toggle`,onClick:f,children:y(l?`web3.action.hideMnemonicQr`:`web3.action.showMnemonicQr`)}),l&&(0,A.jsx)(`div`,{className:`qr-wrap`,children:(0,A.jsx)(J,{value:t,size:260})})]})]}),t&&(0,A.jsxs)(`div`,{className:`web3-mnemonic-reveal`,children:[(0,A.jsx)(`div`,{children:(0,A.jsx)(`button`,{className:`btn btn-primary`,onClick:v,children:y(`web3.action.deriveAddresses`,{count:n})})}),(0,A.jsxs)(`p`,{className:`web3-tools-danger`,children:[(0,A.jsx)(se,{size:14}),y(`web3.warning.privateKey`)]}),r.length>0&&(0,A.jsx)(`div`,{className:`web3-derive-table-wrap`,children:(0,A.jsxs)(`table`,{className:`web3-derive-table`,children:[(0,A.jsx)(`thead`,{children:(0,A.jsxs)(`tr`,{children:[(0,A.jsx)(`th`,{onClick:m,className:`web3-derive-th`,children:y(`web3.label.account`)}),(0,A.jsx)(`th`,{onClick:h,className:`web3-derive-th`,children:y(`web3.label.address`)}),(0,A.jsx)(`th`,{onClick:_,className:`web3-derive-th danger`,children:y(`web3.label.privateKeyToggle`,{action:y(o?`web3.action.hide`:`web3.action.show`)})})]})}),(0,A.jsx)(`tbody`,{children:r.map(e=>(0,A.jsxs)(`tr`,{children:[(0,A.jsx)(`td`,{children:i?e.index+1:``}),(0,A.jsx)(`td`,{translate:`no`,children:a?e.address:``}),(0,A.jsx)(`td`,{className:`danger`,children:(0,A.jsx)(`span`,{translate:`no`,children:o?e.privateKey:``})})]},e.index))})]})})]})]})}function Y({title:e,icon:t,children:n,accent:r=!1}){return(0,A.jsxs)(`div`,{className:`web3-key-card ${r?`accent`:``}`,children:[(0,A.jsxs)(`div`,{className:`web3-key-card-header`,children:[(0,A.jsx)(`span`,{className:`web3-key-card-icon`,children:t}),(0,A.jsx)(`span`,{className:`web3-key-card-title`,children:e})]}),(0,A.jsx)(`div`,{className:`web3-key-card-body`,translate:`no`,children:n})]})}function De(e){return e?`•`.repeat(Math.min(e.length,32)):`-`}function Oe({walletResult:e,keys:t,ipns:n,avatarSrc:r,showPrivateKey:i,onTogglePrivateKey:a}){let{t:o}=p(),s=e?.address||``;return!e||!s?(0,A.jsx)(j,{icon:(0,A.jsx)(x,{size:36}),message:o(`web3.empty.identity`)}):(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(`div`,{className:`web3-identity-card`,children:[(0,A.jsx)(`img`,{src:r,alt:`avatar`,className:`web3-identity-avatar`}),(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`h1`,{className:`web3-identity-name`,children:e.username||o(`web3.notSignedIn`)}),(0,A.jsxs)(`div`,{className:`web3-identity-address`,children:[(0,A.jsx)(`code`,{translate:`no`,children:s.toLowerCase()}),(0,A.jsx)(C,{text:s.toLowerCase()}),(0,A.jsxs)(`a`,{href:`https://debank.com/profile/${s}`,target:`_blank`,rel:`noopener noreferrer`,className:`link`,children:[(0,A.jsx)(y,{size:14}),o(`web3.action.view`)]})]})]})]}),t&&(0,A.jsxs)(`div`,{className:`web3-key-grid`,children:[(0,A.jsx)(Y,{title:o(`web3.label.ed25519Public`),icon:(0,A.jsx)(b,{size:18}),children:(0,A.jsxs)(`div`,{className:`mono-row`,children:[(0,A.jsx)(`code`,{className:`mono`,translate:`no`,children:t.ed_public_key}),(0,A.jsx)(C,{text:t.ed_public_key})]})}),(0,A.jsx)(Y,{title:o(`web3.label.x25519Public`),icon:(0,A.jsx)(T,{size:18}),children:(0,A.jsxs)(`div`,{className:`mono-row`,children:[(0,A.jsx)(`code`,{className:`mono`,translate:`no`,children:t.public_key}),(0,A.jsx)(C,{text:t.public_key})]})}),(0,A.jsx)(Y,{title:o(`web3.label.combinedPrivate`),icon:(0,A.jsx)(ce,{size:18}),accent:!0,children:(0,A.jsxs)(`div`,{className:`mono-row danger`,children:[(0,A.jsx)(`code`,{className:`mono`,translate:`no`,children:i?t.private_key:De(t.private_key)}),(0,A.jsx)(`button`,{className:`btn btn-icon`,onClick:a,title:o(i?`web3.action.hidePrivateKey`:`web3.action.showPrivateKey`),type:`button`,children:i?(0,A.jsx)(E,{size:14}):(0,A.jsx)(D,{size:14})})]})}),(0,A.jsx)(Y,{title:`IPNS ID`,icon:(0,A.jsx)(ae,{size:18}),children:(0,A.jsxs)(`div`,{className:`mono-row`,children:[(0,A.jsx)(`code`,{className:`mono`,translate:`no`,children:n}),(0,A.jsx)(C,{text:n})]})})]})]})}function ke({username:e,password:t,showPassword:n,generating:r,onUsernameChange:i,onPasswordChange:a,onTogglePassword:o,onGenerate:s}){let{t:c}=p();return(0,A.jsxs)(`div`,{className:`input-panel`,children:[(0,A.jsxs)(`div`,{className:`web3-tools-inputs`,children:[(0,A.jsx)(`input`,{type:`text`,placeholder:c(`login.username.placeholder`),value:e,onChange:e=>i(e.target.value),className:`input`,autoCapitalize:`off`,autoCorrect:`off`,spellCheck:`false`}),(0,A.jsxs)(`div`,{className:`input-wrap`,children:[(0,A.jsx)(`input`,{type:n?`text`:`password`,placeholder:c(`web3.login.passwordOptional`),value:t,onChange:e=>a(e.target.value),className:`input`,autoCapitalize:`off`,autoCorrect:`off`,spellCheck:`false`}),(0,A.jsx)(`button`,{className:`input-eye`,onClick:o,type:`button`,children:n?(0,A.jsx)(D,{size:16}):(0,A.jsx)(E,{size:16})})]})]}),(0,A.jsx)(`button`,{className:`btn btn-primary btn-full`,onClick:s,disabled:!e.trim()||r,type:`button`,children:r?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(`span`,{className:`spinner`}),c(`web3.login.generating`)]}):(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(ne,{size:16}),c(`web3.login.generateAndSignIn`)]})})]})}var X=e=>btoa(String.fromCharCode(...e)),Ae=e=>{let t=new Uint8Array([48,5,6,3,43,101,112]),n=new Uint8Array([4,34,4,32,...e.slice(0,32)]),r=new Uint8Array([2,1,0]),i=r.length+t.length+n.length,a=new Uint8Array(2+i);a[0]=48,a[1]=i;let o=2;return a.set(r,o),o+=r.length,a.set(t,o),o+=t.length,a.set(n,o),`-----BEGIN PRIVATE KEY-----\n${X(a).match(/.{1,64}/g)?.join(`
|
|
2
|
+
`)}\n-----END PRIVATE KEY-----`},je=e=>{let t=new Uint8Array([48,5,6,3,43,101,112]),n=new Uint8Array([3,33,0,...e]),r=t.length+n.length,i=new Uint8Array(2+r);i[0]=48,i[1]=r;let a=2;return i.set(t,a),a+=t.length,i.set(n,a),`-----BEGIN PUBLIC KEY-----\n${X(i).match(/.{1,64}/g)?.join(`
|
|
3
|
+
`)}\n-----END PUBLIC KEY-----`},Me=[`wallet`,`pem`,`export`,`EA`];function Ne(){let e=window.location.hash.replace(`#`,``);return Me.includes(e)?e:`wallet`}function Pe(){let{t:e}=p(),t=re(e=>e.isDarkMode),n=re(e=>e.setIsDarkMode),r=re(e=>e.addToast),i=u(e=>e.setUserIdentity),[a,g]=(0,k.useState)(`wallet`),[v,y]=(0,k.useState)(``),[b,C]=(0,k.useState)(``),[E,D]=(0,k.useState)(!1),[O,ae]=(0,k.useState)(null),[oe,se]=(0,k.useState)(null),[ce,le]=(0,k.useState)(``),[ue,de]=(0,k.useState)(``),[fe,j]=(0,k.useState)(``),[M,he]=(0,k.useState)(``),[N,P]=(0,k.useState)([]),[F,I]=(0,k.useState)(0),[L,R]=(0,k.useState)(!0),[z,B]=(0,k.useState)(!0),[ge,_e]=(0,k.useState)(!1),[V,H]=(0,k.useState)(!1),[U,W]=(0,k.useState)(!1),[G,ve]=(0,k.useState)(!1),[ye,be]=(0,k.useState)(!1),[xe,K]=(0,k.useState)(!1),[Se,Ce]=(0,k.useState)(``),[q,we]=(0,k.useState)(``),[Te,J]=(0,k.useState)(!1),[Y,De]=(0,k.useState)(!1),[X,Me]=(0,k.useState)(null),[Pe,Fe]=(0,k.useState)(``),[Ie,Le]=(0,k.useState)(``),[Re,ze]=(0,k.useState)(!1),[Be,Ve]=(0,k.useState)(!1),[Z,He]=(0,k.useState)(null),[Ue,We]=(0,k.useState)(`Hello B. This is from A.`),[Ge,Ke]=(0,k.useState)(``),[qe,Je]=(0,k.useState)(``),[Ye,Xe]=(0,k.useState)(``),[Ze,Qe]=(0,k.useState)(`Hello A. This is from B.`),[$e,et]=(0,k.useState)(``),[tt,nt]=(0,k.useState)(``),[rt,it]=(0,k.useState)(``),[at,ot]=(0,k.useState)(``),[st,ct]=(0,k.useState)(``),[lt,ut]=(0,k.useState)(``),[dt,ft]=(0,k.useState)(``),[pt,Q]=(0,k.useState)(``),[mt,ht]=(0,k.useState)(!1),[gt,_t]=(0,k.useState)(``),[vt,yt]=(0,k.useState)(``),[bt,xt]=(0,k.useState)(``),[St,Ct]=(0,k.useState)(``),[wt,$]=(0,k.useState)(``),[Tt,Et]=(0,k.useState)(!1);(0,k.useEffect)(()=>{g(Ne());let e=()=>g(Ne());return window.addEventListener(`hashchange`,e),()=>window.removeEventListener(`hashchange`,e)},[]);let Dt=e=>{g(e),window.location.hash=e},Ot=(0,k.useCallback)(async()=>{if(!v.trim())return;K(!0),await new Promise(e=>setTimeout(e,0));let t=s(v.trim(),b),n=`${t.username}#${t.address.slice(-4).toUpperCase()}`;ae(t),i({...t,displayName:n}),r(e(`login.toast.signedIn`,{username:t.username}),`success`),he(l(t.danger));let a=c(t.danger);se(a),le(S(a.private_key,a.ed_public_key));let o=w(a.private_key,a.ed_public_key);de(Ae(o.secretKey)),j(je(o.publicKey)),P([]),I(0),H(!1),W(!1),ve(!1),be(!1),K(!1)},[r,b,i,e,v]);function kt(t,n,i){let a=t.trim();if(!a)return;let o=s(a,n),l=c(o.danger);i({username:o.username,address:o.address,publicKey:l.public_key,privateKey:l.private_key}),Je(``),Xe(``),nt(``),it(``),r(e(`web3.toast.accountGenerated`),`success`)}function At({senderAccount:t,recipientAccount:n,message:r,setCipherText:i,setDecryptedText:a,setError:s}){if(!t||!n){s(e(`web3.error.accountsRequired`));return}if(!r.trim()){s(e(`web3.error.messageRequired`));return}i(o(r,{senderPrivateKey:t.privateKey,recipientPublicKey:n.publicKey})),a(``),s(``)}function jt({senderAccount:t,recipientAccount:n,cipherText:r,setDecryptedText:i,setError:a}){if(!t||!n){a(e(`web3.error.accountsRequired`));return}if(!r.trim()){a(e(`web3.error.cipherRequired`));return}let o=d(r,{senderPublicKey:t.publicKey,recipientPrivateKey:n.privateKey});if(!o){a(e(`web3.error.decryptFailed`)),i(``);return}i(o),a(``)}function Mt(){if(!at.trim()){Q(e(`web3.error.senderPublicRequired`));return}if(!st.trim()){Q(e(`web3.error.recipientPrivateRequired`));return}if(!lt.trim()){Q(e(`web3.error.cipherRequired`));return}let t=d(lt,{senderPublicKey:at.trim(),recipientPrivateKey:st.trim()});if(!t){Q(e(`web3.error.decryptFailed`)),ft(``);return}ft(t),Q(``)}function Nt(){if(!gt.trim()){$(e(`web3.error.senderPrivateRequired`));return}if(!vt.trim()){$(e(`web3.error.recipientPublicRequired`));return}if(!bt.trim()){$(e(`web3.error.messageRequired`));return}Ct(o(bt,{senderPrivateKey:gt.trim(),recipientPublicKey:vt.trim()})),$(``)}let Pt=()=>{if(!M)return;let e=[];for(let t=F;t<F+10;t++){let n=`m/44'/60'/0'/0/${t}`,r=f.fromPhrase(M,void 0,n);e.push({index:t,address:r.address,privateKey:r.privateKey})}P(t=>[...t,...e]),I(e=>e+10)},Ft=ie(O?.address||void 0),It=a===`wallet`?`web3.view.wallet`:a===`pem`?`web3.view.pem`:a===`EA`?`web3.view.asymmetric`:`web3.view.export`,Lt=[{id:`wallet`,icon:(0,A.jsx)(x,{size:16}),labelKey:`web3.view.wallet`},{id:`pem`,icon:(0,A.jsx)(_,{size:16}),labelKey:`web3.view.pem`},{id:`export`,icon:(0,A.jsx)(ne,{size:16}),labelKey:`web3.view.export`},{id:`EA`,icon:(0,A.jsx)(T,{size:16}),labelKey:`web3.view.asymmetric`}],Rt=a!==`EA`;return(0,A.jsx)(ee,{sidebar:({closeSidebar:t})=>(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(te,{onNavigate:t}),(0,A.jsx)(`nav`,{className:`sidebar-nav`,children:Lt.map(n=>(0,A.jsxs)(`button`,{onClick:()=>{Dt(n.id),t()},className:`sidebar-nav-btn ${a===n.id?`active`:``}`,children:[n.icon,(0,A.jsx)(`span`,{children:e(n.labelKey)})]},n.id))})]}),headerTitle:(0,A.jsx)(`h2`,{className:`header-title`,children:e(It)}),headerRight:(0,A.jsx)(`button`,{className:`btn btn-icon`,onClick:()=>n(!t),title:e(`common.theme.toggle`),children:t?(0,A.jsx)(m,{size:16}):(0,A.jsx)(h,{size:16})}),children:(0,A.jsx)(`div`,{className:`web3-page`,children:(0,A.jsxs)(`div`,{className:`web3-container ${a===`EA`?`wide`:``}`,children:[Rt&&(0,A.jsx)(ke,{username:v,password:b,showPassword:E,generating:xe,onUsernameChange:y,onPasswordChange:C,onTogglePassword:()=>D(!E),onGenerate:Ot}),a===`wallet`&&(0,A.jsx)(Oe,{walletResult:O,keys:oe,ipns:ce,avatarSrc:Ft,showPrivateKey:ye,onTogglePrivateKey:()=>be(!ye)}),a===`pem`&&(0,A.jsx)(me,{walletResult:O,publicPem:fe,privatePem:ue}),a===`export`&&(0,A.jsx)(Ee,{walletResult:O,mnemonicPhrase:M,deriveBatch:10,deriveList:N,deriveShowIndex:L,deriveShowAddress:z,deriveShowPrivateKey:ge,showAddressQr:V,showMnemonicReveal:U,showMnemonicQr:G,onToggleAddressQr:()=>H(!V),onToggleMnemonicReveal:()=>W(!U),onToggleMnemonicQr:()=>ve(!G),onToggleDeriveIndex:()=>R(!L),onToggleDeriveAddress:()=>B(!z),onToggleDerivePrivateKey:()=>_e(!ge),onDerive:Pt}),a===`EA`&&(0,A.jsx)(pe,{boxAUsername:Se,boxAPassword:q,boxAShowPassword:Te,boxAShowPrivateKey:Y,boxAAccount:X,boxBUsername:Pe,boxBPassword:Ie,boxBShowPassword:Re,boxBShowPrivateKey:Be,boxBAccount:Z,boxABMessage:Ue,boxABCipherText:Ge,boxABDecryptedText:qe,boxABError:Ye,boxBAMessage:Ze,boxBACipherText:$e,boxBADecryptedText:tt,boxBAError:rt,boxEncryptSenderPrivateKey:gt,boxEncryptRecipientPublicKey:vt,boxEncryptMessage:bt,boxEncryptCipherText:St,boxEncryptError:wt,boxEncryptShowPrivateKey:Tt,boxDecryptSenderPublicKey:at,boxDecryptRecipientPrivateKey:st,boxDecryptCipherText:lt,boxDecryptResult:dt,boxDecryptError:pt,boxDecryptShowPrivateKey:mt,onBoxAUsernameChange:Ce,onBoxAPasswordChange:we,onBoxAShowPasswordToggle:()=>J(!Te),onBoxAShowPrivateKeyToggle:()=>De(!Y),onGenerateBoxA:()=>kt(Se,q,Me),onBoxBUsernameChange:Fe,onBoxBPasswordChange:Le,onBoxBShowPasswordToggle:()=>ze(!Re),onBoxBShowPrivateKeyToggle:()=>Ve(!Be),onGenerateBoxB:()=>kt(Pe,Ie,He),onBoxABMessageChange:We,onBoxABCipherTextChange:Ke,onEncryptBoxAB:()=>At({senderAccount:X,recipientAccount:Z,message:Ue,setCipherText:Ke,setDecryptedText:Je,setError:Xe}),onDecryptBoxAB:()=>jt({senderAccount:X,recipientAccount:Z,cipherText:Ge,setDecryptedText:Je,setError:Xe}),onBoxBAMessageChange:Qe,onBoxBACipherTextChange:et,onEncryptBoxBA:()=>At({senderAccount:Z,recipientAccount:X,message:Ze,setCipherText:et,setDecryptedText:nt,setError:it}),onDecryptBoxBA:()=>jt({senderAccount:Z,recipientAccount:X,cipherText:$e,setDecryptedText:nt,setError:it}),onBoxEncryptSenderPrivateKeyChange:_t,onBoxEncryptRecipientPublicKeyChange:yt,onBoxEncryptMessageChange:xt,onBoxEncryptShowPrivateKeyToggle:()=>Et(!Tt),onEncryptOnly:Nt,onBoxDecryptSenderPublicKeyChange:ot,onBoxDecryptRecipientPrivateKeyChange:ct,onBoxDecryptCipherTextChange:ut,onBoxDecryptShowPrivateKeyToggle:()=>ht(!mt),onDecryptOnly:Mt})]})})})}var Fe=i(`/web3/`)({component:Pe});export{Fe as Route};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e,o as t,t as n}from"./jsx-runtime-Bt-cYkS5.js";import{
|
|
1
|
+
import{n as e,o as t,t as n}from"./jsx-runtime-Bt-cYkS5.js";import{T as r,c as i,s as a}from"./ui-BpDGD3IR.js";import{a as o,i as s,n as c}from"./i18n-NjvOSuV6.js";import{i as l,n as u,r as d}from"./LanguageToggle-CSQtRZ3A.js";import{t as f}from"./circle-alert-iuHzciph.js";import{t as p}from"./key-round-DNcpSuMw.js";import{n as m,t as h}from"./SidebarHomeLink-BdsUM4Kt.js";import{L as g,_,c as v,d as y,u as b,v as x,y as S}from"./index-BZ-f0CZd.js";import{i as C,t as w}from"./userProfile-DBkH4s29.js";var T=t(e(),1),E=[{name:`node_url`,required:!1,descriptionKey:`chatJoin.field.nodeUrl`},{name:`node_invite`,required:!1,descriptionKey:`chatJoin.field.nodeInvite`},{name:`uid`,required:!0,descriptionKey:`chatJoin.field.uid`},{name:`identity`,required:!1,descriptionKey:`chatJoin.field.identity`},{name:`logo`,required:!1,descriptionKey:`chatJoin.field.logo`},{name:`avatar`,required:!1,descriptionKey:`chatJoin.field.avatar`},{name:`name`,required:!1,descriptionKey:`chatJoin.field.name`},{name:`locale`,required:!1,descriptionKey:`chatJoin.field.locale`},{name:`channels[].id`,required:!0,descriptionKey:`chatJoin.field.channelId`},{name:`channels[].name`,required:!1,descriptionKey:`chatJoin.field.channelName`}];function D(e){let t=typeof e==`string`?e.trim():e;return c(t)?t:void 0}function O(e){return String(e||``).trim().replace(/\/+$/,``)}function k(e){return String(e||``).trim()}function A({inviteNodeUrl:e,inviteNodeInvite:t,hasBackend:n,activeBackendUrl:r,activeRemoteUrl:i,activeRemoteInvite:a}){let o=O(e),s=O(i),c=O(r);return!!o&&!!s&&n===!0&&c===s&&s===o&&k(a)===k(t)}function j(e){return!!O(e.inviteNodeUrl)&&!A(e)}var M=`data:image/svg+xml,%3Csvg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64"%3E%3Crect width="64" height="64" rx="16" fill="%232f7dd1"/%3E%3Ccircle cx="32" cy="25" r="11" fill="%23f8fbff"/%3E%3Cpath d="M14 56c3-12 12-18 18-18s15 6 18 18" fill="%23f8fbff"/%3E%3C/svg%3E`,N=`data:image/svg+xml,%3Csvg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64"%3E%3Crect width="64" height="64" rx="16" fill="%230f9f7a"/%3E%3Cpath d="M18 20h28v22H18z" rx="6" fill="%23f7fff9"/%3E%3Ccircle cx="27" cy="31" r="3" fill="%230f9f7a"/%3E%3Ccircle cx="37" cy="31" r="3" fill="%230f9f7a"/%3E%3Cpath d="M29 39h6" stroke="%230f9f7a" stroke-width="4" stroke-linecap="round"/%3E%3Cpath d="M32 12v8" stroke="%23f7fff9" stroke-width="5" stroke-linecap="round"/%3E%3C/svg%3E`,P=Object.freeze({id:`chatjoin_support`,name:`User / Service 测试频道`}),F=Object.freeze([Object.freeze({uid:`user`,identity:`user`,name:`测试用户`,avatar:M}),Object.freeze({uid:`service`,identity:`service`,name:`测试客服`,avatar:N})]),I=Object.freeze(F.map(e=>Object.freeze({locale:`zh-CN`,uid:e.uid,identity:e.identity,avatar:e.avatar,name:e.name,channels:[P]})));function L(e){let t=String(e||``).trim();return I.find(e=>e.uid===t)||null}function R(e){return JSON.stringify(e,null,2)}var z=n(),B=`0x955fe80bdb8312165471fcacd6a8f83df88a770dda6f38657ca4e62ec28d5b54`,V=50,H=`https://api.most.box`;function U(e){try{return JSON.parse(e)}catch{return null}}function W(e){return typeof e==`string`?U(e):e}function G(e,t){return t===null?e:JSON.stringify(t,null,2)}function K(e,t,n){if(t&&typeof t==`object`&&`error`in t){let e=t.error;if(typeof e==`string`)return e}return e||n}function q(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function J(e){return typeof e==`string`?e.trim():``}function Y(e){let t=J(e);return t===`user`||t===`service`||t===`service_ai`?t:void 0}function X(e){let t=W(e);if(!q(t))return null;let n=J(t.uid),r=(Array.isArray(t.channels)?t.channels:[]).filter(q).map(e=>({id:J(e.id),name:J(e.name)||void 0})).filter(e=>e.id);return!n||r.length===0?null:{node_url:J(t.node_url)||void 0,node_invite:J(t.node_invite)||void 0,locale:D(t.locale),uid:n,identity:Y(t.identity),logo:J(t.logo)||void 0,avatar:J(t.avatar)||void 0,name:J(t.name)||void 0,channels:r}}function Z(e){return`/chat?channel=${encodeURIComponent(e)}`}function Q(e){return String(e||``).trim().slice(0,V)}function $(){let{t:e,setLocale:t}=o(),n=g({select:e=>e.searchStr}),{token:r,pub:c,fixture:D}=(0,T.useMemo)(()=>{let e=new URLSearchParams(n);return{token:e.get(`token`)||``,pub:e.get(`pub`)||``,fixture:e.get(`fixture`)||``}},[n]),O=v(e=>e.isDarkMode),k=v(e=>e.setIsDarkMode),A=v(e=>e.hasBackend),M=a(e=>e.setUserIdentity),[N,P]=(0,T.useState)(``),[F,I]=(0,T.useState)(``),[V,W]=(0,T.useState)(!0),[q,J]=(0,T.useState)(``),Y=(0,T.useRef)(``);return(0,T.useEffect)(()=>{let n=L(D);if(D&&!n){I(e(`chatJoin.error.unknownFixture`,{fixture:D})),W(!1);return}if(!n&&!r){I(e(`chatJoin.error.missingToken`)),W(!1);return}if(!n&&!c){I(e(`chatJoin.error.missingPub`)),W(!1);return}if(A===null){J(e(`chatJoin.status.checkingBackend`));return}let a=n?`fixture:${D}`:`${r}:${c}`;if(Y.current===a)return;Y.current=a;async function o(n){let r=(t,r)=>n.locale?s(t,n.locale,r):e(t,r);n.locale&&t(n.locale);let a=S(),o=x(),c=_();if(j({inviteNodeUrl:n.node_url,inviteNodeInvite:n.node_invite,hasBackend:A,activeBackendUrl:c,activeRemoteUrl:a,activeRemoteInvite:o})){if(J(r(`chatJoin.status.connectingRemote`)),!(await b({url:n.node_url,invite:n.node_invite||``})).ok)throw Error(r(`chatJoin.error.remoteConnectFailed`));y({url:n.node_url,invite:n.node_invite||``}),v.setState({hasBackend:!0})}else if(!A)throw Error(r(`chatJoin.error.noBackend`));J(r(`chatJoin.status.signingIn`));let l=i(n.uid,``),u={...l,identity:n.identity,displayName:n.name||l.displayName,logo:n.logo,avatar:n.avatar};M(u),J(r(`chatJoin.status.joiningChannel`));let d=``;for(let e of n.channels){let t=await C.createChannel(e.id,`public`,w(u)),n=t.channelKey||t.key||e.id;d||=n;let r=Q(e.name);r&&await C.setChannelRemark(n,r)}let f=n.channels[0];J(r(`chatJoin.status.openingChannel`)),window.location.href=Z(d||f.id)}async function l(){try{if(n){J(e(`chatJoin.status.loadingFixture`,{name:n.name||D})),P(R(n)),await o(n);return}J(e(`chatJoin.status.decryptingInvite`));let t=await fetch(`${H}/api/chat.join.decrypt`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({token:r,pub:c})}),i=await t.text(),a=U(i);if(!t.ok)I(K(i,a,e(`chatJoin.error.decrypt`)));else{P(G(i,a));let t=X(a);if(!t){I(e(`chatJoin.error.invalidInvite`));return}await o(t)}}catch(t){I(e(`chatJoin.error.request`,{message:t instanceof Error?t.message:String(t)}))}finally{W(!1)}}l()},[D,A,c,t,M,e,r]),(0,z.jsx)(m,{sidebar:()=>(0,z.jsx)(h,{}),headerTitle:(0,z.jsx)(`h2`,{className:`header-title`,children:e(`chatJoin.title`)}),headerRight:(0,z.jsx)(`button`,{className:`btn btn-icon`,onClick:()=>k(!O),title:e(`common.theme.toggle`),children:O?(0,z.jsx)(u,{size:16}):(0,z.jsx)(d,{size:16})}),children:(0,z.jsx)(`div`,{className:`chat-join-container`,children:(0,z.jsxs)(`div`,{className:`chat-join-panel`,children:[V?(0,z.jsxs)(`div`,{className:`chat-join-loading`,children:[(0,z.jsx)(p,{size:32}),(0,z.jsx)(`p`,{children:q||e(`chatJoin.status.decrypting`)})]}):F?(0,z.jsxs)(`div`,{className:`chat-join-error`,children:[(0,z.jsx)(f,{size:32}),(0,z.jsx)(`p`,{children:F}),q&&(0,z.jsx)(`p`,{className:`chat-join-status`,children:q}),N&&(0,z.jsx)(`pre`,{className:`chat-join-result`,translate:`no`,children:N})]}):(0,z.jsxs)(`div`,{className:`chat-join-success`,children:[(0,z.jsx)(l,{size:32}),(0,z.jsx)(`p`,{children:q||e(`chatJoin.status.decryptSuccess`)}),(0,z.jsx)(`pre`,{className:`chat-join-result`,translate:`no`,children:N})]}),(0,z.jsxs)(`section`,{className:`chat-join-spec`,"aria-labelledby":`chat-join-spec-title`,children:[(0,z.jsxs)(`div`,{className:`chat-join-helper-title`,children:[(0,z.jsx)(p,{size:18}),(0,z.jsx)(`h3`,{id:`chat-join-spec-title`,children:e(`chatJoin.specTitle`)})]}),(0,z.jsx)(`div`,{className:`chat-join-field-list`,children:E.map(t=>(0,z.jsxs)(`div`,{className:`chat-join-field`,children:[(0,z.jsxs)(`div`,{className:`chat-join-field-meta`,children:[(0,z.jsx)(`code`,{className:`chat-join-field-name`,children:t.name}),(0,z.jsx)(`span`,{children:t.required?e(`chatJoin.field.required`):e(`chatJoin.field.optional`)})]}),(0,z.jsx)(`p`,{children:e(t.descriptionKey)})]},t.name))})]}),(0,z.jsxs)(`section`,{className:`chat-join-helper`,"aria-labelledby":`ea-test-title`,children:[(0,z.jsxs)(`div`,{className:`chat-join-helper-title`,children:[(0,z.jsx)(p,{size:18}),(0,z.jsx)(`h3`,{id:`ea-test-title`,children:e(`chatJoin.testPublicKey`)})]}),(0,z.jsx)(`code`,{className:`ui-code-box chat-join-public-key`,translate:`no`,children:B}),(0,z.jsx)(`a`,{className:`btn`,href:`/web3/#EA`,target:`_blank`,children:e(`chatJoin.openWeb3`)})]})]})})})}function ee(){return(0,z.jsx)(T.Suspense,{children:(0,z.jsx)($,{})})}var te=r(`/chat/join/`)({component:ee});export{te as Route};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e,o as t,t as n}from"./jsx-runtime-Bt-cYkS5.js";import{C as r,T as i,s as a}from"./ui-BpDGD3IR.js";import{a as o}from"./i18n-NjvOSuV6.js";import{n as s,r as c}from"./LanguageToggle-CSQtRZ3A.js";import{t as ee}from"./copy-DEzFUzeX.js";import{n as te}from"./SidebarHomeLink-BdsUM4Kt.js";import{t as ne}from"./play-B-BjsTZz.js";import{t as re}from"./send-BL4d5iOt.js";import{i as ie,n as ae,r as oe,t as se}from"./useGameRoom-CRJL0kcm.js";import{S as l,c as u,i as d,x as f}from"./index-BZ-f0CZd.js";var ce=r(`rotate-ccw`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}]]),p=t(e(),1),m=[`S`,`H`,`C`,`D`],h=[`3`,`4`,`5`,`6`,`7`,`8`,`9`,`10`,`J`,`Q`,`K`,`A`,`2`],g=h.filter(e=>e!==`2`),_=new Map(h.map((e,t)=>[e,t+3])),v=5,y=20,b=1e3;function le({roomCode:e,ownerAddress:t,ownerName:n,players:r=[],random:i=Math.random}){let a=k(r);return a.some(e=>e.address===f(t))||a.unshift({address:f(t),name:Y(n),avatar:``}),x({id:String(e||``).toUpperCase(),ownerAddress:f(t),status:`lobby`,seq:1,players:a.slice(0,6).map((e,t)=>({address:e.address,name:Y(e.name),avatar:l(e.avatar),seat:t,hand:[],handCount:0,score:b,playedCards:0})),deck:[],discard:[],table:null,currentSeat:0,lastWinnerSeat:null,previousWinnerSeat:null,passSeats:[],baseScore:1,bombCount:0,diceRolls:[],roundResult:null,log:[`房间已创建`],winnerSeat:null,random:i})}function ue(e,t=[]){let n=S(e);if(!n||n.status!==`lobby`)return n;let r=new Map(n.players.map(e=>[e.address,e.score]));return n.players=k(t).slice(0,6).map((e,t)=>({address:e.address,name:Y(e.name),avatar:l(e.avatar),seat:t,hand:[],handCount:0,score:r.get(e.address)??b,playedCards:0})),n.seq+=1,x(n)}function de(e,t=Math.random){let n=S(e);if(!n||n.players.length<2)throw Error(`至少需要 2 名玩家`);n.deck=I(F(),t),n.discard=[],n.table=null,n.passSeats=[],n.winnerSeat=null,n.roundResult=null,n.baseScore=1,n.bombCount=0,n.status=`playing`;for(let e of V(n))e.hand=L(n,v),e.handCount=e.hand.length,e.playedCards=0,R(e.hand);let r=M(n,t);return n.currentSeat=r.seat,n.lastWinnerSeat=null,n.log=[`新一局开始,${r.name} 先出牌`],n.diceRolls.length>0&&n.log.unshift(`骰子结果:${n.diceRolls.map(e=>`${e.name} ${e.value}`).join(`,`)}`),n.seq+=1,x(n)}function fe(e,t,n){let r=S(e),i=z(r),a=f(t);if(!i||i.address!==a)return{ok:!1,error:`还没轮到你`,state:x(r)};let o=n.map(e=>i.hand.find(t=>t.id===e));if(o.length===0||o.some(e=>!e))return{ok:!1,error:`手牌不存在`,state:x(r)};let s=C(o);return s?O(s,r.table?.combo)?(o.sort(W),i.hand=i.hand.filter(e=>!n.includes(e.id)),i.handCount=i.hand.length,i.playedCards+=o.length,r.discard.push(...o),r.table={seat:i.seat,playerName:i.name,cards:o,combo:s},r.passSeats=[],r.lastWinnerSeat=i.seat,s.type===`bomb`&&(r.bombCount+=1,r.baseScore*=2),r.log.unshift(`${i.name} 出 ${s.label} ${o.map(J).join(` `)}${s.type===`bomb`?`,底分 ${r.baseScore}`:``}`),i.hand.length===0?N(r,i):H(r),r.seq+=1,{ok:!0,state:x(r)}):{ok:!1,error:`出的牌压不过上一手`,state:x(r)}:{ok:!1,error:`这个牌型不合法`,state:x(r)}}function pe(e,t){let n=S(e),r=z(n),i=f(t);return!r||r.address!==i?{ok:!1,error:`还没轮到你`,state:x(n)}:n.table?(n.passSeats.includes(r.seat)||n.passSeats.push(r.seat),n.log.unshift(`${r.name} 不要`),B(n).map(e=>e.seat).filter(e=>e!==n.lastWinnerSeat).every(e=>n.passSeats.includes(e))?(P(n),n.currentSeat=n.lastWinnerSeat,n.table=null,n.passSeats=[],n.log.unshift(`本轮结束,所有玩家各补 1 张,重新领出`)):H(n),n.seq+=1,{ok:!0,state:x(n)}):{ok:!1,error:`领出时不能不要`,state:x(n)}}function me(e,t){let n=S(e);if(!n)return null;let r=f(t),i=n.players.findIndex(e=>e.address===r);if(i===-1)return x(n);let a=n.players[i],o=n.currentSeat===a.seat,s=n.lastWinnerSeat===a.seat;n.players.splice(i,1),n.passSeats=n.passSeats.filter(e=>e!==a.seat),n.log.unshift(`${a.name} 已退出房间`);let c=V(n);if(n.status===`playing`)if(c.length<=1)c.length===1?N(n,c[0]):(n.status=`finished`,n.log.unshift(`玩家不足,本局结束`));else{if(o){let e=B(n);if(e.length>0){let t=e.findIndex(e=>e.seat>a.seat);n.currentSeat=e[t>=0?t:0].seat}}s&&n.table&&(n.table=null,n.passSeats=[])}return n.seq+=1,x(n)}function x(e){return e?{id:e.id,ownerAddress:e.ownerAddress,status:e.status,seq:Number(e.seq||1),deck:Array.isArray(e.deck)?e.deck.map(q):[],deckCount:e.deck?.length||Number(e.deckCount||0),discard:Array.isArray(e.discard)?e.discard.map(q):[],discardCount:e.discard?.length||Number(e.discardCount||0),currentSeat:Number(e.currentSeat||0),lastWinnerSeat:e.lastWinnerSeat===null||e.lastWinnerSeat===void 0?null:Number(e.lastWinnerSeat),previousWinnerSeat:e.previousWinnerSeat===null||e.previousWinnerSeat===void 0?null:Number(e.previousWinnerSeat),baseScore:Number(e.baseScore||1),bombCount:Number(e.bombCount||0),diceRolls:Array.isArray(e.diceRolls)?e.diceRolls:[],roundResult:e.roundResult||null,table:e.table?{...e.table,cards:e.table.cards.map(q)}:null,passSeats:Array.isArray(e.passSeats)?e.passSeats:[],winnerSeat:e.winnerSeat===null||e.winnerSeat===void 0?null:Number(e.winnerSeat),log:Array.isArray(e.log)?e.log.slice(0,18):[],players:V(e).map(e=>({address:e.address,name:e.name,avatar:l(e.avatar),seat:e.seat,handCount:e.hand?.length??e.handCount??0,score:Number(e.score??b),playedCards:Number(e.playedCards||0),hand:Array.isArray(e.hand)?e.hand.map(q):[]}))}:null}function S(e){return!e||typeof e!=`object`?null:{id:String(e.id||``).toUpperCase(),ownerAddress:f(e.ownerAddress),status:e.status===`playing`||e.status===`finished`?e.status:`lobby`,seq:Number(e.seq||1),players:Array.isArray(e.players)?e.players.map(A).filter(Boolean):[],deck:Array.isArray(e.deck)?e.deck.map(_e).filter(Boolean):[],discard:Array.isArray(e.discard)?e.discard.map(j).filter(Boolean):[],table:e.table&&typeof e.table==`object`?{...e.table,cards:Array.isArray(e.table.cards)?e.table.cards.map(j).filter(Boolean):[]}:null,currentSeat:Number(e.currentSeat||0),lastWinnerSeat:e.lastWinnerSeat===null||e.lastWinnerSeat===void 0?null:Number(e.lastWinnerSeat),previousWinnerSeat:e.previousWinnerSeat===null||e.previousWinnerSeat===void 0?null:Number(e.previousWinnerSeat),passSeats:Array.isArray(e.passSeats)?e.passSeats.map(Number):[],baseScore:Number(e.baseScore||1),bombCount:Number(e.bombCount||0),diceRolls:Array.isArray(e.diceRolls)?e.diceRolls:[],roundResult:e.roundResult||null,log:Array.isArray(e.log)?e.log.map(String):[],winnerSeat:e.winnerSeat===null||e.winnerSeat===void 0?null:Number(e.winnerSeat)}}function C(e){if(!e?.length)return null;e=[...e].sort(W);let t=e.filter(K).length,n=e.filter(e=>!K(e));if(n.length===0)return null;let r=w(e,n,t);if(r)return r;if(e.length===1&&t===0)return D(`single`,G(e[0]),1,[G(e[0])]);if(e.length===2&&U(n,t)){let e=he(n);return D(`pair`,e,2,[e,e])}return T(e)||E(e)}function w(e,t,n){if(e.length<3||!U(t,n))return null;let r=he(t);return D(`bomb`,r,e.length,Array(e.length).fill(r),n===0)}function T(e){if(e.length<3)return null;let t=e.filter(K).length,n=e.filter(e=>!K(e));for(let r=0;r<=g.length-e.length;r+=1){let i=g.slice(r,r+e.length).map(e=>_.get(e)),a=[...i],o=0;for(let e of n){let t=a.indexOf(G(e));t!==-1&&(a.splice(t,1),o+=1)}if(o+t===e.length&&a.length===t)return D(`straight`,i.at(-1),e.length,i)}return null}function E(e){if(e.length<4||e.length%2!=0)return null;let t=e.length/2,n=e.filter(K).length,r=e.filter(e=>!K(e));for(let i=0;i<=g.length-t;i+=1){let a=g.slice(i,i+t).map(e=>_.get(e)),o=a.flatMap(e=>[e,e]),s=0;for(let e of r){let t=o.indexOf(G(e));t!==-1&&(o.splice(t,1),s+=1)}if(s+n===e.length&&o.length===n){let t=a.flatMap(e=>[e,e]);return D(`pairStraight`,a.at(-1),e.length,t)}}return null}function D(e,t,n,r,i=!0){return{type:e,value:t,length:n,resolvedValues:r,pure:i,label:be({type:e,value:t,length:n,resolvedValues:r,pure:i})}}function O(e,t){return e?!t||e.type===`bomb`&&t.type!==`bomb`?!0:e.type===t.type?e.type===`bomb`?e.length===t.length?e.value===t.value?e.pure&&!t.pure:e.value>t.value:e.length>t.length:e.length===t.length?e.type===`single`||e.type===`pair`?e.value===Se(t.value)||e.value===_.get(`2`)&&t.value!==_.get(`2`):e.value===Se(t.value):!1:!1:!1}function k(e){let t=new Set;return e.map(e=>({address:f(e.address),name:Y(e.name),avatar:l(e.avatar),publicKey:String(e.publicKey||``)})).filter(e=>!e.address||t.has(e.address)?!1:(t.add(e.address),!0))}function A(e){let t=f(e.address);return t?{address:t,name:Y(e.name),avatar:l(e.avatar),seat:Number(e.seat||0),hand:Array.isArray(e.hand)?e.hand.map(j).filter(Boolean):[],handCount:Number(e.handCount||0),score:Number(e.score??b),playedCards:Number(e.playedCards||0)}:null}function j(e){if(!e||typeof e!=`object`)return null;let t=String(e.rank||``),n=String(e.suit||``);return!_.has(t)&&t!==`SJ`&&t!==`BJ`||!m.includes(n)&&n!==`Joker`?null:{id:String(e.id||`${n}-${t}`),suit:n,rank:t,label:e.label||J({suit:n,rank:t}),color:e.color||ye({suit:n,rank:t})}}function M(e,t){if(e.previousWinnerSeat!==null)return e.diceRolls=[],V(e).find(t=>t.seat===e.previousWinnerSeat)||V(e)[0];let n=V(e),r=[];for(;n.length>1;){r=n.map(e=>({seat:e.seat,name:e.name,value:Ce(t)}));let i=Math.max(...r.map(e=>e.value)),a=r.filter(e=>e.value===i);if(a.length===1)return e.diceRolls=r,n.find(e=>e.seat===a[0].seat);n=n.filter(e=>a.some(t=>t.seat===e.seat))}return e.diceRolls=r,n[0]}function N(e,t){e.status=`finished`,e.winnerSeat=t.seat,e.previousWinnerSeat=t.seat;let n=[],r=0;for(let i of V(e)){if(i.seat===t.seat)continue;let a=i.playedCards===0,o=a?y:i.hand.length*e.baseScore*.5;i.score-=o,r+=o,n.push({seat:i.seat,name:i.name,loss:o,sealed:a,cardsLeft:i.hand.length})}t.score+=r,e.roundResult={winnerSeat:t.seat,winnerName:t.name,winnerGain:r,baseScore:e.baseScore,bombCount:e.bombCount,losers:n},e.log.unshift(`${t.name} 获胜,赢 ${r} 分`)}function P(e){for(let t of B(e)){if(e.deck.length===0)break;t.hand.push(...L(e,1)),t.handCount=t.hand.length,R(t.hand)}}function F(){let e=[];for(let t of m)for(let n of h)e.push({id:`${t}-${n}`,suit:t,rank:n});return e.push({id:`SJ`,suit:`Joker`,rank:`SJ`}),e.push({id:`BJ`,suit:`Joker`,rank:`BJ`}),e.map(q)}function I(e,t){let n=[...e];for(let e=n.length-1;e>0;--e){let r=Math.floor(t()*(e+1));[n[e],n[r]]=[n[r],n[e]]}return n}function L(e,t){return e.deck.splice(0,t)}function R(e){e.sort(W)}function z(e){return e.players.find(t=>t.seat===e.currentSeat)}function B(e){return V(e).filter(e=>e.hand.length>0)}function V(e){return[...e?.players||[]].sort((e,t)=>e.seat-t.seat)}function H(e){let t=B(e).map(e=>e.seat);e.currentSeat=t[(t.indexOf(e.currentSeat)+1)%t.length]}function U(e,t=0){if(e.length===0)return!1;let n=e[0].rank;return e.every(e=>e.rank===n)&&e.length+t>=2}function he(e){return G(e[0])}function W(e,t){return G(e)-G(t)||ge(e.suit)-ge(t.suit)}function G(e){return _.get(e.rank)||99}function K(e){return e.rank===`SJ`||e.rank===`BJ`}function ge(e){return{D:0,C:1,H:2,S:3,Joker:4}[e]||0}function _e(e){if(typeof e==`string`){let[t,n]=e.split(`-`);return j({id:e,suit:t,rank:n})}return j(e)}function q(e){return{id:e.id,suit:e.suit,rank:e.rank,label:J(e),color:ye(e)}}function J(e){return e.rank===`SJ`?`小王`:e.rank===`BJ`?`大王`:`${ve(e.suit)}${e.rank}`}function ve(e){return{S:`♠`,H:`♥`,C:`♣`,D:`♦`}[e]||``}function ye(e){return e.suit===`H`||e.suit===`D`||e.rank===`BJ`?`red`:`black`}function be(e){let t=e.resolvedValues?.length?`(${e.resolvedValues.map(xe).join(` `)})`:``;return`${{single:`单张`,pair:`对子`,straight:`顺子`,pairStraight:`连对`,bomb:e.pure?`纯炸弹`:`带王炸弹`}[e.type]}${t}`}function xe(e){return h.find(t=>_.get(t)===e)||String(e)}function Se(e){let t=h.findIndex(t=>_.get(t)===e);return t===-1||t>=h.length-1?null:_.get(h[t+1])}function Ce(e){return Math.floor(e()*6)+1}function Y(e){return String(e||`玩家`).trim().slice(0,16)||`玩家`}var X={page:`_page_p7qf6_1`,headerActions:`_headerActions_p7qf6_7`,entry:`_entry_p7qf6_13`,entryBrand:`_entryBrand_p7qf6_23`,cardMark:`_cardMark_p7qf6_29`,entryPanel:`_entryPanel_p7qf6_59`,panel:`_panel_p7qf6_60`,handPanel:`_handPanel_p7qf6_61`,accountLine:`_accountLine_p7qf6_74`,scoreMeta:`_scoreMeta_p7qf6_75`,roomBar:`_roomBar_p7qf6_76`,badges:`_badges_p7qf6_77`,actions:`_actions_p7qf6_78`,joinForm:`_joinForm_p7qf6_98`,status:`_status_p7qf6_119`,gameGrid:`_gameGrid_p7qf6_125`,tablePanel:`_tablePanel_p7qf6_136`,seats:`_seats_p7qf6_170`,player:`_player_p7qf6_176`,active:`_active_p7qf6_193`,winner:`_winner_p7qf6_197`,avatar:`_avatar_p7qf6_201`,centerTable:`_centerTable_p7qf6_235`,deckBox:`_deckBox_p7qf6_242`,playedBox:`_playedBox_p7qf6_243`,playedCards:`_playedCards_p7qf6_271`,notice:`_notice_p7qf6_279`,resultDetail:`_resultDetail_p7qf6_287`,sidePanel:`_sidePanel_p7qf6_298`,scoreRow:`_scoreRow_p7qf6_323`,logPanel:`_logPanel_p7qf6_331`,hand:`_hand_p7qf6_61`,cardButton:`_cardButton_p7qf6_358`,picked:`_picked_p7qf6_368`,card:`_card_p7qf6_29`,red:`_red_p7qf6_399`,black:`_black_p7qf6_403`,small:`_small_p7qf6_407`,preview:`_preview_p7qf6_425`,valid:`_valid_p7qf6_448`},Z=n(),Q=`gandengyan`;function $(...e){return e.filter(Boolean).join(` `)}function we(e,t){return String(e||``).toLowerCase()===String(t||``).toLowerCase()}function Te(e,t){if(typeof window>`u`||!(`speechSynthesis`in window)||!e)return;window.speechSynthesis.cancel();let n=new SpeechSynthesisUtterance(e);n.lang=t,n.rate=1.1,window.speechSynthesis.speak(n)}function Ee(){let{t:e,locale:t}=o(),n=u(e=>e.isDarkMode),r=u(e=>e.setIsDarkMode),i=u(e=>e.addToast),l=a(e=>e.initializeUser),[d,f]=(0,p.useState)(``),[m,h]=(0,p.useState)([]),[g,_]=(0,p.useState)(!1),v=(0,p.useRef)(``),y=(0,p.useRef)(!1),b=se({gameId:Q,onError:e=>i(e,`error`)});(0,p.useEffect)(()=>{l()},[l]),(0,p.useEffect)(()=>{let e=new URLSearchParams(window.location.search).get(`room`)?.toUpperCase();e&&(f(e),v.current=e)},[]),(0,p.useEffect)(()=>{let t=v.current;!t||y.current||!b.isBackendReady||!b.userIdentity||(y.current=!0,v.current=``,b.joinRoom(t).then(t=>{t&&i(e(`game.toast.joinedRoom`),`success`)}))},[b.isBackendReady,b.userIdentity,b.joinRoom,i,e]),(0,p.useEffect)(()=>{if(!b.roomCode)return;let e=`/game/gandengyan?room=${b.roomCode}`;`${window.location.pathname}${window.location.search}`!==e&&window.history.replaceState(null,``,e)},[b.roomCode]);let x=(0,p.useMemo)(()=>ae(b.messages,b.roomCode?{gameId:Q,roomCode:b.roomCode}:{gameId:Q}),[b.messages,b.roomCode]),S=(0,p.useMemo)(()=>oe(b.messages,{gameId:Q,roomCode:b.roomCode}),[b.messages,b.roomCode]),w=S?.payload?.state,T=w?.players.find(e=>we(e.address,b.userIdentity?.address)),E=we(w?.ownerAddress||x.hostAddress,b.userIdentity?.address),D=w?.status===`playing`&&w.currentSeat===T?.seat,O=(0,p.useMemo)(()=>m.map(e=>T?.hand.find(t=>t.id===e)).filter(Boolean),[m,T]),k=(0,p.useMemo)(()=>C(O),[O]),A=b.roomCode&&typeof window<`u`?`${window.location.origin}/game/gandengyan?room=${b.roomCode}`:``,j=(0,p.useRef)(-1),M=(0,p.useRef)(!1);(0,p.useEffect)(()=>{h([])},[w?.seq]),(0,p.useEffect)(()=>{if(!w)return;let n=w.seq;if(j.current<0){j.current=n;return}if(n!==j.current&&(j.current=n,w.status!==`finished`&&(M.current=!1),w.status===`finished`&&w.winnerSeat!==null)){M.current||(M.current=!0,Te(e(`game.gandengyan.speech.gameOver`),t));return}},[t,w?.seq,e]),(0,p.useEffect)(()=>{if(!E||!b.roomCode||!b.userIdentity||S||x.players.length===0)return;let e=le({roomCode:b.roomCode,ownerAddress:b.userIdentity.address,ownerName:b.userIdentity.displayName||b.userIdentity.username,players:x.players});b.sendRoomEvent(`room:state`,{state:e,seq:e.seq})},[b,E,S,x.players]),(0,p.useEffect)(()=>{if(!w||!E||w.status!==`lobby`)return;let e=ue(w,x.players);e&&e.players.length!==w.players.length&&b.sendRoomEvent(`room:state`,{state:e,seq:e.seq})},[b,E,x.players,w]);let N=(0,p.useRef)(0),P=(0,p.useMemo)(()=>b.roomEvents.filter(e=>e.event?.event===`player:leave`),[b.roomEvents]);(0,p.useEffect)(()=>{if(P.length<=N.current)return;let t=P.slice(N.current);N.current=P.length;for(let n of t)i(e(`game.toast.playerLeft`,{player:n.event?.payload?.player?.name||e(`game.player`)}),`info`)},[P,i,e]),(0,p.useEffect)(()=>{if(!w||!E||w.status!==`playing`)return;let e=new Set(x.players.map(e=>e.address.toLowerCase())),t=w.players.find(t=>!e.has(t.address.toLowerCase()));if(!t)return;let n=me(w,t.address);n&&R(n)},[b,E,x.players,w]);async function F(){await b.createRoom()&&i(e(`game.toast.roomCreated`),`success`)}async function I(t){t.preventDefault(),await b.joinRoom(d)&&i(e(`game.toast.joinedRoom`),`success`)}async function L(){A&&(await navigator.clipboard.writeText(A),_(!0),setTimeout(()=>_(!1),1400))}async function R(e){await b.sendRoomEvent(`room:state`,{state:e,seq:e.seq})}async function z(){if(!(!w||!E))try{await R(de(w))}catch(t){i(t instanceof Error?t.message:e(`game.zhajinhua.error.startFailed`),`error`)}}async function B(){await z()}async function V(){if(!w||!b.userIdentity)return;let t=fe(w,b.userIdentity.address,m);if(!t.ok){i(t.error||e(`game.gandengyan.error.playFailed`),`error`);return}await R(t.state)}async function H(){if(!w||!b.userIdentity)return;let t=pe(w,b.userIdentity.address);if(!t.ok){i(t.error||e(`game.gandengyan.error.actionFailed`),`error`);return}await R(t.state)}function U(e){h(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])}return(0,Z.jsx)(te,{sidebar:({closeSidebar:e})=>(0,Z.jsx)(ie,{activeGame:`gandengyan`,closeSidebar:e}),headerTitle:(0,Z.jsx)(`h2`,{className:`header-title`,children:e(`game.gandengyan.title`)}),headerRight:(0,Z.jsxs)(`div`,{className:X.headerActions,children:[w&&(0,Z.jsxs)(`button`,{className:`btn btn-sm`,onClick:L,children:[(0,Z.jsx)(ee,{size:14}),e(g?`common.copied`:`game.action.shareRoom`)]}),(0,Z.jsx)(`button`,{className:`btn btn-icon`,onClick:()=>r(!n),title:e(`common.theme.toggle`),children:n?(0,Z.jsx)(s,{size:16}):(0,Z.jsx)(c,{size:16})})]}),children:(0,Z.jsx)(`main`,{className:X.page,children:w?(0,Z.jsxs)(`section`,{className:X.gameGrid,children:[(0,Z.jsxs)(`div`,{className:X.tablePanel,children:[(0,Z.jsxs)(`div`,{className:X.roomBar,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`strong`,{translate:`no`,children:e(`game.roomLabel`,{room:w.id})}),(0,Z.jsx)(`span`,{children:w.status===`lobby`?e(`game.status.waitingStart`):w.status===`finished`?e(`game.status.finished`):e(`game.status.playing`)})]}),(0,Z.jsx)(`div`,{className:X.badges,children:(0,Z.jsx)(`span`,{children:b.connected?e(`game.status.online`):e(`game.status.offline`)})})]}),(0,Z.jsx)(`div`,{className:X.seats,children:w.players.map(t=>(0,Z.jsx)(De,{player:t,active:w.currentSeat===t.seat,winner:w.winnerSeat===t.seat,relation:ke(T,t,w.players.length,e)},t.seat))}),(0,Z.jsxs)(`div`,{className:X.centerTable,children:[(0,Z.jsxs)(`div`,{className:X.deckBox,children:[(0,Z.jsx)(`span`,{children:e(`game.gandengyan.deck`)}),(0,Z.jsx)(`strong`,{children:w.deckCount})]}),(0,Z.jsx)(`div`,{className:X.playedBox,children:w.table?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`strong`,{children:e(`game.gandengyan.tablePlay`,{player:w.table.playerName,combo:w.table.combo?.label||e(`game.card`)})}),(0,Z.jsx)(`div`,{className:X.playedCards,children:w.table.cards.map(e=>(0,Z.jsx)(Oe,{card:e,small:!0},e.id))})]}):(0,Z.jsx)(`span`,{children:e(`game.gandengyan.waitingLead`)})}),(0,Z.jsxs)(`div`,{className:X.deckBox,children:[(0,Z.jsx)(`span`,{children:e(`game.gandengyan.baseScore`)}),(0,Z.jsx)(`strong`,{children:w.baseScore})]})]}),(0,Z.jsx)(`div`,{className:X.notice,children:w.status===`finished`?w.roundResult?(0,Z.jsxs)(`div`,{className:X.resultDetail,children:[(0,Z.jsxs)(`p`,{children:[e(`game.gandengyan.result.winnerGain`,{player:w.roundResult.winnerName,score:w.roundResult.winnerGain}),w.roundResult.bombCount>0&&e(`game.gandengyan.result.bombCount`,{count:w.roundResult.bombCount})]}),w.roundResult.losers.map(t=>(0,Z.jsx)(`p`,{children:t.sealed?e(`game.gandengyan.result.sealedLoss`,{player:t.name,loss:20}):e(`game.gandengyan.result.cardsLeftLoss`,{player:t.name,cards:t.cardsLeft,loss:t.loss})},t.seat))]}):e(`game.gandengyan.result.winner`,{player:w.players.find(e=>e.seat===w.winnerSeat)?.name||e(`game.player`)}):D?e(`game.gandengyan.status.yourTurn`):e(`game.zhajinhua.status.waitingPlayer`,{player:w.players.find(e=>e.seat===w.currentSeat)?.name||e(`game.player`)})})]}),(0,Z.jsxs)(`aside`,{className:X.sidePanel,children:[(0,Z.jsxs)(`section`,{className:X.panel,children:[(0,Z.jsx)(`h3`,{children:e(`game.gandengyan.roundPanel`)}),E&&w.status===`lobby`&&(0,Z.jsxs)(`button`,{className:`btn btn-primary`,disabled:w.players.length<2,onClick:z,children:[(0,Z.jsx)(ne,{size:16}),e(`game.action.startRound`)]}),E&&w.status===`finished`&&(0,Z.jsxs)(`button`,{className:`btn btn-primary`,onClick:B,children:[(0,Z.jsx)(ce,{size:16}),e(`game.action.nextRound`)]}),!E&&(0,Z.jsx)(`p`,{className:X.status,children:e(`game.waitingHost`)})]}),(0,Z.jsxs)(`section`,{className:X.panel,children:[(0,Z.jsx)(`h3`,{children:e(`game.gandengyan.score`)}),(0,Z.jsxs)(`div`,{className:X.scoreMeta,children:[(0,Z.jsx)(`span`,{children:e(`game.gandengyan.bombCount`,{count:w.bombCount})}),(0,Z.jsx)(`span`,{children:e(`game.gandengyan.discardCount`,{count:w.discardCount})})]}),w.players.map(e=>(0,Z.jsxs)(`div`,{className:X.scoreRow,children:[(0,Z.jsx)(`span`,{translate:`no`,children:e.name}),(0,Z.jsx)(`strong`,{children:e.score})]},e.seat))]}),(0,Z.jsxs)(`section`,{className:$(X.panel,X.logPanel),children:[(0,Z.jsx)(`h3`,{children:e(`game.gandengyan.log`)}),w.log.map((e,t)=>(0,Z.jsx)(`p`,{translate:`no`,children:e},`${e}-${t}`))]})]}),(0,Z.jsxs)(`div`,{className:X.handPanel,children:[(0,Z.jsx)(De,{player:T,active:D,winner:w.winnerSeat===T?.seat}),(0,Z.jsx)(`div`,{className:X.hand,children:T?.hand.map(e=>(0,Z.jsx)(`button`,{className:$(X.cardButton,m.includes(e.id)&&X.picked),onClick:()=>U(e.id),children:(0,Z.jsx)(Oe,{card:e})},e.id))}),(0,Z.jsxs)(`div`,{className:X.actions,children:[(0,Z.jsxs)(`div`,{className:$(X.preview,k&&X.valid),children:[(0,Z.jsx)(`strong`,{children:k?k.label:m.length?e(`game.gandengyan.invalidCombo`):e(`game.gandengyan.selectCards`)}),(0,Z.jsx)(`span`,{children:O.map(e=>e.label).join(` `)||e(`game.gandengyan.jokerOrderHint`)})]}),(0,Z.jsxs)(`button`,{className:`btn btn-primary`,disabled:!D||m.length===0||!k,onClick:V,children:[(0,Z.jsx)(re,{size:16}),e(`game.gandengyan.action.play`)]}),(0,Z.jsx)(`button`,{className:`btn`,disabled:!D||!w.table,onClick:H,children:e(`game.gandengyan.action.pass`)})]})]})]}):(0,Z.jsxs)(`section`,{className:X.entry,children:[(0,Z.jsxs)(`div`,{className:X.entryBrand,children:[(0,Z.jsx)(`div`,{className:X.cardMark,children:e(`game.gandengyan.mark`)}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h1`,{children:e(`game.gandengyan.hero.title`)}),(0,Z.jsx)(`p`,{children:e(`game.hero.desc`)})]})]}),(0,Z.jsxs)(`div`,{className:X.entryPanel,children:[(0,Z.jsxs)(`div`,{className:X.accountLine,children:[(0,Z.jsx)(`span`,{children:e(`game.currentAccount`)}),(0,Z.jsx)(`strong`,{translate:`no`,children:b.userIdentity?.displayName||e(`web3.notSignedIn`)})]}),(0,Z.jsxs)(`button`,{className:`btn btn-primary`,disabled:b.joining,onClick:F,children:[(0,Z.jsx)(ne,{size:16}),e(`game.action.createRoom`)]}),(0,Z.jsxs)(`form`,{onSubmit:I,className:X.joinForm,children:[(0,Z.jsxs)(`label`,{children:[e(`game.roomCode`),(0,Z.jsx)(`input`,{value:d,maxLength:8,onChange:e=>f(e.target.value.toUpperCase()),placeholder:e(`game.roomCode.placeholder`)})]}),(0,Z.jsx)(`button`,{className:`btn`,disabled:b.joining||!d,children:e(`game.action.joinRoom`)})]}),(0,Z.jsx)(`p`,{className:X.status,children:b.isBackendReady?e(`game.status.nodeConnected`):e(`game.status.nodeConnecting`)})]})]})})})}function De({player:e,active:t,winner:n,relation:r=``}){let{t:i}=o();return e?(0,Z.jsxs)(`div`,{className:$(X.player,t&&X.active,n&&X.winner),children:[(0,Z.jsx)(`div`,{className:X.avatar,translate:`no`,children:(0,Z.jsx)(`img`,{src:d(e.address,e.avatar),alt:``})}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`strong`,{translate:`no`,children:e.name}),(0,Z.jsxs)(`span`,{children:[r,r?` · `:``,i(`game.gandengyan.handCount`,{count:e.handCount})]})]})]}):null}function Oe({card:e,small:t=!1}){return(0,Z.jsxs)(`div`,{className:$(X.card,X[e.color],t&&X.small),children:[(0,Z.jsx)(`span`,{children:e.label}),(0,Z.jsx)(`i`,{children:e.suit===`Joker`?`*`:e.label.slice(0,1)})]})}function ke(e,t,n,r){if(!e)return r(`game.gandengyan.position.seat`,{seat:t.seat+1});let i=(t.seat-e.seat+n)%n;return i===0?r(`game.gandengyan.position.me`):n===2?r(`game.gandengyan.position.opponent`):n===3?r(i===1?`game.gandengyan.position.nextOpponent`:`game.gandengyan.position.prevOpponent`):n===4?r(i===1?`game.gandengyan.position.nextOpponent`:i===2?`game.gandengyan.position.partner`:`game.gandengyan.position.prevOpponent`):i%2==0?r(`game.gandengyan.position.seatPartner`,{seat:t.seat+1}):r(`game.gandengyan.position.seatOpponent`,{seat:t.seat+1})}var Ae=i(`/game/gandengyan/`)({component:Ee});export{Ae as Route};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e,o as t,t as n}from"./jsx-runtime-Bt-cYkS5.js";import{C as r,T as i,d as a,l as o,s,u as c}from"./ui-BpDGD3IR.js";import{a as l}from"./i18n-NjvOSuV6.js";import{n as u,r as d}from"./LanguageToggle-CSQtRZ3A.js";import{t as f}from"./copy-DEzFUzeX.js";import{n as p}from"./SidebarHomeLink-BdsUM4Kt.js";import{t as m}from"./play-B-BjsTZz.js";import{a as h,i as g,n as _,r as ee,t as te}from"./useGameRoom-CRJL0kcm.js";import{E as v,N as ne,S as y,b as re,c as b,i as ie,w as x,x as S}from"./index-BZ-f0CZd.js";var ae=r(`refresh-ccw`,[[`path`,{d:`M21 12a9 9 0 0 0-9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`14sxne`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}],[`path`,{d:`M3 12a9 9 0 0 0 9 9 9.75 9.75 0 0 0 6.74-2.74L21 16`,key:`1hlbsb`}],[`path`,{d:`M16 16h5v5`,key:`ccwih5`}]]),C=t(e(),1),oe=[10,20,50,100],w=[`2`,`3`,`4`,`5`,`6`,`7`,`8`,`9`,`10`,`J`,`Q`,`K`,`A`],T=[`D`,`C`,`H`,`S`],E=new Map(w.map((e,t)=>[e,t+2])),D=new Map(T.map((e,t)=>[e,t+1])),O={high:1,pair:2,straight:3,flush:4,straightFlush:5,triple:6},se={[O.high]:`散牌`,[O.pair]:`对子`,[O.straight]:`顺子`,[O.flush]:`金花`,[O.straightFlush]:`顺金`,[O.triple]:`豹子`};function k(e){return x(e)}function ce(e=`zhajinhua`){return re(e)}function le(){return ce(`round`)}function ue(){let e=[];for(let t of T)for(let n of w)e.push(`${n}${t}`);return e}function A(e=ue(),t=Math.random){let n=[...e];for(let e=n.length-1;e>0;e--){let r=Math.floor(t()*(e+1));[n[e],n[r]]=[n[r],n[e]]}return n}function j(e){let t=String(e||``).trim().toUpperCase(),n=t.slice(-1),r=t.slice(0,-1);if(!E.has(r)||!D.has(n))throw Error(`Invalid card: ${e}`);return{id:`${r}${n}`,rank:r,suit:n,rankValue:E.get(r),suitValue:D.get(n)}}function M(e,t){let n=Math.max(e.length,t.length);for(let r=0;r<n;r++){let n=e[r]||0,i=t[r]||0;if(n!==i)return n-i}return 0}function N(e){let t=[...new Set(e)].sort((e,t)=>e-t);return t.length===3?t[0]===2&&t[1]===3&&t[2]===14?3:t[0]+1===t[1]&&t[1]+1===t[2]?t[2]:0:0}function P(e){if(!Array.isArray(e)||e.length!==3)throw Error(`炸金花手牌必须是 3 张牌`);let t=e.map(j),n=t.map(e=>e.rankValue),r=new Map;for(let e of n)r.set(e,(r.get(e)||0)+1);let i=new Set(t.map(e=>e.suit)).size===1,a=N(n),o=[...n].sort((e,t)=>t-e),s=Math.max(...t.map(e=>e.suitValue)),c=O.high,l=o;return r.size===1?(c=O.triple,l=[o[0]]):a&&i?(c=O.straightFlush,l=[a]):i?(c=O.flush,l=o):a?(c=O.straight,l=[a]):r.size===2&&(c=O.pair,l=[[...r.entries()].find(([,e])=>e===2)[0],[...r.entries()].find(([,e])=>e===1)[0]]),{category:c,label:se[c],tiebreakers:l,tieSuit:s,cards:t.map(e=>e.id)}}function F(e,t){let n=P(e),r=P(t);if(n.category!==r.category)return n.category-r.category;let i=M(n.tiebreakers,r.tiebreakers);return i===0?n.tieSuit-r.tieSuit:i}function de(e){return P(e).label}function I({roundId:e,action:t,amount:n,target:r}){return{roundId:e,eventId:ce(`action`),action:t,amount:n,target:r}}function fe(e=[]){let t=e.filter(e=>Number(e.chips)>=10);return t.length>=2&&t.length<=5}function pe({roomCode:e,players:t,hostAddress:n,previousSeq:r=0,previousWinner:i=``,roundId:a=le(),random:o=Math.random}){let s=t.filter(e=>Number(e.chips)>=10).slice(0,5);if(s.length<2)throw Error(`至少需要 2 名有足够筹码的玩家`);let c=A(ue(),o),l={},u=s.map((e,t)=>{let n=c.slice(t*3,t*3+3);return l[e.address]=n,{address:e.address,name:e.name,avatar:y(e.avatar),publicKey:e.publicKey,chips:Number(e.chips)-10,status:`active`,looked:!1,bet:10}}),d,f=S(i),p=f?u.findIndex(e=>S(e.address)===f):-1;return d=p>=0?u[p].address:u[Math.floor(o()*u.length)].address,{roomCode:k(e),roundId:a,status:`playing`,host:S(n),seq:r+1,startedAt:Date.now(),ante:10,pot:10*u.length,currentBet:10,turnAddress:d,players:u,lastAction:`本局开始`,winner:null,showdown:null,appliedEventIds:[],hands:l,actionCounts:{},compareReveal:{}}}function me(e){if(!e)return null;let t={...e};return delete t.hands,K(t)}function he(e,t){let n=L(e);return!n||!t||typeof t!=`object`?null:{...n,hands:K(t)}}function L(e){return!e||typeof e!=`object`||!e.roundId||!Array.isArray(e.players)?null:{roomCode:k(e.roomCode),roundId:String(e.roundId),status:e.status===`finished`?`finished`:`playing`,host:S(e.host),seq:Number(e.seq)||1,startedAt:Number(e.startedAt)||Date.now(),ante:Number(e.ante)||10,pot:Math.max(0,Number(e.pot)||0),currentBet:Math.max(0,Number(e.currentBet)||10),turnAddress:S(e.turnAddress),players:e.players.map(ve).filter(Boolean),lastAction:String(e.lastAction||``),winner:e.winner?S(e.winner):null,showdown:e.showdown&&typeof e.showdown==`object`?K(e.showdown):null,appliedEventIds:Array.isArray(e.appliedEventIds)?e.appliedEventIds.map(String):[],actionCounts:e.actionCounts&&typeof e.actionCounts==`object`?K(e.actionCounts):{},compareReveal:e.compareReveal&&typeof e.compareReveal==`object`?K(e.compareReveal):{},lastCompare:e.lastCompare&&typeof e.lastCompare==`object`?K(e.lastCompare):null,finishedAt:e.finishedAt?Number(e.finishedAt):null}}function R(e,t,n){let r=L(e);if(!r||r.status!==`playing`)return{ok:!1,error:`当前没有进行中的牌局`};let i=S(n),a=r.players.find(e=>e.address===i);if(!a||a.status!==`active`)return{ok:!1,error:`玩家不在本轮牌局中`};if(r.turnAddress!==i)return{ok:!1,error:`还没有轮到你操作`};let o=t?.action;if(![`look`,`call`,`raise`,`compare`,`fold`].includes(o))return{ok:!1,error:`未知操作`};if(o===`look`)return a.looked?{ok:!1,error:`已经看过牌`}:{ok:!0};if(o===`call`)return a.chips>=10?{ok:!0}:{ok:!1,error:`筹码不足,不能跟注`};if(o===`raise`){let e=Number(t.amount);if(!oe.includes(e))return{ok:!1,error:`加注档位无效`};let n=r.currentBet+e-a.bet;return a.chips>=n?{ok:!0}:{ok:!1,error:`筹码不足,不能加注`}}if(o===`compare`){let e=S(t.target),n=r.players.find(t=>t.address===e);if(!e||e===i||!n||n.status!==`active`)return{ok:!1,error:`请选择有效的比牌对象`};if(!r.players.filter(e=>e.status===`active`).every(e=>(r.actionCounts?.[e.address]||0)>=1))return{ok:!1,error:`第一轮不能比牌,请先跟注或加注`};let o=Math.max(0,r.currentBet-a.bet);return a.chips>=o?{ok:!0}:{ok:!1,error:`筹码不足,不能比牌`}}return{ok:!0}}function z(e,t,n){let r=R(e,t,n);if(!r.ok)return{ok:!1,error:r.error,state:e};let i=K(e),a=S(n),o=i.players.find(e=>e.address===a),s=String(t.eventId);if(i.appliedEventIds?.includes(s))return{ok:!0,state:i,duplicate:!0};if(Array.isArray(i.appliedEventIds)||(i.appliedEventIds=[]),i.appliedEventIds.push(s),t.action===`look`)return o.looked=!0,i.lastAction=`${o.name} 看牌`,G(i);if(t.action===`fold`)return o.status=`folded`,i.lastAction=`${o.name} 弃牌`,H(i,a),U(i,a);if(t.action===`call`)return o.chips-=10,o.bet+=10,i.pot+=10,i.lastAction=`${o.name} 跟注`,H(i,a),U(i,a);if(t.action===`raise`){let e=Number(t.amount);return i.currentBet+=e,V(i,o),i.lastAction=`${o.name} 加注 ${e}`,H(i,a),U(i,a)}if(t.action===`compare`){V(i,o);let e=S(t.target),n=i.players.find(t=>t.address===e),r=o.looked,s=n.looked,c=F(i.hands?.[a]||[],i.hands?.[e]||[]),l=c>=0?o:n,u=c>=0?n:o;u.status=`folded`,u.looked=!0,i.compareReveal||={};let d=r&&s,f=!r&&!s;if(d)i.compareReveal[a]=i.hands?.[e]||[],i.compareReveal[e]=i.hands?.[a]||[];else if(f)i.compareReveal[u.address]=i.hands?.[l.address]||[];else{let e=r?o:n,t=r?n:o;i.compareReveal[e.address]=i.hands?.[t.address]||[],i.compareReveal[u.address]=i.hands?.[l.address]||[]}return i.lastCompare={initiator:a,target:e,winner:l.address,loser:u.address,initiatorLooked:r,targetLooked:s,timestamp:Date.now()},i.lastAction=`${o.name} 与 ${n.name} 比牌,${u.name} 出局`,H(i,a),U(i,a)}return{ok:!1,error:`未知操作`,state:e}}function B(e){return(e?.players||[]).filter(e=>e.status===`active`)}function ge(e,t){let n=(e?.players||[]).find(e=>e.address===S(t));if(!e||e.status!==`playing`||!n||n.status!==`active`||e.turnAddress!==n.address)return[];let r=[];return n.looked||r.push(`look`),R(e,{action:`call`},n.address).ok&&r.push(`call`),oe.some(t=>R(e,{action:`raise`,amount:t},n.address).ok)&&r.push(`raise`),B(e).length>1&&e.players.filter(e=>e.status===`active`).every(t=>(e.actionCounts?.[t.address]||0)>=1)&&r.push(`compare`),r.push(`fold`),r}function V(e,t){let n=Math.max(0,e.currentBet-t.bet);t.chips-=n,t.bet+=n,e.pot+=n}function H(e,t){e.actionCounts||={},e.actionCounts[t]=(e.actionCounts[t]||0)+1}function U(e,t){let n=B(e);return n.length===1?_e(e,n[0].address):(e.turnAddress=W(e,t),G(e))}function _e(e,t){let n=e.players.find(e=>e.address===t),r=e.pot;return n&&(n.chips+=e.pot),e.status=`finished`,e.winner=t,e.winAmount=r,e.turnAddress=``,e.showdown=e.hands?K(e.hands):null,e.lastAction=n?`${n.name} 赢得 ${r} 筹码`:`本局结束`,e.pot=0,e.finishedAt=Date.now(),G(e)}function W(e,t){let n=e.players,r=Math.max(0,n.findIndex(e=>e.address===S(t)));for(let e=1;e<=n.length;e++){let t=n[(r+e)%n.length];if(t.status===`active`)return t.address}return``}function G(e){return e.seq=Number(e.seq||0)+1,{ok:!0,state:e}}function ve(e){if(!e||typeof e!=`object`)return null;let t=S(e.address);return t?{address:t,name:String(e.name||v(t)).slice(0,50),avatar:y(e.avatar),publicKey:String(e.publicKey||``),chips:Math.max(0,Number(e.chips)||0),status:e.status===`folded`?`folded`:`active`,looked:e.looked===!0,bet:Math.max(0,Number(e.bet)||0)}:null}function K(e){return JSON.parse(JSON.stringify(e))}var q={page:`_page_1yyew_1`,headerActions:`_headerActions_1yyew_12`,entry:`_entry_1yyew_18`,entryBrand:`_entryBrand_1yyew_28`,cardMark:`_cardMark_1yyew_34`,entryPanel:`_entryPanel_1yyew_62`,accountLine:`_accountLine_1yyew_72`,joinForm:`_joinForm_1yyew_89`,status:`_status_1yyew_110`,board:`_board_1yyew_116`,table:`_table_1yyew_123`,tableCenter:`_tableCenter_1yyew_144`,finishBanner:`_finishBanner_1yyew_173`,finishBannerIcon:`_finishBannerIcon_1yyew_192`,seats:`_seats_1yyew_196`,seat:`_seat_1yyew_196`,seatTurn:`_seatTurn_1yyew_218`,seatWinner:`_seatWinner_1yyew_223`,seatFolded:`_seatFolded_1yyew_228`,seatAvatar:`_seatAvatar_1yyew_232`,seatMain:`_seatMain_1yyew_251`,seatMeta:`_seatMeta_1yyew_252`,panel:`_panel_1yyew_283`,panelSection:`_panelSection_1yyew_290`,panelTitle:`_panelTitle_1yyew_300`,hand:`_hand_1yyew_310`,card:`_card_1yyew_34`,red:`_red_1yyew_344`,black:`_black_1yyew_348`,cardBack:`_cardBack_1yyew_352`,handLabel:`_handLabel_1yyew_373`,actionGrid:`_actionGrid_1yyew_380`,raiseRow:`_raiseRow_1yyew_381`,statusGrid:`_statusGrid_1yyew_392`,muted:`_muted_1yyew_410`,compareOverlay:`_compareOverlay_1yyew_417`,compareBox:`_compareBox_1yyew_429`,compareTitle:`_compareTitle_1yyew_443`,comparePlayers:`_comparePlayers_1yyew_449`,compareSide:`_compareSide_1yyew_456`,compareWinner:`_compareWinner_1yyew_468`,compareName:`_compareName_1yyew_473`,compareCards:`_compareCards_1yyew_484`,compareLabel:`_compareLabel_1yyew_509`,compareVs:`_compareVs_1yyew_515`,compareResult:`_compareResult_1yyew_522`},J=n(),ye=`zhajinhua`;function Y(...e){return e.filter(Boolean).join(` `)}function X(e,t){return String(e||``).toLowerCase()===String(t||``).toLowerCase()}function be(e=``){return e?`${e.slice(0,6)}...${e.slice(-4)}`:``}function xe(e){return e.displayName||e.username}function Se(e){let t=String(e||``),n=t.slice(-1);return{rank:t.slice(0,-1),suit:{S:`♠`,H:`♥`,C:`♣`,D:`♦`}[n]||n,color:n===`H`||n===`D`?`red`:`black`}}function Z(){let{t:e}=l(),t=b(e=>e.isDarkMode),n=b(e=>e.setIsDarkMode),r=b(e=>e.addToast),i=s(e=>e.initializeUser),[v,y]=(0,C.useState)(``),[re,x]=(0,C.useState)(!1),S=(0,C.useRef)(``),w=(0,C.useRef)(!1),[T,E]=(0,C.useState)(20),[D,O]=(0,C.useState)(``),[se,k]=(0,C.useState)({}),[ce,le]=(0,C.useState)(!0),[ue,A]=(0,C.useState)(!1),j=(0,C.useRef)(null),M=(0,C.useRef)(new Set),N=te({gameId:ye,onError:e=>r(e,`error`),getPlayerPayload:e=>{let t=o(e.danger);return{address:e.address,name:xe(e),avatar:e.avatar||``,publicKey:t.public_key,joinedAt:Date.now()}}}),P=(0,C.useMemo)(()=>N.userIdentity?.danger?o(N.userIdentity.danger):null,[N.userIdentity?.danger]);(0,C.useEffect)(()=>{i()},[i]),(0,C.useEffect)(()=>{let e=new URLSearchParams(window.location.search).get(`room`)?.toUpperCase();e&&(y(e),S.current=e)},[]),(0,C.useEffect)(()=>{let t=S.current;!t||w.current||!N.isBackendReady||!N.userIdentity||(w.current=!0,S.current=``,N.joinRoom(t).then(t=>{t&&r(e(`game.toast.joinedRoom`),`success`)}))},[N.isBackendReady,N.userIdentity,N.joinRoom,r,e]),(0,C.useEffect)(()=>{if(!N.roomCode)return;let e=`/game/zhajinhua?room=${N.roomCode}`;`${window.location.pathname}${window.location.search}`!==e&&window.history.replaceState(null,``,e)},[N.roomCode]);let F=(0,C.useMemo)(()=>_(N.messages,{gameId:ye,roomCode:N.roomCode}),[N.messages,N.roomCode]),L=(0,C.useMemo)(()=>ee(N.messages,{gameId:ye,roomCode:N.roomCode}),[N.messages,N.roomCode])?.payload?.round||null,R=L?.host||F.hostAddress,V=X(R,N.userIdentity?.address),H=N.userIdentity?.address?.toLowerCase()||``,U=L?.players.find(e=>X(e.address,H)),_e=U||F.players.find(e=>X(e.address,H)),W=se[L?.roundId||``]||null,G=L?.showdown&&H?L.showdown[H]:null,ve=L?.compareReveal&&H?L.compareReveal[H]:null,K=G||ve||(U?.looked?W:null),Z=ge(L,H),we=B(L),Te=V&&fe(F.players.map(e=>({...e,chips:L?.players.find(t=>X(t.address,e.address))?.chips??1e3}))),Ee=N.roomCode&&typeof window<`u`?`${window.location.origin}/game/zhajinhua?room=${N.roomCode}`:``;(0,C.useEffect)(()=>{if(!(!L||!N.userIdentity||!P||!R))for(let e of N.roomEvents){let t=e.event;if(!t||t.event!==`deal:private`)continue;let n=t.payload;if(n.roundId!==L.roundId||!X(n.recipient,N.userIdentity.address))continue;let r=c(n.encrypted||``,{senderPublicKey:n.senderPublicKey||``,recipientPrivateKey:P.private_key});if(r)try{let e=JSON.parse(r);Array.isArray(e)&&k(t=>({...t,[L.roundId]:e.map(String)}))}catch{}}},[L?.roundId,N.roomEvents,N.userIdentity,R,P?.private_key]),(0,C.useEffect)(()=>{if(L?.status===`finished`&&L.winner){le(!0);let e=setTimeout(()=>le(!1),5e3);return()=>clearTimeout(e)}},[L?.finishedAt,L?.status,L?.winner]),(0,C.useEffect)(()=>{if(L?.lastCompare?.timestamp){A(!0);let e=setTimeout(()=>A(!1),5e3);return()=>clearTimeout(e)}else A(!1)},[L?.lastCompare?.timestamp,L?.roundId]),(0,C.useEffect)(()=>{if(!V||!L||L.status!==`playing`)return;let e=j.current;if(!e)return;let t=N.roomEvents.filter(e=>{let t=e.event;if(!t||t.event!==`player:action`)return!1;let n=t.payload.actionEvent;return!(!n||n.roundId!==L.roundId||M.current.has(n.eventId)||L.appliedEventIds?.includes(n.eventId))});if(t.length===0)return;let n=!1;async function r(){let r=he(L,e);if(r)for(let e of t){if(n)return;let t=(e.event?.payload).actionEvent,i=z(r,t,e.message.author);if(!i.ok){let n=e.message.author;if(!X(n,N.userIdentity?.address)&&r.status===`playing`&&X(r.turnAddress,n)){let e=z(r,I({roundId:r.roundId,action:`call`,amount:void 0,target:void 0}),n);if(e.ok)i=e;else{let e=z(r,I({roundId:r.roundId,action:`fold`,amount:void 0,target:void 0}),n);e.ok&&(i=e)}}if(!i.ok){M.current.add(t.eventId);continue}}if(r=i.state,j.current=i.state.hands,await Ae(i.state)&&M.current.add(t.eventId),i.state.status===`finished`)break}}return r(),()=>{n=!0}},[L?.roundId,L?.seq,L?.status,N.roomEvents,V]);async function De(){await N.createRoom()&&r(e(`game.toast.roomCreated`),`success`)}async function Oe(t){t.preventDefault(),await N.joinRoom(v)&&r(e(`game.toast.joinedRoom`),`success`)}async function ke(){Ee&&(await navigator.clipboard.writeText(Ee),x(!0),setTimeout(()=>x(!1),1400))}async function Ae(e){return N.sendRoomEvent(`room:state`,{round:me(e),seq:e.seq})}async function je(){if(!N.userIdentity||!P||!Te){r(e(`game.zhajinhua.error.notEnoughPlayers`),`error`);return}try{let t=F.players.map(e=>({...e,chips:L?.players.find(t=>X(t.address,e.address))?.chips??1e3})),n=pe({roomCode:N.roomCode,players:t,hostAddress:N.userIdentity.address,previousSeq:L?.seq||0,previousWinner:L?.winner||``});j.current=n.hands,M.current.clear(),await Ae(n);for(let e of n.players){let t=a(JSON.stringify(n.hands[e.address]),{senderPrivateKey:P.private_key,recipientPublicKey:e.publicKey});await N.sendRoomEvent(`deal:private`,{roundId:n.roundId,recipient:e.address,senderPublicKey:P.public_key,encrypted:t})}k(e=>({...e,[n.roundId]:n.hands[N.userIdentity.address.toLowerCase()]})),r(e(`game.zhajinhua.toast.roundStarted`),`success`)}catch(t){r(t instanceof Error?t.message:e(`game.zhajinhua.error.startFailed`),`error`)}}async function $(e,t={}){if(!L||!N.userIdentity)return;let n=I({roundId:L.roundId,action:e,amount:t.amount,target:t.target});await N.sendRoomEvent(`player:action`,{actionEvent:n})}let Me=L?.status===`playing`?X(L.turnAddress,H)?e(`game.zhajinhua.status.yourTurn`):L.turnAddress?e(`game.zhajinhua.status.waitingPlayer`,{player:Q(L.turnAddress,F.players)}):e(`game.status.playing`):L?.status===`finished`?e(`game.status.finished`):e(`game.status.waitingStart`),Ne=we.filter(e=>!X(e.address,H));return(0,J.jsx)(p,{sidebar:({closeSidebar:e})=>(0,J.jsx)(g,{activeGame:`zhajinhua`,closeSidebar:e}),headerTitle:(0,J.jsx)(`h2`,{className:`header-title`,children:e(`game.zhajinhua.title`)}),headerRight:(0,J.jsxs)(`div`,{className:q.headerActions,children:[N.roomCode&&(0,J.jsxs)(`button`,{className:`btn btn-sm`,onClick:ke,children:[(0,J.jsx)(f,{size:14}),e(re?`common.copied`:`game.action.shareRoom`)]}),(0,J.jsx)(`button`,{className:`btn btn-icon`,onClick:()=>n(!t),title:e(`common.theme.toggle`),children:t?(0,J.jsx)(u,{size:16}):(0,J.jsx)(d,{size:16})})]}),children:(0,J.jsx)(`main`,{className:q.page,children:N.roomCode?(0,J.jsxs)(`div`,{className:q.board,children:[(0,J.jsxs)(`section`,{className:q.table,children:[L?.status===`finished`&&L.winner&&ce&&(0,J.jsxs)(`div`,{className:q.finishBanner,children:[(0,J.jsx)(`span`,{className:q.finishBannerIcon,children:`🏆`}),(0,J.jsx)(`span`,{children:e(`game.zhajinhua.result.winChips`,{player:Q(L.winner,F.players),amount:L.winAmount??0})})]}),L?.lastCompare&&ue&&(0,J.jsx)(Ce,{lastCompare:L.lastCompare,compareReveal:L.compareReveal||{},myAddress:H,myDealtHand:W,lobbyPlayers:F.players,onClose:()=>A(!1)}),(0,J.jsxs)(`div`,{className:q.tableCenter,children:[(0,J.jsx)(`span`,{children:e(`game.zhajinhua.pot`)}),(0,J.jsx)(`strong`,{children:L?.pot||0}),(0,J.jsx)(`small`,{children:e(`game.zhajinhua.currentBet`,{amount:L?.currentBet||0})})]}),(0,J.jsx)(`div`,{className:q.seats,children:F.players.map(t=>{let n=L?.players.find(e=>X(e.address,t.address)),r=L?.turnAddress===t.address,i=L?.winner===t.address,a=n?.status===`folded`;return(0,J.jsxs)(`div`,{className:Y(q.seat,r&&q.seatTurn,i&&q.seatWinner,a&&q.seatFolded),children:[(0,J.jsx)(`div`,{className:q.seatAvatar,children:(0,J.jsx)(`img`,{src:ie(t.address,t.avatar),alt:``})}),(0,J.jsxs)(`div`,{className:q.seatMain,children:[(0,J.jsx)(`strong`,{translate:`no`,children:t.name}),(0,J.jsx)(`span`,{translate:`no`,children:be(t.address)})]}),(0,J.jsxs)(`div`,{className:q.seatMeta,children:[(0,J.jsx)(`span`,{children:e(`game.zhajinhua.chips`,{amount:n?.chips??1e3})}),(0,J.jsx)(`span`,{children:n?.status===`folded`?e(`game.zhajinhua.player.folded`):n?.looked?e(`game.zhajinhua.player.looked`):e(L?`game.zhajinhua.player.inRound`:`game.status.waitingStart`)})]})]},t.address)})})]}),(0,J.jsxs)(`aside`,{className:q.panel,children:[(0,J.jsxs)(`div`,{className:q.panelSection,children:[(0,J.jsxs)(`div`,{className:q.panelTitle,children:[(0,J.jsx)(h,{size:16}),(0,J.jsx)(`span`,{children:e(`game.zhajinhua.myHand`)})]}),(0,J.jsx)(`div`,{className:q.hand,children:K?K.map(e=>{let t=Se(e),n=`${t.suit}${t.rank}`;return(0,J.jsxs)(`div`,{className:Y(q.card,q[t.color]),children:[(0,J.jsx)(`span`,{children:n}),(0,J.jsx)(`i`,{children:t.suit})]},e)}):[0,1,2].map(e=>(0,J.jsx)(`div`,{className:q.cardBack,children:(0,J.jsx)(h,{size:18})},e))}),(0,J.jsx)(`p`,{className:q.handLabel,children:K?de(K):e(W?`game.zhajinhua.hand.unlooked`:`game.zhajinhua.hand.waitingDeal`)})]}),(0,J.jsxs)(`div`,{className:q.panelSection,children:[(0,J.jsxs)(`div`,{className:q.panelTitle,children:[(0,J.jsx)(m,{size:16}),(0,J.jsx)(`span`,{children:e(`game.actions`)})]}),V?(0,J.jsxs)(`button`,{className:`btn btn-primary btn-full`,onClick:je,disabled:!Te||L?.status===`playing`,children:[(0,J.jsx)(ae,{size:16}),L?.status===`finished`?e(`game.action.nextRound`):e(`game.action.startRound`)]}):(0,J.jsx)(`p`,{className:q.muted,children:e(`game.waitingHost`)}),V&&L?.status===`finished`&&!Te&&(0,J.jsx)(`p`,{className:q.muted,children:e(`game.zhajinhua.error.tooManyLowChips`)}),(0,J.jsxs)(`div`,{className:q.actionGrid,children:[(0,J.jsxs)(`button`,{className:`btn btn-secondary`,disabled:!Z.includes(`look`),onClick:()=>$(`look`),children:[(0,J.jsx)(ne,{size:16}),e(`game.zhajinhua.action.look`)]}),(0,J.jsx)(`button`,{className:`btn btn-secondary`,disabled:!Z.includes(`call`),onClick:()=>$(`call`),children:e(`game.zhajinhua.action.call`)}),(0,J.jsx)(`button`,{className:`btn btn-secondary`,disabled:!Z.includes(`fold`),onClick:()=>$(`fold`),children:e(`game.zhajinhua.action.fold`)})]}),(0,J.jsxs)(`div`,{className:q.raiseRow,children:[(0,J.jsx)(`select`,{className:`input input-compact`,value:T,onChange:e=>E(Number(e.target.value)),children:oe.map(t=>(0,J.jsx)(`option`,{value:t,children:e(`game.zhajinhua.action.raiseOption`,{amount:t})},t))}),(0,J.jsx)(`button`,{className:`btn btn-secondary`,disabled:!Z.includes(`raise`),onClick:()=>$(`raise`,{amount:T}),children:e(`game.zhajinhua.action.raise`)})]}),(0,J.jsxs)(`div`,{className:q.raiseRow,children:[(0,J.jsxs)(`select`,{className:`input input-compact`,value:D,onChange:e=>O(e.target.value),children:[(0,J.jsx)(`option`,{value:``,children:e(`game.zhajinhua.action.comparePlaceholder`)}),Ne.map(e=>(0,J.jsx)(`option`,{value:e.address,children:e.name},e.address))]}),(0,J.jsx)(`button`,{className:`btn btn-secondary`,disabled:!Z.includes(`compare`)||!D,onClick:()=>$(`compare`,{target:D}),children:e(`game.zhajinhua.action.compare`)})]})]}),(0,J.jsxs)(`div`,{className:q.panelSection,children:[(0,J.jsx)(`div`,{className:q.panelTitle,children:e(`game.status.title`)}),(0,J.jsxs)(`div`,{className:q.statusGrid,children:[(0,J.jsx)(`span`,{children:e(`game.host`)}),(0,J.jsx)(`strong`,{children:R?be(R):`-`}),(0,J.jsx)(`span`,{children:e(`game.zhajinhua.myChips`)}),(0,J.jsx)(`strong`,{children:_e?.chips??1e3}),(0,J.jsx)(`span`,{children:e(`game.round`)}),(0,J.jsx)(`strong`,{children:Me}),(0,J.jsx)(`span`,{children:e(`game.hint`)}),(0,J.jsx)(`strong`,{children:L?.lastAction||e(`game.waitingPlayers`)})]})]})]})]}):(0,J.jsxs)(`section`,{className:q.entry,children:[(0,J.jsxs)(`div`,{className:q.entryBrand,children:[(0,J.jsx)(`div`,{className:q.cardMark,children:(0,J.jsx)(h,{size:48})}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`h1`,{children:e(`game.zhajinhua.hero.title`)}),(0,J.jsx)(`p`,{children:e(`game.hero.desc`)})]})]}),(0,J.jsxs)(`div`,{className:q.entryPanel,children:[(0,J.jsxs)(`div`,{className:q.accountLine,children:[(0,J.jsx)(`span`,{children:e(`game.currentAccount`)}),(0,J.jsx)(`strong`,{translate:`no`,children:N.userIdentity?.displayName||e(`web3.notSignedIn`)})]}),(0,J.jsxs)(`button`,{className:`btn btn-primary`,disabled:N.joining,onClick:De,children:[(0,J.jsx)(m,{size:16}),e(`game.action.createRoom`)]}),(0,J.jsxs)(`form`,{onSubmit:Oe,className:q.joinForm,children:[(0,J.jsxs)(`label`,{children:[e(`game.roomCode`),(0,J.jsx)(`input`,{value:v,maxLength:8,onChange:e=>y(e.target.value.toUpperCase()),placeholder:e(`game.roomCode.placeholder`)})]}),(0,J.jsx)(`button`,{className:`btn`,disabled:N.joining||!v,children:e(`game.action.joinRoom`)})]}),(0,J.jsx)(`p`,{className:q.status,children:N.isBackendReady?e(`game.status.nodeConnected`):e(`game.status.nodeConnecting`)})]})]})})})}function Ce({lastCompare:e,compareReveal:t,myAddress:n,myDealtHand:r,lobbyPlayers:i,onClose:a}){let{t:o}=l(),s=Q(e.initiator,i),c=Q(e.target,i),u=Q(e.winner,i),d=X(n,e.initiator),f=X(n,e.target),p=d||f;function m(e,i){return t[e]||(p&&X(e,n)&&i&&r?r:null)}let g=m(e.initiator,e.initiatorLooked),_=m(e.target,e.targetLooked);return(0,J.jsx)(`div`,{className:q.compareOverlay,onClick:a,children:(0,J.jsxs)(`div`,{className:q.compareBox,onClick:e=>e.stopPropagation(),children:[(0,J.jsx)(`div`,{className:q.compareTitle,children:o(`game.zhajinhua.compareResult`)}),(0,J.jsxs)(`div`,{className:q.comparePlayers,children:[(0,J.jsxs)(`div`,{className:Y(q.compareSide,X(e.winner,e.initiator)&&q.compareWinner),children:[(0,J.jsx)(`div`,{className:q.compareName,children:s}),(0,J.jsx)(`div`,{className:q.compareCards,children:g?g.map(e=>{let t=Se(e);return(0,J.jsxs)(`div`,{className:Y(q.card,q[t.color]),children:[(0,J.jsx)(`span`,{children:t.rank}),(0,J.jsx)(`i`,{children:t.suit})]},e)}):[0,1,2].map(e=>(0,J.jsx)(`div`,{className:q.cardBack,children:(0,J.jsx)(h,{size:18})},e))}),g&&(0,J.jsx)(`div`,{className:q.compareLabel,children:de(g)})]}),(0,J.jsx)(`div`,{className:q.compareVs,children:`VS`}),(0,J.jsxs)(`div`,{className:Y(q.compareSide,X(e.winner,e.target)&&q.compareWinner),children:[(0,J.jsx)(`div`,{className:q.compareName,children:c}),(0,J.jsx)(`div`,{className:q.compareCards,children:_?_.map(e=>{let t=Se(e);return(0,J.jsxs)(`div`,{className:Y(q.card,q[t.color]),children:[(0,J.jsx)(`span`,{children:t.rank}),(0,J.jsx)(`i`,{children:t.suit})]},e)}):[0,1,2].map(e=>(0,J.jsx)(`div`,{className:q.cardBack,children:(0,J.jsx)(h,{size:18})},e))}),_&&(0,J.jsx)(`div`,{className:q.compareLabel,children:de(_)})]})]}),(0,J.jsx)(`div`,{className:q.compareResult,children:o(`game.zhajinhua.result.winner`,{player:u})}),(0,J.jsx)(`button`,{className:`btn btn-sm`,onClick:a,children:o(`common.close`)})]})})}function Q(e,t){let n=e.toLowerCase();return t.find(e=>e.address===n)?.name||be(e)}var we=i(`/game/zhajinhua/`)({component:Z});export{we as Route};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e,o as t,t as n}from"./jsx-runtime-Bt-cYkS5.js";import{C as r,D as i,O as a,T as o,s}from"./ui-BpDGD3IR.js";import{a as ee}from"./i18n-NjvOSuV6.js";import{t as c}from"./download-jEPn2njL.js";import{t as l}from"./external-link-BFaoZeK0.js";import{t as te}from"./file-text-DPA1riJ_.js";import{t as u}from"./hard-drive-Dar_AZEq.js";import{n as ne,t as d}from"./triangle-alert-DGWc8ZHu.js";import{F as f,L as p,c as m,f as re,g as ie}from"./index-BZ-f0CZd.js";import{t as ae}from"./MarketingHeader-CrYsQsQ5.js";import{t as h}from"./format-CR8oUWq6.js";import{i as g,n as _,r as oe,t as se}from"./downloadValidation-DbVOwdmC.js";var ce=r(`circle-x`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m15 9-6 6`,key:`1uzhvr`}],[`path`,{d:`m9 9 6 6`,key:`z0biqf`}]]),v=r(`loader-circle`,[[`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`,key:`13zald`}]]),y=r(`log-in`,[[`path`,{d:`m10 17 5-5-5-5`,key:`1bsop3`}],[`path`,{d:`M15 12H3`,key:`6jk70r`}],[`path`,{d:`M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4`,key:`u53s6r`}]]),b=r(`wifi-off`,[[`path`,{d:`M12 20h.01`,key:`zekei9`}],[`path`,{d:`M8.5 16.429a5 5 0 0 1 7 0`,key:`1bycff`}],[`path`,{d:`M5 12.859a10 10 0 0 1 5.17-2.69`,key:`1dl1wf`}],[`path`,{d:`M19 12.859a10 10 0 0 0-2.007-1.523`,key:`4k23kn`}],[`path`,{d:`M2 8.82a15 15 0 0 1 4.177-2.643`,key:`1grhjp`}],[`path`,{d:`M22 8.82a15 15 0 0 0-11.288-3.764`,key:`z3jwby`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),x=t(e(),1),S=n(),C=1800;function w(e,t){return`most://${e}${t||``}`}function T(e,t){let n=e.trim().replace(/[\\/]+$/,``);return n?`${n}${n.includes(`\\`)?`\\`:`/`}downloads`:t}function E(e,t){let n=e[t];return typeof n==`string`?n:void 0}function D(e,t){let n=e[t];return typeof n==`number`&&Number.isFinite(n)?n:void 0}function le(e){let t;try{t=JSON.parse(e)}catch{return null}if(!t||typeof t!=`object`)return null;let n=t,r=E(n,`event`),i=n.data;if(!r||!i||typeof i!=`object`)return null;let a=i;return{event:r,payload:{taskId:E(a,`taskId`),percent:D(a,`percent`),loaded:D(a,`loaded`),total:D(a,`total`),file:E(a,`file`),fileName:E(a,`fileName`),error:E(a,`error`)}}}function O(){let{t:e}=ee(),{cid:t}=a({from:`/cid/$cid/`}),n=p({select:e=>e.searchStr}),r=m(e=>e.hasBackend),o=m(e=>e.addToast),f=m(e=>e.openConnectModal),E=s(e=>e.identity),D=s(e=>e.openLoginModal),O=(0,x.useMemo)(()=>w(t,n),[t,n]),k=(0,x.useMemo)(()=>g(O),[O]),A=(0,x.useMemo)(()=>se(O,e),[O,e]),fe=k.fileName||t,[j,M]=(0,x.useState)({status:`idle`,message:``}),[N,P]=(0,x.useState)(null),[F,I]=(0,x.useState)({status:`idle`,message:``}),[L,R]=(0,x.useState)(``),[z,B]=(0,x.useState)(0),[V,H]=(0,x.useState)(null),[U,W]=(0,x.useState)(null),[pe,G]=(0,x.useState)(``),[me,K]=(0,x.useState)(!1),q=(0,x.useRef)(0),J=(0,x.useRef)(null),Y=N?.fileName||fe,X=N?.size??U,Z=j.status===`available`||j.status===`already-local`,Q=F.status===`starting`||F.status===`downloading`,he=T(pe,e(`cid.saveToFallback`)),$=(0,x.useCallback)(async()=>{let t=q.current+1;if(q.current=t,R(``),B(0),H(null),W(null),I({status:`idle`,message:``}),A){P(null),M({status:`error`,message:A});return}if(r===null){P(null),M({status:`waiting-backend`,message:e(`cid.status.waitingBackend`)});return}if(r!==!0){P(null),M({status:`backend-missing`,message:e(`cid.status.backendMissing`)});return}if(!E){P(null),M({status:`login-required`,message:e(`cid.status.loginRequired`)});return}M({status:`checking`,message:e(`cid.status.checking`)}),P(null);try{let n=await _.checkDownload(O);if(q.current!==t)return;P(n),M({status:n.alreadyExists?`already-local`:`available`,message:n.alreadyExists?e(`cid.status.alreadyLocal`,{fileName:n.fileName}):e(`cid.status.available`,{fileName:n.fileName})})}catch(e){if(q.current!==t)return;M({status:`error`,message:await oe(e)}),P(null)}},[r,O,e,E,A]);(0,x.useEffect)(()=>{document.title=e(`cid.meta.title`)},[e]),(0,x.useEffect)(()=>{let e=()=>{J.current!==null&&(window.clearTimeout(J.current),J.current=null)},t=()=>{document.visibilityState===`hidden`&&(e(),K(!1))};return document.addEventListener(`visibilitychange`,t),window.addEventListener(`pagehide`,t),()=>{e(),document.removeEventListener(`visibilitychange`,t),window.removeEventListener(`pagehide`,t)}},[]),(0,x.useEffect)(()=>{$()},[$]),(0,x.useEffect)(()=>{if(r!==!0)return;let e=!1;return _.getDataPath().then(t=>{e||G(t.dataPath)}).catch(()=>{e||G(``)}),()=>{e=!0}},[r]),(0,x.useEffect)(()=>{if(!L||!E)return;let t=null,n=!1;return(async()=>{if(t=new WebSocket(await ie(`/ws`)),n){t.close();return}t.onmessage=t=>{let n=le(t.data);!n||n.payload.taskId!==L||(n.event===`download:progress`&&(B(n.payload.percent||0),H(n.payload.loaded??null),W(n.payload.total??null)),n.event===`download:status`&&I({status:`downloading`,message:n.payload.file?e(`cid.status.downloadingFile`,{fileName:n.payload.file}):e(`cid.status.downloading`)}),n.event===`download:success`&&(B(100),I({status:`completed`,message:e(`cid.status.downloadComplete`,{fileName:n.payload.fileName||Y})}),o(e(`cid.toast.downloadComplete`),`success`)),n.event===`download:error`&&(I({status:`error`,message:n.payload.error||e(`cid.status.downloadFailed`,{error:``})}),o(e(`cid.toast.downloadFailed`,{error:n.payload.error||e(`cid.errorFallback`)}),`error`)),n.event===`download:cancelled`&&(I({status:`cancelled`,message:e(`cid.status.cancelled`)}),o(e(`cid.toast.cancelled`),`warning`)))}})(),()=>{n=!0,t?.close()}},[o,Y,e,L,E]);let ge=async()=>{if(!E){D();return}if(r!==!0){f();return}if(!(!Z||Q)){I({status:`starting`,message:e(`cid.status.startingDownload`)}),B(0);try{let t=await _.downloadFile(O);if(t.alreadyExists){I({status:`completed`,message:e(`cid.status.alreadyLocal`,{fileName:t.fileName||Y})}),o(e(`cid.toast.alreadyLocal`),`warning`);return}t.taskId&&(R(t.taskId),I({status:`downloading`,message:e(`cid.status.downloading`)}),o(e(`cid.toast.downloadStarted`),`info`))}catch(t){let n=await re(t,e(`cid.status.downloadFailed`,{error:e(`cid.errorFallback`)}));I({status:`error`,message:n}),o(n,`error`)}}},_e=()=>{K(!1),J.current!==null&&window.clearTimeout(J.current),J.current=window.setTimeout(()=>{J.current=null,document.visibilityState!==`hidden`&&K(!0)},C)},ve=async()=>{L&&await _.cancelDownload(L).catch(()=>{})},ye=ue(j.status,F.status);return(0,S.jsxs)(`div`,{className:`cid-layout`,children:[(0,S.jsx)(ae,{}),(0,S.jsx)(`main`,{className:`cid-page`,children:(0,S.jsxs)(`section`,{className:`cid-shell`,children:[(0,S.jsxs)(`div`,{className:`cid-heading`,children:[(0,S.jsx)(`span`,{className:`cid-kicker`,children:e(`cid.kicker`)}),(0,S.jsx)(`h1`,{children:e(`cid.title`)}),(0,S.jsx)(`p`,{children:e(`cid.subtitle`)})]}),(0,S.jsxs)(`div`,{className:`cid-panel`,children:[(0,S.jsxs)(`div`,{className:`cid-handoff`,"aria-label":e(`cid.handoff.title`),children:[(0,S.jsxs)(`div`,{className:`cid-handoff-copy`,children:[(0,S.jsx)(`p`,{className:`cid-handoff-title`,children:e(`cid.handoff.title`)}),(0,S.jsx)(`p`,{children:e(`cid.handoff.desc`)})]}),(0,S.jsxs)(`a`,{className:`btn btn-primary`,href:O,onClick:_e,children:[(0,S.jsx)(l,{size:16}),e(`cid.handoff.action`)]})]}),me&&(0,S.jsxs)(`div`,{className:`cid-handoff-fallback`,role:`status`,children:[(0,S.jsx)(d,{size:18}),(0,S.jsx)(`p`,{children:e(`cid.handoff.fallback`)}),(0,S.jsxs)(i,{to:`/download/`,className:`btn btn-secondary`,children:[(0,S.jsx)(c,{size:16}),e(`cid.handoff.downloadAction`)]})]}),(0,S.jsxs)(`div`,{className:`cid-status`,children:[(0,S.jsx)(`span`,{className:`cid-status-icon ${j.status}`,children:ye}),(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`p`,{className:`cid-status-label`,children:de(j.status,e)}),(0,S.jsx)(`p`,{className:`cid-status-message`,children:j.message})]})]}),(0,S.jsxs)(`dl`,{className:`cid-details`,children:[(0,S.jsxs)(`div`,{children:[(0,S.jsxs)(`dt`,{children:[(0,S.jsx)(te,{size:16}),e(`cid.fileNameLabel`)]}),(0,S.jsx)(`dd`,{children:Y})]}),(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`dt`,{children:e(`cid.cidLabel`)}),(0,S.jsx)(`dd`,{className:`cid-mono`,children:t})]}),(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`dt`,{children:e(`cid.sizeLabel`)}),(0,S.jsx)(`dd`,{children:X?h(X):e(`cid.unknownSize`)})]}),(0,S.jsxs)(`div`,{children:[(0,S.jsxs)(`dt`,{children:[(0,S.jsx)(u,{size:16}),e(`cid.saveToLabel`)]}),(0,S.jsx)(`dd`,{children:he})]})]}),F.status!==`idle`&&(0,S.jsxs)(`div`,{className:`cid-download-state ${F.status}`,children:[(0,S.jsx)(`p`,{children:F.message}),(F.status===`starting`||F.status===`downloading`)&&(0,S.jsxs)(`div`,{className:`cid-progress`,children:[(0,S.jsx)(`progress`,{className:`cid-progress-bar`,value:z,max:100}),(0,S.jsx)(`span`,{children:V!==null&&U!==null?`${h(V)} / ${h(U)}`:`${z}%`})]})]}),(0,S.jsxs)(`div`,{className:`cid-actions`,children:[j.status===`login-required`&&(0,S.jsxs)(`button`,{className:`btn btn-primary`,onClick:D,children:[(0,S.jsx)(y,{size:16}),e(`cid.loginAction`)]}),j.status===`backend-missing`&&(0,S.jsxs)(`button`,{className:`btn btn-primary`,onClick:f,children:[(0,S.jsx)(b,{size:16}),e(`cid.connectAction`)]}),(0,S.jsxs)(`button`,{className:`btn btn-primary`,disabled:!Z||Q,onClick:ge,children:[Q?(0,S.jsx)(v,{className:`cid-spin-icon`,size:16}):(0,S.jsx)(c,{size:16}),e(Q?`cid.downloadingAction`:`cid.startAction`)]}),L&&F.status===`downloading`&&(0,S.jsxs)(`button`,{className:`btn btn-secondary`,onClick:ve,children:[(0,S.jsx)(ce,{size:16}),e(`cid.cancelAction`)]}),(0,S.jsxs)(`button`,{className:`btn btn-secondary`,disabled:j.status===`checking`,onClick:$,children:[(0,S.jsx)(ne,{size:16}),e(`cid.retryAction`)]}),(0,S.jsx)(i,{to:`/app/`,className:`btn btn-secondary`,children:e(`cid.openAppAction`)})]})]})]})})]})}function ue(e,t){return t===`completed`?(0,S.jsx)(f,{size:28}):t===`error`||e===`error`?(0,S.jsx)(d,{size:28}):e===`checking`||e===`waiting-backend`||t===`starting`||t===`downloading`?(0,S.jsx)(v,{size:28}):e===`backend-missing`?(0,S.jsx)(b,{size:28}):e===`login-required`?(0,S.jsx)(y,{size:28}):(0,S.jsx)(f,{size:28})}function de(e,t){switch(e){case`checking`:return t(`cid.label.checking`);case`available`:return t(`cid.label.available`);case`already-local`:return t(`cid.label.alreadyLocal`);case`login-required`:return t(`cid.label.loginRequired`);case`backend-missing`:return t(`cid.label.backendMissing`);case`waiting-backend`:return t(`cid.label.waitingBackend`);case`error`:return t(`cid.label.error`);default:return t(`cid.label.idle`)}}var k=o(`/cid/$cid/`)({component:O});export{k as Route};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e,o as t,t as n}from"./jsx-runtime-Bt-cYkS5.js";import{C as r,S as i,T as a,a as o,n as s,r as c,s as l,t as u}from"./ui-BpDGD3IR.js";import{a as d}from"./i18n-NjvOSuV6.js";import{t as ee}from"./arrow-right-BU9c_SL4.js";import{n as te,r as ne}from"./LanguageToggle-CSQtRZ3A.js";import{t as f}from"./circle-alert-iuHzciph.js";import{t as p}from"./download-jEPn2njL.js";import{t as m}from"./file-text-DPA1riJ_.js";import{a as h,i as g,n as re,r as ie,t as ae}from"./FilePreviewOverlay-D8H61qbp.js";import{t as oe}from"./loader-BXQtdens.js";import{i as se,n as ce,t as le}from"./SidebarHomeLink-BdsUM4Kt.js";import{t as ue}from"./message-square-Dp09WY1I.js";import{t as _}from"./music-B19Tg557.js";import{t as de}from"./OpenSidebarButton-DnEgqP0S.js";import{t as fe}from"./plus-4hygj-1Z.js";import{t as pe}from"./search-DSkiWdvX.js";import{t as me}from"./trash-2-V12tJ8lI.js";import{N as v,c as y,f as he,i as ge,l as _e}from"./index-BZ-f0CZd.js";import{t as ve}from"./format-CR8oUWq6.js";import{t as ye}from"./SidebarAccount-B4OAl0as.js";import{n as b,r as be,t as xe}from"./downloadValidation-DbVOwdmC.js";import{t as Se}from"./LogoIcon-B2fFe0l1.js";import{i as x,t as Ce}from"./userProfile-DBkH4s29.js";import{t as we}from"./useChannelMessages-B6RMaNDH.js";var Te=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`}]]),Ee=r(`ellipsis`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`19`,cy:`12`,r:`1`,key:`1wjl8i`}],[`circle`,{cx:`5`,cy:`12`,r:`1`,key:`1pcz8c`}]]),De=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`}]]),Oe=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`}]]),S=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`}]]),ke=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`}]]),C=t(e(),1),w=n();function Ae(e){return String(e||``).split(`/`).pop()||e}function je(e){return e===`image`?(0,w.jsx)(g,{size:20}):e===`video`?(0,w.jsx)(h,{size:20}):e===`audio`?(0,w.jsx)(_,{size:20}):(0,w.jsx)(m,{size:20})}function Me({attachment:e,status:t=`idle`,pending:n=!1,onOpen:r}){let{t:i}=d(),a=t===`checking`,o=`ui-file-action chat-attachment-action ${t===`error`?`error`:t===`available`?`available`:``}`.trim(),s=Number.isFinite(e.size)&&e.size>0?ve(e.size):i(`chat.mostboxFile`);return(0,w.jsxs)(`button`,{type:`button`,className:`ui-file-card chat-attachment-card`,onClick:()=>r?.(e),disabled:n||a,title:e.link,translate:`no`,children:[(0,w.jsx)(`span`,{className:`ui-file-icon chat-attachment-icon ${e.kind}`,children:a?(0,w.jsx)(oe,{size:20,className:`ui-spinner chat-attachment-spinner`}):je(e.kind)}),(0,w.jsxs)(`span`,{className:`ui-file-info chat-attachment-info`,children:[(0,w.jsx)(`span`,{className:`ui-file-name chat-attachment-name`,translate:`no`,children:Ae(e.fileName)}),(0,w.jsx)(`span`,{className:`ui-file-meta chat-attachment-meta`,translate:`yes`,children:n?i(`chat.sending`):s})]}),(0,w.jsx)(`span`,{className:o,translate:`yes`,children:a?i(`chat.checking`):t===`available`?(0,w.jsx)(v,{size:16}):t===`error`?(0,w.jsx)(f,{size:17}):(0,w.jsx)(p,{size:16})})]})}var T=[{key:`image`,labelKey:`chat.attachment.image`,accept:`image/*`,icon:g},{key:`video`,labelKey:`chat.attachment.video`,accept:`video/*`,icon:h},{key:`file`,labelKey:`chat.attachment.file`,accept:``,icon:m}],Ne=T.map(e=>e.accept).join(`,`);function Pe({children:e}){return(0,w.jsx)(`div`,{className:`message-bubble`,translate:`no`,children:e})}function Fe({children:e}){return(0,w.jsx)(`div`,{className:`message-bubble has-attachment`,children:e})}function Ie({variant:e,pending:t=!1,avatarSrc:n,author:r,time:i,children:a}){return(0,w.jsxs)(`div`,{className:[`chat-message`,e,t?`pending`:``].filter(Boolean).join(` `),children:[(0,w.jsx)(`img`,{className:`msg-avatar`,src:n,alt:`avatar`}),(0,w.jsxs)(`div`,{className:`msg-content`,children:[(0,w.jsx)(`span`,{className:`message-author`,translate:`no`,children:r}),a,(0,w.jsx)(`span`,{className:`message-time`,children:i})]})]})}function Le({active:e=!1,pinned:t=!1,unread:n=!1,title:r,onSelect:i,onTogglePin:a,onRename:o,onLeave:s}){let{t:c}=d(),l=!!(a||o||s);return(0,w.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,w.jsxs)(`span`,{className:`chat-channel-icon-wrap`,children:[(0,w.jsx)(ue,{size:16}),n&&(0,w.jsx)(`span`,{className:`chat-channel-unread-dot`,title:c(`chat.unread`),"aria-hidden":`true`})]}),(0,w.jsx)(`span`,{className:`chat-channel-title`,children:(0,w.jsx)(`span`,{className:`chat-channel-title-text`,translate:`no`,children:r})}),l&&(0,w.jsx)(u,{ariaLabel:c(`chat.channelActions`),className:`channel-actions-anchor`,placement:`bottom-end`,items:[{key:`pin`,label:c(t?`chat.unpin`:`chat.pin`),icon:t?(0,w.jsx)(S,{size:16}):(0,w.jsx)(Oe,{size:16}),onSelect:()=>a?.()},{key:`rename`,label:c(`chat.rename`),icon:(0,w.jsx)(ie,{size:16}),onSelect:()=>o?.()},{key:`delete`,label:c(`chat.delete`),icon:(0,w.jsx)(me,{size:16}),onSelect:()=>s?.()}],renderTrigger:e=>(0,w.jsx)(`button`,{...e,className:`leave-channel-btn channel-actions-trigger`,title:c(`common.moreActions`),"aria-label":c(`common.moreActions`),children:(0,w.jsx)(Ee,{size:16})})})]})}function Re({members:e}){let{t}=d();return e.length===0?(0,w.jsx)(`div`,{className:`ui-empty-inline channel-members-empty`,children:t(`chat.noMembers`)}):(0,w.jsx)(`div`,{className:`channel-members-grid`,children:e.map(e=>(0,w.jsxs)(`div`,{className:`channel-member`,children:[(0,w.jsx)(`img`,{className:`channel-member-avatar`,src:e.avatarSrc,alt:`avatar`}),(0,w.jsx)(`span`,{className:`channel-member-name`,translate:`no`,children:e.name})]},e.id))})}function ze({message:e,placeholder:t,disabled:n=!1,isPublishingAttachment:r=!1,attachmentButtonTitle:i,attachmentInputRef:a,onMessageChange:o,onSend:s,onSelectAttachmentFiles:c}){let{t:l}=d(),te=n||r,ne=n||!e.trim(),f=i||l(`chat.attachment.add`);function p(e,t){t?.(e.currentTarget.files),e.currentTarget.value=``}function m(t){t.key===`Enter`&&e.trim()&&s()}function h(e){if(te)return;let t=a?.current;t&&(t.accept=e,t.click())}return(0,w.jsxs)(`div`,{className:`chat-input-area`,children:[(0,w.jsx)(`input`,{ref:a,type:`file`,accept:Ne,className:`chat-file-input`,onChange:e=>p(e,c)}),(0,w.jsx)(u,{ariaLabel:l(`chat.attachmentType`),placement:`top-start`,disabled:te,items:T.map(e=>{let t=e.icon;return{key:e.key,label:l(e.labelKey),icon:(0,w.jsx)(t,{size:16}),onSelect:()=>h(e.accept)}}),renderTrigger:e=>(0,w.jsx)(`button`,{...e,className:`btn btn-circle chat-tool-btn`,"aria-label":f,children:r?(0,w.jsx)(oe,{size:18,className:`ui-spinner chat-attachment-spinner`}):(0,w.jsx)(fe,{size:18})})}),(0,w.jsx)(`input`,{type:`text`,className:`input input-pill`,placeholder:t,value:e,disabled:n,onChange:e=>o(e.target.value),onKeyDown:m}),(0,w.jsx)(`button`,{type:`button`,className:`btn btn-circle btn-primary send-btn`,onClick:s,disabled:ne,title:l(`chat.sendMessage`),children:(0,w.jsx)(ee,{size:18})})]})}var E=`mostbox.chat.lastReadAt`;function D(e){return Date.parse(e?.lastMessageAt||``)||Date.parse(e?.createdAt||``)||0}function Be(e){let t=String(e||``).trim().toLowerCase();return t?`${E}:${t}`:``}function O(e,t=Date.now()){let n=Number(e);return Math.max(0,Math.floor(Number.isFinite(n)&&n>0?n:t))}function Ve(e,t=k()){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 He(e,t,n=k()){if(!(!e||!n))try{n.setItem(e,JSON.stringify(t))}catch{}}function Ue(e,t,n=Date.now(),r=Date.now()){if(!t)return{changed:!1,value:e};let i=O(n,r);return(e[t]||0)>=i?{changed:!1,value:e}:{changed:!0,value:{...e,[t]:i}}}function We(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]=O(D(e),n),r=!0)}return{changed:r,value:r?i:e}}function Ge(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=O(n,o),c=t===r,l=String(i||``).toLowerCase()===String(a||``).toLowerCase();if(c||l)return{...Ue(e,t,s,o),notify:!1};let u=e[t]||0;if(u<s)return{changed:!1,notify:!0,value:e};let d=Math.max(0,s-1);return u===d?{changed:!1,notify:!0,value:e}:{changed:!0,notify:!0,value:{...e,[t]:d}}}function Ke(e,t){let n=e?.channelKey||e?.name;return D(e)>(t[n]||0)}function k(){if(!(typeof window>`u`))return window.localStorage}var qe=3,Je=30,Ye=/^[a-zA-Z0-9_-]+$/,Xe=1e4,Ze=12e3,Qe=1200;function A(e){return e?.channelKey||e?.name||``}function j(e){return e?.channelId||e?.name||``}function M(e){return e?.remark||j(e)}function $e(){return typeof window>`u`?``:(new URLSearchParams(window.location.search).get(`channel`)||``).trim()}var et=`chat-file`;function tt(e,t){return e.type.startsWith(`image/`)?`image`:e.type.startsWith(`video/`)?`video`:e.type.startsWith(`audio/`)?`audio`:e.type.startsWith(`text/`)?`text`:re(t)}function nt(e){return e?`${e.slice(0,6)}...${e.slice(-4)}`:`Unknown`}function rt(e){return/#[a-fA-F0-9]{4}$/.test(String(e||``).trim())}function it(){if(typeof window>`u`)return;let e=window;return e.AudioContext||e.webkitAudioContext}function at(){let e=y(e=>e.isDarkMode),t=y(e=>e.setIsDarkMode),n=y(e=>e.hasBackend),r=y(e=>e.addToast),a=y(e=>e.openConnectModal),u=l(e=>e.identity),ee=l(e=>e.openLoginModal),[f,p]=(0,C.useState)([]),[m,h]=(0,C.useState)(null),[g,_]=(0,C.useState)(``),[me,v]=(0,C.useState)(!1),[ve,Ee]=(0,C.useState)(``),[Oe,S]=(0,C.useState)(``),[je,T]=se(!1),[Ne,E]=(0,C.useState)(``),[O,k]=(0,C.useState)(!1),[at,ot]=(0,C.useState)(!1),[st,ct]=se(!1),[lt,N]=(0,C.useState)(null),[ut,dt]=(0,C.useState)(null),[ft,P]=(0,C.useState)(!1),[pt,mt]=(0,C.useState)(``),[ht,gt]=(0,C.useState)(!1),[_t,vt]=(0,C.useState)(null),[yt,bt]=(0,C.useState)(!1),[F,I]=(0,C.useState)({}),[L,R]=(0,C.useState)(null),[xt,St]=(0,C.useState)(!1),[Ct,wt]=(0,C.useState)(!1),[Tt,z]=(0,C.useState)({}),B=u?.identity===`user`,Et=B&&!Ct?u.logo:``,Dt=(0,C.useRef)(null),Ot=(0,C.useRef)(null),kt=(0,C.useRef)(``),At=(0,C.useRef)(new Set),jt=(0,C.useRef)(new Set),V=(0,C.useRef)(null),H=(0,C.useRef)(!1),Mt=(0,C.useRef)(0),U=(0,C.useRef)(new Map),W=(0,C.useRef)(new Set),G=n===!0,{t:K,compareStrings:Nt,formatDate:Pt,formatTime:Ft}=d(),q=(0,C.useCallback)(async(e,t)=>{r(await he(e,t),`error`)},[r]),J=(0,C.useMemo)(()=>Be(u?.address),[u?.address]),It=(0,C.useCallback)((e,t=Date.now())=>{e&&z(n=>{let r=Ue(n,e,t);return r.changed?(He(J,r.value),r.value):n})},[J]),Y=(0,C.useCallback)(()=>{if(H.current||typeof window>`u`)return;let e=it();if(e)try{let t=V.current||new e;V.current=t,t.state===`suspended`&&t.resume().catch(()=>{}),H.current=!0}catch{}},[]),Lt=(0,C.useCallback)(()=>{if(!H.current)return;let e=Date.now();if(e-Mt.current<Qe)return;Mt.current=e;let t=it();if(t)try{let e=V.current||new t;if(V.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{}},[]);function Rt(e,t){switch(e){case`channel:message`:{let e=t?.channelKey||t?.channel,n=t?.message,r=Number(n?.timestamp)||Date.now();if(e){p(t=>t.map(t=>A(t)===e?{...t,lastMessageAt:new Date(r).toISOString()}:t));let t=e===kt.current;z(i=>{let a=Ge(i,{channelName:e,messageTime:r,activeChannelName:t?e:``,messageAuthor:n?.author,userAddress:u?.address});return a.changed&&He(J,a.value),a.notify&&Lt(),a.changed?a.value:i})}break}case`channel:peer:online`:case`channel:peer:offline`:m&&x.getChannelPeers(A(m)).catch(e=>{console.warn(`[Chat] Failed to fetch peers on event:`,e.message)});break;case`channel:joined`:case`channel:left`:$();break;case`user:metadata:updated`:t?.scope===`channels`&&$();break;case`download:success`:{let e=U.current.get(t.taskId);e&&(U.current.delete(t.taskId),W.current.delete(e.cid),I(t=>({...t,[e.cid]:{status:`available`}})),r(K(`chat.attachment.downloadCompleted`,{fileName:t.fileName||Ae(e.fileName)}),`success`),Gt(e,t.fileName||e.fileName));break}case`download:error`:case`download:cancelled`:{let n=U.current.get(t.taskId);n&&(U.current.delete(t.taskId),W.current.delete(n.cid),I(r=>({...r,[n.cid]:{status:`error`,message:e===`download:cancelled`?K(`chat.attachment.downloadCancelled`):t.error||K(`chat.attachment.downloadFailed`)}})),r(e===`download:cancelled`?K(`chat.attachment.downloadCancelled`):t.error||K(`chat.attachment.downloadFailed`),`error`));break}}}let zt=(0,C.useMemo)(()=>f.map(e=>A(e)),[f]),{clearMessages:Bt,messages:X,sendMessage:Vt,syncMessages:Ht}=we({isReady:G,enabled:!!u,channelName:A(m),extraSubscribedChannelNames:zt,peerId:Ne,waitForPeerId:!0,onSyncError:e=>q(e,K(`chat.error.messages`)),onSocketEvent:Rt,onReconnect:$}),Ut=(0,C.useMemo)(()=>{let e=new Map;return X.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)},[X]);function Z(){return G?!0:(a(),!1)}function Q(){return u?!0:(ee(),!1)}(0,C.useEffect)(()=>{let e=()=>{_($e())};return e(),window.addEventListener(`popstate`,e),()=>window.removeEventListener(`popstate`,e)},[]),(0,C.useEffect)(()=>{u&&_($e())},[u?.address]),(0,C.useEffect)(()=>{wt(!1)},[u?.logo]),(0,C.useEffect)(()=>{kt.current=A(m)},[m]),(0,C.useEffect)(()=>{z(Ve(J))},[J]),(0,C.useEffect)(()=>{!J||f.length===0||z(e=>{let t=We(e,f);return t.changed&&He(J,t.value),t.changed?t.value:e})},[J,f]),(0,C.useEffect)(()=>(window.addEventListener(`pointerdown`,Y,{passive:!0}),window.addEventListener(`keydown`,Y),()=>{window.removeEventListener(`pointerdown`,Y),window.removeEventListener(`keydown`,Y)}),[Y]),(0,C.useEffect)(()=>()=>{V.current?.close().catch(()=>{}),V.current=null,H.current=!1},[]),(0,C.useEffect)(()=>{Dt.current?.scrollIntoView({behavior:`smooth`})},[X]),(0,C.useEffect)(()=>{if(!G){E(``);return}_e.get(`/api/node-id`).json().then(e=>E(e.id)).catch(e=>{console.warn(`[Chat] Failed to fetch node ID:`,e.message),q(e,K(`chat.error.nodeId`))})},[G,q,K]),(0,C.useEffect)(()=>{G&&u?(v(!1),$()):v(!1)},[n,G,u?.address]),(0,C.useEffect)(()=>{if(m&&G){let e=A(m);Ht(e,{replace:!0}),x.getChannelPeers(e).catch(()=>{})}},[m,n,G,Ht]),(0,C.useEffect)(()=>{if(!g)return;if(!u){jt.current.has(g)||(jt.current.add(g),ee());return}if(!G||!me)return;let e=f.find(e=>A(e)===g)||f.find(e=>j(e)===g);if(e&&(!m||A(m)!==A(e))){Yt(e);return}if(e&&m&&A(m)===A(e)&&(m.createdAt!==e.createdAt||m.coreKey!==e.coreKey||m.lastMessageAt!==e.lastMessageAt||m.pinned!==e.pinned||m.remark!==e.remark||m.type!==e.type)){h(e);return}if(e)return;let t=`${u.address}:${g}`;if(At.current.has(t)||O)return;let n=Wt(g);if(At.current.add(t),n){r(n,`error`);return}Qt(g)},[f,m,g,me,G,O,u?.address]),(0,C.useEffect)(()=>{u||(p([]),v(!1),h(null),_($e()),dt(null),Bt(),S(``),E(``),P(!1),vt(null),I({}),z({}),W.current.clear(),U.current.clear())},[Bt,u?.address]);function Wt(e){return e.length<qe?K(`chat.validation.nameMin`,{count:qe}):e.length>Je?K(`chat.validation.nameMax`,{count:Je}):e.includes(`.`)?K(`chat.validation.dotReserved`):Ye.test(e)?``:K(`chat.validation.allowedChars`)}async function $(){if(!G){v(!1);return}try{p(await x.getChannels()),v(!0)}catch(e){p([]),v(!1),await q(e,K(`chat.error.channelList`))}}function Gt(e,t=e.fileName){let n=re(t);vt({cid:e.cid,fileName:t,subtype:n===`file`?e.kind:n})}async function Kt(e){let t=xe(e.link,K);if(t)return I(n=>({...n,[e.cid]:{status:`error`,message:t}})),!1;try{I(t=>({...t,[e.cid]:{status:`checking`}}));let t=await b.checkDownload(e.link,{timeout:Xe,requestTimeout:Ze});return I(n=>({...n,[e.cid]:{status:`available`,message:t.alreadyExists?K(`chat.attachment.localAvailable`):K(`chat.attachment.previewAvailable`)}})),!0}catch(t){let n=await be(t);return I(t=>({...t,[e.cid]:{status:`error`,message:n}})),!1}}async function qt(e){R(null),await Kt(e)&&await Jt(e)}async function Jt(e){if(!W.current.has(e.cid)){W.current.add(e.cid),I(t=>({...t,[e.cid]:{status:`available`}}));try{let t=await b.downloadFile(e.link);if(t.alreadyExists||t.fileName){W.current.delete(e.cid),I(t=>({...t,[e.cid]:{status:`available`}})),Gt({...e,fileName:t.fileName||e.fileName},t.fileName||e.fileName);return}t.taskId&&(U.current.set(t.taskId,e),r(K(`chat.attachment.downloadStarted`),`success`))}catch(t){let n=await be(t);W.current.delete(e.cid),I(t=>({...t,[e.cid]:{status:`error`,message:n}}))}}}async function Yt(e){if(!Q()||!Z())return;let t=A(e);It(t,Math.max(D(e),Date.now())),h(e),_(t),window.history.pushState({},``,`?channel=${encodeURIComponent(t)}`)}async function Xt(e,t){if(t&&t.stopPropagation(),Q()&&Z()&&!at){ot(!0);try{if(await x.leaveChannel(e),A(m)===e){h(null),_(``),Bt();let e=new URL(window.location.href);e.searchParams.delete(`channel`),window.history.pushState({},``,e.pathname)}$(),ct.close(),N(null)}catch(e){await q(e,K(`chat.error.leave`))}finally{ot(!1)}}}async function Zt(e){if(!Q()||!Z())return;let t=!e.pinned,n=A(e);try{let e=await x.setChannelPinned(n,t);p(t=>t.map(t=>A(t)===n?{...t,pinned:e.pinned}:t)),h(t=>t&&A(t)===n?{...t,pinned:e.pinned}:t)}catch(e){await q(e,K(t?`chat.error.pin`:`chat.error.unpin`))}}async function Qt(e){let t=e.trim();if(!t||O)return;let n=Wt(t);if(n){r(n,`error`);return}if(Q()&&Z()){k(!0);try{let e=await x.createChannel(t,`public`,Ce(u)),n=e.channelKey||e.key||e.name||t,r=f.find(e=>A(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},a=A(i);p(e=>e.some(e=>A(e)===a)?e.map(e=>A(e)===a?{...e,...i}:e):[...e,i]),T.close(),await Yt(i),$()}catch(e){await q(e,K(`chat.error.join`))}finally{k(!1)}}}async function $t(e,t){if(!e.trim()||!m||!Q()||!Z())return!1;let n=e.trim(),r=A(m);try{let e=await Vt({channelName:r,content:n,attachment:t});return p(t=>t.map(t=>A(t)===r?{...t,lastMessageAt:new Date(Number(e?.timestamp)||Date.now()).toISOString()}:t)),e&&It(r,Number(e.timestamp)||Date.now()),!0}catch(e){return await q(e,K(`chat.error.send`)),!1}}async function en(){if(!Oe.trim())return;let e=Oe.trim();S(``),await $t(e)}function tn(e,t){return`${et}/${e}/${t}`}async function nn(e){if(!(!e||e.length===0||!m)&&Q()&&Z()&&!yt){bt(!0);try{for(let t of Array.from(e)){let e=tn(j(m),t.name),n=await b.publishFile(t,e),i=n.fileName||e,a=n.link||`most://${n.cid}?filename=${encodeURIComponent(i)}`;await $t(a,{kind:tt(t,i),cid:n.cid,fileName:i,link:a,mimeType:t.type||void 0,size:t.size})&&r(K(`chat.attachment.published`,{fileName:Ae(i)}),`success`)}}catch(e){await q(e,K(`chat.error.attachmentSend`))}finally{bt(!1)}}}async function rn(e){if(!Q()||!Z())return;let t=F[e.cid];if(t?.status!==`checking`){if(t?.status===`error`){R(e);return}if(t?.status!==`available`){await Kt(e)&&await Jt(e);return}await Jt(e)}}async function an(e,t){if(!Q()||!Z())return;let n=A(e),r=await x.setChannelRemark(n,t);return p(e=>e.map(e=>A(e)===n?{...e,remark:r.remark}:e)),h(e=>e&&A(e)===n?{...e,remark:r.remark}:e),r.remark}async function on(){if(m)try{await an(m,pt)}catch(e){await q(e,K(`chat.error.remark`))}}async function sn(e){if(!(!ut||ht)){gt(!0);try{await an(ut,e),dt(null)}catch(e){await q(e,K(`chat.error.rename`))}finally{gt(!1)}}}function cn(e){if(!e.attachment)return(0,w.jsx)(Pe,{children:e.content});let t=e.attachment,n=F[t.cid]?.status;return(0,w.jsx)(Fe,{children:(0,w.jsx)(Me,{attachment:t,status:n,pending:e.pending,onOpen:rn})})}function ln(e,t){let n=String(e||``).trim();return n?xt?rt(n)?n:t?`${n}#${t.slice(-4).toUpperCase()}`:n:n.replace(/#[a-fA-F0-9]{4}$/,``):nt(t)}function un(){return(0,w.jsx)(Re,{members:Ut.map(e=>({id:e.address,name:ln(e.displayName,e.address),avatarSrc:ge(e.address,e.avatar)}))})}let dn=B&&!!g&&!m,fn=m?(0,w.jsx)(`h2`,{className:`header-title`,translate:`no`,children:M(m)}):(0,w.jsx)(`h2`,{className:`header-title`,children:K(`chat.title`)}),pn=ve.trim().toLowerCase(),mn=(0,C.useMemo)(()=>[...f].sort((e,t)=>{let n=Number(!!t.pinned)-Number(!!e.pinned);if(n!==0)return n;let r=D(t)-D(e);return r===0?Nt(M(e),M(t)):r}),[f,Nt]),hn=pn?mn.filter(e=>[M(e),j(e),A(e)].some(e=>e.toLowerCase().includes(pn))):mn;return(0,w.jsxs)(ce,{className:`chat-app-layout`,defaultHide:B,sidebar:({closeSidebar:e})=>(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(le,{onNavigate:e}),(0,w.jsx)(`div`,{className:`chat-channel-search`,children:(0,w.jsxs)(`div`,{className:`ui-input-control`,children:[(0,w.jsx)(pe,{className:`ui-input-icon`,size:15}),(0,w.jsx)(`input`,{type:`search`,className:`input input-compact`,placeholder:K(`chat.search.placeholder`),value:ve,onChange:e=>Ee(e.target.value),"aria-label":K(`chat.search.placeholder`)})]})}),(0,w.jsx)(`nav`,{className:`sidebar-nav`,children:f.length===0?(0,w.jsx)(`div`,{className:`sidebar-empty-state`,children:(0,w.jsx)(`p`,{children:K(`chat.empty.noChannels`)})}):hn.length===0?(0,w.jsx)(`div`,{className:`sidebar-empty-state`,children:(0,w.jsx)(`p`,{children:K(`chat.empty.noMatches`)})}):hn.map(t=>(0,w.jsx)(Le,{active:A(m)===A(t),pinned:!!t.pinned,unread:Ke(t,Tt),title:M(t),onSelect:()=>{Yt(t),e()},onTogglePin:()=>void Zt(t),onRename:()=>dt(t),onLeave:()=>{N(t),ct.open()}},A(t)))}),(0,w.jsxs)(`button`,{className:`ui-action-dashed create-channel-btn`,onClick:()=>{!Q()||!Z()||T.open()},children:[(0,w.jsx)(fe,{size:16}),K(`chat.joinChannel`)]}),(0,w.jsx)(ye,{})]}),headerTitle:fn,sidebarToggleReplacement:B?(0,w.jsx)(`span`,{className:`sidebar-toggle-static-logo`,"aria-hidden":`true`,children:Et?(0,w.jsx)(`img`,{className:`sidebar-toggle-static-logo-img`,src:Et,alt:``,onError:()=>wt(!0)}):(0,w.jsx)(Se,{size:18})}):void 0,headerRight:(0,w.jsxs)(`div`,{className:`header-right-actions`,children:[(0,w.jsx)(`button`,{className:`btn btn-icon`,onClick:()=>t(!e),title:K(`common.theme.toggle`),children:e?(0,w.jsx)(te,{size:16}):(0,w.jsx)(ne,{size:16})}),m&&(0,w.jsx)(`button`,{className:`btn btn-icon`,onClick:()=>P(!0),title:K(`chat.channelSettings`),children:(0,w.jsx)(ke,{size:16})})]}),children:[m?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsxs)(`div`,{className:`chat-messages`,children:[X.length===0?(0,w.jsxs)(`div`,{className:`ui-empty-state chat-messages-empty`,children:[(0,w.jsx)(`div`,{className:`ui-empty-icon empty-icon`,children:(0,w.jsx)(ue,{size:28})}),(0,w.jsx)(`p`,{children:K(`chat.empty.noMessages`)})]}):X.map(e=>{let t=e.author?.toLowerCase()===u?.address.toLowerCase();return(0,w.jsx)(Ie,{variant:t?`self`:`other`,pending:e.pending,avatarSrc:ge(e.author,e.avatar||(t?u.avatar:void 0)),author:ln(e.authorName,e.author),time:Ft(e.timestamp),children:cn(e)},e.id||`${e.author}-${e.timestamp}`)}),(0,w.jsx)(`div`,{ref:Dt})]}),(0,w.jsx)(ze,{message:Oe,placeholder:K(u?`chat.composer.placeholder`:`chat.composer.signInPlaceholder`),disabled:!u,isPublishingAttachment:yt,attachmentInputRef:Ot,onMessageChange:S,onSend:en,onSelectAttachmentFiles:e=>{nn(e)}})]}):dn?(0,w.jsxs)(`div`,{className:`ui-empty-state chat-welcome`,children:[(0,w.jsx)(`div`,{className:`ui-empty-icon ui-empty-icon-lg welcome-icon`,children:(0,w.jsx)(oe,{size:36,className:`ui-spinner`})}),(0,w.jsx)(`h2`,{className:`ui-empty-title`,children:K(`chat.restoring.title`)}),(0,w.jsx)(`p`,{className:`ui-empty-desc`,children:K(`chat.restoring.desc`)})]}):(0,w.jsx)(w.Fragment,{children:(0,w.jsxs)(`div`,{className:`ui-empty-state chat-welcome`,children:[(0,w.jsx)(`div`,{className:`ui-empty-icon ui-empty-icon-lg welcome-icon`,children:(0,w.jsx)(ue,{size:36})}),(0,w.jsx)(`h2`,{className:`ui-empty-title`,children:K(`chat.select.title`)}),(0,w.jsx)(`p`,{className:`ui-empty-desc`,children:K(`chat.select.desc`)}),(0,w.jsx)(de,{label:K(`chat.openChannelList`)})]})}),je&&(0,w.jsx)(s,{title:K(`chat.joinChannel`),placeholder:K(`chat.join.placeholder`),confirmText:K(`chat.join.confirm`),validate:Wt,onConfirm:Qt,onClose:()=>T.close(),isLoading:O,loadingText:K(`chat.join.joining`)}),ut&&(0,w.jsx)(s,{title:K(`chat.renameChannel`),placeholder:K(`chat.remark.placeholder`),defaultValue:ut.remark||``,confirmText:K(`chat.remark.save`),onConfirm:sn,onClose:()=>{ht||dt(null)},isLoading:ht,loadingText:K(`chat.remark.saving`),allowEmpty:!0,validate:e=>e.length>50?K(`chat.remark.tooLong`):``}),st&<&&(0,w.jsx)(c,{title:K(`chat.leaveChannel`),message:K(`chat.leaveConfirm`,{channel:M(lt)}),confirmText:K(at?`chat.leaving`:`chat.leaveChannel`),onConfirm:()=>Xt(A(lt),void 0),danger:!0,onClose:()=>{ct.close(),N(null)}}),L&&(0,w.jsx)(o,{onClose:()=>R(null),children:(0,w.jsxs)(`div`,{className:`confirm-modal`,onClick:e=>e.stopPropagation(),children:[(0,w.jsxs)(`div`,{className:`modal-header`,children:[(0,w.jsx)(`h3`,{children:K(`chat.attachment.noSeedsTitle`)}),(0,w.jsx)(`button`,{type:`button`,className:`btn btn-icon`,onClick:()=>R(null),"aria-label":K(`common.close`),children:(0,w.jsx)(i,{size:18})})]}),(0,w.jsx)(`p`,{children:F[L.cid]?.message||K(`chat.attachment.noSeedsFallback`)}),(0,w.jsxs)(`div`,{className:`modal-actions`,children:[(0,w.jsx)(`button`,{type:`button`,className:`btn btn-secondary`,onClick:()=>R(null),children:K(`common.cancel`)}),(0,w.jsx)(`button`,{type:`button`,className:`btn btn-primary`,onClick:()=>qt(L),disabled:F[L.cid]?.status===`checking`,children:F[L.cid]?.status===`checking`?K(`app.checking`):K(`chat.attachment.retryCheck`)})]})]})}),_t&&(0,w.jsx)(ae,{item:_t,isBackendReady:G,getFileDownloadUrl:b.getFileDownloadUrl,onClose:()=>vt(null)}),ft&&m&&(0,w.jsx)(`div`,{className:`channel-detail-overlay`,onClick:()=>P(!1),children:(0,w.jsxs)(`div`,{className:`channel-detail-drawer`,onClick:e=>e.stopPropagation(),children:[(0,w.jsxs)(`div`,{className:`channel-detail-header`,children:[(0,w.jsx)(`h3`,{children:K(`chat.details.title`)}),(0,w.jsx)(`button`,{className:`btn btn-icon`,onClick:()=>P(!1),children:(0,w.jsx)(i,{size:18})})]}),(0,w.jsxs)(`div`,{className:`channel-detail-body`,children:[(0,w.jsxs)(`div`,{className:`channel-detail-section channel-members-section`,children:[(0,w.jsx)(`div`,{className:`channel-detail-label`,children:(0,w.jsx)(`span`,{children:K(`chat.details.members`,{count:Ut.length})})}),un()]}),!B&&(0,w.jsx)(`div`,{className:`channel-detail-section`,children:(0,w.jsxs)(`label`,{className:`setting-switch`,children:[(0,w.jsx)(`span`,{children:K(`chat.details.showAddressSuffix`)}),(0,w.jsx)(`input`,{type:`checkbox`,checked:xt,onChange:e=>St(e.target.checked)})]})}),!B&&(0,w.jsxs)(`div`,{className:`channel-detail-section`,children:[(0,w.jsxs)(`div`,{className:`channel-detail-label`,children:[(0,w.jsx)(De,{size:14}),(0,w.jsx)(`span`,{children:K(`chat.details.channelId`)})]}),(0,w.jsx)(`div`,{className:`ui-meta-box channel-detail-value channel-detail-mono`,translate:`no`,children:j(m)})]}),(0,w.jsxs)(`div`,{className:`channel-detail-section`,children:[(0,w.jsxs)(`div`,{className:`channel-detail-label`,children:[(0,w.jsx)(ie,{size:14}),(0,w.jsx)(`span`,{children:K(`chat.remark.placeholder`)})]}),(0,w.jsx)(`input`,{type:`text`,className:`input input-compact`,placeholder:K(`chat.remark.placeholder`),value:pt,onChange:e=>mt(e.target.value),onFocus:()=>mt(m.remark||``),onBlur:()=>on(),onKeyDown:e=>{e.key===`Enter`&&e.currentTarget.blur()},maxLength:50})]}),(0,w.jsxs)(`div`,{className:`channel-detail-section`,children:[(0,w.jsxs)(`div`,{className:`channel-detail-label`,children:[(0,w.jsx)(Te,{size:14}),(0,w.jsx)(`span`,{children:K(`chat.channel.createdAt`)})]}),(0,w.jsx)(`div`,{className:`ui-meta-box channel-detail-value`,children:m.createdAt?Pt(m.createdAt):`-`})]})]}),!B&&(0,w.jsx)(`div`,{className:`channel-detail-footer`,children:(0,w.jsx)(`button`,{className:`btn btn-secondary btn-block`,onClick:()=>{P(!1),N(m),ct.open()},children:K(`chat.leaveChannel`)})})]})})]})}var ot=a(`/chat/`)({component:at});export{ot as Route};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/MilkdownEditor-DrsyaR4h.js","assets/jsx-runtime-Bt-cYkS5.js","assets/index-BZ-f0CZd.js","assets/ui-BpDGD3IR.js","assets/useNavigate-DWlBD_-b.js","assets/i18n-NjvOSuV6.js","assets/index-Cde4g_dk.css","assets/dist-zyJb88Zz.js","assets/dist-CbTzBiwL.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{n as e,o as t,t as n}from"./jsx-runtime-Bt-cYkS5.js";import{C as r,S as i,T as a,a as o,f as s,n as c,p as l,r as u,s as d}from"./ui-BpDGD3IR.js";import{n as f}from"./useNavigate-DWlBD_-b.js";import{a as p}from"./i18n-NjvOSuV6.js";import{n as m,r as h}from"./LanguageToggle-CSQtRZ3A.js";import{n as g,t as _}from"./lock-CLIE8cct.js";import{n as v,t as y}from"./folder-Cfgc70_F.js";import{t as ee}from"./file-text-DPA1riJ_.js";import{n as b,t as x}from"./SidebarHomeLink-BdsUM4Kt.js";import{t as S}from"./notebook-pen-C8TlK5sB.js";import{t as te}from"./OpenSidebarButton-DnEgqP0S.js";import{t as ne}from"./plus-4hygj-1Z.js";import{t as C}from"./save-BjrbPwhJ.js";import{t as re}from"./search-DSkiWdvX.js";import{t as ie}from"./trash-2-V12tJ8lI.js";import{D as ae,L as oe,N as se,O as ce,c as w,k as T,t as le}from"./index-BZ-f0CZd.js";import{t as E}from"./SidebarAccount-B4OAl0as.js";var ue=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`}]]),de=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`}]]),D=t(e(),1),O=n();function fe(e){return e.type===`directory`?T(e.path?`${e.path}/${e.name}`:e.name):ce(e)}function pe({target:e,directories:t,onMove:n,onClose:r}){let{t:a}=p(),s=T(e.path||``),c=fe(e),l=t.filter(t=>e.type===`directory`?t.path!==c&&!t.path.startsWith(`${c}/`):!0),[u,d]=(0,D.useState)(s),[f,m]=(0,D.useState)(``),[h,_]=(0,D.useState)(new Set),ee=T(f),b=f.trim()?ee:u,x=T(b)===s,S=new Map;for(let e of l){let t=S.get(e.parentPath)||[];t.push(e),S.set(e.parentPath,t)}let te=l.filter(e=>{if(!e.parentPath)return!0;let t=e.parentPath.split(`/`).filter(Boolean);return t.every((e,n)=>h.has(t.slice(0,n+1).join(`/`)))}),ne=[{label:a(`note.root`),path:``},...u.split(`/`).filter(Boolean).map((e,t,n)=>({label:e,path:n.slice(0,t+1).join(`/`)}))];function C(e){d(T(e)),m(``)}function re(e){C(e),S.has(e)&&_(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}function ie(){x||n(b)}return(0,O.jsx)(o,{onClose:r,children:(0,O.jsxs)(`div`,{className:`note-move-modal`,onClick:e=>e.stopPropagation(),children:[(0,O.jsxs)(`div`,{className:`modal-header`,children:[(0,O.jsx)(`h3`,{children:a(`note.move.title`)}),(0,O.jsx)(`button`,{className:`btn btn-icon`,onClick:r,children:(0,O.jsx)(i,{size:18})})]}),(0,O.jsxs)(`div`,{className:`note-move-target`,children:[(0,O.jsx)(`span`,{children:a(`note.move.moving`)}),(0,O.jsx)(`strong`,{translate:`no`,children:e.name})]}),(0,O.jsx)(`div`,{className:`note-move-path`,children:ne.map((e,t)=>(0,O.jsxs)(D.Fragment,{children:[t>0&&(0,O.jsx)(`span`,{children:`/`}),(0,O.jsx)(`button`,{type:`button`,onClick:()=>C(e.path),children:(0,O.jsx)(`span`,{translate:e.path?`no`:`yes`,children:e.label})})]},e.path||`root`))}),(0,O.jsxs)(`div`,{className:`note-move-folder-list`,children:[(0,O.jsxs)(`button`,{type:`button`,className:`note-move-folder-item ${u===``?`selected`:``}`,onClick:()=>C(``),children:[(0,O.jsx)(`span`,{className:`note-move-folder-spacer`}),(0,O.jsx)(y,{className:`note-move-folder-icon`,size:16}),(0,O.jsx)(`span`,{children:a(`note.root`)})]}),l.length===0?(0,O.jsx)(`p`,{className:`note-move-empty`,children:a(`note.move.noFolders`)}):te.map(e=>{let t=S.has(e.path),n=h.has(e.path);return(0,O.jsxs)(`button`,{type:`button`,className:`note-move-folder-item note-move-depth-${Math.min(e.depth,4)} ${u===e.path?`selected`:``}`,onClick:()=>re(e.path),children:[t?n?(0,O.jsx)(g,{className:`note-move-expander`,size:14}):(0,O.jsx)(v,{className:`note-move-expander`,size:14}):(0,O.jsx)(`span`,{className:`note-move-folder-spacer`}),(0,O.jsx)(y,{className:`note-move-folder-icon`,size:16}),(0,O.jsx)(`span`,{translate:`no`,children:e.name}),e.parentPath&&(0,O.jsx)(`small`,{translate:`no`,children:e.parentPath})]},e.path)})]}),(0,O.jsx)(`input`,{className:`input input-compact`,value:f,onChange:e=>m(e.target.value),placeholder:a(`note.move.pathPlaceholder`),translate:`no`}),(0,O.jsxs)(`div`,{className:`note-move-destination`,children:[(0,O.jsx)(`span`,{children:a(`note.move.destinationLabel`)}),(0,O.jsx)(`span`,{translate:b?`no`:`yes`,children:b||a(`note.root`)})]}),(0,O.jsxs)(`div`,{className:`modal-actions`,children:[(0,O.jsx)(`button`,{className:`btn btn-secondary`,onClick:r,children:a(`common.cancel`)}),(0,O.jsx)(`button`,{className:`btn btn-primary`,onClick:ie,disabled:x,children:a(`note.action.move`)})]})]})})}function me({children:e}){return(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(x,{}),e,(0,O.jsx)(E,{})]})}var he=(0,D.lazy)(async()=>({default:(await le(()=>import(`./MilkdownEditor-DrsyaR4h.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8]))).MilkdownEditor}));function ge(e){let t=new URLSearchParams(e),n=t.get(`mode`);return{cid:t.get(`cid`)||void 0,mode:n===`edit`?`edit`:void 0}}function _e(e={}){let t=new URLSearchParams;e.cid&&t.set(`cid`,e.cid),e.mode&&t.set(`mode`,e.mode);let n=t.toString();return n?`/note/?${n}`:`/note/`}function ve(e,t){return e.isSecret||e.content.startsWith(`mp://1`)?t(`note.preview.encrypted`):String(e.content||``).replace(/```[\s\S]*?```/g,` `).replace(/!\[[^\]]*]\([^)]*\)/g,` `).replace(/\[([^\]]+)]\([^)]*\)/g,`$1`).replace(/[#>*_`~|-]/g,` `).replace(/\s+/g,` `).trim()||t(`note.preview.empty`)}var k={"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 A(e,t,n){let r=e instanceof Error?e.message:``,i=k[r];return i?n(i):r||t}function ye(e){return e.type===`directory`?T(e.path?`${e.path}/${e.name}`:e.name):ce(e)}function be(e,t){let n=new Set;for(let t of e){let e=T(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 j(){let{t:e,formatDate:t,compareStrings:n}=p(),r=f(),a=oe({select:e=>e.searchStr}),o=(0,D.useMemo)(()=>ge(a),[a]),g=(0,D.useRef)(null),v=w(e=>e.addToast),x=w(e=>e.isDarkMode),le=w(e=>e.setIsDarkMode),E=d(e=>e.wallet),fe=d(e=>e.openLoginModal),k=w(e=>e.notes),j=w(e=>e.notesPath),M=w(e=>e.setNotesPath),N=w(e=>e.saveNote),xe=w(e=>e.deleteNote),Se=w(e=>e.renameNote),P=w(e=>e.localDataReady),F=o.cid||``,I=k.find(e=>e.cid===F),L=!!F,R=L&&o.mode===`edit`,[z,Ce]=(0,D.useState)(``),[B,V]=(0,D.useState)(null),[H,U]=(0,D.useState)(null),[W,G]=(0,D.useState)(null),[we,K]=(0,D.useState)(``),[Te,q]=(0,D.useState)(``),[Ee,J]=(0,D.useState)(``),[De,Oe]=(0,D.useState)(``),[ke,Ae]=(0,D.useState)(``),[je,Y]=(0,D.useState)(``),[X,Me]=(0,D.useState)(!1),[Ne,Z]=(0,D.useState)(``),[Pe,Fe]=(0,D.useState)(!1);(0,D.useEffect)(()=>{if(!F){K(``),q(``);return}if(!I){K(``),q(P?e(`note.error.notFound`):``);return}if(I.content.startsWith(`mp://1`)){if(!E){K(``),q(e(`note.error.loginToDecrypt`));return}let t=s(I.content,E.danger);if(!t){K(``),q(e(`note.error.decryptFailed`));return}K(t),q(``);return}K(I.content||``),q(``)},[F,P,I,e,E]),(0,D.useEffect)(()=>{if(!R){Fe(!1);return}if(!F||!I){Oe(``),Ae(``),Y(``),Me(!1),Z(P?e(`note.error.notFound`):``);return}if(Oe(I.name),Ae(I.path||``),Me(I.isSecret===!0||I.content.startsWith(`mp://1`)),I.content.startsWith(`mp://1`)){if(!E){Y(``),Z(e(`note.error.loginToDecrypt`));return}let t=s(I.content,E.danger);if(!t){Y(``),Z(e(`note.error.decryptFailed`));return}Y(t),Z(``);return}Y(I.content||``),Z(``)},[F,R,P,I,e,E]),(0,D.useEffect)(()=>{J(I?.name||``)},[I?.cid,I?.name]);let Ie=(0,D.useMemo)(()=>ae(k,j,z),[k,j,z]),Le=Ie.filter(e=>e.type===`file`).length,Re=I?.isSecret===!0||I?.content.startsWith(`mp://1`)===!0,ze=e(R?X?`note.privacy.secret`:`note.privacy.public`:Re?`note.privacy.secret`:`note.privacy.public`),Be=(0,D.useMemo)(()=>{let t=j.split(`/`).filter(Boolean);return[{label:e(`note.root`),path:``},...t.map((e,n)=>({label:e,path:t.slice(0,n+1).join(`/`)}))]},[j,e]),Ve=(0,D.useMemo)(()=>be(k,n),[n,k]);function Q(e={},t=!1){r({href:_e(e),replace:t})}function He(e){Q({cid:e.cid})}function Ue(e){Q({cid:e.cid,mode:`edit`})}function $(){return E?!0:(fe(),!1)}function We(){Q(I?{cid:I.cid}:{})}async function Ge(){if($()){if(!I){v(e(`note.toast.notFound`),`error`);return}if(!De.trim()){v(e(`note.toast.nameRequired`),`warning`);return}Fe(!0);try{let t=g.current?.getMarkdown()??je,n=X?l(t,E.danger):t,r=await N({cid:I.cid,name:De,path:ke,content:n,isSecret:X});Y(t),Q({cid:r},!0),v(e(`note.toast.saved`),`success`)}catch(t){v(A(t,e(`note.toast.saveFailed`),e),`error`)}finally{Fe(!1)}}}function Ke(){$()&&V({title:e(`note.create.title`),placeholder:e(`note.namePlaceholder`),confirmText:e(`note.create.action`),onConfirm:async t=>{if($())try{let n=await N({name:t,path:j,content:``,isSecret:!1});V(null),v(e(`note.toast.created`),`success`),Q({cid:n,mode:`edit`})}catch(t){v(A(t,e(`note.toast.createFailed`),e),`error`)}}})}async function qe(){if(!$()||!I)return;let t=Ee.trim();if(!t){J(I.name),v(e(`note.toast.nameRequired`),`warning`);return}if(t!==I.name)try{Se(ce(I),I.path,t),v(e(`note.toast.renamed`),`success`)}catch(t){J(I.name),v(A(t,e(`note.toast.renameFailed`),e),`error`)}}function Je(e){$()&&G(e)}async function Ye(t){if(W)try{Se(ye(W),t,W.name),G(null),v(e(`note.toast.moved`),`success`)}catch(t){v(A(t,e(`note.toast.moveFailed`),e),`error`)}}function Xe(t){if(!$())return;let n=t.type===`directory`;U({title:e(n?`note.delete.folderTitle`:`note.delete.noteTitle`),message:e(`note.delete.message`,{name:t.name}),confirmText:e(`note.action.delete`),onConfirm:async()=>{xe(n?void 0:t.cid,t.path,t.name),U(null),v(e(`note.toast.deleted`),`success`),t.type===`file`&&t.cid===F&&Q()}})}let Ze=(0,O.jsxs)(`div`,{className:`note-header-title`,children:[(0,O.jsx)(`h2`,{className:`header-title`,children:e(`note.title`)}),(0,O.jsx)(`span`,{children:e(`note.count`,{count:k.length})})]}),Qe=(0,O.jsx)(`div`,{className:`note-theme-wrap`,children:(0,O.jsx)(`button`,{className:`btn btn-icon`,onClick:()=>le(!x),title:e(`common.theme.toggle`),"aria-label":e(`common.theme.toggle`),children:x?(0,O.jsx)(m,{size:16}):(0,O.jsx)(h,{size:16})})}),$e=(0,O.jsxs)(`section`,{className:`note-list-panel note-sidebar-list`,"aria-label":e(`note.listLabel`),children:[(0,O.jsxs)(`div`,{className:`note-list-header`,children:[(0,O.jsx)(`div`,{className:`note-current-location`,children:(0,O.jsx)(`div`,{className:`note-breadcrumbs`,children:Be.map((e,t)=>(0,O.jsxs)(D.Fragment,{children:[t>0&&(0,O.jsx)(`span`,{children:`/`}),(0,O.jsx)(`button`,{onClick:()=>M(e.path),children:(0,O.jsx)(`span`,{translate:e.path?`no`:`yes`,children:e.label})})]},e.path||`root`))})}),(0,O.jsx)(`span`,{className:`note-count`,children:e(`note.count`,{count:Le})})]}),(0,O.jsxs)(`div`,{className:`note-search`,children:[(0,O.jsx)(re,{size:16}),(0,O.jsx)(`input`,{className:`input input-flex`,value:z,onChange:e=>Ce(e.target.value),placeholder:e(`note.search.placeholder`)})]}),Ie.length===0?(0,O.jsxs)(`div`,{className:`ui-empty-state note-empty-state`,children:[(0,O.jsx)(S,{size:32}),(0,O.jsx)(`p`,{children:e(z?`note.empty.noMatches`:`note.empty.noNotes`)})]}):(0,O.jsx)(`div`,{className:`note-list`,children:Ie.map(n=>(0,O.jsx)(`article`,{className:`ui-list-item note-list-item ${n.type===`file`&&n.cid===F?`active`:``}`,children:(0,O.jsxs)(`button`,{className:`ui-list-item-main note-list-item-main ${n.type===`directory`?`folder`:``}`,onClick:()=>{n.type===`directory`?M(T(n.path?`${n.path}/${n.name}`:n.name)):He(n)},children:[(0,O.jsx)(`span`,{className:`ui-list-icon note-list-icon ${n.type===`directory`?`warning`:``}`,children:n.type===`directory`?(0,O.jsx)(y,{size:18}):n.isSecret?(0,O.jsx)(_,{size:18}):(0,O.jsx)(ee,{size:18})}),(0,O.jsxs)(`span`,{className:`ui-list-copy note-list-copy`,children:[(0,O.jsx)(`span`,{className:`ui-list-title note-list-name`,translate:`no`,children:n.name}),n.type===`file`?(0,O.jsx)(`span`,{className:`ui-list-desc note-list-preview`,translate:`no`,children:ve(n,e)}):(0,O.jsx)(`span`,{className:`ui-list-desc note-list-preview`,children:e(`note.folder`)})]}),n.type===`file`&&(0,O.jsx)(`span`,{className:`ui-list-meta note-list-date`,children:t(n.updated_at)})]})},`${n.cid}:${n.path}:${n.name}`))}),(0,O.jsx)(`div`,{className:`note-create-btn`,children:(0,O.jsxs)(`button`,{className:`btn`,onClick:Ke,children:[(0,O.jsx)(ne,{size:16}),e(`note.newNote`)]})})]});return(0,O.jsxs)(b,{sidebar:()=>(0,O.jsx)(me,{children:$e}),headerTitle:Ze,headerRight:Qe,children:[(0,O.jsx)(`main`,{className:`note-page note-browser-page ${L?`has-editor`:``}`,children:(0,O.jsx)(`section`,{className:`note-workspace`,children:(0,O.jsx)(`section`,{className:`note-editor-panel`,"aria-label":e(R?`note.editorLabel.edit`:`note.editorLabel.read`),children:L?(0,O.jsxs)(O.Fragment,{children:[(0,O.jsxs)(`div`,{className:`note-editor-panel-header`,children:[(0,O.jsxs)(`div`,{className:`note-editor-title-area`,children:[R?(0,O.jsx)(`input`,{className:`note-title-input`,value:De,onChange:e=>Oe(e.target.value),placeholder:e(`note.namePlaceholder`),translate:`no`,disabled:!I}):I?(0,O.jsx)(`input`,{className:`note-title-input`,value:Ee,onBlur:qe,onChange:e=>J(e.target.value),onKeyDown:e=>{e.key===`Enter`&&e.currentTarget.blur(),e.key===`Escape`&&(J(I.name),e.currentTarget.blur())},placeholder:e(`note.namePlaceholder`),title:e(`app.rename`),translate:`no`}):(0,O.jsx)(`h3`,{children:e(`note.untitled`)}),I&&(0,O.jsxs)(`div`,{className:`note-editor-info`,children:[(0,O.jsx)(`span`,{children:e(R?`note.mode.edit`:`note.mode.read`)}),(0,O.jsx)(`span`,{children:ze}),(0,O.jsx)(`span`,{children:t(I.updated_at)})]})]}),(0,O.jsxs)(`div`,{className:`note-editor-actions`,children:[(0,O.jsx)(`button`,{type:`button`,className:`btn btn-icon`,onClick:R?We:()=>Q(),title:e(R?`common.cancel`:`common.close`),"aria-label":e(R?`common.cancel`:`common.close`),children:(0,O.jsx)(i,{size:16})}),R?(0,O.jsxs)(O.Fragment,{children:[(0,O.jsxs)(`button`,{className:`btn btn-sm ${X?`btn-warning`:`btn-secondary`}`,onClick:()=>Me(!X),disabled:!I,children:[X?(0,O.jsx)(_,{size:16}):(0,O.jsx)(se,{size:16}),e(X?`note.privacy.secret`:`note.privacy.public`)]}),(0,O.jsxs)(`button`,{className:`btn btn-sm btn-primary`,onClick:Ge,disabled:Pe||!!Ne||!I,children:[(0,O.jsx)(C,{size:16}),e(Pe?`note.action.saving`:`note.action.save`)]})]}):I&&(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(`button`,{type:`button`,className:`btn btn-icon`,onClick:()=>Je(I),title:e(`note.action.move`),"aria-label":e(`note.action.move`),children:(0,O.jsx)(ue,{size:16})}),(0,O.jsx)(`button`,{type:`button`,className:`btn btn-icon note-editor-action-danger`,onClick:()=>Xe(I),title:e(`note.action.delete`),"aria-label":e(`note.action.delete`),children:(0,O.jsx)(ie,{size:16})}),(0,O.jsxs)(`button`,{type:`button`,className:`btn btn-sm btn-primary`,onClick:()=>Ue(I),disabled:!!Te,title:e(`note.action.edit`),"aria-label":e(`note.action.edit`),children:[(0,O.jsx)(de,{size:16}),e(`note.action.edit`)]})]})]})]}),R?Ne?(0,O.jsxs)(`div`,{className:`note-empty-state editor-error`,children:[(0,O.jsx)(_,{size:36}),(0,O.jsx)(`p`,{children:Ne})]}):I?(0,O.jsx)(`div`,{className:`note-editor-frame editing`,children:(0,O.jsx)(he,{ref:g,content:je,onChange:Y,className:`milkdown-editor`})}):(0,O.jsxs)(`div`,{className:`note-empty-state editor-error`,children:[(0,O.jsx)(S,{size:36}),(0,O.jsx)(`p`,{children:e(P?`note.error.notFound`:`note.loading`)})]}):Te?(0,O.jsxs)(`div`,{className:`ui-empty-state note-empty-state editor-error`,children:[(0,O.jsx)(_,{size:36}),(0,O.jsx)(`p`,{children:Te})]}):I?(0,O.jsx)(`div`,{className:`note-editor-frame reading`,children:(0,O.jsx)(he,{content:we,readOnly:!0,className:`milkdown-editor`})}):(0,O.jsxs)(`div`,{className:`ui-empty-state note-empty-state editor-error`,children:[(0,O.jsx)(S,{size:36}),(0,O.jsx)(`p`,{children:e(P?`note.error.notFound`:`note.loading`)})]})]}):(0,O.jsxs)(`div`,{className:`ui-empty-state note-editor-empty`,children:[(0,O.jsx)(`div`,{className:`ui-empty-icon note-editor-empty-icon`,children:(0,O.jsx)(S,{size:32})}),(0,O.jsx)(`h3`,{className:`ui-empty-title`,children:e(`note.noOpen.title`)}),(0,O.jsx)(`p`,{className:`ui-empty-desc`,children:k.length>0?e(`note.noOpen.select`):e(`note.noOpen.createFirst`)}),(0,O.jsx)(te,{label:e(`note.openList`),variant:`default`})]})})})}),B&&(0,O.jsx)(c,{title:B.title,placeholder:B.placeholder,defaultValue:B.defaultValue,confirmText:B.confirmText,onConfirm:B.onConfirm,onClose:()=>V(null)}),H&&(0,O.jsx)(u,{title:H.title,message:H.message,confirmText:H.confirmText,danger:!0,onConfirm:H.onConfirm,onClose:()=>U(null)}),W&&(0,O.jsx)(pe,{target:W,directories:Ve,onMove:Ye,onClose:()=>G(null)})]})}function M(){let{t:e}=p();return(0,O.jsx)(D.Suspense,{fallback:(0,O.jsx)(`div`,{className:`note-editor-loading`,children:e(`note.loading`)}),children:(0,O.jsx)(j,{})})}var N=a(`/note/`)({component:M});export{N as Route};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e,o as t,t as n}from"./jsx-runtime-Bt-cYkS5.js";import{E as r,O as i,c as a,r as o,u as s,w as c}from"./ui-PnUvY9zL.js";import{a as l}from"./i18n--maTEG0d.js";import{o as u}from"./LanguageToggle-BoBNesNU.js";import{t as ee}from"./download-Q6jKMPIG.js";import{t as d}from"./external-link-GQcZwDTT.js";import{a as f,i as p,n as m,r as h}from"./mp-FQvFEcYM.js";import{t as g}from"./key-round-D1zfZzvP.js";import{t as _}from"./loader-BSclU8WE.js";import{t as v}from"./save-BVeMjaW1.js";import{t as te}from"./shield-check-CZYDVJoh.js";import{t as ne}from"./upload-DgxxldtV.js";import{a as y,c as b,f as x,i as S,l as C,n as w,o as T,r as E,s as D}from"./index-Cg4kEvx8.js";import{t as O}from"./MarketingHeader-Derv67Vs.js";import{t as k}from"./MarketingLayout-fc2mymJm.js";var re=c(`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`}]]),ie=c(`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`}]]),ae=c(`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`}]]),oe=c(`wallet-cards`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M3 9a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2`,key:`4125el`}],[`path`,{d:`M3 11h3c.8 0 1.6.3 2.1.9l1.1.9c1.6 1.6 4.1 1.6 5.7 0l1.1-.9c.5-.5 1.3-.9 2.1-.9H21`,key:`1dpki6`}]]),A=t(e(),1),j=n(),se=[{value:``,labelKey:`profile.avatar.address`},...E.map(e=>({value:y(e),labelKey:`profile.avatar.${e}`}))];function ce(e){if(T(e))return!0;try{let t=new URL(e);return t.protocol===`http:`||t.protocol===`https:`}catch{return!1}}function M(){let{t:e}=l(),t=b(e=>e.addToast),n=b(e=>e.hasBackend),r=a(e=>e.identity),c=a(e=>e.openLoginModal),y=a(e=>e.setUserIdentity),T=a(e=>e.logoutUser),E=w(),[M,F]=(0,A.useState)(``),[I,L]=(0,A.useState)(``),[R,z]=(0,A.useState)(``),[B,V]=(0,A.useState)(null),[H,U]=(0,A.useState)(!1),W=(0,j.jsx)(O,{});(0,A.useEffect)(()=>{if(!r){F(``),L(``),z(``);return}F(r.displayName||r.username),L(D(r.avatar)||r.avatar||``),z(``)},[r]);let G=(0,A.useMemo)(()=>r?s(r.danger):null,[r]),le=(0,A.useMemo)(()=>G?m(G.private_key,G.ed_public_key):``,[G]);if(!r)return(0,j.jsx)(k,{header:W,children:(0,j.jsx)(`section`,{className:`profile-page`,children:(0,j.jsx)(`div`,{className:`profile-container narrow`,children:(0,j.jsxs)(`div`,{className:`profile-empty glass`,children:[(0,j.jsx)(`div`,{className:`profile-empty-icon`,children:(0,j.jsx)(p,{size:34})}),(0,j.jsx)(`h1`,{children:e(`profile.signedOut.title`)}),(0,j.jsx)(`p`,{children:e(`profile.signedOut.desc`)}),(0,j.jsxs)(`button`,{type:`button`,className:`btn btn-primary`,onClick:c,children:[(0,j.jsx)(p,{size:16}),e(`account.signIn`)]})]})})})});let ue=D(r.avatar)||r.avatar||``,de=S(r.address,r.avatar),K=r.address.toLowerCase(),fe=I.trim().length>0;async function q(r){if(n===!0)try{await C.put(`/api/user/profile`,{json:{displayName:r.displayName||r.username,avatar:r.avatar||``,updatedAt:r.profileUpdatedAt||Date.now()}}).json()}catch(n){t(await x(n,e(`profile.backup.error.profileSaveFailed`)),`error`)}}function J(n){if(!r)return;let i={...r,avatar:n||void 0,profileUpdatedAt:Date.now()};y(i),q(i),z(``),t(e(`profile.toast.avatarUpdated`),`success`)}function pe(){if(!r)return;let n=M.trim()||r.username,i={...r,displayName:n,profileUpdatedAt:Date.now()};y(i),q(i),F(n),t(e(`profile.toast.saved`),`success`)}function me(){let t=I.trim();if(!t){J(void 0);return}if(!ce(t)){z(e(`nav.avatarUrlInvalid`));return}J(t)}function he(){T(),U(!1)}function ge(){V({title:e(`profile.backup.confirm.backupTitle`),message:e(`profile.backup.confirm.backupMessage`),confirmText:e(`profile.backup.action.cloudBackup`),onConfirm:async()=>{V(null),await E.backupToCloud()}})}function _e(){V({title:e(`profile.backup.confirm.restoreTitle`),message:e(`profile.backup.confirm.restoreMessage`),confirmText:e(`profile.backup.action.cloudRestore`),onConfirm:async()=>{V(null),await E.restoreFromCloud({confirm:!1})}})}function Y(){return new Promise(t=>{let n=e=>{V(null),t(e)};V({title:e(`profile.backup.confirm.importTitle`),message:e(`profile.backup.confirm.restore`),confirmText:e(`profile.backup.action.importLocal`),onConfirm:()=>n(!0),onClose:()=>n(!1)})})}function ve(){E.importLocalBackup({requestConfirm:Y})}let X=E.action===`backup`,Z=E.action===`restore`,Q=E.action===`export`,$=E.action===`import`;return(0,j.jsxs)(k,{header:W,children:[(0,j.jsx)(`section`,{className:`profile-page`,children:(0,j.jsxs)(`div`,{className:`profile-container`,children:[(0,j.jsxs)(`section`,{className:`profile-panel profile-backup-panel`,children:[(0,j.jsx)(`div`,{className:`profile-panel-header`,children:(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`h2`,{children:e(`profile.section.backup`)}),(0,j.jsx)(`p`,{children:e(`profile.section.backup.desc`)})]})}),(0,j.jsxs)(`div`,{className:`profile-backup-actions`,children:[(0,j.jsxs)(`button`,{type:`button`,className:`btn btn-secondary ${Q?`btn-loading`:``}`,onClick:E.exportLocalBackup,disabled:E.busy,children:[Q?(0,j.jsx)(_,{size:16,className:`ui-spinner`}):(0,j.jsx)(ee,{size:16}),e(Q?`profile.backup.status.exporting`:`profile.backup.action.exportLocal`)]}),(0,j.jsxs)(`button`,{type:`button`,className:`btn btn-secondary ${$?`btn-loading`:``}`,onClick:ve,disabled:E.busy,children:[$?(0,j.jsx)(_,{size:16,className:`ui-spinner`}):(0,j.jsx)(ne,{size:16}),e($?`profile.backup.status.importing`:`profile.backup.action.importLocal`)]}),(0,j.jsxs)(`button`,{type:`button`,className:`btn btn-primary ${X?`btn-loading`:``}`,onClick:ge,disabled:E.busy,children:[X?(0,j.jsx)(_,{size:16,className:`ui-spinner`}):(0,j.jsx)(ie,{size:16}),e(X?`profile.backup.status.backingUp`:`profile.backup.action.cloudBackup`)]}),(0,j.jsxs)(`button`,{type:`button`,className:`btn btn-secondary ${Z?`btn-loading`:``}`,onClick:_e,disabled:E.busy,children:[Z?(0,j.jsx)(_,{size:16,className:`ui-spinner`}):(0,j.jsx)(re,{size:16}),e(Z?`profile.backup.status.restoring`:`profile.backup.action.cloudRestore`)]})]})]}),(0,j.jsxs)(`header`,{className:`profile-header`,children:[(0,j.jsx)(`img`,{className:`profile-avatar-large`,src:de,alt:``}),(0,j.jsxs)(`div`,{className:`profile-heading`,children:[(0,j.jsx)(`p`,{className:`profile-kicker`,children:e(`profile.kicker`)}),(0,j.jsx)(`h1`,{children:r.displayName||r.username}),(0,j.jsxs)(`div`,{className:`profile-address-line`,children:[(0,j.jsx)(`code`,{translate:`no`,children:K}),(0,j.jsx)(h,{text:K}),(0,j.jsxs)(`a`,{href:`https://debank.com/profile/${r.address}`,target:`_blank`,rel:`noopener noreferrer`,className:`btn btn-secondary btn-sm`,children:[(0,j.jsx)(d,{size:14}),e(`web3.action.view`)]})]})]}),(0,j.jsxs)(`button`,{type:`button`,className:`btn btn-secondary profile-logout-btn`,onClick:()=>U(!0),children:[(0,j.jsx)(ae,{size:16}),e(`account.logout`)]})]}),(0,j.jsxs)(`div`,{className:`profile-grid`,children:[(0,j.jsxs)(`section`,{className:`profile-panel`,children:[(0,j.jsx)(`div`,{className:`profile-panel-header`,children:(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`h2`,{children:e(`profile.section.account`)}),(0,j.jsx)(`p`,{children:e(`profile.section.account.desc`)})]})}),(0,j.jsxs)(`label`,{className:`profile-field`,children:[(0,j.jsx)(`span`,{children:e(`profile.label.displayName`)}),(0,j.jsxs)(`div`,{className:`profile-field-row`,children:[(0,j.jsx)(`input`,{className:`input`,value:M,onChange:e=>F(e.target.value),placeholder:e(`nav.displayNamePlaceholder`)}),(0,j.jsxs)(`button`,{type:`button`,className:`btn btn-primary`,onClick:pe,children:[(0,j.jsx)(v,{size:16}),e(`profile.action.save`)]})]})]}),(0,j.jsxs)(`div`,{className:`profile-facts`,children:[(0,j.jsx)(N,{label:e(`profile.label.username`),value:r.username}),(0,j.jsx)(N,{label:e(`web3.label.address`),value:r.address,copy:!0})]})]}),(0,j.jsxs)(`section`,{className:`profile-panel`,children:[(0,j.jsx)(`div`,{className:`profile-panel-header`,children:(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`h2`,{children:e(`profile.section.avatar`)}),(0,j.jsx)(`p`,{children:e(`profile.section.avatar.desc`)})]})}),(0,j.jsx)(`div`,{className:`profile-avatar-grid`,role:`list`,children:se.map(t=>{let n=ue===t.value;return(0,j.jsxs)(`button`,{type:`button`,className:[`profile-avatar-option`,n?`selected`:``].filter(Boolean).join(` `),onClick:()=>J(t.value),"aria-pressed":n,title:e(t.labelKey),children:[(0,j.jsx)(`img`,{src:S(r.address,t.value),alt:``,"aria-hidden":`true`}),(0,j.jsx)(`span`,{children:e(t.labelKey)}),n&&(0,j.jsx)(`span`,{className:`profile-avatar-check`,children:(0,j.jsx)(u,{size:14})})]},t.value||`address`)})}),(0,j.jsxs)(`div`,{className:`profile-avatar-url`,children:[(0,j.jsxs)(`label`,{className:`profile-field`,htmlFor:`profile-avatar-url`,children:[(0,j.jsx)(`span`,{children:e(`profile.label.customAvatar`)}),(0,j.jsxs)(`div`,{className:`profile-field-row`,children:[(0,j.jsx)(`input`,{id:`profile-avatar-url`,className:`input`,value:I,onChange:e=>{L(e.target.value),z(``)},placeholder:e(`nav.avatarUrlPlaceholder`)}),(0,j.jsxs)(`button`,{type:`button`,className:`btn btn-secondary`,onClick:me,disabled:!fe,children:[(0,j.jsx)(v,{size:16}),e(`profile.action.save`)]})]})]}),R&&(0,j.jsx)(`p`,{className:`profile-error`,children:R})]})]})]}),(0,j.jsxs)(`section`,{className:`profile-panel profile-identity-panel`,children:[(0,j.jsxs)(`div`,{className:`profile-panel-header`,children:[(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`h2`,{children:e(`profile.section.identity`)}),(0,j.jsx)(`p`,{children:e(`profile.section.identity.desc`)})]}),(0,j.jsxs)(i,{to:`/web3/`,hash:`wallet`,className:`btn btn-secondary`,children:[(0,j.jsx)(oe,{size:16}),e(`profile.action.openWallet`)]})]}),(0,j.jsxs)(`div`,{className:`profile-key-grid`,children:[G&&(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(P,{title:e(`web3.label.ed25519Public`),icon:(0,j.jsx)(f,{size:18}),value:G.ed_public_key}),(0,j.jsx)(P,{title:e(`web3.label.x25519Public`),icon:(0,j.jsx)(g,{size:18}),value:G.public_key})]}),(0,j.jsx)(P,{title:`IPNS ID`,icon:(0,j.jsx)(te,{size:18}),value:le||`-`})]})]})]})}),H&&(0,j.jsx)(o,{title:e(`account.logoutTitle`),message:e(`account.logoutConfirm`),confirmText:e(`account.logout`),danger:!0,onConfirm:he,onClose:()=>U(!1)}),B&&(0,j.jsx)(o,{title:B.title,message:B.message,confirmText:B.confirmText,danger:B.danger,onConfirm:B.onConfirm,onClose:B.onClose||(()=>V(null))})]})}function N({label:e,value:t,copy:n=!1}){return(0,j.jsxs)(`div`,{className:`profile-fact`,children:[(0,j.jsx)(`span`,{children:e}),(0,j.jsxs)(`div`,{className:`profile-fact-value`,children:[(0,j.jsx)(`code`,{translate:`no`,children:t}),n&&(0,j.jsx)(h,{text:t})]})]})}function P({title:e,icon:t,value:n}){return(0,j.jsxs)(`div`,{className:`profile-key-card`,children:[(0,j.jsxs)(`div`,{className:`profile-key-card-header`,children:[(0,j.jsx)(`span`,{className:`profile-key-card-icon`,children:t}),(0,j.jsx)(`span`,{children:e})]}),(0,j.jsxs)(`div`,{className:`mono-row`,children:[(0,j.jsx)(`code`,{className:`mono`,translate:`no`,children:n}),(0,j.jsx)(h,{text:n})]})]})}var F=r(`/profile/`)({component:M});export{F as Route};
|
|
1
|
+
import{n as e,o as t,t as n}from"./jsx-runtime-Bt-cYkS5.js";import{C as r,D as i,T as a,l as o,r as s,s as c}from"./ui-BpDGD3IR.js";import{a as l}from"./i18n-NjvOSuV6.js";import{i as u}from"./LanguageToggle-CSQtRZ3A.js";import{t as ee}from"./download-jEPn2njL.js";import{t as d}from"./external-link-BFaoZeK0.js";import{a as f,i as p,n as m,r as h}from"./mp-B6kdA94c.js";import{t as g}from"./key-round-DNcpSuMw.js";import{t as _}from"./loader-BXQtdens.js";import{t as v}from"./save-BjrbPwhJ.js";import{t as te}from"./shield-check-DzDuWO8r.js";import{t as ne}from"./upload-CoCptKya.js";import{a as y,c as b,f as x,i as S,l as C,n as w,o as T,r as E,s as D}from"./index-BZ-f0CZd.js";import{t as O}from"./MarketingHeader-CrYsQsQ5.js";import{t as k}from"./MarketingLayout-CQurMOSD.js";var re=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`}]]),ie=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`}]]),ae=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`}]]),oe=r(`wallet-cards`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M3 9a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2`,key:`4125el`}],[`path`,{d:`M3 11h3c.8 0 1.6.3 2.1.9l1.1.9c1.6 1.6 4.1 1.6 5.7 0l1.1-.9c.5-.5 1.3-.9 2.1-.9H21`,key:`1dpki6`}]]),A=t(e(),1),j=n(),se=[{value:``,labelKey:`profile.avatar.address`},...E.map(e=>({value:y(e),labelKey:`profile.avatar.${e}`}))];function ce(e){if(T(e))return!0;try{let t=new URL(e);return t.protocol===`http:`||t.protocol===`https:`}catch{return!1}}function M(){let{t:e}=l(),t=b(e=>e.addToast),n=b(e=>e.hasBackend),r=c(e=>e.identity),a=c(e=>e.openLoginModal),y=c(e=>e.setUserIdentity),T=c(e=>e.logoutUser),E=w(),[M,F]=(0,A.useState)(``),[I,L]=(0,A.useState)(``),[R,z]=(0,A.useState)(``),[B,V]=(0,A.useState)(null),[H,U]=(0,A.useState)(!1),W=(0,j.jsx)(O,{});(0,A.useEffect)(()=>{if(!r){F(``),L(``),z(``);return}F(r.displayName||r.username),L(D(r.avatar)||r.avatar||``),z(``)},[r]);let G=(0,A.useMemo)(()=>r?o(r.danger):null,[r]),le=(0,A.useMemo)(()=>G?m(G.private_key,G.ed_public_key):``,[G]);if(!r)return(0,j.jsx)(k,{header:W,children:(0,j.jsx)(`section`,{className:`profile-page`,children:(0,j.jsx)(`div`,{className:`profile-container narrow`,children:(0,j.jsxs)(`div`,{className:`profile-empty glass`,children:[(0,j.jsx)(`div`,{className:`profile-empty-icon`,children:(0,j.jsx)(p,{size:34})}),(0,j.jsx)(`h1`,{children:e(`profile.signedOut.title`)}),(0,j.jsx)(`p`,{children:e(`profile.signedOut.desc`)}),(0,j.jsxs)(`button`,{type:`button`,className:`btn btn-primary`,onClick:a,children:[(0,j.jsx)(p,{size:16}),e(`account.signIn`)]})]})})})});let ue=D(r.avatar)||r.avatar||``,de=S(r.address,r.avatar),K=r.address.toLowerCase(),fe=I.trim().length>0;async function q(r){if(n===!0)try{await C.put(`/api/user/profile`,{json:{displayName:r.displayName||r.username,avatar:r.avatar||``,updatedAt:r.profileUpdatedAt||Date.now()}}).json()}catch(n){t(await x(n,e(`profile.backup.error.profileSaveFailed`)),`error`)}}function J(n){if(!r)return;let i={...r,avatar:n||void 0,profileUpdatedAt:Date.now()};y(i),q(i),z(``),t(e(`profile.toast.avatarUpdated`),`success`)}function pe(){if(!r)return;let n=M.trim()||r.username,i={...r,displayName:n,profileUpdatedAt:Date.now()};y(i),q(i),F(n),t(e(`profile.toast.saved`),`success`)}function me(){let t=I.trim();if(!t){J(void 0);return}if(!ce(t)){z(e(`nav.avatarUrlInvalid`));return}J(t)}function he(){T(),U(!1)}function ge(){V({title:e(`profile.backup.confirm.backupTitle`),message:e(`profile.backup.confirm.backupMessage`),confirmText:e(`profile.backup.action.cloudBackup`),onConfirm:async()=>{V(null),await E.backupToCloud()}})}function _e(){V({title:e(`profile.backup.confirm.restoreTitle`),message:e(`profile.backup.confirm.restoreMessage`),confirmText:e(`profile.backup.action.cloudRestore`),onConfirm:async()=>{V(null),await E.restoreFromCloud({confirm:!1})}})}function Y(){return new Promise(t=>{let n=e=>{V(null),t(e)};V({title:e(`profile.backup.confirm.importTitle`),message:e(`profile.backup.confirm.restore`),confirmText:e(`profile.backup.action.importLocal`),onConfirm:()=>n(!0),onClose:()=>n(!1)})})}function ve(){E.importLocalBackup({requestConfirm:Y})}let X=E.action===`backup`,Z=E.action===`restore`,Q=E.action===`export`,$=E.action===`import`;return(0,j.jsxs)(k,{header:W,children:[(0,j.jsx)(`section`,{className:`profile-page`,children:(0,j.jsxs)(`div`,{className:`profile-container`,children:[(0,j.jsxs)(`section`,{className:`profile-panel profile-backup-panel`,children:[(0,j.jsx)(`div`,{className:`profile-panel-header`,children:(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`h2`,{children:e(`profile.section.backup`)}),(0,j.jsx)(`p`,{children:e(`profile.section.backup.desc`)})]})}),(0,j.jsxs)(`div`,{className:`profile-backup-actions`,children:[(0,j.jsxs)(`button`,{type:`button`,className:`btn btn-secondary ${Q?`btn-loading`:``}`,onClick:E.exportLocalBackup,disabled:E.busy,children:[Q?(0,j.jsx)(_,{size:16,className:`ui-spinner`}):(0,j.jsx)(ee,{size:16}),e(Q?`profile.backup.status.exporting`:`profile.backup.action.exportLocal`)]}),(0,j.jsxs)(`button`,{type:`button`,className:`btn btn-secondary ${$?`btn-loading`:``}`,onClick:ve,disabled:E.busy,children:[$?(0,j.jsx)(_,{size:16,className:`ui-spinner`}):(0,j.jsx)(ne,{size:16}),e($?`profile.backup.status.importing`:`profile.backup.action.importLocal`)]}),(0,j.jsxs)(`button`,{type:`button`,className:`btn btn-primary ${X?`btn-loading`:``}`,onClick:ge,disabled:E.busy,children:[X?(0,j.jsx)(_,{size:16,className:`ui-spinner`}):(0,j.jsx)(ie,{size:16}),e(X?`profile.backup.status.backingUp`:`profile.backup.action.cloudBackup`)]}),(0,j.jsxs)(`button`,{type:`button`,className:`btn btn-secondary ${Z?`btn-loading`:``}`,onClick:_e,disabled:E.busy,children:[Z?(0,j.jsx)(_,{size:16,className:`ui-spinner`}):(0,j.jsx)(re,{size:16}),e(Z?`profile.backup.status.restoring`:`profile.backup.action.cloudRestore`)]})]})]}),(0,j.jsxs)(`header`,{className:`profile-header`,children:[(0,j.jsx)(`img`,{className:`profile-avatar-large`,src:de,alt:``}),(0,j.jsxs)(`div`,{className:`profile-heading`,children:[(0,j.jsx)(`p`,{className:`profile-kicker`,children:e(`profile.kicker`)}),(0,j.jsx)(`h1`,{children:r.displayName||r.username}),(0,j.jsxs)(`div`,{className:`profile-address-line`,children:[(0,j.jsx)(`code`,{translate:`no`,children:K}),(0,j.jsx)(h,{text:K}),(0,j.jsxs)(`a`,{href:`https://debank.com/profile/${r.address}`,target:`_blank`,rel:`noopener noreferrer`,className:`btn btn-secondary btn-sm`,children:[(0,j.jsx)(d,{size:14}),e(`web3.action.view`)]})]})]}),(0,j.jsxs)(`button`,{type:`button`,className:`btn btn-secondary profile-logout-btn`,onClick:()=>U(!0),children:[(0,j.jsx)(ae,{size:16}),e(`account.logout`)]})]}),(0,j.jsxs)(`div`,{className:`profile-grid`,children:[(0,j.jsxs)(`section`,{className:`profile-panel`,children:[(0,j.jsx)(`div`,{className:`profile-panel-header`,children:(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`h2`,{children:e(`profile.section.account`)}),(0,j.jsx)(`p`,{children:e(`profile.section.account.desc`)})]})}),(0,j.jsxs)(`label`,{className:`profile-field`,children:[(0,j.jsx)(`span`,{children:e(`profile.label.displayName`)}),(0,j.jsxs)(`div`,{className:`profile-field-row`,children:[(0,j.jsx)(`input`,{className:`input`,value:M,onChange:e=>F(e.target.value),placeholder:e(`nav.displayNamePlaceholder`)}),(0,j.jsxs)(`button`,{type:`button`,className:`btn btn-primary`,onClick:pe,children:[(0,j.jsx)(v,{size:16}),e(`profile.action.save`)]})]})]}),(0,j.jsxs)(`div`,{className:`profile-facts`,children:[(0,j.jsx)(N,{label:e(`profile.label.username`),value:r.username}),(0,j.jsx)(N,{label:e(`web3.label.address`),value:r.address,copy:!0})]})]}),(0,j.jsxs)(`section`,{className:`profile-panel`,children:[(0,j.jsx)(`div`,{className:`profile-panel-header`,children:(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`h2`,{children:e(`profile.section.avatar`)}),(0,j.jsx)(`p`,{children:e(`profile.section.avatar.desc`)})]})}),(0,j.jsx)(`div`,{className:`profile-avatar-grid`,role:`list`,children:se.map(t=>{let n=ue===t.value;return(0,j.jsxs)(`button`,{type:`button`,className:[`profile-avatar-option`,n?`selected`:``].filter(Boolean).join(` `),onClick:()=>J(t.value),"aria-pressed":n,title:e(t.labelKey),children:[(0,j.jsx)(`img`,{src:S(r.address,t.value),alt:``,"aria-hidden":`true`}),(0,j.jsx)(`span`,{children:e(t.labelKey)}),n&&(0,j.jsx)(`span`,{className:`profile-avatar-check`,children:(0,j.jsx)(u,{size:14})})]},t.value||`address`)})}),(0,j.jsxs)(`div`,{className:`profile-avatar-url`,children:[(0,j.jsxs)(`label`,{className:`profile-field`,htmlFor:`profile-avatar-url`,children:[(0,j.jsx)(`span`,{children:e(`profile.label.customAvatar`)}),(0,j.jsxs)(`div`,{className:`profile-field-row`,children:[(0,j.jsx)(`input`,{id:`profile-avatar-url`,className:`input`,value:I,onChange:e=>{L(e.target.value),z(``)},placeholder:e(`nav.avatarUrlPlaceholder`)}),(0,j.jsxs)(`button`,{type:`button`,className:`btn btn-secondary`,onClick:me,disabled:!fe,children:[(0,j.jsx)(v,{size:16}),e(`profile.action.save`)]})]})]}),R&&(0,j.jsx)(`p`,{className:`profile-error`,children:R})]})]})]}),(0,j.jsxs)(`section`,{className:`profile-panel profile-identity-panel`,children:[(0,j.jsxs)(`div`,{className:`profile-panel-header`,children:[(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`h2`,{children:e(`profile.section.identity`)}),(0,j.jsx)(`p`,{children:e(`profile.section.identity.desc`)})]}),(0,j.jsxs)(i,{to:`/web3/`,hash:`wallet`,className:`btn btn-secondary`,children:[(0,j.jsx)(oe,{size:16}),e(`profile.action.openWallet`)]})]}),(0,j.jsxs)(`div`,{className:`profile-key-grid`,children:[G&&(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(P,{title:e(`web3.label.ed25519Public`),icon:(0,j.jsx)(f,{size:18}),value:G.ed_public_key}),(0,j.jsx)(P,{title:e(`web3.label.x25519Public`),icon:(0,j.jsx)(g,{size:18}),value:G.public_key})]}),(0,j.jsx)(P,{title:`IPNS ID`,icon:(0,j.jsx)(te,{size:18}),value:le||`-`})]})]})]})}),H&&(0,j.jsx)(s,{title:e(`account.logoutTitle`),message:e(`account.logoutConfirm`),confirmText:e(`account.logout`),danger:!0,onConfirm:he,onClose:()=>U(!1)}),B&&(0,j.jsx)(s,{title:B.title,message:B.message,confirmText:B.confirmText,danger:B.danger,onConfirm:B.onConfirm,onClose:B.onClose||(()=>V(null))})]})}function N({label:e,value:t,copy:n=!1}){return(0,j.jsxs)(`div`,{className:`profile-fact`,children:[(0,j.jsx)(`span`,{children:e}),(0,j.jsxs)(`div`,{className:`profile-fact-value`,children:[(0,j.jsx)(`code`,{translate:`no`,children:t}),n&&(0,j.jsx)(h,{text:t})]})]})}function P({title:e,icon:t,value:n}){return(0,j.jsxs)(`div`,{className:`profile-key-card`,children:[(0,j.jsxs)(`div`,{className:`profile-key-card-header`,children:[(0,j.jsx)(`span`,{className:`profile-key-card-icon`,children:t}),(0,j.jsx)(`span`,{children:e})]}),(0,j.jsxs)(`div`,{className:`mono-row`,children:[(0,j.jsx)(`code`,{className:`mono`,translate:`no`,children:n}),(0,j.jsx)(h,{text:n})]})]})}var F=a(`/profile/`)({component:M});export{F as Route};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e,o as t,t as n}from"./jsx-runtime-Bt-cYkS5.js";import{C as r,D as i,T as a}from"./ui-BpDGD3IR.js";import{a as o}from"./i18n-NjvOSuV6.js";import{n as s,t as c}from"./smartphone-tRRFFO0a.js";import{t as l}from"./download-jEPn2njL.js";import{F as u}from"./index-BZ-f0CZd.js";import{t as d}from"./MarketingHeader-CrYsQsQ5.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:c},{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}=o(),[t,n]=(0,v.useState)(null),[r,i]=(0,v.useState)(V?`loading`:`fallback`),[a,c]=(0,v.useState)(`windows:x64`),[d,p]=(0,v.useState)(`r2`);(0,v.useEffect)(()=>{c(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)(l,{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)(l,{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)(s,{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}=o();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)(l,{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)(i,{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=a(`/download/`)({component:J});export{Y as Route};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e,o as t,t as n}from"./jsx-runtime-Bt-cYkS5.js";import{C as r,D as i,T as a,o}from"./ui-BpDGD3IR.js";import{a as s}from"./i18n-NjvOSuV6.js";import{t as c}from"./arrow-right-BU9c_SL4.js";import{i as l}from"./LanguageToggle-CSQtRZ3A.js";import{t as u}from"./download-jEPn2njL.js";import{t as d}from"./external-link-BFaoZeK0.js";import{t as f}from"./hard-drive-Dar_AZEq.js";import{t as p}from"./message-square-Dp09WY1I.js";import{t as m}from"./notebook-pen-C8TlK5sB.js";import{t as h}from"./wallet-T7ONZ3Kg.js";import{M as g,c as _}from"./index-BZ-f0CZd.js";import{t as v}from"./MarketingLayout-CQurMOSD.js";var y=r(`arrow-up-right`,[[`path`,{d:`M7 7h10v10`,key:`1tivn9`}],[`path`,{d:`M7 17 17 7`,key:`1vkiza`}]]),b=r(`folder-open`,[[`path`,{d:`m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2`,key:`usdka0`}]]),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)(b,{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`}]}];function T(){let e=_(e=>e.hasBackend),t=_(e=>e.openConnectModal),[n,r]=(0,S.useState)(`app`),{t:a}=s(),p=o(),m=w.find(e=>e.id===n)||w[0],h=a(m.titleKey),v=m.steps.filter(e=>!(p&&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:a(`common.brand`)}),(0,C.jsx)(`p`,{className:`portal-hero-subtitle`,children:a(`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:w.map(t=>{let o=n===t.id,s=t.requiresBackend,c=s?e===!0?`connected`:e===!1?`disconnected`:`checking`:`none`,l=a(t.titleKey);return(0,C.jsxs)(`button`,{className:`portal-card ${o?`active`:``}`,onClick:()=>r(t.id),children:[(0,C.jsx)(i,{to:t.path,className:`btn btn-icon portal-card-open-btn`,onClick:e=>e.stopPropagation(),title:a(`portal.openFeature`,{title:l}),children:(0,C.jsx)(y,{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:a(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`}),a(`common.status.checking`)]}),c===`connected`&&(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(`span`,{className:`status-dot connected`}),a(`common.status.connected`)]}),c===`disconnected`&&(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(`span`,{className:`status-dot disconnected`}),a(`common.status.needsConnection`)]})]}):(0,C.jsxs)(`div`,{className:`ui-badge portal-card-status ready`,children:[(0,C.jsx)(`span`,{className:`status-dot ready`}),a(`common.status.ready`)]})]},t.id)})}),(0,C.jsxs)(`div`,{className:`portal-node-actions`,"aria-label":a(`portal.nodeEntry`),children:[(0,C.jsxs)(`button`,{onClick:t,className:`btn btn-secondary`,children:[(0,C.jsx)(g,{size:16}),a(`portal.webConnectNode`)]}),(0,C.jsxs)(i,{to:`/admin/`,className:`btn btn-secondary`,children:[(0,C.jsx)(f,{size:16}),a(`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:a(m.heroKey)}),(0,C.jsx)(`p`,{children:a(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)(l,{size:14,strokeWidth:3})}),(0,C.jsx)(`span`,{children:a(e)})]},e))}),(0,C.jsx)(`div`,{className:`portal-marketing-steps`,children:v.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:a(e.titleKey)}),(0,C.jsx)(`p`,{children:a(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)(i,{to:e.link,children:[a(e.linkTextKey),` `,(0,C.jsx)(d,{size:12})]})})]})]},e.num))}),(0,C.jsxs)(`div`,{className:`portal-actions`,children:[(0,C.jsxs)(i,{to:m.path,className:`btn btn-primary`,children:[a(`portal.enterFeature`,{title:h}),(0,C.jsx)(c,{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)(g,{size:16}),a(`portal.webConnectNode`)]}),!p&&(0,C.jsxs)(i,{to:`/download/`,className:`btn btn-secondary`,children:[(0,C.jsx)(u,{size:16}),a(`nav.downloadClient`)]})]})]})]})})})]})}function E(){return(0,C.jsx)(v,{children:(0,C.jsx)(T,{})})}var D=a(`/`)({component:E});export{D as Route};
|