@abtnode/blocklet-services 1.17.7-beta-20251229-223813-e1e6c5e3 → 1.17.7-beta-20251230-120126-2836fe04

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (129) hide show
  1. package/api/libs/auth/adapters/apple.js +1 -1
  2. package/api/libs/auth/adapters/auth0.js +1 -1
  3. package/api/libs/auth/adapters/github.js +1 -1
  4. package/api/libs/auth/adapters/google.js +1 -1
  5. package/api/routes/csp-proxy.js +1 -1
  6. package/api/routes/oauth/client.js +13 -4
  7. package/api/routes/user.js +2 -2
  8. package/dist/assets/{access-control-Zb1P0A-c.js → access-control-CUu6-zRM.js} +1 -1
  9. package/dist/assets/{add-component-core-rrD3IVuo.js → add-component-core-DFUcBIM5.js} +1 -1
  10. package/dist/assets/{add-resource-HYp41Mey.js → add-resource-IrQoFkek.js} +1 -1
  11. package/dist/assets/{addon-RL_2cpli.js → addon-BE1WaOfp.js} +1 -1
  12. package/dist/assets/{advanced-DnipDVXM.js → advanced-DZo8iS0g.js} +1 -1
  13. package/dist/assets/{aigne-B-BPMYqb.js → aigne-m7Za8uoN.js} +1 -1
  14. package/dist/assets/{appearance-DkPwHUmp.js → appearance-DGdzbEUY.js} +1 -1
  15. package/dist/assets/{audit-logs-Qew52P05.js → audit-logs-Bqpc98vL.js} +1 -1
  16. package/dist/assets/{authorize-BlsrYBvj.js → authorize-Bjc5A7mE.js} +1 -1
  17. package/dist/assets/{bind-account-Dhqzfttk.js → bind-account-YrYj0shB.js} +1 -1
  18. package/dist/assets/{branding-BuYkrJWP.js → branding-C6MxoZlS.js} +1 -1
  19. package/dist/assets/{branding-BNZPiOIW.js → branding-D4t4jOvo.js} +1 -1
  20. package/dist/assets/{branding-0WzFBgOW.js → branding-uGHM--4G.js} +1 -1
  21. package/dist/assets/{bundle-avatar-0OtNVOJk.js → bundle-avatar-MwXjHSGV.js} +1 -1
  22. package/dist/assets/{complete-CJbh7iao.js → complete-CJuHsAiS.js} +1 -1
  23. package/dist/assets/{component-BXc-kqPT.js → component-C_Im1DOP.js} +2 -2
  24. package/dist/assets/{config-CH0_ZbU7.js → config-B_-nicf1.js} +1 -1
  25. package/dist/assets/{config-BGjhG44Z.js → config-BaUPvXgr.js} +1 -1
  26. package/dist/assets/{config-D2U-Xwer.js → config-CiyFLDmf.js} +1 -1
  27. package/dist/assets/{config-navigation-zHWUBjBW.js → config-navigation-B6fkilf7.js} +2 -2
  28. package/dist/assets/{config-space-BR-bgToj.js → config-space-Cj3K-KMe.js} +1 -1
  29. package/dist/assets/{confirm-CQcou-U0.js → confirm-Dwk8QEtL.js} +1 -1
  30. package/dist/assets/{connect-DvKksfqN.js → connect-BWWNLaGp.js} +1 -1
  31. package/dist/assets/{connect-DGgUqebM.js → connect-CdpbtEAA.js} +1 -1
  32. package/dist/assets/{connect-to-BkcNrFMt.js → connect-to-DZ8FWX57.js} +1 -1
  33. package/dist/assets/{dashboard-ChfWklE6.js → dashboard-lDmpt-_3.js} +2 -2
  34. package/dist/assets/{delete-confirm-ZZFKP_G2.js → delete-confirm-DP8106B2.js} +1 -1
  35. package/dist/assets/{domain-C7ik5Hza.js → domain-CEjwqMuf.js} +1 -1
  36. package/dist/assets/{domain-action-card-CPXf_2n9.js → domain-action-card-B8B6H9hh.js} +1 -1
  37. package/dist/assets/{domains-D1AXd2xb.js → domains-BKPVrdxp.js} +1 -1
  38. package/dist/assets/{email-C0H5jkk_.js → email-CLJ9Oh9g.js} +1 -1
  39. package/dist/assets/engine-sJAhuypG.js +1 -0
  40. package/dist/assets/{exchange-passport-Bxf933u4.js → exchange-passport-B3v8AOgj.js} +1 -1
  41. package/dist/assets/{form-BCT1goOE.js → form-YGfyOF3u.js} +1 -1
  42. package/dist/assets/{fuel-DW2SqoXv.js → fuel-B_1L7fXu.js} +1 -1
  43. package/dist/assets/{gen-access-key-hcXr_3v-.js → gen-access-key-v0v3wFkW.js} +1 -1
  44. package/dist/assets/{gen-simple-access-key-D_UWgD88.js → gen-simple-access-key-CiXr_y-H.js} +1 -1
  45. package/dist/assets/{get-safe-url-DxpqHRQ1.js → get-safe-url-Bco2TPFW.js} +1 -1
  46. package/dist/assets/{home-ZleX7-XZ.js → home-DwjPSvjP.js} +1 -1
  47. package/dist/assets/{iframe-CFsgaleC.js → iframe-BkiP4bTi.js} +1 -1
  48. package/dist/assets/{index-CFII0zqE.js → index-2h18bhBY.js} +1 -1
  49. package/dist/assets/{index-CgwRpRMk.js → index-AnS2fFHl.js} +1 -1
  50. package/dist/assets/{index-FreeXNkk.js → index-B-MpZQKm.js} +3 -3
  51. package/dist/assets/{index-BZaW_ZpY.js → index-B9LxMeBj.js} +1 -1
  52. package/dist/assets/{index-CwAZTFm0.js → index-BBMhJfkP.js} +1 -1
  53. package/dist/assets/{index-C5S7RLo3.js → index-BBQq8c13.js} +1 -1
  54. package/dist/assets/{index-CjS1scdg.js → index-BUg9FOTN.js} +1 -1
  55. package/dist/assets/{index-B8zAb7Hc.js → index-BeMepvos.js} +1 -1
  56. package/dist/assets/{index-BuuPPt_7.js → index-BhyOyl4s.js} +1 -1
  57. package/dist/assets/{index-C8x3s3XH.js → index-Bs1KlEje.js} +3 -3
  58. package/dist/assets/{index-C9jYw-PP.js → index-C2fMZiXk.js} +1 -1
  59. package/dist/assets/{index-DMZ5Sj4Z.js → index-C7rfvc9y.js} +1 -1
  60. package/dist/assets/{index-Crz9MitX.js → index-CDaq45HC.js} +2 -2
  61. package/dist/assets/{index-BukC8OVR.js → index-CPi7w--z.js} +1 -1
  62. package/dist/assets/{index-Cy2nGhzX.js → index-CpkQ_Cuo.js} +1 -1
  63. package/dist/assets/{index-Co_qmPsj.js → index-DVwGORvZ.js} +1 -1
  64. package/dist/assets/{index-CvxwAvNV.js → index-DWaXyfC0.js} +1 -1
  65. package/dist/assets/{index-LlFgIuCt.js → index-De_yIkHx.js} +1 -1
  66. package/dist/assets/{index-ByoNLuaN.js → index-Dhdz9lk6.js} +1 -1
  67. package/dist/assets/{index-DCKXgmNi.js → index-DmY9feUT.js} +1 -1
  68. package/dist/assets/{index-CGG37rzL.js → index-Dwsd4IGH.js} +1 -1
  69. package/dist/assets/{index-DEKD1iEz.js → index-FMUSsnLv.js} +1 -1
  70. package/dist/assets/{index-DQDt6ixh.js → index-GiNuPyT9.js} +1 -1
  71. package/dist/assets/{index-34B-_i4U.js → index-Gm0RE9Dr.js} +1 -1
  72. package/dist/assets/{index-BXRMGGxp.js → index-ZKGUIO-r.js} +1 -1
  73. package/dist/assets/{index-JzYmPAqa.js → index-_80Z1ZpG.js} +1 -1
  74. package/dist/assets/{invitation-BHrproSe.js → invitation-BQirBsFI.js} +1 -1
  75. package/dist/assets/{invitations-4w_OzLxr.js → invitations-XjQQCuZw.js} +1 -1
  76. package/dist/assets/{invite-B-0DaSfe.js → invite-D2_NU-8H.js} +1 -1
  77. package/dist/assets/{isURL-Dsl0-5oi.js → isURL-CIce9auJ.js} +1 -1
  78. package/dist/assets/{issue-passport-DRq-MGR0.js → issue-passport-CDnnfN1Q.js} +1 -1
  79. package/dist/assets/{item-B-fZE8cJ.js → item-CvLTrzgJ.js} +1 -1
  80. package/dist/assets/{landing-page-ol2He6wT.js → landing-page-CpGoTDlB.js} +1 -1
  81. package/dist/assets/{layout-DP35nSHr.js → layout-vuoHTTUk.js} +1 -1
  82. package/dist/assets/{list-CXg6onZy.js → list-CiYFt3pl.js} +1 -1
  83. package/dist/assets/{list-CRS8_Mwn.js → list-UiDvviK4.js} +1 -1
  84. package/dist/assets/{localization-Bzyury17.js → localization-COdKVuTK.js} +1 -1
  85. package/dist/assets/{log-Bdmpld3D.js → log-CgSeuCwx.js} +1 -1
  86. package/dist/assets/{login-4E4VdNcY.js → login-KpyRmg5X.js} +1 -1
  87. package/dist/assets/{login-oauth-callback-B31rNy6b.js → login-oauth-callback-CJ4tr8SE.js} +1 -1
  88. package/dist/assets/{logo-uploader-B4RelqSZ.js → logo-uploader-BSnNhLLm.js} +1 -1
  89. package/dist/assets/{lost-passport-CehEmPuN.js → lost-passport-Cm4wBrmS.js} +1 -1
  90. package/dist/assets/{open-window-CxHokgoD.js → open-window-DnyNouV2.js} +1 -1
  91. package/dist/assets/{over-due-invoice-payment-DB7bedIv.js → over-due-invoice-payment-Du_WMBUF.js} +1 -1
  92. package/dist/assets/overview-fYkqcG2P.js +116 -0
  93. package/dist/assets/{passport-CgVIIIF1.js → passport-MtVabWNV.js} +1 -1
  94. package/dist/assets/{passport-item-CvEGWX-Y.js → passport-item-CtZmczAl.js} +1 -1
  95. package/dist/assets/{permission-BdJe7FC0.js → permission-2Q-NKCMS.js} +1 -1
  96. package/dist/assets/{preferences-Uxu-Ou4V.js → preferences-CWqTqkeD.js} +1 -1
  97. package/dist/assets/{profile-embed-BF_OFULi.js → profile-embed-Be6Tc2Yd.js} +1 -1
  98. package/dist/assets/{publish-resource-BmcTO-ir.js → publish-resource-BGk3n_Wr.js} +1 -1
  99. package/dist/assets/{runtime-Bsl5i2jc.js → runtime-Ci7sffRR.js} +1 -1
  100. package/dist/assets/sdk-Bes03kcb.js +1 -0
  101. package/dist/assets/security-B283K9t5.js +22 -0
  102. package/dist/assets/{session-8btKYxMi.js → session-CKEyJJp6.js} +1 -1
  103. package/dist/assets/{setup-DhTuP-SU.js → setup-C-CyeYo3.js} +1 -1
  104. package/dist/assets/{spaces-C8s0ejS4.js → spaces-DZfD-jxX.js} +1 -1
  105. package/dist/assets/{start-D0YkmM3s.js → start-CxEl9xTQ.js} +1 -1
  106. package/dist/assets/{starting-progress-rr3ULMDk.js → starting-progress-a6mLuIzL.js} +1 -1
  107. package/dist/assets/{status-CVE6RA_S.js → status-BpPoDS0b.js} +1 -1
  108. package/dist/assets/{step-actions-imyD5TuN.js → step-actions-Cd9frxi3.js} +1 -1
  109. package/dist/assets/{studio-Bwc5fhKe.js → studio-Bn_6WQLs.js} +1 -1
  110. package/dist/assets/{team-DB9e4nhx.js → team-BDHl2zCb.js} +1 -1
  111. package/dist/assets/{traffic-2gK2nM6D.js → traffic-DWDQGBu7.js} +1 -1
  112. package/dist/assets/{transfer-DLAlz7iv.js → transfer-wR5VWleN.js} +1 -1
  113. package/dist/assets/{unsubscribe-BLr8bhvE.js → unsubscribe-BwwEY91Q.js} +1 -1
  114. package/dist/assets/{use-app-logo-BYRQxVgh.js → use-app-logo-C52bRzuf.js} +1 -1
  115. package/dist/assets/{user-center-GNfNdqal.js → user-center-CP1OknZL.js} +1 -1
  116. package/dist/assets/{user-follower-D5UmIVaZ.js → user-follower-CobHkt-I.js} +1 -1
  117. package/dist/assets/{util-BbwZ5cox.js → util-DMqfvzdX.js} +1 -1
  118. package/dist/assets/{util-D8-xR3Bv.js → util-E_z7v0HU.js} +1 -1
  119. package/dist/assets/{wait-connect-Bw-B6lbR.js → wait-connect-DYJDyyTr.js} +1 -1
  120. package/dist/assets/{wizard-BrdF6Gnl.js → wizard-Daquugqz.js} +1 -1
  121. package/dist/assets/{wizard-components-CsJ6IStV.js → wizard-components-Bce-34em.js} +1 -1
  122. package/dist/assets/{wrap-locale-C87TTgDu.js → wrap-locale-B6zyAepP.js} +1 -1
  123. package/dist/assets/{zh-DuMFx3Ce.js → zh-D_qi3l-8.js} +1 -1
  124. package/dist/index.html +1 -1
  125. package/package.json +24 -24
  126. package/dist/assets/engine-CTCpNUzB.js +0 -1
  127. package/dist/assets/overview-C7rRlFBy.js +0 -116
  128. package/dist/assets/sdk-CHfXvAIT.js +0 -1
  129. package/dist/assets/security-Clz2lIto.js +0 -22
@@ -1,4 +1,4 @@
1
- import{j as e,W as m,a6 as z,T as j,at as Ne,D as _e,e7 as V,ao as J,e8 as We,ak as h,b6 as F,bb as Fe,s as fe,e9 as be,br as Ke,am as ge,cF as Ge,M as G,aO as Y,bO as Ye,aP as $,Q as $e,a$ as qe,aR as He,ea as Qe,eb as Xe,ec as Ve,dF as Je,b4 as he}from"./vendor-mui-core-DnR6WYuU.js";import{q as Ze,l as ke,a as ue}from"./vendor-hooks-qxhUUbW5.js";import{r as b,j as et}from"./vendor-react-CTtPmzVP.js";import{Y as M,Z as N,Q as E,J as L,bI as tt,bX as st,al as nt,c as I,j as ot}from"./index-FreeXNkk.js";import{H as B,V as D,aU as at,aV as q,aP as rt,R as it,w as le,aX as ct}from"./vendor-ux-B2x-0VyJ.js";import{u as lt}from"./use-mobile-BINJTzMb.js";import{a as H,d as je,N as dt,c as pt,D as Ce,C as me}from"./vendor-utils-CxWN1dT3.js";import{o as we}from"./vendor-arcblock-hbumvS-z.js";import{a as ut,u as mt,c as xt,D as de,b as ft}from"./index-CjS1scdg.js";import"./index-0SUQD3K4.js";import"./index-BojVbZw0.js";import"./api-FQQlzPOP.js";import{u as Be,C as gt,D as ht,a as St}from"./connect-to-BkcNrFMt.js";import{c as yt,g as bt,d as kt,i as jt,e as xe,f as Ct,h as wt,j as Bt}from"./spaces-C8s0ejS4.js";import{f as Q}from"./index-DBs9Ljax.js";import{v as Dt}from"./index-Bnog6DRk.js";import{a as Et}from"./dashboard-ChfWklE6.js";import{E as Tt}from"./index-D1SIrheh.js";import{x as It}from"./index-DRYJ0xIl.js";import{g as Se}from"./get-safe-url-DxpqHRQ1.js";import{S as Rt}from"./switch-control-CrDv-a96.js";import{C as Pt,u as At}from"./config-space-BR-bgToj.js";import{L as ye}from"./list-header-Cl3jykCe.js";import"./lottie-web-4koyQiv_.js";import"./session-8btKYxMi.js";import"./team-DB9e4nhx.js";import"./isURL-Dsl0-5oi.js";import"./use-app-logo-BYRQxVgh.js";import"./useAsyncRetry-r8dEPb-x.js";import"./useAsync-Dotoxibi.js";import"./useSetState-L-f8mSga.js";import"./index-LlFgIuCt.js";import"./zh-DuMFx3Ce.js";import"./over-due-invoice-payment-DB7bedIv.js";import"./useLocalStorage-BRElXNq3.js";import"./confirm-CQcou-U0.js";import"./passport-CgVIIIF1.js";import"./create-passport-svg-H8kuyoHI.js";import"./index-D9VLhdHJ.js";async function vt({blockletDid:t,nodeApi:o,spaceGateways:a}){let s=!1;const r=await Promise.all(a.map(async n=>{let{name:c}=n;const i=await yt(n.endpoint);return!H(i)&&i!==c&&(c=i,s=!0),{...n,name:c}}));return s&&await Promise.all(r.filter(n=>n.did).map(n=>o.updateBlockletSpaceGateway({input:{did:t,where:{did:n.did},spaceGateway:{...n}}}))),r}function zt({refresh:t}={}){const{blocklet:o}=M(),a=o?.meta?.did,{api:s}=N();return Ze(async()=>{if(!a)return[];const{spaceGateways:r}=await s.getBlockletSpaceGateways({input:{did:a}});return await vt({blockletDid:a,nodeApi:s,spaceGateways:r})??[]},{refreshDeps:[a,t],onError(r){r?.message?.includes("not logged")?console.warn(r):(console.error(r),B.error(Q(r)))}})}function De({deps:t,setLoading:o,backupDate:a}={deps:[],setLoading:()=>{},backupDate:new Date}){const{blocklet:s}=M(),[r,n]=b.useState([]),{api:c}=N(),[i,d]=b.useMemo(()=>a?[E(a).startOf("day").toISOString(),E(a).endOf("day").toISOString()]:[E().startOf("year").toISOString(),E().endOf("day").toISOString()],[a]),l=je(async()=>{try{if(o(!0),!s){n([]);return}const{backups:x}=await c.getBlockletBackups({input:{did:s.meta.did,startTime:i,endTime:d}});n(x??[])}catch(x){console.error(x),B.error(Q(x))}finally{o(!1)}},1e3);return ke(async()=>{l()},[s?.meta?.did].concat(t)),{backups:r}}function Ot({appDid:t}){const{backups:o}=De(),[a,s]=b.useState({message:"",progress:0,completed:!1}),r=N(),{ws:{useSubscription:n}}=r;return n(L.BlockletEvents.backupProgress,c=>{t===c?.appDid&&s(()=>({...c}))},[t]),b.useEffect(()=>{if(o?.length&&dt(o[0]?.status)){const[c]=o;s(()=>({message:c.message,progress:c.progress,completed:c.progress>=100}))}},[o]),a}function Ut({deps:t=[],setLoading:o=()=>{}}={}){const{blocklet:a}=M(),[s,r]=b.useState([]),{api:n}=N(),c=b.useCallback(je(async()=>{if(!n||!a?.meta?.did){r([]);return}try{o(!0);const i=E(),d=i.subtract(1,"year"),{summary:l}=await n.getBlockletBackupSummary({input:{did:a.meta.did,startTime:d.toISOString(),endTime:i.toISOString()}}),x=Array.isArray(l)?l.map(p=>({...p,successCount:+p.successCount,errorCount:+p.errorCount})):[];r(x)}catch(i){console.error("Failed to fetch backup summary:",i),B.error(Q(i)),r([])}finally{o(!1)}},1e3),[]);return ke(async()=>(await c(),()=>{c.cancel()}),[a?.meta?.did].concat(t)),{backupSummary:s}}const Ee=b.createContext({}),{Provider:Lt,Consumer:Os}=Ee;function Te({children:t}){const{t:o}=D(),{api:a}=N(),{blocklet:s}=M(),[r,n]=b.useState(null),[c,i]=b.useState(!1),{data:d,loading:l,mutate:x}=zt({refresh:c}),p=pt(d),f=Ot({appDid:s?.appDid}),u=b.useMemo(()=>bt(s?.environments),[s?.environments]),[k,w]=b.useState(!1),[S,y]=b.useState(0),{backups:Z}=De({deps:[S,r],setLoading:w,backupDate:r}),[ee,te]=b.useState(0),{backupSummary:se}=Ut({deps:[ee]}),[_,U]=b.useState(d?.find(g=>g.endpoint===u)),T=s?.settings?.autoBackup,P=()=>{i(g=>!g)},ne=()=>{te(g=>g+1)},oe=()=>{y(g=>g+1)},K=async g=>{await a.updateAutoBackup({input:{did:s.meta.did,autoBackup:g}})},X=async()=>{await a.abortBlockletBackup({input:{appPid:s.meta.did}})},ae=async(g,v)=>{try{x(R=>{const A=[...R];return A.push({...g,loading:!0}),A}),await a.addBlockletSpaceGateway({input:{did:s.meta.did,spaceGateway:g}}),u!==v&&await a.configBlocklet({input:{did:[s.meta.did],configs:[{key:L.BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_APP_BACKUP_ENDPOINT,value:v}]}}),U(g),P(),B.success(o("storage.spaces.connectedWithName",{name:g?.name??"DID Spaces"}))}catch(R){throw console.error(R),x(A=>[...A].filter(W=>W.did!==g.did)),R}},re=async g=>{g&&(g.endpoint===u&&(await a.configBlocklet({input:{did:[s.meta.did],configs:[{key:L.BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_APP_BACKUP_ENDPOINT,value:""}]}}),T?.enabled&&await K({enabled:!1})),await a.deleteBlockletSpaceGateway({input:{did:s.meta.did,spaceGatewayDid:g?.did}}),x(v=>{const R=[...v];return R.splice(R.indexOf(g),1),R}),U(g),P())},ie=async g=>{await Promise.all([a.updateBlockletSpaceGateway({input:{did:s.meta.did,where:{did:g.did},spaceGateway:g}}),u!==g.endpoint&&a.configBlocklet({input:{did:[s.meta.did],configs:[{key:L.BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_APP_BACKUP_ENDPOINT,value:g.endpoint}]}})]),B.success(o("storage.spaces.connectedWithName",{name:g?.name??"DID Spaces"})),P()},C=g=>g?.endpoint===u;return e.jsx(Lt,{value:{spaceGateways:d||[],selectedSpaceGateway:_,addSpaceGateway:ae,deleteSpaceGateway:re,updateSpaceGateway:ie,refreshSpaceGateways:P,spaceGatewaysLoading:l,spaceGatewaysFirstLoading:p,spaceGatewayIsSelected:C,updateAutoBackup:K,abortBlockletBackup:X,backupEndpoint:u,backupProgress:f,backups:Z,backupSummary:se,refreshBackupSummary:ne,refreshBackups:oe,setBackupDate:n,backupsLoading:k,autoBackup:T},children:t})}Te.propTypes={children:m.any.isRequired};function O(){return b.useContext(Ee)}function Ie({...t}){const{blocklet:o}=M(),{info:a}=N(),{t:s}=D(),r=Be({blocklet:o}),n=tt(a),{spaceGateways:c,addSpaceGateway:i}=O(),d={checkFn:Ce.create({baseURL:me(window.location.origin,st())}).get,webWalletUrl:n,extraParams:{appPid:o.appPid,appDid:r.appDid,appName:r.appName,appDescription:r.appDescription,appUrl:r.appUrl,referrer:r.referrer,scopes:r.scopes,nodeDid:a.did}},l=async({endpoint:p,name:f,did:u})=>{const k=await kt(p);if(!await jt(k)){B.error(s("storage.spaces.gateway.add.invalidUrl"));return}if(c.some(y=>y.endpoint===p)){B.error(s("storage.spaces.gateway.add.duplicate",{name:f}));return}await i({name:f,did:u,url:k,endpoint:p},p)},x=async({spaceGateway:p})=>{try{await l(p)}catch(f){console.error(f),B.error(Q(f))}};return e.jsx(ut,{...t,connectScope:"app",options:d,onSuccess:x})}function Re({...t}){const{t:o}=b.useContext(at),{blocklet:a,loading:s}=Et();if(a?.diskInfo){const r=(i,d,l)=>e.jsxs(j,{children:[i," ",e.jsx("strong",{children:d?nt(d):"empty"})]}),n=a.environments.reduce((i,d)=>(i[d.key]=d.value,i),{}),c=[{key:"appDir",name:o("blocklet.diskInfo.appDir"),value:r(n.BLOCKLET_APP_DIR,a.diskInfo.app)},{key:"dataDir",name:o("blocklet.diskInfo.dataDir"),value:r(n.BLOCKLET_DATA_DIR,a.diskInfo.data)},{key:"logDir",name:o("blocklet.diskInfo.logDir"),value:r(n.BLOCKLET_LOG_DIR,a.diskInfo.log)},{key:"cacheDir",name:o("blocklet.diskInfo.cacheDir"),value:r(n.BLOCKLET_CACHE_DIR,a.diskInfo.cache)}];return e.jsx(Mt,{component:"div",...t,children:c.map(i=>e.jsx(Dt,{valueComponent:"div",nameWidth:120,name:i.name,children:i.value},i.key))})}return s?e.jsx(z,{}):e.jsx(j,{children:o("blocklet.diskInfo.empty")})}const Mt=Ne(j)``;function Pe(){const{t}=D(),{setBackupDate:o,backupSummary:a}=O(),s=mt({key:"lg"}),r=b.useRef(null),n=_e(),c=b.useCallback(l=>{o(l)},[o]),i=b.useMemo(()=>{const l=E().add(1,"day"),x=l.subtract(1,"year"),p=new Map(a.map(u=>[u.date,{date:u.date,successCount:u.successCount,errorCount:u.errorCount}])),f=[];for(let u=x.clone();E(u).isBefore(l);u=u.add(1,"day")){const k=u.format("YYYY-MM-DD");f.push(p.get(k)||{date:k,successCount:0,errorCount:0})}return f},[a]),d=b.useMemo(()=>({grid:{containLabel:!0,right:10,top:30,bottom:12},tooltip:{formatter:k=>{const{date:w,successCount:S,errorCount:y}=i[k.dataIndex]||{date:k.data[0],successCount:0,errorCount:0};return[`<div>${t("common.time")}: ${w}</div>`,`<div>${t("common.succeeded")}: ${S}</div>`,`<div>${t("common.failed")}: ${y}</div>`].join(`
1
+ import{j as e,W as m,a6 as z,T as j,at as Ne,D as _e,e7 as V,ao as J,e8 as We,ak as h,b6 as F,bb as Fe,s as fe,e9 as be,br as Ke,am as ge,cF as Ge,M as G,aO as Y,bO as Ye,aP as $,Q as $e,a$ as qe,aR as He,ea as Qe,eb as Xe,ec as Ve,dF as Je,b4 as he}from"./vendor-mui-core-DnR6WYuU.js";import{q as Ze,l as ke,a as ue}from"./vendor-hooks-qxhUUbW5.js";import{r as b,j as et}from"./vendor-react-CTtPmzVP.js";import{Y as M,Z as N,Q as E,J as L,bI as tt,bX as st,al as nt,c as I,j as ot}from"./index-B-MpZQKm.js";import{H as B,V as D,aU as at,aV as q,aP as rt,R as it,w as le,aX as ct}from"./vendor-ux-B2x-0VyJ.js";import{u as lt}from"./use-mobile-BINJTzMb.js";import{a as H,d as je,N as dt,c as pt,D as Ce,C as me}from"./vendor-utils-CxWN1dT3.js";import{o as we}from"./vendor-arcblock-hbumvS-z.js";import{a as ut,u as mt,c as xt,D as de,b as ft}from"./index-BUg9FOTN.js";import"./index-0SUQD3K4.js";import"./index-BojVbZw0.js";import"./api-FQQlzPOP.js";import{u as Be,C as gt,D as ht,a as St}from"./connect-to-DZ8FWX57.js";import{c as yt,g as bt,d as kt,i as jt,e as xe,f as Ct,h as wt,j as Bt}from"./spaces-DZfD-jxX.js";import{f as Q}from"./index-DBs9Ljax.js";import{v as Dt}from"./index-Bnog6DRk.js";import{a as Et}from"./dashboard-lDmpt-_3.js";import{E as Tt}from"./index-D1SIrheh.js";import{x as It}from"./index-DRYJ0xIl.js";import{g as Se}from"./get-safe-url-Bco2TPFW.js";import{S as Rt}from"./switch-control-CrDv-a96.js";import{C as Pt,u as At}from"./config-space-Cj3K-KMe.js";import{L as ye}from"./list-header-Cl3jykCe.js";import"./lottie-web-4koyQiv_.js";import"./session-CKEyJJp6.js";import"./team-BDHl2zCb.js";import"./isURL-CIce9auJ.js";import"./use-app-logo-C52bRzuf.js";import"./useAsyncRetry-r8dEPb-x.js";import"./useAsync-Dotoxibi.js";import"./useSetState-L-f8mSga.js";import"./index-De_yIkHx.js";import"./zh-D_qi3l-8.js";import"./over-due-invoice-payment-Du_WMBUF.js";import"./useLocalStorage-BRElXNq3.js";import"./confirm-Dwk8QEtL.js";import"./passport-MtVabWNV.js";import"./create-passport-svg-H8kuyoHI.js";import"./index-D9VLhdHJ.js";async function vt({blockletDid:t,nodeApi:o,spaceGateways:a}){let s=!1;const r=await Promise.all(a.map(async n=>{let{name:c}=n;const i=await yt(n.endpoint);return!H(i)&&i!==c&&(c=i,s=!0),{...n,name:c}}));return s&&await Promise.all(r.filter(n=>n.did).map(n=>o.updateBlockletSpaceGateway({input:{did:t,where:{did:n.did},spaceGateway:{...n}}}))),r}function zt({refresh:t}={}){const{blocklet:o}=M(),a=o?.meta?.did,{api:s}=N();return Ze(async()=>{if(!a)return[];const{spaceGateways:r}=await s.getBlockletSpaceGateways({input:{did:a}});return await vt({blockletDid:a,nodeApi:s,spaceGateways:r})??[]},{refreshDeps:[a,t],onError(r){r?.message?.includes("not logged")?console.warn(r):(console.error(r),B.error(Q(r)))}})}function De({deps:t,setLoading:o,backupDate:a}={deps:[],setLoading:()=>{},backupDate:new Date}){const{blocklet:s}=M(),[r,n]=b.useState([]),{api:c}=N(),[i,d]=b.useMemo(()=>a?[E(a).startOf("day").toISOString(),E(a).endOf("day").toISOString()]:[E().startOf("year").toISOString(),E().endOf("day").toISOString()],[a]),l=je(async()=>{try{if(o(!0),!s){n([]);return}const{backups:x}=await c.getBlockletBackups({input:{did:s.meta.did,startTime:i,endTime:d}});n(x??[])}catch(x){console.error(x),B.error(Q(x))}finally{o(!1)}},1e3);return ke(async()=>{l()},[s?.meta?.did].concat(t)),{backups:r}}function Ot({appDid:t}){const{backups:o}=De(),[a,s]=b.useState({message:"",progress:0,completed:!1}),r=N(),{ws:{useSubscription:n}}=r;return n(L.BlockletEvents.backupProgress,c=>{t===c?.appDid&&s(()=>({...c}))},[t]),b.useEffect(()=>{if(o?.length&&dt(o[0]?.status)){const[c]=o;s(()=>({message:c.message,progress:c.progress,completed:c.progress>=100}))}},[o]),a}function Ut({deps:t=[],setLoading:o=()=>{}}={}){const{blocklet:a}=M(),[s,r]=b.useState([]),{api:n}=N(),c=b.useCallback(je(async()=>{if(!n||!a?.meta?.did){r([]);return}try{o(!0);const i=E(),d=i.subtract(1,"year"),{summary:l}=await n.getBlockletBackupSummary({input:{did:a.meta.did,startTime:d.toISOString(),endTime:i.toISOString()}}),x=Array.isArray(l)?l.map(p=>({...p,successCount:+p.successCount,errorCount:+p.errorCount})):[];r(x)}catch(i){console.error("Failed to fetch backup summary:",i),B.error(Q(i)),r([])}finally{o(!1)}},1e3),[]);return ke(async()=>(await c(),()=>{c.cancel()}),[a?.meta?.did].concat(t)),{backupSummary:s}}const Ee=b.createContext({}),{Provider:Lt,Consumer:Os}=Ee;function Te({children:t}){const{t:o}=D(),{api:a}=N(),{blocklet:s}=M(),[r,n]=b.useState(null),[c,i]=b.useState(!1),{data:d,loading:l,mutate:x}=zt({refresh:c}),p=pt(d),f=Ot({appDid:s?.appDid}),u=b.useMemo(()=>bt(s?.environments),[s?.environments]),[k,w]=b.useState(!1),[S,y]=b.useState(0),{backups:Z}=De({deps:[S,r],setLoading:w,backupDate:r}),[ee,te]=b.useState(0),{backupSummary:se}=Ut({deps:[ee]}),[_,U]=b.useState(d?.find(g=>g.endpoint===u)),T=s?.settings?.autoBackup,P=()=>{i(g=>!g)},ne=()=>{te(g=>g+1)},oe=()=>{y(g=>g+1)},K=async g=>{await a.updateAutoBackup({input:{did:s.meta.did,autoBackup:g}})},X=async()=>{await a.abortBlockletBackup({input:{appPid:s.meta.did}})},ae=async(g,v)=>{try{x(R=>{const A=[...R];return A.push({...g,loading:!0}),A}),await a.addBlockletSpaceGateway({input:{did:s.meta.did,spaceGateway:g}}),u!==v&&await a.configBlocklet({input:{did:[s.meta.did],configs:[{key:L.BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_APP_BACKUP_ENDPOINT,value:v}]}}),U(g),P(),B.success(o("storage.spaces.connectedWithName",{name:g?.name??"DID Spaces"}))}catch(R){throw console.error(R),x(A=>[...A].filter(W=>W.did!==g.did)),R}},re=async g=>{g&&(g.endpoint===u&&(await a.configBlocklet({input:{did:[s.meta.did],configs:[{key:L.BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_APP_BACKUP_ENDPOINT,value:""}]}}),T?.enabled&&await K({enabled:!1})),await a.deleteBlockletSpaceGateway({input:{did:s.meta.did,spaceGatewayDid:g?.did}}),x(v=>{const R=[...v];return R.splice(R.indexOf(g),1),R}),U(g),P())},ie=async g=>{await Promise.all([a.updateBlockletSpaceGateway({input:{did:s.meta.did,where:{did:g.did},spaceGateway:g}}),u!==g.endpoint&&a.configBlocklet({input:{did:[s.meta.did],configs:[{key:L.BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_APP_BACKUP_ENDPOINT,value:g.endpoint}]}})]),B.success(o("storage.spaces.connectedWithName",{name:g?.name??"DID Spaces"})),P()},C=g=>g?.endpoint===u;return e.jsx(Lt,{value:{spaceGateways:d||[],selectedSpaceGateway:_,addSpaceGateway:ae,deleteSpaceGateway:re,updateSpaceGateway:ie,refreshSpaceGateways:P,spaceGatewaysLoading:l,spaceGatewaysFirstLoading:p,spaceGatewayIsSelected:C,updateAutoBackup:K,abortBlockletBackup:X,backupEndpoint:u,backupProgress:f,backups:Z,backupSummary:se,refreshBackupSummary:ne,refreshBackups:oe,setBackupDate:n,backupsLoading:k,autoBackup:T},children:t})}Te.propTypes={children:m.any.isRequired};function O(){return b.useContext(Ee)}function Ie({...t}){const{blocklet:o}=M(),{info:a}=N(),{t:s}=D(),r=Be({blocklet:o}),n=tt(a),{spaceGateways:c,addSpaceGateway:i}=O(),d={checkFn:Ce.create({baseURL:me(window.location.origin,st())}).get,webWalletUrl:n,extraParams:{appPid:o.appPid,appDid:r.appDid,appName:r.appName,appDescription:r.appDescription,appUrl:r.appUrl,referrer:r.referrer,scopes:r.scopes,nodeDid:a.did}},l=async({endpoint:p,name:f,did:u})=>{const k=await kt(p);if(!await jt(k)){B.error(s("storage.spaces.gateway.add.invalidUrl"));return}if(c.some(y=>y.endpoint===p)){B.error(s("storage.spaces.gateway.add.duplicate",{name:f}));return}await i({name:f,did:u,url:k,endpoint:p},p)},x=async({spaceGateway:p})=>{try{await l(p)}catch(f){console.error(f),B.error(Q(f))}};return e.jsx(ut,{...t,connectScope:"app",options:d,onSuccess:x})}function Re({...t}){const{t:o}=b.useContext(at),{blocklet:a,loading:s}=Et();if(a?.diskInfo){const r=(i,d,l)=>e.jsxs(j,{children:[i," ",e.jsx("strong",{children:d?nt(d):"empty"})]}),n=a.environments.reduce((i,d)=>(i[d.key]=d.value,i),{}),c=[{key:"appDir",name:o("blocklet.diskInfo.appDir"),value:r(n.BLOCKLET_APP_DIR,a.diskInfo.app)},{key:"dataDir",name:o("blocklet.diskInfo.dataDir"),value:r(n.BLOCKLET_DATA_DIR,a.diskInfo.data)},{key:"logDir",name:o("blocklet.diskInfo.logDir"),value:r(n.BLOCKLET_LOG_DIR,a.diskInfo.log)},{key:"cacheDir",name:o("blocklet.diskInfo.cacheDir"),value:r(n.BLOCKLET_CACHE_DIR,a.diskInfo.cache)}];return e.jsx(Mt,{component:"div",...t,children:c.map(i=>e.jsx(Dt,{valueComponent:"div",nameWidth:120,name:i.name,children:i.value},i.key))})}return s?e.jsx(z,{}):e.jsx(j,{children:o("blocklet.diskInfo.empty")})}const Mt=Ne(j)``;function Pe(){const{t}=D(),{setBackupDate:o,backupSummary:a}=O(),s=mt({key:"lg"}),r=b.useRef(null),n=_e(),c=b.useCallback(l=>{o(l)},[o]),i=b.useMemo(()=>{const l=E().add(1,"day"),x=l.subtract(1,"year"),p=new Map(a.map(u=>[u.date,{date:u.date,successCount:u.successCount,errorCount:u.errorCount}])),f=[];for(let u=x.clone();E(u).isBefore(l);u=u.add(1,"day")){const k=u.format("YYYY-MM-DD");f.push(p.get(k)||{date:k,successCount:0,errorCount:0})}return f},[a]),d=b.useMemo(()=>({grid:{containLabel:!0,right:10,top:30,bottom:12},tooltip:{formatter:k=>{const{date:w,successCount:S,errorCount:y}=i[k.dataIndex]||{date:k.data[0],successCount:0,errorCount:0};return[`<div>${t("common.time")}: ${w}</div>`,`<div>${t("common.succeeded")}: ${S}</div>`,`<div>${t("common.failed")}: ${y}</div>`].join(`
2
2
  `)},backgroundColor:n.palette.background.paper,borderColor:n.palette.divider,textStyle:{color:n.palette.text.primary,fontSize:14},extraCssText:`box-shadow: ${n.shadows[2]}; border-radius: 4px;`,padding:[8,10]},visualMap:{show:!1,min:-12,max:12,pieces:[{min:Number.MIN_SAFE_INTEGER,max:-9,color:V[600]},{min:-9,max:-6,color:V[500]},{min:-6,max:-3,color:V[400]},{min:-3,max:-1,color:V[300]},{min:0,max:0,color:n.palette.grey[200]},{min:1,max:3,color:J[300]},{min:3,max:6,color:J[400]},{min:6,max:9,color:J[500]},{min:9,max:Number.MAX_SAFE_INTEGER,color:J[600]}],orient:"horizontal",left:"center",bottom:12,itemWidth:12,itemHeight:12,textStyle:{color:n.palette.text.secondary,fontSize:12}},calendar:{top:30,left:50,right:10,bottom:4,cellSize:[8,8],splitLine:{show:!1},itemStyle:{borderWidth:2,borderColor:n.palette.background.default,color:n.palette.background.default},dayLabel:{show:!0,firstDay:0,nameMap:["","Mon","","Wed","","Fri",""],position:"start",margin:4,fontSize:10,color:n.palette.text.primary,fontWeight:"400",width:20},monthLabel:{show:!0,nameMap:"cn",align:"left",color:n.palette.text.primary,fontWeight:"400",fontSize:12,position:"start",margin:4,width:30,padding:[0,2]},yearLabel:{show:!1},range:[E().subtract(11,"month").startOf("month").format("YYYY-MM-DD"),E().endOf("month").format("YYYY-MM-DD")],orient:"horizontal"},series:{type:"heatmap",coordinateSystem:"calendar",data:i.map(k=>[k.date,k.errorCount?-k.errorCount:k.successCount]),label:{show:!1},itemStyle:{borderWidth:2,borderColor:n.palette.background.default,borderRadius:4},emphasis:{itemStyle:{borderWidth:2,borderColor:We[200],color:"inherit"}}}}),[i,t,n]);return e.jsxs(e.Fragment,{children:[e.jsx(h,{ref:r,sx:{maxWidth:"1280px",border:"1px solid",borderColor:"divider",padding:"8px",overflowX:"auto"},children:e.jsx(h,{sx:{width:"1200px",height:"180px",position:"relative"},children:e.jsx(Tt,{option:d,style:{height:"100%",width:"100%"},notMerge:!0,lazyUpdate:!1,opts:{renderer:"canvas"},onEvents:{click:l=>{l.componentType==="series"&&l.data&&c(l.data[0])}}})})}),e.jsx(h,{sx:{display:"flex",justifyContent:"flex-end",mt:1,mr:s?2:5,mb:2},children:e.jsxs(F,{direction:s?"column":"row",spacing:s?2:1,sx:{width:"100%",justifyContent:"flex-start",alignItems:s?"flex-start":"center"},children:[e.jsxs(F,{direction:"row",spacing:1,sx:{alignItems:"center"},children:[e.jsx(h,{sx:{width:32,height:12,borderRadius:.5,background:"linear-gradient(90deg, #8B5000 0%, #A36200 33%, #C17700 66%, #E29000 100%)"}}),e.jsx(j,{variant:"body2",sx:{color:"text.secondary"},children:t("storage.spaces.backup.failed")})]}),e.jsxs(F,{direction:"row",spacing:1,sx:{alignItems:"center"},children:[e.jsx(h,{sx:{width:32,height:12,borderRadius:.5,bgcolor:"grey.200",border:"1px solid",borderColor:"grey.200"}}),e.jsx(j,{variant:"body2",sx:{color:"text.secondary"},children:t("storage.spaces.backup.without")})]}),e.jsxs(F,{direction:"row",spacing:1,sx:{alignItems:"center"},children:[e.jsx(h,{sx:{width:32,height:12,borderRadius:.5,background:"linear-gradient(90deg, #9be9a8 0%, #40c463 33%, #30a14e 66%, #216e39 100%)"}}),e.jsx(j,{variant:"body2",sx:{color:"text.secondary"},children:t("storage.spaces.backup.succeeded")})]})]})})]})}const Nt=fe(({className:t,...o})=>e.jsx(ge,{...o,classes:{popper:t}}))(()=>({".MuiTooltip-tooltip":{backgroundColor:"transparent",padding:0,margin:0,boxShadow:"none",maxWidth:"none"},".MuiTooltip-arrow":{color:"rgba(230, 235, 245, 1)"}}));function Ae({status:t,message:o="",createdAt:a}){const{t:s}=D(),r=t===I.BACKUPS.STATUS.PROGRESS&&E().diff(a,"hours")>=I.BACKUPS.TIMEOUT_HOURS,n=r&&s("common.timeoutError"),c=t===I.BACKUPS.STATUS.PROGRESS&&!r,i=t===I.BACKUPS.STATUS.SUCCEEDED&&!r;return c?e.jsxs(j,{sx:{display:"inline-flex",alignItems:"center",fontSize:"14px"},children:[e.jsx(z,{sx:{marginRight:"4px"},size:"12px"}),s("common.progress")]}):i?e.jsx(q,{type:"success",children:s("common.succeeded")}):e.jsxs(h,{sx:{display:"inline-flex",alignItems:"center"},children:[e.jsx(q,{type:"error",children:s("common.failed")}),e.jsx(ge,{style:{display:"flex",alignItems:"center",flexShrink:0},title:o||n,children:e.jsx(be,{children:e.jsx(Ge,{style:{width:"24px",height:"24px"},color:"error"})})})]})}Ae.propTypes={status:m.string.isRequired,message:m.string,createdAt:m.string.isRequired};function ve({metadata:t={}}){const{t:o}=D();if(H(t))return e.jsx(q,{type:"success",children:o("common.succeeded")});const a=t.count||0,s=t.size||0,r=It(s,{iec:!0}),n=e.jsxs(h,{sx:{p:1,borderRadius:1,boxShadow:2,color:"black",backgroundColor:"white"},children:[e.jsxs(j,{variant:"body2",children:[o("common.fileCount"),": ",a]}),e.jsxs(j,{variant:"body2",children:[o("common.fileSize"),": ",r]})]});return e.jsxs(h,{sx:{display:"inline-flex",alignItems:"center"},children:[e.jsx(q,{type:"success",children:o("common.succeeded")}),e.jsx(Nt,{title:n,style:{display:"flex",alignItems:"center",flexShrink:0},placement:"left",children:e.jsx(be,{children:e.jsx(Ke,{style:{width:"24px",height:"24px"},color:"primary"})})})]})}ve.propTypes={metadata:m.object};function ze(){const{t,locale:o}=D(),{spaceGateways:a,backups:s,backupsLoading:r}=O(),n=b.useMemo(()=>[{label:"DID Space",name:"target",options:{customBodyRenderLite:i=>{const{targetUrl:d,targetName:l,status:x,createdAt:p}=s[i],f=x===I.BACKUPS.STATUS.PROGRESS&&E().diff(p,"hours")>=I.BACKUPS.TIMEOUT_HOURS,u=x===I.BACKUPS.STATUS.SUCCEEDED&&!f,k=l||a.find(w=>d?.includes(xe(w?.endpoint)))?.name||"Unknown DID Space";return u?e.jsx(Fe,{href:d,target:"_blank",sx:{fontSize:"16px"},children:k}):e.jsx(j,{variant:"body1",sx:{fontSize:"16px"},children:k})}}},{label:t("common.strategy"),name:"strategy",options:{customBodyRender:i=>{const d=t(i===0?"common.auto":"common.manual");return e.jsx(q,{children:d})}}},{label:t("common.startTime"),name:"createdAt",options:{customBodyRender:i=>E(i).format("YYYY-MM-DD HH:mm:ss")}},{label:t("common.endTime"),name:"updatedAt",options:{customBodyRender:i=>H(i)?"":E(i).format("YYYY-MM-DD HH:mm:ss")}},{label:t("common.status"),name:"status",options:{customBodyRenderLite:i=>{const d=s?.[i]??{},{status:l,message:x,createdAt:p,metadata:f}=d,u=l===I.BACKUPS.STATUS.PROGRESS&&E().diff(p,"hours")>=I.BACKUPS.TIMEOUT_HOURS,k=l===I.BACKUPS.STATUS.PROGRESS&&!u,w=l===I.BACKUPS.STATUS.SUCCEEDED&&!u;return k?e.jsxs(j,{sx:{display:"inline-flex",alignItems:"center",fontSize:"14px"},children:[e.jsx(z,{sx:{marginRight:"4px"},size:"12px"}),t("common.progress")]}):w?e.jsx(ve,{metadata:f}):e.jsx(Ae,{status:l,message:x,createdAt:p})}}}],[s,a,t]),c=b.useMemo(()=>!s?.length,[s]);return e.jsx(e.Fragment,{children:c?e.jsx(h,{sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"100px",color:"#9397A1",marginTop:"16px",marginBottom:"24px"},children:t("storage.spaces.record.emptyData")}):e.jsx(rt,{title:"",loading:r,data:s,columns:n,emptyNode:t("storage.spaces.record.emptyData",o),options:{download:!1,filter:!1,print:!1,search:!1,viewColumns:!1}})})}function _t(){const{t}=D();return e.jsxs(h,{children:[e.jsxs(h,{sx:{display:"flex",gap:3,flexDirection:{xs:"column",md:"row"}},children:[e.jsxs(h,{sx:{display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",alignContent:"center",minWidth:240},children:[e.jsx(xt,{style:{cursor:"pointer",width:"150px",height:"100%",maxHeight:160}}),e.jsx(j,{sx:{my:2,textAlign:"center",color:"text.secondary"},children:t("storage.spaces.connect.provider")}),e.jsx(Ie,{})]}),e.jsxs(h,{sx:{flexGrow:1,minWidth:0},children:[e.jsx(h,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:3},children:e.jsx(j,{sx:{fontSize:"1.2rem",fontWeight:"bold"},children:t("storage.spaces.backup.records")})}),e.jsx(Pe,{})]})]}),e.jsx(ze,{sx:{marginTop:"24px"}}),e.jsx(j,{sx:{fontSize:"1.2rem",fontWeight:"bold",mb:2,mt:2},children:t("common.dataStorage")}),e.jsx(Re,{})]})}function Oe({spaceGateway:t,onConfirm:o=()=>{},onCancel:a=()=>{}}){const{t:s}=D(),[r,n]=b.useState(!1),[c,i]=b.useState(!1),d=(p,f)=>{p?.preventDefault(),p?.stopPropagation(),n(f)},l=async p=>{try{p?.stopPropagation(),i(!0),await o?.(t),n(!1)}catch(f){console.error(f),B.error(`${s("storage.space.gateway.delete.failed")}: ${Q(f)}`)}finally{n(!1),i(!1)}},x=p=>{d(p,!1),a?.(p)};return e.jsxs(e.Fragment,{children:[e.jsxs(G,{color:"red",onClick:p=>d(p,!0),children:[e.jsx(Y,{style:{minWidth:24,color:"red"},children:e.jsx(Ye,{fontSize:"small"})}),e.jsx($,{style:{color:"red"},children:s("common.disconnect")})]}),e.jsx(it,{title:s("storage.spaces.gateway.delete.title"),open:r,confirmButton:{text:s("common.confirm"),props:{size:"small",variant:"contained",color:"error",loading:c}},cancelButton:{text:s("common.cancel"),props:{size:"small",variant:"outlined",disabled:c}},onConfirm:l,onCancel:x,children:e.jsx(j,{sx:{wordWrap:"break-word"},children:s("storage.spaces.gateway.delete.descForBackup",{name:`${t?.name}`})})})]})}Oe.propTypes={spaceGateway:m.shape({name:m.string.isRequired,url:m.string.isRequired,protected:m.bool}).isRequired,onConfirm:m.func,onCancel:m.func};function Ue({spaceGateway:t,selected:o,onDelete:a=()=>{},onConnect:s=()=>{},enableSwitchToSpace:r=!0,backupInProgress:n=!1,...c}){const{abortBlockletBackup:i}=O(),[d,l]=b.useState(null),{t:x}=D(),[p,f]=b.useState(!1),u=(S,y)=>{S.stopPropagation(),S.preventDefault(),l(y&&S.currentTarget)},k=async S=>{try{f(!0),u(S,!1),await s(t)}catch(y){console.error(y),B.error(y.message)}finally{f(!1)}},w=async S=>{try{f(!0),u(S,!1),await i()}catch(y){console.error(y),B.error(y.message)}finally{f(!1)}};return e.jsxs(e.Fragment,{children:[p||t?.loading?e.jsx(z,{sx:{ml:1},size:"24px"}):e.jsx($e,{"aria-label":"more","aria-controls":"actions-menu","aria-haspopup":"true","data-cy":"trigger-blocklet-actions",variant:"outlined",size:"small",onClick:S=>u(S,!0),...c,children:e.jsx(qe,{})}),e.jsxs(He,{id:"simple-menu",anchorEl:d,keepMounted:!0,open:!!d,onClose:S=>u(S,!1),children:[e.jsxs(G,{onClick:S=>{u(S,!1),window.open(Se(t.endpoint?Ct(t.endpoint):t.url,{allowDomains:null}))},children:[e.jsx(Y,{style:{minWidth:24},children:e.jsx(Qe,{fontSize:"small"})}),e.jsx($,{children:x("common.open")})]}),e.jsxs(G,{onClick:S=>{u(S,!1),window.open(Se(wt(t.endpoint),{allowDomains:null}))},children:[e.jsx(Y,{style:{minWidth:24},children:e.jsx(Xe,{fontSize:"small"})}),e.jsx($,{children:x("storage.spaces.strategy.viewBackupFiles")})]}),!o&&r&&e.jsxs(G,{onClick:k,children:[e.jsx(Y,{style:{minWidth:24},children:e.jsx(Ve,{fontSize:"small"})}),e.jsx($,{children:x("storage.spaces.connect.switchToSpace")})]}),n&&e.jsxs(G,{onClick:w,children:[e.jsx(Y,{style:{minWidth:24},children:e.jsx(Je,{fontSize:"small"})}),e.jsx($,{children:x("storage.spaces.connect.abortBlockletBackup")})]}),!n&&e.jsx(Oe,{spaceGateway:t,onConfirm:async()=>{l(null),await a?.(t)},onCancel:()=>l(null)})]})]})}Ue.propTypes={spaceGateway:m.shape({name:m.string.isRequired,url:m.string.isRequired,protected:m.bool,endpoint:m.string.isRequired,loading:m.bool}).isRequired,selected:m.bool.isRequired,enableSwitchToSpace:m.bool,onDelete:m.func,onConnect:m.func,backupInProgress:m.bool};const Wt=fe(({className:t,...o})=>e.jsx(ge,{...o,classes:{popper:t}}))(()=>({".MuiTooltip-tooltip":{backgroundColor:"transparent",padding:0,margin:0,boxShadow:"none",maxWidth:"none"},".MuiTooltip-arrow":{color:"rgba(230, 235, 245, 1)"}}));function Le({spaceGateway:t,spaceStatus:o,selected:a,onConnected:s=()=>{},onDeleted:r=()=>{},onBackedUp:n=()=>{}}){const{t:c,locale:i}=D(),{blocklet:d}=M(),{api:l,info:{did:x}}=N(),{appDid:p,appName:f,appDescription:u,scopes:k,appUrl:w,referrer:S}=Be({blocklet:d}),{backupProgress:y,updateSpaceGateway:Z,deleteSpaceGateway:ee,refreshBackupSummary:te,refreshBackups:se}=O(),[_,U]=b.useState(!1),[T,P]=b.useState({open:!1,action:"one-click-authorization",checkTimeout:1e3*300,messages:{title:c("storage.spaces.authorize.title",{appName:f},i),scan:c("storage.spaces.authorize.scan",{appName:f},i),confirm:"",success:e.jsx(j,{gutterBottom:!0,children:c("storage.spaces.authorize.success")})},onClose:()=>{P(C=>({...C,open:!1}))}}),ne=a&&!_&&o===de.DISCONNECTED,oe=a&&!_&&!t.loading&&o===de.CONNECTED,K=a&&_&&o===de.CONNECTED&&y?.progress>=0,X=async()=>{try{if(await Bt(t?.endpoint)){await l.configBlocklet({input:{did:[d.meta.did],configs:[{key:L.BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_APP_BACKUP_ENDPOINT,value:t.endpoint}]}}),B.success(c("storage.spaces.connect.switchToSpaceSucceeded",{name:t.name?`(${t.name})`:""})),s?.(null,t);return}}catch(C){console.error(C),s?.(C,t);return}P(C=>({...C,open:!0,prefix:me(t.url,"space/api/did"),baseUrl:new URL(t.url).origin,checkFn:Ce.create({baseURL:me(t.url,"space")}).get,extraParams:{appDid:p,appName:f,appDescription:u,scopes:k,appUrl:w,referrer:S,nodeDid:x,spaceDid:t.did}}))},ae=async(C,g)=>{const v=g(C.endpoint),R=xe(v),A=C.space?g(C.space):{};if(t.did&&R!==t.did){P(Me=>({...Me,open:!1}));const W=c("storage.spaces.gateway.switch.failedForMismatchSpace",{name:A?.name?A.name:""});B.error(W),s?.(new Error(W),t);return}const ce={...t,name:A.name??"DID Space",did:A.did??xe(v),endpoint:v};await Z(ce),P(W=>({...W,open:!1})),s?.(null,ce)},re=async()=>{try{if(_)return;U(!0),await l.backupBlocklet({input:{appDid:d.appDid,to:"spaces"}})}catch(C){console.error(C),B.error(C.message),n?.(C,t)}finally{U(!0)}},ie=async()=>{try{await ee(t),B.success(c("storage.spaces.gateway.delete.succeeded",{name:t.name?`(${t.name})`:""})),r?.(null,t)}catch(C){console.error(C),r?.(C,t)}};return b.useEffect(()=>{y?.completed?(a&&(y?.progress===100?(B.success(c("storage.spaces.backupSuccessfully")),n?.(null,t)):y.message&&n?.(new Error(y?.message),t),y.progress=0,y.message=""),U(!1),te(),se()):y.progress&&U(!0)},[y]),e.jsxs(e.Fragment,{children:[e.jsxs(h,{sx:{display:"flex",alignItems:"center",".action-btn":{borderRadius:1,marginLeft:1}},children:[oe&&e.jsx(le,{className:"action-btn",variant:"outlined",size:"small",onClick:re,children:c("storage.spaces.strategy.backupNow")}),ne&&e.jsx(le,{className:"action-btn",variant:"outlined",size:"small",onClick:X,children:c("storage.spaces.disconnected.reconnectNow")}),K&&e.jsx(Wt,{title:y?.message&&e.jsx(h,{sx:{p:1,borderRadius:1,boxShadow:2,color:"black",backgroundColor:"white"},children:e.jsx(j,{variant:"body2",children:y.message})}),children:e.jsxs(le,{className:"action-btn",variant:"outlined",size:"small",sx:{minWidth:70},children:[e.jsx(z,{variant:"determinate",value:y?.progress,size:14,sx:{mr:1}}),y?.progress,"%"]})}),e.jsx(ot,{forceConnected:!1,saveConnect:!1,prefix:T.prefix,open:T.open,popup:!0,action:T.action,baseUrl:T.baseUrl,checkFn:T.checkFn,onSuccess:ae,onClose:T.onClose,checkTimeout:T.checkTimeout,extraParams:T.extraParams,messages:T.messages,locale:i},"get-endpoint")]}),e.jsx(Ue,{sx:{minWidth:32,padding:"2px 4px",ml:1},spaceGateway:t,selected:a,onDelete:ie,onConnect:X,enableSwitchToSpace:y?.completed||H(y?.message),backupInProgress:K})]})}Le.propTypes={spaceGateway:m.shape({did:m.string.isRequired,name:m.string.isRequired,url:m.string.isRequired,endpoint:m.string.isRequired,protected:m.bool,loading:m.bool}).isRequired,spaceStatus:m.string.isRequired,selected:m.bool.isRequired,onConnected:m.func,onDeleted:m.func,onBackedUp:m.func};function Ft({...t}){const{t:o}=D();return e.jsxs(h,{...t,children:[e.jsx(h,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:3},children:e.jsx(j,{sx:{fontSize:"1.2rem",fontWeight:"bold"},children:o("storage.spaces.backup.records")})}),e.jsx(Pe,{}),e.jsx(ze,{})]})}function Kt({...t}){const{t:o}=D(),{autoBackup:a,updateAutoBackup:s}=O(),r=async()=>{try{const n=!a?.enabled;await s({enabled:n}),B.success(o(n?"storage.spaces.autoBackup.enabled":"storage.spaces.autoBackup.disabled"))}catch(n){B.error(n.message)}};return e.jsx(Rt,{checked:!!a?.enabled,onChange:r,name:"enableWelcomePage",labelProps:{label:e.jsx(j,{sx:{marginRight:"8px"},children:e.jsx("span",{children:o("storage.spaces.autoBackup.title")})})},style:{...t.style}})}function Gt(){const{t}=D(),{spaceGateways:o,spaceGatewaysLoading:a,spaceGatewayIsSelected:s}=O(),r=a&&!o?.length,n=({spaceGateway:c,spaceStatus:i,selected:d,refresh:l})=>e.jsx(Le,{spaceGateway:c,spaceStatus:i,selected:d,onConnected:()=>l(),onBackedUp:x=>x&&l()});return e.jsxs(h,{sx:{display:"flex",flexDirection:"column"},children:[e.jsxs(h,{sx:{display:"flex",flexDirection:{xs:"column",md:"row"},gap:{xs:1,md:2},justifyContent:{xs:"center",md:"flex-start"},alignItems:{xs:"flex-start",md:"center"}},children:[e.jsx(j,{sx:{fontSize:"1.2rem",fontWeight:"bold",flexGrow:1},children:t("storage.spaces.connected.title")}),e.jsx(Kt,{}),e.jsx(Ie,{})]}),e.jsx(h,{sx:{mt:2},children:r?e.jsx(h,{sx:{display:"flex",justifyContent:"center"},children:e.jsx(z,{})}):e.jsx(he,{container:!0,spacing:2,children:e.jsx(e.Fragment,{children:o.map(c=>e.jsx(he,{size:{xs:12,md:6},children:e.jsx(ft,{endpoint:c.endpoint,selected:s(c),action:n},c.endpoint)},c.endpoint))})})}),e.jsx(Ft,{sx:{marginTop:"24px"}}),e.jsx(j,{sx:{fontSize:"1.2rem",fontWeight:"bold",mb:2},children:t("common.dataStorage")}),e.jsx(Re,{})]})}function Yt(){const{spaceGatewaysFirstLoading:t,spaceGateways:o}=O();return t?e.jsx(we,{relative:"parent",children:e.jsx(z,{})}):H(o)?e.jsx(_t,{}):e.jsx(Gt,{})}function $t(){return e.jsx(Te,{children:e.jsx(Yt,{})})}function qt(){const{spaceGateway:t,settingStorageEndpoint:o,updateSpaceGateway:a,hasStorageEndpoint:s,loading:r,storageEndpoint:n}=At(),c=ue(()=>({display:"flex",alignItems:"center",justifyContent:"center",paddingTop:"16px"}));return r?e.jsx(we,{relative:"parent",children:e.jsx(z,{})}):e.jsxs(h,{sx:{maxWidth:"md",position:"relative"},children:[s?e.jsx(gt,{spaceGateway:t,settingStorageEndpoint:o}):e.jsx(ht,{}),e.jsx(h,{sx:c,children:e.jsx(St,{onConnect:a,storageEndpoint:n})})]})}function Ht(){const{t}=D();return e.jsxs(Pt,{children:[e.jsxs(F,{spacing:1,sx:{marginBottom:2},children:[e.jsx(j,{sx:{fontSize:"1.2rem",fontWeight:"bold"},children:t("storage.appLevel.title")}),e.jsx(j,{sx:{color:"text.secondary"},children:t("storage.appLevel.description")})]}),e.jsx(qt,{})]})}function Qt({navOrientation:t="vertical",...o}){const{t:a,locale:s}=D(),{blocklet:r}=M(),n=lt({key:"md"}),[c,i]=et(),d=c.get("tab")||"backup",l=n?"horizontal":t,x=ue(()=>{const w=[{label:a("common.backup"),value:"backup"}],S=r?.capabilities?.didSpace;return(S===L.BLOCKLET_APP_SPACE_REQUIREMENT.REQUIRED||S===L.BLOCKLET_APP_SPACE_REQUIREMENT.REQUIRED_ON_SETUP)&&w.push({label:a("common.storage"),value:"storage"}),w},[s,l]),f=ue(()=>({backup:e.jsx($t,{}),storage:e.jsx(Ht,{})}))[d],u=w=>{i(S=>(w==="backup"?S.delete("tab"):S.set("tab",w),S))};if(x.length<=1)return e.jsx(pe,{children:f});const k=e.jsx(ct,{tabs:x,current:d,orientation:l,onChange:u,sx:[{borderRight:1,height:"100%",borderColor:"divider"},l==="horizontal"&&{borderRight:0}]});if(l==="vertical")return e.jsx(h,{...o,children:e.jsxs(F,{direction:{md:"column",lg:"row"},sx:{gap:2},children:[e.jsx(h,{sx:{flexShrink:0},children:e.jsx(ye,{left:k})}),e.jsx(h,{sx:{flexGrow:1,minWidth:0},children:e.jsx(pe,{sx:{mt:1},children:f})})]})});if(l==="horizontal")return e.jsxs(h,{...o,children:[e.jsx(ye,{left:k}),e.jsx(pe,{sx:{mt:2},children:f})]})}Qt.propTypes={navOrientation:m.oneOf(["vertical","horizontal"])};const pe=fe(h)`
3
3
  position: relative;
4
4
  min-height: 66vh;
@@ -1,4 +1,4 @@
1
- import{r as g}from"./vendor-react-CTtPmzVP.js";import{j as e,y as O,x as X,bZ as Z,M as G,ak as m,W as x,a6 as ke,bi as ve,b6 as Q,z as U,bX as Te,a5 as Ae,at as _,T as E,cv as Ke,cu as Re,aZ as De,Q as Se,cD as Ie}from"./vendor-mui-core-DnR6WYuU.js";import{V as S,b2 as B,w as F,aU as Be,aL as oe,bb as H,H as $e,b9 as Ne,K as Ee,aW as Pe,aP as _e,au as We}from"./vendor-ux-B2x-0VyJ.js";import{f as ze}from"./index-DBs9Ljax.js";import{c as z,Z as I,C as qe,bv as Le,Y as Me,ba as ie,bb as ae,bc as re,q as Ue}from"./index-FreeXNkk.js";import{r as ce}from"./passport-item-CvEGWX-Y.js";import{b as W}from"./team-DB9e4nhx.js";import{l as le}from"./arrow-down.svg-C4FUKwt4.js";import{T as de}from"./index-CwAZTFm0.js";import{C as pe}from"./confirm-CQcou-U0.js";import{a3 as Fe,C as P}from"./vendor-utils-CxWN1dT3.js";import{u as He}from"./session-8btKYxMi.js";import{C as V}from"./click-to-copy-CoAdDvF3.js";import{f as Ve}from"./index-BojVbZw0.js";import{D as Oe}from"./delete-confirm-ZZFKP_G2.js";import{P as Xe}from"./permission-BdJe7FC0.js";import{l as q}from"./vendor-arcblock-hbumvS-z.js";import{B as Ze}from"./bundle-avatar-0OtNVOJk.js";import{W as Ge}from"./did-address-Di02Kgvg.js";import{u as me}from"./use-mobile-BINJTzMb.js";import{A as Qe}from"./actions-Dfiiwkit.js";import{T as ne}from"./table-tips-DLm4KjPB.js";import{D as Ye}from"./vendor-hooks-qxhUUbW5.js";import"./lottie-web-4koyQiv_.js";import"./ua-parser-DP5omx3I.js";import"./util-BbwZ5cox.js";import"./base32-DYZff-KX.js";import"./isURL-Dsl0-5oi.js";import"./use-app-logo-BYRQxVgh.js";import"./vendor-mui-x-CQc01l4r.js";import"./AdapterDayjs-C98qzmYr.js";function Y({value:s}){const{t,locale:n}=S(),a=new Date;return new Date(s)<a?e.jsxs("span",{style:{color:"red"},children:[e.jsx(B,{value:s,locale:n}),`${t("setting.accessKey.expired",{time:""})}`]}):e.jsx(B,{mode:"daysLeft",value:s,locale:n,type:"all"})}Y.propTypes={value:x.string.isRequired};function J({value:s,onChange:t,...n}){const{t:a}=S(),i=g.useMemo(()=>[{value:"signature",title:a("setting.accessKey.signature"),description:a("setting.accessKey.signatureDesc")},{value:"simple",title:a("setting.accessKey.simple"),description:a("setting.accessKey.simpleDesc")}],[a]);return e.jsxs(O,{style:{width:"100%"},variant:"outlined",...n,children:[e.jsx(X,{children:a("setting.accessKey.authType")}),e.jsx(Z,{value:s,onChange:t,fullWidth:!0,label:a("setting.accessKey.authType"),IconComponent:l=>e.jsx(le,{...l,width:20,height:20}),children:i.map(l=>e.jsx(G,{value:l.value,children:e.jsxs(m,{children:[e.jsx("span",{children:l.title}),e.jsx(m,{sx:{maxWidth:510,fontSize:12,color:"#999",whiteSpace:"normal"},children:l.description})]})},l.value))})]})}J.propTypes={value:x.string.isRequired,onChange:x.func.isRequired};const ee=()=>{const s=z.RBAC_CONFIG.roles.filter(i=>i.passport),{inService:t}=I(),{roles:n}=W(),a=[...s,...t?n:[]];return Fe(a,"name").filter(i=>i.name!==z.ROLES.OWNER)};function ue(){const{session:s}=He(),t=ee();return g.useMemo(()=>{if(!s?.user?.role)return[];if(["owner","admin"].includes(s.user.role))return t;const a=t.filter(l=>l.name==="guest");return[...t.filter(l=>l.name!=="guest").filter(l=>s.user.passports.find(b=>b.role===l.name)),...a]},[t,s?.user?.passports,s?.user?.role])}function xe({onCreate:s=()=>{},remark:t=""}){const{api:n}=I(),{teamDid:a}=W(),{t:i}=S(),[l,b]=g.useState(!1),[p,j]=g.useState(null),u=ue(),K=()=>{b(!1),j(null)},C=async r=>{const{remark:w,passport:f,authType:o}=r;b(!0);const v=await n.createAccessKey({input:{teamDid:a,remark:w.trim(),passport:f,expireAt:r.expireAt?new Date(r.expireAt).getTime():null,authType:o}}),{data:R}=v;s(R),j(null),b(!1)},d={title:`${i("common.create")} ${i("accessKey")}`,description:(r,w,f)=>e.jsxs(Q,{sx:{gap:3},children:[e.jsx(U,{label:i("setting.accessKey.tip"),autoComplete:"off",variant:"outlined",name:"remark",fullWidth:!0,autoFocus:!0,margin:"dense",value:r.remark,onChange:o=>{w({...r,remark:o.target.value,__disableConfirm:!r.passport||!o.target.value.trim()}),o.target.value.trim()?f(""):f(i("setting.accessKey.remarkInvalid"))},slotProps:{htmlInput:{"data-cy":"remark-input"}}}),e.jsxs(O,{style:{width:"100%"},variant:"outlined",children:[e.jsx(X,{sx:{width:"calc(100% - 46px)"},children:i("setting.accessKey.passport")}),e.jsx(Z,{"data-cy":"create-access-key-select-passport",value:r.passport,onChange:o=>{const v=o.target.value;f(null),w({...r,passport:v,__disableConfirm:!r.remark||!v})},fullWidth:!0,label:i("setting.accessKey.passport"),disabled:l,IconComponent:o=>e.jsx(le,{...o,width:20,height:20}),children:u.map(o=>e.jsx(G,{value:o.name,"data-cy":`create-access-key-passport-option-${o.name}`,children:e.jsxs(m,{children:[e.jsx("span",{children:o.title||o.name}),e.jsx(m,{sx:{maxWidth:440,fontSize:12,color:"#999",whiteSpace:"normal",textAlign:"justify"},children:o.description})]})},o.name))})]}),e.jsx(J,{value:r.authType,onChange:o=>{w({...r,authType:o.target.value})}}),e.jsx(de,{placeholder:i("setting.accessKey.expireTime"),value:r.expireAt,onChange:o=>{w({...r,expireAt:o,__disableConfirm:!r.passport||!r.remark||!o})}})]}),confirm:i("common.confirm"),cancel:i("common.cancel"),color:"primary",params:{remark:t,authType:"signature",__disableConfirm:!t.trim()},onConfirm:C,onCancel:K};return e.jsxs(e.Fragment,{children:[e.jsxs(F,{edge:"end",variant:"contained",color:"primary","data-cy":"add-access-key-btn",onClick:r=>{r.stopPropagation(),j(d)},className:"rule-action",children:[l?e.jsx(ke,{size:16}):e.jsx(ve,{style:{fontSize:16}}),i("common.create")]}),p&&e.jsx(pe,{title:p.title,description:p.description,confirm:p.confirm,color:p.color,cancel:p.cancel,params:p.params,onConfirm:p.onConfirm,onCancel:p.onCancel})]})}xe.propTypes={remark:x.string,onCreate:x.func};function fe({onConfirm:s=()=>{},accessKeyId:t,accessKeySecret:n,hideSecret:a=!0}){const{t:i}=g.useContext(Be),[l,b]=g.useState(!1),[p,j]=g.useState(()=>a),u=I(),K=()=>{j(!p)},C=f=>{b(f.target.checked)},d=P(window.location.origin,u?.info?.routing?.adminPath),r=g.useMemo(()=>a?`const Client = require('@blocklet/server-js');
1
+ import{r as g}from"./vendor-react-CTtPmzVP.js";import{j as e,y as O,x as X,bZ as Z,M as G,ak as m,W as x,a6 as ke,bi as ve,b6 as Q,z as U,bX as Te,a5 as Ae,at as _,T as E,cv as Ke,cu as Re,aZ as De,Q as Se,cD as Ie}from"./vendor-mui-core-DnR6WYuU.js";import{V as S,b2 as B,w as F,aU as Be,aL as oe,bb as H,H as $e,b9 as Ne,K as Ee,aW as Pe,aP as _e,au as We}from"./vendor-ux-B2x-0VyJ.js";import{f as ze}from"./index-DBs9Ljax.js";import{c as z,Z as I,C as qe,bv as Le,Y as Me,ba as ie,bb as ae,bc as re,q as Ue}from"./index-B-MpZQKm.js";import{r as ce}from"./passport-item-CtZmczAl.js";import{b as W}from"./team-BDHl2zCb.js";import{l as le}from"./arrow-down.svg-C4FUKwt4.js";import{T as de}from"./index-BBMhJfkP.js";import{C as pe}from"./confirm-Dwk8QEtL.js";import{a3 as Fe,C as P}from"./vendor-utils-CxWN1dT3.js";import{u as He}from"./session-CKEyJJp6.js";import{C as V}from"./click-to-copy-CoAdDvF3.js";import{f as Ve}from"./index-BojVbZw0.js";import{D as Oe}from"./delete-confirm-DP8106B2.js";import{P as Xe}from"./permission-2Q-NKCMS.js";import{l as q}from"./vendor-arcblock-hbumvS-z.js";import{B as Ze}from"./bundle-avatar-MwXjHSGV.js";import{W as Ge}from"./did-address-Di02Kgvg.js";import{u as me}from"./use-mobile-BINJTzMb.js";import{A as Qe}from"./actions-Dfiiwkit.js";import{T as ne}from"./table-tips-DLm4KjPB.js";import{D as Ye}from"./vendor-hooks-qxhUUbW5.js";import"./lottie-web-4koyQiv_.js";import"./ua-parser-DP5omx3I.js";import"./util-DMqfvzdX.js";import"./base32-DYZff-KX.js";import"./isURL-CIce9auJ.js";import"./use-app-logo-C52bRzuf.js";import"./vendor-mui-x-CQc01l4r.js";import"./AdapterDayjs-C98qzmYr.js";function Y({value:s}){const{t,locale:n}=S(),a=new Date;return new Date(s)<a?e.jsxs("span",{style:{color:"red"},children:[e.jsx(B,{value:s,locale:n}),`${t("setting.accessKey.expired",{time:""})}`]}):e.jsx(B,{mode:"daysLeft",value:s,locale:n,type:"all"})}Y.propTypes={value:x.string.isRequired};function J({value:s,onChange:t,...n}){const{t:a}=S(),i=g.useMemo(()=>[{value:"signature",title:a("setting.accessKey.signature"),description:a("setting.accessKey.signatureDesc")},{value:"simple",title:a("setting.accessKey.simple"),description:a("setting.accessKey.simpleDesc")}],[a]);return e.jsxs(O,{style:{width:"100%"},variant:"outlined",...n,children:[e.jsx(X,{children:a("setting.accessKey.authType")}),e.jsx(Z,{value:s,onChange:t,fullWidth:!0,label:a("setting.accessKey.authType"),IconComponent:l=>e.jsx(le,{...l,width:20,height:20}),children:i.map(l=>e.jsx(G,{value:l.value,children:e.jsxs(m,{children:[e.jsx("span",{children:l.title}),e.jsx(m,{sx:{maxWidth:510,fontSize:12,color:"#999",whiteSpace:"normal"},children:l.description})]})},l.value))})]})}J.propTypes={value:x.string.isRequired,onChange:x.func.isRequired};const ee=()=>{const s=z.RBAC_CONFIG.roles.filter(i=>i.passport),{inService:t}=I(),{roles:n}=W(),a=[...s,...t?n:[]];return Fe(a,"name").filter(i=>i.name!==z.ROLES.OWNER)};function ue(){const{session:s}=He(),t=ee();return g.useMemo(()=>{if(!s?.user?.role)return[];if(["owner","admin"].includes(s.user.role))return t;const a=t.filter(l=>l.name==="guest");return[...t.filter(l=>l.name!=="guest").filter(l=>s.user.passports.find(b=>b.role===l.name)),...a]},[t,s?.user?.passports,s?.user?.role])}function xe({onCreate:s=()=>{},remark:t=""}){const{api:n}=I(),{teamDid:a}=W(),{t:i}=S(),[l,b]=g.useState(!1),[p,j]=g.useState(null),u=ue(),K=()=>{b(!1),j(null)},C=async r=>{const{remark:w,passport:f,authType:o}=r;b(!0);const v=await n.createAccessKey({input:{teamDid:a,remark:w.trim(),passport:f,expireAt:r.expireAt?new Date(r.expireAt).getTime():null,authType:o}}),{data:R}=v;s(R),j(null),b(!1)},d={title:`${i("common.create")} ${i("accessKey")}`,description:(r,w,f)=>e.jsxs(Q,{sx:{gap:3},children:[e.jsx(U,{label:i("setting.accessKey.tip"),autoComplete:"off",variant:"outlined",name:"remark",fullWidth:!0,autoFocus:!0,margin:"dense",value:r.remark,onChange:o=>{w({...r,remark:o.target.value,__disableConfirm:!r.passport||!o.target.value.trim()}),o.target.value.trim()?f(""):f(i("setting.accessKey.remarkInvalid"))},slotProps:{htmlInput:{"data-cy":"remark-input"}}}),e.jsxs(O,{style:{width:"100%"},variant:"outlined",children:[e.jsx(X,{sx:{width:"calc(100% - 46px)"},children:i("setting.accessKey.passport")}),e.jsx(Z,{"data-cy":"create-access-key-select-passport",value:r.passport,onChange:o=>{const v=o.target.value;f(null),w({...r,passport:v,__disableConfirm:!r.remark||!v})},fullWidth:!0,label:i("setting.accessKey.passport"),disabled:l,IconComponent:o=>e.jsx(le,{...o,width:20,height:20}),children:u.map(o=>e.jsx(G,{value:o.name,"data-cy":`create-access-key-passport-option-${o.name}`,children:e.jsxs(m,{children:[e.jsx("span",{children:o.title||o.name}),e.jsx(m,{sx:{maxWidth:440,fontSize:12,color:"#999",whiteSpace:"normal",textAlign:"justify"},children:o.description})]})},o.name))})]}),e.jsx(J,{value:r.authType,onChange:o=>{w({...r,authType:o.target.value})}}),e.jsx(de,{placeholder:i("setting.accessKey.expireTime"),value:r.expireAt,onChange:o=>{w({...r,expireAt:o,__disableConfirm:!r.passport||!r.remark||!o})}})]}),confirm:i("common.confirm"),cancel:i("common.cancel"),color:"primary",params:{remark:t,authType:"signature",__disableConfirm:!t.trim()},onConfirm:C,onCancel:K};return e.jsxs(e.Fragment,{children:[e.jsxs(F,{edge:"end",variant:"contained",color:"primary","data-cy":"add-access-key-btn",onClick:r=>{r.stopPropagation(),j(d)},className:"rule-action",children:[l?e.jsx(ke,{size:16}):e.jsx(ve,{style:{fontSize:16}}),i("common.create")]}),p&&e.jsx(pe,{title:p.title,description:p.description,confirm:p.confirm,color:p.color,cancel:p.cancel,params:p.params,onConfirm:p.onConfirm,onCancel:p.onCancel})]})}xe.propTypes={remark:x.string,onCreate:x.func};function fe({onConfirm:s=()=>{},accessKeyId:t,accessKeySecret:n,hideSecret:a=!0}){const{t:i}=g.useContext(Be),[l,b]=g.useState(!1),[p,j]=g.useState(()=>a),u=I(),K=()=>{j(!p)},C=f=>{b(f.target.checked)},d=P(window.location.origin,u?.info?.routing?.adminPath),r=g.useMemo(()=>a?`const Client = require('@blocklet/server-js');
2
2
  const ensureServerEndpoint = require('@abtnode/util/lib/ensure-server-endpoint');
3
3
  const { joinURL } = require('ufo');
4
4
 
@@ -1,4 +1,4 @@
1
- import{j as t,a6 as f,ak as r,at as j,W as n}from"./vendor-mui-core-DnR6WYuU.js";import{r as h}from"./vendor-react-CTtPmzVP.js";import{aU as S,w as p}from"./vendor-ux-B2x-0VyJ.js";import{a as C}from"./page-header-CHAwrgX-.js";import{Y as g}from"./index-FreeXNkk.js";import{o as b}from"./vendor-arcblock-hbumvS-z.js";import{u as k}from"./config-space-BR-bgToj.js";import{C as y,D as w,a as v}from"./connect-to-BkcNrFMt.js";import{S as c}from"./step-actions-imyD5TuN.js";import{S as E}from"./layout-DP35nSHr.js";import"./vendor-utils-CxWN1dT3.js";import"./vendor-hooks-qxhUUbW5.js";import"./lottie-web-4koyQiv_.js";import"./spaces-C8s0ejS4.js";import"./api-FQQlzPOP.js";import"./index-CjS1scdg.js";import"./index-DRYJ0xIl.js";import"./index-BojVbZw0.js";import"./index-0SUQD3K4.js";import"./index-DBs9Ljax.js";import"./use-mobile-D5clNlrm.js";import"./content-layout-DmSBGGVm.js";function T({onNext:a=()=>{},onPrevious:d=()=>{}}){const{t:e}=h.useContext(S),{blocklet:o}=g(),{spaceGateway:m,settingStorageEndpoint:l,updateSpaceGateway:u,hasStorageEndpoint:x,loading:i,storageEndpoint:s}=k();return i?t.jsx(b,{relative:"parent",children:t.jsx(f,{})}):t.jsxs(B,{children:[t.jsx("div",{className:"header",children:t.jsx(C,{title:e("setup.didSpace.title"),subTitle:e("setup.didSpace.subTitle"),onClickBack:d})}),t.jsxs(r,{className:"form-container",sx:{width:"100%",maxWidth:"720px"},children:[x?t.jsx(y,{spaceGateway:m,settingStorageEndpoint:l}):t.jsx(w,{}),o?.capabilities?.didSpace&&t.jsx(r,{sx:{display:"flex",alignItems:"center",justifyContent:"center",paddingTop:"24px"},children:t.jsx(v,{onConnect:u,storageEndpoint:s})})]}),o?.capabilities?.didSpace==="required"&&t.jsx(c,{mt:8,children:t.jsx(p,{loading:i,variant:"contained",disabled:i||!s,onClick:()=>a(),children:e("setup.continue")})}),o?.capabilities?.didSpace==="optional"&&t.jsx(c,{blocklet:o,onStartNow:()=>a("complete"),children:t.jsx(p,{className:"start-now",loading:i,variant:"contained",disabled:i,onClick:()=>a(),children:e(s?"setup.continue":"setup.skip")})})]})}T.propTypes={onNext:n.func,onPrevious:n.func};const B=j(E)`
1
+ import{j as t,a6 as f,ak as r,at as j,W as n}from"./vendor-mui-core-DnR6WYuU.js";import{r as h}from"./vendor-react-CTtPmzVP.js";import{aU as S,w as p}from"./vendor-ux-B2x-0VyJ.js";import{a as C}from"./page-header-CHAwrgX-.js";import{Y as g}from"./index-B-MpZQKm.js";import{o as b}from"./vendor-arcblock-hbumvS-z.js";import{u as k}from"./config-space-Cj3K-KMe.js";import{C as y,D as w,a as v}from"./connect-to-DZ8FWX57.js";import{S as c}from"./step-actions-Cd9frxi3.js";import{S as E}from"./layout-vuoHTTUk.js";import"./vendor-utils-CxWN1dT3.js";import"./vendor-hooks-qxhUUbW5.js";import"./lottie-web-4koyQiv_.js";import"./spaces-DZfD-jxX.js";import"./api-FQQlzPOP.js";import"./index-BUg9FOTN.js";import"./index-DRYJ0xIl.js";import"./index-BojVbZw0.js";import"./index-0SUQD3K4.js";import"./index-DBs9Ljax.js";import"./use-mobile-D5clNlrm.js";import"./content-layout-DmSBGGVm.js";function T({onNext:a=()=>{},onPrevious:d=()=>{}}){const{t:e}=h.useContext(S),{blocklet:o}=g(),{spaceGateway:m,settingStorageEndpoint:l,updateSpaceGateway:u,hasStorageEndpoint:x,loading:i,storageEndpoint:s}=k();return i?t.jsx(b,{relative:"parent",children:t.jsx(f,{})}):t.jsxs(B,{children:[t.jsx("div",{className:"header",children:t.jsx(C,{title:e("setup.didSpace.title"),subTitle:e("setup.didSpace.subTitle"),onClickBack:d})}),t.jsxs(r,{className:"form-container",sx:{width:"100%",maxWidth:"720px"},children:[x?t.jsx(y,{spaceGateway:m,settingStorageEndpoint:l}):t.jsx(w,{}),o?.capabilities?.didSpace&&t.jsx(r,{sx:{display:"flex",alignItems:"center",justifyContent:"center",paddingTop:"24px"},children:t.jsx(v,{onConnect:u,storageEndpoint:s})})]}),o?.capabilities?.didSpace==="required"&&t.jsx(c,{mt:8,children:t.jsx(p,{loading:i,variant:"contained",disabled:i||!s,onClick:()=>a(),children:e("setup.continue")})}),o?.capabilities?.didSpace==="optional"&&t.jsx(c,{blocklet:o,onStartNow:()=>a("complete"),children:t.jsx(p,{className:"start-now",loading:i,variant:"contained",disabled:i,onClick:()=>a(),children:e(s?"setup.continue":"setup.skip")})})]})}T.propTypes={onNext:n.func,onPrevious:n.func};const B=j(E)`
2
2
  height: 100%;
3
3
  overflow-y: auto;
4
4
  `;export{T as default};
@@ -1,4 +1,4 @@
1
- import{r as u}from"./vendor-react-CTtPmzVP.js";import{W as o,j as e,ak as j,aN as L,z as A,at as K,cZ as B,I as P,a6 as W,by as M,aj as X,cH as H}from"./vendor-mui-core-DnR6WYuU.js";import{C as U}from"./Google-BS4rB0yL.js";import{aU as G}from"./vendor-ux-B2x-0VyJ.js";import{c as Y}from"./create-passport-svg-H8kuyoHI.js";import{A as Z}from"./vendor-arcblock-hbumvS-z.js";import{q as $}from"./index-FreeXNkk.js";import{R as J}from"./required-BQln5OcV.js";import{F as Q}from"./form-wrapper-PT5ZzMQy.js";import{L as v}from"./logo-uploader-B4RelqSZ.js";import{A as ee,a as ne,b as te}from"./collapse-B7gUzFaX.js";const S={description:o.string,editing:o.bool,onChange:o.func,required:o.bool,value:o.any,componentProps:o.object,render:o.func,renderFormItem:o.func};function T({editing:n,value:s,onChange:l}){const[i,c]=u.useState(!1),m=u.useRef(),f=u.useRef(s);u.useEffect(()=>{let a=null;return n&&(a=setTimeout(()=>{c(!0)},50)),()=>{clearTimeout(a)}},[n]);const h=a=>{f.current=a,l(a)},b=()=>{c(!1),l(f.current)},y=e.jsx(j,{className:"form-item-input slot",sx:{px:1},children:e.jsxs(j,{sx:{display:"flex",alignItems:"center"},children:[s,s!=="auto"&&e.jsx("div",{style:{marginLeft:4,backgroundColor:s,width:"1em",height:"1em",borderRadius:"0.2em"}})]})}),p=e.jsxs(j,{onKeyDown:b,sx:{display:"flex",flexGrow:1,alignItems:"center",height:"40px"},children:[e.jsx(j,{onClick:()=>c(!0),sx:{display:"flex",alignItems:"center"},children:e.jsx("div",{ref:m,style:{flexShrink:0,marginLeft:"8px",backgroundColor:s,width:"32px",height:"32px",boxSizing:"border-box",borderRadius:"8px",border:"1px solid #eee",cursor:s==="auto"?"default":"pointer"}})}),e.jsx(L,{open:i,anchorEl:m.current,onClose:()=>c(!1),anchorOrigin:{vertical:"bottom",horizontal:"center"},transformOrigin:{vertical:"top",horizontal:"center"},children:e.jsx(U,{color:s,onChange:a=>h(a.hex)})})]});return n?p:y}T.propTypes=S;function D({editing:n,description:s,value:l,onChange:i,componentProps:c={},...m}){const{placeholder:f}=c,h=u.useRef(l),{t:b}=u.useContext(G),y=a=>{a.key==="Enter"&&i(h.current,"confirm")},p=a=>{h.current=a,i(a)};return n?e.jsx(A,{style:{flex:1},fullWidth:!0,value:l,onChange:a=>{a.persist(),p(a.target.value)},autoFocus:!0,size:"small",variant:"outlined",placeholder:s||f,onKeyDown:y,...m}):e.jsx(j,{className:"form-item-input slot",sx:{px:1},children:l||e.jsx("span",{className:"placeholder",children:b("common.requiredInputPlaceholder",{name:s||f})})})}D.propTypes=S;function O({editing:n,value:s,onChange:l,componentProps:i,...c}){const{blocklet:m}=i,f=s==="auto"?Z(m.appDid):s;return e.jsxs(j,{sx:{display:"flex",alignItems:"center"},children:[e.jsx("div",{style:{width:96,marginRight:12},dangerouslySetInnerHTML:{__html:Y({title:"Owner",issuer:$.getDisplayName(m),issuerDid:m.appDid,ownerName:"Your Name",ownerDid:m.appDid,preferredColor:s||"auto"})}}),e.jsx(T,{...c,editing:n,value:n?f:s,onChange:l,componentProps:i})]})}O.propTypes={...S,componentProps:o.shape({blocklet:o.object.isRequired}).isRequired};const re=H`
1
+ import{r as u}from"./vendor-react-CTtPmzVP.js";import{W as o,j as e,ak as j,aN as L,z as A,at as K,cZ as B,I as P,a6 as W,by as M,aj as X,cH as H}from"./vendor-mui-core-DnR6WYuU.js";import{C as U}from"./Google-BS4rB0yL.js";import{aU as G}from"./vendor-ux-B2x-0VyJ.js";import{c as Y}from"./create-passport-svg-H8kuyoHI.js";import{A as Z}from"./vendor-arcblock-hbumvS-z.js";import{q as $}from"./index-B-MpZQKm.js";import{R as J}from"./required-BQln5OcV.js";import{F as Q}from"./form-wrapper-PT5ZzMQy.js";import{L as v}from"./logo-uploader-BSnNhLLm.js";import{A as ee,a as ne,b as te}from"./collapse-B7gUzFaX.js";const S={description:o.string,editing:o.bool,onChange:o.func,required:o.bool,value:o.any,componentProps:o.object,render:o.func,renderFormItem:o.func};function T({editing:n,value:s,onChange:l}){const[i,c]=u.useState(!1),m=u.useRef(),f=u.useRef(s);u.useEffect(()=>{let a=null;return n&&(a=setTimeout(()=>{c(!0)},50)),()=>{clearTimeout(a)}},[n]);const h=a=>{f.current=a,l(a)},b=()=>{c(!1),l(f.current)},y=e.jsx(j,{className:"form-item-input slot",sx:{px:1},children:e.jsxs(j,{sx:{display:"flex",alignItems:"center"},children:[s,s!=="auto"&&e.jsx("div",{style:{marginLeft:4,backgroundColor:s,width:"1em",height:"1em",borderRadius:"0.2em"}})]})}),p=e.jsxs(j,{onKeyDown:b,sx:{display:"flex",flexGrow:1,alignItems:"center",height:"40px"},children:[e.jsx(j,{onClick:()=>c(!0),sx:{display:"flex",alignItems:"center"},children:e.jsx("div",{ref:m,style:{flexShrink:0,marginLeft:"8px",backgroundColor:s,width:"32px",height:"32px",boxSizing:"border-box",borderRadius:"8px",border:"1px solid #eee",cursor:s==="auto"?"default":"pointer"}})}),e.jsx(L,{open:i,anchorEl:m.current,onClose:()=>c(!1),anchorOrigin:{vertical:"bottom",horizontal:"center"},transformOrigin:{vertical:"top",horizontal:"center"},children:e.jsx(U,{color:s,onChange:a=>h(a.hex)})})]});return n?p:y}T.propTypes=S;function D({editing:n,description:s,value:l,onChange:i,componentProps:c={},...m}){const{placeholder:f}=c,h=u.useRef(l),{t:b}=u.useContext(G),y=a=>{a.key==="Enter"&&i(h.current,"confirm")},p=a=>{h.current=a,i(a)};return n?e.jsx(A,{style:{flex:1},fullWidth:!0,value:l,onChange:a=>{a.persist(),p(a.target.value)},autoFocus:!0,size:"small",variant:"outlined",placeholder:s||f,onKeyDown:y,...m}):e.jsx(j,{className:"form-item-input slot",sx:{px:1},children:l||e.jsx("span",{className:"placeholder",children:b("common.requiredInputPlaceholder",{name:s||f})})})}D.propTypes=S;function O({editing:n,value:s,onChange:l,componentProps:i,...c}){const{blocklet:m}=i,f=s==="auto"?Z(m.appDid):s;return e.jsxs(j,{sx:{display:"flex",alignItems:"center"},children:[e.jsx("div",{style:{width:96,marginRight:12},dangerouslySetInnerHTML:{__html:Y({title:"Owner",issuer:$.getDisplayName(m),issuerDid:m.appDid,ownerName:"Your Name",ownerDid:m.appDid,preferredColor:s||"auto"})}}),e.jsx(T,{...c,editing:n,value:n?f:s,onChange:l,componentProps:i})]})}O.propTypes={...S,componentProps:o.shape({blocklet:o.object.isRequired}).isRequired};const re=H`
2
2
  0%, 100% {
3
3
  transform: scale(1) translateX(0);
4
4
  }
@@ -1,4 +1,4 @@
1
- import{r as j,g as ge}from"./vendor-react-CTtPmzVP.js";import{j as o,T as H,z as $,x as ye,cs as ve,ct as Y,ca as je,F as Ce,bf as Te,aZ as Fe,a6 as U,W as C,bX as be,a5 as we,I as K,at as Z,ak as B,Q as Se,bi as Be,J as De,am as Re}from"./vendor-mui-core-DnR6WYuU.js";import{Z as E,aL as ae,G as le,c as Ne}from"./index-FreeXNkk.js";import{V as M,aL as ce,w as L,H as z,a1 as ee,ba as Pe}from"./vendor-ux-B2x-0VyJ.js";import{e as ue}from"./edit.svg-RRSklUg-.js";import{C as He}from"./lock.svg-BgybwZNe.js";import{G as Ie,T as Le}from"./vendor-utils-CxWN1dT3.js";import{f as pe}from"./index-DBs9Ljax.js";import{b as de}from"./team-DB9e4nhx.js";import{w as me,P as Ee}from"./permission-BdJe7FC0.js";import{C as Me}from"./confirm-CQcou-U0.js";const _e=u=>j.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",...u},j.createElement("path",{d:"M8.4375 4.3125H8.25C8.35313 4.3125 8.4375 4.22812 8.4375 4.125V4.3125H15.5625V4.125C15.5625 4.22812 15.6469 4.3125 15.75 4.3125H15.5625V6H17.25V4.125C17.25 3.29766 16.5773 2.625 15.75 2.625H8.25C7.42266 2.625 6.75 3.29766 6.75 4.125V6H8.4375V4.3125ZM20.25 6H3.75C3.33516 6 3 6.33516 3 6.75V7.5C3 7.60313 3.08437 7.6875 3.1875 7.6875H4.60312L5.18203 19.9453C5.21953 20.7445 5.88047 21.375 6.67969 21.375H17.3203C18.1219 21.375 18.7805 20.7469 18.818 19.9453L19.3969 7.6875H20.8125C20.9156 7.6875 21 7.60313 21 7.5V6.75C21 6.33516 20.6648 6 20.25 6ZM17.1398 19.6875H6.86016L6.29297 7.6875H17.707L17.1398 19.6875Z"}));var A={exports:{}},W={exports:{}},te;function ke(){return te||(te=1,function(){var u="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",m={rotl:function(a,c){return a<<c|a>>>32-c},rotr:function(a,c){return a<<32-c|a>>>c},endian:function(a){if(a.constructor==Number)return m.rotl(a,8)&16711935|m.rotl(a,24)&4278255360;for(var c=0;c<a.length;c++)a[c]=m.endian(a[c]);return a},randomBytes:function(a){for(var c=[];a>0;a--)c.push(Math.floor(Math.random()*256));return c},bytesToWords:function(a){for(var c=[],l=0,p=0;l<a.length;l++,p+=8)c[p>>>5]|=a[l]<<24-p%32;return c},wordsToBytes:function(a){for(var c=[],l=0;l<a.length*32;l+=8)c.push(a[l>>>5]>>>24-l%32&255);return c},bytesToHex:function(a){for(var c=[],l=0;l<a.length;l++)c.push((a[l]>>>4).toString(16)),c.push((a[l]&15).toString(16));return c.join("")},hexToBytes:function(a){for(var c=[],l=0;l<a.length;l+=2)c.push(parseInt(a.substr(l,2),16));return c},bytesToBase64:function(a){for(var c=[],l=0;l<a.length;l+=3)for(var p=a[l]<<16|a[l+1]<<8|a[l+2],d=0;d<4;d++)l*8+d*6<=a.length*8?c.push(u.charAt(p>>>6*(3-d)&63)):c.push("=");return c.join("")},base64ToBytes:function(a){a=a.replace(/[^A-Z0-9+\/]/ig,"");for(var c=[],l=0,p=0;l<a.length;p=++l%4)p!=0&&c.push((u.indexOf(a.charAt(l-1))&Math.pow(2,-2*p+8)-1)<<p*2|u.indexOf(a.charAt(l))>>>6-p*2);return c}};W.exports=m}()),W.exports}var V,re;function ne(){if(re)return V;re=1;var u={utf8:{stringToBytes:function(m){return u.bin.stringToBytes(unescape(encodeURIComponent(m)))},bytesToString:function(m){return decodeURIComponent(escape(u.bin.bytesToString(m)))}},bin:{stringToBytes:function(m){for(var a=[],c=0;c<m.length;c++)a.push(m.charCodeAt(c)&255);return a},bytesToString:function(m){for(var a=[],c=0;c<m.length;c++)a.push(String.fromCharCode(m[c]));return a.join("")}}};return V=u,V}/*!
1
+ import{r as j,g as ge}from"./vendor-react-CTtPmzVP.js";import{j as o,T as H,z as $,x as ye,cs as ve,ct as Y,ca as je,F as Ce,bf as Te,aZ as Fe,a6 as U,W as C,bX as be,a5 as we,I as K,at as Z,ak as B,Q as Se,bi as Be,J as De,am as Re}from"./vendor-mui-core-DnR6WYuU.js";import{Z as E,aL as ae,G as le,c as Ne}from"./index-B-MpZQKm.js";import{V as M,aL as ce,w as L,H as z,a1 as ee,ba as Pe}from"./vendor-ux-B2x-0VyJ.js";import{e as ue}from"./edit.svg-RRSklUg-.js";import{C as He}from"./lock.svg-BgybwZNe.js";import{G as Ie,T as Le}from"./vendor-utils-CxWN1dT3.js";import{f as pe}from"./index-DBs9Ljax.js";import{b as de}from"./team-BDHl2zCb.js";import{w as me,P as Ee}from"./permission-2Q-NKCMS.js";import{C as Me}from"./confirm-Dwk8QEtL.js";const _e=u=>j.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",...u},j.createElement("path",{d:"M8.4375 4.3125H8.25C8.35313 4.3125 8.4375 4.22812 8.4375 4.125V4.3125H15.5625V4.125C15.5625 4.22812 15.6469 4.3125 15.75 4.3125H15.5625V6H17.25V4.125C17.25 3.29766 16.5773 2.625 15.75 2.625H8.25C7.42266 2.625 6.75 3.29766 6.75 4.125V6H8.4375V4.3125ZM20.25 6H3.75C3.33516 6 3 6.33516 3 6.75V7.5C3 7.60313 3.08437 7.6875 3.1875 7.6875H4.60312L5.18203 19.9453C5.21953 20.7445 5.88047 21.375 6.67969 21.375H17.3203C18.1219 21.375 18.7805 20.7469 18.818 19.9453L19.3969 7.6875H20.8125C20.9156 7.6875 21 7.60313 21 7.5V6.75C21 6.33516 20.6648 6 20.25 6ZM17.1398 19.6875H6.86016L6.29297 7.6875H17.707L17.1398 19.6875Z"}));var A={exports:{}},W={exports:{}},te;function ke(){return te||(te=1,function(){var u="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",m={rotl:function(a,c){return a<<c|a>>>32-c},rotr:function(a,c){return a<<32-c|a>>>c},endian:function(a){if(a.constructor==Number)return m.rotl(a,8)&16711935|m.rotl(a,24)&4278255360;for(var c=0;c<a.length;c++)a[c]=m.endian(a[c]);return a},randomBytes:function(a){for(var c=[];a>0;a--)c.push(Math.floor(Math.random()*256));return c},bytesToWords:function(a){for(var c=[],l=0,p=0;l<a.length;l++,p+=8)c[p>>>5]|=a[l]<<24-p%32;return c},wordsToBytes:function(a){for(var c=[],l=0;l<a.length*32;l+=8)c.push(a[l>>>5]>>>24-l%32&255);return c},bytesToHex:function(a){for(var c=[],l=0;l<a.length;l++)c.push((a[l]>>>4).toString(16)),c.push((a[l]&15).toString(16));return c.join("")},hexToBytes:function(a){for(var c=[],l=0;l<a.length;l+=2)c.push(parseInt(a.substr(l,2),16));return c},bytesToBase64:function(a){for(var c=[],l=0;l<a.length;l+=3)for(var p=a[l]<<16|a[l+1]<<8|a[l+2],d=0;d<4;d++)l*8+d*6<=a.length*8?c.push(u.charAt(p>>>6*(3-d)&63)):c.push("=");return c.join("")},base64ToBytes:function(a){a=a.replace(/[^A-Z0-9+\/]/ig,"");for(var c=[],l=0,p=0;l<a.length;p=++l%4)p!=0&&c.push((u.indexOf(a.charAt(l-1))&Math.pow(2,-2*p+8)-1)<<p*2|u.indexOf(a.charAt(l))>>>6-p*2);return c}};W.exports=m}()),W.exports}var V,re;function ne(){if(re)return V;re=1;var u={utf8:{stringToBytes:function(m){return u.bin.stringToBytes(unescape(encodeURIComponent(m)))},bytesToString:function(m){return decodeURIComponent(escape(u.bin.bytesToString(m)))}},bin:{stringToBytes:function(m){for(var a=[],c=0;c<m.length;c++)a.push(m.charCodeAt(c)&255);return a},bytesToString:function(m){for(var a=[],c=0;c<m.length;c++)a.push(String.fromCharCode(m[c]));return a.join("")}}};return V=u,V}/*!
2
2
  * Determine if an object is a Buffer
3
3
  *
4
4
  * @author Feross Aboukhadijeh <https://feross.org>
@@ -1,4 +1,4 @@
1
- import{r as x}from"./vendor-react-CTtPmzVP.js";import{j as e,W as d,am as mt,ak as N,T as X,U as ke,y as Fe,bk as Ve,b$ as Re,bX as Te,a5 as Ie,Q as Ce,dH as Pe,aN as Ee,a6 as Ge,D as Xe,cD as ht,ad as Qe,e4 as gt,e5 as xt,at as ae,b4 as He,n as bt,J as yt,x as jt,bZ as St,M as qe,cB as vt}from"./vendor-mui-core-DnR6WYuU.js";import{e as ee,F as Ct,aB as pe}from"./vendor-utils-CxWN1dT3.js";import{H as q,aV as Nt,V as Y,cN as wt,m as Ye,$ as Ze,w as Ae,aP as Je,bi as be,aL as Rt,aX as Tt,b2 as It,b9 as Et}from"./vendor-ux-B2x-0VyJ.js";import{Z as At,Q as H,c as E,C as Dt,a1 as Ue}from"./index-FreeXNkk.js";import{a as Q,g as De}from"./vendor-hooks-qxhUUbW5.js";import{S as me}from"./shorten-label-C4py9TLA.js";import{v as et}from"./index-Bnog6DRk.js";import{R as tt,A as Ot,S as Lt,a as kt,B as Ft}from"./list-CXg6onZy.js";import{i as Pt,e as _t,N as Bt}from"./team-DB9e4nhx.js";import{W as zt}from"./did-address-Di02Kgvg.js";import{p as st}from"./util-BbwZ5cox.js";import{D as Wt,g as Mt}from"./traffic-2gK2nM6D.js";import{B as nt}from"./bundle-avatar-0OtNVOJk.js";import"./lottie-web-4koyQiv_.js";import"./vendor-arcblock-hbumvS-z.js";import"./server-logo-notext.svg-xZ-i1SpD.js";import"./session-8btKYxMi.js";import"./isURL-Dsl0-5oi.js";import"./use-app-logo-BYRQxVgh.js";import"./base32-DYZff-KX.js";import"./useAsyncRetry-r8dEPb-x.js";import"./useAsync-Dotoxibi.js";import"./iframe-CFsgaleC.js";import"./index-BV9eY5c_.js";import"./index-DBs9Ljax.js";import"./base-chart-ChBZtUEG.js";import"./index-D1SIrheh.js";import"./vendor-mui-x-CQc01l4r.js";import"./AdapterDayjs-C98qzmYr.js";const at=x.createContext({}),{Provider:Kt,Consumer:Hs}=at;function Ht({children:t,blocklet:s=""}){const{api:n,inService:r,ws:{useSubscription:i}}=At(),[l,b]=x.useState([]),[m,S]=x.useState({total:0,pageSize:20,pageCount:0,page:1}),h=Q(()=>s.meta?.did,[s]),[y,v]=x.useState([]),[P,F]=x.useState({}),w=Q(()=>l.length?new Set(l.map(p=>p.id)):new Set,[l]),U=async({page:p=1,pageSize:g=20,...T}={})=>{if(!h)return[];try{const D={paging:{page:p,pageSize:g},...T,teamDid:h,dateRange:T.dateRange?[H(T.dateRange[0]).toISOString(),H(T.dateRange[1]).toISOString()]:void 0},{dids:O,...z}=D;let _="";O&&O.includes("system")&&(_="system");const ie=O?O.filter(oe=>oe!=="system"):[],se={...z,source:_,componentDids:ie},J=await n.getNotificationSendLog({input:se});return F(se),b(J.list),S(J.paging),J.list}catch(D){return q.error(D.message),[]}},M=async()=>{const p=await n.getNotificationComponents({input:{teamDid:h}});v(p.componentDids)},L=x.useCallback(p=>{const g=s.children.find(T=>T.meta?.did===p);if(g)return g.ancestors=[s],g},[s]),k=async({notificationId:p,receivers:g,channels:T,...D})=>{await n.resendNotification({input:{teamDid:h,notificationId:p,receivers:g,channels:T.map(O=>O==="wallet"?E.NOTIFICATION_SEND_CHANNEL.WALLET:O==="pushKit"?E.NOTIFICATION_SEND_CHANNEL.PUSH:O),...D}})},$=x.useCallback(async p=>(await n.getUser({input:{teamDid:h,user:{did:p},options:{enableConnectedAccount:!0}}})).user,[n,h]),V=x.useCallback(async({page:p=1,pageSize:g=20,...T}={})=>{try{const D={paging:{page:p,pageSize:g},...T,userName:T.searchText||"",teamDid:h,dateRange:T.dateRange?[H(T.dateRange[0]).toISOString(),H(T.dateRange[1]).toISOString()]:void 0};return await n.getReceivers({input:D})}catch(D){throw q.error(D.message),D}},[n,h]);x.useEffect(()=>{h&&M()},[h]),i(E.EVENTS.NOTIFICATION_BLOCKLET_UPDATE,p=>{w.has(p.notificationId)&&U(P)},[w,P]),i(E.EVENTS.NOTIFICATION_BLOCKLET_CREATE,p=>{w.has(p.id)||U(P)},[w,P]);const Z={fetch:U,data:l,paging:m,blocklet:s,getComponent:L,resendNotification:k,getUser:$,componentDids:y,getReceivers:V,inService:r,teamDid:h};return e.jsx(Kt,{value:{notificationRecords:Z},children:t})}function _e(){const{notificationRecords:t}=x.useContext(at);return t}he.propTypes={severity:d.oneOf(Object.values(["info","success","error","warning"])).isRequired};const qt={info:"primary",success:"success",error:"error",warning:"warning"};function he({severity:t="info"}){return e.jsx(Nt,{type:qt[t],children:t})}const Ut=(t,s,n="")=>{if(!n||!s)return"";switch(n){case E.NOTIFICATION_SEND_FAILED_REASON.USER_DISABLED:return t("notification.sendStatus.reason.disabled",{channel:s});case E.NOTIFICATION_SEND_FAILED_REASON.CHANNEL_UNAVAILABLE:return t("notification.sendStatus.reason.unavailable",{channel:s});case E.NOTIFICATION_SEND_FAILED_REASON.CHANNEL_DISABLED:return t("notification.sendStatus.reason.notSent",{channel:s});case E.NOTIFICATION_SEND_FAILED_REASON.NOT_ONLINE:return t("notification.sendStatus.reason.offline");default:return n}};function it(t,s,n={}){const{status:r,updatedAt:i,reason:l="",channel:b="wallet"}=n,m=i?t("notification.sendStatus.sentTime",{date:Dt(i,s)}):"",S=Ut(t,b,l);return r===E.NOTIFICATION_SEND_STATUS.FAILED?{status:"failed",title:t("notification.sendStatus.failed"),sentTime:m,reason:S}:r===E.NOTIFICATION_SEND_STATUS.SENT?{status:"success",title:t("notification.sendStatus.success"),sentTime:m}:{status:"pending",title:t("notification.sendStatus.pending"),reason:S,sentTime:m}}const Oe={pending:"#aaaaaa",success:"#34BE74",failed:"#D0021B"},Le=["wallet","pushKit","email"],$e=["info","success","error","warning"],ot=t=>{const{settings:s}=t;return s?.notification?.email?.enabled},rt=t=>{const{settings:s}=t;return s?.notification?.pushKit?.enabled},$t=(t,s)=>{const n=ee(s,"extra.notifications.email",!0);return{available:ot(t),enabled:n}},Vt=(t,s)=>{const n=ee(s,"extra.notifications.push",!0);return{available:rt(t),enabled:n}},Gt=t=>({enabled:ee(t,"extra.notifications.wallet",!0)}),Xt=t=>({enabled:ee(t,"extra.webhooks",[]).length>0}),ge=(t=3)=>new Promise(s=>{setTimeout(()=>{s()},t*1e3)}),Qt=(t,s)=>s==="wallet"||s==="webhook"?[{channel:s,type:"enabled",pass:t("notification.sendStatus.reason.enabled",{channel:s}),fail:t("notification.sendStatus.reason.disabled",{channel:s})}]:s==="pushKit"||s==="email"?[{channel:s,type:"available",pass:t("notification.sendStatus.reason.available",{channel:s}),fail:t("notification.sendStatus.reason.unavailable",{channel:s})},{channel:s,type:"enabled",pass:t("notification.sendStatus.reason.enabled",{channel:s}),fail:t("notification.sendStatus.reason.disabled",{channel:s})}]:[],xe=(t=[])=>{const s=H().startOf("day");return t.filter(n=>H(n.sendAt).isSame(s,"day")).length},Yt=(t,s="")=>{if(s&&Le.includes(s)){const l=`${s}SendRecord`,b=ee(t,l,[]);return xe(b)}const n=ee(t,"webhook",{}),r=Object.keys(n??{})??[];if(s&&r.includes(s)){const l=n[s]??[];return xe(l)}const i={};return Le.forEach(l=>{const b=`${l}SendRecord`,m=ee(t,b,[]),S=xe(m);i[l]=S}),r.length>0&&r.forEach(l=>{const b=n[l]??[],m=xe(b);i[l]=m}),i},ye=(t,s,n)=>{if(!Array.isArray(t))throw new Error("Invalid filterList or index");return t[n].splice(s,1),t},je=(t,s)=>{if(!Array.isArray(s))throw new Error("filters must be an array");return s.length?!s.includes(t):!1},Zt=t=>{switch(t){case E.NOTIFICATION_SEND_CHANNEL.WALLET:return"Wallet";case E.NOTIFICATION_SEND_CHANNEL.PUSH:return"Push Kit";case E.NOTIFICATION_SEND_CHANNEL.EMAIL:return"Email";case E.NOTIFICATION_SEND_CHANNEL.WEBHOOK:return"Webhook";default:return""}},lt=()=>({components:{MUIDataTableFilter:{styleOverrides:{header:{marginBottom:0,p:{margin:0}},root:{"& .MuiGrid-container":{marginTop:0,"& .MuiGrid-item":{paddingTop:0}}}}},MuiPopover:{styleOverrides:{root:{"&.MuiPopover-root":{"& .MuiPaper-root:has(.filter-container)":{width:"420px"}}}}}}});function te({config:t,enableTooltip:s=!0,showTitle:n=!1,children:r=null}){const{status:i,title:l="",sentTime:b="",reason:m=""}=t,S=[l,m].filter(Boolean).join(", ");return e.jsx(mt,{title:s?e.jsxs(e.Fragment,{children:[e.jsx(X,{color:"inherit",sx:{fontSize:12},children:S}),e.jsx("span",{children:b})]}):null,arrow:!0,placement:"top",children:e.jsxs(N,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"4px"},children:[e.jsxs(N,{sx:{position:"relative",minHeight:14,minWidth:14,display:"flex",alignItems:"center",justifyContent:"center"},children:[e.jsx(N,{style:{opacity:.15},sx:{position:"absolute",width:"100%",height:"100%",borderRadius:"50%",bgcolor:Oe[i]}}),e.jsx(N,{sx:{position:"absolute",width:"55%",height:"55%",borderRadius:"50%",bgcolor:Oe[i]}})]}),e.jsx(X,{color:"inherit",sx:{fontSize:12},children:n?l:r})]})})}te.propTypes={config:d.object.isRequired,enableTooltip:d.bool,showTitle:d.bool,children:d.node};Se.propTypes={list:d.array.isRequired,label:d.string.isRequired,onDelete:d.func};function Se({list:t,label:s,onDelete:n=()=>{}}){const{t:r,locale:i}=Y();return e.jsxs(N,{sx:{display:"flex",gap:1,alignItems:"center"},children:[e.jsxs(X,{children:[s,": "]}),t.map(l=>{const b=it(r,i,{status:l});return e.jsx(ke,{size:"small",label:e.jsx(N,{sx:{display:"flex",alignItems:"center",gap:"4px"},children:e.jsx(te,{config:b,enableTooltip:!1,children:b.title})}),onDelete:m=>n(m,l)},l)})]})}Be.propTypes={filterList:d.array.isRequired,onChange:d.func.isRequired,index:d.number.isRequired,column:d.object.isRequired,filterValues:d.array.isRequired,label:d.string.isRequired,renderLabel:d.func.isRequired};function Be({filterList:t,onChange:s,index:n,column:r,filterValues:i,label:l,renderLabel:b}){return e.jsxs(Fe,{className:"filter-container",children:[e.jsx(Ve,{component:"legend",children:l}),e.jsx(Re,{row:!0,children:i.map(m=>e.jsx(Te,{control:e.jsx(Ie,{checked:t[n].indexOf(m.value??m)>-1,onChange:S=>{const h=[...t];S.target.checked?h[n]=[...h[n],m.value??m]:h[n]=h[n].filter(y=>y!==(m.value??m)),s(h[n],n,r)},name:m.value??m}),label:e.jsx("span",{style:{display:"flex",alignItems:"center"},children:b(m)})},m.value??m))})]})}function we(t){return e.jsx(Be,{...t,renderLabel:s=>e.jsx(te,{enableTooltip:!1,config:{status:s.status},children:s.label})})}ce.propTypes={status:d.number.isRequired,updatedAt:d.string.isRequired,reason:d.string,channel:d.string,onResend:d.func};function ce({status:t,updatedAt:s,reason:n="",channel:r="wallet",onResend:i}){const{t:l,locale:b}=Y(),m=it(l,b,{status:t,updatedAt:s,reason:n,channel:r});return e.jsxs(N,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(te,{config:m,showTitle:!0}),m.status!=="success"&&e.jsx(Ce,{className:"resend-btn",size:"small",startIcon:e.jsx(Pe,{}),sx:{fontSize:12,color:"rgba(0, 0, 0, 0.87)",fontWeight:400,".MuiButton-startIcon":{mr:"2px"}},onClick:i,children:l("notification.resend")})]})}ze.propTypes={value:d.array.isRequired,onChange:d.func};function ze({value:t,onChange:s}){const{locale:n}=Y(),r=H().toDate(),[i,l]=x.useState(null),b=x.useCallback(h=>{l(i?null:h.currentTarget)},[i]),m=!!i,S=x.useCallback(h=>{if(!h.startDate||!h.endDate){q.error("Please select a date range");return}if(H(h.startDate).isAfter(h.endDate)||!H(h.startDate).isValid()||!H(h.endDate).isValid()){q.error("Invalid date range");return}s([h.startDate,h.endDate]),l(null)},[s]);return e.jsxs("div",{children:[e.jsx(X,{component:"div",variant:"h5",color:"textPrimary",style:{fontSize:18,fontWeight:"bold"},sx:{mb:0},children:e.jsxs(Ce,{onClick:b,variant:"outlined",size:"small",color:"inherit",children:[Ue(t[0],n)," - ",Ue(t[1],n)]})}),e.jsx(Ee,{open:m,anchorEl:i,onClose:()=>{l(null)},anchorOrigin:{vertical:"bottom",horizontal:"left"},children:e.jsx(Wt,{open:!0,maxDate:r,initialDateRange:{startDate:t[0],endDate:t[1]},toggle:b,definedRanges:Mt(r),onChange:S})})]})}We.propTypes={itemComponent:d.elementType.isRequired};function We({itemComponent:t,...s}){const{t:n}=Y();return!s?.filterList?.filter(i=>i.length).length?null:e.jsxs(N,{sx:{display:"flex",gap:1,alignItems:"center"},children:[e.jsx("div",{className:"toolbar-filter-title",children:n("notification.filter")}),e.jsx("div",{className:"toolbar-filter-content",children:e.jsx(wt.TableFilterList,{...s,ItemComponent:t})})]})}function Me({label:t,onDelete:s,canDelete:n=()=>!0,...r}){const i=s&&typeof s=="function"?s:void 0;let l=!0;return n&&typeof n=="function"&&(l=n({label:t,...r})),e.jsx(ke,{label:t,variant:"outlined",...i&&l?{onDelete:i}:{}})}Me.propTypes={label:d.string.isRequired,onDelete:d.func,canDelete:d.func};const Jt=[{label:"Wallet",value:"app",checked:!0},{label:"Email",value:"email",checked:!0},{label:"Push Kit",value:"push",checked:!0},{label:"Webhook",value:"webhook",checked:!0}];ct.propTypes={loading:d.bool,onCancel:d.func,onConfirm:d.func};function ct({loading:t=!1,onCancel:s=()=>{},onConfirm:n=()=>{}}){const{t:r}=Y(),[i,l]=x.useState(Jt),[b,m]=x.useState(!0),S=(y,v)=>{v.checked=y.target.checked;const P=i.map(F=>({...F,checked:F.value===v.value?v.checked:F.checked}));l(P)},h=y=>{y.stopPropagation(),n({channels:i.filter(v=>v.checked).map(v=>v.value),isResendFailedOnly:b})};return e.jsxs(N,{className:"resend-config",sx:{padding:"16px 24px"},children:[e.jsx(X,{variant:"body1",component:"div",className:"check-title",sx:{fontWeight:700,mb:1},children:r("notification.config")}),e.jsx(N,{className:"choose-channel",children:e.jsxs(Fe,{component:"fieldset",variant:"standard",children:[e.jsx(Ve,{component:"legend",children:r("notification.selectChannels")}),e.jsx(Re,{sx:{display:"flex",flexDirection:"row",flexWrap:"wrap",gap:1},children:i.map(y=>e.jsx(Te,{control:e.jsx(Ie,{checked:y.checked,onChange:v=>S(v,y),name:y.value}),label:y.label},y.value))})]})}),e.jsx(N,{className:"resend-config-footer",children:e.jsx(Re,{children:e.jsx(Te,{control:e.jsx(Ie,{checked:b,onChange:y=>m(y.target.checked)}),label:r("notification.resendFailedOnly")})})}),e.jsxs(N,{className:"resend-config-footer-tip",sx:{display:"flex",justifyContent:"flex-end",gap:1},children:[e.jsx(Ce,{onClick:y=>{y.stopPropagation(),s()},color:"inherit",children:r("common.cancel")}),e.jsxs(Ce,{onClick:h,color:"primary",disabled:t,variant:"contained",autoFocus:!0,style:{marginLeft:8},children:[t&&e.jsx(Ge,{size:16}),r("common.confirm")]})]})]})}dt.propTypes={notificationId:d.string.isRequired,handleResend:d.func,resending:d.bool};function dt({notificationId:t,handleResend:s,resending:n=!1}){const{t:r,locale:i}=Y(),l=Xe(),b=x.useMemo(()=>Ye(l,lt()),[l]),{getReceivers:m,inService:S,teamDid:h,getUser:y,blocklet:v}=_e(),[P,F]=x.useState(!1),[w,U]=x.useState([]),M=De({anchorEl:null,position:null}),L=De({anchorEl:null,position:null}),[k,$]=x.useState(null),[V,Z]=x.useState({total:0,pageSize:10,pageCount:0,page:1}),[p,g]=x.useState({searchText:"",page:1,pageSize:10,walletSendStatus:[],pushKitSendStatus:[],emailSendStatus:[],dateRange:[H().subtract(1,"month").startOf("day").toDate(),H().endOf("day").toDate()]}),[T,D]=x.useState([]),O=[{label:r("notification.sendStatus.pending"),value:0,status:"pending"},{label:r("notification.sendStatus.success"),value:1,status:"success"},{label:r("notification.sendStatus.failed"),value:2,status:"failed"}],z=async()=>{if(!P&&t)try{F(!0);const a=await m({notificationId:t,...p}),o=a.list.map(c=>({...c,receiverUser:{...c.receiverUser,avatar:st(c.receiverUser.avatar,h,S)}}));U(o),Z(a.paging),F(!1)}catch(a){q.error(a.message),F(!1)}};x.useEffect(()=>{z()},[p]);const _=a=>{a.stopPropagation();const o=a.currentTarget;L.anchorEl=o;const c=o.getBoundingClientRect();L.position={top:c.top+window.scrollY,left:c.left+window.scrollX}},ie=a=>a.data.length?e.jsx("div",{style:{display:"flex",alignItems:"center",padding:"10px"},children:e.jsx(Ae,{className:"resend-btn",size:"small",color:"primary",variant:"contained",startIcon:e.jsx(Pe,{}),sx:{".MuiButton-startIcon":{mr:"2px"}},onClick:_,children:r("notification.resend")})}):null,se={sort:!1,download:!1,print:!1,selectableRows:"multiple",searchPlaceholder:r("common.search"),searchAlwaysOpen:!1,filterType:"checkbox",searchDebounceTime:300,page:V.page-1,rowsPerPage:V.pageSize,count:V.total,searchText:p.searchText,tableBodyMaxHeight:"calc(80vh - 260px)",rowsSelected:T,onRowSelectionChange:(a,o)=>{D(o.map(c=>c.dataIndex))},customToolbarSelect:ie},J=({page:a,rowsPerPage:o,searchText:c,filterList:C})=>{const[,B=[],G=[],K=[]]=C;p.pageSize!==o?g(W=>({...W,pageSize:o,page:1})):p.page!==a+1?g(W=>({...W,page:a+1})):p.searchText!==c?g(W=>({...W,searchText:c,page:1})):pe(B,p.walletSendStatus)?pe(G,p.pushKitSendStatus)?pe(K,p.emailSendStatus)||g(W=>({...W,emailSendStatus:K,page:1})):g(W=>({...W,pushKitSendStatus:G,page:1})):g(W=>({...W,walletSendStatus:B,page:1}))},oe=x.useCallback(async(a,o)=>{if(!o)return!1;const c=await y(o);return c?a==="wallet"?Gt(c):a==="email"?$t(v,c):a==="pushKit"?Vt(v,c):a==="webhook"?Xt(c):!0:!1},[y,v]),Ne=x.useCallback(a=>Qt(r,a),[r]),f=()=>{M.anchorEl=null,M.position=null,$(null)},u=()=>{L.anchorEl=null,L.position=null},j=async(a,o,c=!0,C="")=>{if(!(!o.length||!a.length))try{s(a,o,c,C),L.anchorEl||(await ge(.5),f())}catch(B){console.error("handleResend error",{error:B})}},I=async({channels:a,isResendFailedOnly:o})=>{const c=T.map(C=>w[C].receiver);await j(a,c,o),await ge(.5),u(),D([])},A=async(a,o=[],c=!0)=>{try{await j(["webhook"],[a.receiver],c,o)}catch(C){q.error(C.response?C.response.statusText:C.message)}},R=async(a,o,c,C=[],B=!0)=>{if(a.stopPropagation(),Yt(o,c)>=4){q.warning(r("notification.resendLimit"));return}if(!Le.includes(c)){await A(o,C,B);return}if(a){const K=a.currentTarget,W=K.getBoundingClientRect();M.anchorEl=K,M.position={top:W.top+window.scrollY,left:W.left+window.scrollX}}$({channel:c});try{const K=await oe(c,o.receiver);await ge(1),$({channel:c,result:K}),(typeof K=="boolean"&&K||Ct(K)&&Object.values(K).every(W=>!!W))&&(await s([c],[o.receiver],B),L.anchorEl||(await ge(.5),f()))}catch(K){q.error(K.message)}},re=a=>{g(o=>({...o,dateRange:a,page:1}))},ne=(a,o,c,C)=>{a.stopPropagation();const B=c.filter(G=>G!==o);g(G=>({...G,[C]:B,page:1}))},le=Q(()=>[{label:r("notification.receiver"),name:"receiver",width:200,options:{filter:!1,customBodyRenderLite:a=>{const{receiverUser:o,receiver:c}=w[a];return o?e.jsxs(N,{"data-cy":`member-name-${o.fullName}`,sx:{display:"flex",alignItems:"center",gap:1,justifyContent:"flex-start"},children:[e.jsx(Ze,{src:`${o.avatar}?imageFilter=resize&w=48&h=48`,size:32,did:c,shape:"circle",style:{borderRadius:"100%",overflow:"hidden"}}),e.jsx(me,{children:o.fullName})]},c):e.jsx(zt,{size:14,responsive:!1,compact:!0,copyable:!1,did:c})}}},{label:"Wallet",name:"walletSendStatus",width:200,options:{setCellProps:()=>({className:"sent-status-cell"}),filter:!0,filterType:"custom",filterList:p.walletSendStatus??[],customFilterListOptions:{render:a=>e.jsx(Se,{list:a,label:"Wallet",onDelete:(o,c)=>{o.stopPropagation(),ne(o,c,le[1].options.filterList,"walletSendStatus")}}),update:ye},filterOptions:{names:O,fullWidth:!0,logic:je,display:(a,o,c,C)=>e.jsx(we,{label:"Wallet",filterList:a,onChange:o,index:c,column:C,filterValues:O})},customBodyRenderLite:a=>{const{walletSendStatus:o,walletSendAt:c,walletSendFailedReason:C}=w[a];return e.jsx(ce,{status:o,updatedAt:c,reason:C,channel:"wallet",onResend:B=>R(B,w[a],"wallet",[],!1)})}}},{label:"Push Kit",name:"pushKitSendStatus",width:200,options:{setCellProps:()=>({className:"sent-status-cell"}),customBodyRenderLite:a=>{const{pushKitSendStatus:o,pushKitSendAt:c,pushKitSendFailedReason:C}=w[a];return e.jsx(ce,{status:o,updatedAt:c,reason:C,channel:"pushkit",onResend:B=>R(B,w[a],"pushKit",[],!1)})},filter:!0,filterType:"custom",filterList:p.pushKitSendStatus??[],customFilterListOptions:{render:a=>e.jsx(Se,{list:a,label:"Push Kit",onDelete:(o,c)=>{o.stopPropagation(),ne(o,c,le[2].options.filterList,"pushKitSendStatus")}}),update:ye},filterOptions:{names:O,fullWidth:!0,logic:je,display:(a,o,c,C)=>e.jsx(we,{label:"Push Kit",filterList:a,onChange:o,index:c,column:C,filterValues:O})}}},{label:"Email",name:"emailSendStatus",width:200,options:{setCellProps:()=>({className:"sent-status-cell"}),customBodyRenderLite:a=>{const{emailSendStatus:o,emailSendAt:c,emailSendFailedReason:C}=w[a];return e.jsx(ce,{status:o,updatedAt:c,reason:C,channel:"email",onResend:B=>R(B,w[a],"email",[],!1)})},filter:!0,filterType:"custom",filterList:p.emailSendStatus??[],customFilterListOptions:{render:a=>e.jsx(Se,{list:a,label:"Email",onDelete:(o,c)=>{o.stopPropagation(),ne(o,c,le[3].options.filterList,"emailSendStatus")}}),update:ye},filterOptions:{names:O,fullWidth:!0,logic:je,display:(a,o,c,C)=>e.jsx(we,{label:"Email",filterList:a,onChange:o,index:c,column:C,filterValues:O})}}},{label:"Webhook",name:"webhook",width:200,options:{filter:!1,setCellProps:()=>({className:"sent-status-cell"}),customBodyRenderLite:a=>{const{webhook:o}=w[a];if(!o)return null;const c=Object.entries(o)[0];if(!c)return null;const[C,B]=c,G=B[0];return e.jsx(N,{sx:{display:"flex",flexDirection:"column",gap:1},children:e.jsxs(N,{className:"webhook-item",sx:{fontSize:12},children:[e.jsx(me,{maxLength:30,children:C},C),e.jsx(ce,{status:G.status,updatedAt:G.sendAt,reason:G.failedReason,channel:"webhook",onResend:K=>R(K,w[a],"webhook",[C],!1)})]},C)})}}},{label:r("common.createdAt"),name:"createdAt",width:100,options:{filter:!1,customBodyRenderLite:a=>{const{createdAt:o}=w[a];return e.jsx(tt,{value:o,locale:i,shouldUpdate:!0})}}}],[w,i,p,r]),ft=[e.jsx(ze,{value:p.dateRange,onChange:re},"date-picker"),e.jsx(Ae,{variant:"contained",size:"small",color:"primary",loading:P,startIcon:e.jsx(ht,{}),onClick:()=>z(),sx:{".MuiButton-startIcon":{mr:"2px"}},style:{marginLeft:8},children:r("common.refresh")},"refresh")];return e.jsx(N,{sx:{overflow:"auto",".MuiTableCell-head":{whiteSpace:"nowrap",fontWeight:"bold"},".MuiTableCell-root":{paddingRight:"8px",whiteSpace:"nowrap"}},children:e.jsx(ts,{children:e.jsxs(Qe,{theme:b,children:[e.jsx(Je,{className:"receivers-table",locale:i,loading:P,columns:le,data:w,onChange:J,options:se,customButtons:ft,components:{TableFilterList:a=>e.jsx(We,{...a,itemComponent:o=>e.jsx(Me,{...o,canDelete:()=>!1})})}}),M.anchorEl&&e.jsx(Ee,{open:!!M.anchorEl,anchorReference:"anchorPosition",anchorPosition:M.position,onClose:f,anchorOrigin:{vertical:"center",horizontal:"right"},transformOrigin:{vertical:"center",horizontal:"left"},children:e.jsxs(ss,{children:[e.jsxs(X,{variant:"body1",component:"div",className:"check-title",children:[k?.channel," Checking"]}),e.jsx(N,{sx:{display:"flex",flexDirection:"column",gap:"4px"},children:Ne(k?.channel).map(a=>{const{type:o,pass:c,fail:C}=a;return!k?.result||k?.result?.[o]?e.jsxs(X,{variant:"body1",component:"div",className:"check-item",sx:{display:"flex",alignItems:"center",gap:"4px",color:k?.result?.[o]?be.success.main:"inherit"},children:[k?.result?e.jsx(gt,{}):e.jsx(Ge,{size:12,sx:{color:be.primary.main}}),e.jsx("span",{children:c})]},o):e.jsxs(X,{variant:"body1",component:"div",className:"check-item",sx:{display:"flex",alignItems:"center",gap:"4px",color:be.error.main},children:[e.jsx(xt,{}),e.jsx("span",{children:C})]},o)})})]})}),L.anchorEl&&e.jsx(Ee,{open:!!L.anchorEl,anchorReference:"anchorPosition",anchorPosition:L.position,onClose:u,anchorOrigin:{vertical:"center",horizontal:"right"},transformOrigin:{vertical:"center",horizontal:"left"},children:e.jsx(ct,{loading:n,onCancel:u,onConfirm:I})})]})})})}const es=x.memo(dt),ts=ae.div`
1
+ import{r as x}from"./vendor-react-CTtPmzVP.js";import{j as e,W as d,am as mt,ak as N,T as X,U as ke,y as Fe,bk as Ve,b$ as Re,bX as Te,a5 as Ie,Q as Ce,dH as Pe,aN as Ee,a6 as Ge,D as Xe,cD as ht,ad as Qe,e4 as gt,e5 as xt,at as ae,b4 as He,n as bt,J as yt,x as jt,bZ as St,M as qe,cB as vt}from"./vendor-mui-core-DnR6WYuU.js";import{e as ee,F as Ct,aB as pe}from"./vendor-utils-CxWN1dT3.js";import{H as q,aV as Nt,V as Y,cN as wt,m as Ye,$ as Ze,w as Ae,aP as Je,bi as be,aL as Rt,aX as Tt,b2 as It,b9 as Et}from"./vendor-ux-B2x-0VyJ.js";import{Z as At,Q as H,c as E,C as Dt,a1 as Ue}from"./index-B-MpZQKm.js";import{a as Q,g as De}from"./vendor-hooks-qxhUUbW5.js";import{S as me}from"./shorten-label-C4py9TLA.js";import{v as et}from"./index-Bnog6DRk.js";import{R as tt,A as Ot,S as Lt,a as kt,B as Ft}from"./list-CiYFt3pl.js";import{i as Pt,e as _t,N as Bt}from"./team-BDHl2zCb.js";import{W as zt}from"./did-address-Di02Kgvg.js";import{p as st}from"./util-DMqfvzdX.js";import{D as Wt,g as Mt}from"./traffic-DWDQGBu7.js";import{B as nt}from"./bundle-avatar-MwXjHSGV.js";import"./lottie-web-4koyQiv_.js";import"./vendor-arcblock-hbumvS-z.js";import"./server-logo-notext.svg-xZ-i1SpD.js";import"./session-CKEyJJp6.js";import"./isURL-CIce9auJ.js";import"./use-app-logo-C52bRzuf.js";import"./base32-DYZff-KX.js";import"./useAsyncRetry-r8dEPb-x.js";import"./useAsync-Dotoxibi.js";import"./iframe-BkiP4bTi.js";import"./index-BV9eY5c_.js";import"./index-DBs9Ljax.js";import"./base-chart-ChBZtUEG.js";import"./index-D1SIrheh.js";import"./vendor-mui-x-CQc01l4r.js";import"./AdapterDayjs-C98qzmYr.js";const at=x.createContext({}),{Provider:Kt,Consumer:Hs}=at;function Ht({children:t,blocklet:s=""}){const{api:n,inService:r,ws:{useSubscription:i}}=At(),[l,b]=x.useState([]),[m,S]=x.useState({total:0,pageSize:20,pageCount:0,page:1}),h=Q(()=>s.meta?.did,[s]),[y,v]=x.useState([]),[P,F]=x.useState({}),w=Q(()=>l.length?new Set(l.map(p=>p.id)):new Set,[l]),U=async({page:p=1,pageSize:g=20,...T}={})=>{if(!h)return[];try{const D={paging:{page:p,pageSize:g},...T,teamDid:h,dateRange:T.dateRange?[H(T.dateRange[0]).toISOString(),H(T.dateRange[1]).toISOString()]:void 0},{dids:O,...z}=D;let _="";O&&O.includes("system")&&(_="system");const ie=O?O.filter(oe=>oe!=="system"):[],se={...z,source:_,componentDids:ie},J=await n.getNotificationSendLog({input:se});return F(se),b(J.list),S(J.paging),J.list}catch(D){return q.error(D.message),[]}},M=async()=>{const p=await n.getNotificationComponents({input:{teamDid:h}});v(p.componentDids)},L=x.useCallback(p=>{const g=s.children.find(T=>T.meta?.did===p);if(g)return g.ancestors=[s],g},[s]),k=async({notificationId:p,receivers:g,channels:T,...D})=>{await n.resendNotification({input:{teamDid:h,notificationId:p,receivers:g,channels:T.map(O=>O==="wallet"?E.NOTIFICATION_SEND_CHANNEL.WALLET:O==="pushKit"?E.NOTIFICATION_SEND_CHANNEL.PUSH:O),...D}})},$=x.useCallback(async p=>(await n.getUser({input:{teamDid:h,user:{did:p},options:{enableConnectedAccount:!0}}})).user,[n,h]),V=x.useCallback(async({page:p=1,pageSize:g=20,...T}={})=>{try{const D={paging:{page:p,pageSize:g},...T,userName:T.searchText||"",teamDid:h,dateRange:T.dateRange?[H(T.dateRange[0]).toISOString(),H(T.dateRange[1]).toISOString()]:void 0};return await n.getReceivers({input:D})}catch(D){throw q.error(D.message),D}},[n,h]);x.useEffect(()=>{h&&M()},[h]),i(E.EVENTS.NOTIFICATION_BLOCKLET_UPDATE,p=>{w.has(p.notificationId)&&U(P)},[w,P]),i(E.EVENTS.NOTIFICATION_BLOCKLET_CREATE,p=>{w.has(p.id)||U(P)},[w,P]);const Z={fetch:U,data:l,paging:m,blocklet:s,getComponent:L,resendNotification:k,getUser:$,componentDids:y,getReceivers:V,inService:r,teamDid:h};return e.jsx(Kt,{value:{notificationRecords:Z},children:t})}function _e(){const{notificationRecords:t}=x.useContext(at);return t}he.propTypes={severity:d.oneOf(Object.values(["info","success","error","warning"])).isRequired};const qt={info:"primary",success:"success",error:"error",warning:"warning"};function he({severity:t="info"}){return e.jsx(Nt,{type:qt[t],children:t})}const Ut=(t,s,n="")=>{if(!n||!s)return"";switch(n){case E.NOTIFICATION_SEND_FAILED_REASON.USER_DISABLED:return t("notification.sendStatus.reason.disabled",{channel:s});case E.NOTIFICATION_SEND_FAILED_REASON.CHANNEL_UNAVAILABLE:return t("notification.sendStatus.reason.unavailable",{channel:s});case E.NOTIFICATION_SEND_FAILED_REASON.CHANNEL_DISABLED:return t("notification.sendStatus.reason.notSent",{channel:s});case E.NOTIFICATION_SEND_FAILED_REASON.NOT_ONLINE:return t("notification.sendStatus.reason.offline");default:return n}};function it(t,s,n={}){const{status:r,updatedAt:i,reason:l="",channel:b="wallet"}=n,m=i?t("notification.sendStatus.sentTime",{date:Dt(i,s)}):"",S=Ut(t,b,l);return r===E.NOTIFICATION_SEND_STATUS.FAILED?{status:"failed",title:t("notification.sendStatus.failed"),sentTime:m,reason:S}:r===E.NOTIFICATION_SEND_STATUS.SENT?{status:"success",title:t("notification.sendStatus.success"),sentTime:m}:{status:"pending",title:t("notification.sendStatus.pending"),reason:S,sentTime:m}}const Oe={pending:"#aaaaaa",success:"#34BE74",failed:"#D0021B"},Le=["wallet","pushKit","email"],$e=["info","success","error","warning"],ot=t=>{const{settings:s}=t;return s?.notification?.email?.enabled},rt=t=>{const{settings:s}=t;return s?.notification?.pushKit?.enabled},$t=(t,s)=>{const n=ee(s,"extra.notifications.email",!0);return{available:ot(t),enabled:n}},Vt=(t,s)=>{const n=ee(s,"extra.notifications.push",!0);return{available:rt(t),enabled:n}},Gt=t=>({enabled:ee(t,"extra.notifications.wallet",!0)}),Xt=t=>({enabled:ee(t,"extra.webhooks",[]).length>0}),ge=(t=3)=>new Promise(s=>{setTimeout(()=>{s()},t*1e3)}),Qt=(t,s)=>s==="wallet"||s==="webhook"?[{channel:s,type:"enabled",pass:t("notification.sendStatus.reason.enabled",{channel:s}),fail:t("notification.sendStatus.reason.disabled",{channel:s})}]:s==="pushKit"||s==="email"?[{channel:s,type:"available",pass:t("notification.sendStatus.reason.available",{channel:s}),fail:t("notification.sendStatus.reason.unavailable",{channel:s})},{channel:s,type:"enabled",pass:t("notification.sendStatus.reason.enabled",{channel:s}),fail:t("notification.sendStatus.reason.disabled",{channel:s})}]:[],xe=(t=[])=>{const s=H().startOf("day");return t.filter(n=>H(n.sendAt).isSame(s,"day")).length},Yt=(t,s="")=>{if(s&&Le.includes(s)){const l=`${s}SendRecord`,b=ee(t,l,[]);return xe(b)}const n=ee(t,"webhook",{}),r=Object.keys(n??{})??[];if(s&&r.includes(s)){const l=n[s]??[];return xe(l)}const i={};return Le.forEach(l=>{const b=`${l}SendRecord`,m=ee(t,b,[]),S=xe(m);i[l]=S}),r.length>0&&r.forEach(l=>{const b=n[l]??[],m=xe(b);i[l]=m}),i},ye=(t,s,n)=>{if(!Array.isArray(t))throw new Error("Invalid filterList or index");return t[n].splice(s,1),t},je=(t,s)=>{if(!Array.isArray(s))throw new Error("filters must be an array");return s.length?!s.includes(t):!1},Zt=t=>{switch(t){case E.NOTIFICATION_SEND_CHANNEL.WALLET:return"Wallet";case E.NOTIFICATION_SEND_CHANNEL.PUSH:return"Push Kit";case E.NOTIFICATION_SEND_CHANNEL.EMAIL:return"Email";case E.NOTIFICATION_SEND_CHANNEL.WEBHOOK:return"Webhook";default:return""}},lt=()=>({components:{MUIDataTableFilter:{styleOverrides:{header:{marginBottom:0,p:{margin:0}},root:{"& .MuiGrid-container":{marginTop:0,"& .MuiGrid-item":{paddingTop:0}}}}},MuiPopover:{styleOverrides:{root:{"&.MuiPopover-root":{"& .MuiPaper-root:has(.filter-container)":{width:"420px"}}}}}}});function te({config:t,enableTooltip:s=!0,showTitle:n=!1,children:r=null}){const{status:i,title:l="",sentTime:b="",reason:m=""}=t,S=[l,m].filter(Boolean).join(", ");return e.jsx(mt,{title:s?e.jsxs(e.Fragment,{children:[e.jsx(X,{color:"inherit",sx:{fontSize:12},children:S}),e.jsx("span",{children:b})]}):null,arrow:!0,placement:"top",children:e.jsxs(N,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"4px"},children:[e.jsxs(N,{sx:{position:"relative",minHeight:14,minWidth:14,display:"flex",alignItems:"center",justifyContent:"center"},children:[e.jsx(N,{style:{opacity:.15},sx:{position:"absolute",width:"100%",height:"100%",borderRadius:"50%",bgcolor:Oe[i]}}),e.jsx(N,{sx:{position:"absolute",width:"55%",height:"55%",borderRadius:"50%",bgcolor:Oe[i]}})]}),e.jsx(X,{color:"inherit",sx:{fontSize:12},children:n?l:r})]})})}te.propTypes={config:d.object.isRequired,enableTooltip:d.bool,showTitle:d.bool,children:d.node};Se.propTypes={list:d.array.isRequired,label:d.string.isRequired,onDelete:d.func};function Se({list:t,label:s,onDelete:n=()=>{}}){const{t:r,locale:i}=Y();return e.jsxs(N,{sx:{display:"flex",gap:1,alignItems:"center"},children:[e.jsxs(X,{children:[s,": "]}),t.map(l=>{const b=it(r,i,{status:l});return e.jsx(ke,{size:"small",label:e.jsx(N,{sx:{display:"flex",alignItems:"center",gap:"4px"},children:e.jsx(te,{config:b,enableTooltip:!1,children:b.title})}),onDelete:m=>n(m,l)},l)})]})}Be.propTypes={filterList:d.array.isRequired,onChange:d.func.isRequired,index:d.number.isRequired,column:d.object.isRequired,filterValues:d.array.isRequired,label:d.string.isRequired,renderLabel:d.func.isRequired};function Be({filterList:t,onChange:s,index:n,column:r,filterValues:i,label:l,renderLabel:b}){return e.jsxs(Fe,{className:"filter-container",children:[e.jsx(Ve,{component:"legend",children:l}),e.jsx(Re,{row:!0,children:i.map(m=>e.jsx(Te,{control:e.jsx(Ie,{checked:t[n].indexOf(m.value??m)>-1,onChange:S=>{const h=[...t];S.target.checked?h[n]=[...h[n],m.value??m]:h[n]=h[n].filter(y=>y!==(m.value??m)),s(h[n],n,r)},name:m.value??m}),label:e.jsx("span",{style:{display:"flex",alignItems:"center"},children:b(m)})},m.value??m))})]})}function we(t){return e.jsx(Be,{...t,renderLabel:s=>e.jsx(te,{enableTooltip:!1,config:{status:s.status},children:s.label})})}ce.propTypes={status:d.number.isRequired,updatedAt:d.string.isRequired,reason:d.string,channel:d.string,onResend:d.func};function ce({status:t,updatedAt:s,reason:n="",channel:r="wallet",onResend:i}){const{t:l,locale:b}=Y(),m=it(l,b,{status:t,updatedAt:s,reason:n,channel:r});return e.jsxs(N,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(te,{config:m,showTitle:!0}),m.status!=="success"&&e.jsx(Ce,{className:"resend-btn",size:"small",startIcon:e.jsx(Pe,{}),sx:{fontSize:12,color:"rgba(0, 0, 0, 0.87)",fontWeight:400,".MuiButton-startIcon":{mr:"2px"}},onClick:i,children:l("notification.resend")})]})}ze.propTypes={value:d.array.isRequired,onChange:d.func};function ze({value:t,onChange:s}){const{locale:n}=Y(),r=H().toDate(),[i,l]=x.useState(null),b=x.useCallback(h=>{l(i?null:h.currentTarget)},[i]),m=!!i,S=x.useCallback(h=>{if(!h.startDate||!h.endDate){q.error("Please select a date range");return}if(H(h.startDate).isAfter(h.endDate)||!H(h.startDate).isValid()||!H(h.endDate).isValid()){q.error("Invalid date range");return}s([h.startDate,h.endDate]),l(null)},[s]);return e.jsxs("div",{children:[e.jsx(X,{component:"div",variant:"h5",color:"textPrimary",style:{fontSize:18,fontWeight:"bold"},sx:{mb:0},children:e.jsxs(Ce,{onClick:b,variant:"outlined",size:"small",color:"inherit",children:[Ue(t[0],n)," - ",Ue(t[1],n)]})}),e.jsx(Ee,{open:m,anchorEl:i,onClose:()=>{l(null)},anchorOrigin:{vertical:"bottom",horizontal:"left"},children:e.jsx(Wt,{open:!0,maxDate:r,initialDateRange:{startDate:t[0],endDate:t[1]},toggle:b,definedRanges:Mt(r),onChange:S})})]})}We.propTypes={itemComponent:d.elementType.isRequired};function We({itemComponent:t,...s}){const{t:n}=Y();return!s?.filterList?.filter(i=>i.length).length?null:e.jsxs(N,{sx:{display:"flex",gap:1,alignItems:"center"},children:[e.jsx("div",{className:"toolbar-filter-title",children:n("notification.filter")}),e.jsx("div",{className:"toolbar-filter-content",children:e.jsx(wt.TableFilterList,{...s,ItemComponent:t})})]})}function Me({label:t,onDelete:s,canDelete:n=()=>!0,...r}){const i=s&&typeof s=="function"?s:void 0;let l=!0;return n&&typeof n=="function"&&(l=n({label:t,...r})),e.jsx(ke,{label:t,variant:"outlined",...i&&l?{onDelete:i}:{}})}Me.propTypes={label:d.string.isRequired,onDelete:d.func,canDelete:d.func};const Jt=[{label:"Wallet",value:"app",checked:!0},{label:"Email",value:"email",checked:!0},{label:"Push Kit",value:"push",checked:!0},{label:"Webhook",value:"webhook",checked:!0}];ct.propTypes={loading:d.bool,onCancel:d.func,onConfirm:d.func};function ct({loading:t=!1,onCancel:s=()=>{},onConfirm:n=()=>{}}){const{t:r}=Y(),[i,l]=x.useState(Jt),[b,m]=x.useState(!0),S=(y,v)=>{v.checked=y.target.checked;const P=i.map(F=>({...F,checked:F.value===v.value?v.checked:F.checked}));l(P)},h=y=>{y.stopPropagation(),n({channels:i.filter(v=>v.checked).map(v=>v.value),isResendFailedOnly:b})};return e.jsxs(N,{className:"resend-config",sx:{padding:"16px 24px"},children:[e.jsx(X,{variant:"body1",component:"div",className:"check-title",sx:{fontWeight:700,mb:1},children:r("notification.config")}),e.jsx(N,{className:"choose-channel",children:e.jsxs(Fe,{component:"fieldset",variant:"standard",children:[e.jsx(Ve,{component:"legend",children:r("notification.selectChannels")}),e.jsx(Re,{sx:{display:"flex",flexDirection:"row",flexWrap:"wrap",gap:1},children:i.map(y=>e.jsx(Te,{control:e.jsx(Ie,{checked:y.checked,onChange:v=>S(v,y),name:y.value}),label:y.label},y.value))})]})}),e.jsx(N,{className:"resend-config-footer",children:e.jsx(Re,{children:e.jsx(Te,{control:e.jsx(Ie,{checked:b,onChange:y=>m(y.target.checked)}),label:r("notification.resendFailedOnly")})})}),e.jsxs(N,{className:"resend-config-footer-tip",sx:{display:"flex",justifyContent:"flex-end",gap:1},children:[e.jsx(Ce,{onClick:y=>{y.stopPropagation(),s()},color:"inherit",children:r("common.cancel")}),e.jsxs(Ce,{onClick:h,color:"primary",disabled:t,variant:"contained",autoFocus:!0,style:{marginLeft:8},children:[t&&e.jsx(Ge,{size:16}),r("common.confirm")]})]})]})}dt.propTypes={notificationId:d.string.isRequired,handleResend:d.func,resending:d.bool};function dt({notificationId:t,handleResend:s,resending:n=!1}){const{t:r,locale:i}=Y(),l=Xe(),b=x.useMemo(()=>Ye(l,lt()),[l]),{getReceivers:m,inService:S,teamDid:h,getUser:y,blocklet:v}=_e(),[P,F]=x.useState(!1),[w,U]=x.useState([]),M=De({anchorEl:null,position:null}),L=De({anchorEl:null,position:null}),[k,$]=x.useState(null),[V,Z]=x.useState({total:0,pageSize:10,pageCount:0,page:1}),[p,g]=x.useState({searchText:"",page:1,pageSize:10,walletSendStatus:[],pushKitSendStatus:[],emailSendStatus:[],dateRange:[H().subtract(1,"month").startOf("day").toDate(),H().endOf("day").toDate()]}),[T,D]=x.useState([]),O=[{label:r("notification.sendStatus.pending"),value:0,status:"pending"},{label:r("notification.sendStatus.success"),value:1,status:"success"},{label:r("notification.sendStatus.failed"),value:2,status:"failed"}],z=async()=>{if(!P&&t)try{F(!0);const a=await m({notificationId:t,...p}),o=a.list.map(c=>({...c,receiverUser:{...c.receiverUser,avatar:st(c.receiverUser.avatar,h,S)}}));U(o),Z(a.paging),F(!1)}catch(a){q.error(a.message),F(!1)}};x.useEffect(()=>{z()},[p]);const _=a=>{a.stopPropagation();const o=a.currentTarget;L.anchorEl=o;const c=o.getBoundingClientRect();L.position={top:c.top+window.scrollY,left:c.left+window.scrollX}},ie=a=>a.data.length?e.jsx("div",{style:{display:"flex",alignItems:"center",padding:"10px"},children:e.jsx(Ae,{className:"resend-btn",size:"small",color:"primary",variant:"contained",startIcon:e.jsx(Pe,{}),sx:{".MuiButton-startIcon":{mr:"2px"}},onClick:_,children:r("notification.resend")})}):null,se={sort:!1,download:!1,print:!1,selectableRows:"multiple",searchPlaceholder:r("common.search"),searchAlwaysOpen:!1,filterType:"checkbox",searchDebounceTime:300,page:V.page-1,rowsPerPage:V.pageSize,count:V.total,searchText:p.searchText,tableBodyMaxHeight:"calc(80vh - 260px)",rowsSelected:T,onRowSelectionChange:(a,o)=>{D(o.map(c=>c.dataIndex))},customToolbarSelect:ie},J=({page:a,rowsPerPage:o,searchText:c,filterList:C})=>{const[,B=[],G=[],K=[]]=C;p.pageSize!==o?g(W=>({...W,pageSize:o,page:1})):p.page!==a+1?g(W=>({...W,page:a+1})):p.searchText!==c?g(W=>({...W,searchText:c,page:1})):pe(B,p.walletSendStatus)?pe(G,p.pushKitSendStatus)?pe(K,p.emailSendStatus)||g(W=>({...W,emailSendStatus:K,page:1})):g(W=>({...W,pushKitSendStatus:G,page:1})):g(W=>({...W,walletSendStatus:B,page:1}))},oe=x.useCallback(async(a,o)=>{if(!o)return!1;const c=await y(o);return c?a==="wallet"?Gt(c):a==="email"?$t(v,c):a==="pushKit"?Vt(v,c):a==="webhook"?Xt(c):!0:!1},[y,v]),Ne=x.useCallback(a=>Qt(r,a),[r]),f=()=>{M.anchorEl=null,M.position=null,$(null)},u=()=>{L.anchorEl=null,L.position=null},j=async(a,o,c=!0,C="")=>{if(!(!o.length||!a.length))try{s(a,o,c,C),L.anchorEl||(await ge(.5),f())}catch(B){console.error("handleResend error",{error:B})}},I=async({channels:a,isResendFailedOnly:o})=>{const c=T.map(C=>w[C].receiver);await j(a,c,o),await ge(.5),u(),D([])},A=async(a,o=[],c=!0)=>{try{await j(["webhook"],[a.receiver],c,o)}catch(C){q.error(C.response?C.response.statusText:C.message)}},R=async(a,o,c,C=[],B=!0)=>{if(a.stopPropagation(),Yt(o,c)>=4){q.warning(r("notification.resendLimit"));return}if(!Le.includes(c)){await A(o,C,B);return}if(a){const K=a.currentTarget,W=K.getBoundingClientRect();M.anchorEl=K,M.position={top:W.top+window.scrollY,left:W.left+window.scrollX}}$({channel:c});try{const K=await oe(c,o.receiver);await ge(1),$({channel:c,result:K}),(typeof K=="boolean"&&K||Ct(K)&&Object.values(K).every(W=>!!W))&&(await s([c],[o.receiver],B),L.anchorEl||(await ge(.5),f()))}catch(K){q.error(K.message)}},re=a=>{g(o=>({...o,dateRange:a,page:1}))},ne=(a,o,c,C)=>{a.stopPropagation();const B=c.filter(G=>G!==o);g(G=>({...G,[C]:B,page:1}))},le=Q(()=>[{label:r("notification.receiver"),name:"receiver",width:200,options:{filter:!1,customBodyRenderLite:a=>{const{receiverUser:o,receiver:c}=w[a];return o?e.jsxs(N,{"data-cy":`member-name-${o.fullName}`,sx:{display:"flex",alignItems:"center",gap:1,justifyContent:"flex-start"},children:[e.jsx(Ze,{src:`${o.avatar}?imageFilter=resize&w=48&h=48`,size:32,did:c,shape:"circle",style:{borderRadius:"100%",overflow:"hidden"}}),e.jsx(me,{children:o.fullName})]},c):e.jsx(zt,{size:14,responsive:!1,compact:!0,copyable:!1,did:c})}}},{label:"Wallet",name:"walletSendStatus",width:200,options:{setCellProps:()=>({className:"sent-status-cell"}),filter:!0,filterType:"custom",filterList:p.walletSendStatus??[],customFilterListOptions:{render:a=>e.jsx(Se,{list:a,label:"Wallet",onDelete:(o,c)=>{o.stopPropagation(),ne(o,c,le[1].options.filterList,"walletSendStatus")}}),update:ye},filterOptions:{names:O,fullWidth:!0,logic:je,display:(a,o,c,C)=>e.jsx(we,{label:"Wallet",filterList:a,onChange:o,index:c,column:C,filterValues:O})},customBodyRenderLite:a=>{const{walletSendStatus:o,walletSendAt:c,walletSendFailedReason:C}=w[a];return e.jsx(ce,{status:o,updatedAt:c,reason:C,channel:"wallet",onResend:B=>R(B,w[a],"wallet",[],!1)})}}},{label:"Push Kit",name:"pushKitSendStatus",width:200,options:{setCellProps:()=>({className:"sent-status-cell"}),customBodyRenderLite:a=>{const{pushKitSendStatus:o,pushKitSendAt:c,pushKitSendFailedReason:C}=w[a];return e.jsx(ce,{status:o,updatedAt:c,reason:C,channel:"pushkit",onResend:B=>R(B,w[a],"pushKit",[],!1)})},filter:!0,filterType:"custom",filterList:p.pushKitSendStatus??[],customFilterListOptions:{render:a=>e.jsx(Se,{list:a,label:"Push Kit",onDelete:(o,c)=>{o.stopPropagation(),ne(o,c,le[2].options.filterList,"pushKitSendStatus")}}),update:ye},filterOptions:{names:O,fullWidth:!0,logic:je,display:(a,o,c,C)=>e.jsx(we,{label:"Push Kit",filterList:a,onChange:o,index:c,column:C,filterValues:O})}}},{label:"Email",name:"emailSendStatus",width:200,options:{setCellProps:()=>({className:"sent-status-cell"}),customBodyRenderLite:a=>{const{emailSendStatus:o,emailSendAt:c,emailSendFailedReason:C}=w[a];return e.jsx(ce,{status:o,updatedAt:c,reason:C,channel:"email",onResend:B=>R(B,w[a],"email",[],!1)})},filter:!0,filterType:"custom",filterList:p.emailSendStatus??[],customFilterListOptions:{render:a=>e.jsx(Se,{list:a,label:"Email",onDelete:(o,c)=>{o.stopPropagation(),ne(o,c,le[3].options.filterList,"emailSendStatus")}}),update:ye},filterOptions:{names:O,fullWidth:!0,logic:je,display:(a,o,c,C)=>e.jsx(we,{label:"Email",filterList:a,onChange:o,index:c,column:C,filterValues:O})}}},{label:"Webhook",name:"webhook",width:200,options:{filter:!1,setCellProps:()=>({className:"sent-status-cell"}),customBodyRenderLite:a=>{const{webhook:o}=w[a];if(!o)return null;const c=Object.entries(o)[0];if(!c)return null;const[C,B]=c,G=B[0];return e.jsx(N,{sx:{display:"flex",flexDirection:"column",gap:1},children:e.jsxs(N,{className:"webhook-item",sx:{fontSize:12},children:[e.jsx(me,{maxLength:30,children:C},C),e.jsx(ce,{status:G.status,updatedAt:G.sendAt,reason:G.failedReason,channel:"webhook",onResend:K=>R(K,w[a],"webhook",[C],!1)})]},C)})}}},{label:r("common.createdAt"),name:"createdAt",width:100,options:{filter:!1,customBodyRenderLite:a=>{const{createdAt:o}=w[a];return e.jsx(tt,{value:o,locale:i,shouldUpdate:!0})}}}],[w,i,p,r]),ft=[e.jsx(ze,{value:p.dateRange,onChange:re},"date-picker"),e.jsx(Ae,{variant:"contained",size:"small",color:"primary",loading:P,startIcon:e.jsx(ht,{}),onClick:()=>z(),sx:{".MuiButton-startIcon":{mr:"2px"}},style:{marginLeft:8},children:r("common.refresh")},"refresh")];return e.jsx(N,{sx:{overflow:"auto",".MuiTableCell-head":{whiteSpace:"nowrap",fontWeight:"bold"},".MuiTableCell-root":{paddingRight:"8px",whiteSpace:"nowrap"}},children:e.jsx(ts,{children:e.jsxs(Qe,{theme:b,children:[e.jsx(Je,{className:"receivers-table",locale:i,loading:P,columns:le,data:w,onChange:J,options:se,customButtons:ft,components:{TableFilterList:a=>e.jsx(We,{...a,itemComponent:o=>e.jsx(Me,{...o,canDelete:()=>!1})})}}),M.anchorEl&&e.jsx(Ee,{open:!!M.anchorEl,anchorReference:"anchorPosition",anchorPosition:M.position,onClose:f,anchorOrigin:{vertical:"center",horizontal:"right"},transformOrigin:{vertical:"center",horizontal:"left"},children:e.jsxs(ss,{children:[e.jsxs(X,{variant:"body1",component:"div",className:"check-title",children:[k?.channel," Checking"]}),e.jsx(N,{sx:{display:"flex",flexDirection:"column",gap:"4px"},children:Ne(k?.channel).map(a=>{const{type:o,pass:c,fail:C}=a;return!k?.result||k?.result?.[o]?e.jsxs(X,{variant:"body1",component:"div",className:"check-item",sx:{display:"flex",alignItems:"center",gap:"4px",color:k?.result?.[o]?be.success.main:"inherit"},children:[k?.result?e.jsx(gt,{}):e.jsx(Ge,{size:12,sx:{color:be.primary.main}}),e.jsx("span",{children:c})]},o):e.jsxs(X,{variant:"body1",component:"div",className:"check-item",sx:{display:"flex",alignItems:"center",gap:"4px",color:be.error.main},children:[e.jsx(xt,{}),e.jsx("span",{children:C})]},o)})})]})}),L.anchorEl&&e.jsx(Ee,{open:!!L.anchorEl,anchorReference:"anchorPosition",anchorPosition:L.position,onClose:u,anchorOrigin:{vertical:"center",horizontal:"right"},transformOrigin:{vertical:"center",horizontal:"left"},children:e.jsx(ct,{loading:n,onCancel:u,onConfirm:I})})]})})})}const es=x.memo(dt),ts=ae.div`
2
2
  td.MuiTableCell-footer {
3
3
  border: none !important;
4
4
  }
@@ -1,4 +1,4 @@
1
- import{r}from"./vendor-react-CTtPmzVP.js";import{j as i,bD as N,at as g,W as t,ak as _,bu as S,a6 as E,s as z}from"./vendor-mui-core-DnR6WYuU.js";import{g as Z,h as $,b as y,q as T}from"./vendor-hooks-qxhUUbW5.js";import{Q as D,s as U,c as q,R as A,T as L,U as H,V as F}from"./index-FreeXNkk.js";import{aU as O,aL as W,w as B,V as w,$ as Y}from"./vendor-ux-B2x-0VyJ.js";import{N as J}from"./index-CgwRpRMk.js";import{C as K}from"./vendor-utils-CxWN1dT3.js";import{u as Q}from"./use-passport-id-B-b-_oYF.js";import{u as X}from"./session-8btKYxMi.js";import{b as G}from"./sdk-CHfXvAIT.js";import{w as e2}from"./wrap-locale-C87TTgDu.js";function b({invitation:e,createPassportSvg:o,passportColor:c="auto"}){const[d,n]=r.useState(!1),{t:p}=r.useContext(O),s=r.useMemo(()=>(e.role.title||e.role.name).toUpperCase(),[e.role.title,e.role.name]),C=r.useMemo(()=>o({title:s,issuer:e.info.name,issuerDid:e.info.appDid,ownerName:"Your Name",ownerDid:e.info.appDid,preferredColor:e.info.passportColor||c,extra:e.passportExpireTime?{key:"Exp",value:D(e.passportExpireTime).format("YYYY-MM-DD HH:mm:ss")}:void 0}),[e,s]),m=r.useCallback(()=>{n(!0)},[]),a=r.useCallback(()=>{n(!1)},[]);return i.jsxs(i.Fragment,{children:[i.jsx(i2,{children:i.jsxs("div",{className:"invite-passport__card",onClick:m,children:[!!e.display&&i.jsx(J,{data:e.display,style:{width:"100%",height:"100%"}}),!e.display&&i.jsx("div",{className:"invite-passport__cover",dangerouslySetInnerHTML:{__html:C}})]})}),i.jsx(W,{open:d,title:p("invite.viewPermission"),PaperProps:{style:{minHeight:"auto",paddingBottom:"20px"}},onClose:a,children:e.role.permissions&&e.role.permissions.length>0?i.jsx("ul",{style:{listStyle:"circle",padding:"0 20px"},children:e.role.permissions.map(u=>i.jsx("li",{style:{listStyle:"circle"},children:u.description},u.name))}):i.jsxs("div",{style:{color:"#999",textAlign:"center"},children:[i.jsx(N,{style:{width:"30px",height:"30px"}}),i.jsx("div",{children:p("invite.emptyPermission")})]})})]})}b.propTypes={invitation:t.object.isRequired,createPassportSvg:t.func.isRequired,passportColor:t.string};const i2=g.div`
1
+ import{r}from"./vendor-react-CTtPmzVP.js";import{j as i,bD as N,at as g,W as t,ak as _,bu as S,a6 as E,s as z}from"./vendor-mui-core-DnR6WYuU.js";import{g as Z,h as $,b as y,q as T}from"./vendor-hooks-qxhUUbW5.js";import{Q as D,s as U,c as q,R as A,T as L,U as H,V as F}from"./index-B-MpZQKm.js";import{aU as O,aL as W,w as B,V as w,$ as Y}from"./vendor-ux-B2x-0VyJ.js";import{N as J}from"./index-AnS2fFHl.js";import{C as K}from"./vendor-utils-CxWN1dT3.js";import{u as Q}from"./use-passport-id-B-b-_oYF.js";import{u as X}from"./session-CKEyJJp6.js";import{b as G}from"./sdk-Bes03kcb.js";import{w as e2}from"./wrap-locale-B6zyAepP.js";function b({invitation:e,createPassportSvg:o,passportColor:c="auto"}){const[d,n]=r.useState(!1),{t:p}=r.useContext(O),s=r.useMemo(()=>(e.role.title||e.role.name).toUpperCase(),[e.role.title,e.role.name]),C=r.useMemo(()=>o({title:s,issuer:e.info.name,issuerDid:e.info.appDid,ownerName:"Your Name",ownerDid:e.info.appDid,preferredColor:e.info.passportColor||c,extra:e.passportExpireTime?{key:"Exp",value:D(e.passportExpireTime).format("YYYY-MM-DD HH:mm:ss")}:void 0}),[e,s]),m=r.useCallback(()=>{n(!0)},[]),a=r.useCallback(()=>{n(!1)},[]);return i.jsxs(i.Fragment,{children:[i.jsx(i2,{children:i.jsxs("div",{className:"invite-passport__card",onClick:m,children:[!!e.display&&i.jsx(J,{data:e.display,style:{width:"100%",height:"100%"}}),!e.display&&i.jsx("div",{className:"invite-passport__cover",dangerouslySetInnerHTML:{__html:C}})]})}),i.jsx(W,{open:d,title:p("invite.viewPermission"),PaperProps:{style:{minHeight:"auto",paddingBottom:"20px"}},onClose:a,children:e.role.permissions&&e.role.permissions.length>0?i.jsx("ul",{style:{listStyle:"circle",padding:"0 20px"},children:e.role.permissions.map(u=>i.jsx("li",{style:{listStyle:"circle"},children:u.description},u.name))}):i.jsxs("div",{style:{color:"#999",textAlign:"center"},children:[i.jsx(N,{style:{width:"30px",height:"30px"}}),i.jsx("div",{children:p("invite.emptyPermission")})]})})]})}b.propTypes={invitation:t.object.isRequired,createPassportSvg:t.func.isRequired,passportColor:t.string};const i2=g.div`
2
2
  display: flex;
3
3
  max-width: 350px;
4
4
  margin: 30px auto;
@@ -1,3 +1,3 @@
1
- import{r}from"./vendor-react-CTtPmzVP.js";import{j as o,a6 as B,am as D,ak as w,cu as L,at as H,W as x}from"./vendor-mui-core-DnR6WYuU.js";import{aU as P,w as S,aP as T,au as Y}from"./vendor-ux-B2x-0VyJ.js";import{Z as z,Q as M,G as N,e as E,br as W}from"./index-FreeXNkk.js";import{n as A}from"./vendor-utils-CxWN1dT3.js";import{b as G}from"./team-DB9e4nhx.js";import{C as K}from"./confirm-CQcou-U0.js";import{P as Q}from"./permission-BdJe7FC0.js";import{C as U}from"./click-to-copy-CoAdDvF3.js";function Z({invitations:a=[],onRefresh:v=A}){const{api:C,inService:d}=z(),{t,locale:y}=r.useContext(P),{teamDid:h,invitations:f,refresh:g,endpoint:l,roles:j}=G(),[i,m]=r.useState(null),[I,c]=r.useState(!1),s=r.useMemo(()=>a.length>0?a:f,[a,f]),k=async({inviteId:e})=>{if(!I){c(!0);try{await C.deleteInvitation({input:{teamDid:h,inviteId:e}}),g(),v?.(),await E(800)}catch(n){console.error(n)}finally{c(!1),m(null)}}},R=()=>{c(!1),m(null)},p=e=>l?W({inviteId:e.inviteId,endpoint:l}):"",b=[{label:t("team.inviting.link"),name:"inviteId",options:{sort:!1,customBodyRenderLite:e=>{const n=s[e];return l?o.jsx(U,{children:p(n)}):o.jsx(B,{size:16})}}},{label:t("common.role"),name:"role",widtn:70,options:{sort:!1,customBodyRender:e=>{const n=j.find(u=>u.name===e);return n?.title?o.jsx(D,{title:e,children:n.title}):e||"--"}}},{label:t("common.remark"),name:"remark",options:{sort:!1,customBodyRender:e=>e||"--"}},{label:t("team.inviting.inviter"),name:"inviter.fullName",options:{sort:!1,customBodyRender:(e,{rowIndex:n})=>s[n]?.inviter?.fullName}},{label:t("common.expires"),name:"expireDate",options:{sort:!1,customBodyRender:e=>o.jsx(w,{children:M(e).format("YYYY-MM-DD HH:mm")})}},{label:t("common.actions"),name:"",width:100,align:"center",options:{sort:!1,customBodyRenderLite:e=>{const n=s[e];return o.jsx(Q,{permission:d?"":"mutate_team",role:d?N:[],children:o.jsxs(S,{onClick:()=>m({title:t("team.inviting.delete.title"),description:t("team.inviting.delete.description",{link:p(n)}),confirm:t("common.delConfirm"),cancel:t("common.cancel"),onConfirm:()=>k(n),onCancel:R}),size:"small",color:"error",variant:"text",children:[o.jsx(L,{style:{fontSize:"1.2em"}}),t("common.delete")]})})}}}];return o.jsxs(_,{children:[s.length?o.jsx(T,{locale:y,data:[...s],columns:b,verticalKeyWidth:100,options:{download:!1,filter:!1,print:!1,search:!1,viewColumns:!1}}):o.jsx(Y,{sx:{minHeight:200},children:t("common.empty")}),i&&o.jsx(K,{title:i.title,description:i.description,confirm:i.confirm,cancel:i.cancel,params:i.params,onConfirm:i.onConfirm,onCancel:i.onCancel})]})}Z.propTypes={invitations:x.array,onRefresh:x.func};const _=H.div`
1
+ import{r}from"./vendor-react-CTtPmzVP.js";import{j as o,a6 as B,am as D,ak as w,cu as L,at as H,W as x}from"./vendor-mui-core-DnR6WYuU.js";import{aU as P,w as S,aP as T,au as Y}from"./vendor-ux-B2x-0VyJ.js";import{Z as z,Q as M,G as N,e as E,br as W}from"./index-B-MpZQKm.js";import{n as A}from"./vendor-utils-CxWN1dT3.js";import{b as G}from"./team-BDHl2zCb.js";import{C as K}from"./confirm-Dwk8QEtL.js";import{P as Q}from"./permission-2Q-NKCMS.js";import{C as U}from"./click-to-copy-CoAdDvF3.js";function Z({invitations:a=[],onRefresh:v=A}){const{api:C,inService:d}=z(),{t,locale:y}=r.useContext(P),{teamDid:h,invitations:f,refresh:g,endpoint:l,roles:j}=G(),[i,m]=r.useState(null),[I,c]=r.useState(!1),s=r.useMemo(()=>a.length>0?a:f,[a,f]),k=async({inviteId:e})=>{if(!I){c(!0);try{await C.deleteInvitation({input:{teamDid:h,inviteId:e}}),g(),v?.(),await E(800)}catch(n){console.error(n)}finally{c(!1),m(null)}}},R=()=>{c(!1),m(null)},p=e=>l?W({inviteId:e.inviteId,endpoint:l}):"",b=[{label:t("team.inviting.link"),name:"inviteId",options:{sort:!1,customBodyRenderLite:e=>{const n=s[e];return l?o.jsx(U,{children:p(n)}):o.jsx(B,{size:16})}}},{label:t("common.role"),name:"role",widtn:70,options:{sort:!1,customBodyRender:e=>{const n=j.find(u=>u.name===e);return n?.title?o.jsx(D,{title:e,children:n.title}):e||"--"}}},{label:t("common.remark"),name:"remark",options:{sort:!1,customBodyRender:e=>e||"--"}},{label:t("team.inviting.inviter"),name:"inviter.fullName",options:{sort:!1,customBodyRender:(e,{rowIndex:n})=>s[n]?.inviter?.fullName}},{label:t("common.expires"),name:"expireDate",options:{sort:!1,customBodyRender:e=>o.jsx(w,{children:M(e).format("YYYY-MM-DD HH:mm")})}},{label:t("common.actions"),name:"",width:100,align:"center",options:{sort:!1,customBodyRenderLite:e=>{const n=s[e];return o.jsx(Q,{permission:d?"":"mutate_team",role:d?N:[],children:o.jsxs(S,{onClick:()=>m({title:t("team.inviting.delete.title"),description:t("team.inviting.delete.description",{link:p(n)}),confirm:t("common.delConfirm"),cancel:t("common.cancel"),onConfirm:()=>k(n),onCancel:R}),size:"small",color:"error",variant:"text",children:[o.jsx(L,{style:{fontSize:"1.2em"}}),t("common.delete")]})})}}}];return o.jsxs(_,{children:[s.length?o.jsx(T,{locale:y,data:[...s],columns:b,verticalKeyWidth:100,options:{download:!1,filter:!1,print:!1,search:!1,viewColumns:!1}}):o.jsx(Y,{sx:{minHeight:200},children:t("common.empty")}),i&&o.jsx(K,{title:i.title,description:i.description,confirm:i.confirm,cancel:i.cancel,params:i.params,onConfirm:i.onConfirm,onCancel:i.onCancel})]})}Z.propTypes={invitations:x.array,onRefresh:x.func};const _=H.div`
2
2
  margin-top: -20px;
3
3
  `;export{Z as I};
@@ -1 +1 @@
1
- import{j as i,ak as l}from"./vendor-mui-core-DnR6WYuU.js";import{u as x,r as w}from"./vendor-react-CTtPmzVP.js";import{b as g}from"./vendor-hooks-qxhUUbW5.js";import{I as v}from"./invitation-BHrproSe.js";import{K as u}from"./landing-page-ol2He6wT.js";import{V as I,a6 as k}from"./vendor-ux-B2x-0VyJ.js";import{u as S,o as E,a as T,d as j,c as P,H as R}from"./index-FreeXNkk.js";import{g as W}from"./get-safe-url-DxpqHRQ1.js";import{c as N}from"./passport-CgVIIIF1.js";import"./vendor-utils-CxWN1dT3.js";import"./index-CgwRpRMk.js";import"./use-passport-id-B-b-_oYF.js";import"./session-8btKYxMi.js";import"./sdk-CHfXvAIT.js";import"./wrap-locale-C87TTgDu.js";import"./index-Cy2nGhzX.js";import"./lottie-web-4koyQiv_.js";import"./vendor-arcblock-hbumvS-z.js";import"./create-passport-svg-H8kuyoHI.js";function J(n){const c=x(),{searchParams:s}=new URL(window.location.href),{api:m,session:p}=S(),{t:d}=I(),a=s.get("inviteId"),r=s.get("redirect"),f=w.useCallback(async()=>{const{data:t}=await E.get("invitation",{params:{inviteId:a}});return t},[a]),h=g(async(t,o=e=>e)=>{t&&(T(o(t.sessionToken)),j(o(t.refreshToken)),t.visitorId&&k(o(t.visitorId))),await p.refresh(),setTimeout(()=>{if(r){const e=decodeURIComponent(r);e.startsWith(P.WELLKNOWN_SERVICE_PATH_PREFIX)?c(e,{replace:!0}):window.location.href=W(e)}else window.location.href=window.env.pathPrefix||"/"},50)});return i.jsxs(u,{did:window.blocklet?.appPid,children:[i.jsx(R,{children:i.jsxs("title",{children:[d("pageTitle.invite")," | ",window.blocklet?.appName]})}),i.jsx(l,{sx:{width:"560px",maxWidth:"100%",height:"100%"},className:"page-invite",children:i.jsx(v,{...n,getDataFn:f,checkFn:m.get,createPassportSvg:t=>N({...t}),onLoginSuccess:h,inService:!0})})]})}export{J as default};
1
+ import{j as i,ak as l}from"./vendor-mui-core-DnR6WYuU.js";import{u as x,r as w}from"./vendor-react-CTtPmzVP.js";import{b as g}from"./vendor-hooks-qxhUUbW5.js";import{I as v}from"./invitation-BQirBsFI.js";import{K as u}from"./landing-page-CpGoTDlB.js";import{V as I,a6 as k}from"./vendor-ux-B2x-0VyJ.js";import{u as S,o as E,a as T,d as j,c as P,H as R}from"./index-B-MpZQKm.js";import{g as W}from"./get-safe-url-Bco2TPFW.js";import{c as N}from"./passport-MtVabWNV.js";import"./vendor-utils-CxWN1dT3.js";import"./index-AnS2fFHl.js";import"./use-passport-id-B-b-_oYF.js";import"./session-CKEyJJp6.js";import"./sdk-Bes03kcb.js";import"./wrap-locale-B6zyAepP.js";import"./index-CpkQ_Cuo.js";import"./lottie-web-4koyQiv_.js";import"./vendor-arcblock-hbumvS-z.js";import"./create-passport-svg-H8kuyoHI.js";function J(n){const c=x(),{searchParams:s}=new URL(window.location.href),{api:m,session:p}=S(),{t:d}=I(),a=s.get("inviteId"),r=s.get("redirect"),f=w.useCallback(async()=>{const{data:t}=await E.get("invitation",{params:{inviteId:a}});return t},[a]),h=g(async(t,o=e=>e)=>{t&&(T(o(t.sessionToken)),j(o(t.refreshToken)),t.visitorId&&k(o(t.visitorId))),await p.refresh(),setTimeout(()=>{if(r){const e=decodeURIComponent(r);e.startsWith(P.WELLKNOWN_SERVICE_PATH_PREFIX)?c(e,{replace:!0}):window.location.href=W(e)}else window.location.href=window.env.pathPrefix||"/"},50)});return i.jsxs(u,{did:window.blocklet?.appPid,children:[i.jsx(R,{children:i.jsxs("title",{children:[d("pageTitle.invite")," | ",window.blocklet?.appName]})}),i.jsx(l,{sx:{width:"560px",maxWidth:"100%",height:"100%"},className:"page-invite",children:i.jsx(v,{...n,getDataFn:f,checkFn:m.get,createPassportSvg:t=>N({...t}),onLoginSuccess:h,inService:!0})})]})}export{J as default};
@@ -1,2 +1,2 @@
1
- import{g as P}from"./vendor-react-CTtPmzVP.js";import{aQ as E,bh as F,bi as H,bj as Q,bk as $}from"./index-FreeXNkk.js";var h={exports:{}},p={exports:{}},I;function N(){return I||(I=1,function(c,n){Object.defineProperty(n,"__esModule",{value:!0}),n.default=void 0;var v=function(d,y){return d.indexOf(y)!==-1};n.default=v,c.exports=n.default,c.exports.default=n.default}(p,p.exports)),p.exports}var A;function W(){return A||(A=1,function(c,n){Object.defineProperty(n,"__esModule",{value:!0}),n.default=T;var v=o(E()),g=o(H()),d=o(N()),y=o($()),b=o(Q()),S=o(F());function o(e){return e&&e.__esModule?e:{default:e}}function j(e,r){return U(e)||O(e,r)||L(e,r)||R()}function R(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
1
+ import{g as P}from"./vendor-react-CTtPmzVP.js";import{aQ as E,bh as F,bi as H,bj as Q,bk as $}from"./index-B-MpZQKm.js";var h={exports:{}},p={exports:{}},I;function N(){return I||(I=1,function(c,n){Object.defineProperty(n,"__esModule",{value:!0}),n.default=void 0;var v=function(d,y){return d.indexOf(y)!==-1};n.default=v,c.exports=n.default,c.exports.default=n.default}(p,p.exports)),p.exports}var A;function W(){return A||(A=1,function(c,n){Object.defineProperty(n,"__esModule",{value:!0}),n.default=T;var v=o(E()),g=o(H()),d=o(N()),y=o($()),b=o(Q()),S=o(F());function o(e){return e&&e.__esModule?e:{default:e}}function j(e,r){return U(e)||O(e,r)||L(e,r)||R()}function R(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
2
2
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function L(e,r){if(e){if(typeof e=="string")return w(e,r);var l={}.toString.call(e).slice(8,-1);return l==="Object"&&e.constructor&&(l=e.constructor.name),l==="Map"||l==="Set"?Array.from(e):l==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(l)?w(e,r):void 0}}function w(e,r){(r==null||r>e.length)&&(r=e.length);for(var l=0,u=Array(r);l<r;l++)u[l]=e[l];return u}function O(e,r){var l=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(l!=null){var u,a,_,s,i=[],t=!0,f=!1;try{if(_=(l=l.call(e)).next,r!==0)for(;!(t=(u=_.call(l)).done)&&(i.push(u.value),i.length!==r);t=!0);}catch(m){f=!0,a=m}finally{try{if(!t&&l.return!=null&&(s=l.return(),Object(s)!==s))return}finally{if(f)throw a}}return i}}function U(e){if(Array.isArray(e))return e}var k={protocols:["http","https","ftp"],require_tld:!0,require_protocol:!1,require_host:!0,require_port:!1,require_valid_protocol:!0,allow_underscores:!1,allow_trailing_dot:!1,allow_protocol_relative_urls:!1,allow_fragments:!0,allow_query_components:!0,validate_length:!0,max_allowed_length:2084},M=/^\[([^\]]+)\](?::([0-9]+))?$/;function T(e,r){if((0,v.default)(e),!e||/[\s<>]/.test(e)||e.indexOf("mailto:")===0||(r=(0,S.default)(r,k),r.validate_length&&e.length>r.max_allowed_length)||!r.allow_fragments&&(0,d.default)(e,"#")||!r.allow_query_components&&((0,d.default)(e,"?")||(0,d.default)(e,"&")))return!1;var l,u,a,_,s,i,t,f;if(t=e.split("#"),e=t.shift(),t=e.split("?"),e=t.shift(),t=e.split("://"),t.length>1){if(l=t.shift().toLowerCase(),r.require_valid_protocol&&r.protocols.indexOf(l)===-1)return!1}else{if(r.require_protocol)return!1;if(e.slice(0,2)==="//"){if(!r.allow_protocol_relative_urls)return!1;t[0]=e.slice(2)}}if(e=t.join("://"),e==="")return!1;if(t=e.split("/"),e=t.shift(),e===""&&!r.require_host)return!0;if(t=e.split("@"),t.length>1){if(r.disallow_auth||t[0]===""||(u=t.shift(),u.indexOf(":")>=0&&u.split(":").length>2))return!1;var m=u.split(":"),x=j(m,2),C=x[0],D=x[1];if(C===""&&D==="")return!1}_=t.join("@"),i=null,f=null;var q=_.match(M);if(q?(a="",f=q[1],i=q[2]||null):(t=_.split(":"),a=t.shift(),t.length&&(i=t.join(":"))),i!==null&&i.length>0){if(s=parseInt(i,10),!/^[0-9]+$/.test(i)||s<=0||s>65535)return!1}else if(r.require_port)return!1;return r.host_whitelist?(0,g.default)(a,r.host_whitelist):a===""&&!r.require_host?!0:!(!(0,b.default)(a)&&!(0,y.default)(a,r)&&(!f||!(0,b.default)(f,6))||(a=a||f,r.host_blacklist&&(0,g.default)(a,r.host_blacklist)))}c.exports=n.default,c.exports.default=n.default}(h,h.exports)),h.exports}var z=W();const J=P(z);export{J as i};
@@ -1 +1 @@
1
- import{j as s,a6 as w,ak as x}from"./vendor-mui-core-DnR6WYuU.js";import{g as v,q as k,b as p}from"./vendor-hooks-qxhUUbW5.js";import{I as T}from"./invitation-BHrproSe.js";import{K as I}from"./landing-page-ol2He6wT.js";import{V as P,a6 as j}from"./vendor-ux-B2x-0VyJ.js";import{u as R,a as S,d as E,c as N,H as W}from"./index-FreeXNkk.js";import{g as C}from"./get-safe-url-DxpqHRQ1.js";import{c as F}from"./passport-CgVIIIF1.js";import{u as L}from"./vendor-react-CTtPmzVP.js";import"./vendor-utils-CxWN1dT3.js";import"./index-CgwRpRMk.js";import"./use-passport-id-B-b-_oYF.js";import"./session-8btKYxMi.js";import"./sdk-CHfXvAIT.js";import"./wrap-locale-C87TTgDu.js";import"./index-Cy2nGhzX.js";import"./lottie-web-4koyQiv_.js";import"./vendor-arcblock-hbumvS-z.js";import"./create-passport-svg-H8kuyoHI.js";function Z(m){const{searchParams:r}=new URL(window.location.href),{api:a,session:f}=R(),d=L(),{t:u}=P(),n=r.get("id"),c=r.get("redirect"),h=v({state:""}),o=k(async()=>{if(!n)return null;const{data:t}=await a.get("/api/invitation",{params:{inviteId:n,mode:"issue-passport"}});return t}),l=p(()=>{if(o.error)throw o.error;return o?.data}),g=p(async(t,i=e=>e)=>{t&&(t.sessionToken&&S(i(t.sessionToken)),t.refreshToken&&E(i(t.refreshToken)),t.visitorId&&j(i(t.visitorId)),await f.refresh()),setTimeout(()=>{if(c){const e=decodeURIComponent(c);e.startsWith(N.WELLKNOWN_SERVICE_PATH_PREFIX)?d(e,{replace:!0}):window.location.href=C(e)}else window.location.href=window.env.pathPrefix||"/"},50)});return o.loading?s.jsx(w,{}):s.jsxs(I,{did:window.blocklet?.appPid,children:[s.jsx(W,{children:s.jsxs("title",{children:[u("pageTitle.issuePassport")," | ",window.blocklet?.appName]})}),s.jsx(x,{className:"page-invite",sx:{width:"560px",maxWidth:"100%",height:"100%"},children:s.jsx(T,{...m,action:"issue-passport",getDataFn:l,checkFn:a.get,createPassportSvg:F,onLoginSuccess:g,inService:!0,status:h.state})})]})}export{Z as default};
1
+ import{j as s,a6 as w,ak as x}from"./vendor-mui-core-DnR6WYuU.js";import{g as v,q as k,b as p}from"./vendor-hooks-qxhUUbW5.js";import{I as T}from"./invitation-BQirBsFI.js";import{K as I}from"./landing-page-CpGoTDlB.js";import{V as P,a6 as j}from"./vendor-ux-B2x-0VyJ.js";import{u as R,a as S,d as E,c as N,H as W}from"./index-B-MpZQKm.js";import{g as C}from"./get-safe-url-Bco2TPFW.js";import{c as F}from"./passport-MtVabWNV.js";import{u as L}from"./vendor-react-CTtPmzVP.js";import"./vendor-utils-CxWN1dT3.js";import"./index-AnS2fFHl.js";import"./use-passport-id-B-b-_oYF.js";import"./session-CKEyJJp6.js";import"./sdk-Bes03kcb.js";import"./wrap-locale-B6zyAepP.js";import"./index-CpkQ_Cuo.js";import"./lottie-web-4koyQiv_.js";import"./vendor-arcblock-hbumvS-z.js";import"./create-passport-svg-H8kuyoHI.js";function Z(m){const{searchParams:r}=new URL(window.location.href),{api:a,session:f}=R(),d=L(),{t:u}=P(),n=r.get("id"),c=r.get("redirect"),h=v({state:""}),o=k(async()=>{if(!n)return null;const{data:t}=await a.get("/api/invitation",{params:{inviteId:n,mode:"issue-passport"}});return t}),l=p(()=>{if(o.error)throw o.error;return o?.data}),g=p(async(t,i=e=>e)=>{t&&(t.sessionToken&&S(i(t.sessionToken)),t.refreshToken&&E(i(t.refreshToken)),t.visitorId&&j(i(t.visitorId)),await f.refresh()),setTimeout(()=>{if(c){const e=decodeURIComponent(c);e.startsWith(N.WELLKNOWN_SERVICE_PATH_PREFIX)?d(e,{replace:!0}):window.location.href=C(e)}else window.location.href=window.env.pathPrefix||"/"},50)});return o.loading?s.jsx(w,{}):s.jsxs(I,{did:window.blocklet?.appPid,children:[s.jsx(W,{children:s.jsxs("title",{children:[u("pageTitle.issuePassport")," | ",window.blocklet?.appName]})}),s.jsx(x,{className:"page-invite",sx:{width:"560px",maxWidth:"100%",height:"100%"},children:s.jsx(T,{...m,action:"issue-passport",getDataFn:l,checkFn:a.get,createPassportSvg:F,onLoginSuccess:g,inService:!0,status:h.state})})]})}export{Z as default};