@abtnode/blocklet-services 1.17.3-beta-20251117-130331-b2ce7065 → 1.17.3-beta-20251118-061144-335cd35d

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 (211) hide show
  1. package/api/middlewares/verify-sig.js +14 -4
  2. package/api/services/auth/session.js +1 -1
  3. package/dist/assets/{AdapterDayjs-CSsn7VEX.js → AdapterDayjs-C8RSaHa0.js} +1 -1
  4. package/dist/assets/{Google-C-Ei9n0a.js → Google-BT1deiYa.js} +1 -1
  5. package/dist/assets/{access-control-D0vxk-Ay.js → access-control-Ddnn1J4F.js} +1 -1
  6. package/dist/assets/{actions-C0hEY5iN.js → actions-DqoNrBDK.js} +1 -1
  7. package/dist/assets/{add-component-core-7Qng0h9D.js → add-component-core-CZQBpP2b.js} +15 -15
  8. package/dist/assets/{add-resource-CS6pw4MD.js → add-resource-DUXwdNKB.js} +1 -1
  9. package/dist/assets/{addon-B5iZc5zB.js → addon-BgN564dt.js} +2 -2
  10. package/dist/assets/{advanced-QXzUapJI.js → advanced-D9d385yZ.js} +2 -2
  11. package/dist/assets/{aigne-CviOmneT.js → aigne-BK9oL3LS.js} +1 -1
  12. package/dist/assets/api-Btn0Tp3W.js +1 -0
  13. package/dist/assets/{appearance-CkaT_h9I.js → appearance-BLjBQMnd.js} +1 -1
  14. package/dist/assets/{arrow-down.svg-CDi8ywws.js → arrow-down.svg-Uxqj9Lez.js} +1 -1
  15. package/dist/assets/{audit-logs-D2VdqDH8.js → audit-logs-B9JmO_5U.js} +2 -2
  16. package/dist/assets/{authorize-BJr_whxb.js → authorize-BseET0LV.js} +1 -1
  17. package/dist/assets/{base-chart-BIsPFns6.js → base-chart-C-Raz4Q-.js} +1 -1
  18. package/dist/assets/{base32-cypJRki8.js → base32-DB18VP05.js} +1 -1
  19. package/dist/assets/bind-account-DWu2ZbPT.js +1 -0
  20. package/dist/assets/{branding-wKKLyZjs.js → branding-CPYtF-6a.js} +5 -5
  21. package/dist/assets/{branding-B7OUNmDC.js → branding-CmMCHUpY.js} +1 -1
  22. package/dist/assets/branding-DO47QT9Q.js +1 -0
  23. package/dist/assets/{bundle-avatar-Bft1K1fA.js → bundle-avatar-B9iCn_eS.js} +1 -1
  24. package/dist/assets/button-Bm6Z4hYZ.js +1 -0
  25. package/dist/assets/{click-to-copy-Kd1YilQn.js → click-to-copy-CzGMi2Jw.js} +1 -1
  26. package/dist/assets/{cloneDeep-3LGZOUYL.js → cloneDeep-C6qewg0C.js} +1 -1
  27. package/dist/assets/{collapse-Cc8IqFzl.js → collapse-BMy0GGFk.js} +1 -1
  28. package/dist/assets/{complete-FhkNOVEb.js → complete-DFxZ9mZl.js} +1 -1
  29. package/dist/assets/{component-YEpcN0PM.js → component-CmpGxsIf.js} +2 -2
  30. package/dist/assets/{config-ABsyghax.js → config-BMeucuGh.js} +1 -1
  31. package/dist/assets/{config-CfZ5vdbi.js → config-Bg2nv4Ct.js} +5 -5
  32. package/dist/assets/{config-BH7esTqa.js → config-Dj032f65.js} +1 -1
  33. package/dist/assets/{config-navigation-C2Cya4Ts.js → config-navigation-Wws6cRZg.js} +2 -2
  34. package/dist/assets/{config-space-k6_NPjjD.js → config-space-DVbXpK0p.js} +1 -1
  35. package/dist/assets/{confirm-BWGQvLZx.js → confirm-D_oS4C5N.js} +1 -1
  36. package/dist/assets/{connect-DohcTFiY.js → connect-BeM9KScn.js} +1 -1
  37. package/dist/assets/{connect-B1DJAH4e.js → connect-td4SUK2j.js} +1 -1
  38. package/dist/assets/connect-to-CK_BBgim.js +1 -0
  39. package/dist/assets/{content-layout-DJL10aJT.js → content-layout-oyz1EqNZ.js} +1 -1
  40. package/dist/assets/{create-passport-svg-aTWV-cva.js → create-passport-svg-B2TKOs7K.js} +1 -1
  41. package/dist/assets/createClass-BWB0NSWO.js +1 -0
  42. package/dist/assets/{dashboard-CuicHcGI.js → dashboard-B59Yx2EA.js} +2 -2
  43. package/dist/assets/{delete-confirm-DgdA8XR6.js → delete-confirm-DwFvaC6s.js} +1 -1
  44. package/dist/assets/{did-address-B_YPBiI4.js → did-address-C5FXzeAS.js} +1 -1
  45. package/dist/assets/domain-Dwzb8N6w.js +9 -0
  46. package/dist/assets/domain-action-card-CXIxAIsm.js +28 -0
  47. package/dist/assets/domains-0qUGORQe.js +1 -0
  48. package/dist/assets/{email-Bn3hPH00.js → email-CDYDF-7u.js} +1 -1
  49. package/dist/assets/{empty-spinner-Dqkt-AHg.js → empty-spinner-DYOzicuy.js} +1 -1
  50. package/dist/assets/engine-DXhw4g-J.js +1 -0
  51. package/dist/assets/{exchange-passport-3kSU2YMT.js → exchange-passport-CoU5Q4QA.js} +1 -1
  52. package/dist/assets/{form-MjxZB__D.js → form-I14bCwkb.js} +1 -1
  53. package/dist/assets/{form-text-input-BhAqaNAJ.js → form-text-input-B2T0zM2q.js} +1 -1
  54. package/dist/assets/{form-wrapper-SZH1FnTd.js → form-wrapper-C8oo_Fdy.js} +1 -1
  55. package/dist/assets/{fuel-C5ze4Cx7.js → fuel-DlHj4E28.js} +2 -2
  56. package/dist/assets/{gen-access-key-DKzPF3CU.js → gen-access-key-C54GFXyN.js} +1 -1
  57. package/dist/assets/{gen-simple-access-key-DTWz63Us.js → gen-simple-access-key-Cgw0gqQM.js} +1 -1
  58. package/dist/assets/get-safe-url-mKD2PdwN.js +1 -0
  59. package/dist/assets/{home-Bqn3mvqQ.js → home-D6Wx3vEh.js} +1 -1
  60. package/dist/assets/{iframe-CxCgprun.js → iframe-fHGifsex.js} +1 -1
  61. package/dist/assets/{index-BTBrooUu.js → index-B5fUUj0x.js} +1 -1
  62. package/dist/assets/{index-B_NniBaO.js → index-BJAIYdQp.js} +1 -1
  63. package/dist/assets/{index-BPKZON9n.js → index-BUTKGY5W.js} +7 -7
  64. package/dist/assets/{index-CdA2hOvz.js → index-Bdyv52fm.js} +1 -1
  65. package/dist/assets/{index-Clfe99AI.js → index-Bnv7SivR.js} +1 -1
  66. package/dist/assets/index-C1cWdBpP.js +120 -0
  67. package/dist/assets/{index-Dgk0_7wf.js → index-C5hO5d4a.js} +5 -5
  68. package/dist/assets/{index-C_odLDQq.js → index-CPlFvcnd.js} +13 -13
  69. package/dist/assets/index-CWemdG9k.js +7 -0
  70. package/dist/assets/{index-BwSFbkVa.js → index-ChNXm8zt.js} +1 -1
  71. package/dist/assets/{index-Bero09ZY.js → index-Cq3xfsOS.js} +126 -128
  72. package/dist/assets/{index-PwQ2doS3.js → index-CsRxFZuh.js} +1 -1
  73. package/dist/assets/{index-CPJ0NzQN.js → index-Ctf-FbXC.js} +8 -8
  74. package/dist/assets/{index-D9bRGwyn.js → index-D1c_Zlts.js} +1 -1
  75. package/dist/assets/{index-CAMegfIe.js → index-D5TNmV3K.js} +1 -1
  76. package/dist/assets/{index-DlPcYWy3.js → index-DTj7lG0j.js} +1 -1
  77. package/dist/assets/index-DVBwQI1h.js +6 -0
  78. package/dist/assets/{index-CNndXmIt.js → index-DVZm1sCw.js} +1 -1
  79. package/dist/assets/index-DW-pVTUA.js +1 -0
  80. package/dist/assets/{index-OAcqMuQz.js → index-Dd1dREUL.js} +2 -2
  81. package/dist/assets/{index-DKuLdlGi.js → index-De-Vgsb6.js} +1 -1
  82. package/dist/assets/index-DnKyoEA9.js +55 -0
  83. package/dist/assets/{index-VyLFO7R7.js → index-Mix8V5gr.js} +4 -4
  84. package/dist/assets/{index-WzLE1u-g.js → index-NomqB6Iy.js} +1 -1
  85. package/dist/assets/index-S8uuD-j6.js +29 -0
  86. package/dist/assets/{index-DUJ8lwX7.js → index-Tj1dVBHC.js} +10 -10
  87. package/dist/assets/index-WsuqXAUT.js +1 -0
  88. package/dist/assets/{index-BWszlIaS.js → index-ecxGjzSN.js} +2 -2
  89. package/dist/assets/{index-CI7en2_Z.js → index-j9zHEMDv.js} +2 -2
  90. package/dist/assets/{index-CWQp0vgv.js → index-nYsahwVM.js} +1 -1
  91. package/dist/assets/{index-DnJ0ECmd.js → index-phW48DJg.js} +1 -1
  92. package/dist/assets/{index-CXA6Z-BW.js → index-qme31tNJ.js} +5 -5
  93. package/dist/assets/{index-BCKWe_QR.js → index-sE6ANlb1.js} +1 -1
  94. package/dist/assets/{invitation-KNbJYWOf.js → invitation-p9I7Fs_7.js} +2 -2
  95. package/dist/assets/{invitations-Di31zIeh.js → invitations-BYrxk2XC.js} +1 -1
  96. package/dist/assets/{invite-Cq1bQR9j.js → invite-DptGZzm9.js} +1 -1
  97. package/dist/assets/{isURL-RzSyCgzI.js → isURL-DmCvTfVx.js} +2 -2
  98. package/dist/assets/{issue-passport-DnHvhKR-.js → issue-passport-CeJy-eGP.js} +1 -1
  99. package/dist/assets/{item-DVQ8TUdv.js → item-D48n_jCS.js} +1 -1
  100. package/dist/assets/{landing-page-BzztE6uh.js → landing-page-C-nrxraJ.js} +1 -1
  101. package/dist/assets/{launch-result-message-DZJ76kCs.js → launch-result-message-DWeUg9rM.js} +1 -1
  102. package/dist/assets/{layout-D4qCeoWb.js → layout-Bu-krdMM.js} +1 -1
  103. package/dist/assets/{list-BIECWQvk.js → list-Bm-Ae18B.js} +1 -1
  104. package/dist/assets/list-DTYfy5jI.js +103 -0
  105. package/dist/assets/{list-header-BNFs7V0b.js → list-header-BE2kzda_.js} +1 -1
  106. package/dist/assets/localization-BILR5z0M.js +1 -0
  107. package/dist/assets/{log-Uj0MJfkC.js → log-QCNL7fmO.js} +1 -1
  108. package/dist/assets/logger-LLowKmBx.js +1 -0
  109. package/dist/assets/login-CEAH4IAS.js +1 -0
  110. package/dist/assets/{login-oauth-callback-DB_9NuV_.js → login-oauth-callback-C2H6pyf0.js} +1 -1
  111. package/dist/assets/{logo-uploader-BaFwvDBA.js → logo-uploader-D9dqlBcG.js} +1 -1
  112. package/dist/assets/{lost-passport-C2SpMW8x.js → lost-passport-D-HNQTYL.js} +2 -2
  113. package/dist/assets/{observability-BjKI3tFt.js → observability-Zow0Sv-X.js} +1 -1
  114. package/dist/assets/{omit-BZEryV5a.js → omit-hhiOJGRf.js} +1 -1
  115. package/dist/assets/{open-window-CVU9iEs4.js → open-window-DgCyIQ1g.js} +1 -1
  116. package/dist/assets/{over-due-invoice-payment-CFwnz6K1.js → over-due-invoice-payment-DSTf3GE0.js} +1 -1
  117. package/dist/assets/{overview-DpyqbS6x.js → overview-ClqTYGzr.js} +2 -2
  118. package/dist/assets/{page-header-xpG0yfsa.js → page-header-DCvzRay5.js} +1 -1
  119. package/dist/assets/passport-C04lgrV5.js +1 -0
  120. package/dist/assets/{passport-item-Af9VCIFW.js → passport-item-BDPJusYi.js} +1 -1
  121. package/dist/assets/{permission-bm6ygywx.js → permission-CPpfaEat.js} +1 -1
  122. package/dist/assets/{playground-DKMlueFr.js → playground-CAOOFQT1.js} +1 -1
  123. package/dist/assets/preferences-D2CWTpgr.js +1 -0
  124. package/dist/assets/profile-embed-CLHyEYTf.js +1 -0
  125. package/dist/assets/publish-resource-B1BSffEx.js +1 -0
  126. package/dist/assets/{react-beautiful-dnd.esm-aD7p6S7F.js → react-beautiful-dnd.esm-ZwmTP19t.js} +1 -1
  127. package/dist/assets/{react-stripe.esm-BV6kfV2w.js → react-stripe.esm-Dc9snvfb.js} +1 -1
  128. package/dist/assets/{required-C9DLcn9T.js → required-BGaDOGrj.js} +1 -1
  129. package/dist/assets/runtime-AXM1IbpE.js +1 -0
  130. package/dist/assets/{sanitize-usZAK6S4.js → sanitize-BEqBHa8a.js} +1 -1
  131. package/dist/assets/sdk-CvRW7Vwp.js +1 -0
  132. package/dist/assets/{section-MSasF4Cx.js → section-C75bzkkL.js} +1 -1
  133. package/dist/assets/{security-DbLAyZY0.js → security-BKCc6kr9.js} +1 -1
  134. package/dist/assets/{session-jDtNo9RS.js → session-BYq9-2GE.js} +1 -1
  135. package/dist/assets/{setup-C5jTmWDG.js → setup-CdiiCta6.js} +1 -1
  136. package/dist/assets/{shorten-label-dRmYvYJ7.js → shorten-label-RqvHqcC3.js} +1 -1
  137. package/dist/assets/{simple-select-CQxVe4SK.js → simple-select-iVD4-YUy.js} +1 -1
  138. package/dist/assets/{spaces-V5-JD9i7.js → spaces-Bhd_JZon.js} +1 -1
  139. package/dist/assets/{start-6JVejCmJ.js → start-BXKCBBDg.js} +1 -1
  140. package/dist/assets/{starting-progress-BYVwnaNc.js → starting-progress-Ls9oWS4w.js} +1 -1
  141. package/dist/assets/status-Cu5kOgRL.js +1 -0
  142. package/dist/assets/{step-actions-C1GR4GhW.js → step-actions-sALFE9jn.js} +1 -1
  143. package/dist/assets/{studio-DmcnkjTl.js → studio-2AfcGI4x.js} +1 -1
  144. package/dist/assets/{switch-control-CG7qdize.js → switch-control-CLq7MYhJ.js} +1 -1
  145. package/dist/assets/{table-tips-CdXwFA3X.js → table-tips-DBCvmY1v.js} +1 -1
  146. package/dist/assets/team-4Qq9vwj5.js +146 -0
  147. package/dist/assets/traffic-DU_BMQPm.js +1 -0
  148. package/dist/assets/{transfer-D3XcQgCt.js → transfer-DAvviBGy.js} +1 -1
  149. package/dist/assets/{unsubscribe-D-eN0zoM.js → unsubscribe-CzukIuIE.js} +1 -1
  150. package/dist/assets/{use-app-logo-CMlvKxYW.js → use-app-logo-9qTsLgnV.js} +1 -1
  151. package/dist/assets/{use-mobile-Bjbo_Gou.js → use-mobile-DCNBsOlH.js} +1 -1
  152. package/dist/assets/{use-mobile-CjZIGfWP.js → use-mobile-maRlSUwU.js} +1 -1
  153. package/dist/assets/{use-server-logo-uMEEt675.js → use-server-logo-n_aaKVoZ.js} +1 -1
  154. package/dist/assets/use-window-close-PzHKtiXA.js +1 -0
  155. package/dist/assets/{useAsync-BT7wPXCF.js → useAsync-BcVLpt2E.js} +1 -1
  156. package/dist/assets/{useAsync-D25sKCXL.js → useAsync-cZ_FPf9k.js} +1 -1
  157. package/dist/assets/{useAsyncRetry-D-vTCNcS.js → useAsyncRetry-DwwEjrjs.js} +1 -1
  158. package/dist/assets/{useLocalStorage-BVI5Gy_v.js → useLocalStorage-CvPFnddH.js} +1 -1
  159. package/dist/assets/user-center-DynXe12u.js +126 -0
  160. package/dist/assets/{user-follower-CaGHj3ZA.js → user-follower-Br2H5oAR.js} +1 -1
  161. package/dist/assets/{util-BsBRHu6F.js → util-4xOccFjr.js} +1 -1
  162. package/dist/assets/{util-B-6GuSKY.js → util-B1w9UqzK.js} +1 -1
  163. package/dist/assets/{vendor-arcblock-B0VYnHWE.js → vendor-arcblock-CqplRmyi.js} +114 -115
  164. package/dist/assets/{vendor-hooks-iFsOjihK.js → vendor-hooks-CjESGRlR.js} +1 -1
  165. package/dist/assets/{vendor-mui-core-BPcN1m8_.js → vendor-mui-core-CnXrAOs3.js} +1 -1
  166. package/dist/assets/{vendor-mui-x-DEgOZXst.js → vendor-mui-x-bJ5idfMH.js} +1 -1
  167. package/dist/assets/vendor-utils-cJEl_UEd.js +213 -0
  168. package/dist/assets/{vendor-ux-CheVAuK7.js → vendor-ux-5OlTXZBe.js} +10 -10
  169. package/dist/assets/{wait-connect-DyWyU1dI.js → wait-connect-BA-9v9IK.js} +1 -1
  170. package/dist/assets/{wizard-CwvOHxpL.js → wizard-B70SUVne.js} +1 -1
  171. package/dist/assets/{wizard-components-Cu3iAFug.js → wizard-components-Bj1vePv_.js} +1 -1
  172. package/dist/assets/wrap-locale-CyFByfaX.js +1 -0
  173. package/dist/assets/{zh-qs5i9EFZ.js → zh-DBbr_lO3.js} +1 -1
  174. package/dist/index.html +1 -1
  175. package/dist/service-worker.js +1 -1
  176. package/package.json +23 -23
  177. package/dist/assets/api-VWP7Oo6L.js +0 -1
  178. package/dist/assets/bind-account-BCP_Ypfy.js +0 -1
  179. package/dist/assets/branding-BDdxk2E2.js +0 -1
  180. package/dist/assets/button-DAumqZoi.js +0 -1
  181. package/dist/assets/connect-to-BrFtlkBE.js +0 -1
  182. package/dist/assets/createClass-sKvm4qit.js +0 -1
  183. package/dist/assets/domain-BeE_hgxW.js +0 -9
  184. package/dist/assets/domain-action-card-CBIJJCbh.js +0 -28
  185. package/dist/assets/domains-DgAenuDY.js +0 -1
  186. package/dist/assets/engine-DH9sKH0j.js +0 -1
  187. package/dist/assets/get-safe-url-DEmvtN3J.js +0 -1
  188. package/dist/assets/index-B3O5tZNc.js +0 -55
  189. package/dist/assets/index-Bth96Xcv.js +0 -7
  190. package/dist/assets/index-CZ4Y1y1j.js +0 -120
  191. package/dist/assets/index-DUiyqDLR.js +0 -30
  192. package/dist/assets/index-bd0w0UHw.js +0 -6
  193. package/dist/assets/index-hKD4Miak.js +0 -1
  194. package/dist/assets/index-vci0NXIe.js +0 -1
  195. package/dist/assets/list-Dd8HkY3P.js +0 -103
  196. package/dist/assets/localization-CCBoTGdU.js +0 -1
  197. package/dist/assets/logger-D-AxDn18.js +0 -1
  198. package/dist/assets/login-DWAFC8kE.js +0 -1
  199. package/dist/assets/passport-Bei4Q65O.js +0 -1
  200. package/dist/assets/preferences-lGhRntFn.js +0 -1
  201. package/dist/assets/profile-embed-JHxbEwL7.js +0 -1
  202. package/dist/assets/publish-resource-D19FmjtU.js +0 -1
  203. package/dist/assets/runtime-Kn_kNxXD.js +0 -1
  204. package/dist/assets/sdk-C0BAXQzO.js +0 -1
  205. package/dist/assets/status-C9q9BOVN.js +0 -1
  206. package/dist/assets/team-PZ1SHeY3.js +0 -146
  207. package/dist/assets/traffic-Dh35q8G-.js +0 -1
  208. package/dist/assets/use-window-close-Dmw6cTVQ.js +0 -1
  209. package/dist/assets/user-center-Cwsrx5yP.js +0 -126
  210. package/dist/assets/vendor-utils-D6HS5QsS.js +0 -213
  211. package/dist/assets/wrap-locale-BLNR9__l.js +0 -1
@@ -1,28 +0,0 @@
1
- import{aH as bn,T as vn,V as A,p as Cn,H as E,n as te,z as wn,a0 as Ue}from"./vendor-ux-CheVAuK7.js";import{j as e,cX as Ne,cY as Sn,ak as h,a6 as U,b0 as Rn,T as R,aX as ye,D as H,J as ie,am as L,aN as $e,W as t,bb as _e,M as Oe,aO as An,aP as kn,cZ as Tn,b7 as In,b9 as Pn,c_ as qn,c$ as En,b1 as W,P as We,ci as Ln,bh as Fn,at as Mn,a$ as Bn,cW as zn,d0 as Un,d1 as Nn,d2 as $n,d3 as Te,d4 as _,d5 as _n,z as On,n as Wn,bf as Hn,d6 as Vn,cb as Gn}from"./vendor-mui-core-BPcN1m8_.js";import{C as ee,J as Xn,a as Yn,e as Zn,H as je,a5 as Jn,a6 as Kn,n as Y}from"./vendor-utils-D6HS5QsS.js";import{r as j,e as He,g as Qn}from"./vendor-react-Dvs43sk9.js";import{u as se}from"./useSetState-DFuQZPPV.js";import{l as et,k as nt,b as Z,m as tt,w as it}from"./vendor-hooks-iFsOjihK.js";import{bl as Ve,V as Ge,bm as st,bn as Xe,_ as F,ac as oe,Y as Ie,a2 as ot,aS as Pe,bo as rt,B as at,ae as lt,bp as Ye,ad as fe,bq as Ze,br as ct,bs as dt,bt as mt,aX as ut,e as xe,bu as pt,bv as ft}from"./index-Bero09ZY.js";import{w as Je}from"./permission-bm6ygywx.js";import{u as xt,D as qe}from"./useAsyncRetry-D-vTCNcS.js";import{C as re}from"./confirm-BWGQvLZx.js";import{A as ht}from"./actions-C0hEY5iN.js";import{D as gt}from"./delete-confirm-DgdA8XR6.js";import{o as Ee}from"./vendor-arcblock-B0VYnHWE.js";import{u as Dt}from"./useAsync-BT7wPXCF.js";import{f as N}from"./index-DBs9Ljax.js";import{v as yt}from"./index-DlPcYWy3.js";import{g as jt,p as Le}from"./util-B-6GuSKY.js";import{C as bt}from"./click-to-copy-Kd1YilQn.js";const vt=Ve({});vt.interceptors.request.use(n=>{const i=window.blocklet?window.blocklet.prefix:"/";return n.baseURL=i||"",n.url=ee("/api",String(n.url)),n.timeout=2e5,n.params=n.params||{},new URLSearchParams(n.url.split("?")[1]).has("locale")||(n.params.locale=bn()),n},n=>Promise.reject(n));const Ke=(...n)=>Ve(...n),Ct=(n,i)=>i?n?[n,...Array.isArray(i)?i:[i]]:i:n,wt=(n,{width:i=600,height:o=700,name:a="did-domain:popup"}={})=>{const s=window.screenX+(window.innerWidth-i)/2,r=window.screenY+(window.innerHeight-o)/2,u=[`left=${s}`,`top=${r}`,`width=${i}`,`height=${o}`,"resizable=no","scrollbars=yes","status=yes","popup=yes"],l=window.open("",a,u.join(","));if(l===null)throw new Error("Failed to open popup");return l.location.href=Xn(n,{opener:window.location.origin}),l},St="z2qaGosS3rZ7m5ttP3Nd4V4qczR9TryTcRV4p",Qe=async n=>{if(!n||!n?.trim())return null;const i=Ke(),o=new URL(n);o.pathname="__blocklet__.js",o.searchParams.set("type","json");const{data:a}=await i.get(o.toString()),s=a?.componentMountPoints?.find(m=>m.did===St),r=new URL(n);r.pathname=s?.mountPoint;const u=r.toString(),l=ee(u,"/api");return{base:u,api:l}},Rt=Ge({embed:{iconTip:"Click to view subscription details"},buy:{button:{title:"Buy DID Domain"},status:{inProgress:"Please wait while we are processing your request, the domain will be automatically resolved to the current app after the purchase...",success:"Purchase completed!"},error:{failedToCreateSession:"Failed to create session"}}}),At=Ge({embed:{iconTip:"点击查看订阅详情"},buy:{button:{title:"购买 DID 域名"},status:{inProgress:"请稍等,我们正在处理您的请求,购买域名后会自动解析到当前的应用...",success:"购买完成!"},error:{failedToCreateSession:"创建会话失败"}}}),kt={zh:At,en:Rt},Tt=async({didDomainURL:n,delegatee:i,delegateePk:o})=>{const a=await Qe(n);if(!a)return null;const s=Ke({baseURL:a.api}),{data:r}=await s.post("/payment/session",{delegatee:i,delegateePk:o});return{sessionId:r.sessionId,baseURL:a.base}};function It({delegatee:n,delegateePk:i,didDomainURL:o,locale:a,title:s="",onSuccess:r=()=>{},...u}){const{t:l}=A(),[m,p]=et({currentState:1}),f=j.useRef(null),c=nt(async()=>{const d=await Tt({didDomainURL:o,delegatee:n,delegateePk:i});return d},{debounceWait:500,debounceLeading:!0,debounceTrailing:!1,debounceMaxWait:3e3,refreshDeps:[],onError(d){console.error(d)}}),g=Z(d=>{d.data.type==="didDomain.success"&&(r?.({nftDid:d.data?.nftDid,domain:d.data?.domain,chainHost:d.data?.chainHost}),f.current?.close(),f.current=null,p({currentState:4}),setTimeout(()=>{p({currentState:8})},2e3))});tt(()=>{try{window.removeEventListener("message",g),f.current?.close(),f.current=null}catch(d){console.warn("Failed to close popup",d)}});const y=Z(()=>{p({currentState:1})}),x=Z(()=>{if(p({currentState:2}),!c.data){console.error("Failed to create session");return}b({sessionId:c.data.sessionId,baseURL:c.data.baseURL})}),b=Z(({sessionId:d,baseURL:w})=>{window.addEventListener("message",g);const C=new URL(w);C.searchParams.set("sessionId",d),C.searchParams.set("locale",a),C.searchParams.set("embed","1"),f.current=wt(C.toString());const q=setInterval(()=>{f.current?.closed&&(clearInterval(q),y())},1e3);return()=>clearInterval(q)});return e.jsxs(e.Fragment,{children:[e.jsx(Ne,{loading:c.loading,onClick:x,variant:"contained",startIcon:e.jsx(Sn,{}),...u,children:s||l("buy.button.title")}),e.jsxs(Cn,{fullWidth:!0,maxWidth:"xs",open:m.currentState>1&&m.currentState<8,onClose:y,children:[!c.error&&e.jsxs(h,{sx:{display:"flex",alignItems:"center",flexDirection:"column",gap:2},children:[m.currentState===2&&e.jsx(U,{size:50}),m.currentState===4&&e.jsx(Rn,{sx:{color:"primary.main",fontSize:"5rem"}}),m.currentState===2&&e.jsx(R,{children:l("buy.status.inProgress")}),m.currentState===4&&e.jsx(R,{children:l("buy.status.success")})]}),c.error&&e.jsx(ye,{severity:"error",children:l("buy.error.failedToCreateSession")})]})]})}function Pt(n){return e.jsx(vn,{locale:n.locale,translations:kt,children:e.jsx(It,{...n})})}function qt({nftDid:n,didDomainURL:i,locale:o,sx:a={}}){const{t:s}=A(),[r,u]=se({safeIframeRef:null,popoverAnchorEl:null}),l=j.useRef(null),m=H(),p=ie(m.breakpoints.down("md")),f=x=>{u({popoverAnchorEl:x.currentTarget})},c=()=>{u({popoverAnchorEl:null})},g=it(async()=>{const x=await Qe(i);return x?x.base:null});if(!g.value)return null;if(g.loading)return e.jsx(U,{});const y=ee(g.value,`/embed/domain?nft-did=${n}&locale=${o}`);return e.jsxs(e.Fragment,{children:[e.jsx(L,{title:s("embed.iconTip"),children:e.jsx(h,{component:"img",src:ee(i,"/.well-known/service/blocklet/logo"),alt:"logo",onClick:f,sx:[{width:16,height:16},Ct({cursor:"pointer"},a)]})}),e.jsx($e,{id:"popover-info",open:!!r.popoverAnchorEl,anchorEl:r.popoverAnchorEl,onClose:c,anchorOrigin:{vertical:"bottom",horizontal:"right"},children:e.jsx("iframe",{ref:l,title:s("common.subscription"),width:p?"320px":"400px",height:"350px",style:{border:0,display:"block"},src:y})})]})}const Et=n=>["waiting","creating","renewaling"].includes(n);function en({siteId:n,domain:i,onAdd:o=()=>{},children:a=null,did:s,issuing:r=!1,setIssuing:u=()=>{}}){const{t:l}=A(),[m,p]=j.useState(!1),{inService:f}=F(),[c,g]=j.useState(null),{api:y,ws:{useSubscription:x}}=F(),{mode:b,actions:{refreshDomainStatus:d}}=oe(),w=xt(async()=>{const{cert:T}=await y.findCertificateByDomain({input:{domain:i,did:s}});return T}),C=(T,S)=>{T.domain===i&&(u(!1),p(!1),f&&b!=="setup"&&(S==="success"?E.success(l("setup.domain.genCertSuccess",{domain:T.domain})):S==="error"&&E.error(l("setup.domain.genCertFailed",{domain:T.domain,message:T.message}))))};if(j.useEffect(()=>{w.loading||u(Et(w.value?.status))},[w.loading,w.value?.status,u]),x(Ie.BlockletEvents.certError,T=>C(T,"error")),x(Ie.BlockletEvents.certIssued,T=>{w.retry(),d(T.domain),C(T,"success")}),w.loading||w.value?.status==="normal")return"";const q=()=>{p(!1),g(null)},B=async()=>{p(!0);try{await y.issueLetsEncryptCert({input:{siteId:n,domain:i,did:s,inBlockletSetup:b==="setup"}}),o(),u(!0)}catch(T){console.error(T),u(!1)}finally{p(!1),g(null)}},M={title:l("router.cert.genLetsEncryptCert.title"),description:e.jsxs("div",{children:[e.jsx(ye,{severity:"success",children:l("router.cert.genLetsEncryptCert.dnsTip")}),l("router.cert.genLetsEncryptCert.description")]}),confirm:l("common.confirm"),onConfirm:B,onCancel:q},z=T=>{T.stopPropagation(),g(M)};return e.jsxs(e.Fragment,{children:[r?e.jsx(L,{title:l("router.cert.issuing"),children:e.jsx(U,{size:13,style:{fontSize:"13px"}})}):a({loading:m,open:z}),c&&e.jsx(re,{color:"primary",title:c.title,description:c.description,confirm:c.confirm,params:c.params,onConfirm:c.onConfirm,onCancel:c.onCancel})]})}en.propTypes={domain:t.string.isRequired,did:t.string.isRequired,siteId:t.string.isRequired,onAdd:t.func,children:t.any,issuing:t.bool,setIssuing:t.func};function nn({domain:n,domainStatus:i,did:o,onAdd:a=()=>{},children:s=null,issuing:r=!1,setIssuing:u=()=>{},...l}){return st(n)||!Xe(n)||Yn(i)||i?.isHttps?"":e.jsx(en,{...l,domain:n,did:o,onAdd:a,issuing:r,setIssuing:u,children:s})}nn.propTypes={domain:t.string.isRequired,domainStatus:t.shape({isHttps:t.bool}).isRequired,did:t.string.isRequired,onAdd:t.func,children:t.any,issuing:t.bool,setIssuing:t.func};function tn({id:n,domain:i,children:o=null,teamDid:a="",onDelete:s=null}){const{t:r}=A(),[u,l]=j.useState(!1),[m,p]=j.useState(null),{api:f}=F(),c=()=>{l(!1),p(null)},g=async()=>{l(!0);try{await f.deleteDomainAlias({input:{id:n,domainAlias:i,teamDid:a}}),s?.(),await ot(2e3)}catch(b){E.error(b.message)}finally{p(null),l(!1)}},y={keyName:i,title:r("router.domainAlias.delete.title"),description:r("router.domainAlias.delete.description",{domain:i}),confirmPlaceholder:r("router.domainAlias.delete.confirmPlaceholder",{domain:i}),confirm:r("common.delete"),onConfirm:g,onCancel:c},x=b=>{b.stopPropagation(),p(y)};return e.jsxs(e.Fragment,{children:[typeof o=="function"?o({loading:u,open:x}):e.jsxs(te,{edge:"end",onClick:x,size:"small",className:"rule-action",color:"error","data-cy":"action-delete-domain-alias",children:[u?e.jsx(U,{size:16}):e.jsx(_e,{style:{fontSize:16}}),r("common.delete")]}),m&&e.jsx(gt,{keyName:m.keyName,title:m.title,description:m.description,confirmPlaceholder:m.confirmPlaceholder,confirm:m.confirm,params:m.params,onConfirm:m.onConfirm,onCancel:m.onCancel})]})}tn.propTypes={id:t.string.isRequired,domain:t.string.isRequired,children:t.any,teamDid:t.string,onDelete:t.func};function sn({site:n,domain:i,blocklet:o,onDelete:a=()=>{}}){const{t:s}=A(),r=i.value===window.location.hostname;return e.jsx(ht,{"data-cy":"domain-actions",size:"large",actions:[({close:u})=>e.jsx(tn,{id:n.id,domain:i.value,teamDid:o?.meta?.did,onDelete:a,children:({open:l})=>e.jsx(L,{title:r?s("blocklet.router.currentDomainTip"):"",children:e.jsx("span",{children:e.jsxs(Oe,{disabled:i.isProtected||r,dense:!0,onClick:m=>{u(),l(m)},"data-cy":"action-toggle-block",children:[e.jsx(An,{style:{minWidth:24,marginRight:8},children:e.jsx(_e,{})}),e.jsx(kn,{primary:s("common.delete")})]},"remove")})})})]})}sn.propTypes={site:t.object.isRequired,domain:t.object.isRequired,blocklet:t.object.isRequired,onDelete:t.func};const ae=t.shape({href:t.string,accessibility:t.shape({loading:t.bool,accessible:t.bool}),domainStatus:t.shape({isHttps:t.bool,matchedCert:t.object}),dns:t.shape({resolved:t.bool,ip:t.string})});function on({certificate:n={}}){const[i,o]=j.useState(null),a=F(),{t:s,locale:r}=A(),u=p=>{o(p.currentTarget)},l=()=>{o(null)},m=!!i;return e.jsxs(e.Fragment,{children:[e.jsx(Tn,{"aria-owns":m?"mouse-over-popover":void 0,onMouseEnter:u,onMouseLeave:l,style:{color:"#44cdc6",fontSize:"1em",cursor:"pointer"}}),e.jsx($e,{id:"mouse-over-popover",style:{pointerEvents:"none"},open:m,anchorEl:i,anchorOrigin:{vertical:"bottom",horizontal:"left"},transformOrigin:{vertical:"top",horizontal:"left"},onClose:l,disableRestoreFocus:!0,children:e.jsx(In,{children:e.jsxs(Pn,{style:{display:"flex"},children:[e.jsx("div",{children:e.jsx("img",{src:`${a.imgPrefix}/https-certificate-icon.png`,alt:"certificate icon",style:{maxHeight:"100%",maxWidth:"100%"}})}),e.jsxs(R,{component:"div",style:{marginLeft:"16px"},children:[e.jsx(R,{component:"div",style:{fontWeight:"bold"},children:n.domain}),e.jsx(R,{component:"div",children:`${s("common.issuer")}: ${Zn(n,"issuer.commonName","")}`}),e.jsx(R,{component:"div",children:`${s("router.cert.issuedOn")}: ${Pe(n.validFrom,r)}`}),e.jsx(R,{component:"div",children:`${s("router.cert.expiryOn")}: ${Pe(n.validTo,r)}`})]})]})})})]})}on.propTypes={certificate:t.object};function ne({domain:n,filters:i=["domain","http"]}){const{t:o}=A(),{value:a,domainStatus:s}=n;if(!Xe(a))return null;let r=null,u=null;const{isHttps:l,matchedCert:m}=s,{dns:{ip:p,isDnsResolved:f,isCnameMatch:c}={}}=s,g=f&&c;rt(a)||(g||p==="127.0.0.1"?r=e.jsx(L,{title:o("router.domain.verify.ok"),children:e.jsx(qe,{color:"success"})}):r=e.jsx(L,{title:o("router.domain.verify.notResolved"),children:e.jsx(qe,{color:"error"})})),g?l?u=e.jsx(on,{certificate:m}):u=e.jsx(L,{title:o("router.domain.https.bad"),children:e.jsx(qn,{style:{color:"#D0021B",fontSize:"1em",cursor:"pointer"}})}):u=e.jsx(L,{title:o("router.domain.verify.notResolved"),children:e.jsx(En,{style:{color:"#D0021B",fontSize:"1em",cursor:"pointer"}})});const y=i.map(x=>x==="domain"?r:x==="http"?u:null);return j.createElement(j.Fragment,null,...y)}ne.propTypes={domain:ae.isRequired,filters:t.array};const Lt=Je(be,"mutate_blocklets"),Ft=Je(be,"",at);function pi(n){const{inService:i}=F(),{blocklet:o,loadingRuntimeInfo:a}=oe();let s=Lt;return i&&(s=Ft),e.jsx(s,{...n,blocklet:o,inService:i,loadingRuntimeInfo:a})}const Fe="nft-domain";function be({hasPermission:n=!1,blocklet:i,loadingRuntimeInfo:o=!1,inService:a=!1,showAllDomains:s=!1,updateBlockletDomainAliases:r=()=>{},systemTips:u=null}){const{t:l}=A(),m=ie(d=>d.breakpoints.down("md")),p=j.useMemo(()=>{let d=n;return lt(i)&&(d=d&&a),d},[n,a,i]),{site:f}=i,c=j.useMemo(()=>Ye(i.site?.domainAliases),[i.site?.domainAliases]),g=j.useMemo(()=>c.filter(d=>!fe.isCustomDomain(d.value)),[c]),y=j.useMemo(()=>c.filter(d=>fe.isCustomDomain(d.value)),[c]),x=j.useMemo(()=>y.filter(d=>d.type!==Fe),[y]),b=j.useMemo(()=>y.filter(d=>d.type===Fe),[y]);return e.jsxs(e.Fragment,{children:[e.jsxs(W,{sx:{gap:3},children:[!!b.length&&e.jsx(Q,{title:l("common.didDomains"),description:l("common.didDomainsDescription"),domains:b,hasMutatePermission:p,blocklet:i,site:f,mobile:m,showAllDomains:s,updateBlockletDomainAliases:r}),!!x.length&&e.jsx(Q,{title:l("common.manualDomains"),description:l("common.manualDomainsDescription"),domains:x,hasMutatePermission:p,blocklet:i,site:f,mobile:m,showAllDomains:s,updateBlockletDomainAliases:r}),!!g.length&&e.jsxs(h,{children:[u,e.jsx(Q,{title:l("common.systemDomains"),description:l("common.systemDomainsDescription"),domains:g,hasMutatePermission:p,blocklet:i,site:f,mobile:m,updateBlockletDomainAliases:r})]})]}),!c.length&&(o?e.jsx(U,{size:16}):e.jsx(wn,{children:l("common.empty")}))]})}be.propTypes={hasPermission:t.bool,blocklet:t.object.isRequired,loadingRuntimeInfo:t.bool,inService:t.bool.isRequired,showAllDomains:t.bool,updateBlockletDomainAliases:t.func,systemTips:t.node};function J({children:n=null}){return e.jsx(h,{component:"span",sx:{verticalAlign:"bottom"},children:n})}J.propTypes={children:t.node};function he({domain:n,children:i,suffix:o=null,...a}){const{t:s,locale:r}=A(),u=H(),{href:l,accessibility:m,value:p}=n,f=j.useCallback(()=>e.jsx(Ue,{content:je(p),locale:r,style:{marginLeft:"4px",color:u.palette.text.secondary,fontSize:"0.8em"}}),[p,r,u]);return!m||m.loading?e.jsxs(me,{component:"span",...a,children:[e.jsx(L,{title:void 0,placement:"top-end",children:e.jsx(h,{component:"span",children:i})}),f(),e.jsx(J,{children:o}),e.jsx(L,{title:s("blocklet.router.checkUrlAccessible"),placement:"top-end",children:e.jsx(h,{component:"span",className:"status",children:e.jsx(U,{size:13,style:{fontSize:"13px"}})})})]}):m.accessible?e.jsxs(me,{component:"span",...a,children:[e.jsx(h,{component:"a",href:l,target:"_blank",rel:"noopener noreferrer",sx:{color:n.loading?"text.disabled":void 0},children:e.jsx(L,{title:void 0,placement:"top-end",children:e.jsx(h,{component:"span",children:i})})}),f(),e.jsx(J,{children:o})]}):e.jsxs(me,{component:"span",...a,children:[e.jsx(L,{title:s("blocklet.router.urlInaccessible"),placement:"top-end",children:e.jsx(h,{component:"span",children:i})}),!n.loading&&f(),e.jsx(J,{children:o})]})}he.propTypes={domain:ae.isRequired,children:t.any.isRequired,suffix:t.node};const me=Mn(h)`
2
- display: inline-block;
3
- vertical-align: middle;
4
-
5
- & > span {
6
- line-height: 24px;
7
- }
8
-
9
- &,
10
- & > * {
11
- color: ${({theme:n})=>n.palette.text.primary};
12
- font-size: 18px;
13
- }
14
-
15
- &,
16
- & > * {
17
- word-break: break-all;
18
- }
19
-
20
- svg {
21
- vertical-align: text-top;
22
- }
23
-
24
- .status {
25
- margin-left: 8px;
26
- font-size: 13px;
27
- }
28
- `;function ge({hasMutatePermission:n,site:i,domain:o,blocklet:a,onDelete:s}){return n&&!o.isProtected?e.jsx(sn,{site:i,domain:o,blocklet:a,onDelete:s}):null}ge.propTypes={hasMutatePermission:t.bool.isRequired,site:t.object.isRequired,domain:ae.isRequired,blocklet:t.object.isRequired,onDelete:t.func.isRequired};function K({siteId:n,domain:i,blocklet:o,hasMutatePermission:a}){const{info:s}=F(),{t:r,locale:u}=A(),[l,m]=j.useState(!1);return e.jsxs(h,{sx:{display:"flex",justifyContent:"flex-start",alignItems:"center",gap:.5,button:{lineHeight:1}},children:[i.type==="nft-domain"&&e.jsx(qt,{locale:u,nftDid:i.nftDid,didDomainURL:s.nftDomainUrl}),e.jsx(h,{sx:{display:"flex",mt:"-1px"},children:e.jsx(ne,{domain:i,filters:["http"]},`${i.value}-http`)}),a&&i.canGenerateCertificate&&e.jsx(nn,{siteId:n,domain:i.value,domainStatus:i.domainStatus,did:o.meta.did,issuing:l,setIssuing:m,children:({open:p})=>e.jsx(te,{sx:{padding:0},size:"small",onClick:f=>p(f),children:r("router.cert.genLetsEncryptCert.title")})})]})}K.propTypes={siteId:t.string.isRequired,domain:ae.isRequired,blocklet:t.object.isRequired,hasMutatePermission:t.bool.isRequired};function Q({title:n,description:i,domains:o=[],hasMutatePermission:a,blocklet:s,site:r,mobile:u,showAllDomains:l=!1,updateBlockletDomainAliases:m=()=>{}}){const[p,f]=j.useState(!1),c=j.useMemo(()=>l||p?o:o.slice(0,1),[o,p,l]),g=o.length>1,y=x=>a&&!x.isProtected;return e.jsx(We,{elevation:0,sx:{p:3,pb:l?3:1.5,display:"flex",alignItems:"flex-start",gap:3,borderRadius:2,border:"1px solid",borderColor:"divider",transition:"box-shadow 0.2s ease-in-out"},children:e.jsxs(W,{sx:{width:1},children:[e.jsxs(h,{sx:{mb:1.5},children:[e.jsx(R,{variant:"h6",children:n}),e.jsx(R,{sx:{fontSize:12,color:"text.secondary",mt:.5},children:i})]}),c.map((x,b)=>e.jsxs(W,{children:[b!==0&&e.jsx(h,{sx:{my:.75,width:1,height:"1px"}}),!u&&e.jsxs(h,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs(h,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(h,{sx:{height:28,display:"flex",alignItems:"center"},children:e.jsx(ne,{domain:x,filters:["domain"]},`${x.value}-domain`)}),e.jsxs(h,{sx:{display:"flex",alignItems:"center",justifyContent:"flex-start",gap:.5,svg:{width:"1em",height:"1em"},img:{width:"0.9em",height:"0.9em"}},children:[e.jsx(he,{domain:x,target:"_blank",children:x.value}),e.jsx(h,{sx:{mt:"2px"},children:e.jsx(K,{siteId:s.site?.id,domain:x,blocklet:s,hasMutatePermission:a})})]})]}),e.jsx(h,{sx:{button:{padding:0}},children:e.jsx(ge,{hasMutatePermission:a,site:r,domain:x,blocklet:s,onDelete:()=>m(x,"delete")})})]}),u&&e.jsxs(h,{sx:{display:"flex",flexDirection:"column"},children:[e.jsxs(h,{sx:{display:"flex",justifyContent:"flex-start",gap:1},children:[e.jsx(h,{sx:{height:28,display:"flex",alignItems:"center"},children:e.jsx(ne,{domain:x,filters:["domain"]},`${x.value}-domain`)}),e.jsx(he,{domain:x,target:"_blank",suffix:y(x)?null:e.jsx(h,{sx:{display:"inline-flex",alignItems:"center",justifyContent:"space-between",svg:{width:"1em",height:"1rem"},img:{width:"0.9rem",height:"0.9rem"}},children:e.jsx(K,{siteId:s.site?.id,domain:x,blocklet:s,hasMutatePermission:a})}),children:x.value})]}),y(x)&&e.jsxs(h,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",ml:"18px"},children:[e.jsx(h,{sx:{display:"flex",alignItems:"center"},children:e.jsx(K,{siteId:s.site?.id,domain:x,blocklet:s,hasMutatePermission:a})}),e.jsx(h,{sx:{button:{padding:0}},children:e.jsx(ge,{hasMutatePermission:a,site:r,domain:x,blocklet:s,onDelete:()=>m(x,"delete")})})]})]})]},x.value)),g&&!l&&e.jsx(te,{onClick:()=>f(!p),sx:{p:0,mt:.5,alignSelf:"center"},children:p?e.jsx(Ln,{}):e.jsx(Fn,{})})]})})}Q.propTypes={title:t.string.isRequired,description:t.string.isRequired,domains:t.array.isRequired,hasMutatePermission:t.bool.isRequired,blocklet:t.object.isRequired,site:t.object.isRequired,mobile:t.bool.isRequired,showAllDomains:t.bool,updateBlockletDomainAliases:t.func};const rn=j.createContext({}),{Provider:Mt,Consumer:fi}=rn;function Bt({children:n}){const[i,o]=se({domain:"",error:null}),{locale:a}=A(),s={error:i.error,domain:i.domain,setError:r=>{o({error:r})},setDomain:r=>{const u=je(r),l=Ze(u,a);o({domain:u,error:l})}};return e.jsx(Mt,{value:{value:s},children:n})}function zt(){const{value:n}=j.useContext(rn);return n}var ue,Me;function Ut(){if(Me)return ue;Me=1;const{joinURL:n}=ct(),i=dt(),o="z2qaGosS3rZ7m5ttP3Nd4V4qczR9TryTcRV4p";return ue={DID_DOMAIN_SERVICE_DID:o,getDidDomainServiceURL:async s=>{if(!s||!s?.trim())return null;const r=new URL(s);r.pathname="__blocklet__.js",r.searchParams.set("type","json");const{data:u}=await i.get(r.toString()),l=u?.componentMountPoints?.find(c=>c.did===o),m=new URL(s);m.pathname=l?.mountPoint;const p=m.toString(),f=n(p,"/api");return{base:p,api:f,domain:n(f,"/domains")}}},ue}var Nt=Ut();const $t=He(Jn),_t=He(Kn);var pe,Be;function Ot(){if(Be)return pe;Be=1;const n=$t,i=_t;function o(s){return!s||typeof s!="string"?!1:s.split(".").length===2}return pe={isTopLevelDomain:o,formatTopLevelDidDomain:s=>{const r=n(i(s));return r&&(o(r)?`www.${r}`:r)}},pe}var ze=Ot(),Wt=mt();const Ht=Qn(Wt);function an({domain:n="",resolvedTarget:i,...o}){const{t:a,locale:s}=A();return e.jsxs(h,{sx:{backgroundColor:"rgb(236, 251, 253)",borderColor:"rgb(236, 251, 253)",borderRadius:"8px",padding:"12px"},...o,children:[e.jsxs(h,{sx:{display:"flex",flexWrap:"wrap"},children:[a("router.domain.setup.tipStart"),n&&e.jsx(h,{sx:{mx:.5,color:"primary.main",fontWeight:"fontWeightBold"},children:n}),a("router.domain.setup.tipEnd"),":"]}),e.jsxs(W,{sx:{gap:.5,"&>div":{mb:0},marginTop:"12px"},children:[e.jsx(De,{label:a("router.domain.setup.recordType"),value:"CNAME",locale:s}),e.jsx(De,{label:a("router.domain.setup.recordValue"),value:i,locale:s})]})]})}an.propTypes={domain:t.string,resolvedTarget:t.string.isRequired};function De({locale:n,label:i,value:o}){const a=ie(r=>r.breakpoints.down("md")),s=H();return e.jsx(yt,{name:i,nameWidth:120,children:e.jsxs(h,{sx:{display:"flex",alignItems:"center",lineHeight:1},children:[e.jsx(R,{component:"span",sx:[{color:"primary.main",overflow:"auto"},a?{maxWidth:"95%",wordWrap:"break-word"}:{wordWrap:"break-word"}],children:o}),e.jsx(Ue,{content:o,locale:n,style:{marginLeft:"4px",color:s.palette.text.secondary}})]})})}De.propTypes={locale:t.string.isRequired,label:t.string.isRequired,value:t.string.isRequired};function ln({children:n=null,href:i="",sx:o=null,showIcon:a=!1,...s}){const r=H();return e.jsxs(Bn,{href:i,target:"_blank",...s,sx:{display:"inline-flex",alignItems:"center",color:"text.primary",":hover":{color:r.palette.primary.main},...o},children:[n,a&&e.jsx(zn,{fontSize:"small",sx:{ml:"4px",fontSize:"1rem"}})]})}ln.propTypes={children:t.node,sx:t.object,href:t.string,showIcon:t.bool};function cn({records:n}){return e.jsx(Un,{component:h,sx:{".MuiTableCell-root":{color:"text.primary"}},children:e.jsxs(Nn,{children:[e.jsx($n,{children:e.jsxs(Te,{children:[e.jsx(_,{children:"Type"}),e.jsx(_,{children:"Name"}),e.jsx(_,{children:"Data"})]})}),e.jsx(_n,{children:n.map(i=>e.jsxs(Te,{children:[e.jsx(_,{children:i.type}),e.jsx(_,{children:i.name}),e.jsx(_,{sx:{wordBreak:"break-word"},children:e.jsx(bt,{children:i.data})})]},i.name))})]})})}cn.propTypes={records:t.array.isRequired};function dn({url:n,domain:i=""}){const{t:o}=A();return e.jsxs(h,{sx:{display:"flex",flexDirection:"column",gap:2},children:[e.jsxs(h,{sx:{display:"flex",flexDirection:"column",gap:1},children:[e.jsx(R,{component:"h3",variant:"h6",children:o("setting.dns.step1Title")}),e.jsxs(R,{component:"section",children:[o("setting.dns.step1Desc1"),e.jsx(ln,{href:"https://lookup.icann.org/",target:"_blank",children:"ICANN"})]})]}),e.jsxs(h,{sx:{display:"flex",flexDirection:"column",gap:1},children:[e.jsx(R,{component:"h3",variant:"h6",children:o("setting.dns.step2Title",{url:n})}),e.jsx(R,{component:"section",children:o("setting.dns.step2Desc")})]}),e.jsxs(h,{sx:{display:"flex",flexDirection:"column",gap:1},children:[e.jsx(R,{component:"h3",variant:"h6",children:o("setting.dns.step3Title")}),e.jsx(R,{component:"section",children:o("setting.dns.step3Desc")}),e.jsx(cn,{records:[{type:"CNAME",name:jt(n),data:i}]})]})]})}dn.propTypes={url:t.string.isRequired,domain:t.string};const mn=j.createContext();function Vt({children:n}){const{t:i}=A(),{api:o}=F(),{blocklet:a}=oe(),[s,r]=j.useState(null),u=j.useCallback(async(p,f)=>{try{const c=await o.getBlocklet({input:{domain:p,did:a?.meta?.did}});return c?.blocklet?new Promise(g=>{r({title:i("setting.domain.conflictTitle",{domain:p}),description:i("setting.domain.conflictDescription",{domain:p,title:c.blocklet.meta?.title,from:c.blocklet.meta?.title,to:a.meta?.title}),confirm:i("common.confirm"),cancel:i("common.cancel"),onConfirm:async()=>{r(null),await f?.(),g(!0)},onCancel:()=>{r(null),g(!1)}})}):!1}catch(c){return console.error(c),E.error(N(c)),!1}},[o,i,a]),l=j.useCallback(()=>s?e.jsx(re,{title:s.title,description:s.description,confirm:s.confirm,cancel:s.cancel,onConfirm:s.onConfirm,onCancel:s.onCancel}):null,[s]),m=j.useMemo(()=>({checkConflict:u}),[u]);return e.jsxs(mn.Provider,{value:m,children:[n,l()]})}function un(){return j.useContext(mn)}function pn({siteId:n,teamDid:i,cnameDomain:o,defaultCustomDomain:a="",onInputDomain:s=Y,appId:r="",appPk:u="",onSuccess:l=Y,onError:m=Y,disabled:p=!1,autoFocus:f=!0,inBlockletSetup:c=!1,shouldCheckDomain:g=!1,onStateChange:y=Y,currentIp:x="",...b}){const{t:d,locale:w}=A(),{api:C,info:q}=F(),{blocklet:B}=oe(),M=zt(),z=H(),T=ut({key:"sm"}),[S,P]=se({submittingDomain:!1,domain:a,error:null,type:q?.nftDomainUrl?"nftDomain":"inputDomain",showDnsTip:!1}),le=xe.getDisplayName(B),{checkConflict:ve}=un(),{connectApi:gn}=pt(),V=Dt(()=>Nt.getDidDomainServiceURL(q?.nftDomainUrl));if(q?.nftDomainUrl&&V.loading)return e.jsx(h,{...b,onError:m,currentIp:x,children:e.jsx(Ee,{relative:"parent",children:e.jsx(U,{})})});if(V.error)return e.jsx(h,{...b,onError:m,currentIp:x,children:e.jsx(Ee,{relative:"parent",children:V.error.message})});const Ce=V.value,ce=()=>{P({invalidDNSDomain:null})},we=async(D,v,k=!1)=>{await C.addDomainAlias({input:{id:n,domainAlias:D,teamDid:i,inBlockletSetup:!0,force:k}}),P({submittingDomain:!1}),l({domain:D,type:"inputDomain",canGenerateCertificate:!v})},de=async(D,v)=>{y(d("setting.domain.addingDomain"));try{await we(D,v,!1)}catch(k){if(console.error(k),ce(),N(k).includes("already exists")){await ve(D,()=>we(D,v,!0));return}E.error(N(k))}},Se=async({domain:D,type:v,nftDid:k,chainHost:O})=>{try{if(!g){if(v==="inputDomain"){await de(D);return}l({domain:D,type:v,nftDid:k,chainHost:O});return}y({text:d("setting.domain.checkingResolvable")});let I=30;const $=3e3,jn=I*1e3/$,ke=setInterval(()=>{if(I<=0){clearInterval(ke);return}y({text:`${d("setting.domain.checkingResolvable")} (${I--}s)`})},1e3),G=await Ht(()=>C.getDomainDNS({input:{teamDid:i,domain:D}}),{retries:jn,minTimeout:$,maxTimeout:$,onFailedAttempt:console.error});if(clearInterval(ke),!G?.isDnsResolved||!G?.isCnameMatch){let X="";if(G.isDnsResolved?G.isCnameMatch||(X=d("setting.domain.resolvedAddressError",{domain:D,curDomain:o})):X=d("setting.domain.cannotResolve",{domain:D}),v==="nftDomain"){E.error(X),l({domain:D,type:"nftDomain"});return}y({text:""}),P({invalidDNSDomain:{domain:D,error:X},domain:D,type:v,submittingDomain:!1});return}if(v==="nftDomain"){l({domain:D,type:"nftDomain"});return}await de(D)}catch(I){E.error(I.message),y({text:""}),P({submittingDomain:!1})}},Re=async({domain:D,nftDid:v,chainHost:k,force:O})=>{let I=Le(D);I=ze.formatTopLevelDidDomain(I),P({submittingDomain:!0}),await C.addDomainAlias({input:{id:n,type:"nft-domain",domainAlias:I,nftDid:v,chainHost:k,teamDid:i,inBlockletSetup:c,force:O}});const $="nftDomain";P({type:$}),await Se({domain:I,type:$,nftDid:v,chainHost:k})},Dn=async({domain:D,nftDid:v,chainHost:k,isDomainOwner:O})=>{if(!O){const I=d("router.domainAlias.addDomainNFT.authorizeFailed");E.error(I),P({submittingDomain:!1,error:I});return}try{await Re({domain:D,nftDid:v,chainHost:k,force:!1})}catch(I){if(console.error(I),ce(),N(I).includes("already exists")){await ve(D,()=>Re({domain:D,nftDid:v,chainHost:k,force:!0}));return}E.error(N(I))}finally{P({submittingDomain:!1})}},yn=async()=>{try{P({submittingDomain:!0});const D=Le(S.domain);if(q.nftDomainUrl&&Ce&&(await C.isDidDomain({input:{domain:D}})).value===!0){gn.openPopup({prefix:"/connect-to-did-domain",custom:!0,locale:w,extraParams:{provider:"wallet",delegatee:r,delegateePk:u,domain:ze.formatTopLevelDidDomain(S.domain),appName:le,appUrl:xe.getAppUrl(B)},message:{title:d("router.domainAlias.addDomainNFT.connect.title",{appName:le}),scan:d("router.domainAlias.addDomainNFT.connect.scan",{domain:S.domain,appName:le}),confirm:d("router.domainAlias.addDomainNFT.connect.confirm"),success:d("router.domainAlias.addDomainNFT.connect.success")},onSuccess:Dn,onError:k=>{E.error(k.message),P({submittingDomain:!1})},onClose:()=>P({submittingDomain:!1}),checkTimeout:60*5e3},{baseUrl:Ce.base,locale:w});return}await Se({domain:D,type:S.type})}catch(D){P({submittingDomain:!1}),M.setError(D.message)}},Ae=M.error||S.error;return e.jsx(h,{...b,onError:m,currentIp:x,children:e.jsxs(h,{sx:{display:"flex",flexDirection:"column",justifyContent:"flex-start",gap:"1em"},children:[e.jsxs(h,{component:"form",onSubmit:D=>{D.preventDefault(),yn()},sx:{display:"flex",flexDirection:"column",gap:"8px"},children:[e.jsx(R,{sx:{color:z.palette.text.primary},children:d("router.domainAlias.add.tips")}),e.jsx(On,{sx:{display:"block",marginTop:"8px"},label:d("router.domainAlias.add.domainDescription"),helperText:S.type==="inputDomain"&&Ae||d("router.domainAlias.add.helperText"),fullWidth:!0,disabled:p,value:S.domain,size:"small",variant:"outlined",error:!!Ae&&S.type==="inputDomain",onChange:D=>{const v=je(D.target?.value);M.setDomain(v);const k=Ze(v,w);P({domain:v,error:k,type:"inputDomain"}),s({domain:v,error:k,type:"inputDomain"})},autoFocus:f,onBlur:()=>{M.domain||(P({error:null}),M.setError(null))},slotProps:{htmlInput:{"data-cy":"domain-name-input"}}}),e.jsx(h,{sx:{width:"100%",display:"flex",justifyContent:"flex-end"},children:e.jsx(Ne,{"data-cy":"confirm-add-domain",fullWidth:T,variant:"contained",loading:S.submittingDomain,type:"submit",children:d("common.add")})}),e.jsx(h,{sx:{backgroundColor:()=>Wn(z.palette.primary.light,.1),borderRadius:"8px",padding:"12px"},children:d("router.domainAlias.addDomainNFT.topLevelDidDomainHint")}),e.jsxs(h,{sx:{cursor:"pointer",fontSize:"14px",display:"flex",alignItems:"center",gap:"4px",lineHeight:1,color:z.palette.primary.main},onClick:()=>P({showDnsTip:!S.showDnsTip}),children:[e.jsx(Hn,{fontSize:"1em"}),d("router.domainAlias.showTipHint")]}),S.showDnsTip&&e.jsx(an,{domain:S.domain,resolvedTarget:o,style:{marginTop:"4px"}})]}),S.invalidDNSDomain&&e.jsx(re,{maxWidth:"md",title:d("common.reminder"),description:e.jsxs(W,{sx:{gap:2},children:[e.jsx(ye,{severity:"warning",children:d("setting.domain.invalidDNSReminder",{error:S.invalidDNSDomain.error})}),e.jsx(dn,{url:S.domain,domain:o})]}),color:"primary",confirm:d("setting.domain.continueAdd"),onConfirm:()=>de(S.invalidDNSDomain.domain,S.type),onCancel:ce})]})})}pn.propTypes={siteId:t.string.isRequired,currentIp:t.string,teamDid:t.string.isRequired,cnameDomain:t.string.isRequired,defaultCustomDomain:t.string,onInputDomain:t.func,onSuccess:t.func,appId:t.string,appPk:t.string,disabled:t.bool,autoFocus:t.bool,inBlockletSetup:t.bool,shouldCheckDomain:t.bool,onStateChange:t.func,onError:t.func};function fn({id:n,children:i=null,title:o="",teamDid:a="",systemDomains:s,appId:r=null,appPk:u,onAddDomainAlias:l=()=>{},...m}){const{t:p}=A(),[f,c]=se({loading:!1,confirmSetting:null}),g=s.find(d=>fe.isDidDomain(d)),y=()=>{c({loading:!1,confirmSetting:null})},x={title:o||p("router.domainAlias.add.title"),description:function(w,C,q){return e.jsx(pn,{siteId:n,teamDid:a,cnameDomain:g,onSuccess:B=>{l(B),c({confirmSetting:null})},onInputDomain:({domain:B,type:M,error:z})=>{C({...w,domain:B,type:M,__disableConfirm:!!z}),q(z)},appId:r,appPk:u,...m})},confirm:p("common.confirm"),cancel:p("common.cancel"),params:{domain:"",__disableConfirm:!0},onCancel:y},b=d=>{d.stopPropagation(),c({confirmSetting:x})};return e.jsxs(e.Fragment,{children:[typeof i=="function"?i({loading:f.loading,open:b}):e.jsxs(Oe,{onClick:b,className:"rule-action","data-cy":"action-add-domain-alias",children:[f.loading?e.jsx(U,{size:16}):e.jsx(Vn,{style:{fontSize:18,marginRight:5}}),p("router.domainAlias.add.title")]}),f.confirmSetting&&e.jsx(re,{title:f.confirmSetting.title,description:f.confirmSetting.description,confirm:f.confirmSetting.confirm,cancel:f.confirmSetting.cancel,params:f.confirmSetting.params,onCancel:f.confirmSetting.onCancel,showConfirm:!1,showCancel:!0,displayError:!1,color:"primary",loading:f.loading,maxWidth:"sm"})]})}fn.propTypes={id:t.string.isRequired,children:t.any,title:t.string,teamDid:t.string,systemDomains:t.arrayOf(t.string).isRequired,appId:t.string,appPk:t.string.isRequired,onAddDomainAlias:t.func};function Gt(n){return e.jsx(Bt,{children:e.jsx(fn,{...n})})}function xn({appId:n,appPk:i,siteId:o,inBlockletSetup:a,teamDid:s,sx:r={},onAddDomainAlias:u=()=>{},...l}){const{api:m,info:p}=F(),{locale:f,t:c}=A(),{checkConflict:g}=un(),y=async({domain:b,nftDid:d,chainHost:w,force:C})=>{const q={id:o,type:"nft-domain",domainAlias:b,nftDid:d,chainHost:w,teamDid:s,inBlockletSetup:a,force:C};return await m.addDomainAlias({input:q}),q},x=async({domain:b,nftDid:d,chainHost:w})=>{try{const C=await y({domain:b,nftDid:d,chainHost:w,force:!1});u(C)}catch(C){if(N(C).includes("already exists")){await g(b,()=>y({domain:b,nftDid:d,chainHost:w,force:!0}));return}E.error(N(C))}};return e.jsx(Pt,{delegatee:n,delegateePk:i,didDomainURL:p.nftDomainUrl,onSuccess:x,locale:f,variant:"outlined",sx:r,title:c("router.domainAlias.addDomainNFT.buy"),...l})}xn.propTypes={appId:t.string.isRequired,appPk:t.string.isRequired,siteId:t.string.isRequired,inBlockletSetup:t.bool.isRequired,teamDid:t.string.isRequired,sx:t.object,onAddDomainAlias:t.func};function Xt({blocklet:n,bugDidDomainProps:i={},connectDomainProps:o={},updateBlockletDomainAliases:a=()=>{}}){const{t:s}=A(),{info:r}=F(),u=ie(c=>c.breakpoints.down("md")),{site:l}=n,m=j.useMemo(()=>Ye(n.site?.domainAliases),[n.site?.domainAliases]),p=n.environments?.find(c=>c.key==="BLOCKLET_APP_PK")?.value,f=ft(m);return e.jsx(Vt,{children:e.jsx(hn,{action:e.jsxs(h,{sx:{display:"flex",alignItems:u?"stretch":"center",flexDirection:u?"column":"row",gap:1},children:[r.nftDomainUrl&&e.jsx(xn,{variant:"contained",appId:n.appPid,appPk:p,siteId:l.id,inBlockletSetup:!1,teamDid:n.meta.did,onAddDomainAlias:c=>{const g={value:c.domainAlias,isProtected:!1,type:c.type,nftDid:c.nftDid,chainHost:c.chainHost,accessibility:{loading:!0}};a(g)},...i}),e.jsx(Gt,{id:l.id,title:s("common.connectExistingDomain"),teamDid:n.meta?.did,appId:n.appPid,appPk:p,systemDomains:f?.map(c=>c.value),onAddDomainAlias:c=>{const g={value:c.domain,isProtected:!1,type:c.type==="nftDomain"?"nft-domain":"",nftDid:c.nftDid,chainHost:c.chainHost,accessibility:{loading:!0},canGenerateCertificate:c.canGenerateCertificate===void 0?!0:c.canGenerateCertificate};a(g)},...o,children:({open:c})=>e.jsxs(te,{variant:"outlined",sx:{borderColor:"#ddd",color:"text.primary","&:hover":{bgcolor:g=>g.palette.primary.main,color:g=>g.palette.primary.contrastText}},"data-cy":"add-domain-alias",onClick:c,disabled:xe.isInProgress(n.status),children:[e.jsx(Gn,{style:{fontSize:"1.3em",marginRight:4}}),s("common.connectExistingDomain")]})})]})})})}Xt.propTypes={blocklet:t.object.isRequired,bugDidDomainProps:t.object,connectDomainProps:t.object,updateBlockletDomainAliases:t.func};function hn({action:n}){const{t:i}=A();return e.jsxs(We,{elevation:0,sx:{p:3,borderRadius:2,border:"1px solid",borderColor:"divider"},children:[e.jsx(h,{sx:{display:"flex",alignItems:"center",gap:2},children:e.jsxs(h,{sx:{flex:1,width:0,mb:1.5},children:[e.jsx(R,{variant:"h6",children:i("common.bugOrConnectDomain")}),e.jsx(R,{sx:{fontSize:12,color:"text.secondary",mt:.5},children:i("common.bugOrConnectDomainTip")})]})}),n]})}hn.propTypes={action:t.element.isRequired};export{Bt as D,Xt as a,pi as b};
@@ -1 +0,0 @@
1
- import{r as m}from"./vendor-react-Dvs43sk9.js";import{V as n}from"./vendor-ux-CheVAuK7.js";import{ac as p,_ as l,ae as c,e as u}from"./index-Bero09ZY.js";import{a as x,b as d}from"./domain-action-card-CBIJJCbh.js";import{j as t,ak as k,b1 as f,aX as h}from"./vendor-mui-core-BPcN1m8_.js";import"./vendor-utils-D6HS5QsS.js";import"./vendor-hooks-iFsOjihK.js";import"./lottie-web-4koyQiv_.js";import"./vendor-arcblock-B0VYnHWE.js";import"./useSetState-DFuQZPPV.js";import"./permission-bm6ygywx.js";import"./session-jDtNo9RS.js";import"./useAsyncRetry-D-vTCNcS.js";import"./useAsync-D25sKCXL.js";import"./confirm-BWGQvLZx.js";import"./index-DBs9Ljax.js";import"./actions-C0hEY5iN.js";import"./delete-confirm-DgdA8XR6.js";import"./click-to-copy-Kd1YilQn.js";import"./useAsync-BT7wPXCF.js";import"./index-DlPcYWy3.js";import"./util-B-6GuSKY.js";import"./engine-DH9sKH0j.js";function z(){const{blocklet:o,actions:{updateBlockletDomainAliases:i}}=p(),{inService:r}=l(),{t:e}=n(),a=m.useMemo(()=>{let s=!0;return c(o)&&(s=s&&r),s},[r,o]);return t.jsxs(k,{component:f,sx:{gap:3,maxWidth:820},children:[t.jsxs(t.Fragment,{children:[u.isAccessible(o.status)===!1&&t.jsx(h,{severity:"warning",children:e("blocklet.router.noRunning")}),a&&t.jsx(x,{blocklet:o,updateBlockletDomainAliases:i,connectDomainProps:{shouldCheckDomain:!0}})]}),t.jsx(d,{showAllDomains:!0,updateBlockletDomainAliases:i})]})}export{z as default};
@@ -1 +0,0 @@
1
- import{a5 as e}from"./index-Bero09ZY.js";var a=e();export{a as e};
@@ -1 +0,0 @@
1
- import{Q as t}from"./index-Bero09ZY.js";import{H as e}from"./vendor-ux-CheVAuK7.js";function c(...o){try{return t(...o)}catch(r){throw e.error("Invalid redirect url"),console.error("Invalid redirect url",r),r}}export{c as g};
@@ -1,55 +0,0 @@
1
- import{V as ee,H as B,a3 as X,ad as Ee,ae as Ue,af as We,ag as Ve,q as K,X as je,p as ke,n as z,ah as Me,x as _e,z as Ne,A as Ie}from"./vendor-ux-CheVAuK7.js";import{b as u,a as H,g as ie,c as $e}from"./vendor-hooks-iFsOjihK.js";import{r as C}from"./vendor-react-Dvs43sk9.js";import{j as e,ak as r,b6 as R,am as ce,y as O,z as F,Q as V,T as Y,I as le,a3 as oe,W as E,b1 as W,bb as qe,cb as Le,cE as He,at as Fe,D as ye,ah as Oe,cF as Be,a6 as be,cG as Je,a$ as Ze}from"./vendor-mui-core-BPcN1m8_.js";import{_ as N,ac as M,Y as G,be as se,c as ve,b8 as Ke,az as Ge,Z as Ye}from"./index-Bero09ZY.js";import{A as Z,Q as Qe,b as de,Z as Xe,n as Q,$ as et,C as tt,a as nt}from"./vendor-utils-D6HS5QsS.js";import{u as te,C as k,a as Ce}from"./index.esm-JPZAjt0x.js";import{S as re}from"./switch-control-CG7qdize.js";import{S as y}from"./section-MSasF4Cx.js";import{d as st}from"./keyboard-arrow-down-rounded-8U0_i9QO.js";import{u as ot}from"./index-BTBrooUu.js";import{v as it}from"./index-DlPcYWy3.js";import{r as rt}from"./base32-cypJRki8.js";import{C as at}from"./click-to-copy-Kd1YilQn.js";import{u as lt}from"./use-mobile-Bjbo_Gou.js";import"./lottie-web-4koyQiv_.js";import"./vendor-arcblock-B0VYnHWE.js";import"./required-C9DLcn9T.js";const we={width:24,height:24,body:'<path fill="currentColor" d="M5 4v16V4v5v-5Zm3 10h2.675q.275-.575.638-1.075t.812-.925H8q-.425 0-.713.288T7 13q0 .425.288.713T8 14Zm0 4h2.075Q10 17.5 10 17t.075-1H8q-.425 0-.713.288T7 17q0 .425.288.713T8 18Zm-3 4q-.825 0-1.413-.588T3 20V4q0-.825.588-1.413T5 2h7.175q.4 0 .763.15t.637.425l4.85 4.85q.275.275.425.638t.15.762V10.3q-.475-.15-.975-.225T17 10V9h-4q-.425 0-.713-.288T12 8V4H5v16h5.675q.275.575.638 1.075t.812.925H5Zm12-10q2.075 0 3.538 1.463T22 17q0 2.075-1.463 3.538T17 22q-2.075 0-3.538-1.463T12 17q0-2.075 1.463-3.538T17 12Zm0 8q.275 0 .463-.188t.187-.462q0-.275-.187-.463T17 18.7q-.275 0-.463.188t-.187.462q0 .275.188.463T17 20Zm0-6q-.475 0-.875.238t-.65.637q-.1.15-.025.313t.25.237q.15.075.3 0t.275-.2q.125-.175.313-.275t.412-.1q.325 0 .563.213t.237.537q0 .275-.15.463t-.35.387q-.15.15-.313.3t-.287.35q-.075.15-.113.313t-.037.337q0 .225.125.413t.325.187q.2 0 .325-.15t.125-.35q0-.275.15-.488t.35-.412q.3-.275.525-.613t.225-.737q0-.675-.5-1.138T17 14Z"/>'},ue={enabled:!1,domain:"",clientId:"",clientSecret:""};function ct(){const{api:b}=N(),{blocklet:c}=M(),{t,locale:n}=ee(),o=c?.meta?.did,a=Object.assign({...ue},c?.settings?.oauth?.auth0||{}),{handleSubmit:x,control:i,formState:p,watch:d,reset:f}=te({defaultValues:Z(a,Object.keys(ue))}),l=d("enabled"),j=u(async s=>{try{const{blocklet:I}=await b.configOAuth({input:{did:o,oauth:JSON.stringify({auth0:s})}}),L=Object.assign({...ue},I?.settings?.oauth?.auth0||{});f(L),B.success(t("oauth.saveSuccess"))}catch(I){B.error(I.message||t("oauth.saveFailed"))}}),v=u(s=>s?.trim()?!0:t("oauth.auth0.domainDescription")),S=u(s=>s?.trim()?!0:t("oauth.auth0.clientIdDescription")),g=u(s=>s?.trim()?!0:t("oauth.auth0.clientSecretDescription")),w=u(()=>!0),h=H(()=>n==="zh"?"https://www.arcblock.io/blog/docs/did-connect/zh/oauth-config-auth0":"https://www.arcblock.io/blog/docs/did-connect/en/oauth-config-auth0",[n]);return e.jsx(r,{children:e.jsxs("form",{onSubmit:x(j),disabled:!0,children:[e.jsx(y,{title:e.jsxs(r,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx("span",{children:t("oauth.auth0.enable")}),e.jsx(ce,{title:t("oauth.viewDocument"),children:e.jsx(r,{component:"a",sx:{display:"inline-block",color:"inherit",fontSize:0,lineHeight:1},href:h,target:"_blank",rel:"noreferrer",children:e.jsx(X,{icon:we,fontSize:20})})})]}),mb:2.5,children:e.jsx(k,{name:"enabled",control:i,render:({field:s})=>e.jsx(R,{control:e.jsx(re,{sx:{ml:1},checked:s.value,...s})})})}),e.jsx(y,{title:t("oauth.auth0.domain"),children:e.jsx(k,{name:"domain",control:i,rules:{validate:l?v:w},render:({field:s})=>e.jsx(O,{fullWidth:!0,children:e.jsx(F,{...s,size:"small",label:t("oauth.auth0.domain"),error:!!p.errors[s.name],helperText:p.errors[s.name]?.message||" ",disabled:!l})})})}),e.jsx(y,{title:t("oauth.auth0.clientId"),children:e.jsx(k,{name:"clientId",control:i,rules:{validate:l?S:w},render:({field:s})=>e.jsx(O,{fullWidth:!0,children:e.jsx(F,{...s,size:"small",label:t("oauth.auth0.clientId"),error:!!p.errors[s.name],helperText:p.errors[s.name]?.message||" ",disabled:!l})})})}),e.jsx(y,{title:t("oauth.auth0.clientSecret"),children:e.jsx(k,{name:"clientSecret",control:i,rules:{validate:l?g:w},render:({field:s})=>e.jsx(O,{fullWidth:!0,children:e.jsx(F,{...s,size:"small",type:"password",label:t("oauth.auth0.clientSecret"),error:!!p.errors[s.name],helperText:p.errors[s.name]?.message||" ",disabled:!l})})})}),e.jsx(V,{type:"submit",variant:"contained",onSubmit:x(j),disabled:!p.isDirty,children:t("oauth.save")})]})})}const he={enabled:!1,clientId:"",clientSecret:""};function dt(){const{api:b}=N(),{blocklet:c}=M(),{t,locale:n}=ee(),o=c?.meta?.did,a=Object.assign({...he},c?.settings?.oauth?.github||{}),{handleSubmit:x,control:i,formState:p,watch:d,reset:f}=te({defaultValues:Z(a,Object.keys(he))}),l=d("enabled"),j=u(async h=>{try{const{blocklet:s}=await b.configOAuth({input:{did:o,oauth:JSON.stringify({github:h})}}),I=Object.assign({...he},s?.settings?.oauth?.github||{});f(I),B.success(t("oauth.saveSuccess"))}catch(s){B.error(s.message||t("oauth.saveFailed"))}}),v=u(h=>h?.trim()?!0:t("oauth.github.clientIdDescription")),S=u(h=>h?.trim()?!0:t("oauth.github.clientSecretDescription")),g=u(()=>!0),w=H(()=>n==="zh"?"https://www.arcblock.io/blog/docs/did-connect/zh/oauth-config-github":"https://www.arcblock.io/blog/docs/did-connect/en/oauth-config-github",[n]);return e.jsx(r,{children:e.jsxs("form",{onSubmit:x(j),disabled:!0,children:[e.jsx(y,{title:e.jsxs(r,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx("span",{children:t("oauth.github.enable")}),e.jsx(ce,{title:t("oauth.viewDocument"),children:e.jsx(r,{component:"a",sx:{display:"inline-block",color:"inherit",fontSize:0,lineHeight:1},href:w,target:"_blank",rel:"noreferrer",children:e.jsx(X,{icon:we,fontSize:20})})})]}),mb:2.5,sx:{"& .section-content":{alignItems:"center"}},children:e.jsx(k,{name:"enabled",control:i,sx:{alignItems:"center"},render:({field:h})=>e.jsx(R,{control:e.jsx(re,{sx:{ml:1},size:"small",checked:h.value,...h})})})}),e.jsx(y,{title:t("oauth.github.clientId"),children:e.jsx(k,{name:"clientId",control:i,rules:{validate:l?v:g},render:({field:h})=>e.jsx(O,{fullWidth:!0,children:e.jsx(F,{...h,size:"small",label:t("oauth.github.clientId"),error:!!p.errors[h.name],helperText:p.errors[h.name]?.message||" ",disabled:!l})})})}),e.jsx(y,{title:t("oauth.github.clientSecret"),children:e.jsx(k,{name:"clientSecret",control:i,rules:{validate:l?S:g},render:({field:h})=>e.jsx(O,{fullWidth:!0,children:e.jsx(F,{...h,size:"small",type:"password",label:t("oauth.github.clientSecret"),error:!!p.errors[h.name],helperText:p.errors[h.name]?.message||" ",disabled:!l})})})}),e.jsx(V,{type:"submit",variant:"contained",onSubmit:x(j),disabled:!p.isDirty,children:t("oauth.save")})]})})}const me={enabled:!1,clientId:"",clientSecret:""};function ut(){const{api:b}=N(),{blocklet:c}=M(),{t,locale:n}=ee(),o=c?.meta?.did,a=Object.assign({...me},c?.settings?.oauth?.google||{}),{handleSubmit:x,control:i,formState:p,watch:d,reset:f}=te({defaultValues:Z(a,Object.keys(me))}),l=d("enabled"),j=u(async h=>{try{const{blocklet:s}=await b.configOAuth({input:{did:o,oauth:JSON.stringify({google:h})}}),I=Object.assign({...me},s?.settings?.oauth?.google||{});f(I),B.success(t("oauth.saveSuccess"))}catch(s){B.error(s.message||t("oauth.saveFailed"))}}),v=u(h=>h?.trim()?!0:t("oauth.google.clientIdDescription")),S=u(h=>h?.trim()?!0:t("oauth.google.clientSecretDescription")),g=u(()=>!0),w=H(()=>n==="zh"?"https://www.arcblock.io/blog/docs/did-connect/zh/oauth-config-google":"https://www.arcblock.io/blog/docs/did-connect/en/oauth-config-google",[n]);return e.jsx(r,{children:e.jsxs("form",{onSubmit:x(j),disabled:!0,children:[e.jsx(y,{title:e.jsxs(r,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx("span",{children:t("oauth.google.enable")}),e.jsx(ce,{title:t("oauth.viewDocument"),children:e.jsx(r,{component:"a",sx:{display:"inline-block",color:"inherit",fontSize:0,lineHeight:1},href:w,target:"_blank",rel:"noreferrer",children:e.jsx(X,{icon:we,fontSize:20})})})]}),mb:2.5,children:e.jsx(k,{name:"enabled",control:i,render:({field:h})=>e.jsx(R,{control:e.jsx(re,{sx:{ml:1},checked:h.value,...h})})})}),e.jsx(y,{title:t("oauth.google.clientId"),children:e.jsx(k,{name:"clientId",control:i,rules:{validate:l?v:g},render:({field:h})=>e.jsx(O,{fullWidth:!0,children:e.jsx(F,{...h,size:"small",label:t("oauth.google.clientId"),error:!!p.errors[h.name],helperText:p.errors[h.name]?.message||" ",disabled:!l})})})}),e.jsx(y,{title:t("oauth.google.clientSecret"),children:e.jsx(k,{name:"clientSecret",control:i,rules:{validate:l?S:g},render:({field:h})=>e.jsx(O,{fullWidth:!0,children:e.jsx(F,{...h,size:"small",type:"password",label:t("oauth.google.clientSecret"),error:!!p.errors[h.name],helperText:p.errors[h.name]?.message||" ",disabled:!l})})})}),e.jsx(V,{type:"submit",variant:"contained",onSubmit:x(j),disabled:!p.isDirty,children:t("oauth.save")})]})})}const pe={enabled:!1,teamId:"",serviceId:"",keyId:"",authKey:"",bundleId:""};function ht(){const{api:b}=N(),{blocklet:c}=M(),{t}=ee(),n=c?.meta?.did,o=Object.assign({...pe},c?.settings?.oauth?.apple||{}),{handleSubmit:a,control:x,formState:i,watch:p,reset:d}=te({defaultValues:Z(o,Object.keys(pe))}),f=p("enabled"),l=u(async s=>{try{const{blocklet:I}=await b.configOAuth({input:{did:n,oauth:JSON.stringify({apple:s})}}),L=Object.assign({...pe},I?.settings?.oauth?.apple||{});d(L),B.success(t("oauth.saveSuccess"))}catch(I){B.error(I.message||t("oauth.saveFailed"))}}),j=u(s=>s?.trim()?!0:t("oauth.apple.teamIdDescription")),v=u(s=>s?.trim()?!0:t("oauth.apple.serviceIdDescription")),S=u(s=>s?.trim()?!0:t("oauth.apple.keyIdDescription")),g=u(s=>s?.trim()?!0:t("oauth.apple.authKeyDescription")),w=u(s=>s?.trim()?!0:t("oauth.apple.bundleIdDescription")),h=u(()=>!0);return e.jsx(r,{children:e.jsxs("form",{onSubmit:a(l),disabled:!0,children:[e.jsx(y,{title:t("oauth.apple.enable"),mb:2.5,children:e.jsx(k,{name:"enabled",control:x,render:({field:s})=>e.jsx(R,{control:e.jsx(re,{sx:{ml:1},checked:s.value,...s})})})}),e.jsx(y,{title:t("oauth.apple.teamId"),children:e.jsx(k,{name:"teamId",control:x,rules:{validate:f?j:h},render:({field:s})=>e.jsx(O,{fullWidth:!0,children:e.jsx(F,{...s,size:"small",label:t("oauth.apple.teamId"),error:!!i.errors[s.name],helperText:i.errors[s.name]?.message||" ",disabled:!f})})})}),e.jsx(y,{title:t("oauth.apple.bundleId"),children:e.jsx(k,{name:"bundleId",control:x,rules:{validate:f?w:h},render:({field:s})=>e.jsx(O,{fullWidth:!0,children:e.jsx(F,{...s,size:"small",label:t("oauth.apple.bundleId"),error:!!i.errors[s.name],helperText:i.errors[s.name]?.message||" ",disabled:!f})})})}),e.jsx(y,{title:t("oauth.apple.serviceId"),children:e.jsx(k,{name:"serviceId",control:x,rules:{validate:f?v:h},render:({field:s})=>e.jsx(O,{fullWidth:!0,children:e.jsx(F,{...s,size:"small",label:t("oauth.apple.serviceId"),error:!!i.errors[s.name],helperText:i.errors[s.name]?.message||" ",disabled:!f})})})}),e.jsx(y,{title:t("oauth.apple.keyId"),children:e.jsx(k,{name:"keyId",control:x,rules:{validate:f?S:h},render:({field:s})=>e.jsx(O,{fullWidth:!0,children:e.jsx(F,{...s,size:"small",label:t("oauth.apple.keyId"),error:!!i.errors[s.name],helperText:i.errors[s.name]?.message||" ",disabled:!f})})})}),e.jsx(y,{title:t("oauth.apple.authKey"),children:e.jsx(k,{name:"authKey",control:x,rules:{validate:f?g:h},render:({field:s})=>e.jsx(O,{fullWidth:!0,children:e.jsx(F,{...s,size:"small",type:"password",label:t("oauth.apple.authKey"),multiline:!0,rows:4,error:!!i.errors[s.name],helperText:i.errors[s.name]?.message||" ",disabled:!f})})})}),e.jsx(V,{type:"submit",variant:"contained",onSubmit:a(l),disabled:!i.isDirty,children:t("oauth.save")})]})})}const xe={enabled:!1,clientId:"",clientSecret:""};function mt(){const{api:b}=N(),{blocklet:c}=M(),{t}=ee(),n=c?.meta?.did,o=Object.assign({...xe},c?.settings?.oauth?.twitter||{}),{handleSubmit:a,control:x,formState:i,watch:p,reset:d}=te({defaultValues:Z(o,Object.keys(xe))}),f=p("enabled"),l=u(async g=>{try{const{blocklet:w}=await b.configOAuth({input:{did:n,oauth:JSON.stringify({twitter:g})}}),h=Object.assign({...xe},w?.settings?.oauth?.twitter||{});d(h),B.success(t("oauth.saveSuccess"))}catch(w){B.error(w.message||t("oauth.saveFailed"))}}),j=u(g=>g?.trim()?!0:t("oauth.twitter.clientIdDescription")),v=u(g=>g?.trim()?!0:t("oauth.twitter.clientSecretDescription")),S=u(()=>!0);return e.jsx(r,{children:e.jsxs("form",{onSubmit:a(l),disabled:!0,children:[e.jsx(y,{title:e.jsx(r,{sx:{display:"flex",alignItems:"center",gap:1},children:e.jsx("span",{children:t("oauth.twitter.enable")})}),mb:2.5,sx:{"& .section-content":{alignItems:"center"}},children:e.jsx(k,{name:"enabled",control:x,sx:{alignItems:"center"},render:({field:g})=>e.jsx(R,{control:e.jsx(re,{sx:{ml:1},size:"small",checked:g.value,...g})})})}),e.jsx(y,{title:t("oauth.twitter.clientId"),children:e.jsx(k,{name:"clientId",control:x,rules:{validate:f?j:S},render:({field:g})=>e.jsx(O,{fullWidth:!0,children:e.jsx(F,{...g,size:"small",label:t("oauth.twitter.clientId"),error:!!i.errors[g.name],helperText:i.errors[g.name]?.message||" ",disabled:!f})})})}),e.jsx(y,{title:t("oauth.twitter.clientSecret"),children:e.jsx(k,{name:"clientSecret",control:x,rules:{validate:f?v:S},render:({field:g})=>e.jsx(O,{fullWidth:!0,children:e.jsx(F,{...g,size:"small",type:"password",label:t("oauth.twitter.clientSecret"),error:!!i.errors[g.name],helperText:i.errors[g.name]?.message||" ",disabled:!f})})})}),e.jsx(V,{type:"submit",variant:"contained",onSubmit:a(l),disabled:!i.isDirty,children:t("oauth.save")})]})})}const pt={width:24,height:24,body:'<path fill="currentColor" d="M9 20q-.825 0-1.413-.588T7 18q0-.825.588-1.413T9 16q.825 0 1.413.588T11 18q0 .825-.588 1.413T9 20Zm6 0q-.825 0-1.413-.588T13 18q0-.825.588-1.413T15 16q.825 0 1.413.588T17 18q0 .825-.588 1.413T15 20Zm-6-6q-.825 0-1.413-.588T7 12q0-.825.588-1.413T9 10q.825 0 1.413.588T11 12q0 .825-.588 1.413T9 14Zm6 0q-.825 0-1.413-.588T13 12q0-.825.588-1.413T15 10q.825 0 1.413.588T17 12q0 .825-.588 1.413T15 14ZM9 8q-.825 0-1.413-.588T7 6q0-.825.588-1.413T9 4q.825 0 1.413.588T11 6q0 .825-.588 1.413T9 8Zm6 0q-.825 0-1.413-.588T13 6q0-.825.588-1.413T15 4q.825 0 1.413.588T17 6q0 .825-.588 1.413T15 8Z"/>'};function Re({id:b,title:c,children:t,index:n,onMove:o,defaultExpand:a=!1,onEnd:x,icon:i=null}){const[p,d]=C.useState(a),f=C.useRef(null),l=C.useRef(null),[{handlerId:j},v]=Ee({accept:"dragItem",collect(s){return{handlerId:s.getHandlerId()}},hover(s,I){if(!f.current)return;const L=s.index,m=n;if(L===m)return;const A=f.current?.getBoundingClientRect(),_=l.current?.getBoundingClientRect(),ae=(_.bottom-_.top)/2,$=I.getClientOffset().y-A.top;L<m&&$<ae||L>m&&$>ae||(o(L,m),s.index=m)}}),[{isDragging:S},g]=Ue({item:{index:n,type:"dragItem"},collect:s=>({isDragging:s.isDragging()}),end:x});g(l),v(f);const w=S?.5:1,h=u(s=>{s.preventDefault(),s.stopPropagation(),d(!p)});return e.jsxs(r,{ref:f,children:[e.jsxs(r,{sx:{cursor:"pointer","&:hover":{backgroundColor:"grey.100"}},ref:l,"data-handler-id":j,children:[e.jsxs(r,{sx:{py:2,px:1,opacity:w,display:"flex",alignItems:"center",gap:.5},draggable:!1,onClick:h,children:[e.jsx(r,{sx:{pointerEvents:"auto",cursor:"grab","&:active":{cursor:"grabbing"},fontSize:0,color:"text.hint","&:hover":{color:"text.secondary"}},children:e.jsx(X,{fontSize:20,icon:pt})}),e.jsx(r,{sx:{display:"flex",alignItems:"center",flexShrink:0,mr:.5,transform:"translateY(-1px)"},children:i}),e.jsx(Y,{sx:{flex:1},children:c}),e.jsx(le,{size:"small",sx:{pointerEvents:"auto",transform:p?"":"rotate(180deg)",transition:"transform 0.3s ease"},children:e.jsx(X,{icon:st,style:{transform:"scale(1.5)"}})})]}),e.jsx(oe,{})]}),e.jsx(r,{sx:{pl:4,py:2.5,display:p?"block":"none"},children:t})]})}Re.propTypes={title:E.string.isRequired,id:E.string.isRequired,children:E.node.isRequired,index:E.number.isRequired,onMove:E.func.isRequired,onEnd:E.func.isRequired,defaultExpand:E.bool,icon:E.any};const xt=[{name:"github",title:G.PROVIDER_NAME.github,icon:e.jsx(se,{provider:"github",sx:{width:20,height:20}}),component:e.jsx(dt,{})},{name:"google",title:G.PROVIDER_NAME.google,icon:e.jsx(se,{provider:"google",sx:{width:20,height:20}}),component:e.jsx(ut,{})},{name:"apple",title:G.PROVIDER_NAME.apple,icon:e.jsx(se,{provider:"apple",sx:{width:20,height:20}}),component:e.jsx(ht,{})},{name:"twitter",title:G.PROVIDER_NAME.twitter,icon:e.jsx(se,{provider:"twitter",sx:{width:20,height:20}}),component:e.jsx(mt,{})},{name:"auth0",title:G.PROVIDER_NAME.auth0,icon:e.jsx(se,{provider:"auth0",sx:{width:20,height:20}}),component:e.jsx(ct,{})}],ft=["github","google","apple","twitter","auth0"];function gt(){const{api:b}=N(),{blocklet:c}=M(),t=c?.meta?.did,n=c?.settings?.oauth||{},o=Object.keys(n).sort((l,j)=>n[l]?.order!==void 0&&n[j]?.order!==void 0?n[l].order-n[j].order:n[l]?.order!==void 0?-1:1);for(const l of ft)o.includes(l)||o.push(l);const a=ie(o.reduce((l,j,v)=>Object.assign(l,{[j]:v}),{})),x=H(()=>{const l=[...xt];return l.sort((j,v)=>a[j.name]-a[v.name]),l.map(j=>({...j,enabled:n[j.name]?.enabled??!1}))},[a.auth0,a.github,a.google]),i={};typeof window<"u"&&(i.context=window);const p=u(async l=>{const j={};Object.keys(l).forEach(v=>{j[v]={order:l[v]}}),await b.configOAuth({input:{did:t,oauth:JSON.stringify(j)}})}),d=u((l,j)=>{const v=x[l],S=x[j];a[v.name]=j,a[S.name]=l}),f=u(async()=>{await p(a)});return e.jsx(r,{sx:{".section-left":{width:"180px"}},children:e.jsx(We,{backend:Ve,...i,children:x.map((l,j)=>e.jsx(Re,{index:j,id:l.name,title:l.title,icon:l.icon,onMove:d,onEnd:f,defaultExpand:l.enabled,children:l.component},l.name))})})}const J={ttl:ve.SESSION_TTL,cacheTtl:ve.SESSION_CACHE_TTL,email:{enabled:!1,requireVerified:!1,requireUnique:!1,trustOauthProviders:!1,trustedIssuers:[],enableDomainBlackList:!1,domainBlackList:[],enableDomainWhiteList:!1,domainWhiteList:[]},phone:{enabled:!1,requireVerified:!1,requireUnique:!1,regionBlackList:[],trustedIssuers:[]},enableBlacklist:!1};function U(b){return e.jsx(ot,{...b,sx:{transform:"scale(0.75)"}})}function fe(b,c=!1){const t=c?b.ttl*86400:b.ttl/86400;return{...b,ttl:t}}function jt(){const{api:b}=N(),{blocklet:c}=M(),t=c?.meta?.did,n=Qe({},J,c?.settings?.session||{});de(n.ttl)&&(n.ttl=J.ttl),de(n.cacheTtl)&&(n.cacheTtl=J.cacheTtl),n.phone||(n.phone=J.phone),n.email||(n.email=J.email),de(n.enableBlacklist)&&(n.enableBlacklist=J.enableBlacklist);const{handleSubmit:o,control:a,formState:x,reset:i,watch:p}=te({defaultValues:Z(fe(n),["ttl","cacheTtl","email","phone","enableBlacklist"])}),{t:d}=ee(),f=p("email.enabled"),l=p("phone.enabled"),j=p("email.enableDomainBlackList"),v=p("email.enableDomainWhiteList"),{fields:S,append:g,remove:w}=Ce({control:a,name:"email.domainBlackList"}),{fields:h,append:s,remove:I}=Ce({control:a,name:"email.domainWhiteList"}),L=u(async m=>{try{const{blocklet:A}=await b.updateAppSessionConfig({input:{did:t,config:Xe(fe(m,!0),["phone"])}}),_=Object.assign({},J,Z(A?.settings?.session||{},["ttl","cacheTtl","email","phone","enableBlacklist"]));i(fe(_)),B.success(d("common.configSuccess"))}catch(A){B.error(A.message)}});return e.jsx(bt,{onSubmit:o(L),children:e.jsxs(W,{direction:"column",sx:{gap:6},children:[e.jsxs(r,{children:[e.jsxs(r,{children:[e.jsx(Y,{variant:"h6",sx:{fontWeight:600},children:d("blocklet.config.session.profile")}),e.jsx(r,{component:oe,sx:{my:3}})]}),e.jsxs(W,{sx:{gap:2},children:[e.jsx(y,{title:d("blocklet.config.session.fullNameEnabled"),sectionLeftSx:{width:"600px"},children:e.jsx(r,{sx:{alignSelf:"flex-start"},children:e.jsx(U,{disabled:!0,checked:!0})})}),e.jsx(y,{title:d("blocklet.config.session.avatarEnabled"),sectionLeftSx:{width:"600px"},children:e.jsx(r,{sx:{alignSelf:"flex-start"},children:e.jsx(U,{disabled:!0,checked:!0})})}),e.jsx(y,{title:d("blocklet.config.session.emailEnabled"),sectionLeftSx:{width:"600px"},children:e.jsx(r,{sx:{alignSelf:"flex-start"},children:e.jsx(k,{name:"email.enabled",control:a,render:({field:m})=>e.jsx(U,{...m,checked:m.value})})})}),f&&e.jsxs(W,{direction:"column",sx:{ml:2,gap:.5},children:[e.jsx(y,{title:d("blocklet.config.session.emailRequireVerified"),sectionLeftSx:{width:"600px"},children:e.jsx(r,{sx:{alignSelf:"flex-start"},children:e.jsx(k,{name:"email.requireVerified",control:a,render:({field:m})=>e.jsx(R,{sx:{ml:0},control:e.jsx(U,{...m,checked:m.value})})})})}),e.jsx(y,{title:d("blocklet.config.session.emailRequireUnique"),sectionLeftSx:{width:"600px"},children:e.jsx(r,{sx:{alignSelf:"flex-start"},children:e.jsx(k,{name:"email.requireUnique",control:a,render:({field:m})=>e.jsx(R,{sx:{ml:0},control:e.jsx(U,{...m,checked:m.value})})})})}),e.jsx(y,{title:d("blocklet.config.session.emailTrustOauthProviders"),sectionLeftSx:{width:"600px"},children:e.jsx(r,{sx:{alignSelf:"flex-start"},children:e.jsx(k,{name:"email.trustOauthProviders",control:a,render:({field:m})=>e.jsx(R,{sx:{ml:0},control:e.jsx(U,{...m,checked:m.value})})})})}),e.jsx(y,{title:d("blocklet.config.session.enableDomainBlackList"),sectionLeftSx:{width:"600px"},children:e.jsx(r,{sx:{alignSelf:"flex-start"},children:e.jsx(k,{name:"email.enableDomainBlackList",control:a,render:({field:m})=>e.jsx(R,{sx:{ml:0},control:e.jsx(U,{...m,checked:m.value})})})})}),j&&e.jsxs(r,{children:[S.map((m,A)=>e.jsxs(W,{direction:"row",sx:{alignItems:"center",my:1,maxWidth:"720px"},children:[e.jsx(k,{name:`email.domainBlackList.${A}`,control:a,render:_=>e.jsx(F,{..._.field,size:"small",fullWidth:!0})}),e.jsx(le,{onClick:()=>w(A),children:e.jsx(qe,{})})]},m.id)),e.jsx(V,{startIcon:e.jsx(Le,{}),onClick:()=>g(""),children:d("blocklet.config.session.addDomain")})]}),e.jsx(y,{title:d("blocklet.config.session.enableDomainWhiteList"),sectionLeftSx:{width:"600px"},children:e.jsx(r,{sx:{alignSelf:"flex-start"},children:e.jsx(k,{name:"email.enableDomainWhiteList",control:a,render:({field:m})=>e.jsx(R,{sx:{ml:0},control:e.jsx(U,{...m,checked:m.value})})})})}),v&&e.jsxs(r,{children:[h.map((m,A)=>e.jsxs(W,{direction:"row",sx:{alignItems:"center",my:1,maxWidth:"720px"},children:[e.jsx(k,{name:`email.domainWhiteList.${A}`,control:a,render:_=>e.jsx(F,{..._.field,size:"small",fullWidth:!0})}),e.jsx(le,{onClick:()=>I(A),children:e.jsx(qe,{})})]},m.id)),e.jsx(V,{startIcon:e.jsx(Le,{}),onClick:()=>s(""),children:d("blocklet.config.session.addDomain")})]})]}),e.jsxs(r,{sx:{display:"none"},children:[e.jsx(y,{title:d("blocklet.config.session.phoneEnabled"),sectionLeftSx:{width:"600px"},children:e.jsx(r,{sx:{alignSelf:"flex-start"},children:e.jsx(k,{name:"phone.enabled",control:a,disabled:!0,render:({field:m})=>e.jsx(R,{sx:{ml:0},control:e.jsx(U,{...m,checked:m.value})})})})}),l&&e.jsxs(W,{direction:"column",sx:{ml:2,mt:1},children:[e.jsx(y,{title:d("blocklet.config.session.phoneRequireVerified"),sectionLeftSx:{width:"600px"},children:e.jsx(r,{sx:{alignSelf:"flex-start"},children:e.jsx(k,{name:"phone.requireVerified",control:a,render:({field:m})=>e.jsx(R,{sx:{ml:0},control:e.jsx(U,{...m,checked:m.value})})})})}),e.jsx(y,{title:d("blocklet.config.session.phoneRequireUnique"),sectionLeftSx:{width:"600px"},children:e.jsx(r,{sx:{alignSelf:"flex-start"},children:e.jsx(k,{name:"phone.requireUnique",control:a,render:({field:m})=>e.jsx(R,{sx:{ml:0},control:e.jsx(U,{...m,checked:m.value})})})})})]})]})]})]}),e.jsxs(r,{children:[e.jsx(Y,{variant:"h6",sx:{fontWeight:600},children:d("blocklet.config.session.period")}),e.jsx(r,{component:oe,sx:{my:3}}),e.jsx(W,{direction:"column",spacing:2,children:e.jsx(k,{name:"ttl",control:a,rules:{min:1,max:30},render:({field:m})=>e.jsx(O,{fullWidth:!0,sx:{mb:2},children:e.jsx(y,{title:d("blocklet.config.session.ttl",{day:m.value}),sectionLeftSx:{width:"600px"},children:e.jsx(r,{sx:{width:"100%",maxWidth:500,px:2},children:e.jsx(He,{...m,defaultValue:7,step:1,marks:[{value:1,label:d("blocklet.config.session.day",{day:1})},{value:7,label:d("blocklet.config.session.days",{day:7})},{value:14,label:d("blocklet.config.session.days",{day:14})},{value:21,label:d("blocklet.config.session.days",{day:21})},{value:30,label:d("blocklet.config.session.days",{day:30})}],min:1,max:30,valueLabelDisplay:"auto"})})})})})})]}),e.jsxs(r,{children:[e.jsx(Y,{variant:"h6",sx:{fontWeight:600},children:d("blocklet.config.session.experimentalSettings")}),e.jsx(r,{component:oe,sx:{my:3}}),e.jsx(W,{direction:"column",spacing:2,children:e.jsx(y,{title:d("blocklet.config.session.enableBlacklist"),sectionLeftSx:{width:"600px"},children:e.jsx(r,{sx:{alignSelf:"flex-start"},children:e.jsx(k,{name:"enableBlacklist",control:a,render:({field:m})=>e.jsx(R,{sx:{ml:0},control:e.jsx(U,{...m,checked:m.value})})})})})})]}),e.jsx(r,{children:e.jsx(V,{type:"submit",variant:"contained",disabled:!x.isDirty,children:d("oauth.save")})})]})})}const bt=Fe.form`
2
- max-width: 1536px;
3
-
4
- .advanced-config {
5
- border: 0;
6
- padding: 0;
7
- }
8
-
9
- .config-form {
10
- flex-grow: 1;
11
- overflow-y: auto;
12
- will-change: transform;
13
-
14
- &:first-child {
15
- margin: 0;
16
- }
17
-
18
- ${b=>b.theme.breakpoints.down("md")} {
19
- width: 100%;
20
- flex-shrink: 0;
21
- padding: 0 24px;
22
- transform: translate(0, 0);
23
- }
24
- }
25
-
26
- .config-item {
27
- display: flex;
28
- align-items: center;
29
- justify-content: space-between;
30
- }
31
-
32
- .config-desc {
33
- font-weight: normal;
34
- font-size: 12px;
35
- color: #666;
36
- }
37
-
38
- .form-item {
39
- margin-top: 0;
40
- }
41
- `,vt={width:24,height:24,body:'<path fill="currentColor" d="M6 12.05q0 1.125.425 2.188T7.75 16.2l.25.25V15q0-.425.288-.713T9 14q.425 0 .713.288T10 15v4q0 .425-.288.713T9 20H5q-.425 0-.713-.288T4 19q0-.425.288-.713T5 18h1.75l-.4-.35q-1.3-1.15-1.825-2.625T4 12.05Q4 9.7 5.2 7.787T8.425 4.85q.35-.2.738-.025t.512.575q.125.375-.013.75t-.487.575q-1.45.8-2.313 2.213T6 12.05Zm12-.1q0-1.125-.425-2.187T16.25 7.8L16 7.55V9q0 .425-.288.713T15 10q-.425 0-.713-.288T14 9V5q0-.425.288-.713T15 4h4q.425 0 .713.288T20 5q0 .425-.288.713T19 6h-1.75l.4.35q1.225 1.225 1.788 2.663T20 11.95q0 2.35-1.2 4.263t-3.225 2.937q-.35.2-.737.025t-.513-.575q-.125-.375.013-.75t.487-.575q1.45-.8 2.313-2.212T18 11.95Z"/>'};var ge,De;function kt(){if(De)return ge;De=1;const{DEFAULT_IP_DOMAIN_SUFFIX:b,SLOT_FOR_IP_DNS_SITE:c,DEFAULT_DID_DOMAIN:t}=Ke(),{encode:n}=rt();return ge={getIpDnsDomainForBlocklet:x=>`${n(x.meta.did)}-${c}.${b}`,getDidDomainForBlocklet:({did:x,didDomain:i=t})=>`${n(x)}.${i}`},ge}var yt=kt();function Ae({ref:b=null}){const{t:c}=C.useContext(K),{blocklet:t}=M(),{api:n}=N(),o=ie({loadingReject:!1,loadingApprove:!1,mode:"view",show:!1,data:{},callback:Q}),x=ye()?.transitions?.duration?.leavingScreen||300,i=u(()=>{o.mode="view",o.data={},o.callback=Q}),p=u(()=>{o.show=!1,setTimeout(()=>{i()},x)}),d=u(g=>{o.mode="view",o.show=!0,o.data=g}),f=u((g,w=Q)=>{o.mode="approve",o.show=!0,o.data=g,o.callback=w});C.useImperativeHandle(b,()=>({open:d,close:p,approve:f}),[d,p,f]);const l=H(()=>{if(!o.show)return[];o.data.migratedFrom=[o.data.appId,o.data.appPid];const g=["appName","appLogo","appId","appPid","migratedFrom","appDescription","appUrl","version","appliedAt","status","serverId","serverVersion"];return o.data.isMaster!==!1&&et(g,"appliedAt","status"),g.map(w=>{const h=c(`federated.info.${w}`);let s=o.data[w];if(w==="appName"&&o.data.isMaster&&(s=e.jsxs(r,{children:[e.jsx(Oe,{component:Be}),s]})),["appId","appPid","serverId"].includes(w)&&(s=e.jsx(je,{children:s})),["appUrl"].includes(w)&&(s=e.jsx(r,{component:"a",href:s,target:"_blank",children:s})),["appLogo"].includes(w)){const I=tt(`https://${yt.getDidDomainForBlocklet({did:o.data.appPid})}`,ve.WELLKNOWN_SERVICE_PATH_PREFIX,"/blocklet/logo");try{const L=new URL(I);L.searchParams.set("imageFilter","resize"),L.searchParams.set("w","80"),L.searchParams.set("h","80"),s=e.jsx("img",{src:L.href,width:"60",height:"60",alt:o.data.appName})}catch{s=e.jsx("img",{src:I,width:"60",height:"60",alt:o.data.appName})}}return w==="status"&&(s=s&&c(`federated.status.${s}`)),w==="migratedFrom"&&(s=(o.data.migratedFrom||[]).filter(m=>![o.data.appId,o.data.appPid].includes(m)).map(m=>e.jsx(je,{children:m}))),nt(s)&&(s="-"),{name:h,value:s}})},[o.data]),j=o.mode==="approve",v=u(async()=>{try{o.loadingReject=!0,await n.auditFederatedLogin({input:{memberPid:o.data.appPid,did:t.appPid,status:"rejected"}}),p(),o?.callback(!1)}finally{o.loadingReject=!1}}),S=u(async()=>{try{o.loadingApprove=!0,await n.auditFederatedLogin({input:{memberPid:o.data.appPid,did:t.appPid,status:"approved"}}),p(),o?.callback(!0)}finally{o.loadingApprove=!1}});return e.jsx(ke,{open:o.show,title:c(j?"federated.approveToJoinLogin":"federated.siteDetail"),onClose:p,actions:j?e.jsxs(e.Fragment,{children:[e.jsxs(V,{color:"error",variant:"contained",onClick:v,disabled:o.loadingReject,children:[o.loadingReject?e.jsx(be,{size:16,color:"grey"}):null,c("common.reject")]}),e.jsxs(V,{variant:"contained",onClick:S,disabled:o.loadingApprove,children:[o.loadingApprove?e.jsx(be,{size:16,color:"grey"}):null,c("common.approve")]})]}):e.jsx(V,{variant:"outlined",onClick:p,children:c("common.close")}),children:l.map(g=>e.jsx(it,{style:{alignItems:"flex-start"},valueComponent:"div",nameWidth:180,name:g.name,children:g.value},g.name))})}Ae.propTypes={ref:E.any};function Se({ref:b=null}){const t=ye()?.transitions?.duration?.leavingScreen||300,{t:n}=C.useContext(K),o=ie({show:!1,data:{link:""}}),a=u(()=>{o.data.link=""}),x=u(()=>{o.show=!1,setTimeout(()=>{a()},t)}),i=u(({link:d})=>{o.show=!0,o.data.link=d});C.useImperativeHandle(b,()=>({open:i,close:x}),[i,x]);const p=u(()=>{$e(o.data.link),x()});return e.jsxs(ke,{open:o.show,title:n("federated.joinFederatedLogin"),onClose:x,PaperProps:{style:{minHeight:"unset"}},actions:e.jsx(z,{color:"primary",autoFocus:!0,variant:"contained",onClick:p,children:n("common.copyAndClose")}),children:[e.jsx(r,{sx:{mb:2},children:n("federated.inviteJoinFederatedLoginDescription")}),e.jsx(r,{sx:{"& .copy-button":{display:"none !important"}},children:e.jsx(at,{children:o.data.link})})]})}Se.propTypes={ref:E.any};function Pe({mode:b="member"}){const c=C.useRef(null),t=C.useRef(null),{t:n,locale:o}=C.useContext(K),{blocklet:a,actions:{refreshBlocklet:x}}=M(),{confirmApi:i,confirmHolder:p}=Ge(),{api:d}=N(),f=a.settings.federated?.sites||[],l=a.settings.federated?.config||{},j=l.isMaster!==!1,v=f.find(T=>T.appPid===a.appPid),S=ie({loadingSync:!1}),g=u(T=>{t.current?.open(T)}),w=u(T=>{t.current?.approve(T,x)}),h=u(T=>{i.open({title:n("federated.removeFederatedLogin"),content:n("federated.removeFederatedLoginDescription"),confirmButtonText:n("common.confirm"),cancelButtonText:n("common.cancel"),confirmButtonProps:{color:"error"},async onConfirm(D){await d.quitFederatedLogin({input:{did:a.appPid,targetDid:T.appPid}}),D()}})}),s=u(T=>{i.open({title:n("federated.disableFederatedLogin"),content:n("federated.disableFederatedLoginDescription"),confirmButtonText:n("common.confirm"),cancelButtonText:n("common.cancel"),confirmButtonProps:{color:"error"},async onConfirm(D){await d.auditFederatedLogin({input:{memberPid:T.appPid,did:a.appPid,status:"revoked"}}),D()}})}),I=u(T=>{i.open({title:n("federated.enableFederatedLogin"),content:n("federated.enableFederatedLoginDescription"),confirmButtonText:n("common.confirm"),cancelButtonText:n("common.cancel"),async onConfirm(D){await d.auditFederatedLogin({input:{memberPid:T.appPid,did:a.appPid,status:"approved"}}),D()}})}),L=H(()=>{const T=[{label:n("common.name"),name:"appName",options:{customBodyRenderLite:D=>{const q=f[D],ne=q.isMaster!==!1;return e.jsx(r,{sx:{display:"inline-block"},children:e.jsxs(r,{component:"a",href:q.appUrl,target:"_blank",onClick:P=>{P.stopPropagation()},sx:{display:"flex",alignItems:"center"},children:[ne&&e.jsx(Oe,{component:Be,style:{marginRight:"4px"}}),q.appName]})})}}},{label:n("common.did"),name:"appId",options:{customBodyRenderLite:D=>{const q=f[D];return e.jsx(je,{children:q.appId})}}},{label:n("common.status"),name:"status",options:{customBodyRenderLite:D=>{const q=f[D],ne=q.isMaster!==!1;return e.jsx(r,{children:ne?"-":n(`federated.status.${q.status}`)})}}}];return j&&T.push({label:n("common.actions"),name:"actions",options:{customBodyRenderLite:D=>{const q=f[D],ne=q.isMaster!==!1;return e.jsx(r,{sx:{display:"flex",gap:1},children:ne?e.jsxs(e.Fragment,{children:[q.status==="rejected"&&e.jsx(z,{variant:"contained",color:"error",size:"small",onClick:P=>{P.stopPropagation()},children:n("federated.status.rejected")}),q.status==="revoked"&&e.jsx(z,{variant:"contained",color:"secondary",size:"small",onClick:P=>{P.stopPropagation()},children:n("federated.status.revoked")})]}):e.jsxs(e.Fragment,{children:[e.jsx(z,{variant:"contained",color:"error",size:"small",onClick:P=>{P.stopPropagation(),h(q)},children:n("federated.quitMember")},"quiteSite"),q.status==="pending"&&e.jsx(z,{variant:"contained",color:"primary",size:"small",onClick:P=>{P.stopPropagation(),w(q)},children:n("federated.status.pending")},"auditSite"),q.status==="approved"&&e.jsx(z,{variant:"contained",color:"error",size:"small",onClick:P=>{P.stopPropagation(),s(q)},style:{whiteSpace:"nowrap"},children:n("federated.revoke")},"revokeSite"),q.status==="revoked"&&e.jsx(z,{variant:"contained",color:"warning",size:"small",onClick:P=>{P.stopPropagation(),I(q)},style:{whiteSpace:"nowrap"},children:n("federated.approve")},"approveSite")]})})}}}),T},[l.appId,f,j,n]),m=H(()=>({sort:!0,download:!1,filter:!1,print:!1,expandableRowsOnClick:!0,onRowClick(T,{dataIndex:D}){const q=f[D];g(q)}}),[]),A=u(()=>{const T=a.environments.find(D=>D.key===G.BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_APP_URL);T?.value?c.current?.open({link:T.value}):B.error(n("federated.failedToGetFederatedLoginLink"))},[a.site?.domainAliases?.[0]?.href]),_=u(()=>{i.open({title:n("federated.quitFederatedLogin"),content:n("federated.quitFederatedLoginDescription"),confirmButtonText:n("common.confirm"),cancelButtonText:n("common.cancel"),confirmButtonProps:{color:"error"},async onConfirm(T){await d.quitFederatedLogin({input:{did:a.appPid}}),T()}})}),ae=u(()=>{i.open({title:n("federated.disbandFederatedLogin"),content:n("federated.disbandFederatedLoginDescription"),confirmButtonText:n("common.confirm"),cancelButtonText:n("common.cancel"),confirmButtonProps:{color:"error"},async onConfirm(T){await d.disbandFederatedLogin({input:{did:a.appPid}}),T()}})}),Te=u(async()=>{try{S.loadingSync=!0,await Promise.all([await d.syncFederatedConfig({input:{did:a.appPid}}),Me(500)]),B.success(n("common.succeeded"))}finally{S.loadingSync=!1}}),$=[];return v.status!=="pending"&&$.push(e.jsx(ce,{title:n("federated.syncConfig"),children:e.jsx(le,{size:"small",onClick:Te,disabled:S.loadingSync,sx:[{"@keyframes spin":{from:{transform:"rotate(0deg)"},to:{transform:"rotate(360deg)"}}},S.loadingSync?{animation:"spin 1s linear infinite"}:{}],children:e.jsx(X,{icon:vt,style:{fontSize:24}})},"syncConfig")})),b==="master"?($.push(e.jsx(z,{size:"small",variant:"contained",onClick:A,sx:{ml:1},children:n("federated.inviteJoinFederatedLogin")},"inviteJoinFederatedLogin")),$.push(e.jsx(z,{color:"error",size:"small",variant:"contained",onClick:ae,sx:{ml:1},children:n("federated.disbandFederatedLogin")},"disbandFederatedLogin"))):$.push(e.jsx(z,{size:"small",variant:"contained",color:"error",onClick:_,sx:{ml:1},children:n("federated.quitFederatedLogin")},"quitFederatedLogin")),e.jsxs(e.Fragment,{children:[e.jsx(_e,{className:"main-table",locale:o,data:f,columns:L,customButtons:$,title:e.jsx(r,{className:"table-toolbar-left",children:n("oauth.federated")}),options:m}),p,e.jsx(Se,{ref:c}),e.jsx(Ae,{ref:t})]})}Pe.propTypes={mode:E.oneOf(["member","master"])};function ze({ref:b=null}){const{t:c}=C.useContext(K),{api:t}=N(),{blocklet:n}=M(),o=n?.appPid,x=ye()?.transitions?.duration?.leavingScreen||300,i=ie({loading:!1,show:!1,appUrl:"",appUrlError:"",callback:Q}),p=u(()=>{i.appUrl="",i.appUrlError="",i.callback=Q}),d=u(()=>{i.show=!1,setTimeout(()=>{p()},x)}),f=u((v=Q)=>{i.show=!0,i.callback=v});C.useImperativeHandle(b,()=>({open:f,close:d}),[f,d]);const l=u(v=>{if(!v)throw new Error(c("federated.federatedJoinAppUrlRequired"));if(!Ye(v))throw new Error(c("federated.federatedJoinAppUrlInvalid"))}),j=u(async()=>{try{l(i.appUrl),i.loading=!0;const v=await t.joinFederatedLogin({input:{did:o,appUrl:i.appUrl}});i.show=!1,d(),i?.callback(v)}catch(v){i.appUrlError=v.message}finally{i.loading=!1}});return e.jsxs(ke,{open:i.show,title:c("federated.joinFederatedLogin"),onClose:d,PaperProps:{style:{minHeight:"unset"}},actions:e.jsxs(z,{color:"primary",autoFocus:!0,variant:"contained",onClick:j,disabled:i.loading,children:[i.loading?e.jsx(be,{size:16,sx:{mr:1},color:"grey"}):null,c("common.confirm")]}),children:[e.jsx(r,{sx:{mb:1},children:c("federated.joinFederatedLoginDescription")}),e.jsx(F,{fullWidth:!0,variant:"outlined",margin:"dense",placeholder:c("federated.federatedJoinAppUrl"),label:c("federated.federatedJoinAppUrl"),value:i.appUrl,error:!!i.appUrlError,helperText:i.appUrlError||"eg: https://www.arcblock.io",onChange:v=>{i.appUrl=v.target.value}})]})}ze.propTypes={ref:E.any};function wt(){const{t:b}=C.useContext(K);return e.jsxs(W,{direction:"row",spacing:2,sx:{alignItems:"flex-start",p:2},children:[e.jsx(Je,{fontSize:"large",color:"primary"}),e.jsxs(r,{children:[e.jsx(Y,{variant:"h6",gutterBottom:!0,children:b("federated.title")}),e.jsx(Y,{variant:"body2",sx:{color:"text.secondary"},children:b("federated.description")}),e.jsx(Ze,{href:"https://www.arcblock.io/blog/zh/did-connect-federated-login-support",underline:"hover",variant:"body2",color:"primary",target:"_blank",sx:{display:"inline-flex",alignItems:"center",mt:1},children:b("federated.link")})]})]})}function St(){const b=C.useRef(null),c=C.useRef(null),{t}=C.useContext(K),{blocklet:n,actions:{refreshBlocklet:o}}=M(),a=u(()=>{const i=n.site?.domainAliases?.[0]?.href;if(i)try{const p=new URL(i);b.current?.open({link:p.origin})}catch{B.error(t("federated.failedToGetFederatedLoginLink"))}},[n.site?.domainAliases?.[0]?.href]),x=u(()=>{c.current?.open(()=>{o()})});if(n.settings.federated?.sites.length>0){const i=n.settings.federated?.config.isMaster!==!1;return e.jsx(Pe,{mode:i?"master":"member"})}return e.jsxs(e.Fragment,{children:[e.jsx(r,{sx:{display:"flex",flexDirection:"column",gap:2,justifyContent:"center",alignItems:"center",minHeight:"200px"},children:e.jsxs(r,{sx:{maxWidth:400,borderRadius:2,border:"1px solid",borderColor:"divider"},children:[e.jsx(wt,{}),e.jsx(oe,{sx:{width:1}}),e.jsxs(W,{sx:{width:1,p:2,gap:1.5},children:[e.jsx(z,{variant:"contained",onClick:a,sx:{width:1},children:t("federated.inviteJoinFederatedLogin")}),e.jsx(z,{variant:"outlined",onClick:x,sx:{width:1},children:t("federated.joinFederatedLogin")})]})]})}),e.jsx(Se,{ref:b}),e.jsx(ze,{ref:c})]})}function Tt({orientation:b="horizontal"}){const{t:c}=C.useContext(K),t=lt({key:"lg"}),n=[{label:e.jsx(r,{sx:{textAlign:"center",width:"100%"},children:c("oauth.commonSettings")}),value:"settings"},{label:e.jsx(r,{sx:{textAlign:"center",width:"100%"},children:c("oauth.federated")}),value:"federated"},{label:e.jsx(r,{sx:{textAlign:"center",width:"100%"},children:c("oauth.oauth")}),value:"oauth"},{label:e.jsx(r,{sx:{textAlign:"center",width:"100%"},children:c("oauth.moreLogin")}),value:"more"}],[o,a]=C.useState(n[0].value),x=H(()=>({oauth:e.jsx(gt,{}),federated:e.jsx(St,{}),more:e.jsx(Ne,{children:c("oauth.comingSoon")}),settings:e.jsx(jt,{})}),[c]);return b==="vertical"?e.jsx(It,{children:e.jsxs(W,{direction:{md:"column",lg:"row"},sx:{gap:2},children:[e.jsx(r,{sx:{minWidth:"240px",flexShrink:0},children:e.jsx(Ie,{tabs:n,current:o,orientation:t?"horizontal":"vertical",onChange:a,sx:{borderRight:t?0:1,height:"100%",borderColor:"divider"}})}),e.jsx(r,{sx:{flexGrow:1,minWidth:0},children:e.jsx(r,{sx:{maxWidth:"1200px"},children:x[o]})})]})}):e.jsxs(r,{children:[e.jsx(Ie,{tabs:n,current:o,onChange:a}),e.jsx(r,{sx:{marginTop:"10px"},children:x[o]})]})}Tt.propTypes={orientation:E.oneOf(["horizontal","vertical"])};const It=Fe.div`
42
- .MuiTab-root {
43
- text-align: left;
44
- align-items: flex-start;
45
- font-weight: normal;
46
-
47
- div {
48
- text-align: left;
49
- }
50
- }
51
-
52
- .Mui-selected {
53
- font-weight: bold;
54
- }
55
- `;export{Tt as default};
@@ -1,7 +0,0 @@
1
- import{V as L,H as q,a3 as N,B as Y,z as Se,x as Te,a9 as Ie}from"./vendor-ux-CheVAuK7.js";import{q as Re,k as ae,t as We}from"./vendor-hooks-iFsOjihK.js";import{r as v,a as ce}from"./vendor-react-Dvs43sk9.js";import{D as ze,J as de,j as e,Y as De,bC as Oe,$ as $e,ak as d,z as ne,T as S,a6 as F,aX as te,R as Ae,Q as H,b6 as ie,am as P,bf as _,a5 as J,V as G,S as Z,b4 as Pe,U as B,I as M,ci as qe,bh as Be,a7 as Le,F as Me,W as o,b1 as W,a3 as pe,c2 as ee,cj as Fe,aO as He,aP as Ne,ck as Ue,cl as _e,cm as Ve,s as oe,aU as Ke,aj as Ye,cn as Je,aZ as Qe,cc as Xe,bb as Ge,cb as Ze}from"./vendor-mui-core-BPcN1m8_.js";import{_ as V,c as ue,a1 as et,ac as tt,b4 as Q,ar as xe,as as he,at as me}from"./index-Bero09ZY.js";import{u as K}from"./team-PZ1SHeY3.js";import{u as ot}from"./use-mobile-Bjbo_Gou.js";import{u as st,C as X}from"./index.esm-JPZAjt0x.js";import{C as ge,a as be,J as nt}from"./vendor-utils-D6HS5QsS.js";import{C as it}from"./confirm-BWGQvLZx.js";import{A as rt}from"./actions-C0hEY5iN.js";import{T as re}from"./table-tips-CdXwFA3X.js";import"./lottie-web-4koyQiv_.js";import"./vendor-arcblock-B0VYnHWE.js";import"./session-jDtNo9RS.js";import"./isURL-RzSyCgzI.js";import"./use-app-logo-CMlvKxYW.js";import"./index-DBs9Ljax.js";const lt=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}=L(),[w,u]=v.useState({}),j=v.useMemo(()=>{const s={};return Object.entries(n).forEach(([l,{events:m}])=>{const k=m.filter(T=>p[`${T.type}-${T.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 T=`${k.type}-${k.source}`;m[T]=!l}),c(k=>({...k,...m}))},I=s=>{const l={};Object.values(n).forEach(({events:m})=>{m.forEach(k=>{const T=`${k.type}-${k.source}`;l[T]=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(J,{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(S,{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(G,{disablePadding:!0,sx:{border:"1px solid",borderColor:"divider",borderRadius:.5},children:Object.entries(n).map(([s,{source:l,events:m,count:k}],T)=>{const O=j[s]>0,R=j[s]===m.length&&m.length>0,$=w[s];return e.jsxs(ce.Fragment,{children:[e.jsx(Z,{sx:{borderBottom:({palette:i})=>T<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(J,{checked:R,indeterminate:O&&!R,onChange:i=>{i.stopPropagation(),z(m,R)}}),label:e.jsxs(d,{sx:{display:"flex",alignItems:"center",gap:1},children:[l.logo&&e.jsx(Pe,{src:l.logo,sx:{width:24,height:24}}),e.jsx(d,{children:l.title||s}),O&&e.jsx(B,{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(S,{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:$?e.jsx(qe,{}):e.jsx(Be,{})})]})]})}),m.length>0&&e.jsx(Le,{in:$,timeout:"auto",unmountOnExit:!0,children:e.jsx(G,{disablePadding:!0,sx:{p:0,bgcolor:"rgba(0, 0, 0, 0.01)"},children:m.map(i=>{const x=`${i.type}-${i.source}`,t=!!p[x];return e.jsx(Z,{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(J,{checked:t,sx:{flexShrink:0}}),e.jsxs(d,{sx:{flex:1,minWidth:0},children:[e.jsx(S,{variant:"body1",className:"webhook-event-type",sx:{cursor:"pointer",color:"text.primary",wordBreak:"break-word",overflowWrap:"break-word"},children:i.type}),e.jsx(S,{variant:"caption",sx:{color:"text.secondary",display:"block",cursor:"pointer",wordBreak:"break-word",overflowWrap:"break-word"},children:i.description})]})]})},x)})})})]},s)})})}),f&&e.jsx(Me,{error:!0,sx:{mt:1},children:f})]})}fe.propTypes={eventsBySource:o.objectOf(o.shape({source:o.shape({did:o.string.isRequired,title:o.string,description:o.string,version:o.string,logo:o.string}).isRequired,events:o.arrayOf(o.shape({type:o.string.isRequired,description:o.string.isRequired,source:o.string.isRequired})).isRequired,count:o.number.isRequired})).isRequired,selectedEvents:o.objectOf(o.bool).isRequired,setSelectedEvents:o.func.isRequired,error:o.string};function je({id:n=null,url:p="",description:c="",enabledEvents:f=[],onSubmit:r,onClose:w=()=>{}}){const{t:u}=L(),[j,a]=v.useState({}),{teamDid:b}=K(),{api:g}=V(),{loading:y,error:z,eventsBySource:I}=lt(),s=ze(),{control:l,handleSubmit:m,formState:{errors:k},reset:T,setValue:O,trigger:R}=st({defaultValues:{url:"",description:""}}),$=de(s.breakpoints.down("md"));v.useEffect(()=>{const t=Object.values(j).some(h=>h);O("selectedEvents",t?"valid":""),R("selectedEvents")},[j,O,R]);const i=()=>{a({}),T(),w()},x=async t=>{const h=Object.keys(j).filter(C=>j[C]),E={url:t.url,description:t.description,enabledEvents:h.map(C=>{const[D,se]=C.split("-");return!D||!se?null:{type:D,source:se}}).filter(Boolean)};try{if(n){const C=await g.updateWebhookEndpoint({input:{teamDid:b,id:n,data:E}});q.success(`${u("webhookEndpoint.updateWebhook")} ${u("webhookEndpoint.success")}`),r(C)}else{const C=await g.createWebhookEndpoint({input:{teamDid:b,input:E}});q.success(`${u("webhookEndpoint.createWebhook")} ${u("webhookEndpoint.success")}`),r(C)}}catch(C){q.error(C?.message)}i()};return v.useEffect(()=>{T({url:p,description:c}),a(f.reduce((t,h)=>(t[`${h.type}-${h.source}`]=!0,t),{}))},[T,a,p,c,f]),e.jsx(De,{open:!0,onClose:i,maxWidth:"lg",fullWidth:!0,fullScreen:$,sx:{"& .MuiDialog-paper":{minHeight:600}},children:e.jsxs("form",{onSubmit:m(x),children:[e.jsx(Oe,{children:u(n?"webhookEndpoint.editWebhookTitle":"webhookEndpoint.createWebhookTitle")}),e.jsx($e,{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:t})=>e.jsx(ne,{...t,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:t})=>e.jsx(ne,{...t,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:t})=>e.jsx("input",{type:"hidden",...t})}),!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(S,{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(F,{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(H,{onClick:i,children:u("common.cancel")}),e.jsx(H,{type:"submit",variant:"contained",color:"primary",children:u(n?"webhookEndpoint.updateWebhook":"webhookEndpoint.saveWebhook")})]})]})})}je.propTypes={onSubmit:o.func.isRequired,id:o.string,url:o.string,description:o.string,enabledEvents:o.arrayOf(o.shape({type:o.string.isRequired,source:o.string.isRequired})),onClose:o.func};function ye(n){switch(n){case"enabled":return"success";case"disabled":default:return"default"}}const at=(n="en")=>n==="tw"?"zh":n;function U(n,p="YYYY-MM-DD HH:mm:ss",c="en"){return n?et(n).locale(at(c)).format(p):"-"}function ct(n){return typeof n=="number"?!1:be(n)}function dt(n){return n>=200&&n<300}function A({value:n,label:p,tip:c="",divider:f=!1}){const r=ct(n);return e.jsxs(e.Fragment,{children:[e.jsxs(W,{direction:"column",alignItems:"flex-start",children:[e.jsxs(S,{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(S,{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})]})}A.propTypes={label:o.oneOfType([o.string,o.node]).isRequired,value:o.oneOfType([o.string,o.node]).isRequired,tip:o.oneOfType([o.string,o.node]),divider:o.bool};function we({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(S,{variant:"h3",sx:{fontSize:{xs:"18px",md:"1.09375rem"}},component:"div",children:n}),p]})}we.propTypes={title:o.oneOfType([o.string,o.node]).isRequired,children:o.node,mb:o.number,mt:o.number};const pt={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"/>'},ut=n=>{const p={};return n.forEach(c=>{const f=new Date(c.createdAt).toLocaleDateString();p[f]||(p[f]=[]),p[f]?.push(c)}),p};function ke({eventId:n="",webhookEndpointId:p="",event:c=null}){const{api:f,ws:{useSubscription:r}}=V(),{t:w}=L(),{teamDid:u}=K(),{blocklet:j}=tt(),{data:a,loadMore:b,loadingMore:g,loading:y,mutate:z}=Re(t=>{const E=t?Math.ceil(t.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),T=ut(I);if(v.useEffect(()=>{!s&&a?.list.length&&l(a.list[0])},[a?.list.length,s]),r(ue.EVENTS.WEBHOOK_ATTEMPT,t=>{z(h=>{if(h.list.find(C=>C.id===t.id)){const C=h.list.map(D=>D.id===t.id?{...D,...t}:D);return{...h,list:C}}return t.endpoint=h.list[0]?.endpoint,t.event=h.list[0]?.event,{...h,list:[t,...h.list]}})},[]),y)return e.jsx(F,{});const O=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)}))},$=t=>{if(t.responseBody&&t.responseBody?.sessionId&&t.responseBody?.projectId&&t.responseBody?.agentId){const h=j?.site?.domainAliases[0]?.value,E=(j.children||[]).find(D=>D?.meta?.name==="ai-studio"),C=nt(ge(`https://${h}`,E?.mountPoint||"","projects",t.responseBody.projectId,"logs/main"),{sessionId:t.responseBody.sessionId,agentId:t.responseBody.agentId});return e.jsx(M,{sx:{fontSize:20},onClick:()=>window.open(C,"_blank"),children:e.jsx(d,{component:N,icon:Q})})}return null},i=t=>t.status==="pending"?e.jsx(Ue,{color:"warning"}):dt(t.responseStatus)?e.jsx(_e,{color:"success"}):e.jsx(Ve,{color:"error"}),x=s?.triggeredFrom&&(a?.list||[]).find(t=>t.id===s.triggeredFrom);return e.jsxs(xt,{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(T))?e.jsx(S,{sx:{color:"text.secondary"},children:w("webhookEndpoint.waitingForEvents")}):e.jsxs(e.Fragment,{children:[e.jsx(G,{sx:{maxHeight:"calc(100% - 40px)",py:0,overflowY:"auto"},children:Object.entries(T).map(([t,h])=>e.jsxs(ce.Fragment,{children:[e.jsx(Fe,{sx:{p:0},children:t}),h.map(E=>e.jsxs(Z,{sx:{cursor:"pointer",px:1},onClick:()=>l(E),selected:s&&s?.id===E?.id,secondaryAction:e.jsx(S,{sx:{color:"text.secondary"},children:U(E.createdAt,"HH:mm:ss")}),children:[e.jsx(He,{sx:{minWidth:0,mr:1.5},children:i(E)}),e.jsx(Ne,{primary:e.jsx(S,{sx:{color:"text.primary"},children:E.event.type})})]},E.id))]},t))}),O&&e.jsx(d,{sx:{display:"flex",justifyContent:"center",alignItems:"center",width:1},children:e.jsx(H,{variant:"text",type:"button",color:"inherit",onClick:b,disabled:g,sx:{color:t=>t.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(S,{variant:"h4",children:w(`common.${s.status}`)}),e.jsx(d,{children:$(s)})]}),e.jsxs(d,{sx:{display:"flex",alignItems:"center",gap:1},children:[x&&e.jsx(P,{placement:"left",title:e.jsxs(W,{onClick:()=>l(x),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(S,{variant:"body2",sx:{color:"primary.main"},children:w("webhookEndpoint.triggeredFrom")}),e.jsxs(d,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(S,{variant:"body2",children:s.id}),e.jsx(M,{onClick:()=>l(x),children:e.jsx(d,{component:N,icon:Q,sx:{fontSize:16,color:"common.white"}})})]})]})]}),slotProps:{tooltip:{sx:{maxWidth:400}}},children:e.jsx(M,{onClick:()=>l(x),children:e.jsx(d,{component:N,icon:Q,sx:{fontSize:16}})})}),e.jsxs(H,{variant:"outlined",color:"primary",size:"small",onClick:R,disabled:m,children:[e.jsx(d,{component:N,icon:pt,sx:{fontSize:16,animation:m?"spin 1s linear infinite":"none",mr:.5}}),w("notification.resend")]})]})]}),e.jsxs(d,{children:[e.jsxs(S,{variant:"h6",children:[w("webhookEndpoint.response")," (",s.responseStatus,")"]}),e.jsx(Y,{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(S,{variant:"h6",children:w("webhookEndpoint.request")})}),e.jsx(Y,{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(S,{variant:"h6",children:w("webhookEndpoint.eventData")})}),e.jsx(Y,{language:"json",sx:{margin:0},children:JSON.stringify(c.data,null,2)})]})]})]})}ke.propTypes={eventId:o.string,webhookEndpointId:o.string,event:o.shape({type:o.string,data:o.object,request:o.object,requestInfo:o.object})};const xt=oe(ee)`
2
- @keyframes spin {
3
- to {
4
- transform: rotate(360deg);
5
- }
6
- }
7
- `;function Ee({id:n,onClose:p}){const{t:c}=L(),{api:f}=V(),{teamDid:r}=K(),{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(F,{})}):e.jsxs(ht,{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(S,{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(Ye,{})})})]}),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(A,{label:c("common.status"),value:e.jsx(B,{size:"small",variant:"filled",label:a.status,color:ye(a.status),sx:{borderRadius:"4px",lineHeight:"20px",textTransform:"capitalize"}}),divider:!0}),e.jsx(A,{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(B,{size:"small",variant:"filled",label:c("webhookEndpoint.eventsCount",{count:a.enabledEvents.length}),sx:{borderRadius:"4px",lineHeight:"20px",textTransform:"capitalize"}})}),divider:!0}),e.jsx(A,{label:c("webhookEndpoint.version"),value:a.apiVersion,divider:!0}),e.jsx(A,{label:c("common.createdAt"),value:U(a.createdAt),divider:!0}),e.jsx(A,{label:c("common.updatedAt"),value:U(a.updatedAt),divider:!0}),e.jsx(A,{label:c("common.createdBy"),value:e.jsx(P,{arrow:!0,title:a.createUser?.did,children:e.jsx(B,{size:"small",variant:"filled",label:a.createUser?.fullName,sx:{borderRadius:"4px",lineHeight:"20px",textTransform:"capitalize"}})}),divider:!0}),e.jsx(A,{label:c("common.updatedBy"),value:e.jsx(P,{arrow:!0,title:a.updateUser?.did,children:e.jsx(B,{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(we,{title:c("webhookEndpoint.attempts"),mb:0,mt:4}),e.jsx(W,{sx:{height:0,flex:1,overflow:"hidden"},children:e.jsx(ke,{webhookEndpointId:a.id})})]})]})}Ee.propTypes={id:o.string.isRequired,onClose:o.func.isRequired};const ht=oe(W)``;function ve({open:n,onClose:p,id:c}){return e.jsx(Ke,{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(Ee,{id:c,onClose:p})})})}ve.propTypes={open:o.bool.isRequired,onClose:o.func.isRequired,id:o.string.isRequired};function le(){return null}function Ce({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}=L(),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(mt,{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(Se,{children:w}),...g,durable:u,durableKeys:j,data:a,loading:b,components:s,hasRowLink:r,isMobile:z})}Ce.propTypes={options:o.object,columns:o.array,toolbar:o.bool,footer:o.bool,hasRowLink:o.bool,emptyNodeText:o.node,durable:o.string,durableKeys:o.array,data:o.array,loading:o.bool,onChange:o.func,title:o.node,components:o.object};const mt=oe(Te)``,gt=v.memo(Ce);function At(){const{teamDid:n}=K(),p=ot(),c=`webhook-endpoints-${n}`,f=Ie(c),{t:r,locale:w}=L(),{api:u}=V(),[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]=We(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,x)=>{try{await u.updateWebhookEndpoint({input:{teamDid:n,id:i.id,data:{status:x?"disabled":"enabled"}}}),m(),q.success(`${r(x?"webhookEndpoint.disable":"webhookEndpoint.enable")}${r("webhookEndpoint.success")}`)}catch(t){q.error(t?.message)}},[u,n,m,r]),T=v.useCallback(async i=>{try{await u.deleteWebhookEndpoint({input:{teamDid:n,id:i}}),m(),g(x=>({...x,deleteConfirm:null})),q.success(`${r("common.delete")}${r("webhookEndpoint.success")}`)}catch(x){q.error(x?.message)}},[u,n,m,r]),O=(i,x)=>{let t=i.page+1;const h=i.searchText||"";if(h!==j){a(h);return}if(x==="changePage"||x==="changeRowsPerPage"){x!=="changePage"&&(t=1);const E={page:t,pageSize:i.rowsPerPage};a(""),z(E)}};if(s)return e.jsx(te,{severity:"error",children:s.message});if(I||!l)return e.jsx(d,{sx:{display:"flex",justifyContent:"center",alignItems:"center",width:1,height:500},children:e.jsx(F,{})});const R=(l?.list||[]).filter(i=>{if(!j)return!0;const x=j.toLowerCase();return i.description.toLowerCase().includes(x)||i.url.toLowerCase().includes(x)}),$=[{label:"URL",name:"url",options:{customBodyRenderLite:(i,x)=>{const t=R[x];return e.jsxs(d,{sx:{display:"flex",alignItems:"center",cursor:"pointer",gap:.5},children:[e.jsx(S,{variant:"body2",children:t.description}),e.jsx(d,{sx:{display:"flex"},onClick:h=>{h.stopPropagation()},children:e.jsx(P,{title:t.url,children:e.jsx(_,{sx:{fontSize:"15px",marginTop:"1px"}})})})]})}}},{label:"Events",name:"events",options:{customBodyRenderLite:(i,x)=>{const t=R[x];return e.jsx(d,{sx:{display:"flex",alignItems:"center",gap:1,flexWrap:"wrap"},children:t.enabledEvents.map(h=>e.jsx(B,{size:"small",variant:"filled",label:h.type,sx:{borderRadius:"4px",textTransform:"capitalize"}},`${t.source}-${h.type}`))})}}},{label:r("common.status"),name:"status",options:{customBodyRenderLite:(i,x)=>{const t=R[x];return e.jsx(B,{size:"small",variant:"filled",label:r(`webhookEndpoint.${t?.status}`),color:ye(t?.status),sx:{borderRadius:"4px",textTransform:"capitalize"}},`status-${t.status}`)}}},{label:r("common.createdAt"),name:"createdAt",minWidth:200,options:{customBodyRender:i=>U(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,x)=>{const t=R[x],h=t?.status==="enabled";return e.jsx(rt,{actions:[{icon:h?e.jsx(Je,{}):e.jsx(Qe,{}),text:r(h?"webhookEndpoint.disable":"webhookEndpoint.enable"),onClick:E=>{E.stopPropagation(),k(t,h)}},{icon:e.jsx(Xe,{}),text:r("common.edit"),onClick:E=>{E.stopPropagation(),g(C=>({...C,createEdit:{open:!0,id:t.id,url:t.url,description:t.description,enabledEvents:t.enabledEvents}}))}},{icon:e.jsx(Ge,{}),text:r("common.delete"),onClick:E=>{E.stopPropagation(),g(C=>({...C,deleteConfirm:{title:r("webhookEndpoint.deleteWebhook.title"),description:r("webhookEndpoint.deleteWebhook.description"),confirm:r("common.confirm"),cancel:r("common.cancel"),onConfirm:()=>T(t.id),onCancel:()=>g(D=>({...D,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(gt,{durable:c,durableKeys:["page","rowsPerPage"],data:R,columns:$,options:{count:l.count,page:y.page-1,rowsPerPage:y.pageSize,viewColumns:!1,onRowClick:(i,{dataIndex:x})=>{const t=l.list[x];g(h=>({...h,webhookDetail:{open:!0,id:t.id}}))}},loading:I,onChange:O,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(H,{sx:{color:"common.white"},edge:"end",variant:"contained",color:"primary",onClick:()=>g(i=>({...i,createEdit:{...i.createEdit,open:!0}})),className:"rule-action",children:[I?e.jsx(F,{size:16}):e.jsx(Ze,{style:{fontSize:16}}),r("common.create")]},"add")]}),b.webhookDetail.open&&e.jsx(ve,{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(it,{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{At as default};
@@ -1,120 +0,0 @@
1
- import{g as Bt,r as v}from"./vendor-react-Dvs43sk9.js";import{j as e,ak as S,z as X,b6 as me,bg as Ke,y as V,am as ut,d7 as Wt,bn as Kt,at as ie,b1 as mt,W as p,T as ee,U as Je,d8 as pt,b5 as qe,a5 as Me,Q as Pe,d9 as Ge,aN as Ue,a6 as ft,D as ht,da as qt,ad as xt,db as Mt,dc as Ut,c2 as st,n as Ht,J as $t,x as Vt,bc as Jt,M as it,cw as Gt,I as Yt,dd as Qt}from"./vendor-mui-core-BPcN1m8_.js";import{A as gt,J as Xt,C as Zt,e as oe,F as en,a3 as je}from"./vendor-utils-D6HS5QsS.js";import{V as te,H as q,n as le,q as tn,A as bt,a2 as nn,aI as sn,m as jt,$ as vt,x as yt,aJ as ke,p as St,J as an,a9 as rn}from"./vendor-ux-CheVAuK7.js";import{aK as on,_ as Ye,ac as Ct,az as wt,K as _e,c as B,a1 as Z,o as ln,aS as at}from"./index-Bero09ZY.js";import{g as ye,b as $,a as se}from"./vendor-hooks-iFsOjihK.js";import{u as Rt,C as Y}from"./index.esm-JPZAjt0x.js";import{i as He}from"./isURL-RzSyCgzI.js";import{S as Q}from"./section-MSasF4Cx.js";import{A as cn,a as dn,b as un}from"./collapse-Cc8IqFzl.js";import{S as Se}from"./shorten-label-dRmYvYJ7.js";import{v as Tt}from"./index-DlPcYWy3.js";import{R as Nt,A as mn,S as pn,a as fn,B as hn}from"./list-Dd8HkY3P.js";import{j as xn,c as gn,N as bn}from"./team-PZ1SHeY3.js";import{W as jn}from"./did-address-B_YPBiI4.js";import{p as It}from"./util-BsBRHu6F.js";import{D as vn,g as yn}from"./traffic-Dh35q8G-.js";import{B as Et}from"./bundle-avatar-Bft1K1fA.js";import{u as Sn}from"./use-mobile-Bjbo_Gou.js";import"./lottie-web-4koyQiv_.js";import"./vendor-arcblock-B0VYnHWE.js";import"./required-C9DLcn9T.js";import"./server-logo-notext.svg-CKQB0tIp.js";import"./session-jDtNo9RS.js";import"./use-app-logo-CMlvKxYW.js";import"./base32-cypJRki8.js";import"./useAsyncRetry-D-vTCNcS.js";import"./useAsync-D25sKCXL.js";import"./iframe-CxCgprun.js";import"./index-hKD4Miak.js";import"./index-DBs9Ljax.js";import"./base-chart-BIsPFns6.js";import"./index-WzLE1u-g.js";import"./vendor-mui-x-DEgOZXst.js";import"./AdapterDayjs-CSsn7VEX.js";var Re={exports:{}},Te={exports:{}},Ne={exports:{}},rt;function Cn(){return rt||(rt=1,function(t,s){Object.defineProperty(s,"__esModule",{value:!0}),s.default=n;function n(r){return r==null}t.exports=s.default,t.exports.default=s.default}(Ne,Ne.exports)),Ne.exports}var ot;function wn(){return ot||(ot=1,function(t,s){Object.defineProperty(s,"__esModule",{value:!0}),s.default=f;var n=o(on()),r=o(Cn());function o(u){return u&&u.__esModule?u:{default:u}}var l=/^(?:[-+]?(?:0|[1-9][0-9]*))$/,j=/^[-+]?[0-9]+$/;function f(u,a){(0,n.default)(u),a=a||{};var y=a.allow_leading_zeroes===!1?l:j,R=!a.hasOwnProperty("min")||(0,r.default)(a.min)||u>=a.min,w=!a.hasOwnProperty("max")||(0,r.default)(a.max)||u<=a.max,b=!a.hasOwnProperty("lt")||(0,r.default)(a.lt)||u<a.lt,E=!a.hasOwnProperty("gt")||(0,r.default)(a.gt)||u>a.gt;return y.test(u)&&R&&w&&b&&E}t.exports=s.default,t.exports.default=s.default}(Te,Te.exports)),Te.exports}var lt;function Rn(){return lt||(lt=1,function(t,s){Object.defineProperty(s,"__esModule",{value:!0}),s.default=o;var n=r(wn());function r(l){return l&&l.__esModule?l:{default:l}}function o(l){return(0,n.default)(l,{allow_leading_zeroes:!1,min:0,max:65535})}t.exports=s.default,t.exports.default=s.default}(Re,Re.exports)),Re.exports}var Tn=Rn();const Nn=Bt(Tn),ze={enabled:!1,secure:!1,from:"",host:"",port:"",user:"",password:"",companyName:"",companyLink:"",companyAddress:"",supportEmail:""};function In(){const{api:t}=Ye(),{blocklet:s}=Ct(),{t:n}=te(),{confirmApi:r,confirmHolder:o}=wt(),l=s?.meta?.did,j=Object.assign({...ze},s?.settings?.notification?.email||{}),{handleSubmit:f,control:u,formState:a,watch:y,reset:R}=Rt({defaultValues:gt(j,Object.keys(ze))}),w=ye({testReceiver:"",testReceiverError:""}),b=y("enabled"),E=$(async(i,C,D=!0)=>{try{const{blocklet:O}=await t.configNotification({input:{did:l,notification:JSON.stringify({email:i})}}),ae=Object.assign({...ze},O?.settings?.notification?.email||{});R(ae),D&&q.success(n("oauth.saveSuccess"))}catch(O){if(D)q.error(O.message||n("oauth.saveFailed"));else throw O}}),J=$(async(i,C,D)=>{try{a.isDirty&&await E(i,C,!1),await t.sendEmail({input:{did:l,receiver:D,email:JSON.stringify({body:"Your SMTP configuration is correct!",title:"Test email",type:"notification",attachments:[{type:"link",data:{url:"https://community.arcblock.io",title:"Community",image:"https://community.arcblock.io/.well-known/service/blocklet/logo-rect-dark",utm:{campaign:"test-campaign"}}}],utm:{content:"test-email-button"}})}}),q.success(n("notification.email.testSuccess"))}catch(O){q.error(O.message||n("notification.email.testfailed"))}}),M=$((i,C)=>{w.testReceiver=localStorage.getItem("test-receiver")||"",w.testReceiverError="",r.open({title:n("notification.email.testSendEmail"),content:()=>e.jsx(S,{sx:{width:"300px"},children:e.jsx(X,{sx:{mt:1},fullWidth:!0,name:"testReceiver",label:n("notification.email.inputTestReceiver"),value:w.testReceiver,onChange:D=>{w.testReceiver=D.target.value},error:!!w.testReceiverError,helperText:w.testReceiverError||" "})}),confirmButtonText:n("common.confirm"),cancelButtonText:n("common.cancel"),async onConfirm(D){const O=w.testReceiver?.trim();if(!O){w.testReceiverError=n("notification.email.receiverRequired");return}if(!_e(O)){w.testReceiverError=n("notification.email.receiverInvalid");return}w.testReceiverError="",await J(i,C,O),D()}})}),P=$(i=>{const C=i?.trim();return C?_e(C)?!0:n("notification.email.fromInvalid"):n("notification.email.fromRequired")}),F=$(i=>{const C=i?.trim();return C?He(C,{require_host:!1,protocols:[]})?!0:n("notification.email.hostInvalid"):n("notification.email.hostRequired")}),N=$(i=>i?Nn(i)?!0:n("notification.email.portInvalid"):n("notification.email.portRequired")),W=$(i=>i?.trim()?!0:n("notification.email.userRequired")),K=$(i=>i?.trim()?!0:n("notification.email.passwordRequired")),h=$(i=>i?.trim()&&!He(i,{protocols:["http","https"],require_protocol:!0})?n("notification.email.linkInvalid"):!0),T=$(i=>i?.trim()&&!_e(i)?n("notification.email.emailInvalid"):!0),k=$(()=>!0);return e.jsxs(S,{children:[e.jsxs(En,{component:"form",onSubmit:f(E),disabled:!0,sx:{".section-left":{width:"160px"}},children:[e.jsx(Q,{title:n("notification.email.enable"),my:2.5,children:e.jsx(Y,{name:"enabled",control:u,render:({field:i})=>e.jsx(me,{control:e.jsx(Ke,{checked:i.value,...i})})})}),e.jsx(Q,{title:n("notification.email.from"),children:e.jsx(Y,{name:"from",control:u,rules:{validate:b?P:k},render:({field:i})=>e.jsx(V,{fullWidth:!0,children:e.jsx(X,{...i,size:"small",required:!0,label:n("notification.email.from"),error:!!a.errors[i.name],helperText:a.errors[i.name]?.message||" ",disabled:!b})})})}),e.jsx(Q,{title:n("notification.email.host"),children:e.jsx(Y,{name:"host",control:u,rules:{validate:b?F:k},render:({field:i})=>e.jsx(V,{fullWidth:!0,children:e.jsx(X,{...i,size:"small",required:!0,error:!!a.errors[i.name],label:n("notification.email.host"),helperText:a.errors[i.name]?.message||" ",disabled:!b})})})}),e.jsx(Q,{title:n("notification.email.port"),children:e.jsx(Y,{name:"port",control:u,rules:{validate:b?N:k},render:({field:i})=>e.jsx(V,{fullWidth:!0,children:e.jsx(X,{...i,size:"small",required:!0,type:"number",error:!!a.errors[i.name],label:n("notification.email.port"),helperText:a.errors[i.name]?.message||" ",disabled:!b})})})}),e.jsx(Q,{title:n("notification.email.user"),children:e.jsx(Y,{name:"user",control:u,rules:{validate:b?W:k},render:({field:i})=>e.jsx(V,{fullWidth:!0,children:e.jsx(X,{...i,size:"small",required:!0,error:!!a.errors[i.name],label:n("notification.email.user"),helperText:a.errors[i.name]?.message||" ",disabled:!b})})})}),e.jsx(Q,{title:n("notification.email.password"),children:e.jsx(Y,{name:"password",control:u,rules:{validate:b?K:k},render:({field:i})=>e.jsx(V,{fullWidth:!0,children:e.jsx(X,{...i,size:"small",required:!0,type:"password",error:!!a.errors[i.name],label:n("notification.email.password"),helperText:a.errors[i.name]?.message||" ",disabled:!b})})})}),e.jsx(Q,{title:n("notification.email.secure"),children:e.jsx(Y,{name:"secure",control:u,rules:{validate:k},render:({field:i})=>e.jsx(V,{fullWidth:!0,children:e.jsx(me,{control:e.jsx(Ke,{checked:i.value,...i,disabled:!b})})})})}),e.jsxs(cn,{children:[e.jsxs(dn,{expandIcon:e.jsx(Kt,{fontSize:"small"}),"aria-controls":"panel1-content",id:"panel1-header",children:[n("notification.email.signature"),e.jsx(ut,{title:n("notification.email.signatureTooltip"),children:e.jsx(Wt,{fontSize:"small",sx:{ml:1,cursor:"help"}})})]}),e.jsxs(un,{children:[e.jsx(Q,{title:n("notification.email.companyName"),children:e.jsx(Y,{name:"companyName",control:u,rules:{validate:k},render:({field:i})=>e.jsx(V,{fullWidth:!0,children:e.jsx(X,{...i,size:"small",error:!!a.errors[i.name],label:n("notification.email.companyName"),helperText:a.errors[i.name]?.message||" ",disabled:!b})})})}),e.jsx(Q,{title:n("notification.email.companyLink"),children:e.jsx(Y,{name:"companyLink",control:u,rules:{validate:b?h:k},render:({field:i})=>e.jsx(V,{fullWidth:!0,children:e.jsx(X,{...i,size:"small",error:!!a.errors[i.name],label:n("notification.email.companyLink"),helperText:a.errors[i.name]?.message||" ",disabled:!b})})})}),e.jsx(Q,{title:n("notification.email.companyAddress"),children:e.jsx(Y,{name:"companyAddress",control:u,rules:{validate:k},render:({field:i})=>e.jsx(V,{fullWidth:!0,children:e.jsx(X,{...i,size:"small",error:!!a.errors[i.name],label:n("notification.email.companyAddress"),helperText:a.errors[i.name]?.message||" ",disabled:!b})})})}),e.jsx(Q,{title:n("notification.email.supportEmail"),children:e.jsx(Y,{name:"supportEmail",control:u,rules:{validate:b?T:k},render:({field:i})=>e.jsx(V,{fullWidth:!0,children:e.jsx(X,{...i,size:"small",type:"email",error:!!a.errors[i.name],label:n("notification.email.supportEmail"),helperText:a.errors[i.name]?.message||" ",disabled:!b})})})})]})]}),e.jsxs(S,{sx:{display:"flex",justifyContent:"flex-end",gap:2,mt:3},children:[e.jsx(le,{variant:"outlined",color:"warning",onClick:f(M),disabled:!b,children:n("oauth.runTest")}),e.jsx(le,{type:"submit",variant:"contained",disabled:!a.isDirty,children:n("oauth.save")})]})]}),o]})}const En=ie(mt)``,Be={enabled:!1,endpoint:"",did:void 0,pushPath:void 0};function kn(){const{api:t}=Ye(),{blocklet:s}=Ct(),{t:n}=te(),{confirmApi:r,confirmHolder:o}=wt(),l=s?.meta?.did,j=Object.assign({...Be},s?.settings?.notification?.pushKit||{}),{handleSubmit:f,control:u,formState:a,watch:y,reset:R}=Rt({defaultValues:gt(j,Object.keys(Be))}),w=ye({testReceiver:"",testReceiverError:""}),b=y("enabled"),E=$(async(N,W,K=!0)=>{try{const{blocklet:h}=await t.configNotification({input:{did:l,notification:JSON.stringify({pushKit:N})}}),T=Object.assign({...Be},h?.settings?.notification?.pushKit||{});R(T),K&&q.success(n("oauth.saveSuccess"))}catch(h){if(K)q.error(h.message||n("oauth.saveFailed"));else throw h}}),J=$(async(N,W)=>{try{a.isDirty&&await E(N,W,!1);const K=(s?.configs||[]).find(k=>k.key==="BLOCKLET_APP_URL")?.value,h=Xt(Zt(K,B.WELLKNOWN_SERVICE_PATH_PREFIX,"/blocklet/logo"),{v:s?.meta?.version,t:new Date(s?.updatedAt||0).getTime()}),T={type:"passthrough",passthroughType:"messageStatus",data:{message:{title:"Test push-kit notification",body:"This is message from push-kit config test",sender:{did:s?.appDid,fullName:s?.meta?.title,avatar:h}}}};await t.sendPush({input:{did:l,receiver:w.testReceiver,notification:JSON.stringify(T)}}),q.success(n("notification.pushKit.testSuccess"))}catch(K){q.error(K.message||n("notification.pushKit.testfailed"))}}),M=$((N,W)=>{w.testReceiverError="",r.open({title:n("notification.pushKit.testSend"),content:()=>e.jsx(S,{sx:{width:"450px",maxWidth:"100%"},children:e.jsx(X,{sx:{mt:1},fullWidth:!0,name:"testReceiver",label:n("notification.pushKit.inputTestReceiver"),value:w.testReceiver,onChange:K=>{w.testReceiver=K.target.value},error:!!w.testReceiverError,helperText:w.testReceiverError||" "})}),confirmButtonText:n("common.confirm"),cancelButtonText:n("common.cancel"),async onConfirm(K){if(!w.testReceiver?.trim()){w.testReceiverError=n("notification.pushKit.receiverRequired");return}w.testReceiverError="",await J(N,W),K()}})}),P=$(N=>{const W=N?.trim();return W?He(W)?!0:n("notification.pushKit.endpointInvalid"):n("notification.pushKit.endpointRequired")}),F=$(()=>!0);return e.jsxs(S,{children:[e.jsxs(An,{component:"form",onSubmit:f(E),disabled:!0,sx:{".section-left":{width:"160px"}},children:[e.jsx(Q,{title:n("notification.pushKit.enable"),my:2.5,children:e.jsx(Y,{name:"enabled",control:u,render:({field:N})=>e.jsx(me,{control:e.jsx(Ke,{checked:N.value,...N})})})}),e.jsx(Q,{title:n("notification.pushKit.endpoint"),children:e.jsx(Y,{name:"endpoint",control:u,rules:{validate:b?P:F},render:({field:N})=>e.jsx(V,{fullWidth:!0,children:e.jsx(X,{...N,size:"small",required:!0,label:n("notification.pushKit.endpoint"),error:!!a.errors[N.name],helperText:a.errors[N.name]?.message||" ",disabled:!b})})})}),e.jsxs(Q,{title:n("notification.pushKit.customOptions"),children:[e.jsx(Y,{name:"did",control:u,render:({field:N})=>e.jsx(V,{fullWidth:!0,children:e.jsx(X,{...N,size:"small",label:n("notification.pushKit.did"),error:!!a.errors[N.name],helperText:a.errors[N.name]?.message||" ",disabled:!b})})}),e.jsx(Y,{name:"pushPath",control:u,render:({field:N})=>e.jsx(V,{fullWidth:!0,children:e.jsx(X,{...N,size:"small",label:n("notification.pushKit.pushPath"),error:!!a.errors[N.name],helperText:a.errors[N.name]?.message||" ",disabled:!b})})})]}),e.jsxs(S,{sx:{display:"flex",justifyContent:"flex-end",gap:2,mt:3},children:[e.jsx(le,{variant:"outlined",color:"warning",onClick:f(M),disabled:!b,children:n("oauth.runTest")}),e.jsx(le,{type:"submit",variant:"contained",disabled:!a.isDirty,children:n("oauth.save")})]})]}),o]})}const An=ie(mt)``,ct=[{label:e.jsx(S,{sx:{textAlign:"center",width:"100%"},children:"Email"}),value:"email"},{label:e.jsx(S,{sx:{textAlign:"center",width:"100%"},children:"Push Kit"}),value:"pushKit"}];function On(){const[t,s]=v.useState(ct[0].value),{locale:n}=v.useContext(tn),r=se(()=>({email:e.jsx(In,{}),pushKit:e.jsx(kn,{})}),[n]),o=v.useMemo(()=>({padding:"10px 0"}),[]);return e.jsxs(S,{children:[e.jsx(bt,{tabs:ct,current:t,onChange:s}),e.jsx(S,{style:o,children:r[t]})]})}const kt=v.createContext({}),{Provider:Dn,Consumer:Bs}=kt;function Ln({children:t,blocklet:s=""}){const{api:n,inService:r,ws:{useSubscription:o}}=Ye(),[l,j]=v.useState([]),[f,u]=v.useState({total:0,pageSize:20,pageCount:0,page:1}),a=se(()=>s.meta?.did,[s]),[y,R]=v.useState([]),[w,b]=v.useState({}),E=se(()=>l.length?new Set(l.map(h=>h.id)):new Set,[l]),J=async({page:h=1,pageSize:T=20,...k}={})=>{if(!a)return[];try{const i={paging:{page:h,pageSize:T},...k,teamDid:a,dateRange:k.dateRange?[Z(k.dateRange[0]).toISOString(),Z(k.dateRange[1]).toISOString()]:void 0},{dids:C,...D}=i;let O="";C&&C.includes("system")&&(O="system");const ae=C?C.filter(pe=>pe!=="system"):[],de={...D,source:O,componentDids:ae},re=await n.getNotificationSendLog({input:de});return b(de),j(re.list),u(re.paging),re.list}catch(i){return q.error(i.message),[]}},M=async()=>{const h=await n.getNotificationComponents({input:{teamDid:a}});R(h.componentDids)},P=v.useCallback(h=>{const T=s.children.find(k=>k.meta?.did===h);if(T)return T.ancestors=[s],T},[s]),F=async({notificationId:h,receivers:T,channels:k,...i})=>{await n.resendNotification({input:{teamDid:a,notificationId:h,receivers:T,channels:k.map(C=>C==="wallet"?B.NOTIFICATION_SEND_CHANNEL.WALLET:C==="pushKit"?B.NOTIFICATION_SEND_CHANNEL.PUSH:C),...i}})},N=v.useCallback(async h=>(await n.getUser({input:{teamDid:a,user:{did:h},options:{enableConnectedAccount:!0}}})).user,[n,a]),W=v.useCallback(async({page:h=1,pageSize:T=20,...k}={})=>{try{const i={paging:{page:h,pageSize:T},...k,userName:k.searchText||"",teamDid:a,dateRange:k.dateRange?[Z(k.dateRange[0]).toISOString(),Z(k.dateRange[1]).toISOString()]:void 0};return await n.getReceivers({input:i})}catch(i){throw q.error(i.message),i}},[n,a]);v.useEffect(()=>{a&&M()},[a]),o(B.EVENTS.NOTIFICATION_BLOCKLET_UPDATE,h=>{E.has(h.notificationId)&&J(w)},[E,w]),o(B.EVENTS.NOTIFICATION_BLOCKLET_CREATE,h=>{E.has(h.id)||J(w)},[E,w]);const K={fetch:J,data:l,paging:f,blocklet:s,getComponent:P,resendNotification:F,getUser:N,componentDids:y,getReceivers:W,inService:r,teamDid:a};return e.jsx(Dn,{value:{notificationRecords:K},children:t})}function Qe(){const{notificationRecords:t}=v.useContext(kt);return t}Ce.propTypes={severity:p.oneOf(Object.values(["info","success","error","warning"])).isRequired};const Pn={info:"primary",success:"success",error:"error",warning:"warning"};function Ce({severity:t="info"}){return e.jsx(nn,{type:Pn[t],children:t})}const Fn=(t,s,n="")=>{if(!n||!s)return"";switch(n){case B.NOTIFICATION_SEND_FAILED_REASON.USER_DISABLED:return t("notification.sendStatus.reason.disabled",{channel:s});case B.NOTIFICATION_SEND_FAILED_REASON.CHANNEL_UNAVAILABLE:return t("notification.sendStatus.reason.unavailable",{channel:s});case B.NOTIFICATION_SEND_FAILED_REASON.CHANNEL_DISABLED:return t("notification.sendStatus.reason.notSent",{channel:s});case B.NOTIFICATION_SEND_FAILED_REASON.NOT_ONLINE:return t("notification.sendStatus.reason.offline");default:return n}};function At(t,s,n={}){const{status:r,updatedAt:o,reason:l="",channel:j="wallet"}=n,f=o?t("notification.sendStatus.sentTime",{date:ln(o,s)}):"",u=Fn(t,j,l);return r===B.NOTIFICATION_SEND_STATUS.FAILED?{status:"failed",title:t("notification.sendStatus.failed"),sentTime:f,reason:u}:r===B.NOTIFICATION_SEND_STATUS.SENT?{status:"success",title:t("notification.sendStatus.success"),sentTime:f}:{status:"pending",title:t("notification.sendStatus.pending"),reason:u,sentTime:f}}const $e={pending:"#aaaaaa",success:"#34BE74",failed:"#D0021B"},Ve=["wallet","pushKit","email"],dt=["info","success","error","warning"],Ot=t=>{const{settings:s}=t;return s?.notification?.email?.enabled},Dt=t=>{const{settings:s}=t;return s?.notification?.pushKit?.enabled},_n=(t,s)=>{const n=oe(s,"extra.notifications.email",!0);return{available:Ot(t),enabled:n}},zn=(t,s)=>{const n=oe(s,"extra.notifications.push",!0);return{available:Dt(t),enabled:n}},Bn=t=>({enabled:oe(t,"extra.notifications.wallet",!0)}),Wn=t=>({enabled:oe(t,"extra.webhooks",[]).length>0}),Ie=(t=3)=>new Promise(s=>{setTimeout(()=>{s()},t*1e3)}),Kn=(t,s)=>s==="wallet"||s==="webhook"?[{channel:s,type:"enabled",pass:t("notification.sendStatus.reason.enabled",{channel:s}),fail:t("notification.sendStatus.reason.disabled",{channel:s})}]:s==="pushKit"||s==="email"?[{channel:s,type:"available",pass:t("notification.sendStatus.reason.available",{channel:s}),fail:t("notification.sendStatus.reason.unavailable",{channel:s})},{channel:s,type:"enabled",pass:t("notification.sendStatus.reason.enabled",{channel:s}),fail:t("notification.sendStatus.reason.disabled",{channel:s})}]:[],Ee=(t=[])=>{const s=Z().startOf("day");return t.filter(n=>Z(n.sendAt).isSame(s,"day")).length},qn=(t,s="")=>{if(s&&Ve.includes(s)){const l=`${s}SendRecord`,j=oe(t,l,[]);return Ee(j)}const n=oe(t,"webhook",{}),r=Object.keys(n??{})??[];if(s&&r.includes(s)){const l=n[s]??[];return Ee(l)}const o={};return Ve.forEach(l=>{const j=`${l}SendRecord`,f=oe(t,j,[]),u=Ee(f);o[l]=u}),r.length>0&&r.forEach(l=>{const j=n[l]??[],f=Ee(j);o[l]=f}),o},Ae=(t,s,n)=>{if(!Array.isArray(t))throw new Error("Invalid filterList or index");return t[n].splice(s,1),t},Oe=(t,s)=>{if(!Array.isArray(s))throw new Error("filters must be an array");return s.length?!s.includes(t):!1},Mn=t=>{switch(t){case B.NOTIFICATION_SEND_CHANNEL.WALLET:return"Wallet";case B.NOTIFICATION_SEND_CHANNEL.PUSH:return"Push Kit";case B.NOTIFICATION_SEND_CHANNEL.EMAIL:return"Email";case B.NOTIFICATION_SEND_CHANNEL.WEBHOOK:return"Webhook";default:return""}},Lt=()=>({components:{MUIDataTableFilter:{styleOverrides:{header:{marginBottom:0,p:{margin:0}},root:{"& .MuiGrid-container":{marginTop:0,"& .MuiGrid-item":{paddingTop:0}}}}},MuiPopover:{styleOverrides:{root:{"&.MuiPopover-root":{"& .MuiPaper-root:has(.filter-container)":{width:"420px"}}}}}}});function ce({config:t,enableTooltip:s=!0,showTitle:n=!1,children:r=null}){const{status:o,title:l="",sentTime:j="",reason:f=""}=t,u=[l,f].filter(Boolean).join(", ");return e.jsx(ut,{title:s?e.jsxs(e.Fragment,{children:[e.jsx(ee,{color:"inherit",sx:{fontSize:12},children:u}),e.jsx("span",{children:j})]}):null,arrow:!0,placement:"top",children:e.jsxs(S,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"4px"},children:[e.jsxs(S,{sx:{position:"relative",minHeight:14,minWidth:14,display:"flex",alignItems:"center",justifyContent:"center"},children:[e.jsx(S,{style:{opacity:.15},sx:{position:"absolute",width:"100%",height:"100%",borderRadius:"50%",bgcolor:$e[o]}}),e.jsx(S,{sx:{position:"absolute",width:"55%",height:"55%",borderRadius:"50%",bgcolor:$e[o]}})]}),e.jsx(ee,{color:"inherit",sx:{fontSize:12},children:n?l:r})]})})}ce.propTypes={config:p.object.isRequired,enableTooltip:p.bool,showTitle:p.bool,children:p.node};De.propTypes={list:p.array.isRequired,label:p.string.isRequired,onDelete:p.func};function De({list:t,label:s,onDelete:n=()=>{}}){const{t:r,locale:o}=te();return e.jsxs(S,{sx:{display:"flex",gap:1,alignItems:"center"},children:[e.jsxs(ee,{children:[s,": "]}),t.map(l=>{const j=At(r,o,{status:l});return e.jsx(Je,{size:"small",label:e.jsx(S,{sx:{display:"flex",alignItems:"center",gap:"4px"},children:e.jsx(ce,{config:j,enableTooltip:!1,children:j.title})}),onDelete:f=>n(f,l)},l)})]})}Xe.propTypes={filterList:p.array.isRequired,onChange:p.func.isRequired,index:p.number.isRequired,column:p.object.isRequired,filterValues:p.array.isRequired,label:p.string.isRequired,renderLabel:p.func.isRequired};function Xe({filterList:t,onChange:s,index:n,column:r,filterValues:o,label:l,renderLabel:j}){return e.jsxs(V,{className:"filter-container",children:[e.jsx(pt,{component:"legend",children:l}),e.jsx(qe,{row:!0,children:o.map(f=>e.jsx(me,{control:e.jsx(Me,{checked:t[n].indexOf(f.value??f)>-1,onChange:u=>{const a=[...t];u.target.checked?a[n]=[...a[n],f.value??f]:a[n]=a[n].filter(y=>y!==(f.value??f)),s(a[n],n,r)},name:f.value??f}),label:e.jsx("span",{style:{display:"flex",alignItems:"center"},children:j(f)})},f.value??f))})]})}function We(t){return e.jsx(Xe,{...t,renderLabel:s=>e.jsx(ce,{enableTooltip:!1,config:{status:s.status},children:s.label})})}xe.propTypes={status:p.number.isRequired,updatedAt:p.string.isRequired,reason:p.string,channel:p.string,onResend:p.func};function xe({status:t,updatedAt:s,reason:n="",channel:r="wallet",onResend:o}){const{t:l,locale:j}=te(),f=At(l,j,{status:t,updatedAt:s,reason:n,channel:r});return e.jsxs(S,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(ce,{config:f,showTitle:!0}),f.status!=="success"&&e.jsx(Pe,{className:"resend-btn",size:"small",startIcon:e.jsx(Ge,{}),sx:{fontSize:12,color:"rgba(0, 0, 0, 0.87)",fontWeight:400,".MuiButton-startIcon":{mr:"2px"}},onClick:o,children:l("notification.resend")})]})}Ze.propTypes={value:p.array.isRequired,onChange:p.func};function Ze({value:t,onChange:s}){const{locale:n}=te(),r=Z().toDate(),[o,l]=v.useState(null),j=v.useCallback(a=>{l(o?null:a.currentTarget)},[o]),f=!!o,u=v.useCallback(a=>{if(!a.startDate||!a.endDate){q.error("Please select a date range");return}if(Z(a.startDate).isAfter(a.endDate)||!Z(a.startDate).isValid()||!Z(a.endDate).isValid()){q.error("Invalid date range");return}s([a.startDate,a.endDate]),l(null)},[s]);return e.jsxs("div",{children:[e.jsx(ee,{component:"div",variant:"h5",color:"textPrimary",style:{fontSize:18,fontWeight:"bold"},sx:{mb:0},children:e.jsxs(Pe,{onClick:j,variant:"outlined",size:"small",color:"inherit",children:[at(t[0],n)," - ",at(t[1],n)]})}),e.jsx(Ue,{open:f,anchorEl:o,onClose:()=>{l(null)},anchorOrigin:{vertical:"bottom",horizontal:"left"},children:e.jsx(vn,{open:!0,maxDate:r,initialDateRange:{startDate:t[0],endDate:t[1]},toggle:j,definedRanges:yn(r),onChange:u})})]})}et.propTypes={itemComponent:p.elementType.isRequired};function et({itemComponent:t,...s}){const{t:n}=te();return!s?.filterList?.filter(o=>o.length).length?null:e.jsxs(S,{sx:{display:"flex",gap:1,alignItems:"center"},children:[e.jsx("div",{className:"toolbar-filter-title",children:n("notification.filter")}),e.jsx("div",{className:"toolbar-filter-content",children:e.jsx(sn.TableFilterList,{...s,ItemComponent:t})})]})}function tt({label:t,onDelete:s,canDelete:n=()=>!0,...r}){const o=s&&typeof s=="function"?s:void 0;let l=!0;return n&&typeof n=="function"&&(l=n({label:t,...r})),e.jsx(Je,{label:t,variant:"outlined",...o&&l?{onDelete:o}:{}})}tt.propTypes={label:p.string.isRequired,onDelete:p.func,canDelete:p.func};const Un=[{label:"Wallet",value:"app",checked:!0},{label:"Email",value:"email",checked:!0},{label:"Push Kit",value:"push",checked:!0},{label:"Webhook",value:"webhook",checked:!0}];Pt.propTypes={loading:p.bool,onCancel:p.func,onConfirm:p.func};function Pt({loading:t=!1,onCancel:s=()=>{},onConfirm:n=()=>{}}){const{t:r}=te(),[o,l]=v.useState(Un),[j,f]=v.useState(!0),u=(y,R)=>{R.checked=y.target.checked;const w=o.map(b=>({...b,checked:b.value===R.value?R.checked:b.checked}));l(w)},a=y=>{y.stopPropagation(),n({channels:o.filter(R=>R.checked).map(R=>R.value),isResendFailedOnly:j})};return e.jsxs(S,{className:"resend-config",sx:{padding:"16px 24px"},children:[e.jsx(ee,{variant:"body1",component:"div",className:"check-title",sx:{fontWeight:700,mb:1},children:r("notification.config")}),e.jsx(S,{className:"choose-channel",children:e.jsxs(V,{component:"fieldset",variant:"standard",children:[e.jsx(pt,{component:"legend",children:r("notification.selectChannels")}),e.jsx(qe,{sx:{display:"flex",flexDirection:"row",flexWrap:"wrap",gap:1},children:o.map(y=>e.jsx(me,{control:e.jsx(Me,{checked:y.checked,onChange:R=>u(R,y),name:y.value}),label:y.label},y.value))})]})}),e.jsx(S,{className:"resend-config-footer",children:e.jsx(qe,{children:e.jsx(me,{control:e.jsx(Me,{checked:j,onChange:y=>f(y.target.checked)}),label:r("notification.resendFailedOnly")})})}),e.jsxs(S,{className:"resend-config-footer-tip",sx:{display:"flex",justifyContent:"flex-end",gap:1},children:[e.jsx(Pe,{onClick:y=>{y.stopPropagation(),s()},color:"inherit",children:r("common.cancel")}),e.jsxs(Pe,{onClick:a,color:"primary",disabled:t,variant:"contained",autoFocus:!0,style:{marginLeft:8},children:[t&&e.jsx(ft,{size:16}),r("common.confirm")]})]})]})}Ft.propTypes={notificationId:p.string.isRequired,handleResend:p.func,resending:p.bool};function Ft({notificationId:t,handleResend:s,resending:n=!1}){const{t:r,locale:o}=te(),l=ht(),j=v.useMemo(()=>jt(l,Lt()),[l]),{getReceivers:f,inService:u,teamDid:a,getUser:y,blocklet:R}=Qe(),[w,b]=v.useState(!1),[E,J]=v.useState([]),M=ye({anchorEl:null,position:null}),P=ye({anchorEl:null,position:null}),[F,N]=v.useState(null),[W,K]=v.useState({total:0,pageSize:10,pageCount:0,page:1}),[h,T]=v.useState({searchText:"",page:1,pageSize:10,walletSendStatus:[],pushKitSendStatus:[],emailSendStatus:[],dateRange:[Z().subtract(1,"month").startOf("day").toDate(),Z().endOf("day").toDate()]}),[k,i]=v.useState([]),C=[{label:r("notification.sendStatus.pending"),value:0,status:"pending"},{label:r("notification.sendStatus.success"),value:1,status:"success"},{label:r("notification.sendStatus.failed"),value:2,status:"failed"}],D=async()=>{if(!w&&t)try{b(!0);const c=await f({notificationId:t,...h}),d=c.list.map(m=>({...m,receiverUser:{...m.receiverUser,avatar:It(m.receiverUser.avatar,a,u)}}));J(d),K(c.paging),b(!1)}catch(c){q.error(c.message),b(!1)}};v.useEffect(()=>{D()},[h]);const O=c=>{c.stopPropagation();const d=c.currentTarget;P.anchorEl=d;const m=d.getBoundingClientRect();P.position={top:m.top+window.scrollY,left:m.left+window.scrollX}},ae=c=>c.data.length?e.jsx("div",{style:{display:"flex",alignItems:"center",padding:"10px"},children:e.jsx(le,{className:"resend-btn",size:"small",color:"primary",variant:"contained",startIcon:e.jsx(Ge,{}),sx:{".MuiButton-startIcon":{mr:"2px"}},onClick:O,children:r("notification.resend")})}):null,de={sort:!1,download:!1,print:!1,selectableRows:"multiple",searchPlaceholder:r("common.search"),searchAlwaysOpen:!1,filterType:"checkbox",searchDebounceTime:300,page:W.page-1,rowsPerPage:W.pageSize,count:W.total,searchText:h.searchText,tableBodyMaxHeight:"calc(80vh - 260px)",rowsSelected:k,onRowSelectionChange:(c,d)=>{i(d.map(m=>m.dataIndex))},customToolbarSelect:ae},re=({page:c,rowsPerPage:d,searchText:m,filterList:A})=>{const[,U=[],ne=[],G=[]]=A;h.pageSize!==d?T(H=>({...H,pageSize:d,page:1})):h.page!==c+1?T(H=>({...H,page:c+1})):h.searchText!==m?T(H=>({...H,searchText:m,page:1})):je(U,h.walletSendStatus)?je(ne,h.pushKitSendStatus)?je(G,h.emailSendStatus)||T(H=>({...H,emailSendStatus:G,page:1})):T(H=>({...H,pushKitSendStatus:ne,page:1})):T(H=>({...H,walletSendStatus:U,page:1}))},pe=v.useCallback(async(c,d)=>{if(!d)return!1;const m=await y(d);return m?c==="wallet"?Bn(m):c==="email"?_n(R,m):c==="pushKit"?zn(R,m):c==="webhook"?Wn(m):!0:!1},[y,R]),Fe=v.useCallback(c=>Kn(r,c),[r]),ue=()=>{M.anchorEl=null,M.position=null,N(null)},fe=()=>{P.anchorEl=null,P.position=null},we=async(c,d,m=!0,A="")=>{if(!(!d.length||!c.length))try{s(c,d,m,A),P.anchorEl||(await Ie(.5),ue())}catch(U){console.error("handleResend error",{error:U})}},g=async({channels:c,isResendFailedOnly:d})=>{const m=k.map(A=>E[A].receiver);await we(c,m,d),await Ie(.5),fe(),i([])},x=async(c,d=[],m=!0)=>{try{await we(["webhook"],[c.receiver],m,d)}catch(A){q.error(A.response?A.response.statusText:A.message)}},I=async(c,d,m,A=[],U=!0)=>{if(c.stopPropagation(),qn(d,m)>=4){q.warning(r("notification.resendLimit"));return}if(!Ve.includes(m)){await x(d,A,U);return}if(c){const G=c.currentTarget,H=G.getBoundingClientRect();M.anchorEl=G,M.position={top:H.top+window.scrollY,left:H.left+window.scrollX}}N({channel:m});try{const G=await pe(m,d.receiver);await Ie(1),N({channel:m,result:G}),(typeof G=="boolean"&&G||en(G)&&Object.values(G).every(H=>!!H))&&(await s([m],[d.receiver],U),P.anchorEl||(await Ie(.5),ue()))}catch(G){q.error(G.message)}},_=c=>{T(d=>({...d,dateRange:c,page:1}))},z=(c,d,m,A)=>{c.stopPropagation();const U=m.filter(ne=>ne!==d);T(ne=>({...ne,[A]:U,page:1}))},L=se(()=>[{label:r("notification.receiver"),name:"receiver",width:200,options:{filter:!1,customBodyRenderLite:c=>{const{receiverUser:d,receiver:m}=E[c];return d?e.jsxs(S,{"data-cy":`member-name-${d.fullName}`,sx:{display:"flex",alignItems:"center",gap:1,justifyContent:"flex-start"},children:[e.jsx(vt,{src:`${d.avatar}?imageFilter=resize&w=48&h=48`,size:32,did:m,shape:"circle",style:{borderRadius:"100%",overflow:"hidden"}}),e.jsx(Se,{children:d.fullName})]},m):e.jsx(jn,{size:14,responsive:!1,compact:!0,copyable:!1,did:m})}}},{label:"Wallet",name:"walletSendStatus",width:200,options:{setCellProps:()=>({className:"sent-status-cell"}),filter:!0,filterType:"custom",filterList:h.walletSendStatus??[],customFilterListOptions:{render:c=>e.jsx(De,{list:c,label:"Wallet",onDelete:(d,m)=>{d.stopPropagation(),z(d,m,L[1].options.filterList,"walletSendStatus")}}),update:Ae},filterOptions:{names:C,fullWidth:!0,logic:Oe,display:(c,d,m,A)=>e.jsx(We,{label:"Wallet",filterList:c,onChange:d,index:m,column:A,filterValues:C})},customBodyRenderLite:c=>{const{walletSendStatus:d,walletSendAt:m,walletSendFailedReason:A}=E[c];return e.jsx(xe,{status:d,updatedAt:m,reason:A,channel:"wallet",onResend:U=>I(U,E[c],"wallet",[],!1)})}}},{label:"Push Kit",name:"pushKitSendStatus",width:200,options:{setCellProps:()=>({className:"sent-status-cell"}),customBodyRenderLite:c=>{const{pushKitSendStatus:d,pushKitSendAt:m,pushKitSendFailedReason:A}=E[c];return e.jsx(xe,{status:d,updatedAt:m,reason:A,channel:"pushkit",onResend:U=>I(U,E[c],"pushKit",[],!1)})},filter:!0,filterType:"custom",filterList:h.pushKitSendStatus??[],customFilterListOptions:{render:c=>e.jsx(De,{list:c,label:"Push Kit",onDelete:(d,m)=>{d.stopPropagation(),z(d,m,L[2].options.filterList,"pushKitSendStatus")}}),update:Ae},filterOptions:{names:C,fullWidth:!0,logic:Oe,display:(c,d,m,A)=>e.jsx(We,{label:"Push Kit",filterList:c,onChange:d,index:m,column:A,filterValues:C})}}},{label:"Email",name:"emailSendStatus",width:200,options:{setCellProps:()=>({className:"sent-status-cell"}),customBodyRenderLite:c=>{const{emailSendStatus:d,emailSendAt:m,emailSendFailedReason:A}=E[c];return e.jsx(xe,{status:d,updatedAt:m,reason:A,channel:"email",onResend:U=>I(U,E[c],"email",[],!1)})},filter:!0,filterType:"custom",filterList:h.emailSendStatus??[],customFilterListOptions:{render:c=>e.jsx(De,{list:c,label:"Email",onDelete:(d,m)=>{d.stopPropagation(),z(d,m,L[3].options.filterList,"emailSendStatus")}}),update:Ae},filterOptions:{names:C,fullWidth:!0,logic:Oe,display:(c,d,m,A)=>e.jsx(We,{label:"Email",filterList:c,onChange:d,index:m,column:A,filterValues:C})}}},{label:"Webhook",name:"webhook",width:200,options:{filter:!1,setCellProps:()=>({className:"sent-status-cell"}),customBodyRenderLite:c=>{const{webhook:d}=E[c];if(!d)return null;const m=Object.entries(d)[0];if(!m)return null;const[A,U]=m,ne=U[0];return e.jsx(S,{sx:{display:"flex",flexDirection:"column",gap:1},children:e.jsxs(S,{className:"webhook-item",sx:{fontSize:12},children:[e.jsx(Se,{maxLength:30,children:A},A),e.jsx(xe,{status:ne.status,updatedAt:ne.sendAt,reason:ne.failedReason,channel:"webhook",onResend:G=>I(G,E[c],"webhook",[A],!1)})]},A)})}}},{label:r("common.createdAt"),name:"createdAt",width:100,options:{filter:!1,customBodyRenderLite:c=>{const{createdAt:d}=E[c];return e.jsx(Nt,{value:d,locale:o,shouldUpdate:!0})}}}],[E,o,h,r]),he=[e.jsx(Ze,{value:h.dateRange,onChange:_},"date-picker"),e.jsx(le,{variant:"contained",size:"small",color:"primary",loading:w,startIcon:e.jsx(qt,{}),onClick:()=>D(),sx:{".MuiButton-startIcon":{mr:"2px"}},style:{marginLeft:8},children:r("common.refresh")},"refresh")];return e.jsx(S,{sx:{overflow:"auto",".MuiTableCell-head":{whiteSpace:"nowrap",fontWeight:"bold"},".MuiTableCell-root":{paddingRight:"8px",whiteSpace:"nowrap"}},children:e.jsx($n,{children:e.jsxs(xt,{theme:j,children:[e.jsx(yt,{className:"receivers-table",locale:o,loading:w,columns:L,data:E,onChange:re,options:de,customButtons:he,components:{TableFilterList:c=>e.jsx(et,{...c,itemComponent:d=>e.jsx(tt,{...d,canDelete:()=>!1})})}}),M.anchorEl&&e.jsx(Ue,{open:!!M.anchorEl,anchorReference:"anchorPosition",anchorPosition:M.position,onClose:ue,anchorOrigin:{vertical:"center",horizontal:"right"},transformOrigin:{vertical:"center",horizontal:"left"},children:e.jsxs(Vn,{children:[e.jsxs(ee,{variant:"body1",component:"div",className:"check-title",children:[F?.channel," Checking"]}),e.jsx(S,{sx:{display:"flex",flexDirection:"column",gap:"4px"},children:Fe(F?.channel).map(c=>{const{type:d,pass:m,fail:A}=c;return!F?.result||F?.result?.[d]?e.jsxs(ee,{variant:"body1",component:"div",className:"check-item",sx:{display:"flex",alignItems:"center",gap:"4px",color:F?.result?.[d]?ke.success.main:"inherit"},children:[F?.result?e.jsx(Mt,{}):e.jsx(ft,{size:12,sx:{color:ke.primary.main}}),e.jsx("span",{children:m})]},d):e.jsxs(ee,{variant:"body1",component:"div",className:"check-item",sx:{display:"flex",alignItems:"center",gap:"4px",color:ke.error.main},children:[e.jsx(Ut,{}),e.jsx("span",{children:A})]},d)})})]})}),P.anchorEl&&e.jsx(Ue,{open:!!P.anchorEl,anchorReference:"anchorPosition",anchorPosition:P.position,onClose:fe,anchorOrigin:{vertical:"center",horizontal:"right"},transformOrigin:{vertical:"center",horizontal:"left"},children:e.jsx(Pt,{loading:n,onCancel:fe,onConfirm:g})})]})})})}const Hn=v.memo(Ft),$n=ie.div`
2
- td.MuiTableCell-footer {
3
- border: none !important;
4
- }
5
- .sent-status-cell {
6
- .resend-btn {
7
- display: none;
8
- }
9
- &:hover {
10
- .resend-btn {
11
- display: flex;
12
- }
13
- }
14
- }
15
- `,Vn=ie.div`
16
- padding: 8px 16px;
17
- .check-title {
18
- font-weight: 500;
19
- margin-bottom: 8px;
20
- &::first-letter {
21
- text-transform: uppercase;
22
- }
23
- }
24
- .check-item {
25
- svg {
26
- font-size: 16px;
27
- }
28
- font-size: 12px;
29
- }
30
- `,ve=t=>t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}K`:t;function Jn(t){const{wallet:s,push:n,email:r,webhook:o}=t;return[{name:"Wallet",value:e.jsx(ge,{item:s})},{name:"Push",value:e.jsx(ge,{item:n})},{name:"Email",value:e.jsx(ge,{item:r})},...o.total>0?[{name:"Webhook",value:e.jsx(ge,{item:o,isWebhook:!0})}]:[]]}function Gn(t,s,n){const{wallet:r,push:o,email:l,webhook:j}=t;return[{name:"Wallet",value:e.jsx(be,{loading:n,channel:B.NOTIFICATION_SEND_CHANNEL.WALLET,item:r,onResend:s})},{name:"Push",value:e.jsx(be,{loading:n,channel:B.NOTIFICATION_SEND_CHANNEL.PUSH,item:o,onResend:s})},{name:"Email",value:e.jsx(be,{loading:n,channel:B.NOTIFICATION_SEND_CHANNEL.EMAIL,item:l,onResend:s})},...j.total>0?[{name:"Webhook",value:e.jsx(be,{loading:n,channel:B.NOTIFICATION_SEND_CHANNEL.WEBHOOK,item:j,isWebhook:!0,onResend:s})}]:[]]}nt.propTypes={statistics:p.object.isRequired,onResend:p.func,mode:p.oneOf(["simple","detail"]),resending:p.bool};ge.propTypes={item:p.object.isRequired,isWebhook:p.bool};function ge({item:t,isWebhook:s=!1}){const{t:n}=te(),r=s?t.success.length:t.success,o=t.total,l=r===o?"success":"failed";return e.jsx(S,{sx:{display:"flex",alignItems:"center",justifyContent:"flex-start",gap:2},children:e.jsx(S,{sx:{display:"flex",alignItems:"center",gap:1},children:e.jsxs(ce,{config:{status:l},enableTooltip:!1,children:[ve(r)," / ",ve(o)," ",n("notification.sendStatus.success")]})})})}be.propTypes={item:p.object.isRequired,isWebhook:p.bool,channel:p.string,onResend:p.func,loading:p.bool};function be({channel:t=B.NOTIFICATION_SEND_CHANNEL.WALLET,item:s,isWebhook:n=!1,onResend:r=()=>{},loading:o=!1}){const{t:l}=te(),{success:j,failed:f,pending:u}=s,a=Mn(t),y=n?j.length:j,R=n?f.length:f,w=n?u.length:u,b=async P=>{P.stopPropagation();const F=n?[...new Set([...j,...f].map(N=>N))]:[];await r([t],[],!0,F)},E=y+R,J=E>0?y/E*100:0,M=E>0?R/E*100:0;return e.jsxs(Yn,{successRatio:J,failedRatio:M,children:[e.jsxs(ee,{variant:"h6",children:[a," (",s.total,")"]}),e.jsxs(ee,{variant:"body1",sx:{mb:2},children:[e.jsx("span",{style:{color:$e.success,fontWeight:600,fontSize:24},children:ve(y)}),e.jsx("small",{style:{paddingLeft:4},children:l("notification.sendStatus.success")})]}),e.jsxs(S,{className:"unsent-area",children:[e.jsxs(S,{children:[e.jsxs(ce,{config:{status:"failed"},enableTooltip:!1,children:[ve(R)," ",l("notification.sendStatus.failed")]}),e.jsxs(ce,{config:{status:"pending"},enableTooltip:!1,children:[ve(w)," ",l("notification.sendStatus.pending")]})]}),R>0&&e.jsx(S,{className:"resend-btn",children:e.jsx(le,{size:"small",color:"primary",loading:o,variant:"contained",startIcon:e.jsx(Ge,{}),sx:{".MuiButton-startIcon":{mr:"2px"}},onClick:b,children:l("notification.resend")})})]})]})}function nt({statistics:t,mode:s="simple",onResend:n=()=>{},resending:r=!1}){const o=se(()=>s==="simple"?Jn(t):Gn(t,n,r),[t,s]);return s==="simple"?e.jsx("div",{children:o.map(l=>e.jsx(Tt,{style:{alignItems:"flex-start",marginBottom:s==="simple"?0:16},valueComponent:"div",nameWidth:100,name:l.name,children:l.value},l.name))}):e.jsx(st,{container:!0,spacing:2,children:o.map(l=>e.jsx(st,{size:{md:4,sm:6,xs:12},children:l.value},l.name))})}const Yn=ie(S)`
31
- display: flex;
32
- flex-direction: column;
33
- align-items: flex-start;
34
- padding: 16px;
35
- border-radius: 8px;
36
- background: ${({successRatio:t,failedRatio:s,theme:n})=>t===0&&s===0?n.palette.grey[300]:`linear-gradient(to right, ${Ht(n.palette.success.light,.4)} ${t}%, ${n.palette.grey[100]} ${t}%)`};
37
- transition: 'background 0.5s ease';
38
- cursor: pointer;
39
- .unsent-area {
40
- width: 100%;
41
- position: relative;
42
- .resend-btn {
43
- position: absolute;
44
- right: 0;
45
- bottom: 0;
46
- }
47
- }
48
- `;_t.propTypes={notification:p.object.isRequired,onCancel:p.func,blocklet:p.object.isRequired,tab:p.string};function _t({notification:t,onCancel:s=()=>{},blocklet:n,tab:r="info"}){const{t:o,locale:l}=te(),{getComponent:j,resendNotification:f}=Qe(),[u,a]=v.useState(!1),y=se(()=>j(t.componentDid)||n,[n,t.componentDid]),R=ye({tab:r||"info"}),w=v.useCallback(async(h,T,k=!0,i=[])=>{if(!h.length||!t.id)return;const C=T.length>0?T:t?.receivers?.map(O=>O.receiver);if(!C.length)return;let D=[...h];if(D.includes(B.NOTIFICATION_SEND_CHANNEL.PUSH)&&!Dt(n)&&(q.warning(o("notification.sendStatus.reason.unavailable",{channel:"Push Kit"})),D=D.filter(O=>O!==B.NOTIFICATION_SEND_CHANNEL.PUSH)),D.includes(B.NOTIFICATION_SEND_CHANNEL.EMAIL)&&!Ot(n)&&(q.warning(o("notification.sendStatus.reason.unavailable",{channel:"Email"})),D=D.filter(O=>O!==B.NOTIFICATION_SEND_CHANNEL.EMAIL)),!!D.length)try{a(!0),await f({notificationId:t.id,receivers:C,channels:D,resendFailedOnly:k,...D.includes("webhook")&&i.length?{webhookUrls:i}:{}}),q.success("Message has been sent!")}catch(O){console.error("handleResend error",{error:O}),q.error(O.response?O.response.statusText:O.message)}finally{a(!1)}},[n,t.id,t?.receivers,f,o]),b=se(()=>xn(t),[t]),E=se(()=>gn(t),[t]),J=se(()=>b?t?.actorInfo:[],[t]),M=se(()=>n?.did||n?.meta?.did||"",[n]);function P(){return[{name:o("notification.from"),value:b&&E?e.jsx(mn,{actors:J,teamDid:M,size:32,showName:!0}):e.jsx(pn,{size:32,blocklet:y,showName:!0,hideDot:!0})},{name:o("notification.notificationTitle"),value:e.jsx(Se,{maxLength:50,children:t.title})},{name:o("notification.body"),value:b?e.jsx(fn,{notification:t,blocklet:n}):e.jsx(bn,{notification:t,rows:0})},{name:o("notification.severity"),value:e.jsx(Ce,{severity:t.severity})},{name:o("notification.createdAt"),value:e.jsx(an,{value:t.createdAt,locale:l,shouldUpdate:!0,type:"all"})}].map(T=>e.jsx(Tt,{style:{alignItems:"flex-start"},valueComponent:"div",nameWidth:120,name:T.name,children:T.value},T.name))}const F={info:{label:o("common.basicInfo"),value:"info",component:P},receivers:{label:o("notification.receiver"),value:"receivers"},statistics:{label:o("notification.statistics"),value:"statistics"}},N=Object.values(F).map(({label:h,value:T})=>({label:h,value:T})),W=F[R.tab]||F.info,K=h=>{R.tab=h};return e.jsx(St,{title:o("notification.notificationDetails"),fullWidth:!0,maxWidth:"lg",onClose:()=>{R.tab="info",s()},open:!0,actionsPosition:"left",sx:{".ux-dialog_header":{paddingBottom:0},".MuiDialogContent-root":{paddingTop:0}},children:e.jsxs(Xn,{children:[e.jsx(S,{className:"tabs",sx:{mx:3},children:e.jsx(bt,{tabs:N,current:R.tab,onChange:K,scrollButtons:"auto"})}),e.jsxs("div",{className:"body",children:[R.tab==="receivers"&&e.jsx(Hn,{notificationId:t.id,resending:u,handleResend:w}),R.tab==="statistics"&&e.jsx(nt,{statistics:t.statistics,mode:"detail",resending:u,onResend:w}),R.tab==="info"&&e.jsx(W.component,{})]})]})})}const Qn=v.memo(_t),Xn=ie.div`
49
- & > .notification-row {
50
- padding: 0;
51
- }
52
-
53
- .tabs {
54
- margin: 0;
55
- }
56
- .body {
57
- margin-top: 16px;
58
- }
59
-
60
- .channel-item {
61
- display: flex;
62
- padding: 4px;
63
- justify-content: flex-start;
64
- align-items: center;
65
- gap: 8px;
66
- > p {
67
- font-size: 15px;
68
- }
69
- .resend-btn {
70
- svg {
71
- font-size: 16px;
72
- }
73
- display: flex;
74
- align-items: center;
75
- font-size: 12px;
76
- cursor: pointer;
77
- &.disabled {
78
- cursor: not-allowed;
79
- color: ${ke.text.disabled};
80
- }
81
- }
82
- }
83
- `;Le.propTypes={blocklet:p.object,label:p.string};const Zn=ie.div`
84
- display: flex;
85
- justify-items: flex-start;
86
- align-items: center;
87
- gap: 8px;
88
- .name {
89
- display: block;
90
- max-width: 260px;
91
- white-space: nowrap;
92
- overflow: hidden;
93
- text-overflow: ellipsis;
94
- }
95
- `;function Le({blocklet:t=null,label:s=""}){return e.jsx(Zn,{children:t?e.jsxs(e.Fragment,{children:[e.jsx(Et,{size:24,blocklet:t,ancestors:t.ancestors}),e.jsx("span",{className:"name",children:t.title||t.meta?.title})]}):e.jsx("span",{className:"name",children:s})})}zt.propTypes={list:p.array.isRequired,label:p.string.isRequired,onDelete:p.func};function zt({list:t,label:s,onDelete:n=()=>{}}){return e.jsxs(S,{sx:{display:"flex",gap:1,alignItems:"center"},children:[e.jsxs(ee,{children:[s,": "]}),t.map(r=>e.jsx(Je,{size:"small",label:e.jsx(S,{sx:{display:"flex",alignItems:"center",gap:"4px"},children:e.jsx(Ce,{severity:r})}),onDelete:o=>n(o,r)},r))]})}function es(t){return e.jsx(Xe,{...t,renderLabel:s=>e.jsx(Ce,{severity:s})})}function ts({customTableButtons:t}){const{t:s,locale:n}=te(),r=ht(),o=$t(r.breakpoints.down("sm")),l=v.useMemo(()=>jt(r,Lt()),[r]),[j,f]=v.useState(!1),{data:u,paging:a,blocklet:y,fetch:R,getComponent:w,componentDids:b,inService:E,teamDid:J}=Qe(),M=v.useRef(null),[P,F]=v.useState(null),[N,W]=v.useState("info"),K=Sn(),[h,T]=v.useState(!1),k=`notification-records-${y.meta?.did}`,i=rn(k),[C,D]=v.useState({pageSize:i.rowsPerPage||10,page:i.page?i.page+1:1,dids:i.dids||[],dateRange:i.dateRange||[Z().subtract(1,"month").startOf("day").toDate(),Z().endOf("day").toDate()]}),O=se(()=>{if(!y.children||!y.children.length)return[];const g=[];return y.children.forEach(x=>{const I=x.did||x.meta?.did;b.includes(I)&&(x.ancestors=[y],g.push(x))}),g},[b,y]),ae=async g=>{try{f(!0),await R(g),f(!1)}finally{f(!1)}};v.useEffect(()=>{ae(C)},[C]),v.useEffect(()=>{const g=u.find(x=>x.id===P?.id);P&&g&&F({...g})},[u]);const de=(g,x,I,_)=>{g.stopPropagation();const z=I.filter(L=>L!==x);D(L=>({...L,[_]:z,page:1}))},re=({page:g,rowsPerPage:x,filterList:I})=>{const[_=[],,,,z=[]]=I;C.pageSize!==x?D(L=>({...L,pageSize:x,page:1})):C.page!==g+1?D(L=>({...L,page:g+1})):je(C.dids,_)?je(C.severities,z)||D(L=>({...L,severities:z,page:1})):D(L=>({...L,dids:_,page:1}))},pe=v.useCallback(()=>{F(null),W("info")},[]),Fe=v.useCallback(()=>{R(C)},[R,C]),ue=[{label:s("notification.from"),name:"sender",width:400,options:{filter:!0,filterType:"custom",customFilterListOptions:{render:g=>g.map((x,I)=>{if(x==="system")return e.jsx("span",{children:s("notification.system")},`system-${I}`);const _=O.find(z=>(z.did||z.meta?.did)===x);return e.jsx(Le,{blocklet:_,label:_?.title||_?.meta?.title},x)}),update:(g,x,I)=>(g[I].splice(x,1),g)},filterOptions:{names:O,logic:(g,x)=>x.length?!x.includes(g):!1,display:(g,x,I,_)=>e.jsxs(V,{style:{width:"380px"},children:[e.jsx(Vt,{id:"demo-simple-select-label",style:{background:"#ffffff"},children:"Sender"}),e.jsxs(Jt,{multiple:!0,value:g[I],renderValue:z=>e.jsx(S,{style:{overflow:"hidden",textOverflow:"ellipsis"},sx:{display:"flex",gap:1,alignItems:"center"},children:z.map(L=>{if(L==="system")return e.jsx("span",{children:s("notification.system")},L);const he=O.find(c=>(c.did||c.meta?.did)===L);return e.jsx(Le,{blocklet:he,label:he?.title||he?.meta?.title},L)})}),onChange:z=>{g[I]=z.target.value,x(g[I],I,_)},children:[e.jsx(it,{value:"system",children:s("notification.system")}),O.map(z=>{const L=z.did||z.meta?.did;return e.jsx(it,{value:L,children:e.jsx(Le,{blocklet:z,label:z.title||z.meta?.title})},L)})]})]})},customBodyRenderLite:g=>{const x=u[g],I=w(x.componentDid);return e.jsxs(S,{sx:{display:"flex",alignItems:"center",gap:1},children:[I?e.jsx(Et,{size:32,blocklet:I,ancestors:I.ancestors??[]}):e.jsx(hn,{blocklet:y,size:32}),e.jsx(Se,{maxLength:50,children:I?.meta?.title||y?.meta?.title})]})}}},{label:s("notification.receiver"),name:"receivers",width:300,options:{filter:!1,customBodyRenderLite:g=>{const x=u[g],{receivers:I}=x;return e.jsx(Gt,{total:I.length,renderSurplus:_=>_<100?e.jsxs("span",{children:["+",_]}):e.jsx("span",{children:"99+"}),max:3,sx:{justifyContent:"flex-end",height:"32px",".MuiAvatar-root":{width:"32px",height:"32px",fontSize:"12px",border:0,zIndex:2}},onClick:_=>{_.stopPropagation(),F(x),W("receivers")},children:I.map(_=>{const{receiverUser:z}=_,L=It(z.avatar,J,E);return e.jsx(vt,{alt:z.fullName,src:`${L}?imageFilter=resize&w=48&h=48`,size:32,did:_.receiver,shape:"circle",style:{borderRadius:"100%",overflow:"hidden"}},_.receiver)})})}}},{label:s("notification.statistics"),name:"statistics",width:400,options:{filter:!1,customBodyRenderLite:g=>{const x=u[g];return e.jsx(S,{onClick:I=>{I.stopPropagation(),F(x),W("statistics")},children:e.jsx(nt,{statistics:x.statistics})})}}},{label:s("notification.notificationPreview"),name:"data",options:{filter:!1,customBodyRenderLite:g=>{const x=u[g];return e.jsx(Se,{maxLength:50,children:x.title})}}},{label:s("notification.severity"),name:"severity",width:200,options:{setCellProps:()=>({className:"severity-cell"}),customBodyRenderLite:g=>{const x=u[g];return e.jsx(Ce,{severity:x.severity})},filter:!0,filterType:"custom",filterList:C.severities??[],customFilterListOptions:{render:g=>e.jsx(zt,{list:g,label:s("notification.severity"),onDelete:(x,I)=>{x.stopPropagation(),de(x,I,ue[4].options.filterList,"severities")}}),update:Ae},filterOptions:{names:dt,fullWidth:!0,logic:Oe,display:(g,x,I,_)=>e.jsx(es,{label:s("notification.severity"),filterList:g,onChange:x,index:I,column:_,filterValues:dt})}}},{label:s("common.createdAt"),name:"createdAt",width:300,options:{filter:!1,customBodyRenderLite:g=>{const{createdAt:x}=u[g];return e.jsx(Nt,{value:x,locale:n,shouldUpdate:!0})}}}],fe=g=>{D(x=>({...x,dateRange:g,page:1}))},we=[e.jsxs(S,{sx:{display:"flex",alignItems:"center",gap:1.5},children:[e.jsx(Yt,{onClick:()=>T(!0),sx:{p:K?0:void 0},children:e.jsx(Qt,{})},"settings"),K?e.jsx(ee,{children:s("common.setting")}):null]}),...t||[]];return e.jsxs(S,{ref:M,sx:{overflow:"auto",".MuiTableCell-head":{whiteSpace:"nowrap",fontWeight:"bold"},".MuiTableCell-root":{paddingRight:"8px",whiteSpace:"nowrap"}},children:[e.jsx(ns,{isBreakpointsDownSm:o,children:e.jsx(xt,{theme:l,children:e.jsx(yt,{className:"main-table",verticalKeyWidth:100,loading:j,locale:n,columns:ue,data:u,durable:k,onChange:re,options:{sort:!1,download:!1,print:!1,search:!1,expandableRowsOnClick:!0,page:a.page-1,rowsPerPage:a.pageSize,count:a.total,...i,onRowClick:(g,{dataIndex:x})=>{F(u[x])}},title:e.jsx(Ze,{value:C.dateRange,onChange:fe}),customButtons:we,components:{TableFilterList:g=>e.jsx(et,{...g,itemComponent:x=>e.jsx(tt,{...x,canDelete:I=>I?.columnNames?.[I?.index||0]?.name==="sender"})})}})})}),P&&e.jsx(Qn,{refresh:Fe,onCancel:pe,notification:P,blocklet:y,tab:N}),e.jsx(St,{title:`${s("common.notification")} ${s("common.setting")}`,fullWidth:!0,maxWidth:"md",open:h,onClose:()=>T(!1),PaperProps:{style:{minHeight:"500px"}},children:e.jsx(S,{sx:{mt:"-16px",overflowY:"hidden"},children:e.jsx(On,{})})})]})}const ns=ie.div`
96
- td.MuiTableCell-footer {
97
- border: none !important;
98
- }
99
- .sent-status-cell {
100
- .resend-btn {
101
- display: none;
102
- }
103
- &:hover {
104
- .resend-btn {
105
- display: flex;
106
- }
107
- }
108
- }
109
-
110
- .custom-toobar-btns {
111
- gap: 4px;
112
- }
113
- .custom-toobar-title-inner {
114
- display: flex;
115
- justify-content: ${({isBreakpointsDownSm:t})=>t?"space-between":"flex-end"};
116
- padding-right: ${({isBreakpointsDownSm:t})=>t?"0":"8px"};
117
- flex-wrap: wrap;
118
- gap: 8px;
119
- }
120
- `;ss.propTypes={blocklet:p.object.isRequired,customTableButtons:p.array};function ss({blocklet:t={},customTableButtons:s=[]}){return e.jsx(Ln,{blocklet:t,children:e.jsx(ts,{customTableButtons:s})})}export{ss as default};