@abtnode/blocklet-services 1.17.1 → 1.17.2-beta-20251110-023854-e91dad6f

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 (180) hide show
  1. package/api/routes/oauth/client.js +19 -3
  2. package/dist/assets/{AdapterDayjs-DS6RugP1.js → AdapterDayjs-Cf3ilEXQ.js} +1 -1
  3. package/dist/assets/{Google-DL2G-Im-.js → Google-CAi86Mf6.js} +1 -1
  4. package/dist/assets/{access-control-BcP45PDK.js → access-control-CtmOVtqN.js} +1 -1
  5. package/dist/assets/{add-component-core-CDw-LKTz.js → add-component-core-BmqcC6wx.js} +1 -1
  6. package/dist/assets/add-resource-Wd8eygtg.js +1 -0
  7. package/dist/assets/{addon-BNvN2vhl.js → addon-b88MM48E.js} +1 -1
  8. package/dist/assets/{advanced-C0Q1MXTZ.js → advanced-B3-RuDYH.js} +1 -1
  9. package/dist/assets/aigne-dOgJ2u-w.js +10 -0
  10. package/dist/assets/api-Btn0Tp3W.js +1 -0
  11. package/dist/assets/{appearance-Du24FS2u.js → appearance-BqBKdeI5.js} +1 -1
  12. package/dist/assets/{arrow-down.svg-BNc6qym0.js → arrow-down.svg-DeLZPBrE.js} +1 -1
  13. package/dist/assets/{audit-logs-CC69qHzz.js → audit-logs-DtLr59sc.js} +1 -1
  14. package/dist/assets/{authorize-R4UDUnLr.js → authorize-DwHmsRbR.js} +1 -1
  15. package/dist/assets/{base-chart-CPiuDOeg.js → base-chart-C-Raz4Q-.js} +1 -1
  16. package/dist/assets/{base32-DvFJDTUa.js → base32-MTP_2iYY.js} +1 -1
  17. package/dist/assets/{bind-account-BHDDyJhv.js → bind-account-kNuk8_sP.js} +1 -1
  18. package/dist/assets/branding-B5SFGC6H.js +1 -0
  19. package/dist/assets/{branding-JJOTrGtN.js → branding-BDl2jvZZ.js} +1 -1
  20. package/dist/assets/{branding-DtWd56Gj.js → branding-ZWV6HBf3.js} +1 -1
  21. package/dist/assets/{bundle-avatar-DKBZZwLh.js → bundle-avatar-CTtvmGO1.js} +1 -1
  22. package/dist/assets/{button-Cg6OrnF6.js → button-vwR-NYG5.js} +1 -1
  23. package/dist/assets/{click-to-copy-8VrSVycN.js → click-to-copy-BOJgIYli.js} +1 -1
  24. package/dist/assets/{cloneDeep-D_w1MBt4.js → cloneDeep-C6qewg0C.js} +1 -1
  25. package/dist/assets/{complete-DPUMGf1q.js → complete-Bkaq2hgz.js} +2 -2
  26. package/dist/assets/{component-BHy3j7aa.js → component-C45V1KlM.js} +2 -2
  27. package/dist/assets/{config-BaVMK6fr.js → config-BLLq9bPE.js} +1 -1
  28. package/dist/assets/config-Ceq_JEL5.js +53 -0
  29. package/dist/assets/{config-9XjBKwBj.js → config-gkybDvOM.js} +1 -1
  30. package/dist/assets/{config-navigation-CFyO-icX.js → config-navigation-D1-Loy5H.js} +2 -2
  31. package/dist/assets/{config-space-u-t0AaTk.js → config-space-zpk7zMxf.js} +1 -1
  32. package/dist/assets/{confirm-BCjJ3Xga.js → confirm-CR8be0u2.js} +1 -1
  33. package/dist/assets/{connect-DlGrdygd.js → connect-BXpb2qd7.js} +1 -1
  34. package/dist/assets/{connect-B6Xh5geZ.js → connect-DOJrWNED.js} +1 -1
  35. package/dist/assets/{connect-to-DcXC96wu.js → connect-to-CmnRyCBb.js} +1 -1
  36. package/dist/assets/{create-passport-svg-BYZ8eY0w.js → create-passport-svg-C7Utfs-J.js} +1 -1
  37. package/dist/assets/{createClass-BQSl7_FJ.js → createClass-C0dSRoDm.js} +1 -1
  38. package/dist/assets/{dashboard-CQ72RYH1.js → dashboard-Dw224r_Y.js} +2 -2
  39. package/dist/assets/{delete-confirm-D2vWlDhQ.js → delete-confirm-DhJd_sYk.js} +1 -1
  40. package/dist/assets/{did-address-BxZuOgUQ.js → did-address-QgOhyegQ.js} +1 -1
  41. package/dist/assets/{domain-DrZ8Lgz4.js → domain-Cp9UTLSk.js} +1 -1
  42. package/dist/assets/{domain-action-card-CjprVCsh.js → domain-action-card-ClQw061p.js} +2 -2
  43. package/dist/assets/domains-Bqr-LIHe.js +1 -0
  44. package/dist/assets/{email-BLnwK6WC.js → email-CyuoT9tq.js} +1 -1
  45. package/dist/assets/engine-DPn0LHHl.js +1 -0
  46. package/dist/assets/{exchange-passport-CNwWQumn.js → exchange-passport-BpZ027R8.js} +1 -1
  47. package/dist/assets/{form-BmYfNrVX.js → form-5lUoL51-.js} +1 -1
  48. package/dist/assets/{form-text-input-BZq_zjB8.js → form-text-input-Ce6g965V.js} +1 -1
  49. package/dist/assets/{fuel-UmS8I6V5.js → fuel-SLYYbiDW.js} +1 -1
  50. package/dist/assets/{gen-access-key-BG0P5o2E.js → gen-access-key-CXXIb3w7.js} +1 -1
  51. package/dist/assets/gen-simple-access-key-BHzLGV5y.js +1 -0
  52. package/dist/assets/get-safe-url-DpalOXcM.js +1 -0
  53. package/dist/assets/{home-DDCrDH3h.js → home-DIAEkSVB.js} +1 -1
  54. package/dist/assets/{iframe-UTQ_4DZf.js → iframe-BUJLmqjE.js} +1 -1
  55. package/dist/assets/index-40i6YjCX.js +6 -0
  56. package/dist/assets/{index-bAaF7GbQ.js → index-5h5rz7VN.js} +1 -1
  57. package/dist/assets/index-7L77Yf9w.js +120 -0
  58. package/dist/assets/{index-CFpcdpS5.js → index-BQF4zMs8.js} +3 -3
  59. package/dist/assets/{index-BCuYGA8L.js → index-BiE-bsm3.js} +1 -1
  60. package/dist/assets/{index-BCF14HSR.js → index-BiRWeiPY.js} +1 -1
  61. package/dist/assets/{index-Db6d_BmF.js → index-Bjj89nDJ.js} +1 -1
  62. package/dist/assets/{index-CYIpEo41.js → index-Bpiwm7Vd.js} +1 -1
  63. package/dist/assets/{index-DoyPDWTY.js → index-C-ToEbCG.js} +1 -1
  64. package/dist/assets/{index-CRlbskWD.js → index-C45ih46D.js} +11 -11
  65. package/dist/assets/{index-BydChKjR.js → index-COTazo1u.js} +2 -2
  66. package/dist/assets/{index-H8Dc7uuB.js → index-CkOr9jjZ.js} +1 -1
  67. package/dist/assets/{index-Ct7hdtD6.js → index-CsfqJ8ys.js} +1 -1
  68. package/dist/assets/{index-COj40KfT.js → index-CxfTwIi4.js} +1 -1
  69. package/dist/assets/{index-C2c32kYu.js → index-DBJMdrD8.js} +1 -1
  70. package/dist/assets/index-DZRxerxf.js +7 -0
  71. package/dist/assets/{index-Kwxwmog8.js → index-DZsn1cNa.js} +3 -3
  72. package/dist/assets/{index-CrRuO2BQ.js → index-DicW-7Bz.js} +1 -1
  73. package/dist/assets/{index-D-Y0UA7w.js → index-DoMhm8T2.js} +1 -1
  74. package/dist/assets/{index-CfVxzco9.js → index-DzmaBRJ8.js} +1 -1
  75. package/dist/assets/{index-DrTSvHzP.js → index-F1NFyTyg.js} +7 -7
  76. package/dist/assets/index-FV6qYjQd.js +62 -0
  77. package/dist/assets/{index-D2k5qLgT.js → index-FpxO_1p7.js} +1 -1
  78. package/dist/assets/{index-I8DDinX-.js → index-GExzZtCU.js} +1 -1
  79. package/dist/assets/{index-C_bSN26w.js → index-I2xk2ilS.js} +2 -2
  80. package/dist/assets/{index-BM4g9p9K.js → index-NomqB6Iy.js} +1 -1
  81. package/dist/assets/{index-ChcIPY6P.js → index-UR2bgVDi.js} +2 -2
  82. package/dist/assets/{index-CKPpLyCQ.js → index-gt5P4O5b.js} +1 -1
  83. package/dist/assets/{index-Ch4CmFJG.js → index-l32Mt1U_.js} +1 -1
  84. package/dist/assets/{index-CkTEzTCn.js → index-sNHCLgAE.js} +140 -142
  85. package/dist/assets/{index-BjsH7wg6.js → index-x4Yvq15-.js} +1 -1
  86. package/dist/assets/{invitation-PFI3mpiQ.js → invitation-Bu3ivg7N.js} +1 -1
  87. package/dist/assets/{invitations-DBukPMcf.js → invitations-o-DfaNhe.js} +1 -1
  88. package/dist/assets/{invite-Z_7oCnoB.js → invite-C_VhlmyZ.js} +1 -1
  89. package/dist/assets/{isURL-CyShrkvP.js → isURL-D_2bLHU_.js} +2 -2
  90. package/dist/assets/{issue-passport-BexF9o0Q.js → issue-passport-BQmXTz6k.js} +1 -1
  91. package/dist/assets/{item-CBDRQx8K.js → item-BnTXSpRf.js} +1 -1
  92. package/dist/assets/{landing-page-BBuNoMf2.js → landing-page-sUHYSREd.js} +1 -1
  93. package/dist/assets/{layout-DsLcTLhU.js → layout-Ccrs-yyw.js} +1 -1
  94. package/dist/assets/list-Bzvh-74X.js +2 -0
  95. package/dist/assets/list-DORIbGy_.js +103 -0
  96. package/dist/assets/localization-DDhbgRgn.js +1 -0
  97. package/dist/assets/{log-CQbIkXws.js → log-C34JsgaL.js} +1 -1
  98. package/dist/assets/logger-CLmQ42wa.js +1 -0
  99. package/dist/assets/{login-CvnRp8HX.js → login-DHfG4EkA.js} +1 -1
  100. package/dist/assets/{login-oauth-callback-LnLYjVIe.js → login-oauth-callback-B7KlB_uu.js} +1 -1
  101. package/dist/assets/{logo-uploader-DRaSgU8c.js → logo-uploader-D-JPEx8I.js} +1 -1
  102. package/dist/assets/{lost-passport-B5NjzFZd.js → lost-passport-BLFCoJdG.js} +1 -1
  103. package/dist/assets/{omit-CigYLGmT.js → omit-hhiOJGRf.js} +1 -1
  104. package/dist/assets/{open-window-B_B0pir6.js → open-window-Bcj__Y7L.js} +1 -1
  105. package/dist/assets/{over-due-invoice-payment-mGIRggXd.js → over-due-invoice-payment-DUg5ApsD.js} +1 -1
  106. package/dist/assets/{overview-DmcFvtLD.js → overview-B-nkIeNy.js} +2 -2
  107. package/dist/assets/passport-Y64u4kIS.js +1 -0
  108. package/dist/assets/passport-item-DvglsId-.js +1 -0
  109. package/dist/assets/{permission-COoKrWxk.js → permission-DhYNRf8T.js} +1 -1
  110. package/dist/assets/{preferences-CDP-HNka.js → preferences-C4h4Dsj9.js} +1 -1
  111. package/dist/assets/profile-embed-lrJQLQky.js +1 -0
  112. package/dist/assets/{publish-resource-BMF29YI2.js → publish-resource-YXu5vhjp.js} +1 -1
  113. package/dist/assets/{react-beautiful-dnd.esm-4ukAiqxb.js → react-beautiful-dnd.esm-Ci2FESra.js} +1 -1
  114. package/dist/assets/runtime-DK0VmoOa.js +1 -0
  115. package/dist/assets/{sanitize-Bib7lw-G.js → sanitize-BEqBHa8a.js} +1 -1
  116. package/dist/assets/sdk-DFkL0HsT.js +1 -0
  117. package/dist/assets/{security-BcRPxWAt.js → security-DrqBVw07.js} +3 -3
  118. package/dist/assets/{session-GdZETrt0.js → session-BAD0lxQk.js} +1 -1
  119. package/dist/assets/{setup-MQVteZIu.js → setup-Br2wkFI2.js} +1 -1
  120. package/dist/assets/{simple-select-K2bKpwDf.js → simple-select-CzvjrR9I.js} +1 -1
  121. package/dist/assets/{spaces-iPLS3X1a.js → spaces-B0p4-23K.js} +1 -1
  122. package/dist/assets/{start-DE38ex9f.js → start-CXoSJa5Y.js} +1 -1
  123. package/dist/assets/{starting-progress-BQjEEvIV.js → starting-progress-NSYAzE2f.js} +1 -1
  124. package/dist/assets/{status-B0TeD-D-.js → status-guZHdt1q.js} +1 -1
  125. package/dist/assets/{step-actions-DPFoKvBN.js → step-actions-thgNsMmu.js} +1 -1
  126. package/dist/assets/{studio-CEsaMQhd.js → studio-Ceq7d-nC.js} +1 -1
  127. package/dist/assets/{switch-control-BHqY-fHZ.js → switch-control-CHsjrwFX.js} +1 -1
  128. package/dist/assets/{table-tips-6mCQ469z.js → table-tips-cwfDerzR.js} +1 -1
  129. package/dist/assets/{team-aiCyLcOV.js → team-DQuySqMB.js} +1 -1
  130. package/dist/assets/{traffic-CPElxbIH.js → traffic-QKQkjau1.js} +1 -1
  131. package/dist/assets/{transfer-DvfbExaq.js → transfer-B2DeADo4.js} +1 -1
  132. package/dist/assets/{unsubscribe-BfZzYk0c.js → unsubscribe-CBCoBRAZ.js} +1 -1
  133. package/dist/assets/{use-app-logo-Duu7Oh3J.js → use-app-logo-BQTE7YvS.js} +1 -1
  134. package/dist/assets/{use-window-close-CmeMvKPG.js → use-window-close-BgT_dImc.js} +1 -1
  135. package/dist/assets/{useAsync-DouUkRB3.js → useAsync-BcVLpt2E.js} +1 -1
  136. package/dist/assets/{useAsync-BvASW8Y8.js → useAsync-cZ_FPf9k.js} +1 -1
  137. package/dist/assets/{useAsyncRetry-C8ETjgdm.js → useAsyncRetry-DwwEjrjs.js} +1 -1
  138. package/dist/assets/{useLocalStorage-DZQPax49.js → useLocalStorage-C9RLNbTa.js} +1 -1
  139. package/dist/assets/{user-center-BVnh5pB3.js → user-center-Cj7ClpAN.js} +2 -2
  140. package/dist/assets/user-follower-D2fRTkiD.js +32 -0
  141. package/dist/assets/{util-Cx4i9QNN.js → util-BEWQY3Rq.js} +1 -1
  142. package/dist/assets/{util-D4K1svNc.js → util-BsAmOTBh.js} +1 -1
  143. package/dist/assets/{vendor-arcblock-A4RQuZfN.js → vendor-arcblock-CuFtPveO.js} +1 -1
  144. package/dist/assets/{vendor-hooks-OpgB8gyY.js → vendor-hooks-CjESGRlR.js} +1 -1
  145. package/dist/assets/vendor-utils-cJEl_UEd.js +213 -0
  146. package/dist/assets/{vendor-ux-RIH1nUSh.js → vendor-ux-IiQnod3w.js} +7 -7
  147. package/dist/assets/{wait-connect-KtqPocoC.js → wait-connect-DiO80nu-.js} +1 -1
  148. package/dist/assets/{wizard-C9022r7q.js → wizard-Br7PYJDY.js} +1 -1
  149. package/dist/assets/{wizard-components-DboyJGog.js → wizard-components-BJpLH2_r.js} +1 -1
  150. package/dist/assets/wrap-locale-fIPwg8LW.js +1 -0
  151. package/dist/assets/{zh-BQQVY0SI.js → zh-EIKQ0AV8.js} +1 -1
  152. package/dist/index.html +1 -1
  153. package/dist/service-worker.js +1 -1
  154. package/package.json +48 -48
  155. package/dist/assets/add-resource-CcTb_2qn.js +0 -1
  156. package/dist/assets/aigne-CIAkCLWQ.js +0 -10
  157. package/dist/assets/api-BNrHV6cZ.js +0 -1
  158. package/dist/assets/branding-z2zNNpPB.js +0 -1
  159. package/dist/assets/config-zjFvoy0D.js +0 -57
  160. package/dist/assets/domains-Pt7MqfcA.js +0 -1
  161. package/dist/assets/engine-BkRDnUT9.js +0 -1
  162. package/dist/assets/gen-simple-access-key-BD4DDZLa.js +0 -1
  163. package/dist/assets/get-safe-url-Cgcqi5oF.js +0 -1
  164. package/dist/assets/index-C0w3lI6i.js +0 -120
  165. package/dist/assets/index-CpPbuWHL.js +0 -7
  166. package/dist/assets/index-CuFT_Y96.js +0 -6
  167. package/dist/assets/index-DBjdZ7k_.js +0 -63
  168. package/dist/assets/index-OYI_VqY3.js +0 -1
  169. package/dist/assets/list-BDeeBLEM.js +0 -103
  170. package/dist/assets/list-BZRp_F7-.js +0 -2
  171. package/dist/assets/localization-Dp6_R66r.js +0 -1
  172. package/dist/assets/logger-BI25CDXT.js +0 -1
  173. package/dist/assets/passport-CScachCU.js +0 -1
  174. package/dist/assets/passport-item-BefzYs0z.js +0 -1
  175. package/dist/assets/profile-embed-CfTauOJU.js +0 -1
  176. package/dist/assets/runtime-CC2luaxU.js +0 -1
  177. package/dist/assets/sdk-CkMqUWSI.js +0 -1
  178. package/dist/assets/user-follower-z3gqroPM.js +0 -32
  179. package/dist/assets/vendor-utils-ByKYcWuf.js +0 -213
  180. package/dist/assets/wrap-locale-Dkx98Pk6.js +0 -1
@@ -0,0 +1,6 @@
1
+ import{j as e,ak as m,b4 as st,W as h,ar as L,cx as ot,a$ as it,T as N,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,cy 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,cz as yt,cA as jt,s as Ct,J as wt,c1 as Ot,z as me,bD as Ne,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-CnXrAOs3.js";import{V as B,H as O,h as Be,z as Se,U as Re,i as _e,p as Rt,a2 as Et,b as ge,n as Ee}from"./vendor-ux-IiQnod3w.js";import{r as C,i as qe,k as At}from"./vendor-react-Dvs43sk9.js";import{g as G,b as j,k as Ue,a as Wt,v as Lt,q as Nt,c as Bt}from"./vendor-hooks-CjESGRlR.js";import{ar as ie,at as ae,c as Pe,_ as He,az as _t,as as ue,Y as qt,b5 as Ut,o as Ht}from"./index-sNHCLgAE.js";import{u as Fe}from"./team-DQuySqMB.js";import{u as $e}from"./use-mobile-maRlSUwU.js";import{A as Ft}from"./actions-DqoNrBDK.js";import{u as Je}from"./session-BAD0lxQk.js";import{f as E}from"./index-DBs9Ljax.js";import{v as Ce}from"./index-l32Mt1U_.js";import{e as Ve,A as $t,n as te}from"./vendor-utils-cJEl_UEd.js";import{F as Ae}from"./form-text-input-Ce6g965V.js";import{e as Jt}from"./edit.svg-DycWG9v3.js";import{C as Vt}from"./lock.svg-COUP8tyO.js";import{D as Kt,a as Gt,b as Xt,M as Qt}from"./index-GExzZtCU.js";import{c as Yt}from"./passport-Y64u4kIS.js";import{C as Zt}from"./click-to-copy-BOJgIYli.js";import{I as er}from"./invitations-o-DfaNhe.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}=B();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(N,{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(N,{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(N,{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(N,{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}=B(),{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}=B(),{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(N,{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(N,{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(Be,{className:"org-members-table",data:s,columns:d,loading:u,onChange:I,locale:o,options:w})})}function or(){const{t}=B(),{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}=B(),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(N,{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}=B(),{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}=B(),[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(Be,{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}=B(),{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(N,{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(N,{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}=B(),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}=B(),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(N,{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}=B(),{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}=B(),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(N,{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(N,{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(Ne,{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}=B(),{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}=Nt(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}Bt(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(N,{variant:"subtitle1",children:l.title||l.name}),e.jsx(N,{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(N,{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(Ne,{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}=B(),{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,4 +1,4 @@
1
- import{r as u}from"./vendor-react-Dvs43sk9.js";import{W as o,j as e,ak as j,aN as L,z as A,at as K,bn as B,I as P,a6 as W,bF as M,aj as X,bG as G}from"./vendor-mui-core-CnXrAOs3.js";import{C as H}from"./Google-DL2G-Im-.js";import{p as U}from"./vendor-ux-RIH1nUSh.js";import{c as Y}from"./create-passport-svg-BYZ8eY0w.js";import{A as $}from"./vendor-arcblock-A4RQuZfN.js";import{e as J}from"./index-CkTEzTCn.js";import{R as Q}from"./required-BGaDOGrj.js";import{F as Z}from"./form-wrapper-C8oo_Fdy.js";import{L as v}from"./logo-uploader-DRaSgU8c.js";import{A as ee,a as ne,b as te}from"./collapse-BMy0GGFk.js";const S={description:o.string,editing:o.bool,onChange:o.func,required:o.bool,value:o.any,componentProps:o.object,render:o.func,renderFormItem:o.func};function T({editing:n,value:s,onChange:l}){const[i,c]=u.useState(!1),m=u.useRef(),f=u.useRef(s);u.useEffect(()=>{let a=null;return n&&(a=setTimeout(()=>{c(!0)},50)),()=>{clearTimeout(a)}},[n]);const h=a=>{f.current=a,l(a)},b=()=>{c(!1),l(f.current)},y=e.jsx(j,{className:"form-item-input slot",sx:{px:1},children:e.jsxs(j,{sx:{display:"flex",alignItems:"center"},children:[s,s!=="auto"&&e.jsx("div",{style:{marginLeft:4,backgroundColor:s,width:"1em",height:"1em",borderRadius:"0.2em"}})]})}),p=e.jsxs(j,{onKeyDown:b,sx:{display:"flex",flexGrow:1,alignItems:"center",height:"40px"},children:[e.jsx(j,{onClick:()=>c(!0),sx:{display:"flex",alignItems:"center"},children:e.jsx("div",{ref:m,style:{flexShrink:0,marginLeft:"8px",backgroundColor:s,width:"32px",height:"32px",boxSizing:"border-box",borderRadius:"8px",border:"1px solid #eee",cursor:s==="auto"?"default":"pointer"}})}),e.jsx(L,{open:i,anchorEl:m.current,onClose:()=>c(!1),anchorOrigin:{vertical:"bottom",horizontal:"center"},transformOrigin:{vertical:"top",horizontal:"center"},children:e.jsx(H,{color:s,onChange:a=>h(a.hex)})})]});return n?p:y}T.propTypes=S;function D({editing:n,description:s,value:l,onChange:i,componentProps:c={},...m}){const{placeholder:f}=c,h=u.useRef(l),{t:b}=u.useContext(U),y=a=>{a.key==="Enter"&&i(h.current,"confirm")},p=a=>{h.current=a,i(a)};return n?e.jsx(A,{style:{flex:1},fullWidth:!0,value:l,onChange:a=>{a.persist(),p(a.target.value)},autoFocus:!0,size:"small",variant:"outlined",placeholder:s||f,onKeyDown:y,...m}):e.jsx(j,{className:"form-item-input slot",sx:{px:1},children:l||e.jsx("span",{className:"placeholder",children:b("common.requiredInputPlaceholder",{name:s||f})})})}D.propTypes=S;function O({editing:n,value:s,onChange:l,componentProps:i,...c}){const{blocklet:m}=i,f=s==="auto"?$(m.appDid):s;return e.jsxs(j,{sx:{display:"flex",alignItems:"center"},children:[e.jsx("div",{style:{width:96,marginRight:12},dangerouslySetInnerHTML:{__html:Y({title:"Owner",issuer:J.getDisplayName(m),issuerDid:m.appDid,ownerName:"Your Name",ownerDid:m.appDid,preferredColor:s||"auto"})}}),e.jsx(T,{...c,editing:n,value:n?f:s,onChange:l,componentProps:i})]})}O.propTypes={...S,componentProps:o.shape({blocklet:o.object.isRequired}).isRequired};const re=G`
1
+ import{r as u}from"./vendor-react-Dvs43sk9.js";import{W as o,j as e,ak as j,aN as L,z as A,at as K,bn as B,I as P,a6 as W,bF as M,aj as X,bG as G}from"./vendor-mui-core-CnXrAOs3.js";import{C as H}from"./Google-CAi86Mf6.js";import{p as U}from"./vendor-ux-IiQnod3w.js";import{c as Y}from"./create-passport-svg-C7Utfs-J.js";import{A as $}from"./vendor-arcblock-CuFtPveO.js";import{e as J}from"./index-sNHCLgAE.js";import{R as Q}from"./required-BGaDOGrj.js";import{F as Z}from"./form-wrapper-C8oo_Fdy.js";import{L as v}from"./logo-uploader-D-JPEx8I.js";import{A as ee,a as ne,b as te}from"./collapse-BMy0GGFk.js";const S={description:o.string,editing:o.bool,onChange:o.func,required:o.bool,value:o.any,componentProps:o.object,render:o.func,renderFormItem:o.func};function T({editing:n,value:s,onChange:l}){const[i,c]=u.useState(!1),m=u.useRef(),f=u.useRef(s);u.useEffect(()=>{let a=null;return n&&(a=setTimeout(()=>{c(!0)},50)),()=>{clearTimeout(a)}},[n]);const h=a=>{f.current=a,l(a)},b=()=>{c(!1),l(f.current)},y=e.jsx(j,{className:"form-item-input slot",sx:{px:1},children:e.jsxs(j,{sx:{display:"flex",alignItems:"center"},children:[s,s!=="auto"&&e.jsx("div",{style:{marginLeft:4,backgroundColor:s,width:"1em",height:"1em",borderRadius:"0.2em"}})]})}),p=e.jsxs(j,{onKeyDown:b,sx:{display:"flex",flexGrow:1,alignItems:"center",height:"40px"},children:[e.jsx(j,{onClick:()=>c(!0),sx:{display:"flex",alignItems:"center"},children:e.jsx("div",{ref:m,style:{flexShrink:0,marginLeft:"8px",backgroundColor:s,width:"32px",height:"32px",boxSizing:"border-box",borderRadius:"8px",border:"1px solid #eee",cursor:s==="auto"?"default":"pointer"}})}),e.jsx(L,{open:i,anchorEl:m.current,onClose:()=>c(!1),anchorOrigin:{vertical:"bottom",horizontal:"center"},transformOrigin:{vertical:"top",horizontal:"center"},children:e.jsx(H,{color:s,onChange:a=>h(a.hex)})})]});return n?p:y}T.propTypes=S;function D({editing:n,description:s,value:l,onChange:i,componentProps:c={},...m}){const{placeholder:f}=c,h=u.useRef(l),{t:b}=u.useContext(U),y=a=>{a.key==="Enter"&&i(h.current,"confirm")},p=a=>{h.current=a,i(a)};return n?e.jsx(A,{style:{flex:1},fullWidth:!0,value:l,onChange:a=>{a.persist(),p(a.target.value)},autoFocus:!0,size:"small",variant:"outlined",placeholder:s||f,onKeyDown:y,...m}):e.jsx(j,{className:"form-item-input slot",sx:{px:1},children:l||e.jsx("span",{className:"placeholder",children:b("common.requiredInputPlaceholder",{name:s||f})})})}D.propTypes=S;function O({editing:n,value:s,onChange:l,componentProps:i,...c}){const{blocklet:m}=i,f=s==="auto"?$(m.appDid):s;return e.jsxs(j,{sx:{display:"flex",alignItems:"center"},children:[e.jsx("div",{style:{width:96,marginRight:12},dangerouslySetInnerHTML:{__html:Y({title:"Owner",issuer:J.getDisplayName(m),issuerDid:m.appDid,ownerName:"Your Name",ownerDid:m.appDid,preferredColor:s||"auto"})}}),e.jsx(T,{...c,editing:n,value:n?f:s,onChange:l,componentProps:i})]})}O.propTypes={...S,componentProps:o.shape({blocklet:o.object.isRequired}).isRequired};const re=G`
2
2
  0%, 100% {
3
3
  transform: scale(1) translateX(0);
4
4
  }
@@ -0,0 +1,120 @@
1
+ import{g as Bt,r as v}from"./vendor-react-Dvs43sk9.js";import{j as e,ak as S,z as X,b6 as me,bg as Ke,y as V,am as ut,d7 as Wt,bn as Kt,at as ie,b1 as mt,W as p,T as ee,U as Je,d8 as pt,b5 as qe,a5 as Me,Q as Pe,d9 as Ge,aN as Ue,a6 as ft,D as ht,da as qt,ad as xt,db as Mt,dc as Ut,c2 as st,n as Ht,J as $t,x as Vt,bc as Jt,M as it,cw as Gt,I as Yt,dd as Qt}from"./vendor-mui-core-CnXrAOs3.js";import{A as gt,J as Xt,C as Zt,e as oe,F as en,a3 as je}from"./vendor-utils-cJEl_UEd.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-IiQnod3w.js";import{aJ as on,_ as Ye,ac as Ct,az as wt,K as _e,c as B,a1 as Z,o as ln,aR as at}from"./index-sNHCLgAE.js";import{g as ye,b as $,a as se}from"./vendor-hooks-CjESGRlR.js";import{u as Rt,C as Y}from"./index.esm-JPZAjt0x.js";import{i as He}from"./isURL-D_2bLHU_.js";import{S as Q}from"./section-C75bzkkL.js";import{A as cn,a as dn,b as un}from"./collapse-BMy0GGFk.js";import{S as Se}from"./shorten-label-RqvHqcC3.js";import{v as Tt}from"./index-l32Mt1U_.js";import{R as Nt,A as mn,S as pn,a as fn,B as hn}from"./list-DORIbGy_.js";import{j as xn,c as gn,N as bn}from"./team-DQuySqMB.js";import{W as jn}from"./did-address-QgOhyegQ.js";import{p as It}from"./util-BEWQY3Rq.js";import{D as vn,g as yn}from"./traffic-QKQkjau1.js";import{B as Et}from"./bundle-avatar-CTtvmGO1.js";import{u as Sn}from"./use-mobile-maRlSUwU.js";import"./lottie-web-4koyQiv_.js";import"./vendor-arcblock-CuFtPveO.js";import"./required-BGaDOGrj.js";import"./server-logo-notext.svg-CKQB0tIp.js";import"./session-BAD0lxQk.js";import"./use-app-logo-BQTE7YvS.js";import"./base32-MTP_2iYY.js";import"./useAsyncRetry-DwwEjrjs.js";import"./useAsync-cZ_FPf9k.js";import"./iframe-BUJLmqjE.js";import"./index-DBJMdrD8.js";import"./index-DBs9Ljax.js";import"./base-chart-C-Raz4Q-.js";import"./index-NomqB6Iy.js";import"./vendor-mui-x-bJ5idfMH.js";import"./AdapterDayjs-Cf3ilEXQ.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};