most-box 0.2.2 → 0.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -26
- package/electron/main.js +366 -30
- package/electron/preload.js +16 -1
- package/electron/updateChecker.js +18 -11
- package/electron/updateChecker.test.js +23 -7
- package/out/admin/index.html +0 -0
- package/out/app/index.html +0 -0
- package/out/assets/AppShell-gILTcRs-.js +1 -0
- package/out/assets/FilePreviewOverlay-CM-fcIaD.js +1 -0
- package/out/assets/LanguageToggle-B99eQcTE.js +1 -0
- package/out/assets/MarketingHeader-Q2cpkqAM.js +1 -0
- package/out/assets/MarketingLayout-X3Nj2JvA.js +1 -0
- package/out/assets/{MarketingThemeToggle-C6fggkl7.js → MarketingThemeToggle-z4jr4-vt.js} +1 -1
- package/out/assets/{MilkdownEditor-Cfze75zl.js → MilkdownEditor-Bv2VA3bu.js} +1 -1
- package/out/assets/{OpenSidebarButton-DDuALgJ2.js → OpenSidebarButton-CaQJk5LD.js} +1 -1
- package/out/assets/{SidebarAccount-bo1ypzrJ.js → SidebarAccount-CpNVqNva.js} +1 -1
- package/out/assets/arrow-right-mNO53HQi.js +1 -0
- package/out/assets/{circle-alert-BQoSDxUe.js → circle-alert-CofRTRHr.js} +1 -1
- package/out/assets/cloud-DAGFCFIp.js +1 -0
- package/out/assets/{copy-BtJHJnqH.js → copy-5aEv78Eq.js} +1 -1
- package/out/assets/{download-Bg-OdoxM.js → download-Bhqn6hL1.js} +1 -1
- package/out/assets/{downloadValidation-CUvbvj9f.js → downloadValidation-xzpa5rap.js} +1 -1
- package/out/assets/{external-link-m8ZIQe4p.js → external-link-CNR21yFA.js} +1 -1
- package/out/assets/{file-text-DG1orIkZ.js → file-text-CFfvvCnM.js} +1 -1
- package/out/assets/folder-BGJCjyba.js +1 -0
- package/out/assets/{hard-drive-BB-sllXA.js → hard-drive-4vHpA5kz.js} +1 -1
- package/out/assets/index-CgErXULe.css +1 -0
- package/out/assets/index-DN0kD5zr.js +31 -0
- package/out/assets/{index.lazy-BTndBeBF.js → index.lazy-0DsJzEoI.js} +1 -1
- package/out/assets/{index.lazy-DfsgyiMN.js → index.lazy-CJBRtbWA.js} +1 -1
- package/out/assets/{index.lazy-DejOniAm.js → index.lazy-CPV-dZxo.js} +1 -1
- package/out/assets/{index.lazy-DVOcrcEB.js → index.lazy-CQavt0-9.js} +2 -2
- package/out/assets/index.lazy-CUq9lbK_.js +1 -0
- package/out/assets/index.lazy-CxpNXlwa.js +1 -0
- package/out/assets/index.lazy-DOgKxDuF.js +1 -0
- package/out/assets/index.lazy-Dzf-q-Vf.js +1 -0
- package/out/assets/index.lazy-GtegOPkJ.js +2 -0
- package/out/assets/index.lazy-H7NATHUs.js +1 -0
- package/out/assets/index.lazy-b_N8nrYw.js +1 -0
- package/out/assets/index.lazy-erexqght.js +3 -0
- package/out/assets/index.lazy-s3nUpCQ1.js +1 -0
- package/out/assets/{key-round-DIQ3Xt5F.js → key-round-BpSdpOHi.js} +1 -1
- package/out/assets/loader-ByMmV2_4.js +1 -0
- package/out/assets/{lock-tf1t2yuy.js → lock-C0pdaery.js} +1 -1
- package/out/assets/{message-square-DaQH7q-P.js → message-square-Eu86zZup.js} +1 -1
- package/out/assets/{mp-DvFTsIL9.js → mp-DjXDNjls.js} +1 -1
- package/out/assets/{music-DaFvU2DL.js → music-Btrhub6z.js} +1 -1
- package/out/assets/{notebook-pen-CqEFOHKx.js → notebook-pen-CfdFgaDE.js} +1 -1
- package/out/assets/play-D5r9Yvbq.js +1 -0
- package/out/assets/plus-Mlh7r_bm.js +1 -0
- package/out/assets/{refresh-cw-roxAhABl.js → refresh-cw--JB8k6mH.js} +1 -1
- package/out/assets/{save-DR0O9ReR.js → save-DN4eprSt.js} +1 -1
- package/out/assets/search-CbzMyENy.js +1 -0
- package/out/assets/{send-m1XCcuPn.js → send-D8p6f8OD.js} +1 -1
- package/out/assets/{shield-check-BwcvTU4U.js → shield-check-c0labdRH.js} +1 -1
- package/out/assets/{trash-2-CNpsqYc1.js → trash-2-zdhWec_U.js} +1 -1
- package/out/assets/{triangle-alert-DP9EP7IM.js → triangle-alert-D-qigSSn.js} +1 -1
- package/out/assets/upload-BD23c5Pz.js +1 -0
- package/out/assets/{useChannelMessages-46C52EyL.js → useChannelMessages-DS1ntAKN.js} +2 -2
- package/out/assets/useGameRoom-BSPkCY3n.js +1 -0
- package/out/assets/userProfile-BmzBA_Bk.js +1 -0
- package/out/assets/{userStore-C4vdYsQp.js → userStore-q0BBZsIV.js} +1 -1
- package/out/assets/{wallet-CozFU6yK.js → wallet-DmZMdK9A.js} +1 -1
- package/out/assets/{wifi-DIR3g_8A.js → wifi-CVqaPDcv.js} +1 -1
- package/out/chat/index.html +0 -0
- package/out/chat/join/index.html +0 -0
- package/out/download/index.html +2 -2
- package/out/game/gandengyan/index.html +0 -0
- package/out/game/index.html +0 -0
- package/out/game/zhajinhua/index.html +0 -0
- package/out/index.html +2 -2
- package/out/note/index.html +0 -0
- package/out/ping/index.html +2 -2
- package/out/profile/index.html +0 -0
- package/out/web3/index.html +0 -0
- package/package.json +8 -1
- package/server/index.js +2 -2
- package/server/src/core/syncTimestamp.js +10 -0
- package/server/src/http/nodeStatus.js +16 -16
- package/server/src/http/routePolicy.js +2 -2
- package/server/src/http/routes/nodeRoutes.js +21 -19
- package/server/src/index.js +578 -960
- package/server/src/utils/accountBackup.js +134 -0
- package/server/src/utils/api.js +27 -1
- package/out/assets/AppShell-BOtfY12t.js +0 -1
- package/out/assets/FilePreviewOverlay-C5qK9HAE.js +0 -1
- package/out/assets/LanguageToggle-Di5b88mK.js +0 -1
- package/out/assets/MarketingHeader-BOytKcCc.js +0 -1
- package/out/assets/MarketingLayout-B8m1Q7Pa.js +0 -1
- package/out/assets/arrow-right-RldN7Rwi.js +0 -1
- package/out/assets/cloud-DHoTMeZY.js +0 -1
- package/out/assets/index-C0xqKeu-.css +0 -1
- package/out/assets/index-CrAXrmfP.js +0 -31
- package/out/assets/index.lazy-0Njp0U6I.js +0 -1
- package/out/assets/index.lazy-Bq39jYTl.js +0 -1
- package/out/assets/index.lazy-Bu93oGzJ.js +0 -2
- package/out/assets/index.lazy-BvdBwgHx.js +0 -1
- package/out/assets/index.lazy-CIx8ist6.js +0 -3
- package/out/assets/index.lazy-DK7R297q.js +0 -1
- package/out/assets/index.lazy-DpNIiSXF.js +0 -1
- package/out/assets/index.lazy-Vnvz-t7T.js +0 -1
- package/out/assets/index.lazy-v7nBJ-sF.js +0 -1
- package/out/assets/play-B7q6F75-.js +0 -1
- package/out/assets/plus-H2i2mspM.js +0 -1
- package/out/assets/search-ncblG-zw.js +0 -1
- package/out/assets/upload-V--8p13l.js +0 -1
- package/out/assets/useGameRoom-BtxPpfck.js +0 -1
- package/server/src/core/userSyncKeys.js +0 -36
- package/server/src/utils/noteBackup.js +0 -116
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e,o as t,t as n}from"./jsx-runtime-Bt-cYkS5.js";import{a as r,g as i,i as a,r as o,t as s,v as c}from"./userStore-q0BBZsIV.js";import{i as l,r as u}from"./LanguageToggle-B99eQcTE.js";import{t as d}from"./copy-5aEv78Eq.js";import{t as f}from"./AppShell-gILTcRs-.js";import{t as p}from"./play-D5r9Yvbq.js";import{a as m,i as h,n as g,r as ee,t as te}from"./useGameRoom-BSPkCY3n.js";import{I as ne,i as re,j as ie,m as _}from"./index-DN0kD5zr.js";var ae=i(`refresh-ccw`,[[`path`,{d:`M21 12a9 9 0 0 0-9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`14sxne`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}],[`path`,{d:`M3 12a9 9 0 0 0 9 9 9.75 9.75 0 0 0 6.74-2.74L21 16`,key:`1hlbsb`}],[`path`,{d:`M16 16h5v5`,key:`ccwih5`}]]),v=t(e(),1),oe=[10,20,50,100],y=[`2`,`3`,`4`,`5`,`6`,`7`,`8`,`9`,`10`,`J`,`Q`,`K`,`A`],b=[`D`,`C`,`H`,`S`],x=new Map(y.map((e,t)=>[e,t+2])),S=new Map(b.map((e,t)=>[e,t+1])),C={high:1,pair:2,straight:3,flush:4,straightFlush:5,triple:6},w={[C.high]:`散牌`,[C.pair]:`对子`,[C.straight]:`顺子`,[C.flush]:`金花`,[C.straightFlush]:`顺金`,[C.triple]:`豹子`};function T(e){return String(e||``).trim().toUpperCase().replace(/[^A-Z0-9]/g,``).slice(0,8)}function E(e=`zhajinhua`){return`${e}_${Date.now()}_${ve(4)}`}function D(){return E(`round`)}function O(){let e=[];for(let t of b)for(let n of y)e.push(`${n}${t}`);return e}function se(e=O(),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 k(e){let t=String(e||``).trim().toUpperCase(),n=t.slice(-1),r=t.slice(0,-1);if(!x.has(r)||!S.has(n))throw Error(`Invalid card: ${e}`);return{id:`${r}${n}`,rank:r,suit:n,rankValue:x.get(r),suitValue:S.get(n)}}function ce(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 le(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 A(e){if(!Array.isArray(e)||e.length!==3)throw Error(`炸金花手牌必须是 3 张牌`);let t=e.map(k),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=le(n),o=[...n].sort((e,t)=>t-e),s=Math.max(...t.map(e=>e.suitValue)),c=C.high,l=o;return r.size===1?(c=C.triple,l=[o[0]]):a&&i?(c=C.straightFlush,l=[a]):i?(c=C.flush,l=o):a?(c=C.straight,l=[a]):r.size===2&&(c=C.pair,l=[[...r.entries()].find(([,e])=>e===2)[0],[...r.entries()].find(([,e])=>e===1)[0]]),{category:c,label:w[c],tiebreakers:l,tieSuit:s,cards:t.map(e=>e.id)}}function j(e,t){let n=A(e),r=A(t);if(n.category!==r.category)return n.category-r.category;let i=ce(n.tiebreakers,r.tiebreakers);return i===0?n.tieSuit-r.tieSuit:i}function ue(e){return A(e).label}function de({roundId:e,action:t,amount:n,target:r}){return{roundId:e,eventId:E(`action`),action:t,amount:n,target:r}}function fe(e=[]){let t=e.filter(e=>Number(e.chips)>=10);return t.length>=2&&t.length<=5}function pe({roomCode:e,players:t,hostAddress:n,previousSeq:r=0,previousWinner:i=``,roundId:a=D(),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=se(O(),o),l={},u=s.map((e,t)=>{let n=c.slice(t*3,t*3+3);return l[e.address]=n,{address:e.address,name:e.name,avatar:W(e.avatar),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:T(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 me(e){if(!e)return null;let t={...e};return delete t.hands,G(t)}function he(e,t){let n=M(e);return!n||!t||typeof t!=`object`?null:{...n,hands:G(t)}}function M(e){return!e||typeof e!=`object`||!e.roundId||!Array.isArray(e.players)?null:{roomCode:T(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`?G(e.showdown):null,appliedEventIds:Array.isArray(e.appliedEventIds)?e.appliedEventIds.map(String):[],actionCounts:e.actionCounts&&typeof e.actionCounts==`object`?G(e.actionCounts):{},compareReveal:e.compareReveal&&typeof e.compareReveal==`object`?G(e.compareReveal):{},lastCompare:e.lastCompare&&typeof e.lastCompare==`object`?G(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(!oe.includes(e))return{ok:!1,error:`加注档位无效`};let n=r.currentBet+e-a.bet;return a.chips>=n?{ok:!0}:{ok:!1,error:`筹码不足,不能加注`}}if(o===`compare`){let e=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=G(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=j(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 ge(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`),oe.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?G(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||_e(t)).slice(0,50),avatar:W(e.avatar),publicKey:String(e.publicKey||``),chips:Math.max(0,Number(e.chips)||0),status:e.status===`folded`?`folded`:`active`,looked:e.looked===!0,bet:Math.max(0,Number(e.bet)||0)}:null}function U(e){let t=String(e||``).trim();return/^0x[a-fA-F0-9]{40}$/.test(t)?t.toLowerCase():``}function _e(e){return e?`${e.slice(0,6)}...${e.slice(-4)}`:``}function W(e){return String(e||``).trim().slice(0,4096)}function G(e){return JSON.parse(JSON.stringify(e))}function ve(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 K={page:`_page_1yyew_1`,headerActions:`_headerActions_1yyew_12`,entry:`_entry_1yyew_18`,entryBrand:`_entryBrand_1yyew_28`,cardMark:`_cardMark_1yyew_34`,entryPanel:`_entryPanel_1yyew_62`,accountLine:`_accountLine_1yyew_72`,joinForm:`_joinForm_1yyew_89`,status:`_status_1yyew_110`,board:`_board_1yyew_116`,table:`_table_1yyew_123`,tableCenter:`_tableCenter_1yyew_144`,finishBanner:`_finishBanner_1yyew_173`,finishBannerIcon:`_finishBannerIcon_1yyew_192`,seats:`_seats_1yyew_196`,seat:`_seat_1yyew_196`,seatTurn:`_seatTurn_1yyew_218`,seatWinner:`_seatWinner_1yyew_223`,seatFolded:`_seatFolded_1yyew_228`,seatAvatar:`_seatAvatar_1yyew_232`,seatMain:`_seatMain_1yyew_251`,seatMeta:`_seatMeta_1yyew_252`,panel:`_panel_1yyew_283`,panelSection:`_panelSection_1yyew_290`,panelTitle:`_panelTitle_1yyew_300`,hand:`_hand_1yyew_310`,card:`_card_1yyew_34`,red:`_red_1yyew_344`,black:`_black_1yyew_348`,cardBack:`_cardBack_1yyew_352`,handLabel:`_handLabel_1yyew_373`,actionGrid:`_actionGrid_1yyew_380`,raiseRow:`_raiseRow_1yyew_381`,statusGrid:`_statusGrid_1yyew_392`,muted:`_muted_1yyew_410`,compareOverlay:`_compareOverlay_1yyew_417`,compareBox:`_compareBox_1yyew_429`,compareTitle:`_compareTitle_1yyew_443`,comparePlayers:`_comparePlayers_1yyew_449`,compareSide:`_compareSide_1yyew_456`,compareWinner:`_compareWinner_1yyew_468`,compareName:`_compareName_1yyew_473`,compareCards:`_compareCards_1yyew_484`,compareLabel:`_compareLabel_1yyew_509`,compareVs:`_compareVs_1yyew_515`,compareResult:`_compareResult_1yyew_522`},q=n(),ye=`zhajinhua`;function J(...e){return e.filter(Boolean).join(` `)}function Y(e,t){return String(e||``).toLowerCase()===String(t||``).toLowerCase()}function be(e=``){return e?`${e.slice(0,6)}...${e.slice(-4)}`:``}function xe(e){return e.displayName||e.username}function Se(e){let t=String(e||``),n=t.slice(-1);return{rank:t.slice(0,-1),suit:{S:`♠`,H:`♥`,C:`♣`,D:`♦`}[n]||n,color:n===`H`||n===`D`?`red`:`black`}}function X(){let{t:e}=ne(),t=_(e=>e.isDarkMode),n=_(e=>e.setIsDarkMode),i=_(e=>e.addToast),c=s(e=>e.initializeUser),[y,b]=(0,v.useState)(``),[x,S]=(0,v.useState)(!1),C=(0,v.useRef)(``),w=(0,v.useRef)(!1),[T,E]=(0,v.useState)(20),[D,O]=(0,v.useState)(``),[se,k]=(0,v.useState)({}),[ce,le]=(0,v.useState)(!0),[A,j]=(0,v.useState)(!1),M=(0,v.useRef)(null),N=(0,v.useRef)(new Set),I=te({gameId:ye,onError:e=>i(e,`error`),getPlayerPayload:e=>{let t=o(e.danger);return{address:e.address,name:xe(e),avatar:e.avatar||``,publicKey:t.public_key,joinedAt:Date.now()}}}),L=(0,v.useMemo)(()=>I.userIdentity?.danger?o(I.userIdentity.danger):null,[I.userIdentity?.danger]);(0,v.useEffect)(()=>{c()},[c]),(0,v.useEffect)(()=>{let e=new URLSearchParams(window.location.search).get(`room`)?.toUpperCase();e&&(b(e),C.current=e)},[]),(0,v.useEffect)(()=>{let t=C.current;!t||w.current||!I.isBackendReady||!I.userIdentity||(w.current=!0,C.current=``,I.joinRoom(t).then(t=>{t&&i(e(`game.toast.joinedRoom`),`success`)}))},[I.isBackendReady,I.userIdentity,I.joinRoom,i,e]),(0,v.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,v.useMemo)(()=>g(I.messages,{gameId:ye,roomCode:I.roomCode}),[I.messages,I.roomCode]),z=(0,v.useMemo)(()=>ee(I.messages,{gameId:ye,roomCode:I.roomCode}),[I.messages,I.roomCode])?.payload?.round||null,B=z?.host||R.hostAddress,V=Y(B,I.userIdentity?.address),H=I.userIdentity?.address?.toLowerCase()||``,U=z?.players.find(e=>Y(e.address,H)),_e=U||R.players.find(e=>Y(e.address,H)),W=se[z?.roundId||``]||null,G=z?.showdown&&H?z.showdown[H]:null,ve=z?.compareReveal&&H?z.compareReveal[H]:null,X=G||ve||(U?.looked?W:null),Q=ge(z,H),we=F(z),Te=V&&fe(R.players.map(e=>({...e,chips:z?.players.find(t=>Y(t.address,e.address))?.chips??1e3}))),Ee=I.roomCode&&typeof window<`u`?`${window.location.origin}/game/zhajinhua?room=${I.roomCode}`:``;(0,v.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||!Y(n.recipient,I.userIdentity.address))continue;let r=a(n.encrypted||``,{senderPublicKey:n.senderPublicKey||``,recipientPrivateKey:L.private_key});if(r)try{let e=JSON.parse(r);Array.isArray(e)&&k(t=>({...t,[z.roundId]:e.map(String)}))}catch{}}},[z?.roundId,I.roomEvents,I.userIdentity,B,L?.private_key]),(0,v.useEffect)(()=>{if(z?.status===`finished`&&z.winner){le(!0);let e=setTimeout(()=>le(!1),5e3);return()=>clearTimeout(e)}},[z?.finishedAt,z?.status,z?.winner]),(0,v.useEffect)(()=>{if(z?.lastCompare?.timestamp){j(!0);let e=setTimeout(()=>j(!1),5e3);return()=>clearTimeout(e)}else j(!1)},[z?.lastCompare?.timestamp,z?.roundId]),(0,v.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=he(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(!Y(n,I.userIdentity?.address)&&r.status===`playing`&&Y(r.turnAddress,n)){let e=P(r,de({roundId:r.roundId,action:`call`,amount:void 0,target:void 0}),n);if(e.ok)i=e;else{let e=P(r,de({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 Ae(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 De(){await I.createRoom()&&i(e(`game.toast.roomCreated`),`success`)}async function Oe(t){t.preventDefault(),await I.joinRoom(y)&&i(e(`game.toast.joinedRoom`),`success`)}async function ke(){Ee&&(await navigator.clipboard.writeText(Ee),S(!0),setTimeout(()=>S(!1),1400))}async function Ae(e){return I.sendRoomEvent(`room:state`,{round:me(e),seq:e.seq})}async function je(){if(!I.userIdentity||!L||!Te){i(e(`game.zhajinhua.error.notEnoughPlayers`),`error`);return}try{let t=R.players.map(e=>({...e,chips:z?.players.find(t=>Y(t.address,e.address))?.chips??1e3})),n=pe({roomCode:I.roomCode,players:t,hostAddress:I.userIdentity.address,previousSeq:z?.seq||0,previousWinner:z?.winner||``});M.current=n.hands,N.current.clear(),await Ae(n);for(let e of n.players){let t=r(JSON.stringify(n.hands[e.address]),{senderPrivateKey:L.private_key,recipientPublicKey:e.publicKey});await I.sendRoomEvent(`deal:private`,{roundId:n.roundId,recipient:e.address,senderPublicKey:L.public_key,encrypted:t})}k(e=>({...e,[n.roundId]:n.hands[I.userIdentity.address.toLowerCase()]})),i(e(`game.zhajinhua.toast.roundStarted`),`success`)}catch(t){i(t instanceof Error?t.message:e(`game.zhajinhua.error.startFailed`),`error`)}}async function $(e,t={}){if(!z||!I.userIdentity)return;let n=de({roundId:z.roundId,action:e,amount:t.amount,target:t.target});await I.sendRoomEvent(`player:action`,{actionEvent:n})}let Me=z?.status===`playing`?Y(z.turnAddress,H)?e(`game.zhajinhua.status.yourTurn`):z.turnAddress?e(`game.zhajinhua.status.waitingPlayer`,{player:Z(z.turnAddress,R.players)}):e(`game.status.playing`):z?.status===`finished`?e(`game.status.finished`):e(`game.status.waitingStart`),Ne=we.filter(e=>!Y(e.address,H));return(0,q.jsx)(f,{sidebar:({closeSidebar:e})=>(0,q.jsx)(h,{activeGame:`zhajinhua`,closeSidebar:e}),headerTitle:(0,q.jsx)(`h2`,{className:`header-title`,children:e(`game.zhajinhua.title`)}),headerRight:(0,q.jsxs)(`div`,{className:K.headerActions,children:[I.roomCode&&(0,q.jsxs)(`button`,{className:`btn btn-sm`,onClick:ke,children:[(0,q.jsx)(d,{size:14}),e(x?`common.copied`:`game.action.shareRoom`)]}),(0,q.jsx)(`button`,{className:`btn btn-icon`,onClick:()=>n(!t),title:e(`common.theme.toggle`),children:t?(0,q.jsx)(u,{size:16}):(0,q.jsx)(l,{size:16})})]}),children:(0,q.jsx)(`main`,{className:K.page,children:I.roomCode?(0,q.jsxs)(`div`,{className:K.board,children:[(0,q.jsxs)(`section`,{className:K.table,children:[z?.status===`finished`&&z.winner&&ce&&(0,q.jsxs)(`div`,{className:K.finishBanner,children:[(0,q.jsx)(`span`,{className:K.finishBannerIcon,children:`🏆`}),(0,q.jsx)(`span`,{children:e(`game.zhajinhua.result.winChips`,{player:Z(z.winner,R.players),amount:z.winAmount??0})})]}),z?.lastCompare&&A&&(0,q.jsx)(Ce,{lastCompare:z.lastCompare,compareReveal:z.compareReveal||{},myAddress:H,myDealtHand:W,lobbyPlayers:R.players,onClose:()=>j(!1)}),(0,q.jsxs)(`div`,{className:K.tableCenter,children:[(0,q.jsx)(`span`,{children:e(`game.zhajinhua.pot`)}),(0,q.jsx)(`strong`,{children:z?.pot||0}),(0,q.jsx)(`small`,{children:e(`game.zhajinhua.currentBet`,{amount:z?.currentBet||0})})]}),(0,q.jsx)(`div`,{className:K.seats,children:R.players.map(t=>{let n=z?.players.find(e=>Y(e.address,t.address)),r=z?.turnAddress===t.address,i=z?.winner===t.address,a=n?.status===`folded`;return(0,q.jsxs)(`div`,{className:J(K.seat,r&&K.seatTurn,i&&K.seatWinner,a&&K.seatFolded),children:[(0,q.jsx)(`div`,{className:K.seatAvatar,children:(0,q.jsx)(`img`,{src:re(t.address,t.avatar),alt:``})}),(0,q.jsxs)(`div`,{className:K.seatMain,children:[(0,q.jsx)(`strong`,{translate:`no`,children:t.name}),(0,q.jsx)(`span`,{translate:`no`,children:be(t.address)})]}),(0,q.jsxs)(`div`,{className:K.seatMeta,children:[(0,q.jsx)(`span`,{children:e(`game.zhajinhua.chips`,{amount:n?.chips??1e3})}),(0,q.jsx)(`span`,{children:n?.status===`folded`?e(`game.zhajinhua.player.folded`):n?.looked?e(`game.zhajinhua.player.looked`):e(z?`game.zhajinhua.player.inRound`:`game.status.waitingStart`)})]})]},t.address)})})]}),(0,q.jsxs)(`aside`,{className:K.panel,children:[(0,q.jsxs)(`div`,{className:K.panelSection,children:[(0,q.jsxs)(`div`,{className:K.panelTitle,children:[(0,q.jsx)(m,{size:16}),(0,q.jsx)(`span`,{children:e(`game.zhajinhua.myHand`)})]}),(0,q.jsx)(`div`,{className:K.hand,children:X?X.map(e=>{let t=Se(e),n=`${t.suit}${t.rank}`;return(0,q.jsxs)(`div`,{className:J(K.card,K[t.color]),children:[(0,q.jsx)(`span`,{children:n}),(0,q.jsx)(`i`,{children:t.suit})]},e)}):[0,1,2].map(e=>(0,q.jsx)(`div`,{className:K.cardBack,children:(0,q.jsx)(m,{size:18})},e))}),(0,q.jsx)(`p`,{className:K.handLabel,children:X?ue(X):e(W?`game.zhajinhua.hand.unlooked`:`game.zhajinhua.hand.waitingDeal`)})]}),(0,q.jsxs)(`div`,{className:K.panelSection,children:[(0,q.jsxs)(`div`,{className:K.panelTitle,children:[(0,q.jsx)(p,{size:16}),(0,q.jsx)(`span`,{children:e(`game.actions`)})]}),V?(0,q.jsxs)(`button`,{className:`btn btn-primary btn-full`,onClick:je,disabled:!Te||z?.status===`playing`,children:[(0,q.jsx)(ae,{size:16}),z?.status===`finished`?e(`game.action.nextRound`):e(`game.action.startRound`)]}):(0,q.jsx)(`p`,{className:K.muted,children:e(`game.waitingHost`)}),V&&z?.status===`finished`&&!Te&&(0,q.jsx)(`p`,{className:K.muted,children:e(`game.zhajinhua.error.tooManyLowChips`)}),(0,q.jsxs)(`div`,{className:K.actionGrid,children:[(0,q.jsxs)(`button`,{className:`btn btn-secondary`,disabled:!Q.includes(`look`),onClick:()=>$(`look`),children:[(0,q.jsx)(ie,{size:16}),e(`game.zhajinhua.action.look`)]}),(0,q.jsx)(`button`,{className:`btn btn-secondary`,disabled:!Q.includes(`call`),onClick:()=>$(`call`),children:e(`game.zhajinhua.action.call`)}),(0,q.jsx)(`button`,{className:`btn btn-secondary`,disabled:!Q.includes(`fold`),onClick:()=>$(`fold`),children:e(`game.zhajinhua.action.fold`)})]}),(0,q.jsxs)(`div`,{className:K.raiseRow,children:[(0,q.jsx)(`select`,{className:`input input-compact`,value:T,onChange:e=>E(Number(e.target.value)),children:oe.map(t=>(0,q.jsx)(`option`,{value:t,children:e(`game.zhajinhua.action.raiseOption`,{amount:t})},t))}),(0,q.jsx)(`button`,{className:`btn btn-secondary`,disabled:!Q.includes(`raise`),onClick:()=>$(`raise`,{amount:T}),children:e(`game.zhajinhua.action.raise`)})]}),(0,q.jsxs)(`div`,{className:K.raiseRow,children:[(0,q.jsxs)(`select`,{className:`input input-compact`,value:D,onChange:e=>O(e.target.value),children:[(0,q.jsx)(`option`,{value:``,children:e(`game.zhajinhua.action.comparePlaceholder`)}),Ne.map(e=>(0,q.jsx)(`option`,{value:e.address,children:e.name},e.address))]}),(0,q.jsx)(`button`,{className:`btn btn-secondary`,disabled:!Q.includes(`compare`)||!D,onClick:()=>$(`compare`,{target:D}),children:e(`game.zhajinhua.action.compare`)})]})]}),(0,q.jsxs)(`div`,{className:K.panelSection,children:[(0,q.jsx)(`div`,{className:K.panelTitle,children:e(`game.status.title`)}),(0,q.jsxs)(`div`,{className:K.statusGrid,children:[(0,q.jsx)(`span`,{children:e(`game.host`)}),(0,q.jsx)(`strong`,{children:B?be(B):`-`}),(0,q.jsx)(`span`,{children:e(`game.zhajinhua.myChips`)}),(0,q.jsx)(`strong`,{children:_e?.chips??1e3}),(0,q.jsx)(`span`,{children:e(`game.round`)}),(0,q.jsx)(`strong`,{children:Me}),(0,q.jsx)(`span`,{children:e(`game.hint`)}),(0,q.jsx)(`strong`,{children:z?.lastAction||e(`game.waitingPlayers`)})]})]})]})]}):(0,q.jsxs)(`section`,{className:K.entry,children:[(0,q.jsxs)(`div`,{className:K.entryBrand,children:[(0,q.jsx)(`div`,{className:K.cardMark,children:(0,q.jsx)(m,{size:48})}),(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`h1`,{children:e(`game.zhajinhua.hero.title`)}),(0,q.jsx)(`p`,{children:e(`game.hero.desc`)})]})]}),(0,q.jsxs)(`div`,{className:K.entryPanel,children:[(0,q.jsxs)(`div`,{className:K.accountLine,children:[(0,q.jsx)(`span`,{children:e(`game.currentAccount`)}),(0,q.jsx)(`strong`,{translate:`no`,children:I.userIdentity?.displayName||e(`web3.notSignedIn`)})]}),(0,q.jsxs)(`button`,{className:`btn btn-primary`,disabled:I.joining,onClick:De,children:[(0,q.jsx)(p,{size:16}),e(`game.action.createRoom`)]}),(0,q.jsxs)(`form`,{onSubmit:Oe,className:K.joinForm,children:[(0,q.jsxs)(`label`,{children:[e(`game.roomCode`),(0,q.jsx)(`input`,{value:y,maxLength:8,onChange:e=>b(e.target.value.toUpperCase()),placeholder:e(`game.roomCode.placeholder`)})]}),(0,q.jsx)(`button`,{className:`btn`,disabled:I.joining||!y,children:e(`game.action.joinRoom`)})]}),(0,q.jsx)(`p`,{className:K.status,children:I.isBackendReady?e(`game.status.nodeConnected`):e(`game.status.nodeConnecting`)})]})]})})})}function Ce({lastCompare:e,compareReveal:t,myAddress:n,myDealtHand:r,lobbyPlayers:i,onClose:a}){let{t:o}=ne(),s=Z(e.initiator,i),c=Z(e.target,i),l=Z(e.winner,i),u=Y(n,e.initiator),d=Y(n,e.target),f=u||d;function p(e,i){return t[e]||(f&&Y(e,n)&&i&&r?r:null)}let h=p(e.initiator,e.initiatorLooked),g=p(e.target,e.targetLooked);return(0,q.jsx)(`div`,{className:K.compareOverlay,onClick:a,children:(0,q.jsxs)(`div`,{className:K.compareBox,onClick:e=>e.stopPropagation(),children:[(0,q.jsx)(`div`,{className:K.compareTitle,children:o(`game.zhajinhua.compareResult`)}),(0,q.jsxs)(`div`,{className:K.comparePlayers,children:[(0,q.jsxs)(`div`,{className:J(K.compareSide,Y(e.winner,e.initiator)&&K.compareWinner),children:[(0,q.jsx)(`div`,{className:K.compareName,children:s}),(0,q.jsx)(`div`,{className:K.compareCards,children:h?h.map(e=>{let t=Se(e);return(0,q.jsxs)(`div`,{className:J(K.card,K[t.color]),children:[(0,q.jsx)(`span`,{children:t.rank}),(0,q.jsx)(`i`,{children:t.suit})]},e)}):[0,1,2].map(e=>(0,q.jsx)(`div`,{className:K.cardBack,children:(0,q.jsx)(m,{size:18})},e))}),h&&(0,q.jsx)(`div`,{className:K.compareLabel,children:ue(h)})]}),(0,q.jsx)(`div`,{className:K.compareVs,children:`VS`}),(0,q.jsxs)(`div`,{className:J(K.compareSide,Y(e.winner,e.target)&&K.compareWinner),children:[(0,q.jsx)(`div`,{className:K.compareName,children:c}),(0,q.jsx)(`div`,{className:K.compareCards,children:g?g.map(e=>{let t=Se(e);return(0,q.jsxs)(`div`,{className:J(K.card,K[t.color]),children:[(0,q.jsx)(`span`,{children:t.rank}),(0,q.jsx)(`i`,{children:t.suit})]},e)}):[0,1,2].map(e=>(0,q.jsx)(`div`,{className:K.cardBack,children:(0,q.jsx)(m,{size:18})},e))}),g&&(0,q.jsx)(`div`,{className:K.compareLabel,children:ue(g)})]})]}),(0,q.jsx)(`div`,{className:K.compareResult,children:o(`game.zhajinhua.result.winner`,{player:l})}),(0,q.jsx)(`button`,{className:`btn btn-sm`,onClick:a,children:o(`common.close`)})]})})}function Z(e,t){let n=e.toLowerCase();return t.find(e=>e.address===n)?.name||be(e)}var Q=c(`/game/zhajinhua/`)({component:X});export{Q as Route};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/MilkdownEditor-Bv2VA3bu.js","assets/jsx-runtime-Bt-cYkS5.js","assets/index-DN0kD5zr.js","assets/userStore-q0BBZsIV.js","assets/useNavigate-DWlBD_-b.js","assets/index-CgErXULe.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{g as r,o as i,s as ee,t as a,v as o}from"./userStore-q0BBZsIV.js";import{n as s}from"./useNavigate-DWlBD_-b.js";import{i as te,r as c}from"./LanguageToggle-B99eQcTE.js";import{n as l,t as u}from"./lock-C0pdaery.js";import{n as d,t as ne}from"./folder-BGJCjyba.js";import{t as f}from"./file-text-CFfvvCnM.js";import{t as re}from"./AppShell-gILTcRs-.js";import{t as p}from"./notebook-pen-CfdFgaDE.js";import{t as m}from"./OpenSidebarButton-CaQJk5LD.js";import{t as h}from"./plus-Mlh7r_bm.js";import{t as g}from"./save-DN4eprSt.js";import{t as ie}from"./search-CbzMyENy.js";import{t as ae}from"./trash-2-zdhWec_U.js";import{E as _,I as oe,N as v,O as y,T as b,d as se,j as ce,k as le,l as ue,m as x,t as S,u as de,w as fe,z as pe}from"./index-DN0kD5zr.js";import{t as me}from"./SidebarAccount-CpNVqNva.js";var he=r(`move`,[[`path`,{d:`M12 2v20`,key:`t6zp3m`}],[`path`,{d:`m15 19-3 3-3-3`,key:`11eu04`}],[`path`,{d:`m19 9 3 3-3 3`,key:`1mg7y2`}],[`path`,{d:`M2 12h20`,key:`9i4pu4`}],[`path`,{d:`m5 9-3 3 3 3`,key:`j64kie`}],[`path`,{d:`m9 5 3-3 3 3`,key:`l8vdw6`}]]),ge=r(`pencil-ruler`,[[`path`,{d:`M13 7 8.7 2.7a2.41 2.41 0 0 0-3.4 0L2.7 5.3a2.41 2.41 0 0 0 0 3.4L7 13`,key:`orapub`}],[`path`,{d:`m8 6 2-2`,key:`115y1s`}],[`path`,{d:`m18 16 2-2`,key:`ee94s4`}],[`path`,{d:`m17 11 4.3 4.3c.94.94.94 2.46 0 3.4l-2.6 2.6c-.94.94-2.46.94-3.4 0L11 17`,key:`cfq27r`}],[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}],[`path`,{d:`m15 5 4 4`,key:`1mk7zo`}]]),C=t(e(),1),w=n();function T(e){return e.type===`directory`?_(e.path?`${e.path}/${e.name}`:e.name):b(e)}function _e({target:e,directories:t,onMove:n,onClose:r}){let{t:i}=oe(),ee=_(e.path||``),a=T(e),o=t.filter(t=>e.type===`directory`?t.path!==a&&!t.path.startsWith(`${a}/`):!0),[s,te]=(0,C.useState)(ee),[c,u]=(0,C.useState)(``),[f,re]=(0,C.useState)(new Set),p=_(c),m=c.trim()?p:s,h=_(m)===ee,g=new Map;for(let e of o){let t=g.get(e.parentPath)||[];t.push(e),g.set(e.parentPath,t)}let ie=o.filter(e=>{if(!e.parentPath)return!0;let t=e.parentPath.split(`/`).filter(Boolean);return t.every((e,n)=>f.has(t.slice(0,n+1).join(`/`)))}),ae=[{label:i(`note.root`),path:``},...s.split(`/`).filter(Boolean).map((e,t,n)=>({label:e,path:n.slice(0,t+1).join(`/`)}))];function v(e){te(_(e)),u(``)}function y(e){v(e),g.has(e)&&re(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}function b(){h||n(m)}return(0,w.jsx)(se,{onClose:r,children:(0,w.jsxs)(`div`,{className:`note-move-modal`,onClick:e=>e.stopPropagation(),children:[(0,w.jsxs)(`div`,{className:`modal-header`,children:[(0,w.jsx)(`h3`,{children:i(`note.move.title`)}),(0,w.jsx)(`button`,{className:`btn btn-icon`,onClick:r,children:(0,w.jsx)(le,{size:18})})]}),(0,w.jsxs)(`div`,{className:`note-move-target`,children:[(0,w.jsx)(`span`,{children:i(`note.move.moving`)}),(0,w.jsx)(`strong`,{translate:`no`,children:e.name})]}),(0,w.jsx)(`div`,{className:`note-move-path`,children:ae.map((e,t)=>(0,w.jsxs)(C.Fragment,{children:[t>0&&(0,w.jsx)(`span`,{children:`/`}),(0,w.jsx)(`button`,{type:`button`,onClick:()=>v(e.path),children:(0,w.jsx)(`span`,{translate:e.path?`no`:`yes`,children:e.label})})]},e.path||`root`))}),(0,w.jsxs)(`div`,{className:`note-move-folder-list`,children:[(0,w.jsxs)(`button`,{type:`button`,className:`note-move-folder-item ${s===``?`selected`:``}`,onClick:()=>v(``),children:[(0,w.jsx)(`span`,{className:`note-move-folder-spacer`}),(0,w.jsx)(ne,{className:`note-move-folder-icon`,size:16}),(0,w.jsx)(`span`,{children:i(`note.root`)})]}),o.length===0?(0,w.jsx)(`p`,{className:`note-move-empty`,children:i(`note.move.noFolders`)}):ie.map(e=>{let t=g.has(e.path),n=f.has(e.path);return(0,w.jsxs)(`button`,{type:`button`,className:`note-move-folder-item note-move-depth-${Math.min(e.depth,4)} ${s===e.path?`selected`:``}`,onClick:()=>y(e.path),children:[t?n?(0,w.jsx)(l,{className:`note-move-expander`,size:14}):(0,w.jsx)(d,{className:`note-move-expander`,size:14}):(0,w.jsx)(`span`,{className:`note-move-folder-spacer`}),(0,w.jsx)(ne,{className:`note-move-folder-icon`,size:16}),(0,w.jsx)(`span`,{translate:`no`,children:e.name}),e.parentPath&&(0,w.jsx)(`small`,{translate:`no`,children:e.parentPath})]},e.path)})]}),(0,w.jsx)(`input`,{className:`input input-compact`,value:c,onChange:e=>u(e.target.value),placeholder:i(`note.move.pathPlaceholder`),translate:`no`}),(0,w.jsxs)(`div`,{className:`note-move-destination`,children:[(0,w.jsx)(`span`,{children:i(`note.move.destinationLabel`)}),(0,w.jsx)(`span`,{translate:m?`no`:`yes`,children:m||i(`note.root`)})]}),(0,w.jsxs)(`div`,{className:`modal-actions`,children:[(0,w.jsx)(`button`,{className:`btn btn-secondary`,onClick:r,children:i(`common.cancel`)}),(0,w.jsx)(`button`,{className:`btn btn-primary`,onClick:b,disabled:h,children:i(`note.action.move`)})]})]})})}function ve({children:e}){return(0,w.jsxs)(w.Fragment,{children:[(0,w.jsxs)(`button`,{type:`button`,className:`sidebar-header sidebar-header-link`,onClick:y(),children:[(0,w.jsx)(v,{size:18}),(0,w.jsx)(`h1`,{children:`MOST PEOPLE`})]}),e,(0,w.jsx)(me,{})]})}var ye=(0,C.lazy)(async()=>({default:(await S(()=>import(`./MilkdownEditor-Bv2VA3bu.js`),__vite__mapDeps([0,1,2,3,4,5,6,7]))).MilkdownEditor}));function be(e){let t=new URLSearchParams(e),n=t.get(`mode`);return{cid:t.get(`cid`)||void 0,mode:n===`edit`?`edit`:void 0}}function xe(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 Se(e,t){return e.isSecret||e.content.startsWith(`mp://1`)?t(`note.preview.encrypted`):String(e.content||``).replace(/```[\s\S]*?```/g,` `).replace(/!\[[^\]]*]\([^)]*\)/g,` `).replace(/\[([^\]]+)]\([^)]*\)/g,`$1`).replace(/[#>*_`~|-]/g,` `).replace(/\s+/g,` `).trim()||t(`note.preview.empty`)}var E={"note.error.nameRequired":`note.error.nameRequired`,"note.error.nameNoSlash":`note.error.nameNoSlash`,"note.error.nameNoBackslash":`note.error.nameNoBackslash`,"note.error.nameInvalid":`note.error.nameInvalid`,"note.error.nameConflict":`note.error.nameConflict`,"note.error.moveIntoSelf":`note.error.moveIntoSelf`};function D(e,t,n){let r=e instanceof Error?e.message:``,i=E[r];return i?n(i):r||t}function Ce(e){return e.type===`directory`?_(e.path?`${e.path}/${e.name}`:e.name):b(e)}function we(e,t){let n=new Set;for(let t of e){let e=_(t.path).split(`/`).filter(Boolean);for(let t=0;t<e.length;t+=1)n.add(e.slice(0,t+1).join(`/`))}return Array.from(n).sort(t).map(e=>{let t=e.split(`/`);return{path:e,name:t[t.length-1]||e,parentPath:t.slice(0,-1).join(`/`),depth:Math.max(t.length-1,0)}})}function O(){let{t:e,formatDate:t,compareStrings:n}=oe(),r=s(),o=pe({select:e=>e.searchStr}),l=(0,C.useMemo)(()=>be(o),[o]),d=(0,C.useRef)(null),v=x(e=>e.addToast),y=x(e=>e.isDarkMode),se=x(e=>e.setIsDarkMode),S=a(e=>e.wallet),me=a(e=>e.openLoginModal),T=x(e=>e.notes),E=x(e=>e.notesPath),O=x(e=>e.setNotesPath),k=x(e=>e.saveNote),Te=x(e=>e.deleteNote),Ee=x(e=>e.renameNote),A=x(e=>e.localDataReady),j=l.cid||``,M=T.find(e=>e.cid===j),N=!!j,P=N&&l.mode===`edit`,[F,De]=(0,C.useState)(``),[I,Oe]=(0,C.useState)(null),[L,R]=(0,C.useState)(null),[z,B]=(0,C.useState)(null),[ke,V]=(0,C.useState)(``),[H,U]=(0,C.useState)(``),[Ae,W]=(0,C.useState)(``),[G,K]=(0,C.useState)(``),[je,Me]=(0,C.useState)(``),[Ne,q]=(0,C.useState)(``),[J,Y]=(0,C.useState)(!1),[X,Z]=(0,C.useState)(``),[Pe,Fe]=(0,C.useState)(!1);(0,C.useEffect)(()=>{if(!j){V(``),U(``);return}if(!M){V(``),U(A?e(`note.error.notFound`):``);return}if(M.content.startsWith(`mp://1`)){if(!S){V(``),U(e(`note.error.loginToDecrypt`));return}let t=i(M.content,S.danger);if(!t){V(``),U(e(`note.error.decryptFailed`));return}V(t),U(``);return}V(M.content||``),U(``)},[j,A,M,e,S]),(0,C.useEffect)(()=>{if(!P){Fe(!1);return}if(!j||!M){K(``),Me(``),q(``),Y(!1),Z(A?e(`note.error.notFound`):``);return}if(K(M.name),Me(M.path||``),Y(M.isSecret===!0||M.content.startsWith(`mp://1`)),M.content.startsWith(`mp://1`)){if(!S){q(``),Z(e(`note.error.loginToDecrypt`));return}let t=i(M.content,S.danger);if(!t){q(``),Z(e(`note.error.decryptFailed`));return}q(t),Z(``);return}q(M.content||``),Z(``)},[j,P,A,M,e,S]),(0,C.useEffect)(()=>{W(M?.name||``)},[M?.cid,M?.name]);let Ie=(0,C.useMemo)(()=>fe(T,E,F),[T,E,F]),Le=Ie.filter(e=>e.type===`file`).length,Re=M?.isSecret===!0||M?.content.startsWith(`mp://1`)===!0,ze=e(P?J?`note.privacy.secret`:`note.privacy.public`:Re?`note.privacy.secret`:`note.privacy.public`),Be=(0,C.useMemo)(()=>{let t=E.split(`/`).filter(Boolean);return[{label:e(`note.root`),path:``},...t.map((e,n)=>({label:e,path:t.slice(0,n+1).join(`/`)}))]},[E,e]),Ve=(0,C.useMemo)(()=>we(T,n),[n,T]);function Q(e={},t=!1){r({href:xe(e),replace:t})}function He(e){Q({cid:e.cid})}function Ue(e){Q({cid:e.cid,mode:`edit`})}function $(){return S?!0:(me(),!1)}function We(){Q(M?{cid:M.cid}:{})}async function Ge(){if($()){if(!M){v(e(`note.toast.notFound`),`error`);return}if(!G.trim()){v(e(`note.toast.nameRequired`),`warning`);return}Fe(!0);try{let t=d.current?.getMarkdown()??Ne,n=J?ee(t,S.danger):t,r=await k({cid:M.cid,name:G,path:je,content:n,isSecret:J});q(t),Q({cid:r},!0),v(e(`note.toast.saved`),`success`)}catch(t){v(D(t,e(`note.toast.saveFailed`),e),`error`)}finally{Fe(!1)}}}function Ke(){$()&&Oe({title:e(`note.create.title`),placeholder:e(`note.namePlaceholder`),confirmText:e(`note.create.action`),onConfirm:async t=>{if($())try{let n=await k({name:t,path:E,content:``,isSecret:!1});Oe(null),v(e(`note.toast.created`),`success`),Q({cid:n,mode:`edit`})}catch(t){v(D(t,e(`note.toast.createFailed`),e),`error`)}}})}async function qe(){if(!$()||!M)return;let t=Ae.trim();if(!t){W(M.name),v(e(`note.toast.nameRequired`),`warning`);return}if(t!==M.name)try{Ee(b(M),M.path,t),v(e(`note.toast.renamed`),`success`)}catch(t){W(M.name),v(D(t,e(`note.toast.renameFailed`),e),`error`)}}function Je(e){$()&&B(e)}async function Ye(t){if(z)try{Ee(Ce(z),t,z.name),B(null),v(e(`note.toast.moved`),`success`)}catch(t){v(D(t,e(`note.toast.moveFailed`),e),`error`)}}function Xe(t){if(!$())return;let n=t.type===`directory`;R({title:e(n?`note.delete.folderTitle`:`note.delete.noteTitle`),message:e(`note.delete.message`,{name:t.name}),confirmText:e(`note.action.delete`),onConfirm:async()=>{Te(n?void 0:t.cid,t.path,t.name),R(null),v(e(`note.toast.deleted`),`success`),t.type===`file`&&t.cid===j&&Q()}})}let Ze=(0,w.jsxs)(`div`,{className:`note-header-title`,children:[(0,w.jsx)(`h2`,{className:`header-title`,children:e(`note.title`)}),(0,w.jsx)(`span`,{children:e(`note.count`,{count:T.length})})]}),Qe=(0,w.jsx)(`div`,{className:`note-theme-wrap`,children:(0,w.jsx)(`button`,{className:`btn btn-icon`,onClick:()=>se(!y),title:e(`common.theme.toggle`),"aria-label":e(`common.theme.toggle`),children:y?(0,w.jsx)(c,{size:16}):(0,w.jsx)(te,{size:16})})}),$e=(0,w.jsxs)(`section`,{className:`note-list-panel note-sidebar-list`,"aria-label":e(`note.listLabel`),children:[(0,w.jsxs)(`div`,{className:`note-list-header`,children:[(0,w.jsx)(`div`,{className:`note-current-location`,children:(0,w.jsx)(`div`,{className:`note-breadcrumbs`,children:Be.map((e,t)=>(0,w.jsxs)(C.Fragment,{children:[t>0&&(0,w.jsx)(`span`,{children:`/`}),(0,w.jsx)(`button`,{onClick:()=>O(e.path),children:(0,w.jsx)(`span`,{translate:e.path?`no`:`yes`,children:e.label})})]},e.path||`root`))})}),(0,w.jsx)(`span`,{className:`note-count`,children:e(`note.count`,{count:Le})})]}),(0,w.jsxs)(`div`,{className:`note-search`,children:[(0,w.jsx)(ie,{size:16}),(0,w.jsx)(`input`,{className:`input input-flex`,value:F,onChange:e=>De(e.target.value),placeholder:e(`note.search.placeholder`)})]}),Ie.length===0?(0,w.jsxs)(`div`,{className:`ui-empty-state note-empty-state`,children:[(0,w.jsx)(p,{size:32}),(0,w.jsx)(`p`,{children:e(F?`note.empty.noMatches`:`note.empty.noNotes`)})]}):(0,w.jsx)(`div`,{className:`note-list`,children:Ie.map(n=>(0,w.jsx)(`article`,{className:`ui-list-item note-list-item ${n.type===`file`&&n.cid===j?`active`:``}`,children:(0,w.jsxs)(`button`,{className:`ui-list-item-main note-list-item-main ${n.type===`directory`?`folder`:``}`,onClick:()=>{n.type===`directory`?O(_(n.path?`${n.path}/${n.name}`:n.name)):He(n)},children:[(0,w.jsx)(`span`,{className:`ui-list-icon note-list-icon ${n.type===`directory`?`warning`:``}`,children:n.type===`directory`?(0,w.jsx)(ne,{size:18}):n.isSecret?(0,w.jsx)(u,{size:18}):(0,w.jsx)(f,{size:18})}),(0,w.jsxs)(`span`,{className:`ui-list-copy note-list-copy`,children:[(0,w.jsx)(`span`,{className:`ui-list-title note-list-name`,translate:`no`,children:n.name}),n.type===`file`?(0,w.jsx)(`span`,{className:`ui-list-desc note-list-preview`,translate:`no`,children:Se(n,e)}):(0,w.jsx)(`span`,{className:`ui-list-desc note-list-preview`,children:e(`note.folder`)})]}),n.type===`file`&&(0,w.jsx)(`span`,{className:`ui-list-meta note-list-date`,children:t(n.updated_at)})]})},`${n.cid}:${n.path}:${n.name}`))}),(0,w.jsx)(`div`,{className:`note-create-btn`,children:(0,w.jsxs)(`button`,{className:`btn`,onClick:Ke,children:[(0,w.jsx)(h,{size:16}),e(`note.newNote`)]})})]});return(0,w.jsxs)(re,{sidebar:()=>(0,w.jsx)(ve,{children:$e}),headerTitle:Ze,headerRight:Qe,children:[(0,w.jsx)(`main`,{className:`note-page note-browser-page ${N?`has-editor`:``}`,children:(0,w.jsx)(`section`,{className:`note-workspace`,children:(0,w.jsx)(`section`,{className:`note-editor-panel`,"aria-label":e(P?`note.editorLabel.edit`:`note.editorLabel.read`),children:N?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsxs)(`div`,{className:`note-editor-panel-header`,children:[(0,w.jsxs)(`div`,{className:`note-editor-title-area`,children:[P?(0,w.jsx)(`input`,{className:`note-title-input`,value:G,onChange:e=>K(e.target.value),placeholder:e(`note.namePlaceholder`),translate:`no`,disabled:!M}):M?(0,w.jsx)(`input`,{className:`note-title-input`,value:Ae,onBlur:qe,onChange:e=>W(e.target.value),onKeyDown:e=>{e.key===`Enter`&&e.currentTarget.blur(),e.key===`Escape`&&(W(M.name),e.currentTarget.blur())},placeholder:e(`note.namePlaceholder`),title:e(`app.rename`),translate:`no`}):(0,w.jsx)(`h3`,{children:e(`note.untitled`)}),M&&(0,w.jsxs)(`div`,{className:`note-editor-info`,children:[(0,w.jsx)(`span`,{children:e(P?`note.mode.edit`:`note.mode.read`)}),(0,w.jsx)(`span`,{children:ze}),(0,w.jsx)(`span`,{children:t(M.updated_at)})]})]}),(0,w.jsxs)(`div`,{className:`note-editor-actions`,children:[(0,w.jsx)(`button`,{type:`button`,className:`btn btn-icon`,onClick:P?We:()=>Q(),title:e(P?`common.cancel`:`common.close`),"aria-label":e(P?`common.cancel`:`common.close`),children:(0,w.jsx)(le,{size:16})}),P?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsxs)(`button`,{className:`btn btn-sm ${J?`btn-warning`:`btn-secondary`}`,onClick:()=>Y(!J),disabled:!M,children:[J?(0,w.jsx)(u,{size:16}):(0,w.jsx)(ce,{size:16}),e(J?`note.privacy.secret`:`note.privacy.public`)]}),(0,w.jsxs)(`button`,{className:`btn btn-sm btn-primary`,onClick:Ge,disabled:Pe||!!X||!M,children:[(0,w.jsx)(g,{size:16}),e(Pe?`note.action.saving`:`note.action.save`)]})]}):M&&(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(`button`,{type:`button`,className:`btn btn-icon`,onClick:()=>Je(M),title:e(`note.action.move`),"aria-label":e(`note.action.move`),children:(0,w.jsx)(he,{size:16})}),(0,w.jsx)(`button`,{type:`button`,className:`btn btn-icon note-editor-action-danger`,onClick:()=>Xe(M),title:e(`note.action.delete`),"aria-label":e(`note.action.delete`),children:(0,w.jsx)(ae,{size:16})}),(0,w.jsxs)(`button`,{type:`button`,className:`btn btn-sm btn-primary`,onClick:()=>Ue(M),disabled:!!H,title:e(`note.action.edit`),"aria-label":e(`note.action.edit`),children:[(0,w.jsx)(ge,{size:16}),e(`note.action.edit`)]})]})]})]}),P?X?(0,w.jsxs)(`div`,{className:`note-empty-state editor-error`,children:[(0,w.jsx)(u,{size:36}),(0,w.jsx)(`p`,{children:X})]}):M?(0,w.jsx)(`div`,{className:`note-editor-frame editing`,children:(0,w.jsx)(ye,{ref:d,content:Ne,onChange:q,className:`milkdown-editor`})}):(0,w.jsxs)(`div`,{className:`note-empty-state editor-error`,children:[(0,w.jsx)(p,{size:36}),(0,w.jsx)(`p`,{children:e(A?`note.error.notFound`:`note.loading`)})]}):H?(0,w.jsxs)(`div`,{className:`ui-empty-state note-empty-state editor-error`,children:[(0,w.jsx)(u,{size:36}),(0,w.jsx)(`p`,{children:H})]}):M?(0,w.jsx)(`div`,{className:`note-editor-frame reading`,children:(0,w.jsx)(ye,{content:ke,readOnly:!0,className:`milkdown-editor`})}):(0,w.jsxs)(`div`,{className:`ui-empty-state note-empty-state editor-error`,children:[(0,w.jsx)(p,{size:36}),(0,w.jsx)(`p`,{children:e(A?`note.error.notFound`:`note.loading`)})]})]}):(0,w.jsxs)(`div`,{className:`ui-empty-state note-editor-empty`,children:[(0,w.jsx)(`div`,{className:`ui-empty-icon note-editor-empty-icon`,children:(0,w.jsx)(p,{size:32})}),(0,w.jsx)(`h3`,{className:`ui-empty-title`,children:e(`note.noOpen.title`)}),(0,w.jsx)(`p`,{className:`ui-empty-desc`,children:T.length>0?e(`note.noOpen.select`):e(`note.noOpen.createFirst`)}),(0,w.jsx)(m,{label:e(`note.openList`),variant:`default`})]})})})}),I&&(0,w.jsx)(ue,{title:I.title,placeholder:I.placeholder,defaultValue:I.defaultValue,confirmText:I.confirmText,onConfirm:I.onConfirm,onClose:()=>Oe(null)}),L&&(0,w.jsx)(de,{title:L.title,message:L.message,confirmText:L.confirmText,danger:!0,onConfirm:L.onConfirm,onClose:()=>R(null)}),z&&(0,w.jsx)(_e,{target:z,directories:Ve,onMove:Ye,onClose:()=>B(null)})]})}function k(){let{t:e}=oe();return(0,w.jsx)(C.Suspense,{fallback:(0,w.jsx)(`div`,{className:`note-editor-loading`,children:e(`note.loading`)}),children:(0,w.jsx)(O,{})})}var Te=o(`/note/`)({component:k});export{Te as Route};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e,o as t,t as n}from"./jsx-runtime-Bt-cYkS5.js";import{b as r,g as i,r as a,t as o,v as s}from"./userStore-q0BBZsIV.js";import{a as c}from"./LanguageToggle-B99eQcTE.js";import{t as l}from"./download-Bhqn6hL1.js";import{t as u}from"./external-link-CNR21yFA.js";import{a as ee,i as d,n as f,r as p}from"./mp-DjXDNjls.js";import{t as m}from"./key-round-BpSdpOHi.js";import{t as h}from"./loader-ByMmV2_4.js";import{t as g}from"./save-DN4eprSt.js";import{t as _}from"./shield-check-c0labdRH.js";import{t as te}from"./upload-BD23c5Pz.js";import{I as ne,a as v,h as y,i as b,m as x,n as S,o as C,r as w,s as T,u as E,v as D}from"./index-DN0kD5zr.js";import{t as O}from"./MarketingHeader-Q2cpkqAM.js";import{t as k}from"./MarketingLayout-X3Nj2JvA.js";var re=i(`cloud-download`,[[`path`,{d:`M12 13v8l-4-4`,key:`1f5nwf`}],[`path`,{d:`m12 21 4-4`,key:`1lfcce`}],[`path`,{d:`M4.393 15.269A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.436 8.284`,key:`ui1hmy`}]]),ie=i(`cloud-upload`,[[`path`,{d:`M12 13v8`,key:`1l5pq0`}],[`path`,{d:`M4 14.899A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.242`,key:`1pljnt`}],[`path`,{d:`m8 17 4-4 4 4`,key:`1quai1`}]]),ae=i(`log-out`,[[`path`,{d:`m16 17 5-5-5-5`,key:`1bji2h`}],[`path`,{d:`M21 12H9`,key:`dn1m92`}],[`path`,{d:`M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4`,key:`1uf3rs`}]]),oe=i(`wallet-cards`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M3 9a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2`,key:`4125el`}],[`path`,{d:`M3 11h3c.8 0 1.6.3 2.1.9l1.1.9c1.6 1.6 4.1 1.6 5.7 0l1.1-.9c.5-.5 1.3-.9 2.1-.9H21`,key:`1dpki6`}]]),A=t(e(),1),j=n(),se=[{value:``,labelKey:`profile.avatar.address`},...w.map(e=>({value:v(e),labelKey:`profile.avatar.${e}`}))];function ce(e){if(C(e))return!0;try{let t=new URL(e);return t.protocol===`http:`||t.protocol===`https:`}catch{return!1}}function M(){let{t:e}=ne(),t=x(e=>e.addToast),n=x(e=>e.hasBackend),i=o(e=>e.identity),s=o(e=>e.openLoginModal),v=o(e=>e.setUserIdentity),C=o(e=>e.logoutUser),w=S(),[M,F]=(0,A.useState)(``),[I,L]=(0,A.useState)(``),[R,z]=(0,A.useState)(``),[B,V]=(0,A.useState)(null),[H,U]=(0,A.useState)(!1),W=(0,j.jsx)(O,{});(0,A.useEffect)(()=>{if(!i){F(``),L(``),z(``);return}F(i.displayName||i.username),L(T(i.avatar)||i.avatar||``),z(``)},[i]);let G=(0,A.useMemo)(()=>i?a(i.danger):null,[i]),le=(0,A.useMemo)(()=>G?f(G.private_key,G.ed_public_key):``,[G]);if(!i)return(0,j.jsx)(k,{header:W,children:(0,j.jsx)(`section`,{className:`profile-page`,children:(0,j.jsx)(`div`,{className:`profile-container narrow`,children:(0,j.jsxs)(`div`,{className:`profile-empty glass`,children:[(0,j.jsx)(`div`,{className:`profile-empty-icon`,children:(0,j.jsx)(d,{size:34})}),(0,j.jsx)(`h1`,{children:e(`profile.signedOut.title`)}),(0,j.jsx)(`p`,{children:e(`profile.signedOut.desc`)}),(0,j.jsxs)(`button`,{type:`button`,className:`btn btn-primary`,onClick:s,children:[(0,j.jsx)(d,{size:16}),e(`account.signIn`)]})]})})})});let ue=T(i.avatar)||i.avatar||``,de=b(i.address,i.avatar),K=i.address.toLowerCase(),fe=I.trim().length>0;async function q(r){if(n===!0)try{await y.put(`/api/user/profile`,{json:{displayName:r.displayName||r.username,avatar:r.avatar||``,updatedAt:r.profileUpdatedAt||Date.now()}}).json()}catch(n){t(await D(n,e(`profile.backup.error.profileSaveFailed`)),`error`)}}function J(n){if(!i)return;let r={...i,avatar:n||void 0,profileUpdatedAt:Date.now()};v(r),q(r),z(``),t(e(`profile.toast.avatarUpdated`),`success`)}function pe(){if(!i)return;let n=M.trim()||i.username,r={...i,displayName:n,profileUpdatedAt:Date.now()};v(r),q(r),F(n),t(e(`profile.toast.saved`),`success`)}function me(){let t=I.trim();if(!t){J(void 0);return}if(!ce(t)){z(e(`nav.avatarUrlInvalid`));return}J(t)}function he(){C(),U(!1)}function ge(){V({title:e(`profile.backup.confirm.backupTitle`),message:e(`profile.backup.confirm.backupMessage`),confirmText:e(`profile.backup.action.cloudBackup`),onConfirm:async()=>{V(null),await w.backupToCloud()}})}function _e(){V({title:e(`profile.backup.confirm.restoreTitle`),message:e(`profile.backup.confirm.restoreMessage`),confirmText:e(`profile.backup.action.cloudRestore`),onConfirm:async()=>{V(null),await w.restoreFromCloud({confirm:!1})}})}function Y(){return new Promise(t=>{let n=e=>{V(null),t(e)};V({title:e(`profile.backup.confirm.importTitle`),message:e(`profile.backup.confirm.restore`),confirmText:e(`profile.backup.action.importLocal`),onConfirm:()=>n(!0),onClose:()=>n(!1)})})}function ve(){w.importLocalBackup({requestConfirm:Y})}let X=w.action===`backup`,Z=w.action===`restore`,Q=w.action===`export`,$=w.action===`import`;return(0,j.jsxs)(k,{header:W,children:[(0,j.jsx)(`section`,{className:`profile-page`,children:(0,j.jsxs)(`div`,{className:`profile-container`,children:[(0,j.jsxs)(`section`,{className:`profile-panel profile-backup-panel`,children:[(0,j.jsx)(`div`,{className:`profile-panel-header`,children:(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`h2`,{children:e(`profile.section.backup`)}),(0,j.jsx)(`p`,{children:e(`profile.section.backup.desc`)})]})}),(0,j.jsxs)(`div`,{className:`profile-backup-actions`,children:[(0,j.jsxs)(`button`,{type:`button`,className:`btn btn-secondary ${Q?`btn-loading`:``}`,onClick:w.exportLocalBackup,disabled:w.busy,children:[Q?(0,j.jsx)(h,{size:16,className:`ui-spinner`}):(0,j.jsx)(l,{size:16}),e(Q?`profile.backup.status.exporting`:`profile.backup.action.exportLocal`)]}),(0,j.jsxs)(`button`,{type:`button`,className:`btn btn-secondary ${$?`btn-loading`:``}`,onClick:ve,disabled:w.busy,children:[$?(0,j.jsx)(h,{size:16,className:`ui-spinner`}):(0,j.jsx)(te,{size:16}),e($?`profile.backup.status.importing`:`profile.backup.action.importLocal`)]}),(0,j.jsxs)(`button`,{type:`button`,className:`btn btn-primary ${X?`btn-loading`:``}`,onClick:ge,disabled:w.busy,children:[X?(0,j.jsx)(h,{size:16,className:`ui-spinner`}):(0,j.jsx)(ie,{size:16}),e(X?`profile.backup.status.backingUp`:`profile.backup.action.cloudBackup`)]}),(0,j.jsxs)(`button`,{type:`button`,className:`btn btn-secondary ${Z?`btn-loading`:``}`,onClick:_e,disabled:w.busy,children:[Z?(0,j.jsx)(h,{size:16,className:`ui-spinner`}):(0,j.jsx)(re,{size:16}),e(Z?`profile.backup.status.restoring`:`profile.backup.action.cloudRestore`)]})]})]}),(0,j.jsxs)(`header`,{className:`profile-header`,children:[(0,j.jsx)(`img`,{className:`profile-avatar-large`,src:de,alt:``}),(0,j.jsxs)(`div`,{className:`profile-heading`,children:[(0,j.jsx)(`p`,{className:`profile-kicker`,children:e(`profile.kicker`)}),(0,j.jsx)(`h1`,{children:i.displayName||i.username}),(0,j.jsxs)(`div`,{className:`profile-address-line`,children:[(0,j.jsx)(`code`,{translate:`no`,children:K}),(0,j.jsx)(p,{text:K}),(0,j.jsxs)(`a`,{href:`https://debank.com/profile/${i.address}`,target:`_blank`,rel:`noopener noreferrer`,className:`btn btn-secondary btn-sm`,children:[(0,j.jsx)(u,{size:14}),e(`web3.action.view`)]})]})]}),(0,j.jsxs)(`button`,{type:`button`,className:`btn btn-secondary profile-logout-btn`,onClick:()=>U(!0),children:[(0,j.jsx)(ae,{size:16}),e(`account.logout`)]})]}),(0,j.jsxs)(`div`,{className:`profile-grid`,children:[(0,j.jsxs)(`section`,{className:`profile-panel`,children:[(0,j.jsx)(`div`,{className:`profile-panel-header`,children:(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`h2`,{children:e(`profile.section.account`)}),(0,j.jsx)(`p`,{children:e(`profile.section.account.desc`)})]})}),(0,j.jsxs)(`label`,{className:`profile-field`,children:[(0,j.jsx)(`span`,{children:e(`profile.label.displayName`)}),(0,j.jsxs)(`div`,{className:`profile-field-row`,children:[(0,j.jsx)(`input`,{className:`input`,value:M,onChange:e=>F(e.target.value),placeholder:e(`nav.displayNamePlaceholder`)}),(0,j.jsxs)(`button`,{type:`button`,className:`btn btn-primary`,onClick:pe,children:[(0,j.jsx)(g,{size:16}),e(`profile.action.save`)]})]})]}),(0,j.jsxs)(`div`,{className:`profile-facts`,children:[(0,j.jsx)(N,{label:e(`profile.label.username`),value:i.username}),(0,j.jsx)(N,{label:e(`web3.label.address`),value:i.address,copy:!0})]})]}),(0,j.jsxs)(`section`,{className:`profile-panel`,children:[(0,j.jsx)(`div`,{className:`profile-panel-header`,children:(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`h2`,{children:e(`profile.section.avatar`)}),(0,j.jsx)(`p`,{children:e(`profile.section.avatar.desc`)})]})}),(0,j.jsx)(`div`,{className:`profile-avatar-grid`,role:`list`,children:se.map(t=>{let n=ue===t.value;return(0,j.jsxs)(`button`,{type:`button`,className:[`profile-avatar-option`,n?`selected`:``].filter(Boolean).join(` `),onClick:()=>J(t.value),"aria-pressed":n,title:e(t.labelKey),children:[(0,j.jsx)(`img`,{src:b(i.address,t.value),alt:``,"aria-hidden":`true`}),(0,j.jsx)(`span`,{children:e(t.labelKey)}),n&&(0,j.jsx)(`span`,{className:`profile-avatar-check`,children:(0,j.jsx)(c,{size:14})})]},t.value||`address`)})}),(0,j.jsxs)(`div`,{className:`profile-avatar-url`,children:[(0,j.jsxs)(`label`,{className:`profile-field`,htmlFor:`profile-avatar-url`,children:[(0,j.jsx)(`span`,{children:e(`profile.label.customAvatar`)}),(0,j.jsxs)(`div`,{className:`profile-field-row`,children:[(0,j.jsx)(`input`,{id:`profile-avatar-url`,className:`input`,value:I,onChange:e=>{L(e.target.value),z(``)},placeholder:e(`nav.avatarUrlPlaceholder`)}),(0,j.jsxs)(`button`,{type:`button`,className:`btn btn-secondary`,onClick:me,disabled:!fe,children:[(0,j.jsx)(g,{size:16}),e(`profile.action.save`)]})]})]}),R&&(0,j.jsx)(`p`,{className:`profile-error`,children:R})]})]})]}),(0,j.jsxs)(`section`,{className:`profile-panel profile-identity-panel`,children:[(0,j.jsxs)(`div`,{className:`profile-panel-header`,children:[(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`h2`,{children:e(`profile.section.identity`)}),(0,j.jsx)(`p`,{children:e(`profile.section.identity.desc`)})]}),(0,j.jsxs)(r,{to:`/web3/`,hash:`wallet`,className:`btn btn-secondary`,children:[(0,j.jsx)(oe,{size:16}),e(`profile.action.openWallet`)]})]}),(0,j.jsxs)(`div`,{className:`profile-key-grid`,children:[G&&(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(P,{title:e(`web3.label.ed25519Public`),icon:(0,j.jsx)(ee,{size:18}),value:G.ed_public_key}),(0,j.jsx)(P,{title:e(`web3.label.x25519Public`),icon:(0,j.jsx)(m,{size:18}),value:G.public_key})]}),(0,j.jsx)(P,{title:`IPNS ID`,icon:(0,j.jsx)(_,{size:18}),value:le||`-`})]})]})]})}),H&&(0,j.jsx)(E,{title:e(`account.logoutTitle`),message:e(`account.logoutConfirm`),confirmText:e(`account.logout`),danger:!0,onConfirm:he,onClose:()=>U(!1)}),B&&(0,j.jsx)(E,{title:B.title,message:B.message,confirmText:B.confirmText,danger:B.danger,onConfirm:B.onConfirm,onClose:B.onClose||(()=>V(null))})]})}function N({label:e,value:t,copy:n=!1}){return(0,j.jsxs)(`div`,{className:`profile-fact`,children:[(0,j.jsx)(`span`,{children:e}),(0,j.jsxs)(`div`,{className:`profile-fact-value`,children:[(0,j.jsx)(`code`,{translate:`no`,children:t}),n&&(0,j.jsx)(p,{text:t})]})]})}function P({title:e,icon:t,value:n}){return(0,j.jsxs)(`div`,{className:`profile-key-card`,children:[(0,j.jsxs)(`div`,{className:`profile-key-card-header`,children:[(0,j.jsx)(`span`,{className:`profile-key-card-icon`,children:t}),(0,j.jsx)(`span`,{children:e})]}),(0,j.jsxs)(`div`,{className:`mono-row`,children:[(0,j.jsx)(`code`,{className:`mono`,translate:`no`,children:n}),(0,j.jsx)(p,{text:n})]})]})}var F=s(`/profile/`)({component:M});export{F as Route};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e,o as t,t as n}from"./jsx-runtime-Bt-cYkS5.js";import{b as r,g as i,v as a}from"./userStore-q0BBZsIV.js";import{t as o}from"./cloud-DAGFCFIp.js";import{t as s}from"./download-Bhqn6hL1.js";import{I as c}from"./index-DN0kD5zr.js";import{t as l}from"./MarketingHeader-Q2cpkqAM.js";import{n as u}from"./format-CR8oUWq6.js";var d=i(`apple`,[[`path`,{d:`M12 6.528V3a1 1 0 0 1 1-1h0`,key:`11qiee`}],[`path`,{d:`M18.237 21A15 15 0 0 0 22 11a6 6 0 0 0-10-4.472A6 6 0 0 0 2 11a15.1 15.1 0 0 0 3.763 10 3 3 0 0 0 3.648.648 5.5 5.5 0 0 1 5.178 0A3 3 0 0 0 18.237 21`,key:`110c12`}]]),f=i(`code`,[[`path`,{d:`m16 18 6-6-6-6`,key:`eg8j8`}],[`path`,{d:`m8 6-6 6 6 6`,key:`ppft3o`}]]),p=i(`laptop`,[[`path`,{d:`M18 5a2 2 0 0 1 2 2v8.526a2 2 0 0 0 .212.897l1.068 2.127a1 1 0 0 1-.9 1.45H3.62a1 1 0 0 1-.9-1.45l1.068-2.127A2 2 0 0 0 4 15.526V7a2 2 0 0 1 2-2z`,key:`1pdavp`}],[`path`,{d:`M20.054 15.987H3.946`,key:`14rxg9`}]]),m=i(`monitor`,[[`rect`,{width:`20`,height:`14`,x:`2`,y:`3`,rx:`2`,key:`48i651`}],[`line`,{x1:`8`,x2:`16`,y1:`21`,y2:`21`,key:`1svkeh`}],[`line`,{x1:`12`,x2:`12`,y1:`17`,y2:`21`,key:`vw1qmm`}]]),h=t(e(),1),g=n(),_=`https://github.com/most-people/most/releases/latest`,v=`${`https://download.most.box`.replace(/\/+$/,``)}/releases/latest.json`,y=[{platform:`windows`,arch:`x64`,kind:`installer`,filename:`GitHub Releases`,githubUrl:_},{platform:`windows`,arch:`arm64`,kind:`installer`,filename:`GitHub Releases`,githubUrl:_},{platform:`macos`,arch:`x64`,kind:`installer`,filename:`GitHub Releases`,githubUrl:_},{platform:`macos`,arch:`arm64`,kind:`installer`,filename:`GitHub Releases`,githubUrl:_},{platform:`linux`,arch:`x64`,kind:`installer`,filename:`GitHub Releases`,githubUrl:_},{platform:`linux`,arch:`arm64`,kind:`installer`,filename:`GitHub Releases`,githubUrl:_}],b={windows:{name:`Windows`,ext:`.exe`,descKey:`download.platform.windows.desc`,icon:m},macos:{name:`macOS`,ext:`.dmg`,descKey:`download.platform.macos.desc`,icon:d},linux:{name:`Linux`,ext:`.AppImage`,descKey:`download.platform.linux.desc`,icon:p}};function x(e){return typeof e==`object`&&!!e}function S(e){return x(e)?[`windows`,`macos`,`linux`].includes(String(e.platform))&&[`x64`,`arm64`].includes(String(e.arch))&&(e.kind===`installer`||e.kind===`updater`)&&typeof e.filename==`string`&&typeof e.githubUrl==`string`&&(typeof e.r2Url==`string`||e.r2Url===void 0):!1}function C(e){return!x(e)||typeof e.version!=`string`||typeof e.publishedAt!=`string`||!Array.isArray(e.assets)?!1:e.assets.every(S)}function w(){return[navigator.userAgentData?.platform,navigator.platform,navigator.userAgent].filter(Boolean).join(` `).toLowerCase()}function T(){if(typeof navigator>`u`)return`windows:x64`;let e=w(),t=/arm|aarch64/.test(e)?`arm64`:`x64`;return/mac|darwin/.test(e)?`macos:${t}`:/linux/.test(e)?`linux:${t}`:`windows:${t}`}function E(){let{t:e}=c(),[t,n]=(0,h.useState)(null),[r,i]=(0,h.useState)(v?`loading`:`fallback`),[a,l]=(0,h.useState)(`windows:x64`),[d,p]=(0,h.useState)(`r2`);(0,h.useEffect)(()=>{l(T())},[]),(0,h.useEffect)(()=>{if(!v)return;let e=new AbortController;return fetch(v,{cache:`no-store`,signal:e.signal}).then(e=>{if(!e.ok)throw Error(`Manifest request failed: ${e.status}`);return e.json()}).then(e=>{if(!C(e))throw Error(`Invalid download manifest`);n(e),i(`ready`)}).catch(e=>{e instanceof DOMException&&e.name===`AbortError`||(n(null),i(`fallback`))}),()=>e.abort()},[]),(0,h.useEffect)(()=>{r===`fallback`&&p(`github`)},[r]);let m=t?.assets.filter(e=>e.kind===`installer`)||[],_=m.length?m:y,x=_.some(e=>e.r2Url),S=d===`r2`&&x?`r2`:`github`;return(0,g.jsxs)(`div`,{className:`download-options`,children:[(0,g.jsxs)(`div`,{className:`ui-segmented-control download-source-tabs`,role:`tablist`,"aria-label":e(`download.source.label`),children:[(0,g.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":S===`r2`,disabled:!x,className:S===`r2`?`ui-segmented-option download-source-tab is-active`:`ui-segmented-option download-source-tab`,onClick:()=>p(`r2`),children:[(0,g.jsx)(o,{size:15}),`Cloudflare R2`]}),(0,g.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":S===`github`,className:S===`github`?`ui-segmented-option download-source-tab is-active`:`ui-segmented-option download-source-tab`,onClick:()=>p(`github`),children:[(0,g.jsx)(f,{size:15}),`GitHub Releases`]})]}),(0,g.jsx)(`p`,{className:`download-source-note`,children:r===`loading`?e(`download.source.loading`):r===`ready`&&t?e(`download.source.ready`,{version:t.version}):e(`download.source.fallback`)}),(0,g.jsx)(`div`,{className:`download-platform-grid`,children:_.map(t=>{let n=b[t.platform],r=n.icon,i=`${t.platform}:${t.arch}`,o=S===`r2`&&t.r2Url?t.r2Url:t.githubUrl,c=i===a;return(0,g.jsxs)(`article`,{className:c?`download-platform-card is-recommended`:`download-platform-card`,children:[(0,g.jsx)(`div`,{className:`download-platform-icon`,children:(0,g.jsx)(r,{size:32})}),(0,g.jsxs)(`div`,{className:`download-platform-content`,children:[(0,g.jsxs)(`div`,{className:`download-platform-heading`,children:[(0,g.jsx)(`h3`,{children:n.name}),(0,g.jsx)(`span`,{children:t.arch})]}),(0,g.jsx)(`p`,{children:e(n.descKey)}),(0,g.jsxs)(`dl`,{className:`download-platform-meta`,children:[(0,g.jsxs)(`div`,{children:[(0,g.jsx)(`dt`,{children:e(`download.platform.source`)}),(0,g.jsx)(`dd`,{children:S===`r2`&&t.r2Url?e(`download.source.r2Mirror`):`GitHub Releases`})]}),t.size?(0,g.jsxs)(`div`,{children:[(0,g.jsx)(`dt`,{children:e(`download.platform.size`)}),(0,g.jsx)(`dd`,{children:u(t.size)})]}):null,t.cid?(0,g.jsxs)(`div`,{children:[(0,g.jsx)(`dt`,{children:`CID`}),(0,g.jsx)(`dd`,{children:t.cid.slice(0,12)})]}):null]}),(0,g.jsx)(`div`,{className:`download-platform-actions`,children:(0,g.jsxs)(`a`,{href:o,className:`btn btn-primary`,children:[(0,g.jsx)(s,{size:16}),e(`download.platform.action`,{ext:n.ext})]})})]}),c?(0,g.jsx)(`span`,{className:`download-recommended-badge`,children:e(`download.platform.current`)}):null]},i)})})]})}var D=[{featureKey:`download.comparison.node`,webKey:`download.comparison.webConnectsNode`,desktopKey:`download.comparison.desktopBuiltinNode`},{featureKey:`download.comparison.fileSharing`,webKey:`download.comparison.webDependsNode`,desktopKey:`download.comparison.desktopFull`},{featureKey:`download.comparison.verification`,webKey:`download.comparison.webDependsNode`,desktopKey:`download.comparison.desktopFull`},{featureKey:`download.comparison.seeding`,webKey:`download.comparison.webDependsNode`,desktopKey:`download.comparison.desktopDefaultOn`},{featureKey:`download.comparison.largeFiles`,webKey:`download.comparison.webDependsNode`,desktopKey:`download.comparison.desktop10gb`}];function O(){let{t:e}=c();return(0,h.useEffect)(()=>{document.title=e(`download.meta.title`)},[e]),(0,g.jsxs)(`div`,{className:`download-page`,children:[(0,g.jsx)(l,{}),(0,g.jsx)(`section`,{className:`download-hero`,children:(0,g.jsxs)(`div`,{className:`mkt-container`,children:[(0,g.jsx)(`div`,{className:`download-hero-icon`,children:(0,g.jsx)(s,{size:40})}),(0,g.jsx)(`h1`,{className:`download-hero-title`,children:e(`download.hero.title`)}),(0,g.jsx)(`p`,{className:`download-hero-desc`,children:e(`download.hero.desc`)})]})}),(0,g.jsx)(`section`,{className:`download-platforms`,children:(0,g.jsxs)(`div`,{className:`mkt-container`,children:[(0,g.jsx)(`h2`,{className:`download-section-title`,children:e(`download.platforms.title`)}),(0,g.jsx)(E,{})]})}),(0,g.jsx)(`section`,{className:`download-comparison`,children:(0,g.jsxs)(`div`,{className:`mkt-container`,children:[(0,g.jsx)(`h2`,{className:`download-section-title`,children:e(`download.comparison.title`)}),(0,g.jsx)(`div`,{className:`download-table-wrap`,children:(0,g.jsxs)(`table`,{className:`download-table`,children:[(0,g.jsx)(`thead`,{children:(0,g.jsxs)(`tr`,{children:[(0,g.jsx)(`th`,{children:e(`download.comparison.feature`)}),(0,g.jsx)(`th`,{children:e(`download.comparison.web`)}),(0,g.jsx)(`th`,{children:e(`download.comparison.desktop`)})]})}),(0,g.jsx)(`tbody`,{children:D.map(t=>(0,g.jsxs)(`tr`,{children:[(0,g.jsx)(`td`,{children:e(t.featureKey)}),(0,g.jsx)(`td`,{className:`col-web`,children:e(t.webKey)}),(0,g.jsx)(`td`,{className:`col-desktop`,children:e(t.desktopKey)})]},t.featureKey))})]})})]})}),(0,g.jsx)(`section`,{className:`download-cta`,children:(0,g.jsx)(`div`,{className:`mkt-container`,children:(0,g.jsx)(`p`,{className:`download-hero-desc`,children:e(`download.npmNote`)})})}),(0,g.jsx)(`section`,{className:`download-cta`,children:(0,g.jsx)(`div`,{className:`mkt-container`,children:(0,g.jsx)(r,{to:`/`,className:`btn btn-primary`,children:e(`common.backHome`)})})}),(0,g.jsx)(`footer`,{className:`mkt-footer`,children:(0,g.jsx)(`div`,{className:`mkt-container`,children:(0,g.jsx)(`div`,{className:`mkt-footer-inner`,children:(0,g.jsx)(`p`,{className:`mkt-footer-copy`,children:`MostBox`})})})})]})}var k=a(`/download/`)({component:O});export{k as Route};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{n as e,o as t,t as n}from"./jsx-runtime-Bt-cYkS5.js";import{a as r,c as i,d as a,g as o,i as s,p as c,r as l,t as u,u as d,v as f}from"./userStore-q0BBZsIV.js";import{i as p,r as m}from"./LanguageToggle-B99eQcTE.js";import{n as h,t as g}from"./lock-C0pdaery.js";import{t as _}from"./download-Bhqn6hL1.js";import{t as v}from"./external-link-CNR21yFA.js";import{a as y,i as b,n as x,r as S,t as C}from"./mp-DjXDNjls.js";import{t as w}from"./key-round-BpSdpOHi.js";import{t as T}from"./AppShell-gILTcRs-.js";import{t as E}from"./wallet-DmZMdK9A.js";import{I as D,M as O,N as ee,O as te,i as ne,j as k,m as re}from"./index-DN0kD5zr.js";var ie=o(`chevron-up`,[[`path`,{d:`m18 15-6-6-6 6`,key:`153udz`}]]),A=o(`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`}]]),ae=o(`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`}]]),oe=o(`shield-alert`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`M12 8v4`,key:`1got3b`}],[`path`,{d:`M12 16h.01`,key:`1drbdi`}]]),se=o(`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`}]]),j=t(e()),M=n();function ce(e){return e?`•`.repeat(Math.min(e.length,32)):`-`}function le({title:e,username:t,password:n,showPassword:r,showPrivateKey:i,account:a,onUsernameChange:o,onPasswordChange:s,onTogglePassword:c,onTogglePrivateKey:l,onGenerate:u}){let{t:d}=D();return(0,M.jsxs)(`div`,{className:`web3-box-account`,children:[(0,M.jsx)(`div`,{className:`web3-box-account-header`,children:(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`h2`,{children:e}),(0,M.jsx)(`p`,{children:d(`web3.box.account.desc`)})]})}),(0,M.jsxs)(`div`,{className:`web3-box-login`,children:[(0,M.jsx)(`input`,{type:`text`,placeholder:d(`login.username.placeholder`),value:t,onChange:e=>o(e.target.value),className:`input`,autoCapitalize:`off`,autoCorrect:`off`,spellCheck:`false`}),(0,M.jsxs)(`div`,{className:`input-wrap`,children:[(0,M.jsx)(`input`,{type:r?`text`:`password`,placeholder:d(`web3.login.passwordOptional`),value:n,onChange:e=>s(e.target.value),className:`input`,autoCapitalize:`off`,autoCorrect:`off`,spellCheck:`false`}),(0,M.jsx)(`button`,{className:`input-eye`,onClick:c,type:`button`,children:r?(0,M.jsx)(O,{size:16}):(0,M.jsx)(k,{size:16})})]}),(0,M.jsxs)(`button`,{className:`btn btn-primary btn-full`,onClick:u,disabled:!t.trim(),type:`button`,children:[(0,M.jsx)(w,{size:16}),d(`web3.box.account.generate`)]})]}),a?(0,M.jsxs)(`div`,{className:`web3-box-key-list`,children:[(0,M.jsxs)(`div`,{className:`web3-box-key-row`,children:[(0,M.jsx)(`span`,{children:d(`web3.label.address`)}),(0,M.jsxs)(`div`,{className:`mono-row`,children:[(0,M.jsx)(`code`,{className:`mono`,translate:`no`,children:a.address.toLowerCase()}),(0,M.jsx)(S,{text:a.address.toLowerCase()})]})]}),(0,M.jsxs)(`div`,{className:`web3-box-key-row`,children:[(0,M.jsx)(`span`,{children:d(`web3.label.x25519Public`)}),(0,M.jsxs)(`div`,{className:`mono-row`,children:[(0,M.jsx)(`code`,{className:`mono`,translate:`no`,children:a.publicKey}),(0,M.jsx)(S,{text:a.publicKey})]})]}),(0,M.jsxs)(`div`,{className:`web3-box-key-row`,children:[(0,M.jsx)(`span`,{children:d(`web3.label.x25519Private`)}),(0,M.jsxs)(`div`,{className:`mono-row danger`,children:[(0,M.jsx)(`code`,{className:`mono`,translate:`no`,children:i?a.privateKey:ce(a.privateKey)}),(0,M.jsx)(`button`,{className:`btn btn-icon`,onClick:l,title:d(i?`web3.action.hidePrivateKey`:`web3.action.showPrivateKey`),type:`button`,children:i?(0,M.jsx)(k,{size:14}):(0,M.jsx)(O,{size:14})})]})]})]}):null]})}function ue(e,t){return Number.isFinite(e)?t(e):`-`}function de({title:e,description:t,message:n,cipherText:r,decryptedText:i,error:o,encryptLabel:s,decryptLabel:c,messagePlaceholder:l,cipherPlaceholder:u,onMessageChange:d,onCipherTextChange:f,onEncrypt:p,onDecrypt:m}){let{t:h,formatDateTime:_}=D(),v=`box-message-${e.replaceAll(/\s+/g,`-`)}`,y=a(r);return(0,M.jsxs)(`section`,{className:`web3-box-flow`,children:[(0,M.jsx)(`div`,{className:`web3-box-flow-header`,children:(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`h2`,{children:e}),(0,M.jsx)(`p`,{children:t})]})}),(0,M.jsx)(`label`,{className:`web3-box-label`,htmlFor:v,children:h(`web3.box.plaintext`)}),(0,M.jsx)(`textarea`,{id:v,className:`textarea`,value:n,onChange:e=>d(e.target.value),rows:4,placeholder:l,translate:`no`}),(0,M.jsxs)(`div`,{className:`web3-box-actions`,children:[(0,M.jsxs)(`button`,{className:`btn btn-primary`,onClick:p,type:`button`,children:[(0,M.jsx)(g,{size:16}),s]}),(0,M.jsxs)(`button`,{className:`btn btn-secondary`,onClick:m,type:`button`,children:[(0,M.jsx)(w,{size:16}),c]})]}),o&&(0,M.jsx)(`p`,{className:`web3-tools-danger`,children:o}),(0,M.jsxs)(`div`,{className:`web3-box-result-grid`,children:[(0,M.jsxs)(`div`,{className:`web3-box-result`,children:[(0,M.jsx)(`label`,{className:`web3-box-result-header`,children:(0,M.jsx)(`span`,{children:h(`web3.box.ciphertext`)})}),(0,M.jsx)(`textarea`,{className:`textarea mono`,value:r,onChange:e=>f(e.target.value),rows:5,placeholder:u,translate:`no`})]}),(0,M.jsxs)(`div`,{className:`web3-box-result`,children:[(0,M.jsx)(`label`,{className:`web3-box-result-header`,children:(0,M.jsx)(`span`,{children:h(`web3.box.decryptResult`)})}),(0,M.jsx)(`textarea`,{className:`textarea mono`,value:i,readOnly:!0,rows:5,placeholder:h(`web3.box.decryptResultPlaceholder`),translate:`no`})]})]}),y&&(0,M.jsxs)(`div`,{className:`web3-box-token-meta`,children:[(0,M.jsxs)(`div`,{className:`web3-box-token-meta-row`,children:[(0,M.jsx)(`span`,{children:h(`web3.box.timestamp`)}),(0,M.jsx)(`code`,{translate:`no`,children:ue(y.timestampMs,_)})]}),(0,M.jsxs)(`div`,{className:`web3-box-token-meta-row`,children:[(0,M.jsx)(`span`,{children:h(`web3.box.nonce`)}),(0,M.jsx)(`code`,{translate:`no`,children:y.nonce})]})]})]})}function fe(e){let{t}=D();return(0,M.jsxs)(`div`,{className:`web3-box-workspace`,children:[(0,M.jsxs)(`div`,{className:`web3-box-grid`,children:[(0,M.jsx)(le,{title:t(`web3.box.accountA`),username:e.boxAUsername,password:e.boxAPassword,showPassword:e.boxAShowPassword,showPrivateKey:e.boxAShowPrivateKey,account:e.boxAAccount,onUsernameChange:e.onBoxAUsernameChange,onPasswordChange:e.onBoxAPasswordChange,onTogglePassword:e.onBoxAShowPasswordToggle,onTogglePrivateKey:e.onBoxAShowPrivateKeyToggle,onGenerate:e.onGenerateBoxA}),(0,M.jsx)(le,{title:t(`web3.box.accountB`),username:e.boxBUsername,password:e.boxBPassword,showPassword:e.boxBShowPassword,showPrivateKey:e.boxBShowPrivateKey,account:e.boxBAccount,onUsernameChange:e.onBoxBUsernameChange,onPasswordChange:e.onBoxBPasswordChange,onTogglePassword:e.onBoxBShowPasswordToggle,onTogglePrivateKey:e.onBoxBShowPrivateKeyToggle,onGenerate:e.onGenerateBoxB})]}),(0,M.jsxs)(`div`,{className:`web3-box-flow-grid`,children:[(0,M.jsx)(de,{title:`A → B`,description:t(`web3.box.flowAB.desc`),message:e.boxABMessage,cipherText:e.boxABCipherText,decryptedText:e.boxABDecryptedText,error:e.boxABError,encryptLabel:t(`web3.box.flowAB.encrypt`),decryptLabel:t(`web3.box.flowAB.decrypt`),messagePlaceholder:t(`web3.box.flowAB.messagePlaceholder`),cipherPlaceholder:t(`web3.box.cipherPlaceholder`),onMessageChange:e.onBoxABMessageChange,onCipherTextChange:e.onBoxABCipherTextChange,onEncrypt:e.onEncryptBoxAB,onDecrypt:e.onDecryptBoxAB}),(0,M.jsx)(de,{title:`B → A`,description:t(`web3.box.flowBA.desc`),message:e.boxBAMessage,cipherText:e.boxBACipherText,decryptedText:e.boxBADecryptedText,error:e.boxBAError,encryptLabel:t(`web3.box.flowBA.encrypt`),decryptLabel:t(`web3.box.flowBA.decrypt`),messagePlaceholder:t(`web3.box.flowBA.messagePlaceholder`),cipherPlaceholder:t(`web3.box.cipherPlaceholder`),onMessageChange:e.onBoxBAMessageChange,onCipherTextChange:e.onBoxBACipherTextChange,onEncrypt:e.onEncryptBoxBA,onDecrypt:e.onDecryptBoxBA})]}),(0,M.jsxs)(`div`,{className:`web3-box-flow-grid`,children:[(0,M.jsxs)(`section`,{className:`web3-box-flow`,children:[(0,M.jsx)(`div`,{className:`web3-box-flow-header`,children:(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`h2`,{children:t(`web3.box.encryptTitle`)}),(0,M.jsx)(`p`,{children:t(`web3.box.encryptDesc`)})]})}),(0,M.jsx)(`label`,{className:`web3-box-result-header`,children:(0,M.jsx)(`span`,{children:t(`web3.box.sender`)})}),(0,M.jsxs)(`div`,{className:`input-wrap`,children:[(0,M.jsx)(`input`,{type:e.boxEncryptShowPrivateKey?`text`:`password`,placeholder:t(`web3.box.senderPrivatePlaceholder`),value:e.boxEncryptSenderPrivateKey,onChange:t=>e.onBoxEncryptSenderPrivateKeyChange(t.target.value),className:`input`,autoCapitalize:`off`,autoCorrect:`off`,spellCheck:`false`}),(0,M.jsx)(`button`,{className:`input-eye`,onClick:e.onBoxEncryptShowPrivateKeyToggle,type:`button`,children:e.boxEncryptShowPrivateKey?(0,M.jsx)(O,{size:16}):(0,M.jsx)(k,{size:16})})]}),(0,M.jsx)(`label`,{className:`web3-box-result-header`,children:(0,M.jsx)(`span`,{children:t(`web3.box.recipient`)})}),(0,M.jsx)(`input`,{type:`text`,placeholder:t(`web3.box.recipientPublicPlaceholder`),value:e.boxEncryptRecipientPublicKey,onChange:t=>e.onBoxEncryptRecipientPublicKeyChange(t.target.value),className:`input`,autoCapitalize:`off`,autoCorrect:`off`,spellCheck:`false`}),(0,M.jsx)(`label`,{className:`web3-box-result-header`,children:(0,M.jsx)(`span`,{children:t(`web3.box.plaintext`)})}),(0,M.jsx)(`textarea`,{className:`textarea`,value:e.boxEncryptMessage,onChange:t=>e.onBoxEncryptMessageChange(t.target.value),rows:4,placeholder:t(`web3.box.messagePlaceholder`),translate:`no`}),(0,M.jsx)(`div`,{className:`web3-box-actions`,children:(0,M.jsxs)(`button`,{className:`btn btn-primary`,onClick:e.onEncryptOnly,type:`button`,children:[(0,M.jsx)(g,{size:16}),t(`web3.box.encryptTitle`)]})}),e.boxEncryptError&&(0,M.jsx)(`p`,{className:`web3-tools-danger`,children:e.boxEncryptError}),(0,M.jsxs)(`div`,{className:`web3-box-result`,children:[(0,M.jsx)(`label`,{className:`web3-box-result-header`,children:(0,M.jsx)(`span`,{children:t(`web3.box.ciphertext`)})}),(0,M.jsx)(`textarea`,{className:`textarea mono`,value:e.boxEncryptCipherText,readOnly:!0,rows:5,placeholder:t(`web3.box.encryptResultPlaceholder`),translate:`no`})]})]}),(0,M.jsxs)(`section`,{className:`web3-box-flow`,children:[(0,M.jsx)(`div`,{className:`web3-box-flow-header`,children:(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`h2`,{children:t(`web3.box.decryptTitle`)}),(0,M.jsx)(`p`,{children:t(`web3.box.decryptDesc`)})]})}),(0,M.jsx)(`label`,{className:`web3-box-result-header`,children:(0,M.jsx)(`span`,{children:t(`web3.box.sender`)})}),(0,M.jsx)(`input`,{type:`text`,placeholder:t(`web3.box.senderPublicPlaceholder`),value:e.boxDecryptSenderPublicKey,onChange:t=>e.onBoxDecryptSenderPublicKeyChange(t.target.value),className:`input`,autoCapitalize:`off`,autoCorrect:`off`,spellCheck:`false`}),(0,M.jsx)(`label`,{className:`web3-box-result-header`,children:(0,M.jsx)(`span`,{children:t(`web3.box.recipient`)})}),(0,M.jsxs)(`div`,{className:`input-wrap`,children:[(0,M.jsx)(`input`,{type:e.boxDecryptShowPrivateKey?`text`:`password`,placeholder:t(`web3.box.recipientPrivatePlaceholder`),value:e.boxDecryptRecipientPrivateKey,onChange:t=>e.onBoxDecryptRecipientPrivateKeyChange(t.target.value),className:`input`,autoCapitalize:`off`,autoCorrect:`off`,spellCheck:`false`}),(0,M.jsx)(`button`,{className:`input-eye`,onClick:e.onBoxDecryptShowPrivateKeyToggle,type:`button`,children:e.boxDecryptShowPrivateKey?(0,M.jsx)(O,{size:16}):(0,M.jsx)(k,{size:16})})]}),(0,M.jsx)(`label`,{className:`web3-box-result-header`,children:(0,M.jsx)(`span`,{children:t(`web3.box.ciphertext`)})}),(0,M.jsx)(`textarea`,{className:`textarea mono`,value:e.boxDecryptCipherText,onChange:t=>e.onBoxDecryptCipherTextChange(t.target.value),rows:5,placeholder:t(`web3.box.cipherDecryptPlaceholder`),translate:`no`}),(0,M.jsx)(`div`,{className:`web3-box-actions`,children:(0,M.jsxs)(`button`,{className:`btn btn-secondary`,onClick:e.onDecryptOnly,type:`button`,children:[(0,M.jsx)(w,{size:16}),t(`web3.box.decryptTitle`)]})}),e.boxDecryptError&&(0,M.jsx)(`p`,{className:`web3-tools-danger`,children:e.boxDecryptError}),(0,M.jsxs)(`div`,{className:`web3-box-result`,children:[(0,M.jsx)(`label`,{className:`web3-box-result-header`,children:(0,M.jsx)(`span`,{children:t(`web3.box.decryptResult`)})}),(0,M.jsx)(`textarea`,{className:`textarea mono`,value:e.boxDecryptResult,readOnly:!0,rows:5,placeholder:t(`web3.box.decryptResultPlaceholder`),translate:`no`})]})]})]})]})}function N({icon:e,message:t,className:n=`empty-state glass`}){return(0,M.jsxs)(`div`,{className:n,children:[(0,M.jsx)(`div`,{className:`empty-state-icon`,children:e}),(0,M.jsx)(`p`,{children:t})]})}function pe({label:e,pem:t,filename:n}){let{t:r}=D();function i(){let e=new Blob([t],{type:`text/plain`}),r=URL.createObjectURL(e),i=document.createElement(`a`);i.href=r,i.download=n,i.click(),URL.revokeObjectURL(r)}return(0,M.jsxs)(`div`,{className:`web3-pem-block`,children:[(0,M.jsxs)(`div`,{className:`web3-pem-header`,children:[(0,M.jsx)(`span`,{className:`web3-pem-label`,children:e}),(0,M.jsxs)(`div`,{className:`web3-pem-actions`,children:[(0,M.jsx)(S,{text:t,label:r(`common.copy`),className:`btn btn-sm`,iconSize:14}),(0,M.jsxs)(`button`,{type:`button`,className:`btn btn-sm btn-primary`,onClick:i,title:r(`common.download`),children:[(0,M.jsx)(_,{size:14}),r(`common.download`)]})]})]}),(0,M.jsx)(`textarea`,{className:`textarea mono`,value:t,readOnly:!0,rows:6,translate:`no`})]})}function me({walletResult:e,publicPem:t,privatePem:n}){let{t:r}=D();if(!t||!n)return(0,M.jsx)(N,{icon:(0,M.jsx)(g,{size:36}),message:r(`web3.empty.pem`)});let i=e?.username||`wallet`;return(0,M.jsxs)(`div`,{className:`web3-pem-list`,children:[(0,M.jsx)(pe,{label:`${i}.pub`,pem:t,filename:`${i}.pub`}),(0,M.jsx)(pe,{label:`${i}.pem`,pem:n,filename:`${i}.pem`})]})}var P=Object.defineProperty,F=Object.getOwnPropertySymbols,he=Object.prototype.hasOwnProperty,I=Object.prototype.propertyIsEnumerable,L=(e,t,n)=>t in e?P(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,R=(e,t)=>{for(var n in t||={})he.call(t,n)&&L(e,n,t[n]);if(F)for(var n of F(t))I.call(t,n)&&L(e,n,t[n]);return e},z=(e,t)=>{var n={};for(var r in e)he.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&F)for(var r of F(e))t.indexOf(r)<0&&I.call(e,r)&&(n[r]=e[r]);return n},B;(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})(B||={}),(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||={})})(B||={}),(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||={})})(B||={});var V=B,ge={L:V.QrCode.Ecc.LOW,M:V.QrCode.Ecc.MEDIUM,Q:V.QrCode.Ecc.QUARTILE,H:V.QrCode.Ecc.HIGH},H=128,_e=`L`,U=`#FFFFFF`,W=`#000000`,G=!1,K=1,ve=4,ye=0,be=.1;function q(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 xe(e,t){return e.slice().map((e,n)=>n<t.y||n>=t.y+t.h?e:e.map((e,n)=>n<t.x||n>=t.x+t.w?e:!1))}function Se(e,t,n,r){if(r==null)return null;let i=e.length+n*2,a=Math.floor(t*be),o=i/t,s=(r.width||a)*o,c=(r.height||a)*o,l=r.x==null?e.length/2-s/2:r.x*o,u=r.y==null?e.length/2-c/2:r.y*o,d=r.opacity==null?1:r.opacity,f=null;if(r.excavate){let e=Math.floor(l),t=Math.floor(u);f={x:e,y:t,w:Math.ceil(s+l-e),h:Math.ceil(c+u-t)}}let p=r.crossOrigin;return{x:l,y:u,h:c,w:s,excavation:f,opacity:d,crossOrigin:p}}function Ce(e,t){return t==null?e?ve:ye:Math.max(Math.floor(t),0)}function we({value:e,level:t,minVersion:n,includeMargin:r,marginSize:i,imageSettings:a,size:o,boostLevel:s}){let c=j.useMemo(()=>{let r=(Array.isArray(e)?e:[e]).reduce((e,t)=>(e.push(...V.QrSegment.makeSegments(t)),e),[]);return V.QrCode.encodeSegments(r,ge[t],n,void 0,void 0,s)},[e,t,n,s]),{cells:l,margin:u,numCells:d,calculatedImageSettings:f}=j.useMemo(()=>{let e=c.getModules(),t=Ce(r,i);return{cells:e,margin:t,numCells:e.length+t*2,calculatedImageSettings:Se(e,o,t,a)}},[c,o,a,r,i]);return{qrcode:c,margin:u,cells:l,numCells:d,calculatedImageSettings:f}}var Te=function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0}(),Ee=j.forwardRef(function(e,t){let n=e,{value:r,size:i=H,level:a=_e,bgColor:o=U,fgColor:s=W,includeMargin:c=G,minVersion:l=K,boostLevel:u,marginSize:d,imageSettings:f}=n,p=z(n,[`value`,`size`,`level`,`bgColor`,`fgColor`,`includeMargin`,`minVersion`,`boostLevel`,`marginSize`,`imageSettings`]),{style:m}=p,h=z(p,[`style`]),g=f?.src,_=j.useRef(null),v=j.useRef(null),y=j.useCallback(e=>{_.current=e,typeof t==`function`?t(e):t&&(t.current=e)},[t]),[b,x]=j.useState(!1),{margin:S,cells:C,numCells:w,calculatedImageSettings:T}=we({value:r,level:a,minVersion:l,boostLevel:u,includeMargin:c,marginSize:d,imageSettings:f,size:i});j.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=xe(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,Te?t.fill(new Path2D(q(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)}}),j.useEffect(()=>{x(!1)},[g]);let E=R({height:i,width:i},m),D=null;return g!=null&&(D=j.createElement(`img`,{src:g,key:g,style:{display:`none`},onLoad:()=>{x(!0)},ref:v,crossOrigin:T?.crossOrigin})),j.createElement(j.Fragment,null,j.createElement(`canvas`,R({style:E,height:i,width:i,ref:y,role:`img`},h)),D)});Ee.displayName=`QRCodeCanvas`;var J=j.forwardRef(function(e,t){let n=e,{value:r,size:i=H,level:a=_e,bgColor:o=U,fgColor:s=W,includeMargin:c=G,minVersion:l=K,boostLevel:u,title:d,marginSize:f,imageSettings:p}=n,m=z(n,[`value`,`size`,`level`,`bgColor`,`fgColor`,`includeMargin`,`minVersion`,`boostLevel`,`title`,`marginSize`,`imageSettings`]),{margin:h,cells:g,numCells:_,calculatedImageSettings:v}=we({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=xe(g,v.excavation)),b=j.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=q(y,h);return j.createElement(`svg`,R({height:i,width:i,viewBox:`0 0 ${_} ${_}`,ref:t,role:`img`},m),!!d&&j.createElement(`title`,null,d),j.createElement(`path`,{fill:o,d:`M0,0 h${_}v${_}H0z`,shapeRendering:`crispEdges`}),j.createElement(`path`,{fill:s,d:x,shapeRendering:`crispEdges`}),b)});J.displayName=`QRCodeSVG`;function De({walletResult:e,mnemonicPhrase:t,deriveBatch:n,deriveList:r,deriveShowIndex:i,deriveShowAddress:a,deriveShowPrivateKey:o,showAddressQr:s,showMnemonicReveal:c,showMnemonicQr:l,onToggleAddressQr:u,onToggleMnemonicReveal:d,onToggleMnemonicQr:f,onToggleDeriveIndex:p,onToggleDeriveAddress:m,onToggleDerivePrivateKey:g,onDerive:_}){let{t:v}=D(),y=e?.address||``;return!e||!y?(0,M.jsx)(N,{icon:(0,M.jsx)(E,{size:36}),message:v(`web3.empty.walletTools`)}):(0,M.jsxs)(M.Fragment,{children:[(0,M.jsxs)(`div`,{className:`web3-tools-section`,children:[(0,M.jsxs)(`button`,{className:`web3-tools-toggle`,onClick:u,children:[(0,M.jsx)(ae,{size:14}),v(s?`web3.action.hideAddressQr`:`web3.action.showAddressQr`),s?(0,M.jsx)(ie,{size:14}):(0,M.jsx)(h,{size:14})]}),s&&(0,M.jsxs)(`div`,{className:`web3-mnemonic-reveal`,children:[(0,M.jsxs)(`div`,{className:`web3-mnemonic-card`,children:[(0,M.jsx)(`p`,{className:`web3-mnemonic-text`,translate:`no`,children:y}),(0,M.jsx)(S,{text:y})]}),(0,M.jsx)(`div`,{className:`qr-wrap`,children:(0,M.jsx)(J,{value:y,size:200})})]})]}),t&&(0,M.jsxs)(`div`,{className:`web3-tools-section`,children:[(0,M.jsxs)(`button`,{className:`web3-tools-toggle`,onClick:d,children:[(0,M.jsx)(w,{size:14}),v(c?`web3.action.hideMnemonic`:`web3.action.showMnemonic`),c?(0,M.jsx)(ie,{size:14}):(0,M.jsx)(h,{size:14})]}),c&&(0,M.jsxs)(`div`,{className:`web3-mnemonic-reveal`,children:[(0,M.jsxs)(`div`,{className:`web3-mnemonic-card`,children:[(0,M.jsx)(`p`,{className:`web3-mnemonic-text`,translate:`no`,children:t}),(0,M.jsx)(S,{text:t})]}),(0,M.jsxs)(`p`,{className:`web3-tools-danger`,children:[(0,M.jsx)(oe,{size:14}),v(`web3.warning.mnemonic`)]}),(0,M.jsx)(`button`,{className:`web3-tools-toggle`,onClick:f,children:v(l?`web3.action.hideMnemonicQr`:`web3.action.showMnemonicQr`)}),l&&(0,M.jsx)(`div`,{className:`qr-wrap`,children:(0,M.jsx)(J,{value:t,size:260})})]})]}),t&&(0,M.jsxs)(`div`,{className:`web3-mnemonic-reveal`,children:[(0,M.jsx)(`div`,{children:(0,M.jsx)(`button`,{className:`btn btn-primary`,onClick:_,children:v(`web3.action.deriveAddresses`,{count:n})})}),(0,M.jsxs)(`p`,{className:`web3-tools-danger`,children:[(0,M.jsx)(oe,{size:14}),v(`web3.warning.privateKey`)]}),r.length>0&&(0,M.jsx)(`div`,{className:`web3-derive-table-wrap`,children:(0,M.jsxs)(`table`,{className:`web3-derive-table`,children:[(0,M.jsx)(`thead`,{children:(0,M.jsxs)(`tr`,{children:[(0,M.jsx)(`th`,{onClick:p,className:`web3-derive-th`,children:v(`web3.label.account`)}),(0,M.jsx)(`th`,{onClick:m,className:`web3-derive-th`,children:v(`web3.label.address`)}),(0,M.jsx)(`th`,{onClick:g,className:`web3-derive-th danger`,children:v(`web3.label.privateKeyToggle`,{action:v(o?`web3.action.hide`:`web3.action.show`)})})]})}),(0,M.jsx)(`tbody`,{children:r.map(e=>(0,M.jsxs)(`tr`,{children:[(0,M.jsx)(`td`,{children:i?e.index+1:``}),(0,M.jsx)(`td`,{translate:`no`,children:a?e.address:``}),(0,M.jsx)(`td`,{className:`danger`,children:(0,M.jsx)(`span`,{translate:`no`,children:o?e.privateKey:``})})]},e.index))})]})})]})]})}function Y({title:e,icon:t,children:n,accent:r=!1}){return(0,M.jsxs)(`div`,{className:`web3-key-card ${r?`accent`:``}`,children:[(0,M.jsxs)(`div`,{className:`web3-key-card-header`,children:[(0,M.jsx)(`span`,{className:`web3-key-card-icon`,children:t}),(0,M.jsx)(`span`,{className:`web3-key-card-title`,children:e})]}),(0,M.jsx)(`div`,{className:`web3-key-card-body`,translate:`no`,children:n})]})}function Oe(e){return e?`•`.repeat(Math.min(e.length,32)):`-`}function ke({walletResult:e,keys:t,ipns:n,avatarSrc:r,showPrivateKey:i,onTogglePrivateKey:a}){let{t:o}=D(),s=e?.address||``;return!e||!s?(0,M.jsx)(N,{icon:(0,M.jsx)(b,{size:36}),message:o(`web3.empty.identity`)}):(0,M.jsxs)(M.Fragment,{children:[(0,M.jsxs)(`div`,{className:`web3-identity-card`,children:[(0,M.jsx)(`img`,{src:r,alt:`avatar`,className:`web3-identity-avatar`}),(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`h1`,{className:`web3-identity-name`,children:e.username||o(`web3.notSignedIn`)}),(0,M.jsxs)(`div`,{className:`web3-identity-address`,children:[(0,M.jsx)(`code`,{translate:`no`,children:s.toLowerCase()}),(0,M.jsx)(S,{text:s.toLowerCase()}),(0,M.jsxs)(`a`,{href:`https://debank.com/profile/${s}`,target:`_blank`,rel:`noopener noreferrer`,className:`link`,children:[(0,M.jsx)(v,{size:14}),o(`web3.action.view`)]})]})]})]}),t&&(0,M.jsxs)(`div`,{className:`web3-key-grid`,children:[(0,M.jsx)(Y,{title:o(`web3.label.ed25519Public`),icon:(0,M.jsx)(y,{size:18}),children:(0,M.jsxs)(`div`,{className:`mono-row`,children:[(0,M.jsx)(`code`,{className:`mono`,translate:`no`,children:t.ed_public_key}),(0,M.jsx)(S,{text:t.ed_public_key})]})}),(0,M.jsx)(Y,{title:o(`web3.label.x25519Public`),icon:(0,M.jsx)(w,{size:18}),children:(0,M.jsxs)(`div`,{className:`mono-row`,children:[(0,M.jsx)(`code`,{className:`mono`,translate:`no`,children:t.public_key}),(0,M.jsx)(S,{text:t.public_key})]})}),(0,M.jsx)(Y,{title:o(`web3.label.combinedPrivate`),icon:(0,M.jsx)(se,{size:18}),accent:!0,children:(0,M.jsxs)(`div`,{className:`mono-row danger`,children:[(0,M.jsx)(`code`,{className:`mono`,translate:`no`,children:i?t.private_key:Oe(t.private_key)}),(0,M.jsx)(`button`,{className:`btn btn-icon`,onClick:a,title:o(i?`web3.action.hidePrivateKey`:`web3.action.showPrivateKey`),type:`button`,children:i?(0,M.jsx)(k,{size:14}):(0,M.jsx)(O,{size:14})})]})}),(0,M.jsx)(Y,{title:`IPNS ID`,icon:(0,M.jsx)(A,{size:18}),children:(0,M.jsxs)(`div`,{className:`mono-row`,children:[(0,M.jsx)(`code`,{className:`mono`,translate:`no`,children:n}),(0,M.jsx)(S,{text:n})]})})]})]})}function Ae({username:e,password:t,showPassword:n,generating:r,onUsernameChange:i,onPasswordChange:a,onTogglePassword:o,onGenerate:s}){let{t:c}=D();return(0,M.jsxs)(`div`,{className:`input-panel`,children:[(0,M.jsxs)(`div`,{className:`web3-tools-inputs`,children:[(0,M.jsx)(`input`,{type:`text`,placeholder:c(`login.username.placeholder`),value:e,onChange:e=>i(e.target.value),className:`input`,autoCapitalize:`off`,autoCorrect:`off`,spellCheck:`false`}),(0,M.jsxs)(`div`,{className:`input-wrap`,children:[(0,M.jsx)(`input`,{type:n?`text`:`password`,placeholder:c(`web3.login.passwordOptional`),value:t,onChange:e=>a(e.target.value),className:`input`,autoCapitalize:`off`,autoCorrect:`off`,spellCheck:`false`}),(0,M.jsx)(`button`,{className:`input-eye`,onClick:o,type:`button`,children:n?(0,M.jsx)(O,{size:16}):(0,M.jsx)(k,{size:16})})]})]}),(0,M.jsx)(`button`,{className:`btn btn-primary btn-full`,onClick:s,disabled:!e.trim()||r,type:`button`,children:r?(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(`span`,{className:`spinner`}),c(`web3.login.generating`)]}):(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(E,{size:16}),c(`web3.login.generateAndSignIn`)]})})]})}var je=e=>btoa(String.fromCharCode(...e)),Me=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${je(a).match(/.{1,64}/g)?.join(`
|
|
2
|
+
`)}\n-----END PRIVATE KEY-----`},Ne=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${je(i).match(/.{1,64}/g)?.join(`
|
|
3
|
+
`)}\n-----END PUBLIC KEY-----`},X=[`wallet`,`pem`,`export`,`EA`];function Pe(){let e=window.location.hash.replace(`#`,``);return X.includes(e)?e:`wallet`}function Fe(){let{t:e}=D(),t=te(),n=re(e=>e.isDarkMode),a=re(e=>e.setIsDarkMode),o=re(e=>e.addToast),f=u(e=>e.setUserIdentity),[h,_]=(0,j.useState)(`wallet`),[v,y]=(0,j.useState)(``),[S,O]=(0,j.useState)(``),[k,ie]=(0,j.useState)(!1),[A,ae]=(0,j.useState)(null),[oe,se]=(0,j.useState)(null),[ce,le]=(0,j.useState)(``),[ue,de]=(0,j.useState)(``),[N,pe]=(0,j.useState)(``),[P,F]=(0,j.useState)(``),[he,I]=(0,j.useState)([]),[L,R]=(0,j.useState)(0),[z,B]=(0,j.useState)(!0),[V,ge]=(0,j.useState)(!0),[H,_e]=(0,j.useState)(!1),[U,W]=(0,j.useState)(!1),[G,K]=(0,j.useState)(!1),[ve,ye]=(0,j.useState)(!1),[be,q]=(0,j.useState)(!1),[xe,Se]=(0,j.useState)(!1),[Ce,we]=(0,j.useState)(``),[Te,Ee]=(0,j.useState)(``),[J,Y]=(0,j.useState)(!1),[Oe,je]=(0,j.useState)(!1),[X,Fe]=(0,j.useState)(null),[Ie,Le]=(0,j.useState)(``),[Re,ze]=(0,j.useState)(``),[Be,Ve]=(0,j.useState)(!1),[He,Ue]=(0,j.useState)(!1),[Z,We]=(0,j.useState)(null),[Ge,Ke]=(0,j.useState)(`Hello B. This is from A.`),[qe,Je]=(0,j.useState)(``),[Ye,Xe]=(0,j.useState)(``),[Ze,Qe]=(0,j.useState)(``),[$e,et]=(0,j.useState)(`Hello A. This is from B.`),[tt,nt]=(0,j.useState)(``),[rt,it]=(0,j.useState)(``),[at,ot]=(0,j.useState)(``),[st,ct]=(0,j.useState)(``),[lt,ut]=(0,j.useState)(``),[dt,ft]=(0,j.useState)(``),[pt,mt]=(0,j.useState)(``),[ht,Q]=(0,j.useState)(``),[gt,_t]=(0,j.useState)(!1),[vt,yt]=(0,j.useState)(``),[bt,xt]=(0,j.useState)(``),[St,Ct]=(0,j.useState)(``),[wt,Tt]=(0,j.useState)(``),[Et,$]=(0,j.useState)(``),[Dt,Ot]=(0,j.useState)(!1);(0,j.useEffect)(()=>{_(Pe());let e=()=>_(Pe());return window.addEventListener(`hashchange`,e),()=>window.removeEventListener(`hashchange`,e)},[]);let kt=e=>{_(e),window.location.hash=e},At=(0,j.useCallback)(async()=>{if(!v.trim())return;Se(!0),await new Promise(e=>setTimeout(e,0));let t=d(v.trim(),S),n=`${t.username}#${t.address.slice(-4).toUpperCase()}`;ae(t),f({...t,displayName:n}),o(e(`login.toast.signedIn`,{username:t.username}),`success`),F(i(t.danger));let r=l(t.danger);se(r),le(x(r.private_key,r.ed_public_key));let a=C(r.private_key,r.ed_public_key);de(Me(a.secretKey)),pe(Ne(a.publicKey)),I([]),R(0),W(!1),K(!1),ye(!1),q(!1),Se(!1)},[o,S,f,e,v]);function jt(t,n,r){let i=t.trim();if(!i)return;let a=d(i,n),s=l(a.danger);r({username:a.username,address:a.address,publicKey:s.public_key,privateKey:s.private_key}),Xe(``),Qe(``),it(``),ot(``),o(e(`web3.toast.accountGenerated`),`success`)}function Mt({senderAccount:t,recipientAccount:n,message:i,setCipherText:a,setDecryptedText:o,setError:s}){if(!t||!n){s(e(`web3.error.accountsRequired`));return}if(!i.trim()){s(e(`web3.error.messageRequired`));return}a(r(i,{senderPrivateKey:t.privateKey,recipientPublicKey:n.publicKey})),o(``),s(``)}function Nt({senderAccount:t,recipientAccount:n,cipherText:r,setDecryptedText:i,setError:a}){if(!t||!n){a(e(`web3.error.accountsRequired`));return}if(!r.trim()){a(e(`web3.error.cipherRequired`));return}let o=s(r,{senderPublicKey:t.publicKey,recipientPrivateKey:n.privateKey});if(!o){a(e(`web3.error.decryptFailed`)),i(``);return}i(o),a(``)}function Pt(){if(!st.trim()){Q(e(`web3.error.senderPublicRequired`));return}if(!lt.trim()){Q(e(`web3.error.recipientPrivateRequired`));return}if(!dt.trim()){Q(e(`web3.error.cipherRequired`));return}let t=s(dt,{senderPublicKey:st.trim(),recipientPrivateKey:lt.trim()});if(!t){Q(e(`web3.error.decryptFailed`)),mt(``);return}mt(t),Q(``)}function Ft(){if(!vt.trim()){$(e(`web3.error.senderPrivateRequired`));return}if(!bt.trim()){$(e(`web3.error.recipientPublicRequired`));return}if(!St.trim()){$(e(`web3.error.messageRequired`));return}Tt(r(St,{senderPrivateKey:vt.trim(),recipientPublicKey:bt.trim()})),$(``)}let It=()=>{if(!P)return;let e=[];for(let t=L;t<L+10;t++){let n=`m/44'/60'/0'/0/${t}`,r=c.fromPhrase(P,void 0,n);e.push({index:t,address:r.address,privateKey:r.privateKey})}I(t=>[...t,...e]),R(e=>e+10)},Lt=ne(A?.address||void 0),Rt=h===`wallet`?`web3.view.wallet`:h===`pem`?`web3.view.pem`:h===`EA`?`web3.view.asymmetric`:`web3.view.export`,zt=[{id:`wallet`,icon:(0,M.jsx)(b,{size:16}),labelKey:`web3.view.wallet`},{id:`pem`,icon:(0,M.jsx)(g,{size:16}),labelKey:`web3.view.pem`},{id:`export`,icon:(0,M.jsx)(E,{size:16}),labelKey:`web3.view.export`},{id:`EA`,icon:(0,M.jsx)(w,{size:16}),labelKey:`web3.view.asymmetric`}],Bt=h!==`EA`;return(0,M.jsx)(T,{sidebar:({closeSidebar:n})=>(0,M.jsxs)(M.Fragment,{children:[(0,M.jsxs)(`button`,{type:`button`,className:`sidebar-header sidebar-header-link`,onClick:t,children:[(0,M.jsx)(ee,{size:18}),(0,M.jsx)(`h1`,{children:`MOST PEOPLE`})]}),(0,M.jsx)(`nav`,{className:`sidebar-nav`,children:zt.map(t=>(0,M.jsxs)(`button`,{onClick:()=>{kt(t.id),n()},className:`sidebar-nav-btn ${h===t.id?`active`:``}`,children:[t.icon,(0,M.jsx)(`span`,{children:e(t.labelKey)})]},t.id))})]}),headerTitle:(0,M.jsx)(`h2`,{className:`header-title`,children:e(Rt)}),headerRight:(0,M.jsx)(`button`,{className:`btn btn-icon`,onClick:()=>a(!n),title:e(`common.theme.toggle`),children:n?(0,M.jsx)(m,{size:16}):(0,M.jsx)(p,{size:16})}),children:(0,M.jsx)(`div`,{className:`web3-page`,children:(0,M.jsxs)(`div`,{className:`web3-container ${h===`EA`?`wide`:``}`,children:[Bt&&(0,M.jsx)(Ae,{username:v,password:S,showPassword:k,generating:xe,onUsernameChange:y,onPasswordChange:O,onTogglePassword:()=>ie(!k),onGenerate:At}),h===`wallet`&&(0,M.jsx)(ke,{walletResult:A,keys:oe,ipns:ce,avatarSrc:Lt,showPrivateKey:be,onTogglePrivateKey:()=>q(!be)}),h===`pem`&&(0,M.jsx)(me,{walletResult:A,publicPem:N,privatePem:ue}),h===`export`&&(0,M.jsx)(De,{walletResult:A,mnemonicPhrase:P,deriveBatch:10,deriveList:he,deriveShowIndex:z,deriveShowAddress:V,deriveShowPrivateKey:H,showAddressQr:U,showMnemonicReveal:G,showMnemonicQr:ve,onToggleAddressQr:()=>W(!U),onToggleMnemonicReveal:()=>K(!G),onToggleMnemonicQr:()=>ye(!ve),onToggleDeriveIndex:()=>B(!z),onToggleDeriveAddress:()=>ge(!V),onToggleDerivePrivateKey:()=>_e(!H),onDerive:It}),h===`EA`&&(0,M.jsx)(fe,{boxAUsername:Ce,boxAPassword:Te,boxAShowPassword:J,boxAShowPrivateKey:Oe,boxAAccount:X,boxBUsername:Ie,boxBPassword:Re,boxBShowPassword:Be,boxBShowPrivateKey:He,boxBAccount:Z,boxABMessage:Ge,boxABCipherText:qe,boxABDecryptedText:Ye,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:we,onBoxAPasswordChange:Ee,onBoxAShowPasswordToggle:()=>Y(!J),onBoxAShowPrivateKeyToggle:()=>je(!Oe),onGenerateBoxA:()=>jt(Ce,Te,Fe),onBoxBUsernameChange:Le,onBoxBPasswordChange:ze,onBoxBShowPasswordToggle:()=>Ve(!Be),onBoxBShowPrivateKeyToggle:()=>Ue(!He),onGenerateBoxB:()=>jt(Ie,Re,We),onBoxABMessageChange:Ke,onBoxABCipherTextChange:Je,onEncryptBoxAB:()=>Mt({senderAccount:X,recipientAccount:Z,message:Ge,setCipherText:Je,setDecryptedText:Xe,setError:Qe}),onDecryptBoxAB:()=>Nt({senderAccount:X,recipientAccount:Z,cipherText:qe,setDecryptedText:Xe,setError:Qe}),onBoxBAMessageChange:et,onBoxBACipherTextChange:nt,onEncryptBoxBA:()=>Mt({senderAccount:Z,recipientAccount:X,message:$e,setCipherText:nt,setDecryptedText:it,setError:ot}),onDecryptBoxBA:()=>Nt({senderAccount:Z,recipientAccount:X,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})]})})})}var Ie=f(`/web3/`)({component:Fe});export{Ie as Route};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e,o as t,t as n}from"./jsx-runtime-Bt-cYkS5.js";import{b as r,g as i,t as a,v as o,x as ee}from"./userStore-q0BBZsIV.js";import{n as s,t as c}from"./triangle-alert-D-qigSSn.js";import{t as l}from"./download-Bhqn6hL1.js";import{t as te}from"./external-link-CNR21yFA.js";import{t as ne}from"./file-text-CFfvvCnM.js";import{t as re}from"./hard-drive-4vHpA5kz.js";import{t as ie}from"./refresh-cw--JB8k6mH.js";import{I as u,S as ae,m as d,v as oe,z as se}from"./index-DN0kD5zr.js";import{t as f}from"./format-CR8oUWq6.js";import{i as ce,n as p,r as m,t as h}from"./downloadValidation-xzpa5rap.js";var le=i(`circle-x`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m15 9-6 6`,key:`1uzhvr`}],[`path`,{d:`m9 9 6 6`,key:`z0biqf`}]]),g=i(`loader-circle`,[[`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`,key:`13zald`}]]),_=i(`log-in`,[[`path`,{d:`m10 17 5-5-5-5`,key:`1bsop3`}],[`path`,{d:`M15 12H3`,key:`6jk70r`}],[`path`,{d:`M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4`,key:`u53s6r`}]]),v=i(`wifi-off`,[[`path`,{d:`M12 20h.01`,key:`zekei9`}],[`path`,{d:`M8.5 16.429a5 5 0 0 1 7 0`,key:`1bycff`}],[`path`,{d:`M5 12.859a10 10 0 0 1 5.17-2.69`,key:`1dl1wf`}],[`path`,{d:`M19 12.859a10 10 0 0 0-2.007-1.523`,key:`4k23kn`}],[`path`,{d:`M2 8.82a15 15 0 0 1 4.177-2.643`,key:`1grhjp`}],[`path`,{d:`M22 8.82a15 15 0 0 0-11.288-3.764`,key:`z3jwby`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),y=t(e(),1),b=n(),ue=1800;function x(e,t){return`most://${e}${t||``}`}function S(e,t){let n=e.trim().replace(/[\\/]+$/,``);return n?`${n}${n.includes(`\\`)?`\\`:`/`}downloads`:t}function C(e,t){let n=e[t];return typeof n==`string`?n:void 0}function w(e,t){let n=e[t];return typeof n==`number`&&Number.isFinite(n)?n:void 0}function T(e){let t;try{t=JSON.parse(e)}catch{return null}if(!t||typeof t!=`object`)return null;let n=t,r=C(n,`event`),i=n.data;if(!r||!i||typeof i!=`object`)return null;let a=i;return{event:r,payload:{taskId:C(a,`taskId`),percent:w(a,`percent`),loaded:w(a,`loaded`),total:w(a,`total`),file:C(a,`file`),fileName:C(a,`fileName`),error:C(a,`error`)}}}function E(){let{t:e}=u(),{cid:t}=ee({from:`/cid/$cid/`}),n=se({select:e=>e.searchStr}),i=d(e=>e.hasBackend),o=d(e=>e.addToast),s=d(e=>e.openConnectModal),C=a(e=>e.identity),w=a(e=>e.openLoginModal),E=(0,y.useMemo)(()=>x(t,n),[t,n]),k=(0,y.useMemo)(()=>ce(E),[E]),A=(0,y.useMemo)(()=>h(E,e),[E,e]),de=k.fileName||t,[j,M]=(0,y.useState)({status:`idle`,message:``}),[N,P]=(0,y.useState)(null),[F,I]=(0,y.useState)({status:`idle`,message:``}),[L,R]=(0,y.useState)(``),[z,B]=(0,y.useState)(0),[V,H]=(0,y.useState)(null),[U,W]=(0,y.useState)(null),[fe,G]=(0,y.useState)(``),[pe,K]=(0,y.useState)(!1),q=(0,y.useRef)(0),J=(0,y.useRef)(null),Y=N?.fileName||de,X=N?.size??U,Z=j.status===`available`||j.status===`already-local`,Q=F.status===`starting`||F.status===`downloading`,me=S(fe,e(`cid.saveToFallback`)),$=(0,y.useCallback)(async()=>{let t=q.current+1;if(q.current=t,R(``),B(0),H(null),W(null),I({status:`idle`,message:``}),A){P(null),M({status:`error`,message:A});return}if(i===null){P(null),M({status:`waiting-backend`,message:e(`cid.status.waitingBackend`)});return}if(i!==!0){P(null),M({status:`backend-missing`,message:e(`cid.status.backendMissing`)});return}if(!C){P(null),M({status:`login-required`,message:e(`cid.status.loginRequired`)});return}M({status:`checking`,message:e(`cid.status.checking`)}),P(null);try{let n=await p.checkDownload(E);if(q.current!==t)return;P(n),M({status:n.alreadyExists?`already-local`:`available`,message:n.alreadyExists?e(`cid.status.alreadyLocal`,{fileName:n.fileName}):e(`cid.status.available`,{fileName:n.fileName})})}catch(e){if(q.current!==t)return;M({status:`error`,message:await m(e)}),P(null)}},[i,E,e,C,A]);(0,y.useEffect)(()=>{document.title=e(`cid.meta.title`)},[e]),(0,y.useEffect)(()=>{let e=()=>{J.current!==null&&(window.clearTimeout(J.current),J.current=null)},t=()=>{document.visibilityState===`hidden`&&(e(),K(!1))};return document.addEventListener(`visibilitychange`,t),window.addEventListener(`pagehide`,t),()=>{e(),document.removeEventListener(`visibilitychange`,t),window.removeEventListener(`pagehide`,t)}},[]),(0,y.useEffect)(()=>{$()},[$]),(0,y.useEffect)(()=>{if(i!==!0)return;let e=!1;return p.getDataPath().then(t=>{e||G(t.dataPath)}).catch(()=>{e||G(``)}),()=>{e=!0}},[i]),(0,y.useEffect)(()=>{if(!L||!C)return;let t=null,n=!1;return(async()=>{if(t=new WebSocket(await ae(`/ws`)),n){t.close();return}t.onmessage=t=>{let n=T(t.data);!n||n.payload.taskId!==L||(n.event===`download:progress`&&(B(n.payload.percent||0),H(n.payload.loaded??null),W(n.payload.total??null)),n.event===`download:status`&&I({status:`downloading`,message:n.payload.file?e(`cid.status.downloadingFile`,{fileName:n.payload.file}):e(`cid.status.downloading`)}),n.event===`download:success`&&(B(100),I({status:`completed`,message:e(`cid.status.downloadComplete`,{fileName:n.payload.fileName||Y})}),o(e(`cid.toast.downloadComplete`),`success`)),n.event===`download:error`&&(I({status:`error`,message:n.payload.error||e(`cid.status.downloadFailed`,{error:``})}),o(e(`cid.toast.downloadFailed`,{error:n.payload.error||e(`cid.errorFallback`)}),`error`)),n.event===`download:cancelled`&&(I({status:`cancelled`,message:e(`cid.status.cancelled`)}),o(e(`cid.toast.cancelled`),`warning`)))}})(),()=>{n=!0,t?.close()}},[o,Y,e,L,C]);let he=async()=>{if(!C){w();return}if(i!==!0){s();return}if(!(!Z||Q)){I({status:`starting`,message:e(`cid.status.startingDownload`)}),B(0);try{let t=await p.downloadFile(E);if(t.alreadyExists){I({status:`completed`,message:e(`cid.status.alreadyLocal`,{fileName:t.fileName||Y})}),o(e(`cid.toast.alreadyLocal`),`warning`);return}t.taskId&&(R(t.taskId),I({status:`downloading`,message:e(`cid.status.downloading`)}),o(e(`cid.toast.downloadStarted`),`info`))}catch(t){let n=await oe(t,e(`cid.status.downloadFailed`,{error:e(`cid.errorFallback`)}));I({status:`error`,message:n}),o(n,`error`)}}},ge=()=>{K(!1),J.current!==null&&window.clearTimeout(J.current),J.current=window.setTimeout(()=>{J.current=null,document.visibilityState!==`hidden`&&K(!0)},ue)},_e=async()=>{L&&await p.cancelDownload(L).catch(()=>{})},ve=D(j.status,F.status);return(0,b.jsx)(`main`,{className:`cid-page`,children:(0,b.jsxs)(`section`,{className:`cid-shell`,children:[(0,b.jsxs)(`div`,{className:`cid-heading`,children:[(0,b.jsx)(`span`,{className:`cid-kicker`,children:e(`cid.kicker`)}),(0,b.jsx)(`h1`,{children:e(`cid.title`)}),(0,b.jsx)(`p`,{children:e(`cid.subtitle`)})]}),(0,b.jsxs)(`div`,{className:`cid-panel`,children:[(0,b.jsxs)(`div`,{className:`cid-handoff`,"aria-label":e(`cid.handoff.title`),children:[(0,b.jsxs)(`div`,{className:`cid-handoff-copy`,children:[(0,b.jsx)(`p`,{className:`cid-handoff-title`,children:e(`cid.handoff.title`)}),(0,b.jsx)(`p`,{children:e(`cid.handoff.desc`)})]}),(0,b.jsxs)(`a`,{className:`btn btn-primary`,href:E,onClick:ge,children:[(0,b.jsx)(te,{size:16}),e(`cid.handoff.action`)]})]}),pe&&(0,b.jsxs)(`div`,{className:`cid-handoff-fallback`,role:`status`,children:[(0,b.jsx)(c,{size:18}),(0,b.jsx)(`p`,{children:e(`cid.handoff.fallback`)}),(0,b.jsxs)(r,{to:`/download/`,className:`btn btn-secondary`,children:[(0,b.jsx)(l,{size:16}),e(`cid.handoff.downloadAction`)]})]}),(0,b.jsxs)(`div`,{className:`cid-status`,children:[(0,b.jsx)(`span`,{className:`cid-status-icon ${j.status}`,children:ve}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`p`,{className:`cid-status-label`,children:O(j.status,e)}),(0,b.jsx)(`p`,{className:`cid-status-message`,children:j.message})]})]}),(0,b.jsxs)(`dl`,{className:`cid-details`,children:[(0,b.jsxs)(`div`,{children:[(0,b.jsxs)(`dt`,{children:[(0,b.jsx)(ne,{size:16}),e(`cid.fileNameLabel`)]}),(0,b.jsx)(`dd`,{children:Y})]}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`dt`,{children:e(`cid.cidLabel`)}),(0,b.jsx)(`dd`,{className:`cid-mono`,children:t})]}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`dt`,{children:e(`cid.sizeLabel`)}),(0,b.jsx)(`dd`,{children:X?f(X):e(`cid.unknownSize`)})]}),(0,b.jsxs)(`div`,{children:[(0,b.jsxs)(`dt`,{children:[(0,b.jsx)(re,{size:16}),e(`cid.saveToLabel`)]}),(0,b.jsx)(`dd`,{children:me})]})]}),F.status!==`idle`&&(0,b.jsxs)(`div`,{className:`cid-download-state ${F.status}`,children:[(0,b.jsx)(`p`,{children:F.message}),(F.status===`starting`||F.status===`downloading`)&&(0,b.jsxs)(`div`,{className:`cid-progress`,children:[(0,b.jsx)(`progress`,{className:`cid-progress-bar`,value:z,max:100}),(0,b.jsx)(`span`,{children:V!==null&&U!==null?`${f(V)} / ${f(U)}`:`${z}%`})]})]}),(0,b.jsxs)(`div`,{className:`cid-actions`,children:[j.status===`login-required`&&(0,b.jsxs)(`button`,{className:`btn btn-primary`,onClick:w,children:[(0,b.jsx)(_,{size:16}),e(`cid.loginAction`)]}),j.status===`backend-missing`&&(0,b.jsxs)(`button`,{className:`btn btn-primary`,onClick:s,children:[(0,b.jsx)(v,{size:16}),e(`cid.connectAction`)]}),(0,b.jsxs)(`button`,{className:`btn btn-primary`,disabled:!Z||Q,onClick:he,children:[Q?(0,b.jsx)(g,{className:`cid-spin-icon`,size:16}):(0,b.jsx)(l,{size:16}),e(Q?`cid.downloadingAction`:`cid.startAction`)]}),L&&F.status===`downloading`&&(0,b.jsxs)(`button`,{className:`btn btn-secondary`,onClick:_e,children:[(0,b.jsx)(le,{size:16}),e(`cid.cancelAction`)]}),(0,b.jsxs)(`button`,{className:`btn btn-secondary`,disabled:j.status===`checking`,onClick:$,children:[(0,b.jsx)(ie,{size:16}),e(`cid.retryAction`)]}),(0,b.jsx)(r,{to:`/app/`,className:`btn btn-secondary`,children:e(`cid.openAppAction`)})]})]})]})})}function D(e,t){return t===`completed`?(0,b.jsx)(s,{size:28}):t===`error`||e===`error`?(0,b.jsx)(c,{size:28}):e===`checking`||e===`waiting-backend`||t===`starting`||t===`downloading`?(0,b.jsx)(g,{size:28}):e===`backend-missing`?(0,b.jsx)(v,{size:28}):e===`login-required`?(0,b.jsx)(_,{size:28}):(0,b.jsx)(s,{size:28})}function O(e,t){switch(e){case`checking`:return t(`cid.label.checking`);case`available`:return t(`cid.label.available`);case`already-local`:return t(`cid.label.alreadyLocal`);case`login-required`:return t(`cid.label.loginRequired`);case`backend-missing`:return t(`cid.label.backendMissing`);case`waiting-backend`:return t(`cid.label.waitingBackend`);case`error`:return t(`cid.label.error`);default:return t(`cid.label.idle`)}}var k=o(`/cid/$cid/`)({component:E});export{k as Route};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{g as e}from"./userStore-q0BBZsIV.js";var t=e(`key-round`,[[`path`,{d:`M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z`,key:`1s6t7t`}],[`circle`,{cx:`16.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`w0ekpg`}]]);export{t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{g as e}from"./userStore-q0BBZsIV.js";var t=e(`loader`,[[`path`,{d:`M12 2v4`,key:`3427ic`}],[`path`,{d:`m16.2 7.8 2.9-2.9`,key:`r700ao`}],[`path`,{d:`M18 12h4`,key:`wj9ykh`}],[`path`,{d:`m16.2 16.2 2.9 2.9`,key:`1bxg5t`}],[`path`,{d:`M12 18v4`,key:`jadmvz`}],[`path`,{d:`m4.9 19.1 2.9-2.9`,key:`bwix9q`}],[`path`,{d:`M2 12h4`,key:`j09sii`}],[`path`,{d:`m4.9 4.9 2.9 2.9`,key:`giyufr`}]]);export{t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{g as e}from"./userStore-q0BBZsIV.js";var t=e(`chevron-down`,[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]),n=e(`lock`,[[`rect`,{width:`18`,height:`11`,x:`3`,y:`11`,rx:`2`,ry:`2`,key:`1w4ew1`}],[`path`,{d:`M7 11V7a5 5 0 0 1 10 0v4`,key:`fwvmzm`}]]);export{t as n,n as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{g as e}from"./userStore-q0BBZsIV.js";var t=e(`message-square`,[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}]]);export{t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e,o as t,t as n}from"./jsx-runtime-Bt-cYkS5.js";import{
|
|
1
|
+
import{n as e,o as t,t as n}from"./jsx-runtime-Bt-cYkS5.js";import{f as r,g as i,m as a}from"./userStore-q0BBZsIV.js";import{a as o}from"./LanguageToggle-B99eQcTE.js";import{t as s}from"./copy-5aEv78Eq.js";import{I as c}from"./index-DN0kD5zr.js";import{t as l}from"./dayjs.min-Dcc0B6Je.js";var u=i(`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`}]]),d=i(`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`}]]),f=t(e(),1),p=n();function m({text:e,label:t,copiedLabel:n,className:r=`btn btn-icon`,iconSize:i=14}){let{t:a}=c(),[l,u]=(0,f.useState)(!1),d=n||a(`common.copied`),m=t||a(`common.copy`);async function h(){try{await navigator.clipboard.writeText(e),u(!0),setTimeout(()=>u(!1),1500)}catch{}}return(0,p.jsxs)(`button`,{type:`button`,className:r,onClick:h,title:l?d:m,children:[l?(0,p.jsx)(o,{size:i}):(0,p.jsx)(s,{size:i}),t?l?d:t:null]})}var h=t(r(),1);l();var g=`0123456789abcdefghijklmnopqrstuvwxyz`,_=e=>{let t=[];for(;e>=128;)t.push(e&127|128),e>>=7;return t.push(e),t},v=e=>{let t=new Uint8Array([8,1,18,..._(e.length)]),n=new Uint8Array(t.length+e.length);return n.set(t,0),n.set(e,t.length),n},y=(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},b=(e,t)=>{let n=t.slice(2),r=new Uint8Array(a(e+n));return h.default.sign.keyPair.fromSecretKey(r)},x=(e,t)=>{let n=v(b(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`+y(a,g)};export{u as a,d as i,x as n,m as r,b as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{g as e}from"./userStore-q0BBZsIV.js";var t=e(`music`,[[`path`,{d:`M9 18V5l12-2v13`,key:`1jmyc2`}],[`circle`,{cx:`6`,cy:`18`,r:`3`,key:`fqmcym`}],[`circle`,{cx:`18`,cy:`16`,r:`3`,key:`1hluhg`}]]);export{t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{g as e}from"./userStore-q0BBZsIV.js";var t=e(`notebook-pen`,[[`path`,{d:`M13.4 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-7.4`,key:`re6nr2`}],[`path`,{d:`M2 6h4`,key:`aawbzj`}],[`path`,{d:`M2 10h4`,key:`l0bgd4`}],[`path`,{d:`M2 14h4`,key:`1gsvsf`}],[`path`,{d:`M2 18h4`,key:`1bu2t1`}],[`path`,{d:`M21.378 5.626a1 1 0 1 0-3.004-3.004l-5.01 5.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z`,key:`pqwjuv`}]]);export{t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{g as e}from"./userStore-q0BBZsIV.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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{g as e}from"./userStore-q0BBZsIV.js";var t=e(`plus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]);export{t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{g as e}from"./userStore-q0BBZsIV.js";var t=e(`refresh-cw`,[[`path`,{d:`M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8`,key:`v9h5vc`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}],[`path`,{d:`M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16`,key:`3uifl3`}],[`path`,{d:`M8 16H3v5`,key:`1cv678`}]]);export{t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{g as e}from"./userStore-q0BBZsIV.js";var t=e(`save`,[[`path`,{d:`M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z`,key:`1c8476`}],[`path`,{d:`M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7`,key:`1ydtos`}],[`path`,{d:`M7 3v4a1 1 0 0 0 1 1h7`,key:`t51u73`}]]);export{t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{g as e}from"./userStore-q0BBZsIV.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 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{g as e}from"./userStore-q0BBZsIV.js";var t=e(`send`,[[`path`,{d:`M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z`,key:`1ffxy3`}],[`path`,{d:`m21.854 2.147-10.94 10.939`,key:`12cjpa`}]]);export{t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{g as e}from"./userStore-q0BBZsIV.js";var t=e(`shield-check`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]);export{t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{g as e}from"./userStore-q0BBZsIV.js";var t=e(`trash-2`,[[`path`,{d:`M10 11v6`,key:`nco0om`}],[`path`,{d:`M14 11v6`,key:`outv1u`}],[`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`,key:`miytrc`}],[`path`,{d:`M3 6h18`,key:`d0wm0j`}],[`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`,key:`e791ji`}]]);export{t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{g as e}from"./userStore-q0BBZsIV.js";var t=e(`circle-check`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]),n=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 as n,n as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{g as e}from"./userStore-q0BBZsIV.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,3 +1,3 @@
|
|
|
1
|
-
import{n as e,o as t}from"./jsx-runtime-Bt-cYkS5.js";import{t as n}from"./userStore-
|
|
1
|
+
import{n as e,o as t}from"./jsx-runtime-Bt-cYkS5.js";import{t as n}from"./userStore-q0BBZsIV.js";import{S as r}from"./index-DN0kD5zr.js";import{i,r as a}from"./userProfile-BmzBA_Bk.js";var o=t(e(),1);function s(e=``,t=[]){let n=[e,...t];return[...new Set(n.filter(Boolean))]}function c(e=[]){return s(``,e).join(`
|
|
2
2
|
`)}function l(e,t){let n=new Set(e),r=new Set(t);return{subscribe:[...r].filter(e=>!n.has(e)),unsubscribe:[...n].filter(e=>!r.has(e))}}function u(e){return String(e.id||`${e.author||``}-${e.timestamp||``}-${e.content||``}`)}function d(e){let t=Number(e.timestamp);return Number.isFinite(t)?t:0}function f(e){return e.map((e,t)=>({message:e,index:t})).sort((e,t)=>{let n=d(e.message)-d(t.message);return n===0?e.index-t.index:n}).map(e=>e.message)}function p({isReady:e,enabled:t=!0,channelName:d=``,extraSubscribedChannelNames:p=[],peerId:m=``,waitForPeerId:h=!1,limit:g=100,reconnectBaseDelay:_=2500,acceptMessage:v,getMessageKey:y=u,onSyncError:b,onSocketEvent:x,onReconnect:S}){let C=n(e=>e.identity),[w,T]=(0,o.useState)([]),[E,D]=(0,o.useState)(!1),O=(0,o.useMemo)(()=>c(p),[p]),k=(0,o.useRef)(null),A=(0,o.useRef)(d),j=(0,o.useRef)(p),M=(0,o.useRef)(null),N=(0,o.useRef)(0),P=(0,o.useRef)(v),F=(0,o.useRef)(y),I=(0,o.useRef)(x),L=(0,o.useRef)(b),R=(0,o.useRef)(S),z=(0,o.useRef)(m),B=(0,o.useRef)(new Set);(0,o.useEffect)(()=>{j.current=O?O.split(`
|
|
3
|
-
`):[]},[O]),(0,o.useEffect)(()=>{P.current=v},[v]),(0,o.useEffect)(()=>{F.current=y},[y]),(0,o.useEffect)(()=>{I.current=x},[x]),(0,o.useEffect)(()=>{L.current=b},[b]),(0,o.useEffect)(()=>{R.current=S},[S]);let V=(0,o.useCallback)(e=>{let t=P.current;return t?e.filter(t):e},[]),H=(0,o.useCallback)((e,t,n=!0)=>{let r=[...e];for(let e of V(t)){let t=F.current(e);if(n){let n=r.findIndex(t=>t.pending&&t.author?.toLowerCase()===e.author?.toLowerCase()&&t.content===e.content);if(n!==-1){r[n]={...e,id:e.id||t};continue}}r.some(e=>F.current(e)===t)||r.push({...e,id:e.id||t})}return f(r)},[V]),U=(0,o.useCallback)((e,t)=>{k.current?.readyState===WebSocket.OPEN&&k.current.send(JSON.stringify({event:e,data:t}))},[]),W=(0,o.useCallback)(e=>{let t=new Set(e.filter(Boolean)),n=l(B.current,t);for(let e of n.unsubscribe)U(`channel:unsubscribe`,{channel:e});for(let e of n.subscribe)U(`channel:subscribe`,{channel:e});B.current=t},[U]),G=(0,o.useCallback)(()=>s(A.current,j.current),[]),K=(0,o.useCallback)(async(t=A.current,n={})=>{if(!t||!e)return[];try{let e=V(await
|
|
3
|
+
`):[]},[O]),(0,o.useEffect)(()=>{P.current=v},[v]),(0,o.useEffect)(()=>{F.current=y},[y]),(0,o.useEffect)(()=>{I.current=x},[x]),(0,o.useEffect)(()=>{L.current=b},[b]),(0,o.useEffect)(()=>{R.current=S},[S]);let V=(0,o.useCallback)(e=>{let t=P.current;return t?e.filter(t):e},[]),H=(0,o.useCallback)((e,t,n=!0)=>{let r=[...e];for(let e of V(t)){let t=F.current(e);if(n){let n=r.findIndex(t=>t.pending&&t.author?.toLowerCase()===e.author?.toLowerCase()&&t.content===e.content);if(n!==-1){r[n]={...e,id:e.id||t};continue}}r.some(e=>F.current(e)===t)||r.push({...e,id:e.id||t})}return f(r)},[V]),U=(0,o.useCallback)((e,t)=>{k.current?.readyState===WebSocket.OPEN&&k.current.send(JSON.stringify({event:e,data:t}))},[]),W=(0,o.useCallback)(e=>{let t=new Set(e.filter(Boolean)),n=l(B.current,t);for(let e of n.unsubscribe)U(`channel:unsubscribe`,{channel:e});for(let e of n.subscribe)U(`channel:subscribe`,{channel:e});B.current=t},[U]),G=(0,o.useCallback)(()=>s(A.current,j.current),[]),K=(0,o.useCallback)(async(t=A.current,n={})=>{if(!t||!e)return[];try{let e=V(await i.getChannelMessages(t,g));return T(t=>n.replace?f(e):H(t,e,!1)),e}catch(e){return n.replace&&T([]),await L.current?.(e),[]}},[V,e,g,H]);(0,o.useEffect)(()=>{z.current=m,m&&(U(`register`,{peerId:m}),h&&(W(G()),A.current&&K(A.current,{replace:!0})))},[G,m,W,K,h,U]);let q=(0,o.useCallback)(()=>{T([])},[]),J=(0,o.useCallback)(async({channelName:e=A.current,content:t,attachment:n,optimisticId:r})=>{let o=t.trim();if(!e||!o||!C)return null;let s=a(C),c={id:r||`${s.author}-${Date.now()}-${Math.random().toString(36).slice(2)}`,...s,content:o,timestamp:Date.now(),pending:!0,attachment:n};T(e=>f([...e,c]));try{let t=await i.sendChannelMessage({channelName:e,content:o,...s,attachment:n});return T(e=>f(e.map(e=>e.id===c.id?{...t.message,id:t.message.id||F.current(t.message)}:e))),t.message}catch(e){throw T(e=>e.filter(e=>e.id!==c.id)),e}},[C]);return(0,o.useEffect)(()=>{A.current=d,!(!e||!t)&&(d&&K(d,{replace:!0}),(!h||z.current)&&W(G()))},[d,t,O,G,e,W,K,h]),(0,o.useEffect)(()=>{!e||!t||h&&!z.current||W(G())},[t,G,e,W,h]),(0,o.useEffect)(()=>{if(!e||!t){D(!1);return}let n=!1;N.current=0;async function i(){let e=new WebSocket(await r(`/ws`));if(n){e.close();return}e.onopen=()=>{D(!0),N.current=0,z.current&&e.send(JSON.stringify({event:`register`,data:{peerId:z.current}})),(!h||z.current)&&(B.current.clear(),W(G()),A.current&&K(A.current,{replace:!0}),R.current?.())},e.onmessage=e=>{try{let t=JSON.parse(e.data);I.current?.(t.event,t.data),t.event===`channel:message`&&t.data?.channel===A.current&&t.data?.message&&T(e=>H(e,[t.data.message])),t.event===`user:metadata:updated`&&t.data?.scope===`channels`&&A.current&&K(A.current,{replace:!0})}catch{}},e.onclose=()=>{if(D(!1),n)return;let e=N.current;if(e>=20)return;let t=Math.min(_*2**e,3e4);N.current=e+1,M.current=setTimeout(i,t)},e.onerror=()=>e.close(),k.current=e}return i(),()=>{n=!0,M.current&&clearTimeout(M.current),k.current?.close(),k.current=null,B.current.clear()}},[t,G,e,H,_,W,K,h]),{clearMessages:q,connected:E,messages:w,sendMessage:J,setMessages:T,syncMessages:K}}export{p as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e,o as t,t as n}from"./jsx-runtime-Bt-cYkS5.js";import{b as r,g as i,t as a}from"./userStore-q0BBZsIV.js";import{I as o,N as s,O as c,m as l,v as u}from"./index-DN0kD5zr.js";import{t as d}from"./SidebarAccount-CpNVqNva.js";import{i as f,n as p,r as m,t as h}from"./userProfile-BmzBA_Bk.js";import{t as g}from"./useChannelMessages-DS1ntAKN.js";var _=i(`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`}]]),v=i(`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`}]]),y=n(),b=[{id:`gandengyan`,labelKey:`game.gandengyan.title`,href:`/game/gandengyan/`,icon:(0,y.jsx)(v,{size:16})},{id:`zhajinhua`,labelKey:`game.zhajinhua.title`,href:`/game/zhajinhua/`,icon:(0,y.jsx)(_,{size:16})}];function x({activeGame:e,closeSidebar:t}){let{t:n}=o();return(0,y.jsxs)(y.Fragment,{children:[(0,y.jsxs)(`button`,{type:`button`,className:`sidebar-header sidebar-header-link`,onClick:c(),children:[(0,y.jsx)(s,{size:18}),(0,y.jsx)(`h1`,{children:`MOST PEOPLE`})]}),(0,y.jsx)(`nav`,{className:`sidebar-nav`,children:b.map(i=>(0,y.jsxs)(r,{to:i.href,className:`sidebar-nav-btn ${e===i.id?`active`:``}`,onClick:t,children:[i.icon,(0,y.jsx)(`span`,{children:n(i.labelKey)})]},i.id))}),(0,y.jsx)(d,{})]})}var S=t(e(),1),C=`game`,w=`mostbox.game.event`,T=[`gandengyan`,`zhajinhua`],E=`ABCDEFGHJKLMNPQRSTUVWXYZ23456789`;function D(e){let t=String(e||``).trim().toLowerCase();return T.includes(t)?t:``}function O(e){return String(e||``).trim().toUpperCase().replace(/[^A-Z0-9]/g,``).slice(0,8)}function k(e){return/^[A-Z0-9]{4,8}$/.test(String(e||``))}function A(){let e=``;for(let t=0;t<6;t++)e+=E[V(32)];return e}function j(e,t){let n=D(e),r=O(t);return!n||!k(r)?``:`game.${n}.${r.toLowerCase()}`}function M({gameId:e,roomCode:t,event:n,payload:r}){let i=D(e);return{kind:w,version:1,gameId:i,roomCode:O(t),event:String(n||``),eventId:B(i||`game`),payload:r||{}}}function N(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=D(n.gameId),i=O(n.roomCode);return!r||!k(i)||t.gameId&&r!==D(t.gameId)||t.roomCode&&i!==O(t.roomCode)?null:{...n,gameId:r,roomCode:i,payload:n.payload&&typeof n.payload==`object`?n.payload:{}}}catch{return null}}function P(e=[],t={}){let n=[],r=new Map,i=``;for(let a of z(e)){let e=N(a.content,t);if(e){if(e.event===`room:create`){let t=I(e.payload?.player,a);if(!t)continue;i||=t.address,R(n,r,t);continue}if(e.event===`player:join`){let t=I(e.payload?.player,a);t&&R(n,r,t);continue}if(e.event===`player:leave`){let t=L(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:D(t.gameId),roomCode:O(t.roomCode),hostAddress:i,players:n}}function F(e=[],t={}){let n=null;for(let r of z(e)){let e=N(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 I(e,t){if(!e||typeof e!=`object`)return null;let n=t&&typeof t==`object`?t:{author:t},r=n.author,i=L(e.address||r);if(!i||L(r)!==i)return null;let a=String(n.authorName||e.name||``).trim().slice(0,50)||U(i),o=String(n.avatar||e.avatar||``).trim(),s={address:i,name:a,publicKey:String(e.publicKey||``).trim(),joinedAt:Number(e.joinedAt||Date.now())};return o&&(s.avatar=o.slice(0,4096)),s}function L(e){let t=String(e||``).trim();return/^0x[a-fA-F0-9]{40}$/.test(t)?t.toLowerCase():``}function R(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 z(e){return[...e].sort((e,t)=>Number(e.timestamp||0)-Number(t.timestamp||0))}function B(e){return`${e}_${Date.now()}_${H(4)}`}function V(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 H(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 U(e){return e?`${e.slice(0,6)}...${e.slice(-4)}`:``}function W({gameId:e,onError:t,getPlayerPayload:n}){let{t:r}=o(),i=l(e=>e.hasBackend),s=l(e=>e.checkBackend),c=l(e=>e.openConnectModal),d=a(e=>e.identity),p=a(e=>e.openLoginModal),[m,_]=(0,S.useState)(``),[v,y]=(0,S.useState)(``),[b,x]=(0,S.useState)(!1),w=i===!0,T=(0,S.useCallback)(async(e,n)=>{let r=await u(e,n);t&&t(r)},[t]),E=(0,S.useCallback)(t=>!!N(t.content,{gameId:e,roomCode:m}),[e,m]),D=(0,S.useCallback)(t=>{let n=N(t.content,{gameId:e,roomCode:m});return n?`${t.author}-${n.eventId}`:`${t.author}-${t.timestamp}-${t.content}`},[e,m]),{clearMessages:k,connected:P,messages:F,sendMessage:I,syncMessages:L}=g({isReady:w,enabled:!!d,channelName:v,limit:500,acceptMessage:E,getMessageKey:D,onSyncError:e=>T(e,r(`game.room.error.readLog`))}),R=(0,S.useMemo)(()=>F.map(t=>({message:t,event:N(t.content,{gameId:e,roomCode:m})})).filter(e=>e.event),[e,F,m]),z=(0,S.useCallback)(()=>d?w?!0:(c(),!1):(p(),!1),[w,c,p,d]);(0,S.useEffect)(()=>{i===null&&s()},[s,i]);let B=(0,S.useCallback)(async(i,a=!1)=>{if(!z()||!d)return!1;let o=a?A():O(i),s=j(e,o);if(!s)return t&&t(r(`game.room.error.invalidCode`)),!1;x(!0);try{let t=await f.createChannel(s,C,h(d)),r=t.channelKey||t.key||s;return await G(r,d,e,o,a?`room:create`:`player:join`,{player:q(d,n?.(d))}),_(o),y(r),k(),!0}catch(e){return await T(e,r(a?`game.room.error.createFailed`:`game.room.error.joinFailed`)),!1}finally{x(!1)}},[z,e,n,t,T,k,r,d]);return{channelName:v,connected:P,createRoom:(0,S.useCallback)(()=>B(``,!0),[B]),ensureReady:z,isBackendReady:w,joinRoom:(0,S.useCallback)(e=>B(e),[B]),joining:b,messages:F,roomCode:m,roomEvents:R,sendRoomEvent:(0,S.useCallback)(async(t,n={})=>{if(!z()||!d||!v||!m)return!1;let i=M({gameId:e,roomCode:m,event:t,payload:n}),a=JSON.stringify(i);try{return await I({channelName:v,content:a,optimisticId:`${d.address}-${i.eventId}`}),!0}catch(e){return await T(e,r(`game.room.error.sendEventFailed`)),!1}},[v,z,e,T,m,I,r,d]),setRoomCode:_,syncMessages:L,userIdentity:d}}async function G(e,t,n,r,i,a){let o=M({gameId:n,roomCode:r,event:i,payload:a});await f.sendChannelMessage({channelName:e,content:JSON.stringify(o),...m(t)})}function K(e){return{address:e.address,name:p(e),avatar:e.avatar||``,publicKey:``,joinedAt:Date.now()}}function q(e,t={}){let n=K(e),r={...n,...t};return Object.prototype.hasOwnProperty.call(t,`avatar`)||(r.avatar=n.avatar),r}export{_ as a,x as i,P as n,F as r,W as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{h as e,x as t}from"./index-DN0kD5zr.js";var n={getChannels(t={}){let n=new URLSearchParams;t.type&&n.set(`type`,t.type);let r=n.toString();return e.get(r?`/api/channels?${r}`:`/api/channels`).json()},createChannel(t,n=`personal`,r={}){return e.post(`/api/channels`,{json:{name:t,type:n,...r}}).json()},leaveChannel(t){return e.delete(`/api/channels`,{json:{channelKey:t}}).json()},getChannelMessages(t,n=100,r=0){return e.get(`/api/channels/${encodeURIComponent(t)}/messages?limit=${n}&offset=${r}`).json()},sendChannelMessage({channelName:t,content:n,author:r,authorName:i,avatar:a,attachment:o}){return e.post(`/api/channels/${encodeURIComponent(t)}/messages`,{json:o?{content:n,author:r,authorName:i,avatar:a,attachment:o}:{content:n,author:r,authorName:i,avatar:a}}).json()},getChannelMembers(t){return e.get(`/api/channels/${encodeURIComponent(t)}/members`).json()},getChannelPeers(t){return e.get(`/api/channels/${encodeURIComponent(t)}/peers`).json()},setChannelRemark(t,n){return e.put(`/api/channels/${encodeURIComponent(t)}/remark`,{json:{remark:n}}).json()},setChannelPinned(t,n){return e.put(`/api/channels/${encodeURIComponent(t)}/pin`,{json:{pinned:n}}).json()},getFileDownloadUrl(e){return t(`/api/files/${e}/download`)}};function r(e){return e.displayName||e.username}function i(e){return{displayName:r(e),avatar:e.avatar||``}}function a(e){return{author:e.address,authorName:r(e),avatar:e.avatar||``}}export{n as i,r as n,a as r,i as t};
|