most-box 0.3.4 → 0.3.6
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/out/about/index.html +20 -0
- package/out/admin/index.html +0 -0
- package/out/app/index.html +0 -0
- package/out/assets/AccountMenu-B26qus-Q.js +1 -0
- package/out/assets/AppShell-BiYQsNO8.js +1 -0
- package/out/assets/AppTop-D-qYC0ep.js +1 -0
- package/out/assets/ChatRestoringIndicator-CLV78gNW.js +1 -0
- package/out/assets/CopyButton-BrEkzqEq.js +1 -0
- package/out/assets/MarketingHeader-CJXpogPY.js +1 -0
- package/out/assets/MarketingLayout-Ch4sw5Qm.js +1 -0
- package/out/assets/{MilkdownEditor-BzbYt-xb.js → MilkdownEditor-DfhuT9eU.js} +1 -1
- package/out/assets/OpenSidebarButton-Bvwr7B6k.js +1 -0
- package/out/assets/arrow-right-BsHzC0ZL.js +1 -0
- package/out/assets/{arrow-up-down-B-677ip8.js → arrow-up-down-DvLSz6Ma.js} +1 -1
- package/out/assets/{userProfile-BZvkCuet.js → channelApi-C5eHetoJ.js} +1 -1
- package/out/assets/chatJoinInvite-7tuD-STm.js +1 -0
- package/out/assets/{chatNoteDraft-CYbvcEvC.js → chatNoteDraft-DTy6In5R.js} +1 -1
- package/out/assets/{circle-alert-dfN4T6Nq.js → circle-alert-DXVkx8p8.js} +1 -1
- package/out/assets/{copy-B7pPZ2MP.js → copy-OwXDsstV.js} +1 -1
- package/out/assets/{download-COQOcPqI.js → download-Cy2BlfKM.js} +1 -1
- package/out/assets/downloadValidation-Dd43i9_9.js +1 -0
- package/out/assets/{external-link-D6tHlYgS.js → external-link-D_AQSgxW.js} +1 -1
- package/out/assets/{file-text-DiyIGL1I.js → file-text-zvTER2mN.js} +1 -1
- package/out/assets/fingerprint-pattern-BT73ASEB.js +1 -0
- package/out/assets/{folder-BS_GbpPQ.js → folder-6pYYnS2-.js} +1 -1
- package/out/assets/folder-open-DOJ4bB58.js +1 -0
- package/out/assets/format-CAKfypjK.js +1 -0
- package/out/assets/gamepad-2-BYqNgCQr.js +1 -0
- package/out/assets/{hard-drive-Cqa7Rstj.js → hard-drive-DL1KJHmG.js} +1 -1
- package/out/assets/i18n-DKsg67mH.js +1 -0
- package/out/assets/index-FEwag7ej.css +1 -0
- package/out/assets/index-mjFWLwue.js +31 -0
- package/out/assets/index.lazy-8GSHLIGt.js +3 -0
- package/out/assets/index.lazy-B3jH9yBA.js +1 -0
- package/out/assets/index.lazy-B5JMiv3z.js +1 -0
- package/out/assets/index.lazy-BAr7-dhf.js +1 -0
- package/out/assets/index.lazy-BMFwyE_Z.js +3 -0
- package/out/assets/index.lazy-BbA_1LnY.js +1 -0
- package/out/assets/index.lazy-BmpOpQqg.js +1 -0
- package/out/assets/index.lazy-CB3C6kMj.js +1 -0
- package/out/assets/index.lazy-CVOAOO0_.js +1 -0
- package/out/assets/index.lazy-CyFSwJuo.js +1 -0
- package/out/assets/index.lazy-D3iEq2ZW.js +2 -0
- package/out/assets/index.lazy-F3iHN_Ao.js +1 -0
- package/out/assets/index.lazy-PnZR3z1V.js +5 -0
- package/out/assets/index.lazy-qDpRLqXu.js +1 -0
- package/out/assets/index.lazy-s6Ok77GI.js +1 -0
- package/out/assets/{loader-CwyHYZdX.js → loader-C4pED_QP.js} +1 -1
- package/out/assets/lock-yG7M7GkB.js +1 -0
- package/out/assets/{message-square-BgsNXPft.js → message-square-CfApq8Ou.js} +1 -1
- package/out/assets/mp-cEQteKUC.js +1 -0
- package/out/assets/{music-Dn9nm9Qb.js → music-Br2x8TKX.js} +1 -1
- package/out/assets/notebook-pen-Bcd3MrtD.js +1 -0
- package/out/assets/play-DSHtNcOe.js +1 -0
- package/out/assets/{refresh-cw-D4BsHvhi.js → refresh-cw-CfkUlTK9.js} +1 -1
- package/out/assets/{save-B02sbO9Y.js → save-CfYzXcxH.js} +1 -1
- package/out/assets/saveLocalFile-BLTn3Z18.js +1 -0
- package/out/assets/search-DLBOUfny.js +1 -0
- package/out/assets/{send-4dhnJGuS.js → send-Bie9hgHI.js} +1 -1
- package/out/assets/{shield-check-Boae7Nc6.js → shield-check-2-h_eEXp.js} +1 -1
- package/out/assets/{smartphone-JXH-zQXB.js → smartphone-CrsocYJo.js} +1 -1
- package/out/assets/trash-2-B9gno5q6.js +1 -0
- package/out/assets/{triangle-alert-B9sMiA9l.js → triangle-alert-BhNtjKm2.js} +1 -1
- package/out/assets/{upload-DVuXJt_o.js → upload-BmufnMFu.js} +1 -1
- package/out/assets/{useAppStore-DOnk608w.js → useAppStore-DNhyhD20.js} +1 -1
- package/out/assets/useChannelMessages-DKlO_2oW.js +4 -0
- package/out/assets/useGameRoom-DLN636mz.js +1 -0
- package/out/assets/{wallet-D9Iw4YWE.js → wallet-D6HZocla.js} +1 -1
- package/out/assets/{wifi-ljEI_ySA.js → wifi-CILQyKk0.js} +1 -1
- package/out/chat/index.html +0 -0
- package/out/chat/join/demo/index.html +0 -0
- package/out/chat/join/index.html +0 -0
- package/out/download/index.html +2 -2
- package/out/game/gandengyan/index.html +0 -0
- package/out/game/index.html +0 -0
- package/out/game/zhajinhua/index.html +0 -0
- package/out/index.html +2 -2
- package/out/note/index.html +0 -0
- package/out/ping/index.html +2 -2
- package/out/profile/index.html +0 -0
- package/out/web3/index.html +0 -0
- package/package.json +1 -1
- package/server/index.js +18 -1
- package/server/src/core/channelVoice.js +164 -0
- package/server/src/core/mostLink.js +30 -13
- package/server/src/http/nodeStatus.js +2 -2
- package/server/src/http/routes/fileRoutes.js +10 -8
- package/server/src/http/uploads.js +53 -15
- package/server/src/index.js +317 -133
- package/server/src/node/config.js +4 -4
- package/server/src/utils/api.js +9 -1
- package/server/src/utils/avatar.js +1 -10
- package/server/src/utils/downloadMessages.js +7 -7
- package/server/src/utils/errors.js +11 -1
- package/server/src/utils/userIdentity.js +0 -1
- package/out/assets/AccountMenu-ptQklqvD.js +0 -1
- package/out/assets/AppTop-Cy0ZOCxO.js +0 -1
- package/out/assets/CopyButton-C8PIDSJZ.js +0 -1
- package/out/assets/FilePreviewOverlay-faaTnmlN.js +0 -1
- package/out/assets/MarketingHeader-CxJ_OVOW.js +0 -1
- package/out/assets/MarketingLayout-CiN5KYcE.js +0 -1
- package/out/assets/OpenSidebarButton-CGhXxQ5Z.js +0 -1
- package/out/assets/arrow-right-CXzRt0Fp.js +0 -1
- package/out/assets/chatJoinInvite-B-ucvYdg.js +0 -1
- package/out/assets/check-iBCQl0yr.js +0 -1
- package/out/assets/chevron-right-D75NRNNs.js +0 -1
- package/out/assets/downloadValidation-UPgpJbKz.js +0 -1
- package/out/assets/format-CR8oUWq6.js +0 -1
- package/out/assets/index-D0Uk9-58.js +0 -31
- package/out/assets/index-FV6RZlVI.css +0 -1
- package/out/assets/index.lazy-B6XDJ8fg.js +0 -1
- package/out/assets/index.lazy-BFdWbm3R.js +0 -1
- package/out/assets/index.lazy-BzIt7fP4.js +0 -1
- package/out/assets/index.lazy-CLkb32nv.js +0 -1
- package/out/assets/index.lazy-CNmqW4-r.js +0 -1
- package/out/assets/index.lazy-Cnkj-gAd.js +0 -3
- package/out/assets/index.lazy-Cx1bp84f.js +0 -5
- package/out/assets/index.lazy-CxLzR674.js +0 -2
- package/out/assets/index.lazy-D4RjTGu-.js +0 -3
- package/out/assets/index.lazy-D9xLqvqW.js +0 -1
- package/out/assets/index.lazy-DNCF6MTJ.js +0 -1
- package/out/assets/index.lazy-MY-mUG5Z.js +0 -1
- package/out/assets/index.lazy-erUKA2rI.js +0 -1
- package/out/assets/index.lazy-qTjgLKhY.js +0 -1
- package/out/assets/key-round-JR8M3aHl.js +0 -1
- package/out/assets/lock-CuwwlXlx.js +0 -1
- package/out/assets/mp-Dv12gDTx.js +0 -1
- package/out/assets/notebook-pen-BzrCXQJE.js +0 -1
- package/out/assets/play-CvWKSMwY.js +0 -1
- package/out/assets/search-HW4oPOBP.js +0 -1
- package/out/assets/trash-2-BLwoM0ME.js +0 -1
- package/out/assets/useChannelMessages-CDvw-f_x.js +0 -4
- package/out/assets/useGameRoom-CS1w4IqP.js +0 -1
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{n as e,o as t,t as n}from"./jsx-runtime-Bt-cYkS5.js";import{A as r,B as i,E as a,F as o,H as s,I as c,N as l,O as u,R as d,k as f,t as p}from"./useAppStore-DOnk608w.js";import{n as m,r as h,t as g}from"./mp-Dv12gDTx.js";import{n as _,t as v}from"./lock-CuwwlXlx.js";import{t as y}from"./download-COQOcPqI.js";import{t as b}from"./external-link-D6tHlYgS.js";import{t as x}from"./key-round-JR8M3aHl.js";import{i as S}from"./AccountMenu-ptQklqvD.js";import{n as C,t as w}from"./AppTop-Cy0ZOCxO.js";import{t as T}from"./wallet-D9Iw4YWE.js";import{A as E,T as D,f as ee,w as O}from"./index-D0Uk9-58.js";import{t as k}from"./CopyButton-C8PIDSJZ.js";var te=i(`chevron-up`,[[`path`,{d:`m18 15-6-6-6 6`,key:`153udz`}]]),ne=i(`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`}]]),re=i(`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`}]]),ie=i(`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`}]]),ae=i(`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`}]]),A=t(e()),j=n();function oe(e){return e?`•`.repeat(Math.min(e.length,32)):`-`}function se({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}=E();return(0,j.jsxs)(`div`,{className:`web3-box-account`,children:[(0,j.jsx)(`div`,{className:`web3-box-account-header`,children:(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`h2`,{children:e}),(0,j.jsx)(`p`,{children:d(`web3.box.account.desc`)})]})}),(0,j.jsxs)(`div`,{className:`web3-box-login`,children:[(0,j.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,j.jsxs)(`div`,{className:`input-wrap`,children:[(0,j.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,j.jsx)(`button`,{className:`input-eye`,onClick:c,type:`button`,children:r?(0,j.jsx)(D,{size:16}):(0,j.jsx)(O,{size:16})})]}),(0,j.jsxs)(`button`,{className:`btn btn-primary btn-full`,onClick:u,disabled:!t.trim(),type:`button`,children:[(0,j.jsx)(x,{size:16}),d(`web3.box.account.generate`)]})]}),a?(0,j.jsxs)(`div`,{className:`web3-box-key-list`,children:[(0,j.jsxs)(`div`,{className:`web3-box-key-row`,children:[(0,j.jsx)(`span`,{children:d(`web3.label.address`)}),(0,j.jsxs)(`div`,{className:`mono-row`,children:[(0,j.jsx)(`code`,{className:`mono`,translate:`no`,children:a.address.toLowerCase()}),(0,j.jsx)(k,{text:a.address.toLowerCase()})]})]}),(0,j.jsxs)(`div`,{className:`web3-box-key-row`,children:[(0,j.jsx)(`span`,{children:d(`web3.label.x25519Public`)}),(0,j.jsxs)(`div`,{className:`mono-row`,children:[(0,j.jsx)(`code`,{className:`mono`,translate:`no`,children:a.publicKey}),(0,j.jsx)(k,{text:a.publicKey})]})]}),(0,j.jsxs)(`div`,{className:`web3-box-key-row`,children:[(0,j.jsx)(`span`,{children:d(`web3.label.x25519Private`)}),(0,j.jsxs)(`div`,{className:`mono-row danger`,children:[(0,j.jsx)(`code`,{className:`mono`,translate:`no`,children:i?a.privateKey:oe(a.privateKey)}),(0,j.jsx)(`button`,{className:`btn btn-icon`,onClick:l,title:d(i?`web3.action.hidePrivateKey`:`web3.action.showPrivateKey`),type:`button`,children:i?(0,j.jsx)(O,{size:14}):(0,j.jsx)(D,{size:14})})]})]})]}):null]})}function ce(e,t){return Number.isFinite(e)?t(e):`-`}function M({title:e,description:t,message:n,cipherText:r,decryptedText:i,error:a,encryptLabel:o,decryptLabel:s,messagePlaceholder:l,cipherPlaceholder:u,onMessageChange:d,onCipherTextChange:f,onEncrypt:p,onDecrypt:m}){let{t:h,formatDateTime:g}=E(),_=`box-message-${e.replaceAll(/\s+/g,`-`)}`,y=c(r);return(0,j.jsxs)(`section`,{className:`web3-box-flow`,children:[(0,j.jsx)(`div`,{className:`web3-box-flow-header`,children:(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`h2`,{children:e}),(0,j.jsx)(`p`,{children:t})]})}),(0,j.jsx)(`label`,{className:`web3-box-label`,htmlFor:_,children:h(`web3.box.plaintext`)}),(0,j.jsx)(`textarea`,{id:_,className:`textarea`,value:n,onChange:e=>d(e.target.value),rows:4,placeholder:l,translate:`no`}),(0,j.jsxs)(`div`,{className:`web3-box-actions`,children:[(0,j.jsxs)(`button`,{className:`btn btn-primary`,onClick:p,type:`button`,children:[(0,j.jsx)(v,{size:16}),o]}),(0,j.jsxs)(`button`,{className:`btn btn-secondary`,onClick:m,type:`button`,children:[(0,j.jsx)(x,{size:16}),s]})]}),a&&(0,j.jsx)(`p`,{className:`web3-tools-danger`,children:a}),(0,j.jsxs)(`div`,{className:`web3-box-result-grid`,children:[(0,j.jsxs)(`div`,{className:`web3-box-result`,children:[(0,j.jsx)(`label`,{className:`web3-box-result-header`,children:(0,j.jsx)(`span`,{children:h(`web3.box.ciphertext`)})}),(0,j.jsx)(`textarea`,{className:`textarea mono`,value:r,onChange:e=>f(e.target.value),rows:5,placeholder:u,translate:`no`})]}),(0,j.jsxs)(`div`,{className:`web3-box-result`,children:[(0,j.jsx)(`label`,{className:`web3-box-result-header`,children:(0,j.jsx)(`span`,{children:h(`web3.box.decryptResult`)})}),(0,j.jsx)(`textarea`,{className:`textarea mono`,value:i,readOnly:!0,rows:5,placeholder:h(`web3.box.decryptResultPlaceholder`),translate:`no`})]})]}),y&&(0,j.jsxs)(`div`,{className:`web3-box-token-meta`,children:[(0,j.jsxs)(`div`,{className:`web3-box-token-meta-row`,children:[(0,j.jsx)(`span`,{children:h(`web3.box.timestamp`)}),(0,j.jsx)(`code`,{translate:`no`,children:ce(y.timestampMs,g)})]}),(0,j.jsxs)(`div`,{className:`web3-box-token-meta-row`,children:[(0,j.jsx)(`span`,{children:h(`web3.box.nonce`)}),(0,j.jsx)(`code`,{translate:`no`,children:y.nonce})]})]})]})}function le(e){let{t}=E();return(0,j.jsxs)(`div`,{className:`web3-box-workspace`,children:[(0,j.jsxs)(`div`,{className:`web3-box-grid`,children:[(0,j.jsx)(se,{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,j.jsx)(se,{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,j.jsxs)(`div`,{className:`web3-box-flow-grid`,children:[(0,j.jsx)(M,{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,j.jsx)(M,{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,j.jsxs)(`div`,{className:`web3-box-flow-grid`,children:[(0,j.jsxs)(`section`,{className:`web3-box-flow`,children:[(0,j.jsx)(`div`,{className:`web3-box-flow-header`,children:(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`h2`,{children:t(`web3.box.encryptTitle`)}),(0,j.jsx)(`p`,{children:t(`web3.box.encryptDesc`)})]})}),(0,j.jsx)(`label`,{className:`web3-box-result-header`,children:(0,j.jsx)(`span`,{children:t(`web3.box.sender`)})}),(0,j.jsxs)(`div`,{className:`input-wrap`,children:[(0,j.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,j.jsx)(`button`,{className:`input-eye`,onClick:e.onBoxEncryptShowPrivateKeyToggle,type:`button`,children:e.boxEncryptShowPrivateKey?(0,j.jsx)(D,{size:16}):(0,j.jsx)(O,{size:16})})]}),(0,j.jsx)(`label`,{className:`web3-box-result-header`,children:(0,j.jsx)(`span`,{children:t(`web3.box.recipient`)})}),(0,j.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,j.jsx)(`label`,{className:`web3-box-result-header`,children:(0,j.jsx)(`span`,{children:t(`web3.box.plaintext`)})}),(0,j.jsx)(`textarea`,{className:`textarea`,value:e.boxEncryptMessage,onChange:t=>e.onBoxEncryptMessageChange(t.target.value),rows:4,placeholder:t(`web3.box.messagePlaceholder`),translate:`no`}),(0,j.jsx)(`div`,{className:`web3-box-actions`,children:(0,j.jsxs)(`button`,{className:`btn btn-primary`,onClick:e.onEncryptOnly,type:`button`,children:[(0,j.jsx)(v,{size:16}),t(`web3.box.encryptTitle`)]})}),e.boxEncryptError&&(0,j.jsx)(`p`,{className:`web3-tools-danger`,children:e.boxEncryptError}),(0,j.jsxs)(`div`,{className:`web3-box-result`,children:[(0,j.jsx)(`label`,{className:`web3-box-result-header`,children:(0,j.jsx)(`span`,{children:t(`web3.box.ciphertext`)})}),(0,j.jsx)(`textarea`,{className:`textarea mono`,value:e.boxEncryptCipherText,readOnly:!0,rows:5,placeholder:t(`web3.box.encryptResultPlaceholder`),translate:`no`})]})]}),(0,j.jsxs)(`section`,{className:`web3-box-flow`,children:[(0,j.jsx)(`div`,{className:`web3-box-flow-header`,children:(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`h2`,{children:t(`web3.box.decryptTitle`)}),(0,j.jsx)(`p`,{children:t(`web3.box.decryptDesc`)})]})}),(0,j.jsx)(`label`,{className:`web3-box-result-header`,children:(0,j.jsx)(`span`,{children:t(`web3.box.sender`)})}),(0,j.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,j.jsx)(`label`,{className:`web3-box-result-header`,children:(0,j.jsx)(`span`,{children:t(`web3.box.recipient`)})}),(0,j.jsxs)(`div`,{className:`input-wrap`,children:[(0,j.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,j.jsx)(`button`,{className:`input-eye`,onClick:e.onBoxDecryptShowPrivateKeyToggle,type:`button`,children:e.boxDecryptShowPrivateKey?(0,j.jsx)(D,{size:16}):(0,j.jsx)(O,{size:16})})]}),(0,j.jsx)(`label`,{className:`web3-box-result-header`,children:(0,j.jsx)(`span`,{children:t(`web3.box.ciphertext`)})}),(0,j.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,j.jsx)(`div`,{className:`web3-box-actions`,children:(0,j.jsxs)(`button`,{className:`btn btn-secondary`,onClick:e.onDecryptOnly,type:`button`,children:[(0,j.jsx)(x,{size:16}),t(`web3.box.decryptTitle`)]})}),e.boxDecryptError&&(0,j.jsx)(`p`,{className:`web3-tools-danger`,children:e.boxDecryptError}),(0,j.jsxs)(`div`,{className:`web3-box-result`,children:[(0,j.jsx)(`label`,{className:`web3-box-result-header`,children:(0,j.jsx)(`span`,{children:t(`web3.box.decryptResult`)})}),(0,j.jsx)(`textarea`,{className:`textarea mono`,value:e.boxDecryptResult,readOnly:!0,rows:5,placeholder:t(`web3.box.decryptResultPlaceholder`),translate:`no`})]})]})]})]})}function N({icon:e,message:t,className:n=`empty-state glass`}){return(0,j.jsxs)(`div`,{className:n,children:[(0,j.jsx)(`div`,{className:`empty-state-icon`,children:e}),(0,j.jsx)(`p`,{children:t})]})}function ue({label:e,pem:t,filename:n}){let{t:r}=E();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,j.jsxs)(`div`,{className:`web3-pem-block`,children:[(0,j.jsxs)(`div`,{className:`web3-pem-header`,children:[(0,j.jsx)(`span`,{className:`web3-pem-label`,children:e}),(0,j.jsxs)(`div`,{className:`web3-pem-actions`,children:[(0,j.jsx)(k,{text:t,label:r(`common.copy`),className:`btn btn-sm`,iconSize:14}),(0,j.jsxs)(`button`,{type:`button`,className:`btn btn-sm btn-primary`,onClick:i,title:r(`common.download`),children:[(0,j.jsx)(y,{size:14}),r(`common.download`)]})]})]}),(0,j.jsx)(`textarea`,{className:`textarea mono`,value:t,readOnly:!0,rows:6,translate:`no`})]})}function de({walletResult:e,publicPem:t,privatePem:n}){let{t:r}=E();if(!t||!n)return(0,j.jsx)(N,{icon:(0,j.jsx)(v,{size:36}),message:r(`web3.empty.pem`)});let i=e?.username||`wallet`;return(0,j.jsxs)(`div`,{className:`web3-pem-list`,children:[(0,j.jsx)(ue,{label:`${i}.pub`,pem:t,filename:`${i}.pub`}),(0,j.jsx)(ue,{label:`${i}.pem`,pem:n,filename:`${i}.pem`})]})}var fe=Object.defineProperty,P=Object.getOwnPropertySymbols,pe=Object.prototype.hasOwnProperty,F=Object.prototype.propertyIsEnumerable,me=(e,t,n)=>t in e?fe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,I=(e,t)=>{for(var n in t||={})pe.call(t,n)&&me(e,n,t[n]);if(P)for(var n of P(t))F.call(t,n)&&me(e,n,t[n]);return e},L=(e,t)=>{var n={};for(var r in e)pe.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&P)for(var r of P(e))t.indexOf(r)<0&&F.call(e,r)&&(n[r]=e[r]);return n},R;(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})(R||={}),(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||={})})(R||={}),(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||={})})(R||={});var z=R,he={L:z.QrCode.Ecc.LOW,M:z.QrCode.Ecc.MEDIUM,Q:z.QrCode.Ecc.QUARTILE,H:z.QrCode.Ecc.HIGH},B=128,V=`L`,H=`#FFFFFF`,U=`#000000`,W=!1,G=1,ge=4,_e=0,ve=.1;function K(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 ye(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 be(e,t,n,r){if(r==null)return null;let i=e.length+n*2,a=Math.floor(t*ve),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 xe(e,t){return t==null?e?ge:_e: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=A.useMemo(()=>{let r=(Array.isArray(e)?e:[e]).reduce((e,t)=>(e.push(...z.QrSegment.makeSegments(t)),e),[]);return z.QrCode.encodeSegments(r,he[t],n,void 0,void 0,s)},[e,t,n,s]),{cells:l,margin:u,numCells:d,calculatedImageSettings:f}=A.useMemo(()=>{let e=c.getModules(),t=xe(r,i);return{cells:e,margin:t,numCells:e.length+t*2,calculatedImageSettings:be(e,o,t,a)}},[c,o,a,r,i]);return{qrcode:c,margin:u,cells:l,numCells:d,calculatedImageSettings:f}}var Se=function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0}(),Ce=A.forwardRef(function(e,t){let n=e,{value:r,size:i=B,level:a=V,bgColor:o=H,fgColor:s=U,includeMargin:c=W,minVersion:l=G,boostLevel:u,marginSize:d,imageSettings:f}=n,p=L(n,[`value`,`size`,`level`,`bgColor`,`fgColor`,`includeMargin`,`minVersion`,`boostLevel`,`marginSize`,`imageSettings`]),{style:m}=p,h=L(p,[`style`]),g=f?.src,_=A.useRef(null),v=A.useRef(null),y=A.useCallback(e=>{_.current=e,typeof t==`function`?t(e):t&&(t.current=e)},[t]),[b,x]=A.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});A.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=ye(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,Se?t.fill(new Path2D(K(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)}}),A.useEffect(()=>{x(!1)},[g]);let E=I({height:i,width:i},m),D=null;return g!=null&&(D=A.createElement(`img`,{src:g,key:g,style:{display:`none`},onLoad:()=>{x(!0)},ref:v,crossOrigin:T?.crossOrigin})),A.createElement(A.Fragment,null,A.createElement(`canvas`,I({style:E,height:i,width:i,ref:y,role:`img`},h)),D)});Ce.displayName=`QRCodeCanvas`;var J=A.forwardRef(function(e,t){let n=e,{value:r,size:i=B,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=L(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=ye(g,v.excavation)),b=A.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=K(y,h);return A.createElement(`svg`,I({height:i,width:i,viewBox:`0 0 ${_} ${_}`,ref:t,role:`img`},m),!!d&&A.createElement(`title`,null,d),A.createElement(`path`,{fill:o,d:`M0,0 h${_}v${_}H0z`,shapeRendering:`crispEdges`}),A.createElement(`path`,{fill:s,d:x,shapeRendering:`crispEdges`}),b)});J.displayName=`QRCodeSVG`;function we({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:p,onToggleDeriveAddress:m,onToggleDerivePrivateKey:h,onDerive:g}){let{t:v}=E(),y=e?.address||``;return!e||!y?(0,j.jsx)(N,{icon:(0,j.jsx)(T,{size:36}),message:v(`web3.empty.walletTools`)}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsxs)(`div`,{className:`web3-tools-section`,children:[(0,j.jsxs)(`button`,{className:`web3-tools-toggle`,onClick:u,children:[(0,j.jsx)(re,{size:14}),v(s?`web3.action.hideAddressQr`:`web3.action.showAddressQr`),s?(0,j.jsx)(te,{size:14}):(0,j.jsx)(_,{size:14})]}),s&&(0,j.jsxs)(`div`,{className:`web3-mnemonic-reveal`,children:[(0,j.jsxs)(`div`,{className:`web3-mnemonic-card`,children:[(0,j.jsx)(`p`,{className:`web3-mnemonic-text`,translate:`no`,children:y}),(0,j.jsx)(k,{text:y})]}),(0,j.jsx)(`div`,{className:`qr-wrap`,children:(0,j.jsx)(J,{value:y,size:200})})]})]}),t&&(0,j.jsxs)(`div`,{className:`web3-tools-section`,children:[(0,j.jsxs)(`button`,{className:`web3-tools-toggle`,onClick:d,children:[(0,j.jsx)(x,{size:14}),v(c?`web3.action.hideMnemonic`:`web3.action.showMnemonic`),c?(0,j.jsx)(te,{size:14}):(0,j.jsx)(_,{size:14})]}),c&&(0,j.jsxs)(`div`,{className:`web3-mnemonic-reveal`,children:[(0,j.jsxs)(`div`,{className:`web3-mnemonic-card`,children:[(0,j.jsx)(`p`,{className:`web3-mnemonic-text`,translate:`no`,children:t}),(0,j.jsx)(k,{text:t})]}),(0,j.jsxs)(`p`,{className:`web3-tools-danger`,children:[(0,j.jsx)(ie,{size:14}),v(`web3.warning.mnemonic`)]}),(0,j.jsx)(`button`,{className:`web3-tools-toggle`,onClick:f,children:v(l?`web3.action.hideMnemonicQr`:`web3.action.showMnemonicQr`)}),l&&(0,j.jsx)(`div`,{className:`qr-wrap`,children:(0,j.jsx)(J,{value:t,size:260})})]})]}),t&&(0,j.jsxs)(`div`,{className:`web3-mnemonic-reveal`,children:[(0,j.jsx)(`div`,{children:(0,j.jsx)(`button`,{className:`btn btn-primary`,onClick:g,children:v(`web3.action.deriveAddresses`,{count:n})})}),(0,j.jsxs)(`p`,{className:`web3-tools-danger`,children:[(0,j.jsx)(ie,{size:14}),v(`web3.warning.privateKey`)]}),r.length>0&&(0,j.jsx)(`div`,{className:`web3-derive-table-wrap`,children:(0,j.jsxs)(`table`,{className:`web3-derive-table`,children:[(0,j.jsx)(`thead`,{children:(0,j.jsxs)(`tr`,{children:[(0,j.jsx)(`th`,{onClick:p,className:`web3-derive-th`,children:v(`web3.label.account`)}),(0,j.jsx)(`th`,{onClick:m,className:`web3-derive-th`,children:v(`web3.label.address`)}),(0,j.jsx)(`th`,{onClick:h,className:`web3-derive-th danger`,children:v(`web3.label.privateKeyToggle`,{action:v(o?`web3.action.hide`:`web3.action.show`)})})]})}),(0,j.jsx)(`tbody`,{children:r.map(e=>(0,j.jsxs)(`tr`,{children:[(0,j.jsx)(`td`,{children:i?e.index+1:``}),(0,j.jsx)(`td`,{translate:`no`,children:a?e.address:``}),(0,j.jsx)(`td`,{className:`danger`,children:(0,j.jsx)(`span`,{translate:`no`,children:o?e.privateKey:``})})]},e.index))})]})})]})]})}function Y({title:e,icon:t,children:n,accent:r=!1}){return(0,j.jsxs)(`div`,{className:`web3-key-card ${r?`accent`:``}`,children:[(0,j.jsxs)(`div`,{className:`web3-key-card-header`,children:[(0,j.jsx)(`span`,{className:`web3-key-card-icon`,children:t}),(0,j.jsx)(`span`,{className:`web3-key-card-title`,children:e})]}),(0,j.jsx)(`div`,{className:`web3-key-card-body`,translate:`no`,children:n})]})}function Te(e){return e?`•`.repeat(Math.min(e.length,32)):`-`}function Ee({walletResult:e,keys:t,ipns:n,avatarSrc:r,showPrivateKey:i,onTogglePrivateKey:a}){let{t:o}=E(),s=e?.address||``;return!e||!s?(0,j.jsx)(N,{icon:(0,j.jsx)(S,{size:36}),message:o(`web3.empty.identity`)}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsxs)(`div`,{className:`web3-identity-card`,children:[(0,j.jsx)(`img`,{src:r,alt:`avatar`,className:`web3-identity-avatar`}),(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`h1`,{className:`web3-identity-name`,children:e.username||o(`web3.notSignedIn`)}),(0,j.jsxs)(`div`,{className:`web3-identity-address`,children:[(0,j.jsx)(`code`,{translate:`no`,children:s.toLowerCase()}),(0,j.jsx)(k,{text:s.toLowerCase()}),(0,j.jsxs)(`a`,{href:`https://debank.com/profile/${s}`,target:`_blank`,rel:`noopener noreferrer`,className:`link`,children:[(0,j.jsx)(b,{size:14}),o(`web3.action.view`)]})]})]})]}),t&&(0,j.jsxs)(`div`,{className:`web3-key-grid`,children:[(0,j.jsx)(Y,{title:o(`web3.label.ed25519Public`),icon:(0,j.jsx)(h,{size:18}),children:(0,j.jsxs)(`div`,{className:`mono-row`,children:[(0,j.jsx)(`code`,{className:`mono`,translate:`no`,children:t.ed_public_key}),(0,j.jsx)(k,{text:t.ed_public_key})]})}),(0,j.jsx)(Y,{title:o(`web3.label.x25519Public`),icon:(0,j.jsx)(x,{size:18}),children:(0,j.jsxs)(`div`,{className:`mono-row`,children:[(0,j.jsx)(`code`,{className:`mono`,translate:`no`,children:t.public_key}),(0,j.jsx)(k,{text:t.public_key})]})}),(0,j.jsx)(Y,{title:o(`web3.label.combinedPrivate`),icon:(0,j.jsx)(ae,{size:18}),accent:!0,children:(0,j.jsxs)(`div`,{className:`mono-row danger`,children:[(0,j.jsx)(`code`,{className:`mono`,translate:`no`,children:i?t.private_key:Te(t.private_key)}),(0,j.jsx)(`button`,{className:`btn btn-icon`,onClick:a,title:o(i?`web3.action.hidePrivateKey`:`web3.action.showPrivateKey`),type:`button`,children:i?(0,j.jsx)(O,{size:14}):(0,j.jsx)(D,{size:14})})]})}),(0,j.jsx)(Y,{title:`IPNS ID`,icon:(0,j.jsx)(ne,{size:18}),children:(0,j.jsxs)(`div`,{className:`mono-row`,children:[(0,j.jsx)(`code`,{className:`mono`,translate:`no`,children:n}),(0,j.jsx)(k,{text:n})]})})]})]})}function De({username:e,password:t,showPassword:n,generating:r,onUsernameChange:i,onPasswordChange:a,onTogglePassword:o,onGenerate:s}){let{t:c}=E();return(0,j.jsxs)(`div`,{className:`input-panel`,children:[(0,j.jsxs)(`div`,{className:`web3-tools-inputs`,children:[(0,j.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,j.jsxs)(`div`,{className:`input-wrap`,children:[(0,j.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,j.jsx)(`button`,{className:`input-eye`,onClick:o,type:`button`,children:n?(0,j.jsx)(D,{size:16}):(0,j.jsx)(O,{size:16})})]})]}),(0,j.jsx)(`button`,{className:`btn btn-primary btn-full`,onClick:s,disabled:!e.trim()||r,type:`button`,children:r?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(`span`,{className:`spinner`}),c(`web3.login.generating`)]}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(T,{size:16}),c(`web3.login.generateAndSignIn`)]})})]})}var X=e=>btoa(String.fromCharCode(...e)),Oe=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-----`},ke=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-----`},Ae=[`wallet`,`pem`,`export`,`EA`];function je(){let e=window.location.hash.replace(`#`,``);return Ae.includes(e)?e:`wallet`}function Me(){let{t:e}=E(),t=p(e=>e.addToast),n=a(e=>e.setUserIdentity),[i,s]=(0,A.useState)(`wallet`),[c,h]=(0,A.useState)(``),[_,y]=(0,A.useState)(``),[b,D]=(0,A.useState)(!1),[O,k]=(0,A.useState)(null),[te,ne]=(0,A.useState)(null),[re,ie]=(0,A.useState)(``),[ae,oe]=(0,A.useState)(``),[se,ce]=(0,A.useState)(``),[M,N]=(0,A.useState)(``),[ue,fe]=(0,A.useState)([]),[P,pe]=(0,A.useState)(0),[F,me]=(0,A.useState)(!0),[I,L]=(0,A.useState)(!0),[R,z]=(0,A.useState)(!1),[he,B]=(0,A.useState)(!1),[V,H]=(0,A.useState)(!1),[U,W]=(0,A.useState)(!1),[G,ge]=(0,A.useState)(!1),[_e,ve]=(0,A.useState)(!1),[K,ye]=(0,A.useState)(``),[be,xe]=(0,A.useState)(``),[q,Se]=(0,A.useState)(!1),[Ce,J]=(0,A.useState)(!1),[Y,Te]=(0,A.useState)(null),[X,Ae]=(0,A.useState)(``),[Me,Ne]=(0,A.useState)(``),[Pe,Fe]=(0,A.useState)(!1),[Ie,Le]=(0,A.useState)(!1),[Z,Re]=(0,A.useState)(null),[ze,Be]=(0,A.useState)(`Hello B. This is from A.`),[Ve,He]=(0,A.useState)(``),[Ue,We]=(0,A.useState)(``),[Ge,Ke]=(0,A.useState)(``),[qe,Je]=(0,A.useState)(`Hello A. This is from B.`),[Ye,Xe]=(0,A.useState)(``),[Ze,Qe]=(0,A.useState)(``),[$e,et]=(0,A.useState)(``),[tt,nt]=(0,A.useState)(``),[rt,it]=(0,A.useState)(``),[at,ot]=(0,A.useState)(``),[st,ct]=(0,A.useState)(``),[lt,Q]=(0,A.useState)(``),[ut,dt]=(0,A.useState)(!1),[ft,pt]=(0,A.useState)(``),[mt,ht]=(0,A.useState)(``),[gt,_t]=(0,A.useState)(``),[vt,yt]=(0,A.useState)(``),[bt,$]=(0,A.useState)(``),[xt,St]=(0,A.useState)(!1);(0,A.useEffect)(()=>{s(je());let e=()=>s(je());return window.addEventListener(`hashchange`,e),()=>window.removeEventListener(`hashchange`,e)},[]);let Ct=e=>{s(e),window.location.hash=e},wt=(0,A.useCallback)(async()=>{if(!c.trim())return;ve(!0),await new Promise(e=>setTimeout(e,0));let r=o(c.trim(),_),i=`${r.username}#${r.address.slice(-4).toUpperCase()}`;k(r),n({...r,displayName:i}),t(e(`login.toast.signedIn`,{username:r.username}),`success`),N(l(r.danger));let a=u(r.danger);ne(a),ie(m(a.private_key,a.ed_public_key));let s=g(a.private_key,a.ed_public_key);oe(Oe(s.secretKey)),ce(ke(s.publicKey)),fe([]),pe(0),B(!1),H(!1),W(!1),ge(!1),ve(!1)},[t,_,n,e,c]);function Tt(n,r,i){let a=n.trim();if(!a)return;let s=o(a,r),c=u(s.danger);i({username:s.username,address:s.address,publicKey:c.public_key,privateKey:c.private_key}),We(``),Ke(``),Qe(``),et(``),t(e(`web3.toast.accountGenerated`),`success`)}function Et({senderAccount:t,recipientAccount:n,message:i,setCipherText:a,setDecryptedText:o,setError:s}){if(!t||!n){s(e(`web3.error.accountsRequired`));return}if(!i.trim()){s(e(`web3.error.messageRequired`));return}a(r(i,{senderPrivateKey:t.privateKey,recipientPublicKey:n.publicKey})),o(``),s(``)}function Dt({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=f(r,{senderPublicKey:t.publicKey,recipientPrivateKey:n.privateKey});if(!o){a(e(`web3.error.decryptFailed`)),i(``);return}i(o),a(``)}function Ot(){if(!tt.trim()){Q(e(`web3.error.senderPublicRequired`));return}if(!rt.trim()){Q(e(`web3.error.recipientPrivateRequired`));return}if(!at.trim()){Q(e(`web3.error.cipherRequired`));return}let t=f(at,{senderPublicKey:tt.trim(),recipientPrivateKey:rt.trim()});if(!t){Q(e(`web3.error.decryptFailed`)),ct(``);return}ct(t),Q(``)}function kt(){if(!ft.trim()){$(e(`web3.error.senderPrivateRequired`));return}if(!mt.trim()){$(e(`web3.error.recipientPublicRequired`));return}if(!gt.trim()){$(e(`web3.error.messageRequired`));return}yt(r(gt,{senderPrivateKey:ft.trim(),recipientPublicKey:mt.trim()})),$(``)}let At=()=>{if(!M)return;let e=[];for(let t=P;t<P+10;t++){let n=`m/44'/60'/0'/0/${t}`,r=d.fromPhrase(M,void 0,n);e.push({index:t,address:r.address,privateKey:r.privateKey})}fe(t=>[...t,...e]),pe(e=>e+10)},jt=ee(O?.address||void 0),Mt=i===`wallet`?`web3.view.wallet`:i===`pem`?`web3.view.pem`:i===`EA`?`web3.view.asymmetric`:`web3.view.export`,Nt=[{id:`wallet`,icon:(0,j.jsx)(S,{size:16}),labelKey:`web3.view.wallet`},{id:`pem`,icon:(0,j.jsx)(v,{size:16}),labelKey:`web3.view.pem`},{id:`export`,icon:(0,j.jsx)(T,{size:16}),labelKey:`web3.view.export`},{id:`EA`,icon:(0,j.jsx)(x,{size:16}),labelKey:`web3.view.asymmetric`}],Pt=i!==`EA`;return(0,j.jsx)(C,{sidebar:({closeSidebar:t})=>(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(w,{onNavigate:t}),(0,j.jsx)(`nav`,{className:`sidebar-nav`,children:Nt.map(n=>(0,j.jsxs)(`button`,{onClick:()=>{Ct(n.id),t()},className:`sidebar-nav-btn ${i===n.id?`active`:``}`,children:[n.icon,(0,j.jsx)(`span`,{children:e(n.labelKey)})]},n.id))})]}),headerTitle:(0,j.jsx)(`h2`,{className:`header-title`,children:e(Mt)}),children:(0,j.jsx)(`div`,{className:`web3-page`,children:(0,j.jsxs)(`div`,{className:`web3-container ${i===`EA`?`wide`:``}`,children:[Pt&&(0,j.jsx)(De,{username:c,password:_,showPassword:b,generating:_e,onUsernameChange:h,onPasswordChange:y,onTogglePassword:()=>D(!b),onGenerate:wt}),i===`wallet`&&(0,j.jsx)(Ee,{walletResult:O,keys:te,ipns:re,avatarSrc:jt,showPrivateKey:G,onTogglePrivateKey:()=>ge(!G)}),i===`pem`&&(0,j.jsx)(de,{walletResult:O,publicPem:se,privatePem:ae}),i===`export`&&(0,j.jsx)(we,{walletResult:O,mnemonicPhrase:M,deriveBatch:10,deriveList:ue,deriveShowIndex:F,deriveShowAddress:I,deriveShowPrivateKey:R,showAddressQr:he,showMnemonicReveal:V,showMnemonicQr:U,onToggleAddressQr:()=>B(!he),onToggleMnemonicReveal:()=>H(!V),onToggleMnemonicQr:()=>W(!U),onToggleDeriveIndex:()=>me(!F),onToggleDeriveAddress:()=>L(!I),onToggleDerivePrivateKey:()=>z(!R),onDerive:At}),i===`EA`&&(0,j.jsx)(le,{boxAUsername:K,boxAPassword:be,boxAShowPassword:q,boxAShowPrivateKey:Ce,boxAAccount:Y,boxBUsername:X,boxBPassword:Me,boxBShowPassword:Pe,boxBShowPrivateKey:Ie,boxBAccount:Z,boxABMessage:ze,boxABCipherText:Ve,boxABDecryptedText:Ue,boxABError:Ge,boxBAMessage:qe,boxBACipherText:Ye,boxBADecryptedText:Ze,boxBAError:$e,boxEncryptSenderPrivateKey:ft,boxEncryptRecipientPublicKey:mt,boxEncryptMessage:gt,boxEncryptCipherText:vt,boxEncryptError:bt,boxEncryptShowPrivateKey:xt,boxDecryptSenderPublicKey:tt,boxDecryptRecipientPrivateKey:rt,boxDecryptCipherText:at,boxDecryptResult:st,boxDecryptError:lt,boxDecryptShowPrivateKey:ut,onBoxAUsernameChange:ye,onBoxAPasswordChange:xe,onBoxAShowPasswordToggle:()=>Se(!q),onBoxAShowPrivateKeyToggle:()=>J(!Ce),onGenerateBoxA:()=>Tt(K,be,Te),onBoxBUsernameChange:Ae,onBoxBPasswordChange:Ne,onBoxBShowPasswordToggle:()=>Fe(!Pe),onBoxBShowPrivateKeyToggle:()=>Le(!Ie),onGenerateBoxB:()=>Tt(X,Me,Re),onBoxABMessageChange:Be,onBoxABCipherTextChange:He,onEncryptBoxAB:()=>Et({senderAccount:Y,recipientAccount:Z,message:ze,setCipherText:He,setDecryptedText:We,setError:Ke}),onDecryptBoxAB:()=>Dt({senderAccount:Y,recipientAccount:Z,cipherText:Ve,setDecryptedText:We,setError:Ke}),onBoxBAMessageChange:Je,onBoxBACipherTextChange:Xe,onEncryptBoxBA:()=>Et({senderAccount:Z,recipientAccount:Y,message:qe,setCipherText:Xe,setDecryptedText:Qe,setError:et}),onDecryptBoxBA:()=>Dt({senderAccount:Z,recipientAccount:Y,cipherText:Ye,setDecryptedText:Qe,setError:et}),onBoxEncryptSenderPrivateKeyChange:pt,onBoxEncryptRecipientPublicKeyChange:ht,onBoxEncryptMessageChange:_t,onBoxEncryptShowPrivateKeyToggle:()=>St(!xt),onEncryptOnly:kt,onBoxDecryptSenderPublicKeyChange:nt,onBoxDecryptRecipientPrivateKeyChange:it,onBoxDecryptCipherTextChange:ot,onBoxDecryptShowPrivateKeyToggle:()=>dt(!ut),onDecryptOnly:Ot})]})})})}var Ne=s(`/web3/`)({component:Me});export{Ne as Route};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{n as e,o as t,t as n}from"./jsx-runtime-Bt-cYkS5.js";import{D as r,E as i,H as a,a as o,d as s,m as c,p as l,r as u,t as d}from"./useAppStore-DOnk608w.js";import{t as f}from"./circle-alert-dfN4T6Nq.js";import{t as p}from"./check-iBCQl0yr.js";import{t as m}from"./key-round-JR8M3aHl.js";import{t as h}from"./refresh-cw-D4BsHvhi.js";import{A as g,E as _,N as v,k as y,x as b}from"./index-D0Uk9-58.js";import{i as x,t as S}from"./userProfile-BZvkCuet.js";import{r as C,t as w}from"./chatJoinInvite-B-ucvYdg.js";var T=t(e(),1),E=n();function D({children:e,className:t=``}){return(0,E.jsx)(`main`,{className:t,children:e})}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`,theme:`sparkbit`,name:`测试用户`,avatar:M}),Object.freeze({uid:`service`,name:`测试客服`,avatar:N})]),I=Object.freeze(F.map(e=>Object.freeze({locale:`zh-CN`,uid:e.uid,theme:e.theme,avatar:e.avatar,name:e.name,channels:[P]})));function L(e){let t=String(e||``).trim();return I.find(e=>e.uid===t)||null}var R=50,z=w;function B(e){try{return JSON.parse(e)}catch{return null}}function V(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 H(e){return`/chat?channel=${encodeURIComponent(e)}`}function U(e){return String(e||``).trim().slice(0,R)}function W(){let{t:e,setLocale:t}=g(),n=b(),a=v({select:e=>e.searchStr}),{token:w,pub:O,fixture:k}=(0,T.useMemo)(()=>{let e=new URLSearchParams(a);return{token:e.get(`token`)||``,pub:e.get(`pub`)||``,fixture:e.get(`fixture`)||``}},[a]),A=d(e=>e.hasBackend),M=i(e=>e.setUserIdentity),[N,P]=(0,T.useState)(``),[F,I]=(0,T.useState)(!0),[R,W]=(0,T.useState)(``),[G,K]=(0,T.useState)(0),q=(0,T.useRef)(``);function J(){q.current=``,P(``),W(``),I(!0),K(e=>e+1)}return(0,T.useEffect)(()=>{let n=L(k);if(k&&!n){P(e(`chatJoin.error.unknownFixture`,{fixture:k})),I(!1);return}if(!n&&!w){P(e(`chatJoin.error.missingToken`)),I(!1);return}if(!n&&!O){P(e(`chatJoin.error.missingPub`)),I(!1);return}if(A===null){W(e(`chatJoin.status.checkingBackend`));return}let i=n?`fixture:${k}`:`${w}:${O}`;if(q.current===i)return;q.current=i;async function a(n){let i=(t,r)=>n.locale?y(t,n.locale,r):e(t,r);n.locale&&t(n.locale);let a=c(),f=l(),p=s();if(j({inviteNodeUrl:n.node_url,inviteNodeInvite:n.node_invite,hasBackend:A,activeBackendUrl:p,activeRemoteUrl:a,activeRemoteInvite:f})){if(W(i(`chatJoin.status.connectingRemote`)),!(await u({url:n.node_url,invite:n.node_invite||``})).ok)throw Error(i(`chatJoin.error.remoteConnectFailed`));o({url:n.node_url,invite:n.node_invite||``}),d.setState({hasBackend:!0})}else if(!A)throw Error(i(`chatJoin.error.noBackend`));W(i(`chatJoin.status.signingIn`));let m=r(n.uid,``),h={...m,theme:n.theme,displayName:n.name||m.displayName,logo:n.logo,logo_dark:n.logo_dark,data:n.data,avatar:n.avatar};M(h),W(i(`chatJoin.status.joiningChannel`));let g=``;for(let e of n.channels){let t=await x.createChannel(e.id,`public`,S(h)),n=t.channelKey||t.key||e.id;g||=n;let r=U(e.name);r&&await x.setChannelRemark(n,r)}let _=n.channels[0];W(i(`chatJoin.status.openingChannel`)),window.location.href=H(g||_.id)}async function f(){try{if(n){W(e(`chatJoin.status.loadingFixture`,{name:n.name||k})),await a(n);return}W(e(`chatJoin.status.decryptingInvite`));let t=await fetch(`${z}/api/chat.join.decrypt`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({token:w,pub:O})}),r=await t.text(),i=B(r);if(!t.ok)P(V(r,i,e(`chatJoin.error.decrypt`)));else{let t=C(i);if(!t){P(e(`chatJoin.error.invalidInvite`));return}await a(t)}}catch(t){P(e(`chatJoin.error.request`,{message:t instanceof Error?t.message:String(t)}))}finally{I(!1)}}f()},[k,A,O,G,t,M,e,w]),(0,E.jsx)(D,{className:`chat-join-loading-page`,children:(0,E.jsx)(`div`,{className:`chat-join-loading-panel`,children:F?(0,E.jsxs)(`div`,{className:`chat-join-loading`,children:[(0,E.jsx)(m,{size:32}),(0,E.jsx)(`p`,{children:R||e(`chatJoin.status.decrypting`)})]}):N?(0,E.jsxs)(`div`,{className:`chat-join-error`,children:[(0,E.jsx)(f,{size:32}),(0,E.jsx)(`p`,{children:N}),R&&(0,E.jsx)(`p`,{className:`chat-join-status`,children:R}),(0,E.jsxs)(`div`,{className:`chat-join-actions`,children:[(0,E.jsxs)(`button`,{type:`button`,className:`btn btn-secondary`,onClick:n,children:[(0,E.jsx)(_,{size:16}),e(`common.back`)]}),(0,E.jsxs)(`button`,{type:`button`,className:`btn btn-primary`,onClick:J,children:[(0,E.jsx)(h,{size:16}),e(`chatJoin.action.retry`)]})]})]}):(0,E.jsxs)(`div`,{className:`chat-join-success`,children:[(0,E.jsx)(p,{size:32}),(0,E.jsx)(`p`,{children:R||e(`chatJoin.status.decryptSuccess`)})]})})})}function G(){return(0,E.jsx)(T.Suspense,{children:(0,E.jsx)(W,{})})}var K=a(`/chat/join/`)({component:G});export{K as Route};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{n as e,o as t,t as n}from"./jsx-runtime-Bt-cYkS5.js";import{A as r,B as i,E as a,H as o,O as s,_ as c,g as l,h as u,k as d,t as f,x as p,y as m}from"./useAppStore-DOnk608w.js";import{t as h}from"./copy-B7pPZ2MP.js";import{n as g}from"./AppTop-Cy0ZOCxO.js";import{t as ee}from"./play-CvWKSMwY.js";import{a as _,i as te,n as ne,r as re,t as ie}from"./useGameRoom-CS1w4IqP.js";import{A as ae,f as oe,w as se}from"./index-D0Uk9-58.js";var ce=i(`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`}]]),v=t(e(),1),y=[10,20,50,100],b=[`2`,`3`,`4`,`5`,`6`,`7`,`8`,`9`,`10`,`J`,`Q`,`K`,`A`],x=[`D`,`C`,`H`,`S`],le=new Map(b.map((e,t)=>[e,t+2])),ue=new Map(x.map((e,t)=>[e,t+1])),S={high:1,pair:2,straight:3,flush:4,straightFlush:5,triple:6},de={[S.high]:`散牌`,[S.pair]:`对子`,[S.straight]:`顺子`,[S.flush]:`金花`,[S.straightFlush]:`顺金`,[S.triple]:`豹子`};function C(e){return m(e)}function w(e=`zhajinhua`){return u(e)}function T(){return w(`round`)}function E(){let e=[];for(let t of x)for(let n of b)e.push(`${n}${t}`);return e}function D(e=E(),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 O(e){let t=String(e||``).trim().toUpperCase(),n=t.slice(-1),r=t.slice(0,-1);if(!le.has(r)||!ue.has(n))throw Error(`Invalid card: ${e}`);return{id:`${r}${n}`,rank:r,suit:n,rankValue:le.get(r),suitValue:ue.get(n)}}function k(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 A(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 j(e){if(!Array.isArray(e)||e.length!==3)throw Error(`炸金花手牌必须是 3 张牌`);let t=e.map(O),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=A(n),o=[...n].sort((e,t)=>t-e),s=Math.max(...t.map(e=>e.suitValue)),c=S.high,l=o;return r.size===1?(c=S.triple,l=[o[0]]):a&&i?(c=S.straightFlush,l=[a]):i?(c=S.flush,l=o):a?(c=S.straight,l=[a]):r.size===2&&(c=S.pair,l=[[...r.entries()].find(([,e])=>e===2)[0],[...r.entries()].find(([,e])=>e===1)[0]]),{category:c,label:de[c],tiebreakers:l,tieSuit:s,cards:t.map(e=>e.id)}}function M(e,t){let n=j(e),r=j(t);if(n.category!==r.category)return n.category-r.category;let i=k(n.tiebreakers,r.tiebreakers);return i===0?n.tieSuit-r.tieSuit:i}function N(e){return j(e).label}function P({roundId:e,action:t,amount:n,target:r}){return{roundId:e,eventId:w(`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=T(),random:o=Math.random}){let s=t.filter(e=>Number(e.chips)>=10).slice(0,5);if(s.length<2)throw Error(`至少需要 2 名有足够筹码的玩家`);let u=D(E(),o),d={},f=s.map((e,t)=>{let n=u.slice(t*3,t*3+3);return d[e.address]=n,{address:e.address,name:e.name,avatar:c(e.avatar),publicKey:e.publicKey,chips:Number(e.chips)-10,status:`active`,looked:!1,bet:10}}),p,m=l(i),h=m?f.findIndex(e=>l(e.address)===m):-1;return p=h>=0?f[h].address:f[Math.floor(o()*f.length)].address,{roomCode:C(e),roundId:a,status:`playing`,host:l(n),seq:r+1,startedAt:Date.now(),ante:10,pot:10*f.length,currentBet:10,turnAddress:p,players:f,lastAction:`本局开始`,winner:null,showdown:null,appliedEventIds:[],hands:d,actionCounts:{},compareReveal:{}}}function me(e){if(!e)return null;let t={...e};return delete t.hands,W(t)}function he(e,t){let n=F(e);return!n||!t||typeof t!=`object`?null:{...n,hands:W(t)}}function F(e){return!e||typeof e!=`object`||!e.roundId||!Array.isArray(e.players)?null:{roomCode:C(e.roomCode),roundId:String(e.roundId),status:e.status===`finished`?`finished`:`playing`,host:l(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:l(e.turnAddress),players:e.players.map(U).filter(Boolean),lastAction:String(e.lastAction||``),winner:e.winner?l(e.winner):null,showdown:e.showdown&&typeof e.showdown==`object`?W(e.showdown):null,appliedEventIds:Array.isArray(e.appliedEventIds)?e.appliedEventIds.map(String):[],actionCounts:e.actionCounts&&typeof e.actionCounts==`object`?W(e.actionCounts):{},compareReveal:e.compareReveal&&typeof e.compareReveal==`object`?W(e.compareReveal):{},lastCompare:e.lastCompare&&typeof e.lastCompare==`object`?W(e.lastCompare):null,finishedAt:e.finishedAt?Number(e.finishedAt):null}}function I(e,t,n){let r=F(e);if(!r||r.status!==`playing`)return{ok:!1,error:`当前没有进行中的牌局`};let i=l(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(!y.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=l(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 L(e,t,n){let r=I(e,t,n);if(!r.ok)return{ok:!1,error:r.error,state:e};let i=W(e),a=l(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} 看牌`,H(i);if(t.action===`fold`)return o.status=`folded`,i.lastAction=`${o.name} 弃牌`,B(i,a),V(i,a);if(t.action===`call`)return o.chips-=10,o.bet+=10,i.pot+=10,i.lastAction=`${o.name} 跟注`,B(i,a),V(i,a);if(t.action===`raise`){let e=Number(t.amount);return i.currentBet+=e,z(i,o),i.lastAction=`${o.name} 加注 ${e}`,B(i,a),V(i,a)}if(t.action===`compare`){z(i,o);let e=l(t.target),n=i.players.find(t=>t.address===e),r=o.looked,s=n.looked,c=M(i.hands?.[a]||[],i.hands?.[e]||[]),u=c>=0?o:n,d=c>=0?n:o;d.status=`folded`,d.looked=!0,i.compareReveal||={};let f=r&&s,p=!r&&!s;if(f)i.compareReveal[a]=i.hands?.[e]||[],i.compareReveal[e]=i.hands?.[a]||[];else if(p)i.compareReveal[d.address]=i.hands?.[u.address]||[];else{let e=r?o:n,t=r?n:o;i.compareReveal[e.address]=i.hands?.[t.address]||[],i.compareReveal[d.address]=i.hands?.[u.address]||[]}return i.lastCompare={initiator:a,target:e,winner:u.address,loser:d.address,initiatorLooked:r,targetLooked:s,timestamp:Date.now()},i.lastAction=`${o.name} 与 ${n.name} 比牌,${d.name} 出局`,B(i,a),V(i,a)}return{ok:!1,error:`未知操作`,state:e}}function R(e){return(e?.players||[]).filter(e=>e.status===`active`)}function ge(e,t){let n=(e?.players||[]).find(e=>e.address===l(t));if(!e||e.status!==`playing`||!n||n.status!==`active`||e.turnAddress!==n.address)return[];let r=[];return n.looked||r.push(`look`),I(e,{action:`call`},n.address).ok&&r.push(`call`),y.some(t=>I(e,{action:`raise`,amount:t},n.address).ok)&&r.push(`raise`),R(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 z(e,t){let n=Math.max(0,e.currentBet-t.bet);t.chips-=n,t.bet+=n,e.pot+=n}function B(e,t){e.actionCounts||={},e.actionCounts[t]=(e.actionCounts[t]||0)+1}function V(e,t){let n=R(e);return n.length===1?_e(e,n[0].address):(e.turnAddress=ve(e,t),H(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?W(e.hands):null,e.lastAction=n?`${n.name} 赢得 ${r} 筹码`:`本局结束`,e.pot=0,e.finishedAt=Date.now(),H(e)}function ve(e,t){let n=e.players,r=Math.max(0,n.findIndex(e=>e.address===l(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 H(e){return e.seq=Number(e.seq||0)+1,{ok:!0,state:e}}function U(e){if(!e||typeof e!=`object`)return null;let t=l(e.address);return t?{address:t,name:String(e.name||p(t)).slice(0,50),avatar:c(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 W(e){return JSON.parse(JSON.stringify(e))}var G={page:`_page_p8eol_1`,headerActions:`_headerActions_p8eol_12`,entry:`_entry_p8eol_18`,entryBrand:`_entryBrand_p8eol_28`,cardMark:`_cardMark_p8eol_34`,entryPanel:`_entryPanel_p8eol_62`,accountLine:`_accountLine_p8eol_72`,joinForm:`_joinForm_p8eol_89`,status:`_status_p8eol_110`,board:`_board_p8eol_116`,table:`_table_p8eol_123`,tableCenter:`_tableCenter_p8eol_144`,finishBanner:`_finishBanner_p8eol_173`,finishBannerIcon:`_finishBannerIcon_p8eol_192`,seats:`_seats_p8eol_196`,seat:`_seat_p8eol_196`,seatTurn:`_seatTurn_p8eol_218`,seatWinner:`_seatWinner_p8eol_223`,seatFolded:`_seatFolded_p8eol_228`,seatAvatar:`_seatAvatar_p8eol_232`,seatAvatarOffline:`_seatAvatarOffline_p8eol_252`,onlineDot:`_onlineDot_p8eol_257`,seatMain:`_seatMain_p8eol_269`,seatMeta:`_seatMeta_p8eol_270`,panel:`_panel_p8eol_301`,panelSection:`_panelSection_p8eol_308`,panelTitle:`_panelTitle_p8eol_318`,hand:`_hand_p8eol_328`,card:`_card_p8eol_34`,red:`_red_p8eol_362`,black:`_black_p8eol_366`,cardBack:`_cardBack_p8eol_370`,handLabel:`_handLabel_p8eol_391`,actionGrid:`_actionGrid_p8eol_398`,raiseRow:`_raiseRow_p8eol_399`,statusGrid:`_statusGrid_p8eol_410`,muted:`_muted_p8eol_428`,compareOverlay:`_compareOverlay_p8eol_435`,compareBox:`_compareBox_p8eol_447`,compareTitle:`_compareTitle_p8eol_461`,comparePlayers:`_comparePlayers_p8eol_467`,compareSide:`_compareSide_p8eol_474`,compareWinner:`_compareWinner_p8eol_486`,compareName:`_compareName_p8eol_491`,compareCards:`_compareCards_p8eol_502`,compareLabel:`_compareLabel_p8eol_527`,compareVs:`_compareVs_p8eol_533`,compareResult:`_compareResult_p8eol_540`},K=n(),q=`zhajinhua`;function J(...e){return e.filter(Boolean).join(` `)}function Y(e,t){return String(e||``).toLowerCase()===String(t||``).toLowerCase()}function ye(e=``){return e?`${e.slice(0,6)}...${e.slice(-4)}`:``}function be(e){return e.displayName||e.username}function xe(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 X(){let{t:e}=ae(),t=f(e=>e.addToast),n=a(e=>e.initializeUser),[i,o]=(0,v.useState)(``),[c,l]=(0,v.useState)(!1),u=(0,v.useRef)(``),p=(0,v.useRef)(!1),[m,b]=(0,v.useState)(20),[x,le]=(0,v.useState)(``),[ue,S]=(0,v.useState)({}),[de,C]=(0,v.useState)(!0),[w,T]=(0,v.useState)(!1),E=(0,v.useRef)(null),D=(0,v.useRef)(new Set),O=ie({gameId:q,onError:e=>t(e,`error`),getPlayerPayload:e=>{let t=s(e.danger);return{address:e.address,name:be(e),avatar:e.avatar||``,publicKey:t.public_key,joinedAt:Date.now()}}}),k=(0,v.useMemo)(()=>O.userIdentity?.danger?s(O.userIdentity.danger):null,[O.userIdentity?.danger]);(0,v.useEffect)(()=>{n()},[n]),(0,v.useEffect)(()=>{let e=new URLSearchParams(window.location.search).get(`room`)?.toUpperCase();e&&(o(e),u.current=e)},[]),(0,v.useEffect)(()=>{let n=u.current;!n||p.current||!O.isBackendReady||!O.userIdentity||(p.current=!0,u.current=``,O.joinRoom(n).then(n=>{n&&t(e(`game.toast.joinedRoom`),`success`)}))},[O.isBackendReady,O.userIdentity,O.joinRoom,t,e]),(0,v.useEffect)(()=>{if(!O.roomCode)return;let e=`/game/zhajinhua?room=${O.roomCode}`;`${window.location.pathname}${window.location.search}`!==e&&window.history.replaceState(null,``,e)},[O.roomCode]);let A=(0,v.useMemo)(()=>ne(O.messages,{gameId:q,roomCode:O.roomCode}),[O.messages,O.roomCode]),j=(0,v.useMemo)(()=>re(O.messages,{gameId:q,roomCode:O.roomCode}),[O.messages,O.roomCode])?.payload?.round||null,M=j?.host||A.hostAddress,F=Y(M,O.userIdentity?.address),I=O.userIdentity?.address?.toLowerCase()||``,z=j?.players.find(e=>Y(e.address,I)),B=z||A.players.find(e=>Y(e.address,I)),V=ue[j?.roundId||``]||null,_e=j?.showdown&&I?j.showdown[I]:null,ve=j?.compareReveal&&I?j.compareReveal[I]:null,H=_e||ve||(z?.looked?V:null),U=ge(j,I),W=R(j),X=F&&fe(A.players.map(e=>({...e,chips:j?.players.find(t=>Y(t.address,e.address))?.chips??1e3}))),Q=O.roomCode&&typeof window<`u`?`${window.location.origin}/game/zhajinhua?room=${O.roomCode}`:``;(0,v.useEffect)(()=>{if(!(!j||!O.userIdentity||!k||!M))for(let e of O.roomEvents){let t=e.event;if(!t||t.event!==`deal:private`)continue;let n=t.payload;if(n.roundId!==j.roundId||!Y(n.recipient,O.userIdentity.address))continue;let r=d(n.encrypted||``,{senderPublicKey:n.senderPublicKey||``,recipientPrivateKey:k.private_key});if(r)try{let e=JSON.parse(r);Array.isArray(e)&&S(t=>({...t,[j.roundId]:e.map(String)}))}catch{}}},[j?.roundId,O.roomEvents,O.userIdentity,M,k?.private_key]),(0,v.useEffect)(()=>{if(j?.status===`finished`&&j.winner){C(!0);let e=setTimeout(()=>C(!1),5e3);return()=>clearTimeout(e)}},[j?.finishedAt,j?.status,j?.winner]),(0,v.useEffect)(()=>{if(j?.lastCompare?.timestamp){T(!0);let e=setTimeout(()=>T(!1),5e3);return()=>clearTimeout(e)}else T(!1)},[j?.lastCompare?.timestamp,j?.roundId]),(0,v.useEffect)(()=>{if(!F||!j||j.status!==`playing`)return;let e=E.current;if(!e)return;let t=O.roomEvents.filter(e=>{let t=e.event;if(!t||t.event!==`player:action`)return!1;let n=t.payload.actionEvent;return!(!n||n.roundId!==j.roundId||D.current.has(n.eventId)||j.appliedEventIds?.includes(n.eventId))});if(t.length===0)return;let n=!1;async function r(){let r=he(j,e);if(r)for(let e of t){if(n)return;let t=(e.event?.payload).actionEvent,i=L(r,t,e.message.author);if(!i.ok){let n=e.message.author;if(!Y(n,O.userIdentity?.address)&&r.status===`playing`&&Y(r.turnAddress,n)){let e=L(r,P({roundId:r.roundId,action:`call`,amount:void 0,target:void 0}),n);if(e.ok)i=e;else{let e=L(r,P({roundId:r.roundId,action:`fold`,amount:void 0,target:void 0}),n);e.ok&&(i=e)}}if(!i.ok){D.current.add(t.eventId);continue}}if(r=i.state,E.current=i.state.hands,await De(i.state)&&D.current.add(t.eventId),i.state.status===`finished`)break}}return r(),()=>{n=!0}},[j?.roundId,j?.seq,j?.status,O.roomEvents,F]);async function we(){await O.createRoom()&&t(e(`game.toast.roomCreated`),`success`)}async function Te(n){n.preventDefault(),await O.joinRoom(i)&&t(e(`game.toast.joinedRoom`),`success`)}async function Ee(){Q&&(await navigator.clipboard.writeText(Q),l(!0),setTimeout(()=>l(!1),1400))}async function De(e){return O.sendRoomEvent(`room:state`,{round:me(e),seq:e.seq})}async function Oe(){if(!O.userIdentity||!k||!X){t(e(`game.zhajinhua.error.notEnoughPlayers`),`error`);return}try{let n=A.players.map(e=>({...e,chips:j?.players.find(t=>Y(t.address,e.address))?.chips??1e3})),i=pe({roomCode:O.roomCode,players:n,hostAddress:O.userIdentity.address,previousSeq:j?.seq||0,previousWinner:j?.winner||``});E.current=i.hands,D.current.clear(),await De(i);for(let e of i.players){let t=r(JSON.stringify(i.hands[e.address]),{senderPrivateKey:k.private_key,recipientPublicKey:e.publicKey});await O.sendRoomEvent(`deal:private`,{roundId:i.roundId,recipient:e.address,senderPublicKey:k.public_key,encrypted:t})}S(e=>({...e,[i.roundId]:i.hands[O.userIdentity.address.toLowerCase()]})),t(e(`game.zhajinhua.toast.roundStarted`),`success`)}catch(n){t(n instanceof Error?n.message:e(`game.zhajinhua.error.startFailed`),`error`)}}async function $(e,t={}){if(!j||!O.userIdentity)return;let n=P({roundId:j.roundId,action:e,amount:t.amount,target:t.target});await O.sendRoomEvent(`player:action`,{actionEvent:n})}let ke=j?.status===`playing`?Y(j.turnAddress,I)?e(`game.zhajinhua.status.yourTurn`):j.turnAddress?e(`game.zhajinhua.status.waitingPlayer`,{player:Z(j.turnAddress,A.players,O.presenceByAddress)}):e(`game.status.playing`):j?.status===`finished`?e(`game.status.finished`):e(`game.status.waitingStart`),Ae=W.filter(e=>!Y(e.address,I));return(0,K.jsx)(g,{sidebar:({closeSidebar:e})=>(0,K.jsx)(te,{activeGame:`zhajinhua`,closeSidebar:e}),headerTitle:(0,K.jsx)(`h2`,{className:`header-title`,children:e(`game.zhajinhua.title`)}),headerRight:(0,K.jsx)(`div`,{className:G.headerActions,children:O.roomCode&&(0,K.jsxs)(`button`,{className:`btn btn-sm`,onClick:Ee,children:[(0,K.jsx)(h,{size:14}),e(c?`common.copied`:`game.action.shareRoom`)]})}),children:(0,K.jsx)(`main`,{className:G.page,children:O.roomCode?(0,K.jsxs)(`div`,{className:G.board,children:[(0,K.jsxs)(`section`,{className:G.table,children:[j?.status===`finished`&&j.winner&&de&&(0,K.jsxs)(`div`,{className:G.finishBanner,children:[(0,K.jsx)(`span`,{className:G.finishBannerIcon,children:`🏆`}),(0,K.jsx)(`span`,{children:e(`game.zhajinhua.result.winChips`,{player:Z(j.winner,A.players,O.presenceByAddress),amount:j.winAmount??0})})]}),j?.lastCompare&&w&&(0,K.jsx)(Se,{lastCompare:j.lastCompare,compareReveal:j.compareReveal||{},myAddress:I,myDealtHand:V,lobbyPlayers:A.players,presenceByAddress:O.presenceByAddress,onClose:()=>T(!1)}),(0,K.jsxs)(`div`,{className:G.tableCenter,children:[(0,K.jsx)(`span`,{children:e(`game.zhajinhua.pot`)}),(0,K.jsx)(`strong`,{children:j?.pot||0}),(0,K.jsx)(`small`,{children:e(`game.zhajinhua.currentBet`,{amount:j?.currentBet||0})})]}),(0,K.jsx)(`div`,{className:G.seats,children:A.players.map(t=>{let n=j?.players.find(e=>Y(e.address,t.address)),r=Ce(t,O.presenceByAddress,O.onlineAddresses),i=j?.turnAddress===t.address,a=j?.winner===t.address,o=n?.status===`folded`;return(0,K.jsxs)(`div`,{className:J(G.seat,i&&G.seatTurn,a&&G.seatWinner,o&&G.seatFolded),children:[(0,K.jsxs)(`div`,{className:J(G.seatAvatar,!r.online&&G.seatAvatarOffline),children:[(0,K.jsx)(`img`,{src:oe(t.address,r.avatar),alt:``}),r.online&&(0,K.jsx)(`span`,{className:G.onlineDot})]}),(0,K.jsxs)(`div`,{className:G.seatMain,children:[(0,K.jsx)(`strong`,{translate:`no`,children:r.name}),(0,K.jsx)(`span`,{translate:`no`,children:ye(t.address)})]}),(0,K.jsxs)(`div`,{className:G.seatMeta,children:[(0,K.jsx)(`span`,{children:e(`game.zhajinhua.chips`,{amount:n?.chips??1e3})}),(0,K.jsx)(`span`,{children:n?.status===`folded`?e(`game.zhajinhua.player.folded`):n?.looked?e(`game.zhajinhua.player.looked`):e(j?`game.zhajinhua.player.inRound`:`game.status.waitingStart`)})]})]},t.address)})})]}),(0,K.jsxs)(`aside`,{className:G.panel,children:[(0,K.jsxs)(`div`,{className:G.panelSection,children:[(0,K.jsxs)(`div`,{className:G.panelTitle,children:[(0,K.jsx)(_,{size:16}),(0,K.jsx)(`span`,{children:e(`game.zhajinhua.myHand`)})]}),(0,K.jsx)(`div`,{className:G.hand,children:H?H.map(e=>{let t=xe(e),n=`${t.suit}${t.rank}`;return(0,K.jsxs)(`div`,{className:J(G.card,G[t.color]),children:[(0,K.jsx)(`span`,{children:n}),(0,K.jsx)(`i`,{children:t.suit})]},e)}):[0,1,2].map(e=>(0,K.jsx)(`div`,{className:G.cardBack,children:(0,K.jsx)(_,{size:18})},e))}),(0,K.jsx)(`p`,{className:G.handLabel,children:H?N(H):e(V?`game.zhajinhua.hand.unlooked`:`game.zhajinhua.hand.waitingDeal`)})]}),(0,K.jsxs)(`div`,{className:G.panelSection,children:[(0,K.jsxs)(`div`,{className:G.panelTitle,children:[(0,K.jsx)(ee,{size:16}),(0,K.jsx)(`span`,{children:e(`game.actions`)})]}),F?(0,K.jsxs)(`button`,{className:`btn btn-primary btn-full`,onClick:Oe,disabled:!X||j?.status===`playing`,children:[(0,K.jsx)(ce,{size:16}),j?.status===`finished`?e(`game.action.nextRound`):e(`game.action.startRound`)]}):(0,K.jsx)(`p`,{className:G.muted,children:e(`game.waitingHost`)}),F&&j?.status===`finished`&&!X&&(0,K.jsx)(`p`,{className:G.muted,children:e(`game.zhajinhua.error.tooManyLowChips`)}),(0,K.jsxs)(`div`,{className:G.actionGrid,children:[(0,K.jsxs)(`button`,{className:`btn btn-secondary`,disabled:!U.includes(`look`),onClick:()=>$(`look`),children:[(0,K.jsx)(se,{size:16}),e(`game.zhajinhua.action.look`)]}),(0,K.jsx)(`button`,{className:`btn btn-secondary`,disabled:!U.includes(`call`),onClick:()=>$(`call`),children:e(`game.zhajinhua.action.call`)}),(0,K.jsx)(`button`,{className:`btn btn-secondary`,disabled:!U.includes(`fold`),onClick:()=>$(`fold`),children:e(`game.zhajinhua.action.fold`)})]}),(0,K.jsxs)(`div`,{className:G.raiseRow,children:[(0,K.jsx)(`select`,{className:`input input-compact`,value:m,onChange:e=>b(Number(e.target.value)),children:y.map(t=>(0,K.jsx)(`option`,{value:t,children:e(`game.zhajinhua.action.raiseOption`,{amount:t})},t))}),(0,K.jsx)(`button`,{className:`btn btn-secondary`,disabled:!U.includes(`raise`),onClick:()=>$(`raise`,{amount:m}),children:e(`game.zhajinhua.action.raise`)})]}),(0,K.jsxs)(`div`,{className:G.raiseRow,children:[(0,K.jsxs)(`select`,{className:`input input-compact`,value:x,onChange:e=>le(e.target.value),children:[(0,K.jsx)(`option`,{value:``,children:e(`game.zhajinhua.action.comparePlaceholder`)}),Ae.map(e=>(0,K.jsx)(`option`,{value:e.address,children:Z(e.address,Ae,O.presenceByAddress)},e.address))]}),(0,K.jsx)(`button`,{className:`btn btn-secondary`,disabled:!U.includes(`compare`)||!x,onClick:()=>$(`compare`,{target:x}),children:e(`game.zhajinhua.action.compare`)})]})]}),(0,K.jsxs)(`div`,{className:G.panelSection,children:[(0,K.jsx)(`div`,{className:G.panelTitle,children:e(`game.status.title`)}),(0,K.jsxs)(`div`,{className:G.statusGrid,children:[(0,K.jsx)(`span`,{children:e(`game.host`)}),(0,K.jsx)(`strong`,{children:M?ye(M):`-`}),(0,K.jsx)(`span`,{children:e(`game.zhajinhua.myChips`)}),(0,K.jsx)(`strong`,{children:B?.chips??1e3}),(0,K.jsx)(`span`,{children:e(`game.round`)}),(0,K.jsx)(`strong`,{children:ke}),(0,K.jsx)(`span`,{children:e(`game.hint`)}),(0,K.jsx)(`strong`,{children:j?.lastAction||e(`game.waitingPlayers`)})]})]})]})]}):(0,K.jsxs)(`section`,{className:G.entry,children:[(0,K.jsxs)(`div`,{className:G.entryBrand,children:[(0,K.jsx)(`div`,{className:G.cardMark,children:(0,K.jsx)(_,{size:48})}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h1`,{children:e(`game.zhajinhua.hero.title`)}),(0,K.jsx)(`p`,{children:e(`game.hero.desc`)})]})]}),(0,K.jsxs)(`div`,{className:G.entryPanel,children:[(0,K.jsxs)(`div`,{className:G.accountLine,children:[(0,K.jsx)(`span`,{children:e(`game.currentAccount`)}),(0,K.jsx)(`strong`,{translate:`no`,children:O.userIdentity?.displayName||e(`web3.notSignedIn`)})]}),(0,K.jsxs)(`button`,{className:`btn btn-primary`,disabled:O.joining,onClick:we,children:[(0,K.jsx)(ee,{size:16}),e(`game.action.createRoom`)]}),(0,K.jsxs)(`form`,{onSubmit:Te,className:G.joinForm,children:[(0,K.jsxs)(`label`,{children:[e(`game.roomCode`),(0,K.jsx)(`input`,{value:i,maxLength:8,onChange:e=>o(e.target.value.toUpperCase()),placeholder:e(`game.roomCode.placeholder`)})]}),(0,K.jsx)(`button`,{className:`btn`,disabled:O.joining||!i,children:e(`game.action.joinRoom`)})]}),(0,K.jsx)(`p`,{className:G.status,children:O.isBackendReady?e(`game.status.nodeConnected`):e(`game.status.nodeConnecting`)})]})]})})})}function Se({lastCompare:e,compareReveal:t,myAddress:n,myDealtHand:r,lobbyPlayers:i,presenceByAddress:a,onClose:o}){let{t:s}=ae(),c=Z(e.initiator,i,a),l=Z(e.target,i,a),u=Z(e.winner,i,a),d=Y(n,e.initiator),f=Y(n,e.target),p=d||f;function m(e,i){return t[e]||(p&&Y(e,n)&&i&&r?r:null)}let h=m(e.initiator,e.initiatorLooked),g=m(e.target,e.targetLooked);return(0,K.jsx)(`div`,{className:G.compareOverlay,onClick:o,children:(0,K.jsxs)(`div`,{className:G.compareBox,onClick:e=>e.stopPropagation(),children:[(0,K.jsx)(`div`,{className:G.compareTitle,children:s(`game.zhajinhua.compareResult`)}),(0,K.jsxs)(`div`,{className:G.comparePlayers,children:[(0,K.jsxs)(`div`,{className:J(G.compareSide,Y(e.winner,e.initiator)&&G.compareWinner),children:[(0,K.jsx)(`div`,{className:G.compareName,children:c}),(0,K.jsx)(`div`,{className:G.compareCards,children:h?h.map(e=>{let t=xe(e);return(0,K.jsxs)(`div`,{className:J(G.card,G[t.color]),children:[(0,K.jsx)(`span`,{children:t.rank}),(0,K.jsx)(`i`,{children:t.suit})]},e)}):[0,1,2].map(e=>(0,K.jsx)(`div`,{className:G.cardBack,children:(0,K.jsx)(_,{size:18})},e))}),h&&(0,K.jsx)(`div`,{className:G.compareLabel,children:N(h)})]}),(0,K.jsx)(`div`,{className:G.compareVs,children:`VS`}),(0,K.jsxs)(`div`,{className:J(G.compareSide,Y(e.winner,e.target)&&G.compareWinner),children:[(0,K.jsx)(`div`,{className:G.compareName,children:l}),(0,K.jsx)(`div`,{className:G.compareCards,children:g?g.map(e=>{let t=xe(e);return(0,K.jsxs)(`div`,{className:J(G.card,G[t.color]),children:[(0,K.jsx)(`span`,{children:t.rank}),(0,K.jsx)(`i`,{children:t.suit})]},e)}):[0,1,2].map(e=>(0,K.jsx)(`div`,{className:G.cardBack,children:(0,K.jsx)(_,{size:18})},e))}),g&&(0,K.jsx)(`div`,{className:G.compareLabel,children:N(g)})]})]}),(0,K.jsx)(`div`,{className:G.compareResult,children:s(`game.zhajinhua.result.winner`,{player:u})}),(0,K.jsx)(`button`,{className:`btn btn-sm`,onClick:o,children:s(`common.close`)})]})})}function Z(e,t,n){let r=Q(e);return n.get(r)?.displayName||t.find(e=>Q(e.address)===r)?.name||ye(e)}function Q(e=``){return String(e||``).trim().toLowerCase()}function Ce(e,t,n){let r=Q(e.address),i=t.get(r);return{name:Z(e.address,[e],t),avatar:i?.avatar||e.avatar||``,online:r?n.has(r):!1}}var we=o(`/game/zhajinhua/`)({component:X});export{we as Route};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{n as e,o as t,t as n}from"./jsx-runtime-Bt-cYkS5.js";import{B as r,E as i,H as a,c as o,o as s,t as c,u as l}from"./useAppStore-DOnk608w.js";import{t as ee}from"./OpenSidebarButton-CGhXxQ5Z.js";import{a as te,i as u,n as d,r as f,t as ne}from"./FilePreviewOverlay-faaTnmlN.js";import{t as re}from"./arrow-up-down-B-677ip8.js";import{t as p}from"./check-iBCQl0yr.js";import{t as ie}from"./chevron-right-D75NRNNs.js";import{t as ae}from"./copy-B7pPZ2MP.js";import{t as oe}from"./download-COQOcPqI.js";import{t as se}from"./file-text-DiyIGL1I.js";import{t as m}from"./folder-BS_GbpPQ.js";import{t as ce}from"./loader-CwyHYZdX.js";import{i as le,n as ue,t as de}from"./AppTop-Cy0ZOCxO.js";import{t as h}from"./music-Dn9nm9Qb.js";import{t as fe}from"./search-HW4oPOBP.js";import{t as pe}from"./trash-2-BLwoM0ME.js";import{t as me}from"./upload-DVuXJt_o.js";import{A as he,S as g,_ as ge,v as _e,y as _}from"./index-D0Uk9-58.js";import{t as ve}from"./format-CR8oUWq6.js";import{n as v,r as ye,t as be}from"./downloadValidation-UPgpJbKz.js";var xe=r(`files`,[[`path`,{d:`M15 2h-4a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V8`,key:`14sh0y`}],[`path`,{d:`M16.706 2.706A2.4 2.4 0 0 0 15 2v5a1 1 0 0 0 1 1h5a2.4 2.4 0 0 0-.706-1.706z`,key:`1970lx`}],[`path`,{d:`M5 7a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 1.732-1`,key:`l4dndm`}]]),Se=r(`info`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 16v-4`,key:`1dtifu`}],[`path`,{d:`M12 8h.01`,key:`e9boi3`}]]),Ce=r(`star`,[[`path`,{d:`M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z`,key:`r04s7s`}]]),y=t(e(),1);function we(e={}){let t=e.timeout??2e3,[n,r]=(0,y.useState)(null),[i,a]=(0,y.useState)(!1),o=(0,y.useRef)(null);(0,y.useEffect)(()=>()=>{window.clearTimeout(o.current)},[]);let s=e=>{window.clearTimeout(o.current),o.current=window.setTimeout(()=>a(!1),t),a(e)};return{copy:e=>{`clipboard`in navigator?navigator.clipboard.writeText(e).then(()=>{r(null),s(!0)}).catch(e=>r(e)):r(Error(`useClipboard: navigator.clipboard is not supported`))},reset:()=>{a(!1),r(null),window.clearTimeout(o.current)},error:n,copied:i}}var b=n();function x(e){let t=e.lastIndexOf(`/`);return t===-1?{folder:``,name:e}:{folder:e.substring(0,t),name:e.substring(t+1)}}function Te({file:e,isSelected:t,onSelect:n,onPreview:r}){let i=d(e.fileName),a=(0,b.jsx)(se,{size:24,color:`#fff`});return i===`image`?a=(0,b.jsx)(f,{size:24,color:`#fff`}):i===`video`?a=(0,b.jsx)(u,{size:24,color:`#fff`}):i===`audio`&&(a=(0,b.jsx)(h,{size:24,color:`#fff`})),(0,b.jsxs)(`div`,{"data-id":e.cid,onClick:()=>n(e.cid),onDoubleClick:()=>r(e),className:`card ${t?`selected`:``}`,children:[(0,b.jsx)(`div`,{className:`card-icon ${e.starred?`starred`:`file`}`,children:a}),(0,b.jsx)(`p`,{className:`card-name`,translate:`no`,children:x(e.fileName).name})]})}function Ee({folder:e,onClick:t}){return(0,b.jsxs)(`div`,{onClick:t,className:`card`,children:[(0,b.jsx)(`div`,{className:`card-icon folder`,children:(0,b.jsx)(m,{size:28,color:`#fff`})}),(0,b.jsx)(`p`,{className:`card-name`,translate:`no`,children:e.name})]})}function S(e,t){return e?[{path:``,name:t},...e.split(`/`).filter(Boolean).map((e,t,n)=>({path:n.slice(0,t+1).join(`/`),name:e}))]:[]}function De({items:e,allFolders:t,currentPath:n,onMove:r,onClose:i}){let[a,o]=(0,y.useState)(``),[s,c]=(0,y.useState)(n),{t:l}=he(),ee=S(a,l(`move.root`));function te(){r(a||s.trim())}let u=t.filter(e=>{if(a===``)return!e.path.includes(`/`);let t=a+`/`;return e.path.startsWith(t)?!e.path.substring(t.length).includes(`/`):!1});return(0,b.jsx)(_,{onClose:i,children:(0,b.jsxs)(`div`,{className:`move-modal`,onClick:e=>e.stopPropagation(),children:[(0,b.jsxs)(`div`,{className:`modal-header`,children:[(0,b.jsx)(`h3`,{children:l(`move.title`)}),(0,b.jsx)(`button`,{type:`button`,onClick:i,className:`btn btn-icon`,children:(0,b.jsx)(g,{size:18})})]}),(0,b.jsx)(`p`,{className:`move-modal-desc`,children:l(`move.selectedCount`,{count:e.length})}),(0,b.jsx)(`div`,{className:`move-new-folder`,children:(0,b.jsx)(`input`,{type:`text`,className:`input`,value:s,onChange:e=>c(e.target.value),placeholder:l(`move.pathPlaceholder`),translate:`no`})}),(0,b.jsx)(`p`,{className:`move-modal-hint`,children:l(`move.pathExample`)}),(0,b.jsx)(`div`,{className:`move-breadcrumb`,children:ee.map((e,t)=>(0,b.jsxs)(y.Fragment,{children:[t>0&&(0,b.jsx)(`span`,{className:`breadcrumb-separator`,children:`/`}),(0,b.jsx)(`button`,{type:`button`,onClick:()=>{o(e.path),c(e.path)},className:`move-breadcrumb-btn ${a===e.path&&!s?`active`:``}`,children:(0,b.jsx)(`span`,{translate:e.path?`no`:`yes`,children:e.name})})]},e.path))}),(0,b.jsxs)(`div`,{className:`move-folder-list`,children:[u.length===0&&(0,b.jsx)(`p`,{className:`move-modal-empty`,children:l(`move.noSubfolders`)}),u.map(e=>(0,b.jsxs)(`button`,{type:`button`,onClick:()=>o(e.path),className:`move-folder-item ${a===e.path&&!s?`selected`:``}`,children:[(0,b.jsx)(m,{size:16}),(0,b.jsx)(`span`,{translate:`no`,children:e.name})]},e.path))]}),(0,b.jsxs)(`div`,{className:`modal-actions`,children:[(0,b.jsx)(`button`,{type:`button`,onClick:i,className:`btn btn-secondary`,children:l(`common.cancel`)}),(0,b.jsx)(`button`,{type:`button`,onClick:te,className:`btn btn-primary`,children:l(`move.action`)})]})]})})}var C=`https://most.box`;function Oe(e,t){let n=String(t||``).trim(),r=`${C}/cid/${encodeURIComponent(e)}`;return n?`${r}?filename=${encodeURIComponent(n)}`:r}function w(e){return x(e)}function ke(e){let t=new Set;return e.forEach(e=>{let{folder:n}=w(e.fileName),r=n.split(`/`).filter(Boolean),i=``;for(let e of r)i+=(i?`/`:``)+e,t.add(i)}),[...t].sort()}function T(e,t){let n=t?t+`/`:``;return e.filter(e=>{let t=e.toLowerCase().startsWith(n.toLowerCase()),r=e.substring(n.length);return t&&!r.includes(`/`)}).map(e=>({name:e.substring(n.length),path:e}))}function Ae(e,t,n){return{folders:T(t,n),files:e.filter(e=>w(e.fileName).folder===n)}}function je(e,t){return e?[{path:``,name:t},...e.split(`/`).filter(Boolean).map((e,t,n)=>({path:n.slice(0,t+1).join(`/`),name:e}))]:[]}function Me(){let e=c(e=>e.addToast),t=c(e=>e.hasBackend),n=c(e=>e.openConnectModal),r=i(e=>e.identity),a=i(e=>e.openLoginModal),[u,f]=(0,y.useState)([]),[m,h]=(0,y.useState)([]),[x,S]=(0,y.useState)(null),[C,T]=(0,y.useState)(`all`),[Me,E]=(0,y.useState)(!1),[D,O]=(0,y.useState)([]),[Ne,k]=(0,y.useState)(null),[A,j]=(0,y.useState)(null),[Pe,Fe]=le(!1),[Ie,Le]=(0,y.useState)(``),[M,N]=(0,y.useState)(null),[P,Re]=(0,y.useState)(!1),[ze,F]=(0,y.useState)([]),[Be,I]=le(!1),[L,R]=(0,y.useState)(``),{copy:Ve,copied:He}=we({timeout:2e3}),[Ue,We]=le(!1),[z,B]=(0,y.useState)(null),[V,Ge]=(0,y.useState)(null),[Ke,qe]=(0,y.useState)(!1),{t:H,formatDate:Je}=he(),U=t===!0,Ye=e=>e?Je(e):``,W=x||``,Xe=ke(u),{folders:Ze,files:Qe}=Ae(u,Xe,W);function G(){return U?!0:(n(),!1)}function K(){return r?!0:(a(),!1)}let $e=L?u.filter(e=>w(e.fileName).name.toLowerCase().includes(L.toLowerCase())):Qe,q=async()=>{if(!U||!r){f([]);return}try{f(await v.listPublishedFiles()||[])}catch{f([])}},J=async()=>{if(!U||!r){h([]);return}try{h(await v.listTrashFiles()||[])}catch{h([])}},et=e=>{O(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},tt=async t=>{if(K()&&G())try{await v.restoreTrashFile(t),e(H(`app.toast.restored`),`success`),q(),J()}catch(t){e(await s(t,H(`app.toast.restoreFailed`)),`error`)}},nt=async()=>{K()&&G()&&B({title:H(`app.clearTrash.title`),message:H(`app.clearTrash.message`),confirmText:H(`app.clear`),danger:!0,onConfirm:async()=>{B(null);try{await v.emptyTrash(),e(H(`app.toast.trashEmptied`),`success`),J()}catch(t){e(await s(t,H(`app.toast.emptyFailed`)),`error`)}}})},rt=async t=>{if(K()&&G())try{let n=await v.toggleStar(t);f(e=>e.map(e=>e.cid===t?{...e,starred:n.starred}:e)),e(n.starred?H(`app.toast.favorited`):H(`app.toast.unfavorited`),`success`)}catch(t){e(await s(t,H(`app.toast.actionFailed`)),`error`)}},it=async()=>{if(!K()||!G())return;let t=C===`trash`;B({title:H(t?`app.permanentDelete`:`app.batchDelete`),message:H(t?`app.deleteSelectedPermanent`:`app.deleteSelected`,{count:D.length}),confirmText:H(t?`app.permanentDelete`:`app.delete`),danger:!0,onConfirm:async()=>{B(null);try{for(let e of D)t?await v.permanentDeleteTrashFile(e):e.startsWith(`__`)||await v.deletePublishedFile(e);O([]),e(H(t?`app.toast.deletedPermanently`:`app.toast.deleted`),`success`),q(),J()}catch(t){e(await s(t,H(`app.toast.deleteFailed`)),`error`)}}})},at=async t=>{if(K()&&G())try{for(let e of D){let n=u.find(t=>t.cid===e);if(!n)continue;let{name:r}=w(n.fileName),i=t?`${t}/${r}`:r;n.fileName!==i&&await v.moveFile(e,i)}O([]),We.close(),e(H(`app.toast.moved`),`success`),q()}catch(t){e(await s(t,H(`app.toast.moveFailed`)),`error`)}},ot=t=>{let n=!!t.path,r=n?t.name:w(t.fileName).name;Ge({title:H(n?`app.renameFolder`:`app.renameFile`),placeholder:H(`app.enterNewName`),defaultValue:r,confirmText:H(`app.rename`),onConfirm:async i=>{if(i!==r&&K()&&G()){qe(!0);try{if(n){let n=t.path.lastIndexOf(`/`),r=n===-1?``:t.path.substring(0,n),a=r?`${r}/${i}`:i;await v.renameFolder(t.path,a),e(H(`app.toast.renamed`),`success`),q(),Q(a)}else{let{folder:n}=w(t.fileName),r=n?`${n}/${i}`:i;await v.moveFile(t.cid,r),e(H(`app.toast.renamed`),`success`),q()}Ge(null)}catch(t){e(await s(t,H(`app.toast.renameFailed`)),`error`)}finally{qe(!1)}}}})},st=async t=>{if(!r){a(),e(H(`app.toast.signInBeforePublish`),`warning`);return}if(!G())return;let n=W?W+`/`:``,i=[];for(let r of Array.from(t)){let t=n+r.name;if(u.some(e=>e.fileName===t)){e(H(`app.fileAlreadyExists`,{fileName:r.name}),`warning`);continue}let a=`upload_${Date.now()}_${Math.random().toString(36).slice(2,8)}`,o={id:a,fileName:r.name,progress:0,type:`upload`,status:`uploading`};i.push(o),F(e=>[...e,o]),i.length>0&&I.open();try{(await v.publishFile(r,t)).alreadyExists?(F(e=>e.map(e=>e.id===a?{...e,status:`completed`}:e)),e(H(`app.fileAlreadyExists`,{fileName:r.name}),`warning`)):(F(e=>e.map(e=>e.id===a?{...e,progress:100,status:`completed`}:e)),e(H(`app.fileAddedLocal`,{fileName:r.name}),`success`))}catch(t){F(e=>e.map(e=>e.id===a?{...e,status:`error`}:e)),e(await s(t,H(`app.publishFailedWithFile`,{fileName:r.name})),`error`)}}setTimeout(()=>{F(e=>e.filter(e=>e.status!==`completed`&&e.status!==`error`&&e.status!==`cancelled`))},3e3),q()},ct=A?Oe(A.cid,A.fileName):``,lt=()=>{ct&&Ve(ct)},[Y,ut]=(0,y.useState)(!1),X=Ie.trim(),Z=M?.status===`success`&&M.link===X,dt=()=>{Fe.close(),N(null)},ft=e=>{Le(e.target.value),N(null)},pt=async()=>{let t=be(X,H);if(t){N({status:`error`,link:X,message:t}),e(t,`warning`);return}if(!(P||Y)&&K()&&G()){Re(!0),N(null);try{let t=await v.checkDownload(X);N({status:`success`,link:X,message:t.alreadyExists?H(`app.fileAlreadyLocal`,{fileName:t.fileName}):H(`app.fileAvailable`,{fileName:t.fileName})}),e(t.alreadyExists?H(`app.fileAlreadyExists`,{fileName:t.fileName}):H(`app.toast.checkPassed`),t.alreadyExists?`warning`:`success`)}catch(t){let n=await ye(t);N({status:`error`,link:X,message:n}),e(n,`error`)}finally{Re(!1)}}},mt=async()=>{if(!r){a(),e(H(`app.toast.signInBeforeDownload`),`warning`);return}if(!G())return;let t=be(X,H);if(t){e(t,`warning`);return}if(!Z){e(H(`app.toast.checkLinkFirst`),`warning`);return}if(!Y){ut(!0);try{let t=await v.downloadFile(X);if(Le(``),N(null),dt(),t.alreadyExists)e(H(`app.fileAlreadyExists`,{fileName:t.fileName}),`warning`);else{let n={id:t.taskId,fileName:H(`app.downloadFallbackName`),progress:0,type:`download`,status:`downloading`};F(e=>[...e,n]),I.open(),e(H(`app.toast.downloadStarted`),`info`)}}catch(t){e(await s(t,H(`app.toast.downloadFailed`)),`error`)}finally{ut(!1)}}},ht=async t=>{if(K()&&G()&&t.type===`download`&&t.status===`downloading`){F(e=>e.map(e=>e.id===t.id?{...e,status:`cancelling`}:e));try{await v.cancelDownload(t.id)}catch(n){F(e=>e.map(e=>e.id===t.id?{...e,status:`downloading`}:e)),e(await s(n,H(`app.toast.cancelFailed`)),`error`)}}},gt=async t=>{if(K()&&G()){if(t.localAvailable===!1){e(H(`app.toast.fileNotLocal`),`warning`);return}try{let n=await fetch(v.getFileDownloadUrl(t.cid),{headers:await o(`GET`,`/api/files/${t.cid}/download`)});if(!n.ok)throw Error(H(`app.toast.getFileFailed`));let r=await n.blob(),i=window.showSaveFilePicker;if(i){let n=await(await i({suggestedName:t.fileName})).createWritable();await n.write(r),await n.close(),e(H(`app.toast.fileSaved`),`success`)}else{let n=URL.createObjectURL(r),i=document.createElement(`a`);i.href=n,i.download=t.fileName,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(n),e(H(`app.toast.fileDownloaded`),`success`)}}catch(t){t.name!==`AbortError`&&e(H(`app.saveFailedWithError`,{error:t.message}),`error`)}}},_t=async t=>{if(K()&&G())try{e(H(`app.toast.startPullLocal`),`info`),await v.cacheFile(t.cid),e(H(`app.toast.pulledAndSeeding`),`success`),q()}catch(t){e(await s(t,H(`app.toast.pullFailed`)),`error`)}},Q=e=>{S(e||null),O([])};(0,y.useEffect)(()=>{if(t!==!0)return;let n=null,r=!1;return(async()=>{if(n=new WebSocket(await l(`/ws`)),r){n.close();return}n.onmessage=t=>{try{let{event:n,data:r}=JSON.parse(t.data);if(n===`publish:success`||n===`download:success`){q();let t=r.taskId||r.fileName;F(e=>e.map(e=>e.id===t||e.fileName===r.fileName?{...e,progress:100,status:`completed`}:e)),n===`download:success`&&(r.alreadyExists?e(H(`app.fileAlreadyExists`,{fileName:r.fileName}),`warning`):e(H(`app.fileDownloadCompleted`,{fileName:r.fileName}),`success`),setTimeout(()=>{F(e=>e.filter(e=>!(e.id===t&&e.status===`completed`)))},3e3))}n===`publish:progress`&&F(e=>e.map(e=>{if(r.file&&e.fileName===r.file&&e.type===`upload`){let t=50;return r.stage===`calculating-cid`?t=25:r.stage===`uploading`?t=75:r.stage===`complete`&&(t=100),{...e,progress:t}}return e})),n===`download:progress`&&F(e=>e.map(e=>e.id===r.taskId?{...e,progress:r.percent||0,loaded:r.loaded,total:r.total}:e)),n===`download:error`&&(F(e=>e.map(e=>e.id===r.taskId?{...e,status:`error`}:e)),e(H(`app.downloadFailedWithError`,{error:r.error}),`error`)),n===`download:status`&&F(e=>e.map(e=>e.id===r.taskId?{...e,fileName:r.file||e.fileName}:e)),n===`download:cancelled`&&(F(e=>e.map(e=>e.id===r.taskId?{...e,status:`cancelled`}:e)),e(H(`app.toast.downloadCancelled`),`warning`)),n===`user:metadata:updated`&&(q(),J())}catch(e){console.warn(`[App WS] Failed to parse message:`,e.message)}}})(),()=>{r=!0,n?.close()}},[t,r?.address]),(0,y.useEffect)(()=>{if(t===!0&&r){q(),J();return}t===!1&&(f([]),h([]))},[t,r?.address]),(0,y.useEffect)(()=>{r||(O([]),k(null),j(null),Le(``),N(null),F([]),R(``),S(null),T(`all`))},[r?.address]);let vt=H(C===`all`?`app.nav.local`:C===`starred`?`app.nav.favorites`:`app.nav.trash`),$=C===`all`?$e:C===`starred`?u.filter(e=>e.starred&&w(e.fileName).name.toLowerCase().includes(L.toLowerCase())):m.filter(e=>w(e.fileName).name.toLowerCase().includes(L.toLowerCase())),yt=C===`starred`?[]:Ze.filter(e=>e.name.toLowerCase().includes(L.toLowerCase())),bt=je(W,H(`app.allContent`));return(0,b.jsxs)(ue,{sidebar:({closeSidebar:e})=>(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(de,{onNavigate:e}),(0,b.jsx)(`nav`,{className:`sidebar-nav`,children:[{id:`all`,icon:(0,b.jsx)(xe,{size:18}),label:H(`app.nav.local`)},{id:`starred`,icon:(0,b.jsx)(Ce,{size:18}),label:H(`app.nav.favorites`)},{id:`trash`,icon:(0,b.jsx)(pe,{size:18}),label:H(`app.nav.trash`)}].map(t=>(0,b.jsxs)(`button`,{onClick:()=>{T(t.id),S(null),O([]),R(``),e()},className:`sidebar-nav-btn ${C===t.id?`active`:``}`,children:[t.icon,(0,b.jsx)(`span`,{children:t.label})]},t.id))})]}),headerTitle:(0,b.jsx)(`h2`,{className:`header-title`,children:vt}),headerRight:(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(`div`,{className:`search-box`,children:[(0,b.jsx)(fe,{size:14}),(0,b.jsx)(`input`,{type:`text`,value:L,onChange:e=>R(e.target.value),placeholder:H(`app.search.placeholder`)}),L&&(0,b.jsx)(`button`,{onClick:()=>R(``),children:(0,b.jsx)(g,{size:12})})]}),C===`trash`&&m.length>0&&(0,b.jsx)(`button`,{onClick:nt,className:`btn btn-sm btn-empty-trash`,children:H(`app.emptyTrash`)}),(0,b.jsx)(`button`,{onClick:()=>I.open(),className:`btn btn-icon`,children:(0,b.jsx)(re,{size:16})})]}),children:[C===`all`&&(0,b.jsxs)(`div`,{className:`action-grid`,children:[(0,b.jsxs)(`div`,{className:`action-card upload ${Me?`drag-over`:``}`,onDragOver:e=>{e.preventDefault(),E(!0)},onDragLeave:()=>E(!1),onDrop:e=>{e.preventDefault(),E(!1),!(!K()||!G())&&st(e.dataTransfer.files)},children:[(0,b.jsx)(`input`,{type:`file`,multiple:!0,onClick:e=>{(!K()||!G())&&e.preventDefault()},onChange:e=>st(e.target.files),className:`action-card-input`}),(0,b.jsx)(me,{size:20,className:`action-grid-icon`}),(0,b.jsx)(`p`,{children:H(`app.publishFile`)})]}),(0,b.jsxs)(`div`,{className:`action-card action-card-download`,onClick:()=>{!K()||!G()||Fe.open()},children:[(0,b.jsx)(oe,{size:20,className:`action-grid-icon`}),(0,b.jsx)(`p`,{children:H(`app.downloadFile`)})]})]}),C===`all`&&(0,b.jsx)(`div`,{className:`breadcrumb`,children:W?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(`button`,{onClick:()=>Q(``),children:H(`app.allContent`)}),bt.slice(1).map((e,t)=>(0,b.jsxs)(y.Fragment,{children:[(0,b.jsx)(ie,{size:12}),(0,b.jsx)(`button`,{onClick:()=>Q(e.path),className:t===bt.length-2?`current`:``,children:(0,b.jsx)(`span`,{translate:`no`,children:e.name})}),t===bt.length-2&&(0,b.jsx)(`button`,{onClick:()=>ot(e),className:`breadcrumb-edit-btn`,children:(0,b.jsx)(te,{size:12})})]},e.path))]}):null}),(0,b.jsxs)(`div`,{className:`content-grid`,children:[C===`trash`&&($.length===0?(0,b.jsxs)(`div`,{className:`empty-state app-empty-state`,children:[(0,b.jsx)(`p`,{children:H(L?`app.noMatches`:`app.trashEmpty`)}),(0,b.jsx)(ee,{label:H(`app.openFileNavigation`)})]}):(0,b.jsx)(`div`,{className:`file-grid`,children:$.map(e=>(0,b.jsxs)(`div`,{onClick:()=>O(t=>t.includes(e.cid)?t.filter(t=>t!==e.cid):[...t,e.cid]),onDoubleClick:()=>tt(e.cid),className:`card ${D.includes(e.cid)?`selected`:``}`,children:[(0,b.jsx)(`div`,{className:`card-icon trash`,children:(0,b.jsx)(se,{size:24,color:`#fff`})}),(0,b.jsx)(`p`,{className:`card-name`,translate:`no`,children:w(e.fileName).name}),(0,b.jsx)(`p`,{className:`card-date`,children:H(`app.deletedOn`,{date:Ye(e.deletedAt)})})]},e.cid))})),C!==`trash`&&($.length===0&&yt.length===0?(0,b.jsxs)(`div`,{className:`empty-state app-empty-state`,children:[(0,b.jsx)(`p`,{children:H(L?`app.noMatches`:C===`starred`?`app.noFavorites`:`app.noLocalFiles`)}),(0,b.jsx)(ee,{label:H(`app.openFileNavigation`)})]}):(0,b.jsxs)(`div`,{className:`file-grid`,children:[yt.map(e=>(0,b.jsx)(Ee,{folder:e,onClick:()=>Q(e.path)},e.path)),$.map(t=>(0,b.jsx)(Te,{file:t,isSelected:D.includes(t.cid),onSelect:et,onPreview:t=>{if(t.localAvailable===!1){e(H(`app.toast.fileNotLocal`),`warning`);return}k({...t,subtype:d(t.fileName)})}},t.cid))]}))]}),z&&(0,b.jsx)(_e,{title:z.title,message:z.message,confirmText:z.confirmText,danger:z.danger,onConfirm:z.onConfirm,onClose:()=>B(null)}),V&&(0,b.jsx)(ge,{title:V.title,placeholder:V.placeholder,defaultValue:V.defaultValue,confirmText:V.confirmText,isLoading:Ke,onConfirm:V.onConfirm,onClose:()=>Ge(null)}),Ue&&(0,b.jsx)(De,{items:D.map(e=>u.find(t=>t.cid===e)).filter(Boolean),allFolders:Xe.map(e=>({path:e,name:e.split(`/`).pop()})),currentPath:W,onMove:at,onClose:()=>We.close()}),A&&(0,b.jsx)(_,{onClose:()=>j(null),children:(0,b.jsxs)(`div`,{className:`share-modal`,onClick:e=>e.stopPropagation(),children:[(0,b.jsxs)(`div`,{className:`modal-header`,children:[(0,b.jsx)(`h3`,{children:H(`app.shareLink`)}),(0,b.jsx)(`button`,{onClick:()=>j(null),className:`btn btn-icon`,children:(0,b.jsx)(g,{size:18})})]}),(0,b.jsxs)(`div`,{className:`share-link-box`,children:[(0,b.jsx)(`div`,{className:`share-link-text`,translate:`no`,children:ct}),(0,b.jsx)(`button`,{onClick:lt,className:`btn btn-circle btn-primary ${He?`copied`:``}`,children:He?(0,b.jsx)(p,{size:18}):(0,b.jsx)(ae,{size:18})})]}),(0,b.jsx)(`div`,{className:`share-storage-note`,children:(0,b.jsx)(`span`,{children:H(`app.shareSeedNote`)})})]})}),Pe&&(0,b.jsx)(_,{onClose:dt,children:(0,b.jsxs)(`div`,{className:`download-modal`,onClick:e=>e.stopPropagation(),children:[(0,b.jsxs)(`div`,{className:`modal-header`,children:[(0,b.jsx)(`h3`,{children:H(`app.downloadFile`)}),(0,b.jsx)(`button`,{onClick:dt,className:`btn btn-icon`,children:(0,b.jsx)(g,{size:18})})]}),(0,b.jsxs)(`div`,{className:`download-link-row`,children:[(0,b.jsx)(`input`,{type:`text`,className:`input`,value:Ie,onChange:ft,placeholder:H(`app.downloadLink.placeholder`)}),(0,b.jsxs)(`button`,{type:`button`,onClick:pt,disabled:!X||P||Y,className:`btn btn-secondary download-check-btn`,children:[P?(0,b.jsx)(ce,{size:14,className:`spin`}):Z?(0,b.jsx)(p,{size:14}):(0,b.jsx)(fe,{size:14}),H(P?`app.checking`:Z?`app.passed`:`app.check`)]})]}),M&&(0,b.jsxs)(`div`,{className:`download-check-status ${M.status}`,children:[M.status===`success`?(0,b.jsx)(p,{size:14}):(0,b.jsx)(Se,{size:14}),(0,b.jsx)(`span`,{children:M.message})]}),(0,b.jsxs)(`button`,{onClick:mt,disabled:!Z||Y||P,className:`btn btn-info btn-full`,children:[Y?(0,b.jsx)(ce,{size:14,className:`spin`}):(0,b.jsx)(oe,{size:14}),H(Y?`app.downloading`:`app.startDownload`)]})]})}),Ne&&(0,b.jsx)(ne,{item:Ne,isBackendReady:U,getFileDownloadUrl:v.getFileDownloadUrl,onClose:()=>k(null)}),D.length>0&&(0,b.jsxs)(`div`,{className:`batch-bar`,children:[(0,b.jsx)(`span`,{className:`batch-info`,children:H(`app.selectedItems`,{count:D.length})}),(0,b.jsx)(`button`,{onClick:()=>O([]),className:`batch-dismiss`,children:(0,b.jsx)(g,{size:16})}),(0,b.jsx)(`div`,{className:`batch-divider`}),C===`trash`?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(`button`,{onClick:async()=>{K()&&G()&&(await Promise.all(D.map(e=>v.restoreTrashFile(e))),O([]),e(H(`app.toast.restored`),`success`),q(),J())},className:`btn btn-sm`,children:H(`app.restore`)}),(0,b.jsx)(`button`,{onClick:it,className:`btn btn-sm btn-danger`,children:H(`app.permanentDelete`)})]}):(0,b.jsxs)(b.Fragment,{children:[D.length===1&&(()=>{let e=u.find(e=>e.cid===D[0]);return e&&d(e.fileName)!==`file`})()&&(0,b.jsx)(`button`,{onClick:()=>{let t=u.find(e=>e.cid===D[0]);if(t){if(t.localAvailable===!1){e(H(`app.toast.fileNotLocal`),`warning`);return}let n=d(t.fileName);k({...t,subtype:n})}},className:`btn btn-sm`,children:H(`app.preview`)}),(0,b.jsx)(`button`,{onClick:()=>{let e=D.some(e=>{let t=u.find(t=>t.cid===e);return t&&!t.starred});D.forEach(t=>{let n=u.find(e=>e.cid===t);n&&(e?!n.starred:n.starred)&&rt(t)})},className:`btn btn-sm btn-star`,children:H(`app.favorite`)}),D.length===1&&(0,b.jsx)(`button`,{onClick:()=>{let e=u.find(e=>e.cid===D[0]);e&&ot(e)},className:`btn btn-sm`,children:H(`app.rename`)}),(0,b.jsx)(`button`,{onClick:()=>We.open(),className:`btn btn-sm btn-move`,children:H(`app.move`)}),(0,b.jsx)(`button`,{onClick:it,className:`btn btn-sm btn-danger`,children:H(`app.delete`)}),D.length===1&&(()=>{let e=u.find(e=>e.cid===D[0]);return e&&e.localAvailable===!1})()&&(0,b.jsx)(`button`,{onClick:()=>{let e=u.find(e=>e.cid===D[0]);e&&_t(e)},className:`btn btn-sm`,children:H(`app.pullToLocal`)}),D.length===1&&(0,b.jsx)(`button`,{onClick:()=>j(u.find(e=>e.cid===D[0])),className:`btn btn-sm`,children:H(`app.share`)}),D.length===1&&(0,b.jsx)(`button`,{onClick:()=>{let e=u.find(e=>e.cid===D[0]);e&>(e)},className:`btn btn-sm`,children:H(`app.saveAs`)})]})]}),Be&&(0,b.jsx)(_,{onClose:()=>I.close(),children:(0,b.jsxs)(`div`,{className:`transfer-modal`,onClick:e=>e.stopPropagation(),children:[(0,b.jsxs)(`div`,{className:`modal-header`,children:[(0,b.jsx)(`h3`,{children:H(`app.transfers`)}),(0,b.jsx)(`button`,{onClick:()=>I.close(),className:`btn btn-icon`,children:(0,b.jsx)(g,{size:18})})]}),ze.length===0?(0,b.jsx)(`div`,{className:`empty-transfer`,children:H(`app.noTransfers`)}):ze.map(e=>(0,b.jsxs)(`div`,{className:`transfer-item`,children:[(0,b.jsxs)(`div`,{className:`transfer-item-header`,children:[e.type===`upload`?(0,b.jsx)(me,{size:14}):(0,b.jsx)(oe,{size:14}),(0,b.jsx)(`span`,{className:`transfer-item-name`,translate:`no`,children:e.fileName}),e.status===`downloading`&&e.type===`download`&&(0,b.jsx)(`button`,{onClick:()=>ht(e),className:`transfer-item-cancel`,children:(0,b.jsx)(g,{size:14})})]}),(0,b.jsxs)(`div`,{className:`transfer-progress-row`,children:[(0,b.jsx)(`progress`,{className:`transfer-progress-meter ${e.type===`download`?`download`:``} ${e.status===`error`?`error`:``} ${e.status===`cancelled`?`cancelled`:``}`,value:Math.max(0,Math.min(100,e.progress)),max:100,"aria-label":H(`app.transferProgress`,{fileName:e.fileName})}),(0,b.jsx)(`span`,{className:`transfer-progress-text`,children:e.status===`completed`?H(`app.completed`):e.status===`error`?H(`app.failed`):e.status===`cancelled`?H(`app.cancelled`):e.status===`cancelling`?H(`app.cancelling`):e.loaded&&e.total?`${ve(e.loaded)}/${ve(e.total)}`:`${e.progress}%`})]})]},e.id))]})})]})}var E=a(`/app/`)({component:Me});export{E as Route};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{n as e,o as t,t as n}from"./jsx-runtime-Bt-cYkS5.js";import{B as r,H as i,W as a,t as o}from"./useAppStore-DOnk608w.js";import{t as s}from"./arrow-right-CXzRt0Fp.js";import{t as c}from"./check-iBCQl0yr.js";import{t as l}from"./download-COQOcPqI.js";import{t as u}from"./external-link-D6tHlYgS.js";import{n as d,t as f}from"./notebook-pen-BzrCXQJE.js";import{t as p}from"./hard-drive-Cqa7Rstj.js";import{t as m}from"./message-square-BgsNXPft.js";import{t as h}from"./wallet-D9Iw4YWE.js";import{A as g,C as _,b as v}from"./index-D0Uk9-58.js";import{t as y}from"./MarketingLayout-CiN5KYcE.js";var b=r(`arrow-up-right`,[[`path`,{d:`M7 7h10v10`,key:`1tivn9`}],[`path`,{d:`M7 17 17 7`,key:`1vkiza`}]]),x=r(`gamepad-2`,[[`line`,{x1:`6`,x2:`10`,y1:`11`,y2:`11`,key:`1gktln`}],[`line`,{x1:`8`,x2:`8`,y1:`9`,y2:`13`,key:`qnk9ow`}],[`line`,{x1:`15`,x2:`15.01`,y1:`12`,y2:`12`,key:`krot7o`}],[`line`,{x1:`18`,x2:`18.01`,y1:`10`,y2:`10`,key:`1lcuu1`}],[`path`,{d:`M17.32 5H6.68a4 4 0 0 0-3.978 3.59c-.006.052-.01.101-.017.152C2.604 9.416 2 14.456 2 16a3 3 0 0 0 3 3c1 0 1.5-.5 2-1l1.414-1.414A2 2 0 0 1 9.828 16h4.344a2 2 0 0 1 1.414.586L17 18c.5.5 1 1 2 1a3 3 0 0 0 3-3c0-1.545-.604-6.584-.685-7.258-.007-.05-.011-.1-.017-.151A4 4 0 0 0 17.32 5z`,key:`mfqc10`}]]),S=t(e(),1),C=n(),w=[{id:`app`,titleKey:`portal.feature.app.title`,subtitleKey:`portal.feature.app.subtitle`,icon:(0,C.jsx)(d,{size:28}),path:`/app/`,requiresBackend:!0,heroKey:`portal.feature.app.hero`,descKey:`portal.feature.app.desc`,featureKeys:[`portal.feature.app.bullet.localIdentity`,`portal.feature.app.bullet.hyperswarm`,`portal.feature.app.bullet.largeFiles`,`portal.feature.app.bullet.cid`,`portal.feature.app.bullet.seedAfterDownload`,`portal.feature.app.bullet.noCloud`,`portal.feature.app.bullet.desktop`,`portal.feature.app.bullet.openSource`],steps:[{num:`1`,titleKey:`portal.feature.app.step.download.title`,descKey:`portal.feature.app.step.download.desc`,link:`/download/`,linkTextKey:`portal.feature.app.step.download.link`,hideInDesktopClient:!0},{num:`2`,titleKey:`portal.feature.app.step.install.title`,descKey:`portal.feature.app.step.install.desc`,hideInDesktopClient:!0},{num:`3`,titleKey:`portal.feature.app.step.share.title`,descKey:`portal.feature.app.step.share.desc`}]},{id:`chat`,titleKey:`portal.feature.chat.title`,subtitleKey:`portal.feature.chat.subtitle`,icon:(0,C.jsx)(m,{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)(f,{size:28}),path:`/note/`,requiresBackend:!1,heroKey:`portal.feature.note.hero`,descKey:`portal.feature.note.desc`,featureKeys:[`portal.feature.note.bullet.markdown`,`portal.feature.note.bullet.privacy`,`portal.feature.note.bullet.folders`,`portal.feature.note.bullet.web3`,`portal.feature.note.bullet.backup`,`portal.feature.note.bullet.independent`],steps:[{num:`1`,titleKey:`portal.feature.note.step.account.title`,descKey:`portal.feature.note.step.account.desc`},{num:`2`,titleKey:`portal.feature.note.step.create.title`,descKey:`portal.feature.note.step.create.desc`},{num:`3`,titleKey:`portal.feature.note.step.backup.title`,descKey:`portal.feature.note.step.backup.desc`}]},{id:`gandengyan`,titleKey:`portal.feature.game.title`,subtitleKey:`portal.feature.game.subtitle`,icon:(0,C.jsx)(x,{size:28}),path:`/game/gandengyan/`,requiresBackend:!0,heroKey:`portal.feature.game.hero`,descKey:`portal.feature.game.desc`,featureKeys:[`portal.feature.game.bullet.account`,`portal.feature.game.bullet.channel`,`portal.feature.game.bullet.link`,`portal.feature.game.bullet.rules`,`portal.feature.game.bullet.maintain`],steps:[{num:`1`,titleKey:`portal.feature.game.step.login.title`,descKey:`portal.feature.game.step.login.desc`},{num:`2`,titleKey:`portal.feature.game.step.create.title`,descKey:`portal.feature.game.step.create.desc`},{num:`3`,titleKey:`portal.feature.game.step.test.title`,descKey:`portal.feature.game.step.test.desc`}]},{id:`web3`,titleKey:`portal.feature.web3.title`,subtitleKey:`portal.feature.web3.subtitle`,icon:(0,C.jsx)(h,{size:28}),path:`/web3/`,requiresBackend:!1,heroKey:`portal.feature.web3.hero`,descKey:`portal.feature.web3.desc`,featureKeys:[`portal.feature.web3.bullet.frontend`,`portal.feature.web3.bullet.keys`,`portal.feature.web3.bullet.mnemonic`,`portal.feature.web3.bullet.eth`,`portal.feature.web3.bullet.pem`,`portal.feature.web3.bullet.qr`],steps:[{num:`1`,titleKey:`portal.feature.web3.step.username.title`,descKey:`portal.feature.web3.step.username.desc`},{num:`2`,titleKey:`portal.feature.web3.step.keys.title`,descKey:`portal.feature.web3.step.keys.desc`},{num:`3`,titleKey:`portal.feature.web3.step.export.title`,descKey:`portal.feature.web3.step.export.desc`}]}],T=[`chat`,`app`,`note`,`gandengyan`,`web3`];function E(){let e=o(e=>e.hasBackend),t=o(e=>e.openConnectModal),[n,r]=(0,S.useState)(`chat`),{t:i}=g(),d=v(),f=T.map(e=>w.find(t=>t.id===e)).filter(e=>!!e),m=f.find(e=>e.id===n)||f[0],h=i(m.titleKey),y=m.steps.filter(e=>!(d&&e.hideInDesktopClient));return(0,C.jsxs)(`div`,{className:`portal-page`,children:[(0,C.jsx)(`section`,{className:`portal-hero`,children:(0,C.jsxs)(`div`,{className:`mkt-container`,children:[(0,C.jsx)(`h1`,{className:`portal-hero-title`,children:i(`common.brand`)}),(0,C.jsx)(`p`,{className:`portal-hero-subtitle`,children:i(`portal.hero.subtitle`)})]})}),(0,C.jsx)(`section`,{className:`portal-cards-section`,children:(0,C.jsxs)(`div`,{className:`mkt-container`,children:[(0,C.jsx)(`div`,{className:`portal-cards`,children:f.map(t=>{let o=n===t.id,s=t.requiresBackend,c=s?e===!0?`connected`:e===!1?`disconnected`:`checking`:`none`,l=i(t.titleKey);return(0,C.jsxs)(`button`,{className:`portal-card ${o?`active`:``}`,onClick:()=>r(t.id),children:[(0,C.jsx)(a,{to:t.path,className:`btn btn-icon portal-card-open-btn`,onClick:e=>e.stopPropagation(),title:i(`portal.openFeature`,{title:l}),children:(0,C.jsx)(b,{size:16})}),(0,C.jsx)(`div`,{className:`portal-card-icon`,children:t.icon}),(0,C.jsx)(`div`,{className:`portal-card-title`,children:l}),(0,C.jsx)(`div`,{className:`portal-card-subtitle`,children:i(t.subtitleKey)}),s?(0,C.jsxs)(`div`,{className:`ui-badge portal-card-status ${c}`,children:[c===`checking`&&(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(`span`,{className:`status-dot checking`}),i(`common.status.checking`)]}),c===`connected`&&(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(`span`,{className:`status-dot connected`}),i(`common.status.connected`)]}),c===`disconnected`&&(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(`span`,{className:`status-dot disconnected`}),i(`common.status.needsConnection`)]})]}):(0,C.jsxs)(`div`,{className:`ui-badge portal-card-status ready`,children:[(0,C.jsx)(`span`,{className:`status-dot ready`}),i(`common.status.ready`)]})]},t.id)})}),(0,C.jsxs)(`div`,{className:`portal-node-actions`,"aria-label":i(`portal.nodeEntry`),children:[(0,C.jsxs)(`button`,{onClick:t,className:`btn btn-secondary`,children:[(0,C.jsx)(_,{size:16}),i(`portal.webConnectNode`)]}),(0,C.jsxs)(a,{to:`/admin/`,className:`btn btn-secondary`,children:[(0,C.jsx)(p,{size:16}),i(`portal.nodeAdmin`)]})]})]})}),(0,C.jsx)(`section`,{className:`portal-marketing`,children:(0,C.jsx)(`div`,{className:`mkt-container`,children:(0,C.jsxs)(`div`,{className:`portal-marketing-inner`,children:[(0,C.jsxs)(`div`,{className:`portal-marketing-header`,children:[(0,C.jsx)(`h2`,{children:i(m.heroKey)}),(0,C.jsx)(`p`,{children:i(m.descKey)})]}),(0,C.jsx)(`div`,{className:`portal-marketing-features`,children:m.featureKeys.map(e=>(0,C.jsxs)(`div`,{className:`portal-feature-item`,children:[(0,C.jsx)(`span`,{className:`portal-feature-icon`,children:(0,C.jsx)(c,{size:14,strokeWidth:3})}),(0,C.jsx)(`span`,{children:i(e)})]},e))}),(0,C.jsx)(`div`,{className:`portal-marketing-steps`,children:y.map((e,t)=>(0,C.jsxs)(`div`,{className:`portal-step`,children:[(0,C.jsx)(`span`,{className:`portal-step-num`,children:t+1}),(0,C.jsxs)(`div`,{className:`portal-step-content`,children:[(0,C.jsx)(`strong`,{children:i(e.titleKey)}),(0,C.jsx)(`p`,{children:i(e.descKey)}),e.code&&(0,C.jsx)(`code`,{className:`portal-step-code`,translate:`no`,children:e.code}),e.link&&e.linkTextKey&&(0,C.jsx)(`p`,{className:`portal-step-link`,children:(0,C.jsxs)(a,{to:e.link,children:[i(e.linkTextKey),` `,(0,C.jsx)(u,{size:12})]})})]})]},e.num))}),(0,C.jsxs)(`div`,{className:`portal-actions`,children:[(0,C.jsxs)(a,{to:m.path,className:`btn btn-primary`,children:[i(`portal.enterFeature`,{title:h}),(0,C.jsx)(s,{size:16})]}),m.requiresBackend&&e===!1&&(0,C.jsxs)(C.Fragment,{children:[(0,C.jsxs)(`button`,{onClick:t,className:`btn btn-secondary`,children:[(0,C.jsx)(_,{size:16}),i(`portal.webConnectNode`)]}),!d&&(0,C.jsxs)(a,{to:`/download/`,className:`btn btn-secondary`,children:[(0,C.jsx)(l,{size:16}),i(`nav.downloadClient`)]})]})]})]})})})]})}function D(){return(0,C.jsx)(y,{children:(0,C.jsx)(E,{})})}var O=i(`/`)({component:D});export{O as Route};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{n as e,o as t,t as n}from"./jsx-runtime-Bt-cYkS5.js";import{B as r,E as i,H as a,O as ee,W as o,n as te,o as ne,t as s}from"./useAppStore-DOnk608w.js";import{n as c,r as l}from"./mp-Dv12gDTx.js";import{t as u}from"./circle-alert-dfN4T6Nq.js";import{t as d}from"./check-iBCQl0yr.js";import{t as re}from"./download-COQOcPqI.js";import{t as ie}from"./external-link-D6tHlYgS.js";import{t as ae}from"./key-round-JR8M3aHl.js";import{i as f}from"./AccountMenu-ptQklqvD.js";import{t as p}from"./loader-CwyHYZdX.js";import{t as m}from"./save-B02sbO9Y.js";import{t as h}from"./shield-check-Boae7Nc6.js";import{t as g}from"./upload-DVuXJt_o.js";import{A as _,D as v,S as y,d as b,f as x,h as S,m as C,n as oe,p as w,v as se,y as ce}from"./index-D0Uk9-58.js";import{t as le}from"./MarketingHeader-CxJ_OVOW.js";import{t as T}from"./CopyButton-C8PIDSJZ.js";import{t as E}from"./MarketingLayout-CiN5KYcE.js";var ue=r(`cloud-download`,[[`path`,{d:`M12 13v8l-4-4`,key:`1f5nwf`}],[`path`,{d:`m12 21 4-4`,key:`1lfcce`}],[`path`,{d:`M4.393 15.269A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.436 8.284`,key:`ui1hmy`}]]),de=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`}]]),fe=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`}]]),pe=r(`wallet-cards`,[[`path`,{d:`M3 11h3.75a2 2 0 0 1 1.6.8l.45.6a4 4 0 0 0 6.4 0l.45-.6a2 2 0 0 1 1.6-.8H21`,key:`1vwh6y`}],[`path`,{d:`M3 7h18`,key:`1uiuf2`}],[`rect`,{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`,key:`h1oib`}]]),D=t(e(),1),O=n(),k=[{value:``,labelKey:`profile.avatar.address`},...b.map(e=>({value:w(e),labelKey:`profile.avatar.${e}`}))];function A(e){if(C(e))return!0;try{let t=new URL(e);return t.protocol===`http:`||t.protocol===`https:`}catch{return!1}}function j(e){return e===`disabled`?`is-disabled`:e===`working`?`is-working`:e===`synced`?`is-synced`:e===`error`?`is-error`:`is-idle`}function M({status:e,busy:t}){return t||e===`working`?(0,O.jsx)(p,{size:16,className:`ui-spinner`}):e===`synced`?(0,O.jsx)(v,{size:16}):e===`error`?(0,O.jsx)(u,{size:16}):(0,O.jsx)(h,{size:16})}function N(){let{formatNumber:e,t}=_(),n=s(e=>e.addToast),r=s(e=>e.hasBackend),a=i(e=>e.identity),u=i(e=>e.openLoginModal),v=i(e=>e.setUserIdentity),b=i(e=>e.logoutUser),C=oe(),[w,N]=(0,D.useState)(``),[I,L]=(0,D.useState)(``),[R,z]=(0,D.useState)(``),[B,V]=(0,D.useState)(!1),[H,U]=(0,D.useState)(null),W=(0,O.jsx)(le,{});(0,D.useEffect)(()=>{if(!a){N(``),L(``),z(``);return}N(a.displayName||a.username),L(S(a.avatar)||a.avatar||``),z(``)},[a]),(0,D.useEffect)(()=>{a&&C.refreshBackupSummary()},[C.refreshBackupSummary,r,a]);let G=(0,D.useMemo)(()=>a?ee(a.danger):null,[a]),me=(0,D.useMemo)(()=>G?c(G.private_key,G.ed_public_key):``,[G]);if(!a)return(0,O.jsx)(E,{header:W,children:(0,O.jsx)(`section`,{className:`profile-page`,children:(0,O.jsx)(`div`,{className:`profile-container narrow`,children:(0,O.jsxs)(`div`,{className:`profile-empty glass`,children:[(0,O.jsx)(`div`,{className:`profile-empty-icon`,children:(0,O.jsx)(f,{size:34})}),(0,O.jsx)(`h1`,{children:t(`profile.signedOut.title`)}),(0,O.jsx)(`p`,{children:t(`profile.signedOut.desc`)}),(0,O.jsxs)(`button`,{type:`button`,className:`btn btn-primary`,onClick:u,children:[(0,O.jsx)(f,{size:16}),t(`account.signIn`)]})]})})})});let he=S(a.avatar)||a.avatar||``,ge=x(a.address,a.avatar),K=a.address.toLowerCase(),_e=I.trim().length>0,ve=j(C.status),q=C.action===`backup`,J=C.action===`restore`,Y=C.action===`export`,X=C.action===`import`,ye=[{key:`notes`,label:t(`profile.backup.summary.notes`),value:C.notesCount},{key:`files`,label:t(`profile.backup.summary.files`),value:C.backupSummary.filesCount},{key:`trash`,label:t(`profile.backup.summary.trash`),value:C.backupSummary.trashFilesCount},{key:`channels`,label:t(`profile.backup.summary.channels`),value:C.backupSummary.channelsCount}];function be(){U({title:t(`profile.backup.confirm.backupTitle`),message:t(`profile.backup.confirm.backupMessage`),confirmText:t(`profile.backup.action.cloudBackup`),onConfirm:async()=>{U(null),await C.backupToCloud()}})}function xe(){U({title:t(`profile.backup.confirm.restoreTitle`),message:t(`profile.backup.confirm.restoreMessage`),confirmText:t(`profile.backup.action.cloudRestore`),onConfirm:async()=>{U(null),await C.restoreFromCloud({confirm:!1})}})}function Se(){return new Promise(e=>{let n=t=>{U(null),e(t)};U({title:t(`profile.backup.confirm.importTitle`),message:t(`profile.backup.confirm.restore`),confirmText:t(`profile.backup.action.importLocal`),onConfirm:()=>n(!0),onClose:()=>n(!1)})})}function Z(){C.importLocalBackup({requestConfirm:Se})}let Ce=[{key:`cloud-backup`,tone:`cloud-backup`,label:t(q?`profile.backup.status.backingUp`:`profile.backup.action.cloudBackup`),icon:q?(0,O.jsx)(p,{size:16,className:`ui-spinner`}):(0,O.jsx)(de,{size:16}),onClick:be},{key:`cloud-restore`,tone:`cloud-restore`,label:t(J?`profile.backup.status.restoring`:`profile.backup.action.cloudRestore`),icon:J?(0,O.jsx)(p,{size:16,className:`ui-spinner`}):(0,O.jsx)(ue,{size:16}),onClick:xe},{key:`export-local`,tone:`export-local`,label:t(Y?`profile.backup.status.exporting`:`profile.backup.action.exportLocal`),icon:Y?(0,O.jsx)(p,{size:16,className:`ui-spinner`}):(0,O.jsx)(re,{size:16}),onClick:C.exportLocalBackup},{key:`import-local`,tone:`import-local`,label:t(X?`profile.backup.status.importing`:`profile.backup.action.importLocal`),icon:X?(0,O.jsx)(p,{size:16,className:`ui-spinner`}):(0,O.jsx)(g,{size:16}),onClick:Z}];async function Q(e){if(r===!0)try{await te.put(`/api/user/profile`,{json:{displayName:e.displayName||e.username,avatar:e.avatar||``,updatedAt:e.profileUpdatedAt||Date.now()}}).json()}catch(e){n(await ne(e,t(`profile.backup.error.profileSaveFailed`)),`error`)}}function $(e){if(!a)return;let r={...a,avatar:e||void 0,profileUpdatedAt:Date.now()};v(r),Q(r),z(``),n(t(`profile.toast.avatarUpdated`),`success`)}function we(){if(!a)return;let e=w.trim()||a.username,r={...a,displayName:e,profileUpdatedAt:Date.now()};v(r),Q(r),N(e),n(t(`profile.toast.saved`),`success`)}function Te(){let e=I.trim();if(!e){$(void 0);return}if(!A(e)){z(t(`nav.avatarUrlInvalid`));return}$(e)}function Ee(){b(),V(!1)}return(0,O.jsxs)(E,{header:W,children:[(0,O.jsx)(`section`,{className:`profile-page`,children:(0,O.jsxs)(`div`,{className:`profile-container`,children:[(0,O.jsxs)(`section`,{className:`profile-panel profile-backup-card`,children:[(0,O.jsxs)(`div`,{className:`profile-panel-header profile-backup-header`,children:[(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`h2`,{children:t(`profile.section.backup`)}),(0,O.jsx)(`p`,{children:t(`profile.section.backup.desc`)})]}),(0,O.jsxs)(`span`,{className:`profile-backup-status ${ve}`,children:[(0,O.jsx)(M,{status:C.status,busy:C.busy}),C.statusLabel]})]}),(0,O.jsx)(`div`,{className:`profile-backup-summary`,"aria-label":t(`profile.backup.summary.label`),children:ye.map(t=>(0,O.jsxs)(`div`,{className:`profile-backup-stat`,children:[(0,O.jsx)(`span`,{className:`profile-backup-stat-value`,children:t.value===null?C.backupSummary.loading?`...`:`-`:e(t.value)}),(0,O.jsx)(`span`,{className:`profile-backup-stat-label`,children:t.label})]},t.key))}),(0,O.jsx)(`div`,{className:`profile-backup-actions`,children:Ce.map(e=>(0,O.jsxs)(`button`,{type:`button`,className:[`btn`,`profile-backup-action`,`is-${e.tone}`].join(` `),disabled:C.busy,onClick:e.onClick,children:[e.icon,e.label]},e.key))})]}),(0,O.jsxs)(`header`,{className:`profile-header`,children:[(0,O.jsx)(`img`,{className:`profile-avatar-large`,src:ge,alt:``}),(0,O.jsxs)(`div`,{className:`profile-heading`,children:[(0,O.jsx)(`p`,{className:`profile-kicker`,children:t(`profile.kicker`)}),(0,O.jsx)(`h1`,{children:a.displayName||a.username}),(0,O.jsxs)(`div`,{className:`profile-address-line`,children:[(0,O.jsx)(`code`,{translate:`no`,children:K}),(0,O.jsx)(T,{text:K}),(0,O.jsxs)(`a`,{href:`https://debank.com/profile/${a.address}`,target:`_blank`,rel:`noopener noreferrer`,className:`btn btn-secondary btn-sm`,children:[(0,O.jsx)(ie,{size:14}),t(`web3.action.view`)]})]})]}),(0,O.jsxs)(`button`,{type:`button`,className:`btn btn-secondary profile-logout-btn`,onClick:()=>V(!0),children:[(0,O.jsx)(fe,{size:16}),t(`account.logout`)]})]}),(0,O.jsxs)(`div`,{className:`profile-grid`,children:[(0,O.jsxs)(`section`,{className:`profile-panel`,children:[(0,O.jsx)(`div`,{className:`profile-panel-header`,children:(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`h2`,{children:t(`profile.section.account`)}),(0,O.jsx)(`p`,{children:t(`profile.section.account.desc`)})]})}),(0,O.jsxs)(`label`,{className:`profile-field`,children:[(0,O.jsx)(`span`,{children:t(`profile.label.displayName`)}),(0,O.jsxs)(`div`,{className:`profile-field-row`,children:[(0,O.jsx)(`input`,{className:`input`,value:w,onChange:e=>N(e.target.value),placeholder:t(`nav.displayNamePlaceholder`)}),(0,O.jsxs)(`button`,{type:`button`,className:`btn btn-primary`,onClick:we,children:[(0,O.jsx)(m,{size:16}),t(`profile.action.save`)]})]})]}),(0,O.jsx)(`div`,{className:`profile-facts`,children:(0,O.jsx)(P,{label:t(`profile.label.username`),value:a.username})})]}),(0,O.jsxs)(`section`,{className:`profile-panel`,children:[(0,O.jsx)(`div`,{className:`profile-panel-header`,children:(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`h2`,{children:t(`profile.section.avatar`)}),(0,O.jsx)(`p`,{children:t(`profile.section.avatar.desc`)})]})}),(0,O.jsx)(`div`,{className:`profile-avatar-grid`,role:`list`,children:k.map(e=>{let n=he===e.value;return(0,O.jsxs)(`button`,{type:`button`,className:[`profile-avatar-option`,n?`selected`:``].filter(Boolean).join(` `),onClick:()=>$(e.value),"aria-pressed":n,title:t(e.labelKey),children:[(0,O.jsx)(`img`,{src:x(a.address,e.value),alt:``,"aria-hidden":`true`}),(0,O.jsx)(`span`,{children:t(e.labelKey)}),n&&(0,O.jsx)(`span`,{className:`profile-avatar-check`,children:(0,O.jsx)(d,{size:14})})]},e.value||`address`)})}),(0,O.jsxs)(`div`,{className:`profile-avatar-url`,children:[(0,O.jsxs)(`label`,{className:`profile-field`,htmlFor:`profile-avatar-url`,children:[(0,O.jsx)(`span`,{children:t(`profile.label.customAvatar`)}),(0,O.jsxs)(`div`,{className:`profile-field-row`,children:[(0,O.jsx)(`input`,{id:`profile-avatar-url`,className:`input`,value:I,onChange:e=>{L(e.target.value),z(``)},placeholder:t(`nav.avatarUrlPlaceholder`)}),(0,O.jsxs)(`button`,{type:`button`,className:`btn btn-secondary`,onClick:Te,disabled:!_e,children:[(0,O.jsx)(m,{size:16}),t(`profile.action.save`)]})]})]}),R&&(0,O.jsx)(`p`,{className:`profile-error`,children:R})]})]})]}),(0,O.jsxs)(`section`,{className:`profile-panel profile-identity-panel`,children:[(0,O.jsxs)(`div`,{className:`profile-panel-header`,children:[(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`h2`,{children:t(`profile.section.identity`)}),(0,O.jsx)(`p`,{children:t(`profile.section.identity.desc`)})]}),(0,O.jsxs)(o,{to:`/web3/`,hash:`wallet`,className:`btn btn-secondary`,children:[(0,O.jsx)(pe,{size:16}),t(`profile.action.openWallet`)]})]}),(0,O.jsxs)(`div`,{className:`profile-key-grid`,children:[G&&(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(F,{title:t(`web3.label.ed25519Public`),icon:(0,O.jsx)(l,{size:18}),value:G.ed_public_key}),(0,O.jsx)(F,{title:t(`web3.label.x25519Public`),icon:(0,O.jsx)(ae,{size:18}),value:G.public_key})]}),(0,O.jsx)(F,{title:`IPNS ID`,icon:(0,O.jsx)(h,{size:18}),value:me||`-`})]})]})]})}),H&&(0,O.jsx)(se,{title:H.title,message:H.message,confirmText:H.confirmText,danger:H.danger,onConfirm:H.onConfirm,onClose:H.onClose||(()=>U(null))}),B&&(0,O.jsx)(ce,{className:`profile-logout-overlay`,onClose:()=>V(!1),children:(0,O.jsxs)(`div`,{className:`confirm-modal profile-logout-modal`,onClick:e=>e.stopPropagation(),children:[(0,O.jsxs)(`div`,{className:`modal-header`,children:[(0,O.jsx)(`h3`,{children:t(`account.logoutTitle`)}),(0,O.jsx)(`button`,{type:`button`,className:`btn btn-icon`,onClick:()=>V(!1),"aria-label":t(`common.close`),children:(0,O.jsx)(y,{size:18})})]}),(0,O.jsx)(`p`,{className:`profile-logout-reminder`,children:t(`profile.logout.backupReminder`)}),(0,O.jsxs)(`div`,{className:`profile-logout-backup-actions`,children:[(0,O.jsx)(`button`,{type:`button`,className:`btn btn-secondary`,disabled:C.busy,onClick:()=>void C.backupToCloud(),children:t(`profile.backup.action.cloudBackup`)}),(0,O.jsx)(`button`,{type:`button`,className:`btn btn-secondary`,disabled:C.busy,onClick:()=>void C.exportLocalBackup(),children:t(`profile.backup.action.exportLocal`)})]}),(0,O.jsxs)(`div`,{className:`modal-actions`,children:[(0,O.jsx)(`button`,{type:`button`,className:`btn btn-secondary`,onClick:()=>V(!1),children:t(`common.cancel`)}),(0,O.jsx)(`button`,{type:`button`,className:`btn btn-danger`,onClick:Ee,children:t(`account.logout`)})]})]})})]})}function P({label:e,value:t,copy:n=!1}){return(0,O.jsxs)(`div`,{className:`profile-fact`,children:[(0,O.jsx)(`span`,{children:e}),(0,O.jsxs)(`div`,{className:`profile-fact-value`,children:[(0,O.jsx)(`code`,{translate:`no`,children:t}),n&&(0,O.jsx)(T,{text:t})]})]})}function F({title:e,icon:t,value:n}){return(0,O.jsxs)(`div`,{className:`profile-key-card`,children:[(0,O.jsxs)(`div`,{className:`profile-key-card-header`,children:[(0,O.jsx)(`span`,{className:`profile-key-card-icon`,children:t}),(0,O.jsx)(`span`,{children:e})]}),(0,O.jsxs)(`div`,{className:`mono-row`,children:[(0,O.jsx)(`code`,{className:`mono`,translate:`no`,children:n}),(0,O.jsx)(T,{text:n})]})]})}var I=a(`/profile/`)({component:N});export{I as Route};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{B as e}from"./useAppStore-DOnk608w.js";var t=e(`key-round`,[[`path`,{d:`M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z`,key:`1s6t7t`}],[`circle`,{cx:`16.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`w0ekpg`}]]);export{t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{B as e}from"./useAppStore-DOnk608w.js";var t=e(`chevron-down`,[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]),n=e(`lock`,[[`rect`,{width:`18`,height:`11`,x:`3`,y:`11`,rx:`2`,ry:`2`,key:`1w4ew1`}],[`path`,{d:`M7 11V7a5 5 0 0 1 10 0v4`,key:`fwvmzm`}]]);export{t as n,n as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{o as e}from"./jsx-runtime-Bt-cYkS5.js";import{B as t,L as n,z as r}from"./useAppStore-DOnk608w.js";import{t as i}from"./dayjs.min-Dcc0B6Je.js";var a=t(`fingerprint-pattern`,[[`path`,{d:`M12 10a2 2 0 0 0-2 2c0 1.02-.1 2.51-.26 4`,key:`1nerag`}],[`path`,{d:`M14 13.12c0 2.38 0 6.38-1 8.88`,key:`o46ks0`}],[`path`,{d:`M17.29 21.02c.12-.6.43-2.3.5-3.02`,key:`ptglia`}],[`path`,{d:`M2 12a10 10 0 0 1 18-6`,key:`ydlgp0`}],[`path`,{d:`M2 16h.01`,key:`1gqxmh`}],[`path`,{d:`M21.8 16c.2-2 .131-5.354 0-6`,key:`drycrb`}],[`path`,{d:`M5 19.5C5.5 18 6 15 6 12a6 6 0 0 1 .34-2`,key:`1tidbn`}],[`path`,{d:`M8.65 22c.21-.66.45-1.32.57-2`,key:`13wd9y`}],[`path`,{d:`M9 6.8a6 6 0 0 1 9 5.2v2`,key:`1fr1j5`}]]),o=e(n(),1);i();var s=`0123456789abcdefghijklmnopqrstuvwxyz`,c=e=>{let t=[];for(;e>=128;)t.push(e&127|128),e>>=7;return t.push(e),t},l=e=>{let t=new Uint8Array([8,1,18,...c(e.length)]),n=new Uint8Array(t.length+e.length);return n.set(t,0),n.set(e,t.length),n},u=(e,t)=>{if(e.length===0)return``;let n=t.length,r=0;for(;r<e.length&&e[r]===0;)r++;let i=[0];for(let t=r;t<e.length;t++){let r=e[t];for(let e=0;e<i.length;e++){let t=i[e]*256+r;i[e]=t%n,r=Math.floor(t/n)}for(;r>0;)i.push(r%n),r=Math.floor(r/n)}let a=``;for(let e=0;e<r;e++)a+=t[0];for(let e=i.length-1;e>=0;e--)a+=t[i[e]];return a},d=(e,t)=>{let n=t.slice(2),i=new Uint8Array(r(e+n));return o.default.sign.keyPair.fromSecretKey(i)},f=(e,t)=>{let n=l(d(e,t).publicKey),r=new Uint8Array(2+n.length);r[0]=0,r[1]=36,r.set(n,2);let i=new Uint8Array([1,114]),a=new Uint8Array(i.length+r.length);return a.set(i,0),a.set(r,i.length),`k`+u(a,s)};export{f as n,a as r,d as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{B as e}from"./useAppStore-DOnk608w.js";var t=e(`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`}]]),n=e(`notebook-pen`,[[`path`,{d:`M13.4 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-7.4`,key:`re6nr2`}],[`path`,{d:`M2 6h4`,key:`aawbzj`}],[`path`,{d:`M2 10h4`,key:`l0bgd4`}],[`path`,{d:`M2 14h4`,key:`1gsvsf`}],[`path`,{d:`M2 18h4`,key:`1bu2t1`}],[`path`,{d:`M21.378 5.626a1 1 0 1 0-3.004-3.004l-5.01 5.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z`,key:`pqwjuv`}]]);export{t as n,n as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{B as e}from"./useAppStore-DOnk608w.js";var t=e(`play`,[[`path`,{d:`M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z`,key:`10ikf1`}]]);export{t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{B as e}from"./useAppStore-DOnk608w.js";var t=e(`search`,[[`path`,{d:`m21 21-4.34-4.34`,key:`14j7rj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}]]);export{t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{B as e}from"./useAppStore-DOnk608w.js";var t=e(`trash-2`,[[`path`,{d:`M10 11v6`,key:`nco0om`}],[`path`,{d:`M14 11v6`,key:`outv1u`}],[`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`,key:`miytrc`}],[`path`,{d:`M3 6h18`,key:`d0wm0j`}],[`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`,key:`e791ji`}]]);export{t};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import{n as e,o as t}from"./jsx-runtime-Bt-cYkS5.js";import{E as n,u as r}from"./useAppStore-DOnk608w.js";import{i,r as ee}from"./userProfile-BZvkCuet.js";var a=t(e(),1);function o(e=``,t=[]){let n=[e,...t];return[...new Set(n.filter(Boolean))]}function s(e=[]){return o(``,e).join(`
|
|
2
|
-
`)}function c(e,t){let n=new Set(e),r=new Set(t);return{subscribe:[...r].filter(e=>!n.has(e)),unsubscribe:[...n].filter(e=>!r.has(e))}}var te=15*1e3;function l(e){return String(e.id||`${e.author||``}-${e.timestamp||``}-${e.content||``}`)}function u(e){let t=Number(e.timestamp);return Number.isFinite(t)?t:0}function d(e){return e.map((e,t)=>({message:e,index:t})).sort((e,t)=>{let n=u(e.message)-u(t.message);return n===0?e.index-t.index:n}).map(e=>e.message)}function ne(){return`presence-${Date.now()}-${Math.random().toString(36).slice(2)}`}function f({isReady:e,enabled:t=!0,channelName:u=``,extraSubscribedChannelNames:f=[],peerId:p=``,waitForPeerId:m=!1,limit:h=100,reconnectBaseDelay:g=2500,acceptMessage:_,getMessageKey:v=l,onSyncError:y,onSocketEvent:b,onReconnect:x,presenceEnabled:S=!1,presenceProfile:C={}}){let w=n(e=>e.identity),[re,T]=(0,a.useState)([]),[E,D]=(0,a.useState)(!1),O=(0,a.useMemo)(()=>s(f),[f]),k=(0,a.useRef)(null),A=(0,a.useRef)(u),j=(0,a.useRef)(f),M=(0,a.useRef)(null),N=(0,a.useRef)(0),P=(0,a.useRef)(_),F=(0,a.useRef)(v),I=(0,a.useRef)(b),L=(0,a.useRef)(y),R=(0,a.useRef)(x),z=(0,a.useRef)(p),B=(0,a.useRef)(new Set),V=(0,a.useRef)(S),H=(0,a.useRef)(C),U=(0,a.useRef)(ne()),W=(0,a.useRef)(``);(0,a.useEffect)(()=>{j.current=O?O.split(`
|
|
3
|
-
`):[]},[O]),(0,a.useEffect)(()=>{P.current=_},[_]),(0,a.useEffect)(()=>{F.current=v},[v]),(0,a.useEffect)(()=>{I.current=b},[b]),(0,a.useEffect)(()=>{L.current=y},[y]),(0,a.useEffect)(()=>{R.current=x},[x]),(0,a.useEffect)(()=>{V.current=S},[S]),(0,a.useEffect)(()=>{H.current=C},[C]);let G=(0,a.useCallback)(e=>{let t=P.current;return t?e.filter(t):e},[]),K=(0,a.useCallback)((e,t,n=!0)=>{let r=[...e];for(let e of G(t)){let t=F.current(e);if(n){let n=r.findIndex(t=>t.pending&&t.author?.toLowerCase()===e.author?.toLowerCase()&&t.content===e.content);if(n!==-1){r[n]={...e,id:e.id||t};continue}}r.some(e=>F.current(e)===t)||r.push({...e,id:e.id||t})}return d(r)},[G]),q=(0,a.useCallback)((e,t)=>{k.current?.readyState===WebSocket.OPEN&&k.current.send(JSON.stringify({event:e,data:t}))},[]),J=(0,a.useCallback)(e=>({channel:e,sessionId:U.current,...H.current}),[]),Y=(0,a.useCallback)((e=W.current)=>{e&&(q(`channel:presence:leave`,{channel:e,sessionId:U.current}),W.current===e&&(W.current=``))},[q]),X=(0,a.useCallback)(e=>{!e||!V.current||!w||(q(`channel:presence:join`,J(e)),W.current=e)},[J,w,q]),Z=(0,a.useCallback)(e=>{let t=new Set(e.filter(Boolean)),n=c(B.current,t);for(let e of n.unsubscribe)q(`channel:unsubscribe`,{channel:e});for(let e of n.subscribe)q(`channel:subscribe`,{channel:e});B.current=t},[q]),Q=(0,a.useCallback)(()=>o(A.current,j.current),[]),$=(0,a.useCallback)(async(t=A.current,n={})=>{if(!t||!e)return[];try{let e=G(await i.getChannelMessages(t,h));return T(t=>n.replace?d(e):K(t,e,!1)),e}catch(e){return n.replace&&T([]),await L.current?.(e),[]}},[G,e,h,K]);(0,a.useEffect)(()=>{z.current=p,p&&(q(`register`,{peerId:p}),m&&(Z(Q()),A.current&&$(A.current,{replace:!0})))},[Q,p,Z,$,m,q]);let ie=(0,a.useCallback)(()=>{T([])},[]),ae=(0,a.useCallback)(async({channelName:e=A.current,content:t,attachment:n,optimisticId:r})=>{let a=t.trim();if(!e||!a||!w)return null;let o=ee(w),s={id:r||`${o.author}-${Date.now()}-${Math.random().toString(36).slice(2)}`,...o,content:a,timestamp:Date.now(),pending:!0,attachment:n};T(e=>d([...e,s]));try{let t=await i.sendChannelMessage({channelName:e,content:a,...o,attachment:n});return T(e=>d(e.map(e=>e.id===s.id?{...t.message,id:t.message.id||F.current(t.message)}:e))),t.message}catch(e){throw T(e=>e.filter(e=>e.id!==s.id)),e}},[w]);return(0,a.useEffect)(()=>{A.current=u,!(!e||!t)&&(u&&$(u,{replace:!0}),(!m||z.current)&&Z(Q()))},[u,t,O,Q,e,Z,$,m]),(0,a.useEffect)(()=>{if(!E||!S||!w||!u){Y();return}let e=W.current;e&&e!==u&&Y(e),W.current!==u&&X(u)},[u,E,X,Y,S,w]),(0,a.useEffect)(()=>{let e=W.current;!E||!S||!e||!w||q(`channel:presence:profile`,J(e))},[E,J,S,(0,a.useMemo)(()=>[C.displayName||``,C.avatar||``,C.profileUpdatedAt||``].join(`
|
|
4
|
-
`),[C.avatar,C.displayName,C.profileUpdatedAt]),w,q]),(0,a.useEffect)(()=>{if(!E||!S||!w)return;let e=window.setInterval(()=>{let e=W.current;e&&q(`channel:presence:heartbeat`,{channel:e,sessionId:U.current})},te);return()=>window.clearInterval(e)},[E,S,w,q]),(0,a.useEffect)(()=>{!e||!t||m&&!z.current||Z(Q())},[t,Q,e,Z,m]),(0,a.useEffect)(()=>{if(!e||!t){D(!1);return}let n=!1;N.current=0;async function i(){let e=new WebSocket(await r(`/ws`));if(n){e.close();return}e.onopen=()=>{D(!0),N.current=0,z.current&&e.send(JSON.stringify({event:`register`,data:{peerId:z.current}})),(!m||z.current)&&(B.current.clear(),Z(Q()),A.current&&$(A.current,{replace:!0}),R.current?.())},e.onmessage=e=>{try{let t=JSON.parse(e.data);I.current?.(t.event,t.data),t.event===`channel:message`&&t.data?.channel===A.current&&t.data?.message&&T(e=>K(e,[t.data.message])),t.event===`user:metadata:updated`&&t.data?.scope===`channels`&&A.current&&$(A.current,{replace:!0})}catch{}},e.onclose=()=>{if(D(!1),W.current=``,n)return;let e=N.current;if(e>=20)return;let t=Math.min(g*2**e,3e4);N.current=e+1,M.current=setTimeout(i,t)},e.onerror=()=>e.close(),k.current=e}return i(),()=>{n=!0,M.current&&clearTimeout(M.current),Y(),k.current?.close(),k.current=null,B.current.clear()}},[t,Q,e,Y,K,g,Z,$,m]),{clearMessages:ie,connected:E,messages:re,sendMessage:ae,setMessages:T,syncMessages:$}}export{f as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{n as e,o as t,t as n}from"./jsx-runtime-Bt-cYkS5.js";import{B as r,E as i,W as a,_ as o,b as s,g as c,h as l,o as u,t as d,v as f,x as p,y as m}from"./useAppStore-DOnk608w.js";import{t as h}from"./AppTop-Cy0ZOCxO.js";import{A as g}from"./index-D0Uk9-58.js";import{i as _,n as v,r as y,t as b}from"./userProfile-BZvkCuet.js";import{t as x}from"./useChannelMessages-CDvw-f_x.js";var S=r(`spade`,[[`path`,{d:`M12 18v4`,key:`jadmvz`}],[`path`,{d:`M2 14.499a5.5 5.5 0 0 0 9.591 3.675.6.6 0 0 1 .818.001A5.5 5.5 0 0 0 22 14.5c0-2.29-1.5-4-3-5.5l-5.492-5.312a2 2 0 0 0-3-.02L5 8.999c-1.5 1.5-3 3.2-3 5.5`,key:`1aw2pz`}]]),C=r(`swords`,[[`polyline`,{points:`14.5 17.5 3 6 3 3 6 3 17.5 14.5`,key:`1hfsw2`}],[`line`,{x1:`13`,x2:`19`,y1:`19`,y2:`13`,key:`1vrmhu`}],[`line`,{x1:`16`,x2:`20`,y1:`16`,y2:`20`,key:`1bron3`}],[`line`,{x1:`19`,x2:`21`,y1:`21`,y2:`19`,key:`13pww6`}],[`polyline`,{points:`14.5 6.5 18 3 21 3 21 6 17.5 9.5`,key:`hbey2j`}],[`line`,{x1:`5`,x2:`9`,y1:`14`,y2:`18`,key:`1hf58s`}],[`line`,{x1:`7`,x2:`4`,y1:`17`,y2:`20`,key:`pidxm4`}],[`line`,{x1:`3`,x2:`5`,y1:`19`,y2:`21`,key:`1pehsh`}]]),w=n(),T=[{id:`gandengyan`,labelKey:`game.gandengyan.title`,href:`/game/gandengyan/`,icon:(0,w.jsx)(C,{size:16})},{id:`zhajinhua`,labelKey:`game.zhajinhua.title`,href:`/game/zhajinhua/`,icon:(0,w.jsx)(S,{size:16})}];function E({activeGame:e,closeSidebar:t}){let{t:n}=g();return(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(h,{onNavigate:t}),(0,w.jsx)(`nav`,{className:`sidebar-nav`,children:T.map(r=>(0,w.jsxs)(a,{to:r.href,className:`sidebar-nav-btn ${e===r.id?`active`:``}`,onClick:t,children:[r.icon,(0,w.jsx)(`span`,{children:n(r.labelKey)})]},r.id))})]})}var D=t(e(),1),O=`game`,k=`mostbox.game.event`,A=[`gandengyan`,`zhajinhua`],j=`ABCDEFGHJKLMNPQRSTUVWXYZ23456789`;function M(e){let t=String(e||``).trim().toLowerCase();return A.includes(t)?t:``}function N(e){return m(e)}function P(e){return/^[A-Z0-9]{4,8}$/.test(String(e||``))}function F(){let e=``;for(let t=0;t<6;t++)e+=j[s(32)];return e}function I(e,t){let n=M(e),r=N(t);return!n||!P(r)?``:`game.${n}.${r.toLowerCase()}`}function L({gameId:e,roomCode:t,event:n,payload:r}){let i=M(e);return{kind:k,version:1,gameId:i,roomCode:N(t),event:String(n||``),eventId:l(i||`game`),payload:r||{}}}function R(e,t={}){try{let n=JSON.parse(String(e||``));if(!n||n.kind!==`mostbox.game.event`||n.version!==1||typeof n.event!=`string`||typeof n.eventId!=`string`)return null;let r=M(n.gameId),i=N(n.roomCode);return!r||!P(i)||t.gameId&&r!==M(t.gameId)||t.roomCode&&i!==N(t.roomCode)?null:{...n,gameId:r,roomCode:i,payload:n.payload&&typeof n.payload==`object`?n.payload:{}}}catch{return null}}function z(e=[],t={}){let n=[],r=new Map,i=``;for(let a of U(e)){let e=R(a.content,t);if(e){if(e.event===`room:create`){let t=V(e.payload?.player,a);if(!t)continue;i||=t.address,H(n,r,t);continue}if(e.event===`player:join`){let t=V(e.payload?.player,a);t&&H(n,r,t);continue}if(e.event===`player:leave`){let t=c(e.payload?.player?.address||a.author);if(t){let e=n.findIndex(e=>e.address===t);e!==-1&&(n.splice(e,1),r.delete(t))}}}}return{gameId:M(t.gameId),roomCode:N(t.roomCode),hostAddress:i,players:n}}function B(e=[],t={}){let n=null;for(let r of U(e)){let e=R(r.content,t);if(!e||e.event!==`room:state`)continue;let i=Number(e.payload?.seq||0);(!n||i>=Number(n.payload?.seq||0))&&(n=e)}return n}function V(e,t){if(!e||typeof e!=`object`)return null;let n=t&&typeof t==`object`?t:{author:t},r=n.author,i=c(e.address||r);if(!i||c(r)!==i)return null;let a=f(n.authorName||e.name,p(i)),s=o(n.avatar||e.avatar),l={address:i,name:a,publicKey:String(e.publicKey||``).trim(),joinedAt:Number(e.joinedAt||Date.now())};return s&&(l.avatar=s),l}function H(e,t,n){let r=t.get(n.address);if(r){Object.assign(r,n);return}e.push(n),t.set(n.address,n)}function U(e){return[...e].sort((e,t)=>Number(e.timestamp||0)-Number(t.timestamp||0))}function W({gameId:e,onError:t,getPlayerPayload:n}){let{t:r}=g(),a=d(e=>e.hasBackend),o=d(e=>e.checkBackend),s=d(e=>e.openConnectModal),l=i(e=>e.identity),f=i(e=>e.openLoginModal),[p,m]=(0,D.useState)(``),[h,v]=(0,D.useState)(``),[y,S]=(0,D.useState)([]),[C,w]=(0,D.useState)(!1),T=(0,D.useRef)(h);T.current=h;let E=a===!0,k=(0,D.useMemo)(()=>l?{...b(l),profileUpdatedAt:l.profileUpdatedAt}:{},[l?.avatar,l?.displayName,l?.profileUpdatedAt,l?.username]),A=(0,D.useCallback)(async(e,n)=>{let r=await u(e,n);t&&t(r)},[t]),j=(0,D.useCallback)(async(e=T.current)=>{if(!e||!E)return S([]),[];try{let t=await _.getChannelPresence(e);return T.current===e?(S(t),t):[]}catch(e){return console.warn(`[Game] Failed to fetch channel presence:`,e instanceof Error?e.message:e),[]}},[E]),M=(0,D.useCallback)((e,t)=>{if(e!==`channel:presence`)return;let n=String(t?.channelKey||t?.channel||``).trim(),r=T.current;r&&(!n||n===r)&&j(r)},[j]),P=(0,D.useCallback)(t=>!!R(t.content,{gameId:e,roomCode:p}),[e,p]),z=(0,D.useCallback)(t=>{let n=R(t.content,{gameId:e,roomCode:p});return n?`${t.author}-${n.eventId}`:`${t.author}-${t.timestamp}-${t.content}`},[e,p]),{clearMessages:B,connected:V,messages:H,sendMessage:U,syncMessages:W}=x({isReady:E,enabled:!!l,channelName:h,limit:500,acceptMessage:P,getMessageKey:z,onSyncError:e=>A(e,r(`game.room.error.readLog`)),onSocketEvent:M,onReconnect:()=>{j()},presenceEnabled:!!(h&&l),presenceProfile:k});(0,D.useEffect)(()=>{if(!h||!E){S([]);return}j(h)},[h,E,j]);let K=(0,D.useMemo)(()=>H.map(t=>({message:t,event:R(t.content,{gameId:e,roomCode:p})})).filter(e=>e.event),[e,H,p]),J=(0,D.useMemo)(()=>{let e=new Map;return y.forEach(t=>{let n=c(t.address);!n||!t.online||e.set(n,t)}),e},[y]),Y=(0,D.useMemo)(()=>new Set(J.keys()),[J]),X=(0,D.useCallback)(()=>l?E?!0:(s(),!1):(f(),!1),[E,s,f,l]);(0,D.useEffect)(()=>{a===null&&o()},[o,a]);let Z=(0,D.useCallback)(async(i,a=!1)=>{if(!X()||!l)return!1;let o=a?F():N(i),s=I(e,o);if(!s)return t&&t(r(`game.room.error.invalidCode`)),!1;w(!0);try{let t=await _.createChannel(s,O,b(l)),r=t.channelKey||t.key||s;return await G(r,l,e,o,a?`room:create`:`player:join`,{player:q(l,n?.(l))}),m(o),v(r),B(),!0}catch(e){return await A(e,r(a?`game.room.error.createFailed`:`game.room.error.joinFailed`)),!1}finally{w(!1)}},[X,e,n,t,A,B,r,l]);return{channelName:h,channelPresence:y,connected:V,createRoom:(0,D.useCallback)(()=>Z(``,!0),[Z]),ensureReady:X,isBackendReady:E,joinRoom:(0,D.useCallback)(e=>Z(e),[Z]),joining:C,messages:H,onlineAddresses:Y,presenceByAddress:J,roomCode:p,roomEvents:K,sendRoomEvent:(0,D.useCallback)(async(t,n={})=>{if(!X()||!l||!h||!p)return!1;let i=L({gameId:e,roomCode:p,event:t,payload:n}),a=JSON.stringify(i);try{return await U({channelName:h,content:a,optimisticId:`${l.address}-${i.eventId}`}),!0}catch(e){return await A(e,r(`game.room.error.sendEventFailed`)),!1}},[h,X,e,A,p,U,r,l]),setRoomCode:m,syncMessages:W,userIdentity:l}}async function G(e,t,n,r,i,a){let o=L({gameId:n,roomCode:r,event:i,payload:a});await _.sendChannelMessage({channelName:e,content:JSON.stringify(o),...y(t)})}function K(e){return{address:e.address,name:v(e),avatar:e.avatar||``,publicKey:``,joinedAt:Date.now()}}function q(e,t={}){let n=K(e),r={...n,...t};return Object.prototype.hasOwnProperty.call(t,`avatar`)||(r.avatar=n.avatar),r}export{S as a,E as i,z as n,B as r,W as t};
|