most-box 0.1.9 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (157) hide show
  1. package/README.md +16 -3
  2. package/out/admin/index.html +0 -0
  3. package/out/app/index.html +0 -0
  4. package/out/assets/AppShell-CQhg6DJU.js +1 -0
  5. package/out/assets/ChatUi-BepWs-ZU.js +1 -0
  6. package/out/assets/LanguageToggle-CtzCCAYv.js +1 -0
  7. package/out/assets/{LogoIcon-CYQ7cHd5.js → LogoIcon-Dxto3Sb4.js} +1 -1
  8. package/out/assets/{MarketingLayout-BTIbv4fW.js → MarketingLayout-BQw0IS2i.js} +1 -1
  9. package/out/assets/MarketingThemeToggle-DBaC9bjz.js +1 -0
  10. package/out/assets/MilkdownEditor-BqJzntYE.js +1054 -0
  11. package/out/assets/MoveModal-4D9n11Kw.js +1 -0
  12. package/out/assets/Nav-9MDdvgNs.js +1 -0
  13. package/out/assets/NoteSidebar-C-rIt32H.js +1 -0
  14. package/out/assets/OpenSidebarButton-Dd0JmKuE.js +1 -0
  15. package/out/assets/PemBlock-C8dEIzu-.js +1 -0
  16. package/out/assets/SidebarAccount-ClS-N0lq.js +1 -0
  17. package/out/assets/arrow-right-urE9Rd7j.js +1 -0
  18. package/out/assets/channelApi-BwQU0-h1.js +1 -0
  19. package/out/assets/check-DUNsD2t6.js +1 -0
  20. package/out/assets/chevron-down-D6mpsfv4.js +1 -0
  21. package/out/assets/{circle-alert-CqEQz6P4.js → circle-alert-W0iyN4sC.js} +1 -1
  22. package/out/assets/cloud-BMyOoC2x.js +1 -0
  23. package/out/assets/code-B1Cb_Icm.js +1 -0
  24. package/out/assets/{copy-CM-qWlbv.js → copy-C1MttOli.js} +1 -1
  25. package/out/assets/{dist-CvatM4u8.js → dist-8QDHqrPN.js} +1 -1
  26. package/out/assets/{dist-BmtYO1GG.js → dist-B0JrbG7f.js} +5 -5
  27. package/out/assets/{dist-DBpw-A8y.js → dist-BFSyuOuw.js} +1 -1
  28. package/out/assets/{dist-D5Cf0hK8.js → dist-BPs0Xns9.js} +2 -2
  29. package/out/assets/{dist-BQV5zYG_.js → dist-Br_5lLVO.js} +9 -9
  30. package/out/assets/{dist-CrzjJUOw.js → dist-BzqqCPi2.js} +1 -1
  31. package/out/assets/dist-C3lbe8SW.js +9 -0
  32. package/out/assets/{dist-CWJ3323z.js → dist-CfU9fwWz.js} +1 -1
  33. package/out/assets/{dist-BdmTLuCI.js → dist-DCX0ws1K.js} +1 -1
  34. package/out/assets/{dist-DrumcFOX.js → dist-DJdv-Ma3.js} +1 -1
  35. package/out/assets/{dist-C5HibLEW.js → dist-chOCTzB2.js} +1 -1
  36. package/out/assets/{download-0rM8xVCe.js → download-y7SZXu6E.js} +1 -1
  37. package/out/assets/downloadValidation-B0p9Ai_9.js +1 -0
  38. package/out/assets/filePreview-UI9NH34f.js +1 -0
  39. package/out/assets/format-CR8oUWq6.js +1 -0
  40. package/out/assets/game-CdU3xnZo.js +1 -0
  41. package/out/assets/{hard-drive-CCdIvSap.js → hard-drive-D13Qbobu.js} +1 -1
  42. package/out/assets/image-DJCA16l_.js +1 -0
  43. package/out/assets/index-BdaFEQG-.css +1 -0
  44. package/out/assets/index-QxXZzOUL.js +33 -0
  45. package/out/assets/index.lazy-BBTTFanX.js +1 -0
  46. package/out/assets/index.lazy-BG4ZylHD.js +2 -0
  47. package/out/assets/index.lazy-Bi-6ZXZX.js +1 -0
  48. package/out/assets/index.lazy-BixWVr0B.js +1 -0
  49. package/out/assets/index.lazy-BjFwNYy5.js +3 -0
  50. package/out/assets/index.lazy-C8EIQsXY.js +2 -0
  51. package/out/assets/index.lazy-CarNe2uu.js +1 -0
  52. package/out/assets/index.lazy-DEuGu3H3.js +1 -0
  53. package/out/assets/index.lazy-GPyILCA7.js +3 -0
  54. package/out/assets/index.lazy-I8ofndXl.js +1 -0
  55. package/out/assets/index.lazy-TxhWsA7y.js +1 -0
  56. package/out/assets/index.lazy-azfky8k7.js +1 -0
  57. package/out/assets/{key-round-tIqGrtt_.js → key-round-CZniN9lv.js} +1 -1
  58. package/out/assets/lock-D5OSNhep.js +1 -0
  59. package/out/assets/log-out-B6phyZ5z.js +1 -0
  60. package/out/assets/{music-BkZKq879.js → music-CbUskKgg.js} +1 -1
  61. package/out/assets/{notebook-pen-B4VSbweh.js → notebook-pen-DqKDQ6MJ.js} +1 -1
  62. package/out/assets/play-BIl8q9eU.js +1 -0
  63. package/out/assets/plus-BxxbpH6Q.js +1 -0
  64. package/out/assets/{save-BzjzC3eV.js → save-DkH1n_Ov.js} +1 -1
  65. package/out/assets/search-BQi5Z0E-.js +1 -0
  66. package/out/assets/{send-DtQInX0y.js → send-Cl6NtD2T.js} +1 -1
  67. package/out/assets/{trash-2-BhMrUgGM.js → trash-2-BBjpgK_f.js} +1 -1
  68. package/out/assets/triangle-alert-l98G8u9O.js +1 -0
  69. package/out/assets/upload-ByP6Ydde.js +1 -0
  70. package/out/assets/{useChannelMessages-Bs1hEJyd.js → useChannelMessages-BgbYfF2c.js} +2 -2
  71. package/out/assets/useGameRoom-DPmweWwe.js +1 -0
  72. package/out/assets/{wallet-YxbxCi7C.js → wallet-c7zIhNSM.js} +1 -1
  73. package/out/assets/{wifi-v3JpPCNm.js → wifi-Bm4biAjc.js} +1 -1
  74. package/out/chat/index.html +0 -0
  75. package/out/chat/join/index.html +0 -0
  76. package/out/demo/index.html +0 -0
  77. package/out/download/index.html +6 -2
  78. package/out/game/gandengyan/index.html +0 -0
  79. package/out/game/index.html +0 -0
  80. package/out/game/zhajinhua/index.html +0 -0
  81. package/out/index.html +6 -2
  82. package/out/note/index.html +0 -0
  83. package/out/ping/index.html +6 -2
  84. package/out/web3/index.html +0 -0
  85. package/package.json +2 -2
  86. package/server/index.js +9 -0
  87. package/server/src/core/channelAttachment.js +7 -3
  88. package/server/src/core/channelIdentity.js +50 -0
  89. package/server/src/core/cid.js +6 -1
  90. package/server/src/core/cidTopic.js +18 -4
  91. package/server/src/core/displayPath.js +10 -0
  92. package/server/src/core/gameRoom.js +2 -2
  93. package/server/src/core/mostLink.js +45 -25
  94. package/server/src/core/ownerMetadata.js +34 -0
  95. package/server/src/core/userSyncKeys.js +36 -0
  96. package/server/src/http/app.js +71 -149
  97. package/server/src/http/dataPath.js +26 -0
  98. package/server/src/http/errors.js +8 -4
  99. package/server/src/http/nodeStatus.js +13 -13
  100. package/server/src/http/rateLimit.js +39 -0
  101. package/server/src/http/routePolicy.js +43 -0
  102. package/server/src/index.js +1909 -759
  103. package/server/src/node/offlineSwarm.js +20 -0
  104. package/server/src/utils/api.js +1 -15
  105. package/server/src/utils/downloadMessages.js +17 -18
  106. package/server/src/utils/errors.js +3 -1
  107. package/server/src/utils/noteUtils.js +27 -3
  108. package/out/assets/AppShell-DmZQwVA9.js +0 -1
  109. package/out/assets/ChatUi-CVGqjFdx.js +0 -1
  110. package/out/assets/MilkdownEditor-BL8xE7u9.js +0 -1054
  111. package/out/assets/MoveModal-BKkVBvrS.js +0 -1
  112. package/out/assets/Nav-BDGeJnbC.js +0 -1
  113. package/out/assets/NoteSidebar-BIJ8_m5K.js +0 -1
  114. package/out/assets/OpenSidebarButton-Di62DGiu.js +0 -1
  115. package/out/assets/PemBlock-Dxx6k9MH.js +0 -1
  116. package/out/assets/SidebarAccount-CCHZLGdP.js +0 -1
  117. package/out/assets/admin-BepWGXWG.js +0 -2
  118. package/out/assets/app-3D79fY3w.js +0 -1
  119. package/out/assets/arrow-right-D0sGC8QA.js +0 -1
  120. package/out/assets/channelApi-CL7YsIQ-.js +0 -1
  121. package/out/assets/chat-B56sk6od.js +0 -1
  122. package/out/assets/check-DdfnsLKm.js +0 -1
  123. package/out/assets/chevron-down-Xlb3wTxd.js +0 -1
  124. package/out/assets/circle-check-CwAH4dgJ.js +0 -1
  125. package/out/assets/cloud-CcPRoob1.js +0 -1
  126. package/out/assets/code-Dr6STnCn.js +0 -1
  127. package/out/assets/database-DQ7ZtUT9.js +0 -1
  128. package/out/assets/dateTime-D1koKRQU.js +0 -1
  129. package/out/assets/demo-B_6rlIjn.js +0 -3
  130. package/out/assets/dist-BGtXa07s.js +0 -9
  131. package/out/assets/download-BLPU-Kzq.js +0 -1
  132. package/out/assets/downloadMessages-7Xbd-HhS.js +0 -1
  133. package/out/assets/ed25519-BEctXF0E.js +0 -1
  134. package/out/assets/filePreview-BvbHWUTG.js +0 -1
  135. package/out/assets/folder-CcbCxm-k.js +0 -1
  136. package/out/assets/game-B0zuqnOh.js +0 -1
  137. package/out/assets/gandengyan-DbQC7hCK.js +0 -1
  138. package/out/assets/index-BLhmAher.css +0 -1
  139. package/out/assets/index-Cf23WD2V.js +0 -29
  140. package/out/assets/join-DQHXjlfH.js +0 -1
  141. package/out/assets/note-DmWqGSS2.js +0 -2
  142. package/out/assets/ping-JILckfMu.js +0 -1
  143. package/out/assets/play-BIl5vwqS.js +0 -1
  144. package/out/assets/plus-DHvLpuuw.js +0 -1
  145. package/out/assets/routes-Dyckj88f.js +0 -1
  146. package/out/assets/search-C-EpsDNl.js +0 -1
  147. package/out/assets/sun-C3IUQTpa.js +0 -1
  148. package/out/assets/tools-BEctXF0E.js +0 -1
  149. package/out/assets/triangle-alert-DUODU79n.js +0 -1
  150. package/out/assets/upload-CpDM23UH.js +0 -1
  151. package/out/assets/useGameRoom-C6UgmIGG.js +0 -1
  152. package/out/assets/web3-CRX1YFmw.js +0 -3
  153. package/out/assets/zhajinhua-QDmSZbOp.js +0 -1
  154. package/out/web3/ed25519/index.html +0 -0
  155. package/out/web3/tools/index.html +0 -0
  156. /package/out/assets/{gandengyan-8eWJAjpY.css → index-8eWJAjpY.css} +0 -0
  157. /package/out/assets/{zhajinhua-BZc4blbW.css → index-BZc4blbW.css} +0 -0
@@ -1 +0,0 @@
1
- import{n as e,o as t,t as n}from"./jsx-runtime-Bt-cYkS5.js";import{t as r}from"./check-DdfnsLKm.js";import{t as i}from"./circle-alert-CqEQz6P4.js";import{t as a}from"./key-round-tIqGrtt_.js";import{t as o}from"./AppShell-DmZQwVA9.js";import{n as s,t as c}from"./sun-C3IUQTpa.js";import{G as l,U as u,d,f,h as p,m,u as h}from"./index-Cf23WD2V.js";import{t as g}from"./channelApi-CL7YsIQ-.js";var _=t(e(),1),v=[{name:`node_url`,required:!1,description:`Web 端未连接后端时,用于连接远程节点。`},{name:`node_invite`,required:!1,description:`配合 node_url 作为远程节点邀请码。`},{name:`uid`,required:!0,description:`作为用户名,密码为空,用于生成账户并自动登录。`},{name:`identity`,required:!1,description:`邀请身份类型;user 为普通用户视图。`},{name:`logo`,required:!1,description:`覆盖邀请用户聊天页顶部 logo。`},{name:`avatar`,required:!1,description:`覆盖默认头像。`},{name:`name`,required:!1,description:`覆盖默认昵称。`},{name:`locale`,required:!1,description:`预留给多语言切换,当前暂不执行。`},{name:`channels[].id`,required:!0,description:`频道 ID,用于自动加入频道。`},{name:`channels[].name`,required:!1,description:`频道备注,不作为频道 ID。`}],y=n(),b=`0x955fe80bdb8312165471fcacd6a8f83df88a770dda6f38657ca4e62ec28d5b54`,x=50,S=`https://api.most.box`;function C(e){try{return JSON.parse(e)}catch{return null}}function w(e){return typeof e==`string`?C(e):e}function T(e,t){return t===null?e:JSON.stringify(t,null,2)}function E(e,t){if(t&&typeof t==`object`&&`error`in t){let e=t.error;if(typeof e==`string`)return e}return e||`解密失败`}function D(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function O(e){return typeof e==`string`?e.trim():``}function k(e){let t=O(e);return t===`user`||t===`service`||t===`service_ai`?t:void 0}function A(e){let t=w(e);if(!D(t))return null;let n=O(t.uid),r=(Array.isArray(t.channels)?t.channels:[]).filter(D).map(e=>({id:O(e.id),name:O(e.name)||void 0})).filter(e=>e.id);return!n||r.length===0?null:{node_url:O(t.node_url)||void 0,node_invite:O(t.node_invite)||void 0,locale:O(t.locale)||void 0,uid:n,identity:k(t.identity),logo:O(t.logo)||void 0,avatar:O(t.avatar)||void 0,name:O(t.name)||void 0,channels:r}}function j(e){return`/chat?channel=${encodeURIComponent(e)}`}function M(e){return String(e||``).trim().slice(0,x)}function N(){let e=l({select:e=>e.searchStr}),{token:t,pub:n}=(0,_.useMemo)(()=>{let t=new URLSearchParams(e);return{token:t.get(`token`)||``,pub:t.get(`pub`)||``}},[e]),x=f(e=>e.isDarkMode),w=f(e=>e.setIsDarkMode),D=f(e=>e.hasBackend),O=h(e=>e.setUserIdentity),[k,N]=(0,_.useState)(``),[P,F]=(0,_.useState)(``),[I,L]=(0,_.useState)(!0),[R,z]=(0,_.useState)(``),B=(0,_.useRef)(``);return(0,_.useEffect)(()=>{if(!t){F(`缺少 token 参数`),L(!1);return}if(!n){F(`缺少 pub 参数`),L(!1);return}if(D===null){z(`正在检测后端连接...`);return}let e=`${t}:${n}`;if(B.current===e)return;B.current=e;async function r(e){if(e.node_url){if(z(`正在连接远程节点...`),!(await m({url:e.node_url,invite:e.node_invite||``})).ok)throw Error(`远程节点连接失败`);p({url:e.node_url,invite:e.node_invite||``}),f.setState({hasBackend:!0})}else if(!D)throw Error(`未连接后端,邀请中也没有 node_url`);z(`正在登录邀请账号...`);let t=d(e.uid,``);O({...t,identity:e.identity,displayName:e.name||t.displayName,logo:e.logo,avatar:e.avatar}),z(`正在加入频道...`);for(let n of e.channels){await g.createChannel(n.id,`public`,{displayName:e.name||t.displayName,avatar:e.avatar});let r=M(n.name);r&&await g.setChannelRemark(n.id,r)}let n=e.channels[0];z(`加入成功,正在打开频道...`),window.location.href=j(n.id)}async function i(){try{z(`正在解密邀请...`);let e=await fetch(`${S}/api/chat.join.decrypt`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({token:t,pub:n})}),i=await e.text(),a=C(i);if(!e.ok)F(E(i,a));else{N(T(i,a));let e=A(a);if(!e){F(`邀请内容缺少 uid 或 channels[].id`);return}await r(e)}}catch(e){F(`请求出错: ${e instanceof Error?e.message:String(e)}`)}finally{L(!1)}}i()},[D,n,O,t]),(0,y.jsx)(o,{sidebar:()=>(0,y.jsxs)(`div`,{className:`sidebar-header sidebar-header-link`,onClick:()=>window.location.href=`/chat`,children:[(0,y.jsx)(u,{size:18}),(0,y.jsx)(`h1`,{children:`MOST PEOPLE`})]}),headerTitle:(0,y.jsx)(`h2`,{className:`header-title`,children:`加入频道`}),headerRight:(0,y.jsx)(`button`,{className:`btn btn-icon`,onClick:()=>w(!x),title:`切换主题`,children:x?(0,y.jsx)(c,{size:16}):(0,y.jsx)(s,{size:16})}),children:(0,y.jsx)(`div`,{className:`chat-join-container`,children:(0,y.jsxs)(`div`,{className:`chat-join-panel`,children:[I?(0,y.jsxs)(`div`,{className:`chat-join-loading`,children:[(0,y.jsx)(a,{size:32}),(0,y.jsx)(`p`,{children:R||`正在解密...`})]}):P?(0,y.jsxs)(`div`,{className:`chat-join-error`,children:[(0,y.jsx)(i,{size:32}),(0,y.jsx)(`p`,{children:P}),R&&(0,y.jsx)(`p`,{className:`chat-join-status`,children:R}),k&&(0,y.jsx)(`pre`,{className:`chat-join-result`,children:k})]}):(0,y.jsxs)(`div`,{className:`chat-join-success`,children:[(0,y.jsx)(r,{size:32}),(0,y.jsx)(`p`,{children:R||`解密成功`}),(0,y.jsx)(`pre`,{className:`chat-join-result`,children:k})]}),(0,y.jsxs)(`section`,{className:`chat-join-spec`,"aria-labelledby":`chat-join-spec-title`,children:[(0,y.jsxs)(`div`,{className:`chat-join-helper-title`,children:[(0,y.jsx)(a,{size:18}),(0,y.jsx)(`h3`,{id:`chat-join-spec-title`,children:`支持字段`})]}),(0,y.jsx)(`div`,{className:`chat-join-field-list`,children:v.map(e=>(0,y.jsxs)(`div`,{className:`chat-join-field`,children:[(0,y.jsxs)(`div`,{className:`chat-join-field-meta`,children:[(0,y.jsx)(`code`,{className:`chat-join-field-name`,children:e.name}),(0,y.jsx)(`span`,{children:e.required?`必填`:`可选`})]}),(0,y.jsx)(`p`,{children:e.description})]},e.name))})]}),(0,y.jsxs)(`section`,{className:`chat-join-helper`,"aria-labelledby":`ea-test-title`,children:[(0,y.jsxs)(`div`,{className:`chat-join-helper-title`,children:[(0,y.jsx)(a,{size:18}),(0,y.jsx)(`h3`,{id:`ea-test-title`,children:`测试公钥`})]}),(0,y.jsx)(`code`,{className:`ui-code-box chat-join-public-key`,children:b}),(0,y.jsx)(`a`,{className:`btn`,href:`/web3/#EA`,target:`_blank`,children:`前往 Web3 工具箱`})]})]})})})}function P(){return(0,y.jsx)(_.Suspense,{children:(0,y.jsx)(N,{})})}var F=P;export{F as component};
@@ -1,2 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/MilkdownEditor-BL8xE7u9.js","assets/jsx-runtime-Bt-cYkS5.js","assets/index-Cf23WD2V.js","assets/index-BLhmAher.css","assets/dist-zyJb88Zz.js","assets/dist-CbTzBiwL.js"])))=>i.map(i=>d[i]);
2
- import{n as e,o as t,t as n}from"./jsx-runtime-Bt-cYkS5.js";import{t as r}from"./folder-CcbCxm-k.js";import{n as i,t as a}from"./trash-2-BhMrUgGM.js";import{n as o,t as s}from"./dateTime-D1koKRQU.js";import{t as c}from"./AppShell-DmZQwVA9.js";import{n as l,t as u}from"./sun-C3IUQTpa.js";import{t as d}from"./notebook-pen-B4VSbweh.js";import{t as ee}from"./OpenSidebarButton-Di62DGiu.js";import{t as f}from"./plus-DHvLpuuw.js";import{t as p}from"./save-BzjzC3eV.js";import{t as m}from"./search-C-EpsDNl.js";import{E as h,F as g,G as _,I as te,J as ne,L as re,O as ie,P as v,T as y,V as ae,W as b,f as x,o as oe,s as se,t as S,u as C,z as ce}from"./index-Cf23WD2V.js";import{n as le,r as ue,t as de}from"./NoteSidebar-BIJ8_m5K.js";var fe=b(`move`,[[`path`,{d:`M12 2v20`,key:`t6zp3m`}],[`path`,{d:`m15 19-3 3-3-3`,key:`11eu04`}],[`path`,{d:`m19 9 3 3-3 3`,key:`1mg7y2`}],[`path`,{d:`M2 12h20`,key:`9i4pu4`}],[`path`,{d:`m5 9-3 3 3 3`,key:`j64kie`}],[`path`,{d:`m9 5 3-3 3 3`,key:`l8vdw6`}]]),pe=b(`pencil-ruler`,[[`path`,{d:`M13 7 8.7 2.7a2.41 2.41 0 0 0-3.4 0L2.7 5.3a2.41 2.41 0 0 0 0 3.4L7 13`,key:`orapub`}],[`path`,{d:`m8 6 2-2`,key:`115y1s`}],[`path`,{d:`m18 16 2-2`,key:`ee94s4`}],[`path`,{d:`m17 11 4.3 4.3c.94.94.94 2.46 0 3.4l-2.6 2.6c-.94.94-2.46.94-3.4 0L11 17`,key:`cfq27r`}],[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}],[`path`,{d:`m15 5 4 4`,key:`1mk7zo`}]]),w=t(e(),1),T=`https://api.most.box/auth/backup`;async function E(e,t){return(await e.clone().json().catch(()=>null))?.error||t}function me(e,t){return h(JSON.stringify({notes:e||[]}),t)}function D(e,t){if(!String(e||``).startsWith(`mp://1`))throw Error(`无效的备份数据格式`);let n=y(e,t);if(!n)throw Error(`解密失败,请确认当前 Web3 登录账号正确`);let r=JSON.parse(n);if(!Array.isArray(r.notes))throw Error(`备份数据缺少 notes`);return r}async function O(e){return v(JSON.stringify({notes:e||[]}))}async function k(e,t,n=T){let r=Date.now().toString(),i=new URL(n).pathname,a=`${r}:${String(t).toUpperCase()}:${i}`,{address:o,signature:s}=await ie(e.danger,a);return{Authorization:`${o},${r},${s}`}}async function A(e,t){let n=await v(JSON.stringify({notes:t||[]}));return{cid:n,body:me(t,e.danger),headers:{"Content-Type":`text/plain`,"x-backup-cid":n,...await k(e,`PUT`,T)}}}async function he(e,t,n=T){let r=await A(e,t),i=await fetch(n,{method:`PUT`,headers:r.headers,body:r.body});if(!i.ok)throw Error(await E(i,`云备份失败`));return{cid:r.cid}}async function j(e,t=T){let n=await fetch(t,{method:`GET`,headers:await k(e,`GET`,t)});if(n.status===404)return{found:!1,cid:``,time:0,notes:[]};if(!n.ok)throw Error(await E(n,`云端恢复失败`));let r=await n.text();if(!r)throw Error(`云端无备份数据`);let i=D(r,e.danger);return{found:!0,cid:n.headers.get(`x-backup-cid`)||``,time:Number(n.headers.get(`x-backup-time`)||0),notes:i.notes}}var M=!1,N=``,P=``;function F(e,t){return e instanceof Error?e.message:t}function I(e){switch(e){case`disabled`:return`未登录`;case`checking`:return`检查中`;case`uploading`:return`同步中`;case`restoring`:return`恢复中`;case`synced`:return`已同步`;case`conflict`:return`有冲突`;case`error`:return`同步失败`;default:return`待同步`}}function ge(){let e=C(e=>e.wallet),t=C(e=>e.openLoginModal),n=x(e=>e.addToast),r=x(e=>e.notes),i=x(e=>e.importNotes),a=x(e=>e.localDataReady),[o,s]=(0,w.useState)(null),[c,l]=(0,w.useState)(e?`idle`:`disabled`),[u,d]=(0,w.useState)(M),[ee,f]=(0,w.useState)(!1),p=(0,w.useRef)(0),m=(0,w.useCallback)(e=>{M=e,d(e)},[]),h=(0,w.useCallback)((e=!1)=>C.getState().wallet||(e||t(),null),[n,t]),g=(0,w.useCallback)(async(e={})=>{let{silent:t=!1,confirmConflict:r=!0}=e,i=h(t);if(!i)return l(`disabled`),!1;if(M&&r&&!window.confirm(`本地数据与云端不一致,本地修改将会覆盖云端数据,是否继续?`))return t||n(`已取消同步`,`info`),l(`conflict`),!1;s(`save`),l(`uploading`);try{let e=x.getState().notes;return N=(await he(i,e)).cid,P=i.address,m(!1),l(`synced`),t||n(`云端备份已更新`,`success`),!0}catch(e){return l(`error`),t?console.info(F(e,`云备份失败`)):n(F(e,`云备份失败`),`error`),!1}finally{s(null)}},[n,h,m]),_=(0,w.useCallback)(async(e={})=>{let{manual:t=!1,uploadWhenMissing:r=!1}=e,a=h(!t);if(!a)return l(`disabled`),!1;s(t?`restore`:`sync`),l(t?`restoring`:`checking`);try{let e=await j(a),o=x.getState().notes;if(!e.found)return m(!1),P=a.address,r&&o.length>0?(s(null),g({silent:!0,confirmConflict:!1})):(l(o.length>0?`idle`:`synced`),t&&n(`云端暂无备份`,`info`),!1);let c=e.notes||[],u=await O(o),d=e.cid||await O(c);return o.length>0&&u!==d&&!window.confirm(`云端备份与本地笔记不一致。恢复会覆盖本地笔记,是否继续?`)?(m(!0),l(`conflict`),t&&n(`已取消恢复`,`info`),!1):(u!==d&&i(c),N=d,P=a.address,m(!1),l(`synced`),t&&n(`已从云端恢复`,`success`),!0)}catch(e){return l(`error`),t?n(F(e,`云端恢复失败`),`error`):console.info(F(e,`云端恢复失败`)),!1}finally{s(null)}},[n,i,h,m,g]),te=(0,w.useCallback)(()=>{let e=h(!1);if(e)try{let t=x.getState().notes,r=me(t,e.danger),i=new Blob([r],{type:`text/plain`}),a=URL.createObjectURL(i),o=document.createElement(`a`);o.href=a,o.download=`${e.address.slice(-4)}-most-notes-${new Date().toISOString().slice(0,10)}.txt`,o.click(),URL.revokeObjectURL(a),n(`笔记已导出到本地`,`success`)}catch(e){n(F(e,`导出失败`),`error`)}},[n,h]),ne=(0,w.useCallback)(()=>{let e=h(!1);if(!e)return;let t=document.createElement(`input`);t.type=`file`,t.accept=`.txt`,t.onchange=t=>{let r=t.target.files?.[0];if(!r)return;let a=new FileReader;a.onload=async()=>{try{let t=a.result,r=D(t,e.danger);if(x.getState().notes.length>0&&!window.confirm(`恢复将覆盖当前本地笔记,是否继续?`)){n(`已取消恢复`,`info`);return}i(r.notes),n(`已从本地恢复笔记`,`success`),await g({silent:!0})}catch(e){n(F(e,`导入失败`),`error`)}},a.readAsText(r)},t.click()},[n,i,h,g]);return(0,w.useEffect)(()=>{if(!a)return;if(!e){P=``,N=``,f(!1),m(!1),l(`disabled`);return}if(P===e.address){f(!0),l(M?`conflict`:`synced`);return}let t=!1;return f(!1),_({manual:!1,uploadWhenMissing:!0}).finally(()=>{t||f(!0)}),()=>{t=!0}},[a,_,m,e]),(0,w.useEffect)(()=>{if(!e||!a||!ee||(p.current+=1,p.current<=1))return;let t=window.setTimeout(async()=>{let e=x.getState().notes;await O(e)!==N&&await g({silent:!0})},900);return()=>window.clearTimeout(t)},[ee,a,r,g,e]),{action:o,status:c,statusLabel:(0,w.useMemo)(()=>I(c),[c]),hasConflict:u,uploadNow:g,restoreFromCloud:_,exportLocalBackup:te,importLocalBackup:ne}}var L=n(),_e=(0,w.lazy)(async()=>({default:(await S(()=>import(`./MilkdownEditor-BL8xE7u9.js`),__vite__mapDeps([0,1,2,3,4,5]))).MilkdownEditor}));function ve(e){let t=new URLSearchParams(e),n=t.get(`mode`);return{cid:t.get(`cid`)||void 0,mode:n===`edit`?`edit`:void 0}}function ye(e={}){let t=new URLSearchParams;e.cid&&t.set(`cid`,e.cid),e.mode&&t.set(`mode`,e.mode);let n=t.toString();return n?`/note/?${n}`:`/note/`}function be(e){return e.isSecret||e.content.startsWith(`mp://1`)?`私密内容已加密`:String(e.content||``).replace(/```[\s\S]*?```/g,` `).replace(/!\[[^\]]*]\([^)]*\)/g,` `).replace(/\[([^\]]+)]\([^)]*\)/g,`$1`).replace(/[#>*_`~|-]/g,` `).replace(/\s+/g,` `).trim()||`空白笔记`}function R(e,t){return e instanceof Error?e.message:t}function xe(e){return e.type===`directory`?re(e.path?`${e.path}/${e.name}`:e.name):te(e)}function Se(e){let t=new Set;for(let n of e){let e=re(n.path).split(`/`).filter(Boolean);for(let n=0;n<e.length;n+=1)t.add(e.slice(0,n+1).join(`/`))}return Array.from(t).sort((e,t)=>e.localeCompare(t,`zh-CN`)).map(e=>{let t=e.split(`/`);return{path:e,name:t[t.length-1]||e,parentPath:t.slice(0,-1).join(`/`),depth:Math.max(t.length-1,0)}})}function z(){let e=ne(),t=_({select:e=>e.searchStr}),n=(0,w.useMemo)(()=>ve(t),[t]),ie=(0,w.useRef)(null),v=ge(),b=x(e=>e.addToast),S=x(e=>e.isDarkMode),T=x(e=>e.setIsDarkMode),E=C(e=>e.wallet),me=C(e=>e.openLoginModal),D=x(e=>e.notes),O=x(e=>e.notesPath),k=x(e=>e.setNotesPath),A=x(e=>e.saveNote),he=x(e=>e.deleteNote),j=x(e=>e.renameNote),M=x(e=>e.localDataReady),N=n.cid||``,P=D.find(e=>e.cid===N),F=!!N,I=F&&n.mode===`edit`,[z,Ce]=(0,w.useState)(``),[B,V]=(0,w.useState)(null),[H,U]=(0,w.useState)(null),[W,G]=(0,w.useState)(null),[we,K]=(0,w.useState)(``),[Te,q]=(0,w.useState)(``),[Ee,J]=(0,w.useState)(``),[De,Oe]=(0,w.useState)(``),[ke,Ae]=(0,w.useState)(``),[je,Y]=(0,w.useState)(``),[X,Me]=(0,w.useState)(!1),[Ne,Z]=(0,w.useState)(``),[Pe,Fe]=(0,w.useState)(!1);(0,w.useEffect)(()=>{if(!N){K(``),q(``);return}if(!P){K(``),q(M?`笔记不存在`:``);return}if(P.content.startsWith(`mp://1`)){if(!E){K(``),q(`请先登录 Web3 账号以解密此笔记`);return}let e=y(P.content,E.danger);if(!e){K(``),q(`无法解密,请确认当前 Web3 账号正确`);return}K(e),q(``);return}K(P.content||``),q(``)},[N,M,P,E]),(0,w.useEffect)(()=>{if(!I){Fe(!1);return}if(!N||!P){Oe(``),Ae(``),Y(``),Me(!1),Z(M?`笔记不存在`:``);return}if(Oe(P.name),Ae(P.path||``),Me(P.isSecret===!0||P.content.startsWith(`mp://1`)),P.content.startsWith(`mp://1`)){if(!E){Y(``),Z(`请先登录 Web3 账号以解密此笔记`);return}let e=y(P.content,E.danger);if(!e){Y(``),Z(`无法解密,请确认当前 Web3 账号正确`);return}Y(e),Z(``);return}Y(P.content||``),Z(``)},[N,I,M,P,E]),(0,w.useEffect)(()=>{J(P?.name||``)},[P?.cid,P?.name]);let Ie=(0,w.useMemo)(()=>g(D,O,z),[D,O,z]),Le=Ie.filter(e=>e.type===`file`).length,Re=P?.isSecret===!0||P?.content.startsWith(`mp://1`)===!0,ze=I?X?`私密`:`公开`:Re?`私密`:`公开`,Be=(0,w.useMemo)(()=>{let e=O.split(`/`).filter(Boolean);return[{label:`全部笔记`,path:``},...e.map((t,n)=>({label:t,path:e.slice(0,n+1).join(`/`)}))]},[O]),Ve=(0,w.useMemo)(()=>Se(D),[D]);function Q(t={},n=!1){e({href:ye(t),replace:n})}function He(e){Q({cid:e.cid})}function Ue(e){Q({cid:e.cid,mode:`edit`})}function $(){return E?!0:(me(),!1)}function We(){Q(P?{cid:P.cid}:{})}async function Ge(){if($()){if(!P){b(`笔记不存在`,`error`);return}if(!De.trim()){b(`请输入笔记名称`,`warning`);return}Fe(!0);try{let e=ie.current?.getMarkdown()??je,t=X?h(e,E.danger):e,n=await A({cid:P.cid,name:De,path:ke,content:t,isSecret:X});Y(e),b(`笔记已保存`,`success`),await v.uploadNow({silent:!0}),Q({cid:n},!0)}catch(e){b(R(e,`保存失败`),`error`)}finally{Fe(!1)}}}function Ke(){$()&&V({title:`新建笔记`,placeholder:`笔记名称`,confirmText:`创建`,onConfirm:async e=>{if($())try{let t=await A({name:e,path:O,content:``,isSecret:!1});V(null),b(`笔记已创建`,`success`),await v.uploadNow({silent:!0}),Q({cid:t,mode:`edit`})}catch(e){b(R(e,`创建失败`),`error`)}}})}async function qe(){if(!$()||!P)return;let e=Ee.trim();if(!e){J(P.name),b(`请输入笔记名称`,`warning`);return}if(e!==P.name)try{j(te(P),P.path,e),b(`已重命名`,`success`),await v.uploadNow({silent:!0})}catch(e){J(P.name),b(R(e,`重命名失败`),`error`)}}function Je(e){$()&&G(e)}async function Ye(e){if(W)try{j(xe(W),e,W.name),G(null),b(`已移动`,`success`),await v.uploadNow({silent:!0})}catch(e){b(R(e,`移动失败`),`error`)}}function Xe(e){if(!$())return;let t=e.type===`directory`;U({title:t?`删除文件夹`:`删除笔记`,message:`确定要删除「${e.name}」吗?此操作不可撤销。`,confirmText:`删除`,onConfirm:async()=>{he(t?void 0:e.cid,e.path,e.name),U(null),b(`已删除`,`success`),await v.uploadNow({silent:!0}),e.type===`file`&&e.cid===N&&Q()}})}let Ze=(0,L.jsxs)(`div`,{className:`note-header-title`,children:[(0,L.jsx)(`h2`,{className:`header-title`,children:`笔记`}),(0,L.jsxs)(`span`,{children:[D.length,` 篇`]})]}),Qe=(0,L.jsxs)(`div`,{className:`note-theme-wrap`,children:[(0,L.jsx)(`button`,{className:`btn btn-icon`,onClick:()=>T(!S),title:`切换主题`,"aria-label":`切换主题`,children:S?(0,L.jsx)(u,{size:16}):(0,L.jsx)(l,{size:16})}),(0,L.jsx)(ue,{sync:v})]}),$e=(0,L.jsxs)(`section`,{className:`note-list-panel note-sidebar-list`,"aria-label":`笔记列表`,children:[(0,L.jsxs)(`div`,{className:`note-list-header`,children:[(0,L.jsx)(`div`,{className:`note-current-location`,children:(0,L.jsx)(`div`,{className:`note-breadcrumbs`,children:Be.map((e,t)=>(0,L.jsxs)(w.Fragment,{children:[t>0&&(0,L.jsx)(`span`,{children:`/`}),(0,L.jsx)(`button`,{onClick:()=>k(e.path),children:e.label})]},e.path||`root`))})}),(0,L.jsxs)(`span`,{className:`note-count`,children:[Le,` 篇`]})]}),(0,L.jsxs)(`div`,{className:`note-search`,children:[(0,L.jsx)(m,{size:16}),(0,L.jsx)(`input`,{className:`input input-flex`,value:z,onChange:e=>Ce(e.target.value),placeholder:`搜索笔记`})]}),Ie.length===0?(0,L.jsxs)(`div`,{className:`ui-empty-state note-empty-state`,children:[(0,L.jsx)(d,{size:32}),(0,L.jsx)(`p`,{children:z?`未找到笔记`:`还没有笔记`})]}):(0,L.jsx)(`div`,{className:`note-list`,children:Ie.map(e=>(0,L.jsx)(`article`,{className:`ui-list-item note-list-item ${e.type===`file`&&e.cid===N?`active`:``}`,children:(0,L.jsxs)(`button`,{className:`ui-list-item-main note-list-item-main ${e.type===`directory`?`folder`:``}`,onClick:()=>{e.type===`directory`?k(re(e.path?`${e.path}/${e.name}`:e.name)):He(e)},children:[(0,L.jsx)(`span`,{className:`ui-list-icon note-list-icon ${e.type===`directory`?`warning`:``}`,children:e.type===`directory`?(0,L.jsx)(r,{size:18}):e.isSecret?(0,L.jsx)(o,{size:18}):(0,L.jsx)(i,{size:18})}),(0,L.jsxs)(`span`,{className:`ui-list-copy note-list-copy`,children:[(0,L.jsx)(`span`,{className:`ui-list-title note-list-name`,children:e.name}),e.type===`file`?(0,L.jsx)(`span`,{className:`ui-list-desc note-list-preview`,children:be(e)}):(0,L.jsx)(`span`,{className:`ui-list-desc note-list-preview`,children:`文件夹`})]}),e.type===`file`&&(0,L.jsx)(`span`,{className:`ui-list-meta note-list-date`,children:s(e.updated_at)})]})},`${e.cid}:${e.path}:${e.name}`))}),(0,L.jsx)(`div`,{className:`note-create-btn`,children:(0,L.jsxs)(`button`,{className:`btn`,onClick:Ke,children:[(0,L.jsx)(f,{size:16}),`新笔记`]})})]});return(0,L.jsxs)(c,{sidebar:()=>(0,L.jsx)(de,{children:$e}),headerTitle:Ze,headerRight:Qe,children:[(0,L.jsx)(`main`,{className:`note-page note-browser-page ${F?`has-editor`:``}`,children:(0,L.jsx)(`section`,{className:`note-workspace`,children:(0,L.jsx)(`section`,{className:`note-editor-panel`,"aria-label":I?`笔记编辑器`:`笔记阅读器`,children:F?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`div`,{className:`note-editor-panel-header`,children:[(0,L.jsxs)(`div`,{className:`note-editor-title-area`,children:[I?(0,L.jsx)(`input`,{className:`note-title-input`,value:De,onChange:e=>Oe(e.target.value),placeholder:`笔记名称`,disabled:!P}):P?(0,L.jsx)(`input`,{className:`note-title-input`,value:Ee,onBlur:qe,onChange:e=>J(e.target.value),onKeyDown:e=>{e.key===`Enter`&&e.currentTarget.blur(),e.key===`Escape`&&(J(P.name),e.currentTarget.blur())},placeholder:`笔记名称`,title:`重命名`}):(0,L.jsx)(`h3`,{children:`未命名笔记`}),P&&(0,L.jsxs)(`div`,{className:`note-editor-info`,children:[(0,L.jsx)(`span`,{children:I?`编辑模式`:`阅读模式`}),(0,L.jsx)(`span`,{children:ze}),(0,L.jsx)(`span`,{children:s(P.updated_at)})]})]}),(0,L.jsxs)(`div`,{className:`note-editor-actions`,children:[(0,L.jsx)(`button`,{type:`button`,className:`btn btn-icon`,onClick:I?We:()=>Q(),title:I?`取消`:`关闭`,"aria-label":I?`取消`:`关闭`,children:(0,L.jsx)(ce,{size:16})}),I?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`button`,{className:`btn btn-sm ${X?`btn-warning`:`btn-secondary`}`,onClick:()=>Me(!X),disabled:!P,children:[X?(0,L.jsx)(o,{size:16}):(0,L.jsx)(ae,{size:16}),X?`私密`:`公开`]}),(0,L.jsxs)(`button`,{className:`btn btn-sm btn-primary`,onClick:Ge,disabled:Pe||!!Ne||!P,children:[(0,L.jsx)(p,{size:16}),Pe?`保存中`:`保存`]})]}):P&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`button`,{type:`button`,className:`btn btn-icon`,onClick:()=>Je(P),title:`移动`,"aria-label":`移动`,children:(0,L.jsx)(fe,{size:16})}),(0,L.jsx)(`button`,{type:`button`,className:`btn btn-icon note-editor-action-danger`,onClick:()=>Xe(P),title:`删除`,"aria-label":`删除`,children:(0,L.jsx)(a,{size:16})}),(0,L.jsxs)(`button`,{type:`button`,className:`btn btn-sm btn-primary`,onClick:()=>Ue(P),disabled:!!Te,title:`编辑`,"aria-label":`编辑`,children:[(0,L.jsx)(pe,{size:16}),`编辑`]})]})]})]}),I?Ne?(0,L.jsxs)(`div`,{className:`note-empty-state editor-error`,children:[(0,L.jsx)(o,{size:36}),(0,L.jsx)(`p`,{children:Ne})]}):P?(0,L.jsx)(`div`,{className:`note-editor-frame editing`,children:(0,L.jsx)(_e,{ref:ie,content:je,onChange:Y,className:`milkdown-editor`})}):(0,L.jsxs)(`div`,{className:`note-empty-state editor-error`,children:[(0,L.jsx)(d,{size:36}),(0,L.jsx)(`p`,{children:M?`笔记不存在`:`加载中...`})]}):Te?(0,L.jsxs)(`div`,{className:`ui-empty-state note-empty-state editor-error`,children:[(0,L.jsx)(o,{size:36}),(0,L.jsx)(`p`,{children:Te})]}):P?(0,L.jsx)(`div`,{className:`note-editor-frame reading`,children:(0,L.jsx)(_e,{content:we,readOnly:!0,className:`milkdown-editor`})}):(0,L.jsxs)(`div`,{className:`ui-empty-state note-empty-state editor-error`,children:[(0,L.jsx)(d,{size:36}),(0,L.jsx)(`p`,{children:M?`笔记不存在`:`加载中...`})]})]}):(0,L.jsxs)(`div`,{className:`ui-empty-state note-editor-empty`,children:[(0,L.jsx)(`div`,{className:`ui-empty-icon note-editor-empty-icon`,children:(0,L.jsx)(d,{size:32})}),(0,L.jsx)(`h3`,{className:`ui-empty-title`,children:`没有打开的笔记`}),(0,L.jsx)(`p`,{className:`ui-empty-desc`,children:D.length>0?`选择一篇笔记继续`:`创建第一篇笔记`}),(0,L.jsx)(ee,{label:`打开笔记列表`,variant:`default`})]})})})}),B&&(0,L.jsx)(oe,{title:B.title,placeholder:B.placeholder,defaultValue:B.defaultValue,confirmText:B.confirmText,onConfirm:B.onConfirm,onClose:()=>V(null)}),H&&(0,L.jsx)(se,{title:H.title,message:H.message,confirmText:H.confirmText,danger:!0,onConfirm:H.onConfirm,onClose:()=>U(null)}),W&&(0,L.jsx)(le,{target:W,directories:Ve,onMove:Ye,onClose:()=>G(null)})]})}function Ce(){return(0,L.jsx)(w.Suspense,{fallback:(0,L.jsx)(`div`,{className:`note-editor-loading`,children:`加载中...`}),children:(0,L.jsx)(z,{})})}var B=Ce;export{B as component};
@@ -1 +0,0 @@
1
- import{n as e,o as t,t as n}from"./jsx-runtime-Bt-cYkS5.js";import{t as r}from"./cloud-CcPRoob1.js";import{n as i}from"./LogoIcon-CYQ7cHd5.js";import{t as a}from"./music-BkZKq879.js";import{t as o}from"./play-BIl5vwqS.js";import{t as s}from"./search-C-EpsDNl.js";import{t as c}from"./send-DtQInX0y.js";import{t as l}from"./wifi-v3JpPCNm.js";import{W as u}from"./index-Cf23WD2V.js";import{t as d}from"./MarketingLayout-BTIbv4fW.js";var f=u(`at-sign`,[[`circle`,{cx:`12`,cy:`12`,r:`4`,key:`4exip2`}],[`path`,{d:`M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8`,key:`7n84p3`}]]),p=u(`book-open`,[[`path`,{d:`M12 7v14`,key:`1akyts`}],[`path`,{d:`M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z`,key:`ruj8y`}]]),m=u(`bot`,[[`path`,{d:`M12 8V4H8`,key:`hb8ula`}],[`rect`,{width:`16`,height:`12`,x:`4`,y:`8`,rx:`2`,key:`enze0r`}],[`path`,{d:`M2 14h2`,key:`vft8re`}],[`path`,{d:`M20 14h2`,key:`4cs60a`}],[`path`,{d:`M15 13v2`,key:`1xurst`}],[`path`,{d:`M9 13v2`,key:`rq6x2g`}]]),h=u(`camera`,[[`path`,{d:`M13.997 4a2 2 0 0 1 1.76 1.05l.486.9A2 2 0 0 0 18.003 7H20a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2h1.997a2 2 0 0 0 1.759-1.048l.489-.904A2 2 0 0 1 10.004 4z`,key:`18u6gg`}],[`circle`,{cx:`12`,cy:`13`,r:`3`,key:`1vg3eu`}]]),ee=u(`messages-square`,[[`path`,{d:`M16 10a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 14.286V4a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2z`,key:`1n2ejm`}],[`path`,{d:`M20 9a2 2 0 0 1 2 2v10.286a.71.71 0 0 1-1.212.502l-2.202-2.202A2 2 0 0 0 17.172 19H10a2 2 0 0 1-2-2v-1`,key:`1qfcsi`}]]),g=u(`package`,[[`path`,{d:`M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z`,key:`1a0edw`}],[`path`,{d:`M12 22V12`,key:`d0xqtd`}],[`polyline`,{points:`3.29 7 12 12 20.71 7`,key:`ousv84`}],[`path`,{d:`m7.5 4.27 9 5.15`,key:`1c824w`}]]),_=u(`rotate-cw`,[[`path`,{d:`M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8`,key:`1p45f6`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}]]),v=u(`smartphone`,[[`rect`,{width:`14`,height:`20`,x:`5`,y:`2`,rx:`2`,ry:`2`,key:`1yt0o3`}],[`path`,{d:`M12 18h.01`,key:`mhygvu`}]]),te=u(`terminal`,[[`path`,{d:`M12 19h8`,key:`baeox8`}],[`path`,{d:`m4 17 6-6-6-6`,key:`1yngyt`}]]),y=u(`triangle`,[[`path`,{d:`M13.73 4a2 2 0 0 0-3.46 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3Z`,key:`14u9p9`}]]),b=t(e(),1);function ne(e,t){let n=e.icons,r=e.aliases||Object.create(null),i=Object.create(null);function a(e){if(n[e])return i[e]=[];if(!(e in i)){i[e]=null;let t=r[e]&&r[e].parent,n=t&&a(t);n&&(i[e]=[t].concat(n))}return i[e]}return Object.keys(n).concat(Object.keys(r)).forEach(a),i}var x=Object.freeze({left:0,top:0,width:16,height:16}),S=Object.freeze({rotate:0,vFlip:!1,hFlip:!1}),C=Object.freeze({...x,...S}),w=Object.freeze({...C,body:``,hidden:!1});function re(e,t){let n={};!e.hFlip!=!t.hFlip&&(n.hFlip=!0),!e.vFlip!=!t.vFlip&&(n.vFlip=!0);let r=((e.rotate||0)+(t.rotate||0))%4;return r&&(n.rotate=r),n}function T(e,t){let n=re(e,t);for(let r in w)r in S?r in e&&!(r in n)&&(n[r]=S[r]):r in t?n[r]=t[r]:r in e&&(n[r]=e[r]);return n}function ie(e,t,n){let r=e.icons,i=e.aliases||Object.create(null),a={};function o(e){a=T(r[e]||i[e],a)}return o(t),n.forEach(o),T(e,a)}function E(e,t){let n=[];if(typeof e!=`object`||typeof e.icons!=`object`)return n;e.not_found instanceof Array&&e.not_found.forEach(e=>{t(e,null),n.push(e)});let r=ne(e);for(let i in r){let a=r[i];a&&(t(i,ie(e,i,a)),n.push(i))}return n}var ae={provider:``,aliases:{},not_found:{},...x};function D(e,t){for(let n in t)if(n in e&&typeof e[n]!=typeof t[n])return!1;return!0}function O(e){if(typeof e!=`object`||!e)return null;let t=e;if(typeof t.prefix!=`string`||!e.icons||typeof e.icons!=`object`||!D(e,ae))return null;let n=t.icons;for(let e in n){let t=n[e];if(!e||typeof t.body!=`string`||!D(t,w))return null}let r=t.aliases||Object.create(null);for(let e in r){let t=r[e],i=t.parent;if(!e||typeof i!=`string`||!n[i]&&!r[i]||!D(t,w))return null}return t}var k=Object.create(null);function oe(e,t){return{provider:e,prefix:t,icons:Object.create(null),missing:new Set}}function A(e,t){let n=k[e]||(k[e]=Object.create(null));return n[t]||(n[t]=oe(e,t))}function se(e,t){return O(t)?E(t,(t,n)=>{n?e.icons[t]=n:e.missing.add(t)}):[]}function ce(e,t,n){try{if(typeof n.body==`string`)return e.icons[t]={...n},!0}catch{}return!1}var le=/^[a-z0-9]+(-[a-z0-9]+)*$/,j=(e,t,n,r=``)=>{let i=e.split(`:`);if(e.slice(0,1)===`@`){if(i.length<2||i.length>3)return null;r=i.shift().slice(1)}if(i.length>3||!i.length)return null;if(i.length>1){let e=i.pop(),n=i.pop(),a={provider:i.length>0?i[0]:r,prefix:n,name:e};return t&&!M(a)?null:a}let a=i[0],o=a.split(`-`);if(o.length>1){let e={provider:r,prefix:o.shift(),name:o.join(`-`)};return t&&!M(e)?null:e}if(n&&r===``){let e={provider:r,prefix:``,name:a};return t&&!M(e,n)?null:e}return null},M=(e,t)=>e?!!((t&&e.prefix===``||e.prefix)&&e.name):!1,N=!1;function P(e){return typeof e==`boolean`&&(N=e),N}function F(e){let t=typeof e==`string`?j(e,!0,N):e;if(t){let e=A(t.provider,t.prefix),n=t.name;return e.icons[n]||(e.missing.has(n)?null:void 0)}}function ue(e,t){let n=j(e,!0,N);if(!n)return!1;let r=A(n.provider,n.prefix);return t?ce(r,n.name,t):(r.missing.add(n.name),!0)}function de(e,t){if(typeof e!=`object`)return!1;if(typeof t!=`string`&&(t=e.provider||``),N&&!t&&!e.prefix){let t=!1;return O(e)&&(e.prefix=``,E(e,(e,n)=>{ue(e,n)&&(t=!0)})),t}let n=e.prefix;return M({prefix:n,name:`a`})?!!se(A(t,n),e):!1}var I=Object.freeze({width:null,height:null}),L=Object.freeze({...I,...S}),fe=/(-?[0-9.]*[0-9]+[0-9.]*)/g,pe=/^-?[0-9.]*[0-9]+[0-9.]*$/g;function R(e,t,n){if(t===1)return e;if(n||=100,typeof e==`number`)return Math.ceil(e*t*n)/n;if(typeof e!=`string`)return e;let r=e.split(fe);if(r===null||!r.length)return e;let i=[],a=r.shift(),o=pe.test(a);for(;;){if(o){let e=parseFloat(a);isNaN(e)?i.push(a):i.push(Math.ceil(e*t*n)/n)}else i.push(a);if(a=r.shift(),a===void 0)return i.join(``);o=!o}}function me(e,t=`defs`){let n=``,r=e.indexOf(`<`+t);for(;r>=0;){let i=e.indexOf(`>`,r),a=e.indexOf(`</`+t);if(i===-1||a===-1)break;let o=e.indexOf(`>`,a);if(o===-1)break;n+=e.slice(i+1,a).trim(),e=e.slice(0,r).trim()+e.slice(o+1)}return{defs:n,content:e}}function he(e,t){return e?`<defs>`+e+`</defs>`+t:t}function ge(e,t,n){let r=me(e);return he(r.defs,t+r.content+n)}var _e=e=>e===`unset`||e===`undefined`||e===`none`;function ve(e,t){let n={...C,...e},r={...L,...t},i={left:n.left,top:n.top,width:n.width,height:n.height},a=n.body;[n,r].forEach(e=>{let t=[],n=e.hFlip,r=e.vFlip,o=e.rotate;n?r?o+=2:(t.push(`translate(`+(i.width+i.left).toString()+` `+(0-i.top).toString()+`)`),t.push(`scale(-1 1)`),i.top=i.left=0):r&&(t.push(`translate(`+(0-i.left).toString()+` `+(i.height+i.top).toString()+`)`),t.push(`scale(1 -1)`),i.top=i.left=0);let s;switch(o<0&&(o-=Math.floor(o/4)*4),o%=4,o){case 1:s=i.height/2+i.top,t.unshift(`rotate(90 `+s.toString()+` `+s.toString()+`)`);break;case 2:t.unshift(`rotate(180 `+(i.width/2+i.left).toString()+` `+(i.height/2+i.top).toString()+`)`);break;case 3:s=i.width/2+i.left,t.unshift(`rotate(-90 `+s.toString()+` `+s.toString()+`)`);break}o%2==1&&(i.left!==i.top&&(s=i.left,i.left=i.top,i.top=s),i.width!==i.height&&(s=i.width,i.width=i.height,i.height=s)),t.length&&(a=ge(a,`<g transform="`+t.join(` `)+`">`,`</g>`))});let o=r.width,s=r.height,c=i.width,l=i.height,u,d;o===null?(d=s===null?`1em`:s===`auto`?l:s,u=R(d,c/l)):(u=o===`auto`?c:o,d=s===null?R(u,l/c):s===`auto`?l:s);let f={},p=(e,t)=>{_e(t)||(f[e]=t.toString())};p(`width`,u),p(`height`,d);let m=[i.left,i.top,c,l];return f.viewBox=m.join(` `),{attributes:f,viewBox:m,body:a}}var ye=/\sid="(\S+)"/g,be=`IconifyId`+Date.now().toString(16)+(Math.random()*16777216|0).toString(16),xe=0;function Se(e,t=be){let n=[],r;for(;r=ye.exec(e);)n.push(r[1]);if(!n.length)return e;let i=`suffix`+(Math.random()*16777216|Date.now()).toString(16);return n.forEach(n=>{let r=typeof t==`function`?t(n):t+(xe++).toString(),a=n.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`);e=e.replace(RegExp(`([#;"])(`+a+`)([")]|\\.[a-z])`,`g`),`$1`+r+i+`$3`)}),e=e.replace(new RegExp(i,`g`),``),e}var z=Object.create(null);function Ce(e,t){z[e]=t}function B(e){return z[e]||z[``]}function V(e){let t;if(typeof e.resources==`string`)t=[e.resources];else if(t=e.resources,!(t instanceof Array)||!t.length)return null;return{resources:t,path:e.path||`/`,maxURL:e.maxURL||500,rotate:e.rotate||750,timeout:e.timeout||5e3,random:e.random===!0,index:e.index||0,dataAfterTimeout:e.dataAfterTimeout!==!1}}for(var H=Object.create(null),U=[`https://api.simplesvg.com`,`https://api.unisvg.com`],W=[];U.length>0;)U.length===1||Math.random()>.5?W.push(U.shift()):W.push(U.pop());H[``]=V({resources:[`https://api.iconify.design`].concat(W)});function we(e,t){let n=V(t);return n===null?!1:(H[e]=n,!0)}function G(e){return H[e]}var K=(()=>{let e;try{if(e=fetch,typeof e==`function`)return e}catch{}})();function Te(e,t){let n=G(e);if(!n)return 0;let r;if(!n.maxURL)r=0;else{let e=0;n.resources.forEach(t=>{e=Math.max(e,t.length)});let i=t+`.json?icons=`;r=n.maxURL-e-n.path.length-i.length}return r}function Ee(e){return e===404}var De=(e,t,n)=>{let r=[],i=Te(e,t),a=`icons`,o={type:a,provider:e,prefix:t,icons:[]},s=0;return n.forEach((n,c)=>{s+=n.length+1,s>=i&&c>0&&(r.push(o),o={type:a,provider:e,prefix:t,icons:[]},s=n.length),o.icons.push(n)}),r.push(o),r};function Oe(e){if(typeof e==`string`){let t=G(e);if(t)return t.path}return`/`}var ke={prepare:De,send:(e,t,n)=>{if(!K){n(`abort`,424);return}let r=Oe(t.provider);switch(t.type){case`icons`:{let e=t.prefix,n=t.icons.join(`,`),i=new URLSearchParams({icons:n});r+=e+`.json?`+i.toString();break}case`custom`:{let e=t.uri;r+=e.slice(0,1)===`/`?e.slice(1):e;break}default:n(`abort`,400);return}let i=503;K(e+r).then(e=>{let t=e.status;if(t!==200){setTimeout(()=>{n(Ee(t)?`abort`:`next`,t)});return}return i=501,e.json()}).then(e=>{if(typeof e!=`object`||!e){setTimeout(()=>{e===404?n(`abort`,e):n(`next`,i)});return}setTimeout(()=>{n(`success`,e)})}).catch(()=>{n(`next`,i)})}};function q(e,t){e.forEach(e=>{let n=e.loaderCallbacks;n&&(e.loaderCallbacks=n.filter(e=>e.id!==t))})}function Ae(e){e.pendingCallbacksFlag||(e.pendingCallbacksFlag=!0,setTimeout(()=>{e.pendingCallbacksFlag=!1;let t=e.loaderCallbacks?e.loaderCallbacks.slice(0):[];if(!t.length)return;let n=!1,r=e.provider,i=e.prefix;t.forEach(t=>{let a=t.icons,o=a.pending.length;a.pending=a.pending.filter(t=>{if(t.prefix!==i)return!0;let o=t.name;if(e.icons[o])a.loaded.push({provider:r,prefix:i,name:o});else if(e.missing.has(o))a.missing.push({provider:r,prefix:i,name:o});else return n=!0,!0;return!1}),a.pending.length!==o&&(n||q([e],t.id),t.callback(a.loaded.slice(0),a.missing.slice(0),a.pending.slice(0),t.abort))})}))}var je=0;function Me(e,t,n){let r=je++,i=q.bind(null,n,r);if(!t.pending.length)return i;let a={id:r,icons:t,callback:e,abort:i};return n.forEach(e=>{(e.loaderCallbacks||=[]).push(a)}),i}function Ne(e){let t={loaded:[],missing:[],pending:[]},n=Object.create(null);e.sort((e,t)=>e.provider===t.provider?e.prefix===t.prefix?e.name.localeCompare(t.name):e.prefix.localeCompare(t.prefix):e.provider.localeCompare(t.provider));let r={provider:``,prefix:``,name:``};return e.forEach(e=>{if(r.name===e.name&&r.prefix===e.prefix&&r.provider===e.provider)return;r=e;let i=e.provider,a=e.prefix,o=e.name,s=n[i]||(n[i]=Object.create(null)),c=s[a]||(s[a]=A(i,a)),l;l=o in c.icons?t.loaded:a===``||c.missing.has(o)?t.missing:t.pending;let u={provider:i,prefix:a,name:o};l.push(u)}),t}function Pe(e,t=!0,n=!1){let r=[];return e.forEach(e=>{let i=typeof e==`string`?j(e,t,n):e;i&&r.push(i)}),r}var Fe={resources:[],index:0,timeout:2e3,rotate:750,random:!1,dataAfterTimeout:!1};function Ie(e,t,n,r){let i=e.resources.length,a=e.random?Math.floor(Math.random()*i):e.index,o;if(e.random){let t=e.resources.slice(0);for(o=[];t.length>1;){let e=Math.floor(Math.random()*t.length);o.push(t[e]),t=t.slice(0,e).concat(t.slice(e+1))}o=o.concat(t)}else o=e.resources.slice(a).concat(e.resources.slice(0,a));let s=Date.now(),c=`pending`,l=0,u,d=null,f=[],p=[];typeof r==`function`&&p.push(r);function m(){d&&=(clearTimeout(d),null)}function h(){c===`pending`&&(c=`aborted`),m(),f.forEach(e=>{e.status===`pending`&&(e.status=`aborted`)}),f=[]}function ee(e,t){t&&(p=[]),typeof e==`function`&&p.push(e)}function g(){return{startTime:s,payload:t,status:c,queriesSent:l,queriesPending:f.length,subscribe:ee,abort:h}}function _(){c=`failed`,p.forEach(e=>{e(void 0,u)})}function v(){f.forEach(e=>{e.status===`pending`&&(e.status=`aborted`)}),f=[]}function te(t,n,r){let i=n!==`success`;switch(f=f.filter(e=>e!==t),c){case`pending`:break;case`failed`:if(i||!e.dataAfterTimeout)return;break;default:return}if(n===`abort`){u=r,_();return}if(i){u=r,f.length||(o.length?y():_());return}if(m(),v(),!e.random){let n=e.resources.indexOf(t.resource);n!==-1&&n!==e.index&&(e.index=n)}c=`completed`,p.forEach(e=>{e(r)})}function y(){if(c!==`pending`)return;m();let r=o.shift();if(r===void 0){if(f.length){d=setTimeout(()=>{m(),c===`pending`&&(v(),_())},e.timeout);return}_();return}let i={status:`pending`,resource:r,callback:(e,t)=>{te(i,e,t)}};f.push(i),l++,d=setTimeout(y,e.rotate),n(r,t,i.callback)}return setTimeout(y),g}function Le(e){let t={...Fe,...e},n=[];function r(){n=n.filter(e=>e().status===`pending`)}function i(e,i,a){let o=Ie(t,e,i,(e,t)=>{r(),a&&a(e,t)});return n.push(o),o}function a(e){return n.find(t=>e(t))||null}return{query:i,find:a,setIndex:e=>{t.index=e},getIndex:()=>t.index,cleanup:r}}function Re(){}var J=Object.create(null);function ze(e){if(!J[e]){let t=G(e);if(!t)return;J[e]={config:t,redundancy:Le(t)}}return J[e]}function Be(e,t,n){let r,i;if(typeof e==`string`){let t=B(e);if(!t)return n(void 0,424),Re;i=t.send;let a=ze(e);a&&(r=a.redundancy)}else{let t=V(e);if(t){r=Le(t);let n=B(e.resources?e.resources[0]:``);n&&(i=n.send)}}return!r||!i?(n(void 0,424),Re):r.query(t,i,n)().abort}function Ve(){}function He(e){e.iconsLoaderFlag||(e.iconsLoaderFlag=!0,setTimeout(()=>{e.iconsLoaderFlag=!1,Ae(e)}))}function Ue(e){let t=[],n=[];return e.forEach(e=>{(e.match(le)?t:n).push(e)}),{valid:t,invalid:n}}function Y(e,t,n){function r(){let n=e.pendingIcons;t.forEach(t=>{n&&n.delete(t),e.icons[t]||e.missing.add(t)})}if(n&&typeof n==`object`)try{if(!se(e,n).length){r();return}}catch(e){console.error(e)}r(),He(e)}function We(e,t){e instanceof Promise?e.then(e=>{t(e)}).catch(()=>{t(null)}):t(e)}function Ge(e,t){e.iconsToLoad?e.iconsToLoad=e.iconsToLoad.concat(t).sort():e.iconsToLoad=t,e.iconsQueueFlag||(e.iconsQueueFlag=!0,setTimeout(()=>{e.iconsQueueFlag=!1;let{provider:t,prefix:n}=e,r=e.iconsToLoad;if(delete e.iconsToLoad,!r||!r.length)return;let i=e.loadIcon;if(e.loadIcons&&(r.length>1||!i)){We(e.loadIcons(r,n,t),t=>{Y(e,r,t)});return}if(i){r.forEach(r=>{We(i(r,n,t),t=>{Y(e,[r],t?{prefix:n,icons:{[r]:t}}:null)})});return}let{valid:a,invalid:o}=Ue(r);if(o.length&&Y(e,o,null),!a.length)return;let s=n.match(le)?B(t):null;if(!s){Y(e,a,null);return}s.prepare(t,n,a).forEach(n=>{Be(t,n,t=>{Y(e,n.icons,t)})})}))}var Ke=(e,t)=>{let n=Ne(Pe(e,!0,P()));if(!n.pending.length){let e=!0;return t&&setTimeout(()=>{e&&t(n.loaded,n.missing,n.pending,Ve)}),()=>{e=!1}}let r=Object.create(null),i=[],a,o;return n.pending.forEach(e=>{let{provider:t,prefix:n}=e;if(n===o&&t===a)return;a=t,o=n,i.push(A(t,n));let s=r[t]||(r[t]=Object.create(null));s[n]||(s[n]=[])}),n.pending.forEach(e=>{let{provider:t,prefix:n,name:i}=e,a=A(t,n),o=a.pendingIcons||=new Set;o.has(i)||(o.add(i),r[t][n].push(i))}),i.forEach(e=>{let t=r[e.provider][e.prefix];t.length&&Ge(e,t)}),t?Me(t,n,i):Ve};function qe(e,t){let n={...e};for(let e in t){let r=t[e],i=typeof r;e in I?(r===null||r&&(i===`string`||i===`number`))&&(n[e]=r):i===typeof n[e]&&(n[e]=e===`rotate`?r%4:r)}return n}var Je=/[\s,]+/;function Ye(e,t){t.split(Je).forEach(t=>{switch(t.trim()){case`horizontal`:e.hFlip=!0;break;case`vertical`:e.vFlip=!0;break}})}function Xe(e,t=0){let n=e.replace(/^-?[0-9.]*/,``);function r(e){for(;e<0;)e+=4;return e%4}if(n===``){let t=parseInt(e);return isNaN(t)?0:r(t)}else if(n!==e){let t=0;switch(n){case`%`:t=25;break;case`deg`:t=90}if(t){let i=parseFloat(e.slice(0,e.length-n.length));return isNaN(i)?0:(i/=t,i%1==0?r(i):0)}}return t}function Ze(e,t){let n=e.indexOf(`xlink:`)===-1?``:` xmlns:xlink="http://www.w3.org/1999/xlink"`;for(let e in t)n+=` `+e+`="`+t[e]+`"`;return`<svg xmlns="http://www.w3.org/2000/svg"`+n+`>`+e+`</svg>`}function Qe(e){return e.replace(/"/g,`'`).replace(/%/g,`%25`).replace(/#/g,`%23`).replace(/</g,`%3C`).replace(/>/g,`%3E`).replace(/\s+/g,` `)}function $e(e){return`data:image/svg+xml,`+Qe(e)}function et(e){return`url("`+$e(e)+`")`}var X;function tt(){try{X=window.trustedTypes.createPolicy(`iconify`,{createHTML:e=>e})}catch{X=null}}function nt(e){return X===void 0&&tt(),X?X.createHTML(e):e}var rt={...L,inline:!1},it={xmlns:`http://www.w3.org/2000/svg`,xmlnsXlink:`http://www.w3.org/1999/xlink`,"aria-hidden":!0,role:`img`},at={display:`inline-block`},Z={backgroundColor:`currentColor`},ot={backgroundColor:`transparent`},st={Image:`var(--svg)`,Repeat:`no-repeat`,Size:`100% 100%`},ct={WebkitMask:Z,mask:Z,background:ot};for(let e in ct){let t=ct[e];for(let n in st)t[e+n]=st[n]}var lt={...rt,inline:!0};function ut(e){return e+(e.match(/^[-0-9.]+$/)?`px`:``)}var dt=(e,t,n)=>{let r=t.inline?lt:rt,i=qe(r,t),a=t.mode||`svg`,o={},s=t.style||{},c={...a===`svg`?it:{}};if(n){let e=j(n,!1,!0);if(e){let t=[`iconify`];for(let n of[`provider`,`prefix`])e[n]&&t.push(`iconify--`+e[n]);c.className=t.join(` `)}}for(let e in t){let n=t[e];if(n!==void 0)switch(e){case`icon`:case`style`:case`children`:case`onLoad`:case`mode`:case`ssr`:case`fallback`:break;case`_ref`:c.ref=n;break;case`className`:c[e]=(c[e]?c[e]+` `:``)+n;break;case`inline`:case`hFlip`:case`vFlip`:i[e]=n===!0||n===`true`||n===1;break;case`flip`:typeof n==`string`&&Ye(i,n);break;case`color`:o.color=n;break;case`rotate`:typeof n==`string`?i[e]=Xe(n):typeof n==`number`&&(i[e]=n);break;case`ariaHidden`:case`aria-hidden`:n!==!0&&n!==`true`&&delete c[`aria-hidden`];break;default:r[e]===void 0&&(c[e]=n)}}let l=ve(e,i),u=l.attributes;if(i.inline&&(o.verticalAlign=`-0.125em`),a===`svg`){c.style={...o,...s},Object.assign(c,u);let e=0,n=t.id;return typeof n==`string`&&(n=n.replace(/-/g,`_`)),c.dangerouslySetInnerHTML={__html:nt(Se(l.body,n?()=>n+`ID`+ e++:`iconifyReact`))},(0,b.createElement)(`svg`,c)}let{body:d,width:f,height:p}=e,m=a===`mask`||(a===`bg`?!1:d.indexOf(`currentColor`)!==-1),h=Ze(d,{...u,width:f+``,height:p+``});return c.style={...o,"--svg":et(h),width:ut(u.width),height:ut(u.height),...at,...m?Z:ot,...s},(0,b.createElement)(`span`,c)};if(P(!0),Ce(``,ke),typeof document<`u`&&typeof window<`u`){let e=window;if(e.IconifyPreload!==void 0){let t=e.IconifyPreload,n=`Invalid IconifyPreload syntax.`;typeof t==`object`&&t&&(t instanceof Array?t:[t]).forEach(e=>{try{(typeof e!=`object`||!e||e instanceof Array||typeof e.icons!=`object`||typeof e.prefix!=`string`||!de(e))&&console.error(n)}catch{console.error(n)}})}if(e.IconifyProviders!==void 0){let t=e.IconifyProviders;if(typeof t==`object`&&t)for(let e in t){let n=`IconifyProviders[`+e+`] is invalid.`;try{let r=t[e];if(typeof r!=`object`||!r||r.resources===void 0)continue;we(e,r)||console.error(n)}catch{console.error(n)}}}}function ft(e){let[t,n]=(0,b.useState)(!!e.ssr),[r,i]=(0,b.useState)({});function a(t){if(t){let t=e.icon;if(typeof t==`object`)return{name:``,data:t};let n=F(t);if(n)return{name:t,data:n}}return{name:``}}let[o,s]=(0,b.useState)(a(!!e.ssr));function c(){let e=r.callback;e&&(e(),i({}))}function l(e){if(JSON.stringify(o)!==JSON.stringify(e))return c(),s(e),!0}function u(){var t;let n=e.icon;if(typeof n==`object`){l({name:``,data:n});return}let r=F(n);l({name:n,data:r})&&(r===void 0?i({callback:Ke([n],u)}):r&&((t=e.onLoad)==null||t.call(e,n)))}(0,b.useEffect)(()=>(n(!0),c),[]),(0,b.useEffect)(()=>{t&&u()},[e.icon,t]);let{name:d,data:f}=o;return f?dt({...C,...f},e,d):e.children?e.children:e.fallback?e.fallback:(0,b.createElement)(`span`,{})}var pt=(0,b.forwardRef)((e,t)=>ft({...e,_ref:t}));(0,b.forwardRef)((e,t)=>ft({inline:!0,...e,_ref:t}));var Q=n(),$=[{name:`Google`,host:`google.com`,icon:`simple-icons:google`,fallback:(0,Q.jsx)(s,{size:20})},{name:`Cloudflare`,host:`cloudflare.com`,icon:`simple-icons:cloudflare`,fallback:(0,Q.jsx)(r,{size:20})},{name:`YouTube`,host:`youtube.com`,icon:`simple-icons:youtube`,fallback:(0,Q.jsx)(o,{size:20})},{name:`GitHub`,host:`github.com`,icon:`simple-icons:github`,fallback:(0,Q.jsx)(te,{size:20})},{name:`ChatGPT`,host:`chatgpt.com`,icon:`simple-icons:openai`,fallback:(0,Q.jsx)(m,{size:20})},{name:`X`,host:`x.com`,icon:`simple-icons:x`,fallback:(0,Q.jsx)(f,{size:20})},{name:`Instagram`,host:`instagram.com`,icon:`simple-icons:instagram`,fallback:(0,Q.jsx)(h,{size:20})},{name:`Reddit`,host:`reddit.com`,icon:`simple-icons:reddit`,fallback:(0,Q.jsx)(i,{size:20})},{name:`Wikipedia`,host:`wikipedia.org`,icon:`simple-icons:wikipedia`,fallback:(0,Q.jsx)(p,{size:20})},{name:`Apple`,host:`apple.com`,icon:`simple-icons:apple`,fallback:(0,Q.jsx)(v,{size:20})},{name:`Telegram`,host:`telegram.org`,icon:`simple-icons:telegram`,fallback:(0,Q.jsx)(c,{size:20})},{name:`Discord`,host:`discord.com`,icon:`simple-icons:discord`,fallback:(0,Q.jsx)(ee,{size:20})},{name:`TikTok`,host:`tiktok.com`,icon:`simple-icons:tiktok`,fallback:(0,Q.jsx)(a,{size:20})},{name:`npm`,host:`npmjs.com`,icon:`simple-icons:npm`,fallback:(0,Q.jsx)(g,{size:20})},{name:`Vercel`,host:`vercel.com`,icon:`simple-icons:vercel`,fallback:(0,Q.jsx)(y,{size:20})}],mt=5e3;function ht({icon:e,fallback:t}){let[n,r]=(0,b.useState)(!1);return(0,b.useEffect)(()=>{let t=new Image;t.onload=()=>r(!0),t.onerror=()=>r(!1),t.src=`https://api.iconify.design/${e.replace(`:`,`/`)}.svg`},[e]),(0,Q.jsxs)(`span`,{className:`brand-icon-wrap`,children:[(0,Q.jsx)(`span`,{className:`brand-icon-fallback ${n?`hidden`:``}`,children:t}),(0,Q.jsx)(`span`,{className:`brand-icon-real ${n?`visible`:``}`,children:(0,Q.jsx)(pt,{icon:e,width:20,height:20})})]})}function gt(){let[e,t]=(0,b.useState)(new Map),[n,r]=(0,b.useState)(!1),i=(0,b.useRef)(new Map),a=(0,b.useCallback)(e=>{t(t=>{let n=new Map(t);return n.set(e,{status:`pending`,latency:0}),n});let n=new AbortController;i.current.set(e,n);let r=performance.now(),a=(n,r)=>{t(t=>{let i=new Map(t);return i.set(e,{status:n,latency:r}),i})},o=setTimeout(()=>{n.abort()},mt);fetch(`https://${e}/`,{method:`HEAD`,mode:`no-cors`,cache:`no-store`,signal:n.signal}).then(()=>{clearTimeout(o),a(`ok`,Math.round(performance.now()-r))}).catch(()=>{clearTimeout(o),a(`timeout`,0)})},[]),o=(0,b.useCallback)(()=>{r(!0);let e=new Map;$.forEach(t=>{e.set(t.host,{status:`pending`,latency:0})}),t(e);let n=new Set($.map(e=>e.host));$.forEach(e=>{let a=new AbortController;i.current.set(e.host,a);let o=performance.now(),s=(i,a)=>{n.has(e.host)&&(n.delete(e.host),t(t=>{let n=new Map(t);return n.set(e.host,{status:i,latency:a}),n}),n.size===0&&r(!1))},c=setTimeout(()=>{a.abort()},mt);fetch(`https://${e.host}/`,{method:`HEAD`,mode:`no-cors`,cache:`no-store`,signal:a.signal}).then(()=>{clearTimeout(c),s(`ok`,Math.round(performance.now()-o))}).catch(()=>{clearTimeout(c),s(`timeout`,0)})})},[]);return(0,b.useEffect)(()=>(o(),()=>{i.current.forEach(e=>e.abort()),i.current.clear()}),[o]),(0,Q.jsxs)(`div`,{className:`ping-page`,children:[(0,Q.jsxs)(`div`,{className:`ping-header`,children:[(0,Q.jsxs)(`div`,{className:`ping-title-wrap`,children:[(0,Q.jsx)(l,{size:28,className:`ping-title-icon`}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h1`,{className:`ping-title`,children:`网络连通性`}),(0,Q.jsx)(`p`,{className:`ping-subtitle`,children:`通过向对应网站发送请求进行测试,延迟值仅供参考。`})]})]}),(0,Q.jsx)(`button`,{className:`btn btn-icon`,onClick:o,disabled:n,"aria-label":`重新测试全部`,title:`重新测试全部`,children:(0,Q.jsx)(_,{size:18,className:n?`ping-spin`:``})})]}),(0,Q.jsx)(`div`,{className:`ping-grid`,children:$.map(t=>{let n=e.get(t.host),r=!n||n.status===`pending`,i=n?.status===`timeout`;return(0,Q.jsxs)(`div`,{className:`ping-card ${r?`pending`:``}`,children:[(0,Q.jsxs)(`div`,{className:`ping-card-top`,children:[(0,Q.jsx)(`span`,{className:`ping-card-icon`,children:(0,Q.jsx)(ht,{icon:t.icon,fallback:t.fallback})}),(0,Q.jsx)(`a`,{href:`https://${t.host}`,target:`_blank`,rel:`noreferrer`,className:`ping-card-name`,children:t.name}),(0,Q.jsx)(`button`,{className:`ping-card-refresh`,onClick:()=>a(t.host),disabled:r,"aria-label":`重新测试 ${t.name}`,title:`重新测试`,children:(0,Q.jsx)(_,{size:13,className:r?`ping-spin`:``})})]}),(0,Q.jsxs)(`div`,{className:`ping-card-bottom`,children:[r?(0,Q.jsx)(`span`,{className:`ping-pulse-dot`}):(0,Q.jsx)(`span`,{className:`ping-status-label ${i?`is-error`:`is-success`}`,children:i?`不可用`:`可用`}),(0,Q.jsx)(`span`,{className:`ping-latency ${r?`is-muted`:i?`is-error`:`is-success`}`,children:r?`--`:i?`超时`:`${n.latency} ms`})]})]},t.host)})})]})}function _t(){return(0,Q.jsx)(d,{children:(0,Q.jsx)(gt,{})})}var vt=_t;export{vt as component};
@@ -1 +0,0 @@
1
- import{W as e}from"./index-Cf23WD2V.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{W as e}from"./index-Cf23WD2V.js";var t=e(`plus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]);export{t};
@@ -1 +0,0 @@
1
- import{n as e,o as t,t as n}from"./jsx-runtime-Bt-cYkS5.js";import{t as r}from"./arrow-right-D0sGC8QA.js";import{t as i}from"./check-DdfnsLKm.js";import{t as a}from"./download-0rM8xVCe.js";import{n as o,t as s}from"./wallet-YxbxCi7C.js";import{t as c}from"./hard-drive-CCdIvSap.js";import{n as l}from"./LogoIcon-CYQ7cHd5.js";import{t as u}from"./notebook-pen-B4VSbweh.js";import{B as d,K as f,W as p,f as m}from"./index-Cf23WD2V.js";import{t as h}from"./MarketingLayout-BTIbv4fW.js";var g=p(`arrow-up-right`,[[`path`,{d:`M7 7h10v10`,key:`1tivn9`}],[`path`,{d:`M7 17 17 7`,key:`1vkiza`}]]),_=p(`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`}]]),v=p(`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`}]]),y=t(e(),1),b=n(),x=[{id:`app`,title:`MostBox`,subtitle:`P2P 文件分享`,icon:(0,b.jsx)(_,{size:28}),path:`/app/`,requiresBackend:!0,hero:`P2P 文件分享,无需注册`,desc:`基于 Hyperswarm 的去中心化文件传输,让文件分享回归点对点。MostBox 不是云盘;链接来自 CID,可用性来自当前在线种子。当前 MVP 优先使用桌面客户端。`,features:[`无需云端账号,使用本地身份隔离数据`,`Hyperswarm P2P 直连传输`,`GB 级大文件流式处理`,`相同文件 = 相同 CID,链接可反复校验`,`下载完成后默认继续做种`,`相比微信、QQ 或网盘,不依赖中心化账号和云端托管`,`Web 端只连接已有节点,桌面端提供完整 P2P 能力`,`MIT 开源,自托管,数据完全自主掌控`],steps:[{num:`1`,title:`下载客户端`,desc:`支持 Windows、macOS 和 Linux,桌面端提供完整的 P2P 能力。`,link:`/download/`,linkText:`前往下载页`},{num:`2`,title:`安装并运行`,desc:`安装后打开应用,无需单独安装 Node.js。`},{num:`3`,title:`开始分享`,desc:`发布文件生成 most:// 链接,朋友下载校验通过后也会成为新的种子。`}]},{id:`chat`,title:`P2P 聊天`,subtitle:`频道加密通讯`,icon:(0,b.jsx)(l,{size:28}),path:`/chat/`,requiresBackend:!0,hero:`去中心化频道聊天`,desc:`基于 Hypercore 的 P2P 加密即时通讯。创建频道,邀请朋友,端到端加密,无需服务器中转。`,features:[`P2P 加密频道消息`,`本地登录身份保护消息署名`,`消息通过 Hyperswarm 网络同步`,`离线消息自动同步`,`无需中心化账号注册`],steps:[{num:`1`,title:`下载客户端`,desc:`支持 Windows、macOS 和 Linux。`,link:`/download/`,linkText:`前往下载页`},{num:`2`,title:`创建频道`,desc:`输入任意频道名即可加入或创建。`},{num:`3`,title:`开始聊天`,desc:`发送消息,P2P 网络自动同步给所有在线节点。`}]},{id:`note`,title:`笔记`,subtitle:`加密云备份`,icon:(0,b.jsx)(u,{size:28}),path:`/note/`,requiresBackend:!1,hero:`Web3 加密笔记`,desc:`使用本地 Web3 密钥加密 Markdown 笔记,可在浏览器本地保存并按需同步到云端备份。`,features:[`Markdown 块编辑器`,`公开 / 私密笔记切换`,`文件夹、搜索和移动`,`Web3 登录态加密`,`云端备份与恢复`,`独立于 P2P 文件分享`],steps:[{num:`1`,title:`生成 Web3 账号`,desc:`用用户名和密码派生本地密钥。`},{num:`2`,title:`创建笔记`,desc:`写 Markdown,按需切换为私密内容。`},{num:`3`,title:`备份恢复`,desc:`登录后可把加密笔记同步到云端。`}]},{id:`gandengyan`,title:`游戏`,subtitle:`P2P 牌桌`,icon:(0,b.jsx)(v,{size:28}),path:`/game/gandengyan/`,requiresBackend:!0,hero:`常驻节点里的在线牌桌`,desc:`把干瞪眼作为 MostBox 的独立页面接入,复用现有频道消息、Web3 登录身份和桌面端常驻入口。`,features:[`使用 MostBox 本地账号进入房间`,`复用 /chat/ 的频道后端,不新增游戏后端接口`,`房间链接可直接分享到群组`,`支持 1-2 副牌、2-6 人和人机陪测`,`游戏规则、频道事件和页面样式拆分维护`],steps:[{num:`1`,title:`登录账号`,desc:`使用现有 MostBox Web3 本地账号作为牌桌身份。`},{num:`2`,title:`创建房间`,desc:`创建房间后复制链接,发给朋友加入。`},{num:`3`,title:`开始调试`,desc:`可先用人机补位测试出牌、计分和房间同步。`}]},{id:`web3`,title:`Web3`,subtitle:`账户工具箱`,icon:(0,b.jsx)(s,{size:28}),path:`/web3/`,requiresBackend:!1,hero:`确定性密钥派生工具箱`,desc:`纯前端运行的 Web3 账户工具。输入用户名和密码,即可生成 Ed25519 / x25519 密钥对、助记词、以太坊地址,支持 PEM 导出和地址派生。`,features:[`纯前端运行,无需后端`,`Ed25519 / x25519 密钥对生成`,`BIP-39 助记词派生`,`以太坊地址与私钥导出`,`PEM 格式密钥导出`,`二维码展示地址与助记词`],steps:[{num:`1`,title:`输入用户名`,desc:`用户名 + 密码(可选)作为种子。`},{num:`2`,title:`查看密钥`,desc:`即时生成 Ed25519、x25519 公钥与 IPNS ID。`},{num:`3`,title:`导出使用`,desc:`复制地址、导出 PEM、派生子地址。`}]}];function S(){let e=m(e=>e.hasBackend),t=m(e=>e.openConnectModal),[n,s]=(0,y.useState)(`app`),l=x.find(e=>e.id===n)||x[0];return(0,b.jsxs)(`div`,{className:`portal-page`,children:[(0,b.jsx)(`section`,{className:`portal-hero`,children:(0,b.jsxs)(`div`,{className:`mkt-container`,children:[(0,b.jsx)(`h1`,{className:`portal-hero-title`,children:`MOST PEOPLE`}),(0,b.jsx)(`p`,{className:`portal-hero-subtitle`,children:`去中心化 P2P 工具箱`})]})}),(0,b.jsx)(`section`,{className:`portal-cards-section`,children:(0,b.jsxs)(`div`,{className:`mkt-container`,children:[(0,b.jsx)(`div`,{className:`portal-cards`,children:x.map(t=>{let r=n===t.id,i=t.requiresBackend,a=i?e===!0?`connected`:e===!1?`disconnected`:`checking`:`none`;return(0,b.jsxs)(`button`,{className:`portal-card ${r?`active`:``}`,onClick:()=>s(t.id),children:[(0,b.jsx)(f,{to:t.path,className:`btn btn-icon portal-card-open-btn`,onClick:e=>e.stopPropagation(),title:`打开${t.title}`,children:(0,b.jsx)(g,{size:16})}),(0,b.jsx)(`div`,{className:`portal-card-icon`,children:t.icon}),(0,b.jsx)(`div`,{className:`portal-card-title`,children:t.title}),(0,b.jsx)(`div`,{className:`portal-card-subtitle`,children:t.subtitle}),i?(0,b.jsxs)(`div`,{className:`ui-badge portal-card-status ${a}`,children:[a===`checking`&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(`span`,{className:`status-dot checking`}),`检测中`]}),a===`connected`&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(`span`,{className:`status-dot connected`}),`已连接`]}),a===`disconnected`&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(`span`,{className:`status-dot disconnected`}),`需连接`]})]}):(0,b.jsxs)(`div`,{className:`ui-badge portal-card-status ready`,children:[(0,b.jsx)(`span`,{className:`status-dot ready`}),`已就绪`]})]},t.id)})}),(0,b.jsxs)(`div`,{className:`portal-node-actions`,"aria-label":`节点入口`,children:[(0,b.jsxs)(`button`,{onClick:t,className:`btn btn-secondary`,children:[(0,b.jsx)(d,{size:16}),`Web 连接节点`]}),(0,b.jsxs)(f,{to:`/admin/`,className:`btn btn-secondary`,children:[(0,b.jsx)(c,{size:16}),`节点管理`]})]})]})}),(0,b.jsx)(`section`,{className:`portal-marketing`,children:(0,b.jsx)(`div`,{className:`mkt-container`,children:(0,b.jsx)(`div`,{className:`portal-marketing-inner`,children:(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(`div`,{className:`portal-marketing-header`,children:[(0,b.jsx)(`h2`,{children:l.hero}),(0,b.jsx)(`p`,{children:l.desc})]}),(0,b.jsx)(`div`,{className:`portal-marketing-features`,children:l.features.map((e,t)=>(0,b.jsxs)(`div`,{className:`portal-feature-item`,children:[(0,b.jsx)(`span`,{className:`portal-feature-icon`,children:(0,b.jsx)(i,{size:14,strokeWidth:3})}),(0,b.jsx)(`span`,{children:e})]},t))}),(0,b.jsx)(`div`,{className:`portal-marketing-steps`,children:l.steps.map(e=>(0,b.jsxs)(`div`,{className:`portal-step`,children:[(0,b.jsx)(`span`,{className:`portal-step-num`,children:e.num}),(0,b.jsxs)(`div`,{className:`portal-step-content`,children:[(0,b.jsx)(`strong`,{children:e.title}),(0,b.jsx)(`p`,{children:e.desc}),e.code&&(0,b.jsx)(`code`,{className:`portal-step-code`,children:e.code}),e.link&&(0,b.jsx)(`p`,{className:`portal-step-link`,children:(0,b.jsxs)(f,{to:e.link,children:[e.linkText,` `,(0,b.jsx)(o,{size:12})]})})]})]},e.num))}),(0,b.jsxs)(`div`,{className:`portal-actions`,children:[(0,b.jsxs)(f,{to:l.path,className:`btn btn-primary`,children:[`进入 `,l.title,(0,b.jsx)(r,{size:16})]}),l.requiresBackend&&e===!1&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(`button`,{onClick:t,className:`btn btn-secondary`,children:[(0,b.jsx)(d,{size:16}),`Web 连接节点`]}),(0,b.jsxs)(f,{to:`/download/`,className:`btn btn-secondary`,children:[(0,b.jsx)(a,{size:16}),`下载客户端`]})]})]})]})})})})]})}function C(){return(0,b.jsx)(h,{children:(0,b.jsx)(S,{})})}var w=C;export{w as component};
@@ -1 +0,0 @@
1
- import{W as e}from"./index-Cf23WD2V.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{W as e}from"./index-Cf23WD2V.js";var t=e(`moon`,[[`path`,{d:`M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401`,key:`kfwtm`}]]),n=e(`sun`,[[`circle`,{cx:`12`,cy:`12`,r:`4`,key:`4exip2`}],[`path`,{d:`M12 2v2`,key:`tus03m`}],[`path`,{d:`M12 20v2`,key:`1lh1kg`}],[`path`,{d:`m4.93 4.93 1.41 1.41`,key:`149t6j`}],[`path`,{d:`m17.66 17.66 1.41 1.41`,key:`ptbguv`}],[`path`,{d:`M2 12h2`,key:`1t8f8n`}],[`path`,{d:`M20 12h2`,key:`1q8mjw`}],[`path`,{d:`m6.34 17.66-1.41 1.41`,key:`1m8zz5`}],[`path`,{d:`m19.07 4.93-1.41 1.41`,key:`1shlcs`}]]);export{t as n,n as t};
@@ -1 +0,0 @@
1
- import{t as e}from"./jsx-runtime-Bt-cYkS5.js";import{q as t}from"./index-Cf23WD2V.js";var n=e(),r=()=>(0,n.jsx)(t,{to:`/web3/`,replace:!0});export{r as component};
@@ -1 +0,0 @@
1
- import{W as e}from"./index-Cf23WD2V.js";var t=e(`triangle-alert`,[[`path`,{d:`m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3`,key:`wmoenq`}],[`path`,{d:`M12 9v4`,key:`juzpu7`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]);export{t};
@@ -1 +0,0 @@
1
- import{W as e}from"./index-Cf23WD2V.js";var t=e(`upload`,[[`path`,{d:`M12 3v12`,key:`1x0j5s`}],[`path`,{d:`m17 8-5-5-5 5`,key:`7q97r8`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}]]);export{t};
@@ -1 +0,0 @@
1
- import{n as e,o as t,t as n}from"./jsx-runtime-Bt-cYkS5.js";import{t as r}from"./SidebarAccount-CCHZLGdP.js";import{K as i,U as a,W as o,f as s,g as c,u as l}from"./index-Cf23WD2V.js";import{t as u}from"./channelApi-CL7YsIQ-.js";import{t as d}from"./useChannelMessages-Bs1hEJyd.js";var f=o(`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`}]]),p=o(`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`}]]),m=n(),h=[{id:`gandengyan`,label:`干瞪眼`,href:`/game/gandengyan/`,icon:(0,m.jsx)(p,{size:16})},{id:`zhajinhua`,label:`炸金花`,href:`/game/zhajinhua/`,icon:(0,m.jsx)(f,{size:16})}];function g({activeGame:e,closeSidebar:t}){return(0,m.jsxs)(m.Fragment,{children:[(0,m.jsxs)(i,{to:`/`,className:`sidebar-header sidebar-header-link`,children:[(0,m.jsx)(a,{size:18}),(0,m.jsx)(`h1`,{children:`MOST PEOPLE`})]}),(0,m.jsx)(`nav`,{className:`sidebar-nav`,children:h.map(n=>(0,m.jsxs)(i,{to:n.href,className:`sidebar-nav-btn ${e===n.id?`active`:``}`,onClick:t,children:[n.icon,(0,m.jsx)(`span`,{children:n.label})]},n.id))}),(0,m.jsx)(r,{})]})}var _=t(e(),1),v=`game`,y=`mostbox.game.event`,b=[`gandengyan`,`zhajinhua`],x=`ABCDEFGHJKLMNPQRSTUVWXYZ23456789`;function S(e){let t=String(e||``).trim().toLowerCase();return b.includes(t)?t:``}function C(e){return String(e||``).trim().toUpperCase().replace(/[^A-Z0-9]/g,``).slice(0,8)}function w(e){return/^[A-Z0-9]{4,8}$/.test(String(e||``))}function T(){let e=``;for(let t=0;t<6;t++)e+=x[I(32)];return e}function E(e,t){let n=S(e),r=C(t);return!n||!w(r)?``:`game-${n}-${r.toLowerCase()}`}function D({gameId:e,roomCode:t,event:n,payload:r}){let i=S(e);return{kind:y,version:1,gameId:i,roomCode:C(t),event:String(n||``),eventId:F(i||`game`),payload:r||{}}}function O(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=S(n.gameId),i=C(n.roomCode);return!r||!w(i)||t.gameId&&r!==S(t.gameId)||t.roomCode&&i!==C(t.roomCode)?null:{...n,gameId:r,roomCode:i,payload:n.payload&&typeof n.payload==`object`?n.payload:{}}}catch{return null}}function k(e=[],t={}){let n=[],r=new Map,i=``;for(let a of P(e)){let e=O(a.content,t);if(e){if(e.event===`room:create`){let t=j(e.payload?.player,a.author);if(!t)continue;i||=t.address,N(n,r,t);continue}if(e.event===`player:join`){let t=j(e.payload?.player,a.author);t&&N(n,r,t);continue}if(e.event===`player:leave`){let t=M(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:S(t.gameId),roomCode:C(t.roomCode),hostAddress:i,players:n}}function A(e=[],t={}){let n=null;for(let r of P(e)){let e=O(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 j(e,t){if(!e||typeof e!=`object`)return null;let n=M(e.address||t);return!n||M(t)!==n?null:{address:n,name:String(e.name||``).trim().slice(0,50)||R(n),publicKey:String(e.publicKey||``).trim(),joinedAt:Number(e.joinedAt||Date.now())}}function M(e){let t=String(e||``).trim();return/^0x[a-fA-F0-9]{40}$/.test(t)?t.toLowerCase():``}function N(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 P(e){return[...e].sort((e,t)=>Number(e.timestamp||0)-Number(t.timestamp||0))}function F(e){return`${e}_${Date.now()}_${L(4)}`}function I(e){if(globalThis.crypto?.getRandomValues){let t=new Uint32Array(1);return globalThis.crypto.getRandomValues(t),t[0]%e}return Math.floor(Math.random()*e)}function L(e){let t=new Uint8Array(e);if(globalThis.crypto?.getRandomValues)globalThis.crypto.getRandomValues(t);else for(let e=0;e<t.length;e++)t[e]=Math.floor(Math.random()*256);return[...t].map(e=>e.toString(16).padStart(2,`0`)).join(``)}function R(e){return e?`${e.slice(0,6)}...${e.slice(-4)}`:``}function z({gameId:e,onError:t,getPlayerPayload:n}){let r=s(e=>e.hasBackend),i=s(e=>e.checkBackend),a=s(e=>e.openConnectModal),o=l(e=>e.identity),f=l(e=>e.openLoginModal),[p,m]=(0,_.useState)(``),[h,g]=(0,_.useState)(``),[y,b]=(0,_.useState)(!1),x=r===!0,S=(0,_.useCallback)(async(e,n)=>{let r=await c(e,n);t&&t(r)},[t]),w=(0,_.useCallback)(t=>!!O(t.content,{gameId:e,roomCode:p}),[e,p]),k=(0,_.useCallback)(t=>{let n=O(t.content,{gameId:e,roomCode:p});return n?`${t.author}-${n.eventId}`:`${t.author}-${t.timestamp}-${t.content}`},[e,p]),{clearMessages:A,connected:j,messages:M,sendMessage:N,syncMessages:P}=d({isReady:x,enabled:!!o,channelName:h,limit:500,acceptMessage:w,getMessageKey:k,onSyncError:e=>S(e,`无法读取房间记录`)}),F=(0,_.useMemo)(()=>M.map(t=>({message:t,event:O(t.content,{gameId:e,roomCode:p})})).filter(e=>e.event),[e,M,p]),I=(0,_.useCallback)(()=>o?x?!0:(a(),!1):(f(),!1),[x,a,f,o]);(0,_.useEffect)(()=>{r===null&&i()},[i,r]);let L=(0,_.useCallback)(async(r,i=!1)=>{if(!I()||!o)return!1;let a=i?T():C(r),s=E(e,a);if(!s)return t&&t(`请输入 4-8 位房间码`),!1;b(!0);try{return await u.createChannel(s,v),await B(s,o,e,a,i?`room:create`:`player:join`,{player:n?n(o):V(o)}),m(a),g(s),A(),!0}catch(e){return await S(e,i?`创建房间失败`:`进入房间失败`),!1}finally{b(!1)}},[I,e,n,t,S,A,o]);return{channelName:h,connected:j,createRoom:(0,_.useCallback)(()=>L(``,!0),[L]),ensureReady:I,isBackendReady:x,joinRoom:(0,_.useCallback)(e=>L(e),[L]),joining:y,messages:M,roomCode:p,roomEvents:F,sendRoomEvent:(0,_.useCallback)(async(t,n={})=>{if(!I()||!o||!h||!p)return!1;let r=D({gameId:e,roomCode:p,event:t,payload:n}),i=JSON.stringify(r);try{return await N({channelName:h,content:i,author:o.address,authorName:H(o),optimisticId:`${o.address}-${r.eventId}`}),!0}catch(e){return await S(e,`发送房间事件失败`),!1}},[h,I,e,S,p,N,o]),setRoomCode:m,syncMessages:P,userIdentity:o}}async function B(e,t,n,r,i,a){let o=D({gameId:n,roomCode:r,event:i,payload:a});await u.sendChannelMessage({channelName:e,content:JSON.stringify(o),author:t.address,authorName:H(t)})}function V(e){return{address:e.address,name:H(e),publicKey:``,joinedAt:Date.now()}}function H(e){return e.displayName||e.username}export{f as a,g as i,k as n,A as r,z as t};
@@ -1,3 +0,0 @@
1
- import{n as e,o as t,t as n}from"./jsx-runtime-Bt-cYkS5.js";import{t as r}from"./chevron-down-Xlb3wTxd.js";import{t as i}from"./database-DQ7ZtUT9.js";import{t as a}from"./download-0rM8xVCe.js";import{n as o,t as s}from"./wallet-YxbxCi7C.js";import{t as c}from"./key-round-tIqGrtt_.js";import{n as l}from"./dateTime-D1koKRQU.js";import{t as u}from"./AppShell-DmZQwVA9.js";import{n as d,t as f}from"./sun-C3IUQTpa.js";import{a as p,i as m,n as h,r as g,t as _}from"./PemBlock-Dxx6k9MH.js";import{t as v}from"./triangle-alert-DUODU79n.js";import{t as y}from"./upload-CpDM23UH.js";import{A as b,C as x,D as S,H as C,M as w,N as T,S as ee,U as te,V as E,W as D,f as O,g as k,i as ne,j as re,k as ie,p as A,s as ae,u as j,w as oe}from"./index-Cf23WD2V.js";var se=D(`chevron-up`,[[`path`,{d:`m18 15-6-6-6 6`,key:`153udz`}]]),M=D(`file-braces`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 12a1 1 0 0 0-1 1v1a1 1 0 0 1-1 1 1 1 0 0 1 1 1v1a1 1 0 0 0 1 1`,key:`1oajmo`}],[`path`,{d:`M14 18a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1 1 1 0 0 1-1-1v-1a1 1 0 0 0-1-1`,key:`mpwhp6`}]]),ce=D(`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`}]]),le=D(`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`}]]),ue=D(`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`}]]),de=D(`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`}]]),fe=D(`user`,[[`path`,{d:`M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2`,key:`975kel`}],[`circle`,{cx:`12`,cy:`7`,r:`4`,key:`17ys0d`}]]),N=t(e(),1),pe=t(re(),1),me=`0123456789abcdefghijklmnopqrstuvwxyz`,he=e=>{let t=[];for(;e>=128;)t.push(e&127|128),e>>=7;return t.push(e),t},ge=e=>{let t=new Uint8Array([8,1,18,...he(e.length)]),n=new Uint8Array(t.length+e.length);return n.set(t,0),n.set(e,t.length),n},_e=(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},ve=(e,t)=>{let n=t.slice(2),r=new Uint8Array(T(e+n));return pe.default.sign.keyPair.fromSecretKey(r)},ye=(e,t)=>{let n=ge(ve(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`+_e(a,me)},P=n();function be(e){return e?`•`.repeat(Math.min(e.length,32)):`-`}function xe({title:e,username:t,password:n,showPassword:r,showPrivateKey:i,account:a,onUsernameChange:o,onPasswordChange:s,onTogglePassword:l,onTogglePrivateKey:u,onGenerate:d}){return(0,P.jsxs)(`div`,{className:`web3-box-account`,children:[(0,P.jsx)(`div`,{className:`web3-box-account-header`,children:(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`h2`,{children:e}),(0,P.jsx)(`p`,{children:`用户名和密码会确定性生成 x25519 密钥对。`})]})}),(0,P.jsxs)(`div`,{className:`web3-box-login`,children:[(0,P.jsx)(`input`,{type:`text`,placeholder:`用户名`,value:t,onChange:e=>o(e.target.value),className:`input`,autoCapitalize:`off`,autoCorrect:`off`,spellCheck:`false`}),(0,P.jsxs)(`div`,{className:`input-wrap`,children:[(0,P.jsx)(`input`,{type:r?`text`:`password`,placeholder:`密码(可选)`,value:n,onChange:e=>s(e.target.value),className:`input`,autoCapitalize:`off`,autoCorrect:`off`,spellCheck:`false`}),(0,P.jsx)(`button`,{className:`input-eye`,onClick:l,type:`button`,children:r?(0,P.jsx)(C,{size:16}):(0,P.jsx)(E,{size:16})})]}),(0,P.jsxs)(`button`,{className:`btn btn-primary btn-full`,onClick:d,disabled:!t.trim(),type:`button`,children:[(0,P.jsx)(c,{size:16}),`生成账号`]})]}),a?(0,P.jsxs)(`div`,{className:`web3-box-key-list`,children:[(0,P.jsxs)(`div`,{className:`web3-box-key-row`,children:[(0,P.jsx)(`span`,{children:`地址`}),(0,P.jsxs)(`div`,{className:`mono-row`,children:[(0,P.jsx)(`code`,{className:`mono`,children:a.address.toLowerCase()}),(0,P.jsx)(m,{text:a.address.toLowerCase()})]})]}),(0,P.jsxs)(`div`,{className:`web3-box-key-row`,children:[(0,P.jsx)(`span`,{children:`x25519 公钥`}),(0,P.jsxs)(`div`,{className:`mono-row`,children:[(0,P.jsx)(`code`,{className:`mono`,children:a.publicKey}),(0,P.jsx)(m,{text:a.publicKey})]})]}),(0,P.jsxs)(`div`,{className:`web3-box-key-row`,children:[(0,P.jsx)(`span`,{children:`x25519 私钥`}),(0,P.jsxs)(`div`,{className:`mono-row danger`,children:[(0,P.jsx)(`code`,{className:`mono`,children:i?a.privateKey:be(a.privateKey)}),(0,P.jsx)(`button`,{className:`btn btn-icon`,onClick:u,title:i?`隐藏私钥`:`显示私钥`,type:`button`,children:i?(0,P.jsx)(E,{size:14}):(0,P.jsx)(C,{size:14})})]})]})]}):null]})}function Se(e){return Number.isFinite(e)?`${new Date(e).toLocaleString()}`:`-`}function F({title:e,description:t,message:n,cipherText:r,decryptedText:i,error:a,encryptLabel:o,decryptLabel:s,messagePlaceholder:u,cipherPlaceholder:d,onMessageChange:f,onCipherTextChange:p,onEncrypt:m,onDecrypt:h}){let g=`box-message-${e.replaceAll(/\s+/g,`-`)}`,_=b(r);return(0,P.jsxs)(`section`,{className:`web3-box-flow`,children:[(0,P.jsx)(`div`,{className:`web3-box-flow-header`,children:(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`h2`,{children:e}),(0,P.jsx)(`p`,{children:t})]})}),(0,P.jsx)(`label`,{className:`web3-box-label`,htmlFor:g,children:`明文`}),(0,P.jsx)(`textarea`,{id:g,className:`textarea`,value:n,onChange:e=>f(e.target.value),rows:4,placeholder:u}),(0,P.jsxs)(`div`,{className:`web3-box-actions`,children:[(0,P.jsxs)(`button`,{className:`btn btn-primary`,onClick:m,type:`button`,children:[(0,P.jsx)(l,{size:16}),o]}),(0,P.jsxs)(`button`,{className:`btn btn-secondary`,onClick:h,type:`button`,children:[(0,P.jsx)(c,{size:16}),s]})]}),a&&(0,P.jsx)(`p`,{className:`web3-tools-danger`,children:a}),(0,P.jsxs)(`div`,{className:`web3-box-result-grid`,children:[(0,P.jsxs)(`div`,{className:`web3-box-result`,children:[(0,P.jsx)(`label`,{className:`web3-box-result-header`,children:(0,P.jsx)(`span`,{children:`密文`})}),(0,P.jsx)(`textarea`,{className:`textarea mono`,value:r,onChange:e=>p(e.target.value),rows:5,placeholder:d})]}),(0,P.jsxs)(`div`,{className:`web3-box-result`,children:[(0,P.jsx)(`label`,{className:`web3-box-result-header`,children:(0,P.jsx)(`span`,{children:`解密结果`})}),(0,P.jsx)(`textarea`,{className:`textarea mono`,value:i,readOnly:!0,rows:5,placeholder:`解密成功后显示明文`})]})]}),_&&(0,P.jsxs)(`div`,{className:`web3-box-token-meta`,children:[(0,P.jsxs)(`div`,{className:`web3-box-token-meta-row`,children:[(0,P.jsx)(`span`,{children:`时间戳`}),(0,P.jsx)(`code`,{children:Se(_.timestampMs)})]}),(0,P.jsxs)(`div`,{className:`web3-box-token-meta-row`,children:[(0,P.jsx)(`span`,{children:`随机数`}),(0,P.jsx)(`code`,{children:_.nonce})]})]})]})}function Ce(e){return(0,P.jsxs)(`div`,{className:`web3-box-workspace`,children:[(0,P.jsxs)(`div`,{className:`web3-box-grid`,children:[(0,P.jsx)(xe,{title:`A 账号`,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,P.jsx)(xe,{title:`B 账号`,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,P.jsxs)(`div`,{className:`web3-box-flow-grid`,children:[(0,P.jsx)(F,{title:`A → B`,description:`加密使用 A 私钥 + B 公钥;解密使用 A 公钥 + B 私钥。`,message:e.boxABMessage,cipherText:e.boxABCipherText,decryptedText:e.boxABDecryptedText,error:e.boxABError,encryptLabel:`用 A 私钥 + B 公钥加密`,decryptLabel:`用 A 公钥 + B 私钥解密`,messagePlaceholder:`输入要从 A 发给 B 的消息`,cipherPlaceholder:`加密后生成密文,或粘贴已有密文`,onMessageChange:e.onBoxABMessageChange,onCipherTextChange:e.onBoxABCipherTextChange,onEncrypt:e.onEncryptBoxAB,onDecrypt:e.onDecryptBoxAB}),(0,P.jsx)(F,{title:`B → A`,description:`加密使用 B 私钥 + A 公钥;解密使用 B 公钥 + A 私钥。`,message:e.boxBAMessage,cipherText:e.boxBACipherText,decryptedText:e.boxBADecryptedText,error:e.boxBAError,encryptLabel:`用 B 私钥 + A 公钥加密`,decryptLabel:`用 B 公钥 + A 私钥解密`,messagePlaceholder:`输入要从 B 发给 A 的消息`,cipherPlaceholder:`加密后生成密文,或粘贴已有密文`,onMessageChange:e.onBoxBAMessageChange,onCipherTextChange:e.onBoxBACipherTextChange,onEncrypt:e.onEncryptBoxBA,onDecrypt:e.onDecryptBoxBA})]}),(0,P.jsxs)(`div`,{className:`web3-box-flow-grid`,children:[(0,P.jsxs)(`section`,{className:`web3-box-flow`,children:[(0,P.jsx)(`div`,{className:`web3-box-flow-header`,children:(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`h2`,{children:`加密`}),(0,P.jsx)(`p`,{children:`只输入发送方私钥和接收方公钥即可加密,无需生成完整账号。`})]})}),(0,P.jsx)(`label`,{className:`web3-box-result-header`,children:(0,P.jsx)(`span`,{children:`发送方`})}),(0,P.jsxs)(`div`,{className:`input-wrap`,children:[(0,P.jsx)(`input`,{type:e.boxEncryptShowPrivateKey?`text`:`password`,placeholder:`发送方 x25519 私钥`,value:e.boxEncryptSenderPrivateKey,onChange:t=>e.onBoxEncryptSenderPrivateKeyChange(t.target.value),className:`input`,autoCapitalize:`off`,autoCorrect:`off`,spellCheck:`false`}),(0,P.jsx)(`button`,{className:`input-eye`,onClick:e.onBoxEncryptShowPrivateKeyToggle,type:`button`,children:e.boxEncryptShowPrivateKey?(0,P.jsx)(C,{size:16}):(0,P.jsx)(E,{size:16})})]}),(0,P.jsx)(`label`,{className:`web3-box-result-header`,children:(0,P.jsx)(`span`,{children:`接收方`})}),(0,P.jsx)(`input`,{type:`text`,placeholder:`接收方 x25519 公钥`,value:e.boxEncryptRecipientPublicKey,onChange:t=>e.onBoxEncryptRecipientPublicKeyChange(t.target.value),className:`input`,autoCapitalize:`off`,autoCorrect:`off`,spellCheck:`false`}),(0,P.jsx)(`label`,{className:`web3-box-result-header`,children:(0,P.jsx)(`span`,{children:`明文`})}),(0,P.jsx)(`textarea`,{className:`textarea`,value:e.boxEncryptMessage,onChange:t=>e.onBoxEncryptMessageChange(t.target.value),rows:4,placeholder:`输入要加密的消息`}),(0,P.jsx)(`div`,{className:`web3-box-actions`,children:(0,P.jsxs)(`button`,{className:`btn btn-primary`,onClick:e.onEncryptOnly,type:`button`,children:[(0,P.jsx)(l,{size:16}),`加密`]})}),e.boxEncryptError&&(0,P.jsx)(`p`,{className:`web3-tools-danger`,children:e.boxEncryptError}),(0,P.jsxs)(`div`,{className:`web3-box-result`,children:[(0,P.jsx)(`label`,{className:`web3-box-result-header`,children:(0,P.jsx)(`span`,{children:`密文`})}),(0,P.jsx)(`textarea`,{className:`textarea mono`,value:e.boxEncryptCipherText,readOnly:!0,rows:5,placeholder:`加密成功后显示密文`})]})]}),(0,P.jsxs)(`section`,{className:`web3-box-flow`,children:[(0,P.jsx)(`div`,{className:`web3-box-flow-header`,children:(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`h2`,{children:`解密`}),(0,P.jsx)(`p`,{children:`只输入发送方公钥和接收方私钥即可解密,无需生成完整账号。`})]})}),(0,P.jsx)(`label`,{className:`web3-box-result-header`,children:(0,P.jsx)(`span`,{children:`发送方`})}),(0,P.jsx)(`input`,{type:`text`,placeholder:`发送方 x25519 公钥`,value:e.boxDecryptSenderPublicKey,onChange:t=>e.onBoxDecryptSenderPublicKeyChange(t.target.value),className:`input`,autoCapitalize:`off`,autoCorrect:`off`,spellCheck:`false`}),(0,P.jsx)(`label`,{className:`web3-box-result-header`,children:(0,P.jsx)(`span`,{children:`接收方`})}),(0,P.jsxs)(`div`,{className:`input-wrap`,children:[(0,P.jsx)(`input`,{type:e.boxDecryptShowPrivateKey?`text`:`password`,placeholder:`接收方 x25519 私钥`,value:e.boxDecryptRecipientPrivateKey,onChange:t=>e.onBoxDecryptRecipientPrivateKeyChange(t.target.value),className:`input`,autoCapitalize:`off`,autoCorrect:`off`,spellCheck:`false`}),(0,P.jsx)(`button`,{className:`input-eye`,onClick:e.onBoxDecryptShowPrivateKeyToggle,type:`button`,children:e.boxDecryptShowPrivateKey?(0,P.jsx)(C,{size:16}):(0,P.jsx)(E,{size:16})})]}),(0,P.jsx)(`label`,{className:`web3-box-result-header`,children:(0,P.jsx)(`span`,{children:`密文`})}),(0,P.jsx)(`textarea`,{className:`textarea mono`,value:e.boxDecryptCipherText,onChange:t=>e.onBoxDecryptCipherTextChange(t.target.value),rows:5,placeholder:`粘贴要解密的密文`}),(0,P.jsx)(`div`,{className:`web3-box-actions`,children:(0,P.jsxs)(`button`,{className:`btn btn-secondary`,onClick:e.onDecryptOnly,type:`button`,children:[(0,P.jsx)(c,{size:16}),`解密`]})}),e.boxDecryptError&&(0,P.jsx)(`p`,{className:`web3-tools-danger`,children:e.boxDecryptError}),(0,P.jsxs)(`div`,{className:`web3-box-result`,children:[(0,P.jsx)(`label`,{className:`web3-box-result-header`,children:(0,P.jsx)(`span`,{children:`解密结果`})}),(0,P.jsx)(`textarea`,{className:`textarea mono`,value:e.boxDecryptResult,readOnly:!0,rows:5,placeholder:`解密成功后显示明文`})]})]})]})]})}function we({walletResult:e,publicPem:t,privatePem:n}){if(!t||!n)return(0,P.jsx)(g,{icon:(0,P.jsx)(l,{size:36}),message:`请输入用户名和密码以生成 PEM 密钥`});let r=e?.username||`wallet`;return(0,P.jsxs)(`div`,{className:`web3-pem-list`,children:[(0,P.jsx)(_,{label:`${r}.pub`,pem:t,filename:`${r}.pub`}),(0,P.jsx)(_,{label:`${r}.pem`,pem:n,filename:`${r}.pem`})]})}function Te(e){let t=new Blob([JSON.stringify(e,null,2)],{type:`application/json`}),n=URL.createObjectURL(t),r=document.createElement(`a`),i=new Date().toISOString().replace(/[:.]/g,`-`);r.href=n,r.download=`mostbox-user-data-${e.ownerAddress}-${i}.json`,document.body.appendChild(r),r.click(),r.remove(),URL.revokeObjectURL(n)}function Ee(){let e=O(e=>e.addToast),t=j(e=>e.identity),n=j(e=>e.openLoginModal),[r,o]=(0,N.useState)(null),[s,c]=(0,N.useState)(!1),[l,u]=(0,N.useState)(``);return(0,N.useEffect)(()=>{t&&(c(!0),u(``),A.get(`/api/user/export`).json().then(o).catch(async e=>u(await k(e,`导出预览失败`))).finally(()=>c(!1)))},[t?.address]),(0,P.jsxs)(`section`,{id:`user-export`,className:`web3-key-card`,children:[(0,P.jsxs)(`div`,{className:`web3-key-card-header`,children:[(0,P.jsx)(`span`,{className:`web3-key-card-icon`,children:(0,P.jsx)(i,{size:18})}),(0,P.jsx)(`span`,{className:`web3-key-card-title`,children:`MostBox 元数据导出`})]}),(0,P.jsx)(`div`,{className:`web3-key-card-body web3-data-stack`,children:t?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(`div`,{className:`web3-data-summary`,children:[(0,P.jsx)(`span`,{children:`当前用户`}),(0,P.jsx)(`strong`,{children:t.address})]}),(0,P.jsxs)(`div`,{className:`web3-data-grid`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`span`,{children:`文件`}),(0,P.jsx)(`strong`,{children:r?.files.length??`-`})]}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`span`,{children:`回收站`}),(0,P.jsx)(`strong`,{children:r?.trashFiles.length??`-`})]}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`span`,{children:`频道`}),(0,P.jsx)(`strong`,{children:r?.channels.length??`-`})]})]}),l&&(0,P.jsx)(`p`,{className:`web3-tools-danger`,children:l}),(0,P.jsxs)(`button`,{className:`btn btn-primary`,onClick:async()=>{if(!t){n();return}c(!0),u(``);try{let t=await A.get(`/api/user/export`).json();o(t),Te(t),e(`用户数据已导出`,`success`)}catch(t){let n=await k(t,`导出失败`);u(n),e(n,`error`)}finally{c(!1)}},disabled:s,children:[(0,P.jsx)(a,{size:16}),s?`处理中...`:`导出 JSON`]})]}):(0,P.jsx)(`button`,{className:`btn btn-primary`,onClick:n,children:`登录后导出`})})]})}function I(e){return!Number.isFinite(e)||e<=0?`0 B`:e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:e<1024*1024*1024?`${(e/(1024*1024)).toFixed(1)} MB`:`${(e/(1024*1024*1024)).toFixed(2)} GB`}function De(){let e=O(e=>e.addToast),t=j(e=>e.identity),n=j(e=>e.openLoginModal),[r,i]=(0,N.useState)(null),[a,o]=(0,N.useState)(``),[s,c]=(0,N.useState)(null),[l,u]=(0,N.useState)(null),[d,f]=(0,N.useState)(!1),[p,m]=(0,N.useState)(``),[h,g]=(0,N.useState)(!1);return(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(`section`,{id:`user-import`,className:`web3-key-card`,children:[(0,P.jsxs)(`div`,{className:`web3-key-card-header`,children:[(0,P.jsx)(`span`,{className:`web3-key-card-icon`,children:(0,P.jsx)(M,{size:18})}),(0,P.jsx)(`span`,{className:`web3-key-card-title`,children:`MostBox 元数据导入`})]}),(0,P.jsx)(`div`,{className:`web3-key-card-body web3-data-stack`,children:t?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(`label`,{className:`web3-import-drop`,children:[(0,P.jsx)(y,{size:20}),(0,P.jsx)(`span`,{children:a||`选择导出的 JSON 文件`}),(0,P.jsx)(`input`,{type:`file`,accept:`application/json,.json`,onChange:async r=>{let a=r.target.files?.[0];if(c(null),u(null),m(``),i(null),a){o(a.name);try{let e=await a.text(),r=JSON.parse(e);if(i(r),!t){n();return}f(!0),c(await A.post(`/api/user/import/check`,{json:{package:r},timeout:6e4}).json())}catch(t){let n=t instanceof SyntaxError?`JSON 文件格式无效`:await k(t,`导入预检失败`);m(n),e(n,`error`)}finally{f(!1)}}}})]}),d&&(0,P.jsx)(`p`,{className:`web3-data-muted`,children:`处理中...`}),p&&(0,P.jsx)(`p`,{className:`web3-tools-danger`,children:p}),s&&(0,P.jsxs)(`div`,{className:`web3-data-stack`,children:[(0,P.jsxs)(`div`,{className:`web3-data-grid`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`span`,{children:`当前文件`}),(0,P.jsx)(`strong`,{children:s.currentFileCount})]}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`span`,{children:`导入文件`}),(0,P.jsx)(`strong`,{children:s.importFileCount})]}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`span`,{children:`所需容量`}),(0,P.jsx)(`strong`,{children:I(s.requiredBytes)})]}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`span`,{children:`可用容量`}),(0,P.jsx)(`strong`,{children:I(s.availableBytes)})]})]}),!s.ready&&(0,P.jsxs)(`div`,{className:`web3-import-failures`,children:[(0,P.jsxs)(`div`,{className:`web3-data-warning`,children:[(0,P.jsx)(v,{size:16}),(0,P.jsx)(`span`,{children:`当前导入包不能完整导入`})]}),s.failures.slice(0,20).map((e,t)=>(0,P.jsxs)(`p`,{children:[e.fileName||e.cid||`导入包`,`:`,` `,e.error]},`${e.cid||e.fileName||t}`))]}),s.ready&&(0,P.jsx)(`button`,{className:`btn btn-danger`,onClick:()=>g(!0),disabled:d,children:`覆盖并导入`})]}),l&&(0,P.jsxs)(`div`,{className:`web3-import-result`,children:[(0,P.jsxs)(`strong`,{children:[`已导入 `,l.importedFiles,` 个文件,`,l.importedTrashFiles,` 个回收站项`]}),l.failedFiles.map(e=>(0,P.jsxs)(`p`,{children:[e.fileName,`: `,e.error]},e.cid))]})]}):(0,P.jsx)(`button`,{className:`btn btn-primary`,onClick:n,children:`登录后导入`})})]}),h&&(0,P.jsx)(ae,{title:`覆盖当前用户数据`,message:`导入会先清空当前账号在本节点的文件视图、回收站和频道偏好,然后用导入包重建。`,confirmText:d?`导入中...`:`确认导入`,danger:!0,onConfirm:async()=>{if(!t){n();return}if(!(!r||!s?.ready||!s.checkId)){f(!0),m(``),u(null);try{let t=await A.post(`/api/user/import`,{json:{package:r,checkId:s.checkId},timeout:12e4}).json();u(t),e(t.success?`导入完成`:`导入完成,部分文件失败`,t.success?`success`:`error`),g(!1)}catch(t){let n=await k(t,`导入失败`);m(n),e(n,`error`)}finally{f(!1)}}},onClose:()=>g(!1)})]})}var Oe=Object.defineProperty,L=Object.getOwnPropertySymbols,R=Object.prototype.hasOwnProperty,z=Object.prototype.propertyIsEnumerable,ke=(e,t,n)=>t in e?Oe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,B=(e,t)=>{for(var n in t||={})R.call(t,n)&&ke(e,n,t[n]);if(L)for(var n of L(t))z.call(t,n)&&ke(e,n,t[n]);return e},V=(e,t)=>{var n={};for(var r in e)R.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&L)for(var r of L(e))t.indexOf(r)<0&&z.call(e,r)&&(n[r]=e[r]);return n},H;(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})(H||={}),(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||={})})(H||={}),(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||={})})(H||={});var U=H,Ae={L:U.QrCode.Ecc.LOW,M:U.QrCode.Ecc.MEDIUM,Q:U.QrCode.Ecc.QUARTILE,H:U.QrCode.Ecc.HIGH},W=128,je=`L`,G=`#FFFFFF`,Me=`#000000`,K=!1,Ne=1,Pe=4,Fe=0,Ie=.1;function Le(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 q(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 Re(e,t,n,r){if(r==null)return null;let i=e.length+n*2,a=Math.floor(t*Ie),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 ze(e,t){return t==null?e?Pe:Fe:Math.max(Math.floor(t),0)}function Be({value:e,level:t,minVersion:n,includeMargin:r,marginSize:i,imageSettings:a,size:o,boostLevel:s}){let c=N.useMemo(()=>{let r=(Array.isArray(e)?e:[e]).reduce((e,t)=>(e.push(...U.QrSegment.makeSegments(t)),e),[]);return U.QrCode.encodeSegments(r,Ae[t],n,void 0,void 0,s)},[e,t,n,s]),{cells:l,margin:u,numCells:d,calculatedImageSettings:f}=N.useMemo(()=>{let e=c.getModules(),t=ze(r,i);return{cells:e,margin:t,numCells:e.length+t*2,calculatedImageSettings:Re(e,o,t,a)}},[c,o,a,r,i]);return{qrcode:c,margin:u,cells:l,numCells:d,calculatedImageSettings:f}}var J=function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0}(),Ve=N.forwardRef(function(e,t){let n=e,{value:r,size:i=W,level:a=je,bgColor:o=G,fgColor:s=Me,includeMargin:c=K,minVersion:l=Ne,boostLevel:u,marginSize:d,imageSettings:f}=n,p=V(n,[`value`,`size`,`level`,`bgColor`,`fgColor`,`includeMargin`,`minVersion`,`boostLevel`,`marginSize`,`imageSettings`]),{style:m}=p,h=V(p,[`style`]),g=f?.src,_=N.useRef(null),v=N.useRef(null),y=N.useCallback(e=>{_.current=e,typeof t==`function`?t(e):t&&(t.current=e)},[t]),[b,x]=N.useState(!1),{margin:S,cells:C,numCells:w,calculatedImageSettings:T}=Be({value:r,level:a,minVersion:l,boostLevel:u,includeMargin:c,marginSize:d,imageSettings:f,size:i});N.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=q(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,J?t.fill(new Path2D(Le(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)}}),N.useEffect(()=>{x(!1)},[g]);let ee=B({height:i,width:i},m),te=null;return g!=null&&(te=N.createElement(`img`,{src:g,key:g,style:{display:`none`},onLoad:()=>{x(!0)},ref:v,crossOrigin:T?.crossOrigin})),N.createElement(N.Fragment,null,N.createElement(`canvas`,B({style:ee,height:i,width:i,ref:y,role:`img`},h)),te)});Ve.displayName=`QRCodeCanvas`;var Y=N.forwardRef(function(e,t){let n=e,{value:r,size:i=W,level:a=je,bgColor:o=G,fgColor:s=Me,includeMargin:c=K,minVersion:l=Ne,boostLevel:u,title:d,marginSize:f,imageSettings:p}=n,m=V(n,[`value`,`size`,`level`,`bgColor`,`fgColor`,`includeMargin`,`minVersion`,`boostLevel`,`title`,`marginSize`,`imageSettings`]),{margin:h,cells:g,numCells:_,calculatedImageSettings:v}=Be({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=q(g,v.excavation)),b=N.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=Le(y,h);return N.createElement(`svg`,B({height:i,width:i,viewBox:`0 0 ${_} ${_}`,ref:t,role:`img`},m),!!d&&N.createElement(`title`,null,d),N.createElement(`path`,{fill:o,d:`M0,0 h${_}v${_}H0z`,shapeRendering:`crispEdges`}),N.createElement(`path`,{fill:s,d:x,shapeRendering:`crispEdges`}),b)});Y.displayName=`QRCodeSVG`;function He({walletResult:e,mnemonicPhrase:t,deriveBatch:n,deriveList:i,deriveShowIndex:a,deriveShowAddress:o,deriveShowPrivateKey:l,showAddressQr:u,showMnemonicReveal:d,showMnemonicQr:f,onToggleAddressQr:h,onToggleMnemonicReveal:_,onToggleMnemonicQr:v,onToggleDeriveIndex:y,onToggleDeriveAddress:b,onToggleDerivePrivateKey:x,onDerive:S}){let C=e?.address||``;return!e||!C?(0,P.jsx)(g,{icon:(0,P.jsx)(s,{size:36}),message:`请输入用户名和密码以使用钱包工具`}):(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(`div`,{className:`web3-tools-section`,children:[(0,P.jsxs)(`button`,{className:`web3-tools-toggle`,onClick:h,children:[(0,P.jsx)(ue,{size:14}),u?`隐藏地址二维码`:`显示地址二维码`,u?(0,P.jsx)(se,{size:14}):(0,P.jsx)(r,{size:14})]}),u&&(0,P.jsxs)(`div`,{className:`web3-mnemonic-reveal`,children:[(0,P.jsxs)(`div`,{className:`web3-mnemonic-card`,children:[(0,P.jsx)(`p`,{className:`web3-mnemonic-text`,children:C}),(0,P.jsx)(m,{text:C})]}),(0,P.jsx)(`div`,{className:`qr-wrap`,children:(0,P.jsx)(Y,{value:C,size:200})})]})]}),t&&(0,P.jsxs)(`div`,{className:`web3-tools-section`,children:[(0,P.jsxs)(`button`,{className:`web3-tools-toggle`,onClick:_,children:[(0,P.jsx)(c,{size:14}),d?`隐藏助记词`:`显示助记词`,d?(0,P.jsx)(se,{size:14}):(0,P.jsx)(r,{size:14})]}),d&&(0,P.jsxs)(`div`,{className:`web3-mnemonic-reveal`,children:[(0,P.jsxs)(`div`,{className:`web3-mnemonic-card`,children:[(0,P.jsx)(`p`,{className:`web3-mnemonic-text`,children:t}),(0,P.jsx)(m,{text:t})]}),(0,P.jsxs)(`p`,{className:`web3-tools-danger`,children:[(0,P.jsx)(p,{size:14}),`任何拥有您助记词的人都可以窃取您账户中的任何资产,切勿泄露!!!`]}),(0,P.jsx)(`button`,{className:`web3-tools-toggle`,onClick:v,children:f?`隐藏助记词二维码`:`显示助记词二维码`}),f&&(0,P.jsx)(`div`,{className:`qr-wrap`,children:(0,P.jsx)(Y,{value:t,size:260})})]})]}),t&&(0,P.jsxs)(`div`,{className:`web3-mnemonic-reveal`,children:[(0,P.jsx)(`div`,{children:(0,P.jsxs)(`button`,{className:`btn btn-primary`,onClick:S,children:[`派生 `,n,` 个地址`]})}),(0,P.jsxs)(`p`,{className:`web3-tools-danger`,children:[(0,P.jsx)(p,{size:14}),`任何拥有您私钥的人都可以窃取您地址中的任何资产,切勿泄露!!!`]}),i.length>0&&(0,P.jsx)(`div`,{className:`web3-derive-table-wrap`,children:(0,P.jsxs)(`table`,{className:`web3-derive-table`,children:[(0,P.jsx)(`thead`,{children:(0,P.jsxs)(`tr`,{children:[(0,P.jsx)(`th`,{onClick:y,className:`web3-derive-th`,children:`账户`}),(0,P.jsx)(`th`,{onClick:b,className:`web3-derive-th`,children:`地址`}),(0,P.jsxs)(`th`,{onClick:x,className:`web3-derive-th danger`,children:[`私钥(点击`,l?`隐藏`:`显示`,`)`]})]})}),(0,P.jsx)(`tbody`,{children:i.map(e=>(0,P.jsxs)(`tr`,{children:[(0,P.jsx)(`td`,{children:a?e.index+1:``}),(0,P.jsx)(`td`,{children:o?e.address:``}),(0,P.jsx)(`td`,{className:`danger`,children:l?e.privateKey:``})]},e.index))})]})})]})]})}function Ue(e){return e?`•`.repeat(Math.min(e.length,32)):`-`}function We({walletResult:e,keys:t,ipns:n,avatarSrc:r,showPrivateKey:i,onTogglePrivateKey:a}){let s=e?.address||``;return!e||!s?(0,P.jsx)(g,{icon:(0,P.jsx)(fe,{size:36}),message:`请输入用户名和密码以查看身份信息`}):(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(`div`,{className:`web3-identity-card`,children:[(0,P.jsx)(`img`,{src:r,alt:`avatar`,className:`web3-identity-avatar`}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`h1`,{className:`web3-identity-name`,children:e.username||`未登录`}),(0,P.jsxs)(`div`,{className:`web3-identity-address`,children:[(0,P.jsx)(`code`,{children:s.toLowerCase()}),(0,P.jsx)(m,{text:s.toLowerCase()}),(0,P.jsxs)(`a`,{href:`https://debank.com/profile/${s}`,target:`_blank`,rel:`noopener noreferrer`,className:`link`,children:[(0,P.jsx)(o,{size:14}),`查看`]})]})]})]}),t&&(0,P.jsxs)(`div`,{className:`web3-key-grid`,children:[(0,P.jsx)(h,{title:`Ed25519 公钥`,icon:(0,P.jsx)(ce,{size:18}),children:(0,P.jsxs)(`div`,{className:`mono-row`,children:[(0,P.jsx)(`code`,{className:`mono`,children:t.ed_public_key}),(0,P.jsx)(m,{text:t.ed_public_key})]})}),(0,P.jsx)(h,{title:`x25519 公钥`,icon:(0,P.jsx)(c,{size:18}),children:(0,P.jsxs)(`div`,{className:`mono-row`,children:[(0,P.jsx)(`code`,{className:`mono`,children:t.public_key}),(0,P.jsx)(m,{text:t.public_key})]})}),(0,P.jsx)(h,{title:`x25519 & Ed25519 私钥`,icon:(0,P.jsx)(de,{size:18}),accent:!0,children:(0,P.jsxs)(`div`,{className:`mono-row danger`,children:[(0,P.jsx)(`code`,{className:`mono`,children:i?t.private_key:Ue(t.private_key)}),(0,P.jsx)(`button`,{className:`btn btn-icon`,onClick:a,title:i?`隐藏私钥`:`显示私钥`,type:`button`,children:i?(0,P.jsx)(E,{size:14}):(0,P.jsx)(C,{size:14})})]})}),(0,P.jsx)(h,{title:`IPNS ID`,icon:(0,P.jsx)(le,{size:18}),children:(0,P.jsxs)(`div`,{className:`mono-row`,children:[(0,P.jsx)(`code`,{className:`mono`,children:n}),(0,P.jsx)(m,{text:n})]})})]})]})}function Ge({username:e,password:t,showPassword:n,generating:r,onUsernameChange:i,onPasswordChange:a,onTogglePassword:o,onGenerate:c}){return(0,P.jsxs)(`div`,{className:`input-panel`,children:[(0,P.jsxs)(`div`,{className:`web3-tools-inputs`,children:[(0,P.jsx)(`input`,{type:`text`,placeholder:`用户名`,value:e,onChange:e=>i(e.target.value),className:`input`,autoCapitalize:`off`,autoCorrect:`off`,spellCheck:`false`}),(0,P.jsxs)(`div`,{className:`input-wrap`,children:[(0,P.jsx)(`input`,{type:n?`text`:`password`,placeholder:`密码(可选)`,value:t,onChange:e=>a(e.target.value),className:`input`,autoCapitalize:`off`,autoCorrect:`off`,spellCheck:`false`}),(0,P.jsx)(`button`,{className:`input-eye`,onClick:o,type:`button`,children:n?(0,P.jsx)(C,{size:16}):(0,P.jsx)(E,{size:16})})]})]}),(0,P.jsx)(`button`,{className:`btn btn-primary btn-full`,onClick:c,disabled:!e.trim()||r,type:`button`,children:r?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`span`,{className:`spinner`}),`生成中...`]}):(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(s,{size:16}),`生成并登录`]})})]})}var X=e=>btoa(String.fromCharCode(...e)),Ke=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-----`},qe=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-----`},Je=[`wallet`,`pem`,`export`,`EA`,`user-export`,`user-import`];function Ye(){let e=window.location.hash.replace(`#`,``);return Je.includes(e)?e:`wallet`}function Xe(){let e=O(e=>e.isDarkMode),t=O(e=>e.setIsDarkMode),n=O(e=>e.addToast),r=j(e=>e.setUserIdentity),[a,o]=(0,N.useState)(`wallet`),[p,m]=(0,N.useState)(``),[h,g]=(0,N.useState)(``),[_,v]=(0,N.useState)(!1),[b,C]=(0,N.useState)(null),[T,E]=(0,N.useState)(null),[D,k]=(0,N.useState)(``),[re,A]=(0,N.useState)(``),[ae,se]=(0,N.useState)(``),[M,ce]=(0,N.useState)(``),[le,ue]=(0,N.useState)([]),[de,pe]=(0,N.useState)(0),[me,he]=(0,N.useState)(!0),[ge,_e]=(0,N.useState)(!0),[be,xe]=(0,N.useState)(!1),[Se,F]=(0,N.useState)(!1),[Te,I]=(0,N.useState)(!1),[Oe,L]=(0,N.useState)(!1),[R,z]=(0,N.useState)(!1),[ke,B]=(0,N.useState)(!1),[V,H]=(0,N.useState)(``),[U,Ae]=(0,N.useState)(``),[W,je]=(0,N.useState)(!1),[G,Me]=(0,N.useState)(!1),[K,Ne]=(0,N.useState)(null),[Pe,Fe]=(0,N.useState)(``),[Ie,Le]=(0,N.useState)(``),[q,Re]=(0,N.useState)(!1),[ze,Be]=(0,N.useState)(!1),[J,Ve]=(0,N.useState)(null),[Y,Ue]=(0,N.useState)(`你好,B。这是来自 A 的加密消息。`),[X,Je]=(0,N.useState)(``),[Xe,Z]=(0,N.useState)(``),[Ze,Qe]=(0,N.useState)(``),[$e,et]=(0,N.useState)(`你好,A。这是来自 B 的加密消息。`),[tt,nt]=(0,N.useState)(``),[rt,it]=(0,N.useState)(``),[at,ot]=(0,N.useState)(``),[st,ct]=(0,N.useState)(``),[lt,ut]=(0,N.useState)(``),[dt,ft]=(0,N.useState)(``),[pt,mt]=(0,N.useState)(``),[ht,Q]=(0,N.useState)(``),[gt,_t]=(0,N.useState)(!1),[vt,yt]=(0,N.useState)(``),[bt,xt]=(0,N.useState)(``),[St,Ct]=(0,N.useState)(``),[wt,Tt]=(0,N.useState)(``),[Et,$]=(0,N.useState)(``),[Dt,Ot]=(0,N.useState)(!1);(0,N.useEffect)(()=>{o(Ye());let e=()=>o(Ye());return window.addEventListener(`hashchange`,e),()=>window.removeEventListener(`hashchange`,e)},[]);let kt=e=>{o(e),window.location.hash=e},At=(0,N.useCallback)(async()=>{if(!p.trim())return;B(!0),await new Promise(e=>setTimeout(e,0));let e=ie(p.trim(),h),t=`${e.username}#${e.address.slice(-4).toUpperCase()}`;C(e),r({...e,displayName:t}),n(`已登录 ${e.username}`,`success`),ce(S(e.danger));let i=ee(e.danger);E(i),k(ye(i.private_key,i.ed_public_key));let a=ve(i.private_key,i.ed_public_key);A(Ke(a.secretKey)),se(qe(a.publicKey)),ue([]),pe(0),F(!1),I(!1),L(!1),z(!1),B(!1)},[n,h,r,p]);function jt(e,t,r){let i=e.trim();if(!i)return;let a=ie(i,t),o=ee(a.danger);r({username:a.username,address:a.address,publicKey:o.public_key,privateKey:o.private_key}),Z(``),Qe(``),it(``),ot(``),n(`账号已生成`,`success`)}function Mt({senderAccount:e,recipientAccount:t,message:n,setCipherText:r,setDecryptedText:i,setError:a}){if(!e||!t){a(`请先生成 A 和 B 两个账号`);return}if(!n.trim()){a(`请输入要加密的消息`);return}r(oe(n,{senderPrivateKey:e.privateKey,recipientPublicKey:t.publicKey})),i(``),a(``)}function Nt({senderAccount:e,recipientAccount:t,cipherText:n,setDecryptedText:r,setError:i}){if(!e||!t){i(`请先生成 A 和 B 两个账号`);return}if(!n.trim()){i(`请先生成或粘贴密文`);return}let a=x(n,{senderPublicKey:e.publicKey,recipientPrivateKey:t.privateKey});if(!a){i(`解密失败,请确认发送方公钥、接收方私钥和密文匹配`),r(``);return}r(a),i(``)}function Pt(){if(!st.trim()){Q(`请输入发送方公钥`);return}if(!lt.trim()){Q(`请输入接收方私钥`);return}if(!dt.trim()){Q(`请粘贴密文`);return}let e=x(dt,{senderPublicKey:st.trim(),recipientPrivateKey:lt.trim()});if(!e){Q(`解密失败,请确认发送方公钥、接收方私钥和密文匹配`),mt(``);return}mt(e),Q(``)}function Ft(){if(!vt.trim()){$(`请输入发送方私钥`);return}if(!bt.trim()){$(`请输入接收方公钥`);return}if(!St.trim()){$(`请输入要加密的消息`);return}Tt(oe(St,{senderPrivateKey:vt.trim(),recipientPublicKey:bt.trim()})),$(``)}let It=()=>{if(!M)return;let e=[];for(let t=de;t<de+10;t++){let n=`m/44'/60'/0'/0/${t}`,r=w.fromPhrase(M,void 0,n);e.push({index:t,address:r.address,privateKey:r.privateKey})}ue(t=>[...t,...e]),pe(e=>e+10)},Lt=ne(b?.address||void 0),Rt=a===`wallet`?`Web3`:a===`pem`?`PEM 导出`:a===`EA`?`非对称加密`:a===`user-export`?`用户数据导出`:a===`user-import`?`用户数据导入`:`Wallet 导出`,zt=[{id:`wallet`,icon:(0,P.jsx)(fe,{size:16}),label:`Web3`},{id:`pem`,icon:(0,P.jsx)(l,{size:16}),label:`PEM 导出`},{id:`export`,icon:(0,P.jsx)(s,{size:16}),label:`Wallet 导出`},{id:`EA`,icon:(0,P.jsx)(c,{size:16}),label:`非对称加密`},{id:`user-export`,icon:(0,P.jsx)(i,{size:16}),label:`数据导出`},{id:`user-import`,icon:(0,P.jsx)(y,{size:16}),label:`数据导入`}],Bt=a!==`EA`&&!a.startsWith(`user-`);return(0,P.jsx)(u,{sidebar:({closeSidebar:e})=>(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(`div`,{className:`sidebar-header sidebar-header-link`,onClick:()=>window.location.href=`/`,children:[(0,P.jsx)(te,{size:18}),(0,P.jsx)(`h1`,{children:`MOST PEOPLE`})]}),(0,P.jsx)(`nav`,{className:`sidebar-nav`,children:zt.map(t=>(0,P.jsxs)(`button`,{onClick:()=>{kt(t.id),e()},className:`sidebar-nav-btn ${a===t.id?`active`:``}`,children:[t.icon,(0,P.jsx)(`span`,{children:t.label})]},t.id))})]}),headerTitle:(0,P.jsx)(`h2`,{className:`header-title`,children:Rt}),headerRight:(0,P.jsx)(`button`,{className:`btn btn-icon`,onClick:()=>t(!e),title:`切换主题`,children:e?(0,P.jsx)(f,{size:16}):(0,P.jsx)(d,{size:16})}),children:(0,P.jsx)(`div`,{className:`web3-page`,children:(0,P.jsxs)(`div`,{className:`web3-container ${a===`EA`?`wide`:``}`,children:[Bt&&(0,P.jsx)(Ge,{username:p,password:h,showPassword:_,generating:ke,onUsernameChange:m,onPasswordChange:g,onTogglePassword:()=>v(!_),onGenerate:At}),a===`wallet`&&(0,P.jsx)(We,{walletResult:b,keys:T,ipns:D,avatarSrc:Lt,showPrivateKey:R,onTogglePrivateKey:()=>z(!R)}),a===`pem`&&(0,P.jsx)(we,{walletResult:b,publicPem:ae,privatePem:re}),a===`export`&&(0,P.jsx)(He,{walletResult:b,mnemonicPhrase:M,deriveBatch:10,deriveList:le,deriveShowIndex:me,deriveShowAddress:ge,deriveShowPrivateKey:be,showAddressQr:Se,showMnemonicReveal:Te,showMnemonicQr:Oe,onToggleAddressQr:()=>F(!Se),onToggleMnemonicReveal:()=>I(!Te),onToggleMnemonicQr:()=>L(!Oe),onToggleDeriveIndex:()=>he(!me),onToggleDeriveAddress:()=>_e(!ge),onToggleDerivePrivateKey:()=>xe(!be),onDerive:It}),a===`EA`&&(0,P.jsx)(Ce,{boxAUsername:V,boxAPassword:U,boxAShowPassword:W,boxAShowPrivateKey:G,boxAAccount:K,boxBUsername:Pe,boxBPassword:Ie,boxBShowPassword:q,boxBShowPrivateKey:ze,boxBAccount:J,boxABMessage:Y,boxABCipherText:X,boxABDecryptedText:Xe,boxABError:Ze,boxBAMessage:$e,boxBACipherText:tt,boxBADecryptedText:rt,boxBAError:at,boxEncryptSenderPrivateKey:vt,boxEncryptRecipientPublicKey:bt,boxEncryptMessage:St,boxEncryptCipherText:wt,boxEncryptError:Et,boxEncryptShowPrivateKey:Dt,boxDecryptSenderPublicKey:st,boxDecryptRecipientPrivateKey:lt,boxDecryptCipherText:dt,boxDecryptResult:pt,boxDecryptError:ht,boxDecryptShowPrivateKey:gt,onBoxAUsernameChange:H,onBoxAPasswordChange:Ae,onBoxAShowPasswordToggle:()=>je(!W),onBoxAShowPrivateKeyToggle:()=>Me(!G),onGenerateBoxA:()=>jt(V,U,Ne),onBoxBUsernameChange:Fe,onBoxBPasswordChange:Le,onBoxBShowPasswordToggle:()=>Re(!q),onBoxBShowPrivateKeyToggle:()=>Be(!ze),onGenerateBoxB:()=>jt(Pe,Ie,Ve),onBoxABMessageChange:Ue,onBoxABCipherTextChange:Je,onEncryptBoxAB:()=>Mt({senderAccount:K,recipientAccount:J,message:Y,setCipherText:Je,setDecryptedText:Z,setError:Qe}),onDecryptBoxAB:()=>Nt({senderAccount:K,recipientAccount:J,cipherText:X,setDecryptedText:Z,setError:Qe}),onBoxBAMessageChange:et,onBoxBACipherTextChange:nt,onEncryptBoxBA:()=>Mt({senderAccount:J,recipientAccount:K,message:$e,setCipherText:nt,setDecryptedText:it,setError:ot}),onDecryptBoxBA:()=>Nt({senderAccount:J,recipientAccount:K,cipherText:tt,setDecryptedText:it,setError:ot}),onBoxEncryptSenderPrivateKeyChange:yt,onBoxEncryptRecipientPublicKeyChange:xt,onBoxEncryptMessageChange:Ct,onBoxEncryptShowPrivateKeyToggle:()=>Ot(!Dt),onEncryptOnly:Ft,onBoxDecryptSenderPublicKeyChange:ct,onBoxDecryptRecipientPrivateKeyChange:ut,onBoxDecryptCipherTextChange:ft,onBoxDecryptShowPrivateKeyToggle:()=>_t(!gt),onDecryptOnly:Pt}),a===`user-export`&&(0,P.jsx)(Ee,{}),a===`user-import`&&(0,P.jsx)(De,{})]})})})}var Z=Xe;export{Z as component};
@@ -1 +0,0 @@
1
- import{n as e,o as t,t as n}from"./jsx-runtime-Bt-cYkS5.js";import{t as r}from"./copy-CM-qWlbv.js";import{t as i}from"./AppShell-DmZQwVA9.js";import{n as a,t as o}from"./sun-C3IUQTpa.js";import{t as s}from"./play-BIl5vwqS.js";import{a as c,i as l,n as u,r as d,t as f}from"./useGameRoom-C6UgmIGG.js";import{C as p,S as m,V as h,W as g,f as ee,u as te,w as ne}from"./index-Cf23WD2V.js";var re=g(`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`}]]),_=t(e(),1),v=[10,20,50,100],y=[`2`,`3`,`4`,`5`,`6`,`7`,`8`,`9`,`10`,`J`,`Q`,`K`,`A`],b=[`D`,`C`,`H`,`S`],ie=new Map(y.map((e,t)=>[e,t+2])),x=new Map(b.map((e,t)=>[e,t+1])),S={high:1,pair:2,straight:3,flush:4,straightFlush:5,triple:6},C={[S.high]:`散牌`,[S.pair]:`对子`,[S.straight]:`顺子`,[S.flush]:`金花`,[S.straightFlush]:`顺金`,[S.triple]:`豹子`};function w(e){return String(e||``).trim().toUpperCase().replace(/[^A-Z0-9]/g,``).slice(0,8)}function T(e=`zhajinhua`){return`${e}_${Date.now()}_${he(4)}`}function E(){return T(`round`)}function D(){let e=[];for(let t of b)for(let n of y)e.push(`${n}${t}`);return e}function ae(e=D(),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(!ie.has(r)||!x.has(n))throw Error(`Invalid card: ${e}`);return{id:`${r}${n}`,rank:r,suit:n,rankValue:ie.get(r),suitValue:x.get(n)}}function oe(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 se(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 k(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=se(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:C[c],tiebreakers:l,tieSuit:s,cards:t.map(e=>e.id)}}function A(e,t){let n=k(e),r=k(t);if(n.category!==r.category)return n.category-r.category;let i=oe(n.tiebreakers,r.tiebreakers);return i===0?n.tieSuit-r.tieSuit:i}function ce(e){return k(e).label}function j({roundId:e,action:t,amount:n,target:r}){return{roundId:e,eventId:T(`action`),action:t,amount:n,target:r}}function le(e=[]){let t=e.filter(e=>Number(e.chips)>=10);return t.length>=2&&t.length<=5}function ue({roomCode:e,players:t,hostAddress:n,previousSeq:r=0,previousWinner:i=``,roundId:a=E(),random:o=Math.random}){let s=t.filter(e=>Number(e.chips)>=10).slice(0,5);if(s.length<2)throw Error(`至少需要 2 名有足够筹码的玩家`);let c=ae(D(),o),l={},u=s.map((e,t)=>{let n=c.slice(t*3,t*3+3);return l[e.address]=n,{address:e.address,name:e.name,publicKey:e.publicKey,chips:Number(e.chips)-10,status:`active`,looked:!1,bet:10}}),d,f=U(i),p=f?u.findIndex(e=>U(e.address)===f):-1;return d=p>=0?u[p].address:u[Math.floor(o()*u.length)].address,{roomCode:w(e),roundId:a,status:`playing`,host:U(n),seq:r+1,startedAt:Date.now(),ante:10,pot:10*u.length,currentBet:10,turnAddress:d,players:u,lastAction:`本局开始`,winner:null,showdown:null,appliedEventIds:[],hands:l,actionCounts:{},compareReveal:{}}}function de(e){if(!e)return null;let t={...e};return delete t.hands,W(t)}function fe(e,t){let n=M(e);return!n||!t||typeof t!=`object`?null:{...n,hands:W(t)}}function M(e){return!e||typeof e!=`object`||!e.roundId||!Array.isArray(e.players)?null:{roomCode:w(e.roomCode),roundId:String(e.roundId),status:e.status===`finished`?`finished`:`playing`,host:U(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:U(e.turnAddress),players:e.players.map(H).filter(Boolean),lastAction:String(e.lastAction||``),winner:e.winner?U(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 N(e,t,n){let r=M(e);if(!r||r.status!==`playing`)return{ok:!1,error:`当前没有进行中的牌局`};let i=U(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(!v.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=U(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 P(e,t,n){let r=N(e,t,n);if(!r.ok)return{ok:!1,error:r.error,state:e};let i=W(e),a=U(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} 看牌`,V(i);if(t.action===`fold`)return o.status=`folded`,i.lastAction=`${o.name} 弃牌`,L(i,a),R(i,a);if(t.action===`call`)return o.chips-=10,o.bet+=10,i.pot+=10,i.lastAction=`${o.name} 跟注`,L(i,a),R(i,a);if(t.action===`raise`){let e=Number(t.amount);return i.currentBet+=e,I(i,o),i.lastAction=`${o.name} 加注 ${e}`,L(i,a),R(i,a)}if(t.action===`compare`){I(i,o);let e=U(t.target),n=i.players.find(t=>t.address===e),r=o.looked,s=n.looked,c=A(i.hands?.[a]||[],i.hands?.[e]||[]),l=c>=0?o:n,u=c>=0?n:o;u.status=`folded`,u.looked=!0,i.compareReveal||={};let d=r&&s,f=!r&&!s;if(d)i.compareReveal[a]=i.hands?.[e]||[],i.compareReveal[e]=i.hands?.[a]||[];else if(f)i.compareReveal[u.address]=i.hands?.[l.address]||[];else{let e=r?o:n,t=r?n:o;i.compareReveal[e.address]=i.hands?.[t.address]||[],i.compareReveal[u.address]=i.hands?.[l.address]||[]}return i.lastCompare={initiator:a,target:e,winner:l.address,loser:u.address,initiatorLooked:r,targetLooked:s,timestamp:Date.now()},i.lastAction=`${o.name} 与 ${n.name} 比牌,${u.name} 出局`,L(i,a),R(i,a)}return{ok:!1,error:`未知操作`,state:e}}function F(e){return(e?.players||[]).filter(e=>e.status===`active`)}function pe(e,t){let n=(e?.players||[]).find(e=>e.address===U(t));if(!e||e.status!==`playing`||!n||n.status!==`active`||e.turnAddress!==n.address)return[];let r=[];return n.looked||r.push(`look`),N(e,{action:`call`},n.address).ok&&r.push(`call`),v.some(t=>N(e,{action:`raise`,amount:t},n.address).ok)&&r.push(`raise`),F(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 I(e,t){let n=Math.max(0,e.currentBet-t.bet);t.chips-=n,t.bet+=n,e.pot+=n}function L(e,t){e.actionCounts||={},e.actionCounts[t]=(e.actionCounts[t]||0)+1}function R(e,t){let n=F(e);return n.length===1?z(e,n[0].address):(e.turnAddress=B(e,t),V(e))}function z(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(),V(e)}function B(e,t){let n=e.players,r=Math.max(0,n.findIndex(e=>e.address===U(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 V(e){return e.seq=Number(e.seq||0)+1,{ok:!0,state:e}}function H(e){if(!e||typeof e!=`object`)return null;let t=U(e.address);return t?{address:t,name:String(e.name||me(t)).slice(0,50),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 U(e){let t=String(e||``).trim();return/^0x[a-fA-F0-9]{40}$/.test(t)?t.toLowerCase():``}function me(e){return e?`${e.slice(0,6)}...${e.slice(-4)}`:``}function W(e){return JSON.parse(JSON.stringify(e))}function he(e){let t=new Uint8Array(e);if(globalThis.crypto?.getRandomValues)globalThis.crypto.getRandomValues(t);else for(let e=0;e<t.length;e++)t[e]=Math.floor(Math.random()*256);return[...t].map(e=>e.toString(16).padStart(2,`0`)).join(``)}var G={page:`_page_1nzmd_1`,headerActions:`_headerActions_1nzmd_12`,entry:`_entry_1nzmd_18`,entryBrand:`_entryBrand_1nzmd_28`,cardMark:`_cardMark_1nzmd_34`,entryPanel:`_entryPanel_1nzmd_62`,accountLine:`_accountLine_1nzmd_72`,joinForm:`_joinForm_1nzmd_89`,status:`_status_1nzmd_110`,board:`_board_1nzmd_116`,table:`_table_1nzmd_123`,tableCenter:`_tableCenter_1nzmd_144`,finishBanner:`_finishBanner_1nzmd_173`,finishBannerIcon:`_finishBannerIcon_1nzmd_192`,seats:`_seats_1nzmd_196`,seat:`_seat_1nzmd_196`,seatTurn:`_seatTurn_1nzmd_218`,seatWinner:`_seatWinner_1nzmd_223`,seatFolded:`_seatFolded_1nzmd_228`,seatAvatar:`_seatAvatar_1nzmd_232`,seatMain:`_seatMain_1nzmd_244`,seatMeta:`_seatMeta_1nzmd_245`,panel:`_panel_1nzmd_276`,panelSection:`_panelSection_1nzmd_283`,panelTitle:`_panelTitle_1nzmd_293`,hand:`_hand_1nzmd_303`,card:`_card_1nzmd_34`,red:`_red_1nzmd_337`,black:`_black_1nzmd_341`,cardBack:`_cardBack_1nzmd_345`,handLabel:`_handLabel_1nzmd_366`,actionGrid:`_actionGrid_1nzmd_373`,raiseRow:`_raiseRow_1nzmd_374`,statusGrid:`_statusGrid_1nzmd_385`,muted:`_muted_1nzmd_403`,compareOverlay:`_compareOverlay_1nzmd_410`,compareBox:`_compareBox_1nzmd_422`,compareTitle:`_compareTitle_1nzmd_436`,comparePlayers:`_comparePlayers_1nzmd_442`,compareSide:`_compareSide_1nzmd_449`,compareWinner:`_compareWinner_1nzmd_461`,compareName:`_compareName_1nzmd_466`,compareCards:`_compareCards_1nzmd_477`,compareLabel:`_compareLabel_1nzmd_502`,compareVs:`_compareVs_1nzmd_508`,compareResult:`_compareResult_1nzmd_515`},K=n(),ge=`zhajinhua`;function q(...e){return e.filter(Boolean).join(` `)}function J(e,t){return String(e||``).toLowerCase()===String(t||``).toLowerCase()}function _e(e=``){return e?`${e.slice(0,6)}...${e.slice(-4)}`:``}function ve(e){return e.displayName||e.username}function ye(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 be(){let e=ee(e=>e.isDarkMode),t=ee(e=>e.setIsDarkMode),n=ee(e=>e.addToast),g=te(e=>e.initializeUser),[y,b]=(0,_.useState)(``),[ie,x]=(0,_.useState)(!1),S=(0,_.useRef)(``),C=(0,_.useRef)(!1),[w,T]=(0,_.useState)(20),[E,D]=(0,_.useState)(``),[ae,O]=(0,_.useState)({}),[oe,se]=(0,_.useState)(!0),[k,A]=(0,_.useState)(!1),M=(0,_.useRef)(null),N=(0,_.useRef)(new Set),I=f({gameId:ge,onError:e=>n(e,`error`),getPlayerPayload:e=>{let t=m(e.danger);return{address:e.address,name:ve(e),publicKey:t.public_key,joinedAt:Date.now()}}}),L=(0,_.useMemo)(()=>I.userIdentity?.danger?m(I.userIdentity.danger):null,[I.userIdentity?.danger]);(0,_.useEffect)(()=>{g()},[g]),(0,_.useEffect)(()=>{let e=new URLSearchParams(window.location.search).get(`room`)?.toUpperCase();e&&(b(e),S.current=e)},[]),(0,_.useEffect)(()=>{let e=S.current;!e||C.current||!I.isBackendReady||!I.userIdentity||(C.current=!0,S.current=``,I.joinRoom(e).then(e=>{e&&n(`已进入房间`,`success`)}))},[I.isBackendReady,I.userIdentity,I.joinRoom,n]),(0,_.useEffect)(()=>{if(!I.roomCode)return;let e=`/game/zhajinhua?room=${I.roomCode}`;`${window.location.pathname}${window.location.search}`!==e&&window.history.replaceState(null,``,e)},[I.roomCode]);let R=(0,_.useMemo)(()=>u(I.messages,{gameId:ge,roomCode:I.roomCode}),[I.messages,I.roomCode]),z=(0,_.useMemo)(()=>d(I.messages,{gameId:ge,roomCode:I.roomCode}),[I.messages,I.roomCode])?.payload?.round||null,B=z?.host||R.hostAddress,V=J(B,I.userIdentity?.address),H=I.userIdentity?.address?.toLowerCase()||``,U=z?.players.find(e=>J(e.address,H)),me=U||R.players.find(e=>J(e.address,H)),W=ae[z?.roundId||``]||null,he=z?.showdown&&H?z.showdown[H]:null,be=z?.compareReveal&&H?z.compareReveal[H]:null,X=he||be||(U?.looked?W:null),Z=pe(z,H),Se=F(z),Q=V&&le(R.players.map(e=>({...e,chips:z?.players.find(t=>J(t.address,e.address))?.chips??1e3}))),Ce=I.roomCode&&typeof window<`u`?`${window.location.origin}/game/zhajinhua?room=${I.roomCode}`:``;(0,_.useEffect)(()=>{if(!(!z||!I.userIdentity||!L||!B))for(let e of I.roomEvents){let t=e.event;if(!t||t.event!==`deal:private`)continue;let n=t.payload;if(n.roundId!==z.roundId||!J(n.recipient,I.userIdentity.address))continue;let r=p(n.encrypted||``,{senderPublicKey:n.senderPublicKey||``,recipientPrivateKey:L.private_key});if(r)try{let e=JSON.parse(r);Array.isArray(e)&&O(t=>({...t,[z.roundId]:e.map(String)}))}catch{}}},[z?.roundId,I.roomEvents,I.userIdentity,B,L?.private_key]),(0,_.useEffect)(()=>{if(z?.status===`finished`&&z.winner){se(!0);let e=setTimeout(()=>se(!1),5e3);return()=>clearTimeout(e)}},[z?.finishedAt,z?.status,z?.winner]),(0,_.useEffect)(()=>{if(z?.lastCompare?.timestamp){A(!0);let e=setTimeout(()=>A(!1),5e3);return()=>clearTimeout(e)}else A(!1)},[z?.lastCompare?.timestamp,z?.roundId]),(0,_.useEffect)(()=>{if(!V||!z||z.status!==`playing`)return;let e=M.current;if(!e)return;let t=I.roomEvents.filter(e=>{let t=e.event;if(!t||t.event!==`player:action`)return!1;let n=t.payload.actionEvent;return!(!n||n.roundId!==z.roundId||N.current.has(n.eventId)||z.appliedEventIds?.includes(n.eventId))});if(t.length===0)return;let n=!1;async function r(){let r=fe(z,e);if(r)for(let e of t){if(n)return;let t=(e.event?.payload).actionEvent,i=P(r,t,e.message.author);if(!i.ok){let n=e.message.author;if(!J(n,I.userIdentity?.address)&&r.status===`playing`&&J(r.turnAddress,n)){let e=P(r,j({roundId:r.roundId,action:`call`,amount:void 0,target:void 0}),n);if(e.ok)i=e;else{let e=P(r,j({roundId:r.roundId,action:`fold`,amount:void 0,target:void 0}),n);e.ok&&(i=e)}}if(!i.ok){N.current.add(t.eventId);continue}}if(r=i.state,M.current=i.state.hands,await De(i.state)&&N.current.add(t.eventId),i.state.status===`finished`)break}}return r(),()=>{n=!0}},[z?.roundId,z?.seq,z?.status,I.roomEvents,V]);async function we(){await I.createRoom()&&n(`房间已创建`,`success`)}async function Te(e){e.preventDefault(),await I.joinRoom(y)&&n(`已进入房间`,`success`)}async function Ee(){Ce&&(await navigator.clipboard.writeText(Ce),x(!0),setTimeout(()=>x(!1),1400))}async function De(e){return I.sendRoomEvent(`room:state`,{round:de(e),seq:e.seq})}async function Oe(){if(!I.userIdentity||!L||!Q){n(`至少需要 2 名有足够筹码的玩家`,`error`);return}try{let e=R.players.map(e=>({...e,chips:z?.players.find(t=>J(t.address,e.address))?.chips??1e3})),t=ue({roomCode:I.roomCode,players:e,hostAddress:I.userIdentity.address,previousSeq:z?.seq||0,previousWinner:z?.winner||``});M.current=t.hands,N.current.clear(),await De(t);for(let e of t.players){let n=ne(JSON.stringify(t.hands[e.address]),{senderPrivateKey:L.private_key,recipientPublicKey:e.publicKey});await I.sendRoomEvent(`deal:private`,{roundId:t.roundId,recipient:e.address,senderPublicKey:L.public_key,encrypted:n})}O(e=>({...e,[t.roundId]:t.hands[I.userIdentity.address.toLowerCase()]})),n(`新一局已开始`,`success`)}catch(e){n(e instanceof Error?e.message:`开局失败`,`error`)}}async function $(e,t={}){if(!z||!I.userIdentity)return;let n=j({roundId:z.roundId,action:e,amount:t.amount,target:t.target});await I.sendRoomEvent(`player:action`,{actionEvent:n})}let ke=z?.status===`playing`?J(z.turnAddress,H)?`轮到你操作`:z.turnAddress?`等待 ${Y(z.turnAddress,R.players)}`:`进行中`:z?.status===`finished`?`本局结束`:`等待开局`,Ae=Se.filter(e=>!J(e.address,H));return(0,K.jsx)(i,{sidebar:({closeSidebar:e})=>(0,K.jsx)(l,{activeGame:`zhajinhua`,closeSidebar:e}),headerTitle:(0,K.jsx)(`h2`,{className:`header-title`,children:`炸金花`}),headerRight:(0,K.jsxs)(`div`,{className:G.headerActions,children:[I.roomCode&&(0,K.jsxs)(`button`,{className:`btn btn-sm`,onClick:Ee,children:[(0,K.jsx)(r,{size:14}),ie?`已复制`:`分享房间`]}),(0,K.jsx)(`button`,{className:`btn btn-icon`,onClick:()=>t(!e),title:`切换主题`,children:e?(0,K.jsx)(o,{size:16}):(0,K.jsx)(a,{size:16})})]}),children:(0,K.jsx)(`main`,{className:G.page,children:I.roomCode?(0,K.jsxs)(`div`,{className:G.board,children:[(0,K.jsxs)(`section`,{className:G.table,children:[z?.status===`finished`&&z.winner&&oe&&(0,K.jsxs)(`div`,{className:G.finishBanner,children:[(0,K.jsx)(`span`,{className:G.finishBannerIcon,children:`🏆`}),(0,K.jsxs)(`span`,{children:[Y(z.winner,R.players),` 赢得`,` `,z.winAmount??0,` 筹码`]})]}),z?.lastCompare&&k&&(0,K.jsx)(xe,{lastCompare:z.lastCompare,compareReveal:z.compareReveal||{},myAddress:H,myDealtHand:W,lobbyPlayers:R.players,onClose:()=>A(!1)}),(0,K.jsxs)(`div`,{className:G.tableCenter,children:[(0,K.jsx)(`span`,{children:`底池`}),(0,K.jsx)(`strong`,{children:z?.pot||0}),(0,K.jsxs)(`small`,{children:[`当前注 `,z?.currentBet||0]})]}),(0,K.jsx)(`div`,{className:G.seats,children:R.players.map(e=>{let t=z?.players.find(t=>J(t.address,e.address)),n=z?.turnAddress===e.address,r=z?.winner===e.address,i=t?.status===`folded`;return(0,K.jsxs)(`div`,{className:q(G.seat,n&&G.seatTurn,r&&G.seatWinner,i&&G.seatFolded),children:[(0,K.jsx)(`div`,{className:G.seatAvatar,children:e.name.slice(0,1)}),(0,K.jsxs)(`div`,{className:G.seatMain,children:[(0,K.jsx)(`strong`,{children:e.name}),(0,K.jsx)(`span`,{children:_e(e.address)})]}),(0,K.jsxs)(`div`,{className:G.seatMeta,children:[(0,K.jsxs)(`span`,{children:[t?.chips??1e3,` 筹码`]}),(0,K.jsx)(`span`,{children:t?.status===`folded`?`已弃牌`:t?.looked?`已看牌`:z?`在局中`:`等待开局`})]})]},e.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)(c,{size:16}),(0,K.jsx)(`span`,{children:`我的手牌`})]}),(0,K.jsx)(`div`,{className:G.hand,children:X?X.map(e=>{let t=ye(e),n=`${t.suit}${t.rank}`;return(0,K.jsxs)(`div`,{className:q(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)(c,{size:18})},e))}),(0,K.jsx)(`p`,{className:G.handLabel,children:X?ce(X):W?`未看牌`:`等待房主发牌`})]}),(0,K.jsxs)(`div`,{className:G.panelSection,children:[(0,K.jsxs)(`div`,{className:G.panelTitle,children:[(0,K.jsx)(s,{size:16}),(0,K.jsx)(`span`,{children:`操作`})]}),V?(0,K.jsxs)(`button`,{className:`btn btn-primary btn-full`,onClick:Oe,disabled:!Q||z?.status===`playing`,children:[(0,K.jsx)(re,{size:16}),z?.status===`finished`?`再来一局`:`开始本局`]}):(0,K.jsx)(`p`,{className:G.muted,children:`等待房主开始或继续牌局。`}),V&&z?.status===`finished`&&!Q&&(0,K.jsx)(`p`,{className:G.muted,children:`筹码不足的玩家太多,无法开局`}),(0,K.jsxs)(`div`,{className:G.actionGrid,children:[(0,K.jsxs)(`button`,{className:`btn btn-secondary`,disabled:!Z.includes(`look`),onClick:()=>$(`look`),children:[(0,K.jsx)(h,{size:16}),`看牌`]}),(0,K.jsx)(`button`,{className:`btn btn-secondary`,disabled:!Z.includes(`call`),onClick:()=>$(`call`),children:`跟注`}),(0,K.jsx)(`button`,{className:`btn btn-secondary`,disabled:!Z.includes(`fold`),onClick:()=>$(`fold`),children:`弃牌`})]}),(0,K.jsxs)(`div`,{className:G.raiseRow,children:[(0,K.jsx)(`select`,{className:`input input-compact`,value:w,onChange:e=>T(Number(e.target.value)),children:v.map(e=>(0,K.jsxs)(`option`,{value:e,children:[`加 `,e]},e))}),(0,K.jsx)(`button`,{className:`btn btn-secondary`,disabled:!Z.includes(`raise`),onClick:()=>$(`raise`,{amount:w}),children:`加注`})]}),(0,K.jsxs)(`div`,{className:G.raiseRow,children:[(0,K.jsxs)(`select`,{className:`input input-compact`,value:E,onChange:e=>D(e.target.value),children:[(0,K.jsx)(`option`,{value:``,children:`选择比牌对象`}),Ae.map(e=>(0,K.jsx)(`option`,{value:e.address,children:e.name},e.address))]}),(0,K.jsx)(`button`,{className:`btn btn-secondary`,disabled:!Z.includes(`compare`)||!E,onClick:()=>$(`compare`,{target:E}),children:`比牌`})]})]}),(0,K.jsxs)(`div`,{className:G.panelSection,children:[(0,K.jsx)(`div`,{className:G.panelTitle,children:`状态`}),(0,K.jsxs)(`div`,{className:G.statusGrid,children:[(0,K.jsx)(`span`,{children:`房主`}),(0,K.jsx)(`strong`,{children:B?_e(B):`-`}),(0,K.jsx)(`span`,{children:`我的筹码`}),(0,K.jsx)(`strong`,{children:me?.chips??1e3}),(0,K.jsx)(`span`,{children:`本轮`}),(0,K.jsx)(`strong`,{children:ke}),(0,K.jsx)(`span`,{children:`提示`}),(0,K.jsx)(`strong`,{children:z?.lastAction||`等待玩家加入`})]})]})]})]}):(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)(c,{size:48})}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h1`,{children:`炸金花牌桌`}),(0,K.jsx)(`p`,{children:`创建房间码邀请朋友加入,房间状态通过 MostBox P2P 频道同步。`})]})]}),(0,K.jsxs)(`div`,{className:G.entryPanel,children:[(0,K.jsxs)(`div`,{className:G.accountLine,children:[(0,K.jsx)(`span`,{children:`当前账号`}),(0,K.jsx)(`strong`,{children:I.userIdentity?.displayName||`未登录`})]}),(0,K.jsxs)(`button`,{className:`btn btn-primary`,disabled:I.joining,onClick:we,children:[(0,K.jsx)(s,{size:16}),`创建房间`]}),(0,K.jsxs)(`form`,{onSubmit:Te,className:G.joinForm,children:[(0,K.jsxs)(`label`,{children:[`房间号`,(0,K.jsx)(`input`,{value:y,maxLength:8,onChange:e=>b(e.target.value.toUpperCase()),placeholder:`输入房间号`})]}),(0,K.jsx)(`button`,{className:`btn`,disabled:I.joining||!y,children:`加入房间`})]}),(0,K.jsx)(`p`,{className:G.status,children:I.isBackendReady?`节点已连接`:`正在连接节点...`})]})]})})})}function xe({lastCompare:e,compareReveal:t,myAddress:n,myDealtHand:r,lobbyPlayers:i,onClose:a}){let o=Y(e.initiator,i),s=Y(e.target,i),l=Y(e.winner,i),u=J(n,e.initiator),d=J(n,e.target),f=u||d;function p(e,i){return t[e]||(f&&J(e,n)&&i&&r?r:null)}let m=p(e.initiator,e.initiatorLooked),h=p(e.target,e.targetLooked);return(0,K.jsx)(`div`,{className:G.compareOverlay,onClick:a,children:(0,K.jsxs)(`div`,{className:G.compareBox,onClick:e=>e.stopPropagation(),children:[(0,K.jsx)(`div`,{className:G.compareTitle,children:`比牌结果`}),(0,K.jsxs)(`div`,{className:G.comparePlayers,children:[(0,K.jsxs)(`div`,{className:q(G.compareSide,J(e.winner,e.initiator)&&G.compareWinner),children:[(0,K.jsx)(`div`,{className:G.compareName,children:o}),(0,K.jsx)(`div`,{className:G.compareCards,children:m?m.map(e=>{let t=ye(e);return(0,K.jsxs)(`div`,{className:q(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)(c,{size:18})},e))}),m&&(0,K.jsx)(`div`,{className:G.compareLabel,children:ce(m)})]}),(0,K.jsx)(`div`,{className:G.compareVs,children:`VS`}),(0,K.jsxs)(`div`,{className:q(G.compareSide,J(e.winner,e.target)&&G.compareWinner),children:[(0,K.jsx)(`div`,{className:G.compareName,children:s}),(0,K.jsx)(`div`,{className:G.compareCards,children:h?h.map(e=>{let t=ye(e);return(0,K.jsxs)(`div`,{className:q(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)(c,{size:18})},e))}),h&&(0,K.jsx)(`div`,{className:G.compareLabel,children:ce(h)})]})]}),(0,K.jsxs)(`div`,{className:G.compareResult,children:[l,` 胜出`]}),(0,K.jsx)(`button`,{className:`btn btn-sm`,onClick:a,children:`关闭`})]})})}function Y(e,t){let n=e.toLowerCase();return t.find(e=>e.address===n)?.name||_e(e)}var X=be;export{X as component};
Binary file
Binary file