@abtnode/blocklet-services 1.17.3-beta-20251126-121502-d0926972 → 1.17.3-beta-20251128-095123-a76cb6bc

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 (238) hide show
  1. package/api/routes/oauth/client.js +11 -1
  2. package/api/routes/user.js +23 -3
  3. package/api/services/auth/connect/gen-access-key.js +1 -0
  4. package/api/services/auth/connect/verify-destroy.js +32 -31
  5. package/api/services/auth/connect/verify-elevated.js +1 -0
  6. package/api/services/notification/queue.js +34 -7
  7. package/api/util/user-util.js +48 -0
  8. package/dist/assets/{AdapterDayjs-B2uxdBcK.js → AdapterDayjs-OZNn2tpO.js} +1 -1
  9. package/dist/assets/{Google-mmkrFmA4.js → Google-PoHjNVzr.js} +1 -1
  10. package/dist/assets/{access-control-BsrYt8sR.js → access-control-2f5ZUYvn.js} +1 -1
  11. package/dist/assets/actions-CIp6hu8_.js +1 -0
  12. package/dist/assets/{add-component-core-DdA5-pKs.js → add-component-core-C8wP5DXr.js} +35 -35
  13. package/dist/assets/add-resource-D-X1I5_V.js +1 -0
  14. package/dist/assets/{addon-DMnO8VZk.js → addon-DWBAL8PD.js} +2 -2
  15. package/dist/assets/{advanced-D4bpKYrU.js → advanced-l0XvYXrR.js} +2 -2
  16. package/dist/assets/{aigne-BKYy4lDi.js → aigne-CsKyE9Oj.js} +1 -1
  17. package/dist/assets/api-DIucIOLX.js +1 -0
  18. package/dist/assets/{appearance-CoZeiSDb.js → appearance-CDE_5zqq.js} +1 -1
  19. package/dist/assets/{ar-Dz5bxvSE.js → ar-BJZY7v5z.js} +2 -2
  20. package/dist/assets/{arrow-down.svg-arX2hS9A.js → arrow-down.svg-C5rjQJG2.js} +1 -1
  21. package/dist/assets/{audit-logs-Tol8dkkk.js → audit-logs-CvWoJqnE.js} +2 -2
  22. package/dist/assets/{authorize-Bma44S9y.js → authorize-CgqsMeVu.js} +1 -1
  23. package/dist/assets/{base-chart-Gh7OtL-d.js → base-chart-DvlyWvB2.js} +1 -1
  24. package/dist/assets/{base32-HmSqZ9zU.js → base32-AX-I0UaR.js} +1 -1
  25. package/dist/assets/bind-account-C_93rOKB.js +1 -0
  26. package/dist/assets/{branding-CnmWjFbu.js → branding-C56V2vpD.js} +1 -1
  27. package/dist/assets/branding-D-5p5wha.js +1 -0
  28. package/dist/assets/{branding-Fj3LseIw.js → branding-MYLazJOV.js} +5 -5
  29. package/dist/assets/{bundle-avatar-CeDsDt5-.js → bundle-avatar-BdQv8P8t.js} +1 -1
  30. package/dist/assets/button-8Nchte_6.js +1 -0
  31. package/dist/assets/click-to-copy-DZ_4RDjR.js +1 -0
  32. package/dist/assets/{cloneDeep-D_9o-MDF.js → cloneDeep-B7kH4W7U.js} +1 -1
  33. package/dist/assets/{collapse-BlkBpbz3.js → collapse-CHg4yEHL.js} +1 -1
  34. package/dist/assets/{complete-DetpIm2X.js → complete-BSud_fLS.js} +1 -1
  35. package/dist/assets/{component-Br_A0gxQ.js → component-Z_4kfVE0.js} +2 -2
  36. package/dist/assets/{config-hHQ1dQ0r.js → config-QNXiPFng.js} +1 -1
  37. package/dist/assets/{config-BZ68qemi.js → config-YjT0ptkh.js} +6 -6
  38. package/dist/assets/{config-navigation-CIiX_S1E.js → config-navigation-BdlyLYhE.js} +2 -2
  39. package/dist/assets/{config-space-DcxPvrsQ.js → config-space-BSBup5aB.js} +1 -1
  40. package/dist/assets/{config-DaTqZM7S.js → config-tFuMpr42.js} +1 -1
  41. package/dist/assets/{confirm-CQifLVQz.js → confirm-DPD7yjeR.js} +1 -1
  42. package/dist/assets/{connect-BYne4RoU.js → connect-C51xT0zT.js} +1 -1
  43. package/dist/assets/{connect-DCXdY6aM.js → connect-DFCRlbN9.js} +1 -1
  44. package/dist/assets/connect-to-B-qzDPba.js +1 -0
  45. package/dist/assets/{content-layout-CpbYUNJ8.js → content-layout-RghQFMLL.js} +1 -1
  46. package/dist/assets/{create-passport-svg-hAgKE5uX.js → create-passport-svg-BZVXsAoP.js} +1 -1
  47. package/dist/assets/createClass-dlbhjEVd.js +1 -0
  48. package/dist/assets/{dashboard-PCrwcW_N.js → dashboard-Cto_eSyJ.js} +2 -2
  49. package/dist/assets/{de-Ztxy5vEB.js → de-BF0NHTXz.js} +2 -2
  50. package/dist/assets/{delete-confirm-DP77Lldw.js → delete-confirm-G3d9EUZU.js} +1 -1
  51. package/dist/assets/{did-address-CLsSdiw3.js → did-address-CihvGtuj.js} +1 -1
  52. package/dist/assets/domain-CJ3ZeLQs.js +9 -0
  53. package/dist/assets/{domain-action-card-DmLVoK6X.js → domain-action-card-BAzAGOUR.js} +2 -2
  54. package/dist/assets/domains-CbYSc-np.js +1 -0
  55. package/dist/assets/{email-zUlL8Ooc.js → email-BbooLxm_.js} +1 -1
  56. package/dist/assets/{empty-spinner-DiVQXbse.js → empty-spinner-2ylB84wv.js} +1 -1
  57. package/dist/assets/engine-7kGw4V-U.js +1 -0
  58. package/dist/assets/{es-Cd-spoK_.js → es-Dv2m4LXp.js} +2 -2
  59. package/dist/assets/{exchange-passport-4jMKVLBc.js → exchange-passport-B7UqzIxE.js} +1 -1
  60. package/dist/assets/{form-BhkklUts.js → form-Ci18kVmF.js} +3 -3
  61. package/dist/assets/{form-text-input-BFhD3mCK.js → form-text-input-CBL3JAev.js} +1 -1
  62. package/dist/assets/{form-wrapper-B9XdbV9a.js → form-wrapper-CqFSijKV.js} +1 -1
  63. package/dist/assets/{fr-k8jXteN1.js → fr-BGhg9oO3.js} +2 -2
  64. package/dist/assets/{fuel-_LHEMXNX.js → fuel-BE74WZ6j.js} +1 -1
  65. package/dist/assets/{gen-access-key-Cuu-iyxE.js → gen-access-key-s40ict9x.js} +1 -1
  66. package/dist/assets/{gen-simple-access-key-ud5DXiqY.js → gen-simple-access-key-D8YVPusH.js} +1 -1
  67. package/dist/assets/get-safe-url-DT47R_1b.js +1 -0
  68. package/dist/assets/{hi-CvpI1-tn.js → hi-CPfDhW8g.js} +2 -2
  69. package/dist/assets/{home-D-jA_4Lm.js → home-C9ok8LuA.js} +1 -1
  70. package/dist/assets/{id-D8coHs1U.js → id-9TUzKF6k.js} +2 -2
  71. package/dist/assets/{iframe-DwMwGxmX.js → iframe-BoFxpqBT.js} +1 -1
  72. package/dist/assets/{index-Cvr1OSm0.js → index-B9Igf2rm.js} +1 -1
  73. package/dist/assets/{index-D0XVz0dc.js → index-BF7MtybM.js} +1 -1
  74. package/dist/assets/{index-BO3UQZPi.js → index-BJz7bmlp.js} +1 -1
  75. package/dist/assets/{index-DjE2GQIM.js → index-BpNkmzkz.js} +2 -2
  76. package/dist/assets/{index-DDNvzM4M.js → index-ByWjeUNp.js} +7 -7
  77. package/dist/assets/{index-s6v6fZUe.js → index-C0TbDTja.js} +4 -4
  78. package/dist/assets/{index-BNBVWXSX.js → index-CCaP8G-5.js} +2 -2
  79. package/dist/assets/index-CFLPfp6M.js +124 -0
  80. package/dist/assets/index-CMuQuCcn.js +1 -0
  81. package/dist/assets/{index-xERuGIw0.js → index-CN4lpn74.js} +132 -134
  82. package/dist/assets/{index-auhzedGi.js → index-CO3X6G_g.js} +1 -1
  83. package/dist/assets/{index-ByEQy1Lz.js → index-CTzNs74h.js} +2 -2
  84. package/dist/assets/index-CUHwnb5s.js +120 -0
  85. package/dist/assets/index-CekShFJg.js +6 -0
  86. package/dist/assets/{index-BQyVf1E3.js → index-CgnIkelt.js} +1 -1
  87. package/dist/assets/index-CimoFUNL.js +7 -0
  88. package/dist/assets/index-CionuFLd.js +1 -0
  89. package/dist/assets/{index-Cpsil-_J.js → index-ClpPXMAi.js} +5 -5
  90. package/dist/assets/{index-BLT40lDy.js → index-CpVl3QY6.js} +8 -8
  91. package/dist/assets/{index-DYMBrhSA.js → index-DA2Pny4B.js} +1 -1
  92. package/dist/assets/{index-B65qJcbt.js → index-DA4iEV0M.js} +1 -1
  93. package/dist/assets/index-DQB7DBpQ.js +29 -0
  94. package/dist/assets/{index-kzb9GjyJ.js → index-DXYr8-bJ.js} +1 -1
  95. package/dist/assets/{index-D_l_jjH3.js → index-DaIayPTI.js} +2 -2
  96. package/dist/assets/{index-B3nY7xOz.js → index-DbmL_qgW.js} +8 -8
  97. package/dist/assets/{index-CR-yimk0.js → index-DrJnt_vf.js} +4 -4
  98. package/dist/assets/index-DsQDfClt.js +1 -0
  99. package/dist/assets/index-DtUiw_0b.js +55 -0
  100. package/dist/assets/{index-BcssdfWc.js → index-YApW_a5L.js} +1 -1
  101. package/dist/assets/{index-B1hEtoFm.js → index-bbu7QFpz.js} +1 -1
  102. package/dist/assets/{index-CoJqP_N2.js → index-h3JyhqqC.js} +1 -1
  103. package/dist/assets/{index-KzZiqY9D.js → index-tukXJbMk.js} +6 -6
  104. package/dist/assets/{index-BWgjTPxl.js → index-yGC4DbEU.js} +1 -1
  105. package/dist/assets/{invitation-gK2vIEsH.js → invitation-XkzkbIwS.js} +2 -2
  106. package/dist/assets/{invitations-lfws_T2N.js → invitations-Cy_dNcIE.js} +1 -1
  107. package/dist/assets/{invite-CGloPprm.js → invite-BSYvges4.js} +1 -1
  108. package/dist/assets/{isURL-CDvz38EO.js → isURL-DskT4RKm.js} +2 -2
  109. package/dist/assets/{issue-passport-Dl3X8TTW.js → issue-passport-opYjcMCB.js} +1 -1
  110. package/dist/assets/{item-CTQ1F-Dd.js → item-DToR6hlW.js} +1 -1
  111. package/dist/assets/{ja-Dkn5OA2r.js → ja-DT5bRsBF.js} +2 -2
  112. package/dist/assets/{ko-DXfRo0NY.js → ko-CJn9PyPz.js} +2 -2
  113. package/dist/assets/{landing-page-DKcKat1r.js → landing-page-DFIsLbb7.js} +1 -1
  114. package/dist/assets/{launch-result-message--rgseiAA.js → launch-result-message-AcBN2VCj.js} +1 -1
  115. package/dist/assets/{layout-D1wjW1Oy.js → layout-CkQwn0NR.js} +1 -1
  116. package/dist/assets/list-D4Gs036Z.js +103 -0
  117. package/dist/assets/{list-MeDKce8j.js → list-D5UHzaOx.js} +1 -1
  118. package/dist/assets/{list-header-DOS7AnGs.js → list-header-CA-QkwGq.js} +1 -1
  119. package/dist/assets/localization-DzNUtlVV.js +1 -0
  120. package/dist/assets/{log-B9KcwZD3.js → log-RL9u31-I.js} +1 -1
  121. package/dist/assets/logger-DQUu6ucJ.js +1 -0
  122. package/dist/assets/login-CqeIoGod.js +1 -0
  123. package/dist/assets/{login-oauth-callback-f64z-iJf.js → login-oauth-callback-0Nu4mPXk.js} +1 -1
  124. package/dist/assets/{logo-uploader-D6c2iUqg.js → logo-uploader-Cv5-KB8L.js} +1 -1
  125. package/dist/assets/lost-passport-CoOQTlhO.js +167 -0
  126. package/dist/assets/{observability-D1A-1uvj.js → observability-Bzq6nAvX.js} +1 -1
  127. package/dist/assets/{omit-BSwpPhgW.js → omit-W13eVnqC.js} +1 -1
  128. package/dist/assets/{open-window-7JDNMA9V.js → open-window-BHKfDlI-.js} +1 -1
  129. package/dist/assets/{over-due-invoice-payment-CljuJ4kk.js → over-due-invoice-payment-MovV2cwi.js} +1 -1
  130. package/dist/assets/{overview-CI-TDe1L.js → overview-CCLvrJi4.js} +2 -2
  131. package/dist/assets/{page-header-Dh_UA7fa.js → page-header-B4MDj6gy.js} +1 -1
  132. package/dist/assets/passport-CqvORkfw.js +1 -0
  133. package/dist/assets/{passport-item-DwumTPQv.js → passport-item-BMa8rd85.js} +1 -1
  134. package/dist/assets/{permission-Blt9Onuq.js → permission-DLnMVuoy.js} +1 -1
  135. package/dist/assets/{playground-kZ9J2CEx.js → playground-C71u8_tm.js} +1 -1
  136. package/dist/assets/preferences-CDvS8_ng.js +1 -0
  137. package/dist/assets/profile-embed-C8ofqlbV.js +1 -0
  138. package/dist/assets/pt-K9FK6Ube.js +5 -0
  139. package/dist/assets/publish-resource-CMoJF5DA.js +1 -0
  140. package/dist/assets/{react-beautiful-dnd.esm-CbCp5m8Z.js → react-beautiful-dnd.esm--C1KYPc1.js} +1 -1
  141. package/dist/assets/{react-stripe.esm-C8Keba5n.js → react-stripe.esm-DlJMzZK2.js} +1 -1
  142. package/dist/assets/{required-CgSsIuqu.js → required-glXJjYm5.js} +1 -1
  143. package/dist/assets/ru-C_RwukUu.js +5 -0
  144. package/dist/assets/runtime-D2sDgwrj.js +1 -0
  145. package/dist/assets/{sanitize-aIE75FMz.js → sanitize-Bm63FeNh.js} +1 -1
  146. package/dist/assets/sdk-CiQg0Ndf.js +1 -0
  147. package/dist/assets/{section-tQK-hwwW.js → section-4gVAq_Fp.js} +1 -1
  148. package/dist/assets/{security-DEVrQWpZ.js → security-D7O7D2Dn.js} +1 -1
  149. package/dist/assets/{session-CAj-TcUY.js → session-DNlfWI2Z.js} +1 -1
  150. package/dist/assets/{setup-BT6-74rK.js → setup-CxJT_7C9.js} +1 -1
  151. package/dist/assets/{shorten-label-JstixX67.js → shorten-label-Cf--RqV-.js} +1 -1
  152. package/dist/assets/{simple-select-_qsehgaA.js → simple-select-BAtHv3cq.js} +1 -1
  153. package/dist/assets/{spaces-B6flHcN-.js → spaces-B9YyAxJd.js} +1 -1
  154. package/dist/assets/{start-BMKAy5mb.js → start-TaXS82Bg.js} +1 -1
  155. package/dist/assets/{starting-progress-SNgrsu02.js → starting-progress-B6ma-ZGa.js} +1 -1
  156. package/dist/assets/status-DsksxwVa.js +1 -0
  157. package/dist/assets/{step-actions-BcFE8m2n.js → step-actions-DbAALRbw.js} +1 -1
  158. package/dist/assets/{studio-BkTwhFSX.js → studio-IkWmW2Xk.js} +1 -1
  159. package/dist/assets/{switch-control-DVE8MCqI.js → switch-control-DdOZdvsu.js} +1 -1
  160. package/dist/assets/{table-tips-DMkRZoRQ.js → table-tips-cVuoMOXE.js} +1 -1
  161. package/dist/assets/team-BnNEVFdE.js +146 -0
  162. package/dist/assets/th-Bhii_FfA.js +5 -0
  163. package/dist/assets/traffic-BibrNphF.js +1 -0
  164. package/dist/assets/{transfer-3jaJ_59b.js → transfer-CPU5ZBFf.js} +1 -1
  165. package/dist/assets/{unsubscribe-zGPKbsNi.js → unsubscribe-CBHokiq9.js} +1 -1
  166. package/dist/assets/{use-app-logo-mH-ZWGvv.js → use-app-logo-BWOYOuhG.js} +1 -1
  167. package/dist/assets/{use-mobile-BdZU3Qy2.js → use-mobile-BpPz1bKz.js} +1 -1
  168. package/dist/assets/{use-mobile-nqweJXIG.js → use-mobile-DoKVMODs.js} +1 -1
  169. package/dist/assets/{use-server-logo-YhCrW0Nr.js → use-server-logo-UGU40YsW.js} +1 -1
  170. package/dist/assets/{use-window-close-B1fcc1UV.js → use-window-close-CbUhh9L6.js} +1 -1
  171. package/dist/assets/{useAsync-CuuTq_2R.js → useAsync-Be4McwD-.js} +1 -1
  172. package/dist/assets/{useAsync-Di_jotad.js → useAsync-Cc-dQGZL.js} +1 -1
  173. package/dist/assets/{useAsyncRetry-DhVFzdPo.js → useAsyncRetry-DHTJ61Jg.js} +1 -1
  174. package/dist/assets/{useLocalStorage-BCYIznDQ.js → useLocalStorage-UFpv-3wa.js} +1 -1
  175. package/dist/assets/user-center-DxoxMBFK.js +126 -0
  176. package/dist/assets/{user-follower-DYsXrJ7n.js → user-follower-CNxYFKVI.js} +1 -1
  177. package/dist/assets/{util-wCHwyw_F.js → util-DWpY3O7e.js} +1 -1
  178. package/dist/assets/{util-BN6NLUU2.js → util-DzwOLYt5.js} +1 -1
  179. package/dist/assets/{vendor-arcblock-BRRIrPlW.js → vendor-arcblock-3xKfH3F1.js} +114 -115
  180. package/dist/assets/{vendor-hooks-BeI8hpF9.js → vendor-hooks-fhL5FJET.js} +1 -1
  181. package/dist/assets/{vendor-mui-core-B62p29u8.js → vendor-mui-core-DHT36AZL.js} +1 -1
  182. package/dist/assets/{vendor-mui-x-vSVDqxyB.js → vendor-mui-x-B4OOX5Es.js} +1 -1
  183. package/dist/assets/vendor-utils-BSZ4yJws.js +213 -0
  184. package/dist/assets/{vendor-ux-k_TkMNDV.js → vendor-ux-sqP3hEhY.js} +45 -45
  185. package/dist/assets/vi-DVF2tjOG.js +5 -0
  186. package/dist/assets/{wait-connect-Df9uvB6x.js → wait-connect-Crb0Z6pk.js} +1 -1
  187. package/dist/assets/{wizard-GCfJ08HB.js → wizard-GO-eYrph.js} +1 -1
  188. package/dist/assets/{wizard-components-D_w2hIhz.js → wizard-components-B0p6B74G.js} +1 -1
  189. package/dist/assets/wrap-locale-C_7Ff1OO.js +1 -0
  190. package/dist/assets/{zh-DB1zAstv.js → zh-98nxdLeR.js} +2 -2
  191. package/dist/assets/{zh-QBR-GmxX.js → zh-kaABsCb2.js} +1 -1
  192. package/dist/assets/{zh-tw-DVMVT9am.js → zh-tw-BdDE7n5E.js} +2 -2
  193. package/dist/index.html +1 -1
  194. package/dist/service-worker.js +1 -1
  195. package/package.json +32 -32
  196. package/dist/assets/actions-BQZmpgjH.js +0 -1
  197. package/dist/assets/add-resource-BwJJ0aia.js +0 -1
  198. package/dist/assets/api-C1vNuLNj.js +0 -1
  199. package/dist/assets/bind-account-BHZb-y1l.js +0 -1
  200. package/dist/assets/branding-DhsDum88.js +0 -1
  201. package/dist/assets/button-M1tE0EM6.js +0 -1
  202. package/dist/assets/click-to-copy-COEss4SB.js +0 -1
  203. package/dist/assets/connect-to-Dp0mJeqn.js +0 -1
  204. package/dist/assets/createClass-D1NoiqdO.js +0 -1
  205. package/dist/assets/domain-DptzkTFQ.js +0 -9
  206. package/dist/assets/domains-Cj55weM5.js +0 -1
  207. package/dist/assets/engine-Br5kqWzP.js +0 -1
  208. package/dist/assets/get-safe-url-baxNHkAA.js +0 -1
  209. package/dist/assets/index-C3PPGtfI.js +0 -6
  210. package/dist/assets/index-ClXqfbDZ.js +0 -1
  211. package/dist/assets/index-CozzYt0Z.js +0 -7
  212. package/dist/assets/index-D45cjNSM.js +0 -1
  213. package/dist/assets/index-DBBPnrYI.js +0 -124
  214. package/dist/assets/index-Dr1AOLd_.js +0 -30
  215. package/dist/assets/index-DxlME7t_.js +0 -120
  216. package/dist/assets/index-N6YyFqDu.js +0 -1
  217. package/dist/assets/index-kD1YmpMU.js +0 -55
  218. package/dist/assets/list-DPsX8TMn.js +0 -103
  219. package/dist/assets/localization-CASCfNj1.js +0 -1
  220. package/dist/assets/logger-6-51jSsQ.js +0 -1
  221. package/dist/assets/login-Cbb7F6Mu.js +0 -1
  222. package/dist/assets/lost-passport-CSoln1QB.js +0 -167
  223. package/dist/assets/passport-0dxK_pTH.js +0 -1
  224. package/dist/assets/preferences-OylPiHSa.js +0 -1
  225. package/dist/assets/profile-embed-CCdzwTKi.js +0 -1
  226. package/dist/assets/pt-CNQsUMCu.js +0 -5
  227. package/dist/assets/publish-resource-Adc4901F.js +0 -1
  228. package/dist/assets/ru-CjyCft4V.js +0 -5
  229. package/dist/assets/runtime-OGDYw4nO.js +0 -1
  230. package/dist/assets/sdk-CxQIQdbk.js +0 -1
  231. package/dist/assets/status-GY7lihPg.js +0 -1
  232. package/dist/assets/team-DANl8A6y.js +0 -146
  233. package/dist/assets/th-WQWRMKAv.js +0 -5
  234. package/dist/assets/traffic-D_pUHfvx.js +0 -1
  235. package/dist/assets/user-center-gH0CVETg.js +0 -126
  236. package/dist/assets/vendor-utils-DZwtp8ph.js +0 -213
  237. package/dist/assets/vi-Br98wbNi.js +0 -5
  238. package/dist/assets/wrap-locale-Dgf6KVHX.js +0 -1
@@ -1,4 +1,4 @@
1
- import{j as a,D as M,T as _,ce as T,Q as W,cf as X,aV as q,ak as h,cg as Y,aU as Z,av as B,f as C,b$ as J,ch as K}from"./vendor-mui-core-B62p29u8.js";import{r as d,k as L,L as z,n as ee,o as ae}from"./vendor-react-CUXIiAnY.js";import{H as E,aX as te}from"./index-xERuGIw0.js";import{e as ie}from"./vendor-hooks-BeI8hpF9.js";import{M as re,l as m,a7 as A,a8 as S}from"./vendor-ux-k_TkMNDV.js";import{z as oe}from"./vendor-arcblock-BRRIrPlW.js";const H=d.createContext(null),se=e=>{const i=d.use(H);return d.useLayoutEffect(()=>{},[]),i};function le({children:e=void 0,...i}){const[t,r]=d.useState({inFullPage:!1,showToggleButton:!1,headerVisibleInFullPage:!0,footerVisibleInFullPage:!1,sidebarVisibleInFullPage:!1}),s=()=>{r(o=>({...o,inFullPage:!o.inFullPage}))},l=d.useMemo(()=>({...t,headerVisible:!t.inFullPage||t.headerVisibleInFullPage,footerVisible:!t.inFullPage||t.footerVisibleInFullPage,sidebarVisible:!t.inFullPage||t.sidebarVisibleInFullPage,toggleFullPage:s,configure:o=>r(n=>({...n,...o}))}),[t]);return a.jsx(H,{value:l,...i,children:e})}function ne({name:e,size:i=36,alt:t="",color:r="#000000",prefix:s="/images",showBadge:l=!1,style:o={},...n}){const c=`${s}/${e}-${r.replace(/^#/,"")}.png`;return a.jsxs(de,{style:{width:i,height:i},children:[a.jsx(re,{width:i,height:i,alt:t||e,src:c,style:Object.assign({width:i},o),...n}),l&&a.jsx("i",{className:"badge-point"})]})}const de=m("div")`
1
+ import{j as a,D as M,T as _,ce as T,Q as W,cf as q,aV as X,ak as h,cg as Y,aU as Z,av as B,f as C,b$ as J,ch as K}from"./vendor-mui-core-DHT36AZL.js";import{r as d,k as L,L as z,n as ee,o as ae}from"./vendor-react-CUXIiAnY.js";import{H as E,aW as te}from"./index-CN4lpn74.js";import{e as ie}from"./vendor-hooks-fhL5FJET.js";import{M as re,l as m,a0 as A,a1 as S}from"./vendor-ux-sqP3hEhY.js";import{z as oe}from"./vendor-arcblock-3xKfH3F1.js";const H=d.createContext(null),se=e=>{const i=d.use(H);return d.useLayoutEffect(()=>{},[]),i};function le({children:e=void 0,...i}){const[t,r]=d.useState({inFullPage:!1,showToggleButton:!1,headerVisibleInFullPage:!0,footerVisibleInFullPage:!1,sidebarVisibleInFullPage:!1}),s=()=>{r(o=>({...o,inFullPage:!o.inFullPage}))},l=d.useMemo(()=>({...t,headerVisible:!t.inFullPage||t.headerVisibleInFullPage,footerVisible:!t.inFullPage||t.footerVisibleInFullPage,sidebarVisible:!t.inFullPage||t.sidebarVisibleInFullPage,toggleFullPage:s,configure:o=>r(n=>({...n,...o}))}),[t]);return a.jsx(H,{value:l,...i,children:e})}function ne({name:e,size:i=36,alt:t="",color:r="#000000",prefix:s="/images",showBadge:l=!1,style:o={},...n}){const c=`${s}/${e}-${r.replace(/^#/,"")}.png`;return a.jsxs(de,{style:{width:i,height:i},children:[a.jsx(re,{width:i,height:i,alt:t||e,src:c,style:Object.assign({width:i},o),...n}),l&&a.jsx("i",{className:"badge-point"})]})}const de=m("div")`
2
2
  position: relative;
3
3
  .badge-point {
4
4
  position: absolute;
@@ -132,7 +132,7 @@ import{j as a,D as M,T as _,ce as T,Q as W,cf as X,aV as q,ak as h,cg as Y,aU as
132
132
  display: block;
133
133
  }
134
134
  }
135
- `;function ue({onToggleMenu:e,brand:i=void 0,description:t=void 0,addons:r=void 0,brandAddon:s=void 0,homeUrl:l="/",logo:o=void 0,children:n,...c}){return a.jsx(xe,{position:"sticky",className:"header",...c,children:a.jsxs(X,{disableGutters:!1,className:"header-toolbar",children:[a.jsx(W,{color:"inherit","aria-label":"open drawer",className:"header-menu","aira-label":"header menu button",onClick:e,children:a.jsx(q,{})}),a.jsxs(z,{to:l,className:"header-link",children:[a.jsx(h,{sx:{display:{xs:"none",md:"block"}},className:"header-logo",children:o||a.jsx(A,{showText:!1})}),a.jsxs("div",{className:"header-title",children:[a.jsxs(_,{component:"h2",noWrap:!0,className:"header-title__primary",children:[i,s]}),a.jsx(_,{component:"p",noWrap:!0,className:"header-title__secondary",children:t})]})]}),a.jsx(h,{sx:{flexGrow:1}}),!!n&&a.jsx("div",{className:"header-children",children:n}),a.jsx("div",{className:"header-addons",children:r})]})})}const me=m("div")`
135
+ `;function ue({onToggleMenu:e,brand:i=void 0,description:t=void 0,addons:r=void 0,brandAddon:s=void 0,homeUrl:l="/",logo:o=void 0,children:n,...c}){return a.jsx(xe,{position:"sticky",className:"header",...c,children:a.jsxs(q,{disableGutters:!1,className:"header-toolbar",children:[a.jsx(W,{color:"inherit","aria-label":"open drawer",className:"header-menu","aira-label":"header menu button",onClick:e,children:a.jsx(X,{})}),a.jsxs(z,{to:l,className:"header-link",children:[a.jsx(h,{sx:{display:{xs:"none",md:"block"}},className:"header-logo",children:o||a.jsx(A,{showText:!1})}),a.jsxs("div",{className:"header-title",children:[a.jsxs(_,{component:"h2",noWrap:!0,className:"header-title__primary",children:[i,s]}),a.jsx(_,{component:"p",noWrap:!0,className:"header-title__secondary",children:t})]})]}),a.jsx(h,{sx:{flexGrow:1}}),!!n&&a.jsx("div",{className:"header-children",children:n}),a.jsx("div",{className:"header-addons",children:r})]})})}const me=m("div")`
136
136
  &.dashboard {
137
137
  display: flex;
138
138
  flex-direction: column;
@@ -0,0 +1,120 @@
1
+ import{g as Bt,r as v}from"./vendor-react-CUXIiAnY.js";import{j as e,ak as S,z as X,b6 as me,bg as Ke,y as V,am as ut,d8 as Wt,bn as Kt,at as ie,b1 as mt,W as p,T as ee,U as Je,d9 as pt,b5 as qe,a5 as Me,Q as Pe,da as Ge,aN as Ue,a6 as ft,D as ht,ci as qt,ad as xt,db as Mt,dc as Ut,c2 as st,n as Ht,J as $t,x as Vt,bc as Jt,M as it,cx as Gt,I as Yt,dd as Qt}from"./vendor-mui-core-DHT36AZL.js";import{A as gt,J as Xt,C as Zt,e as oe,F as en,a3 as je}from"./vendor-utils-BSZ4yJws.js";import{V as te,H as q,n as le,p as tn,j as bt,Q as nn,aD as sn,m as jt,$ as vt,h as yt,aE as ke,b as St,z as an,a2 as rn}from"./vendor-ux-sqP3hEhY.js";import{aK as on,_ as Ye,ac as Ct,aA as wt,K as _e,c as B,a1 as Z,o as ln,aS as at}from"./index-CN4lpn74.js";import{g as ye,b as $,a as se}from"./vendor-hooks-fhL5FJET.js";import{u as Rt,C as Y}from"./index.esm-DTmS4tth.js";import{i as He}from"./isURL-DskT4RKm.js";import{S as Q}from"./section-4gVAq_Fp.js";import{A as cn,a as dn,b as un}from"./collapse-CHg4yEHL.js";import{S as Se}from"./shorten-label-Cf--RqV-.js";import{v as Tt}from"./index-BF7MtybM.js";import{R as Nt,A as mn,S as pn,a as fn,B as hn}from"./list-D4Gs036Z.js";import{j as xn,c as gn,N as bn}from"./team-BnNEVFdE.js";import{W as jn}from"./did-address-CihvGtuj.js";import{p as It}from"./util-DzwOLYt5.js";import{D as vn,g as yn}from"./traffic-BibrNphF.js";import{B as Et}from"./bundle-avatar-BdQv8P8t.js";import{u as Sn}from"./use-mobile-DoKVMODs.js";import"./lottie-web-4koyQiv_.js";import"./vendor-arcblock-3xKfH3F1.js";import"./required-glXJjYm5.js";import"./server-logo-notext.svg-DHxZ1bRk.js";import"./session-DNlfWI2Z.js";import"./use-app-logo-BWOYOuhG.js";import"./base32-AX-I0UaR.js";import"./useAsyncRetry-DHTJ61Jg.js";import"./useAsync-Cc-dQGZL.js";import"./iframe-BoFxpqBT.js";import"./index-DsQDfClt.js";import"./index-DBs9Ljax.js";import"./base-chart-DvlyWvB2.js";import"./index-DA2Pny4B.js";import"./vendor-mui-x-B4OOX5Es.js";import"./AdapterDayjs-OZNn2tpO.js";var Re={exports:{}},Te={exports:{}},Ne={exports:{}},rt;function Cn(){return rt||(rt=1,function(t,s){Object.defineProperty(s,"__esModule",{value:!0}),s.default=n;function n(r){return r==null}t.exports=s.default,t.exports.default=s.default}(Ne,Ne.exports)),Ne.exports}var ot;function wn(){return ot||(ot=1,function(t,s){Object.defineProperty(s,"__esModule",{value:!0}),s.default=f;var n=o(on()),r=o(Cn());function o(u){return u&&u.__esModule?u:{default:u}}var l=/^(?:[-+]?(?:0|[1-9][0-9]*))$/,j=/^[-+]?[0-9]+$/;function f(u,a){(0,n.default)(u),a=a||{};var y=a.allow_leading_zeroes===!1?l:j,R=!a.hasOwnProperty("min")||(0,r.default)(a.min)||u>=a.min,w=!a.hasOwnProperty("max")||(0,r.default)(a.max)||u<=a.max,b=!a.hasOwnProperty("lt")||(0,r.default)(a.lt)||u<a.lt,E=!a.hasOwnProperty("gt")||(0,r.default)(a.gt)||u>a.gt;return y.test(u)&&R&&w&&b&&E}t.exports=s.default,t.exports.default=s.default}(Te,Te.exports)),Te.exports}var lt;function Rn(){return lt||(lt=1,function(t,s){Object.defineProperty(s,"__esModule",{value:!0}),s.default=o;var n=r(wn());function r(l){return l&&l.__esModule?l:{default:l}}function o(l){return(0,n.default)(l,{allow_leading_zeroes:!1,min:0,max:65535})}t.exports=s.default,t.exports.default=s.default}(Re,Re.exports)),Re.exports}var Tn=Rn();const Nn=Bt(Tn),ze={enabled:!1,secure:!1,from:"",host:"",port:"",user:"",password:"",companyName:"",companyLink:"",companyAddress:"",supportEmail:""};function In(){const{api:t}=Ye(),{blocklet:s}=Ct(),{t:n}=te(),{confirmApi:r,confirmHolder:o}=wt(),l=s?.meta?.did,j=Object.assign({...ze},s?.settings?.notification?.email||{}),{handleSubmit:f,control:u,formState:a,watch:y,reset:R}=Rt({defaultValues:gt(j,Object.keys(ze))}),w=ye({testReceiver:"",testReceiverError:""}),b=y("enabled"),E=$(async(i,C,D=!0)=>{try{const{blocklet:O}=await t.configNotification({input:{did:l,notification:JSON.stringify({email:i})}}),ae=Object.assign({...ze},O?.settings?.notification?.email||{});R(ae),D&&q.success(n("oauth.saveSuccess"))}catch(O){if(D)q.error(O.message||n("oauth.saveFailed"));else throw O}}),J=$(async(i,C,D)=>{try{a.isDirty&&await E(i,C,!1),await t.sendEmail({input:{did:l,receiver:D,email:JSON.stringify({body:"Your SMTP configuration is correct!",title:"Test email",type:"notification",attachments:[{type:"link",data:{url:"https://community.arcblock.io",title:"Community",image:"https://community.arcblock.io/.well-known/service/blocklet/logo-rect-dark",utm:{campaign:"test-campaign"}}}],utm:{content:"test-email-button"}})}}),q.success(n("notification.email.testSuccess"))}catch(O){q.error(O.message||n("notification.email.testfailed"))}}),M=$((i,C)=>{w.testReceiver=localStorage.getItem("test-receiver")||"",w.testReceiverError="",r.open({title:n("notification.email.testSendEmail"),content:()=>e.jsx(S,{sx:{width:"300px"},children:e.jsx(X,{sx:{mt:1},fullWidth:!0,name:"testReceiver",label:n("notification.email.inputTestReceiver"),value:w.testReceiver,onChange:D=>{w.testReceiver=D.target.value},error:!!w.testReceiverError,helperText:w.testReceiverError||" "})}),confirmButtonText:n("common.confirm"),cancelButtonText:n("common.cancel"),async onConfirm(D){const O=w.testReceiver?.trim();if(!O){w.testReceiverError=n("notification.email.receiverRequired");return}if(!_e(O)){w.testReceiverError=n("notification.email.receiverInvalid");return}w.testReceiverError="",await J(i,C,O),D()}})}),P=$(i=>{const C=i?.trim();return C?_e(C)?!0:n("notification.email.fromInvalid"):n("notification.email.fromRequired")}),F=$(i=>{const C=i?.trim();return C?He(C,{require_host:!1,protocols:[]})?!0:n("notification.email.hostInvalid"):n("notification.email.hostRequired")}),N=$(i=>i?Nn(i)?!0:n("notification.email.portInvalid"):n("notification.email.portRequired")),W=$(i=>i?.trim()?!0:n("notification.email.userRequired")),K=$(i=>i?.trim()?!0:n("notification.email.passwordRequired")),h=$(i=>i?.trim()&&!He(i,{protocols:["http","https"],require_protocol:!0})?n("notification.email.linkInvalid"):!0),T=$(i=>i?.trim()&&!_e(i)?n("notification.email.emailInvalid"):!0),k=$(()=>!0);return e.jsxs(S,{children:[e.jsxs(En,{component:"form",onSubmit:f(E),disabled:!0,sx:{".section-left":{width:"160px"}},children:[e.jsx(Q,{title:n("notification.email.enable"),my:2.5,children:e.jsx(Y,{name:"enabled",control:u,render:({field:i})=>e.jsx(me,{control:e.jsx(Ke,{checked:i.value,...i})})})}),e.jsx(Q,{title:n("notification.email.from"),children:e.jsx(Y,{name:"from",control:u,rules:{validate:b?P:k},render:({field:i})=>e.jsx(V,{fullWidth:!0,children:e.jsx(X,{...i,size:"small",required:!0,label:n("notification.email.from"),error:!!a.errors[i.name],helperText:a.errors[i.name]?.message||" ",disabled:!b})})})}),e.jsx(Q,{title:n("notification.email.host"),children:e.jsx(Y,{name:"host",control:u,rules:{validate:b?F:k},render:({field:i})=>e.jsx(V,{fullWidth:!0,children:e.jsx(X,{...i,size:"small",required:!0,error:!!a.errors[i.name],label:n("notification.email.host"),helperText:a.errors[i.name]?.message||" ",disabled:!b})})})}),e.jsx(Q,{title:n("notification.email.port"),children:e.jsx(Y,{name:"port",control:u,rules:{validate:b?N:k},render:({field:i})=>e.jsx(V,{fullWidth:!0,children:e.jsx(X,{...i,size:"small",required:!0,type:"number",error:!!a.errors[i.name],label:n("notification.email.port"),helperText:a.errors[i.name]?.message||" ",disabled:!b})})})}),e.jsx(Q,{title:n("notification.email.user"),children:e.jsx(Y,{name:"user",control:u,rules:{validate:b?W:k},render:({field:i})=>e.jsx(V,{fullWidth:!0,children:e.jsx(X,{...i,size:"small",required:!0,error:!!a.errors[i.name],label:n("notification.email.user"),helperText:a.errors[i.name]?.message||" ",disabled:!b})})})}),e.jsx(Q,{title:n("notification.email.password"),children:e.jsx(Y,{name:"password",control:u,rules:{validate:b?K:k},render:({field:i})=>e.jsx(V,{fullWidth:!0,children:e.jsx(X,{...i,size:"small",required:!0,type:"password",error:!!a.errors[i.name],label:n("notification.email.password"),helperText:a.errors[i.name]?.message||" ",disabled:!b})})})}),e.jsx(Q,{title:n("notification.email.secure"),children:e.jsx(Y,{name:"secure",control:u,rules:{validate:k},render:({field:i})=>e.jsx(V,{fullWidth:!0,children:e.jsx(me,{control:e.jsx(Ke,{checked:i.value,...i,disabled:!b})})})})}),e.jsxs(cn,{children:[e.jsxs(dn,{expandIcon:e.jsx(Kt,{fontSize:"small"}),"aria-controls":"panel1-content",id:"panel1-header",children:[n("notification.email.signature"),e.jsx(ut,{title:n("notification.email.signatureTooltip"),children:e.jsx(Wt,{fontSize:"small",sx:{ml:1,cursor:"help"}})})]}),e.jsxs(un,{children:[e.jsx(Q,{title:n("notification.email.companyName"),children:e.jsx(Y,{name:"companyName",control:u,rules:{validate:k},render:({field:i})=>e.jsx(V,{fullWidth:!0,children:e.jsx(X,{...i,size:"small",error:!!a.errors[i.name],label:n("notification.email.companyName"),helperText:a.errors[i.name]?.message||" ",disabled:!b})})})}),e.jsx(Q,{title:n("notification.email.companyLink"),children:e.jsx(Y,{name:"companyLink",control:u,rules:{validate:b?h:k},render:({field:i})=>e.jsx(V,{fullWidth:!0,children:e.jsx(X,{...i,size:"small",error:!!a.errors[i.name],label:n("notification.email.companyLink"),helperText:a.errors[i.name]?.message||" ",disabled:!b})})})}),e.jsx(Q,{title:n("notification.email.companyAddress"),children:e.jsx(Y,{name:"companyAddress",control:u,rules:{validate:k},render:({field:i})=>e.jsx(V,{fullWidth:!0,children:e.jsx(X,{...i,size:"small",error:!!a.errors[i.name],label:n("notification.email.companyAddress"),helperText:a.errors[i.name]?.message||" ",disabled:!b})})})}),e.jsx(Q,{title:n("notification.email.supportEmail"),children:e.jsx(Y,{name:"supportEmail",control:u,rules:{validate:b?T:k},render:({field:i})=>e.jsx(V,{fullWidth:!0,children:e.jsx(X,{...i,size:"small",type:"email",error:!!a.errors[i.name],label:n("notification.email.supportEmail"),helperText:a.errors[i.name]?.message||" ",disabled:!b})})})})]})]}),e.jsxs(S,{sx:{display:"flex",justifyContent:"flex-end",gap:2,mt:3},children:[e.jsx(le,{variant:"outlined",color:"warning",onClick:f(M),disabled:!b,children:n("oauth.runTest")}),e.jsx(le,{type:"submit",variant:"contained",disabled:!a.isDirty,children:n("oauth.save")})]})]}),o]})}const En=ie(mt)``,Be={enabled:!1,endpoint:"",did:void 0,pushPath:void 0};function kn(){const{api:t}=Ye(),{blocklet:s}=Ct(),{t:n}=te(),{confirmApi:r,confirmHolder:o}=wt(),l=s?.meta?.did,j=Object.assign({...Be},s?.settings?.notification?.pushKit||{}),{handleSubmit:f,control:u,formState:a,watch:y,reset:R}=Rt({defaultValues:gt(j,Object.keys(Be))}),w=ye({testReceiver:"",testReceiverError:""}),b=y("enabled"),E=$(async(N,W,K=!0)=>{try{const{blocklet:h}=await t.configNotification({input:{did:l,notification:JSON.stringify({pushKit:N})}}),T=Object.assign({...Be},h?.settings?.notification?.pushKit||{});R(T),K&&q.success(n("oauth.saveSuccess"))}catch(h){if(K)q.error(h.message||n("oauth.saveFailed"));else throw h}}),J=$(async(N,W)=>{try{a.isDirty&&await E(N,W,!1);const K=(s?.configs||[]).find(k=>k.key==="BLOCKLET_APP_URL")?.value,h=Xt(Zt(K,B.WELLKNOWN_SERVICE_PATH_PREFIX,"/blocklet/logo"),{v:s?.meta?.version,t:new Date(s?.updatedAt||0).getTime()}),T={type:"passthrough",passthroughType:"messageStatus",data:{message:{title:"Test push-kit notification",body:"This is message from push-kit config test",sender:{did:s?.appDid,fullName:s?.meta?.title,avatar:h}}}};await t.sendPush({input:{did:l,receiver:w.testReceiver,notification:JSON.stringify(T)}}),q.success(n("notification.pushKit.testSuccess"))}catch(K){q.error(K.message||n("notification.pushKit.testfailed"))}}),M=$((N,W)=>{w.testReceiverError="",r.open({title:n("notification.pushKit.testSend"),content:()=>e.jsx(S,{sx:{width:"450px",maxWidth:"100%"},children:e.jsx(X,{sx:{mt:1},fullWidth:!0,name:"testReceiver",label:n("notification.pushKit.inputTestReceiver"),value:w.testReceiver,onChange:K=>{w.testReceiver=K.target.value},error:!!w.testReceiverError,helperText:w.testReceiverError||" "})}),confirmButtonText:n("common.confirm"),cancelButtonText:n("common.cancel"),async onConfirm(K){if(!w.testReceiver?.trim()){w.testReceiverError=n("notification.pushKit.receiverRequired");return}w.testReceiverError="",await J(N,W),K()}})}),P=$(N=>{const W=N?.trim();return W?He(W)?!0:n("notification.pushKit.endpointInvalid"):n("notification.pushKit.endpointRequired")}),F=$(()=>!0);return e.jsxs(S,{children:[e.jsxs(An,{component:"form",onSubmit:f(E),disabled:!0,sx:{".section-left":{width:"160px"}},children:[e.jsx(Q,{title:n("notification.pushKit.enable"),my:2.5,children:e.jsx(Y,{name:"enabled",control:u,render:({field:N})=>e.jsx(me,{control:e.jsx(Ke,{checked:N.value,...N})})})}),e.jsx(Q,{title:n("notification.pushKit.endpoint"),children:e.jsx(Y,{name:"endpoint",control:u,rules:{validate:b?P:F},render:({field:N})=>e.jsx(V,{fullWidth:!0,children:e.jsx(X,{...N,size:"small",required:!0,label:n("notification.pushKit.endpoint"),error:!!a.errors[N.name],helperText:a.errors[N.name]?.message||" ",disabled:!b})})})}),e.jsxs(Q,{title:n("notification.pushKit.customOptions"),children:[e.jsx(Y,{name:"did",control:u,render:({field:N})=>e.jsx(V,{fullWidth:!0,children:e.jsx(X,{...N,size:"small",label:n("notification.pushKit.did"),error:!!a.errors[N.name],helperText:a.errors[N.name]?.message||" ",disabled:!b})})}),e.jsx(Y,{name:"pushPath",control:u,render:({field:N})=>e.jsx(V,{fullWidth:!0,children:e.jsx(X,{...N,size:"small",label:n("notification.pushKit.pushPath"),error:!!a.errors[N.name],helperText:a.errors[N.name]?.message||" ",disabled:!b})})})]}),e.jsxs(S,{sx:{display:"flex",justifyContent:"flex-end",gap:2,mt:3},children:[e.jsx(le,{variant:"outlined",color:"warning",onClick:f(M),disabled:!b,children:n("oauth.runTest")}),e.jsx(le,{type:"submit",variant:"contained",disabled:!a.isDirty,children:n("oauth.save")})]})]}),o]})}const An=ie(mt)``,ct=[{label:e.jsx(S,{sx:{textAlign:"center",width:"100%"},children:"Email"}),value:"email"},{label:e.jsx(S,{sx:{textAlign:"center",width:"100%"},children:"Push Kit"}),value:"pushKit"}];function On(){const[t,s]=v.useState(ct[0].value),{locale:n}=v.useContext(tn),r=se(()=>({email:e.jsx(In,{}),pushKit:e.jsx(kn,{})}),[n]),o=v.useMemo(()=>({padding:"10px 0"}),[]);return e.jsxs(S,{children:[e.jsx(bt,{tabs:ct,current:t,onChange:s}),e.jsx(S,{style:o,children:r[t]})]})}const kt=v.createContext({}),{Provider:Dn,Consumer:Bs}=kt;function Ln({children:t,blocklet:s=""}){const{api:n,inService:r,ws:{useSubscription:o}}=Ye(),[l,j]=v.useState([]),[f,u]=v.useState({total:0,pageSize:20,pageCount:0,page:1}),a=se(()=>s.meta?.did,[s]),[y,R]=v.useState([]),[w,b]=v.useState({}),E=se(()=>l.length?new Set(l.map(h=>h.id)):new Set,[l]),J=async({page:h=1,pageSize:T=20,...k}={})=>{if(!a)return[];try{const i={paging:{page:h,pageSize:T},...k,teamDid:a,dateRange:k.dateRange?[Z(k.dateRange[0]).toISOString(),Z(k.dateRange[1]).toISOString()]:void 0},{dids:C,...D}=i;let O="";C&&C.includes("system")&&(O="system");const ae=C?C.filter(pe=>pe!=="system"):[],de={...D,source:O,componentDids:ae},re=await n.getNotificationSendLog({input:de});return b(de),j(re.list),u(re.paging),re.list}catch(i){return q.error(i.message),[]}},M=async()=>{const h=await n.getNotificationComponents({input:{teamDid:a}});R(h.componentDids)},P=v.useCallback(h=>{const T=s.children.find(k=>k.meta?.did===h);if(T)return T.ancestors=[s],T},[s]),F=async({notificationId:h,receivers:T,channels:k,...i})=>{await n.resendNotification({input:{teamDid:a,notificationId:h,receivers:T,channels:k.map(C=>C==="wallet"?B.NOTIFICATION_SEND_CHANNEL.WALLET:C==="pushKit"?B.NOTIFICATION_SEND_CHANNEL.PUSH:C),...i}})},N=v.useCallback(async h=>(await n.getUser({input:{teamDid:a,user:{did:h},options:{enableConnectedAccount:!0}}})).user,[n,a]),W=v.useCallback(async({page:h=1,pageSize:T=20,...k}={})=>{try{const i={paging:{page:h,pageSize:T},...k,userName:k.searchText||"",teamDid:a,dateRange:k.dateRange?[Z(k.dateRange[0]).toISOString(),Z(k.dateRange[1]).toISOString()]:void 0};return await n.getReceivers({input:i})}catch(i){throw q.error(i.message),i}},[n,a]);v.useEffect(()=>{a&&M()},[a]),o(B.EVENTS.NOTIFICATION_BLOCKLET_UPDATE,h=>{E.has(h.notificationId)&&J(w)},[E,w]),o(B.EVENTS.NOTIFICATION_BLOCKLET_CREATE,h=>{E.has(h.id)||J(w)},[E,w]);const K={fetch:J,data:l,paging:f,blocklet:s,getComponent:P,resendNotification:F,getUser:N,componentDids:y,getReceivers:W,inService:r,teamDid:a};return e.jsx(Dn,{value:{notificationRecords:K},children:t})}function Qe(){const{notificationRecords:t}=v.useContext(kt);return t}Ce.propTypes={severity:p.oneOf(Object.values(["info","success","error","warning"])).isRequired};const Pn={info:"primary",success:"success",error:"error",warning:"warning"};function Ce({severity:t="info"}){return e.jsx(nn,{type:Pn[t],children:t})}const Fn=(t,s,n="")=>{if(!n||!s)return"";switch(n){case B.NOTIFICATION_SEND_FAILED_REASON.USER_DISABLED:return t("notification.sendStatus.reason.disabled",{channel:s});case B.NOTIFICATION_SEND_FAILED_REASON.CHANNEL_UNAVAILABLE:return t("notification.sendStatus.reason.unavailable",{channel:s});case B.NOTIFICATION_SEND_FAILED_REASON.CHANNEL_DISABLED:return t("notification.sendStatus.reason.notSent",{channel:s});case B.NOTIFICATION_SEND_FAILED_REASON.NOT_ONLINE:return t("notification.sendStatus.reason.offline");default:return n}};function At(t,s,n={}){const{status:r,updatedAt:o,reason:l="",channel:j="wallet"}=n,f=o?t("notification.sendStatus.sentTime",{date:ln(o,s)}):"",u=Fn(t,j,l);return r===B.NOTIFICATION_SEND_STATUS.FAILED?{status:"failed",title:t("notification.sendStatus.failed"),sentTime:f,reason:u}:r===B.NOTIFICATION_SEND_STATUS.SENT?{status:"success",title:t("notification.sendStatus.success"),sentTime:f}:{status:"pending",title:t("notification.sendStatus.pending"),reason:u,sentTime:f}}const $e={pending:"#aaaaaa",success:"#34BE74",failed:"#D0021B"},Ve=["wallet","pushKit","email"],dt=["info","success","error","warning"],Ot=t=>{const{settings:s}=t;return s?.notification?.email?.enabled},Dt=t=>{const{settings:s}=t;return s?.notification?.pushKit?.enabled},_n=(t,s)=>{const n=oe(s,"extra.notifications.email",!0);return{available:Ot(t),enabled:n}},zn=(t,s)=>{const n=oe(s,"extra.notifications.push",!0);return{available:Dt(t),enabled:n}},Bn=t=>({enabled:oe(t,"extra.notifications.wallet",!0)}),Wn=t=>({enabled:oe(t,"extra.webhooks",[]).length>0}),Ie=(t=3)=>new Promise(s=>{setTimeout(()=>{s()},t*1e3)}),Kn=(t,s)=>s==="wallet"||s==="webhook"?[{channel:s,type:"enabled",pass:t("notification.sendStatus.reason.enabled",{channel:s}),fail:t("notification.sendStatus.reason.disabled",{channel:s})}]:s==="pushKit"||s==="email"?[{channel:s,type:"available",pass:t("notification.sendStatus.reason.available",{channel:s}),fail:t("notification.sendStatus.reason.unavailable",{channel:s})},{channel:s,type:"enabled",pass:t("notification.sendStatus.reason.enabled",{channel:s}),fail:t("notification.sendStatus.reason.disabled",{channel:s})}]:[],Ee=(t=[])=>{const s=Z().startOf("day");return t.filter(n=>Z(n.sendAt).isSame(s,"day")).length},qn=(t,s="")=>{if(s&&Ve.includes(s)){const l=`${s}SendRecord`,j=oe(t,l,[]);return Ee(j)}const n=oe(t,"webhook",{}),r=Object.keys(n??{})??[];if(s&&r.includes(s)){const l=n[s]??[];return Ee(l)}const o={};return Ve.forEach(l=>{const j=`${l}SendRecord`,f=oe(t,j,[]),u=Ee(f);o[l]=u}),r.length>0&&r.forEach(l=>{const j=n[l]??[],f=Ee(j);o[l]=f}),o},Ae=(t,s,n)=>{if(!Array.isArray(t))throw new Error("Invalid filterList or index");return t[n].splice(s,1),t},Oe=(t,s)=>{if(!Array.isArray(s))throw new Error("filters must be an array");return s.length?!s.includes(t):!1},Mn=t=>{switch(t){case B.NOTIFICATION_SEND_CHANNEL.WALLET:return"Wallet";case B.NOTIFICATION_SEND_CHANNEL.PUSH:return"Push Kit";case B.NOTIFICATION_SEND_CHANNEL.EMAIL:return"Email";case B.NOTIFICATION_SEND_CHANNEL.WEBHOOK:return"Webhook";default:return""}},Lt=()=>({components:{MUIDataTableFilter:{styleOverrides:{header:{marginBottom:0,p:{margin:0}},root:{"& .MuiGrid-container":{marginTop:0,"& .MuiGrid-item":{paddingTop:0}}}}},MuiPopover:{styleOverrides:{root:{"&.MuiPopover-root":{"& .MuiPaper-root:has(.filter-container)":{width:"420px"}}}}}}});function ce({config:t,enableTooltip:s=!0,showTitle:n=!1,children:r=null}){const{status:o,title:l="",sentTime:j="",reason:f=""}=t,u=[l,f].filter(Boolean).join(", ");return e.jsx(ut,{title:s?e.jsxs(e.Fragment,{children:[e.jsx(ee,{color:"inherit",sx:{fontSize:12},children:u}),e.jsx("span",{children:j})]}):null,arrow:!0,placement:"top",children:e.jsxs(S,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"4px"},children:[e.jsxs(S,{sx:{position:"relative",minHeight:14,minWidth:14,display:"flex",alignItems:"center",justifyContent:"center"},children:[e.jsx(S,{style:{opacity:.15},sx:{position:"absolute",width:"100%",height:"100%",borderRadius:"50%",bgcolor:$e[o]}}),e.jsx(S,{sx:{position:"absolute",width:"55%",height:"55%",borderRadius:"50%",bgcolor:$e[o]}})]}),e.jsx(ee,{color:"inherit",sx:{fontSize:12},children:n?l:r})]})})}ce.propTypes={config:p.object.isRequired,enableTooltip:p.bool,showTitle:p.bool,children:p.node};De.propTypes={list:p.array.isRequired,label:p.string.isRequired,onDelete:p.func};function De({list:t,label:s,onDelete:n=()=>{}}){const{t:r,locale:o}=te();return e.jsxs(S,{sx:{display:"flex",gap:1,alignItems:"center"},children:[e.jsxs(ee,{children:[s,": "]}),t.map(l=>{const j=At(r,o,{status:l});return e.jsx(Je,{size:"small",label:e.jsx(S,{sx:{display:"flex",alignItems:"center",gap:"4px"},children:e.jsx(ce,{config:j,enableTooltip:!1,children:j.title})}),onDelete:f=>n(f,l)},l)})]})}Xe.propTypes={filterList:p.array.isRequired,onChange:p.func.isRequired,index:p.number.isRequired,column:p.object.isRequired,filterValues:p.array.isRequired,label:p.string.isRequired,renderLabel:p.func.isRequired};function Xe({filterList:t,onChange:s,index:n,column:r,filterValues:o,label:l,renderLabel:j}){return e.jsxs(V,{className:"filter-container",children:[e.jsx(pt,{component:"legend",children:l}),e.jsx(qe,{row:!0,children:o.map(f=>e.jsx(me,{control:e.jsx(Me,{checked:t[n].indexOf(f.value??f)>-1,onChange:u=>{const a=[...t];u.target.checked?a[n]=[...a[n],f.value??f]:a[n]=a[n].filter(y=>y!==(f.value??f)),s(a[n],n,r)},name:f.value??f}),label:e.jsx("span",{style:{display:"flex",alignItems:"center"},children:j(f)})},f.value??f))})]})}function We(t){return e.jsx(Xe,{...t,renderLabel:s=>e.jsx(ce,{enableTooltip:!1,config:{status:s.status},children:s.label})})}xe.propTypes={status:p.number.isRequired,updatedAt:p.string.isRequired,reason:p.string,channel:p.string,onResend:p.func};function xe({status:t,updatedAt:s,reason:n="",channel:r="wallet",onResend:o}){const{t:l,locale:j}=te(),f=At(l,j,{status:t,updatedAt:s,reason:n,channel:r});return e.jsxs(S,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(ce,{config:f,showTitle:!0}),f.status!=="success"&&e.jsx(Pe,{className:"resend-btn",size:"small",startIcon:e.jsx(Ge,{}),sx:{fontSize:12,color:"rgba(0, 0, 0, 0.87)",fontWeight:400,".MuiButton-startIcon":{mr:"2px"}},onClick:o,children:l("notification.resend")})]})}Ze.propTypes={value:p.array.isRequired,onChange:p.func};function Ze({value:t,onChange:s}){const{locale:n}=te(),r=Z().toDate(),[o,l]=v.useState(null),j=v.useCallback(a=>{l(o?null:a.currentTarget)},[o]),f=!!o,u=v.useCallback(a=>{if(!a.startDate||!a.endDate){q.error("Please select a date range");return}if(Z(a.startDate).isAfter(a.endDate)||!Z(a.startDate).isValid()||!Z(a.endDate).isValid()){q.error("Invalid date range");return}s([a.startDate,a.endDate]),l(null)},[s]);return e.jsxs("div",{children:[e.jsx(ee,{component:"div",variant:"h5",color:"textPrimary",style:{fontSize:18,fontWeight:"bold"},sx:{mb:0},children:e.jsxs(Pe,{onClick:j,variant:"outlined",size:"small",color:"inherit",children:[at(t[0],n)," - ",at(t[1],n)]})}),e.jsx(Ue,{open:f,anchorEl:o,onClose:()=>{l(null)},anchorOrigin:{vertical:"bottom",horizontal:"left"},children:e.jsx(vn,{open:!0,maxDate:r,initialDateRange:{startDate:t[0],endDate:t[1]},toggle:j,definedRanges:yn(r),onChange:u})})]})}et.propTypes={itemComponent:p.elementType.isRequired};function et({itemComponent:t,...s}){const{t:n}=te();return!s?.filterList?.filter(o=>o.length).length?null:e.jsxs(S,{sx:{display:"flex",gap:1,alignItems:"center"},children:[e.jsx("div",{className:"toolbar-filter-title",children:n("notification.filter")}),e.jsx("div",{className:"toolbar-filter-content",children:e.jsx(sn.TableFilterList,{...s,ItemComponent:t})})]})}function tt({label:t,onDelete:s,canDelete:n=()=>!0,...r}){const o=s&&typeof s=="function"?s:void 0;let l=!0;return n&&typeof n=="function"&&(l=n({label:t,...r})),e.jsx(Je,{label:t,variant:"outlined",...o&&l?{onDelete:o}:{}})}tt.propTypes={label:p.string.isRequired,onDelete:p.func,canDelete:p.func};const Un=[{label:"Wallet",value:"app",checked:!0},{label:"Email",value:"email",checked:!0},{label:"Push Kit",value:"push",checked:!0},{label:"Webhook",value:"webhook",checked:!0}];Pt.propTypes={loading:p.bool,onCancel:p.func,onConfirm:p.func};function Pt({loading:t=!1,onCancel:s=()=>{},onConfirm:n=()=>{}}){const{t:r}=te(),[o,l]=v.useState(Un),[j,f]=v.useState(!0),u=(y,R)=>{R.checked=y.target.checked;const w=o.map(b=>({...b,checked:b.value===R.value?R.checked:b.checked}));l(w)},a=y=>{y.stopPropagation(),n({channels:o.filter(R=>R.checked).map(R=>R.value),isResendFailedOnly:j})};return e.jsxs(S,{className:"resend-config",sx:{padding:"16px 24px"},children:[e.jsx(ee,{variant:"body1",component:"div",className:"check-title",sx:{fontWeight:700,mb:1},children:r("notification.config")}),e.jsx(S,{className:"choose-channel",children:e.jsxs(V,{component:"fieldset",variant:"standard",children:[e.jsx(pt,{component:"legend",children:r("notification.selectChannels")}),e.jsx(qe,{sx:{display:"flex",flexDirection:"row",flexWrap:"wrap",gap:1},children:o.map(y=>e.jsx(me,{control:e.jsx(Me,{checked:y.checked,onChange:R=>u(R,y),name:y.value}),label:y.label},y.value))})]})}),e.jsx(S,{className:"resend-config-footer",children:e.jsx(qe,{children:e.jsx(me,{control:e.jsx(Me,{checked:j,onChange:y=>f(y.target.checked)}),label:r("notification.resendFailedOnly")})})}),e.jsxs(S,{className:"resend-config-footer-tip",sx:{display:"flex",justifyContent:"flex-end",gap:1},children:[e.jsx(Pe,{onClick:y=>{y.stopPropagation(),s()},color:"inherit",children:r("common.cancel")}),e.jsxs(Pe,{onClick:a,color:"primary",disabled:t,variant:"contained",autoFocus:!0,style:{marginLeft:8},children:[t&&e.jsx(ft,{size:16}),r("common.confirm")]})]})]})}Ft.propTypes={notificationId:p.string.isRequired,handleResend:p.func,resending:p.bool};function Ft({notificationId:t,handleResend:s,resending:n=!1}){const{t:r,locale:o}=te(),l=ht(),j=v.useMemo(()=>jt(l,Lt()),[l]),{getReceivers:f,inService:u,teamDid:a,getUser:y,blocklet:R}=Qe(),[w,b]=v.useState(!1),[E,J]=v.useState([]),M=ye({anchorEl:null,position:null}),P=ye({anchorEl:null,position:null}),[F,N]=v.useState(null),[W,K]=v.useState({total:0,pageSize:10,pageCount:0,page:1}),[h,T]=v.useState({searchText:"",page:1,pageSize:10,walletSendStatus:[],pushKitSendStatus:[],emailSendStatus:[],dateRange:[Z().subtract(1,"month").startOf("day").toDate(),Z().endOf("day").toDate()]}),[k,i]=v.useState([]),C=[{label:r("notification.sendStatus.pending"),value:0,status:"pending"},{label:r("notification.sendStatus.success"),value:1,status:"success"},{label:r("notification.sendStatus.failed"),value:2,status:"failed"}],D=async()=>{if(!w&&t)try{b(!0);const c=await f({notificationId:t,...h}),d=c.list.map(m=>({...m,receiverUser:{...m.receiverUser,avatar:It(m.receiverUser.avatar,a,u)}}));J(d),K(c.paging),b(!1)}catch(c){q.error(c.message),b(!1)}};v.useEffect(()=>{D()},[h]);const O=c=>{c.stopPropagation();const d=c.currentTarget;P.anchorEl=d;const m=d.getBoundingClientRect();P.position={top:m.top+window.scrollY,left:m.left+window.scrollX}},ae=c=>c.data.length?e.jsx("div",{style:{display:"flex",alignItems:"center",padding:"10px"},children:e.jsx(le,{className:"resend-btn",size:"small",color:"primary",variant:"contained",startIcon:e.jsx(Ge,{}),sx:{".MuiButton-startIcon":{mr:"2px"}},onClick:O,children:r("notification.resend")})}):null,de={sort:!1,download:!1,print:!1,selectableRows:"multiple",searchPlaceholder:r("common.search"),searchAlwaysOpen:!1,filterType:"checkbox",searchDebounceTime:300,page:W.page-1,rowsPerPage:W.pageSize,count:W.total,searchText:h.searchText,tableBodyMaxHeight:"calc(80vh - 260px)",rowsSelected:k,onRowSelectionChange:(c,d)=>{i(d.map(m=>m.dataIndex))},customToolbarSelect:ae},re=({page:c,rowsPerPage:d,searchText:m,filterList:A})=>{const[,U=[],ne=[],G=[]]=A;h.pageSize!==d?T(H=>({...H,pageSize:d,page:1})):h.page!==c+1?T(H=>({...H,page:c+1})):h.searchText!==m?T(H=>({...H,searchText:m,page:1})):je(U,h.walletSendStatus)?je(ne,h.pushKitSendStatus)?je(G,h.emailSendStatus)||T(H=>({...H,emailSendStatus:G,page:1})):T(H=>({...H,pushKitSendStatus:ne,page:1})):T(H=>({...H,walletSendStatus:U,page:1}))},pe=v.useCallback(async(c,d)=>{if(!d)return!1;const m=await y(d);return m?c==="wallet"?Bn(m):c==="email"?_n(R,m):c==="pushKit"?zn(R,m):c==="webhook"?Wn(m):!0:!1},[y,R]),Fe=v.useCallback(c=>Kn(r,c),[r]),ue=()=>{M.anchorEl=null,M.position=null,N(null)},fe=()=>{P.anchorEl=null,P.position=null},we=async(c,d,m=!0,A="")=>{if(!(!d.length||!c.length))try{s(c,d,m,A),P.anchorEl||(await Ie(.5),ue())}catch(U){console.error("handleResend error",{error:U})}},g=async({channels:c,isResendFailedOnly:d})=>{const m=k.map(A=>E[A].receiver);await we(c,m,d),await Ie(.5),fe(),i([])},x=async(c,d=[],m=!0)=>{try{await we(["webhook"],[c.receiver],m,d)}catch(A){q.error(A.response?A.response.statusText:A.message)}},I=async(c,d,m,A=[],U=!0)=>{if(c.stopPropagation(),qn(d,m)>=4){q.warning(r("notification.resendLimit"));return}if(!Ve.includes(m)){await x(d,A,U);return}if(c){const G=c.currentTarget,H=G.getBoundingClientRect();M.anchorEl=G,M.position={top:H.top+window.scrollY,left:H.left+window.scrollX}}N({channel:m});try{const G=await pe(m,d.receiver);await Ie(1),N({channel:m,result:G}),(typeof G=="boolean"&&G||en(G)&&Object.values(G).every(H=>!!H))&&(await s([m],[d.receiver],U),P.anchorEl||(await Ie(.5),ue()))}catch(G){q.error(G.message)}},_=c=>{T(d=>({...d,dateRange:c,page:1}))},z=(c,d,m,A)=>{c.stopPropagation();const U=m.filter(ne=>ne!==d);T(ne=>({...ne,[A]:U,page:1}))},L=se(()=>[{label:r("notification.receiver"),name:"receiver",width:200,options:{filter:!1,customBodyRenderLite:c=>{const{receiverUser:d,receiver:m}=E[c];return d?e.jsxs(S,{"data-cy":`member-name-${d.fullName}`,sx:{display:"flex",alignItems:"center",gap:1,justifyContent:"flex-start"},children:[e.jsx(vt,{src:`${d.avatar}?imageFilter=resize&w=48&h=48`,size:32,did:m,shape:"circle",style:{borderRadius:"100%",overflow:"hidden"}}),e.jsx(Se,{children:d.fullName})]},m):e.jsx(jn,{size:14,responsive:!1,compact:!0,copyable:!1,did:m})}}},{label:"Wallet",name:"walletSendStatus",width:200,options:{setCellProps:()=>({className:"sent-status-cell"}),filter:!0,filterType:"custom",filterList:h.walletSendStatus??[],customFilterListOptions:{render:c=>e.jsx(De,{list:c,label:"Wallet",onDelete:(d,m)=>{d.stopPropagation(),z(d,m,L[1].options.filterList,"walletSendStatus")}}),update:Ae},filterOptions:{names:C,fullWidth:!0,logic:Oe,display:(c,d,m,A)=>e.jsx(We,{label:"Wallet",filterList:c,onChange:d,index:m,column:A,filterValues:C})},customBodyRenderLite:c=>{const{walletSendStatus:d,walletSendAt:m,walletSendFailedReason:A}=E[c];return e.jsx(xe,{status:d,updatedAt:m,reason:A,channel:"wallet",onResend:U=>I(U,E[c],"wallet",[],!1)})}}},{label:"Push Kit",name:"pushKitSendStatus",width:200,options:{setCellProps:()=>({className:"sent-status-cell"}),customBodyRenderLite:c=>{const{pushKitSendStatus:d,pushKitSendAt:m,pushKitSendFailedReason:A}=E[c];return e.jsx(xe,{status:d,updatedAt:m,reason:A,channel:"pushkit",onResend:U=>I(U,E[c],"pushKit",[],!1)})},filter:!0,filterType:"custom",filterList:h.pushKitSendStatus??[],customFilterListOptions:{render:c=>e.jsx(De,{list:c,label:"Push Kit",onDelete:(d,m)=>{d.stopPropagation(),z(d,m,L[2].options.filterList,"pushKitSendStatus")}}),update:Ae},filterOptions:{names:C,fullWidth:!0,logic:Oe,display:(c,d,m,A)=>e.jsx(We,{label:"Push Kit",filterList:c,onChange:d,index:m,column:A,filterValues:C})}}},{label:"Email",name:"emailSendStatus",width:200,options:{setCellProps:()=>({className:"sent-status-cell"}),customBodyRenderLite:c=>{const{emailSendStatus:d,emailSendAt:m,emailSendFailedReason:A}=E[c];return e.jsx(xe,{status:d,updatedAt:m,reason:A,channel:"email",onResend:U=>I(U,E[c],"email",[],!1)})},filter:!0,filterType:"custom",filterList:h.emailSendStatus??[],customFilterListOptions:{render:c=>e.jsx(De,{list:c,label:"Email",onDelete:(d,m)=>{d.stopPropagation(),z(d,m,L[3].options.filterList,"emailSendStatus")}}),update:Ae},filterOptions:{names:C,fullWidth:!0,logic:Oe,display:(c,d,m,A)=>e.jsx(We,{label:"Email",filterList:c,onChange:d,index:m,column:A,filterValues:C})}}},{label:"Webhook",name:"webhook",width:200,options:{filter:!1,setCellProps:()=>({className:"sent-status-cell"}),customBodyRenderLite:c=>{const{webhook:d}=E[c];if(!d)return null;const m=Object.entries(d)[0];if(!m)return null;const[A,U]=m,ne=U[0];return e.jsx(S,{sx:{display:"flex",flexDirection:"column",gap:1},children:e.jsxs(S,{className:"webhook-item",sx:{fontSize:12},children:[e.jsx(Se,{maxLength:30,children:A},A),e.jsx(xe,{status:ne.status,updatedAt:ne.sendAt,reason:ne.failedReason,channel:"webhook",onResend:G=>I(G,E[c],"webhook",[A],!1)})]},A)})}}},{label:r("common.createdAt"),name:"createdAt",width:100,options:{filter:!1,customBodyRenderLite:c=>{const{createdAt:d}=E[c];return e.jsx(Nt,{value:d,locale:o,shouldUpdate:!0})}}}],[E,o,h,r]),he=[e.jsx(Ze,{value:h.dateRange,onChange:_},"date-picker"),e.jsx(le,{variant:"contained",size:"small",color:"primary",loading:w,startIcon:e.jsx(qt,{}),onClick:()=>D(),sx:{".MuiButton-startIcon":{mr:"2px"}},style:{marginLeft:8},children:r("common.refresh")},"refresh")];return e.jsx(S,{sx:{overflow:"auto",".MuiTableCell-head":{whiteSpace:"nowrap",fontWeight:"bold"},".MuiTableCell-root":{paddingRight:"8px",whiteSpace:"nowrap"}},children:e.jsx($n,{children:e.jsxs(xt,{theme:j,children:[e.jsx(yt,{className:"receivers-table",locale:o,loading:w,columns:L,data:E,onChange:re,options:de,customButtons:he,components:{TableFilterList:c=>e.jsx(et,{...c,itemComponent:d=>e.jsx(tt,{...d,canDelete:()=>!1})})}}),M.anchorEl&&e.jsx(Ue,{open:!!M.anchorEl,anchorReference:"anchorPosition",anchorPosition:M.position,onClose:ue,anchorOrigin:{vertical:"center",horizontal:"right"},transformOrigin:{vertical:"center",horizontal:"left"},children:e.jsxs(Vn,{children:[e.jsxs(ee,{variant:"body1",component:"div",className:"check-title",children:[F?.channel," Checking"]}),e.jsx(S,{sx:{display:"flex",flexDirection:"column",gap:"4px"},children:Fe(F?.channel).map(c=>{const{type:d,pass:m,fail:A}=c;return!F?.result||F?.result?.[d]?e.jsxs(ee,{variant:"body1",component:"div",className:"check-item",sx:{display:"flex",alignItems:"center",gap:"4px",color:F?.result?.[d]?ke.success.main:"inherit"},children:[F?.result?e.jsx(Mt,{}):e.jsx(ft,{size:12,sx:{color:ke.primary.main}}),e.jsx("span",{children:m})]},d):e.jsxs(ee,{variant:"body1",component:"div",className:"check-item",sx:{display:"flex",alignItems:"center",gap:"4px",color:ke.error.main},children:[e.jsx(Ut,{}),e.jsx("span",{children:A})]},d)})})]})}),P.anchorEl&&e.jsx(Ue,{open:!!P.anchorEl,anchorReference:"anchorPosition",anchorPosition:P.position,onClose:fe,anchorOrigin:{vertical:"center",horizontal:"right"},transformOrigin:{vertical:"center",horizontal:"left"},children:e.jsx(Pt,{loading:n,onCancel:fe,onConfirm:g})})]})})})}const Hn=v.memo(Ft),$n=ie.div`
2
+ td.MuiTableCell-footer {
3
+ border: none !important;
4
+ }
5
+ .sent-status-cell {
6
+ .resend-btn {
7
+ display: none;
8
+ }
9
+ &:hover {
10
+ .resend-btn {
11
+ display: flex;
12
+ }
13
+ }
14
+ }
15
+ `,Vn=ie.div`
16
+ padding: 8px 16px;
17
+ .check-title {
18
+ font-weight: 500;
19
+ margin-bottom: 8px;
20
+ &::first-letter {
21
+ text-transform: uppercase;
22
+ }
23
+ }
24
+ .check-item {
25
+ svg {
26
+ font-size: 16px;
27
+ }
28
+ font-size: 12px;
29
+ }
30
+ `,ve=t=>t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}K`:t;function Jn(t){const{wallet:s,push:n,email:r,webhook:o}=t;return[{name:"Wallet",value:e.jsx(ge,{item:s})},{name:"Push",value:e.jsx(ge,{item:n})},{name:"Email",value:e.jsx(ge,{item:r})},...o.total>0?[{name:"Webhook",value:e.jsx(ge,{item:o,isWebhook:!0})}]:[]]}function Gn(t,s,n){const{wallet:r,push:o,email:l,webhook:j}=t;return[{name:"Wallet",value:e.jsx(be,{loading:n,channel:B.NOTIFICATION_SEND_CHANNEL.WALLET,item:r,onResend:s})},{name:"Push",value:e.jsx(be,{loading:n,channel:B.NOTIFICATION_SEND_CHANNEL.PUSH,item:o,onResend:s})},{name:"Email",value:e.jsx(be,{loading:n,channel:B.NOTIFICATION_SEND_CHANNEL.EMAIL,item:l,onResend:s})},...j.total>0?[{name:"Webhook",value:e.jsx(be,{loading:n,channel:B.NOTIFICATION_SEND_CHANNEL.WEBHOOK,item:j,isWebhook:!0,onResend:s})}]:[]]}nt.propTypes={statistics:p.object.isRequired,onResend:p.func,mode:p.oneOf(["simple","detail"]),resending:p.bool};ge.propTypes={item:p.object.isRequired,isWebhook:p.bool};function ge({item:t,isWebhook:s=!1}){const{t:n}=te(),r=s?t.success.length:t.success,o=t.total,l=r===o?"success":"failed";return e.jsx(S,{sx:{display:"flex",alignItems:"center",justifyContent:"flex-start",gap:2},children:e.jsx(S,{sx:{display:"flex",alignItems:"center",gap:1},children:e.jsxs(ce,{config:{status:l},enableTooltip:!1,children:[ve(r)," / ",ve(o)," ",n("notification.sendStatus.success")]})})})}be.propTypes={item:p.object.isRequired,isWebhook:p.bool,channel:p.string,onResend:p.func,loading:p.bool};function be({channel:t=B.NOTIFICATION_SEND_CHANNEL.WALLET,item:s,isWebhook:n=!1,onResend:r=()=>{},loading:o=!1}){const{t:l}=te(),{success:j,failed:f,pending:u}=s,a=Mn(t),y=n?j.length:j,R=n?f.length:f,w=n?u.length:u,b=async P=>{P.stopPropagation();const F=n?[...new Set([...j,...f].map(N=>N))]:[];await r([t],[],!0,F)},E=y+R,J=E>0?y/E*100:0,M=E>0?R/E*100:0;return e.jsxs(Yn,{successRatio:J,failedRatio:M,children:[e.jsxs(ee,{variant:"h6",children:[a," (",s.total,")"]}),e.jsxs(ee,{variant:"body1",sx:{mb:2},children:[e.jsx("span",{style:{color:$e.success,fontWeight:600,fontSize:24},children:ve(y)}),e.jsx("small",{style:{paddingLeft:4},children:l("notification.sendStatus.success")})]}),e.jsxs(S,{className:"unsent-area",children:[e.jsxs(S,{children:[e.jsxs(ce,{config:{status:"failed"},enableTooltip:!1,children:[ve(R)," ",l("notification.sendStatus.failed")]}),e.jsxs(ce,{config:{status:"pending"},enableTooltip:!1,children:[ve(w)," ",l("notification.sendStatus.pending")]})]}),R>0&&e.jsx(S,{className:"resend-btn",children:e.jsx(le,{size:"small",color:"primary",loading:o,variant:"contained",startIcon:e.jsx(Ge,{}),sx:{".MuiButton-startIcon":{mr:"2px"}},onClick:b,children:l("notification.resend")})})]})]})}function nt({statistics:t,mode:s="simple",onResend:n=()=>{},resending:r=!1}){const o=se(()=>s==="simple"?Jn(t):Gn(t,n,r),[t,s]);return s==="simple"?e.jsx("div",{children:o.map(l=>e.jsx(Tt,{style:{alignItems:"flex-start",marginBottom:s==="simple"?0:16},valueComponent:"div",nameWidth:100,name:l.name,children:l.value},l.name))}):e.jsx(st,{container:!0,spacing:2,children:o.map(l=>e.jsx(st,{size:{md:4,sm:6,xs:12},children:l.value},l.name))})}const Yn=ie(S)`
31
+ display: flex;
32
+ flex-direction: column;
33
+ align-items: flex-start;
34
+ padding: 16px;
35
+ border-radius: 8px;
36
+ background: ${({successRatio:t,failedRatio:s,theme:n})=>t===0&&s===0?n.palette.grey[300]:`linear-gradient(to right, ${Ht(n.palette.success.light,.4)} ${t}%, ${n.palette.grey[100]} ${t}%)`};
37
+ transition: 'background 0.5s ease';
38
+ cursor: pointer;
39
+ .unsent-area {
40
+ width: 100%;
41
+ position: relative;
42
+ .resend-btn {
43
+ position: absolute;
44
+ right: 0;
45
+ bottom: 0;
46
+ }
47
+ }
48
+ `;_t.propTypes={notification:p.object.isRequired,onCancel:p.func,blocklet:p.object.isRequired,tab:p.string};function _t({notification:t,onCancel:s=()=>{},blocklet:n,tab:r="info"}){const{t:o,locale:l}=te(),{getComponent:j,resendNotification:f}=Qe(),[u,a]=v.useState(!1),y=se(()=>j(t.componentDid)||n,[n,t.componentDid]),R=ye({tab:r||"info"}),w=v.useCallback(async(h,T,k=!0,i=[])=>{if(!h.length||!t.id)return;const C=T.length>0?T:t?.receivers?.map(O=>O.receiver);if(!C.length)return;let D=[...h];if(D.includes(B.NOTIFICATION_SEND_CHANNEL.PUSH)&&!Dt(n)&&(q.warning(o("notification.sendStatus.reason.unavailable",{channel:"Push Kit"})),D=D.filter(O=>O!==B.NOTIFICATION_SEND_CHANNEL.PUSH)),D.includes(B.NOTIFICATION_SEND_CHANNEL.EMAIL)&&!Ot(n)&&(q.warning(o("notification.sendStatus.reason.unavailable",{channel:"Email"})),D=D.filter(O=>O!==B.NOTIFICATION_SEND_CHANNEL.EMAIL)),!!D.length)try{a(!0),await f({notificationId:t.id,receivers:C,channels:D,resendFailedOnly:k,...D.includes("webhook")&&i.length?{webhookUrls:i}:{}}),q.success("Message has been sent!")}catch(O){console.error("handleResend error",{error:O}),q.error(O.response?O.response.statusText:O.message)}finally{a(!1)}},[n,t.id,t?.receivers,f,o]),b=se(()=>xn(t),[t]),E=se(()=>gn(t),[t]),J=se(()=>b?t?.actorInfo:[],[t]),M=se(()=>n?.did||n?.meta?.did||"",[n]);function P(){return[{name:o("notification.from"),value:b&&E?e.jsx(mn,{actors:J,teamDid:M,size:32,showName:!0}):e.jsx(pn,{size:32,blocklet:y,showName:!0,hideDot:!0})},{name:o("notification.notificationTitle"),value:e.jsx(Se,{maxLength:50,children:t.title})},{name:o("notification.body"),value:b?e.jsx(fn,{notification:t,blocklet:n}):e.jsx(bn,{notification:t,rows:0})},{name:o("notification.severity"),value:e.jsx(Ce,{severity:t.severity})},{name:o("notification.createdAt"),value:e.jsx(an,{value:t.createdAt,locale:l,shouldUpdate:!0,type:"all"})}].map(T=>e.jsx(Tt,{style:{alignItems:"flex-start"},valueComponent:"div",nameWidth:120,name:T.name,children:T.value},T.name))}const F={info:{label:o("common.basicInfo"),value:"info",component:P},receivers:{label:o("notification.receiver"),value:"receivers"},statistics:{label:o("notification.statistics"),value:"statistics"}},N=Object.values(F).map(({label:h,value:T})=>({label:h,value:T})),W=F[R.tab]||F.info,K=h=>{R.tab=h};return e.jsx(St,{title:o("notification.notificationDetails"),fullWidth:!0,maxWidth:"lg",onClose:()=>{R.tab="info",s()},open:!0,actionsPosition:"left",sx:{".ux-dialog_header":{paddingBottom:0},".MuiDialogContent-root":{paddingTop:0}},children:e.jsxs(Xn,{children:[e.jsx(S,{className:"tabs",sx:{mx:3},children:e.jsx(bt,{tabs:N,current:R.tab,onChange:K,scrollButtons:"auto"})}),e.jsxs("div",{className:"body",children:[R.tab==="receivers"&&e.jsx(Hn,{notificationId:t.id,resending:u,handleResend:w}),R.tab==="statistics"&&e.jsx(nt,{statistics:t.statistics,mode:"detail",resending:u,onResend:w}),R.tab==="info"&&e.jsx(W.component,{})]})]})})}const Qn=v.memo(_t),Xn=ie.div`
49
+ & > .notification-row {
50
+ padding: 0;
51
+ }
52
+
53
+ .tabs {
54
+ margin: 0;
55
+ }
56
+ .body {
57
+ margin-top: 16px;
58
+ }
59
+
60
+ .channel-item {
61
+ display: flex;
62
+ padding: 4px;
63
+ justify-content: flex-start;
64
+ align-items: center;
65
+ gap: 8px;
66
+ > p {
67
+ font-size: 15px;
68
+ }
69
+ .resend-btn {
70
+ svg {
71
+ font-size: 16px;
72
+ }
73
+ display: flex;
74
+ align-items: center;
75
+ font-size: 12px;
76
+ cursor: pointer;
77
+ &.disabled {
78
+ cursor: not-allowed;
79
+ color: ${ke.text.disabled};
80
+ }
81
+ }
82
+ }
83
+ `;Le.propTypes={blocklet:p.object,label:p.string};const Zn=ie.div`
84
+ display: flex;
85
+ justify-items: flex-start;
86
+ align-items: center;
87
+ gap: 8px;
88
+ .name {
89
+ display: block;
90
+ max-width: 260px;
91
+ white-space: nowrap;
92
+ overflow: hidden;
93
+ text-overflow: ellipsis;
94
+ }
95
+ `;function Le({blocklet:t=null,label:s=""}){return e.jsx(Zn,{children:t?e.jsxs(e.Fragment,{children:[e.jsx(Et,{size:24,blocklet:t,ancestors:t.ancestors}),e.jsx("span",{className:"name",children:t.title||t.meta?.title})]}):e.jsx("span",{className:"name",children:s})})}zt.propTypes={list:p.array.isRequired,label:p.string.isRequired,onDelete:p.func};function zt({list:t,label:s,onDelete:n=()=>{}}){return e.jsxs(S,{sx:{display:"flex",gap:1,alignItems:"center"},children:[e.jsxs(ee,{children:[s,": "]}),t.map(r=>e.jsx(Je,{size:"small",label:e.jsx(S,{sx:{display:"flex",alignItems:"center",gap:"4px"},children:e.jsx(Ce,{severity:r})}),onDelete:o=>n(o,r)},r))]})}function es(t){return e.jsx(Xe,{...t,renderLabel:s=>e.jsx(Ce,{severity:s})})}function ts({customTableButtons:t}){const{t:s,locale:n}=te(),r=ht(),o=$t(r.breakpoints.down("sm")),l=v.useMemo(()=>jt(r,Lt()),[r]),[j,f]=v.useState(!1),{data:u,paging:a,blocklet:y,fetch:R,getComponent:w,componentDids:b,inService:E,teamDid:J}=Qe(),M=v.useRef(null),[P,F]=v.useState(null),[N,W]=v.useState("info"),K=Sn(),[h,T]=v.useState(!1),k=`notification-records-${y.meta?.did}`,i=rn(k),[C,D]=v.useState({pageSize:i.rowsPerPage||10,page:i.page?i.page+1:1,dids:i.dids||[],dateRange:i.dateRange||[Z().subtract(1,"month").startOf("day").toDate(),Z().endOf("day").toDate()]}),O=se(()=>{if(!y.children||!y.children.length)return[];const g=[];return y.children.forEach(x=>{const I=x.did||x.meta?.did;b.includes(I)&&(x.ancestors=[y],g.push(x))}),g},[b,y]),ae=async g=>{try{f(!0),await R(g),f(!1)}finally{f(!1)}};v.useEffect(()=>{ae(C)},[C]),v.useEffect(()=>{const g=u.find(x=>x.id===P?.id);P&&g&&F({...g})},[u]);const de=(g,x,I,_)=>{g.stopPropagation();const z=I.filter(L=>L!==x);D(L=>({...L,[_]:z,page:1}))},re=({page:g,rowsPerPage:x,filterList:I})=>{const[_=[],,,,z=[]]=I;C.pageSize!==x?D(L=>({...L,pageSize:x,page:1})):C.page!==g+1?D(L=>({...L,page:g+1})):je(C.dids,_)?je(C.severities,z)||D(L=>({...L,severities:z,page:1})):D(L=>({...L,dids:_,page:1}))},pe=v.useCallback(()=>{F(null),W("info")},[]),Fe=v.useCallback(()=>{R(C)},[R,C]),ue=[{label:s("notification.from"),name:"sender",width:400,options:{filter:!0,filterType:"custom",customFilterListOptions:{render:g=>g.map((x,I)=>{if(x==="system")return e.jsx("span",{children:s("notification.system")},`system-${I}`);const _=O.find(z=>(z.did||z.meta?.did)===x);return e.jsx(Le,{blocklet:_,label:_?.title||_?.meta?.title},x)}),update:(g,x,I)=>(g[I].splice(x,1),g)},filterOptions:{names:O,logic:(g,x)=>x.length?!x.includes(g):!1,display:(g,x,I,_)=>e.jsxs(V,{style:{width:"380px"},children:[e.jsx(Vt,{id:"demo-simple-select-label",style:{background:"#ffffff"},children:"Sender"}),e.jsxs(Jt,{multiple:!0,value:g[I],renderValue:z=>e.jsx(S,{style:{overflow:"hidden",textOverflow:"ellipsis"},sx:{display:"flex",gap:1,alignItems:"center"},children:z.map(L=>{if(L==="system")return e.jsx("span",{children:s("notification.system")},L);const he=O.find(c=>(c.did||c.meta?.did)===L);return e.jsx(Le,{blocklet:he,label:he?.title||he?.meta?.title},L)})}),onChange:z=>{g[I]=z.target.value,x(g[I],I,_)},children:[e.jsx(it,{value:"system",children:s("notification.system")}),O.map(z=>{const L=z.did||z.meta?.did;return e.jsx(it,{value:L,children:e.jsx(Le,{blocklet:z,label:z.title||z.meta?.title})},L)})]})]})},customBodyRenderLite:g=>{const x=u[g],I=w(x.componentDid);return e.jsxs(S,{sx:{display:"flex",alignItems:"center",gap:1},children:[I?e.jsx(Et,{size:32,blocklet:I,ancestors:I.ancestors??[]}):e.jsx(hn,{blocklet:y,size:32}),e.jsx(Se,{maxLength:50,children:I?.meta?.title||y?.meta?.title})]})}}},{label:s("notification.receiver"),name:"receivers",width:300,options:{filter:!1,customBodyRenderLite:g=>{const x=u[g],{receivers:I}=x;return e.jsx(Gt,{total:I.length,renderSurplus:_=>_<100?e.jsxs("span",{children:["+",_]}):e.jsx("span",{children:"99+"}),max:3,sx:{justifyContent:"flex-end",height:"32px",".MuiAvatar-root":{width:"32px",height:"32px",fontSize:"12px",border:0,zIndex:2}},onClick:_=>{_.stopPropagation(),F(x),W("receivers")},children:I.map(_=>{const{receiverUser:z}=_,L=It(z.avatar,J,E);return e.jsx(vt,{alt:z.fullName,src:`${L}?imageFilter=resize&w=48&h=48`,size:32,did:_.receiver,shape:"circle",style:{borderRadius:"100%",overflow:"hidden"}},_.receiver)})})}}},{label:s("notification.statistics"),name:"statistics",width:400,options:{filter:!1,customBodyRenderLite:g=>{const x=u[g];return e.jsx(S,{onClick:I=>{I.stopPropagation(),F(x),W("statistics")},children:e.jsx(nt,{statistics:x.statistics})})}}},{label:s("notification.notificationPreview"),name:"data",options:{filter:!1,customBodyRenderLite:g=>{const x=u[g];return e.jsx(Se,{maxLength:50,children:x.title})}}},{label:s("notification.severity"),name:"severity",width:200,options:{setCellProps:()=>({className:"severity-cell"}),customBodyRenderLite:g=>{const x=u[g];return e.jsx(Ce,{severity:x.severity})},filter:!0,filterType:"custom",filterList:C.severities??[],customFilterListOptions:{render:g=>e.jsx(zt,{list:g,label:s("notification.severity"),onDelete:(x,I)=>{x.stopPropagation(),de(x,I,ue[4].options.filterList,"severities")}}),update:Ae},filterOptions:{names:dt,fullWidth:!0,logic:Oe,display:(g,x,I,_)=>e.jsx(es,{label:s("notification.severity"),filterList:g,onChange:x,index:I,column:_,filterValues:dt})}}},{label:s("common.createdAt"),name:"createdAt",width:300,options:{filter:!1,customBodyRenderLite:g=>{const{createdAt:x}=u[g];return e.jsx(Nt,{value:x,locale:n,shouldUpdate:!0})}}}],fe=g=>{D(x=>({...x,dateRange:g,page:1}))},we=[e.jsxs(S,{sx:{display:"flex",alignItems:"center",gap:1.5},children:[e.jsx(Yt,{onClick:()=>T(!0),sx:{p:K?0:void 0},children:e.jsx(Qt,{})},"settings"),K?e.jsx(ee,{children:s("common.setting")}):null]}),...t||[]];return e.jsxs(S,{ref:M,sx:{overflow:"auto",".MuiTableCell-head":{whiteSpace:"nowrap",fontWeight:"bold"},".MuiTableCell-root":{paddingRight:"8px",whiteSpace:"nowrap"}},children:[e.jsx(ns,{isBreakpointsDownSm:o,children:e.jsx(xt,{theme:l,children:e.jsx(yt,{className:"main-table",verticalKeyWidth:100,loading:j,locale:n,columns:ue,data:u,durable:k,onChange:re,options:{sort:!1,download:!1,print:!1,search:!1,expandableRowsOnClick:!0,page:a.page-1,rowsPerPage:a.pageSize,count:a.total,...i,onRowClick:(g,{dataIndex:x})=>{F(u[x])}},title:e.jsx(Ze,{value:C.dateRange,onChange:fe}),customButtons:we,components:{TableFilterList:g=>e.jsx(et,{...g,itemComponent:x=>e.jsx(tt,{...x,canDelete:I=>I?.columnNames?.[I?.index||0]?.name==="sender"})})}})})}),P&&e.jsx(Qn,{refresh:Fe,onCancel:pe,notification:P,blocklet:y,tab:N}),e.jsx(St,{title:`${s("common.notification")} ${s("common.setting")}`,fullWidth:!0,maxWidth:"md",open:h,onClose:()=>T(!1),PaperProps:{style:{minHeight:"500px"}},children:e.jsx(S,{sx:{mt:"-16px",overflowY:"hidden"},children:e.jsx(On,{})})})]})}const ns=ie.div`
96
+ td.MuiTableCell-footer {
97
+ border: none !important;
98
+ }
99
+ .sent-status-cell {
100
+ .resend-btn {
101
+ display: none;
102
+ }
103
+ &:hover {
104
+ .resend-btn {
105
+ display: flex;
106
+ }
107
+ }
108
+ }
109
+
110
+ .custom-toobar-btns {
111
+ gap: 4px;
112
+ }
113
+ .custom-toobar-title-inner {
114
+ display: flex;
115
+ justify-content: ${({isBreakpointsDownSm:t})=>t?"space-between":"flex-end"};
116
+ padding-right: ${({isBreakpointsDownSm:t})=>t?"0":"8px"};
117
+ flex-wrap: wrap;
118
+ gap: 8px;
119
+ }
120
+ `;ss.propTypes={blocklet:p.object.isRequired,customTableButtons:p.array};function ss({blocklet:t={},customTableButtons:s=[]}){return e.jsx(Ln,{blocklet:t,children:e.jsx(ts,{customTableButtons:s})})}export{ss as default};
@@ -0,0 +1,6 @@
1
+ import{j as e,ak as m,b4 as st,W as h,ar as L,cy as ot,a$ as it,T as B,c3 as at,c4 as lt,D as ct,V as dt,I as Oe,bb as oe,U as Z,n as ce,S as mt,cz as ut,Q as J,ai as gt,am as de,bf as pt,cb as xt,cc as ht,b1 as ze,b7 as ft,b8 as bt,b9 as vt,cA as yt,cB as jt,s as Ct,J as wt,c1 as Ot,z as me,bD as Be,aX as St,a6 as Tt,bV as Pt,aj as It,y as Dt,x as kt,bc as Mt,M as zt}from"./vendor-mui-core-DHT36AZL.js";import{V as N,H as O,h as Ne,z as Se,U as Re,i as _e,p as Rt,a2 as Et,b as ge,n as Ee}from"./vendor-ux-sqP3hEhY.js";import{r as C,i as qe,k as At}from"./vendor-react-CUXIiAnY.js";import{g as G,b as j,k as Ue,a as Wt,v as Lt,q as Bt,c as Nt}from"./vendor-hooks-fhL5FJET.js";import{ar as ie,at as ae,c as Pe,_ as He,aA as _t,as as ue,Y as qt,b6 as Ut,o as Ht}from"./index-CN4lpn74.js";import{u as Fe}from"./team-BnNEVFdE.js";import{u as $e}from"./use-mobile-DoKVMODs.js";import{A as Ft}from"./actions-CIp6hu8_.js";import{u as Je}from"./session-DNlfWI2Z.js";import{f as E}from"./index-DBs9Ljax.js";import{v as Ce}from"./index-BF7MtybM.js";import{e as Ve,A as $t,n as te}from"./vendor-utils-BSZ4yJws.js";import{F as Ae}from"./form-text-input-CBL3JAev.js";import{e as Jt}from"./edit.svg-Dz9cVo7r.js";import{C as Vt}from"./lock.svg-BPCZ0CT3.js";import{D as Kt,a as Gt,b as Xt,M as Qt}from"./index-C0TbDTja.js";import{c as Yt}from"./passport-CqvORkfw.js";import{C as Zt}from"./click-to-copy-DZ_4RDjR.js";import{I as er}from"./invitations-Cy_dNcIE.js";function Ke({members:t,total:o}){return e.jsxs(m,{className:"members-avatar-group",sx:{display:"flex",alignItems:"center","& > *:not(:first-of-type)":{ml:-1}},children:[t.map((a,i)=>e.jsx(m,{sx:{position:"relative",zIndex:i},children:e.jsx(ie,{did:a.userDid,avatarSize:32,cardType:ae.AvatarOnly,showHoverCard:!1})},a.userDid)),o>5&&e.jsxs(st,{sx:{width:32,height:32,bgcolor:"grey",fontSize:14},children:["+",o-5]})]})}Ke.propTypes={members:h.array.isRequired,total:h.number.isRequired};function Ge({org:t={},loading:o=!1}){const{t:a,locale:i}=N();return t.id?o?e.jsxs(m,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(L,{variant:"text",width:50,height:24}),e.jsx(L,{variant:"text",width:20,height:24})]}):e.jsxs(ot,{"aria-label":"breadcrumb",children:[e.jsx(it,{underline:"hover",color:"inherit",href:`${Pe.WELLKNOWN_SERVICE_PATH_PREFIX}/user/orgs?locale=${i}`,children:a("common.orgs")}),e.jsx(B,{children:t.name})]}):null}Ge.propTypes={org:h.object.isRequired,loading:h.bool};function tr(t){if(!t)return"";if(/[\u4e00-\u9fa5]/.test(t.charAt(0)))return t.charAt(0);const o=t.trim().split(/\s+/);return o.length>1?o.slice(0,2).map(a=>a.charAt(0).toUpperCase()).join(""):t.charAt(0).toUpperCase()}function Xe({org:t,loading:o=!1}){return e.jsxs(m,{sx:{display:"flex",alignItems:"center",gap:2},children:[e.jsx(m,{sx:{width:56,height:56,borderRadius:1,backgroundColor:"grey.100",display:"flex",alignItems:"center",justifyContent:"center"},children:o?e.jsx(L,{variant:"text",width:25,height:25}):e.jsx(B,{sx:{fontSize:30,fontWeight:600},children:tr(t.name)})}),e.jsxs(m,{sx:{flex:1,display:"flex",flexDirection:"column",justifyContent:"space-between"},children:[e.jsx(B,{variant:"h4",sx:{overflow:"hidden",display:"-webkit-box",WebkitLineClamp:1,WebkitBoxOrient:"vertical",textOverflow:"ellipsis"},children:o?e.jsx(L,{variant:"text",width:"10%",height:24}):t.name||"-"}),e.jsx(B,{variant:"body1",sx:{fontSize:14,lineHeight:1.2,overflow:"hidden",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical"},children:o?e.jsx(L,{variant:"text",width:"30%",height:24}):t.description||"-"})]})]})}Xe.propTypes={org:h.shape({name:h.string,description:h.string}).isRequired,loading:h.bool};function Ie({tabs:t,currentTab:o,onTabChange:a,loading:i=!1,extra:r=null}){return e.jsxs(m,{sx:{display:"flex",gap:1,alignItems:"center",justifyContent:"space-between",flexWrap:"wrap"},children:[i?e.jsx(L,{variant:"text",width:300,height:56}):e.jsx(at,{color:"primary",size:"small",value:o,exclusive:!0,onChange:(s,u)=>{u!==null&&a(u)},disabled:i,children:t.map(s=>e.jsx(lt,{size:"small",value:s.value,children:s.label},s.value))}),e.jsx(m,{children:r})]})}Ie.propTypes={tabs:h.array.isRequired,currentTab:h.string.isRequired,onTabChange:h.func.isRequired,loading:h.bool,extra:h.node};const Qe=C.createContext({}),{Provider:rr,Consumer:Rr}=Qe,we={type:"",org:{},paging:{page:1,pageSize:10}};function nr({children:t,editable:o=!0,mode:a="user-center",id:i=""}){const{t:r}=N(),{api:s}=He(),{teamDid:u}=Fe(),{session:b}=Je(),[g,y]=C.useState(!1),[I,d]=C.useState(0),[w,T]=C.useState(0),f=G({loading:!1,org:null,members:[],membersPaging:{page:1,pageSize:10},invitations:[],refresh:null,editable:!1,roles:[],error:null}),x=C.useMemo(()=>b?.user?.did,[b?.user?.did]),z=G({all:JSON.parse(JSON.stringify(we)),myCreated:JSON.parse(JSON.stringify({...we,type:"owned"})),myJoined:JSON.parse(JSON.stringify({...we,type:"joined"}))}),D=G({mode:"",org:null}),v=G({loading:!1,org:null,showInvite:!1,showInviting:!1,inviteLink:"",roles:[],mode:"list"}),S=G({mode:"create",item:null,loading:!1,org:null,visible:!1}),U=C.useMemo(()=>window.blocklet?.settings?.org||{},[]),{confirmApi:H,confirmHolder:X}=_t(),re=j(async({org:n={},type:c="",paging:p={page:1,pageSize:10}})=>{try{y(!0);const R=await s.getOrgs({input:{teamDid:u,paging:p,org:n,...c?{type:c}:{}}});return z.all={org:n,paging:p,type:c},R}catch(R){console.error(R),O.error(E(R));return}finally{y(!1)}}),M=j(async({org:n={},paging:c={page:1,pageSize:10}})=>{try{y(!0);const p=await s.getOrgs({input:{teamDid:u,paging:c,org:n,type:"owned"}});return d(p?.paging?.total||0),z.myCreated={org:n,paging:c,type:"owned"},p}catch(p){console.error(p),O.error(E(p));return}finally{y(!1)}}),A=j(async({org:n={},paging:c={page:1,pageSize:10}})=>{try{y(!0);const p=await s.getOrgs({input:{teamDid:u,paging:c,org:n,type:"joined"}});return z.myJoined={org:n,paging:c,type:"joined"},p}catch(p){console.error(p),O.error(E(p));return}finally{y(!1)}}),k=j(()=>{T(n=>n+1)}),F=j(async n=>{try{await s.deleteOrg({input:{teamDid:u,id:n.id}}),k()}catch(c){console.error(c),O.error(E(c))}}),pe=j(n=>new Promise((c,p)=>{H.open({title:r("team.orgs.deleteConfirm",{name:n.name}),content:r("team.orgs.deleteConfirmDescription"),confirmButtonText:r("common.delete"),cancelButtonText:r("common.cancel"),confirmButtonProps:{color:"error"},onConfirm:async R=>{await F(n),R(),c()},onCancel:()=>{p()}})})),xe=j(async n=>{try{await s.updateOrg({input:{teamDid:u,org:n}}),O.success(r("team.orgs.mutate.updateSuccess"))}catch(c){console.error(c),O.error(E(c))}}),ee=j(async n=>{try{await s.createOrg({input:{teamDid:u,name:n.name,description:n.description}}),O.success(r("team.orgs.mutate.createSuccess")),k()}catch(c){console.error(c),O.error(E(c))}}),V=j(async(n,c=f.membersPaging)=>{try{const p=await s.getOrgMembers({input:{teamDid:u,orgId:n,paging:c}});f.members=p.users,f.membersPaging=p.paging}catch(p){console.error(p),O.error(E(p))}}),ne=j(async(n,c={page:1,pageSize:10})=>{try{const p=await s.getInvitations({input:{teamDid:u,orgId:n,paging:c}});f.invitations=p.invitations}catch(p){console.error(p),O.error(E(p))}}),Q=j(async n=>{try{const c=await s.getRoles({input:{teamDid:u,orgId:n}});f.roles=c.roles,v.roles=c.roles}catch(c){console.error(c),O.error(E(c))}}),he=j(async(n,c)=>{try{await s.removeOrgMember({input:{teamDid:u,orgId:n,userDid:c}}),O.success(r("team.orgs.invite.removeSuccess")),Promise.all([V(n),ne(n)])}catch(p){console.error(p),O.error(E(p))}}),Y=j((n,c)=>{const{user:p,status:R}=c,$=R==="inviting";return new Promise((ye,le)=>{H.open({title:$?r("team.orgs.member.removeInvitingMember",{name:p.fullName}):r("team.orgs.member.removeMemberConfirm",{name:p.fullName}),content:$?r("team.orgs.member.removeInvitingMemberDescription",{name:p.fullName}):r("team.orgs.member.removeMemberConfirmDescription"),confirmButtonProps:{color:"error"},onConfirm:async je=>{await he(n,p.did),je(),ye()},onCancel:()=>{le()}})})}),se=j(async n=>{try{const c=await s.getOrg({input:{teamDid:u,id:n}});f.org=c.org,f.error=null,f.editable=o?c?.org?.ownerDid===x:!1}catch(c){f.error=E(c),console.error(c),O.error(E(c))}}),fe=j(n=>{if(!U?.enabled){O.error(r("team.orgs.mutate.orgNotEnabled"));return}D.org=n,D.mode="update"}),be=j(()=>{if(!U?.enabled){O.error(r("team.orgs.mutate.orgNotEnabled"));return}const{maxOrgPerUser:n=10}=U;if(n<=I){O.error(r("team.orgs.mutate.maxOrgPerUser",{maxOrgPerUser:n}));return}D.org={},D.mode="create"}),ve=j(({org:n,open:c=!1,mode:p="list"})=>{if(c&&n){if(v.org=n,v.mode=p,!U?.enabled){O.error(r("team.orgs.mutate.orgNotEnabled"));return}const{maxMemberPerOrg:R=100}=U;if(n.membersCount=n.membersCount||1,R<=(n?.membersCount??1)){O.error(r("team.orgs.mutate.maxMemberPerOrg",{maxMemberPerOrg:R}));return}Q(n.id)}else v.mode="list",v.org=null,v.roles=[],v.inviteLink="";v.showInvite=c}),Me=j(({org:n,open:c=!1})=>{v.showInviting=c,v.org=c?n:null}),K=j(()=>{D.org=null,D.mode=""}),l=j(async n=>{try{if(f.loading=!0,await se(n),f.error)return;f.editable?await Promise.all([V(n),ne(n),Q(n)]):await Promise.all([V(n),Q(n)])}catch(c){console.error(c)}finally{f.loading=!1}}),P=j(async({userDids:n,role:c,email:p,inviteType:R})=>{try{const{org:$}=v||{};if(!$)throw new Error(400,"Org is not found");v.loading=!0;const ye=await s.inviteMembersToOrg({input:{userDids:n,email:p,teamDid:u,orgId:$.id,role:c,inviteType:R}}),{failedDids:le,inviteLink:je}=ye.data||{};R==="external"?v.inviteLink=je:le.length?O.success(r("team.orgs.invite.failed",{count:le.length})):O.success(r("team.orgs.invite.success")),v.mode==="detail"?l($.id):k()}catch($){console.error($),O.error(E($))}finally{v.loading=!1}}),W=j(({org:n,mode:c="create",open:p=!1,item:R=null})=>{S.visible=p,S.org=p?n:null,S.mode=p?c:"create",S.item=p&&c==="update"?R:null});C.useEffect(()=>{i&&l(i)},[i,l]);const q={editable:o,refresh:k,refreshTrigger:w,loading:g,mode:a,teamDid:u,onTriggerEditOrg:fe,onTriggerCreateOrg:be,onCancelMutateOrg:K,mutationParams:D,inviteParams:{...v,onTriggerInviteDialog:ve,onTriggerInvitingDialog:Me},orgDetail:{...f,refresh:l},passportParams:{...S,onTriggerPassportDialog:W},requests:{getAllOrgs:re,getMyCreatedOrgs:M,getMyJoinedOrgs:A,deleteOrg:pe,updateOrg:xe,createOrg:ee,getOrgMembers:V,getOrgInvitations:ne,removeOrgMember:Y,getOrg:se,inviteMembers:P,getOrgRoles:Q}};return e.jsxs(rr,{value:q,children:[t,X]})}function _(){return C.useContext(Qe)}function Ye({index:t=0}){const o=[{name:"75%",info:"45%",detail:"60%"},{name:"65%",info:"55%",detail:"40%"},{name:"90%",info:"30%",detail:"65%"}],a=o[t%o.length];return e.jsxs(mt,{sx:{px:0,py:1},children:[e.jsx(ut,{children:e.jsx(L,{variant:"circular",width:32,height:32})}),e.jsxs(m,{sx:{flex:1},children:[e.jsx(L,{variant:"text",width:a.name,height:20,sx:{mb:.5}}),e.jsx(L,{variant:"text",width:a.info,height:16,sx:{mb:.25}})]})]})}Ye.propTypes={index:h.number};function sr(){const{t,locale:o}=N(),{orgDetail:a,requests:i}=_(),{org:r,members:s,loading:u,editable:b,membersPaging:g}=a||{},y=ct(),I=(T,f)=>{f==="changePage"&&(g.page=T.page+1,i.getOrgMembers(r.id,g)),f==="changeRowsPerPage"&&(g.page=1,g.pageSize=T.rowsPerPage,i.getOrgMembers(r.id,g))},d=[{name:"user",label:" ",options:{filter:!1,sort:!1,setCellHeaderProps:()=>({style:{display:"none"}}),setCellProps:()=>({style:{width:"33.33%"}}),customBodyRender:(T,f)=>{const x=s[f.rowIndex];if(!x||!x.user)return null;const{user:z}=x,D=x.userDid===r.ownerDid;return e.jsx(m,{sx:{py:{xs:.5,sm:1}},children:e.jsx(ie,{avatarSize:32,user:z,showDid:!0,cardType:ae.Detailed,infoType:ue.Minimal,sx:{border:0,padding:0},showHoverCard:!1,renderTopRightContent:b&&!D?()=>e.jsx(m,{sx:{display:{xs:"block",sm:"none"}},children:e.jsx(Oe,{size:"small",color:"error","aria-label":"delete",title:t("team.orgs.invite.remove"),onClick:v=>{v.stopPropagation(),i.removeOrgMember(r.id,x)},children:e.jsx(oe,{fontSize:"small"})})}):void 0})})}}},{name:"status",label:" ",options:{filter:!1,sort:!1,setCellHeaderProps:()=>({style:{display:"none"}}),setCellProps:()=>({style:{width:"33.33%"}}),customBodyRender:(T,f)=>{const x=s[f.rowIndex];if(!x||!x.user)return null;const{user:z}=x,{passports:D=[]}=z;return e.jsxs(m,{sx:{display:"flex",flexDirection:{xs:"column",sm:"row"},gap:.5,alignItems:"flex-start",py:{xs:.5,sm:1}},children:[e.jsxs(m,{sx:{display:{xs:"flex",sm:"none"},flexDirection:"row",gap:.5,alignItems:"center",flexWrap:"nowrap",overflow:"auto",maxWidth:"100%"},children:[D.map(v=>e.jsx(Z,{label:v.title,size:"small",sx:{flexShrink:0}},v.id)),x.status==="inviting"?e.jsx(Z,{label:t("common.inviting"),size:"small",sx:{backgroundColor:ce(y.palette.warning.main,.15),color:y.palette.warning.dark,flexShrink:0}}):e.jsx(Z,{label:t("team.orgs.active"),size:"small",sx:{backgroundColor:ce(y.palette.success.main,.15),color:y.palette.success.dark,flexShrink:0}}),x.updatedAt&&e.jsxs(B,{variant:"caption",color:"text.secondary",sx:{whiteSpace:"nowrap",flexShrink:0},children:[x.status==="inviting"?t("team.orgs.invitedAt"):t("team.orgs.joinedAt")," ",e.jsx(Se,{value:x.updatedAt})]})]}),e.jsxs(m,{sx:{display:{xs:"none",sm:"flex"},flexDirection:"row",gap:.5,alignItems:"center"},children:[D.map(v=>e.jsx(Z,{label:v.title,size:"small"},v.id)),x.status==="inviting"?e.jsx(Z,{label:t("common.inviting"),size:"small",sx:{backgroundColor:ce(y.palette.warning.main,.15),color:y.palette.warning.dark}}):e.jsx(Z,{label:t("team.orgs.active"),size:"small",sx:{backgroundColor:ce(y.palette.success.main,.15),color:y.palette.success.dark}})]})]})}}},{name:"updatedAt",label:" ",options:{filter:!1,sort:!1,setCellHeaderProps:()=>({style:{display:"none"}}),setCellProps:()=>({style:{width:"33.33%"}}),customBodyRender:(T,f)=>{const x=s[f.rowIndex];return!x||!x.updatedAt?null:e.jsx(m,{sx:{py:{xs:.5,sm:1},display:{xs:"none",sm:"flex"},flexDirection:"column",gap:.5,minWidth:0},children:e.jsxs(B,{variant:"caption",color:"text.secondary",sx:{whiteSpace:"nowrap"},children:[x.status==="inviting"?t("team.orgs.invitedAt"):t("team.orgs.joinedAt"),e.jsx(Se,{value:x.updatedAt})]})})}}},{name:"actions",label:" ",options:{filter:!1,sort:!1,setCellHeaderProps:()=>({style:{display:"none"}}),setCellProps:()=>({style:{width:"80px",minWidth:"80px",maxWidth:"80px"}}),customBodyRender:(T,f)=>{const x=s[f.rowIndex];if(!x||!x.user)return null;const z=x.userDid===r.ownerDid;return!b||z?null:e.jsx(m,{sx:{py:{xs:.5,sm:1},display:{xs:"none",sm:"block"}},children:e.jsx(Oe,{color:"error","aria-label":"delete",title:t("team.orgs.invite.remove"),onClick:()=>i.removeOrgMember(r.id,x),children:e.jsx(oe,{})})})}}}],w={sort:!1,download:!1,filter:!1,print:!1,search:!1,viewColumns:!1,selectableRows:"none",expandableRowsOnClick:!1,page:g.page-1,rowsPerPage:g.pageSize,count:g.total||0,pagination:g.pageCount>1};return u?e.jsx(m,{className:"members-list",children:e.jsx(dt,{sx:{width:"100%",bgcolor:"background.paper"},children:Array.from({length:3},(T,f)=>e.jsx(Ye,{index:f},`skeleton-${f}`))})}):e.jsx(m,{className:"members-list",sx:{width:"100%","& .org-members-table > div":{overflow:"hidden"},"& .MuiPaper-root":{overflow:{xs:"hidden",sm:"auto"}},"& table":{width:{xs:"100%",sm:"auto"},tableLayout:{xs:"fixed",sm:"auto"}},"& .MuiTableRow-root .MuiTableCell-root":{py:{xs:.5,sm:1}},"& tbody tr":{display:{xs:"grid",sm:"table-row"},gridTemplateColumns:{xs:"1fr",sm:"auto"},gridTemplateRows:{xs:"auto auto",sm:"auto"},"& td":{display:{xs:"block !important",sm:"table-cell !important"},"&:nth-of-type(1)":{gridColumn:{xs:"1",sm:"auto"},gridRow:{xs:"1",sm:"auto"}},"&:nth-of-type(2)":{gridColumn:{xs:"1",sm:"auto"},gridRow:{xs:"2",sm:"auto"},minWidth:{xs:0,sm:"auto"}},"&:nth-of-type(3), &:nth-of-type(4)":{display:{xs:"none !important",sm:"table-cell !important"}}}}},children:e.jsx(Ne,{className:"org-members-table",data:s,columns:d,loading:u,onChange:I,locale:o,options:w})})}function or(){const{t}=N(),{orgDetail:o,inviteParams:a}=_(),{invitations:i,editable:r,org:s}=o||{};return r?e.jsxs(m,{sx:{display:"flex",gap:1},children:[e.jsxs(J,{variant:"outlined",style:{flexShrink:0},color:"primary",size:"small",onClick:()=>{a.onTriggerInvitingDialog({org:s,open:!0})},children:[e.jsx(Re,{style:{height:"1em",marginRight:4},icon:"tabler:user"}),t("common.inviting"),i.length?` (${i.length})`:""]}),e.jsx(J,{variant:"contained",size:"small",onClick:()=>{a.onTriggerInviteDialog({org:s,open:!0,mode:"detail"})},startIcon:e.jsx(Re,{style:{fontSize:14},icon:"tabler:user-plus"}),children:t("common.invite")})]}):null}function De({children:t,...o}){const a=$e(),[i,r]=C.useState(!1),s=j(()=>{r(!i)});return C.useEffect(()=>{r(!1)},[a]),a?e.jsx(gt,{onClickAway:()=>r(!1),children:e.jsx(de,{...o,disableFocusListener:!0,disableHoverListener:!0,disableTouchListener:!0,slotProps:{popper:{disablePortal:!0}},open:i,onClose:s,children:C.cloneElement(t,{onClick:s})})}):e.jsx(de,{...o,children:t})}De.propTypes=de.propTypes;De.defaultProps=de.defaultProps;function ir(){const{orgDetail:t,requests:o}=_(),{org:a,loading:i,editable:r}=t||{},{t:s,locale:u}=N(),b=qe(),g=C.useMemo(()=>{const{settings:d={}}=window.blocklet||{};return Ve(d,"org.maxMemberPerOrg",100)},[]),y=j(async(d,w)=>{const T={...$t(a,["id","name","description"]),[d]:w};await o.updateOrg(T),t.refresh(T.id)}),I=j(async()=>{await o.deleteOrg(a),b(`${Pe.WELLKNOWN_SERVICE_PATH_PREFIX}/user/orgs?locale=${u}`)});return e.jsxs(m,{children:[e.jsxs(m,{sx:{display:"grid",gridTemplateColumns:"1fr",gap:2},children:[e.jsx(Ce,{valueComponent:"div",nameWidth:180,name:s("team.orgs.mutate.name"),children:r?e.jsx(Ae,{style:{marginTop:0},disabled:i,loading:i,initialValue:a.name,onSubmit:d=>y("name",d)}):a.name},a.name),e.jsx(Ce,{valueComponent:"div",nameWidth:180,name:s("common.description"),children:r?e.jsx(Ae,{style:{marginTop:0},disabled:i,loading:i,initialValue:a.description,type:"textarea",rows:3,onSubmit:d=>y("description",d)}):a.description},a.description),e.jsx(Ce,{valueComponent:"div",nameWidth:180,name:e.jsxs(B,{sx:{display:"flex",alignItems:"center",gap:.5},children:[s("team.orgs.invite.maxMembers"),e.jsx(De,{title:s("team.orgs.invite.maxMembersTip"),children:e.jsx(pt,{fontSize:"small",sx:{cursor:"pointer",fontSize:14}})})]}),children:g},a.id)]}),r&&e.jsx(m,{display:"flex",justifyContent:"flex-end",children:e.jsx(J,{variant:"contained",color:"error",size:"small",startIcon:e.jsx(oe,{style:{fontSize:16}}),onClick:I,children:s("team.orgs.deleteOrg")})})]})}function ar(){const{orgDetail:t,requests:o}=_(),{roles:a,org:i,editable:r}=t||{},[s,u]=C.useState(!1),b=(window.blocklet?.environments||[]).find(g=>g.key===qt.BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_PASSPORT_COLOR)?.value||"auto";return e.jsxs(Kt,{children:[e.jsx(m,{className:"list",children:a.map(g=>e.jsx(Gt,{role:g,createPassportSvg:Yt,onUpdate:u,actions:r?e.jsx("div",{className:"action",children:Ut(g.name)?e.jsx(Vt,{}):e.jsx(Jt,{})}):null,passportProps:{issuer:i.name,issuerDid:i.ownerDid,ownerDid:i.ownerDid,preferredColor:b}},g.name))}),s&&e.jsx(Xt,{onCancel:()=>u(!1),roles:a,onSuccess:()=>{u(!1),o.getOrgRoles(i.id)},onDelete:()=>{u(!1),o.getOrgRoles(i.id)},mode:"update",roleName:s.name,item:s,orgId:i.id,hasPermission:r})]})}function lr(){const{t}=N(),{orgDetail:o,passportParams:a}=_(),{org:i,editable:r}=o||{};return r?e.jsx(m,{sx:{display:"flex",gap:1},children:e.jsx(J,{variant:"contained",size:"small",onClick:()=>{a.onTriggerPassportDialog({org:i,open:!0})},startIcon:e.jsx(xt,{}),children:t("team.passport.create.title")})}):null}function cr(){const{teamDid:t,passportParams:o,requests:a}=_(),{visible:i,org:r}=o||{};return i?e.jsx(Qt,{teamDid:t,orgId:r.id,onCancel:()=>o.onTriggerPassportDialog({open:!1}),onSuccess:()=>{o.onTriggerPassportDialog({open:!1}),a.getOrgRoles(r.id)}}):null}function ke({id:t="",inDialog:o=!1}){const{orgDetail:a}=_(),{t:i}=N(),[r,s]=C.useState("members"),{org:u,loading:b,refresh:g,error:y}=a||{},I=[{label:i("team.orgs.members"),value:"members"},{label:i("common.settings"),value:"settings"},{label:i("team.member.passports"),value:"passports"}];if(C.useEffect(()=>{t&&o&&g(t)},[t,o]),y)return e.jsx(_e,{children:y});if(!u)return null;const d=()=>r==="members"?e.jsx(or,{}):r==="passports"?e.jsx(lr,{}):null;return e.jsxs(m,{children:[!o&&e.jsx(Ge,{org:u,loading:b}),e.jsxs(m,{sx:{mt:2},children:[e.jsx(Xe,{org:u,loading:b}),e.jsxs(m,{sx:{mt:1,p:2,border:w=>`1px solid ${w.palette.divider}`,borderRadius:1},children:[e.jsx(Ie,{tabs:I,currentTab:r,onTabChange:s,loading:b,extra:d()}),e.jsxs(m,{sx:{mt:2},children:[r==="members"&&e.jsx(sr,{}),r==="settings"&&e.jsx(ir,{}),r==="passports"&&e.jsx(ar,{})]})]})]})]})}ke.propTypes={id:h.string,inDialog:h.bool};function dr(){const{t,locale:o}=C.useContext(Rt),{teamDid:a}=Fe(),i=C.useRef(null),[r,s]=C.useState(null),[u,b]=C.useState(0),g=$e(),y=`orgs-${a}`,I=Et(y),d=G({searchText:I.searchText||"",pageSize:I.rowsPerPage||10,page:1}),{editable:w,loading:T,requests:f,onTriggerEditOrg:x,onTriggerCreateOrg:z,refreshTrigger:D}=_(),{data:v,refresh:S}=Ue(async()=>{const M={};d.searchText&&(M.name=d.searchText,M.description=d.searchText);const{orgs:A,paging:k}=await f.getAllOrgs({org:M,paging:{page:d.page,pageSize:d.pageSize}});return b(k.total),A},{refreshDeps:[a,d.page,d.pageSize,d.searchText],onError:M=>{O.error(E(M))}}),U=({page:M,rowsPerPage:A,searchText:k})=>{d.pageSize!==A?(d.pageSize=A,d.page=1):d.page!==M+1?d.page=M+1:d.searchText!==k&&(d.searchText=k,d.page=1)};C.useEffect(()=>{D>0&&S&&S()},[D,S]);const H=[{label:t("common.orgs"),name:"name"},{label:t("common.members"),name:"members",options:{customBodyRender:(M,{rowIndex:A})=>{const k=v[A];return e.jsx(Ke,{members:k.members,total:k.membersCount})}}},{label:t("team.orgs.description"),name:"description"},{label:t("common.createdBy"),name:"owner",options:{customBodyRender:(M,{rowIndex:A})=>{const k=v[A];return e.jsx(m,{children:e.jsx(ie,{showHoverCard:!1,avatarSize:32,did:k.ownerDid,cardType:ae.Detailed,infoType:ue.Minimal,sx:{border:0,padding:0,...g&&{minWidth:"unset"}}})})}}},{label:t("common.createdAt"),name:"createdAt",options:{customBodyRender:M=>e.jsx(m,{children:M?e.jsx(Se,{value:M,locale:o}):"-"})}},w&&{label:t("common.actions"),name:"actions",width:100,align:"center",verticalKeyAlign:"center",options:{customBodyRender:(M,{rowIndex:A})=>{const k=v[A];return e.jsx(m,{children:e.jsx(Ft,{"data-cy":"orgs-table-actions",actions:[{icon:e.jsx(ht,{}),text:t("common.edit"),onClick:F=>{F.stopPropagation(),x(k)}},{icon:e.jsx(oe,{}),text:t("common.delete"),onClick:F=>{F.stopPropagation(),f.deleteOrg(k)}}]})})}}}],X={sort:!1,download:!1,filter:!1,print:!1,expandableRowsOnClick:!0,onRowClick(M,A,k){if(i.current?.contains(k.target)){const F=v[A.dataIndex];s(F)}},page:d.page-1,rowsPerPage:d.pageSize,count:u,searchDebounceTime:600},re=w?[e.jsx(J,{variant:"contained",size:"small",onClick:()=>{z()},children:t("common.create")},"add")]:[];return e.jsxs(m,{children:[e.jsx("div",{ref:i,className:"orgs-table",children:e.jsx(Ne,{className:"orgs-table",verticalKeyWidth:100,loading:T,columns:H,data:v||[],locale:o,durable:y,durableKeys:["page","rowsPerPage"],customButtons:re,options:X,onChange:U})}),r&&e.jsx(ge,{fullWidth:!0,maxWidth:"lg",title:r.name,open:!!r,onClose:()=>s(null),sx:{".MuiDialogContent-root":{pt:0}},children:e.jsx(ke,{id:r.id,inDialog:!0})})]})}function Ze({org:t,onInviteUser:o=te,onDelete:a=te,onClick:i=te,loading:r=!1,editable:s=!0}){const{t:u}=N(),{session:b}=Je(),g=C.useMemo(()=>b?.user?.did===t.ownerDid,[b?.user?.did,t.ownerDid]),y=()=>s?e.jsxs(e.Fragment,{children:[e.jsx(We,{variant:"outlined",size:"small",startIcon:e.jsx(jt,{style:{fontSize:16}}),onClick:d=>{d.stopPropagation(),o?.(t)},children:u("common.invite")}),e.jsx(We,{variant:"contained",color:"error",size:"small",startIcon:e.jsx(oe,{style:{fontSize:16}}),onClick:d=>{d.stopPropagation(),a?.(t)},children:u("common.delete")})]}):null,I=j(()=>g?null:t?.passports?.length>0?e.jsx(Z,{label:t.passports[0].title,size:"small"}):null);return e.jsx(ze,{sx:{flexDirection:{xs:"column",md:"row"},gap:{xs:2,md:2},cursor:"pointer",minWidth:300},onClick:()=>i?.(t),children:e.jsxs(ft,{sx:{boxShadow:1,border:"1px solid",borderColor:"divider",backgroundColor:"background.default",flex:1,display:"flex",flexDirection:"column"},children:[e.jsx(bt,{title:e.jsxs(ze,{direction:"row",spacing:1,sx:{alignItems:"center",justifyContent:"space-between"},children:[r?e.jsx(L,{variant:"text",width:"100%",height:24}):e.jsx(B,{variant:"h4",sx:{fontWeight:600},children:t.name}),r?e.jsx(L,{variant:"text",width:50,height:24}):I()]}),sx:{pb:2}}),e.jsxs(vt,{sx:{pt:0,flex:1,display:"flex",flexDirection:"column",gap:1,"&.MuiCardContent-root":{pb:2}},children:[e.jsx(B,{variant:"body2",sx:{color:"text.secondary",overflow:"hidden",display:"-webkit-box",WebkitLineClamp:3,WebkitBoxOrient:"vertical",height:56},children:r?e.jsxs(e.Fragment,{children:[e.jsx(L,{variant:"text",width:"100%",height:24}),e.jsx(L,{variant:"text",width:"80%",height:24})]}):t.description}),e.jsxs(m,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[r?e.jsx(L,{variant:"text",width:"30%",height:24}):e.jsxs(m,{sx:{display:"flex",alignItems:"center",gap:.5,color:"text.secondary",fontSize:14},children:[e.jsx(yt,{sx:{fontSize:"18px"}}),e.jsxs("span",{children:[t.membersCount||t.members?.length||1," ",u("team.orgs.members")]})]}),e.jsx(m,{sx:{display:"flex",alignItems:"center",gap:1},children:r?e.jsxs(e.Fragment,{children:[e.jsx(L,{variant:"text",width:50,height:24}),e.jsx(L,{variant:"text",width:50,height:24})]}):y()})]})]})]})})}Ze.propTypes={org:h.object.isRequired,onInviteUser:h.func,onDelete:h.func,onClick:h.func,loading:h.bool,editable:h.bool};const We=Ct(J)`
2
+ font-weight: 500;
3
+ .MuiButton-icon {
4
+ margin-right: 4px;
5
+ }
6
+ `;function et({paging:t,loading:o=!1,onChange:a=()=>{}}){const{locale:i}=N(),r=wt(d=>d.breakpoints.down("lg")),s=j((d,w)=>{a({page:w+1})}),u=j(d=>{const w=Number(d.target.value);a({page:1,pageSize:w})});if(t.pageCount<=1)return null;const{page:b,pageSize:g,total:y}=t,I=b-1<=0?0:b-1;return e.jsx(m,{className:"pagination",sx:{width:"100%",flex:1,display:"flex",justifyContent:r?"center":"flex-end"},children:e.jsx(Ot,{component:"div",disabled:o,count:y,locale:i,page:I,rowsPerPage:g,rowsPerPageOptions:[],onPageChange:s,onRowsPerPageChange:u})})}et.propTypes={paging:h.shape({page:h.number,pageSize:h.number,total:h.number,pageCount:h.number}).isRequired,loading:h.bool,onChange:h.func};function Te({type:t,onInviteUser:o=te,onClickOrg:a=te,editable:i=!0,extra:r=null}){const{t:s}=N(),u=G({page:1,pageSize:6}),{requests:b,loading:g,refreshTrigger:y}=_(),I=C.useMemo(()=>s(t==="owned"?"team.orgs.myCreated":"team.orgs.myJoined"),[t,s]),d=C.useMemo(()=>s(t==="owned"?"team.orgs.myCreatedEmpty":"team.orgs.myJoinedEmpty"),[t,s]),{data:w,refresh:T}=Ue(()=>(t==="owned"?b.getMyCreatedOrgs:b.getMyJoinedOrgs)({paging:u}),{refreshDeps:[u.page,u.pageSize,t]}),{orgs:f=[],paging:x}=w||{},z=C.useMemo(()=>g?[{id:1},{id:2},{id:3}]:f,[g,f]),D=C.useMemo(()=>!g&&f.length===0,[g,f]),v=j(S=>{u.page=S.page});return C.useEffect(()=>{y>0&&T&&T()},[y,T]),e.jsxs(m,{children:[e.jsxs(m,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mb:2},children:[e.jsx(B,{variant:"h6",children:I}),r]}),D?e.jsx(m,{className:"orgs-empty",sx:{py:4},children:e.jsx(_e,{children:d})}):e.jsxs(m,{children:[e.jsx(m,{sx:{display:"grid",px:1,gridTemplateColumns:{md:"1fr",lg:"repeat(2, 1fr)",xl:"repeat(3, 1fr)"},gap:2},children:z.map(S=>e.jsx(Ze,{org:S,onInviteUser:o,onDelete:b.deleteOrg,onClick:a,loading:g,editable:i},S.id))}),x?.pageCount>1&&e.jsx(et,{paging:x,loading:g,onChange:v})]})]})}Te.propTypes={type:h.oneOf(["owned","joined"]).isRequired,onInviteUser:h.func,onClickOrg:h.func,editable:h.bool,extra:h.node};function mr(){const{t}=N(),{onTriggerCreateOrg:o,inviteParams:a}=_(),i=qe(),r=At(),s=j(b=>{a.org=b,a.onTriggerInviteDialog({open:!0,org:b,mode:"list"})}),u=j(b=>{const g=`${Pe.WELLKNOWN_SERVICE_PATH_PREFIX}/user/orgs/${b.id}`;i({pathname:g,search:r.search})});return e.jsxs(m,{sx:{display:"flex",flexDirection:"column",gap:2},children:[e.jsx(Te,{type:"owned",onInviteUser:s,onClickOrg:u,extra:e.jsx(J,{onClick:o,children:t("common.create")})}),e.jsx(Te,{type:"joined",onInviteUser:s,onClickOrg:u,editable:!1})]})}function tt({mode:t="create",item:o={},onSuccess:a=te,mutationParams:i=void 0}){const[r,s]=C.useState(!1),[u,b]=C.useState(""),{t:g}=N(),y=_(),{requests:I,onCancelMutateOrg:d}=i||y,w=G({name:o.name||"",description:o.description||""}),T=async()=>{const x=w.name.trim();if(!x){b(g("team.orgs.validate.nameEmpty"));return}if(x.length>20){b(g("team.orgs.validate.nameTooLong",{length:20}));return}const z=w.description.trim();if(z.length>255){b(g("team.orgs.validate.descriptionTooLong",{length:255}));return}b(null),s(!0);try{t==="create"?await I.createOrg({name:x,description:z}):await I.updateOrg({id:o.id,name:x,description:z}),d(),a()}catch(D){console.error(D);const v=E(D);b(v),O.error(E(u))}finally{s(!1)}},f=e.jsxs("div",{children:[e.jsx(B,{component:"div",style:{marginTop:16},children:e.jsx(me,{label:g("team.orgs.mutate.name"),autoComplete:"off",variant:"outlined",name:"name","data-cy":"mutate-org-input-name",fullWidth:!0,autoFocus:!0,value:w.name,onChange:x=>{b(null),w.name=x.target.value},disabled:r})}),e.jsx(B,{component:"div",style:{marginTop:16,marginBottom:16},children:e.jsx(me,{label:g("common.description"),autoComplete:"off",variant:"outlined",name:"description","data-cy":"mutate-org-input-description",fullWidth:!0,value:w.description,onChange:x=>{b(null),w.description=x.target.value},disabled:r,multiline:!0,rows:3})})]});return e.jsxs(ge,{title:g("team.orgs.mutate.title",{mode:g(t==="create"?"common.create":"common.update")}),fullWidth:!0,open:!0,onClose:d,showCloseButton:!1,actions:e.jsxs(e.Fragment,{children:[e.jsx(Ee,{onClick:d,color:"inherit",children:g("common.cancel")}),e.jsxs(Ee,{"data-cy":"mutate-org-confirm",onClick:T,color:"primary",disabled:r,variant:"contained",autoFocus:!0,children:[r&&e.jsx(Tt,{size:16}),g(t==="create"?"common.create":"common.update")]})]}),children:[e.jsx(Be,{component:"div",children:f}),!!u&&e.jsx(St,{severity:"error",style:{width:"100%",margin:0},children:u})]})}tt.propTypes={mode:h.oneOf(["create","update"]),item:h.object,onSuccess:h.func,mutationParams:h.object};var ur={};const Le=20;function gr(){const{t,locale:o}=N(),{api:a}=He(),{inviteParams:i,teamDid:r,requests:s}=_(),{showInvite:u,onTriggerInviteDialog:b,org:g,inviteLink:y,roles:I}=i||{},[d,w]=C.useState([]),[T,f]=C.useState(""),[x,z]=C.useState(!1),[D,v]=C.useState(""),[S,U]=C.useState("internal"),[H,X]=C.useState(""),[re,M]=C.useState(0),A=[{label:t("blocklet.internal"),value:"internal"},{label:t("blocklet.external"),value:"external"}],k=Wt(()=>{const{settings:l}=window.blocklet||{};return Ve(l,"notification.email.enabled")},[]),F=Lt(D,{wait:500}),{data:pe,loadMore:xe,loadingMore:ee}=Bt(async l=>{const P=l?Math.ceil(l.list.length/Le)+1:1,W=await a.getOrgInvitableUsers({input:{teamDid:r,id:g.id,query:{search:F},paging:{page:P,pageSize:Le}}}),{users:q=[],paging:n}=W||{};return{list:q,total:n?.total||0}},{reloadDeps:[r,F,g.id],isNoMore:l=>l?.list.length?l.list.length>=l?.total:!0,onError:l=>{console.error("Get users failed",l)}}),{list:V=[],total:ne=0}=pe||{},Q=V.length<ne,he=j(l=>{const P=l.target,{scrollTop:W,scrollHeight:q,clientHeight:n}=P;q-W-n<50&&!ee&&Q&&xe()}),Y=j(()=>{w([]),f(""),v(""),U("internal"),X(""),M(0),b({open:!1})}),se=j(async()=>{if(S==="internal"&&!d.length){O.error(t("team.orgs.invite.pleaseSelectUsers"));return}if(S==="external"&&!H.trim()){O.error(t("team.orgs.invite.pleaseEnterEmail"));return}if(!T){O.error(t("team.orgs.invite.pleaseSelectRole"));return}try{const l=S==="internal"?d.map(W=>W.did):[],P=S==="external"?H.trim():"";await s.inviteMembers({userDids:l,email:P,role:T,inviteType:S}),S==="external"?M(1):Y()}catch(l){console.error(l),O.error(E(l))}finally{z(!1)}}),fe=j(l=>{w(P=>P.filter(W=>W.did!==l.did))}),be=j(l=>{U(l),l==="external"?w([]):X("")}),ve=j(()=>{if(["1","true"].includes(ur.IS_E2E)){Y();return}Nt(y),O.success(t("common.copied")),Y()}),K=[{title:t("team.orgs.invite.inviteTitle",{orgName:g.name}),body:()=>e.jsxs(m,{sx:{display:"flex",flexDirection:"column",gap:2},children:[e.jsx(m,{sx:{display:"flex",justifyContent:"flex-start"},children:e.jsx(Ie,{tabs:A,currentTab:S,onTabChange:be,loading:x})}),S==="internal"&&e.jsx(Pt,{multiple:!0,options:V,"data-cy":"invite-org-select-users",loading:ee,disabled:x,getOptionLabel:l=>`${l.fullName||l.name||l.did||""}`,isOptionEqualToValue:(l,P)=>l.did===P.did,filterOptions:l=>l,value:d,inputValue:D,onChange:(l,P,W,q)=>{if(W==="selectOption"){const n=q.option,c=d.some(p=>p.did===n.did);w(c?p=>p.filter(R=>R.did!==n.did):p=>[...p,n]),v("")}else w(P)},onInputChange:(l,P,W)=>{W==="input"?v(P):W==="clear"&&v("")},renderInput:l=>e.jsx(me,{...l,label:t("common.member"),placeholder:t("team.orgs.invite.chooseUsersToInvite"),slotProps:{input:{...l.InputProps,endAdornment:e.jsxs(e.Fragment,{children:[ee&&e.jsx(m,{sx:{ml:1,fontSize:14,color:"text.secondary"},children:t("common.loading")}),l.InputProps.endAdornment]})}}}),renderValue:l=>e.jsx(m,{sx:{display:"flex",flexWrap:"wrap",gap:1},children:l.map(P=>e.jsx(ie,{did:P.did,avatarSize:20,cardType:ae.Detailed,infoType:ue.Minimal,sx:{border:0,padding:0,minWidth:150,maxWidth:150},showHoverCard:!1,renderTopRightContent:()=>e.jsx(Oe,{size:"small",onClick:()=>fe(P),children:e.jsx(It,{sx:{fontSize:14}})})},P.did))}),slotProps:{listbox:{onScroll:he,sx:{maxHeight:300}},popper:{placement:"bottom-start",modifiers:[{name:"flip",enabled:!0,options:{altBoundary:!0,rootBoundary:"document",padding:8}}]}},renderOption:(l,P,{index:W})=>{const q=d.some(c=>c.did===P.did),n=W===V.length-1;return e.jsxs(m,{children:[e.jsx(m,{component:"li",...l,sx:{backgroundColor:q?"action.selected":"transparent",fontWeight:q?600:400,"&:hover":{backgroundColor:q?"action.selected":"action.hover"},position:"relative"},children:e.jsxs(m,{sx:{display:"flex",alignItems:"center",width:"100%"},children:[e.jsx(m,{sx:{flex:1},children:e.jsx(ie,{avatarSize:32,did:P.did,showDid:!0,cardType:ae.Detailed,infoType:ue.Minimal,sx:{border:0,padding:0},showHoverCard:!1})}),q&&e.jsx(m,{sx:{width:20,height:20,borderRadius:"50%",backgroundColor:"primary.main",color:"white",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"12px",ml:1},children:"✓"})]})},P.did),n&&Q&&e.jsx(m,{sx:{display:"flex",justifyContent:"center",py:1,color:"text.secondary",fontSize:"0.875rem"},children:t(ee?"common.loadingMore":"common.loadMore")})]},P.did)}}),S==="external"&&e.jsx(me,{fullWidth:!0,type:"email",label:t("common.email"),placeholder:t("team.orgs.invite.enterEmailAddress"),value:H,onChange:l=>X(l.target.value),disabled:x,variant:"outlined"}),e.jsxs(Dt,{fullWidth:!0,variant:"outlined",children:[e.jsx(kt,{children:t("common.passport")}),e.jsx(Mt,{"data-cy":"invite-org-select-role",value:T,onChange:l=>{f(l.target.value)},fullWidth:!0,label:t("common.passport"),disabled:x,onKeyPress:l=>{l.key==="Enter"&&(l.preventDefault(),se())},children:I.map(l=>e.jsx(zt,{value:l.name,"data-cy":`invite-org-select-option-${l.name}`,children:e.jsxs(m,{sx:{display:"flex",flexDirection:"column"},children:[e.jsx(B,{variant:"subtitle1",children:l.title||l.name}),e.jsx(B,{variant:"caption",sx:{opacity:.7},children:l.description})]})},l.name))})]})]}),onConfirm:se},{title:t("team.inviting.link"),body:()=>e.jsxs("div",{children:[e.jsx(m,{sx:{fontSize:16,fontWeight:"bold"},children:t("team.member.inviteDialog.createSuccessTip",{expireDate:Ht("1760765405325",o)})}),e.jsx("div",{style:{marginTop:"40px"}}),e.jsx(Zt,{children:y}),k&&e.jsx(m,{sx:{mt:2},children:e.jsx(B,{variant:"body1",children:t("team.orgs.invite.inviteLinkSendToEmail",{email:H})})})]}),confirm:t("common.copy"),onConfirm:ve}][re];return e.jsx(ge,{title:K.title||t("common.invite"),open:u,onClose:Y,maxWidth:"sm",fullWidth:!0,showCloseButton:!0,actions:[e.jsx(J,{onClick:Y,disabled:x,children:t("common.cancel")},"cancel"),e.jsx(J,{loading:x,onClick:K.onConfirm,variant:"contained",disabled:S==="internal"&&!d.length||S==="external"&&!H.trim()||x,children:K.confirm||t("common.invite")},"invite")],sx:{".MuiDialogContent-root":{pt:0}},children:e.jsx(Be,{className:"dialog-content-body",component:"div",children:typeof K.body=="function"?K.body():K.body})})}function rt({layout:t="card",id:o=""}){const{t:a}=N(),{mutationParams:i,inviteParams:r,orgDetail:s,requests:u,passportParams:b}=_(),{invitations:g,org:y}=s||{},{showInvite:I,showInviting:d,onTriggerInvitingDialog:w}=r||{},T=()=>o?e.jsx(ke,{id:o}):t==="table"?e.jsx(dr,{}):e.jsx(mr,{}),f=j(()=>{u.getOrgInvitations(y.id)});return e.jsxs(m,{children:[T(),i.mode?e.jsx(tt,{mode:i.mode,item:i.org}):null,I?e.jsx(gr,{}):null,d?e.jsx(ge,{title:a("common.inviting"),onClose:()=>w({open:!1}),open:d,maxWidth:"lg",fullWidth:!0,children:e.jsx(er,{invitations:g,onRefresh:f})}):null,b.visible?e.jsx(cr,{}):null]})}rt.propTypes={layout:h.oneOf(["table","card"]),id:h.string};function nt({layout:t="card",mode:o="user-center",editable:a=!0,id:i=""}){return e.jsx(nr,{editable:a,mode:o,id:i,children:e.jsx(rt,{layout:t,id:i})})}nt.propTypes={layout:h.oneOf(["table","card"]),mode:h.oneOf(["dashboard","user-center"]),editable:h.bool,id:h.string};const Er=Object.freeze(Object.defineProperty({__proto__:null,default:nt},Symbol.toStringTag,{value:"Module"}));export{nt as O,De as T,Er as i};
@@ -1 +1 @@
1
- import{r as p}from"./vendor-react-CUXIiAnY.js";import{j as a,y as b,W as t,z as y,M as E,ak as I}from"./vendor-mui-core-B62p29u8.js";import{a as j}from"./vendor-hooks-BeI8hpF9.js";import{a1 as r}from"./index-xERuGIw0.js";import{V as A}from"./vendor-ux-k_TkMNDV.js";import{l as C}from"./arrow-down.svg-arX2hS9A.js";import{L as O,D as H}from"./vendor-mui-x-vSVDqxyB.js";import{A as R}from"./AdapterDayjs-B2uxdBcK.js";function v({value:s=null,onChange:i,error:l=!1,helperText:c="",label:h="",timezone:e="",minDateTime:f=null}){const d=j(()=>{let n=r();return s&&(n=e?r(s).tz(e):r(s)),n},[s,e]),m=n=>{const T=e?r(n).tz(e):r(n);i(new Date(T.format("YYYY-MM-DD HH:mm:00")))};return a.jsx(O,{dateAdapter:R,children:a.jsx(b,{fullWidth:!0,error:l,children:a.jsx(H,{label:h,minDateTime:f,value:d,onChange:m,slotProps:{textField:{error:l,helperText:l?c:""}},format:"YYYY-MM-DD HH:mm"})})})}v.propTypes={value:t.oneOfType([t.string,t.instanceOf(Date)]),onChange:t.func.isRequired,error:t.bool,helperText:t.string,label:t.string,timezone:t.string,minDateTime:t.instanceOf(Date)};function U(s){return a.jsx(C,{...s,width:20,height:20})}const u={MINUTES_30:30*60*1e3,HOUR_1:60*60*1e3,HOURS_3:3*60*60*1e3,DAY_1:24*60*60*1e3,DAYS_7:7*24*60*60*1e3,DAYS_30:30*24*60*60*1e3};function $({placeholder:s="",value:i="",onChange:l,timezone:c="",showError:h=!0}){const{t:e}=A(),[f,d]=p.useState(i||""),[m,n]=p.useState(null),[T,Y]=p.useState(null),x=p.useMemo(()=>[{value:u.MINUTES_30,label:`30 ${e("common.minutes")}`},{value:u.HOUR_1,label:`1 ${e("common.hour")}`},{value:u.HOURS_3,label:`3 ${e("common.hours")}`},{value:u.DAY_1,label:`1 ${e("common.day")}`},{value:u.DAYS_7,label:`7 ${e("common.days")}`},{value:u.DAYS_30,label:`30 ${e("common.days")}`},{value:"custom",label:e("common.custom")}],[e]),M=o=>{if(d(o),o==="custom"){const D=c?r().tz(c):r(),S=D.add(1,"day").toDate();Y(D),n(S),l(S)}else l(new Date(Date.now()+o))},_=o=>{n(o),l(o)};p.useEffect(()=>{i&&(x.find(D=>r(D.value).isSame(i))||(d("custom"),n(i)))},[]);const g=j(()=>h?!!(!m||r(m).isBefore(r())):!1,[m,e]);return a.jsxs(a.Fragment,{children:[a.jsx(b,{fullWidth:!0,children:a.jsx(y,{select:!0,value:f,label:s||e("team.passport.passportExpireTime"),onChange:o=>M(o.target.value),variant:"outlined",slotProps:{select:{IconComponent:U}},sx:{"& .MuiInputLabel-root":{width:"calc(100% - 46px)"}},children:x.map(o=>a.jsx(E,{value:o.value,children:o.label},o.value))})}),f==="custom"&&a.jsx(I,{children:a.jsx(v,{value:m,onChange:_,label:e("team.passport.customExpireTime"),timezone:c,error:!!g,helperText:g?e("team.passport.customExpireTimeIsInvalid"):void 0,minDateTime:T})})]})}$.propTypes={value:t.oneOfType([t.string,t.instanceOf(Date)]),onChange:t.func.isRequired,timezone:t.string,placeholder:t.string,showError:t.bool};export{$ as T};
1
+ import{r as p}from"./vendor-react-CUXIiAnY.js";import{j as a,y as b,W as t,z as y,M as E,ak as I}from"./vendor-mui-core-DHT36AZL.js";import{a as j}from"./vendor-hooks-fhL5FJET.js";import{a1 as r}from"./index-CN4lpn74.js";import{V as A}from"./vendor-ux-sqP3hEhY.js";import{l as C}from"./arrow-down.svg-C5rjQJG2.js";import{L as O,D as H}from"./vendor-mui-x-B4OOX5Es.js";import{A as R}from"./AdapterDayjs-OZNn2tpO.js";function v({value:s=null,onChange:i,error:l=!1,helperText:c="",label:h="",timezone:e="",minDateTime:f=null}){const d=j(()=>{let n=r();return s&&(n=e?r(s).tz(e):r(s)),n},[s,e]),m=n=>{const T=e?r(n).tz(e):r(n);i(new Date(T.format("YYYY-MM-DD HH:mm:00")))};return a.jsx(O,{dateAdapter:R,children:a.jsx(b,{fullWidth:!0,error:l,children:a.jsx(H,{label:h,minDateTime:f,value:d,onChange:m,slotProps:{textField:{error:l,helperText:l?c:""}},format:"YYYY-MM-DD HH:mm"})})})}v.propTypes={value:t.oneOfType([t.string,t.instanceOf(Date)]),onChange:t.func.isRequired,error:t.bool,helperText:t.string,label:t.string,timezone:t.string,minDateTime:t.instanceOf(Date)};function U(s){return a.jsx(C,{...s,width:20,height:20})}const u={MINUTES_30:30*60*1e3,HOUR_1:60*60*1e3,HOURS_3:3*60*60*1e3,DAY_1:24*60*60*1e3,DAYS_7:7*24*60*60*1e3,DAYS_30:30*24*60*60*1e3};function $({placeholder:s="",value:i="",onChange:l,timezone:c="",showError:h=!0}){const{t:e}=A(),[f,d]=p.useState(i||""),[m,n]=p.useState(null),[T,Y]=p.useState(null),x=p.useMemo(()=>[{value:u.MINUTES_30,label:`30 ${e("common.minutes")}`},{value:u.HOUR_1,label:`1 ${e("common.hour")}`},{value:u.HOURS_3,label:`3 ${e("common.hours")}`},{value:u.DAY_1,label:`1 ${e("common.day")}`},{value:u.DAYS_7,label:`7 ${e("common.days")}`},{value:u.DAYS_30,label:`30 ${e("common.days")}`},{value:"custom",label:e("common.custom")}],[e]),M=o=>{if(d(o),o==="custom"){const D=c?r().tz(c):r(),S=D.add(1,"day").toDate();Y(D),n(S),l(S)}else l(new Date(Date.now()+o))},_=o=>{n(o),l(o)};p.useEffect(()=>{i&&(x.find(D=>r(D.value).isSame(i))||(d("custom"),n(i)))},[]);const g=j(()=>h?!!(!m||r(m).isBefore(r())):!1,[m,e]);return a.jsxs(a.Fragment,{children:[a.jsx(b,{fullWidth:!0,children:a.jsx(y,{select:!0,value:f,label:s||e("team.passport.passportExpireTime"),onChange:o=>M(o.target.value),variant:"outlined",slotProps:{select:{IconComponent:U}},sx:{"& .MuiInputLabel-root":{width:"calc(100% - 46px)"}},children:x.map(o=>a.jsx(E,{value:o.value,children:o.label},o.value))})}),f==="custom"&&a.jsx(I,{children:a.jsx(v,{value:m,onChange:_,label:e("team.passport.customExpireTime"),timezone:c,error:!!g,helperText:g?e("team.passport.customExpireTimeIsInvalid"):void 0,minDateTime:T})})]})}$.propTypes={value:t.oneOfType([t.string,t.instanceOf(Date)]),onChange:t.func.isRequired,timezone:t.string,placeholder:t.string,showError:t.bool};export{$ as T};
@@ -0,0 +1,7 @@
1
+ import{V as L,H as q,U as N,k as Y,i as Se,h as Te,a2 as Ie}from"./vendor-ux-sqP3hEhY.js";import{q as Re,k as ae,t as We}from"./vendor-hooks-fhL5FJET.js";import{r as v,a as ce}from"./vendor-react-CUXIiAnY.js";import{D as ze,J as de,j as e,Y as De,bC as Oe,$ as $e,ak as d,z as ne,T as S,a6 as F,aX as te,R as Ae,Q as H,b6 as ie,am as P,bf as _,a5 as J,V as G,S as Z,b4 as Pe,U as B,I as M,cj as qe,bh as Be,a7 as Le,F as Me,W as o,b1 as W,a3 as pe,c2 as ee,ck as Fe,aO as He,aP as Ne,cl as Ue,cm as _e,cn as Ve,s as oe,aU as Ke,aj as Ye,co as Je,aZ as Qe,cc as Xe,bb as Ge,cb as Ze}from"./vendor-mui-core-DHT36AZL.js";import{_ as V,c as ue,a1 as et,ac as tt,b4 as Q,ar as xe,as as he,at as me}from"./index-CN4lpn74.js";import{u as K}from"./team-BnNEVFdE.js";import{u as ot}from"./use-mobile-DoKVMODs.js";import{u as st,C as X}from"./index.esm-DTmS4tth.js";import{C as ge,a as be,J as nt}from"./vendor-utils-BSZ4yJws.js";import{C as it}from"./confirm-DPD7yjeR.js";import{A as rt}from"./actions-CIp6hu8_.js";import{T as re}from"./table-tips-cVuoMOXE.js";import"./lottie-web-4koyQiv_.js";import"./vendor-arcblock-3xKfH3F1.js";import"./session-DNlfWI2Z.js";import"./isURL-DskT4RKm.js";import"./use-app-logo-BWOYOuhG.js";import"./index-DBs9Ljax.js";const lt=n=>{const[p,c]=v.useState(null),[f,r]=v.useState(!0),[w,u]=v.useState(null),j=window.blocklet?.appUrl,a=v.useMemo(()=>{const g={};return p&&(p.sources.forEach(y=>{g[y.did]={source:y,events:[],count:0}}),p.events.forEach(y=>{g[y.source]&&(g[y.source].events.push(y),g[y.source].count+=1)})),g},[p]),b=async()=>{try{if(r(!0),!j)return;const y=await(await fetch(ge(j,ue.WELLKNOWN_SERVICE_PATH_PREFIX,"/openevent.json"))).json();c(y),u(null)}catch(g){u(g instanceof Error?g:new Error(String(g)))}finally{r(!1)}};return v.useEffect(()=>{b()},[j]),{openEvent:p,setOpenEvent:c,eventsBySource:a,loading:f,error:w,loadData:b}};function fe({eventsBySource:n,selectedEvents:p,setSelectedEvents:c,error:f=null}){const{t:r}=L(),[w,u]=v.useState({}),j=v.useMemo(()=>{const s={};return Object.entries(n).forEach(([l,{events:m}])=>{const k=m.filter(T=>p[`${T.type}-${T.source}`]).length;s[l]=k}),s},[n,p]),a=v.useMemo(()=>Object.values(j).reduce((s,l)=>s+l,0),[j]),b=v.useMemo(()=>Object.values(n).reduce((s,{events:l})=>s+l.length,0),[n]),g=(s,l)=>{l.stopPropagation(),u({...w,[s]:!w[s]})},y=s=>{const l=`${s.type}-${s.source}`;c(m=>({...m,[l]:!m[l]}))},z=(s,l)=>{const m={};s.forEach(k=>{const T=`${k.type}-${k.source}`;m[T]=!l}),c(k=>({...k,...m}))},I=s=>{const l={};Object.values(n).forEach(({events:m})=>{m.forEach(k=>{const T=`${k.type}-${k.source}`;l[T]=s.target.checked})}),c(l)};return e.jsxs(d,{sx:{width:"100%"},children:[e.jsxs(d,{sx:{display:"flex",alignItems:"center",mb:1,mt:1},children:[e.jsx(ie,{control:e.jsx(J,{onChange:I,checked:a>0&&a===b}),label:e.jsxs(d,{sx:{display:"flex",alignItems:"center",cursor:"pointer"},children:[r("webhookEndpoint.selectAllEvents"),e.jsx(d,{sx:{display:"flex",alignItems:"center"},children:e.jsx(P,{title:r("webhookEndpoint.selectAllEventsTooltip"),placement:"right",children:e.jsx(_,{fontSize:"small",sx:{ml:.5,cursor:"help"}})})})]}),sx:{m:0}}),a>0&&e.jsx(S,{variant:"body2",color:"primary",sx:{ml:"auto"},children:r("webhookEndpoint.selectedEventsCount",{count:a})})]}),e.jsx(d,{className:"webhook-event-selector",sx:{maxHeight:"50vh",overflowY:"auto",overflowX:"hidden"},children:e.jsx(G,{disablePadding:!0,sx:{border:"1px solid",borderColor:"divider",borderRadius:.5},children:Object.entries(n).map(([s,{source:l,events:m,count:k}],T)=>{const O=j[s]>0,R=j[s]===m.length&&m.length>0,$=w[s];return e.jsxs(ce.Fragment,{children:[e.jsx(Z,{sx:{borderBottom:({palette:i})=>T<Object.keys(n).length-1?`1px solid ${i.divider}`:"none",px:0,py:1,"&:hover":{bgcolor:"rgba(0, 0, 0, 0.02)"}},children:e.jsxs(d,{sx:{display:"flex",width:"100%",justifyContent:"space-between",alignItems:"center"},onClick:i=>{i.target.closest(".MuiFormControlLabel-root")||g(s,i)},children:[e.jsx(d,{sx:{display:"flex",alignItems:"center"},children:m.length>0&&e.jsx(ie,{control:e.jsx(J,{checked:R,indeterminate:O&&!R,onChange:i=>{i.stopPropagation(),z(m,R)}}),label:e.jsxs(d,{sx:{display:"flex",alignItems:"center",gap:1},children:[l.logo&&e.jsx(Pe,{src:l.logo,sx:{width:24,height:24}}),e.jsx(d,{children:l.title||s}),O&&e.jsx(B,{label:r("webhookEndpoint.selectedCount",{count:j[s]}),size:"small",sx:{mt:"2px",height:"20px",fontSize:"12px",bgcolor:i=>`${i.palette.primary.main}20`,color:"primary.main",fontWeight:500}})]}),sx:{m:0,"& .MuiFormControlLabel-label":{flex:1}}})}),e.jsxs(d,{sx:{display:"flex",alignItems:"center"},children:[e.jsx(S,{variant:"body2",sx:{color:"text.secondary",mr:1},children:r("webhookEndpoint.eventsCount",{count:k})}),m.length>0&&e.jsx(M,{size:"small",edge:"end",children:$?e.jsx(qe,{}):e.jsx(Be,{})})]})]})}),m.length>0&&e.jsx(Le,{in:$,timeout:"auto",unmountOnExit:!0,children:e.jsx(G,{disablePadding:!0,sx:{p:0,bgcolor:"rgba(0, 0, 0, 0.01)"},children:m.map(i=>{const x=`${i.type}-${i.source}`,t=!!p[x];return e.jsx(Z,{dense:!0,sx:{py:.75,px:1},onClick:()=>y(i),children:e.jsxs(d,{sx:{display:"flex",alignItems:"flex-start",width:"100%"},children:[e.jsx(J,{checked:t,sx:{flexShrink:0}}),e.jsxs(d,{sx:{flex:1,minWidth:0},children:[e.jsx(S,{variant:"body1",className:"webhook-event-type",sx:{cursor:"pointer",color:"text.primary",wordBreak:"break-word",overflowWrap:"break-word"},children:i.type}),e.jsx(S,{variant:"caption",sx:{color:"text.secondary",display:"block",cursor:"pointer",wordBreak:"break-word",overflowWrap:"break-word"},children:i.description})]})]})},x)})})})]},s)})})}),f&&e.jsx(Me,{error:!0,sx:{mt:1},children:f})]})}fe.propTypes={eventsBySource:o.objectOf(o.shape({source:o.shape({did:o.string.isRequired,title:o.string,description:o.string,version:o.string,logo:o.string}).isRequired,events:o.arrayOf(o.shape({type:o.string.isRequired,description:o.string.isRequired,source:o.string.isRequired})).isRequired,count:o.number.isRequired})).isRequired,selectedEvents:o.objectOf(o.bool).isRequired,setSelectedEvents:o.func.isRequired,error:o.string};function je({id:n=null,url:p="",description:c="",enabledEvents:f=[],onSubmit:r,onClose:w=()=>{}}){const{t:u}=L(),[j,a]=v.useState({}),{teamDid:b}=K(),{api:g}=V(),{loading:y,error:z,eventsBySource:I}=lt(),s=ze(),{control:l,handleSubmit:m,formState:{errors:k},reset:T,setValue:O,trigger:R}=st({defaultValues:{url:"",description:""}}),$=de(s.breakpoints.down("md"));v.useEffect(()=>{const t=Object.values(j).some(h=>h);O("selectedEvents",t?"valid":""),R("selectedEvents")},[j,O,R]);const i=()=>{a({}),T(),w()},x=async t=>{const h=Object.keys(j).filter(C=>j[C]),E={url:t.url,description:t.description,enabledEvents:h.map(C=>{const[D,se]=C.split("-");return!D||!se?null:{type:D,source:se}}).filter(Boolean)};try{if(n){const C=await g.updateWebhookEndpoint({input:{teamDid:b,id:n,data:E}});q.success(`${u("webhookEndpoint.updateWebhook")} ${u("webhookEndpoint.success")}`),r(C)}else{const C=await g.createWebhookEndpoint({input:{teamDid:b,input:E}});q.success(`${u("webhookEndpoint.createWebhook")} ${u("webhookEndpoint.success")}`),r(C)}}catch(C){q.error(C?.message)}i()};return v.useEffect(()=>{T({url:p,description:c}),a(f.reduce((t,h)=>(t[`${h.type}-${h.source}`]=!0,t),{}))},[T,a,p,c,f]),e.jsx(De,{open:!0,onClose:i,maxWidth:"lg",fullWidth:!0,fullScreen:$,sx:{"& .MuiDialog-paper":{minHeight:600}},children:e.jsxs("form",{onSubmit:m(x),children:[e.jsx(Oe,{children:u(n?"webhookEndpoint.editWebhookTitle":"webhookEndpoint.createWebhookTitle")}),e.jsx($e,{children:e.jsxs(d,{sx:{display:"flex",flexDirection:"column",gap:2,mt:2},children:[e.jsx(X,{name:"url",control:l,rules:{required:u("webhookEndpoint.validation.urlRequired"),pattern:{value:/^(http|https):\/\/[^ "]+$/,message:u("webhookEndpoint.validation.urlInvalid")}},render:({field:t})=>e.jsx(ne,{...t,label:u("webhookEndpoint.url.label"),fullWidth:!0,error:!!k.url,helperText:k.url?.message})}),e.jsx(X,{name:"description",control:l,rules:{required:u("webhookEndpoint.validation.descriptionRequired")},render:({field:t})=>e.jsx(ne,{...t,label:u("webhookEndpoint.description.label"),fullWidth:!0,multiline:!0,minRows:2,maxRows:4,error:!!k.description,helperText:k.description?.message})}),e.jsx(X,{name:"selectedEvents",control:l,rules:{required:u("webhookEndpoint.validation.eventRequired")},render:({field:t})=>e.jsx("input",{type:"hidden",...t})}),!y&&I&&Object.keys(I).length>0&&e.jsx(fe,{eventsBySource:I,selectedEvents:j,setSelectedEvents:a,error:k.selectedEvents?.message}),!y&&(!I||Object.keys(I).length===0)&&e.jsx(S,{sx:{color:"text.secondary"},children:u("webhookEndpoint.noAvailableEvents")}),y&&e.jsx(d,{sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"500px",width:"100%"},children:e.jsx(F,{size:20})}),z&&e.jsx(te,{severity:"error",children:u("webhookEndpoint.loadingError",{message:z?.message})})]})}),e.jsxs(Ae,{sx:{p:"8px 24px 24px"},children:[e.jsx(H,{onClick:i,children:u("common.cancel")}),e.jsx(H,{type:"submit",variant:"contained",color:"primary",children:u(n?"webhookEndpoint.updateWebhook":"webhookEndpoint.saveWebhook")})]})]})})}je.propTypes={onSubmit:o.func.isRequired,id:o.string,url:o.string,description:o.string,enabledEvents:o.arrayOf(o.shape({type:o.string.isRequired,source:o.string.isRequired})),onClose:o.func};function ye(n){switch(n){case"enabled":return"success";case"disabled":default:return"default"}}const at=(n="en")=>n==="tw"?"zh":n;function U(n,p="YYYY-MM-DD HH:mm:ss",c="en"){return n?et(n).locale(at(c)).format(p):"-"}function ct(n){return typeof n=="number"?!1:be(n)}function dt(n){return n>=200&&n<300}function A({value:n,label:p,tip:c="",divider:f=!1}){const r=ct(n);return e.jsxs(e.Fragment,{children:[e.jsxs(W,{direction:"column",alignItems:"flex-start",children:[e.jsxs(S,{component:"div",variant:"body1",mb:1,color:"text.primary",sx:{fontWeight:500},children:[p,!!c&&e.jsx(P,{title:c,children:e.jsx(_,{fontSize:"small"})})]}),e.jsx(S,{component:"div",variant:"body1",color:r?"text.disabled":"text.secondary",sx:{width:"100%",minHeight:"24px"},children:r?"-":n})]}),f&&e.jsx(pe,{orientation:"vertical",flexItem:!0})]})}A.propTypes={label:o.oneOfType([o.string,o.node]).isRequired,value:o.oneOfType([o.string,o.node]).isRequired,tip:o.oneOfType([o.string,o.node]),divider:o.bool};function we({title:n,children:p=null,mb:c=1.5,mt:f=1.5}){return e.jsxs(W,{className:"section-header",direction:"row",sx:{justifyContent:"space-between",alignItems:"center",flexWrap:"wrap",gap:1,mb:c,mt:f,pb:1},children:[e.jsx(S,{variant:"h3",sx:{fontSize:{xs:"18px",md:"1.09375rem"}},component:"div",children:n}),p]})}we.propTypes={title:o.oneOfType([o.string,o.node]).isRequired,children:o.node,mb:o.number,mt:o.number};const pt={width:24,height:24,body:'<path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M20 11A8.1 8.1 0 0 0 4.5 9M4 5v4h4m-4 4a8.1 8.1 0 0 0 15.5 2m.5 4v-4h-4"/>'},ut=n=>{const p={};return n.forEach(c=>{const f=new Date(c.createdAt).toLocaleDateString();p[f]||(p[f]=[]),p[f]?.push(c)}),p};function ke({eventId:n="",webhookEndpointId:p="",event:c=null}){const{api:f,ws:{useSubscription:r}}=V(),{t:w}=L(),{teamDid:u}=K(),{blocklet:j}=tt(),{data:a,loadMore:b,loadingMore:g,loading:y,mutate:z}=Re(t=>{const E=t?Math.ceil(t.list.length/15)+1:1;return f.getWebhookAttempts({input:{teamDid:u,input:{eventId:n,webhookId:p},paging:{page:E,pageSize:15}}})},{reloadDeps:[n,p]}),I=a?.list||[],[s,l]=v.useState(null),[m,k]=v.useState(!1),T=ut(I);if(v.useEffect(()=>{!s&&a?.list.length&&l(a.list[0])},[a?.list.length,s]),r(ue.EVENTS.WEBHOOK_ATTEMPT,t=>{z(h=>{if(h.list.find(C=>C.id===t.id)){const C=h.list.map(D=>D.id===t.id?{...D,...t}:D);return{...h,list:C}}return t.endpoint=h.list[0]?.endpoint,t.event=h.list[0]?.event,{...h,list:[t,...h.list]}})},[]),y)return e.jsx(F,{});const O=a&&a.list.length<a.paging.total,R=async()=>{s&&(k(!0),await f.retryWebhookAttempt({input:{teamDid:u,eventId:s.event.id,webhookId:p,attemptId:s.id}}).finally(()=>{setTimeout(()=>{k(!1)},1e3)}))},$=t=>{if(t.responseBody&&t.responseBody?.sessionId&&t.responseBody?.projectId&&t.responseBody?.agentId){const h=j?.site?.domainAliases[0]?.value,E=(j.children||[]).find(D=>D?.meta?.name==="ai-studio"),C=nt(ge(`https://${h}`,E?.mountPoint||"","projects",t.responseBody.projectId,"logs/main"),{sessionId:t.responseBody.sessionId,agentId:t.responseBody.agentId});return e.jsx(M,{sx:{fontSize:20},onClick:()=>window.open(C,"_blank"),children:e.jsx(d,{component:N,icon:Q})})}return null},i=t=>t.status==="pending"?e.jsx(Ue,{color:"warning"}):dt(t.responseStatus)?e.jsx(_e,{color:"success"}):e.jsx(Ve,{color:"error"}),x=s?.triggeredFrom&&(a?.list||[]).find(t=>t.id===s.triggeredFrom);return e.jsxs(xt,{container:!0,spacing:{xs:0,md:1},sx:{height:1},children:[e.jsx(ee,{size:{xs:12,md:4},sx:{height:1},children:be(Object.keys(T))?e.jsx(S,{sx:{color:"text.secondary"},children:w("webhookEndpoint.waitingForEvents")}):e.jsxs(e.Fragment,{children:[e.jsx(G,{sx:{maxHeight:"calc(100% - 40px)",py:0,overflowY:"auto"},children:Object.entries(T).map(([t,h])=>e.jsxs(ce.Fragment,{children:[e.jsx(Fe,{sx:{p:0},children:t}),h.map(E=>e.jsxs(Z,{sx:{cursor:"pointer",px:1},onClick:()=>l(E),selected:s&&s?.id===E?.id,secondaryAction:e.jsx(S,{sx:{color:"text.secondary"},children:U(E.createdAt,"HH:mm:ss")}),children:[e.jsx(He,{sx:{minWidth:0,mr:1.5},children:i(E)}),e.jsx(Ne,{primary:e.jsx(S,{sx:{color:"text.primary"},children:E.event.type})})]},E.id))]},t))}),O&&e.jsx(d,{sx:{display:"flex",justifyContent:"center",alignItems:"center",width:1},children:e.jsx(H,{variant:"text",type:"button",color:"inherit",onClick:b,disabled:g,sx:{color:t=>t.palette.text.disabled},children:w(g?"webhookEndpoint.loadingMore":"webhookEndpoint.loadMore")})})]})}),e.jsxs(ee,{size:{xs:12,md:8},sx:{height:1},children:[s&&e.jsxs(W,{direction:"column",spacing:2,sx:{height:1,overflow:"auto",pl:{xs:0,md:1},mt:{xs:2,md:0},borderLeft:{xs:"none"}},children:[e.jsxs(d,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs(d,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(S,{variant:"h4",children:w(`common.${s.status}`)}),e.jsx(d,{children:$(s)})]}),e.jsxs(d,{sx:{display:"flex",alignItems:"center",gap:1},children:[x&&e.jsx(P,{placement:"left",title:e.jsxs(W,{onClick:()=>l(x),sx:{gap:1,cursor:"pointer",".did-address-text":{color:"common.white"}},children:[e.jsx(xe,{showDid:!0,did:s.triggeredBy,cardType:me.Detailed,infoType:he.Minimal,sx:{border:0,padding:0,minWidth:0,".MuiTypography-root":{color:"common.white",fontWeight:400}}}),e.jsx(pe,{}),e.jsxs(d,{sx:{display:"flex",flexDirection:"column"},children:[e.jsx(S,{variant:"body2",sx:{color:"primary.main"},children:w("webhookEndpoint.triggeredFrom")}),e.jsxs(d,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(S,{variant:"body2",children:s.id}),e.jsx(M,{onClick:()=>l(x),children:e.jsx(d,{component:N,icon:Q,sx:{fontSize:16,color:"common.white"}})})]})]})]}),slotProps:{tooltip:{sx:{maxWidth:400}}},children:e.jsx(M,{onClick:()=>l(x),children:e.jsx(d,{component:N,icon:Q,sx:{fontSize:16}})})}),e.jsxs(H,{variant:"outlined",color:"primary",size:"small",onClick:R,disabled:m,children:[e.jsx(d,{component:N,icon:pt,sx:{fontSize:16,animation:m?"spin 1s linear infinite":"none",mr:.5}}),w("notification.resend")]})]})]}),e.jsxs(d,{children:[e.jsxs(S,{variant:"h6",children:[w("webhookEndpoint.response")," (",s.responseStatus,")"]}),e.jsx(Y,{language:"json",children:JSON.stringify(s.responseBody,null,2)})]}),e.jsxs(d,{children:[e.jsx(W,{direction:"row",spacing:1,sx:{alignItems:"center"},children:e.jsx(S,{variant:"h6",children:w("webhookEndpoint.request")})}),e.jsx(Y,{language:"json",sx:{margin:0},children:JSON.stringify(s.event,null,2)})]})]}),a?.list.length===0&&c&&e.jsxs(d,{children:[e.jsx(W,{direction:"row",spacing:1,sx:{alignItems:"center"},children:e.jsx(S,{variant:"h6",children:w("webhookEndpoint.eventData")})}),e.jsx(Y,{language:"json",sx:{margin:0},children:JSON.stringify(c.data,null,2)})]})]})]})}ke.propTypes={eventId:o.string,webhookEndpointId:o.string,event:o.shape({type:o.string,data:o.object,request:o.object,requestInfo:o.object})};const xt=oe(ee)`
2
+ @keyframes spin {
3
+ to {
4
+ transform: rotate(360deg);
5
+ }
6
+ }
7
+ `;function Ee({id:n,onClose:p}){const{t:c}=L(),{api:f}=V(),{teamDid:r}=K(),{loading:w,error:u,data:j}=ae(()=>f.getWebhookEndpoint({input:{teamDid:r,id:n}})),a=j?.data;return u?e.jsx(te,{severity:"error",children:u.message}):w||!a?e.jsx(d,{sx:{display:"flex",justifyContent:"center",alignItems:"center",height:1,width:1},children:e.jsx(F,{})}):e.jsxs(ht,{direction:"column",sx:{height:{xs:"auto",md:1}},children:[e.jsxs(d,{children:[e.jsxs(W,{direction:"row",sx:{justifyContent:"space-between",alignItems:"center"},children:[e.jsx(W,{sx:{flex:1,width:0},children:e.jsxs(d,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(S,{variant:"h5",sx:{fontWeight:600,overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis"},children:a.description}),e.jsx(P,{title:a.url,children:e.jsx(_,{sx:{fontSize:"16px",marginTop:"2px"}})})]})}),e.jsx(W,{direction:"row",sx:{alignItems:"center"},children:e.jsx(M,{edge:"end",color:"inherit",onClick:p,children:e.jsx(Ye,{})})})]}),e.jsx(d,{sx:{mt:2},children:e.jsxs(W,{className:"section-body",direction:{xs:"column",md:"row"},spacing:{xs:1,md:3},sx:{justifyContent:"flex-start",flexWrap:"wrap",pt:2,mt:2,borderTop:"1px solid #eee"},children:[e.jsx(A,{label:c("common.status"),value:e.jsx(B,{size:"small",variant:"filled",label:a.status,color:ye(a.status),sx:{borderRadius:"4px",lineHeight:"20px",textTransform:"capitalize"}}),divider:!0}),e.jsx(A,{label:c("webhookEndpoint.listen"),value:e.jsx(P,{arrow:!0,title:e.jsx("ul",{style:{padding:0,margin:0},children:a.enabledEvents.map(b=>e.jsx("li",{style:{fontSize:"0.7875rem"},children:b?.type},b))}),children:e.jsx(B,{size:"small",variant:"filled",label:c("webhookEndpoint.eventsCount",{count:a.enabledEvents.length}),sx:{borderRadius:"4px",lineHeight:"20px",textTransform:"capitalize"}})}),divider:!0}),e.jsx(A,{label:c("webhookEndpoint.version"),value:a.apiVersion,divider:!0}),e.jsx(A,{label:c("common.createdAt"),value:U(a.createdAt),divider:!0}),e.jsx(A,{label:c("common.updatedAt"),value:U(a.updatedAt),divider:!0}),e.jsx(A,{label:c("common.createdBy"),value:e.jsx(P,{arrow:!0,title:a.createUser?.did,children:e.jsx(B,{size:"small",variant:"filled",label:a.createUser?.fullName,sx:{borderRadius:"4px",lineHeight:"20px",textTransform:"capitalize"}})}),divider:!0}),e.jsx(A,{label:c("common.updatedBy"),value:e.jsx(P,{arrow:!0,title:a.updateUser?.did,children:e.jsx(B,{size:"small",variant:"filled",label:a.updateUser?.fullName,sx:{borderRadius:"4px",lineHeight:"20px",textTransform:"capitalize"}})})})]})})]}),e.jsxs(W,{className:"section",sx:{flex:1,height:0,overflow:"hidden"},children:[e.jsx(we,{title:c("webhookEndpoint.attempts"),mb:0,mt:4}),e.jsx(W,{sx:{height:0,flex:1,overflow:"hidden"},children:e.jsx(ke,{webhookEndpointId:a.id})})]})]})}Ee.propTypes={id:o.string.isRequired,onClose:o.func.isRequired};const ht=oe(W)``;function ve({open:n,onClose:p,id:c}){return e.jsx(Ke,{anchor:"right",open:n,onClose:p,slotProps:{paper:{sx:{width:"90vw",maxWidth:"1200px"}}},children:e.jsx(d,{sx:{height:"100vh",p:3},children:e.jsx(Ee,{id:c,onClose:p})})})}ve.propTypes={open:o.bool.isRequired,onClose:o.func.isRequired,id:o.string.isRequired};function le(){return null}function Ce({options:n={},columns:p=[],toolbar:c=!0,footer:f=!0,hasRowLink:r=!1,emptyNodeText:w="",durable:u="",durableKeys:j=[],data:a=[],loading:b=!1,...g}){const{locale:y}=L(),z=de(l=>l.breakpoints.down("md")),I={print:!1,download:!1,filter:!1,selectableRows:"none",rowsPerPage:z?5:10,rowsPerPageOptions:[5,10,20,50,100],searchDebounceTime:300,tableBodyHeight:"100%",loading:!0},s={};return c||(s.TableToolbar=le),f||(s.TableFooter=le),e.jsx(mt,{locale:y,options:{...I,...n},columns:(p||[]).map(l=>(l.options=l.options||{},l.options.filter=l.options.filter||!1,l.options.sort=l.options.sort||!1,l)),emptyNode:e.jsx(Se,{children:w}),...g,durable:u,durableKeys:j,data:a,loading:b,components:s,hasRowLink:r,isMobile:z})}Ce.propTypes={options:o.object,columns:o.array,toolbar:o.bool,footer:o.bool,hasRowLink:o.bool,emptyNodeText:o.node,durable:o.string,durableKeys:o.array,data:o.array,loading:o.bool,onChange:o.func,title:o.node,components:o.object};const mt=oe(Te)``,gt=v.memo(Ce);function At(){const{teamDid:n}=K(),p=ot(),c=`webhook-endpoints-${n}`,f=Ie(c),{t:r,locale:w}=L(),{api:u}=V(),[j,a]=v.useState(""),[b,g]=v.useState({webhookDetail:{open:!1,id:null},createEdit:{open:!1,id:null,url:"",description:"",enabledEvents:[]},deleteConfirm:null}),[y,z]=We(c,{defaultValue:{pageSize:f.rowsPerPage||20,page:f.page?f.page+1:1}}),{loading:I,error:s,data:l,refresh:m}=ae(()=>u.getWebhookEndpoints({input:{teamDid:n,paging:{page:y.page,pageSize:y.pageSize}}}));v.useEffect(()=>{m()},[y,m]);const k=v.useCallback(async(i,x)=>{try{await u.updateWebhookEndpoint({input:{teamDid:n,id:i.id,data:{status:x?"disabled":"enabled"}}}),m(),q.success(`${r(x?"webhookEndpoint.disable":"webhookEndpoint.enable")}${r("webhookEndpoint.success")}`)}catch(t){q.error(t?.message)}},[u,n,m,r]),T=v.useCallback(async i=>{try{await u.deleteWebhookEndpoint({input:{teamDid:n,id:i}}),m(),g(x=>({...x,deleteConfirm:null})),q.success(`${r("common.delete")}${r("webhookEndpoint.success")}`)}catch(x){q.error(x?.message)}},[u,n,m,r]),O=(i,x)=>{let t=i.page+1;const h=i.searchText||"";if(h!==j){a(h);return}if(x==="changePage"||x==="changeRowsPerPage"){x!=="changePage"&&(t=1);const E={page:t,pageSize:i.rowsPerPage};a(""),z(E)}};if(s)return e.jsx(te,{severity:"error",children:s.message});if(I||!l)return e.jsx(d,{sx:{display:"flex",justifyContent:"center",alignItems:"center",width:1,height:500},children:e.jsx(F,{})});const R=(l?.list||[]).filter(i=>{if(!j)return!0;const x=j.toLowerCase();return i.description.toLowerCase().includes(x)||i.url.toLowerCase().includes(x)}),$=[{label:"URL",name:"url",options:{customBodyRenderLite:(i,x)=>{const t=R[x];return e.jsxs(d,{sx:{display:"flex",alignItems:"center",cursor:"pointer",gap:.5},children:[e.jsx(S,{variant:"body2",children:t.description}),e.jsx(d,{sx:{display:"flex"},onClick:h=>{h.stopPropagation()},children:e.jsx(P,{title:t.url,children:e.jsx(_,{sx:{fontSize:"15px",marginTop:"1px"}})})})]})}}},{label:"Events",name:"events",options:{customBodyRenderLite:(i,x)=>{const t=R[x];return e.jsx(d,{sx:{display:"flex",alignItems:"center",gap:1,flexWrap:"wrap"},children:t.enabledEvents.map(h=>e.jsx(B,{size:"small",variant:"filled",label:h.type,sx:{borderRadius:"4px",textTransform:"capitalize"}},`${t.source}-${h.type}`))})}}},{label:r("common.status"),name:"status",options:{customBodyRenderLite:(i,x)=>{const t=R[x];return e.jsx(B,{size:"small",variant:"filled",label:r(`webhookEndpoint.${t?.status}`),color:ye(t?.status),sx:{borderRadius:"4px",textTransform:"capitalize"}},`status-${t.status}`)}}},{label:r("common.createdAt"),name:"createdAt",minWidth:200,options:{customBodyRender:i=>U(i)}},{label:r("common.createdBy"),name:"createUser",width:100,options:{customBodyRender:i=>i?e.jsx(xe,{showDid:!0,did:i?.did,cardType:me.Detailed,infoType:he.Minimal,sx:{border:0,padding:0}}):"-"}},{label:r("common.actions"),name:"actions",width:100,align:"center",verticalKeyAlign:"center",options:{customBodyRenderLite:(i,x)=>{const t=R[x],h=t?.status==="enabled";return e.jsx(rt,{actions:[{icon:h?e.jsx(Je,{}):e.jsx(Qe,{}),text:r(h?"webhookEndpoint.disable":"webhookEndpoint.enable"),onClick:E=>{E.stopPropagation(),k(t,h)}},{icon:e.jsx(Xe,{}),text:r("common.edit"),onClick:E=>{E.stopPropagation(),g(C=>({...C,createEdit:{open:!0,id:t.id,url:t.url,description:t.description,enabledEvents:t.enabledEvents}}))}},{icon:e.jsx(Ge,{}),text:r("common.delete"),onClick:E=>{E.stopPropagation(),g(C=>({...C,deleteConfirm:{title:r("webhookEndpoint.deleteWebhook.title"),description:r("webhookEndpoint.deleteWebhook.description"),confirm:r("common.confirm"),cancel:r("common.cancel"),onConfirm:()=>T(t.id),onCancel:()=>g(D=>({...D,deleteConfirm:null}))}}))}}]})}}}];return e.jsxs(d,{sx:{".custom-toobar-btns":{gap:"8px"},".custom-toobar-title .custom-toobar-title-inner>span":{display:"flex",alignItems:"center","white-space":"inherit",height:"100%"}},children:[p?e.jsx(re,{title:r("webhookEndpoint.listTitle"),tooltipTitle:r("webhookEndpoint.tooltipTitle"),link:`https://www.arcblock.io/docs/blocklet-developer/${w}/webhook`}):null,e.jsx(gt,{durable:c,durableKeys:["page","rowsPerPage"],data:R,columns:$,options:{count:l.count,page:y.page-1,rowsPerPage:y.pageSize,viewColumns:!1,onRowClick:(i,{dataIndex:x})=>{const t=l.list[x];g(h=>({...h,webhookDetail:{open:!0,id:t.id}}))}},loading:I,onChange:O,emptyNodeText:e.jsx(W,{sx:{gap:1},children:r("webhookEndpoint.noWebhooksAdded")}),title:p?null:e.jsx(re,{title:r("webhookEndpoint.listTitle"),tooltipTitle:r("webhookEndpoint.tooltipTitle"),link:`https://www.arcblock.io/docs/blocklet-developer/${w}/webhook`}),customButtons:[e.jsxs(H,{sx:{color:"common.white"},edge:"end",variant:"contained",color:"primary",onClick:()=>g(i=>({...i,createEdit:{...i.createEdit,open:!0}})),className:"rule-action",children:[I?e.jsx(F,{size:16}):e.jsx(Ze,{style:{fontSize:16}}),r("common.create")]},"add")]}),b.webhookDetail.open&&e.jsx(ve,{open:!0,onClose:()=>g(i=>({...i,webhookDetail:{open:!1,id:null}})),id:b.webhookDetail.id}),b.createEdit.open&&e.jsx(je,{onSubmit:m,...b.createEdit,onClose:()=>g(i=>({...i,createEdit:{id:null,url:"",description:"",enabledEvents:[],open:!1}}))}),b.deleteConfirm&&e.jsx(it,{title:b.deleteConfirm.title,description:b.deleteConfirm.description,confirm:b.deleteConfirm.confirm,cancel:b.deleteConfirm.cancel,params:b.deleteConfirm.params,onConfirm:b.deleteConfirm.onConfirm,onCancel:b.deleteConfirm.onCancel})]})}export{At as default};
@@ -0,0 +1 @@
1
+ import{_ as r}from"./vendor-ux-sqP3hEhY.js";import{V as _,W as e}from"./index-CN4lpn74.js";const m={en:_(e),ar:()=>r(()=>import("./ar-BJZY7v5z.js"),[],import.meta.url).then(t=>_(t.default)),de:()=>r(()=>import("./de-BF0NHTXz.js"),[],import.meta.url).then(t=>_(t.default)),es:()=>r(()=>import("./es-Dv2m4LXp.js"),[],import.meta.url).then(t=>_(t.default)),fr:()=>r(()=>import("./fr-BGhg9oO3.js"),[],import.meta.url).then(t=>_(t.default)),hi:()=>r(()=>import("./hi-CPfDhW8g.js"),[],import.meta.url).then(t=>_(t.default)),id:()=>r(()=>import("./id-9TUzKF6k.js"),[],import.meta.url).then(t=>_(t.default)),ja:()=>r(()=>import("./ja-DT5bRsBF.js"),[],import.meta.url).then(t=>_(t.default)),ko:()=>r(()=>import("./ko-CJn9PyPz.js"),[],import.meta.url).then(t=>_(t.default)),pt:()=>r(()=>import("./pt-K9FK6Ube.js"),[],import.meta.url).then(t=>_(t.default)),ru:()=>r(()=>import("./ru-C_RwukUu.js"),[],import.meta.url).then(t=>_(t.default)),th:()=>r(()=>import("./th-Bhii_FfA.js"),[],import.meta.url).then(t=>_(t.default)),vi:()=>r(()=>import("./vi-DVF2tjOG.js"),[],import.meta.url).then(t=>_(t.default)),"zh-TW":()=>r(()=>import("./zh-tw-BdDE7n5E.js"),[],import.meta.url).then(t=>_(t.default)),zh:()=>r(()=>import("./zh-98nxdLeR.js"),[],import.meta.url).then(t=>_(t.default))};export{m as t};