@abtnode/blocklet-services 1.17.5-beta-20251214-231110-497f8d27 → 1.17.6-beta-20251216-081847-bf91c4db

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 (278) hide show
  1. package/api/libs/connect/session.js +6 -9
  2. package/api/routes/federated.js +2 -2
  3. package/dist/assets/AdapterDayjs-Bfr4sW4C.js +3 -0
  4. package/dist/assets/{Community-C7CFokDQ.js → Community-CELsDteM.js} +1 -1
  5. package/dist/assets/{Google-qCiUM9VP.js → Google-DA3WTnLE.js} +1 -1
  6. package/dist/assets/{Holiday-DyVifdc-.js → Holiday-DOCjSYjH.js} +1 -1
  7. package/dist/assets/{Meeting-DbtUCCZq.js → Meeting-BAXt_LiK.js} +1 -1
  8. package/dist/assets/{OffSick-BtITykO3.js → OffSick-BGEr8Nkc.js} +1 -1
  9. package/dist/assets/{WorkingRemotely-mKvokr6L.js → WorkingRemotely-BcneAIXG.js} +1 -1
  10. package/dist/assets/access-control-BZvc7AZG.js +14 -0
  11. package/dist/assets/actions-Dfiiwkit.js +1 -0
  12. package/dist/assets/{add-component-core-CFL73x1V.js → add-component-core-CNH5E2RR.js} +1 -1
  13. package/dist/assets/add-resource-BWEvlWkH.js +1 -0
  14. package/dist/assets/addon-uM70Qwac.js +14 -0
  15. package/dist/assets/{advanced-Djs25PXG.js → advanced-Caeqx4XB.js} +1 -1
  16. package/dist/assets/aigne-B9drp8Pq.js +10 -0
  17. package/dist/assets/api-C75sLx9p.js +1 -0
  18. package/dist/assets/appearance-DM7p-6Wl.js +1 -0
  19. package/dist/assets/arrow-down.svg-C4FUKwt4.js +1 -0
  20. package/dist/assets/{audit-logs-CXjhDj8M.js → audit-logs-L-gO50KL.js} +2 -2
  21. package/dist/assets/authorize-D2d4GCpP.js +1 -0
  22. package/dist/assets/{base-chart-BXspUQ5X.js → base-chart-DSDnGziZ.js} +1 -1
  23. package/dist/assets/{base32-E_M8YiDy.js → base32-B-7CnEFd.js} +1 -1
  24. package/dist/assets/bind-account-DuzArGdZ.js +1 -0
  25. package/dist/assets/{branding-B6_O9dwM.js → branding-Dx40btDl.js} +1 -1
  26. package/dist/assets/{branding-BN5xzu2K.js → branding-aCdIMhb0.js} +5 -5
  27. package/dist/assets/branding-bYH66Nug.js +1 -0
  28. package/dist/assets/bundle-avatar-B1jZNqcH.js +1 -0
  29. package/dist/assets/button-BnSiFtNt.js +1 -0
  30. package/dist/assets/click-to-copy-CwdgHxjB.js +1 -0
  31. package/dist/assets/cloneDeep-B_fYlLpl.js +1 -0
  32. package/dist/assets/{collapse-DRXViE1U.js → collapse-B7gUzFaX.js} +1 -1
  33. package/dist/assets/{complete-DERkCyic.js → complete-Rr-_Zaon.js} +3 -3
  34. package/dist/assets/{component-BFEXoFyD.js → component-DZretbSC.js} +2 -2
  35. package/dist/assets/{config-DBQhYXkx.js → config-Bjbv_xI5.js} +1 -1
  36. package/dist/assets/config-BkqISfFO.js +53 -0
  37. package/dist/assets/{config-mfnTXE1f.js → config-Dw0qq-09.js} +2 -2
  38. package/dist/assets/{config-navigation-CL9YkEzl.js → config-navigation-Dj8qf6cK.js} +8 -8
  39. package/dist/assets/config-space-Dw6ITGIj.js +1 -0
  40. package/dist/assets/confirm-Bpit6U3-.js +7 -0
  41. package/dist/assets/{connect-DXN8mBKc.js → connect-B1ZA3nS8.js} +1 -1
  42. package/dist/assets/connect-Bl7-1lbc.js +1 -0
  43. package/dist/assets/connect-to-BsxW3JJi.js +1 -0
  44. package/dist/assets/{content-layout-B5NObRcH.js → content-layout-DmSBGGVm.js} +1 -1
  45. package/dist/assets/{create-passport-svg-BwqsyTOz.js → create-passport-svg-DGPNsGUE.js} +1 -1
  46. package/dist/assets/createClass-B5uCYz0o.js +1 -0
  47. package/dist/assets/{dashboard-DHhNID_3.js → dashboard-DBwE7l6f.js} +7 -7
  48. package/dist/assets/{delete-confirm-DSQSBte5.js → delete-confirm-L0HXJtqt.js} +1 -1
  49. package/dist/assets/did-address-uvYuZ4wv.js +1 -0
  50. package/dist/assets/domain-BoEowNlU.js +9 -0
  51. package/dist/assets/domain-action-card-BB0jQwcH.js +28 -0
  52. package/dist/assets/domains-kgzxNW_C.js +1 -0
  53. package/dist/assets/{edit.svg-Dz9cVo7r.js → edit.svg-RRSklUg-.js} +1 -1
  54. package/dist/assets/{email-DDHqRiNE.js → email-BAr61Jer.js} +2 -2
  55. package/dist/assets/{empty-spinner-0EAHJWBW.js → empty-spinner-BYDonf35.js} +1 -1
  56. package/dist/assets/engine-DWk3y4cO.js +1 -0
  57. package/dist/assets/exchange-passport-BuJUAVgN.js +1 -0
  58. package/dist/assets/{form-C-ZRaynb.js → form-kdwSU-mv.js} +3 -3
  59. package/dist/assets/form-text-input-B_h8beXh.js +11 -0
  60. package/dist/assets/{form-wrapper-dz0PgYyA.js → form-wrapper-PT5ZzMQy.js} +1 -1
  61. package/dist/assets/fuel-C9kfBZ4R.js +32 -0
  62. package/dist/assets/gen-access-key-Bh-o1OFU.js +1 -0
  63. package/dist/assets/gen-simple-access-key-DHmIlRFl.js +1 -0
  64. package/dist/assets/get-safe-url-gaxZoVzJ.js +1 -0
  65. package/dist/assets/{home-D8RPk4rl.js → home-Cb5I193s.js} +1 -1
  66. package/dist/assets/{iframe-DbxlfoSv.js → iframe-C233G1py.js} +1 -1
  67. package/dist/assets/{index-Dnont80V.js → index-B0Q9wWG1.js} +2 -2
  68. package/dist/assets/{index-BfyoUnq5.js → index-B7DVpLRM.js} +34 -34
  69. package/dist/assets/index-BScxMPlP.js +1 -0
  70. package/dist/assets/{index-CiQvt8QY.js → index-BT70k77_.js} +2 -2
  71. package/dist/assets/index-BaaFi7Vh.js +1 -0
  72. package/dist/assets/{index-CmT6o_W4.js → index-Bf3Peb0q.js} +5 -5
  73. package/dist/assets/{index-BIFlvVef.js → index-C-vVEZcs.js} +6 -6
  74. package/dist/assets/{index-BajjN1HU.js → index-CGP3CGlC.js} +6 -6
  75. package/dist/assets/{index-Ccjxs0wr.js → index-CI3rRJqa.js} +12 -12
  76. package/dist/assets/{index-CAtE4xM9.js → index-CK3KHeKw.js} +8 -8
  77. package/dist/assets/{index-CIvZ7HIX.js → index-CRAuhYSg.js} +1 -1
  78. package/dist/assets/{index-CJBVOMty.js → index-CUlOq3Sr.js} +4 -4
  79. package/dist/assets/{index-DK4Rvfj9.js → index-CZBIYuko.js} +1 -1
  80. package/dist/assets/{index-BjLM8Gon.js → index-CaTDaKrX.js} +1 -1
  81. package/dist/assets/index-CqD-x8pw.js +7 -0
  82. package/dist/assets/{index-Bs5xamxm.js → index-CtORPeiq.js} +2 -2
  83. package/dist/assets/index-D-a8pZtp.js +1 -0
  84. package/dist/assets/{index-BOiRUuPB.js → index-D24LKXzO.js} +1 -1
  85. package/dist/assets/{index-C0q1NhNR.js → index-D29her4n.js} +1 -1
  86. package/dist/assets/index-DACtt7qd.js +102 -0
  87. package/dist/assets/{index-BRGQOPmE.js → index-D_u0j8BO.js} +1 -1
  88. package/dist/assets/{index-B6QOO2yw.js → index-DjpxFmgG.js} +7 -7
  89. package/dist/assets/index-DuDIkjct.js +55 -0
  90. package/dist/assets/{index-BXtrOI0G.js → index-DwJ_NASi.js} +1 -1
  91. package/dist/assets/{index-Dijoh4El.js → index-DwyzCfdd.js} +103 -103
  92. package/dist/assets/index-KIswy2vM.js +120 -0
  93. package/dist/assets/index-LaMi0T4w.js +1 -0
  94. package/dist/assets/index-MQEkIEm-.js +1 -0
  95. package/dist/assets/{index-DHn4LCaq.js → index-OMkyTUNX.js} +4 -4
  96. package/dist/assets/index-WT6M-zj8.js +6 -0
  97. package/dist/assets/{index-BsA1v5Kx.js → index-_tncRnTu.js} +1 -1
  98. package/dist/assets/index-lK6Pf_qM.js +11 -0
  99. package/dist/assets/{index-CMec_woq.js → index-m1ZQT0sU.js} +1 -1
  100. package/dist/assets/{index-bb4s-8hu.js → index-oS8X43Pb.js} +6 -6
  101. package/dist/assets/index-xE7OidBo.js +1 -0
  102. package/dist/assets/{index.esm-DTmS4tth.js → index.esm-Co8ZxFyk.js} +1 -1
  103. package/dist/assets/{invitation-Cjg3Rgxl.js → invitation-C2S2tPzG.js} +7 -7
  104. package/dist/assets/invitations-Dil5QWBY.js +3 -0
  105. package/dist/assets/invite-GVnju9RQ.js +1 -0
  106. package/dist/assets/{isURL-wZZwzwyC.js → isURL-ZFgr0DWl.js} +2 -2
  107. package/dist/assets/issue-passport-BmU6NmKw.js +1 -0
  108. package/dist/assets/{item-Bpf_gGYt.js → item-DfQKizv4.js} +1 -1
  109. package/dist/assets/landing-page-C3zTr0-n.js +1 -0
  110. package/dist/assets/{launch-result-message-BTBdTioQ.js → launch-result-message-MNpx7ysR.js} +1 -1
  111. package/dist/assets/{layout-CZo9vMzc.js → layout-tkk_Lr2y.js} +1 -1
  112. package/dist/assets/list-BvgV1Jbh.js +2 -0
  113. package/dist/assets/list-YOpLH3o0.js +103 -0
  114. package/dist/assets/{list-header-BQo9L_6R.js → list-header-Cl3jykCe.js} +1 -1
  115. package/dist/assets/localization-DcnSNZHz.js +1 -0
  116. package/dist/assets/{lock.svg-BPCZ0CT3.js → lock.svg-BgybwZNe.js} +1 -1
  117. package/dist/assets/{log-KsUeQx46.js → log-C0zcaEbO.js} +1 -1
  118. package/dist/assets/logger-BbBkOuwH.js +1 -0
  119. package/dist/assets/login-BR26IXZx.js +1 -0
  120. package/dist/assets/login-oauth-callback-DCJMx5J1.js +1 -0
  121. package/dist/assets/logo-uploader-TLOlwvRt.js +30 -0
  122. package/dist/assets/{lost-passport-DWR3ith-.js → lost-passport-DE5KGhjz.js} +3 -3
  123. package/dist/assets/{lottie-react.esm-CD0xFBYg.js → lottie-react.esm-E4oo1jhL.js} +1 -1
  124. package/dist/assets/omit-D_PYZZLm.js +1 -0
  125. package/dist/assets/{open-window-Ct_MP3Sx.js → open-window-CPNpPXku.js} +1 -1
  126. package/dist/assets/over-due-invoice-payment-1EZsSUm4.js +1 -0
  127. package/dist/assets/{overview-5u7B_D_6.js → overview-CMduEuAK.js} +2 -2
  128. package/dist/assets/{page-header-Cgwo2np-.js → page-header-CHAwrgX-.js} +1 -1
  129. package/dist/assets/passport-Dg1YWagy.js +1 -0
  130. package/dist/assets/passport-item-QbgyHapR.js +1 -0
  131. package/dist/assets/{permission-BYxNrlaa.js → permission-C0bmOzVj.js} +1 -1
  132. package/dist/assets/preferences-0l0Zmaom.js +1 -0
  133. package/dist/assets/profile-embed-BQzLZZkK.js +1 -0
  134. package/dist/assets/publish-resource-ggObFvMi.js +1 -0
  135. package/dist/assets/{question-mark-circle.svg-DK9nTUDZ.js → question-mark-circle.svg-CByEVDhb.js} +1 -1
  136. package/dist/assets/{raf-schd.esm-JNUhxcps.js → raf-schd.esm-XXBRsnmf.js} +1 -1
  137. package/dist/assets/{react-beautiful-dnd.esm-Cvsu51oI.js → react-beautiful-dnd.esm-zYw9dagY.js} +1 -1
  138. package/dist/assets/{react-stripe.esm-Dqbe1A8R.js → react-stripe.esm-CVZErl8X.js} +1 -1
  139. package/dist/assets/{required-B0Gua-D1.js → required-BQln5OcV.js} +1 -1
  140. package/dist/assets/{revoke.svg-CuiCGfVW.js → revoke.svg-CNl4LAbv.js} +1 -1
  141. package/dist/assets/runtime-BNKE0VfZ.js +1 -0
  142. package/dist/assets/{sanitize-D6Abg5_T.js → sanitize-CtCDGQB6.js} +1 -1
  143. package/dist/assets/sdk-YVE2MSze.js +1 -0
  144. package/dist/assets/{section-BkMzBpvM.js → section-jXB9AxBb.js} +1 -1
  145. package/dist/assets/{security-DCG1tmZe.js → security-CWEVWbF4.js} +3 -3
  146. package/dist/assets/{server-logo-notext.svg-DHxZ1bRk.js → server-logo-notext.svg-xZ-i1SpD.js} +1 -1
  147. package/dist/assets/session-Des-0R_y.js +1 -0
  148. package/dist/assets/setup-Cps_vpFS.js +24 -0
  149. package/dist/assets/{shorten-label-DhOty_4j.js → shorten-label-C4py9TLA.js} +1 -1
  150. package/dist/assets/{simple-select-D0q2J-Br.js → simple-select-DbXWLzPn.js} +1 -1
  151. package/dist/assets/{spaces-DM95DgFM.js → spaces-2YPkTkBR.js} +1 -1
  152. package/dist/assets/start-CuCNmoqX.js +187 -0
  153. package/dist/assets/{starting-progress-aMYWzin8.js → starting-progress-xuCef6_T.js} +2 -2
  154. package/dist/assets/status-DleDsf-t.js +1 -0
  155. package/dist/assets/{step-actions-nHHLzUFh.js → step-actions-AHe2MQxo.js} +1 -1
  156. package/dist/assets/studio-HfI11Uc3.js +6 -0
  157. package/dist/assets/{switch-control-BAyRLHvJ.js → switch-control-CzYig10w.js} +1 -1
  158. package/dist/assets/switch-rIcJ7tho.js +1 -0
  159. package/dist/assets/{table-tips-BA9A3QDk.js → table-tips-Ba9Kf02z.js} +1 -1
  160. package/dist/assets/team-BWkxYdcc.js +146 -0
  161. package/dist/assets/traffic-jB6onGHq.js +1 -0
  162. package/dist/assets/transfer-DspVAdFc.js +16 -0
  163. package/dist/assets/unsubscribe-CKdMi1Kx.js +1 -0
  164. package/dist/assets/use-app-logo-BAGvxEU-.js +1 -0
  165. package/dist/assets/{use-mobile-Dwc30NoL.js → use-mobile-BINJTzMb.js} +1 -1
  166. package/dist/assets/{use-mobile-Vtj5nBdp.js → use-mobile-D5clNlrm.js} +1 -1
  167. package/dist/assets/{use-server-logo-BfNy3Xkj.js → use-server-logo-Cv1kAPgB.js} +1 -1
  168. package/dist/assets/use-window-close-D7QBHj75.js +1 -0
  169. package/dist/assets/useAsync-CgTefzpB.js +1 -0
  170. package/dist/assets/{useAsync-DNDhrs-2.js → useAsync-CxjyODHb.js} +1 -1
  171. package/dist/assets/{useAsyncRetry-CSW1hopB.js → useAsyncRetry-BnuUJFwY.js} +1 -1
  172. package/dist/assets/useLocalStorage-Bj52e1ZW.js +1 -0
  173. package/dist/assets/{useSetState-cWrp7qoX.js → useSetState-L-f8mSga.js} +1 -1
  174. package/dist/assets/user-center-CL_lKzgJ.js +125 -0
  175. package/dist/assets/user-follower-CfiG4RXf.js +32 -0
  176. package/dist/assets/{util-DSnAozzs.js → util-C9cWBCZz.js} +1 -1
  177. package/dist/assets/{util-BxX0TJKJ.js → util-DXf_zMuU.js} +1 -1
  178. package/dist/assets/{vendor-arcblock-D4Rvz_D3.js → vendor-arcblock-DkdOhPyM.js} +1 -1
  179. package/dist/assets/{vendor-hooks-U4TTuKG0.js → vendor-hooks-BZ19vVZ7.js} +2 -2
  180. package/dist/assets/{vendor-mui-core-B5XNUjey.js → vendor-mui-core-DnR6WYuU.js} +2 -2
  181. package/dist/assets/{vendor-mui-x-DtPl0qBm.js → vendor-mui-x-CQc01l4r.js} +1 -1
  182. package/dist/assets/{vendor-react-CUXIiAnY.js → vendor-react-CTtPmzVP.js} +1 -1
  183. package/dist/assets/{vendor-utils-CFxoplqC.js → vendor-utils-D5UG1a5Y.js} +2 -2
  184. package/dist/assets/{vendor-ux-BX9dSNUy.js → vendor-ux-DMZIE6wA.js} +2 -2
  185. package/dist/assets/{wait-connect-CCXiMHZY.js → wait-connect-D2wPrbE3.js} +1 -1
  186. package/dist/assets/{wizard-TEBzHS-w.js → wizard-EYZCXWG5.js} +2 -2
  187. package/dist/assets/wizard-components-PMRUmw6U.js +52 -0
  188. package/dist/assets/wrap-locale-B4E8Yvgz.js +1 -0
  189. package/dist/assets/{zh-Dr9buZnV.js → zh-CSl2KD_S.js} +1 -1
  190. package/dist/assets/zh-CXK3bXGt.js +1 -0
  191. package/dist/assets/{zh-tw-CeXBj2i0.js → zh-tw-BiloxWNq.js} +1 -1
  192. package/dist/index.html +1 -1
  193. package/dist/service-worker.js +25 -2
  194. package/package.json +50 -50
  195. package/dist/assets/AdapterDayjs-p1MGZm94.js +0 -3
  196. package/dist/assets/access-control-C6MQq9M9.js +0 -14
  197. package/dist/assets/actions-CiAs-6JM.js +0 -1
  198. package/dist/assets/add-resource-DVpeKvW6.js +0 -1
  199. package/dist/assets/addon-B5NG3IsS.js +0 -14
  200. package/dist/assets/aigne-WBAWm6yx.js +0 -10
  201. package/dist/assets/api-Cjc501Es.js +0 -1
  202. package/dist/assets/appearance-CVS4AfPI.js +0 -1
  203. package/dist/assets/arrow-down.svg-Dhs0HydJ.js +0 -1
  204. package/dist/assets/authorize-uzVAAuOd.js +0 -1
  205. package/dist/assets/bind-account-N3cioth0.js +0 -1
  206. package/dist/assets/branding-BFn6p_xP.js +0 -1
  207. package/dist/assets/bundle-avatar-CfVy3gda.js +0 -1
  208. package/dist/assets/button-4KPacREM.js +0 -1
  209. package/dist/assets/click-to-copy-DXHOGoUP.js +0 -1
  210. package/dist/assets/cloneDeep-DjDct56M.js +0 -1
  211. package/dist/assets/config-CwbUhIlW.js +0 -57
  212. package/dist/assets/config-space-3dNLmLWy.js +0 -1
  213. package/dist/assets/confirm-BIsS5xyi.js +0 -7
  214. package/dist/assets/connect-DMt_37_e.js +0 -1
  215. package/dist/assets/connect-to-D3C0j8V8.js +0 -1
  216. package/dist/assets/createClass-CkCf2FLT.js +0 -1
  217. package/dist/assets/did-address-Qmm0nyiR.js +0 -1
  218. package/dist/assets/domain-DcU9P4mp.js +0 -9
  219. package/dist/assets/domain-action-card-D9HXIIpd.js +0 -28
  220. package/dist/assets/domains-DVkGbWo7.js +0 -1
  221. package/dist/assets/engine-Cx3nUUOw.js +0 -1
  222. package/dist/assets/exchange-passport-Bxh8blMK.js +0 -1
  223. package/dist/assets/form-text-input-CbjI2VZQ.js +0 -11
  224. package/dist/assets/fuel-BdIacIqD.js +0 -32
  225. package/dist/assets/gen-access-key-DdjBRI5O.js +0 -1
  226. package/dist/assets/gen-simple-access-key-CBGi0io0.js +0 -1
  227. package/dist/assets/get-safe-url-pZvXlaJu.js +0 -1
  228. package/dist/assets/index-5B_H2zYd.js +0 -1
  229. package/dist/assets/index-6M8OhYM1.js +0 -1
  230. package/dist/assets/index-BRky7Qm3.js +0 -7
  231. package/dist/assets/index-CUIcSX4q.js +0 -102
  232. package/dist/assets/index-CtuxXUm_.js +0 -1
  233. package/dist/assets/index-DCPJbOWh.js +0 -55
  234. package/dist/assets/index-DD9ceQKr.js +0 -1
  235. package/dist/assets/index-Dn_bIjgF.js +0 -6
  236. package/dist/assets/index-G1If4Shq.js +0 -120
  237. package/dist/assets/index-RxqUBm3A.js +0 -11
  238. package/dist/assets/index-SH0LXIEm.js +0 -1
  239. package/dist/assets/index-mgpYakv8.js +0 -1
  240. package/dist/assets/invitations-xEsO2f9m.js +0 -3
  241. package/dist/assets/invite-ChOQtk0E.js +0 -1
  242. package/dist/assets/issue-passport-CUGjhBZr.js +0 -1
  243. package/dist/assets/landing-page-zT1Tduxx.js +0 -1
  244. package/dist/assets/list-Cj5o6_aJ.js +0 -103
  245. package/dist/assets/list-dBF9Lx52.js +0 -2
  246. package/dist/assets/localization-BhQNA1fu.js +0 -1
  247. package/dist/assets/logger-CWdgyrlX.js +0 -1
  248. package/dist/assets/login-BRtDYFyr.js +0 -1
  249. package/dist/assets/login-oauth-callback-BVOT5KIP.js +0 -1
  250. package/dist/assets/logo-uploader-CMuaTg_2.js +0 -30
  251. package/dist/assets/omit-DZEUV_m7.js +0 -1
  252. package/dist/assets/over-due-invoice-payment-EIjXZOAF.js +0 -1
  253. package/dist/assets/passport-BcfDxGFq.js +0 -1
  254. package/dist/assets/passport-item-BnRaEMVZ.js +0 -1
  255. package/dist/assets/preferences-BgyNzrci.js +0 -1
  256. package/dist/assets/profile-embed-C3hI8xed.js +0 -1
  257. package/dist/assets/publish-resource-CreTipUc.js +0 -1
  258. package/dist/assets/runtime-BwoZhRe2.js +0 -1
  259. package/dist/assets/sdk-Do4pV1s0.js +0 -1
  260. package/dist/assets/session-DUT2afHJ.js +0 -1
  261. package/dist/assets/setup-ephJCw43.js +0 -24
  262. package/dist/assets/start-sucUqu8u.js +0 -187
  263. package/dist/assets/status-BFw6nCWi.js +0 -1
  264. package/dist/assets/studio-BKkw9WY-.js +0 -6
  265. package/dist/assets/switch-C5K07M96.js +0 -1
  266. package/dist/assets/team-HgvOpVEJ.js +0 -146
  267. package/dist/assets/traffic-BvA-dAE6.js +0 -1
  268. package/dist/assets/transfer-CiITg5ql.js +0 -16
  269. package/dist/assets/unsubscribe-2BjO5Axx.js +0 -1
  270. package/dist/assets/use-app-logo-D9eQSUYq.js +0 -1
  271. package/dist/assets/use-window-close-DLSxYDw-.js +0 -1
  272. package/dist/assets/useAsync-Dy8z2Lh_.js +0 -1
  273. package/dist/assets/useLocalStorage-oIIa9C3F.js +0 -1
  274. package/dist/assets/user-center-BODNsVgb.js +0 -126
  275. package/dist/assets/user-follower-ODH9p68y.js +0 -32
  276. package/dist/assets/wizard-components-MqkmgXy5.js +0 -52
  277. package/dist/assets/wrap-locale-Dk2yVg3Y.js +0 -1
  278. package/dist/assets/zh-C6-KWz-k.js +0 -1
@@ -1,4 +1,4 @@
1
- import{j as e,y as yr,bc as ye,M as ne,ak as m,Q as G,W as u,J as ve,c1 as vr,I as W,aN as wr,T as A,aj as jr,b5 as Pe,P as Ie,b6 as Te,a5 as Re,z as Ue,A as Fe,cj as Cr,bh as kr,U as Me,cW as Sr,cX as Pr,at as V,cY as Ir,a6 as Y,n as oe,D as Tr,cZ as Rr,ar as Ae,b1 as we,c_ as Mr,aX as Ar,a$ as Er,c$ as zr}from"./vendor-mui-core-B5XNUjey.js";import{r as y,a as Wr,u as Lr,j as Dr}from"./vendor-react-CUXIiAnY.js";import{t as _e,Z as $r,a4 as Br,R as Ee,D as Or,C as se,n as H,A as Nr}from"./vendor-utils-CFxoplqC.js";import{a as Ur,G as Fr,be as _r,c as je,ad as qr,K as Hr,bc as qe,bf as Gr,aA as He,Z as le,bg as Kr,a9 as Yr,aa as Zr,bh as Vr}from"./index-Dijoh4El.js";import{a as R,h as Qr,k as ce,g as Q,b as M,j as Xr}from"./vendor-hooks-U4TTuKG0.js";import{l as Ge}from"./arrow-down.svg-Dhs0HydJ.js";import{p as Ce,U as E,V as L,ai as Jr,i as Ke,aj as et,H as O,ak as rt,al as tt,am as ze,e as nt,n as Ye,d as ke,an as ot,ao as T,D as st,C as it,$ as at,ap as lt,aq as ct,o as Ze}from"./vendor-ux-BX9dSNUy.js";import{N as dt}from"./list-Cj5o6_aJ.js";import{d as ut}from"./search-4YYphs0l.js";import{B as We}from"./bundle-avatar-CfVy3gda.js";import{h as Le,T as pt}from"./team-HgvOpVEJ.js";import{b as ft,d as ht,a as Ve,c as Qe,e as xt,f as mt,h as gt,$ as bt}from"./user-center-BODNsVgb.js";import{T as ge,O as yt}from"./index-Dn_bIjgF.js";import{c as vt}from"./passport-BcfDxGFq.js";import{N as Xe,U as Je}from"./index-CUIcSX4q.js";import{u as de}from"./use-mobile-Dwc30NoL.js";import wt from"./index-SH0LXIEm.js";import{U as jt,a as Ct}from"./user-follower-ODH9p68y.js";import{f as Z}from"./index-DBs9Ljax.js";import{S as er}from"./switch-C5K07M96.js";import{u as De}from"./index-BOiRUuPB.js";import kt from"./index-bb4s-8hu.js";import{o as St}from"./vendor-arcblock-D4Rvz_D3.js";import{c as Pt,b as ie,a as It,S as Tt}from"./index-DHn4LCaq.js";import"./index-C0q1NhNR.js";import"./index-BojVbZw0.js";import"./lottie-web-4koyQiv_.js";import"./server-logo-notext.svg-DHxZ1bRk.js";import"./util-DSnAozzs.js";import"./base32-E_M8YiDy.js";import"./session-DUT2afHJ.js";import"./isURL-wZZwzwyC.js";import"./use-app-logo-D9eQSUYq.js";import"./index-BIFlvVef.js";import"./revoke.svg-CuiCGfVW.js";import"./use-mobile-Vtj5nBdp.js";import"./actions-CiAs-6JM.js";import"./index-BjLM8Gon.js";import"./form-text-input-CbjI2VZQ.js";import"./required-B0Gua-D1.js";import"./form-wrapper-dz0PgYyA.js";import"./edit.svg-Dz9cVo7r.js";import"./lock.svg-BPCZ0CT3.js";import"./index-CmT6o_W4.js";import"./permission-BYxNrlaa.js";import"./confirm-BIsS5xyi.js";import"./click-to-copy-DXHOGoUP.js";import"./invitations-xEsO2f9m.js";import"./create-passport-svg-BwqsyTOz.js";import"./api-Cjc501Es.js";import"./table-tips-BA9A3QDk.js";import"./ua-parser-DP5omx3I.js";import"./sdk-Do4pV1s0.js";import"./passport-item-BnRaEMVZ.js";import"./did-address-Qmm0nyiR.js";import"./index-mgpYakv8.js";import"./vendor-mui-x-DtPl0qBm.js";import"./AdapterDayjs-p1MGZm94.js";import"./delete-confirm-DSQSBte5.js";import"./index-DRYJ0xIl.js";function Rt(){let r=new Map;function i({root:s,rootMargin:t,threshold:n}){let f=r.get(s);f||(f=new Map,r.set(s,f));let a=JSON.stringify({rootMargin:t,threshold:n}),p=f.get(a);if(!p){let l=new Map;p={observer:new IntersectionObserver(x=>{x.forEach(o=>{l.get(o.target)?.(o)})},{root:s,rootMargin:t,threshold:n}),entryCallbacks:l},f.set(a,p)}return{observe:(l,x)=>{p.entryCallbacks.set(l,x),p.observer.observe(l)},unobserve:l=>{p.entryCallbacks.delete(l),p.observer.unobserve(l)}}}return{getObserver:i}}var Mt="0px",At=[0],Et=Rt();function zt(r){let i=r?.rootMargin??Mt,s=r?.threshold??At,t=y.useRef(null),n=y.useRef(null),f=y.useRef(null),[a,p]=y.useState(),l=y.useCallback(()=>{let C=t.current;if(!C){p(void 0);return}let v=Et.getObserver({root:n.current,rootMargin:i,threshold:s});v.observe(C,d=>{p(d)}),f.current=v},[i,s]),x=y.useCallback(()=>{let C=f.current,v=t.current;v&&C?.unobserve(v),f.current=null},[]),o=y.useCallback(C=>{x(),t.current=C,l()},[l,x]),h=y.useCallback(C=>{x(),n.current=C,l()},[l,x]);return[o,{entry:a,rootRef:h}]}var Wt=zt;function Lt(r){let[i,s]=Wt(r),t=!!s.entry?.isIntersecting,[n,f]=y.useState(t);return t&&!n&&f(!0),[i,{...s,isVisible:t,wasEverVisible:n}]}var Dt=Lt,$t=100;function Bt({loading:r,hasNextPage:i,onLoadMore:s,rootMargin:t,disabled:n,delayInMs:f=$t}){let a=y.useRef(s),[p,{rootRef:l,isVisible:x}]=Dt({rootMargin:t});y.useEffect(()=>{a.current=s},[s]);let o=!n&&!r&&x&&i;return y.useEffect(()=>{if(o){let h=setTimeout(()=>{a.current()},f);return()=>{clearTimeout(h)}}},[o,f]),[p,{rootRef:l}]}var Ot=Bt;const me={info:"#3B82F6",success:"#10B981",warning:"#F59E0B",error:"#EF4444"};ae.propTypes={severity:u.oneOf(["info","success","warning","error",""]).isRequired,size:u.number};function ae({severity:r,size:i=8}){return me[r]?e.jsx(m,{component:"span",sx:{display:"inline-block",width:i,height:i,borderRadius:"50%",backgroundColor:me[r]||me.info}}):null}rr.propTypes={theme:u.string,type:u.oneOf(["button","line","select"]),onSelectType:u.func,extra:u.node,loading:u.bool,currentTab:u.oneOf(["info","success","warning","error",""])};function rr({theme:r="dark",type:i="button",onSelectType:s,extra:t=void 0,currentTab:n="",loading:f=!1,...a}){const{t:p}=y.useContext(Ce),l=[{label:p("notification.allSeverity"),value:""},{label:p("notification.severityType.info"),value:"info"},{label:p("notification.severityType.success"),value:"success"},{label:p("notification.severityType.warning"),value:"warning"},{label:p("notification.severityType.error"),value:"error"}],x=g=>{(g!==n||!f)&&s(g)},o=y.useMemo(()=>{const g={width:"100%",bgcolor:r==="dark"?"#F9FAFB":"",overflowY:"auto",paddingTop:i==="select"?"0":"5px",whiteSpace:"nowrap",borderRadius:0,display:"flex",justifyContent:"space-between",alignItems:"flex-end",flexWrap:"wrap",gap:"8px"};return i==="line"?Object.assign(g,{}):g},[i,r]),h=(g,j,S)=>e.jsx(G,{disabled:f,onClick:()=>x(g.value),className:`profile-button ${j?"active":""}`,...a,children:g.label},g.value||S),C=(g,j,S)=>e.jsx(G,{variant:"text",disabled:f,onClick:()=>x(g.value),className:`profile-line-button ${j?"active":""}`,...a,children:g.label},g.value||S),v=()=>l?.map((g,j)=>{const S=n===g?.value;return i==="line"?e.jsx(y.Fragment,{children:C(g,S,j)},g.value||j):e.jsx(y.Fragment,{children:h(g,S,j)},g.value||j)}),d=g=>{const{value:j}=g.target;x(j==="all"?"":j)};return i==="select"?e.jsx(yr,{sx:{maxWidth:300},children:e.jsx(ye,{value:n||"all",onChange:d,size:"small",label:"Severity",IconComponent:g=>e.jsx(Ge,{...g,width:20,height:20}),MenuProps:{autoFocus:!1,PaperProps:{style:{maxHeight:400,overflowY:"auto",borderRadius:"8px",boxShadow:"0px 6px 24px rgba(0, 0, 0, 0.15)"}}},variant:"outlined",sx:{fieldset:{border:"none"}},children:l.map((g,j)=>e.jsx(ne,{value:g.value||"all",children:e.jsxs(m,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(ae,{severity:g.value}),g.label]})},g.value||j))})}):e.jsxs(m,{className:"severity-tabs",sx:o,children:[e.jsx(m,{sx:{...i==="line"?{flex:1,borderBottom:"1px solid",borderColor:"grey.200"}:{display:"flex",gap:"24px"}},children:v()}),t]})}tr.propTypes={paging:u.objectOf(u.any).isRequired,loading:u.bool.isRequired,onChange:u.func.isRequired};function tr({loading:r,paging:i,onChange:s}){const{t}=y.useContext(Ce),n=ve(l=>l.breakpoints.down("md"));if(i.pageCount<=0||n)return null;const f=(l,x)=>{s({page:x+1})},a=l=>{const x=Number(l.target.value);s({page:1,pageSize:x})},p=i.page-1<=0?0:i.page-1;return e.jsx(m,{className:"notification-pagination",sx:{mt:2,display:"flex",justifyContent:"flex-end"},children:e.jsx(vr,{component:"div",disabled:r,count:i.total,page:p,rowsPerPageOptions:[10,20,50,100],labelRowsPerPage:t("pagination.rowsPerPage"),labelDisplayedRows:({from:l,to:x,count:o})=>`${l}–${x} / ${o!==-1?o:`${t()}more than ${x}`}`,rowsPerPage:i.pageSize,onPageChange:f,onRowsPerPageChange:a})})}const Nt=y.memo(tr),Ut={width:24,height:24,body:'<path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 4h16v2.172a2 2 0 0 1-.586 1.414L15 12v7l-6 2v-8.5L4.52 7.572A2 2 0 0 1 4 6.227V4z"/>'},$e=6,Be={"& .MuiCheckbox-root":{padding:"4px"},"& .MuiCheckbox-root .MuiSvgIcon-root":{fontSize:"1.35rem"},"& .MuiCheckbox-root:not(.Mui-checked)":{color:"divider"},"& .MuiCheckbox-root.Mui-checked":{color:"primary.main"},"& .MuiCheckbox-root .css-i4bv87-MuiSvgIcon-root":{width:"1.1em",height:"1.1em"},"& .MuiCheckbox-root svg":{stroke:"divider",strokeWidth:.7}},Ft={border:"1px solid",borderColor:"divider",borderRadius:1,overflow:"hidden",backgroundColor:"background.paper",backgroundImage:"none",transition:"all 0.2s ease-in-out"},Oe=()=>({...Ft,width:"calc(50% - 8px)"});nr.propTypes={loading:u.bool,type:u.oneOf(["server","service"]),onFilterChange:u.func,blockletMap:u.object,filterType:u.oneOf(["component","entity"]),selectedId:u.array,severity:u.array,enableMarkAllAsRead:u.bool,unReadCount:u.number,onReadFilterChange:u.func,currentReadFilter:u.string};function nr({onFilterChange:r=()=>{},loading:i=!1,type:s="service",blockletMap:t={},filterType:n="component",selectedId:f=[],severity:a=[],enableMarkAllAsRead:p=!0,unReadCount:l=0,onReadFilterChange:x=()=>{},currentReadFilter:o="all"}){const{t:h}=y.useContext(Ce),[C,v]=y.useState(null),d=!!C,[g,j]=y.useState(f),[S,D]=y.useState(a),[b,k]=y.useState(!1),[P,_]=y.useState(""),[$,N]=y.useState([]);y.useEffect(()=>{j(f),D(a)},[f,a]);const U=[{label:h("notification.filterType.all"),value:"all"},{label:h("notification.filterType.unread"),value:"unread"}],X=c=>{(c!==o||!i)&&x(c)},K=[{label:h("notification.severityType.info"),value:"info"},{label:h("notification.severityType.success"),value:"success"},{label:h("notification.severityType.warning"),value:"warning"},{label:h("notification.severityType.error"),value:"error"}],J=c=>{v(c.currentTarget),_(""),k(!1)},pe=()=>{v(null)},ee=c=>{const w=g.includes(c)?g.filter(I=>I!==c):[...g,c];j(w),r({id:w,severity:S})},re=c=>{const w=S.includes(c)?S.filter(I=>I!==c):[...S,c];D(w),r({severity:w,id:g})},fe=c=>{_(c.target.value)},he=()=>{k(!b)},q=Wr.useMemo(()=>{if(!t.size)return[];const c=[];return n==="component"&&c.push({label:h("notification.system"),id:"system"}),Array.from(t).forEach(([,w])=>{const I=w.did||w.meta?.did,z=w.title||w.meta?.title||"",B=w.appPid||w.appDid;(n==="component"&&B!==I||n==="entity"&&B===I)&&c.push({label:z,id:I,blocklet:w,ancestors:w.ancestors})}),c},[t,n,h]);y.useEffect(()=>{if(P.trim()==="")N(q);else{const c=P.toLowerCase(),w=q.filter(I=>I.label.toLowerCase().includes(c));N(w)}},[P,q]);const xe=P.trim()!==""||b?$:$.slice(0,$e);return e.jsxs(m,{children:[e.jsxs(m,{sx:{display:"flex",justifyContent:p?"space-between":"flex-end",alignItems:"flex-start",flexWrap:"wrap",gap:1},children:[p&&e.jsx(m,{sx:{display:"flex",gap:1.5},children:U.map(c=>e.jsxs(G,{disabled:i,onClick:()=>X(c.value),className:`profile-button ${o===c.value?"active":""}`,sx:{...s==="service"&&o===c.value?{color:"secondary.main"}:{},color:"red",fontWeight:o===c.value?"bold":"normal"},children:[c.label,c.value==="unread"&&l>0&&` (${l})`]},c.value))}),e.jsxs(m,{sx:{display:"flex",justifyContent:"flex-end",gap:2},children:[e.jsx(W,{size:"small",onClick:J,disabled:i,sx:{minWidth:"auto",borderRadius:1,border:"1px solid",borderColor:"divider","&:hover":{backgroundColor:"action.hover"}},children:e.jsx(E,{icon:Ut,hFlip:!0})}),e.jsx(wr,{open:d,anchorEl:C,onClose:pe,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},slotProps:{paper:{sx:{p:3,width:450,maxHeight:500,overflowY:"auto",backgroundColor:"background.paper",backgroundImage:"none",borderRadius:1,boxShadow:"0px 6px 24px rgba(0, 0, 0, 0.15)"}}},children:e.jsxs(m,{children:[e.jsxs(m,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:2,height:"28px"},children:[e.jsx(A,{variant:"subtitle1",sx:{fontWeight:"bold"},children:h("notification.severity")}),e.jsx(m,{sx:{minWidth:"60px",display:"flex",justifyContent:"flex-end"},children:(g.length>0||S.length>0)&&e.jsx(G,{size:"small",onClick:()=>{j([]),D([]),r({severity:[],id:[]})},startIcon:e.jsx(jr,{fontSize:"small"}),sx:{color:"text.secondary",textTransform:"none",minWidth:"auto","&:hover":{backgroundColor:"transparent"},"& .MuiButton-startIcon":{marginRight:"2px"}},children:h("notification.clear")})})]}),e.jsx(m,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:3},children:e.jsx(Pe,{sx:{display:"flex",flexDirection:"row",flexWrap:"wrap",gap:2,flex:1},children:K.map(c=>e.jsx(Ie,{elevation:0,sx:Oe(S.includes(c.value)),children:e.jsx(Te,{sx:{margin:0,padding:.5,width:"100%","& .MuiFormControlLabel-label":{display:"flex",alignItems:"center",gap:1,fontSize:"0.875rem"},...Be},control:e.jsx(Re,{checked:S.includes(c.value),onChange:()=>re(c.value),disabled:i,size:"small"}),label:e.jsxs(m,{sx:{display:"flex",alignItems:"center",justifyContent:"flex-start",gap:.5},children:[e.jsx(ae,{severity:c.value}),c.label]})})},c.value))})}),e.jsxs(m,{sx:{mb:2},children:[e.jsxs(m,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:2,mb:1.5},children:[e.jsx(A,{variant:"subtitle1",sx:{fontWeight:"bold",width:"calc(100% - 36px)"},children:h("notification.from")}),e.jsx(m,{sx:{display:"flex",alignItems:"center",width:"calc(100% - 36px)"},children:e.jsx(Ue,{size:"small",placeholder:"search",value:P,onChange:fe,sx:{width:"100%","& .MuiOutlinedInput-input":{padding:"6px 4px 6px 0"},".MuiOutlinedInput-root":{"&:hover":{fieldset:{borderColor:"divider"}},"&.Mui-focused":{fieldset:{borderColor:"divider"}}},fieldset:{borderColor:"divider"}},slotProps:{input:{size:"small",startAdornment:e.jsx(Fe,{position:"start",sx:{marginRight:"2px"},children:e.jsx(E,{icon:ut})})}}})})]}),e.jsx(Pe,{sx:{display:"flex",flexDirection:"row",flexWrap:"wrap",gap:2},children:xe.map(c=>e.jsx(Ie,{elevation:0,sx:Oe(g.includes(c.id)),children:e.jsx(Te,{sx:{margin:0,padding:.5,width:"100%","& .MuiFormControlLabel-label":{fontSize:"0.875rem",width:"calc(100% - 36px)"},...Be},control:e.jsx(Re,{checked:g.includes(c.id),onChange:()=>ee(c.id),disabled:i,size:"small"}),label:e.jsxs(m,{sx:{display:"flex",alignItems:"center",justifyContent:"flex-start",gap:.5,minWidth:0,width:"100%"},children:[c.blocklet&&e.jsx(We,{size:20,blocklet:c.blocklet,ancestors:c.ancestors,style:{borderRadius:4,flexShrink:0}}),e.jsx(A,{noWrap:!0,variant:"body2",component:"span",title:c.label,sx:{flex:1,overflow:"hidden",textOverflow:"ellipsis",maxWidth:"100%"},children:c.label})]})})},c.id))}),$.length>$e&&P.trim()===""&&e.jsx(G,{fullWidth:!0,size:"small",onClick:he,sx:{mt:1},endIcon:b?e.jsx(Cr,{}):e.jsx(kr,{})})]})]})})]})]}),g.length>0||S.length>0?e.jsxs(m,{className:"notification-filter-content",sx:{display:"flex",flexWrap:"wrap",gap:1,mt:2},children:[S.map(c=>{const w=K.find(I=>I.value===c);return e.jsx(Me,{label:e.jsxs(m,{sx:{display:"flex",alignItems:"center",gap:.5},children:[e.jsx(ae,{severity:c}),w?w.label:c]}),onDelete:()=>re(c),size:"small",variant:"outlined",sx:{borderRadius:2,color:"text.secondary",borderColor:"divider","& .MuiChip-label":{display:"flex",alignItems:"center"}}},`severity-${c}`)}),g.map(c=>{const w=q.find(I=>I.id===c);return e.jsx(Me,{label:e.jsxs(m,{sx:{display:"flex",alignItems:"center",gap:.5},children:[w?.blocklet&&e.jsx(We,{size:16,blocklet:w.blocklet,ancestors:w.ancestors,style:{borderRadius:4,flexShrink:0}}),w?w.label:c]}),variant:"outlined",onDelete:()=>ee(c),size:"small",sx:{borderRadius:2,color:"text.secondary",borderColor:"divider","& .MuiChip-label":{display:"flex",alignItems:"center"}}},`component-${c}`)})]}):null]})}const _t=V(Ir)`
1
+ import{j as e,y as yr,bZ as ye,M as ne,ak as m,Q as G,W as u,J as ve,b_ as vr,I as W,aN as wr,T as A,aj as jr,b$ as Pe,P as Ie,bX as Te,a5 as Re,z as Ue,A as Fe,c0 as Cr,b0 as kr,U as Me,b3 as Sr,c1 as Pr,at as V,c2 as Ir,a6 as Y,n as oe,D as Tr,c3 as Rr,ar as Ae,b6 as we,c4 as Mr,aZ as Ar,bb as Er,bj as zr}from"./vendor-mui-core-DnR6WYuU.js";import{r as y,a as Wr,j as Dr,m as Lr}from"./vendor-react-CTtPmzVP.js";import{t as _e,I as Br,O as Or,a4 as Ee,D as $r,C as se,n as H,A as Nr}from"./vendor-utils-D5UG1a5Y.js";import{u as Ur,ay as Fr,az as _r,c as je,aA as qr,h as Hr,aB as qe,aC as Gr,aD as He,a3 as le,aE as Kr,aF as Yr,af as Zr,aG as Vr}from"./index-DwyzCfdd.js";import{a as R,h as Qr,q as ce,g as Q,b as M,l as Jr}from"./vendor-hooks-BZ19vVZ7.js";import{l as Ge}from"./arrow-down.svg-C4FUKwt4.js";import{b2 as Ce,N as E,V as D,b6 as Xr,aY as Ke,b7 as et,Q as $,aj as rt,aE as tt,b8 as ze,a0 as nt,J as Ye,ak as ke,a7 as ot,at as T,a5 as st,a6 as it,$ as at,b9 as lt,ba as ct,a2 as Ze}from"./vendor-ux-DMZIE6wA.js";import{N as dt}from"./list-YOpLH3o0.js";import{d as ut}from"./search-4YYphs0l.js";import{B as We}from"./bundle-avatar-B1jZNqcH.js";import{c as De,T as pt}from"./team-BWkxYdcc.js";import{b as ft,d as ht,a as Ve,c as Qe,e as xt,f as mt,h as gt,$ as bt}from"./user-center-CL_lKzgJ.js";import{T as ge,O as yt}from"./index-WT6M-zj8.js";import{c as vt}from"./passport-Dg1YWagy.js";import{N as Je,U as Xe}from"./index-DACtt7qd.js";import{u as de}from"./use-mobile-D5clNlrm.js";import wt from"./index-D-a8pZtp.js";import{U as jt,a as Ct}from"./user-follower-CfiG4RXf.js";import{f as Z}from"./index-DBs9Ljax.js";import{S as er}from"./switch-rIcJ7tho.js";import{u as Le}from"./index-D24LKXzO.js";import kt from"./index-oS8X43Pb.js";import{o as St}from"./vendor-arcblock-DkdOhPyM.js";import{D as Pt,a as ie,b as It,S as Tt}from"./index-OMkyTUNX.js";import"./index-D29her4n.js";import"./index-BojVbZw0.js";import"./lottie-web-4koyQiv_.js";import"./server-logo-notext.svg-xZ-i1SpD.js";import"./util-C9cWBCZz.js";import"./base32-B-7CnEFd.js";import"./session-Des-0R_y.js";import"./isURL-ZFgr0DWl.js";import"./use-app-logo-BAGvxEU-.js";import"./index-C-vVEZcs.js";import"./revoke.svg-CNl4LAbv.js";import"./use-mobile-BINJTzMb.js";import"./actions-Dfiiwkit.js";import"./index-CaTDaKrX.js";import"./form-text-input-B_h8beXh.js";import"./required-BQln5OcV.js";import"./form-wrapper-PT5ZzMQy.js";import"./edit.svg-RRSklUg-.js";import"./lock.svg-BgybwZNe.js";import"./index-Bf3Peb0q.js";import"./permission-C0bmOzVj.js";import"./confirm-Bpit6U3-.js";import"./click-to-copy-CwdgHxjB.js";import"./invitations-Dil5QWBY.js";import"./create-passport-svg-DGPNsGUE.js";import"./api-C75sLx9p.js";import"./table-tips-Ba9Kf02z.js";import"./ua-parser-DP5omx3I.js";import"./sdk-YVE2MSze.js";import"./passport-item-QbgyHapR.js";import"./did-address-uvYuZ4wv.js";import"./index-LaMi0T4w.js";import"./vendor-mui-x-CQc01l4r.js";import"./AdapterDayjs-Bfr4sW4C.js";import"./delete-confirm-L0HXJtqt.js";import"./index-DRYJ0xIl.js";function Rt(){let r=new Map;function i({root:s,rootMargin:t,threshold:n}){let f=r.get(s);f||(f=new Map,r.set(s,f));let a=JSON.stringify({rootMargin:t,threshold:n}),p=f.get(a);if(!p){let l=new Map;p={observer:new IntersectionObserver(x=>{x.forEach(o=>{l.get(o.target)?.(o)})},{root:s,rootMargin:t,threshold:n}),entryCallbacks:l},f.set(a,p)}return{observe:(l,x)=>{p.entryCallbacks.set(l,x),p.observer.observe(l)},unobserve:l=>{p.entryCallbacks.delete(l),p.observer.unobserve(l)}}}return{getObserver:i}}var Mt="0px",At=[0],Et=Rt();function zt(r){let i=r?.rootMargin??Mt,s=r?.threshold??At,t=y.useRef(null),n=y.useRef(null),f=y.useRef(null),[a,p]=y.useState(),l=y.useCallback(()=>{let C=t.current;if(!C){p(void 0);return}let v=Et.getObserver({root:n.current,rootMargin:i,threshold:s});v.observe(C,d=>{p(d)}),f.current=v},[i,s]),x=y.useCallback(()=>{let C=f.current,v=t.current;v&&C?.unobserve(v),f.current=null},[]),o=y.useCallback(C=>{x(),t.current=C,l()},[l,x]),h=y.useCallback(C=>{x(),n.current=C,l()},[l,x]);return[o,{entry:a,rootRef:h}]}var Wt=zt;function Dt(r){let[i,s]=Wt(r),t=!!s.entry?.isIntersecting,[n,f]=y.useState(t);return t&&!n&&f(!0),[i,{...s,isVisible:t,wasEverVisible:n}]}var Lt=Dt,Bt=100;function Ot({loading:r,hasNextPage:i,onLoadMore:s,rootMargin:t,disabled:n,delayInMs:f=Bt}){let a=y.useRef(s),[p,{rootRef:l,isVisible:x}]=Lt({rootMargin:t});y.useEffect(()=>{a.current=s},[s]);let o=!n&&!r&&x&&i;return y.useEffect(()=>{if(o){let h=setTimeout(()=>{a.current()},f);return()=>{clearTimeout(h)}}},[o,f]),[p,{rootRef:l}]}var $t=Ot;const me={info:"#3B82F6",success:"#10B981",warning:"#F59E0B",error:"#EF4444"};ae.propTypes={severity:u.oneOf(["info","success","warning","error",""]).isRequired,size:u.number};function ae({severity:r,size:i=8}){return me[r]?e.jsx(m,{component:"span",sx:{display:"inline-block",width:i,height:i,borderRadius:"50%",backgroundColor:me[r]||me.info}}):null}rr.propTypes={theme:u.string,type:u.oneOf(["button","line","select"]),onSelectType:u.func,extra:u.node,loading:u.bool,currentTab:u.oneOf(["info","success","warning","error",""])};function rr({theme:r="dark",type:i="button",onSelectType:s,extra:t=void 0,currentTab:n="",loading:f=!1,...a}){const{t:p}=y.useContext(Ce),l=[{label:p("notification.allSeverity"),value:""},{label:p("notification.severityType.info"),value:"info"},{label:p("notification.severityType.success"),value:"success"},{label:p("notification.severityType.warning"),value:"warning"},{label:p("notification.severityType.error"),value:"error"}],x=g=>{(g!==n||!f)&&s(g)},o=y.useMemo(()=>{const g={width:"100%",bgcolor:r==="dark"?"#F9FAFB":"",overflowY:"auto",paddingTop:i==="select"?"0":"5px",whiteSpace:"nowrap",borderRadius:0,display:"flex",justifyContent:"space-between",alignItems:"flex-end",flexWrap:"wrap",gap:"8px"};return i==="line"?Object.assign(g,{}):g},[i,r]),h=(g,j,S)=>e.jsx(G,{disabled:f,onClick:()=>x(g.value),className:`profile-button ${j?"active":""}`,...a,children:g.label},g.value||S),C=(g,j,S)=>e.jsx(G,{variant:"text",disabled:f,onClick:()=>x(g.value),className:`profile-line-button ${j?"active":""}`,...a,children:g.label},g.value||S),v=()=>l?.map((g,j)=>{const S=n===g?.value;return i==="line"?e.jsx(y.Fragment,{children:C(g,S,j)},g.value||j):e.jsx(y.Fragment,{children:h(g,S,j)},g.value||j)}),d=g=>{const{value:j}=g.target;x(j==="all"?"":j)};return i==="select"?e.jsx(yr,{sx:{maxWidth:300},children:e.jsx(ye,{value:n||"all",onChange:d,size:"small",label:"Severity",IconComponent:g=>e.jsx(Ge,{...g,width:20,height:20}),MenuProps:{autoFocus:!1,PaperProps:{style:{maxHeight:400,overflowY:"auto",borderRadius:"8px",boxShadow:"0px 6px 24px rgba(0, 0, 0, 0.15)"}}},variant:"outlined",sx:{fieldset:{border:"none"}},children:l.map((g,j)=>e.jsx(ne,{value:g.value||"all",children:e.jsxs(m,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(ae,{severity:g.value}),g.label]})},g.value||j))})}):e.jsxs(m,{className:"severity-tabs",sx:o,children:[e.jsx(m,{sx:{...i==="line"?{flex:1,borderBottom:"1px solid",borderColor:"grey.200"}:{display:"flex",gap:"24px"}},children:v()}),t]})}tr.propTypes={paging:u.objectOf(u.any).isRequired,loading:u.bool.isRequired,onChange:u.func.isRequired};function tr({loading:r,paging:i,onChange:s}){const{t}=y.useContext(Ce),n=ve(l=>l.breakpoints.down("md"));if(i.pageCount<=0||n)return null;const f=(l,x)=>{s({page:x+1})},a=l=>{const x=Number(l.target.value);s({page:1,pageSize:x})},p=i.page-1<=0?0:i.page-1;return e.jsx(m,{className:"notification-pagination",sx:{mt:2,display:"flex",justifyContent:"flex-end"},children:e.jsx(vr,{component:"div",disabled:r,count:i.total,page:p,rowsPerPageOptions:[10,20,50,100],labelRowsPerPage:t("pagination.rowsPerPage"),labelDisplayedRows:({from:l,to:x,count:o})=>`${l}–${x} / ${o!==-1?o:`${t()}more than ${x}`}`,rowsPerPage:i.pageSize,onPageChange:f,onRowsPerPageChange:a})})}const Nt=y.memo(tr),Ut={width:24,height:24,body:'<path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 4h16v2.172a2 2 0 0 1-.586 1.414L15 12v7l-6 2v-8.5L4.52 7.572A2 2 0 0 1 4 6.227V4z"/>'},Be=6,Oe={"& .MuiCheckbox-root":{padding:"4px"},"& .MuiCheckbox-root .MuiSvgIcon-root":{fontSize:"1.35rem"},"& .MuiCheckbox-root:not(.Mui-checked)":{color:"divider"},"& .MuiCheckbox-root.Mui-checked":{color:"primary.main"},"& .MuiCheckbox-root .css-i4bv87-MuiSvgIcon-root":{width:"1.1em",height:"1.1em"},"& .MuiCheckbox-root svg":{stroke:"divider",strokeWidth:.7}},Ft={border:"1px solid",borderColor:"divider",borderRadius:1,overflow:"hidden",backgroundColor:"background.paper",backgroundImage:"none",transition:"all 0.2s ease-in-out"},$e=()=>({...Ft,width:"calc(50% - 8px)"});nr.propTypes={loading:u.bool,type:u.oneOf(["server","service"]),onFilterChange:u.func,blockletMap:u.object,filterType:u.oneOf(["component","entity"]),selectedId:u.array,severity:u.array,enableMarkAllAsRead:u.bool,unReadCount:u.number,onReadFilterChange:u.func,currentReadFilter:u.string};function nr({onFilterChange:r=()=>{},loading:i=!1,type:s="service",blockletMap:t={},filterType:n="component",selectedId:f=[],severity:a=[],enableMarkAllAsRead:p=!0,unReadCount:l=0,onReadFilterChange:x=()=>{},currentReadFilter:o="all"}){const{t:h}=y.useContext(Ce),[C,v]=y.useState(null),d=!!C,[g,j]=y.useState(f),[S,L]=y.useState(a),[b,k]=y.useState(!1),[P,_]=y.useState(""),[B,N]=y.useState([]);y.useEffect(()=>{j(f),L(a)},[f,a]);const U=[{label:h("notification.filterType.all"),value:"all"},{label:h("notification.filterType.unread"),value:"unread"}],J=c=>{(c!==o||!i)&&x(c)},K=[{label:h("notification.severityType.info"),value:"info"},{label:h("notification.severityType.success"),value:"success"},{label:h("notification.severityType.warning"),value:"warning"},{label:h("notification.severityType.error"),value:"error"}],X=c=>{v(c.currentTarget),_(""),k(!1)},pe=()=>{v(null)},ee=c=>{const w=g.includes(c)?g.filter(I=>I!==c):[...g,c];j(w),r({id:w,severity:S})},re=c=>{const w=S.includes(c)?S.filter(I=>I!==c):[...S,c];L(w),r({severity:w,id:g})},fe=c=>{_(c.target.value)},he=()=>{k(!b)},q=Wr.useMemo(()=>{if(!t.size)return[];const c=[];return n==="component"&&c.push({label:h("notification.system"),id:"system"}),Array.from(t).forEach(([,w])=>{const I=w.did||w.meta?.did,z=w.title||w.meta?.title||"",O=w.appPid||w.appDid;(n==="component"&&O!==I||n==="entity"&&O===I)&&c.push({label:z,id:I,blocklet:w,ancestors:w.ancestors})}),c},[t,n,h]);y.useEffect(()=>{if(P.trim()==="")N(q);else{const c=P.toLowerCase(),w=q.filter(I=>I.label.toLowerCase().includes(c));N(w)}},[P,q]);const xe=P.trim()!==""||b?B:B.slice(0,Be);return e.jsxs(m,{children:[e.jsxs(m,{sx:{display:"flex",justifyContent:p?"space-between":"flex-end",alignItems:"flex-start",flexWrap:"wrap",gap:1},children:[p&&e.jsx(m,{sx:{display:"flex",gap:1.5},children:U.map(c=>e.jsxs(G,{disabled:i,onClick:()=>J(c.value),className:`profile-button ${o===c.value?"active":""}`,sx:{...s==="service"&&o===c.value?{color:"secondary.main"}:{},color:"red",fontWeight:o===c.value?"bold":"normal"},children:[c.label,c.value==="unread"&&l>0&&` (${l})`]},c.value))}),e.jsxs(m,{sx:{display:"flex",justifyContent:"flex-end",gap:2},children:[e.jsx(W,{size:"small",onClick:X,disabled:i,sx:{minWidth:"auto",borderRadius:1,border:"1px solid",borderColor:"divider","&:hover":{backgroundColor:"action.hover"}},children:e.jsx(E,{icon:Ut,hFlip:!0})}),e.jsx(wr,{open:d,anchorEl:C,onClose:pe,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},slotProps:{paper:{sx:{p:3,width:450,maxHeight:500,overflowY:"auto",backgroundColor:"background.paper",backgroundImage:"none",borderRadius:1,boxShadow:"0px 6px 24px rgba(0, 0, 0, 0.15)"}}},children:e.jsxs(m,{children:[e.jsxs(m,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:2,height:"28px"},children:[e.jsx(A,{variant:"subtitle1",sx:{fontWeight:"bold"},children:h("notification.severity")}),e.jsx(m,{sx:{minWidth:"60px",display:"flex",justifyContent:"flex-end"},children:(g.length>0||S.length>0)&&e.jsx(G,{size:"small",onClick:()=>{j([]),L([]),r({severity:[],id:[]})},startIcon:e.jsx(jr,{fontSize:"small"}),sx:{color:"text.secondary",textTransform:"none",minWidth:"auto","&:hover":{backgroundColor:"transparent"},"& .MuiButton-startIcon":{marginRight:"2px"}},children:h("notification.clear")})})]}),e.jsx(m,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:3},children:e.jsx(Pe,{sx:{display:"flex",flexDirection:"row",flexWrap:"wrap",gap:2,flex:1},children:K.map(c=>e.jsx(Ie,{elevation:0,sx:$e(S.includes(c.value)),children:e.jsx(Te,{sx:{margin:0,padding:.5,width:"100%","& .MuiFormControlLabel-label":{display:"flex",alignItems:"center",gap:1,fontSize:"0.875rem"},...Oe},control:e.jsx(Re,{checked:S.includes(c.value),onChange:()=>re(c.value),disabled:i,size:"small"}),label:e.jsxs(m,{sx:{display:"flex",alignItems:"center",justifyContent:"flex-start",gap:.5},children:[e.jsx(ae,{severity:c.value}),c.label]})})},c.value))})}),e.jsxs(m,{sx:{mb:2},children:[e.jsxs(m,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:2,mb:1.5},children:[e.jsx(A,{variant:"subtitle1",sx:{fontWeight:"bold",width:"calc(100% - 36px)"},children:h("notification.from")}),e.jsx(m,{sx:{display:"flex",alignItems:"center",width:"calc(100% - 36px)"},children:e.jsx(Ue,{size:"small",placeholder:"search",value:P,onChange:fe,sx:{width:"100%","& .MuiOutlinedInput-input":{padding:"6px 4px 6px 0"},".MuiOutlinedInput-root":{"&:hover":{fieldset:{borderColor:"divider"}},"&.Mui-focused":{fieldset:{borderColor:"divider"}}},fieldset:{borderColor:"divider"}},slotProps:{input:{size:"small",startAdornment:e.jsx(Fe,{position:"start",sx:{marginRight:"2px"},children:e.jsx(E,{icon:ut})})}}})})]}),e.jsx(Pe,{sx:{display:"flex",flexDirection:"row",flexWrap:"wrap",gap:2},children:xe.map(c=>e.jsx(Ie,{elevation:0,sx:$e(g.includes(c.id)),children:e.jsx(Te,{sx:{margin:0,padding:.5,width:"100%","& .MuiFormControlLabel-label":{fontSize:"0.875rem",width:"calc(100% - 36px)"},...Oe},control:e.jsx(Re,{checked:g.includes(c.id),onChange:()=>ee(c.id),disabled:i,size:"small"}),label:e.jsxs(m,{sx:{display:"flex",alignItems:"center",justifyContent:"flex-start",gap:.5,minWidth:0,width:"100%"},children:[c.blocklet&&e.jsx(We,{size:20,blocklet:c.blocklet,ancestors:c.ancestors,style:{borderRadius:4,flexShrink:0}}),e.jsx(A,{noWrap:!0,variant:"body2",component:"span",title:c.label,sx:{flex:1,overflow:"hidden",textOverflow:"ellipsis",maxWidth:"100%"},children:c.label})]})})},c.id))}),B.length>Be&&P.trim()===""&&e.jsx(G,{fullWidth:!0,size:"small",onClick:he,sx:{mt:1},endIcon:b?e.jsx(Cr,{}):e.jsx(kr,{})})]})]})})]})]}),g.length>0||S.length>0?e.jsxs(m,{className:"notification-filter-content",sx:{display:"flex",flexWrap:"wrap",gap:1,mt:2},children:[S.map(c=>{const w=K.find(I=>I.value===c);return e.jsx(Me,{label:e.jsxs(m,{sx:{display:"flex",alignItems:"center",gap:.5},children:[e.jsx(ae,{severity:c}),w?w.label:c]}),onDelete:()=>re(c),size:"small",variant:"outlined",sx:{borderRadius:2,color:"text.secondary",borderColor:"divider","& .MuiChip-label":{display:"flex",alignItems:"center"}}},`severity-${c}`)}),g.map(c=>{const w=q.find(I=>I.id===c);return e.jsx(Me,{label:e.jsxs(m,{sx:{display:"flex",alignItems:"center",gap:.5},children:[w?.blocklet&&e.jsx(We,{size:16,blocklet:w.blocklet,ancestors:w.ancestors,style:{borderRadius:4,flexShrink:0}}),w?w.label:c]}),variant:"outlined",onDelete:()=>ee(c),size:"small",sx:{borderRadius:2,color:"text.secondary",borderColor:"divider","& .MuiChip-label":{display:"flex",alignItems:"center"}}},`component-${c}`)})]}):null]})}const _t=V(Ir)`
2
2
  position: fixed;
3
3
  bottom: 20px;
4
4
  right: 20px;
@@ -73,7 +73,7 @@ import{j as e,y as yr,bc as ye,M as ne,ak as m,Q as G,W as u,J as ve,c1 as vr,I
73
73
  *::-webkit-scrollbar {
74
74
  display: none; /* Chrome, Safari and Opera */
75
75
  }
76
- `;or.propTypes={blocklets:u.array,context:u.object,pagination:u.bool,inDialog:u.bool,filterType:u.oneOf(["component","entity"]),toViewAll:u.func,type:u.oneOf(["server","service"])};function or({blocklets:r=[],context:i,pagination:s=!0,inDialog:t=!1,filterType:n="component",toViewAll:f=()=>{},type:a="service"}){const{data:p,paging:l,refresh:x,loading:o,params:h,onReadNotification:C,componentDids:v,filterUnReadCount:d,initial:g}=i,j=c=>{x({...h,severity:c&&typeof c=="string"?[c]:c||[],paging:{...h.paging,page:1}})},[S]=Lr(),D=R(()=>S.get("id"),[S]),b=ve(c=>c.breakpoints.down("md")),[k,P]=y.useState(0),[_,$]=y.useState(!1),N=y.useMemo(()=>h.read===!1?"unread":"all",[h.read]),U=R(()=>_e(c=>{if(o)return;const w=p.length,I=p.filter(B=>!Le(B)).length;let z={...h,append:!0,paging:{...h.paging,...c,currentPage:(l.currentPage||0)+1}};N==="unread"&&I<w&&c.page>h.paging.page&&(z={...h,append:!0,paging:{...h.paging,...c,page:h.paging.page||1,currentPage:(l.currentPage||0)+1}}),x(z)},500),[p,h,N,l,o,x]);Qr(()=>{g&&typeof g=="function"&&g()}),y.useEffect(()=>{(!l.currentPage||l.currentPage===1)&&P(l.total)},[l.total,l.currentPage]),y.useEffect(()=>{setTimeout(()=>{const c=document.getElementById(D);c&&c.scrollIntoView({behavior:"smooth",block:"center"}),$(!0)},100),setTimeout(()=>{$(!1)},3e3)},[D]);const X=R(()=>p?.length>0&&p.length<k,[p,k]),K=y.useCallback(c=>{const{blocklet:w={}}=window,I=[w?.did,...(w?.ancestors||[]).map(z=>z)];return v?.includes(c)||I.findIndex(z=>z===c)>-1},[v]),J=y.useMemo(()=>{const c=new Map;return r.length&&r.forEach(w=>{const I=w?.did||w.meta?.did;I&&!c.has(I)&&(w.ancestors=[],c.set(I,w),w?.alsoKnownAs?.length>0&&w.alsoKnownAs.forEach(z=>{c.has(z)||c.set(z,w)})),w?.children?.length>0&&w.children.forEach(z=>{const B=z?.did||z.meta?.did;B&&!c.has(B)&&K(B)&&(z.ancestors=[w],c.set(B,z))})}),c},[r,K]),pe=y.useCallback(()=>{o||U({page:l.page+1})},[l.page,o,U]),[ee]=Ot({loading:o,hasNextPage:X,onLoadMore:pe}),re=c=>{!c||Le(c)||C(c.id).then(()=>{t&&f()})},fe=({severity:c,id:w})=>{if(o)return;let I={};n==="component"?I={entityId:[],componentDid:w}:n==="entity"&&(I={componentDid:[],entityId:w}),x({...h,severity:c,...I,paging:{...h.paging,page:1}})},he=c=>{if(o)return;let w={...h,paging:{...h.paging,page:1}};c==="unread"?(w.read=!1,w.paging.currentPage=1):w=$r(w,"read"),x(w)},q=R(()=>n==="component"?Array.isArray(h.componentDid)?h.componentDid:[]:n==="entity"?Array.isArray(h.entityId)?h.entityId:[]:[],[h,n]),xe=R(()=>(Array.isArray(h.severity)?h.severity:[])[0]||"",[h.severity]);return e.jsxs(Ht,{inDialog:!!t,children:[t?e.jsx(rr,{currentTab:xe,type:"line",theme:"light",onSelectType:j}):e.jsx(nr,{loading:o,blockletMap:J,unReadCount:d,filterType:n,type:a,selectedId:q,onFilterChange:fe,severity:h.severity,onReadFilterChange:he,currentReadFilter:N}),!b&&o?e.jsx(m,{sx:{display:"flex",width:"100%",minHeight:400,justifyContent:"center",alignItems:"center"},children:e.jsx(Y,{})}):e.jsx(dt,{data:p,blockletMap:J,onReadNotification:re,onReadBatch:C,inDialog:t,highlightId:D,highlight:!t&&_,type:a}),s&&!b?e.jsx(Nt,{loading:o,paging:l,onChange:U}):null,s&&b&&(o||X)?e.jsx(m,{ref:ee,sx:{display:"flex",width:"100%",minHeight:100,justifyContent:"center",alignItems:"center"},children:e.jsx(Y,{})}):null,!t&&b?e.jsx(qt,{}):null]})}const Gt=y.memo(or),F=new _r;function ue(r){const{userDid:i=""}={},{session:s}=Ur(),t=R(()=>{if(i)return i;const l=window.location.href,x=Br(l);return x?.did?Array.isArray(x.did)?x.did[0]:x.did:s?.user?.did},[s?.user?.did,i]),n=R(()=>s.user,[s]),f=R(()=>n?t===n?.did:!1,[t,n?.did]),a=ce(async()=>{if(await Fr(()=>s?.initialized),f)return s.user;if(t)return F.user.getUserPublicInfo({did:t})},{refreshDeps:[t,f,s?.initialized,n]}),p=R(()=>n?.passports?.some(l=>l.role===je.ROLES.OWNER),[n]);return{currentDid:t,session:s,isMyself:f,user:n,viewUser:a.data,isOwner:p}}function sr({user:r,...i}){const{t:s}=L(),t=Tr(),n=R(()=>{const p=(r?.passports||[]).map(l=>({...l,revoked:l.status===Jr.REVOKED}));return p.sort((l,x)=>l.revoked===x.revoked?0:l.revoked?1:-1),Ee(p.filter(l=>!l.display),"role").concat(Ee(p.filter(l=>l.display),"display.content"))},[r?.passports]),f=R(()=>n?.find(p=>p.name===r.role),[n,r?.role]),a=t.palette.primary.main;return n.length===0?e.jsx(m,{children:e.jsx(Ke,{children:s("userCenter.noPassport")})}):e.jsx(m,{...i,sx:{display:"grid",justifyItems:"start",gridTemplateColumns:{xs:"repeat(2, 1fr)",sm:"repeat(2, 1fr)",md:"repeat(3, 1fr)",lg:"repeat(5, 1fr)"},gap:2.5,...i.sx},children:n.map(p=>e.jsx(ft,{passport:p,user:r,color:window.blocklet.passportColor,createPassportSvg:vt,title:f&&f.role===p.role?s("userCenter.currentPassport"):"",sx:{flexDirection:"column",alignItems:"center",gap:1,".passport-item__display":{width:166,height:166,borderRadius:1,px:2,display:"flex",justifyContent:"center",backgroundColor:"grey.50",boxShadow:f&&f.role===p.role?`0px 2px 4px 0px ${a}, 0px 1px 2px -1px ${a}, 0px 0px 0px 1px ${a} !important`:"unset"},".passport-item__body":{marginLeft:"0 !important"}}},p.id))})}sr.propTypes={user:u.object.isRequired};function Kt({visible:r,onClose:i,nft:s}){return!r||!s?null:e.jsx(Yt,{children:e.jsx(Rr,{open:r,onClose:i,children:e.jsx(Zt,{onClick:i,children:e.jsx(Xe,{data:Je(s),address:s.address,inset:!0})})})})}const Yt=V.div`
76
+ `;or.propTypes={blocklets:u.array,context:u.object,pagination:u.bool,inDialog:u.bool,filterType:u.oneOf(["component","entity"]),toViewAll:u.func,type:u.oneOf(["server","service"])};function or({blocklets:r=[],context:i,pagination:s=!0,inDialog:t=!1,filterType:n="component",toViewAll:f=()=>{},type:a="service"}){const{data:p,paging:l,refresh:x,loading:o,params:h,onReadNotification:C,componentDids:v,filterUnReadCount:d,initial:g}=i,j=c=>{x({...h,severity:c&&typeof c=="string"?[c]:c||[],paging:{...h.paging,page:1}})},[S]=Dr(),L=R(()=>S.get("id"),[S]),b=ve(c=>c.breakpoints.down("md")),[k,P]=y.useState(0),[_,B]=y.useState(!1),N=y.useMemo(()=>h.read===!1?"unread":"all",[h.read]),U=R(()=>_e(c=>{if(o)return;const w=p.length,I=p.filter(O=>!De(O)).length;let z={...h,append:!0,paging:{...h.paging,...c,currentPage:(l.currentPage||0)+1}};N==="unread"&&I<w&&c.page>h.paging.page&&(z={...h,append:!0,paging:{...h.paging,...c,page:h.paging.page||1,currentPage:(l.currentPage||0)+1}}),x(z)},500),[p,h,N,l,o,x]);Qr(()=>{g&&typeof g=="function"&&g()}),y.useEffect(()=>{(!l.currentPage||l.currentPage===1)&&P(l.total)},[l.total,l.currentPage]),y.useEffect(()=>{setTimeout(()=>{const c=document.getElementById(L);c&&c.scrollIntoView({behavior:"smooth",block:"center"}),B(!0)},100),setTimeout(()=>{B(!1)},3e3)},[L]);const J=R(()=>p?.length>0&&p.length<k,[p,k]),K=y.useCallback(c=>{const{blocklet:w={}}=window,I=[w?.did,...(w?.ancestors||[]).map(z=>z)];return v?.includes(c)||I.findIndex(z=>z===c)>-1},[v]),X=y.useMemo(()=>{const c=new Map;return r.length&&r.forEach(w=>{const I=w?.did||w.meta?.did;I&&!c.has(I)&&(w.ancestors=[],c.set(I,w),w?.alsoKnownAs?.length>0&&w.alsoKnownAs.forEach(z=>{c.has(z)||c.set(z,w)})),w?.children?.length>0&&w.children.forEach(z=>{const O=z?.did||z.meta?.did;O&&!c.has(O)&&K(O)&&(z.ancestors=[w],c.set(O,z))})}),c},[r,K]),pe=y.useCallback(()=>{o||U({page:l.page+1})},[l.page,o,U]),[ee]=$t({loading:o,hasNextPage:J,onLoadMore:pe}),re=c=>{!c||De(c)||C(c.id).then(()=>{t&&f()})},fe=({severity:c,id:w})=>{if(o)return;let I={};n==="component"?I={entityId:[],componentDid:w}:n==="entity"&&(I={componentDid:[],entityId:w}),x({...h,severity:c,...I,paging:{...h.paging,page:1}})},he=c=>{if(o)return;let w={...h,paging:{...h.paging,page:1}};c==="unread"?(w.read=!1,w.paging.currentPage=1):w=Br(w,"read"),x(w)},q=R(()=>n==="component"?Array.isArray(h.componentDid)?h.componentDid:[]:n==="entity"?Array.isArray(h.entityId)?h.entityId:[]:[],[h,n]),xe=R(()=>(Array.isArray(h.severity)?h.severity:[])[0]||"",[h.severity]);return e.jsxs(Ht,{inDialog:!!t,children:[t?e.jsx(rr,{currentTab:xe,type:"line",theme:"light",onSelectType:j}):e.jsx(nr,{loading:o,blockletMap:X,unReadCount:d,filterType:n,type:a,selectedId:q,onFilterChange:fe,severity:h.severity,onReadFilterChange:he,currentReadFilter:N}),!b&&o?e.jsx(m,{sx:{display:"flex",width:"100%",minHeight:400,justifyContent:"center",alignItems:"center"},children:e.jsx(Y,{})}):e.jsx(dt,{data:p,blockletMap:X,onReadNotification:re,onReadBatch:C,inDialog:t,highlightId:L,highlight:!t&&_,type:a}),s&&!b?e.jsx(Nt,{loading:o,paging:l,onChange:U}):null,s&&b&&(o||J)?e.jsx(m,{ref:ee,sx:{display:"flex",width:"100%",minHeight:100,justifyContent:"center",alignItems:"center"},children:e.jsx(Y,{})}):null,!t&&b?e.jsx(qt,{}):null]})}const Gt=y.memo(or),F=new _r;function ue(r){const{userDid:i=""}={},{session:s}=Ur(),t=R(()=>{if(i)return i;const l=window.location.href,x=Or(l);return x?.did?Array.isArray(x.did)?x.did[0]:x.did:s?.user?.did},[s?.user?.did,i]),n=R(()=>s.user,[s]),f=R(()=>n?t===n?.did:!1,[t,n?.did]),a=ce(async()=>{if(await Fr(()=>s?.initialized),f)return s.user;if(t)return F.user.getUserPublicInfo({did:t})},{refreshDeps:[t,f,s?.initialized,n]}),p=R(()=>n?.passports?.some(l=>l.role===je.ROLES.OWNER),[n]);return{currentDid:t,session:s,isMyself:f,user:n,viewUser:a.data,isOwner:p}}function sr({user:r,...i}){const{t:s}=D(),t=Tr(),n=R(()=>{const p=(r?.passports||[]).map(l=>({...l,revoked:l.status===Xr.REVOKED}));return p.sort((l,x)=>l.revoked===x.revoked?0:l.revoked?1:-1),Ee(p.filter(l=>!l.display),"role").concat(Ee(p.filter(l=>l.display),"display.content"))},[r?.passports]),f=R(()=>n?.find(p=>p.name===r.role),[n,r?.role]),a=t.palette.primary.main;return n.length===0?e.jsx(m,{children:e.jsx(Ke,{children:s("userCenter.noPassport")})}):e.jsx(m,{...i,sx:{display:"grid",justifyItems:"start",gridTemplateColumns:{xs:"repeat(2, 1fr)",sm:"repeat(2, 1fr)",md:"repeat(3, 1fr)",lg:"repeat(5, 1fr)"},gap:2.5,...i.sx},children:n.map(p=>e.jsx(ft,{passport:p,user:r,color:window.blocklet.passportColor,createPassportSvg:vt,title:f&&f.role===p.role?s("userCenter.currentPassport"):"",sx:{flexDirection:"column",alignItems:"center",gap:1,".passport-item__display":{width:166,height:166,borderRadius:1,px:2,display:"flex",justifyContent:"center",backgroundColor:"grey.50",boxShadow:f&&f.role===p.role?`0px 2px 4px 0px ${a}, 0px 1px 2px -1px ${a}, 0px 0px 0px 1px ${a} !important`:"unset"},".passport-item__body":{marginLeft:"0 !important"}}},p.id))})}sr.propTypes={user:u.object.isRequired};function Kt({visible:r,onClose:i,nft:s}){return!r||!s?null:e.jsx(Yt,{children:e.jsx(Rr,{open:r,onClose:i,children:e.jsx(Zt,{onClick:i,children:e.jsx(Je,{data:Xe(s),address:s.address,inset:!0})})})})}const Yt=V.div`
77
77
  position: relative;
78
78
  width: 100%;
79
79
  height: 100%;
@@ -118,7 +118,7 @@ import{j as e,y as yr,bc as ye,M as ne,ak as m,Q as G,W as u,J as ve,c1 as vr,I
118
118
  height: 75vmin;
119
119
  }
120
120
  }
121
- `,Vt=r=>({position:"absolute",top:0,left:0,right:0,bottom:0,backgroundColor:"rgba(0, 0, 0, 0.6)",opacity:0,transition:"opacity 0.3s ease-in-out",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1,"& .mask-item":{backgroundColor:oe(r.palette.background.paper,.9),color:"text.primary","&:hover":{backgroundColor:oe(r.palette.background.paper,1)}}}),Qt={position:"absolute",bottom:0,left:0,right:0,height:24,backgroundColor:"rgba(0, 0, 0, 0.6)",display:"flex",alignItems:"center",justifyContent:"center",color:"white",gap:1,zIndex:1,"& .mask-item":{width:20,height:20,color:"white"}},Ne="https://main.abtnetwork.io/explorer";function ir({user:r}){const{t:i,locale:s}=L(),t=de(),[n,f]=y.useState({visible:!1,nft:null}),[a,p]=y.useState({anchorEl:null,props:null}),l=b=>{const k=se(Ne,"assets",b);window.open(k,"_blank")},x=(b,k)=>{let P="";typeof k.data?.value=="string"?P=JSON.parse(k.data?.value)?.domain:P=k.data?.value?.domain,p({anchorEl:b,props:{title:P?`Hey, I just won an NFT at the ${P} event!`:"Hey, I just won an NFT!",url:se(Ne,"assets",k.address)}})},o=b=>{f({visible:!0,nft:b})},h=Q({page:1,size:20}),C=ce(async(b=h)=>(await Or.get(`${je.WELLKNOWN_SERVICE_PATH_PREFIX}/ocap/listAssets`,{params:{ownerAddress:r.did,...b}})).data,{ready:r?.did&&h,defaultParams:[h],refreshDeps:[r?.did,h]}),{loading:v,data:d}=C,g=d?.page??{cursor:0,next:!1,total:0},j=(b,k)=>{h.page=k,C.run(h)},S=M(b=>[e.jsx(W,{size:"small",className:"mask-item",onClick:k=>{k.stopPropagation(),l(b.address)},children:e.jsx(E,{icon:"tabler:link",fontSize:18})},"link"),e.jsx(W,{size:"small",onClick:k=>{k.stopPropagation(),x(k.currentTarget,b)},className:"mask-item",children:e.jsx(E,{icon:"tabler:share-2",fontSize:18})},"share"),e.jsx(W,{size:"small",onClick:k=>{k.stopPropagation(),o(b)},className:"mask-item",children:e.jsx(E,{icon:"tabler:eye",fontSize:18})},"view")]),D=R(()=>{if(v){const b=["skeleton-1","skeleton-2","skeleton-3","skeleton-4","skeleton-5"].map(k=>e.jsx(Ae,{variant:"rectangular",width:"15%",height:166,sx:{borderRadius:1,flexShrink:0}},k));return e.jsxs(m,{sx:{display:"flex",flexDirection:"column",gap:2},children:[e.jsx(Ae,{width:"20%"}),e.jsx(m,{sx:{display:"flex",flexDirection:"row",gap:2,flexWrap:"nowrap"},children:b})]})}return e.jsxs(e.Fragment,{children:[e.jsx(A,{sx:{color:"grey.A700",fontWeight:600,mb:2.5},children:i("userCenter.common.nft")}),d?.assets?.length===0&&!v&&e.jsx(m,{sx:{display:"flex",justifyContent:"center",alignItems:"center",width:"100%",height:"100%"},children:e.jsx(Ke,{children:i("userCenter.common.noNFT")})}),e.jsx(m,{className:"nft-list-wrapper",sx:{display:"grid",justifyItems:"start",gridTemplateColumns:{xs:"repeat(2, 1fr)",sm:"repeat(3, 1fr)",md:"repeat(3, 1fr)",lg:"repeat(5, 1fr)"},gap:2.5},children:d?.assets?.map(b=>e.jsxs(m,{sx:{flexShrink:0,width:{xs:120,sm:120,md:120,lg:166},height:{xs:120,sm:120,md:120,lg:166},position:"relative",borderRadius:1,overflow:"hidden",cursor:"pointer",...t?{}:{"&:hover .mask":{opacity:1}}},children:[e.jsx(Xe,{data:Je(b),address:b.address,inset:!0,imageFilter:{imageFilter:"resize",w:"500",f:"webp"}}),t?e.jsx(m,{className:"footer-mask",sx:Qt,children:S(b)}):e.jsx(m,{className:"mask",sx:Vt,children:e.jsx(we,{direction:"row",spacing:1,children:S(b)})})]},b.address))}),g.next||h.page>1?e.jsx(Mr,{sx:{display:"flex",justifyContent:"center",mt:2},page:h.page,onChange:j,count:Math.ceil(g.total/h.size),size:"small"}):null,e.jsx(Kt,{visible:n.visible&&!!n.nft,nft:n.nft,onClose:()=>{f({visible:!1,nft:null})}}),e.jsx(et,{locale:s,anchorEl:a.anchorEl,onClose:()=>{p({anchorEl:null,props:null})},sharedProps:a.props||{title:"",url:""}})]})},[v,g,h.page,h.size,j,a,n]);return e.jsx(m,{sx:{border:"1px solid",borderColor:"divider",borderRadius:1,p:2,mb:5},children:D})}ir.propTypes={user:u.object.isRequired};function Xt(){const{t:r}=L(),{user:i,isMyself:s,viewUser:t}=ue();return e.jsxs(m,{sx:{display:"flex",flexDirection:"column",gap:2.5},children:[s?e.jsxs(m,{sx:{border:"1px solid",borderColor:"divider",borderRadius:1.5,p:2},children:[e.jsx(A,{sx:{color:"text.primary",fontWeight:600,mb:2.5},children:r("userCenter.passport")}),e.jsx(sr,{user:i})]}):null,e.jsx(ir,{user:s?i:t})]})}const Jt=[{name:"English",code:"en"},{name:"中文",code:"zh"}];function ar({user:r,onSave:i}){const{t:s,changeLocale:t}=L(),n=Q({locale:r.locale,loading:!1}),f=M(async a=>{try{const{value:p}=a.target;n.loading=!0,await F.user.saveProfile({locale:p}),await i("profile"),t(p),n.locale=p}catch(p){O.error(Z(p))}finally{n.loading=!1}});return e.jsxs(m,{sx:{gap:1,display:"grid",alignItems:"center",gridTemplateColumns:{xs:"1fr",sm:"max-content 1fr"}},children:[e.jsx(m,{children:s("userCenter.commonSetting.locale")}),e.jsx(m,{children:e.jsx(ye,{value:n.locale,onChange:f,size:"small",IconComponent:a=>e.jsx(Ge,{...a,width:20,height:20}),sx:{minWidth:200,"&:hover":{"fieldset.MuiOutlinedInput-notchedOutline":{borderColor:"divider"}},fieldset:{borderColor:"divider"}},children:(window.blocklet.languages||Jt).map(a=>e.jsx(ne,{value:a.code,children:a.name},a.code))})})]})}ar.propTypes={user:u.shape({locale:u.string}).isRequired,onSave:u.func.isRequired};function lr({type:r,url:i,enabled:s,onEdit:t,onChange:n,onDelete:f}){return e.jsxs(m,{sx:{display:"flex",width:"100%",alignItems:"center",justifyContent:"space-between",py:1,px:1.5,gap:.75,borderRadius:1,"& .hover-actions":{opacity:0,transition:"opacity 0.2s"},"&:hover":{backgroundColor:"action.hover","& .hover-actions":{opacity:1}}},children:[e.jsxs(m,{sx:{display:"flex",alignItems:"center",gap:1,flex:1,minWidth:0,cursor:"pointer"},onClick:t,children:[e.jsx(ge,{title:r,children:e.jsx(E,{icon:r==="slack"?"logos:slack-icon":"material-symbols:link-rounded"})}),e.jsx(A,{sx:{color:"text.primary",fontSize:14,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:i})]}),e.jsxs(m,{sx:{minWidth:72,flexShrink:0,display:"flex",alignItems:"center",justifyContent:"flex-end",gap:1},children:[e.jsx(W,{className:"hover-actions",size:"small",onClick:t,sx:{p:0},children:e.jsx(E,{icon:Ve})}),e.jsx(W,{color:"error",onClick:f,size:"small",sx:{p:0},children:e.jsx(E,{icon:Qe})}),e.jsx(er,{checked:s,onChange:n})]})]})}lr.propTypes={type:u.string.isRequired,url:u.string.isRequired,onEdit:u.func.isRequired,onChange:u.func.isRequired,enabled:u.bool.isRequired,onDelete:u.func.isRequired};function be({onTest:r=H,onDelete:i=H,onSave:s=H,onCancel:t=H,type:n="slack",url:f="",enabled:a=!0,edit:p=!1,webhooks:l=[]}){const{t:x}=L(),o=Q({type:n||"slack",url:f||"",edit:p??!1,enabled:a??!0,error:"",loading:!1}),h=M(()=>o.url?o.type==="slack"&&!qr.isSlackWebhookUrl(o.url)||!Hr(o.url)?(o.error=x("common.invalid"),!1):l.some(S=>S.url===f&&o.url===f?!1:S.url===o.url)?(o.error=x("common.duplicate"),!1):(o.error="",!0):(o.error=x("common.required"),!1)),C=M(()=>{o.edit=!1,o.url=f||"",o.type=n||"slack",o.error="",o.loading=!1,t()}),v=M(async j=>{o.loading=!0,await r(j),o.loading=!1}),d=M(j=>()=>{h()&&j({type:o.type,url:o.url,enabled:o.enabled})}),g=R(()=>o.error?e.jsx(A,{component:"span",color:"error",children:o.error}):o.edit?o.loading?e.jsx(Y,{size:16}):e.jsx(W,{size:"small",onClick:d(v),sx:{mr:-1},children:e.jsx(E,{icon:ht})}):null,[o.error,o.edit,o.loading]);return o.edit?e.jsxs(m,{sx:{display:"flex",gap:1.5,px:1.5,width:"100%",alignItems:{xs:"flex-start",md:"center"},flexDirection:{xs:"column",md:"row"}},children:[e.jsxs(ye,{sx:{borderRadius:1,"&.Mui-disabled":{backgroundColor:"grey.50"}},disabled:!o.edit||o.loading,size:"small",value:o.type,onChange:j=>{o.type=j.target.value},children:[e.jsx(ne,{value:"api",children:x("userCenter.webhook.url")}),e.jsx(ne,{value:"slack",children:x("userCenter.webhook.slack")})]}),e.jsxs(m,{sx:{display:"flex",alignItems:"center",gap:.5,width:"100%"},children:[e.jsx(Ue,{sx:{flex:1,".MuiInputBase-root":{borderRadius:1,"&.Mui-disabled":{backgroundColor:"grey.50"}}},disabled:!o.edit||o.loading,fullWidth:!0,size:"small",required:!0,value:o.url,onChange:j=>{o.url=j.target.value,o.error="",h()},error:!!o.error,slotProps:{input:{endAdornment:e.jsx(Fe,{position:"end",children:g})}}}),e.jsx(m,{sx:{display:"flex",gap:.5},children:o.edit?e.jsxs(e.Fragment,{children:[e.jsx(W,{color:"success",onClick:d((...j)=>{s(...j),o.edit=!1}),sx:{borderRadius:1,border:"1px solid",borderColor:"grey.200"},children:e.jsx(E,{icon:rt})}),e.jsx(W,{color:"error",onClick:C,sx:{borderRadius:1,border:"1px solid",borderColor:"grey.200"},children:e.jsx(E,{icon:tt})})]}):e.jsxs(e.Fragment,{children:[e.jsx(W,{onClick:()=>{o.edit=!0},sx:{borderRadius:1,border:"1px solid",borderColor:"grey.200"},children:e.jsx(E,{icon:Ve})}),e.jsx(W,{color:"error",onClick:()=>{i({type:o.type,url:o.url})},sx:{borderRadius:1,border:"1px solid",borderColor:"grey.200"},children:e.jsx(E,{icon:Qe})})]})})]})]}):e.jsx(lr,{type:o.type,url:o.url,enabled:o.enabled,onEdit:()=>{o.edit=!0},onChange:j=>{o.enabled=j,d((...S)=>s(...S))()},onDelete:()=>{i({type:o.type,url:o.url})}})}be.propTypes={onTest:u.func,onDelete:u.func,onSave:u.func,onCancel:u.func,type:u.oneOf(["api","slack"]),url:u.string,edit:u.bool,webhooks:u.array,enabled:u.bool};function te({title:r=void 0,description:i=void 0,value:s,onChange:t,isMobile:n,type:f}){const a=M(p=>{p.stopPropagation()});return e.jsxs(m,{sx:{width:"100%",display:"flex",alignItems:"center",justifyContent:"space-between",cursor:"pointer",py:1,px:1.5,gap:.75,borderRadius:1,"&:hover":{backgroundColor:"action.hover"}},children:[e.jsxs(m,{sx:{display:"flex",alignItems:"center",gap:1},children:[f==="push"?e.jsx(E,{icon:"tabler:bell"}):e.jsx(qe,{provider:f,sx:{width:"1em",height:"1em",flexShrink:0,fontSize:16}}),e.jsxs(A,{component:"div",onClick:a,sx:{color:"text.primary",fontSize:14,display:"flex",flexWrap:n?"wrap":"nowrap",columnGap:1,flex:1,whiteSpace:n?"normal":"nowrap"},children:[r,i]})]}),e.jsx(er,{sx:{minWidth:36,flexShrink:0},checked:s,onChange:t})]})}te.propTypes={title:u.string,description:u.node,value:u.bool.isRequired,onChange:u.func.isRequired,isMobile:u.bool.isRequired,type:u.oneOf(["wallet","email","push"]).isRequired};function cr({user:r,isMobile:i}){const{t:s}=L(),t=Q({showAdd:!1}),n=ce(async()=>await F.user.getUserNotificationConfig(),{refreshDeps:[r],loadingDelay:300}),f=R(()=>({wallet:!0,email:!0,phone:!1,push:!0,...n?.data?.notifications||{}}),[n?.data?.notifications]),a=R(()=>n?.data?.webhooks||[],[n?.data?.webhooks]),p=M(async v=>{try{await F.user.saveUserNotificationConfig(v),O.success(s("userCenter.saveSuccess")),n.run()}catch(d){O.error(Z(d))}}),l=M(async(v,d)=>{await p({notifications:{[v]:d}})}),x=async v=>{try{await F.user.testNotificationWebhook(v),O.success(s("userCenter.webhookTested"))}catch(d){O.error(Z(d))}},o=M(async v=>{await p({webhooks:a.filter((d,g)=>g!==v)})}),h=M(async(v,d)=>{await p({webhooks:a.map((g,j)=>j===v?d:g)})}),C=M(async v=>{await p({webhooks:[...a,v]}),t.showAdd=!1});return n.error?e.jsx(Ar,{severity:"error",children:n.error.message}):n.loading||!n.data?e.jsx(m,{sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"100px"},children:e.jsx(Y,{})}):e.jsxs(m,{sx:{display:"flex",flexDirection:"column",".MuiSwitch-track":{borderRadius:"100vw"},".MuiSwitch-thumb":{borderRadius:"100%"},".MuiSwitch-root.MuiSwitch-sizeSmall":{height:"20px",width:"36px",".MuiSwitch-thumb":{width:"16px",height:"16px"}}},children:[e.jsxs(m,{sx:{display:"flex",flexDirection:"column",alignItems:"start",".MuiFormControlLabel-root":{gap:1,m:0,flexDirection:{xs:"row-reverse",md:"row"},width:{xs:"100%",md:"unset"}}},children:[e.jsx(te,{value:f.wallet,isMobile:i,type:"wallet",title:s("userCenter.walletNotification"),onChange:v=>l("wallet",v),description:ze(r)&&e.jsx(nt,{did:ze(r),showQrcode:!1,showAvatar:!i,copyable:!0,compact:!0,responsive:!0,startChars:i?2:6})}),e.jsx(te,{value:f.email,isMobile:i,type:"email",onChange:v=>l("email",v),title:s("userCenter.emailNotification"),description:r?.email&&e.jsx(A,{component:"span",sx:{color:"text.secondary",fontSize:13},children:r?.email})}),e.jsx(te,{isMobile:i,value:f.push,type:"push",title:s("userCenter.pushNotification"),onChange:v=>l("push",v)})]}),e.jsxs(we,{useFlexGap:!0,direction:"column",sx:{alignItems:"start"},children:[a.map((v,d)=>e.jsx(be,{enabled:v.enabled,onTest:x,onDelete:()=>o(d),onSave:(...g)=>h(d,...g),type:v.type,url:v.url,edit:!1,webhooks:a},`${d}_${v.url}`)),t.showAdd&&e.jsx(be,{onTest:x,onCancel:()=>{t.showAdd=!1},onSave:(...v)=>C(...v),edit:!0,webhooks:a},"add"),e.jsx(Ye,{variant:"outlined",size:"small",sx:{color:"text.primary",borderColor:"divider","&:hover":{borderColor:"divider"},py:.5,borderRadius:1,mt:1,ml:1.5},startIcon:e.jsx(E,{icon:xt}),onClick:()=>{t.showAdd=!0},children:s("userCenter.addWebhook")})]})]})}cr.propTypes={user:u.object.isRequired,isMobile:u.bool.isRequired};function dr({item:r}){const i=ke(),{blocklet:s}=Gr(),{confirmApi:t,confirmHolder:n}=He(),f=Q({loading:!1}),{t:a}=L(),{session:p}=y.use(le),{bindOAuth:l,unbindOAuth:x,setBaseUrl:o,baseUrl:h}=p.useOAuth(),{disconnectPasskey:C,setTargetAppPid:v}=p.usePasskey(),d=R(()=>ot[r?.provider]||"unknown",[r?.provider]),g=M(b=>b?._bind?b.provider===T.WALLET&&b.did?a("userCenter.thirdPartyLogin.walletAccountCantRemove"):b.provider===T.PASSKEY&&i.arcSphere?a("userCenter.thirdPartyLogin.dontSupportRemoveinArcSphere"):b._mainProvider&&i.arcSphere?a("userCenter.thirdPartyLogin.mainProviderCantRemove"):"":""),j=M(async()=>{if(r?.provider===T.PASSKEY){await new Promise((b,k)=>{t.open({title:a("userCenter.thirdPartyLogin.disconnectPasskey",{name:d}),content:a("userCenter.thirdPartyLogin.disconnectPasskeyDescription",{name:d}),confirmButtonText:a("common.confirm"),confirmButtonProps:{color:"error"},cancelButtonText:a("common.cancel"),onConfirm(P){C({session:p,connectedAccount:r}).then(b).catch(k),P()},onCancel:b})});return}try{f.loading=!0,await new Promise((b,k)=>{if(r?._bind)t.open({title:a("userCenter.thirdPartyLogin.confirmUnbind",{name:d}),content:a("userCenter.thirdPartyLogin.confirmUnbindDescription",{name:d}),confirmButtonText:a("common.confirm"),confirmButtonProps:{color:"error"},cancelButtonText:a("common.cancel"),onConfirm(P){x({session:p,connectedAccount:{...Nr(r,["did","pk"]),showProvider:r.provider,provider:r._rawProvider}}).then(b).catch(k),P()},onCancel:b});else if(r.provider===T.WALLET)t.open({title:a("userCenter.thirdPartyLogin.confirmBindWallet",{name:d}),content:a("userCenter.thirdPartyLogin.confirmBindWalletDescription",{name:d}),confirmButtonText:a("common.confirm"),confirmButtonProps:{color:"primary"},cancelButtonText:a("common.cancel"),onConfirm:P=>{p.bindWallet({onSuccess:b,onCancel:k}),P()},onCancel:b});else{const P=h,_=window?.blocklet;let $="/";const N=st(_),U=it(_);N&&U?.appPid&&p?.user?.sourceAppPid&&($=U.appUrl),o($),v(s?.appPid),l({session:p,oauthItem:{...r,provider:r._rawProvider}}).then(b).catch(k).finally(()=>{o(P),v()})}})}catch(b){console.error(`Failed to ${r?._bind?"unbind":"bind"} oauth account`,b)}finally{f.loading=!1}}),S=M(b=>b.provider===T.WALLET&&b.did?a("userCenter.thirdPartyLogin.walletAccount"):b._mainProvider?a("userCenter.thirdPartyLogin.mainAccount"):b?._bind?a("userCenter.thirdPartyLogin.disconnect"):a("userCenter.thirdPartyLogin.connect")),D=M(b=>b.provider===T.WALLET&&b.did||b.provider===T.PASSKEY&&(i.arcSphere||i.wallet)?!0:!!r._mainProvider,[i.arcSphere]);return e.jsxs(e.Fragment,{children:[e.jsxs(m,{sx:{borderRadius:1,border:"1px solid",borderColor:"divider",backgroundColor:"grey.50",display:"flex",alignItems:"center",py:1,px:1.5,gap:.75,fontSize:"14px",lineHeight:1,overflow:"hidden"},children:[e.jsx(qe,{provider:r?.provider,sx:{width:"1em",height:"1em",flexShrink:0,fontSize:16}}),e.jsx(m,{sx:{flex:1,display:{xs:r.userInfo?.email||r.did?"none":"block",sm:"block"}},children:d}),r.userInfo?.email||r.did?e.jsxs(m,{sx:{display:"flex",alignItems:"center",gap:.5,overflow:"hidden"},children:[e.jsx(m,{sx:{flex:1,textOverflow:"ellipsis",overflow:"hidden",lineHeight:"normal"},children:r.userInfo?.email||r.did}),r.userInfo?.name?e.jsx(ge,{title:e.jsxs(m,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(at,{size:36,variant:"circle",shape:"circle",src:r.userInfo?.picture,did:r.did}),e.jsxs(m,{children:[e.jsx(A,{sx:{whiteSpace:"normal",wordBreak:"break-all",fontSize:"0.9rem"},children:r.userInfo?.name}),e.jsx(A,{sx:{whiteSpace:"normal",wordBreak:"break-all",fontSize:"0.9rem"},children:r.userInfo?.email})]})]}),children:e.jsx(m,{component:E,icon:Kr,sx:{color:"text.secondary",fontSize:16,cursor:"pointer",flexShrink:0}})}):null]}):null]}),e.jsx(ge,{title:g(r),placement:"auto",children:e.jsx(m,{children:e.jsx(Ye,{variant:"outlined",size:"small",sx:b=>{const k=b.palette.error.main,P=b.palette.primary.main;return{color:r?._bind?k:P,borderColor:r?._bind?k:P,backgroundColor:"background.default","&:hover":{borderColor:r?._bind?k:P,backgroundColor:"action.hover"},py:.5,borderRadius:1,fontWeight:500,whiteSpace:"nowrap"}},fullWidth:!0,startIcon:f.loading?null:e.jsx(E,{icon:mt}),onClick:j,disabled:D(r),loading:f.loading,children:S(r)})})}),n]})}dr.propTypes={item:u.shape({provider:u.string,did:u.string,pk:u.string,userInfo:u.object,id:u.string,_bind:u.bool,_rawProvider:u.string,_mainProvider:u.bool}).isRequired};function ur({user:r}){const{session:i}=y.use(le),[s,t]=y.useState({}),{getOAuthConfigs:n}=i.useOAuth(),f=ke();Xr(async()=>{const l=await n({sourceAppPid:r?.sourceAppPid});t(l)},[r?.sourceAppPid]);const a=R(()=>{const l=Object.keys(s).map(x=>({...s[x],provider:x})).filter(x=>x.enabled);return[{provider:T.WALLET,order:-1},...l,{provider:T.PASSKEY,order:1/0}]},[s]),p=R(()=>{const l=lt(r);let x=!1,o="",h=ct(r);const C=l.find(d=>d.provider===T.AUTH0);return C&&(C.id.startsWith("google-oauth2|")&&(l.some(d=>d.provider==="google")||(x=!0,o=T.GOOGLE,h===T.AUTH0&&(h=T.GOOGLE))),C.id.startsWith("appleid|")&&(l.some(d=>d.provider===T.APPLE)||(x=!0,o=T.APPLE,h===T.AUTH0&&(h=T.APPLE))),C.id.startsWith("github|")&&(l.some(d=>d.provider===T.GITHUB)||(x=!0,o=T.GITHUB,h===T.AUTH0&&(h=T.GITHUB)))),a.map(d=>{if(d.provider===T.AUTH0&&x)return null;const g=x&&d.provider===o?l.find(j=>j.provider===T.AUTH0):l.find(j=>j.provider===d.provider);return g?{...d,provider:d.provider,did:g.did,pk:g.pk,userInfo:g.userInfo,_bind:!0,_rawProvider:g.provider,_mainProvider:d.provider===h}:{...d,provider:d.provider,_rawProvider:d.provider,_mainProvider:d.provider===h}}).filter(d=>!(!d||d.provider===T.PASSKEY&&!d.did)).sort((d,g)=>d._mainProvider?-1:d?.order!==void 0&&g?.order!==void 0?d.order-g.order:d?.order!==void 0?-1:1)},[r?.connectedAccounts,a]);return e.jsxs(m,{sx:{gap:1,display:"grid",gridTemplateColumns:"1fr min-content"},children:[p.map(l=>e.jsx(dr,{item:l},l?.provider)),f.wallet||f.arcSphere?null:e.jsx(Yr,{behavior:"only-new",action:"connect",createMode:"connect",createButtonText:"Add New Passkey",onSuccess:H,onError:H,dense:!0,sx:{px:1.5,py:1,gap:.75}})]})}ur.propTypes={user:u.object.isRequired};function pr({configList:r,onSave:i}){const[s,t]=y.useState(r),{t:n}=L(),f=M(async(a,p)=>{try{const l=await F.user.saveUserPrivacyConfig({[a]:typeof p=="string"?p:!p});t(s.map(x=>({...x,value:l?.[x.key]??x.value}))),O.success(n("userCenter.saveSuccess")),i("privacy")}catch(l){O.error(Z(l))}});return y.useEffect(()=>{t(r)},[r]),e.jsx(m,{sx:{display:"flex",flexDirection:"column",gap:1,alignItems:"start",".MuiFormControlLabel-root":{gap:1,m:0,flexDirection:{xs:"row-reverse",md:"row"},width:{xs:"100%",md:"unset"}},".MuiSwitch-track":{borderRadius:"100vw"},".MuiSwitch-thumb":{borderRadius:"100%"},".MuiSwitch-root.MuiSwitch-sizeSmall":{height:"20px",width:"36px",".MuiSwitch-thumb":{width:"16px",height:"16px"}}},children:s.map(a=>{if(a.isPrivate)return null;const p=!a.value||["all","follower-only"].includes(a.value);return e.jsxs(m,{children:[e.jsx(De,{checked:p,labelProps:{label:e.jsx(A,{sx:{color:"text.primary",fontSize:14,display:"flex",flexFlow:"wrap",columnGap:1,flex:1},children:n("userCenter.toPublic",{name:a.name})})},size:"small",onChange:l=>{const{checked:x}=l.target;a.followersOnly?f(a.key,x?"all":"private"):f(a.key,x)}},a.key),a.followersOnly&&p&&e.jsx(m,{sx:{pl:3,pt:1},children:e.jsx(De,{checked:a.value==="follower-only",labelProps:{label:e.jsx(A,{sx:{color:"text.primary",fontSize:14,display:"flex",flexFlow:"wrap",columnGap:1,flex:1},children:n("team.userFollowers.followersOnly")})},size:"small",onChange:l=>{const{checked:x}=l.target;f(a.key,x?"follower-only":"all")}})})]})})})}pr.propTypes={configList:u.arrayOf(u.shape({key:u.string.isRequired,name:u.string.isRequired,value:u.bool.isRequired,isPrivate:u.bool})).isRequired,onSave:u.func.isRequired};function fr({onDestroySelf:r=void 0}){const{confirmHolder:i}=He(),{t:s}=L(),{session:t}=y.use(le),n=M(async()=>{if(!r||typeof r!="function")return;const f=t.withSecondaryAuth(r,{extraParams:{removeUserDid:t?.user?.did,input:{user:{did:t?.user?.did},teamDid:window?.blocklet?.did}},operation:"destroySelf"});try{await f(),t.logout()}catch(a){O.error(a?.message||s("userCenter.destroyMyself.error"))}});return e.jsxs(e.Fragment,{children:[e.jsx(m,{children:e.jsxs(m,{sx:{display:"flex",alignItems:"center",gap:1,justifyContent:"space-between",flexWrap:"wrap"},children:[e.jsxs(m,{children:[e.jsx(A,{variant:"h6",sx:{fontSize:"0.875rem !important",fontWeight:"bold"},children:s("userCenter.dangerZone.deleteAccount")}),e.jsx(A,{variant:"caption",sx:{color:"text.secondary"},children:s("userCenter.dangerZone.deleteAccountDescription")})]}),e.jsx(G,{variant:"contained",color:"error",size:"small",onClick:n,children:s("userCenter.dangerZone.delete")})]})}),i]})}fr.propTypes={onDestroySelf:u.func};function en(){const r=de({key:"md"}),i=ve(n=>n.breakpoints.down("lg")),s={display:"flex",justifyContent:"flex-end",flexWrap:"wrap",textAlign:"right","&.expired-at > div":{maxWidth:160,justifyContent:"flex-end",flexWrap:"wrap"}},t=R(()=>Ze({},r?s:{}),[r]);return e.jsx(m,{id:"user-center-access-key-setting",sx:{maxWidth:r?"unset":i?"calc(100vw - 300px)":"100%",...r&&{".pc-access-key-table > div:nth-child(2)":{border:"1px solid",borderColor:"divider",borderRadius:1}},".MuiTableCell-head":{whiteSpace:"nowrap",fontWeight:"bold"},".MuiTableRow-root":{border:"unset","&:nth-child(even)":{backgroundColor:"grey.50","&:hover":{backgroundColor:n=>`${n.palette.grey[50]} !important`}}},".MuiTableRow-hover":{"&:hover":{backgroundColor:"inherit !important"}},".MuiTableCell-root":{paddingRight:"8px",paddingLeft:"8px",color:"text.secondary",...r&&{padding:"8px !important","&:first-child":{paddingTop:"20px!important"},"&:last-child":{paddingBottom:"20px!important"}}}},children:e.jsx(kt,{isSelf:!0,columnSx:t})})}function hr({onDestroySelf:r=void 0,userCenterTabs:i=[]}){const{t:s}=L(),{user:t,session:n,isMyself:f,isOwner:a}=ue(),l=ke().arcSphere,x=de({key:"md"}),o=ce(async()=>t&&f?await F.user.getUserPrivacyConfig({did:t.did}):null,{refreshDeps:[t,f],loadingDelay:300}),h=R(()=>i.map(d=>({key:d.value,name:d.label,value:d.protected,isPrivate:d.isPrivate,followersOnly:d.followersOnly})),[i]),C=M(async d=>d==="privacy"?(await o.runAsync(),o.data):(d==="profile"&&await n.refresh(),null));y.useEffect(()=>{const d=window.location.hash.slice(1);d&&document.getElementById(d)?.scrollIntoView({behavior:"smooth"})},[]);const v=R(()=>[l?void 0:{label:s("userCenter.commonSetting.title"),value:"common",content:e.jsx(ar,{user:t,onSave:C})},{label:s("userCenter.notificationManagement"),value:"notification",content:e.jsx(cr,{user:t,isMobile:x})},{label:s("userCenter.thirdPartyLogin.title"),value:"thirdPartyLogin",content:e.jsx(ur,{user:t})},{label:s("common.accessKeys"),value:"accessKeys",content:e.jsx(en,{isSelf:!0})},{label:s("common.mcpServers"),value:"mcpServers",content:e.jsx(wt,{})},{label:s("userCenter.privacyManagement"),value:"privacy",content:e.jsx(pr,{configList:h,onSave:C})},{label:s("userCenter.sessionManagement"),value:"session",content:e.jsx(jt,{user:t,showUser:!1,getUserSessions:d=>F.userSession.getMyLoginSessions({},d)})},!a&&r&&typeof r=="function"?{label:s("userCenter.dangerZone.title"),value:"dangerZone",content:e.jsx(fr,{onDestroySelf:r}),sx:{borderColor:"error.main"}}:null].filter(Boolean),[t,h,x,a,r]);return f?e.jsx(m,{className:"user-center-settings",sx:{display:"flex",flexDirection:"column",gap:2.5,minWidth:{md:500},"@media (min-width: 1200px) and (max-width: 1260px)":{maxWidth:750},"@media (min-width: 1100px) and (max-width: 1199px)":{maxWidth:650},"@media (min-width: 1000px) and (max-width: 1099px)":{maxWidth:600},"@media (max-width: 1049px)":{maxWidth:"100%"}},children:v.map(d=>d?e.jsxs(m,{id:d.value,sx:Ze({border:"1px solid",borderColor:"divider",borderRadius:1,p:2,"&:last-child":{mb:5}},d.sx),children:[e.jsx(A,{sx:{color:"text.primary",fontWeight:600},children:d.label}),e.jsx(m,{sx:{mt:2.5},children:d.content})]},d.value):null)}):null}hr.propTypes={onDestroySelf:u.func,userCenterTabs:u.array};const xr=y.createContext({}),{Provider:rn,Consumer:go}=xr;function mr({children:r}){const[i]=y.useState(!1),{session:s}=y.use(le),{user:t}=s,[n,f]=y.useState(),a=y.useMemo(()=>t?.didSpace?.endpoint,[t?.didSpace]);y.useEffect(()=>{f(t?.didSpace)},[t?.didSpace]);const p=async()=>{f(void 0)},l=h=>{},x=async h=>{f(h),await l(h.endpoint)},o=!!(a&&n);return e.jsx(rn,{value:{loading:i,spaceGateway:n,session:s,deleteSpaceGateway:p,updateSpaceGateway:x,storageEndpoint:a,settingStorageEndpoint:l,hasStorageEndpoint:o},children:r})}function Se(){return y.use(xr)}mr.propTypes={children:u.node.isRequired};function tn(r){const i=r.replace(/\/api\/space\/.+/,""),t=r.replace(/\/$/,"").split("/").at(-4);return se(i,"space",t)}function gr({session:r,spaceGateway:i,spaceStatus:s,refresh:t}){return e.jsxs(we,{direction:"row",spacing:1,children:[s===Pt.DISCONNECTED&&e.jsx(ie,{reconnect:!0,variant:"outlined",session:r,spaceDid:r.user?.didSpace?.did,spaceGatewayUrl:r.user?.didSpace?.url,connectScope:"user",onSuccess:async()=>{await t()},onError:n=>{console.error(n),O.error(Z(n))}}),e.jsx(W,{size:"small",LinkComponent:Er,href:tn(i.endpoint),target:"_blank",children:e.jsx(zr,{})})]})}gr.propTypes={session:u.object.isRequired,spaceGateway:u.object.isRequired,spaceStatus:u.string.isRequired,refresh:u.func.isRequired};function br({spaceGateway:r=void 0}){const{t:i}=L(),{updateSpaceGateway:s,session:t}=Se(),n=de(),f=({spaceGateway:a})=>s(a);return e.jsxs(m,{sx:{display:"flex",flexDirection:"column"},children:[e.jsxs(m,{sx:{display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"space-between",marginBottom:"12px"},children:[e.jsx(A,{sx:{fontSize:"16px",fontWeight:"bold"},children:i("userCenter.storage.spaces.connected.title")}),!n&&e.jsx(ie,{connectScope:"user",connectText:i("userCenter.storage.spaces.connected.switch"),session:t,onSuccess:f})]}),e.jsx(m,{children:r&&e.jsx(It,{endpoint:r.endpoint,deps:[r],selected:!0,footer:!0,action:a=>e.jsx(gr,{session:t,...a})},r.endpoint)}),n&&e.jsx(m,{sx:{display:"flex",alignItems:"center",justifyContent:"center",marginTop:2},children:e.jsx(ie,{connectScope:"user",connectText:i("userCenter.storage.spaces.connected.switch"),session:t,onSuccess:f})})]})}br.propTypes={spaceGateway:u.object};function nn(){const{t:r}=L(),{updateSpaceGateway:i,session:s}=Se(),t=({spaceGateway:n})=>i(n);return e.jsxs(m,{sx:{display:"flex",flexDirection:"column"},children:[e.jsx(A,{sx:{fontSize:"16px",fontWeight:"bold"},children:r("userCenter.storage.spaces.connect.providerForStorage")}),e.jsx(Tt,{viewBox:"0 0 228 258",style:{width:"156px",height:"156px",margin:"16px 0"}}),e.jsx(m,{children:e.jsx(ie,{session:s,onSuccess:t})})]})}function on(){const{spaceGateway:r,hasStorageEndpoint:i,loading:s}=Se(),{isMyself:t}=ue();return t?s?e.jsx(St,{relative:"parent",children:e.jsx(Y,{})}):e.jsx(an,{children:e.jsx(m,{sx:{maxWidth:"720px"},children:i?e.jsx(br,{spaceGateway:r}):e.jsx(nn,{})})}):null}function sn(){return e.jsx(mr,{children:e.jsx(on,{})})}const an=V(m)`
121
+ `,Vt=r=>({position:"absolute",top:0,left:0,right:0,bottom:0,backgroundColor:"rgba(0, 0, 0, 0.6)",opacity:0,transition:"opacity 0.3s ease-in-out",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1,"& .mask-item":{backgroundColor:oe(r.palette.background.paper,.9),color:"text.primary","&:hover":{backgroundColor:oe(r.palette.background.paper,1)}}}),Qt={position:"absolute",bottom:0,left:0,right:0,height:24,backgroundColor:"rgba(0, 0, 0, 0.6)",display:"flex",alignItems:"center",justifyContent:"center",color:"white",gap:1,zIndex:1,"& .mask-item":{width:20,height:20,color:"white"}},Ne="https://main.abtnetwork.io/explorer";function ir({user:r}){const{t:i,locale:s}=D(),t=de(),[n,f]=y.useState({visible:!1,nft:null}),[a,p]=y.useState({anchorEl:null,props:null}),l=b=>{const k=se(Ne,"assets",b);window.open(k,"_blank")},x=(b,k)=>{let P="";typeof k.data?.value=="string"?P=JSON.parse(k.data?.value)?.domain:P=k.data?.value?.domain,p({anchorEl:b,props:{title:P?`Hey, I just won an NFT at the ${P} event!`:"Hey, I just won an NFT!",url:se(Ne,"assets",k.address)}})},o=b=>{f({visible:!0,nft:b})},h=Q({page:1,size:20}),C=ce(async(b=h)=>(await $r.get(`${je.WELLKNOWN_SERVICE_PATH_PREFIX}/ocap/listAssets`,{params:{ownerAddress:r.did,...b}})).data,{ready:r?.did&&h,defaultParams:[h],refreshDeps:[r?.did,h]}),{loading:v,data:d}=C,g=d?.page??{cursor:0,next:!1,total:0},j=(b,k)=>{h.page=k,C.run(h)},S=M(b=>[e.jsx(W,{size:"small",className:"mask-item",onClick:k=>{k.stopPropagation(),l(b.address)},children:e.jsx(E,{icon:"tabler:link",fontSize:18})},"link"),e.jsx(W,{size:"small",onClick:k=>{k.stopPropagation(),x(k.currentTarget,b)},className:"mask-item",children:e.jsx(E,{icon:"tabler:share-2",fontSize:18})},"share"),e.jsx(W,{size:"small",onClick:k=>{k.stopPropagation(),o(b)},className:"mask-item",children:e.jsx(E,{icon:"tabler:eye",fontSize:18})},"view")]),L=R(()=>{if(v){const b=["skeleton-1","skeleton-2","skeleton-3","skeleton-4","skeleton-5"].map(k=>e.jsx(Ae,{variant:"rectangular",width:"15%",height:166,sx:{borderRadius:1,flexShrink:0}},k));return e.jsxs(m,{sx:{display:"flex",flexDirection:"column",gap:2},children:[e.jsx(Ae,{width:"20%"}),e.jsx(m,{sx:{display:"flex",flexDirection:"row",gap:2,flexWrap:"nowrap"},children:b})]})}return e.jsxs(e.Fragment,{children:[e.jsx(A,{sx:{color:"grey.A700",fontWeight:600,mb:2.5},children:i("userCenter.common.nft")}),d?.assets?.length===0&&!v&&e.jsx(m,{sx:{display:"flex",justifyContent:"center",alignItems:"center",width:"100%",height:"100%"},children:e.jsx(Ke,{children:i("userCenter.common.noNFT")})}),e.jsx(m,{className:"nft-list-wrapper",sx:{display:"grid",justifyItems:"start",gridTemplateColumns:{xs:"repeat(2, 1fr)",sm:"repeat(3, 1fr)",md:"repeat(3, 1fr)",lg:"repeat(5, 1fr)"},gap:2.5},children:d?.assets?.map(b=>e.jsxs(m,{sx:{flexShrink:0,width:{xs:120,sm:120,md:120,lg:166},height:{xs:120,sm:120,md:120,lg:166},position:"relative",borderRadius:1,overflow:"hidden",cursor:"pointer",...t?{}:{"&:hover .mask":{opacity:1}}},children:[e.jsx(Je,{data:Xe(b),address:b.address,inset:!0,imageFilter:{imageFilter:"resize",w:"500",f:"webp"}}),t?e.jsx(m,{className:"footer-mask",sx:Qt,children:S(b)}):e.jsx(m,{className:"mask",sx:Vt,children:e.jsx(we,{direction:"row",spacing:1,children:S(b)})})]},b.address))}),g.next||h.page>1?e.jsx(Mr,{sx:{display:"flex",justifyContent:"center",mt:2},page:h.page,onChange:j,count:Math.ceil(g.total/h.size),size:"small"}):null,e.jsx(Kt,{visible:n.visible&&!!n.nft,nft:n.nft,onClose:()=>{f({visible:!1,nft:null})}}),e.jsx(et,{locale:s,anchorEl:a.anchorEl,onClose:()=>{p({anchorEl:null,props:null})},sharedProps:a.props||{title:"",url:""}})]})},[v,g,h.page,h.size,j,a,n]);return e.jsx(m,{sx:{border:"1px solid",borderColor:"divider",borderRadius:1,p:2,mb:5},children:L})}ir.propTypes={user:u.object.isRequired};function Jt(){const{t:r}=D(),{user:i,isMyself:s,viewUser:t}=ue();return e.jsxs(m,{sx:{display:"flex",flexDirection:"column",gap:2.5},children:[s?e.jsxs(m,{sx:{border:"1px solid",borderColor:"divider",borderRadius:1.5,p:2},children:[e.jsx(A,{sx:{color:"text.primary",fontWeight:600,mb:2.5},children:r("userCenter.passport")}),e.jsx(sr,{user:i})]}):null,e.jsx(ir,{user:s?i:t})]})}const Xt=[{name:"English",code:"en"},{name:"中文",code:"zh"}];function ar({user:r,onSave:i}){const{t:s,changeLocale:t}=D(),n=Q({locale:r.locale,loading:!1}),f=M(async a=>{try{const{value:p}=a.target;n.loading=!0,await F.user.saveProfile({locale:p}),await i("profile"),t(p),n.locale=p}catch(p){$.error(Z(p))}finally{n.loading=!1}});return e.jsxs(m,{sx:{gap:1,display:"grid",alignItems:"center",gridTemplateColumns:{xs:"1fr",sm:"max-content 1fr"}},children:[e.jsx(m,{children:s("userCenter.commonSetting.locale")}),e.jsx(m,{children:e.jsx(ye,{value:n.locale,onChange:f,size:"small",IconComponent:a=>e.jsx(Ge,{...a,width:20,height:20}),sx:{minWidth:200,"&:hover":{"fieldset.MuiOutlinedInput-notchedOutline":{borderColor:"divider"}},fieldset:{borderColor:"divider"}},children:(window.blocklet.languages||Xt).map(a=>e.jsx(ne,{value:a.code,children:a.name},a.code))})})]})}ar.propTypes={user:u.shape({locale:u.string}).isRequired,onSave:u.func.isRequired};function lr({type:r,url:i,enabled:s,onEdit:t,onChange:n,onDelete:f}){return e.jsxs(m,{sx:{display:"flex",width:"100%",alignItems:"center",justifyContent:"space-between",py:1,px:1.5,gap:.75,borderRadius:1,"& .hover-actions":{opacity:0,transition:"opacity 0.2s"},"&:hover":{backgroundColor:"action.hover","& .hover-actions":{opacity:1}}},children:[e.jsxs(m,{sx:{display:"flex",alignItems:"center",gap:1,flex:1,minWidth:0,cursor:"pointer"},onClick:t,children:[e.jsx(ge,{title:r,children:e.jsx(E,{icon:r==="slack"?"logos:slack-icon":"material-symbols:link-rounded"})}),e.jsx(A,{sx:{color:"text.primary",fontSize:14,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:i})]}),e.jsxs(m,{sx:{minWidth:72,flexShrink:0,display:"flex",alignItems:"center",justifyContent:"flex-end",gap:1},children:[e.jsx(W,{className:"hover-actions",size:"small",onClick:t,sx:{p:0},children:e.jsx(E,{icon:Ve})}),e.jsx(W,{color:"error",onClick:f,size:"small",sx:{p:0},children:e.jsx(E,{icon:Qe})}),e.jsx(er,{checked:s,onChange:n})]})]})}lr.propTypes={type:u.string.isRequired,url:u.string.isRequired,onEdit:u.func.isRequired,onChange:u.func.isRequired,enabled:u.bool.isRequired,onDelete:u.func.isRequired};function be({onTest:r=H,onDelete:i=H,onSave:s=H,onCancel:t=H,type:n="slack",url:f="",enabled:a=!0,edit:p=!1,webhooks:l=[]}){const{t:x}=D(),o=Q({type:n||"slack",url:f||"",edit:p??!1,enabled:a??!0,error:"",loading:!1}),h=M(()=>o.url?o.type==="slack"&&!qr.isSlackWebhookUrl(o.url)||!Hr(o.url)?(o.error=x("common.invalid"),!1):l.some(S=>S.url===f&&o.url===f?!1:S.url===o.url)?(o.error=x("common.duplicate"),!1):(o.error="",!0):(o.error=x("common.required"),!1)),C=M(()=>{o.edit=!1,o.url=f||"",o.type=n||"slack",o.error="",o.loading=!1,t()}),v=M(async j=>{o.loading=!0,await r(j),o.loading=!1}),d=M(j=>()=>{h()&&j({type:o.type,url:o.url,enabled:o.enabled})}),g=R(()=>o.error?e.jsx(A,{component:"span",color:"error",children:o.error}):o.edit?o.loading?e.jsx(Y,{size:16}):e.jsx(W,{size:"small",onClick:d(v),sx:{mr:-1},children:e.jsx(E,{icon:ht})}):null,[o.error,o.edit,o.loading]);return o.edit?e.jsxs(m,{sx:{display:"flex",gap:1.5,px:1.5,width:"100%",alignItems:{xs:"flex-start",md:"center"},flexDirection:{xs:"column",md:"row"}},children:[e.jsxs(ye,{sx:{borderRadius:1,"&.Mui-disabled":{backgroundColor:"grey.50"}},disabled:!o.edit||o.loading,size:"small",value:o.type,onChange:j=>{o.type=j.target.value},children:[e.jsx(ne,{value:"api",children:x("userCenter.webhook.url")}),e.jsx(ne,{value:"slack",children:x("userCenter.webhook.slack")})]}),e.jsxs(m,{sx:{display:"flex",alignItems:"center",gap:.5,width:"100%"},children:[e.jsx(Ue,{sx:{flex:1,".MuiInputBase-root":{borderRadius:1,"&.Mui-disabled":{backgroundColor:"grey.50"}}},disabled:!o.edit||o.loading,fullWidth:!0,size:"small",required:!0,value:o.url,onChange:j=>{o.url=j.target.value,o.error="",h()},error:!!o.error,slotProps:{input:{endAdornment:e.jsx(Fe,{position:"end",children:g})}}}),e.jsx(m,{sx:{display:"flex",gap:.5},children:o.edit?e.jsxs(e.Fragment,{children:[e.jsx(W,{color:"success",onClick:d((...j)=>{s(...j),o.edit=!1}),sx:{borderRadius:1,border:"1px solid",borderColor:"grey.200"},children:e.jsx(E,{icon:rt})}),e.jsx(W,{color:"error",onClick:C,sx:{borderRadius:1,border:"1px solid",borderColor:"grey.200"},children:e.jsx(E,{icon:tt})})]}):e.jsxs(e.Fragment,{children:[e.jsx(W,{onClick:()=>{o.edit=!0},sx:{borderRadius:1,border:"1px solid",borderColor:"grey.200"},children:e.jsx(E,{icon:Ve})}),e.jsx(W,{color:"error",onClick:()=>{i({type:o.type,url:o.url})},sx:{borderRadius:1,border:"1px solid",borderColor:"grey.200"},children:e.jsx(E,{icon:Qe})})]})})]})]}):e.jsx(lr,{type:o.type,url:o.url,enabled:o.enabled,onEdit:()=>{o.edit=!0},onChange:j=>{o.enabled=j,d((...S)=>s(...S))()},onDelete:()=>{i({type:o.type,url:o.url})}})}be.propTypes={onTest:u.func,onDelete:u.func,onSave:u.func,onCancel:u.func,type:u.oneOf(["api","slack"]),url:u.string,edit:u.bool,webhooks:u.array,enabled:u.bool};function te({title:r=void 0,description:i=void 0,value:s,onChange:t,isMobile:n,type:f}){const a=M(p=>{p.stopPropagation()});return e.jsxs(m,{sx:{width:"100%",display:"flex",alignItems:"center",justifyContent:"space-between",cursor:"pointer",py:1,px:1.5,gap:.75,borderRadius:1,"&:hover":{backgroundColor:"action.hover"}},children:[e.jsxs(m,{sx:{display:"flex",alignItems:"center",gap:1},children:[f==="push"?e.jsx(E,{icon:"tabler:bell"}):e.jsx(qe,{provider:f,sx:{width:"1em",height:"1em",flexShrink:0,fontSize:16}}),e.jsxs(A,{component:"div",onClick:a,sx:{color:"text.primary",fontSize:14,display:"flex",flexWrap:n?"wrap":"nowrap",columnGap:1,flex:1,whiteSpace:n?"normal":"nowrap"},children:[r,i]})]}),e.jsx(er,{sx:{minWidth:36,flexShrink:0},checked:s,onChange:t})]})}te.propTypes={title:u.string,description:u.node,value:u.bool.isRequired,onChange:u.func.isRequired,isMobile:u.bool.isRequired,type:u.oneOf(["wallet","email","push"]).isRequired};function cr({user:r,isMobile:i}){const{t:s}=D(),t=Q({showAdd:!1}),n=ce(async()=>await F.user.getUserNotificationConfig(),{refreshDeps:[r],loadingDelay:300}),f=R(()=>({wallet:!0,email:!0,phone:!1,push:!0,...n?.data?.notifications||{}}),[n?.data?.notifications]),a=R(()=>n?.data?.webhooks||[],[n?.data?.webhooks]),p=M(async v=>{try{await F.user.saveUserNotificationConfig(v),$.success(s("userCenter.saveSuccess")),n.run()}catch(d){$.error(Z(d))}}),l=M(async(v,d)=>{await p({notifications:{[v]:d}})}),x=async v=>{try{await F.user.testNotificationWebhook(v),$.success(s("userCenter.webhookTested"))}catch(d){$.error(Z(d))}},o=M(async v=>{await p({webhooks:a.filter((d,g)=>g!==v)})}),h=M(async(v,d)=>{await p({webhooks:a.map((g,j)=>j===v?d:g)})}),C=M(async v=>{await p({webhooks:[...a,v]}),t.showAdd=!1});return n.error?e.jsx(Ar,{severity:"error",children:n.error.message}):n.loading||!n.data?e.jsx(m,{sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"100px"},children:e.jsx(Y,{})}):e.jsxs(m,{sx:{display:"flex",flexDirection:"column",".MuiSwitch-track":{borderRadius:"100vw"},".MuiSwitch-thumb":{borderRadius:"100%"},".MuiSwitch-root.MuiSwitch-sizeSmall":{height:"20px",width:"36px",".MuiSwitch-thumb":{width:"16px",height:"16px"}}},children:[e.jsxs(m,{sx:{display:"flex",flexDirection:"column",alignItems:"start",".MuiFormControlLabel-root":{gap:1,m:0,flexDirection:{xs:"row-reverse",md:"row"},width:{xs:"100%",md:"unset"}}},children:[e.jsx(te,{value:f.wallet,isMobile:i,type:"wallet",title:s("userCenter.walletNotification"),onChange:v=>l("wallet",v),description:ze(r)&&e.jsx(nt,{did:ze(r),showQrcode:!1,showAvatar:!i,copyable:!0,compact:!0,responsive:!0,startChars:i?2:6})}),e.jsx(te,{value:f.email,isMobile:i,type:"email",onChange:v=>l("email",v),title:s("userCenter.emailNotification"),description:r?.email&&e.jsx(A,{component:"span",sx:{color:"text.secondary",fontSize:13},children:r?.email})}),e.jsx(te,{isMobile:i,value:f.push,type:"push",title:s("userCenter.pushNotification"),onChange:v=>l("push",v)})]}),e.jsxs(we,{useFlexGap:!0,direction:"column",sx:{alignItems:"start"},children:[a.map((v,d)=>e.jsx(be,{enabled:v.enabled,onTest:x,onDelete:()=>o(d),onSave:(...g)=>h(d,...g),type:v.type,url:v.url,edit:!1,webhooks:a},`${d}_${v.url}`)),t.showAdd&&e.jsx(be,{onTest:x,onCancel:()=>{t.showAdd=!1},onSave:(...v)=>C(...v),edit:!0,webhooks:a},"add"),e.jsx(Ye,{variant:"outlined",size:"small",sx:{color:"text.primary",borderColor:"divider","&:hover":{borderColor:"divider"},py:.5,borderRadius:1,mt:1,ml:1.5},startIcon:e.jsx(E,{icon:xt}),onClick:()=>{t.showAdd=!0},children:s("userCenter.addWebhook")})]})]})}cr.propTypes={user:u.object.isRequired,isMobile:u.bool.isRequired};function dr({item:r}){const i=ke(),{blocklet:s}=Gr(),{confirmApi:t,confirmHolder:n}=He(),f=Q({loading:!1}),{t:a}=D(),{session:p}=y.use(le),{bindOAuth:l,unbindOAuth:x,setBaseUrl:o,baseUrl:h}=p.useOAuth(),{disconnectPasskey:C,setTargetAppPid:v}=p.usePasskey(),d=R(()=>ot[r?.provider]||"unknown",[r?.provider]),g=M(b=>b?._bind?b.provider===T.WALLET&&b.did?a("userCenter.thirdPartyLogin.walletAccountCantRemove"):b.provider===T.PASSKEY&&i.arcSphere?a("userCenter.thirdPartyLogin.dontSupportRemoveinArcSphere"):b._mainProvider&&i.arcSphere?a("userCenter.thirdPartyLogin.mainProviderCantRemove"):"":""),j=M(async()=>{if(r?.provider===T.PASSKEY){await new Promise((b,k)=>{t.open({title:a("userCenter.thirdPartyLogin.disconnectPasskey",{name:d}),content:a("userCenter.thirdPartyLogin.disconnectPasskeyDescription",{name:d}),confirmButtonText:a("common.confirm"),confirmButtonProps:{color:"error"},cancelButtonText:a("common.cancel"),onConfirm(P){C({session:p,connectedAccount:r}).then(b).catch(k),P()},onCancel:b})});return}try{f.loading=!0,await new Promise((b,k)=>{if(r?._bind)t.open({title:a("userCenter.thirdPartyLogin.confirmUnbind",{name:d}),content:a("userCenter.thirdPartyLogin.confirmUnbindDescription",{name:d}),confirmButtonText:a("common.confirm"),confirmButtonProps:{color:"error"},cancelButtonText:a("common.cancel"),onConfirm(P){x({session:p,connectedAccount:{...Nr(r,["did","pk"]),showProvider:r.provider,provider:r._rawProvider}}).then(b).catch(k),P()},onCancel:b});else if(r.provider===T.WALLET)t.open({title:a("userCenter.thirdPartyLogin.confirmBindWallet",{name:d}),content:a("userCenter.thirdPartyLogin.confirmBindWalletDescription",{name:d}),confirmButtonText:a("common.confirm"),confirmButtonProps:{color:"primary"},cancelButtonText:a("common.cancel"),onConfirm:P=>{p.bindWallet({onSuccess:b,onCancel:k}),P()},onCancel:b});else{const P=h,_=window?.blocklet;let B="/";const N=st(_),U=it(_);N&&U?.appPid&&p?.user?.sourceAppPid&&(B=U.appUrl),o(B),v(s?.appPid),l({session:p,oauthItem:{...r,provider:r._rawProvider}}).then(b).catch(k).finally(()=>{o(P),v()})}})}catch(b){console.error(`Failed to ${r?._bind?"unbind":"bind"} oauth account`,b)}finally{f.loading=!1}}),S=M(b=>b.provider===T.WALLET&&b.did?a("userCenter.thirdPartyLogin.walletAccount"):b._mainProvider?a("userCenter.thirdPartyLogin.mainAccount"):b?._bind?a("userCenter.thirdPartyLogin.disconnect"):a("userCenter.thirdPartyLogin.connect")),L=M(b=>b.provider===T.WALLET&&b.did||b.provider===T.PASSKEY&&(i.arcSphere||i.wallet)?!0:!!r._mainProvider,[i.arcSphere]);return e.jsxs(e.Fragment,{children:[e.jsxs(m,{sx:{borderRadius:1,border:"1px solid",borderColor:"divider",backgroundColor:"grey.50",display:"flex",alignItems:"center",py:1,px:1.5,gap:.75,fontSize:"14px",lineHeight:1,overflow:"hidden"},children:[e.jsx(qe,{provider:r?.provider,sx:{width:"1em",height:"1em",flexShrink:0,fontSize:16}}),e.jsx(m,{sx:{flex:1,display:{xs:r.userInfo?.email||r.did?"none":"block",sm:"block"}},children:d}),r.userInfo?.email||r.did?e.jsxs(m,{sx:{display:"flex",alignItems:"center",gap:.5,overflow:"hidden"},children:[e.jsx(m,{sx:{flex:1,textOverflow:"ellipsis",overflow:"hidden",lineHeight:"normal"},children:r.userInfo?.email||r.did}),r.userInfo?.name?e.jsx(ge,{title:e.jsxs(m,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(at,{size:36,variant:"circle",shape:"circle",src:r.userInfo?.picture,did:r.did}),e.jsxs(m,{children:[e.jsx(A,{sx:{whiteSpace:"normal",wordBreak:"break-all",fontSize:"0.9rem"},children:r.userInfo?.name}),e.jsx(A,{sx:{whiteSpace:"normal",wordBreak:"break-all",fontSize:"0.9rem"},children:r.userInfo?.email})]})]}),children:e.jsx(m,{component:E,icon:Kr,sx:{color:"text.secondary",fontSize:16,cursor:"pointer",flexShrink:0}})}):null]}):null]}),e.jsx(ge,{title:g(r),placement:"auto",children:e.jsx(m,{children:e.jsx(Ye,{variant:"outlined",size:"small",sx:b=>{const k=b.palette.error.main,P=b.palette.primary.main;return{color:r?._bind?k:P,borderColor:r?._bind?k:P,backgroundColor:"background.default","&:hover":{borderColor:r?._bind?k:P,backgroundColor:"action.hover"},py:.5,borderRadius:1,fontWeight:500,whiteSpace:"nowrap"}},fullWidth:!0,startIcon:f.loading?null:e.jsx(E,{icon:mt}),onClick:j,disabled:L(r),loading:f.loading,children:S(r)})})}),n]})}dr.propTypes={item:u.shape({provider:u.string,did:u.string,pk:u.string,userInfo:u.object,id:u.string,_bind:u.bool,_rawProvider:u.string,_mainProvider:u.bool}).isRequired};function ur({user:r}){const{session:i}=y.use(le),[s,t]=y.useState({}),{getOAuthConfigs:n}=i.useOAuth(),f=ke();Jr(async()=>{const l=await n({sourceAppPid:r?.sourceAppPid});t(l)},[r?.sourceAppPid]);const a=R(()=>{const l=Object.keys(s).map(x=>({...s[x],provider:x})).filter(x=>x.enabled);return[{provider:T.WALLET,order:-1},...l,{provider:T.PASSKEY,order:1/0}]},[s]),p=R(()=>{const l=lt(r);let x=!1,o="",h=ct(r);const C=l.find(d=>d.provider===T.AUTH0);return C&&(C.id.startsWith("google-oauth2|")&&(l.some(d=>d.provider==="google")||(x=!0,o=T.GOOGLE,h===T.AUTH0&&(h=T.GOOGLE))),C.id.startsWith("appleid|")&&(l.some(d=>d.provider===T.APPLE)||(x=!0,o=T.APPLE,h===T.AUTH0&&(h=T.APPLE))),C.id.startsWith("github|")&&(l.some(d=>d.provider===T.GITHUB)||(x=!0,o=T.GITHUB,h===T.AUTH0&&(h=T.GITHUB)))),a.map(d=>{if(d.provider===T.AUTH0&&x)return null;const g=x&&d.provider===o?l.find(j=>j.provider===T.AUTH0):l.find(j=>j.provider===d.provider);return g?{...d,provider:d.provider,did:g.did,pk:g.pk,userInfo:g.userInfo,_bind:!0,_rawProvider:g.provider,_mainProvider:d.provider===h}:{...d,provider:d.provider,_rawProvider:d.provider,_mainProvider:d.provider===h}}).filter(d=>!(!d||d.provider===T.PASSKEY&&!d.did)).sort((d,g)=>d._mainProvider?-1:d?.order!==void 0&&g?.order!==void 0?d.order-g.order:d?.order!==void 0?-1:1)},[r?.connectedAccounts,a]);return e.jsxs(m,{sx:{gap:1,display:"grid",gridTemplateColumns:"1fr min-content"},children:[p.map(l=>e.jsx(dr,{item:l},l?.provider)),f.wallet||f.arcSphere?null:e.jsx(Yr,{behavior:"only-new",action:"connect",createMode:"connect",createButtonText:"Add New Passkey",onSuccess:H,onError:H,dense:!0,sx:{px:1.5,py:1,gap:.75}})]})}ur.propTypes={user:u.object.isRequired};function pr({configList:r,onSave:i}){const[s,t]=y.useState(r),{t:n}=D(),f=M(async(a,p)=>{try{const l=await F.user.saveUserPrivacyConfig({[a]:typeof p=="string"?p:!p});t(s.map(x=>({...x,value:l?.[x.key]??x.value}))),$.success(n("userCenter.saveSuccess")),i("privacy")}catch(l){$.error(Z(l))}});return y.useEffect(()=>{t(r)},[r]),e.jsx(m,{sx:{display:"flex",flexDirection:"column",gap:1,alignItems:"start",".MuiFormControlLabel-root":{gap:1,m:0,flexDirection:{xs:"row-reverse",md:"row"},width:{xs:"100%",md:"unset"}},".MuiSwitch-track":{borderRadius:"100vw"},".MuiSwitch-thumb":{borderRadius:"100%"},".MuiSwitch-root.MuiSwitch-sizeSmall":{height:"20px",width:"36px",".MuiSwitch-thumb":{width:"16px",height:"16px"}}},children:s.map(a=>{if(a.isPrivate)return null;const p=!a.value||["all","follower-only"].includes(a.value);return e.jsxs(m,{children:[e.jsx(Le,{checked:p,labelProps:{label:e.jsx(A,{sx:{color:"text.primary",fontSize:14,display:"flex",flexFlow:"wrap",columnGap:1,flex:1},children:n("userCenter.toPublic",{name:a.name})})},size:"small",onChange:l=>{const{checked:x}=l.target;a.followersOnly?f(a.key,x?"all":"private"):f(a.key,x)}},a.key),a.followersOnly&&p&&e.jsx(m,{sx:{pl:3,pt:1},children:e.jsx(Le,{checked:a.value==="follower-only",labelProps:{label:e.jsx(A,{sx:{color:"text.primary",fontSize:14,display:"flex",flexFlow:"wrap",columnGap:1,flex:1},children:n("team.userFollowers.followersOnly")})},size:"small",onChange:l=>{const{checked:x}=l.target;f(a.key,x?"follower-only":"all")}})})]})})})}pr.propTypes={configList:u.arrayOf(u.shape({key:u.string.isRequired,name:u.string.isRequired,value:u.bool.isRequired,isPrivate:u.bool})).isRequired,onSave:u.func.isRequired};function fr({onDestroySelf:r=void 0}){const{confirmHolder:i}=He(),{t:s}=D(),{session:t}=y.use(le),n=M(async()=>{if(!r||typeof r!="function")return;const f=t.withSecondaryAuth(r,{extraParams:{removeUserDid:t?.user?.did,input:{user:{did:t?.user?.did},teamDid:window?.blocklet?.did}},operation:"destroySelf"});try{await f(),t.logout()}catch(a){$.error(a?.message||s("userCenter.destroyMyself.error"))}});return e.jsxs(e.Fragment,{children:[e.jsx(m,{children:e.jsxs(m,{sx:{display:"flex",alignItems:"center",gap:1,justifyContent:"space-between",flexWrap:"wrap"},children:[e.jsxs(m,{children:[e.jsx(A,{variant:"h6",sx:{fontSize:"0.875rem !important",fontWeight:"bold"},children:s("userCenter.dangerZone.deleteAccount")}),e.jsx(A,{variant:"caption",sx:{color:"text.secondary"},children:s("userCenter.dangerZone.deleteAccountDescription")})]}),e.jsx(G,{variant:"contained",color:"error",size:"small",onClick:n,children:s("userCenter.dangerZone.delete")})]})}),i]})}fr.propTypes={onDestroySelf:u.func};function en(){const r=de({key:"md"}),i=ve(n=>n.breakpoints.down("lg")),s={display:"flex",justifyContent:"flex-end",flexWrap:"wrap",textAlign:"right","&.expired-at > div":{maxWidth:160,justifyContent:"flex-end",flexWrap:"wrap"}},t=R(()=>Ze({},r?s:{}),[r]);return e.jsx(m,{id:"user-center-access-key-setting",sx:{maxWidth:r?"unset":i?"calc(100vw - 300px)":"100%",...r&&{".pc-access-key-table > div:nth-child(2)":{border:"1px solid",borderColor:"divider",borderRadius:1}},".MuiTableCell-head":{whiteSpace:"nowrap",fontWeight:"bold"},".MuiTableRow-root":{border:"unset","&:nth-child(even)":{backgroundColor:"grey.50","&:hover":{backgroundColor:n=>`${n.palette.grey[50]} !important`}}},".MuiTableRow-hover":{"&:hover":{backgroundColor:"inherit !important"}},".MuiTableCell-root":{paddingRight:"8px",paddingLeft:"8px",color:"text.secondary",...r&&{padding:"8px !important","&:first-child":{paddingTop:"20px!important"},"&:last-child":{paddingBottom:"20px!important"}}}},children:e.jsx(kt,{isSelf:!0,columnSx:t})})}function hr({onDestroySelf:r=void 0,userCenterTabs:i=[]}){const{t:s}=D(),{user:t,session:n,isMyself:f,isOwner:a}=ue(),l=ke().arcSphere,x=de({key:"md"}),o=ce(async()=>t&&f?await F.user.getUserPrivacyConfig({did:t.did}):null,{refreshDeps:[t,f],loadingDelay:300}),h=R(()=>i.map(d=>({key:d.value,name:d.label,value:d.protected,isPrivate:d.isPrivate,followersOnly:d.followersOnly})),[i]),C=M(async d=>d==="privacy"?(await o.runAsync(),o.data):(d==="profile"&&await n.refresh(),null));y.useEffect(()=>{const d=window.location.hash.slice(1);d&&document.getElementById(d)?.scrollIntoView({behavior:"smooth"})},[]);const v=R(()=>[l?void 0:{label:s("userCenter.commonSetting.title"),value:"common",content:e.jsx(ar,{user:t,onSave:C})},{label:s("userCenter.notificationManagement"),value:"notification",content:e.jsx(cr,{user:t,isMobile:x})},{label:s("userCenter.thirdPartyLogin.title"),value:"thirdPartyLogin",content:e.jsx(ur,{user:t})},{label:s("common.accessKeys"),value:"accessKeys",content:e.jsx(en,{isSelf:!0})},{label:s("common.mcpServers"),value:"mcpServers",content:e.jsx(wt,{})},{label:s("userCenter.privacyManagement"),value:"privacy",content:e.jsx(pr,{configList:h,onSave:C})},{label:s("userCenter.sessionManagement"),value:"session",content:e.jsx(jt,{user:t,showUser:!1,getUserSessions:d=>F.userSession.getMyLoginSessions({},d)})},!a&&r&&typeof r=="function"?{label:s("userCenter.dangerZone.title"),value:"dangerZone",content:e.jsx(fr,{onDestroySelf:r}),sx:{borderColor:"error.main"}}:null].filter(Boolean),[t,h,x,a,r]);return f?e.jsx(m,{className:"user-center-settings",sx:{display:"flex",flexDirection:"column",gap:2.5,minWidth:{md:500},"@media (min-width: 1200px) and (max-width: 1260px)":{maxWidth:750},"@media (min-width: 1100px) and (max-width: 1199px)":{maxWidth:650},"@media (min-width: 1000px) and (max-width: 1099px)":{maxWidth:600},"@media (max-width: 1049px)":{maxWidth:"100%"}},children:v.map(d=>d?e.jsxs(m,{id:d.value,sx:Ze({border:"1px solid",borderColor:"divider",borderRadius:1,p:2,"&:last-child":{mb:5}},d.sx),children:[e.jsx(A,{sx:{color:"text.primary",fontWeight:600},children:d.label}),e.jsx(m,{sx:{mt:2.5},children:d.content})]},d.value):null)}):null}hr.propTypes={onDestroySelf:u.func,userCenterTabs:u.array};const xr=y.createContext({}),{Provider:rn,Consumer:go}=xr;function mr({children:r}){const[i]=y.useState(!1),{session:s}=y.use(le),{user:t}=s,[n,f]=y.useState(),a=y.useMemo(()=>t?.didSpace?.endpoint,[t?.didSpace]);y.useEffect(()=>{f(t?.didSpace)},[t?.didSpace]);const p=async()=>{f(void 0)},l=h=>{},x=async h=>{f(h),await l(h.endpoint)},o=!!(a&&n);return e.jsx(rn,{value:{loading:i,spaceGateway:n,session:s,deleteSpaceGateway:p,updateSpaceGateway:x,storageEndpoint:a,settingStorageEndpoint:l,hasStorageEndpoint:o},children:r})}function Se(){return y.use(xr)}mr.propTypes={children:u.node.isRequired};function tn(r){const i=r.replace(/\/api\/space\/.+/,""),t=r.replace(/\/$/,"").split("/").at(-4);return se(i,"space",t)}function gr({session:r,spaceGateway:i,spaceStatus:s,refresh:t}){return e.jsxs(we,{direction:"row",spacing:1,children:[s===Pt.DISCONNECTED&&e.jsx(ie,{reconnect:!0,variant:"outlined",session:r,spaceDid:r.user?.didSpace?.did,spaceGatewayUrl:r.user?.didSpace?.url,connectScope:"user",onSuccess:async()=>{await t()},onError:n=>{console.error(n),$.error(Z(n))}}),e.jsx(W,{size:"small",LinkComponent:Er,href:tn(i.endpoint),target:"_blank",children:e.jsx(zr,{})})]})}gr.propTypes={session:u.object.isRequired,spaceGateway:u.object.isRequired,spaceStatus:u.string.isRequired,refresh:u.func.isRequired};function br({spaceGateway:r=void 0}){const{t:i}=D(),{updateSpaceGateway:s,session:t}=Se(),n=de(),f=({spaceGateway:a})=>s(a);return e.jsxs(m,{sx:{display:"flex",flexDirection:"column"},children:[e.jsxs(m,{sx:{display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"space-between",marginBottom:"12px"},children:[e.jsx(A,{sx:{fontSize:"16px",fontWeight:"bold"},children:i("userCenter.storage.spaces.connected.title")}),!n&&e.jsx(ie,{connectScope:"user",connectText:i("userCenter.storage.spaces.connected.switch"),session:t,onSuccess:f})]}),e.jsx(m,{children:r&&e.jsx(It,{endpoint:r.endpoint,deps:[r],selected:!0,footer:!0,action:a=>e.jsx(gr,{session:t,...a})},r.endpoint)}),n&&e.jsx(m,{sx:{display:"flex",alignItems:"center",justifyContent:"center",marginTop:2},children:e.jsx(ie,{connectScope:"user",connectText:i("userCenter.storage.spaces.connected.switch"),session:t,onSuccess:f})})]})}br.propTypes={spaceGateway:u.object};function nn(){const{t:r}=D(),{updateSpaceGateway:i,session:s}=Se(),t=({spaceGateway:n})=>i(n);return e.jsxs(m,{sx:{display:"flex",flexDirection:"column"},children:[e.jsx(A,{sx:{fontSize:"16px",fontWeight:"bold"},children:r("userCenter.storage.spaces.connect.providerForStorage")}),e.jsx(Tt,{viewBox:"0 0 228 258",style:{width:"156px",height:"156px",margin:"16px 0"}}),e.jsx(m,{children:e.jsx(ie,{session:s,onSuccess:t})})]})}function on(){const{spaceGateway:r,hasStorageEndpoint:i,loading:s}=Se(),{isMyself:t}=ue();return t?s?e.jsx(St,{relative:"parent",children:e.jsx(Y,{})}):e.jsx(an,{children:e.jsx(m,{sx:{maxWidth:"720px"},children:i?e.jsx(br,{spaceGateway:r}):e.jsx(nn,{})})}):null}function sn(){return e.jsx(mr,{children:e.jsx(on,{})})}const an=V(m)`
122
122
  height: 100%;
123
123
  overflow-y: auto;
124
- `;function ln(){const{user:r,isMyself:i,viewUser:s}=ue(),{followed:t}=gt();return e.jsx(m,{children:e.jsx(Ct,{teamDid:window?.blocklet?.did||"",user:i?r:s,showInvitees:i,followed:t})})}function cn({tab:r=""}){const{api:i}=Zr(),s=y.useRef(null),t=Dr(),n=r||t.tab,a=new URLSearchParams(window.location.search).get("embed")||window.sessionStorage?.getItem("embed"),p=Vr(),l=R(()=>({...window.blocklet,meta:{did:window.blocklet.did,name:window.blocklet.did},children:window?.blocklet?.componentMountPoints.map(o=>({...o,meta:{...o,did:o.did,name:o.name||o.title||"",logo:"logo.png"}}))})),x=async o=>{const{input:h,sessionId:C}=o;try{await i.destroySelf({input:{...h,sessionId:C}})}catch(v){console.error("destroy myself error",v)}};return e.jsx(pt,{mode:"user-center",children:e.jsxs(bt,{ref:s,embed:a==="1",currentTab:n?se(je.WELLKNOWN_SERVICE_PATH_PREFIX,"user",n):"",disableAutoRedirect:n==="settings",children:[n==="notifications"?e.jsx(Gt,{blocklets:[l],context:p}):null,n==="nfts"?e.jsx(Xt,{}):null,n==="settings"?e.jsx(hr,{onDestroySelf:x}):null,n==="did-spaces"?e.jsx(sn,{}):null,n==="user-followers"?e.jsx(ln,{}):null,n==="orgs"?e.jsx(yt,{id:t.id||""}):null]})})}cn.propTypes={tab:u.string};export{cn as default};
124
+ `;function ln(){const{user:r,isMyself:i,viewUser:s}=ue(),{followed:t}=gt();return e.jsx(m,{children:e.jsx(Ct,{teamDid:window?.blocklet?.did||"",user:i?r:s,showInvitees:i,followed:t})})}function cn({tab:r=""}){const{api:i}=Zr(),s=y.useRef(null),t=Lr(),n=r||t.tab,a=new URLSearchParams(window.location.search).get("embed")||window.sessionStorage?.getItem("embed"),p=Vr(),l=R(()=>({...window.blocklet,meta:{did:window.blocklet.did,name:window.blocklet.did},children:window?.blocklet?.componentMountPoints.map(o=>({...o,meta:{...o,did:o.did,name:o.name||o.title||"",logo:"logo.png"}}))})),x=async o=>{const{input:h,sessionId:C}=o;try{await i.destroySelf({input:{...h,sessionId:C}})}catch(v){console.error("destroy myself error",v)}};return e.jsx(pt,{mode:"user-center",children:e.jsxs(bt,{ref:s,embed:a==="1",currentTab:n?se(je.WELLKNOWN_SERVICE_PATH_PREFIX,"user",n):"",disableAutoRedirect:n==="settings",children:[n==="notifications"?e.jsx(Gt,{blocklets:[l],context:p}):null,n==="nfts"?e.jsx(Jt,{}):null,n==="settings"?e.jsx(hr,{onDestroySelf:x}):null,n==="did-spaces"?e.jsx(sn,{}):null,n==="user-followers"?e.jsx(ln,{}):null,n==="orgs"?e.jsx(yt,{id:t.id||""}):null]})})}cn.propTypes={tab:u.string};export{cn as default};
@@ -1,4 +1,4 @@
1
- import{E as oT,F as $m,G as Xm,H as Zm}from"./vendor-hooks-U4TTuKG0.js";import{B as qm}from"./vendor-utils-CFxoplqC.js";import{g as jL,a as JL,r as QL}from"./vendor-react-CUXIiAnY.js";/*! *****************************************************************************
1
+ import{F as oT,G as $m,H as Xm,I as Zm}from"./vendor-hooks-BZ19vVZ7.js";import{B as qm}from"./vendor-utils-D5UG1a5Y.js";import{g as jL,a as JL,r as QL}from"./vendor-react-CTtPmzVP.js";/*! *****************************************************************************
2
2
  Copyright (c) Microsoft Corporation.
3
3
 
4
4
  Permission to use, copy, modify, and/or distribute this software for any
@@ -1,4 +1,4 @@
1
- import{j as e,T as i}from"./vendor-mui-core-B5XNUjey.js";import{K as p,L as c}from"./vendor-utils-CFxoplqC.js";import{l as x}from"./vendor-ux-BX9dSNUy.js";function y({name:t,nameFormatter:r=o=>typeof o=="string"?o.split(" ").map(f=>p(c(f))).join(" "):o,layout:n="horizontal",children:a,valueComponent:l="div",nameWidth:m=90,...s}){return e.jsxs(d,{layout:n,width:m,...s,children:[e.jsx(i,{color:"textSecondary",className:"info-row__name",children:r(t)}),a&&e.jsx(i,{color:"textPrimary",component:l,className:"info-row__value",children:a})]})}const d=x("div")`
1
+ import{j as e,T as i}from"./vendor-mui-core-DnR6WYuU.js";import{aa as p,ag as c}from"./vendor-utils-D5UG1a5Y.js";import{l as x}from"./vendor-ux-DMZIE6wA.js";function y({name:t,nameFormatter:r=o=>typeof o=="string"?o.split(" ").map(f=>p(c(f))).join(" "):o,layout:n="horizontal",children:a,valueComponent:l="div",nameWidth:m=90,...s}){return e.jsxs(d,{layout:n,width:m,...s,children:[e.jsx(i,{color:"textSecondary",className:"info-row__name",children:r(t)}),a&&e.jsx(i,{color:"textPrimary",component:l,className:"info-row__value",children:a})]})}const d=x("div")`
2
2
  display: flex;
3
3
  flex-direction: ${t=>t.layout==="vertical"?"column":"row"};
4
4
  justify-content: flex-start;
@@ -0,0 +1,7 @@
1
+ import{V as B,Q as q,N as F,bk as K,aY as Ce,aZ as Se,bi as Te}from"./vendor-ux-DMZIE6wA.js";import{v as Ie,q as ae,o as Re}from"./vendor-hooks-BZ19vVZ7.js";import{r as v,a as ce}from"./vendor-react-CTtPmzVP.js";import{D as We,J as de,j as e,Y as ze,b5 as De,$ as Oe,ak as d,z as ne,T as C,a6 as U,aZ as te,R as Ae,Q as N,bX as ie,am as P,bl as _,a5 as Q,V as Z,S as G,b2 as $e,U as L,I as M,c0 as Pe,b0 as qe,a7 as Le,F as Be,W as t,b6 as W,a3 as pe,b4 as ee,c9 as Me,aO as Ne,aP as Fe,dQ as He,dR as Ue,dS as _e,s as oe,aU as Ye,aj as Ve,cv as Ke,cu as Qe,bi as Je}from"./vendor-mui-core-DnR6WYuU.js";import{Z as Y,c as ue,Q as Xe,Y as Ze,cn as J,ba as xe,bb as he,bc as me}from"./index-DwyzCfdd.js";import{S as Ge}from"./switch-rIcJ7tho.js";import{b as V}from"./team-BWkxYdcc.js";import{u as et}from"./use-mobile-BINJTzMb.js";import{u as tt,C as X}from"./index.esm-Co8ZxFyk.js";import{C as ge,a as be,J as ot}from"./vendor-utils-D5UG1a5Y.js";import{C as st}from"./confirm-Bpit6U3-.js";import{A as nt}from"./actions-Dfiiwkit.js";import{T as re}from"./table-tips-Ba9Kf02z.js";import"./lottie-web-4koyQiv_.js";import"./vendor-arcblock-DkdOhPyM.js";import"./session-Des-0R_y.js";import"./isURL-ZFgr0DWl.js";import"./use-app-logo-BAGvxEU-.js";import"./index-DBs9Ljax.js";const it=n=>{const[p,c]=v.useState(null),[f,r]=v.useState(!0),[w,u]=v.useState(null),j=window.blocklet?.appUrl,a=v.useMemo(()=>{const g={};return p&&(p.sources.forEach(y=>{g[y.did]={source:y,events:[],count:0}}),p.events.forEach(y=>{g[y.source]&&(g[y.source].events.push(y),g[y.source].count+=1)})),g},[p]),b=async()=>{try{if(r(!0),!j)return;const y=await(await fetch(ge(j,ue.WELLKNOWN_SERVICE_PATH_PREFIX,"/openevent.json"))).json();c(y),u(null)}catch(g){u(g instanceof Error?g:new Error(String(g)))}finally{r(!1)}};return v.useEffect(()=>{b()},[j]),{openEvent:p,setOpenEvent:c,eventsBySource:a,loading:f,error:w,loadData:b}};function fe({eventsBySource:n,selectedEvents:p,setSelectedEvents:c,error:f=null}){const{t:r}=B(),[w,u]=v.useState({}),j=v.useMemo(()=>{const s={};return Object.entries(n).forEach(([l,{events:m}])=>{const k=m.filter(S=>p[`${S.type}-${S.source}`]).length;s[l]=k}),s},[n,p]),a=v.useMemo(()=>Object.values(j).reduce((s,l)=>s+l,0),[j]),b=v.useMemo(()=>Object.values(n).reduce((s,{events:l})=>s+l.length,0),[n]),g=(s,l)=>{l.stopPropagation(),u({...w,[s]:!w[s]})},y=s=>{const l=`${s.type}-${s.source}`;c(m=>({...m,[l]:!m[l]}))},z=(s,l)=>{const m={};s.forEach(k=>{const S=`${k.type}-${k.source}`;m[S]=!l}),c(k=>({...k,...m}))},I=s=>{const l={};Object.values(n).forEach(({events:m})=>{m.forEach(k=>{const S=`${k.type}-${k.source}`;l[S]=s.target.checked})}),c(l)};return e.jsxs(d,{sx:{width:"100%"},children:[e.jsxs(d,{sx:{display:"flex",alignItems:"center",mb:1,mt:1},children:[e.jsx(ie,{control:e.jsx(Q,{onChange:I,checked:a>0&&a===b}),label:e.jsxs(d,{sx:{display:"flex",alignItems:"center",cursor:"pointer"},children:[r("webhookEndpoint.selectAllEvents"),e.jsx(d,{sx:{display:"flex",alignItems:"center"},children:e.jsx(P,{title:r("webhookEndpoint.selectAllEventsTooltip"),placement:"right",children:e.jsx(_,{fontSize:"small",sx:{ml:.5,cursor:"help"}})})})]}),sx:{m:0}}),a>0&&e.jsx(C,{variant:"body2",color:"primary",sx:{ml:"auto"},children:r("webhookEndpoint.selectedEventsCount",{count:a})})]}),e.jsx(d,{className:"webhook-event-selector",sx:{maxHeight:"50vh",overflowY:"auto",overflowX:"hidden"},children:e.jsx(Z,{disablePadding:!0,sx:{border:"1px solid",borderColor:"divider",borderRadius:.5},children:Object.entries(n).map(([s,{source:l,events:m,count:k}],S)=>{const D=j[s]>0,R=j[s]===m.length&&m.length>0,O=w[s];return e.jsxs(ce.Fragment,{children:[e.jsx(G,{sx:{borderBottom:({palette:i})=>S<Object.keys(n).length-1?`1px solid ${i.divider}`:"none",px:0,py:1,"&:hover":{bgcolor:"rgba(0, 0, 0, 0.02)"}},children:e.jsxs(d,{sx:{display:"flex",width:"100%",justifyContent:"space-between",alignItems:"center"},onClick:i=>{i.target.closest(".MuiFormControlLabel-root")||g(s,i)},children:[e.jsx(d,{sx:{display:"flex",alignItems:"center"},children:m.length>0&&e.jsx(ie,{control:e.jsx(Q,{checked:R,indeterminate:D&&!R,onChange:i=>{i.stopPropagation(),z(m,R)}}),label:e.jsxs(d,{sx:{display:"flex",alignItems:"center",gap:1},children:[l.logo&&e.jsx($e,{src:l.logo,sx:{width:24,height:24}}),e.jsx(d,{children:l.title||s}),D&&e.jsx(L,{label:r("webhookEndpoint.selectedCount",{count:j[s]}),size:"small",sx:{mt:"2px",height:"20px",fontSize:"12px",bgcolor:i=>`${i.palette.primary.main}20`,color:"primary.main",fontWeight:500}})]}),sx:{m:0,"& .MuiFormControlLabel-label":{flex:1}}})}),e.jsxs(d,{sx:{display:"flex",alignItems:"center"},children:[e.jsx(C,{variant:"body2",sx:{color:"text.secondary",mr:1},children:r("webhookEndpoint.eventsCount",{count:k})}),m.length>0&&e.jsx(M,{size:"small",edge:"end",children:O?e.jsx(Pe,{}):e.jsx(qe,{})})]})]})}),m.length>0&&e.jsx(Le,{in:O,timeout:"auto",unmountOnExit:!0,children:e.jsx(Z,{disablePadding:!0,sx:{p:0,bgcolor:"rgba(0, 0, 0, 0.01)"},children:m.map(i=>{const h=`${i.type}-${i.source}`,o=!!p[h];return e.jsx(G,{dense:!0,sx:{py:.75,px:1},onClick:()=>y(i),children:e.jsxs(d,{sx:{display:"flex",alignItems:"flex-start",width:"100%"},children:[e.jsx(Q,{checked:o,sx:{flexShrink:0}}),e.jsxs(d,{sx:{flex:1,minWidth:0},children:[e.jsx(C,{variant:"body1",className:"webhook-event-type",sx:{cursor:"pointer",color:"text.primary",wordBreak:"break-word",overflowWrap:"break-word"},children:i.type}),e.jsx(C,{variant:"caption",sx:{color:"text.secondary",display:"block",cursor:"pointer",wordBreak:"break-word",overflowWrap:"break-word"},children:i.description})]})]})},h)})})})]},s)})})}),f&&e.jsx(Be,{error:!0,sx:{mt:1},children:f})]})}fe.propTypes={eventsBySource:t.objectOf(t.shape({source:t.shape({did:t.string.isRequired,title:t.string,description:t.string,version:t.string,logo:t.string}).isRequired,events:t.arrayOf(t.shape({type:t.string.isRequired,description:t.string.isRequired,source:t.string.isRequired})).isRequired,count:t.number.isRequired})).isRequired,selectedEvents:t.objectOf(t.bool).isRequired,setSelectedEvents:t.func.isRequired,error:t.string};function je({id:n=null,url:p="",description:c="",enabledEvents:f=[],onSubmit:r,onClose:w=()=>{}}){const{t:u}=B(),[j,a]=v.useState({}),{teamDid:b}=V(),{api:g}=Y(),{loading:y,error:z,eventsBySource:I}=it(),s=We(),{control:l,handleSubmit:m,formState:{errors:k},reset:S,setValue:D,trigger:R}=tt({defaultValues:{url:"",description:""}}),O=de(s.breakpoints.down("md"));v.useEffect(()=>{const o=Object.values(j).some(x=>x);D("selectedEvents",o?"valid":""),R("selectedEvents")},[j,D,R]);const i=()=>{a({}),S(),w()},h=async o=>{const x=Object.keys(j).filter(T=>j[T]),E={url:o.url,description:o.description,enabledEvents:x.map(T=>{const[A,se]=T.split("-");return!A||!se?null:{type:A,source:se}}).filter(Boolean)};try{if(n){const T=await g.updateWebhookEndpoint({input:{teamDid:b,id:n,data:E}});q.success(`${u("webhookEndpoint.updateWebhook")} ${u("webhookEndpoint.success")}`),r(T)}else{const T=await g.createWebhookEndpoint({input:{teamDid:b,input:E}});q.success(`${u("webhookEndpoint.createWebhook")} ${u("webhookEndpoint.success")}`),r(T)}}catch(T){q.error(T?.message)}i()};return v.useEffect(()=>{S({url:p,description:c}),a(f.reduce((o,x)=>(o[`${x.type}-${x.source}`]=!0,o),{}))},[S,a,p,c,f]),e.jsx(ze,{open:!0,onClose:i,maxWidth:"lg",fullWidth:!0,fullScreen:O,children:e.jsxs("form",{onSubmit:m(h),children:[e.jsx(De,{children:u(n?"webhookEndpoint.editWebhookTitle":"webhookEndpoint.createWebhookTitle")}),e.jsx(Oe,{children:e.jsxs(d,{sx:{display:"flex",flexDirection:"column",gap:2,mt:2},children:[e.jsx(X,{name:"url",control:l,rules:{required:u("webhookEndpoint.validation.urlRequired"),pattern:{value:/^(http|https):\/\/[^ "]+$/,message:u("webhookEndpoint.validation.urlInvalid")}},render:({field:o})=>e.jsx(ne,{...o,label:u("webhookEndpoint.url.label"),fullWidth:!0,error:!!k.url,helperText:k.url?.message})}),e.jsx(X,{name:"description",control:l,rules:{required:u("webhookEndpoint.validation.descriptionRequired")},render:({field:o})=>e.jsx(ne,{...o,label:u("webhookEndpoint.description.label"),fullWidth:!0,multiline:!0,minRows:2,maxRows:4,error:!!k.description,helperText:k.description?.message})}),e.jsx(X,{name:"selectedEvents",control:l,rules:{required:u("webhookEndpoint.validation.eventRequired")},render:({field:o})=>e.jsx("input",{type:"hidden",...o})}),!y&&I&&Object.keys(I).length>0&&e.jsx(fe,{eventsBySource:I,selectedEvents:j,setSelectedEvents:a,error:k.selectedEvents?.message}),!y&&(!I||Object.keys(I).length===0)&&e.jsx(C,{sx:{color:"text.secondary"},children:u("webhookEndpoint.noAvailableEvents")}),y&&e.jsx(d,{sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"500px",width:"100%"},children:e.jsx(U,{size:20})}),z&&e.jsx(te,{severity:"error",children:u("webhookEndpoint.loadingError",{message:z?.message})})]})}),e.jsxs(Ae,{sx:{p:"8px 24px 24px"},children:[e.jsx(N,{onClick:i,children:u("common.cancel")}),e.jsx(N,{type:"submit",variant:"contained",color:"primary",children:u(n?"webhookEndpoint.updateWebhook":"webhookEndpoint.saveWebhook")})]})]})})}je.propTypes={onSubmit:t.func.isRequired,id:t.string,url:t.string,description:t.string,enabledEvents:t.arrayOf(t.shape({type:t.string.isRequired,source:t.string.isRequired})),onClose:t.func};function rt(n){switch(n){case"enabled":return"success";case"disabled":default:return"default"}}const lt=(n="en")=>n==="tw"?"zh":n;function H(n,p="YYYY-MM-DD HH:mm:ss",c="en"){return n?Xe(n).locale(lt(c)).format(p):"-"}function at(n){return typeof n=="number"?!1:be(n)}function ct(n){return n>=200&&n<300}function $({value:n,label:p,tip:c="",divider:f=!1}){const r=at(n);return e.jsxs(e.Fragment,{children:[e.jsxs(W,{direction:"column",alignItems:"flex-start",children:[e.jsxs(C,{component:"div",variant:"body1",mb:1,color:"text.primary",sx:{fontWeight:500},children:[p,!!c&&e.jsx(P,{title:c,children:e.jsx(_,{fontSize:"small"})})]}),e.jsx(C,{component:"div",variant:"body1",color:r?"text.disabled":"text.secondary",sx:{width:"100%",minHeight:"24px"},children:r?"-":n})]}),f&&e.jsx(pe,{orientation:"vertical",flexItem:!0})]})}$.propTypes={label:t.oneOfType([t.string,t.node]).isRequired,value:t.oneOfType([t.string,t.node]).isRequired,tip:t.oneOfType([t.string,t.node]),divider:t.bool};function ye({title:n,children:p=null,mb:c=1.5,mt:f=1.5}){return e.jsxs(W,{className:"section-header",direction:"row",sx:{justifyContent:"space-between",alignItems:"center",flexWrap:"wrap",gap:1,mb:c,mt:f,pb:1},children:[e.jsx(C,{variant:"h3",sx:{fontSize:{xs:"18px",md:"1.09375rem"}},component:"div",children:n}),p]})}ye.propTypes={title:t.oneOfType([t.string,t.node]).isRequired,children:t.node,mb:t.number,mt:t.number};const dt={width:24,height:24,body:'<path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M20 11A8.1 8.1 0 0 0 4.5 9M4 5v4h4m-4 4a8.1 8.1 0 0 0 15.5 2m.5 4v-4h-4"/>'},pt=n=>{const p={};return n.forEach(c=>{const f=new Date(c.createdAt).toLocaleDateString();p[f]||(p[f]=[]),p[f]?.push(c)}),p};function we({eventId:n="",webhookEndpointId:p="",event:c=null}){const{api:f,ws:{useSubscription:r}}=Y(),{t:w}=B(),{teamDid:u}=V(),{blocklet:j}=Ze(),{data:a,loadMore:b,loadingMore:g,loading:y,mutate:z}=Ie(o=>{const E=o?Math.ceil(o.list.length/15)+1:1;return f.getWebhookAttempts({input:{teamDid:u,input:{eventId:n,webhookId:p},paging:{page:E,pageSize:15}}})},{reloadDeps:[n,p]}),I=a?.list||[],[s,l]=v.useState(null),[m,k]=v.useState(!1),S=pt(I);if(v.useEffect(()=>{!s&&a?.list.length&&l(a.list[0])},[a?.list.length,s]),r(ue.EVENTS.WEBHOOK_ATTEMPT,o=>{z(x=>{if(x.list.find(T=>T.id===o.id)){const T=x.list.map(A=>A.id===o.id?{...A,...o}:A);return{...x,list:T}}return o.endpoint=x.list[0]?.endpoint,o.event=x.list[0]?.event,{...x,list:[o,...x.list]}})},[]),y)return e.jsx(U,{});const D=a&&a.list.length<a.paging.total,R=async()=>{s&&(k(!0),await f.retryWebhookAttempt({input:{teamDid:u,eventId:s.event.id,webhookId:p,attemptId:s.id}}).finally(()=>{setTimeout(()=>{k(!1)},1e3)}))},O=o=>{if(o.responseBody&&o.responseBody?.sessionId&&o.responseBody?.projectId&&o.responseBody?.agentId){const x=j?.site?.domainAliases[0]?.value,E=(j.children||[]).find(A=>A?.meta?.name==="ai-studio"),T=ot(ge(`https://${x}`,E?.mountPoint||"","projects",o.responseBody.projectId,"logs/main"),{sessionId:o.responseBody.sessionId,agentId:o.responseBody.agentId});return e.jsx(M,{sx:{fontSize:20},onClick:()=>window.open(T,"_blank"),children:e.jsx(d,{component:F,icon:J})})}return null},i=o=>o.status==="pending"?e.jsx(He,{color:"warning"}):ct(o.responseStatus)?e.jsx(Ue,{color:"success"}):e.jsx(_e,{color:"error"}),h=s?.triggeredFrom&&(a?.list||[]).find(o=>o.id===s.triggeredFrom);return e.jsxs(ut,{container:!0,spacing:{xs:0,md:1},sx:{height:1},children:[e.jsx(ee,{size:{xs:12,md:4},sx:{height:1},children:be(Object.keys(S))?e.jsx(C,{sx:{color:"text.secondary"},children:w("webhookEndpoint.waitingForEvents")}):e.jsxs(e.Fragment,{children:[e.jsx(Z,{sx:{maxHeight:"calc(100% - 40px)",py:0,overflowY:"auto"},children:Object.entries(S).map(([o,x])=>e.jsxs(ce.Fragment,{children:[e.jsx(Me,{sx:{p:0},children:o}),x.map(E=>e.jsxs(G,{sx:{cursor:"pointer",px:1},onClick:()=>l(E),selected:s&&s?.id===E?.id,secondaryAction:e.jsx(C,{sx:{color:"text.secondary"},children:H(E.createdAt,"HH:mm:ss")}),children:[e.jsx(Ne,{sx:{minWidth:0,mr:1.5},children:i(E)}),e.jsx(Fe,{primary:e.jsx(C,{sx:{color:"text.primary"},children:E.event.type})})]},E.id))]},o))}),D&&e.jsx(d,{sx:{display:"flex",justifyContent:"center",alignItems:"center",width:1},children:e.jsx(N,{variant:"text",type:"button",color:"inherit",onClick:b,disabled:g,sx:{color:o=>o.palette.text.disabled},children:w(g?"webhookEndpoint.loadingMore":"webhookEndpoint.loadMore")})})]})}),e.jsxs(ee,{size:{xs:12,md:8},sx:{height:1},children:[s&&e.jsxs(W,{direction:"column",spacing:2,sx:{height:1,overflow:"auto",pl:{xs:0,md:1},mt:{xs:2,md:0},borderLeft:{xs:"none"}},children:[e.jsxs(d,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs(d,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(C,{variant:"h4",children:w(`common.${s.status}`)}),e.jsx(d,{children:O(s)})]}),e.jsxs(d,{sx:{display:"flex",alignItems:"center",gap:1},children:[h&&e.jsx(P,{placement:"left",title:e.jsxs(W,{onClick:()=>l(h),sx:{gap:1,cursor:"pointer",".did-address-text":{color:"common.white"}},children:[e.jsx(xe,{showDid:!0,did:s.triggeredBy,cardType:me.Detailed,infoType:he.Minimal,sx:{border:0,padding:0,minWidth:0,".MuiTypography-root":{color:"common.white",fontWeight:400}}}),e.jsx(pe,{}),e.jsxs(d,{sx:{display:"flex",flexDirection:"column"},children:[e.jsx(C,{variant:"body2",sx:{color:"primary.main"},children:w("webhookEndpoint.triggeredFrom")}),e.jsxs(d,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(C,{variant:"body2",children:s.id}),e.jsx(M,{onClick:()=>l(h),children:e.jsx(d,{component:F,icon:J,sx:{fontSize:16,color:"common.white"}})})]})]})]}),slotProps:{tooltip:{sx:{maxWidth:400}}},children:e.jsx(M,{onClick:()=>l(h),children:e.jsx(d,{component:F,icon:J,sx:{fontSize:16}})})}),e.jsxs(N,{variant:"outlined",color:"primary",size:"small",onClick:R,disabled:m,children:[e.jsx(d,{component:F,icon:dt,sx:{fontSize:16,animation:m?"spin 1s linear infinite":"none",mr:.5}}),w("notification.resend")]})]})]}),e.jsxs(d,{children:[e.jsxs(C,{variant:"h6",children:[w("webhookEndpoint.response")," (",s.responseStatus,")"]}),e.jsx(K,{language:"json",children:JSON.stringify(s.responseBody,null,2)})]}),e.jsxs(d,{children:[e.jsx(W,{direction:"row",spacing:1,sx:{alignItems:"center"},children:e.jsx(C,{variant:"h6",children:w("webhookEndpoint.request")})}),e.jsx(K,{language:"json",sx:{margin:0},children:JSON.stringify(s.event,null,2)})]})]}),a?.list.length===0&&c&&e.jsxs(d,{children:[e.jsx(W,{direction:"row",spacing:1,sx:{alignItems:"center"},children:e.jsx(C,{variant:"h6",children:w("webhookEndpoint.eventData")})}),e.jsx(K,{language:"json",sx:{margin:0},children:JSON.stringify(c.data,null,2)})]})]})]})}we.propTypes={eventId:t.string,webhookEndpointId:t.string,event:t.shape({type:t.string,data:t.object,request:t.object,requestInfo:t.object})};const ut=oe(ee)`
2
+ @keyframes spin {
3
+ to {
4
+ transform: rotate(360deg);
5
+ }
6
+ }
7
+ `;function ke({id:n,onClose:p}){const{t:c}=B(),{api:f}=Y(),{teamDid:r}=V(),{loading:w,error:u,data:j}=ae(()=>f.getWebhookEndpoint({input:{teamDid:r,id:n}})),a=j?.data;return u?e.jsx(te,{severity:"error",children:u.message}):w||!a?e.jsx(d,{sx:{display:"flex",justifyContent:"center",alignItems:"center",height:1,width:1},children:e.jsx(U,{})}):e.jsxs(xt,{direction:"column",sx:{height:{xs:"auto",md:1}},children:[e.jsxs(d,{children:[e.jsxs(W,{direction:"row",sx:{justifyContent:"space-between",alignItems:"center"},children:[e.jsx(W,{sx:{flex:1,width:0},children:e.jsxs(d,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(C,{variant:"h5",sx:{fontWeight:600,overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis"},children:a.description}),e.jsx(P,{title:a.url,children:e.jsx(_,{sx:{fontSize:"16px",marginTop:"2px"}})})]})}),e.jsx(W,{direction:"row",sx:{alignItems:"center"},children:e.jsx(M,{edge:"end",color:"inherit",onClick:p,children:e.jsx(Ve,{})})})]}),e.jsx(d,{sx:{mt:2},children:e.jsxs(W,{className:"section-body",direction:{xs:"column",md:"row"},spacing:{xs:1,md:3},sx:{justifyContent:"flex-start",flexWrap:"wrap",pt:2,mt:2,borderTop:"1px solid #eee"},children:[e.jsx($,{label:c("common.status"),value:e.jsx(L,{size:"small",variant:"filled",label:a.status,color:rt(a.status),sx:{borderRadius:"4px",lineHeight:"20px",textTransform:"capitalize"}}),divider:!0}),e.jsx($,{label:c("webhookEndpoint.listen"),value:e.jsx(P,{arrow:!0,title:e.jsx("ul",{style:{padding:0,margin:0},children:a.enabledEvents.map(b=>e.jsx("li",{style:{fontSize:"0.7875rem"},children:b?.type},b))}),children:e.jsx(L,{size:"small",variant:"filled",label:c("webhookEndpoint.eventsCount",{count:a.enabledEvents.length}),sx:{borderRadius:"4px",lineHeight:"20px",textTransform:"capitalize"}})}),divider:!0}),e.jsx($,{label:c("webhookEndpoint.version"),value:a.apiVersion,divider:!0}),e.jsx($,{label:c("common.createdAt"),value:H(a.createdAt),divider:!0}),e.jsx($,{label:c("common.updatedAt"),value:H(a.updatedAt),divider:!0}),e.jsx($,{label:c("common.createdBy"),value:e.jsx(P,{arrow:!0,title:a.createUser?.did,children:e.jsx(L,{size:"small",variant:"filled",label:a.createUser?.fullName,sx:{borderRadius:"4px",lineHeight:"20px",textTransform:"capitalize"}})}),divider:!0}),e.jsx($,{label:c("common.updatedBy"),value:e.jsx(P,{arrow:!0,title:a.updateUser?.did,children:e.jsx(L,{size:"small",variant:"filled",label:a.updateUser?.fullName,sx:{borderRadius:"4px",lineHeight:"20px",textTransform:"capitalize"}})})})]})})]}),e.jsxs(W,{className:"section",sx:{flex:1,height:0,overflow:"hidden"},children:[e.jsx(ye,{title:c("webhookEndpoint.attempts"),mb:0,mt:4}),e.jsx(W,{sx:{height:0,flex:1,overflow:"hidden"},children:e.jsx(we,{webhookEndpointId:a.id})})]})]})}ke.propTypes={id:t.string.isRequired,onClose:t.func.isRequired};const xt=oe(W)``;function Ee({open:n,onClose:p,id:c}){return e.jsx(Ye,{anchor:"right",open:n,onClose:p,slotProps:{paper:{sx:{width:"90vw",maxWidth:"1200px"}}},children:e.jsx(d,{sx:{height:"100vh",p:3},children:e.jsx(ke,{id:c,onClose:p})})})}Ee.propTypes={open:t.bool.isRequired,onClose:t.func.isRequired,id:t.string.isRequired};function le(){return null}function ve({options:n={},columns:p=[],toolbar:c=!0,footer:f=!0,hasRowLink:r=!1,emptyNodeText:w="",durable:u="",durableKeys:j=[],data:a=[],loading:b=!1,...g}){const{locale:y}=B(),z=de(l=>l.breakpoints.down("md")),I={print:!1,download:!1,filter:!1,selectableRows:"none",rowsPerPage:z?5:10,rowsPerPageOptions:[5,10,20,50,100],searchDebounceTime:300,tableBodyHeight:"100%",loading:!0},s={};return c||(s.TableToolbar=le),f||(s.TableFooter=le),e.jsx(ht,{locale:y,options:{...I,...n},columns:(p||[]).map(l=>(l.options=l.options||{},l.options.filter=l.options.filter||!1,l.options.sort=l.options.sort||!1,l)),emptyNode:e.jsx(Ce,{children:w}),...g,durable:u,durableKeys:j,data:a,loading:b,components:s,hasRowLink:r,isMobile:z})}ve.propTypes={options:t.object,columns:t.array,toolbar:t.bool,footer:t.bool,hasRowLink:t.bool,emptyNodeText:t.node,durable:t.string,durableKeys:t.array,data:t.array,loading:t.bool,onChange:t.func,title:t.node,components:t.object};const ht=oe(Se)``,mt=v.memo(ve);function $t(){const{teamDid:n}=V(),p=et(),c=`webhook-endpoints-${n}`,f=Te(c),{t:r,locale:w}=B(),{api:u}=Y(),[j,a]=v.useState(""),[b,g]=v.useState({webhookDetail:{open:!1,id:null},createEdit:{open:!1,id:null,url:"",description:"",enabledEvents:[]},deleteConfirm:null}),[y,z]=Re(c,{defaultValue:{pageSize:f.rowsPerPage||20,page:f.page?f.page+1:1}}),{loading:I,error:s,data:l,refresh:m}=ae(()=>u.getWebhookEndpoints({input:{teamDid:n,paging:{page:y.page,pageSize:y.pageSize}}}));v.useEffect(()=>{m()},[y,m]);const k=v.useCallback(async(i,h)=>{try{await u.updateWebhookEndpoint({input:{teamDid:n,id:i.id,data:{status:h?"disabled":"enabled"}}}),m(),q.success(`${r(h?"webhookEndpoint.disable":"webhookEndpoint.enable")}${r("webhookEndpoint.success")}`)}catch(o){q.error(o?.message)}},[u,n,m,r]),S=v.useCallback(async i=>{try{await u.deleteWebhookEndpoint({input:{teamDid:n,id:i}}),m(),g(h=>({...h,deleteConfirm:null})),q.success(`${r("common.delete")}${r("webhookEndpoint.success")}`)}catch(h){q.error(h?.message)}},[u,n,m,r]),D=(i,h)=>{let o=i.page+1;const x=i.searchText||"";if(x!==j){a(x);return}if(h==="changePage"||h==="changeRowsPerPage"){h!=="changePage"&&(o=1);const E={page:o,pageSize:i.rowsPerPage};a(""),z(E)}};if(s)return e.jsx(te,{severity:"error",children:s.message});const R=(l?.list||[]).filter(i=>{if(!j)return!0;const h=j.toLowerCase();return i.description.toLowerCase().includes(h)||i.url.toLowerCase().includes(h)}),O=[{label:"URL",name:"url",options:{customBodyRenderLite:(i,h)=>{const o=R[h];return e.jsxs(d,{sx:{display:"flex",alignItems:"center",cursor:"pointer",gap:.5},children:[e.jsx(C,{variant:"body2",children:o.description}),e.jsx(d,{sx:{display:"flex"},onClick:x=>{x.stopPropagation()},children:e.jsx(P,{title:o.url,children:e.jsx(_,{sx:{fontSize:"15px",marginTop:"1px"}})})})]})}}},{label:"Events",name:"events",options:{customBodyRenderLite:(i,h)=>{const o=R[h];return e.jsx(d,{sx:{display:"flex",alignItems:"center",gap:1,flexWrap:"wrap"},children:o.enabledEvents.map(x=>e.jsx(L,{size:"small",variant:"filled",label:x.type,sx:{borderRadius:"4px",textTransform:"capitalize"}},`${o.source}-${x.type}`))})}}},{label:r("common.status"),name:"status",options:{customBodyRenderLite:(i,h)=>{const o=R[h],x=o?.status==="enabled";return e.jsx(d,{onClick:E=>E.stopPropagation(),children:e.jsx(Ge,{checked:x,onChange:()=>k(o,x)},`status-${o.status}`)})}}},{label:r("common.createdAt"),name:"createdAt",minWidth:200,options:{customBodyRender:i=>H(i)}},{label:r("common.createdBy"),name:"createUser",width:100,options:{customBodyRender:i=>i?e.jsx(xe,{showDid:!0,did:i?.did,cardType:me.Detailed,infoType:he.Minimal,sx:{border:0,padding:0}}):"-"}},{label:r("common.actions"),name:"actions",width:100,align:"center",verticalKeyAlign:"center",options:{customBodyRenderLite:(i,h)=>{const o=R[h];return e.jsx(nt,{actions:[{icon:e.jsx(Ke,{}),text:r("common.edit"),onClick:x=>{x.stopPropagation(),g(E=>({...E,createEdit:{open:!0,id:o.id,url:o.url,description:o.description,enabledEvents:o.enabledEvents}}))}},{icon:e.jsx(Qe,{}),text:r("common.delete"),onClick:x=>{x.stopPropagation(),g(E=>({...E,deleteConfirm:{title:r("webhookEndpoint.deleteWebhook.title"),description:r("webhookEndpoint.deleteWebhook.description"),confirm:r("common.confirm"),cancel:r("common.cancel"),onConfirm:()=>S(o.id),onCancel:()=>g(T=>({...T,deleteConfirm:null}))}}))}}]})}}}];return e.jsxs(d,{sx:{".custom-toobar-btns":{gap:"8px"},".custom-toobar-title .custom-toobar-title-inner>span":{display:"flex",alignItems:"center","white-space":"inherit",height:"100%"}},children:[p?e.jsx(re,{title:r("webhookEndpoint.listTitle"),tooltipTitle:r("webhookEndpoint.tooltipTitle"),link:`https://www.arcblock.io/docs/blocklet-developer/${w}/webhook`}):null,e.jsx(mt,{durable:c,durableKeys:["page","rowsPerPage"],data:R,columns:O,options:{count:l?.count||0,page:y.page-1,rowsPerPage:y.pageSize,viewColumns:!1,onRowClick:(i,{dataIndex:h})=>{const o=l.list[h];g(x=>({...x,webhookDetail:{open:!0,id:o.id}}))}},loading:I||!l,onChange:D,emptyNodeText:e.jsx(W,{sx:{gap:1},children:r("webhookEndpoint.noWebhooksAdded")}),title:p?null:e.jsx(re,{title:r("webhookEndpoint.listTitle"),tooltipTitle:r("webhookEndpoint.tooltipTitle"),link:`https://www.arcblock.io/docs/blocklet-developer/${w}/webhook`}),customButtons:[e.jsxs(N,{edge:"end",variant:"contained",color:"primary",onClick:()=>g(i=>({...i,createEdit:{...i.createEdit,open:!0}})),className:"rule-action",children:[I?e.jsx(U,{size:16}):e.jsx(Je,{style:{fontSize:16}}),r("common.create")]},"add")]}),b.webhookDetail.open&&e.jsx(Ee,{open:!0,onClose:()=>g(i=>({...i,webhookDetail:{open:!1,id:null}})),id:b.webhookDetail.id}),b.createEdit.open&&e.jsx(je,{onSubmit:m,...b.createEdit,onClose:()=>g(i=>({...i,createEdit:{id:null,url:"",description:"",enabledEvents:[],open:!1}}))}),b.deleteConfirm&&e.jsx(st,{title:b.deleteConfirm.title,description:b.deleteConfirm.description,confirm:b.deleteConfirm.confirm,cancel:b.deleteConfirm.cancel,params:b.deleteConfirm.params,onConfirm:b.deleteConfirm.onConfirm,onCancel:b.deleteConfirm.onCancel})]})}export{$t as default};
@@ -1,5 +1,5 @@
1
- import{j as e,W as m,a6 as z,T as j,at as Ne,D as _e,cM as V,ao as J,cN as We,ak as h,b1 as K,a$ as Ke,s as fe,cO as be,co as Ge,am as ge,cq as Fe,M as F,aO as Y,bX as Ye,aP as $,Q as $e,be as qe,aR as He,cP as Qe,cQ as Xe,cR as Ve,cS as Je,c2 as he}from"./vendor-mui-core-B5XNUjey.js";import{k as Ze,j as ke,a as ue}from"./vendor-hooks-U4TTuKG0.js";import{r as b,u as et}from"./vendor-react-CUXIiAnY.js";import{ac as M,_ as N,a1 as E,J as L,aQ as tt,aR as st,aI as nt,c as I,v as ot}from"./index-Dijoh4El.js";import{H as B,V as D,p as at,Q as q,h as rt,W as it,n as le,j as ct}from"./vendor-ux-BX9dSNUy.js";import{u as lt}from"./use-mobile-Vtj5nBdp.js";import{a as H,d as je,a1 as dt,c as pt,D as Ce,C as me}from"./vendor-utils-CFxoplqC.js";import{o as we}from"./vendor-arcblock-D4Rvz_D3.js";import{b as ut,u as mt,D as xt,c as de,a as ft}from"./index-DHn4LCaq.js";import"./index-C0q1NhNR.js";import"./index-BojVbZw0.js";import"./api-Cjc501Es.js";import{u as Be,C as gt,D as ht,a as St}from"./connect-to-D3C0j8V8.js";import{b as yt,c as bt,d as kt,i as jt,e as xe,f as Ct,h as wt,j as Bt}from"./spaces-DM95DgFM.js";import{f as Q}from"./index-DBs9Ljax.js";import{v as Dt}from"./index-BjLM8Gon.js";import{u as Et}from"./dashboard-DHhNID_3.js";import{E as Tt}from"./index-DK4Rvfj9.js";import{x as It}from"./index-DRYJ0xIl.js";import{g as Se}from"./get-safe-url-pZvXlaJu.js";import{S as Rt}from"./switch-control-BAyRLHvJ.js";import{C as Pt,u as vt}from"./config-space-3dNLmLWy.js";import{L as ye}from"./list-header-BQo9L_6R.js";import"./lottie-web-4koyQiv_.js";import"./session-DUT2afHJ.js";import"./team-HgvOpVEJ.js";import"./isURL-wZZwzwyC.js";import"./use-app-logo-D9eQSUYq.js";import"./useAsyncRetry-CSW1hopB.js";import"./useAsync-DNDhrs-2.js";import"./useSetState-cWrp7qoX.js";import"./index-BRGQOPmE.js";import"./over-due-invoice-payment-EIjXZOAF.js";import"./useLocalStorage-oIIa9C3F.js";import"./confirm-BIsS5xyi.js";import"./passport-BcfDxGFq.js";import"./create-passport-svg-BwqsyTOz.js";import"./index-BOiRUuPB.js";async function At({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 At({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:zs}=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)},G=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,A)=>{try{x(R=>{const v=[...R];return v.push({...g,loading:!0}),v}),await a.addBlockletSpaceGateway({input:{did:s.meta.did,spaceGateway:g}}),u!==A&&await a.configBlocklet({input:{did:[s.meta.did],configs:[{key:L.BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_APP_BACKUP_ENDPOINT,value:A}]}}),U(g),P(),B.success(o("storage.spaces.connectedWithName",{name:g?.name??"DID Spaces"}))}catch(R){throw console.error(R),x(v=>[...v].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 G({enabled:!1})),await a.deleteBlockletSpaceGateway({input:{did:s.meta.did,spaceGatewayDid:g?.did}}),x(A=>{const R=[...A];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:G,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
- `)},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(K,{direction:s?"column":"row",spacing:s?2:1,sx:{width:"100%",justifyContent:"flex-start",alignItems:s?"flex-start":"center"},children:[e.jsxs(K,{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(K,{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(K,{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 ve({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(Fe,{style:{width:"24px",height:"24px"},color:"error"})})})]})}ve.propTypes={status:m.string.isRequired,message:m.string,createdAt:m.string.isRequired};function Ae({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(Ge,{style:{width:"24px",height:"24px"},color:"primary"})})})]})}Ae.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(Ke,{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(Ae,{metadata:f}):e.jsx(ve,{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(F,{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(F,{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(F,{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(F,{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(F,{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,G=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 A=g(C.endpoint),R=xe(A),v=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:v?.name?v.name:""});B.error(W),s?.(new Error(W),t);return}const ce={...t,name:v.name??"DID Space",did:v.did??xe(A),endpoint:A};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")}),G&&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:G})]})}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 Kt({...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 Gt({...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 Ft(){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(Gt,{}),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(Kt,{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(Ft,{})}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}=vt(),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(K,{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(K,{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)`
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 X,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 Je,ec as Ve,dF as Xe,b4 as he}from"./vendor-mui-core-DnR6WYuU.js";import{q as Ze,l as ke,a as ue}from"./vendor-hooks-BZ19vVZ7.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,bH as tt,bW as st,al as nt,c as I,l as ot}from"./index-DwyzCfdd.js";import{Q as B,V as D,b2 as at,b4 as q,aZ as rt,R as it,J as le,b3 as ct}from"./vendor-ux-DMZIE6wA.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-D5UG1a5Y.js";import{o as we}from"./vendor-arcblock-DkdOhPyM.js";import{a as ut,u as mt,c as xt,D as de,b as ft}from"./index-OMkyTUNX.js";import"./index-D29her4n.js";import"./index-BojVbZw0.js";import"./api-C75sLx9p.js";import{u as Be,C as gt,D as ht,a as St}from"./connect-to-BsxW3JJi.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-2YPkTkBR.js";import{f as Q}from"./index-DBs9Ljax.js";import{v as Dt}from"./index-CaTDaKrX.js";import{a as Et}from"./dashboard-DBwE7l6f.js";import{E as Tt}from"./index-CZBIYuko.js";import{x as It}from"./index-DRYJ0xIl.js";import{g as Se}from"./get-safe-url-gaxZoVzJ.js";import{S as Rt}from"./switch-control-CzYig10w.js";import{C as Pt,u as At}from"./config-space-Dw6ITGIj.js";import{L as ye}from"./list-header-Cl3jykCe.js";import"./lottie-web-4koyQiv_.js";import"./session-Des-0R_y.js";import"./team-BWkxYdcc.js";import"./isURL-ZFgr0DWl.js";import"./use-app-logo-BAGvxEU-.js";import"./useAsyncRetry-BnuUJFwY.js";import"./useAsync-CxjyODHb.js";import"./useSetState-L-f8mSga.js";import"./index-D_u0j8BO.js";import"./over-due-invoice-payment-1EZsSUm4.js";import"./useLocalStorage-Bj52e1ZW.js";import"./confirm-Bpit6U3-.js";import"./passport-Dg1YWagy.js";import"./create-passport-svg-DGPNsGUE.js";import"./index-D24LKXzO.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:zs}=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}})},J=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:J,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
+ `)},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:X[300]},{min:3,max:6,color:X[400]},{min:6,max:9,color:X[500]},{min:9,max:Number.MAX_SAFE_INTEGER,color:X[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(Je,{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(Xe,{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,J=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:J,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:J,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;
5
5
  overflow: hidden;
@@ -0,0 +1 @@
1
+ import{r as l}from"./vendor-react-CTtPmzVP.js";import{V as C,$ as E,b3 as M,bk as P}from"./vendor-ux-DMZIE6wA.js";import{q as y}from"./vendor-hooks-BZ19vVZ7.js";import{j as e,ak as s,a6 as S,aZ as w,b6 as W,y as L,x as _,bZ as B,M as D,T as z,bb as A,I as K,cC as N,Q as F,W as q}from"./vendor-mui-core-DnR6WYuU.js";import{c as T,Z as k}from"./index-DwyzCfdd.js";import{a as U}from"./api-C75sLx9p.js";import{T as V}from"./table-tips-Ba9Kf02z.js";import{b as Z}from"./team-BWkxYdcc.js";import{u as G}from"./session-Des-0R_y.js";import"./vendor-utils-D5UG1a5Y.js";import"./lottie-web-4koyQiv_.js";import"./vendor-arcblock-DkdOhPyM.js";import"./use-mobile-BINJTzMb.js";import"./isURL-ZFgr0DWl.js";import"./use-app-logo-BAGvxEU-.js";function $({endpoint:i}){const[t,a]=l.useState("mcp-link"),x=k(),{api:h}=k(),{teamDid:m}=Z(),{t:c,locale:p}=C(),{session:r}=G(),{data:u,run:o,loading:b}=y(()=>{const f={owner:T.SERVER_ROLES.ADMIN}[r?.user?.role]||r?.user?.role;return h.createAccessKey({input:{teamDid:m,passport:f,authType:"simple",remark:"Generated by MCP Servers"}})},{manual:!0}),{imgPrefix:n}=x,j=l.useMemo(()=>[{icon:e.jsx(s,{sx:{width:20,height:20},children:"🔗"}),value:"mcp-link",label:"MCP Link"},{icon:e.jsx(s,{component:"img",src:`${n}/mcp/claude.webp`,alt:"Claude",sx:{width:20,height:20}}),value:"claude",label:"Claude"},{icon:e.jsx(s,{component:"img",src:`${n}/mcp/cursor.png`,alt:"Cursor",sx:{width:20,height:20}}),value:"cursor",label:"Cursor"},{icon:e.jsx(s,{component:"img",src:`${n}/mcp/cline.png`,alt:"Cline",sx:{width:20,height:20}}),value:"cline",label:"Cline"},{icon:e.jsx(s,{component:"img",src:`${n}/mcp/roocline.png`,alt:"Roo Cline",sx:{width:20,height:20}}),value:"roo-cline",label:"Roo Cline"},{icon:e.jsx(s,{component:"img",src:`${n}/mcp/windsurf.png`,alt:"Windsurf",sx:{width:20,height:20}}),value:"windsurf",label:"Windsurf"},{icon:e.jsx(s,{component:"img",src:`${n}/mcp/witsy.png`,alt:"Witsy",sx:{width:20,height:20}}),value:"witsy",label:"Witsy"}],[n]),v=j.find(d=>d.value===t),g=l.useMemo(()=>u?.data?.accessKeySecret,[u]),R=l.useMemo(()=>!g&&t!=="mcp-link",[g,t]),I=d=>{const f=`npx @blocklet/install-mcp@latest i ${i} --client ${d} --streamableHTTP --oauth2Bearer ${g}`;switch(d){case"cursor":case"claude":case"cline":case"roo-cline":case"windsurf":case"witsy":return f;case"mcp-link":default:return i}};return e.jsxs(s,{className:"mcp-servers-container",children:[e.jsx(M,{tabs:j,current:t,onChange:a,scrollButtons:"auto",iconPosition:"start"}),e.jsxs(s,{children:[e.jsxs(s,{sx:{display:"flex",alignItems:"center",gap:.5},children:[e.jsx(z,{component:"span",variant:"h6",sx:{fontWeight:"bold",my:2},children:t==="mcp-link"?v?.label:`${v?.label} ${c("installCommand")}`}),t!=="mcp-link"&&e.jsx(A,{href:`https://www.arcblock.io/docs/blocklet-developer/${p}/mcp-${t}`,target:"_blank",rel:"noopener noreferrer",children:e.jsx(K,{size:"small",children:e.jsx(N,{fontSize:"small"})})})]}),e.jsxs(s,{className:"mcp-servers-codeblock",sx:{position:"relative","& pre":{borderRadius:1},"& .codeblock__inner":{overflow:"auto !important",borderRadius:1}},children:[e.jsx(P,{code:I(t),language:"shell",style:{margin:0},showDefaultText:!1}),R&&e.jsx(s,{sx:{position:"absolute",top:0,right:0,left:0,bottom:0,display:"flex",alignItems:"center",justifyContent:"center",bgcolor:"action.active",backdropFilter:"blur(3px)",WebkitBackdropFilter:"blur(3px)",zIndex:1},children:b?e.jsx(S,{}):e.jsx(F,{variant:"contained",color:"primary",onClick:o,size:"small",children:`${c("common.generate")} ${c("command")}`})})]})]})]})}$.propTypes={endpoint:q.string.isRequired};function ce(){const[i,t]=l.useState(null),{t:a,locale:x}=C(),h=`${window?.blocklet?.appUrl}${T.WELLKNOWN_SERVICE_PATH_PREFIX}/mcp/servers`,{data:m,loading:c,error:p}=y(()=>Promise.all([U.get(h)])),r=l.useMemo(()=>m?.[0]?.data?.servers||[],[m]);l.useEffect(()=>{r?.length&&t(r.find(o=>o.did===window?.blocklet?.did)||r[0])},[r]);const u=o=>{const b=o.target.value;t(r.find(n=>n.did===b))};return c?e.jsx(s,{children:e.jsx(S,{})}):p?e.jsx(w,{color:"error",children:p?.message}):r?.length?e.jsxs(W,{sx:{gap:2,maxWidth:1200},children:[e.jsx(V,{title:a("mcp.listTitle"),tooltipTitle:a("mcp.tooltipTitle"),link:`https://www.arcblock.io/docs/blocklet-developer/${x}/mcp-server`}),e.jsxs(L,{fullWidth:!0,children:[e.jsx(_,{id:"server-select-label",children:a("mcp.available")}),e.jsx(B,{labelId:"server-select-label",value:i?.did||"",label:a("mcp.available"),onChange:u,children:r.map(o=>e.jsx(D,{value:o.did,children:e.jsxs(s,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(E,{variant:"rounded",shape:"square",did:o.did,src:o.logo,size:20}),e.jsx(s,{sx:{fontSize:14},children:o.name})]})},o.did))})]}),i&&e.jsx($,{endpoint:i.endpoint})]}):e.jsx(w,{color:"warning",children:a("mcp.noServer")})}export{ce as default};
@@ -1 +1 @@
1
- import{j as i,b6 as e,bg as a,W as s}from"./vendor-mui-core-B5XNUjey.js";import{l}from"./vendor-ux-BX9dSNUy.js";const r=l(t=>i.jsx(a,{focusVisibleClassName:".Mui-focusVisible",disableRipple:!0,...t}))(({theme:t})=>({width:42,height:26,padding:0,"& .MuiSwitch-switchBase":{padding:0,margin:2,transitionDuration:"300ms","&.Mui-checked":{transform:"translateX(16px)",color:"#fff","& + .MuiSwitch-track":{backgroundColor:t.palette.primary.main,opacity:1,border:0},"&.Mui-disabled + .MuiSwitch-track":{opacity:.5}},"&.Mui-focusVisible .MuiSwitch-thumb":{color:t.palette.primary.main,border:"6px solid #fff"},"&.Mui-disabled .MuiSwitch-thumb":{color:t.palette.mode==="light"?t.palette.grey[100]:t.palette.grey[600]},"&.Mui-disabled + .MuiSwitch-track":{opacity:t.palette.mode==="light"?.7:.3}},"& .MuiSwitch-thumb":{boxSizing:"border-box",width:22,height:22},"& .MuiSwitch-track":{borderRadius:26/2,backgroundColor:t.palette.grey[200],opacity:1,transition:t.transitions.create(["background-color"],{duration:500})}}));function c({labelProps:t=null,...o}){return t?i.jsx(e,{control:i.jsx(r,{...o}),...t}):i.jsx(r,{...o})}c.propTypes={labelProps:s.object};export{c as u};
1
+ import{j as i,bX as e,bn as a,W as s}from"./vendor-mui-core-DnR6WYuU.js";import{l}from"./vendor-ux-DMZIE6wA.js";const r=l(t=>i.jsx(a,{focusVisibleClassName:".Mui-focusVisible",disableRipple:!0,...t}))(({theme:t})=>({width:42,height:26,padding:0,"& .MuiSwitch-switchBase":{padding:0,margin:2,transitionDuration:"300ms","&.Mui-checked":{transform:"translateX(16px)",color:"#fff","& + .MuiSwitch-track":{backgroundColor:t.palette.primary.main,opacity:1,border:0},"&.Mui-disabled + .MuiSwitch-track":{opacity:.5}},"&.Mui-focusVisible .MuiSwitch-thumb":{color:t.palette.primary.main,border:"6px solid #fff"},"&.Mui-disabled .MuiSwitch-thumb":{color:t.palette.mode==="light"?t.palette.grey[100]:t.palette.grey[600]},"&.Mui-disabled + .MuiSwitch-track":{opacity:t.palette.mode==="light"?.7:.3}},"& .MuiSwitch-thumb":{boxSizing:"border-box",width:22,height:22},"& .MuiSwitch-track":{borderRadius:26/2,backgroundColor:t.palette.grey[200],opacity:1,transition:t.transitions.create(["background-color"],{duration:500})}}));function c({labelProps:t=null,...o}){return t?i.jsx(e,{control:i.jsx(r,{...o}),...t}):i.jsx(r,{...o})}c.propTypes={labelProps:s.object};export{c as u};