@abtnode/blocklet-services 1.16.45-beta-20250609-111118-0d252ebe → 1.16.45-beta-20250612-231219-481217be

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 (217) hide show
  1. package/api/cache.js +36 -21
  2. package/api/libs/connect/session.js +2 -2
  3. package/api/middlewares/proxy-to-daemon.js +6 -2
  4. package/api/routes/blocklet.js +25 -5
  5. package/api/routes/dns-resolver.js +1 -1
  6. package/api/routes/env.js +2 -1
  7. package/api/services/auth/connect/invite.js +1 -1
  8. package/api/services/auth/connect/issue-passport.js +1 -1
  9. package/api/services/auth/connect/verify-destroy.js +3 -6
  10. package/api/services/auth/connect/verify-elevated.js +8 -9
  11. package/api/services/auth/session.js +1 -1
  12. package/api/services/oauth/server.js +2 -1
  13. package/api/socket/channel/did.js +2 -2
  14. package/dist/assets/{AdapterDayjs-BXVfASrK.js → AdapterDayjs-BzjU9O7t.js} +1 -1
  15. package/dist/assets/{ArrowDropDown-Ce8TY3aP.js → ArrowDropDown-CrJjI_sT.js} +1 -1
  16. package/dist/assets/{CheckCircle-M9NlpTm_.js → CheckCircle-BcPSvH2E.js} +1 -1
  17. package/dist/assets/{ChevronLeft-02OWcWpH.js → ChevronLeft-Ch9iK6fF.js} +1 -1
  18. package/dist/assets/{ChevronRight-CB8w0u2n.js → ChevronRight-DclARA5k.js} +1 -1
  19. package/dist/assets/{Community-vE_QnoqV.js → Community-D4mv0jfL.js} +1 -1
  20. package/dist/assets/{DeleteOutline-1-hBNY1U.js → DeleteOutline-CnS2XiM1.js} +1 -1
  21. package/dist/assets/{Done-CcJLRcBY.js → Done-C9LPqADS.js} +1 -1
  22. package/dist/assets/{Download-HHknpEZd.js → Download-D9LfWoxF.js} +1 -1
  23. package/dist/assets/{Edit-hd-cDU5C.js → Edit-rPlryssW.js} +1 -1
  24. package/dist/assets/{EditIcon-DiM9RB8U.js → EditIcon-DfiDnAsm.js} +1 -1
  25. package/dist/assets/{Error-D0rGqAKE.js → Error-q_AhSCeT.js} +1 -1
  26. package/dist/assets/{ExpandLess-Fb-uW6u_.js → ExpandLess-Da2Rv9Ox.js} +1 -1
  27. package/dist/assets/{Google-WGwK551e.js → Google-Buu8u6PW.js} +1 -1
  28. package/dist/assets/{Holiday-BnL2IwX3.js → Holiday-DkzYmdt-.js} +1 -1
  29. package/dist/assets/{Home-DeTVRhMG.js → Home-DkCBzKe9.js} +1 -1
  30. package/dist/assets/{InfoOutlined-CLiL5VeK.js → InfoOutlined-C8ZBPUhD.js} +1 -1
  31. package/dist/assets/{Launch-BwVeOcBz.js → Launch-Nu8TBDKk.js} +1 -1
  32. package/dist/assets/{LaunchOutlined-CPurmWuM.js → LaunchOutlined-DQZ7S23O.js} +1 -1
  33. package/dist/assets/{LockIcon-QnxDGvZv.js → LockIcon-BEG59s5q.js} +1 -1
  34. package/dist/assets/{Meeting-BkjjPbp7.js → Meeting-KSUAdbzW.js} +1 -1
  35. package/dist/assets/{MoreHoriz-9E3q8aHi.js → MoreHoriz-Ba9rYlyz.js} +1 -1
  36. package/dist/assets/{OffSick-D2B01pyN.js → OffSick-B0VcZ-o0.js} +1 -1
  37. package/dist/assets/{PlayArrow-B_ZNrQDa.js → PlayArrow-RVSfCmrB.js} +1 -1
  38. package/dist/assets/{QuestionMarkCircle-BMcwgPWr.js → QuestionMarkCircle-jbhclAfX.js} +1 -1
  39. package/dist/assets/{TuneOutlined-0oMZE8a4.js → TuneOutlined-CwV20zYf.js} +1 -1
  40. package/dist/assets/{ViewList-ColSGL1_.js → ViewList-D1BI4ac9.js} +1 -1
  41. package/dist/assets/{WorkingRemotely-CxoGYC4d.js → WorkingRemotely-5Kw3C-_c.js} +1 -1
  42. package/dist/assets/{access-control-nyeEpwlF.js → access-control-C-kFaf9T.js} +1 -1
  43. package/dist/assets/{actions-DtL6bYnA.js → actions-DYQW2ChM.js} +1 -1
  44. package/dist/assets/{add-component-core-CaE3xcyT.js → add-component-core-UeQfX1b1.js} +37 -37
  45. package/dist/assets/add-resource-BdL-oJxe.js +1 -0
  46. package/dist/assets/{addon-e-JO0VU3.js → addon-DMedfvRj.js} +1 -1
  47. package/dist/assets/{advanced-yrYBgA5T.js → advanced-BZZToP_j.js} +2 -2
  48. package/dist/assets/api-87p2GGd0.js +1 -0
  49. package/dist/assets/{appearance-DB1QowgL.js → appearance-CYop22yw.js} +1 -1
  50. package/dist/assets/ar-D9QEDjY-.js +7 -0
  51. package/dist/assets/{audit-logs-BamIXrWh.js → audit-logs-BtBk6uAY.js} +3 -3
  52. package/dist/assets/{authorize-B9LP0G9q.js → authorize-CQZkUNyV.js} +1 -1
  53. package/dist/assets/{base-chart-BYonGucU.js → base-chart-C2FJuVG1.js} +1 -1
  54. package/dist/assets/{base32-CmYq1ikq.js → base32-DEjena1X.js} +1 -1
  55. package/dist/assets/{branding-OlEgtAUT.js → branding-7ppDxFZf.js} +2 -2
  56. package/dist/assets/branding-gXMozCeI.js +54 -0
  57. package/dist/assets/{bundle-avatar-C41ZXEbR.js → bundle-avatar-B5-ypzmO.js} +1 -1
  58. package/dist/assets/button-YPMo8IwK.js +1 -0
  59. package/dist/assets/{click-to-copy-BUVqg1RQ.js → click-to-copy-BMX2P5UB.js} +1 -1
  60. package/dist/assets/{cloneDeep-ro06l5HL.js → cloneDeep-Jl_OPbSo.js} +1 -1
  61. package/dist/assets/{collapse--nd2JDBL.js → collapse-9taxUXec.js} +1 -1
  62. package/dist/assets/{complete-gnnvUqGU.js → complete-C8T0HN-B.js} +1 -1
  63. package/dist/assets/{component-ClWADDCr.js → component-D6hOmRzO.js} +1 -1
  64. package/dist/assets/{config-2Sy6fCTJ.js → config-DcwlSddI.js} +1 -1
  65. package/dist/assets/{config-QpBBpp7d.js → config-Sq1CUTiJ.js} +1 -1
  66. package/dist/assets/{config-navigation-CsVa3Hf0.js → config-navigation-IR_yUgmM.js} +6 -6
  67. package/dist/assets/{config-space-B39Ur9Mf.js → config-space-C3fS58cn.js} +1 -1
  68. package/dist/assets/{confirm-Bay3BcpN.js → confirm-DApmnpvm.js} +1 -1
  69. package/dist/assets/{connect-T4cAO9om.js → connect-BF4GoRL-.js} +1 -1
  70. package/dist/assets/connect-Bf8y7fMm.js +5 -0
  71. package/dist/assets/{connect-to-Dac7orQh.js → connect-to-Bwfa2hMr.js} +1 -1
  72. package/dist/assets/{content-layout-DuPlKBe3.js → content-layout-BC2QkTYi.js} +1 -1
  73. package/dist/assets/dashboard-B2X6c8E8.js +239 -0
  74. package/dist/assets/{de-Dv_ApqsF.js → de-BOa43YBF.js} +2 -2
  75. package/dist/assets/{delete-confirm-B1F5wKdb.js → delete-confirm-BsEqJQRY.js} +1 -1
  76. package/dist/assets/{did-address-bJAfhuZx.js → did-address-L54dTMrT.js} +1 -1
  77. package/dist/assets/domain-BGh0GDuZ.js +9 -0
  78. package/dist/assets/{domain-action-card-yyZstsWL.js → domain-action-card-DWqnvzry.js} +2 -2
  79. package/dist/assets/domains-CdwErmIF.js +1 -0
  80. package/dist/assets/dot-iw3hN9HL.js +7 -0
  81. package/dist/assets/{email-CYOorZ7K.js → email-By_nAv9m.js} +1 -1
  82. package/dist/assets/{empty-spinner-DSwpCqdd.js → empty-spinner-BHwHZpq-.js} +1 -1
  83. package/dist/assets/es-A3ma-OJp.js +9 -0
  84. package/dist/assets/{exchange-passport-xHfEBrd8.js → exchange-passport-BsgMfRJS.js} +1 -1
  85. package/dist/assets/fr-I3xKp6I5.js +7 -0
  86. package/dist/assets/{fuel-CtSAk9S3.js → fuel-RMmgm9AQ.js} +1 -1
  87. package/dist/assets/{gen-access-key-CoOxXtqa.js → gen-access-key-4teK8Dys.js} +1 -1
  88. package/dist/assets/{get-safe-url-BWDUV79Q.js → get-safe-url-B8xlSMyD.js} +1 -1
  89. package/dist/assets/{get-safe-url-CwT4-jkw.js → get-safe-url-t1C0E5Ux.js} +1 -1
  90. package/dist/assets/{hi-Dqbq8i5Y.js → hi-DacRhM8A.js} +1 -1
  91. package/dist/assets/{home-D1kBU1RC.js → home-CmHUXg5q.js} +1 -1
  92. package/dist/assets/{id-Bxr8o3Uo.js → id-B7LQAHL7.js} +3 -3
  93. package/dist/assets/{iframe-DsIqy16E.js → iframe-Dj9NLHp2.js} +1 -1
  94. package/dist/assets/{index-BoQJXOtZ.js → index-B2NkqENf.js} +1 -1
  95. package/dist/assets/{index-BpvW-cUy.js → index-BCtTVvHw.js} +1 -1
  96. package/dist/assets/{index-Cx-ESLe9.js → index-Bb7iSrGO.js} +4 -4
  97. package/dist/assets/{index-CTfYMqG2.js → index-Be8E3hiQ.js} +5 -5
  98. package/dist/assets/{index-DQl2QJod.js → index-BeE0KRva.js} +2 -2
  99. package/dist/assets/{index-DWgnwzKO.js → index-Bv7OAPJU.js} +1 -1
  100. package/dist/assets/{index-BnR8uU0R.js → index-BzZuK-66.js} +1 -1
  101. package/dist/assets/{index-CyS4mBmV.js → index-C8uNNoMb.js} +6 -6
  102. package/dist/assets/{index-CI4cLtBE.js → index-CCOwwQoc.js} +1 -1
  103. package/dist/assets/{index-DMSe2Qjx.js → index-CJQbYw9E.js} +2 -2
  104. package/dist/assets/{index-Dntq1ezd.js → index-CKY4HT0P.js} +1 -1
  105. package/dist/assets/{index-B18R5SlV.js → index-CMYalRl2.js} +7 -7
  106. package/dist/assets/{index-BXjOxZPH.js → index-CTlzm-Mc.js} +1 -1
  107. package/dist/assets/{index-8kcb4Nom.js → index-Cs3-IS09.js} +1 -1
  108. package/dist/assets/{index-DU8cx_m6.js → index-DEZojGsm.js} +1 -1
  109. package/dist/assets/{index-B7qZ5OdP.js → index-DXeoVV9Y.js} +11 -11
  110. package/dist/assets/{index-B1fP-8KR.js → index-DaM-GRtb.js} +2 -2
  111. package/dist/assets/{index-DaMn1fo9.js → index-Dfw2EDXA.js} +10 -10
  112. package/dist/assets/{index-DO-a7P7z.js → index-Dgsq6V-N.js} +1 -1
  113. package/dist/assets/{index-B4wY8GsU.js → index-DtZg53T9.js} +3 -3
  114. package/dist/assets/{index-j6UAnd8n.js → index-F85lIJcp.js} +1 -1
  115. package/dist/assets/{index-CY9xLy04.js → index-Inc_KF9k.js} +3 -3
  116. package/dist/assets/{index-CZgWTJXl.js → index-Mzv6hCex.js} +1 -1
  117. package/dist/assets/{index-Brd3-BIC.js → index-NnUiYa0L.js} +1 -1
  118. package/dist/assets/{index-C5vFhD_w.js → index-SX_KWrQh.js} +1 -1
  119. package/dist/assets/{invitation-BsuZg3B2.js → invitation-Ck_kq3Tr.js} +3 -3
  120. package/dist/assets/{invite-YNiMO-nB.js → invite-89aeW4Ho.js} +1 -1
  121. package/dist/assets/{issue-passport-2R7-XHuR.js → issue-passport-4udVYVdq.js} +1 -1
  122. package/dist/assets/{item-DHMVgmIa.js → item-D0U5vYXJ.js} +1 -1
  123. package/dist/assets/{ja-CJfcqkdo.js → ja-DRQ4Eecl.js} +3 -1
  124. package/dist/assets/{ko-BxAazRix.js → ko-CzL3UzwL.js} +3 -1
  125. package/dist/assets/{launch-result-message-DNgJY11G.js → launch-result-message-AharZGq2.js} +1 -1
  126. package/dist/assets/{layout-BnunMkuP.js → layout-CQb1lhEv.js} +1 -1
  127. package/dist/assets/{list-h4Ed_myi.js → list-BOdwWlS0.js} +2 -2
  128. package/dist/assets/{list-DZwgo-zf.js → list-KVxvPXZu.js} +6 -6
  129. package/dist/assets/{list-header-D976e09p.js → list-header-C7gle0n0.js} +1 -1
  130. package/dist/assets/localization-OxVxEhoS.js +1 -0
  131. package/dist/assets/{log-6M_J_pon.js → log-DOIh9luu.js} +1 -1
  132. package/dist/assets/{logger-KwxABgLK.js → logger-Dhaq1LDX.js} +1 -1
  133. package/dist/assets/{login-C2ILZhOf.js → login-J6Bsrh3B.js} +1 -1
  134. package/dist/assets/{login-oauth-callback-Dt9V4GRH.js → login-oauth-callback-BRmEibAb.js} +1 -1
  135. package/dist/assets/{logo-uploader-Dhh7Un4G.js → logo-uploader-Dzebv-rF.js} +3 -3
  136. package/dist/assets/{lost-passport-JODD9Yck.js → lost-passport-p5ZuXjnG.js} +2 -2
  137. package/dist/assets/{omit-O1pUD7ku.js → omit-BlzmxIB5.js} +1 -1
  138. package/dist/assets/{open-window-Dn44K3ur.js → open-window-Byi7CkW_.js} +1 -1
  139. package/dist/assets/{overview-Bjj9JLCV.js → overview-ClOSCvvh.js} +1 -1
  140. package/dist/assets/{page-header-JH9JWGMg.js → page-header-C_KAJILy.js} +1 -1
  141. package/dist/assets/{passport-item-CoNRdRpk.js → passport-item-Du8-xENr.js} +1 -1
  142. package/dist/assets/{permission-B7ZHEOJv.js → permission-ClRym5FB.js} +1 -1
  143. package/dist/assets/preferences-B6Y0XpLo.js +1 -0
  144. package/dist/assets/profile-embed-C_hd_hMh.js +1 -0
  145. package/dist/assets/{pt-FpFCyI6v.js → pt-CHKumXYv.js} +3 -3
  146. package/dist/assets/publish-resource-kHaYkbDE.js +1 -0
  147. package/dist/assets/{react-beautiful-dnd.esm-DCPrD7-r.js → react-beautiful-dnd.esm-CHsohizU.js} +1 -1
  148. package/dist/assets/{ru-BuGIFp9h.js → ru-CvkEKhgU.js} +1 -1
  149. package/dist/assets/{runtime-1mGYl_p2.js → runtime-D5P_2uNM.js} +1 -1
  150. package/dist/assets/{sanitize-DbZs1H_T.js → sanitize-B18rcrOf.js} +1 -1
  151. package/dist/assets/sdk-CbugbTkF.js +1 -0
  152. package/dist/assets/search-4YYphs0l.js +1 -0
  153. package/dist/assets/section-BDMQAX_r.js +41 -0
  154. package/dist/assets/{security-C2l4SCkx.js → security-CXewZHyS.js} +1 -1
  155. package/dist/assets/{session-1k8BRnYA.js → session-Bkvl2PSP.js} +1 -1
  156. package/dist/assets/setup-TPtYDnBB.js +30 -0
  157. package/dist/assets/{shorten-label-CTSJhlwO.js → shorten-label-BQvbtscf.js} +1 -1
  158. package/dist/assets/{simple-select-cKQxVH3U.js → simple-select-0cjVFuay.js} +1 -1
  159. package/dist/assets/{slicedToArray-CRrLoxQ4.js → slicedToArray-DFQjSbCD.js} +1 -1
  160. package/dist/assets/{spaces-CpSu6mVL.js → spaces-C1lh7et6.js} +1 -1
  161. package/dist/assets/{start-BotjXVuZ.js → start-BgSlMXsE.js} +1 -1
  162. package/dist/assets/{starting-progress-a7uoLG-L.js → starting-progress-BikYigPA.js} +1 -1
  163. package/dist/assets/{status-DIJ9lK3F.js → status-DDvFiBxA.js} +1 -1
  164. package/dist/assets/{step-actions-DLZOEVat.js → step-actions-_23FIn8v.js} +1 -1
  165. package/dist/assets/{studio-Cua13-ul.js → studio-Db5oA_Tx.js} +1 -1
  166. package/dist/assets/{switch-control-CzaI2YNK.js → switch-control-BYqb8MZf.js} +1 -1
  167. package/dist/assets/{table-tips-Czrj7r52.js → table-tips-BW6G2sKO.js} +1 -1
  168. package/dist/assets/{th-BafLD2wR.js → th-B2BUfjNJ.js} +1 -1
  169. package/dist/assets/{traffic-fPCLOWN3.js → traffic-CUSLm0PX.js} +1 -1
  170. package/dist/assets/{transfer-BqCYXmCB.js → transfer-CSsXAviu.js} +1 -1
  171. package/dist/assets/{unsubscribe-BE77Etc2.js → unsubscribe-BA46-fTa.js} +1 -1
  172. package/dist/assets/{use-blocklet-logo-DGSQQmh2.js → use-blocklet-logo-CTCMbFiC.js} +1 -1
  173. package/dist/assets/{use-mobile-CXU9YBvX.js → use-mobile-CtTQsfXN.js} +1 -1
  174. package/dist/assets/{use-mobile-CiFFAdJf.js → use-mobile-DwzRjjku.js} +1 -1
  175. package/dist/assets/{use-server-logo-BbYHFDuK.js → use-server-logo-UTr-CyJD.js} +1 -1
  176. package/dist/assets/useAsync-DVHp96Uu.js +1 -0
  177. package/dist/assets/{useLocalStorage-BF3BqN1O.js → useLocalStorage-DyVGBDlt.js} +1 -1
  178. package/dist/assets/user-center-Cap4mg5H.js +77 -0
  179. package/dist/assets/{util-xXGeezrD.js → util-DlS4tWs9.js} +1 -1
  180. package/dist/assets/{util-CS4PqVkK.js → util-M3UFXQFT.js} +1 -1
  181. package/dist/assets/{vendor-arcblock-B4hgrXYM.js → vendor-arcblock-DiSm3oUX.js} +7 -7
  182. package/dist/assets/{vendor-hooks-BCm626KH.js → vendor-hooks-BFlOfe0M.js} +1 -1
  183. package/dist/assets/{vendor-mui-core-wlbruq2I.js → vendor-mui-core-Bq8gXTan.js} +1 -1
  184. package/dist/assets/{vendor-mui-x-BKgL6hAa.js → vendor-mui-x-1nqAyytV.js} +1 -1
  185. package/dist/assets/vendor-utils-BotmZdBm.js +208 -0
  186. package/dist/assets/{vendor-ux-did-connect-CX7qG3_M.js → vendor-ux-did-connect-DVX9lQ8a.js} +66 -66
  187. package/dist/assets/{vi-BMZxxaJ2.js → vi-BykmwIAT.js} +3 -3
  188. package/dist/assets/wrap-locale-B8EvOR-l.js +1 -0
  189. package/dist/assets/{zh-DusA4qAT.js → zh-CbCaOuAd.js} +3 -1
  190. package/dist/assets/{zh-tw-BO-QhSNP.js → zh-tw-C9JfiCVV.js} +3 -1
  191. package/dist/index.html +6 -6
  192. package/dist/service-worker.js +1 -1
  193. package/package.json +33 -33
  194. package/dist/assets/add-resource-CG8u25Lv.js +0 -1
  195. package/dist/assets/api-CQoRx33p.js +0 -1
  196. package/dist/assets/ar-0ZkmCCuq.js +0 -7
  197. package/dist/assets/branding-C2Dm2Z1c.js +0 -54
  198. package/dist/assets/button-C0Vra3Ak.js +0 -1
  199. package/dist/assets/connect-B77rXeVL.js +0 -5
  200. package/dist/assets/dashboard-k0XcV2m5.js +0 -239
  201. package/dist/assets/domain-CEwb0Lyz.js +0 -9
  202. package/dist/assets/domains-CRt4uYYF.js +0 -1
  203. package/dist/assets/dot-DR7_m3Np.js +0 -7
  204. package/dist/assets/es-D_uF0siv.js +0 -7
  205. package/dist/assets/fr-DVFSQfDp.js +0 -7
  206. package/dist/assets/localization-BNjdHo-G.js +0 -1
  207. package/dist/assets/preferences-DUSp_pAb.js +0 -1
  208. package/dist/assets/profile-embed-BIjwkrGW.js +0 -1
  209. package/dist/assets/publish-resource-AW43Z8jj.js +0 -1
  210. package/dist/assets/sdk-BJQcHaGO.js +0 -1
  211. package/dist/assets/section-Bb547IGJ.js +0 -41
  212. package/dist/assets/setup-DxzbFXmd.js +0 -30
  213. package/dist/assets/useAsync-BMCqtJH2.js +0 -1
  214. package/dist/assets/useAsync-CBEJDwr0.js +0 -1
  215. package/dist/assets/user-center-olJmefSX.js +0 -77
  216. package/dist/assets/vendor-utils-B3iZkn2R.js +0 -208
  217. package/dist/assets/wrap-locale-Byq7otyk.js +0 -1
@@ -1,4 +1,4 @@
1
- import{g as Ut,r as C}from"./vendor-react-DEoibe3W.js";import{ah as ue,al as ht,j as e,aa as T,O as te,bt as ge,bu as We,bp as Y,ad as xt,H as x,a9 as Je,T as ae,E as Xe,bA as gt,bR as Ke,bS as qe,y as Le,b7 as Me,ab as bt,bJ as jt,Y as vt,cn as yt,m as Ht,as as dt,bs as Vt,bo as Yt,q as ut,bY as Gt,I as Jt}from"./vendor-mui-core-wlbruq2I.js";import{J as St,z as Xt,A as Qt,e as fe,aB as ye,C as Zt}from"./vendor-utils-B3iZkn2R.js";import{y as es,a as re,ab as Ct,a3 as q,X as ke,c0 as ts,B as me,k as W,bb as ss,ax as wt,bg as ns,r as Qe,c1 as is,a2 as Tt,ac as Rt,bA as Ae,ar as Nt,$ as as,bH as rs}from"./vendor-ux-did-connect-CX7qG3_M.js";import{D as Ze,G as Et,aC as It,aD as Q,y as se,n as os,K as pt}from"./index-B18R5SlV.js";import{a as Te,u as V,b as ce}from"./vendor-hooks-BCm626KH.js";import{a as et,b as ls}from"./dashboard-k0XcV2m5.js";import{f as $e,i as cs,d as ds}from"./use-blocklet-logo-DGSQQmh2.js";import{A as us,a as ps,d as fs,b as ms}from"./collapse--nd2JDBL.js";import{S as ee}from"./section-Bb547IGJ.js";import{S as Re}from"./shorten-label-CTSJhlwO.js";import{I as At}from"./index-BnR8uU0R.js";import{R as Ot,A as hs,S as xs,a as gs,b as bs,B as js}from"./list-DZwgo-zf.js";import{W as vs}from"./did-address-bJAfhuZx.js";import{p as Dt}from"./util-CS4PqVkK.js";import{D as ys,g as Ss}from"./traffic-fPCLOWN3.js";import{B as Lt}from"./bundle-avatar-C41ZXEbR.js";import{u as Cs}from"./use-mobile-CXU9YBvX.js";import"./lottie-web-jYmAQWuC.js";import"./vendor-arcblock-B4hgrXYM.js";import"./useLocalStorage-BF3BqN1O.js";import"./index-8eXqqyHQ.js";import"./confirm-Bay3BcpN.js";import"./PlayArrow-B_ZNrQDa.js";import"./get-safe-url-CwT4-jkw.js";import"./session-1k8BRnYA.js";import"./InfoOutlined-CLiL5VeK.js";import"./dot-DR7_m3Np.js";import"./useAsync-BMCqtJH2.js";import"./useSetState-CWq0AVWn.js";import"./use-mobile-CiFFAdJf.js";import"./index-DU8cx_m6.js";import"./CheckCircle-M9NlpTm_.js";import"./base32-CmYq1ikq.js";import"./iframe-DsIqy16E.js";import"./LaunchOutlined-CPurmWuM.js";import"./ChevronLeft-02OWcWpH.js";import"./ChevronRight-CB8w0u2n.js";import"./index-BoQJXOtZ.js";import"./base-chart-BYonGucU.js";import"./index-Dntq1ezd.js";import"./vendor-mui-x-BKgL6hAa.js";import"./AdapterDayjs-BXVfASrK.js";var Ue={exports:{}},He={exports:{}},Ve={exports:{}};(function(n,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=s;function s(r){return r==null}n.exports=t.default,n.exports.default=t.default})(Ve,Ve.exports);var ws=Ve.exports;(function(n,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=p;var s=o(es),r=o(ws);function o(h){return h&&h.__esModule?h:{default:h}}var l=/^(?:[-+]?(?:0|[1-9][0-9]*))$/,y=/^[-+]?[0-9]+$/;function p(h,i){(0,s.default)(h),i=i||{};var A=i.allow_leading_zeroes===!1?l:y,O=!i.hasOwnProperty("min")||(0,r.default)(i.min)||h>=i.min,R=!i.hasOwnProperty("max")||(0,r.default)(i.max)||h<=i.max,S=!i.hasOwnProperty("lt")||(0,r.default)(i.lt)||h<i.lt,D=!i.hasOwnProperty("gt")||(0,r.default)(i.gt)||h>i.gt;return A.test(h)&&O&&R&&S&&D}n.exports=t.default,n.exports.default=t.default})(He,He.exports);var Ts=He.exports;(function(n,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=o;var s=r(Ts);function r(l){return l&&l.__esModule?l:{default:l}}function o(l){return(0,s.default)(l,{allow_leading_zeroes:!1,min:0,max:65535})}n.exports=t.default,n.exports.default=t.default})(Ue,Ue.exports);var Rs=Ue.exports;const Ns=Ut(Rs),Fe={enabled:!1,secure:!1,from:"",host:"",port:"",user:"",password:"",companyName:"",companyLink:"",companyAddress:"",supportEmail:""};function Es(){var N,E,P;const{api:n}=Ze(),{blocklet:t}=Et(),{t:s}=re(),{confirmApi:r,confirmHolder:o}=Ct(),l=(N=t==null?void 0:t.meta)==null?void 0:N.did,y=Object.assign({...Fe},((P=(E=t==null?void 0:t.settings)==null?void 0:E.notification)==null?void 0:P.email)||{}),{handleSubmit:p,control:h,formState:i,watch:A,reset:O}=It({defaultValues:St(y,Object.keys(Fe))}),R=Te({testReceiver:"",testReceiverError:""}),S=A("enabled"),D=V(async(a,m,$=!0)=>{var U,oe;try{const{blocklet:le}=await n.configNotification({input:{did:l,notification:JSON.stringify({email:a})}}),pe=Object.assign({...Fe},((oe=(U=le==null?void 0:le.settings)==null?void 0:U.notification)==null?void 0:oe.email)||{});O(pe),$&&q.success(s("oauth.saveSuccess"))}catch(le){if($)q.error(le.message||s("oauth.saveFailed"));else throw le}}),G=V(async(a,m,$)=>{try{i.isDirty&&await D(a,m,!1),await n.sendEmail({input:{did:l,receiver:$,email:JSON.stringify({body:"Your SMTP configuration is correct!",title:"Test email",type:"notification"})}}),q.success(s("notification.email.testSuccess"))}catch(U){q.error(U.message||s("notification.email.testfailed"))}}),z=V((a,m)=>{R.testReceiver="",R.testReceiverError="",r.open({title:s("notification.email.testSendEmail"),content:()=>e.jsx(T,{sx:{width:"300px"},children:e.jsx(te,{sx:{mt:1},fullWidth:!0,name:"testReceiver",label:s("notification.email.inputTestReceiver"),value:R.testReceiver,onChange:$=>{R.testReceiver=$.target.value},error:!!R.testReceiverError,helperText:R.testReceiverError||" "})}),confirmButtonText:s("common.confirm"),cancelButtonText:s("common.cancel"),async onConfirm($){var oe;const U=(oe=R.testReceiver)==null?void 0:oe.trim();if(!U){R.testReceiverError=s("notification.email.receiverRequired");return}if(!ke(U)){R.testReceiverError=s("notification.email.receiverInvalid");return}R.testReceiverError="",await G(a,m,U),$()}})}),B=V(a=>{const m=a==null?void 0:a.trim();return m?ke(m)?!0:s("notification.email.fromInvalid"):s("notification.email.fromRequired")}),_=V(a=>{const m=a==null?void 0:a.trim();return m?$e(m,{require_host:!1,protocols:[]})?!0:s("notification.email.hostInvalid"):s("notification.email.hostRequired")}),M=V(a=>a?Ns(a)?!0:s("notification.email.portInvalid"):s("notification.email.portRequired")),J=V(a=>a!=null&&a.trim()?!0:s("notification.email.userRequired")),ie=V(a=>a!=null&&a.trim()?!0:s("notification.email.passwordRequired")),c=V(a=>a!=null&&a.trim()&&!$e(a,{protocols:["http","https"],require_protocol:!0})?s("notification.email.linkInvalid"):!0),g=V(a=>a!=null&&a.trim()&&!ke(a)?s("notification.email.emailInvalid"):!0),j=V(()=>!0);return e.jsxs(T,{children:[e.jsxs(Is,{component:"form",onSubmit:p(D),disabled:!0,sx:{".section-left":{width:"160px"}},children:[e.jsx(ee,{title:s("notification.email.enable"),my:2.5,children:e.jsx(Q,{name:"enabled",control:h,render:({field:a})=>e.jsx(ge,{control:e.jsx(We,{checked:a.value,...a})})})}),e.jsx(ee,{title:s("notification.email.from"),children:e.jsx(Q,{name:"from",control:h,rules:{validate:S?B:j},render:({field:a})=>{var m;return e.jsx(Y,{fullWidth:!0,children:e.jsx(te,{...a,size:"small",required:!0,label:s("notification.email.from"),error:!!i.errors[a.name],helperText:((m=i.errors[a.name])==null?void 0:m.message)||" ",disabled:!S})})}})}),e.jsx(ee,{title:s("notification.email.host"),children:e.jsx(Q,{name:"host",control:h,rules:{validate:S?_:j},render:({field:a})=>{var m;return e.jsx(Y,{fullWidth:!0,children:e.jsx(te,{...a,size:"small",required:!0,error:!!i.errors[a.name],label:s("notification.email.host"),helperText:((m=i.errors[a.name])==null?void 0:m.message)||" ",disabled:!S})})}})}),e.jsx(ee,{title:s("notification.email.port"),children:e.jsx(Q,{name:"port",control:h,rules:{validate:S?M:j},render:({field:a})=>{var m;return e.jsx(Y,{fullWidth:!0,children:e.jsx(te,{...a,size:"small",required:!0,type:"number",error:!!i.errors[a.name],label:s("notification.email.port"),helperText:((m=i.errors[a.name])==null?void 0:m.message)||" ",disabled:!S})})}})}),e.jsx(ee,{title:s("notification.email.user"),children:e.jsx(Q,{name:"user",control:h,rules:{validate:S?J:j},render:({field:a})=>{var m;return e.jsx(Y,{fullWidth:!0,children:e.jsx(te,{...a,size:"small",required:!0,error:!!i.errors[a.name],label:s("notification.email.user"),helperText:((m=i.errors[a.name])==null?void 0:m.message)||" ",disabled:!S})})}})}),e.jsx(ee,{title:s("notification.email.password"),children:e.jsx(Q,{name:"password",control:h,rules:{validate:S?ie:j},render:({field:a})=>{var m;return e.jsx(Y,{fullWidth:!0,children:e.jsx(te,{...a,size:"small",required:!0,type:"password",error:!!i.errors[a.name],label:s("notification.email.password"),helperText:((m=i.errors[a.name])==null?void 0:m.message)||" ",disabled:!S})})}})}),e.jsx(ee,{title:s("notification.email.secure"),children:e.jsx(Q,{name:"secure",control:h,rules:{validate:j},render:({field:a})=>e.jsx(Y,{fullWidth:!0,children:e.jsx(ge,{control:e.jsx(We,{checked:a.value,...a,disabled:!S})})})})}),e.jsxs(us,{children:[e.jsxs(ps,{expandIcon:e.jsx(fs,{fontSize:"small"}),"aria-controls":"panel1-content",id:"panel1-header",children:[s("notification.email.signature"),e.jsx(xt,{title:s("notification.email.signatureTooltip"),children:e.jsx(ts,{fontSize:"small",sx:{ml:1,cursor:"help"}})})]}),e.jsxs(ms,{children:[e.jsx(ee,{title:s("notification.email.companyName"),children:e.jsx(Q,{name:"companyName",control:h,rules:{validate:j},render:({field:a})=>{var m;return e.jsx(Y,{fullWidth:!0,children:e.jsx(te,{...a,size:"small",error:!!i.errors[a.name],label:s("notification.email.companyName"),helperText:((m=i.errors[a.name])==null?void 0:m.message)||" ",disabled:!S})})}})}),e.jsx(ee,{title:s("notification.email.companyLink"),children:e.jsx(Q,{name:"companyLink",control:h,rules:{validate:S?c:j},render:({field:a})=>{var m;return e.jsx(Y,{fullWidth:!0,children:e.jsx(te,{...a,size:"small",error:!!i.errors[a.name],label:s("notification.email.companyLink"),helperText:((m=i.errors[a.name])==null?void 0:m.message)||" ",disabled:!S})})}})}),e.jsx(ee,{title:s("notification.email.companyAddress"),children:e.jsx(Q,{name:"companyAddress",control:h,rules:{validate:j},render:({field:a})=>{var m;return e.jsx(Y,{fullWidth:!0,children:e.jsx(te,{...a,size:"small",error:!!i.errors[a.name],label:s("notification.email.companyAddress"),helperText:((m=i.errors[a.name])==null?void 0:m.message)||" ",disabled:!S})})}})}),e.jsx(ee,{title:s("notification.email.supportEmail"),children:e.jsx(Q,{name:"supportEmail",control:h,rules:{validate:S?g:j},render:({field:a})=>{var m;return e.jsx(Y,{fullWidth:!0,children:e.jsx(te,{...a,size:"small",type:"email",error:!!i.errors[a.name],label:s("notification.email.supportEmail"),helperText:((m=i.errors[a.name])==null?void 0:m.message)||" ",disabled:!S})})}})})]})]}),e.jsxs(T,{sx:{display:"flex",justifyContent:"flex-end",gap:2,mt:3},children:[e.jsx(me,{variant:"outlined",color:"warning",onClick:p(z),disabled:!S,children:s("oauth.runTest")}),e.jsx(me,{type:"submit",variant:"contained",disabled:!i.isDirty,children:s("oauth.save")})]})]}),o]})}const Is=ue(ht)``,Be={enabled:!1,endpoint:"",did:void 0,pushPath:void 0};function As(){var M,J,ie;const{api:n}=Ze(),{blocklet:t}=Et(),{t:s}=re(),{confirmApi:r,confirmHolder:o}=Ct(),l=(M=t==null?void 0:t.meta)==null?void 0:M.did,y=Object.assign({...Be},((ie=(J=t==null?void 0:t.settings)==null?void 0:J.notification)==null?void 0:ie.pushKit)||{}),{handleSubmit:p,control:h,formState:i,watch:A,reset:O}=It({defaultValues:St(y,Object.keys(Be))}),R=Te({testReceiver:"",testReceiverError:""}),S=A("enabled"),D=V(async(c,g,j=!0)=>{var N,E;try{const{blocklet:P}=await n.configNotification({input:{did:l,notification:JSON.stringify({pushKit:c})}}),a=Object.assign({...Be},((E=(N=P==null?void 0:P.settings)==null?void 0:N.notification)==null?void 0:E.pushKit)||{});O(a),j&&q.success(s("oauth.saveSuccess"))}catch(P){if(j)q.error(P.message||s("oauth.saveFailed"));else throw P}}),G=V(async(c,g)=>{var j,N,E;try{i.isDirty&&await D(c,g,!1);const P=(j=((t==null?void 0:t.configs)||[]).find($=>$.key==="BLOCKLET_APP_URL"))==null?void 0:j.value,a=Xt(Qt(P,W.WELLKNOWN_SERVICE_PATH_PREFIX,"/blocklet/logo"),{v:(N=t==null?void 0:t.meta)==null?void 0:N.version,t:new Date((t==null?void 0:t.updatedAt)||0).getTime()}),m={type:"passthrough",passthroughType:"messageStatus",data:{message:{title:"Test push-kit notification",body:"This is message from push-kit config test",sender:{did:t==null?void 0:t.appDid,fullName:(E=t==null?void 0:t.meta)==null?void 0:E.title,avatar:a}}}};await n.sendPush({input:{did:l,receiver:R.testReceiver,notification:JSON.stringify(m)}}),q.success(s("notification.pushKit.testSuccess"))}catch(P){q.error(P.message||s("notification.pushKit.testfailed"))}}),z=V((c,g)=>{R.testReceiverError="",r.open({title:s("notification.pushKit.testSend"),content:()=>e.jsx(T,{sx:{width:"450px",maxWidth:"100%"},children:e.jsx(te,{sx:{mt:1},fullWidth:!0,name:"testReceiver",label:s("notification.pushKit.inputTestReceiver"),value:R.testReceiver,onChange:j=>{R.testReceiver=j.target.value},error:!!R.testReceiverError,helperText:R.testReceiverError||" "})}),confirmButtonText:s("common.confirm"),cancelButtonText:s("common.cancel"),async onConfirm(j){var E;if(!((E=R.testReceiver)==null?void 0:E.trim())){R.testReceiverError=s("notification.pushKit.receiverRequired");return}R.testReceiverError="",await G(c,g),j()}})}),B=V(c=>{const g=c==null?void 0:c.trim();return g?$e(g)?!0:s("notification.pushKit.endpointInvalid"):s("notification.pushKit.endpointRequired")}),_=V(()=>!0);return e.jsxs(T,{children:[e.jsxs(Os,{component:"form",onSubmit:p(D),disabled:!0,sx:{".section-left":{width:"160px"}},children:[e.jsx(ee,{title:s("notification.pushKit.enable"),my:2.5,children:e.jsx(Q,{name:"enabled",control:h,render:({field:c})=>e.jsx(ge,{control:e.jsx(We,{checked:c.value,...c})})})}),e.jsx(ee,{title:s("notification.pushKit.endpoint"),children:e.jsx(Q,{name:"endpoint",control:h,rules:{validate:S?B:_},render:({field:c})=>{var g;return e.jsx(Y,{fullWidth:!0,children:e.jsx(te,{...c,size:"small",required:!0,label:s("notification.pushKit.endpoint"),error:!!i.errors[c.name],helperText:((g=i.errors[c.name])==null?void 0:g.message)||" ",disabled:!S})})}})}),e.jsxs(ee,{title:s("notification.pushKit.customOptions"),children:[e.jsx(Q,{name:"did",control:h,render:({field:c})=>{var g;return e.jsx(Y,{fullWidth:!0,children:e.jsx(te,{...c,size:"small",label:s("notification.pushKit.did"),error:!!i.errors[c.name],helperText:((g=i.errors[c.name])==null?void 0:g.message)||" ",disabled:!S})})}}),e.jsx(Q,{name:"pushPath",control:h,render:({field:c})=>{var g;return e.jsx(Y,{fullWidth:!0,children:e.jsx(te,{...c,size:"small",label:s("notification.pushKit.pushPath"),error:!!i.errors[c.name],helperText:((g=i.errors[c.name])==null?void 0:g.message)||" ",disabled:!S})})}})]}),e.jsxs(T,{sx:{display:"flex",justifyContent:"flex-end",gap:2,mt:3},children:[e.jsx(me,{variant:"outlined",color:"warning",onClick:p(z),disabled:!S,children:s("oauth.runTest")}),e.jsx(me,{type:"submit",variant:"contained",disabled:!i.isDirty,children:s("oauth.save")})]})]}),o]})}const Os=ue(ht)``,ft=[{label:e.jsx(T,{textAlign:"center",width:"100%",children:"Email"}),value:"email"},{label:e.jsx(T,{textAlign:"center",width:"100%",children:"Push Kit"}),value:"pushKit"}];function Ds(){const[n,t]=C.useState(ft[0].value),{locale:s}=C.useContext(ss),r=ce(()=>({email:e.jsx(Es,{}),pushKit:e.jsx(As,{})}),[s]),o=C.useMemo(()=>({padding:"10px 0"}),[]);return e.jsxs(T,{children:[e.jsx(wt,{tabs:ft,current:n,onChange:t}),e.jsx(T,{style:o,children:r[n]})]})}const Pt=C.createContext({}),{Provider:Ls,Consumer:si}=Pt;function Ps({children:n,blocklet:t=""}){const{api:s,inService:r,ws:{useSubscription:o}}=Ze(),[l,y]=C.useState([]),[p,h]=C.useState({total:0,pageSize:20,pageCount:0,page:1}),i=ce(()=>{var c;return(c=t.meta)==null?void 0:c.did},[t]),[A,O]=C.useState([]),[R,S]=C.useState({}),D=ce(()=>l.length?new Set(l.map(c=>c.id)):new Set,[l]),G=async({page:c=1,pageSize:g=20,...j}={})=>{if(!i)return[];try{const N={paging:{page:c,pageSize:g},...j,teamDid:i,dateRange:j.dateRange?[se(j.dateRange[0]).toISOString(),se(j.dateRange[1]).toISOString()]:void 0},{dids:E,...P}=N;let a="";E&&E.includes("system")&&(a="system");const m=E?E.filter(oe=>oe!=="system"):[],$={...P,source:a,componentDids:m},U=await s.getNotificationSendLog({input:$});return S($),y(U.list),h(U.paging),U.list}catch(N){return q.error(N.message),[]}},z=async()=>{const c=await s.getNotificationComponents({input:{teamDid:i}});O(c.componentDids)},B=C.useCallback(c=>{const g=t.children.find(j=>{var N;return((N=j.meta)==null?void 0:N.did)===c});if(g)return g.ancestors=[t],g},[t]),_=async({notificationId:c,receivers:g,channels:j,...N})=>{await s.resendNotification({input:{teamDid:i,notificationId:c,receivers:g,channels:j.map(E=>E==="wallet"?W.NOTIFICATION_SEND_CHANNEL.WALLET:E==="pushKit"?W.NOTIFICATION_SEND_CHANNEL.PUSH:E),...N}})},M=C.useCallback(async c=>(await s.getUser({input:{teamDid:i,user:{did:c}}})).user,[s,i]),J=C.useCallback(async({page:c=1,pageSize:g=20,...j}={})=>{try{const N={paging:{page:c,pageSize:g},...j,userName:j.searchText||"",teamDid:i,dateRange:j.dateRange?[se(j.dateRange[0]).toISOString(),se(j.dateRange[1]).toISOString()]:void 0};return await s.getReceivers({input:N})}catch(N){throw q.error(N.message),N}},[s,i]);C.useEffect(()=>{i&&z()},[i]),o(W.EVENTS.NOTIFICATION_BLOCKLET_UPDATE,c=>{D.has(c.notificationId)&&G(R)},[D,R]),o(W.EVENTS.NOTIFICATION_BLOCKLET_CREATE,c=>{D.has(c.id)||G(R)},[D,R]);const ie={fetch:G,data:l,paging:p,blocklet:t,getComponent:B,resendNotification:_,getUser:M,componentDids:A,getReceivers:J,inService:r,teamDid:i};return e.jsx(Ls,{value:{notificationRecords:ie},children:n})}function tt(){const{notificationRecords:n}=C.useContext(Pt);return n}Ne.propTypes={severity:x.oneOf(Object.values(["info","success","error","warning"])).isRequired};const _s={info:"primary",success:"success",error:"error",warning:"warning"};function Ne({severity:n="info"}){return e.jsx(ns,{type:_s[n],children:n})}var st={},ks=Je;Object.defineProperty(st,"__esModule",{value:!0});var _t=st.default=void 0,Fs=ks(Qe()),Bs=e;_t=st.default=(0,Fs.default)((0,Bs.jsx)("path",{d:"M16.59 7.58 10 14.17l-3.59-3.58L5 12l5 5 8-8zM12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2m0 18c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8"}),"CheckCircleOutline");var nt={},zs=Je;Object.defineProperty(nt,"__esModule",{value:!0});var kt=nt.default=void 0,Ws=zs(Qe()),Ks=e;kt=nt.default=(0,Ws.default)((0,Ks.jsx)("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2M4 12c0-4.42 3.58-8 8-8 1.85 0 3.55.63 4.9 1.69L5.69 16.9C4.63 15.55 4 13.85 4 12m8 8c-1.85 0-3.55-.63-4.9-1.69L18.31 7.1C19.37 8.45 20 10.15 20 12c0 4.42-3.58 8-8 8"}),"Block");var it={},qs=Je;Object.defineProperty(it,"__esModule",{value:!0});var Ft=it.default=void 0,Ms=qs(Qe()),$s=e;Ft=it.default=(0,Ms.default)((0,$s.jsx)("path",{d:"M17.65 6.35C16.2 4.9 14.21 4 12 4c-4.42 0-7.99 3.58-7.99 8s3.57 8 7.99 8c3.73 0 6.84-2.55 7.73-6h-2.08c-.82 2.33-3.04 4-5.65 4-3.31 0-6-2.69-6-6s2.69-6 6-6c1.66 0 3.14.69 4.22 1.78L13 11h7V4z"}),"Refresh");const Us=(n,t,s="")=>{if(!s||!t)return"";switch(s){case W.NOTIFICATION_SEND_FAILED_REASON.USER_DISABLED:return n("notification.sendStatus.reason.disabled",{channel:t});case W.NOTIFICATION_SEND_FAILED_REASON.CHANNEL_UNAVAILABLE:return n("notification.sendStatus.reason.unavailable",{channel:t});case W.NOTIFICATION_SEND_FAILED_REASON.CHANNEL_DISABLED:return n("notification.sendStatus.reason.notSent",{channel:t});case W.NOTIFICATION_SEND_FAILED_REASON.NOT_ONLINE:return n("notification.sendStatus.reason.offline");default:return s}};function Bt(n,t,s={}){const{status:r,updatedAt:o,reason:l="",channel:y="wallet"}=s,p=o?n("notification.sendStatus.sentTime",{date:os(o,t)}):"",h=Us(n,y,l);return r===W.NOTIFICATION_SEND_STATUS.FAILED?{status:"failed",title:n("notification.sendStatus.failed"),sentTime:p,reason:h}:r===W.NOTIFICATION_SEND_STATUS.SENT?{status:"success",title:n("notification.sendStatus.success"),sentTime:p}:{status:"pending",title:n("notification.sendStatus.pending"),reason:h,sentTime:p}}const Ye={pending:"#aaaaaa",success:"#34BE74",failed:"#D0021B"},Ge=["wallet","pushKit","email"],mt=["info","success","error","warning"],zt=n=>{var s,r;const{settings:t}=n;return(r=(s=t==null?void 0:t.notification)==null?void 0:s.email)==null?void 0:r.enabled},Wt=n=>{var s,r;const{settings:t}=n;return(r=(s=t==null?void 0:t.notification)==null?void 0:s.pushKit)==null?void 0:r.enabled},Hs=(n,t)=>{const s=fe(t,"extra.notifications.email",!0);return{available:zt(n),enabled:s}},Vs=(n,t)=>{const s=fe(t,"extra.notifications.push",!0);return{available:Wt(n),enabled:s}},Ys=n=>({enabled:fe(n,"extra.notifications.wallet",!0)}),Gs=n=>({enabled:fe(n,"extra.webhooks",[]).length>0}),Ee=(n=3)=>new Promise(t=>{setTimeout(()=>{t()},n*1e3)}),Js=(n,t)=>t==="wallet"||t==="webhook"?[{channel:t,type:"enabled",pass:n("notification.sendStatus.reason.enabled",{channel:t}),fail:n("notification.sendStatus.reason.disabled",{channel:t})}]:t==="pushKit"||t==="email"?[{channel:t,type:"available",pass:n("notification.sendStatus.reason.available",{channel:t}),fail:n("notification.sendStatus.reason.unavailable",{channel:t})},{channel:t,type:"enabled",pass:n("notification.sendStatus.reason.enabled",{channel:t}),fail:n("notification.sendStatus.reason.disabled",{channel:t})}]:[],Ie=(n=[])=>{const t=se().startOf("day");return n.filter(s=>se(s.sendAt).isSame(t,"day")).length},Xs=(n,t="")=>{if(t&&Ge.includes(t)){const l=`${t}SendRecord`,y=fe(n,l,[]);return Ie(y)}const s=fe(n,"webhook",{}),r=Object.keys(s??{})??[];if(t&&r.includes(t)){const l=s[t]??[];return Ie(l)}const o={};return Ge.forEach(l=>{const y=`${l}SendRecord`,p=fe(n,y,[]),h=Ie(p);o[l]=h}),r.length>0&&r.forEach(l=>{const y=s[l]??[],p=Ie(y);o[l]=p}),o},Oe=(n,t,s)=>{if(!Array.isArray(n))throw new Error("Invalid filterList or index");return n[s].splice(t,1),n},De=(n,t)=>{if(!Array.isArray(t))throw new Error("filters must be an array");return t.length?!t.includes(n):!1},Qs=n=>{switch(n){case W.NOTIFICATION_SEND_CHANNEL.WALLET:return"Wallet";case W.NOTIFICATION_SEND_CHANNEL.PUSH:return"Push Kit";case W.NOTIFICATION_SEND_CHANNEL.EMAIL:return"Email";case W.NOTIFICATION_SEND_CHANNEL.WEBHOOK:return"Webhook";default:return""}},Kt=()=>({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 de({config:n,enableTooltip:t=!0,showTitle:s=!1,children:r}){const{status:o,title:l="",sentTime:y="",reason:p=""}=n,h=[l,p].filter(Boolean).join(", ");return e.jsx(xt,{title:t?e.jsxs(e.Fragment,{children:[e.jsx(ae,{color:"inherit",sx:{fontSize:12},children:h}),e.jsx("span",{children:y})]}):null,arrow:!0,placement:"top",children:e.jsxs(T,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"4px"},children:[e.jsxs(T,{position:"relative",minHeight:14,minWidth:14,display:"flex",alignItems:"center",justifyContent:"center",children:[e.jsx(T,{position:"absolute",width:"100%",height:"100%",borderRadius:"50%",bgcolor:Ye[o],style:{opacity:.15}}),e.jsx(T,{position:"absolute",width:"55%",height:"55%",borderRadius:"50%",bgcolor:Ye[o]})]}),e.jsx(ae,{color:"inherit",sx:{fontSize:12},children:s?l:r})]})})}de.propTypes={config:x.object.isRequired,enableTooltip:x.bool,showTitle:x.bool,children:x.node};de.defaultProps={enableTooltip:!0,showTitle:!1,children:null};Se.propTypes={list:x.array.isRequired,label:x.string.isRequired,onDelete:x.func};Se.defaultProps={onDelete:()=>{}};function Se({list:n,label:t,onDelete:s}){const{t:r,locale:o}=re();return e.jsxs(T,{display:"flex",gap:1,alignItems:"center",children:[e.jsxs(ae,{children:[t,": "]}),n.map(l=>{const y=Bt(r,o,{status:l});return e.jsx(Xe,{size:"small",label:e.jsx(T,{display:"flex",alignItems:"center",sx:{gap:"4px"},children:e.jsx(de,{config:y,enableTooltip:!1,children:y.title})}),onDelete:p=>s(p,l)},l)})]})}at.propTypes={filterList:x.array.isRequired,onChange:x.func.isRequired,index:x.number.isRequired,column:x.object.isRequired,filterValues:x.array.isRequired,label:x.string.isRequired,renderLabel:x.func.isRequired};function at({filterList:n,onChange:t,index:s,column:r,filterValues:o,label:l,renderLabel:y}){return e.jsxs(Y,{className:"filter-container",children:[e.jsx(gt,{component:"legend",children:l}),e.jsx(Ke,{row:!0,children:o.map(p=>e.jsx(ge,{control:e.jsx(qe,{checked:n[s].indexOf(p.value??p)>-1,onChange:h=>{const i=[...n];h.target.checked?i[s]=[...i[s],p.value??p]:i[s]=i[s].filter(A=>A!==(p.value??p)),t(i[s],s,r)},name:p.value??p}),label:e.jsx("span",{style:{display:"flex",alignItems:"center"},children:y(p)})},p.value??p))})]})}function ze(n){return e.jsx(at,{...n,renderLabel:t=>e.jsx(de,{enableTooltip:!1,config:{status:t.status},children:t.label})})}ve.propTypes={status:x.number.isRequired,updatedAt:x.string.isRequired,reason:x.string,channel:x.string,onResend:x.func};function ve({status:n,updatedAt:t,reason:s="",channel:r="wallet",onResend:o}){const{t:l,locale:y}=re(),p=Bt(l,y,{status:n,updatedAt:t,reason:s,channel:r});return e.jsxs(T,{display:"flex",alignItems:"center",gap:1,children:[e.jsx(de,{config:p,showTitle:!0}),p.status!=="success"&&e.jsx(Le,{className:"resend-btn",size:"small",startIcon:e.jsx(et,{}),sx:{fontSize:12,color:"rgba(0, 0, 0, 0.87)",fontWeight:400,".MuiButton-startIcon":{mr:"2px"}},onClick:o,children:l("notification.resend")})]})}rt.propTypes={value:x.array.isRequired,onChange:x.func};function rt({value:n,onChange:t}){const{locale:s}=re(),r=se().toDate(),[o,l]=C.useState(null),y=C.useCallback(i=>{l(o?null:i.currentTarget)},[o]),p=!!o,h=C.useCallback(i=>{if(!i.startDate||!i.endDate){q.error("Please select a date range");return}if(se(i.startDate).isAfter(i.endDate)||!se(i.startDate).isValid()||!se(i.endDate).isValid()){q.error("Invalid date range");return}t([i.startDate,i.endDate]),l(null)},[t]);return e.jsxs("div",{children:[e.jsx(ae,{component:"div",variant:"h5",color:"textPrimary",style:{fontSize:18,fontWeight:"bold"},mb:0,children:e.jsxs(Le,{onClick:y,variant:"outlined",size:"small",color:"inherit",children:[pt(n[0],s)," - ",pt(n[1],s)]})}),e.jsx(Me,{open:p,anchorEl:o,onClose:()=>{l(null)},anchorOrigin:{vertical:"bottom",horizontal:"left"},children:e.jsx(ys,{open:!0,maxDate:r,initialDateRange:{startDate:n[0],endDate:n[1]},toggle:y,definedRanges:Ss(r),onChange:h})})]})}ot.propTypes={itemComponent:x.elementType.isRequired};function ot({itemComponent:n,...t}){var o;const{t:s}=re();return!((o=t==null?void 0:t.filterList)!=null&&o.filter(l=>l.length).length)?null:e.jsxs(T,{display:"flex",gap:1,alignItems:"center",children:[e.jsx("div",{className:"toolbar-filter-title",children:s("notification.filter")}),e.jsx("div",{className:"toolbar-filter-content",children:e.jsx(is.TableFilterList,{...t,ItemComponent:n})})]})}function Pe({label:n,onDelete:t,canDelete:s=()=>!0,...r}){const o=t&&typeof t=="function"?t:void 0;let l=!0;return s&&typeof s=="function"&&(l=s({label:n,...r})),e.jsx(Xe,{label:n,variant:"outlined",...o&&l?{onDelete:o}:{}})}Pe.propTypes={label:x.string.isRequired,onDelete:x.func,canDelete:x.func};Pe.defaultProps={canDelete:()=>!0};const Zs=[{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}];lt.propTypes={loading:x.bool,onCancel:x.func,onConfirm:x.func};lt.defaultProps={loading:!1,onCancel:()=>{},onConfirm:()=>{}};function lt({loading:n=!1,onCancel:t,onConfirm:s}){const{t:r}=re(),[o,l]=C.useState(Zs),[y,p]=C.useState(!0),h=(A,O)=>{O.checked=A.target.checked;const R=o.map(S=>({...S,checked:S.value===O.value?O.checked:S.checked}));l(R)},i=A=>{A.stopPropagation(),s({channels:o.filter(O=>O.checked).map(O=>O.value),isResendFailedOnly:y})};return e.jsxs(T,{className:"resend-config",sx:{padding:"16px 24px"},children:[e.jsx(ae,{variant:"body1",component:"div",className:"check-title",sx:{fontWeight:700,mb:1},children:r("notification.config")}),e.jsx(T,{className:"choose-channel",children:e.jsxs(Y,{component:"fieldset",variant:"standard",children:[e.jsx(gt,{component:"legend",children:r("notification.selectChannels")}),e.jsx(Ke,{sx:{display:"flex",flexDirection:"row",flexWrap:"wrap",gap:1},children:o.map(A=>e.jsx(ge,{control:e.jsx(qe,{checked:A.checked,onChange:O=>h(O,A),name:A.value}),label:A.label},A.value))})]})}),e.jsx(T,{className:"resend-config-footer",children:e.jsx(Ke,{children:e.jsx(ge,{control:e.jsx(qe,{checked:y,onChange:A=>p(A.target.checked)}),label:r("notification.resendFailedOnly")})})}),e.jsxs(T,{display:"flex",justifyContent:"flex-end",gap:1,className:"resend-config-footer-tip",children:[e.jsx(Le,{onClick:A=>{A.stopPropagation(),t()},color:"inherit",children:r("common.cancel")}),e.jsxs(Le,{onClick:i,color:"primary",disabled:n,variant:"contained",autoFocus:!0,style:{marginLeft:8},children:[n&&e.jsx(bt,{size:16}),r("common.confirm")]})]})]})}qt.propTypes={notificationId:x.string.isRequired,handleResend:x.func,resending:x.bool};function qt({notificationId:n,handleResend:t,resending:s=!1}){const{t:r,locale:o}=re(),l=jt(),y=C.useMemo(()=>vt(l,Kt()),[l]),{getReceivers:p,inService:h,teamDid:i,getUser:A,blocklet:O}=tt(),[R,S]=C.useState(!1),[D,G]=C.useState([]),z=Te({anchorEl:null,position:null}),B=Te({anchorEl:null,position:null}),[_,M]=C.useState(null),[J,ie]=C.useState({total:0,pageSize:10,pageCount:0,page:1}),[c,g]=C.useState({searchText:"",page:1,pageSize:10,walletSendStatus:[],pushKitSendStatus:[],emailSendStatus:[],dateRange:[se().subtract(1,"month").startOf("day").toDate(),se().endOf("day").toDate()]}),[j,N]=C.useState([]),E=[{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"}],P=async()=>{if(!R&&n)try{S(!0);const d=await p({notificationId:n,...c}),u=d.list.map(f=>({...f,receiverUser:{...f.receiverUser,avatar:Dt(f.receiverUser.avatar,i,h)}}));G(u),ie(d.paging),S(!1)}catch(d){q.error(d.message),S(!1)}};C.useEffect(()=>{P()},[c]);const a=d=>{d.stopPropagation();const u=d.currentTarget;B.anchorEl=u;const f=u.getBoundingClientRect();B.position={top:f.top+window.scrollY,left:f.left+window.scrollX}},m=d=>d.data.length?e.jsx("div",{style:{display:"flex",alignItems:"center",padding:"10px"},children:e.jsx(me,{className:"resend-btn",size:"small",color:"primary",variant:"contained",startIcon:e.jsx(et,{}),sx:{".MuiButton-startIcon":{mr:"2px"}},onClick:a,children:r("notification.resend")})}):null,$={sort:!1,download:!1,print:!1,selectableRows:"multiple",searchPlaceholder:r("common.search"),searchAlwaysOpen:!1,filterType:"checkbox",searchDebounceTime:300,page:J.page-1,rowsPerPage:J.pageSize,count:J.total,searchText:c.searchText,tableBodyMaxHeight:"calc(80vh - 260px)",rowsSelected:j,onRowSelectionChange:(d,u)=>{N(u.map(f=>f.dataIndex))},customToolbarSelect:m},U=({page:d,rowsPerPage:u,searchText:f,filterList:L})=>{const[,K=[],Z=[],X=[]]=L;c.pageSize!==u?g(H=>({...H,pageSize:u,page:1})):c.page!==d+1?g(H=>({...H,page:d+1})):c.searchText!==f?g(H=>({...H,searchText:f,page:1})):ye(K,c.walletSendStatus)?ye(Z,c.pushKitSendStatus)?ye(X,c.emailSendStatus)||g(H=>({...H,emailSendStatus:X,page:1})):g(H=>({...H,pushKitSendStatus:Z,page:1})):g(H=>({...H,walletSendStatus:K,page:1}))},oe=C.useCallback(async(d,u)=>{if(!u)return!1;const f=await A(u);return f?d==="wallet"?Ys(f):d==="email"?Hs(O,f):d==="pushKit"?Vs(O,f):d==="webhook"?Gs(f):!0:!1},[A,O]),le=C.useCallback(d=>Js(r,d),[r]),pe=()=>{z.anchorEl=null,z.position=null,M(null)},be=()=>{B.anchorEl=null,B.position=null},je=async(d,u,f=!0,L="")=>{if(!(!u.length||!d.length))try{t(d,u,f,L),B.anchorEl||(await Ee(.5),pe())}catch(K){console.error("handleResend error",{error:K})}},v=async({channels:d,isResendFailedOnly:u})=>{const f=j.map(L=>D[L].receiver);await je(d,f,u),await Ee(.5),be(),N([])},b=async(d,u=[],f=!0)=>{try{await je(["webhook"],[d.receiver],f,u)}catch(L){q.error(L.response?L.response.statusText:L.message)}},w=async(d,u,f,L=[],K=!0)=>{if(d.stopPropagation(),Xs(u,f)>=4){q.warning(r("notification.resendLimit"));return}if(!Ge.includes(f)){await b(u,L,K);return}if(d){const X=d.currentTarget,H=X.getBoundingClientRect();z.anchorEl=X,z.position={top:H.top+window.scrollY,left:H.left+window.scrollX}}M({channel:f});try{const X=await oe(f,u.receiver);await Ee(1),M({channel:f,result:X}),(typeof X=="boolean"&&X||Zt(X)&&Object.values(X).every(H=>!!H))&&(await t([f],[u.receiver],K),B.anchorEl||(await Ee(.5),pe()))}catch(X){q.error(X.message)}},I=d=>{g(u=>({...u,dateRange:d,page:1}))},k=(d,u,f,L)=>{d.stopPropagation();const K=f.filter(Z=>Z!==u);g(Z=>({...Z,[L]:K,page:1}))},F=ce(()=>[{label:r("notification.receiver"),name:"receiver",width:200,options:{filter:!1,customBodyRenderLite:d=>{const{receiverUser:u,receiver:f}=D[d];return u?e.jsxs(T,{"data-cy":`member-name-${u.fullName}`,display:"flex",alignItems:"center",gap:1,justifyContent:"flex-start",children:[e.jsx(Tt,{src:`${u.avatar}?imageFilter=resize&w=48&h=48`,size:32,did:f,shape:"circle",style:{borderRadius:"100%",overflow:"hidden"}}),e.jsx(Re,{children:u.fullName})]},f):e.jsx(vs,{size:14,responsive:!1,compact:!0,copyable:!1,did:f})}}},{label:"Wallet",name:"walletSendStatus",width:200,options:{setCellProps:()=>({className:"sent-status-cell"}),filter:!0,filterType:"custom",filterList:c.walletSendStatus??[],customFilterListOptions:{render:d=>e.jsx(Se,{list:d,label:"Wallet",onDelete:(u,f)=>{u.stopPropagation(),k(u,f,F[1].options.filterList,"walletSendStatus")}}),update:Oe},filterOptions:{names:E,fullWidth:!0,logic:De,display:(d,u,f,L)=>e.jsx(ze,{label:"Wallet",filterList:d,onChange:u,index:f,column:L,filterValues:E})},customBodyRenderLite:d=>{const{walletSendStatus:u,walletSendAt:f,walletSendFailedReason:L}=D[d];return e.jsx(ve,{status:u,updatedAt:f,reason:L,channel:"wallet",onResend:K=>w(K,D[d],"wallet",[],!1)})}}},{label:"Push Kit",name:"pushKitSendStatus",width:200,options:{setCellProps:()=>({className:"sent-status-cell"}),customBodyRenderLite:d=>{const{pushKitSendStatus:u,pushKitSendAt:f,pushKitSendFailedReason:L}=D[d];return e.jsx(ve,{status:u,updatedAt:f,reason:L,channel:"pushkit",onResend:K=>w(K,D[d],"pushKit",[],!1)})},filter:!0,filterType:"custom",filterList:c.pushKitSendStatus??[],customFilterListOptions:{render:d=>e.jsx(Se,{list:d,label:"Push Kit",onDelete:(u,f)=>{u.stopPropagation(),k(u,f,F[2].options.filterList,"pushKitSendStatus")}}),update:Oe},filterOptions:{names:E,fullWidth:!0,logic:De,display:(d,u,f,L)=>e.jsx(ze,{label:"Push Kit",filterList:d,onChange:u,index:f,column:L,filterValues:E})}}},{label:"Email",name:"emailSendStatus",width:200,options:{setCellProps:()=>({className:"sent-status-cell"}),customBodyRenderLite:d=>{const{emailSendStatus:u,emailSendAt:f,emailSendFailedReason:L}=D[d];return e.jsx(ve,{status:u,updatedAt:f,reason:L,channel:"email",onResend:K=>w(K,D[d],"email",[],!1)})},filter:!0,filterType:"custom",filterList:c.emailSendStatus??[],customFilterListOptions:{render:d=>e.jsx(Se,{list:d,label:"Email",onDelete:(u,f)=>{u.stopPropagation(),k(u,f,F[3].options.filterList,"emailSendStatus")}}),update:Oe},filterOptions:{names:E,fullWidth:!0,logic:De,display:(d,u,f,L)=>e.jsx(ze,{label:"Email",filterList:d,onChange:u,index:f,column:L,filterValues:E})}}},{label:"Webhook",name:"webhook",width:200,options:{filter:!1,setCellProps:()=>({className:"sent-status-cell"}),customBodyRenderLite:d=>{const{webhook:u}=D[d];if(!u)return null;const f=Object.entries(u)[0];if(!f)return null;const[L,K]=f,Z=K[0];return e.jsx(T,{display:"flex",flexDirection:"column",gap:1,children:e.jsxs(T,{className:"webhook-item",fontSize:12,children:[e.jsx(Re,{maxLength:30,children:L},L),e.jsx(ve,{status:Z.status,updatedAt:Z.sendAt,reason:Z.failedReason,channel:"webhook",onResend:X=>w(X,D[d],"webhook",[L],!1)})]},L)})}}},{label:r("common.createdAt"),name:"createdAt",width:100,options:{filter:!1,customBodyRenderLite:d=>{const{createdAt:u}=D[d];return e.jsx(Ot,{value:u,locale:o,shouldUpdate:!0})}}}],[D,o,c,r]),ne=[e.jsx(rt,{value:c.dateRange,onChange:I},"date-picker"),e.jsx(me,{variant:"contained",size:"small",color:"primary",loading:R,startIcon:e.jsx(Ft,{}),onClick:()=>P(),sx:{".MuiButton-startIcon":{mr:"2px"}},style:{marginLeft:8},children:r("common.refresh")},"refresh")];return e.jsx(T,{sx:{overflow:"auto",".MuiTableCell-head":{whiteSpace:"nowrap",fontWeight:"bold"},".MuiTableCell-root":{paddingRight:"8px",whiteSpace:"nowrap"}},children:e.jsx(tn,{children:e.jsxs(yt,{theme:y,children:[e.jsx(Rt,{className:"receivers-table",locale:o,loading:R,columns:F,data:D,onChange:U,options:$,customButtons:ne,components:{TableFilterList:d=>e.jsx(ot,{...d,itemComponent:u=>e.jsx(Pe,{...u,canDelete:()=>!1})})}}),z.anchorEl&&e.jsx(Me,{open:!!z.anchorEl,anchorReference:"anchorPosition",anchorPosition:z.position,onClose:pe,anchorOrigin:{vertical:"center",horizontal:"right"},transformOrigin:{vertical:"center",horizontal:"left"},children:e.jsxs(sn,{children:[e.jsxs(ae,{variant:"body1",component:"div",className:"check-title",children:[_==null?void 0:_.channel," Checking"]}),e.jsx(T,{display:"flex",flexDirection:"column",sx:{gap:"4px"},children:le(_==null?void 0:_.channel).map(d=>{var K,Z;const{type:u,pass:f,fail:L}=d;return!(_!=null&&_.result)||(K=_==null?void 0:_.result)!=null&&K[u]?e.jsxs(ae,{variant:"body1",component:"div",className:"check-item",display:"flex",alignItems:"center",sx:{gap:"4px",color:(Z=_==null?void 0:_.result)!=null&&Z[u]?Ae.success.main:"inherit"},children:[_!=null&&_.result?e.jsx(_t,{}):e.jsx(bt,{size:12,sx:{color:Ae.primary.main}}),e.jsx("span",{children:f})]},u):e.jsxs(ae,{variant:"body1",component:"div",display:"flex",alignItems:"center",className:"check-item",sx:{gap:"4px",color:Ae.error.main},children:[e.jsx(kt,{}),e.jsx("span",{children:L})]},u)})})]})}),B.anchorEl&&e.jsx(Me,{open:!!B.anchorEl,anchorReference:"anchorPosition",anchorPosition:B.position,onClose:be,anchorOrigin:{vertical:"center",horizontal:"right"},transformOrigin:{vertical:"center",horizontal:"left"},children:e.jsx(lt,{loading:s,onCancel:be,onConfirm:v})})]})})})}const en=C.memo(qt),tn=ue.div`
1
+ import{g as Ut,r as C}from"./vendor-react-DEoibe3W.js";import{ah as ue,al as ht,j as e,aa as T,O as te,bs as ge,bt as We,bo as G,ad as xt,H as x,a9 as Je,T as ae,E as Xe,bz as gt,bQ as Ke,bR as qe,y as Le,b6 as Me,ab as bt,bI as jt,Y as vt,cn as yt,m as Ht,as as dt,br as Vt,bn as Gt,q as ut,bX as Yt,I as Jt}from"./vendor-mui-core-Bq8gXTan.js";import{J as St,z as Xt,A as Qt,e as fe,aB as ye,C as Zt}from"./vendor-utils-BotmZdBm.js";import{y as es,a as re,ab as Ct,a3 as q,X as ke,b$ as ts,B as me,k as W,bb as ss,ax as wt,bg as ns,r as Qe,c0 as is,a2 as Tt,ac as Rt,bz as Oe,ar as Nt,$ as as,bG as rs}from"./vendor-ux-did-connect-DVX9lQ8a.js";import{D as Ze,G as Et,aC as It,aD as Q,y as se,n as os,K as pt}from"./index-CMYalRl2.js";import{a as Te,u as V,b as ce}from"./vendor-hooks-BFlOfe0M.js";import{a as et,b as ls}from"./dashboard-B2X6c8E8.js";import{f as $e,i as cs,d as ds}from"./use-blocklet-logo-CTCMbFiC.js";import{A as us,a as ps,d as fs,b as ms}from"./collapse-9taxUXec.js";import{S as ee}from"./section-BDMQAX_r.js";import{S as Re}from"./shorten-label-BQvbtscf.js";import{I as Ot}from"./index-BzZuK-66.js";import{R as At,A as hs,S as xs,a as gs,b as bs,B as js}from"./list-KVxvPXZu.js";import{W as vs}from"./did-address-L54dTMrT.js";import{p as Dt}from"./util-M3UFXQFT.js";import{D as ys,g as Ss}from"./traffic-CUSLm0PX.js";import{B as Lt}from"./bundle-avatar-B5-ypzmO.js";import{u as Cs}from"./use-mobile-DwzRjjku.js";import"./lottie-web-jYmAQWuC.js";import"./vendor-arcblock-DiSm3oUX.js";import"./useLocalStorage-DyVGBDlt.js";import"./index-8eXqqyHQ.js";import"./confirm-DApmnpvm.js";import"./PlayArrow-RVSfCmrB.js";import"./get-safe-url-B8xlSMyD.js";import"./session-Bkvl2PSP.js";import"./InfoOutlined-C8ZBPUhD.js";import"./dot-iw3hN9HL.js";import"./useAsync-DVHp96Uu.js";import"./useSetState-CWq0AVWn.js";import"./use-mobile-CtTQsfXN.js";import"./index-DEZojGsm.js";import"./CheckCircle-BcPSvH2E.js";import"./base32-DEjena1X.js";import"./iframe-Dj9NLHp2.js";import"./LaunchOutlined-DQZ7S23O.js";import"./ChevronLeft-Ch9iK6fF.js";import"./ChevronRight-DclARA5k.js";import"./index-B2NkqENf.js";import"./base-chart-C2FJuVG1.js";import"./index-CKY4HT0P.js";import"./vendor-mui-x-1nqAyytV.js";import"./AdapterDayjs-BzjU9O7t.js";var Ue={exports:{}},He={exports:{}},Ve={exports:{}};(function(n,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=s;function s(r){return r==null}n.exports=t.default,n.exports.default=t.default})(Ve,Ve.exports);var ws=Ve.exports;(function(n,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=p;var s=o(es),r=o(ws);function o(h){return h&&h.__esModule?h:{default:h}}var l=/^(?:[-+]?(?:0|[1-9][0-9]*))$/,y=/^[-+]?[0-9]+$/;function p(h,i){(0,s.default)(h),i=i||{};var O=i.allow_leading_zeroes===!1?l:y,A=!i.hasOwnProperty("min")||(0,r.default)(i.min)||h>=i.min,R=!i.hasOwnProperty("max")||(0,r.default)(i.max)||h<=i.max,S=!i.hasOwnProperty("lt")||(0,r.default)(i.lt)||h<i.lt,D=!i.hasOwnProperty("gt")||(0,r.default)(i.gt)||h>i.gt;return O.test(h)&&A&&R&&S&&D}n.exports=t.default,n.exports.default=t.default})(He,He.exports);var Ts=He.exports;(function(n,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=o;var s=r(Ts);function r(l){return l&&l.__esModule?l:{default:l}}function o(l){return(0,s.default)(l,{allow_leading_zeroes:!1,min:0,max:65535})}n.exports=t.default,n.exports.default=t.default})(Ue,Ue.exports);var Rs=Ue.exports;const Ns=Ut(Rs),Fe={enabled:!1,secure:!1,from:"",host:"",port:"",user:"",password:"",companyName:"",companyLink:"",companyAddress:"",supportEmail:""};function Es(){var N,E,P;const{api:n}=Ze(),{blocklet:t}=Et(),{t:s}=re(),{confirmApi:r,confirmHolder:o}=Ct(),l=(N=t==null?void 0:t.meta)==null?void 0:N.did,y=Object.assign({...Fe},((P=(E=t==null?void 0:t.settings)==null?void 0:E.notification)==null?void 0:P.email)||{}),{handleSubmit:p,control:h,formState:i,watch:O,reset:A}=It({defaultValues:St(y,Object.keys(Fe))}),R=Te({testReceiver:"",testReceiverError:""}),S=O("enabled"),D=V(async(a,m,$=!0)=>{var U,oe;try{const{blocklet:le}=await n.configNotification({input:{did:l,notification:JSON.stringify({email:a})}}),pe=Object.assign({...Fe},((oe=(U=le==null?void 0:le.settings)==null?void 0:U.notification)==null?void 0:oe.email)||{});A(pe),$&&q.success(s("oauth.saveSuccess"))}catch(le){if($)q.error(le.message||s("oauth.saveFailed"));else throw le}}),Y=V(async(a,m,$)=>{try{i.isDirty&&await D(a,m,!1),await n.sendEmail({input:{did:l,receiver:$,email:JSON.stringify({body:"Your SMTP configuration is correct!",title:"Test email",type:"notification"})}}),q.success(s("notification.email.testSuccess"))}catch(U){q.error(U.message||s("notification.email.testfailed"))}}),B=V((a,m)=>{R.testReceiver="",R.testReceiverError="",r.open({title:s("notification.email.testSendEmail"),content:()=>e.jsx(T,{sx:{width:"300px"},children:e.jsx(te,{sx:{mt:1},fullWidth:!0,name:"testReceiver",label:s("notification.email.inputTestReceiver"),value:R.testReceiver,onChange:$=>{R.testReceiver=$.target.value},error:!!R.testReceiverError,helperText:R.testReceiverError||" "})}),confirmButtonText:s("common.confirm"),cancelButtonText:s("common.cancel"),async onConfirm($){var oe;const U=(oe=R.testReceiver)==null?void 0:oe.trim();if(!U){R.testReceiverError=s("notification.email.receiverRequired");return}if(!ke(U)){R.testReceiverError=s("notification.email.receiverInvalid");return}R.testReceiverError="",await Y(a,m,U),$()}})}),z=V(a=>{const m=a==null?void 0:a.trim();return m?ke(m)?!0:s("notification.email.fromInvalid"):s("notification.email.fromRequired")}),_=V(a=>{const m=a==null?void 0:a.trim();return m?$e(m,{require_host:!1,protocols:[]})?!0:s("notification.email.hostInvalid"):s("notification.email.hostRequired")}),M=V(a=>a?Ns(a)?!0:s("notification.email.portInvalid"):s("notification.email.portRequired")),J=V(a=>a!=null&&a.trim()?!0:s("notification.email.userRequired")),ie=V(a=>a!=null&&a.trim()?!0:s("notification.email.passwordRequired")),c=V(a=>a!=null&&a.trim()&&!$e(a,{protocols:["http","https"],require_protocol:!0})?s("notification.email.linkInvalid"):!0),g=V(a=>a!=null&&a.trim()&&!ke(a)?s("notification.email.emailInvalid"):!0),j=V(()=>!0);return e.jsxs(T,{children:[e.jsxs(Is,{component:"form",onSubmit:p(D),disabled:!0,sx:{".section-left":{width:"160px"}},children:[e.jsx(ee,{title:s("notification.email.enable"),my:2.5,children:e.jsx(Q,{name:"enabled",control:h,render:({field:a})=>e.jsx(ge,{control:e.jsx(We,{checked:a.value,...a})})})}),e.jsx(ee,{title:s("notification.email.from"),children:e.jsx(Q,{name:"from",control:h,rules:{validate:S?z:j},render:({field:a})=>{var m;return e.jsx(G,{fullWidth:!0,children:e.jsx(te,{...a,size:"small",required:!0,label:s("notification.email.from"),error:!!i.errors[a.name],helperText:((m=i.errors[a.name])==null?void 0:m.message)||" ",disabled:!S})})}})}),e.jsx(ee,{title:s("notification.email.host"),children:e.jsx(Q,{name:"host",control:h,rules:{validate:S?_:j},render:({field:a})=>{var m;return e.jsx(G,{fullWidth:!0,children:e.jsx(te,{...a,size:"small",required:!0,error:!!i.errors[a.name],label:s("notification.email.host"),helperText:((m=i.errors[a.name])==null?void 0:m.message)||" ",disabled:!S})})}})}),e.jsx(ee,{title:s("notification.email.port"),children:e.jsx(Q,{name:"port",control:h,rules:{validate:S?M:j},render:({field:a})=>{var m;return e.jsx(G,{fullWidth:!0,children:e.jsx(te,{...a,size:"small",required:!0,type:"number",error:!!i.errors[a.name],label:s("notification.email.port"),helperText:((m=i.errors[a.name])==null?void 0:m.message)||" ",disabled:!S})})}})}),e.jsx(ee,{title:s("notification.email.user"),children:e.jsx(Q,{name:"user",control:h,rules:{validate:S?J:j},render:({field:a})=>{var m;return e.jsx(G,{fullWidth:!0,children:e.jsx(te,{...a,size:"small",required:!0,error:!!i.errors[a.name],label:s("notification.email.user"),helperText:((m=i.errors[a.name])==null?void 0:m.message)||" ",disabled:!S})})}})}),e.jsx(ee,{title:s("notification.email.password"),children:e.jsx(Q,{name:"password",control:h,rules:{validate:S?ie:j},render:({field:a})=>{var m;return e.jsx(G,{fullWidth:!0,children:e.jsx(te,{...a,size:"small",required:!0,type:"password",error:!!i.errors[a.name],label:s("notification.email.password"),helperText:((m=i.errors[a.name])==null?void 0:m.message)||" ",disabled:!S})})}})}),e.jsx(ee,{title:s("notification.email.secure"),children:e.jsx(Q,{name:"secure",control:h,rules:{validate:j},render:({field:a})=>e.jsx(G,{fullWidth:!0,children:e.jsx(ge,{control:e.jsx(We,{checked:a.value,...a,disabled:!S})})})})}),e.jsxs(us,{children:[e.jsxs(ps,{expandIcon:e.jsx(fs,{fontSize:"small"}),"aria-controls":"panel1-content",id:"panel1-header",children:[s("notification.email.signature"),e.jsx(xt,{title:s("notification.email.signatureTooltip"),children:e.jsx(ts,{fontSize:"small",sx:{ml:1,cursor:"help"}})})]}),e.jsxs(ms,{children:[e.jsx(ee,{title:s("notification.email.companyName"),children:e.jsx(Q,{name:"companyName",control:h,rules:{validate:j},render:({field:a})=>{var m;return e.jsx(G,{fullWidth:!0,children:e.jsx(te,{...a,size:"small",error:!!i.errors[a.name],label:s("notification.email.companyName"),helperText:((m=i.errors[a.name])==null?void 0:m.message)||" ",disabled:!S})})}})}),e.jsx(ee,{title:s("notification.email.companyLink"),children:e.jsx(Q,{name:"companyLink",control:h,rules:{validate:S?c:j},render:({field:a})=>{var m;return e.jsx(G,{fullWidth:!0,children:e.jsx(te,{...a,size:"small",error:!!i.errors[a.name],label:s("notification.email.companyLink"),helperText:((m=i.errors[a.name])==null?void 0:m.message)||" ",disabled:!S})})}})}),e.jsx(ee,{title:s("notification.email.companyAddress"),children:e.jsx(Q,{name:"companyAddress",control:h,rules:{validate:j},render:({field:a})=>{var m;return e.jsx(G,{fullWidth:!0,children:e.jsx(te,{...a,size:"small",error:!!i.errors[a.name],label:s("notification.email.companyAddress"),helperText:((m=i.errors[a.name])==null?void 0:m.message)||" ",disabled:!S})})}})}),e.jsx(ee,{title:s("notification.email.supportEmail"),children:e.jsx(Q,{name:"supportEmail",control:h,rules:{validate:S?g:j},render:({field:a})=>{var m;return e.jsx(G,{fullWidth:!0,children:e.jsx(te,{...a,size:"small",type:"email",error:!!i.errors[a.name],label:s("notification.email.supportEmail"),helperText:((m=i.errors[a.name])==null?void 0:m.message)||" ",disabled:!S})})}})})]})]}),e.jsxs(T,{sx:{display:"flex",justifyContent:"flex-end",gap:2,mt:3},children:[e.jsx(me,{variant:"outlined",color:"warning",onClick:p(B),disabled:!S,children:s("oauth.runTest")}),e.jsx(me,{type:"submit",variant:"contained",disabled:!i.isDirty,children:s("oauth.save")})]})]}),o]})}const Is=ue(ht)``,ze={enabled:!1,endpoint:"",did:void 0,pushPath:void 0};function Os(){var M,J,ie;const{api:n}=Ze(),{blocklet:t}=Et(),{t:s}=re(),{confirmApi:r,confirmHolder:o}=Ct(),l=(M=t==null?void 0:t.meta)==null?void 0:M.did,y=Object.assign({...ze},((ie=(J=t==null?void 0:t.settings)==null?void 0:J.notification)==null?void 0:ie.pushKit)||{}),{handleSubmit:p,control:h,formState:i,watch:O,reset:A}=It({defaultValues:St(y,Object.keys(ze))}),R=Te({testReceiver:"",testReceiverError:""}),S=O("enabled"),D=V(async(c,g,j=!0)=>{var N,E;try{const{blocklet:P}=await n.configNotification({input:{did:l,notification:JSON.stringify({pushKit:c})}}),a=Object.assign({...ze},((E=(N=P==null?void 0:P.settings)==null?void 0:N.notification)==null?void 0:E.pushKit)||{});A(a),j&&q.success(s("oauth.saveSuccess"))}catch(P){if(j)q.error(P.message||s("oauth.saveFailed"));else throw P}}),Y=V(async(c,g)=>{var j,N,E;try{i.isDirty&&await D(c,g,!1);const P=(j=((t==null?void 0:t.configs)||[]).find($=>$.key==="BLOCKLET_APP_URL"))==null?void 0:j.value,a=Xt(Qt(P,W.WELLKNOWN_SERVICE_PATH_PREFIX,"/blocklet/logo"),{v:(N=t==null?void 0:t.meta)==null?void 0:N.version,t:new Date((t==null?void 0:t.updatedAt)||0).getTime()}),m={type:"passthrough",passthroughType:"messageStatus",data:{message:{title:"Test push-kit notification",body:"This is message from push-kit config test",sender:{did:t==null?void 0:t.appDid,fullName:(E=t==null?void 0:t.meta)==null?void 0:E.title,avatar:a}}}};await n.sendPush({input:{did:l,receiver:R.testReceiver,notification:JSON.stringify(m)}}),q.success(s("notification.pushKit.testSuccess"))}catch(P){q.error(P.message||s("notification.pushKit.testfailed"))}}),B=V((c,g)=>{R.testReceiverError="",r.open({title:s("notification.pushKit.testSend"),content:()=>e.jsx(T,{sx:{width:"450px",maxWidth:"100%"},children:e.jsx(te,{sx:{mt:1},fullWidth:!0,name:"testReceiver",label:s("notification.pushKit.inputTestReceiver"),value:R.testReceiver,onChange:j=>{R.testReceiver=j.target.value},error:!!R.testReceiverError,helperText:R.testReceiverError||" "})}),confirmButtonText:s("common.confirm"),cancelButtonText:s("common.cancel"),async onConfirm(j){var E;if(!((E=R.testReceiver)==null?void 0:E.trim())){R.testReceiverError=s("notification.pushKit.receiverRequired");return}R.testReceiverError="",await Y(c,g),j()}})}),z=V(c=>{const g=c==null?void 0:c.trim();return g?$e(g)?!0:s("notification.pushKit.endpointInvalid"):s("notification.pushKit.endpointRequired")}),_=V(()=>!0);return e.jsxs(T,{children:[e.jsxs(As,{component:"form",onSubmit:p(D),disabled:!0,sx:{".section-left":{width:"160px"}},children:[e.jsx(ee,{title:s("notification.pushKit.enable"),my:2.5,children:e.jsx(Q,{name:"enabled",control:h,render:({field:c})=>e.jsx(ge,{control:e.jsx(We,{checked:c.value,...c})})})}),e.jsx(ee,{title:s("notification.pushKit.endpoint"),children:e.jsx(Q,{name:"endpoint",control:h,rules:{validate:S?z:_},render:({field:c})=>{var g;return e.jsx(G,{fullWidth:!0,children:e.jsx(te,{...c,size:"small",required:!0,label:s("notification.pushKit.endpoint"),error:!!i.errors[c.name],helperText:((g=i.errors[c.name])==null?void 0:g.message)||" ",disabled:!S})})}})}),e.jsxs(ee,{title:s("notification.pushKit.customOptions"),children:[e.jsx(Q,{name:"did",control:h,render:({field:c})=>{var g;return e.jsx(G,{fullWidth:!0,children:e.jsx(te,{...c,size:"small",label:s("notification.pushKit.did"),error:!!i.errors[c.name],helperText:((g=i.errors[c.name])==null?void 0:g.message)||" ",disabled:!S})})}}),e.jsx(Q,{name:"pushPath",control:h,render:({field:c})=>{var g;return e.jsx(G,{fullWidth:!0,children:e.jsx(te,{...c,size:"small",label:s("notification.pushKit.pushPath"),error:!!i.errors[c.name],helperText:((g=i.errors[c.name])==null?void 0:g.message)||" ",disabled:!S})})}})]}),e.jsxs(T,{sx:{display:"flex",justifyContent:"flex-end",gap:2,mt:3},children:[e.jsx(me,{variant:"outlined",color:"warning",onClick:p(B),disabled:!S,children:s("oauth.runTest")}),e.jsx(me,{type:"submit",variant:"contained",disabled:!i.isDirty,children:s("oauth.save")})]})]}),o]})}const As=ue(ht)``,ft=[{label:e.jsx(T,{textAlign:"center",width:"100%",children:"Email"}),value:"email"},{label:e.jsx(T,{textAlign:"center",width:"100%",children:"Push Kit"}),value:"pushKit"}];function Ds(){const[n,t]=C.useState(ft[0].value),{locale:s}=C.useContext(ss),r=ce(()=>({email:e.jsx(Es,{}),pushKit:e.jsx(Os,{})}),[s]),o=C.useMemo(()=>({padding:"10px 0"}),[]);return e.jsxs(T,{children:[e.jsx(wt,{tabs:ft,current:n,onChange:t}),e.jsx(T,{style:o,children:r[n]})]})}const Pt=C.createContext({}),{Provider:Ls,Consumer:si}=Pt;function Ps({children:n,blocklet:t=""}){const{api:s,inService:r,ws:{useSubscription:o}}=Ze(),[l,y]=C.useState([]),[p,h]=C.useState({total:0,pageSize:20,pageCount:0,page:1}),i=ce(()=>{var c;return(c=t.meta)==null?void 0:c.did},[t]),[O,A]=C.useState([]),[R,S]=C.useState({}),D=ce(()=>l.length?new Set(l.map(c=>c.id)):new Set,[l]),Y=async({page:c=1,pageSize:g=20,...j}={})=>{if(!i)return[];try{const N={paging:{page:c,pageSize:g},...j,teamDid:i,dateRange:j.dateRange?[se(j.dateRange[0]).toISOString(),se(j.dateRange[1]).toISOString()]:void 0},{dids:E,...P}=N;let a="";E&&E.includes("system")&&(a="system");const m=E?E.filter(oe=>oe!=="system"):[],$={...P,source:a,componentDids:m},U=await s.getNotificationSendLog({input:$});return S($),y(U.list),h(U.paging),U.list}catch(N){return q.error(N.message),[]}},B=async()=>{const c=await s.getNotificationComponents({input:{teamDid:i}});A(c.componentDids)},z=C.useCallback(c=>{const g=t.children.find(j=>{var N;return((N=j.meta)==null?void 0:N.did)===c});if(g)return g.ancestors=[t],g},[t]),_=async({notificationId:c,receivers:g,channels:j,...N})=>{await s.resendNotification({input:{teamDid:i,notificationId:c,receivers:g,channels:j.map(E=>E==="wallet"?W.NOTIFICATION_SEND_CHANNEL.WALLET:E==="pushKit"?W.NOTIFICATION_SEND_CHANNEL.PUSH:E),...N}})},M=C.useCallback(async c=>(await s.getUser({input:{teamDid:i,user:{did:c}}})).user,[s,i]),J=C.useCallback(async({page:c=1,pageSize:g=20,...j}={})=>{try{const N={paging:{page:c,pageSize:g},...j,userName:j.searchText||"",teamDid:i,dateRange:j.dateRange?[se(j.dateRange[0]).toISOString(),se(j.dateRange[1]).toISOString()]:void 0};return await s.getReceivers({input:N})}catch(N){throw q.error(N.message),N}},[s,i]);C.useEffect(()=>{i&&B()},[i]),o(W.EVENTS.NOTIFICATION_BLOCKLET_UPDATE,c=>{D.has(c.notificationId)&&Y(R)},[D,R]),o(W.EVENTS.NOTIFICATION_BLOCKLET_CREATE,c=>{D.has(c.id)||Y(R)},[D,R]);const ie={fetch:Y,data:l,paging:p,blocklet:t,getComponent:z,resendNotification:_,getUser:M,componentDids:O,getReceivers:J,inService:r,teamDid:i};return e.jsx(Ls,{value:{notificationRecords:ie},children:n})}function tt(){const{notificationRecords:n}=C.useContext(Pt);return n}Ne.propTypes={severity:x.oneOf(Object.values(["info","success","error","warning"])).isRequired};const _s={info:"primary",success:"success",error:"error",warning:"warning"};function Ne({severity:n="info"}){return e.jsx(ns,{type:_s[n],children:n})}var st={},ks=Je;Object.defineProperty(st,"__esModule",{value:!0});var _t=st.default=void 0,Fs=ks(Qe()),zs=e;_t=st.default=(0,Fs.default)((0,zs.jsx)("path",{d:"M16.59 7.58 10 14.17l-3.59-3.58L5 12l5 5 8-8zM12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2m0 18c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8"}),"CheckCircleOutline");var nt={},Bs=Je;Object.defineProperty(nt,"__esModule",{value:!0});var kt=nt.default=void 0,Ws=Bs(Qe()),Ks=e;kt=nt.default=(0,Ws.default)((0,Ks.jsx)("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2M4 12c0-4.42 3.58-8 8-8 1.85 0 3.55.63 4.9 1.69L5.69 16.9C4.63 15.55 4 13.85 4 12m8 8c-1.85 0-3.55-.63-4.9-1.69L18.31 7.1C19.37 8.45 20 10.15 20 12c0 4.42-3.58 8-8 8"}),"Block");var it={},qs=Je;Object.defineProperty(it,"__esModule",{value:!0});var Ft=it.default=void 0,Ms=qs(Qe()),$s=e;Ft=it.default=(0,Ms.default)((0,$s.jsx)("path",{d:"M17.65 6.35C16.2 4.9 14.21 4 12 4c-4.42 0-7.99 3.58-7.99 8s3.57 8 7.99 8c3.73 0 6.84-2.55 7.73-6h-2.08c-.82 2.33-3.04 4-5.65 4-3.31 0-6-2.69-6-6s2.69-6 6-6c1.66 0 3.14.69 4.22 1.78L13 11h7V4z"}),"Refresh");const Us=(n,t,s="")=>{if(!s||!t)return"";switch(s){case W.NOTIFICATION_SEND_FAILED_REASON.USER_DISABLED:return n("notification.sendStatus.reason.disabled",{channel:t});case W.NOTIFICATION_SEND_FAILED_REASON.CHANNEL_UNAVAILABLE:return n("notification.sendStatus.reason.unavailable",{channel:t});case W.NOTIFICATION_SEND_FAILED_REASON.CHANNEL_DISABLED:return n("notification.sendStatus.reason.notSent",{channel:t});case W.NOTIFICATION_SEND_FAILED_REASON.NOT_ONLINE:return n("notification.sendStatus.reason.offline");default:return s}};function zt(n,t,s={}){const{status:r,updatedAt:o,reason:l="",channel:y="wallet"}=s,p=o?n("notification.sendStatus.sentTime",{date:os(o,t)}):"",h=Us(n,y,l);return r===W.NOTIFICATION_SEND_STATUS.FAILED?{status:"failed",title:n("notification.sendStatus.failed"),sentTime:p,reason:h}:r===W.NOTIFICATION_SEND_STATUS.SENT?{status:"success",title:n("notification.sendStatus.success"),sentTime:p}:{status:"pending",title:n("notification.sendStatus.pending"),reason:h,sentTime:p}}const Ge={pending:"#aaaaaa",success:"#34BE74",failed:"#D0021B"},Ye=["wallet","pushKit","email"],mt=["info","success","error","warning"],Bt=n=>{var s,r;const{settings:t}=n;return(r=(s=t==null?void 0:t.notification)==null?void 0:s.email)==null?void 0:r.enabled},Wt=n=>{var s,r;const{settings:t}=n;return(r=(s=t==null?void 0:t.notification)==null?void 0:s.pushKit)==null?void 0:r.enabled},Hs=(n,t)=>{const s=fe(t,"extra.notifications.email",!0);return{available:Bt(n),enabled:s}},Vs=(n,t)=>{const s=fe(t,"extra.notifications.push",!0);return{available:Wt(n),enabled:s}},Gs=n=>({enabled:fe(n,"extra.notifications.wallet",!0)}),Ys=n=>({enabled:fe(n,"extra.webhooks",[]).length>0}),Ee=(n=3)=>new Promise(t=>{setTimeout(()=>{t()},n*1e3)}),Js=(n,t)=>t==="wallet"||t==="webhook"?[{channel:t,type:"enabled",pass:n("notification.sendStatus.reason.enabled",{channel:t}),fail:n("notification.sendStatus.reason.disabled",{channel:t})}]:t==="pushKit"||t==="email"?[{channel:t,type:"available",pass:n("notification.sendStatus.reason.available",{channel:t}),fail:n("notification.sendStatus.reason.unavailable",{channel:t})},{channel:t,type:"enabled",pass:n("notification.sendStatus.reason.enabled",{channel:t}),fail:n("notification.sendStatus.reason.disabled",{channel:t})}]:[],Ie=(n=[])=>{const t=se().startOf("day");return n.filter(s=>se(s.sendAt).isSame(t,"day")).length},Xs=(n,t="")=>{if(t&&Ye.includes(t)){const l=`${t}SendRecord`,y=fe(n,l,[]);return Ie(y)}const s=fe(n,"webhook",{}),r=Object.keys(s??{})??[];if(t&&r.includes(t)){const l=s[t]??[];return Ie(l)}const o={};return Ye.forEach(l=>{const y=`${l}SendRecord`,p=fe(n,y,[]),h=Ie(p);o[l]=h}),r.length>0&&r.forEach(l=>{const y=s[l]??[],p=Ie(y);o[l]=p}),o},Ae=(n,t,s)=>{if(!Array.isArray(n))throw new Error("Invalid filterList or index");return n[s].splice(t,1),n},De=(n,t)=>{if(!Array.isArray(t))throw new Error("filters must be an array");return t.length?!t.includes(n):!1},Qs=n=>{switch(n){case W.NOTIFICATION_SEND_CHANNEL.WALLET:return"Wallet";case W.NOTIFICATION_SEND_CHANNEL.PUSH:return"Push Kit";case W.NOTIFICATION_SEND_CHANNEL.EMAIL:return"Email";case W.NOTIFICATION_SEND_CHANNEL.WEBHOOK:return"Webhook";default:return""}},Kt=()=>({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 de({config:n,enableTooltip:t=!0,showTitle:s=!1,children:r}){const{status:o,title:l="",sentTime:y="",reason:p=""}=n,h=[l,p].filter(Boolean).join(", ");return e.jsx(xt,{title:t?e.jsxs(e.Fragment,{children:[e.jsx(ae,{color:"inherit",sx:{fontSize:12},children:h}),e.jsx("span",{children:y})]}):null,arrow:!0,placement:"top",children:e.jsxs(T,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"4px"},children:[e.jsxs(T,{position:"relative",minHeight:14,minWidth:14,display:"flex",alignItems:"center",justifyContent:"center",children:[e.jsx(T,{position:"absolute",width:"100%",height:"100%",borderRadius:"50%",bgcolor:Ge[o],style:{opacity:.15}}),e.jsx(T,{position:"absolute",width:"55%",height:"55%",borderRadius:"50%",bgcolor:Ge[o]})]}),e.jsx(ae,{color:"inherit",sx:{fontSize:12},children:s?l:r})]})})}de.propTypes={config:x.object.isRequired,enableTooltip:x.bool,showTitle:x.bool,children:x.node};de.defaultProps={enableTooltip:!0,showTitle:!1,children:null};Se.propTypes={list:x.array.isRequired,label:x.string.isRequired,onDelete:x.func};Se.defaultProps={onDelete:()=>{}};function Se({list:n,label:t,onDelete:s}){const{t:r,locale:o}=re();return e.jsxs(T,{display:"flex",gap:1,alignItems:"center",children:[e.jsxs(ae,{children:[t,": "]}),n.map(l=>{const y=zt(r,o,{status:l});return e.jsx(Xe,{size:"small",label:e.jsx(T,{display:"flex",alignItems:"center",sx:{gap:"4px"},children:e.jsx(de,{config:y,enableTooltip:!1,children:y.title})}),onDelete:p=>s(p,l)},l)})]})}at.propTypes={filterList:x.array.isRequired,onChange:x.func.isRequired,index:x.number.isRequired,column:x.object.isRequired,filterValues:x.array.isRequired,label:x.string.isRequired,renderLabel:x.func.isRequired};function at({filterList:n,onChange:t,index:s,column:r,filterValues:o,label:l,renderLabel:y}){return e.jsxs(G,{className:"filter-container",children:[e.jsx(gt,{component:"legend",children:l}),e.jsx(Ke,{row:!0,children:o.map(p=>e.jsx(ge,{control:e.jsx(qe,{checked:n[s].indexOf(p.value??p)>-1,onChange:h=>{const i=[...n];h.target.checked?i[s]=[...i[s],p.value??p]:i[s]=i[s].filter(O=>O!==(p.value??p)),t(i[s],s,r)},name:p.value??p}),label:e.jsx("span",{style:{display:"flex",alignItems:"center"},children:y(p)})},p.value??p))})]})}function Be(n){return e.jsx(at,{...n,renderLabel:t=>e.jsx(de,{enableTooltip:!1,config:{status:t.status},children:t.label})})}ve.propTypes={status:x.number.isRequired,updatedAt:x.string.isRequired,reason:x.string,channel:x.string,onResend:x.func};function ve({status:n,updatedAt:t,reason:s="",channel:r="wallet",onResend:o}){const{t:l,locale:y}=re(),p=zt(l,y,{status:n,updatedAt:t,reason:s,channel:r});return e.jsxs(T,{display:"flex",alignItems:"center",gap:1,children:[e.jsx(de,{config:p,showTitle:!0}),p.status!=="success"&&e.jsx(Le,{className:"resend-btn",size:"small",startIcon:e.jsx(et,{}),sx:{fontSize:12,color:"rgba(0, 0, 0, 0.87)",fontWeight:400,".MuiButton-startIcon":{mr:"2px"}},onClick:o,children:l("notification.resend")})]})}rt.propTypes={value:x.array.isRequired,onChange:x.func};function rt({value:n,onChange:t}){const{locale:s}=re(),r=se().toDate(),[o,l]=C.useState(null),y=C.useCallback(i=>{l(o?null:i.currentTarget)},[o]),p=!!o,h=C.useCallback(i=>{if(!i.startDate||!i.endDate){q.error("Please select a date range");return}if(se(i.startDate).isAfter(i.endDate)||!se(i.startDate).isValid()||!se(i.endDate).isValid()){q.error("Invalid date range");return}t([i.startDate,i.endDate]),l(null)},[t]);return e.jsxs("div",{children:[e.jsx(ae,{component:"div",variant:"h5",color:"textPrimary",style:{fontSize:18,fontWeight:"bold"},mb:0,children:e.jsxs(Le,{onClick:y,variant:"outlined",size:"small",color:"inherit",children:[pt(n[0],s)," - ",pt(n[1],s)]})}),e.jsx(Me,{open:p,anchorEl:o,onClose:()=>{l(null)},anchorOrigin:{vertical:"bottom",horizontal:"left"},children:e.jsx(ys,{open:!0,maxDate:r,initialDateRange:{startDate:n[0],endDate:n[1]},toggle:y,definedRanges:Ss(r),onChange:h})})]})}ot.propTypes={itemComponent:x.elementType.isRequired};function ot({itemComponent:n,...t}){var o;const{t:s}=re();return!((o=t==null?void 0:t.filterList)!=null&&o.filter(l=>l.length).length)?null:e.jsxs(T,{display:"flex",gap:1,alignItems:"center",children:[e.jsx("div",{className:"toolbar-filter-title",children:s("notification.filter")}),e.jsx("div",{className:"toolbar-filter-content",children:e.jsx(is.TableFilterList,{...t,ItemComponent:n})})]})}function Pe({label:n,onDelete:t,canDelete:s=()=>!0,...r}){const o=t&&typeof t=="function"?t:void 0;let l=!0;return s&&typeof s=="function"&&(l=s({label:n,...r})),e.jsx(Xe,{label:n,variant:"outlined",...o&&l?{onDelete:o}:{}})}Pe.propTypes={label:x.string.isRequired,onDelete:x.func,canDelete:x.func};Pe.defaultProps={canDelete:()=>!0};const Zs=[{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}];lt.propTypes={loading:x.bool,onCancel:x.func,onConfirm:x.func};lt.defaultProps={loading:!1,onCancel:()=>{},onConfirm:()=>{}};function lt({loading:n=!1,onCancel:t,onConfirm:s}){const{t:r}=re(),[o,l]=C.useState(Zs),[y,p]=C.useState(!0),h=(O,A)=>{A.checked=O.target.checked;const R=o.map(S=>({...S,checked:S.value===A.value?A.checked:S.checked}));l(R)},i=O=>{O.stopPropagation(),s({channels:o.filter(A=>A.checked).map(A=>A.value),isResendFailedOnly:y})};return e.jsxs(T,{className:"resend-config",sx:{padding:"16px 24px"},children:[e.jsx(ae,{variant:"body1",component:"div",className:"check-title",sx:{fontWeight:700,mb:1},children:r("notification.config")}),e.jsx(T,{className:"choose-channel",children:e.jsxs(G,{component:"fieldset",variant:"standard",children:[e.jsx(gt,{component:"legend",children:r("notification.selectChannels")}),e.jsx(Ke,{sx:{display:"flex",flexDirection:"row",flexWrap:"wrap",gap:1},children:o.map(O=>e.jsx(ge,{control:e.jsx(qe,{checked:O.checked,onChange:A=>h(A,O),name:O.value}),label:O.label},O.value))})]})}),e.jsx(T,{className:"resend-config-footer",children:e.jsx(Ke,{children:e.jsx(ge,{control:e.jsx(qe,{checked:y,onChange:O=>p(O.target.checked)}),label:r("notification.resendFailedOnly")})})}),e.jsxs(T,{display:"flex",justifyContent:"flex-end",gap:1,className:"resend-config-footer-tip",children:[e.jsx(Le,{onClick:O=>{O.stopPropagation(),t()},color:"inherit",children:r("common.cancel")}),e.jsxs(Le,{onClick:i,color:"primary",disabled:n,variant:"contained",autoFocus:!0,style:{marginLeft:8},children:[n&&e.jsx(bt,{size:16}),r("common.confirm")]})]})]})}qt.propTypes={notificationId:x.string.isRequired,handleResend:x.func,resending:x.bool};function qt({notificationId:n,handleResend:t,resending:s=!1}){const{t:r,locale:o}=re(),l=jt(),y=C.useMemo(()=>vt(l,Kt()),[l]),{getReceivers:p,inService:h,teamDid:i,getUser:O,blocklet:A}=tt(),[R,S]=C.useState(!1),[D,Y]=C.useState([]),B=Te({anchorEl:null,position:null}),z=Te({anchorEl:null,position:null}),[_,M]=C.useState(null),[J,ie]=C.useState({total:0,pageSize:10,pageCount:0,page:1}),[c,g]=C.useState({searchText:"",page:1,pageSize:10,walletSendStatus:[],pushKitSendStatus:[],emailSendStatus:[],dateRange:[se().subtract(1,"month").startOf("day").toDate(),se().endOf("day").toDate()]}),[j,N]=C.useState([]),E=[{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"}],P=async()=>{if(!R&&n)try{S(!0);const d=await p({notificationId:n,...c}),u=d.list.map(f=>({...f,receiverUser:{...f.receiverUser,avatar:Dt(f.receiverUser.avatar,i,h)}}));Y(u),ie(d.paging),S(!1)}catch(d){q.error(d.message),S(!1)}};C.useEffect(()=>{P()},[c]);const a=d=>{d.stopPropagation();const u=d.currentTarget;z.anchorEl=u;const f=u.getBoundingClientRect();z.position={top:f.top+window.scrollY,left:f.left+window.scrollX}},m=d=>d.data.length?e.jsx("div",{style:{display:"flex",alignItems:"center",padding:"10px"},children:e.jsx(me,{className:"resend-btn",size:"small",color:"primary",variant:"contained",startIcon:e.jsx(et,{}),sx:{".MuiButton-startIcon":{mr:"2px"}},onClick:a,children:r("notification.resend")})}):null,$={sort:!1,download:!1,print:!1,selectableRows:"multiple",searchPlaceholder:r("common.search"),searchAlwaysOpen:!1,filterType:"checkbox",searchDebounceTime:300,page:J.page-1,rowsPerPage:J.pageSize,count:J.total,searchText:c.searchText,tableBodyMaxHeight:"calc(80vh - 260px)",rowsSelected:j,onRowSelectionChange:(d,u)=>{N(u.map(f=>f.dataIndex))},customToolbarSelect:m},U=({page:d,rowsPerPage:u,searchText:f,filterList:L})=>{const[,K=[],Z=[],X=[]]=L;c.pageSize!==u?g(H=>({...H,pageSize:u,page:1})):c.page!==d+1?g(H=>({...H,page:d+1})):c.searchText!==f?g(H=>({...H,searchText:f,page:1})):ye(K,c.walletSendStatus)?ye(Z,c.pushKitSendStatus)?ye(X,c.emailSendStatus)||g(H=>({...H,emailSendStatus:X,page:1})):g(H=>({...H,pushKitSendStatus:Z,page:1})):g(H=>({...H,walletSendStatus:K,page:1}))},oe=C.useCallback(async(d,u)=>{if(!u)return!1;const f=await O(u);return f?d==="wallet"?Gs(f):d==="email"?Hs(A,f):d==="pushKit"?Vs(A,f):d==="webhook"?Ys(f):!0:!1},[O,A]),le=C.useCallback(d=>Js(r,d),[r]),pe=()=>{B.anchorEl=null,B.position=null,M(null)},be=()=>{z.anchorEl=null,z.position=null},je=async(d,u,f=!0,L="")=>{if(!(!u.length||!d.length))try{t(d,u,f,L),z.anchorEl||(await Ee(.5),pe())}catch(K){console.error("handleResend error",{error:K})}},v=async({channels:d,isResendFailedOnly:u})=>{const f=j.map(L=>D[L].receiver);await je(d,f,u),await Ee(.5),be(),N([])},b=async(d,u=[],f=!0)=>{try{await je(["webhook"],[d.receiver],f,u)}catch(L){q.error(L.response?L.response.statusText:L.message)}},w=async(d,u,f,L=[],K=!0)=>{if(d.stopPropagation(),Xs(u,f)>=4){q.warning(r("notification.resendLimit"));return}if(!Ye.includes(f)){await b(u,L,K);return}if(d){const X=d.currentTarget,H=X.getBoundingClientRect();B.anchorEl=X,B.position={top:H.top+window.scrollY,left:H.left+window.scrollX}}M({channel:f});try{const X=await oe(f,u.receiver);await Ee(1),M({channel:f,result:X}),(typeof X=="boolean"&&X||Zt(X)&&Object.values(X).every(H=>!!H))&&(await t([f],[u.receiver],K),z.anchorEl||(await Ee(.5),pe()))}catch(X){q.error(X.message)}},I=d=>{g(u=>({...u,dateRange:d,page:1}))},k=(d,u,f,L)=>{d.stopPropagation();const K=f.filter(Z=>Z!==u);g(Z=>({...Z,[L]:K,page:1}))},F=ce(()=>[{label:r("notification.receiver"),name:"receiver",width:200,options:{filter:!1,customBodyRenderLite:d=>{const{receiverUser:u,receiver:f}=D[d];return u?e.jsxs(T,{"data-cy":`member-name-${u.fullName}`,display:"flex",alignItems:"center",gap:1,justifyContent:"flex-start",children:[e.jsx(Tt,{src:`${u.avatar}?imageFilter=resize&w=48&h=48`,size:32,did:f,shape:"circle",style:{borderRadius:"100%",overflow:"hidden"}}),e.jsx(Re,{children:u.fullName})]},f):e.jsx(vs,{size:14,responsive:!1,compact:!0,copyable:!1,did:f})}}},{label:"Wallet",name:"walletSendStatus",width:200,options:{setCellProps:()=>({className:"sent-status-cell"}),filter:!0,filterType:"custom",filterList:c.walletSendStatus??[],customFilterListOptions:{render:d=>e.jsx(Se,{list:d,label:"Wallet",onDelete:(u,f)=>{u.stopPropagation(),k(u,f,F[1].options.filterList,"walletSendStatus")}}),update:Ae},filterOptions:{names:E,fullWidth:!0,logic:De,display:(d,u,f,L)=>e.jsx(Be,{label:"Wallet",filterList:d,onChange:u,index:f,column:L,filterValues:E})},customBodyRenderLite:d=>{const{walletSendStatus:u,walletSendAt:f,walletSendFailedReason:L}=D[d];return e.jsx(ve,{status:u,updatedAt:f,reason:L,channel:"wallet",onResend:K=>w(K,D[d],"wallet",[],!1)})}}},{label:"Push Kit",name:"pushKitSendStatus",width:200,options:{setCellProps:()=>({className:"sent-status-cell"}),customBodyRenderLite:d=>{const{pushKitSendStatus:u,pushKitSendAt:f,pushKitSendFailedReason:L}=D[d];return e.jsx(ve,{status:u,updatedAt:f,reason:L,channel:"pushkit",onResend:K=>w(K,D[d],"pushKit",[],!1)})},filter:!0,filterType:"custom",filterList:c.pushKitSendStatus??[],customFilterListOptions:{render:d=>e.jsx(Se,{list:d,label:"Push Kit",onDelete:(u,f)=>{u.stopPropagation(),k(u,f,F[2].options.filterList,"pushKitSendStatus")}}),update:Ae},filterOptions:{names:E,fullWidth:!0,logic:De,display:(d,u,f,L)=>e.jsx(Be,{label:"Push Kit",filterList:d,onChange:u,index:f,column:L,filterValues:E})}}},{label:"Email",name:"emailSendStatus",width:200,options:{setCellProps:()=>({className:"sent-status-cell"}),customBodyRenderLite:d=>{const{emailSendStatus:u,emailSendAt:f,emailSendFailedReason:L}=D[d];return e.jsx(ve,{status:u,updatedAt:f,reason:L,channel:"email",onResend:K=>w(K,D[d],"email",[],!1)})},filter:!0,filterType:"custom",filterList:c.emailSendStatus??[],customFilterListOptions:{render:d=>e.jsx(Se,{list:d,label:"Email",onDelete:(u,f)=>{u.stopPropagation(),k(u,f,F[3].options.filterList,"emailSendStatus")}}),update:Ae},filterOptions:{names:E,fullWidth:!0,logic:De,display:(d,u,f,L)=>e.jsx(Be,{label:"Email",filterList:d,onChange:u,index:f,column:L,filterValues:E})}}},{label:"Webhook",name:"webhook",width:200,options:{filter:!1,setCellProps:()=>({className:"sent-status-cell"}),customBodyRenderLite:d=>{const{webhook:u}=D[d];if(!u)return null;const f=Object.entries(u)[0];if(!f)return null;const[L,K]=f,Z=K[0];return e.jsx(T,{display:"flex",flexDirection:"column",gap:1,children:e.jsxs(T,{className:"webhook-item",fontSize:12,children:[e.jsx(Re,{maxLength:30,children:L},L),e.jsx(ve,{status:Z.status,updatedAt:Z.sendAt,reason:Z.failedReason,channel:"webhook",onResend:X=>w(X,D[d],"webhook",[L],!1)})]},L)})}}},{label:r("common.createdAt"),name:"createdAt",width:100,options:{filter:!1,customBodyRenderLite:d=>{const{createdAt:u}=D[d];return e.jsx(At,{value:u,locale:o,shouldUpdate:!0})}}}],[D,o,c,r]),ne=[e.jsx(rt,{value:c.dateRange,onChange:I},"date-picker"),e.jsx(me,{variant:"contained",size:"small",color:"primary",loading:R,startIcon:e.jsx(Ft,{}),onClick:()=>P(),sx:{".MuiButton-startIcon":{mr:"2px"}},style:{marginLeft:8},children:r("common.refresh")},"refresh")];return e.jsx(T,{sx:{overflow:"auto",".MuiTableCell-head":{whiteSpace:"nowrap",fontWeight:"bold"},".MuiTableCell-root":{paddingRight:"8px",whiteSpace:"nowrap"}},children:e.jsx(tn,{children:e.jsxs(yt,{theme:y,children:[e.jsx(Rt,{className:"receivers-table",locale:o,loading:R,columns:F,data:D,onChange:U,options:$,customButtons:ne,components:{TableFilterList:d=>e.jsx(ot,{...d,itemComponent:u=>e.jsx(Pe,{...u,canDelete:()=>!1})})}}),B.anchorEl&&e.jsx(Me,{open:!!B.anchorEl,anchorReference:"anchorPosition",anchorPosition:B.position,onClose:pe,anchorOrigin:{vertical:"center",horizontal:"right"},transformOrigin:{vertical:"center",horizontal:"left"},children:e.jsxs(sn,{children:[e.jsxs(ae,{variant:"body1",component:"div",className:"check-title",children:[_==null?void 0:_.channel," Checking"]}),e.jsx(T,{display:"flex",flexDirection:"column",sx:{gap:"4px"},children:le(_==null?void 0:_.channel).map(d=>{var K,Z;const{type:u,pass:f,fail:L}=d;return!(_!=null&&_.result)||(K=_==null?void 0:_.result)!=null&&K[u]?e.jsxs(ae,{variant:"body1",component:"div",className:"check-item",display:"flex",alignItems:"center",sx:{gap:"4px",color:(Z=_==null?void 0:_.result)!=null&&Z[u]?Oe.success.main:"inherit"},children:[_!=null&&_.result?e.jsx(_t,{}):e.jsx(bt,{size:12,sx:{color:Oe.primary.main}}),e.jsx("span",{children:f})]},u):e.jsxs(ae,{variant:"body1",component:"div",display:"flex",alignItems:"center",className:"check-item",sx:{gap:"4px",color:Oe.error.main},children:[e.jsx(kt,{}),e.jsx("span",{children:L})]},u)})})]})}),z.anchorEl&&e.jsx(Me,{open:!!z.anchorEl,anchorReference:"anchorPosition",anchorPosition:z.position,onClose:be,anchorOrigin:{vertical:"center",horizontal:"right"},transformOrigin:{vertical:"center",horizontal:"left"},children:e.jsx(lt,{loading:s,onCancel:be,onConfirm:v})})]})})})}const en=C.memo(qt),tn=ue.div`
2
2
  td.MuiTableCell-footer {
3
3
  border: none !important;
4
4
  }
@@ -27,7 +27,7 @@ import{g as Ut,r as C}from"./vendor-react-DEoibe3W.js";import{ah as ue,al as ht,
27
27
  }
28
28
  font-size: 12px;
29
29
  }
30
- `,Ce=n=>n>=1e6?`${(n/1e6).toFixed(1)}M`:n>=1e3?`${(n/1e3).toFixed(1)}K`:n;function nn(n){const{wallet:t,push:s,email:r,webhook:o}=n;return[{name:"Wallet",value:e.jsx(he,{item:t})},{name:"Push",value:e.jsx(he,{item:s})},{name:"Email",value:e.jsx(he,{item:r})},...o.total>0?[{name:"Webhook",value:e.jsx(he,{item:o,isWebhook:!0})}]:[]]}function an(n,t,s){const{wallet:r,push:o,email:l,webhook:y}=n;return[{name:"Wallet",value:e.jsx(xe,{loading:s,channel:W.NOTIFICATION_SEND_CHANNEL.WALLET,item:r,onResend:t})},{name:"Push",value:e.jsx(xe,{loading:s,channel:W.NOTIFICATION_SEND_CHANNEL.PUSH,item:o,onResend:t})},{name:"Email",value:e.jsx(xe,{loading:s,channel:W.NOTIFICATION_SEND_CHANNEL.EMAIL,item:l,onResend:t})},...y.total>0?[{name:"Webhook",value:e.jsx(xe,{loading:s,channel:W.NOTIFICATION_SEND_CHANNEL.WEBHOOK,item:y,isWebhook:!0,onResend:t})}]:[]]}_e.propTypes={statistics:x.object.isRequired,onResend:x.func,mode:x.oneOf(["simple","detail"]),resending:x.bool};_e.defaultProps={mode:"simple",onResend:()=>{},resending:!1};he.propTypes={item:x.object.isRequired,isWebhook:x.bool};he.defaultProps={isWebhook:!1};function he({item:n,isWebhook:t=!1}){const{t:s}=re(),r=t?n.success.length:n.success,o=n.total,l=r===o?"success":"failed";return e.jsx(T,{display:"flex",alignItems:"center",justifyContent:"flex-start",gap:2,children:e.jsx(T,{display:"flex",alignItems:"center",gap:1,children:e.jsxs(de,{config:{status:l},enableTooltip:!1,children:[Ce(r)," / ",Ce(o)," ",s("notification.sendStatus.success")]})})})}xe.propTypes={item:x.object.isRequired,isWebhook:x.bool,channel:x.string,onResend:x.func,loading:x.bool};xe.defaultProps={isWebhook:!1,channel:W.NOTIFICATION_SEND_CHANNEL.WALLET,onResend:()=>{},loading:!1};function xe({channel:n,item:t,isWebhook:s=!1,onResend:r,loading:o}){const{t:l}=re(),{success:y,failed:p,pending:h}=t,i=Qs(n),A=s?y.length:y,O=s?p.length:p,R=s?h.length:h,S=async B=>{B.stopPropagation();const _=s?[...new Set([...y,...p].map(M=>M))]:[];await r([n],[],!0,_)},D=A+O,G=D>0?A/D*100:0,z=D>0?O/D*100:0;return e.jsxs(rn,{successRatio:G,failedRatio:z,children:[e.jsxs(ae,{variant:"h6",children:[i," (",t.total,")"]}),e.jsxs(ae,{variant:"body1",sx:{mb:2},children:[e.jsx("span",{style:{color:Ye.success,fontWeight:600,fontSize:24},children:Ce(A)}),e.jsx("small",{style:{paddingLeft:4},children:l("notification.sendStatus.success")})]}),e.jsxs(T,{className:"unsent-area",children:[e.jsxs(T,{children:[e.jsxs(de,{config:{status:"failed"},enableTooltip:!1,children:[Ce(O)," ",l("notification.sendStatus.failed")]}),e.jsxs(de,{config:{status:"pending"},enableTooltip:!1,children:[Ce(R)," ",l("notification.sendStatus.pending")]})]}),O>0&&e.jsx(T,{className:"resend-btn",children:e.jsx(me,{size:"small",color:"primary",loading:o,variant:"contained",startIcon:e.jsx(et,{}),sx:{".MuiButton-startIcon":{mr:"2px"}},onClick:S,children:l("notification.resend")})})]})]})}function _e({statistics:n,mode:t="simple",onResend:s,resending:r}){const o=ce(()=>t==="simple"?nn(n):an(n,s,r),[n,t]);return t==="simple"?e.jsx("div",{children:o.map(l=>e.jsx(At,{style:{alignItems:"flex-start",marginBottom:t==="simple"?0:16},valueComponent:"div",nameWidth:100,name:l.name,children:l.value},l.name))}):e.jsx(dt,{container:!0,spacing:2,children:o.map(l=>e.jsx(dt,{item:!0,md:4,sm:6,xs:12,children:l.value},l.name))})}const rn=ue(T)`
30
+ `,Ce=n=>n>=1e6?`${(n/1e6).toFixed(1)}M`:n>=1e3?`${(n/1e3).toFixed(1)}K`:n;function nn(n){const{wallet:t,push:s,email:r,webhook:o}=n;return[{name:"Wallet",value:e.jsx(he,{item:t})},{name:"Push",value:e.jsx(he,{item:s})},{name:"Email",value:e.jsx(he,{item:r})},...o.total>0?[{name:"Webhook",value:e.jsx(he,{item:o,isWebhook:!0})}]:[]]}function an(n,t,s){const{wallet:r,push:o,email:l,webhook:y}=n;return[{name:"Wallet",value:e.jsx(xe,{loading:s,channel:W.NOTIFICATION_SEND_CHANNEL.WALLET,item:r,onResend:t})},{name:"Push",value:e.jsx(xe,{loading:s,channel:W.NOTIFICATION_SEND_CHANNEL.PUSH,item:o,onResend:t})},{name:"Email",value:e.jsx(xe,{loading:s,channel:W.NOTIFICATION_SEND_CHANNEL.EMAIL,item:l,onResend:t})},...y.total>0?[{name:"Webhook",value:e.jsx(xe,{loading:s,channel:W.NOTIFICATION_SEND_CHANNEL.WEBHOOK,item:y,isWebhook:!0,onResend:t})}]:[]]}_e.propTypes={statistics:x.object.isRequired,onResend:x.func,mode:x.oneOf(["simple","detail"]),resending:x.bool};_e.defaultProps={mode:"simple",onResend:()=>{},resending:!1};he.propTypes={item:x.object.isRequired,isWebhook:x.bool};he.defaultProps={isWebhook:!1};function he({item:n,isWebhook:t=!1}){const{t:s}=re(),r=t?n.success.length:n.success,o=n.total,l=r===o?"success":"failed";return e.jsx(T,{display:"flex",alignItems:"center",justifyContent:"flex-start",gap:2,children:e.jsx(T,{display:"flex",alignItems:"center",gap:1,children:e.jsxs(de,{config:{status:l},enableTooltip:!1,children:[Ce(r)," / ",Ce(o)," ",s("notification.sendStatus.success")]})})})}xe.propTypes={item:x.object.isRequired,isWebhook:x.bool,channel:x.string,onResend:x.func,loading:x.bool};xe.defaultProps={isWebhook:!1,channel:W.NOTIFICATION_SEND_CHANNEL.WALLET,onResend:()=>{},loading:!1};function xe({channel:n,item:t,isWebhook:s=!1,onResend:r,loading:o}){const{t:l}=re(),{success:y,failed:p,pending:h}=t,i=Qs(n),O=s?y.length:y,A=s?p.length:p,R=s?h.length:h,S=async z=>{z.stopPropagation();const _=s?[...new Set([...y,...p].map(M=>M))]:[];await r([n],[],!0,_)},D=O+A,Y=D>0?O/D*100:0,B=D>0?A/D*100:0;return e.jsxs(rn,{successRatio:Y,failedRatio:B,children:[e.jsxs(ae,{variant:"h6",children:[i," (",t.total,")"]}),e.jsxs(ae,{variant:"body1",sx:{mb:2},children:[e.jsx("span",{style:{color:Ge.success,fontWeight:600,fontSize:24},children:Ce(O)}),e.jsx("small",{style:{paddingLeft:4},children:l("notification.sendStatus.success")})]}),e.jsxs(T,{className:"unsent-area",children:[e.jsxs(T,{children:[e.jsxs(de,{config:{status:"failed"},enableTooltip:!1,children:[Ce(A)," ",l("notification.sendStatus.failed")]}),e.jsxs(de,{config:{status:"pending"},enableTooltip:!1,children:[Ce(R)," ",l("notification.sendStatus.pending")]})]}),A>0&&e.jsx(T,{className:"resend-btn",children:e.jsx(me,{size:"small",color:"primary",loading:o,variant:"contained",startIcon:e.jsx(et,{}),sx:{".MuiButton-startIcon":{mr:"2px"}},onClick:S,children:l("notification.resend")})})]})]})}function _e({statistics:n,mode:t="simple",onResend:s,resending:r}){const o=ce(()=>t==="simple"?nn(n):an(n,s,r),[n,t]);return t==="simple"?e.jsx("div",{children:o.map(l=>e.jsx(Ot,{style:{alignItems:"flex-start",marginBottom:t==="simple"?0:16},valueComponent:"div",nameWidth:100,name:l.name,children:l.value},l.name))}):e.jsx(dt,{container:!0,spacing:2,children:o.map(l=>e.jsx(dt,{item:!0,md:4,sm:6,xs:12,children:l.value},l.name))})}const rn=ue(T)`
31
31
  display: flex;
32
32
  flex-direction: column;
33
33
  align-items: flex-start;
@@ -45,7 +45,7 @@ import{g as Ut,r as C}from"./vendor-react-DEoibe3W.js";import{ah as ue,al as ht,
45
45
  bottom: 0;
46
46
  }
47
47
  }
48
- `;Mt.propTypes={notification:x.object.isRequired,onCancel:x.func,blocklet:x.object.isRequired,tab:x.string};function Mt({notification:n,onCancel:t=()=>{},blocklet:s,tab:r="info"}){const{t:o,locale:l}=re(),{getComponent:y,resendNotification:p}=tt(),[h,i]=C.useState(!1),A=ce(()=>y(n.componentDid)||s,[s,n.componentDid]),O=Te({tab:r||"info"}),R=C.useCallback(async(c,g,j=!0,N=[])=>{var a;if(!c.length||!n.id)return;const E=g.length>0?g:(a=n==null?void 0:n.receivers)==null?void 0:a.map(m=>m.receiver);if(!E.length)return;let P=[...c];if(P.includes(W.NOTIFICATION_SEND_CHANNEL.PUSH)&&!Wt(s)&&(q.warning(o("notification.sendStatus.reason.unavailable",{channel:"Push Kit"})),P=P.filter(m=>m!==W.NOTIFICATION_SEND_CHANNEL.PUSH)),P.includes(W.NOTIFICATION_SEND_CHANNEL.EMAIL)&&!zt(s)&&(q.warning(o("notification.sendStatus.reason.unavailable",{channel:"Email"})),P=P.filter(m=>m!==W.NOTIFICATION_SEND_CHANNEL.EMAIL)),!!P.length)try{i(!0),await p({notificationId:n.id,receivers:E,channels:P,resendFailedOnly:j,...P.includes("webhook")&&N.length?{webhookUrls:N}:{}}),q.success("Message has been sent!")}catch(m){console.error("handleResend error",{error:m}),q.error(m.response?m.response.statusText:m.message)}finally{i(!1)}},[s,n.id,n==null?void 0:n.receivers,p,o]),S=ce(()=>cs(n),[n]),D=ce(()=>ds(n),[n]),G=ce(()=>S?n==null?void 0:n.actorInfo:[],[n]),z=ce(()=>{var c;return(s==null?void 0:s.did)||((c=s==null?void 0:s.meta)==null?void 0:c.did)||""},[s]);function B(){return[{name:o("notification.from"),value:S&&D?e.jsx(hs,{actors:G,teamDid:z,size:32,showName:!0}):e.jsx(xs,{size:32,blocklet:A,showName:!0,hideDot:!0})},{name:o("notification.notificationTitle"),value:e.jsx(Re,{maxLength:50,children:n.title})},{name:o("notification.body"),value:S?e.jsx(gs,{notification:n,blocklet:s}):e.jsx(bs,{notification:n,rows:0})},{name:o("notification.severity"),value:e.jsx(Ne,{severity:n.severity})},{name:o("notification.createdAt"),value:e.jsx(as,{value:n.createdAt,locale:l,shouldUpdate:!0,type:"all"})}].map(g=>e.jsx(At,{style:{alignItems:"flex-start"},valueComponent:"div",nameWidth:120,name:g.name,children:g.value},g.name))}const _={info:{label:o("common.basicInfo"),value:"info",component:B},receivers:{label:o("notification.receiver"),value:"receivers"},statistics:{label:o("notification.statistics"),value:"statistics"}},M=Object.values(_).map(({label:c,value:g})=>({label:c,value:g})),J=_[O.tab]||_.info,ie=c=>{O.tab=c};return e.jsx(Nt,{title:o("notification.notificationDetails"),fullWidth:!0,maxWidth:"lg",onClose:()=>{O.tab="info",t()},open:!0,actionsPosition:"left",sx:{".ux-dialog_header":{paddingBottom:0},".MuiDialogContent-root":{paddingTop:0}},children:e.jsxs(ln,{children:[e.jsx(T,{mx:3,className:"tabs",children:e.jsx(wt,{tabs:M,current:O.tab,onChange:ie,scrollButtons:"auto"})}),e.jsxs("div",{className:"body",children:[O.tab==="receivers"&&e.jsx(en,{notificationId:n.id,resending:h,handleResend:R}),O.tab==="statistics"&&e.jsx(_e,{statistics:n.statistics,mode:"detail",resending:h,onResend:R}),O.tab==="info"&&e.jsx(J.component,{})]})]})})}const on=C.memo(Mt),ln=ue.div`
48
+ `;Mt.propTypes={notification:x.object.isRequired,onCancel:x.func,blocklet:x.object.isRequired,tab:x.string};function Mt({notification:n,onCancel:t=()=>{},blocklet:s,tab:r="info"}){const{t:o,locale:l}=re(),{getComponent:y,resendNotification:p}=tt(),[h,i]=C.useState(!1),O=ce(()=>y(n.componentDid)||s,[s,n.componentDid]),A=Te({tab:r||"info"}),R=C.useCallback(async(c,g,j=!0,N=[])=>{var a;if(!c.length||!n.id)return;const E=g.length>0?g:(a=n==null?void 0:n.receivers)==null?void 0:a.map(m=>m.receiver);if(!E.length)return;let P=[...c];if(P.includes(W.NOTIFICATION_SEND_CHANNEL.PUSH)&&!Wt(s)&&(q.warning(o("notification.sendStatus.reason.unavailable",{channel:"Push Kit"})),P=P.filter(m=>m!==W.NOTIFICATION_SEND_CHANNEL.PUSH)),P.includes(W.NOTIFICATION_SEND_CHANNEL.EMAIL)&&!Bt(s)&&(q.warning(o("notification.sendStatus.reason.unavailable",{channel:"Email"})),P=P.filter(m=>m!==W.NOTIFICATION_SEND_CHANNEL.EMAIL)),!!P.length)try{i(!0),await p({notificationId:n.id,receivers:E,channels:P,resendFailedOnly:j,...P.includes("webhook")&&N.length?{webhookUrls:N}:{}}),q.success("Message has been sent!")}catch(m){console.error("handleResend error",{error:m}),q.error(m.response?m.response.statusText:m.message)}finally{i(!1)}},[s,n.id,n==null?void 0:n.receivers,p,o]),S=ce(()=>cs(n),[n]),D=ce(()=>ds(n),[n]),Y=ce(()=>S?n==null?void 0:n.actorInfo:[],[n]),B=ce(()=>{var c;return(s==null?void 0:s.did)||((c=s==null?void 0:s.meta)==null?void 0:c.did)||""},[s]);function z(){return[{name:o("notification.from"),value:S&&D?e.jsx(hs,{actors:Y,teamDid:B,size:32,showName:!0}):e.jsx(xs,{size:32,blocklet:O,showName:!0,hideDot:!0})},{name:o("notification.notificationTitle"),value:e.jsx(Re,{maxLength:50,children:n.title})},{name:o("notification.body"),value:S?e.jsx(gs,{notification:n,blocklet:s}):e.jsx(bs,{notification:n,rows:0})},{name:o("notification.severity"),value:e.jsx(Ne,{severity:n.severity})},{name:o("notification.createdAt"),value:e.jsx(as,{value:n.createdAt,locale:l,shouldUpdate:!0,type:"all"})}].map(g=>e.jsx(Ot,{style:{alignItems:"flex-start"},valueComponent:"div",nameWidth:120,name:g.name,children:g.value},g.name))}const _={info:{label:o("common.basicInfo"),value:"info",component:z},receivers:{label:o("notification.receiver"),value:"receivers"},statistics:{label:o("notification.statistics"),value:"statistics"}},M=Object.values(_).map(({label:c,value:g})=>({label:c,value:g})),J=_[A.tab]||_.info,ie=c=>{A.tab=c};return e.jsx(Nt,{title:o("notification.notificationDetails"),fullWidth:!0,maxWidth:"lg",onClose:()=>{A.tab="info",t()},open:!0,actionsPosition:"left",sx:{".ux-dialog_header":{paddingBottom:0},".MuiDialogContent-root":{paddingTop:0}},children:e.jsxs(ln,{children:[e.jsx(T,{mx:3,className:"tabs",children:e.jsx(wt,{tabs:M,current:A.tab,onChange:ie,scrollButtons:"auto"})}),e.jsxs("div",{className:"body",children:[A.tab==="receivers"&&e.jsx(en,{notificationId:n.id,resending:h,handleResend:R}),A.tab==="statistics"&&e.jsx(_e,{statistics:n.statistics,mode:"detail",resending:h,onResend:R}),A.tab==="info"&&e.jsx(J.component,{})]})]})})}const on=C.memo(Mt),ln=ue.div`
49
49
  & > .notification-row {
50
50
  padding: 0;
51
51
  }
@@ -76,7 +76,7 @@ import{g as Ut,r as C}from"./vendor-react-DEoibe3W.js";import{ah as ue,al as ht,
76
76
  cursor: pointer;
77
77
  &.disabled {
78
78
  cursor: not-allowed;
79
- color: ${Ae.text.disabled};
79
+ color: ${Oe.text.disabled};
80
80
  }
81
81
  }
82
82
  }
@@ -92,7 +92,7 @@ import{g as Ut,r as C}from"./vendor-react-DEoibe3W.js";import{ah as ue,al as ht,
92
92
  overflow: hidden;
93
93
  text-overflow: ellipsis;
94
94
  }
95
- `;function we({blocklet:n,label:t}){var s;return e.jsx(cn,{children:n?e.jsxs(e.Fragment,{children:[e.jsx(Lt,{size:24,blocklet:n,ancestors:n.ancestors}),e.jsx("span",{className:"name",children:n.title||((s=n.meta)==null?void 0:s.title)})]}):e.jsx("span",{className:"name",children:t})})}ct.propTypes={list:x.array.isRequired,label:x.string.isRequired,onDelete:x.func};ct.defaultProps={onDelete:()=>{}};function ct({list:n,label:t,onDelete:s}){return e.jsxs(T,{display:"flex",gap:1,alignItems:"center",children:[e.jsxs(ae,{children:[t,": "]}),n.map(r=>e.jsx(Xe,{size:"small",label:e.jsx(T,{display:"flex",alignItems:"center",sx:{gap:"4px"},children:e.jsx(Ne,{severity:r})}),onDelete:o=>s(o,r)},r))]})}function dn(n){return e.jsx(at,{...n,renderLabel:t=>e.jsx(Ne,{severity:t})})}function un({customTableButtons:n}){var je;const{t,locale:s}=re(),r=jt(),o=C.useMemo(()=>vt(r,Kt()),[r]),[l,y]=C.useState(!1),{data:p,paging:h,blocklet:i,fetch:A,getComponent:O,componentDids:R,inService:S,teamDid:D}=tt(),G=C.useRef(null),[z,B]=C.useState(null),[_,M]=C.useState("info"),J=Cs(),[ie,c]=C.useState(!1),g=`notification-records-${(je=i.meta)==null?void 0:je.did}`,j=rs(g),[N,E]=C.useState({pageSize:j.rowsPerPage||10,page:j.page?j.page+1:1,dids:j.dids||[],dateRange:j.dateRange||[se().subtract(1,"month").startOf("day").toDate(),se().endOf("day").toDate()]}),P=ce(()=>{if(!i.children||!i.children.length)return[];const v=[];return i.children.forEach(b=>{var I;const w=b.did||((I=b.meta)==null?void 0:I.did);R.includes(w)&&(b.ancestors=[i],v.push(b))}),v},[R,i]),a=async v=>{try{y(!0),await A(v),y(!1)}finally{y(!1)}};C.useEffect(()=>{a(N)},[N]),C.useEffect(()=>{const v=p.find(b=>b.id===(z==null?void 0:z.id));z&&v&&B({...v})},[p]);const m=(v,b,w,I)=>{v.stopPropagation();const k=w.filter(F=>F!==b);E(F=>({...F,[I]:k,page:1}))},$=({page:v,rowsPerPage:b,filterList:w})=>{const[I=[],,,,k=[]]=w;N.pageSize!==b?E(F=>({...F,pageSize:b,page:1})):N.page!==v+1?E(F=>({...F,page:v+1})):ye(N.dids,I)?ye(N.severities,k)||E(F=>({...F,severities:k,page:1})):E(F=>({...F,dids:I,page:1}))},U=C.useCallback(()=>{B(null),M("info")},[]),oe=C.useCallback(()=>{A(N)},[A,N]),le=[{label:t("notification.from"),name:"sender",width:400,options:{filter:!0,filterType:"custom",customFilterListOptions:{render:v=>v.map((b,w)=>{var k;if(b==="system")return e.jsx("span",{children:t("notification.system")},`system-${w}`);const I=P.find(F=>{var d;return(F.did||((d=F.meta)==null?void 0:d.did))===b});return e.jsx(we,{blocklet:I,label:(I==null?void 0:I.title)||((k=I==null?void 0:I.meta)==null?void 0:k.title)},b)}),update:(v,b,w)=>(v[w].splice(b,1),v)},filterOptions:{names:P,logic:(v,b)=>b.length?!b.includes(v):!1,display:(v,b,w,I)=>e.jsxs(Y,{style:{width:"380px"},children:[e.jsx(Vt,{id:"demo-simple-select-label",style:{background:"#ffffff"},children:"Sender"}),e.jsxs(Yt,{multiple:!0,value:v[w],renderValue:k=>e.jsx(T,{display:"flex",gap:1,alignItems:"center",style:{overflow:"hidden",textOverflow:"ellipsis"},children:k.map(F=>{var d;if(F==="system")return e.jsx("span",{children:t("notification.system")},F);const ne=P.find(u=>{var L;return(u.did||((L=u.meta)==null?void 0:L.did))===F});return e.jsx(we,{blocklet:ne,label:(ne==null?void 0:ne.title)||((d=ne==null?void 0:ne.meta)==null?void 0:d.title)},F)})}),onChange:k=>{v[w]=k.target.value,b(v[w],w,I)},children:[e.jsx(ut,{value:"system",children:t("notification.system")}),P.map(k=>{var ne,d;const F=k.did||((ne=k.meta)==null?void 0:ne.did);return e.jsx(ut,{value:F,children:e.jsx(we,{blocklet:k,label:k.title||((d=k.meta)==null?void 0:d.title)})},F)})]})]})},customBodyRenderLite:v=>{var I,k;const b=p[v],w=O(b.componentDid);return e.jsxs(T,{display:"flex",alignItems:"center",gap:1,children:[w?e.jsx(Lt,{size:32,blocklet:w,ancestors:w.ancestors??[]}):e.jsx(js,{blocklet:i,size:32}),e.jsx(Re,{maxLength:50,children:((I=w==null?void 0:w.meta)==null?void 0:I.title)||((k=i==null?void 0:i.meta)==null?void 0:k.title)})]})}}},{label:t("notification.receiver"),name:"receivers",width:300,options:{filter:!1,customBodyRenderLite:v=>{const b=p[v],{receivers:w}=b;return e.jsx(Gt,{total:w.length,renderSurplus:I=>I<100?e.jsxs("span",{children:["+",I]}):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:I=>{I.stopPropagation(),B(b),M("receivers")},children:w.map(I=>{const{receiverUser:k}=I,F=Dt(k.avatar,D,S);return e.jsx(Tt,{alt:k.fullName,src:`${F}?imageFilter=resize&w=48&h=48`,size:32,did:I.receiver,shape:"circle",style:{borderRadius:"100%",overflow:"hidden"}},I.receiver)})})}}},{label:t("notification.statistics"),name:"statistics",width:400,options:{filter:!1,customBodyRenderLite:v=>{const b=p[v];return e.jsx(T,{onClick:w=>{w.stopPropagation(),B(b),M("statistics")},children:e.jsx(_e,{statistics:b.statistics})})}}},{label:t("notification.notificationPreview"),name:"data",options:{filter:!1,customBodyRenderLite:v=>{const b=p[v];return e.jsx(Re,{maxLength:50,children:b.title})}}},{label:t("notification.severity"),name:"severity",width:200,options:{setCellProps:()=>({className:"severity-cell"}),customBodyRenderLite:v=>{const b=p[v];return e.jsx(Ne,{severity:b.severity})},filter:!0,filterType:"custom",filterList:N.severities??[],customFilterListOptions:{render:v=>e.jsx(ct,{list:v,label:t("notification.severity"),onDelete:(b,w)=>{b.stopPropagation(),m(b,w,le[4].options.filterList,"severities")}}),update:Oe},filterOptions:{names:mt,fullWidth:!0,logic:De,display:(v,b,w,I)=>e.jsx(dn,{label:t("notification.severity"),filterList:v,onChange:b,index:w,column:I,filterValues:mt})}}},{label:t("common.createdAt"),name:"createdAt",width:300,options:{filter:!1,customBodyRenderLite:v=>{const{createdAt:b}=p[v];return e.jsx(Ot,{value:b,locale:s,shouldUpdate:!0})}}}],pe=v=>{E(b=>({...b,dateRange:v,page:1}))},be=[e.jsxs(T,{display:"flex",alignItems:"center",gap:1.5,children:[e.jsx(Jt,{onClick:()=>c(!0),sx:{p:J?0:void 0},children:e.jsx(ls,{})},"settings"),J?e.jsx(ae,{children:t("common.setting")}):null]}),...n||[]];return e.jsxs(T,{ref:G,sx:{overflow:"auto",".MuiTableCell-head":{whiteSpace:"nowrap",fontWeight:"bold"},".MuiTableCell-root":{paddingRight:"8px",whiteSpace:"nowrap"}},children:[e.jsx(pn,{children:e.jsx(yt,{theme:o,children:e.jsx(Rt,{className:"main-table",verticalKeyWidth:100,loading:l,locale:s,columns:le,data:p,durable:g,onChange:$,options:{sort:!1,download:!1,print:!1,search:!1,expandableRowsOnClick:!0,page:h.page-1,rowsPerPage:h.pageSize,count:h.total,...j,onRowClick:(v,{dataIndex:b})=>{B(p[b])}},customPreButtons:[e.jsx(rt,{value:N.dateRange,onChange:pe})],customButtons:be,components:{TableFilterList:v=>e.jsx(ot,{...v,itemComponent:b=>e.jsx(Pe,{...b,canDelete:w=>{var k;const I=(k=w==null?void 0:w.columnNames)==null?void 0:k[(w==null?void 0:w.index)||0];return(I==null?void 0:I.name)==="sender"}})})}})})}),z&&e.jsx(on,{refresh:oe,onCancel:U,notification:z,blocklet:i,tab:_}),e.jsx(Nt,{title:`${t("common.notification")} ${t("common.setting")}`,fullWidth:!0,maxWidth:"md",open:ie,onClose:()=>c(!1),PaperProps:{style:{minHeight:"500px"}},children:e.jsx(T,{sx:{mt:"-16px",overflowY:"hidden"},children:e.jsx(Ds,{})})})]})}const pn=ue.div`
95
+ `;function we({blocklet:n,label:t}){var s;return e.jsx(cn,{children:n?e.jsxs(e.Fragment,{children:[e.jsx(Lt,{size:24,blocklet:n,ancestors:n.ancestors}),e.jsx("span",{className:"name",children:n.title||((s=n.meta)==null?void 0:s.title)})]}):e.jsx("span",{className:"name",children:t})})}ct.propTypes={list:x.array.isRequired,label:x.string.isRequired,onDelete:x.func};ct.defaultProps={onDelete:()=>{}};function ct({list:n,label:t,onDelete:s}){return e.jsxs(T,{display:"flex",gap:1,alignItems:"center",children:[e.jsxs(ae,{children:[t,": "]}),n.map(r=>e.jsx(Xe,{size:"small",label:e.jsx(T,{display:"flex",alignItems:"center",sx:{gap:"4px"},children:e.jsx(Ne,{severity:r})}),onDelete:o=>s(o,r)},r))]})}function dn(n){return e.jsx(at,{...n,renderLabel:t=>e.jsx(Ne,{severity:t})})}function un({customTableButtons:n}){var je;const{t,locale:s}=re(),r=jt(),o=C.useMemo(()=>vt(r,Kt()),[r]),[l,y]=C.useState(!1),{data:p,paging:h,blocklet:i,fetch:O,getComponent:A,componentDids:R,inService:S,teamDid:D}=tt(),Y=C.useRef(null),[B,z]=C.useState(null),[_,M]=C.useState("info"),J=Cs(),[ie,c]=C.useState(!1),g=`notification-records-${(je=i.meta)==null?void 0:je.did}`,j=rs(g),[N,E]=C.useState({pageSize:j.rowsPerPage||10,page:j.page?j.page+1:1,dids:j.dids||[],dateRange:j.dateRange||[se().subtract(1,"month").startOf("day").toDate(),se().endOf("day").toDate()]}),P=ce(()=>{if(!i.children||!i.children.length)return[];const v=[];return i.children.forEach(b=>{var I;const w=b.did||((I=b.meta)==null?void 0:I.did);R.includes(w)&&(b.ancestors=[i],v.push(b))}),v},[R,i]),a=async v=>{try{y(!0),await O(v),y(!1)}finally{y(!1)}};C.useEffect(()=>{a(N)},[N]),C.useEffect(()=>{const v=p.find(b=>b.id===(B==null?void 0:B.id));B&&v&&z({...v})},[p]);const m=(v,b,w,I)=>{v.stopPropagation();const k=w.filter(F=>F!==b);E(F=>({...F,[I]:k,page:1}))},$=({page:v,rowsPerPage:b,filterList:w})=>{const[I=[],,,,k=[]]=w;N.pageSize!==b?E(F=>({...F,pageSize:b,page:1})):N.page!==v+1?E(F=>({...F,page:v+1})):ye(N.dids,I)?ye(N.severities,k)||E(F=>({...F,severities:k,page:1})):E(F=>({...F,dids:I,page:1}))},U=C.useCallback(()=>{z(null),M("info")},[]),oe=C.useCallback(()=>{O(N)},[O,N]),le=[{label:t("notification.from"),name:"sender",width:400,options:{filter:!0,filterType:"custom",customFilterListOptions:{render:v=>v.map((b,w)=>{var k;if(b==="system")return e.jsx("span",{children:t("notification.system")},`system-${w}`);const I=P.find(F=>{var d;return(F.did||((d=F.meta)==null?void 0:d.did))===b});return e.jsx(we,{blocklet:I,label:(I==null?void 0:I.title)||((k=I==null?void 0:I.meta)==null?void 0:k.title)},b)}),update:(v,b,w)=>(v[w].splice(b,1),v)},filterOptions:{names:P,logic:(v,b)=>b.length?!b.includes(v):!1,display:(v,b,w,I)=>e.jsxs(G,{style:{width:"380px"},children:[e.jsx(Vt,{id:"demo-simple-select-label",style:{background:"#ffffff"},children:"Sender"}),e.jsxs(Gt,{multiple:!0,value:v[w],renderValue:k=>e.jsx(T,{display:"flex",gap:1,alignItems:"center",style:{overflow:"hidden",textOverflow:"ellipsis"},children:k.map(F=>{var d;if(F==="system")return e.jsx("span",{children:t("notification.system")},F);const ne=P.find(u=>{var L;return(u.did||((L=u.meta)==null?void 0:L.did))===F});return e.jsx(we,{blocklet:ne,label:(ne==null?void 0:ne.title)||((d=ne==null?void 0:ne.meta)==null?void 0:d.title)},F)})}),onChange:k=>{v[w]=k.target.value,b(v[w],w,I)},children:[e.jsx(ut,{value:"system",children:t("notification.system")}),P.map(k=>{var ne,d;const F=k.did||((ne=k.meta)==null?void 0:ne.did);return e.jsx(ut,{value:F,children:e.jsx(we,{blocklet:k,label:k.title||((d=k.meta)==null?void 0:d.title)})},F)})]})]})},customBodyRenderLite:v=>{var I,k;const b=p[v],w=A(b.componentDid);return e.jsxs(T,{display:"flex",alignItems:"center",gap:1,children:[w?e.jsx(Lt,{size:32,blocklet:w,ancestors:w.ancestors??[]}):e.jsx(js,{blocklet:i,size:32}),e.jsx(Re,{maxLength:50,children:((I=w==null?void 0:w.meta)==null?void 0:I.title)||((k=i==null?void 0:i.meta)==null?void 0:k.title)})]})}}},{label:t("notification.receiver"),name:"receivers",width:300,options:{filter:!1,customBodyRenderLite:v=>{const b=p[v],{receivers:w}=b;return e.jsx(Yt,{total:w.length,renderSurplus:I=>I<100?e.jsxs("span",{children:["+",I]}):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:I=>{I.stopPropagation(),z(b),M("receivers")},children:w.map(I=>{const{receiverUser:k}=I,F=Dt(k.avatar,D,S);return e.jsx(Tt,{alt:k.fullName,src:`${F}?imageFilter=resize&w=48&h=48`,size:32,did:I.receiver,shape:"circle",style:{borderRadius:"100%",overflow:"hidden"}},I.receiver)})})}}},{label:t("notification.statistics"),name:"statistics",width:400,options:{filter:!1,customBodyRenderLite:v=>{const b=p[v];return e.jsx(T,{onClick:w=>{w.stopPropagation(),z(b),M("statistics")},children:e.jsx(_e,{statistics:b.statistics})})}}},{label:t("notification.notificationPreview"),name:"data",options:{filter:!1,customBodyRenderLite:v=>{const b=p[v];return e.jsx(Re,{maxLength:50,children:b.title})}}},{label:t("notification.severity"),name:"severity",width:200,options:{setCellProps:()=>({className:"severity-cell"}),customBodyRenderLite:v=>{const b=p[v];return e.jsx(Ne,{severity:b.severity})},filter:!0,filterType:"custom",filterList:N.severities??[],customFilterListOptions:{render:v=>e.jsx(ct,{list:v,label:t("notification.severity"),onDelete:(b,w)=>{b.stopPropagation(),m(b,w,le[4].options.filterList,"severities")}}),update:Ae},filterOptions:{names:mt,fullWidth:!0,logic:De,display:(v,b,w,I)=>e.jsx(dn,{label:t("notification.severity"),filterList:v,onChange:b,index:w,column:I,filterValues:mt})}}},{label:t("common.createdAt"),name:"createdAt",width:300,options:{filter:!1,customBodyRenderLite:v=>{const{createdAt:b}=p[v];return e.jsx(At,{value:b,locale:s,shouldUpdate:!0})}}}],pe=v=>{E(b=>({...b,dateRange:v,page:1}))},be=[e.jsxs(T,{display:"flex",alignItems:"center",gap:1.5,children:[e.jsx(Jt,{onClick:()=>c(!0),sx:{p:J?0:void 0},children:e.jsx(ls,{})},"settings"),J?e.jsx(ae,{children:t("common.setting")}):null]}),...n||[]];return e.jsxs(T,{ref:Y,sx:{overflow:"auto",".MuiTableCell-head":{whiteSpace:"nowrap",fontWeight:"bold"},".MuiTableCell-root":{paddingRight:"8px",whiteSpace:"nowrap"}},children:[e.jsx(pn,{children:e.jsx(yt,{theme:o,children:e.jsx(Rt,{className:"main-table",verticalKeyWidth:100,loading:l,locale:s,columns:le,data:p,durable:g,onChange:$,options:{sort:!1,download:!1,print:!1,search:!1,expandableRowsOnClick:!0,page:h.page-1,rowsPerPage:h.pageSize,count:h.total,...j,onRowClick:(v,{dataIndex:b})=>{z(p[b])}},customPreButtons:[e.jsx(rt,{value:N.dateRange,onChange:pe})],customButtons:be,components:{TableFilterList:v=>e.jsx(ot,{...v,itemComponent:b=>e.jsx(Pe,{...b,canDelete:w=>{var k;const I=(k=w==null?void 0:w.columnNames)==null?void 0:k[(w==null?void 0:w.index)||0];return(I==null?void 0:I.name)==="sender"}})})}})})}),B&&e.jsx(on,{refresh:oe,onCancel:U,notification:B,blocklet:i,tab:_}),e.jsx(Nt,{title:`${t("common.notification")} ${t("common.setting")}`,fullWidth:!0,maxWidth:"md",open:ie,onClose:()=>c(!1),PaperProps:{style:{minHeight:"500px"}},children:e.jsx(T,{sx:{mt:"-16px",overflowY:"hidden"},children:e.jsx(Ds,{})})})]})}const pn=ue.div`
96
96
  td.MuiTableCell-footer {
97
97
  border: none !important;
98
98
  }
@@ -1,7 +1,7 @@
1
- import{a as _,a3 as q,k as ve,r as se,bs as Ee,bt as Ce,bu as Se,I as U,bZ as Q,b_ as X,a5 as Me,ac as Le,bH as _e}from"./vendor-ux-did-connect-CX7qG3_M.js";import{t as Be,l as Te,j as He}from"./vendor-hooks-BCm626KH.js";import{r as C,b as ie}from"./vendor-react-DEoibe3W.js";import{d as re}from"./InfoOutlined-CLiL5VeK.js";import{i as Fe,v as Ne}from"./vendor-arcblock-B4hgrXYM.js";import{D as V,aC as Ue,aD as Z,G as Ie,y as Ke}from"./index-B18R5SlV.js";import{u as Y}from"./dashboard-k0XcV2m5.js";import{u as Ve}from"./use-mobile-CXU9YBvX.js";import{H as o,j as e,D as Ye,aj as Je,t as Ge,aa as d,O as je,T as S,ab as F,ak as le,z as Qe,y as N,bt as ye,bS as ee,ad as $,L as te,A as oe,aq as Xe,E as M,I as H,C as Ze,br as et,al as D,cg as tt,X as Re,a9 as ae,s as de,as as ne,bq as ot,b8 as nt,b9 as st,an as it,c0 as rt,v as lt,ch as at,ci as dt,cj as ct,ck as ut}from"./vendor-mui-core-wlbruq2I.js";import{d as pt}from"./ExpandLess-Fb-uW6u_.js";import{b as De,z as ht,A as xt}from"./vendor-utils-B3iZkn2R.js";import{C as mt}from"./confirm-Bay3BcpN.js";import{A as ft}from"./actions-DtL6bYnA.js";import{T as we}from"./table-tips-Czrj7r52.js";import"./lottie-web-jYmAQWuC.js";import"./useLocalStorage-BF3BqN1O.js";import"./index-8eXqqyHQ.js";import"./PlayArrow-B_ZNrQDa.js";import"./get-safe-url-CwT4-jkw.js";import"./session-1k8BRnYA.js";import"./use-blocklet-logo-DGSQQmh2.js";import"./dot-DR7_m3Np.js";import"./useAsync-BMCqtJH2.js";import"./useSetState-CWq0AVWn.js";import"./use-mobile-CiFFAdJf.js";import"./MoreHoriz-9E3q8aHi.js";const gt=s=>{var b,T;const[c,p]=C.useState(null),[v,l]=C.useState(!s),[k,u]=C.useState(null),{blocklet:f}=Ie(),i=(T=(b=f==null?void 0:f.site)==null?void 0:b.domainAliases[0])==null?void 0:T.value,y=C.useMemo(()=>{const j={};return c&&(c.sources.forEach(n=>{j[n.did]={source:n,events:[],count:0}}),c.events.forEach(n=>{j[n.source]&&(j[n.source].events.push(n),j[n.source].count+=1)})),j},[c]),w=async()=>{try{if(l(!0),!i)return;const n=await(await fetch(`https://${i}${ve.WELLKNOWN_SERVICE_PATH_PREFIX}/openevent.json`)).json();p(n),u(null)}catch(j){u(j instanceof Error?j:new Error(String(j)))}finally{l(!1)}};return C.useEffect(()=>{w()},[i]),{openEvent:c,setOpenEvent:p,eventsBySource:y,loading:v,error:k,loadData:w}};function ce({eventsBySource:s,selectedEvents:c,setSelectedEvents:p,error:v}){const{t:l}=_(),[k,u]=C.useState({}),f=C.useMemo(()=>{const n={};return Object.entries(s).forEach(([h,{events:x}])=>{const E=x.filter(I=>c[`${I.type}-${I.source}`]).length;n[h]=E}),n},[s,c]),i=C.useMemo(()=>Object.values(f).reduce((n,h)=>n+h,0),[f]),y=C.useMemo(()=>Object.values(s).reduce((n,{events:h})=>n+h.length,0),[s]),w=(n,h)=>{h.stopPropagation(),u({...k,[n]:!k[n]})},b=n=>{const h=`${n.type}-${n.source}`;p(x=>({...x,[h]:!x[h]}))},T=(n,h)=>{const x={};n.forEach(E=>{const I=`${E.type}-${E.source}`;x[I]=!h}),p(E=>({...E,...x}))},j=n=>{const h={};Object.values(s).forEach(({events:x})=>{x.forEach(E=>{const I=`${E.type}-${E.source}`;h[I]=n.target.checked})}),p(h)};return e.jsxs(d,{sx:{width:"100%"},children:[e.jsxs(d,{sx:{display:"flex",alignItems:"center",mb:1,mt:1},children:[e.jsx(ye,{control:e.jsx(ee,{onChange:j,checked:i>0&&i===y}),label:e.jsxs(d,{sx:{display:"flex",alignItems:"center",cursor:"pointer"},children:[l("webhookEndpoint.selectAllEvents"),e.jsx(d,{sx:{display:"flex",alignItems:"center"},children:e.jsx($,{title:l("webhookEndpoint.selectAllEventsTooltip"),placement:"right",children:e.jsx(re,{fontSize:"small",sx:{ml:.5,cursor:"help"}})})})]}),sx:{m:0}}),i>0&&e.jsx(S,{variant:"body2",color:"primary",sx:{ml:"auto"},children:l("webhookEndpoint.selectedEventsCount",{count:i})})]}),e.jsx(d,{sx:{maxHeight:"50vh",overflow:"auto"},children:e.jsx(te,{disablePadding:!0,sx:{border:"1px solid",borderColor:"divider",borderRadius:"4px"},children:Object.entries(s).map(([n,{source:h,events:x,count:E}],I)=>{const O=f[n]>0,R=f[n]===x.length&&x.length>0,A=k[n];return e.jsxs(ie.Fragment,{children:[e.jsx(oe,{sx:{borderBottom:({palette:r})=>I<Object.keys(s).length-1?`1px solid ${r.divider}`:"none",px:2,py:1.5,"&:hover":{bgcolor:"rgba(0, 0, 0, 0.02)"}},children:e.jsxs(d,{sx:{display:"flex",width:"100%",justifyContent:"space-between",alignItems:"center"},onClick:r=>{r.target.closest(".MuiFormControlLabel-root")||w(n,r)},children:[e.jsx(d,{sx:{display:"flex",alignItems:"center"},children:x.length>0&&e.jsx(ye,{control:e.jsx(ee,{checked:R,indeterminate:O&&!R,onChange:r=>{r.stopPropagation(),T(x,R)}}),label:e.jsxs(d,{sx:{display:"flex",alignItems:"center",gap:1},children:[h.logo&&e.jsx(Xe,{src:h.logo,sx:{width:24,height:24}}),e.jsx(d,{children:h.title||n}),O&&e.jsx(M,{label:l("webhookEndpoint.selectedCount",{count:f[n]}),size:"small",sx:{mt:"2px",height:"20px",fontSize:"12px",bgcolor:r=>`${r.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",color:"text.secondary",sx:{mr:1},children:l("webhookEndpoint.eventsCount",{count:E})}),x.length>0&&e.jsx(H,{size:"small",edge:"end",children:A?e.jsx(pt,{}):e.jsx(Fe,{})})]})]})}),x.length>0&&e.jsx(Ze,{in:A,timeout:"auto",unmountOnExit:!0,children:e.jsx(te,{disablePadding:!0,sx:{pl:2,pr:2,py:1,bgcolor:"rgba(0, 0, 0, 0.01)"},children:x.map(r=>{const a=`${r.type}-${r.source}`,t=!!c[a];return e.jsx(oe,{dense:!0,sx:{py:.75},onClick:()=>b(r),children:e.jsxs(d,{sx:{display:"flex",alignItems:"flex-start",width:"100%"},children:[e.jsx(ee,{checked:t,sx:{mr:1}}),e.jsxs(d,{children:[e.jsx(S,{variant:"body1",sx:{cursor:"pointer",color:"text.primary"},children:r.type}),e.jsx(S,{variant:"caption",color:"text.secondary",sx:{display:"block",cursor:"pointer"},children:r.description})]})]})},a)})})})]},n)})})}),v&&e.jsx(et,{error:!0,sx:{mt:1},children:v})]})}ce.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};ce.defaultProps={error:null};function ue({id:s,url:c,description:p,enabledEvents:v,onSubmit:l,onClose:k}){var r;const{t:u}=_(),[f,i]=C.useState({}),{teamDid:y}=Y(),{api:w}=V(),{loading:b,error:T,eventsBySource:j}=gt(),{control:n,handleSubmit:h,formState:{errors:x},reset:E,setValue:I,trigger:O}=Ue({defaultValues:{url:"",description:""}});C.useEffect(()=>{const a=Object.values(f).some(t=>t);I("selectedEvents",a?"valid":""),O("selectedEvents")},[f,I,O]);const R=()=>{i({}),E(),k()},A=async a=>{const t=Object.keys(f).filter(m=>f[m]),g={url:a.url,description:a.description,enabledEvents:t.map(m=>{const[P,z]=m.split("-");return!P||!z?null:{type:P,source:z}}).filter(Boolean)};try{if(s){const m=await w.updateWebhookEndpoint({input:{teamDid:y,id:s,data:g}});q.success(`${u("webhookEndpoint.updateWebhook")} ${u("webhookEndpoint.success")}`),l(m)}else{const m=await w.createWebhookEndpoint({input:{teamDid:y,input:g}});q.success(`${u("webhookEndpoint.createWebhook")} ${u("webhookEndpoint.success")}`),l(m)}}catch(m){q.error(m==null?void 0:m.message)}R()};return C.useEffect(()=>{E({url:c,description:p}),i(v.reduce((a,t)=>(a[`${t.type}-${t.source}`]=!0,a),{}))},[E,i,c,p,v]),e.jsx(Ye,{open:!0,onClose:R,maxWidth:"lg",fullWidth:!0,sx:{"& .MuiDialog-paper":{minHeight:600}},children:e.jsxs("form",{onSubmit:h(A),children:[e.jsx(Je,{children:u(s?"webhookEndpoint.editWebhookTitle":"webhookEndpoint.createWebhookTitle")}),e.jsx(Ge,{children:e.jsxs(d,{sx:{display:"flex",flexDirection:"column",gap:2,mt:2},children:[e.jsx(Z,{name:"url",control:n,rules:{required:u("webhookEndpoint.validation.urlRequired"),pattern:{value:/^(http|https):\/\/[^ "]+$/,message:u("webhookEndpoint.validation.urlInvalid")}},render:({field:a})=>{var t;return e.jsx(je,{...a,label:u("webhookEndpoint.url.label"),fullWidth:!0,error:!!x.url,helperText:(t=x.url)==null?void 0:t.message})}}),e.jsx(Z,{name:"description",control:n,rules:{required:u("webhookEndpoint.validation.descriptionRequired")},render:({field:a})=>{var t;return e.jsx(je,{...a,label:u("webhookEndpoint.description.label"),fullWidth:!0,multiline:!0,minRows:2,maxRows:4,error:!!x.description,helperText:(t=x.description)==null?void 0:t.message})}}),e.jsx(Z,{name:"selectedEvents",control:n,rules:{required:u("webhookEndpoint.validation.eventRequired")},render:({field:a})=>e.jsx("input",{type:"hidden",...a})}),!b&&j&&Object.keys(j).length>0&&e.jsx(ce,{eventsBySource:j,selectedEvents:f,setSelectedEvents:i,error:(r=x.selectedEvents)==null?void 0:r.message}),!b&&(!j||Object.keys(j).length===0)&&e.jsx(S,{color:"text.secondary",children:u("webhookEndpoint.noAvailableEvents")}),b&&e.jsx(d,{sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"500px",width:"100%"},children:e.jsx(F,{size:20})}),T&&e.jsx(le,{severity:"error",children:u("webhookEndpoint.loadingError",{message:T==null?void 0:T.message})})]})}),e.jsxs(Qe,{sx:{p:"8px 24px 24px"},children:[e.jsx(N,{onClick:R,children:u("common.cancel")}),e.jsx(N,{type:"submit",variant:"contained",color:"primary",children:u(s?"webhookEndpoint.updateWebhook":"webhookEndpoint.saveWebhook")})]})]})})}ue.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};ue.defaultProps={id:null,url:"",description:"",enabledEvents:[],onClose:()=>{}};function Pe(s){switch(s){case"enabled":return"success";case"disabled":default:return"default"}}const bt=(s="en")=>s==="tw"?"zh":s;function K(s,c="YYYY-MM-DD HH:mm:ss",p="en"){return s?Ke(s).locale(bt(p)).format(c):"-"}function jt(s){return typeof s=="number"?!1:De(s)}function yt(s){return s>=200&&s<300}function W(s){const c=jt(s.value);return e.jsxs(e.Fragment,{children:[e.jsxs(D,{direction:"column",alignItems:"flex-start",children:[e.jsxs(S,{component:"div",variant:"body1",mb:1,color:"text.primary",sx:{fontWeight:500},children:[s.label,!!s.tip&&e.jsx($,{title:s.tip,children:e.jsx(tt,{fontSize:"small"})})]}),e.jsx(S,{component:"div",variant:"body1",color:c?"text.disabled":"text.secondary",sx:{width:"100%",minHeight:"24px"},children:c?"-":s.value})]}),s.divider&&e.jsx(Re,{orientation:"vertical",flexItem:!0})]})}W.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};W.defaultProps={tip:"",divider:!1};function pe(s){return e.jsxs(D,{className:"section-header",direction:"row",justifyContent:"space-between",alignItems:"center",flexWrap:"wrap",gap:1,sx:{mb:s.mb,mt:s.mt,pb:1},children:[e.jsx(S,{variant:"h3",sx:{fontSize:{xs:"18px",md:"1.09375rem"}},component:"div",children:s.title}),s.children]})}pe.propTypes={title:o.oneOfType([o.string,o.node]).isRequired,children:o.node,mb:o.number,mt:o.number};pe.defaultProps={children:null,mb:1.5,mt:1.5};var he={},wt=ae;Object.defineProperty(he,"__esModule",{value:!0});var ze=he.default=void 0,kt=wt(se()),vt=e;ze=he.default=(0,kt.default)((0,vt.jsx)("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2M7 13.5c-.83 0-1.5-.67-1.5-1.5s.67-1.5 1.5-1.5 1.5.67 1.5 1.5-.67 1.5-1.5 1.5m5 0c-.83 0-1.5-.67-1.5-1.5s.67-1.5 1.5-1.5 1.5.67 1.5 1.5-.67 1.5-1.5 1.5m5 0c-.83 0-1.5-.67-1.5-1.5s.67-1.5 1.5-1.5 1.5.67 1.5 1.5-.67 1.5-1.5 1.5"}),"Pending");var xe={},Et=ae;Object.defineProperty(xe,"__esModule",{value:!0});var Oe=xe.default=void 0,Ct=Et(se()),St=e;Oe=xe.default=(0,Ct.default)((0,St.jsx)("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2m0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8m4.59-12.42L10 14.17l-2.59-2.58L6 13l4 4 8-8z"}),"CheckCircleOutlined");var me={},Tt=ae;Object.defineProperty(me,"__esModule",{value:!0});var We=me.default=void 0,It=Tt(se()),Rt=e;We=me.default=(0,It.default)((0,Rt.jsx)("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2m1 15h-2v-2h2zm0-4h-2V7h2z"}),"ErrorOutlined");const Dt={width:24,height:24,body:'<path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M20 11A8.1 8.1 0 0 0 4.5 9M4 5v4h4m-4 4a8.1 8.1 0 0 0 15.5 2m.5 4v-4h-4"/>'},Pt=s=>{const c={};return s.forEach(p=>{var l;const v=new Date(p.createdAt).toLocaleDateString();c[v]||(c[v]=[]),(l=c[v])==null||l.push(p)}),c};function fe({eventId:s,webhookEndpointId:c,event:p}){const{api:v,ws:{useSubscription:l}}=V(),{t:k}=_(),{teamDid:u}=Y(),{blocklet:f}=Ie(),{data:i,loadMore:y,loadingMore:w,loading:b,mutate:T}=Be(t=>{const m=t?Math.ceil(t.list.length/15)+1:1;return v.getWebhookAttempts({input:{teamDid:u,input:{eventId:s,webhookId:c},paging:{page:m,pageSize:15}}})},{reloadDeps:[s,c]}),j=(i==null?void 0:i.list)||[],[n,h]=C.useState(null),[x,E]=C.useState(!1),I=Pt(j);if(C.useEffect(()=>{!n&&(i!=null&&i.list.length)&&h(i.list[0])},[i==null?void 0:i.list.length,n]),l(ve.EVENTS.WEBHOOK_ATTEMPT,t=>{T(g=>{var P,z;if(g.list.find(L=>L.id===t.id)){const L=g.list.map(B=>B.id===t.id?{...B,...t}:B);return{...g,list:L}}return t.endpoint=(P=g.list[0])==null?void 0:P.endpoint,t.event=(z=g.list[0])==null?void 0:z.event,{...g,list:[t,...g.list]}})},[]),b)return e.jsx(F,{});const O=i&&i.list.length<i.paging.total,R=async()=>{n&&(E(!0),await v.retryWebhookAttempt({input:{teamDid:u,eventId:n.event.id,webhookId:c,attemptId:n.id}}).finally(()=>{setTimeout(()=>{E(!1)},1e3)}))},A=t=>{var g,m,P,z,L;if(t.responseBody&&((g=t.responseBody)!=null&&g.sessionId)&&((m=t.responseBody)!=null&&m.projectId)&&((P=t.responseBody)!=null&&P.agentId)){const B=(L=(z=f==null?void 0:f.site)==null?void 0:z.domainAliases[0])==null?void 0:L.value,J=(f.children||[]).find(G=>{var be;return((be=G==null?void 0:G.meta)==null?void 0:be.name)==="ai-studio"}),qe=ht(xt(`https://${B}`,(J==null?void 0:J.mountPoint)||"","projects",t.responseBody.projectId,"logs/main"),{sessionId:t.responseBody.sessionId,agentId:t.responseBody.agentId});return e.jsx(H,{sx:{fontSize:20},onClick:()=>window.open(qe,"_blank"),children:e.jsx(d,{component:U,icon:Q})})}return null},r=t=>t.status==="pending"?e.jsx(ze,{color:"warning"}):yt(t.responseStatus)?e.jsx(Oe,{color:"success"}):e.jsx(We,{color:"error"}),a=(n==null?void 0:n.triggeredFrom)&&((i==null?void 0:i.list)||[]).find(t=>t.id===n.triggeredFrom);return e.jsxs(zt,{container:!0,spacing:{xs:0,md:1},sx:{height:1},children:[e.jsx(ne,{item:!0,xs:12,md:4,height:1,children:De(Object.keys(I))?e.jsx(S,{color:"text.secondary",children:k("webhookEndpoint.waitingForEvents")}):e.jsxs(e.Fragment,{children:[e.jsx(te,{sx:{maxHeight:"calc(100% - 40px)",py:0,overflowY:"auto"},children:Object.entries(I).map(([t,g])=>e.jsxs(ie.Fragment,{children:[e.jsx(ot,{sx:{p:0},children:t}),g.map(m=>e.jsxs(oe,{sx:{cursor:"pointer",px:1},onClick:()=>h(m),selected:n&&(n==null?void 0:n.id)===(m==null?void 0:m.id),secondaryAction:e.jsx(S,{color:"text.secondary",children:K(m.createdAt,"HH:mm:ss")}),children:[e.jsx(nt,{sx:{minWidth:0,mr:1.5},children:r(m)}),e.jsx(st,{primary:e.jsx(S,{color:"text.primary",children:m.event.type})})]},m.id))]},t))}),O&&e.jsx(d,{display:"flex",justifyContent:"center",alignItems:"center",width:1,children:e.jsx(N,{variant:"text",type:"button",color:"inherit",onClick:y,disabled:w,sx:{color:t=>t.palette.text.disabled},children:k(w?"webhookEndpoint.loadingMore":"webhookEndpoint.loadMore")})})]})}),e.jsxs(ne,{item:!0,xs:12,md:8,height:1,children:[n&&e.jsxs(D,{height:1,overflow:"auto",direction:"column",spacing:2,sx:{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:k(`common.${n.status}`)}),e.jsx(d,{children:A(n)})]}),e.jsxs(d,{sx:{display:"flex",alignItems:"center",gap:1},children:[a&&e.jsx($,{componentsProps:{tooltip:{sx:{maxWidth:400}}},placement:"left",title:e.jsxs(D,{gap:1,sx:{cursor:"pointer",".did-address-text":{color:"common.white"}},onClick:()=>h(a),children:[e.jsx(Ee,{showDid:!0,did:n.triggeredBy,cardType:Ce.Detailed,infoType:Se.Minimal,sx:{border:0,padding:0,minWidth:0,".MuiTypography-root":{color:"common.white",fontWeight:400}}}),e.jsx(Re,{}),e.jsxs(d,{sx:{display:"flex",flexDirection:"column"},children:[e.jsx(S,{variant:"body2",sx:{color:"primary.main"},children:k("webhookEndpoint.triggeredFrom")}),e.jsxs(d,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(S,{variant:"body2",children:n.id}),e.jsx(H,{onClick:()=>h(a),children:e.jsx(d,{component:U,icon:Q,sx:{fontSize:16,color:"common.white"}})})]})]})]}),children:e.jsx(H,{onClick:()=>h(a),children:e.jsx(d,{component:U,icon:Q,sx:{fontSize:16}})})}),e.jsxs(N,{variant:"outlined",color:"primary",size:"small",onClick:R,disabled:x,children:[e.jsx(d,{component:U,icon:Dt,sx:{fontSize:16,animation:x?"spin 1s linear infinite":"none",mr:.5}}),k("notification.resend")]})]})]}),e.jsxs(d,{children:[e.jsxs(S,{variant:"h6",children:[k("webhookEndpoint.response")," (",n.responseStatus,")"]}),e.jsx(X,{language:"json",children:JSON.stringify(n.responseBody,null,2)})]}),e.jsxs(d,{children:[e.jsx(D,{direction:"row",alignItems:"center",spacing:1,children:e.jsx(S,{variant:"h6",children:k("webhookEndpoint.request")})}),e.jsx(X,{language:"json",sx:{margin:0},children:JSON.stringify(n.event,null,2)})]})]}),(i==null?void 0:i.list.length)===0&&p&&e.jsxs(d,{children:[e.jsx(D,{direction:"row",alignItems:"center",spacing:1,children:e.jsx(S,{variant:"h6",children:k("webhookEndpoint.eventData")})}),e.jsx(X,{language:"json",sx:{margin:0},children:JSON.stringify(p.data,null,2)})]})]})]})}fe.propTypes={eventId:o.string,webhookEndpointId:o.string,event:o.shape({type:o.string,data:o.object,request:o.object,requestInfo:o.object})};fe.defaultProps={eventId:"",webhookEndpointId:"",event:null};const zt=de(ne)`
1
+ import{a as _,a3 as q,k as ve,r as se,br as Ee,bs as Ce,bt as Se,I as U,bY as Q,bZ as X,a5 as Me,ac as Le,bG as _e}from"./vendor-ux-did-connect-DVX9lQ8a.js";import{t as Be,l as Te,j as Fe}from"./vendor-hooks-BFlOfe0M.js";import{r as C,b as ie}from"./vendor-react-DEoibe3W.js";import{d as re}from"./InfoOutlined-C8ZBPUhD.js";import{i as He,v as Ne}from"./vendor-arcblock-DiSm3oUX.js";import{D as V,aC as Ue,aD as Z,G as Ie,y as Ke}from"./index-CMYalRl2.js";import{u as Y}from"./dashboard-B2X6c8E8.js";import{u as Ve}from"./use-mobile-DwzRjjku.js";import{H as o,j as e,D as Ye,aj as Ge,t as Je,aa as d,O as je,T as S,ab as H,ak as le,z as Qe,y as N,bs as ye,bR as ee,ad as A,L as te,A as oe,aq as Xe,E as M,I as F,C as Ze,bq as et,al as D,cg as tt,X as Re,a9 as ae,s as de,as as ne,bp as ot,b7 as nt,b8 as st,an as it,b$ as rt,v as lt,ch as at,ci as dt,cj as ct,ck as ut}from"./vendor-mui-core-Bq8gXTan.js";import{d as pt}from"./ExpandLess-Da2Rv9Ox.js";import{b as De,z as ht,A as xt}from"./vendor-utils-BotmZdBm.js";import{C as mt}from"./confirm-DApmnpvm.js";import{A as ft}from"./actions-DYQW2ChM.js";import{T as we}from"./table-tips-BW6G2sKO.js";import"./lottie-web-jYmAQWuC.js";import"./useLocalStorage-DyVGBDlt.js";import"./index-8eXqqyHQ.js";import"./PlayArrow-RVSfCmrB.js";import"./get-safe-url-B8xlSMyD.js";import"./session-Bkvl2PSP.js";import"./use-blocklet-logo-CTCMbFiC.js";import"./dot-iw3hN9HL.js";import"./useAsync-DVHp96Uu.js";import"./useSetState-CWq0AVWn.js";import"./use-mobile-CtTQsfXN.js";import"./MoreHoriz-Ba9rYlyz.js";const gt=s=>{var b,T;const[c,p]=C.useState(null),[v,l]=C.useState(!s),[k,u]=C.useState(null),{blocklet:f}=Ie(),i=(T=(b=f==null?void 0:f.site)==null?void 0:b.domainAliases[0])==null?void 0:T.value,y=C.useMemo(()=>{const j={};return c&&(c.sources.forEach(n=>{j[n.did]={source:n,events:[],count:0}}),c.events.forEach(n=>{j[n.source]&&(j[n.source].events.push(n),j[n.source].count+=1)})),j},[c]),w=async()=>{try{if(l(!0),!i)return;const n=await(await fetch(`https://${i}${ve.WELLKNOWN_SERVICE_PATH_PREFIX}/openevent.json`)).json();p(n),u(null)}catch(j){u(j instanceof Error?j:new Error(String(j)))}finally{l(!1)}};return C.useEffect(()=>{w()},[i]),{openEvent:c,setOpenEvent:p,eventsBySource:y,loading:v,error:k,loadData:w}};function ce({eventsBySource:s,selectedEvents:c,setSelectedEvents:p,error:v}){const{t:l}=_(),[k,u]=C.useState({}),f=C.useMemo(()=>{const n={};return Object.entries(s).forEach(([h,{events:x}])=>{const E=x.filter(I=>c[`${I.type}-${I.source}`]).length;n[h]=E}),n},[s,c]),i=C.useMemo(()=>Object.values(f).reduce((n,h)=>n+h,0),[f]),y=C.useMemo(()=>Object.values(s).reduce((n,{events:h})=>n+h.length,0),[s]),w=(n,h)=>{h.stopPropagation(),u({...k,[n]:!k[n]})},b=n=>{const h=`${n.type}-${n.source}`;p(x=>({...x,[h]:!x[h]}))},T=(n,h)=>{const x={};n.forEach(E=>{const I=`${E.type}-${E.source}`;x[I]=!h}),p(E=>({...E,...x}))},j=n=>{const h={};Object.values(s).forEach(({events:x})=>{x.forEach(E=>{const I=`${E.type}-${E.source}`;h[I]=n.target.checked})}),p(h)};return e.jsxs(d,{sx:{width:"100%"},children:[e.jsxs(d,{sx:{display:"flex",alignItems:"center",mb:1,mt:1},children:[e.jsx(ye,{control:e.jsx(ee,{onChange:j,checked:i>0&&i===y}),label:e.jsxs(d,{sx:{display:"flex",alignItems:"center",cursor:"pointer"},children:[l("webhookEndpoint.selectAllEvents"),e.jsx(d,{sx:{display:"flex",alignItems:"center"},children:e.jsx(A,{title:l("webhookEndpoint.selectAllEventsTooltip"),placement:"right",children:e.jsx(re,{fontSize:"small",sx:{ml:.5,cursor:"help"}})})})]}),sx:{m:0}}),i>0&&e.jsx(S,{variant:"body2",color:"primary",sx:{ml:"auto"},children:l("webhookEndpoint.selectedEventsCount",{count:i})})]}),e.jsx(d,{sx:{maxHeight:"50vh",overflow:"auto"},children:e.jsx(te,{disablePadding:!0,sx:{border:"1px solid",borderColor:"divider",borderRadius:"4px"},children:Object.entries(s).map(([n,{source:h,events:x,count:E}],I)=>{const O=f[n]>0,R=f[n]===x.length&&x.length>0,$=k[n];return e.jsxs(ie.Fragment,{children:[e.jsx(oe,{sx:{borderBottom:({palette:r})=>I<Object.keys(s).length-1?`1px solid ${r.divider}`:"none",px:2,py:1.5,"&:hover":{bgcolor:"rgba(0, 0, 0, 0.02)"}},children:e.jsxs(d,{sx:{display:"flex",width:"100%",justifyContent:"space-between",alignItems:"center"},onClick:r=>{r.target.closest(".MuiFormControlLabel-root")||w(n,r)},children:[e.jsx(d,{sx:{display:"flex",alignItems:"center"},children:x.length>0&&e.jsx(ye,{control:e.jsx(ee,{checked:R,indeterminate:O&&!R,onChange:r=>{r.stopPropagation(),T(x,R)}}),label:e.jsxs(d,{sx:{display:"flex",alignItems:"center",gap:1},children:[h.logo&&e.jsx(Xe,{src:h.logo,sx:{width:24,height:24}}),e.jsx(d,{children:h.title||n}),O&&e.jsx(M,{label:l("webhookEndpoint.selectedCount",{count:f[n]}),size:"small",sx:{mt:"2px",height:"20px",fontSize:"12px",bgcolor:r=>`${r.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",color:"text.secondary",sx:{mr:1},children:l("webhookEndpoint.eventsCount",{count:E})}),x.length>0&&e.jsx(F,{size:"small",edge:"end",children:$?e.jsx(pt,{}):e.jsx(He,{})})]})]})}),x.length>0&&e.jsx(Ze,{in:$,timeout:"auto",unmountOnExit:!0,children:e.jsx(te,{disablePadding:!0,sx:{pl:2,pr:2,py:1,bgcolor:"rgba(0, 0, 0, 0.01)"},children:x.map(r=>{const a=`${r.type}-${r.source}`,t=!!c[a];return e.jsx(oe,{dense:!0,sx:{py:.75},onClick:()=>b(r),children:e.jsxs(d,{sx:{display:"flex",alignItems:"flex-start",width:"100%"},children:[e.jsx(ee,{checked:t,sx:{mr:1}}),e.jsxs(d,{children:[e.jsx(S,{variant:"body1",sx:{cursor:"pointer",color:"text.primary"},children:r.type}),e.jsx(S,{variant:"caption",color:"text.secondary",sx:{display:"block",cursor:"pointer"},children:r.description})]})]})},a)})})})]},n)})})}),v&&e.jsx(et,{error:!0,sx:{mt:1},children:v})]})}ce.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};ce.defaultProps={error:null};function ue({id:s,url:c,description:p,enabledEvents:v,onSubmit:l,onClose:k}){var r;const{t:u}=_(),[f,i]=C.useState({}),{teamDid:y}=Y(),{api:w}=V(),{loading:b,error:T,eventsBySource:j}=gt(),{control:n,handleSubmit:h,formState:{errors:x},reset:E,setValue:I,trigger:O}=Ue({defaultValues:{url:"",description:""}});C.useEffect(()=>{const a=Object.values(f).some(t=>t);I("selectedEvents",a?"valid":""),O("selectedEvents")},[f,I,O]);const R=()=>{i({}),E(),k()},$=async a=>{const t=Object.keys(f).filter(m=>f[m]),g={url:a.url,description:a.description,enabledEvents:t.map(m=>{const[P,z]=m.split("-");return!P||!z?null:{type:P,source:z}}).filter(Boolean)};try{if(s){const m=await w.updateWebhookEndpoint({input:{teamDid:y,id:s,data:g}});q.success(`${u("webhookEndpoint.updateWebhook")} ${u("webhookEndpoint.success")}`),l(m)}else{const m=await w.createWebhookEndpoint({input:{teamDid:y,input:g}});q.success(`${u("webhookEndpoint.createWebhook")} ${u("webhookEndpoint.success")}`),l(m)}}catch(m){q.error(m==null?void 0:m.message)}R()};return C.useEffect(()=>{E({url:c,description:p}),i(v.reduce((a,t)=>(a[`${t.type}-${t.source}`]=!0,a),{}))},[E,i,c,p,v]),e.jsx(Ye,{open:!0,onClose:R,maxWidth:"lg",fullWidth:!0,sx:{"& .MuiDialog-paper":{minHeight:600}},children:e.jsxs("form",{onSubmit:h($),children:[e.jsx(Ge,{children:u(s?"webhookEndpoint.editWebhookTitle":"webhookEndpoint.createWebhookTitle")}),e.jsx(Je,{children:e.jsxs(d,{sx:{display:"flex",flexDirection:"column",gap:2,mt:2},children:[e.jsx(Z,{name:"url",control:n,rules:{required:u("webhookEndpoint.validation.urlRequired"),pattern:{value:/^(http|https):\/\/[^ "]+$/,message:u("webhookEndpoint.validation.urlInvalid")}},render:({field:a})=>{var t;return e.jsx(je,{...a,label:u("webhookEndpoint.url.label"),fullWidth:!0,error:!!x.url,helperText:(t=x.url)==null?void 0:t.message})}}),e.jsx(Z,{name:"description",control:n,rules:{required:u("webhookEndpoint.validation.descriptionRequired")},render:({field:a})=>{var t;return e.jsx(je,{...a,label:u("webhookEndpoint.description.label"),fullWidth:!0,multiline:!0,minRows:2,maxRows:4,error:!!x.description,helperText:(t=x.description)==null?void 0:t.message})}}),e.jsx(Z,{name:"selectedEvents",control:n,rules:{required:u("webhookEndpoint.validation.eventRequired")},render:({field:a})=>e.jsx("input",{type:"hidden",...a})}),!b&&j&&Object.keys(j).length>0&&e.jsx(ce,{eventsBySource:j,selectedEvents:f,setSelectedEvents:i,error:(r=x.selectedEvents)==null?void 0:r.message}),!b&&(!j||Object.keys(j).length===0)&&e.jsx(S,{color:"text.secondary",children:u("webhookEndpoint.noAvailableEvents")}),b&&e.jsx(d,{sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"500px",width:"100%"},children:e.jsx(H,{size:20})}),T&&e.jsx(le,{severity:"error",children:u("webhookEndpoint.loadingError",{message:T==null?void 0:T.message})})]})}),e.jsxs(Qe,{sx:{p:"8px 24px 24px"},children:[e.jsx(N,{onClick:R,children:u("common.cancel")}),e.jsx(N,{type:"submit",variant:"contained",color:"primary",children:u(s?"webhookEndpoint.updateWebhook":"webhookEndpoint.saveWebhook")})]})]})})}ue.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};ue.defaultProps={id:null,url:"",description:"",enabledEvents:[],onClose:()=>{}};function Pe(s){switch(s){case"enabled":return"success";case"disabled":default:return"default"}}const bt=(s="en")=>s==="tw"?"zh":s;function K(s,c="YYYY-MM-DD HH:mm:ss",p="en"){return s?Ke(s).locale(bt(p)).format(c):"-"}function jt(s){return typeof s=="number"?!1:De(s)}function yt(s){return s>=200&&s<300}function W(s){const c=jt(s.value);return e.jsxs(e.Fragment,{children:[e.jsxs(D,{direction:"column",alignItems:"flex-start",children:[e.jsxs(S,{component:"div",variant:"body1",mb:1,color:"text.primary",sx:{fontWeight:500},children:[s.label,!!s.tip&&e.jsx(A,{title:s.tip,children:e.jsx(tt,{fontSize:"small"})})]}),e.jsx(S,{component:"div",variant:"body1",color:c?"text.disabled":"text.secondary",sx:{width:"100%",minHeight:"24px"},children:c?"-":s.value})]}),s.divider&&e.jsx(Re,{orientation:"vertical",flexItem:!0})]})}W.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};W.defaultProps={tip:"",divider:!1};function pe(s){return e.jsxs(D,{className:"section-header",direction:"row",justifyContent:"space-between",alignItems:"center",flexWrap:"wrap",gap:1,sx:{mb:s.mb,mt:s.mt,pb:1},children:[e.jsx(S,{variant:"h3",sx:{fontSize:{xs:"18px",md:"1.09375rem"}},component:"div",children:s.title}),s.children]})}pe.propTypes={title:o.oneOfType([o.string,o.node]).isRequired,children:o.node,mb:o.number,mt:o.number};pe.defaultProps={children:null,mb:1.5,mt:1.5};var he={},wt=ae;Object.defineProperty(he,"__esModule",{value:!0});var ze=he.default=void 0,kt=wt(se()),vt=e;ze=he.default=(0,kt.default)((0,vt.jsx)("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2M7 13.5c-.83 0-1.5-.67-1.5-1.5s.67-1.5 1.5-1.5 1.5.67 1.5 1.5-.67 1.5-1.5 1.5m5 0c-.83 0-1.5-.67-1.5-1.5s.67-1.5 1.5-1.5 1.5.67 1.5 1.5-.67 1.5-1.5 1.5m5 0c-.83 0-1.5-.67-1.5-1.5s.67-1.5 1.5-1.5 1.5.67 1.5 1.5-.67 1.5-1.5 1.5"}),"Pending");var xe={},Et=ae;Object.defineProperty(xe,"__esModule",{value:!0});var Oe=xe.default=void 0,Ct=Et(se()),St=e;Oe=xe.default=(0,Ct.default)((0,St.jsx)("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2m0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8m4.59-12.42L10 14.17l-2.59-2.58L6 13l4 4 8-8z"}),"CheckCircleOutlined");var me={},Tt=ae;Object.defineProperty(me,"__esModule",{value:!0});var We=me.default=void 0,It=Tt(se()),Rt=e;We=me.default=(0,It.default)((0,Rt.jsx)("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2m1 15h-2v-2h2zm0-4h-2V7h2z"}),"ErrorOutlined");const Dt={width:24,height:24,body:'<path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M20 11A8.1 8.1 0 0 0 4.5 9M4 5v4h4m-4 4a8.1 8.1 0 0 0 15.5 2m.5 4v-4h-4"/>'},Pt=s=>{const c={};return s.forEach(p=>{var l;const v=new Date(p.createdAt).toLocaleDateString();c[v]||(c[v]=[]),(l=c[v])==null||l.push(p)}),c};function fe({eventId:s,webhookEndpointId:c,event:p}){const{api:v,ws:{useSubscription:l}}=V(),{t:k}=_(),{teamDid:u}=Y(),{blocklet:f}=Ie(),{data:i,loadMore:y,loadingMore:w,loading:b,mutate:T}=Be(t=>{const m=t?Math.ceil(t.list.length/15)+1:1;return v.getWebhookAttempts({input:{teamDid:u,input:{eventId:s,webhookId:c},paging:{page:m,pageSize:15}}})},{reloadDeps:[s,c]}),j=(i==null?void 0:i.list)||[],[n,h]=C.useState(null),[x,E]=C.useState(!1),I=Pt(j);if(C.useEffect(()=>{!n&&(i!=null&&i.list.length)&&h(i.list[0])},[i==null?void 0:i.list.length,n]),l(ve.EVENTS.WEBHOOK_ATTEMPT,t=>{T(g=>{var P,z;if(g.list.find(L=>L.id===t.id)){const L=g.list.map(B=>B.id===t.id?{...B,...t}:B);return{...g,list:L}}return t.endpoint=(P=g.list[0])==null?void 0:P.endpoint,t.event=(z=g.list[0])==null?void 0:z.event,{...g,list:[t,...g.list]}})},[]),b)return e.jsx(H,{});const O=i&&i.list.length<i.paging.total,R=async()=>{n&&(E(!0),await v.retryWebhookAttempt({input:{teamDid:u,eventId:n.event.id,webhookId:c,attemptId:n.id}}).finally(()=>{setTimeout(()=>{E(!1)},1e3)}))},$=t=>{var g,m,P,z,L;if(t.responseBody&&((g=t.responseBody)!=null&&g.sessionId)&&((m=t.responseBody)!=null&&m.projectId)&&((P=t.responseBody)!=null&&P.agentId)){const B=(L=(z=f==null?void 0:f.site)==null?void 0:z.domainAliases[0])==null?void 0:L.value,G=(f.children||[]).find(J=>{var be;return((be=J==null?void 0:J.meta)==null?void 0:be.name)==="ai-studio"}),qe=ht(xt(`https://${B}`,(G==null?void 0:G.mountPoint)||"","projects",t.responseBody.projectId,"logs/main"),{sessionId:t.responseBody.sessionId,agentId:t.responseBody.agentId});return e.jsx(F,{sx:{fontSize:20},onClick:()=>window.open(qe,"_blank"),children:e.jsx(d,{component:U,icon:Q})})}return null},r=t=>t.status==="pending"?e.jsx(ze,{color:"warning"}):yt(t.responseStatus)?e.jsx(Oe,{color:"success"}):e.jsx(We,{color:"error"}),a=(n==null?void 0:n.triggeredFrom)&&((i==null?void 0:i.list)||[]).find(t=>t.id===n.triggeredFrom);return e.jsxs(zt,{container:!0,spacing:{xs:0,md:1},sx:{height:1},children:[e.jsx(ne,{item:!0,xs:12,md:4,height:1,children:De(Object.keys(I))?e.jsx(S,{color:"text.secondary",children:k("webhookEndpoint.waitingForEvents")}):e.jsxs(e.Fragment,{children:[e.jsx(te,{sx:{maxHeight:"calc(100% - 40px)",py:0,overflowY:"auto"},children:Object.entries(I).map(([t,g])=>e.jsxs(ie.Fragment,{children:[e.jsx(ot,{sx:{p:0},children:t}),g.map(m=>e.jsxs(oe,{sx:{cursor:"pointer",px:1},onClick:()=>h(m),selected:n&&(n==null?void 0:n.id)===(m==null?void 0:m.id),secondaryAction:e.jsx(S,{color:"text.secondary",children:K(m.createdAt,"HH:mm:ss")}),children:[e.jsx(nt,{sx:{minWidth:0,mr:1.5},children:r(m)}),e.jsx(st,{primary:e.jsx(S,{color:"text.primary",children:m.event.type})})]},m.id))]},t))}),O&&e.jsx(d,{display:"flex",justifyContent:"center",alignItems:"center",width:1,children:e.jsx(N,{variant:"text",type:"button",color:"inherit",onClick:y,disabled:w,sx:{color:t=>t.palette.text.disabled},children:k(w?"webhookEndpoint.loadingMore":"webhookEndpoint.loadMore")})})]})}),e.jsxs(ne,{item:!0,xs:12,md:8,height:1,children:[n&&e.jsxs(D,{height:1,overflow:"auto",direction:"column",spacing:2,sx:{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:k(`common.${n.status}`)}),e.jsx(d,{children:$(n)})]}),e.jsxs(d,{sx:{display:"flex",alignItems:"center",gap:1},children:[a&&e.jsx(A,{componentsProps:{tooltip:{sx:{maxWidth:400}}},placement:"left",title:e.jsxs(D,{gap:1,sx:{cursor:"pointer",".did-address-text":{color:"common.white"}},onClick:()=>h(a),children:[e.jsx(Ee,{showDid:!0,did:n.triggeredBy,cardType:Ce.Detailed,infoType:Se.Minimal,sx:{border:0,padding:0,minWidth:0,".MuiTypography-root":{color:"common.white",fontWeight:400}}}),e.jsx(Re,{}),e.jsxs(d,{sx:{display:"flex",flexDirection:"column"},children:[e.jsx(S,{variant:"body2",sx:{color:"primary.main"},children:k("webhookEndpoint.triggeredFrom")}),e.jsxs(d,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(S,{variant:"body2",children:n.id}),e.jsx(F,{onClick:()=>h(a),children:e.jsx(d,{component:U,icon:Q,sx:{fontSize:16,color:"common.white"}})})]})]})]}),children:e.jsx(F,{onClick:()=>h(a),children:e.jsx(d,{component:U,icon:Q,sx:{fontSize:16}})})}),e.jsxs(N,{variant:"outlined",color:"primary",size:"small",onClick:R,disabled:x,children:[e.jsx(d,{component:U,icon:Dt,sx:{fontSize:16,animation:x?"spin 1s linear infinite":"none",mr:.5}}),k("notification.resend")]})]})]}),e.jsxs(d,{children:[e.jsxs(S,{variant:"h6",children:[k("webhookEndpoint.response")," (",n.responseStatus,")"]}),e.jsx(X,{language:"json",children:JSON.stringify(n.responseBody,null,2)})]}),e.jsxs(d,{children:[e.jsx(D,{direction:"row",alignItems:"center",spacing:1,children:e.jsx(S,{variant:"h6",children:k("webhookEndpoint.request")})}),e.jsx(X,{language:"json",sx:{margin:0},children:JSON.stringify(n.event,null,2)})]})]}),(i==null?void 0:i.list.length)===0&&p&&e.jsxs(d,{children:[e.jsx(D,{direction:"row",alignItems:"center",spacing:1,children:e.jsx(S,{variant:"h6",children:k("webhookEndpoint.eventData")})}),e.jsx(X,{language:"json",sx:{margin:0},children:JSON.stringify(p.data,null,2)})]})]})]})}fe.propTypes={eventId:o.string,webhookEndpointId:o.string,event:o.shape({type:o.string,data:o.object,request:o.object,requestInfo:o.object})};fe.defaultProps={eventId:"",webhookEndpointId:"",event:null};const zt=de(ne)`
2
2
  @keyframes spin {
3
3
  to {
4
4
  transform: rotate(360deg);
5
5
  }
6
6
  }
7
- `;function Ae({id:s,onClose:c}){var y,w,b,T;const{t:p}=_(),{api:v}=V(),{teamDid:l}=Y(),{loading:k,error:u,data:f}=Te(()=>v.getWebhookEndpoint({input:{teamDid:l,id:s}})),i=f==null?void 0:f.data;return u?e.jsx(le,{severity:"error",children:u.message}):k||!i?e.jsx(d,{display:"flex",justifyContent:"center",alignItems:"center",height:1,width:1,children:e.jsx(F,{})}):e.jsxs(Ot,{direction:"column",sx:{height:{xs:"auto",md:1}},children:[e.jsxs(d,{children:[e.jsxs(D,{direction:"row",justifyContent:"space-between",alignItems:"center",children:[e.jsx(D,{flex:1,width:0,children:e.jsxs(d,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(S,{variant:"h5",fontWeight:600,sx:{overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis"},children:i.description}),e.jsx($,{title:i.url,children:e.jsx(re,{sx:{fontSize:"16px",marginTop:"2px"}})})]})}),e.jsx(D,{direction:"row",alignItems:"center",children:e.jsx(H,{edge:"end",color:"inherit",onClick:c,children:e.jsx(rt,{})})})]}),e.jsx(d,{mt:2,children:e.jsxs(D,{className:"section-body",direction:{xs:"column",md:"row"},spacing:{xs:1,md:3},justifyContent:"flex-start",flexWrap:"wrap",sx:{pt:2,mt:2,borderTop:"1px solid #eee"},children:[e.jsx(W,{label:p("common.status"),value:e.jsx(M,{size:"small",variant:"filled",label:i.status,color:Pe(i.status),sx:{borderRadius:"4px",lineHeight:"20px",textTransform:"capitalize"}}),divider:!0}),e.jsx(W,{label:p("webhookEndpoint.listen"),value:e.jsx($,{arrow:!0,title:e.jsx("ul",{style:{padding:0,margin:0},children:i.enabledEvents.map(j=>e.jsx("li",{style:{fontSize:"0.7875rem"},children:j==null?void 0:j.type},j))}),children:e.jsx(M,{size:"small",variant:"filled",label:p("webhookEndpoint.eventsCount",{count:i.enabledEvents.length}),sx:{borderRadius:"4px",lineHeight:"20px",textTransform:"capitalize"}})}),divider:!0}),e.jsx(W,{label:p("webhookEndpoint.version"),value:i.apiVersion,divider:!0}),e.jsx(W,{label:p("common.createdAt"),value:K(i.createdAt),divider:!0}),e.jsx(W,{label:p("common.updatedAt"),value:K(i.updatedAt),divider:!0}),e.jsx(W,{label:p("common.createdBy"),value:e.jsx($,{arrow:!0,title:(y=i.createUser)==null?void 0:y.did,children:e.jsx(M,{size:"small",variant:"filled",label:(w=i.createUser)==null?void 0:w.fullName,sx:{borderRadius:"4px",lineHeight:"20px",textTransform:"capitalize"}})}),divider:!0}),e.jsx(W,{label:p("common.updatedBy"),value:e.jsx($,{arrow:!0,title:(b=i.updateUser)==null?void 0:b.did,children:e.jsx(M,{size:"small",variant:"filled",label:(T=i.updateUser)==null?void 0:T.fullName,sx:{borderRadius:"4px",lineHeight:"20px",textTransform:"capitalize"}})})})]})})]}),e.jsxs(D,{className:"section",flex:1,height:0,overflow:"hidden",children:[e.jsx(pe,{title:p("webhookEndpoint.attempts"),mb:0,mt:4}),e.jsx(D,{height:0,flex:1,overflow:"hidden",children:e.jsx(fe,{webhookEndpointId:i.id})})]})]})}Ae.propTypes={id:o.string.isRequired,onClose:o.func.isRequired};const Ot=de(D)``;function $e({open:s,onClose:c,id:p}){return e.jsx(it,{anchor:"right",open:s,onClose:c,PaperProps:{sx:{width:"90vw",maxWidth:"1200px"}},children:e.jsx(d,{sx:{height:"100vh",p:3},children:e.jsx(Ae,{id:p,onClose:c})})})}$e.propTypes={open:o.bool.isRequired,onClose:o.func.isRequired,id:o.string.isRequired};function ke(){return null}const ge=ie.memo(({options:s,columns:c,toolbar:p=!0,footer:v=!0,hasRowLink:l=!1,emptyNodeText:k="",...u})=>{const{locale:f}=_(),i=lt(b=>b.breakpoints.down("md")),y={print:!1,download:!1,filter:!1,selectableRows:"none",rowsPerPage:i?5:10,rowsPerPageOptions:[5,10,20,50,100],searchDebounceTime:300,tableBodyHeight:"100%",loading:!0},w={};return p||(w.TableToolbar=ke),v||(w.TableFooter=ke),e.jsx(Wt,{locale:f,options:{...y,...s},columns:(c||[]).map(b=>(b.options=b.options||{},b.options.filter=b.options.filter||!1,b.options.sort=b.options.sort||!1,b)),emptyNode:e.jsx(Me,{children:k}),...u,components:w,hasRowLink:l,isMobile:i})});ge.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};ge.defaultProps={options:{},columns:[],toolbar:!0,footer:!0,hasRowLink:!1,emptyNodeText:null,durable:"",durableKeys:[],data:[],loading:!1,onChange:()=>{},title:null,components:{}};const Wt=de(Le)``,At=ge;function ao(){const{teamDid:s}=Y(),c=Ve(),p=`webhook-endpoints-${s}`,v=_e(p),{t:l,locale:k}=_(),{api:u}=V(),[f,i]=C.useState(""),[y,w]=C.useState({webhookDetail:{open:!1,id:null},createEdit:{open:!1,id:null,url:"",description:"",enabledEvents:[]},deleteConfirm:null}),[b,T]=He(p,{defaultValue:{pageSize:v.rowsPerPage||20,page:v.page?v.page+1:1}}),{loading:j,error:n,data:h,refresh:x}=Te(()=>u.getWebhookEndpoints({input:{teamDid:s,paging:{page:b.page,pageSize:b.pageSize}}}));C.useEffect(()=>{x()},[b,x]);const E=C.useCallback(async(r,a)=>{try{await u.updateWebhookEndpoint({input:{teamDid:s,id:r.id,data:{status:a?"disabled":"enabled"}}}),x(),q.success(`${l(a?"webhookEndpoint.disable":"webhookEndpoint.enable")}${l("webhookEndpoint.success")}`)}catch(t){q.error(t==null?void 0:t.message)}},[u,s,x,l]),I=C.useCallback(async r=>{try{await u.deleteWebhookEndpoint({input:{teamDid:s,id:r}}),x(),w(a=>({...a,deleteConfirm:null})),q.success(`${l("common.delete")}${l("webhookEndpoint.success")}`)}catch(a){q.error(a==null?void 0:a.message)}},[u,s,x,l]),O=(r,a)=>{let t=r.page+1;const g=r.searchText||"";if(g!==f){i(g);return}if(a==="changePage"||a==="changeRowsPerPage"){a!=="changePage"&&(t=1);const m={page:t,pageSize:r.rowsPerPage};i(""),T(m)}};if(n)return e.jsx(le,{severity:"error",children:n.message});if(j||!h)return e.jsx(d,{display:"flex",justifyContent:"center",alignItems:"center",width:1,height:500,children:e.jsx(F,{})});const R=((h==null?void 0:h.list)||[]).filter(r=>{if(!f)return!0;const a=f.toLowerCase();return r.description.toLowerCase().includes(a)||r.url.toLowerCase().includes(a)}),A=[{label:"URL",name:"url",options:{customBodyRenderLite:(r,a)=>{const t=R[a];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:g=>{g.stopPropagation()},children:e.jsx($,{title:t.url,children:e.jsx(re,{sx:{fontSize:"15px",marginTop:"1px"}})})})]})}}},{label:"Events",name:"events",options:{customBodyRenderLite:(r,a)=>{const t=R[a];return e.jsx(d,{sx:{display:"flex",alignItems:"center",gap:1,flexWrap:"wrap"},children:t.enabledEvents.map(g=>e.jsx(M,{size:"small",variant:"filled",label:g.type,sx:{borderRadius:"4px",textTransform:"capitalize"}},`${t.source}-${g.type}`))})}}},{label:l("common.status"),name:"status",options:{customBodyRenderLite:(r,a)=>{const t=R[a];return e.jsx(M,{size:"small",variant:"filled",label:l(`webhookEndpoint.${t==null?void 0:t.status}`),color:Pe(t==null?void 0:t.status),sx:{borderRadius:"4px",textTransform:"capitalize"}},`status-${t.status}`)}}},{label:l("common.createdAt"),name:"createdAt",minWidth:200,options:{customBodyRender:r=>K(r)}},{label:l("common.createdBy"),name:"createUser",width:100,options:{customBodyRender:r=>r?e.jsx(Ee,{showDid:!0,did:r==null?void 0:r.did,cardType:Ce.Detailed,infoType:Se.Minimal,sx:{border:0,padding:0}}):"-"}},{label:l("common.actions"),name:"actions",width:100,align:"center",verticalKeyAlign:"center",options:{customBodyRenderLite:(r,a)=>{const t=R[a],g=(t==null?void 0:t.status)==="enabled";return e.jsx(ft,{actions:[{icon:g?e.jsx(at,{}):e.jsx(dt,{}),text:l(g?"webhookEndpoint.disable":"webhookEndpoint.enable"),onClick:m=>{m.stopPropagation(),E(t,g)}},{icon:e.jsx(ct,{}),text:l("common.edit"),onClick:m=>{m.stopPropagation(),w(P=>({...P,createEdit:{open:!0,id:t.id,url:t.url,description:t.description,enabledEvents:t.enabledEvents}}))}},{icon:e.jsx(ut,{}),text:l("common.delete"),onClick:m=>{m.stopPropagation(),w(P=>({...P,deleteConfirm:{title:l("webhookEndpoint.deleteWebhook.title"),description:l("webhookEndpoint.deleteWebhook.description"),confirm:l("common.confirm"),cancel:l("common.cancel"),onConfirm:()=>I(t.id),onCancel:()=>w(z=>({...z,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:[c?e.jsx(we,{title:l("webhookEndpoint.listTitle"),tooltipTitle:l("webhookEndpoint.tooltipTitle"),link:`https://www.arcblock.io/docs/blocklet-developer/${k}/webhook`}):null,e.jsx(At,{durable:p,durableKeys:["page","rowsPerPage"],data:R,columns:A,options:{count:h.count,page:b.page-1,rowsPerPage:b.pageSize,viewColumns:!1,onRowClick:(r,{dataIndex:a})=>{const t=h.list[a];w(g=>({...g,webhookDetail:{open:!0,id:t.id}}))}},loading:j,onChange:O,emptyNodeText:e.jsx(D,{gap:1,children:l("webhookEndpoint.noWebhooksAdded")}),title:c?null:e.jsx(we,{title:l("webhookEndpoint.listTitle"),tooltipTitle:l("webhookEndpoint.tooltipTitle"),link:`https://www.arcblock.io/docs/blocklet-developer/${k}/webhook`}),customButtons:[e.jsxs(N,{sx:{color:"common.white"},edge:"end",variant:"contained",color:"primary",onClick:()=>w(r=>({...r,createEdit:{...r.createEdit,open:!0}})),className:"rule-action",children:[j?e.jsx(F,{size:16}):e.jsx(Ne,{style:{fontSize:16}}),l("common.create")]},"add")]}),y.webhookDetail.open&&e.jsx($e,{open:!0,onClose:()=>w(r=>({...r,webhookDetail:{open:!1,id:null}})),id:y.webhookDetail.id}),y.createEdit.open&&e.jsx(ue,{onSubmit:x,...y.createEdit,onClose:()=>w(r=>({...r,createEdit:{id:null,url:"",description:"",enabledEvents:[],open:!1}}))}),y.deleteConfirm&&e.jsx(mt,{title:y.deleteConfirm.title,description:y.deleteConfirm.description,confirm:y.deleteConfirm.confirm,cancel:y.deleteConfirm.cancel,params:y.deleteConfirm.params,onConfirm:y.deleteConfirm.onConfirm,onCancel:y.deleteConfirm.onCancel})]})}export{ao as default};
7
+ `;function $e({id:s,onClose:c}){var y,w,b,T;const{t:p}=_(),{api:v}=V(),{teamDid:l}=Y(),{loading:k,error:u,data:f}=Te(()=>v.getWebhookEndpoint({input:{teamDid:l,id:s}})),i=f==null?void 0:f.data;return u?e.jsx(le,{severity:"error",children:u.message}):k||!i?e.jsx(d,{display:"flex",justifyContent:"center",alignItems:"center",height:1,width:1,children:e.jsx(H,{})}):e.jsxs(Ot,{direction:"column",sx:{height:{xs:"auto",md:1}},children:[e.jsxs(d,{children:[e.jsxs(D,{direction:"row",justifyContent:"space-between",alignItems:"center",children:[e.jsx(D,{flex:1,width:0,children:e.jsxs(d,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(S,{variant:"h5",fontWeight:600,sx:{overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis"},children:i.description}),e.jsx(A,{title:i.url,children:e.jsx(re,{sx:{fontSize:"16px",marginTop:"2px"}})})]})}),e.jsx(D,{direction:"row",alignItems:"center",children:e.jsx(F,{edge:"end",color:"inherit",onClick:c,children:e.jsx(rt,{})})})]}),e.jsx(d,{mt:2,children:e.jsxs(D,{className:"section-body",direction:{xs:"column",md:"row"},spacing:{xs:1,md:3},justifyContent:"flex-start",flexWrap:"wrap",sx:{pt:2,mt:2,borderTop:"1px solid #eee"},children:[e.jsx(W,{label:p("common.status"),value:e.jsx(M,{size:"small",variant:"filled",label:i.status,color:Pe(i.status),sx:{borderRadius:"4px",lineHeight:"20px",textTransform:"capitalize"}}),divider:!0}),e.jsx(W,{label:p("webhookEndpoint.listen"),value:e.jsx(A,{arrow:!0,title:e.jsx("ul",{style:{padding:0,margin:0},children:i.enabledEvents.map(j=>e.jsx("li",{style:{fontSize:"0.7875rem"},children:j==null?void 0:j.type},j))}),children:e.jsx(M,{size:"small",variant:"filled",label:p("webhookEndpoint.eventsCount",{count:i.enabledEvents.length}),sx:{borderRadius:"4px",lineHeight:"20px",textTransform:"capitalize"}})}),divider:!0}),e.jsx(W,{label:p("webhookEndpoint.version"),value:i.apiVersion,divider:!0}),e.jsx(W,{label:p("common.createdAt"),value:K(i.createdAt),divider:!0}),e.jsx(W,{label:p("common.updatedAt"),value:K(i.updatedAt),divider:!0}),e.jsx(W,{label:p("common.createdBy"),value:e.jsx(A,{arrow:!0,title:(y=i.createUser)==null?void 0:y.did,children:e.jsx(M,{size:"small",variant:"filled",label:(w=i.createUser)==null?void 0:w.fullName,sx:{borderRadius:"4px",lineHeight:"20px",textTransform:"capitalize"}})}),divider:!0}),e.jsx(W,{label:p("common.updatedBy"),value:e.jsx(A,{arrow:!0,title:(b=i.updateUser)==null?void 0:b.did,children:e.jsx(M,{size:"small",variant:"filled",label:(T=i.updateUser)==null?void 0:T.fullName,sx:{borderRadius:"4px",lineHeight:"20px",textTransform:"capitalize"}})})})]})})]}),e.jsxs(D,{className:"section",flex:1,height:0,overflow:"hidden",children:[e.jsx(pe,{title:p("webhookEndpoint.attempts"),mb:0,mt:4}),e.jsx(D,{height:0,flex:1,overflow:"hidden",children:e.jsx(fe,{webhookEndpointId:i.id})})]})]})}$e.propTypes={id:o.string.isRequired,onClose:o.func.isRequired};const Ot=de(D)``;function Ae({open:s,onClose:c,id:p}){return e.jsx(it,{anchor:"right",open:s,onClose:c,PaperProps:{sx:{width:"90vw",maxWidth:"1200px"}},children:e.jsx(d,{sx:{height:"100vh",p:3},children:e.jsx($e,{id:p,onClose:c})})})}Ae.propTypes={open:o.bool.isRequired,onClose:o.func.isRequired,id:o.string.isRequired};function ke(){return null}const ge=ie.memo(({options:s,columns:c,toolbar:p=!0,footer:v=!0,hasRowLink:l=!1,emptyNodeText:k="",...u})=>{const{locale:f}=_(),i=lt(b=>b.breakpoints.down("md")),y={print:!1,download:!1,filter:!1,selectableRows:"none",rowsPerPage:i?5:10,rowsPerPageOptions:[5,10,20,50,100],searchDebounceTime:300,tableBodyHeight:"100%",loading:!0},w={};return p||(w.TableToolbar=ke),v||(w.TableFooter=ke),e.jsx(Wt,{locale:f,options:{...y,...s},columns:(c||[]).map(b=>(b.options=b.options||{},b.options.filter=b.options.filter||!1,b.options.sort=b.options.sort||!1,b)),emptyNode:e.jsx(Me,{children:k}),...u,components:w,hasRowLink:l,isMobile:i})});ge.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};ge.defaultProps={options:{},columns:[],toolbar:!0,footer:!0,hasRowLink:!1,emptyNodeText:null,durable:"",durableKeys:[],data:[],loading:!1,onChange:()=>{},title:null,components:{}};const Wt=de(Le)``,$t=ge;function ao(){const{teamDid:s}=Y(),c=Ve(),p=`webhook-endpoints-${s}`,v=_e(p),{t:l,locale:k}=_(),{api:u}=V(),[f,i]=C.useState(""),[y,w]=C.useState({webhookDetail:{open:!1,id:null},createEdit:{open:!1,id:null,url:"",description:"",enabledEvents:[]},deleteConfirm:null}),[b,T]=Fe(p,{defaultValue:{pageSize:v.rowsPerPage||20,page:v.page?v.page+1:1}}),{loading:j,error:n,data:h,refresh:x}=Te(()=>u.getWebhookEndpoints({input:{teamDid:s,paging:{page:b.page,pageSize:b.pageSize}}}));C.useEffect(()=>{x()},[b,x]);const E=C.useCallback(async(r,a)=>{try{await u.updateWebhookEndpoint({input:{teamDid:s,id:r.id,data:{status:a?"disabled":"enabled"}}}),x(),q.success(`${l(a?"webhookEndpoint.disable":"webhookEndpoint.enable")}${l("webhookEndpoint.success")}`)}catch(t){q.error(t==null?void 0:t.message)}},[u,s,x,l]),I=C.useCallback(async r=>{try{await u.deleteWebhookEndpoint({input:{teamDid:s,id:r}}),x(),w(a=>({...a,deleteConfirm:null})),q.success(`${l("common.delete")}${l("webhookEndpoint.success")}`)}catch(a){q.error(a==null?void 0:a.message)}},[u,s,x,l]),O=(r,a)=>{let t=r.page+1;const g=r.searchText||"";if(g!==f){i(g);return}if(a==="changePage"||a==="changeRowsPerPage"){a!=="changePage"&&(t=1);const m={page:t,pageSize:r.rowsPerPage};i(""),T(m)}};if(n)return e.jsx(le,{severity:"error",children:n.message});if(j||!h)return e.jsx(d,{display:"flex",justifyContent:"center",alignItems:"center",width:1,height:500,children:e.jsx(H,{})});const R=((h==null?void 0:h.list)||[]).filter(r=>{if(!f)return!0;const a=f.toLowerCase();return r.description.toLowerCase().includes(a)||r.url.toLowerCase().includes(a)}),$=[{label:"URL",name:"url",options:{customBodyRenderLite:(r,a)=>{const t=R[a];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:g=>{g.stopPropagation()},children:e.jsx(A,{title:t.url,children:e.jsx(re,{sx:{fontSize:"15px",marginTop:"1px"}})})})]})}}},{label:"Events",name:"events",options:{customBodyRenderLite:(r,a)=>{const t=R[a];return e.jsx(d,{sx:{display:"flex",alignItems:"center",gap:1,flexWrap:"wrap"},children:t.enabledEvents.map(g=>e.jsx(M,{size:"small",variant:"filled",label:g.type,sx:{borderRadius:"4px",textTransform:"capitalize"}},`${t.source}-${g.type}`))})}}},{label:l("common.status"),name:"status",options:{customBodyRenderLite:(r,a)=>{const t=R[a];return e.jsx(M,{size:"small",variant:"filled",label:l(`webhookEndpoint.${t==null?void 0:t.status}`),color:Pe(t==null?void 0:t.status),sx:{borderRadius:"4px",textTransform:"capitalize"}},`status-${t.status}`)}}},{label:l("common.createdAt"),name:"createdAt",minWidth:200,options:{customBodyRender:r=>K(r)}},{label:l("common.createdBy"),name:"createUser",width:100,options:{customBodyRender:r=>r?e.jsx(Ee,{showDid:!0,did:r==null?void 0:r.did,cardType:Ce.Detailed,infoType:Se.Minimal,sx:{border:0,padding:0}}):"-"}},{label:l("common.actions"),name:"actions",width:100,align:"center",verticalKeyAlign:"center",options:{customBodyRenderLite:(r,a)=>{const t=R[a],g=(t==null?void 0:t.status)==="enabled";return e.jsx(ft,{actions:[{icon:g?e.jsx(at,{}):e.jsx(dt,{}),text:l(g?"webhookEndpoint.disable":"webhookEndpoint.enable"),onClick:m=>{m.stopPropagation(),E(t,g)}},{icon:e.jsx(ct,{}),text:l("common.edit"),onClick:m=>{m.stopPropagation(),w(P=>({...P,createEdit:{open:!0,id:t.id,url:t.url,description:t.description,enabledEvents:t.enabledEvents}}))}},{icon:e.jsx(ut,{}),text:l("common.delete"),onClick:m=>{m.stopPropagation(),w(P=>({...P,deleteConfirm:{title:l("webhookEndpoint.deleteWebhook.title"),description:l("webhookEndpoint.deleteWebhook.description"),confirm:l("common.confirm"),cancel:l("common.cancel"),onConfirm:()=>I(t.id),onCancel:()=>w(z=>({...z,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:[c?e.jsx(we,{title:l("webhookEndpoint.listTitle"),tooltipTitle:l("webhookEndpoint.tooltipTitle"),link:`https://www.arcblock.io/docs/blocklet-developer/${k}/webhook`}):null,e.jsx($t,{durable:p,durableKeys:["page","rowsPerPage"],data:R,columns:$,options:{count:h.count,page:b.page-1,rowsPerPage:b.pageSize,viewColumns:!1,onRowClick:(r,{dataIndex:a})=>{const t=h.list[a];w(g=>({...g,webhookDetail:{open:!0,id:t.id}}))}},loading:j,onChange:O,emptyNodeText:e.jsx(D,{gap:1,children:l("webhookEndpoint.noWebhooksAdded")}),title:c?null:e.jsx(we,{title:l("webhookEndpoint.listTitle"),tooltipTitle:l("webhookEndpoint.tooltipTitle"),link:`https://www.arcblock.io/docs/blocklet-developer/${k}/webhook`}),customButtons:[e.jsxs(N,{sx:{color:"common.white"},edge:"end",variant:"contained",color:"primary",onClick:()=>w(r=>({...r,createEdit:{...r.createEdit,open:!0}})),className:"rule-action",children:[j?e.jsx(H,{size:16}):e.jsx(Ne,{style:{fontSize:16}}),l("common.create")]},"add")]}),y.webhookDetail.open&&e.jsx(Ae,{open:!0,onClose:()=>w(r=>({...r,webhookDetail:{open:!1,id:null}})),id:y.webhookDetail.id}),y.createEdit.open&&e.jsx(ue,{onSubmit:x,...y.createEdit,onClose:()=>w(r=>({...r,createEdit:{id:null,url:"",description:"",enabledEvents:[],open:!1}}))}),y.deleteConfirm&&e.jsx(mt,{title:y.deleteConfirm.title,description:y.deleteConfirm.description,confirm:y.deleteConfirm.confirm,cancel:y.deleteConfirm.cancel,params:y.deleteConfirm.params,onConfirm:y.deleteConfirm.onConfirm,onCancel:y.deleteConfirm.onCancel})]})}export{ao as default};
@@ -1 +1 @@
1
- import{d as A,v as R,p as w,e as p}from"./index-BXjOxZPH.js";const O=/^[a-zA-Z][a-zA-Z\d+\-.]*?:/,x=/^[a-zA-Z]:\\/;function N(e){if(typeof e!="string")throw new TypeError(`Expected a \`string\`, got \`${typeof e}\``);return x.test(e)?!1:O.test(e)}const _=["http","https"],z=["nofollow"],L={};function T(e){const r=e||L,g=r.protocols||_,u=A(r.test);return function(h){R(h,"element",function(t,y,E){if(t.tagName==="a"&&typeof t.properties.href=="string"&&u(t,y,E)){const o=t.properties.href;if(N(o)?g.includes(o.slice(0,o.indexOf(":"))):o.startsWith("//")){const n=s(r.content,t),c=n&&!Array.isArray(n)?[n]:n,i=s(r.rel,t)||z,a=typeof i=="string"?w(i):i,f=s(r.target,t),l=s(r.properties,t);if(l&&Object.assign(t.properties,p(l)),a.length>0&&(t.properties.rel=[...a]),f&&(t.properties.target=f),c){const m=s(r.contentProperties,t)||{};t.children.push({type:"element",tagName:"span",properties:p(m),children:p(c)})}}}})}}function s(e,r){return typeof e=="function"?e(r):e}export{T as r};
1
+ import{d as A,v as R,p as w,e as p}from"./index-CTlzm-Mc.js";const O=/^[a-zA-Z][a-zA-Z\d+\-.]*?:/,x=/^[a-zA-Z]:\\/;function N(e){if(typeof e!="string")throw new TypeError(`Expected a \`string\`, got \`${typeof e}\``);return x.test(e)?!1:O.test(e)}const _=["http","https"],z=["nofollow"],L={};function T(e){const r=e||L,g=r.protocols||_,u=A(r.test);return function(h){R(h,"element",function(t,y,E){if(t.tagName==="a"&&typeof t.properties.href=="string"&&u(t,y,E)){const o=t.properties.href;if(N(o)?g.includes(o.slice(0,o.indexOf(":"))):o.startsWith("//")){const n=s(r.content,t),c=n&&!Array.isArray(n)?[n]:n,i=s(r.rel,t)||z,a=typeof i=="string"?w(i):i,f=s(r.target,t),l=s(r.properties,t);if(l&&Object.assign(t.properties,p(l)),a.length>0&&(t.properties.rel=[...a]),f&&(t.properties.target=f),c){const m=s(r.contentProperties,t)||{};t.children.push({type:"element",tagName:"span",properties:p(m),children:p(c)})}}}})}}function s(e,r){return typeof e=="function"?e(r):e}export{T as r};
@@ -1,4 +1,4 @@
1
- import{j as r,T as i}from"./vendor-mui-core-wlbruq2I.js";import{a0 as p,an as x}from"./vendor-utils-B3iZkn2R.js";import{s as c}from"./vendor-ux-did-connect-CX7qG3_M.js";function h({name:t,nameFormatter:a=o=>typeof o=="string"?o.split(" ").map(f=>p(x(f))).join(" "):o,layout:n="horizontal",children:e,valueComponent:l="div",nameWidth:s=90,...m}){return r.jsxs(u,{layout:n,width:s,...m,children:[r.jsx(i,{color:"textSecondary",className:"info-row__name",children:a(t)}),e&&r.jsx(i,{color:"textPrimary",component:l,className:"info-row__value",children:e})]})}const u=c("div")`
1
+ import{j as r,T as i}from"./vendor-mui-core-Bq8gXTan.js";import{a0 as p,an as x}from"./vendor-utils-BotmZdBm.js";import{s as c}from"./vendor-ux-did-connect-DVX9lQ8a.js";function h({name:t,nameFormatter:a=o=>typeof o=="string"?o.split(" ").map(f=>p(x(f))).join(" "):o,layout:n="horizontal",children:e,valueComponent:l="div",nameWidth:s=90,...m}){return r.jsxs(u,{layout:n,width:s,...m,children:[r.jsx(i,{color:"textSecondary",className:"info-row__name",children:a(t)}),e&&r.jsx(i,{color:"textPrimary",component:l,className:"info-row__value",children:e})]})}const u=c("div")`
2
2
  display: flex;
3
3
  flex-direction: ${t=>t.layout==="vertical"?"column":"row"};
4
4
  justify-content: flex-start;