@abtnode/blocklet-services 1.17.4-beta-20251204-080001-08643fbe → 1.17.4-beta-20251205-104405-28838df1

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 (198) hide show
  1. package/api/middlewares/verify-sig.js +29 -10
  2. package/dist/assets/{AdapterDayjs-BuAhqT20.js → AdapterDayjs-DEl3BogQ.js} +1 -1
  3. package/dist/assets/{Google-Dp7qGnxg.js → Google-FE-PKKgg.js} +1 -1
  4. package/dist/assets/{access-control-D1ovo6-o.js → access-control-DOpkbifA.js} +1 -1
  5. package/dist/assets/{add-component-core-BIhDwpuV.js → add-component-core-wpc1J2BH.js} +1 -1
  6. package/dist/assets/{add-resource-C4TkG7UD.js → add-resource-CslAO771.js} +1 -1
  7. package/dist/assets/{addon-DAMRKj2r.js → addon-DdNYGDp4.js} +1 -1
  8. package/dist/assets/{advanced-BPAoOjLm.js → advanced-QWXBTgpB.js} +1 -1
  9. package/dist/assets/{aigne-B6ByRL09.js → aigne-DoudzB_0.js} +1 -1
  10. package/dist/assets/api-uGeIZn4a.js +1 -0
  11. package/dist/assets/{appearance-EkIyryBQ.js → appearance-C--T1yEy.js} +1 -1
  12. package/dist/assets/ar-Cwm1-0yA.js +7 -0
  13. package/dist/assets/{arrow-down.svg-Cn1jfZom.js → arrow-down.svg-BE-0knfW.js} +1 -1
  14. package/dist/assets/{audit-logs-C9C7P-Sv.js → audit-logs-CBGJi3D2.js} +1 -1
  15. package/dist/assets/{authorize-DrmC8YuR.js → authorize-QdLwmrZR.js} +1 -1
  16. package/dist/assets/{base-chart-DJyGks5q.js → base-chart-CcNdwghd.js} +1 -1
  17. package/dist/assets/{base32-CnxuWLTI.js → base32-eAS52qli.js} +1 -1
  18. package/dist/assets/{bind-account-BBEcbwvl.js → bind-account-D5vP44eh.js} +1 -1
  19. package/dist/assets/{branding-BznRcuN9.js → branding-B0sUWGQz.js} +1 -1
  20. package/dist/assets/branding-De5qPtGR.js +1 -0
  21. package/dist/assets/{branding-ChfGbwwx.js → branding-_1kxBl_k.js} +1 -1
  22. package/dist/assets/{bundle-avatar-DGFHJNB_.js → bundle-avatar-32N3x3xU.js} +1 -1
  23. package/dist/assets/{button-pTTwNqRf.js → button-DqhIB3De.js} +1 -1
  24. package/dist/assets/{click-to-copy-CAd3nEo4.js → click-to-copy-BuSTGPjJ.js} +1 -1
  25. package/dist/assets/{cloneDeep-B7kH4W7U.js → cloneDeep-DHlHhGOY.js} +1 -1
  26. package/dist/assets/{complete-DGRt8hbz.js → complete-Dow8rsOd.js} +1 -1
  27. package/dist/assets/{component-7HXhlkqA.js → component-BAz0O6p3.js} +57 -57
  28. package/dist/assets/{config-jsIGlbhn.js → config-CpjVTk_0.js} +1 -1
  29. package/dist/assets/{config-hYngbDX9.js → config-CzKzlfrL.js} +5 -5
  30. package/dist/assets/{config-De0LSoek.js → config-S1ErpcbM.js} +1 -1
  31. package/dist/assets/{config-navigation-Dnu_lIYd.js → config-navigation-CDLoKHDM.js} +3 -3
  32. package/dist/assets/{config-space-Cjm8zHqm.js → config-space-BywO8K6k.js} +1 -1
  33. package/dist/assets/{confirm-g44rz8hw.js → confirm-CsXep4ZX.js} +1 -1
  34. package/dist/assets/{connect-DiOZmi5p.js → connect-BVziqmk-.js} +1 -1
  35. package/dist/assets/{connect-CdDqD7_5.js → connect-Dg3BjAlC.js} +1 -1
  36. package/dist/assets/{connect-to-Bi5k3ZXU.js → connect-to-DvsUYNJv.js} +1 -1
  37. package/dist/assets/{create-passport-svg-BLBQxsEK.js → create-passport-svg-CIUyZVGt.js} +1 -1
  38. package/dist/assets/{createClass-mqcDPFI4.js → createClass-C4n9PQtV.js} +1 -1
  39. package/dist/assets/dashboard-CL6mI9qw.js +106 -0
  40. package/dist/assets/de-XQM4sDLo.js +7 -0
  41. package/dist/assets/{delete-confirm-Cw0wPOzJ.js → delete-confirm-BSzvSp8_.js} +1 -1
  42. package/dist/assets/{did-address-BOsJWqi1.js → did-address-j4poFq12.js} +1 -1
  43. package/dist/assets/{domain-BpCcezRq.js → domain-CNIwNykZ.js} +1 -1
  44. package/dist/assets/{domain-action-card-FG12ETj5.js → domain-action-card-BWxruxm4.js} +1 -1
  45. package/dist/assets/domains-CYSnteZ-.js +1 -0
  46. package/dist/assets/{email-DmAbJJ8K.js → email-BUE0xhg8.js} +1 -1
  47. package/dist/assets/engine-D_YTKCbf.js +1 -0
  48. package/dist/assets/es-D4zFwVhj.js +9 -0
  49. package/dist/assets/{exchange-passport-C3TLdHrh.js → exchange-passport-B_YUy8xg.js} +1 -1
  50. package/dist/assets/{form-BGvxztTN.js → form-C3lQx0_f.js} +1 -1
  51. package/dist/assets/{form-text-input-BFJU5Psq.js → form-text-input-Sp9mVO8Z.js} +1 -1
  52. package/dist/assets/fr-BQXlmrTL.js +7 -0
  53. package/dist/assets/{fuel-BHnBcNst.js → fuel-8vtXn14o.js} +1 -1
  54. package/dist/assets/{gen-access-key-DMekoh9G.js → gen-access-key-Cv0mVir2.js} +1 -1
  55. package/dist/assets/{gen-simple-access-key-CKo8-San.js → gen-simple-access-key-CG7rkGCK.js} +1 -1
  56. package/dist/assets/get-safe-url-DB8WYPm8.js +1 -0
  57. package/dist/assets/hi-Cdz2GskJ.js +5 -0
  58. package/dist/assets/{home-Disgh1zw.js → home-Da9sD5LZ.js} +1 -1
  59. package/dist/assets/id-Q9i8FdSt.js +7 -0
  60. package/dist/assets/{iframe-DWt09ONv.js → iframe-BOu2WQ8Y.js} +1 -1
  61. package/dist/assets/{index-Cbz9zwoD.js → index-9EeZkpuz.js} +1 -1
  62. package/dist/assets/index-B3lpnLC0.js +1 -0
  63. package/dist/assets/{index-C3cD5fjJ.js → index-B7Hwfql4.js} +1 -1
  64. package/dist/assets/{index-B87ktLq-.js → index-BHyRI_gV.js} +1 -1
  65. package/dist/assets/{index-BnfJXuxc.js → index-BO-5QIwf.js} +1 -1
  66. package/dist/assets/{index-CG-mH6e1.js → index-BmFAdUmE.js} +2 -2
  67. package/dist/assets/{index-DA2Pny4B.js → index-BnOhhAn2.js} +1 -1
  68. package/dist/assets/{index-CwAM1jrM.js → index-BpulWIIa.js} +1 -1
  69. package/dist/assets/{index-DxaRhCwJ.js → index-ByefI9hC.js} +1 -1
  70. package/dist/assets/{index-DxQFjZlw.js → index-BzDzFVcf.js} +2 -2
  71. package/dist/assets/{index-CPDkpfNV.js → index-C5-jy29d.js} +1 -1
  72. package/dist/assets/{index-D5tCTUjA.js → index-CC4kGiqP.js} +1 -1
  73. package/dist/assets/{index-CSfyeeXh.js → index-CEbTLr_A.js} +1 -1
  74. package/dist/assets/{index-BIJNkmLb.js → index-CJ1z6qNA.js} +1 -1
  75. package/dist/assets/{index-Dgb4cDcB.js → index-CJongjoV.js} +1 -1
  76. package/dist/assets/{index-C_W4n3wb.js → index-CVclk1-n.js} +1 -1
  77. package/dist/assets/{index-Duu9lR4r.js → index-CY8CdteZ.js} +1 -1
  78. package/dist/assets/{index-Cke5eCl6.js → index-Cmd4UiOo.js} +1 -1
  79. package/dist/assets/{index-fJzIwqxQ.js → index-CzTPIbVu.js} +1 -1
  80. package/dist/assets/{index--6oAMl0L.js → index-DFfEr4If.js} +1 -1
  81. package/dist/assets/{index-bb9HF7R1.js → index-DQCqwXpW.js} +1 -1
  82. package/dist/assets/{index-Hh69Xj8u.js → index-DSbS9vii.js} +2 -2
  83. package/dist/assets/{index-CJ1a35hD.js → index-DdXkI8FK.js} +1 -1
  84. package/dist/assets/{index-CYxU-iOV.js → index-DiNmJxr2.js} +1 -1
  85. package/dist/assets/{index-gy2ZIEt_.js → index-DkaI7B4e.js} +1 -1
  86. package/dist/assets/{index-EH5vv2Ba.js → index-d0ayyNAl.js} +3 -3
  87. package/dist/assets/{index-Cx5JU0Ln.js → index-jPmRCtiq.js} +7 -7
  88. package/dist/assets/{index-BC_wNmTA.js → index-o-_irE6S.js} +1 -1
  89. package/dist/assets/{index-7uZYu-Ep.js → index-y-XalrLG.js} +1 -1
  90. package/dist/assets/{index-Ca4Ccmqm.js → index-ySP_m_Ux.js} +1 -1
  91. package/dist/assets/{index-k8gDRcJR.js → index-z0V_qaSH.js} +1 -1
  92. package/dist/assets/{invitation-C9uUexLK.js → invitation-Dr0R_Zm3.js} +1 -1
  93. package/dist/assets/{invitations-sELORD_h.js → invitations-DgB-ff90.js} +1 -1
  94. package/dist/assets/{invite-CXR3ZLRS.js → invite-DM8gXHE_.js} +1 -1
  95. package/dist/assets/{isURL-CohjRVvR.js → isURL-CTWDUgGm.js} +1 -1
  96. package/dist/assets/{issue-passport-q8H-mSA2.js → issue-passport-5xsfQh4x.js} +1 -1
  97. package/dist/assets/{item-BIqA21iq.js → item-B7J3-doM.js} +1 -1
  98. package/dist/assets/ja-CH8WZngC.js +9 -0
  99. package/dist/assets/ko-Nli9PwTV.js +9 -0
  100. package/dist/assets/{landing-page-DgPDUi6Y.js → landing-page-D5rNUC4m.js} +1 -1
  101. package/dist/assets/{layout-Cr6KApqq.js → layout-Dqc1Rw-q.js} +1 -1
  102. package/dist/assets/{list-DaqruRvJ.js → list-Dm7-Jiww.js} +1 -1
  103. package/dist/assets/{list-DZKko9y8.js → list-uwVz32FG.js} +1 -1
  104. package/dist/assets/localization-ByyQzA4g.js +1 -0
  105. package/dist/assets/{log-DwPeERno.js → log-DmRGsyT9.js} +17 -17
  106. package/dist/assets/logger-Du6zTrGC.js +1 -0
  107. package/dist/assets/{login-Fd_qnrRk.js → login-DVxbUkmV.js} +1 -1
  108. package/dist/assets/{login-oauth-callback-BWKfq40w.js → login-oauth-callback-D3NWzIdd.js} +1 -1
  109. package/dist/assets/{logo-uploader-_reea4L6.js → logo-uploader-Bs_7E0-m.js} +1 -1
  110. package/dist/assets/{lost-passport-DmkXn2Nz.js → lost-passport-DR_9dtm9.js} +1 -1
  111. package/dist/assets/{omit-W13eVnqC.js → omit-CpvduH4b.js} +1 -1
  112. package/dist/assets/{open-window-DCReXykr.js → open-window-n4P49X8a.js} +1 -1
  113. package/dist/assets/{over-due-invoice-payment-Bsp5V3AP.js → over-due-invoice-payment-C-ZuUAsL.js} +1 -1
  114. package/dist/assets/{overview-CXMCgIAo.js → overview-Tdx-8ilS.js} +3 -3
  115. package/dist/assets/passport-DnUeoVIR.js +1 -0
  116. package/dist/assets/{passport-item-CEM3FQ2i.js → passport-item-DAeIvzgs.js} +1 -1
  117. package/dist/assets/{permission-G7gi0qR2.js → permission-iIDMQlq_.js} +1 -1
  118. package/dist/assets/{preferences-DalbRqbk.js → preferences-RXCdhC2X.js} +1 -1
  119. package/dist/assets/profile-embed-xkS3CrGD.js +1 -0
  120. package/dist/assets/pt-eVksFEJb.js +5 -0
  121. package/dist/assets/{publish-resource-BqB_XJ-d.js → publish-resource-CcexZ4v9.js} +1 -1
  122. package/dist/assets/{react-beautiful-dnd.esm-Clor-N66.js → react-beautiful-dnd.esm-DFHKVO-K.js} +1 -1
  123. package/dist/assets/ru-ycnIgUGb.js +5 -0
  124. package/dist/assets/runtime-DeZdhum6.js +1 -0
  125. package/dist/assets/{sanitize-Bm63FeNh.js → sanitize-CdfxCSD9.js} +1 -1
  126. package/dist/assets/sdk-DxKHN0C9.js +1 -0
  127. package/dist/assets/{security-CnSkbe_3.js → security-C6PwatSL.js} +1 -1
  128. package/dist/assets/{session-CAOgTWka.js → session-L__eR8rN.js} +1 -1
  129. package/dist/assets/{setup-B6xOe2m-.js → setup-C6HhC4jt.js} +1 -1
  130. package/dist/assets/{simple-select-Cg51s1gv.js → simple-select-CxoXsQVr.js} +1 -1
  131. package/dist/assets/{spaces-3bFBxoYi.js → spaces-24WmguiI.js} +1 -1
  132. package/dist/assets/{start-CkQJJ_tn.js → start-CEgdy1zB.js} +1 -1
  133. package/dist/assets/{starting-progress-C1yUqqL2.js → starting-progress-BoRrvgWe.js} +1 -1
  134. package/dist/assets/{status-6KTOVV9E.js → status-viNRhemG.js} +1 -1
  135. package/dist/assets/{step-actions-DHdqImlg.js → step-actions-C_mNllFC.js} +1 -1
  136. package/dist/assets/{studio-B65PiAI_.js → studio-CH0XVaW0.js} +1 -1
  137. package/dist/assets/{switch-CjOUxynL.js → switch-D2wksu-s.js} +1 -1
  138. package/dist/assets/{switch-control-BFsTsyuN.js → switch-control-D-yLpfsT.js} +1 -1
  139. package/dist/assets/{table-tips-EHWVzPWe.js → table-tips-sMVI7VOu.js} +1 -1
  140. package/dist/assets/{team-CG74iq-4.js → team-Caq5y5Xs.js} +1 -1
  141. package/dist/assets/th-BvLhxkpi.js +5 -0
  142. package/dist/assets/{traffic-Cyi-eL2B.js → traffic-KlkugfEB.js} +1 -1
  143. package/dist/assets/{transfer-BNHZEvsT.js → transfer-CXj22i68.js} +1 -1
  144. package/dist/assets/{unsubscribe-DmlsM6iA.js → unsubscribe-Bm4Jw2Kh.js} +1 -1
  145. package/dist/assets/{use-app-logo-BAJtA-EN.js → use-app-logo-C_3MNDVC.js} +1 -1
  146. package/dist/assets/{use-window-close-Bo92fPIm.js → use-window-close-CgevJhno.js} +1 -1
  147. package/dist/assets/{useAsync-Cc-dQGZL.js → useAsync-BCC9JxQR.js} +1 -1
  148. package/dist/assets/{useAsync-Be4McwD-.js → useAsync-P_Velqz1.js} +1 -1
  149. package/dist/assets/{useAsyncRetry-a2Wewn3F.js → useAsyncRetry-LJm0Fhbe.js} +1 -1
  150. package/dist/assets/{useLocalStorage-BBhMedc2.js → useLocalStorage-6wbaKET6.js} +1 -1
  151. package/dist/assets/{user-center-CNFpJssw.js → user-center-eZZBxCnH.js} +2 -2
  152. package/dist/assets/{user-follower-BsFDOo99.js → user-follower-udSlTR0u.js} +1 -1
  153. package/dist/assets/{util-B41ySVcQ.js → util-9a6OMNK7.js} +1 -1
  154. package/dist/assets/{util-DkhTntVV.js → util-BQfBCQq1.js} +1 -1
  155. package/dist/assets/{vendor-arcblock-BL_VyzmH.js → vendor-arcblock-D8WYBDYe.js} +1 -1
  156. package/dist/assets/{vendor-hooks-fhL5FJET.js → vendor-hooks-PN9SWiQm.js} +1 -1
  157. package/dist/assets/{vendor-utils-BSZ4yJws.js → vendor-utils-BgSaqjGx.js} +1 -1
  158. package/dist/assets/{vendor-ux-D507n6h6.js → vendor-ux-r9bApERu.js} +2 -2
  159. package/dist/assets/vi-BmM-09Iq.js +5 -0
  160. package/dist/assets/{wait-connect-48vXA6Ey.js → wait-connect-D-anNiug.js} +1 -1
  161. package/dist/assets/{wizard-BwJoQAJL.js → wizard-DnHSYuTP.js} +1 -1
  162. package/dist/assets/{wizard-components-C4msLQny.js → wizard-components-C6KwiiLp.js} +1 -1
  163. package/dist/assets/wrap-locale--xtBp5yb.js +1 -0
  164. package/dist/assets/{zh-DZI4Yy2m.js → zh-BkVzTN9N.js} +2 -2
  165. package/dist/assets/{zh-BNKpRkuo.js → zh-Djej3j0D.js} +1 -1
  166. package/dist/assets/zh-tw-CW4J6ddt.js +9 -0
  167. package/dist/index.html +1 -1
  168. package/dist/service-worker.js +1 -1
  169. package/package.json +24 -24
  170. package/dist/assets/api-DIucIOLX.js +0 -1
  171. package/dist/assets/ar-C89Z16Ql.js +0 -7
  172. package/dist/assets/branding-GuXEK2Lx.js +0 -1
  173. package/dist/assets/dashboard-Bcb81CDA.js +0 -106
  174. package/dist/assets/de-BsCDrfBl.js +0 -7
  175. package/dist/assets/domains-Cgl-LcPh.js +0 -1
  176. package/dist/assets/engine-BXpJ8aB3.js +0 -1
  177. package/dist/assets/es-BJh_XsEm.js +0 -9
  178. package/dist/assets/fr-DRJMwn7V.js +0 -7
  179. package/dist/assets/get-safe-url-DHtEly1m.js +0 -1
  180. package/dist/assets/hi-h-9Yl5g9.js +0 -5
  181. package/dist/assets/id-BDWggRsa.js +0 -7
  182. package/dist/assets/index-DLvroCDC.js +0 -1
  183. package/dist/assets/ja-R9EF3xbB.js +0 -9
  184. package/dist/assets/ko-C_QLPZyk.js +0 -9
  185. package/dist/assets/localization-B72YTR3I.js +0 -1
  186. package/dist/assets/logger-CjpdOowp.js +0 -1
  187. package/dist/assets/observability-SEfRhcXj.js +0 -1
  188. package/dist/assets/passport-Dsw-sETA.js +0 -1
  189. package/dist/assets/playground-Bo63Spph.js +0 -1
  190. package/dist/assets/profile-embed-CQgwIw3w.js +0 -1
  191. package/dist/assets/pt-DpYO8djd.js +0 -5
  192. package/dist/assets/ru-DkZtar3s.js +0 -5
  193. package/dist/assets/runtime-k8xPJwHr.js +0 -1
  194. package/dist/assets/sdk-BLKW-lxg.js +0 -1
  195. package/dist/assets/th-04iX5CrT.js +0 -5
  196. package/dist/assets/vi-kOP0E9Ga.js +0 -5
  197. package/dist/assets/wrap-locale-D5uKJYzr.js +0 -1
  198. package/dist/assets/zh-tw-BLapUUeq.js +0 -9
@@ -1,4 +1,4 @@
1
- import{r as u}from"./vendor-react-CUXIiAnY.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-BPQ6AEW_.js";import{C as H}from"./Google-Dp7qGnxg.js";import{p as U}from"./vendor-ux-D507n6h6.js";import{c as Y}from"./create-passport-svg-BLBQxsEK.js";import{A as $}from"./vendor-arcblock-BL_VyzmH.js";import{e as J}from"./index-Cx5JU0Ln.js";import{R as Q}from"./required-Btg6mEmX.js";import{F as Z}from"./form-wrapper-CU8kJXy5.js";import{L as v}from"./logo-uploader-_reea4L6.js";import{A as ee,a as ne,b as te}from"./collapse-CzqKk-Uw.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-CUXIiAnY.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-BPQ6AEW_.js";import{C as H}from"./Google-FE-PKKgg.js";import{p as U}from"./vendor-ux-r9bApERu.js";import{c as Y}from"./create-passport-svg-CIUyZVGt.js";import{A as $}from"./vendor-arcblock-D8WYBDYe.js";import{e as J}from"./index-jPmRCtiq.js";import{R as Q}from"./required-Btg6mEmX.js";import{F as Z}from"./form-wrapper-CU8kJXy5.js";import{L as v}from"./logo-uploader-Bs_7E0-m.js";import{A as ee,a as ne,b as te}from"./collapse-CzqKk-Uw.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
  }
@@ -1,4 +1,4 @@
1
- import{j as e,W as u,a6 as z,T as j,at as _e,D as We,cH as V,ao as J,cI as Ke,ak as h,b1 as K,a$ as Ge,s as fe,cJ as be,co as Fe,am as ge,cq as Ye,M as F,aO as Y,bX as $e,aP as $,Q as qe,be as He,aR as Qe,cK as Xe,cL as Ve,cM as Je,cN as Ze,c2 as he}from"./vendor-mui-core-BPQ6AEW_.js";import{k as ke,j as je,a as ue}from"./vendor-hooks-fhL5FJET.js";import{r as b,u as et}from"./vendor-react-CUXIiAnY.js";import{ac as O,_ as L,a1 as E,Y as N,aQ as tt,aR as st,aI as nt,c as T,v as ot}from"./index-Cx5JU0Ln.js";import{H as B,V as D,p as at,Q as q,h as rt,W as it,n as le,j as ct}from"./vendor-ux-D507n6h6.js";import{u as lt}from"./use-mobile-ajdJIsoX.js";import{a as H,d as Ce,a0 as dt,c as pt,D as we,C as me}from"./vendor-utils-BSZ4yJws.js";import{o as Be}from"./vendor-arcblock-BL_VyzmH.js";import{b as ut,u as mt,D as xt,c as de,a as ft}from"./index-gy2ZIEt_.js";import"./index-BIJNkmLb.js";import"./index-BojVbZw0.js";import"./api-DIucIOLX.js";import{u as De,C as gt,D as ht,a as St}from"./connect-to-Bi5k3ZXU.js";import{b as yt,c as bt,d as kt,i as jt,e as xe,f as Ct,h as wt,j as Bt}from"./spaces-3bFBxoYi.js";import{f as Q}from"./index-DBs9Ljax.js";import{v as Dt}from"./index-Ca4Ccmqm.js";import{E as Et}from"./index-DA2Pny4B.js";import{x as It}from"./index-DRYJ0xIl.js";import{g as Se}from"./get-safe-url-DHtEly1m.js";import{S as Tt}from"./switch-control-BFsTsyuN.js";import{C as Rt,u as Pt}from"./config-space-Cjm8zHqm.js";import{L as ye}from"./list-header-Cv_gaaAc.js";import"./lottie-web-4koyQiv_.js";import"./index-C3cD5fjJ.js";async function vt({blockletDid:t,nodeApi:n,spaceGateways:o}){let s=!1;const r=await Promise.all(o.map(async a=>{let{name:c}=a;const i=await yt(a.endpoint);return!H(i)&&i!==c&&(c=i,s=!0),{...a,name:c}}));return s&&await Promise.all(r.filter(a=>a.did).map(a=>n.updateBlockletSpaceGateway({input:{did:t,where:{did:a.did},spaceGateway:{...a}}}))),r}function At({refresh:t}={}){const{blocklet:n}=O(),o=n?.meta?.did,{api:s}=L();return ke(async()=>{if(!o)return[];const{spaceGateways:r}=await s.getBlockletSpaceGateways({input:{did:o}});return await vt({blockletDid:o,nodeApi:s,spaceGateways:r})??[]},{refreshDeps:[o,t],onError(r){r?.message?.includes("not logged")?console.warn(r):(console.error(r),B.error(Q(r)))}})}function Ee({deps:t,setLoading:n,backupDate:o}={deps:[],setLoading:()=>{},backupDate:new Date}){const{blocklet:s}=O(),[r,a]=b.useState([]),{api:c}=L(),[i,d]=b.useMemo(()=>o?[E(o).startOf("day").toISOString(),E(o).endOf("day").toISOString()]:[E().startOf("year").toISOString(),E().endOf("day").toISOString()],[o]),l=Ce(async()=>{try{if(n(!0),!s){a([]);return}const{backups:x}=await c.getBlockletBackups({input:{did:s.meta.did,startTime:i,endTime:d}});a(x??[])}catch(x){console.error(x),B.error(Q(x))}finally{n(!1)}},1e3);return je(async()=>{l()},[s?.meta?.did].concat(t)),{backups:r}}function zt({appDid:t}){const{backups:n}=Ee(),[o,s]=b.useState({message:"",progress:0,completed:!1}),r=L(),{ws:{useSubscription:a}}=r;return a(N.BlockletEvents.backupProgress,c=>{t===c?.appDid&&s(()=>({...c}))},[t]),b.useEffect(()=>{if(n?.length&&dt(n[0]?.status)){const[c]=n;s(()=>({message:c.message,progress:c.progress,completed:c.progress>=100}))}},[n]),o}function Ot({deps:t=[],setLoading:n=()=>{}}={}){const{blocklet:o}=O(),[s,r]=b.useState([]),{api:a}=L(),c=b.useCallback(Ce(async()=>{if(!a||!o?.meta?.did){r([]);return}try{n(!0);const i=E(),d=i.subtract(1,"year"),{summary:l}=await a.getBlockletBackupSummary({input:{did:o.meta.did,startTime:d.toISOString(),endTime:i.toISOString()}});r(Array.isArray(l)?l:[])}catch(i){console.error("Failed to fetch backup summary:",i),B.error(Q(i)),r([])}finally{n(!1)}},1e3),[]);return je(async()=>(await c(),()=>{c.cancel()}),[o?.meta?.did].concat(t)),{backupSummary:s}}const Ie=b.createContext({}),{Provider:Lt,Consumer:bs}=Ie;function Te({children:t}){const{t:n}=D(),{api:o}=L(),{blocklet:s}=O(),[r,a]=b.useState(null),[c,i]=b.useState(!1),{data:d,loading:l,mutate:x}=At({refresh:c}),g=pt(d),m=zt({appDid:s?.appDid}),p=b.useMemo(()=>bt(s?.environments),[s?.environments]),[k,w]=b.useState(!1),[S,y]=b.useState(0),{backups:Z}=Ee({deps:[S,r],setLoading:w,backupDate:r}),[ee,te]=b.useState(0),{backupSummary:se}=Ot({deps:[ee]}),[_,M]=b.useState(d?.find(f=>f.endpoint===p)),I=s?.settings?.autoBackup,P=()=>{i(f=>!f)},ne=()=>{te(f=>f+1)},oe=()=>{y(f=>f+1)},G=async f=>{await o.updateAutoBackup({input:{did:s.meta.did,autoBackup:f}})},X=async()=>{await o.abortBlockletBackup({input:{appPid:s.meta.did}})},ae=async(f,A)=>{try{x(R=>{const v=[...R];return v.push({...f,loading:!0}),v}),await o.addBlockletSpaceGateway({input:{did:s.meta.did,spaceGateway:f}}),p!==A&&await o.configBlocklet({input:{did:[s.meta.did],configs:[{key:N.BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_APP_BACKUP_ENDPOINT,value:A}]}}),M(f),P(),B.success(n("storage.spaces.connectedWithName",{name:f?.name??"DID Spaces"}))}catch(R){throw console.error(R),x(v=>[...v].filter(W=>W.did!==f.did)),R}},re=async f=>{f&&(f.endpoint===p&&(await o.configBlocklet({input:{did:[s.meta.did],configs:[{key:N.BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_APP_BACKUP_ENDPOINT,value:""}]}}),I?.enabled&&await G({enabled:!1})),await o.deleteBlockletSpaceGateway({input:{did:s.meta.did,spaceGatewayDid:f?.did}}),x(A=>{const R=[...A];return R.splice(R.indexOf(f),1),R}),M(f),P())},ie=async f=>{await Promise.all([o.updateBlockletSpaceGateway({input:{did:s.meta.did,where:{did:f.did},spaceGateway:f}}),p!==f.endpoint&&o.configBlocklet({input:{did:[s.meta.did],configs:[{key:N.BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_APP_BACKUP_ENDPOINT,value:f.endpoint}]}})]),B.success(n("storage.spaces.connectedWithName",{name:f?.name??"DID Spaces"})),P()},C=f=>f?.endpoint===p;return e.jsx(Lt,{value:{spaceGateways:d||[],selectedSpaceGateway:_,addSpaceGateway:ae,deleteSpaceGateway:re,updateSpaceGateway:ie,refreshSpaceGateways:P,spaceGatewaysLoading:l,spaceGatewaysFirstLoading:g,spaceGatewayIsSelected:C,updateAutoBackup:G,abortBlockletBackup:X,backupEndpoint:p,backupProgress:m,backups:Z,backupSummary:se,refreshBackupSummary:ne,refreshBackups:oe,setBackupDate:a,backupsLoading:k,autoBackup:I},children:t})}Te.propTypes={children:u.any.isRequired};function U(){return b.useContext(Ie)}function Re({...t}){const{blocklet:n}=O(),{info:o}=L(),{t:s}=D(),r=De({blocklet:n}),a=tt(o),{spaceGateways:c,addSpaceGateway:i}=U(),d={checkFn:we.create({baseURL:me(window.location.origin,st())}).get,webWalletUrl:a,extraParams:{appPid:n.appPid,appDid:r.appDid,appName:r.appName,appDescription:r.appDescription,appUrl:r.appUrl,referrer:r.referrer,scopes:r.scopes,nodeDid:o.did}},l=async({endpoint:g,name:m,did:p})=>{const k=await kt(g);if(!await jt(k)){B.error(s("storage.spaces.gateway.add.invalidUrl"));return}if(c.some(y=>y.endpoint===g)){B.error(s("storage.spaces.gateway.add.duplicate",{name:m}));return}await i({name:m,did:p,url:k,endpoint:g},g)},x=async({spaceGateway:g})=>{try{await l(g)}catch(m){console.error(m),B.error(Q(m))}};return e.jsx(ut,{...t,connectScope:"app",options:d,onSuccess:x})}function Ut(){const{api:t}=L(),{blocklet:n}=O(),{data:o,loading:s}=ke(()=>t.getBlocklet({input:{did:n?.meta?.did,attachDiskInfo:!0,attachRuntimeInfo:!0}}),{ready:!!n?.meta?.did,refreshDeps:[n?.meta?.did]});return{blocklet:o?.blocklet??null,loading:s}}function Pe({...t}){const{t:n}=b.useContext(at),{blocklet:o,loading:s}=Ut();if(o?.diskInfo){const r=(i,d,l)=>e.jsxs(j,{children:[i," ",e.jsx("strong",{children:d?nt(d):"empty"})]}),a=o.environments.reduce((i,d)=>(i[d.key]=d.value,i),{}),c=[{key:"appDir",name:n("blocklet.diskInfo.appDir"),value:r(a.BLOCKLET_APP_DIR,o.diskInfo.app)},{key:"dataDir",name:n("blocklet.diskInfo.dataDir"),value:r(a.BLOCKLET_DATA_DIR,o.diskInfo.data)},{key:"logDir",name:n("blocklet.diskInfo.logDir"),value:r(a.BLOCKLET_LOG_DIR,o.diskInfo.log)},{key:"cacheDir",name:n("blocklet.diskInfo.cacheDir"),value:r(a.BLOCKLET_CACHE_DIR,o.diskInfo.cache)}];return e.jsx(Mt,{component:"div",...t,children:c.map(i=>e.jsx(Dt,{valueComponent:"div",nameWidth:120,name:i.name,children:i.value},i.key))})}return s?e.jsx(z,{}):e.jsx(j,{children:n("blocklet.diskInfo.empty")})}const Mt=_e(j)``;function ve(){const{t}=D(),{setBackupDate:n,backupSummary:o}=U(),s=mt({key:"lg"}),r=b.useRef(null),a=We(),c=b.useCallback(l=>{n(l)},[n]),i=b.useMemo(()=>{const l=E().add(1,"day"),x=l.subtract(1,"year"),g=new Map(o.map(p=>[p.date,{date:p.date,successCount:p.successCount,errorCount:p.errorCount}])),m=[];for(let p=x.clone();E(p).isBefore(l);p=p.add(1,"day")){const k=p.format("YYYY-MM-DD");m.push(g.get(k)||{date:k,successCount:0,errorCount:0})}return m},[o]),d=b.useMemo(()=>({grid:{containLabel:!0,right:10,top:30,bottom:12},tooltip:{formatter:k=>{const{date:w,successCount:S,errorCount:y}=i[k.dataIndex]||{date:k.data[0],successCount:0,errorCount:0};return[`<div>${t("common.time")}: ${w}</div>`,`<div>${t("common.succeeded")}: ${S}</div>`,`<div>${t("common.failed")}: ${y}</div>`].join(`
1
+ import{j as e,W as u,a6 as z,T as j,at as _e,D as We,cH as V,ao as J,cI as Ke,ak as h,b1 as K,a$ as Ge,s as fe,cJ as be,co as Fe,am as ge,cq as Ye,M as F,aO as Y,bX as $e,aP as $,Q as qe,be as He,aR as Qe,cK as Xe,cL as Ve,cM as Je,cN as Ze,c2 as he}from"./vendor-mui-core-BPQ6AEW_.js";import{k as ke,j as je,a as ue}from"./vendor-hooks-PN9SWiQm.js";import{r as b,u as et}from"./vendor-react-CUXIiAnY.js";import{ac as O,_ as L,a1 as E,Y as N,aQ as tt,aR as st,aI as nt,c as T,v as ot}from"./index-jPmRCtiq.js";import{H as B,V as D,p as at,Q as q,h as rt,W as it,n as le,j as ct}from"./vendor-ux-r9bApERu.js";import{u as lt}from"./use-mobile-ajdJIsoX.js";import{a as H,d as Ce,a0 as dt,c as pt,D as we,C as me}from"./vendor-utils-BgSaqjGx.js";import{o as Be}from"./vendor-arcblock-D8WYBDYe.js";import{b as ut,u as mt,D as xt,c as de,a as ft}from"./index-DkaI7B4e.js";import"./index-CJ1z6qNA.js";import"./index-BojVbZw0.js";import"./api-uGeIZn4a.js";import{u as De,C as gt,D as ht,a as St}from"./connect-to-DvsUYNJv.js";import{b as yt,c as bt,d as kt,i as jt,e as xe,f as Ct,h as wt,j as Bt}from"./spaces-24WmguiI.js";import{f as Q}from"./index-DBs9Ljax.js";import{v as Dt}from"./index-ySP_m_Ux.js";import{E as Et}from"./index-BnOhhAn2.js";import{x as It}from"./index-DRYJ0xIl.js";import{g as Se}from"./get-safe-url-DB8WYPm8.js";import{S as Tt}from"./switch-control-D-yLpfsT.js";import{C as Rt,u as Pt}from"./config-space-BywO8K6k.js";import{L as ye}from"./list-header-Cv_gaaAc.js";import"./lottie-web-4koyQiv_.js";import"./index-B7Hwfql4.js";async function vt({blockletDid:t,nodeApi:n,spaceGateways:o}){let s=!1;const r=await Promise.all(o.map(async a=>{let{name:c}=a;const i=await yt(a.endpoint);return!H(i)&&i!==c&&(c=i,s=!0),{...a,name:c}}));return s&&await Promise.all(r.filter(a=>a.did).map(a=>n.updateBlockletSpaceGateway({input:{did:t,where:{did:a.did},spaceGateway:{...a}}}))),r}function At({refresh:t}={}){const{blocklet:n}=O(),o=n?.meta?.did,{api:s}=L();return ke(async()=>{if(!o)return[];const{spaceGateways:r}=await s.getBlockletSpaceGateways({input:{did:o}});return await vt({blockletDid:o,nodeApi:s,spaceGateways:r})??[]},{refreshDeps:[o,t],onError(r){r?.message?.includes("not logged")?console.warn(r):(console.error(r),B.error(Q(r)))}})}function Ee({deps:t,setLoading:n,backupDate:o}={deps:[],setLoading:()=>{},backupDate:new Date}){const{blocklet:s}=O(),[r,a]=b.useState([]),{api:c}=L(),[i,d]=b.useMemo(()=>o?[E(o).startOf("day").toISOString(),E(o).endOf("day").toISOString()]:[E().startOf("year").toISOString(),E().endOf("day").toISOString()],[o]),l=Ce(async()=>{try{if(n(!0),!s){a([]);return}const{backups:x}=await c.getBlockletBackups({input:{did:s.meta.did,startTime:i,endTime:d}});a(x??[])}catch(x){console.error(x),B.error(Q(x))}finally{n(!1)}},1e3);return je(async()=>{l()},[s?.meta?.did].concat(t)),{backups:r}}function zt({appDid:t}){const{backups:n}=Ee(),[o,s]=b.useState({message:"",progress:0,completed:!1}),r=L(),{ws:{useSubscription:a}}=r;return a(N.BlockletEvents.backupProgress,c=>{t===c?.appDid&&s(()=>({...c}))},[t]),b.useEffect(()=>{if(n?.length&&dt(n[0]?.status)){const[c]=n;s(()=>({message:c.message,progress:c.progress,completed:c.progress>=100}))}},[n]),o}function Ot({deps:t=[],setLoading:n=()=>{}}={}){const{blocklet:o}=O(),[s,r]=b.useState([]),{api:a}=L(),c=b.useCallback(Ce(async()=>{if(!a||!o?.meta?.did){r([]);return}try{n(!0);const i=E(),d=i.subtract(1,"year"),{summary:l}=await a.getBlockletBackupSummary({input:{did:o.meta.did,startTime:d.toISOString(),endTime:i.toISOString()}});r(Array.isArray(l)?l:[])}catch(i){console.error("Failed to fetch backup summary:",i),B.error(Q(i)),r([])}finally{n(!1)}},1e3),[]);return je(async()=>(await c(),()=>{c.cancel()}),[o?.meta?.did].concat(t)),{backupSummary:s}}const Ie=b.createContext({}),{Provider:Lt,Consumer:bs}=Ie;function Te({children:t}){const{t:n}=D(),{api:o}=L(),{blocklet:s}=O(),[r,a]=b.useState(null),[c,i]=b.useState(!1),{data:d,loading:l,mutate:x}=At({refresh:c}),g=pt(d),m=zt({appDid:s?.appDid}),p=b.useMemo(()=>bt(s?.environments),[s?.environments]),[k,w]=b.useState(!1),[S,y]=b.useState(0),{backups:Z}=Ee({deps:[S,r],setLoading:w,backupDate:r}),[ee,te]=b.useState(0),{backupSummary:se}=Ot({deps:[ee]}),[_,M]=b.useState(d?.find(f=>f.endpoint===p)),I=s?.settings?.autoBackup,P=()=>{i(f=>!f)},ne=()=>{te(f=>f+1)},oe=()=>{y(f=>f+1)},G=async f=>{await o.updateAutoBackup({input:{did:s.meta.did,autoBackup:f}})},X=async()=>{await o.abortBlockletBackup({input:{appPid:s.meta.did}})},ae=async(f,A)=>{try{x(R=>{const v=[...R];return v.push({...f,loading:!0}),v}),await o.addBlockletSpaceGateway({input:{did:s.meta.did,spaceGateway:f}}),p!==A&&await o.configBlocklet({input:{did:[s.meta.did],configs:[{key:N.BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_APP_BACKUP_ENDPOINT,value:A}]}}),M(f),P(),B.success(n("storage.spaces.connectedWithName",{name:f?.name??"DID Spaces"}))}catch(R){throw console.error(R),x(v=>[...v].filter(W=>W.did!==f.did)),R}},re=async f=>{f&&(f.endpoint===p&&(await o.configBlocklet({input:{did:[s.meta.did],configs:[{key:N.BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_APP_BACKUP_ENDPOINT,value:""}]}}),I?.enabled&&await G({enabled:!1})),await o.deleteBlockletSpaceGateway({input:{did:s.meta.did,spaceGatewayDid:f?.did}}),x(A=>{const R=[...A];return R.splice(R.indexOf(f),1),R}),M(f),P())},ie=async f=>{await Promise.all([o.updateBlockletSpaceGateway({input:{did:s.meta.did,where:{did:f.did},spaceGateway:f}}),p!==f.endpoint&&o.configBlocklet({input:{did:[s.meta.did],configs:[{key:N.BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_APP_BACKUP_ENDPOINT,value:f.endpoint}]}})]),B.success(n("storage.spaces.connectedWithName",{name:f?.name??"DID Spaces"})),P()},C=f=>f?.endpoint===p;return e.jsx(Lt,{value:{spaceGateways:d||[],selectedSpaceGateway:_,addSpaceGateway:ae,deleteSpaceGateway:re,updateSpaceGateway:ie,refreshSpaceGateways:P,spaceGatewaysLoading:l,spaceGatewaysFirstLoading:g,spaceGatewayIsSelected:C,updateAutoBackup:G,abortBlockletBackup:X,backupEndpoint:p,backupProgress:m,backups:Z,backupSummary:se,refreshBackupSummary:ne,refreshBackups:oe,setBackupDate:a,backupsLoading:k,autoBackup:I},children:t})}Te.propTypes={children:u.any.isRequired};function U(){return b.useContext(Ie)}function Re({...t}){const{blocklet:n}=O(),{info:o}=L(),{t:s}=D(),r=De({blocklet:n}),a=tt(o),{spaceGateways:c,addSpaceGateway:i}=U(),d={checkFn:we.create({baseURL:me(window.location.origin,st())}).get,webWalletUrl:a,extraParams:{appPid:n.appPid,appDid:r.appDid,appName:r.appName,appDescription:r.appDescription,appUrl:r.appUrl,referrer:r.referrer,scopes:r.scopes,nodeDid:o.did}},l=async({endpoint:g,name:m,did:p})=>{const k=await kt(g);if(!await jt(k)){B.error(s("storage.spaces.gateway.add.invalidUrl"));return}if(c.some(y=>y.endpoint===g)){B.error(s("storage.spaces.gateway.add.duplicate",{name:m}));return}await i({name:m,did:p,url:k,endpoint:g},g)},x=async({spaceGateway:g})=>{try{await l(g)}catch(m){console.error(m),B.error(Q(m))}};return e.jsx(ut,{...t,connectScope:"app",options:d,onSuccess:x})}function Ut(){const{api:t}=L(),{blocklet:n}=O(),{data:o,loading:s}=ke(()=>t.getBlocklet({input:{did:n?.meta?.did,attachDiskInfo:!0,attachRuntimeInfo:!0}}),{ready:!!n?.meta?.did,refreshDeps:[n?.meta?.did]});return{blocklet:o?.blocklet??null,loading:s}}function Pe({...t}){const{t:n}=b.useContext(at),{blocklet:o,loading:s}=Ut();if(o?.diskInfo){const r=(i,d,l)=>e.jsxs(j,{children:[i," ",e.jsx("strong",{children:d?nt(d):"empty"})]}),a=o.environments.reduce((i,d)=>(i[d.key]=d.value,i),{}),c=[{key:"appDir",name:n("blocklet.diskInfo.appDir"),value:r(a.BLOCKLET_APP_DIR,o.diskInfo.app)},{key:"dataDir",name:n("blocklet.diskInfo.dataDir"),value:r(a.BLOCKLET_DATA_DIR,o.diskInfo.data)},{key:"logDir",name:n("blocklet.diskInfo.logDir"),value:r(a.BLOCKLET_LOG_DIR,o.diskInfo.log)},{key:"cacheDir",name:n("blocklet.diskInfo.cacheDir"),value:r(a.BLOCKLET_CACHE_DIR,o.diskInfo.cache)}];return e.jsx(Mt,{component:"div",...t,children:c.map(i=>e.jsx(Dt,{valueComponent:"div",nameWidth:120,name:i.name,children:i.value},i.key))})}return s?e.jsx(z,{}):e.jsx(j,{children:n("blocklet.diskInfo.empty")})}const Mt=_e(j)``;function ve(){const{t}=D(),{setBackupDate:n,backupSummary:o}=U(),s=mt({key:"lg"}),r=b.useRef(null),a=We(),c=b.useCallback(l=>{n(l)},[n]),i=b.useMemo(()=>{const l=E().add(1,"day"),x=l.subtract(1,"year"),g=new Map(o.map(p=>[p.date,{date:p.date,successCount:p.successCount,errorCount:p.errorCount}])),m=[];for(let p=x.clone();E(p).isBefore(l);p=p.add(1,"day")){const k=p.format("YYYY-MM-DD");m.push(g.get(k)||{date:k,successCount:0,errorCount:0})}return m},[o]),d=b.useMemo(()=>({grid:{containLabel:!0,right:10,top:30,bottom:12},tooltip:{formatter:k=>{const{date:w,successCount:S,errorCount:y}=i[k.dataIndex]||{date:k.data[0],successCount:0,errorCount:0};return[`<div>${t("common.time")}: ${w}</div>`,`<div>${t("common.succeeded")}: ${S}</div>`,`<div>${t("common.failed")}: ${y}</div>`].join(`
2
2
  `)},backgroundColor:a.palette.background.paper,borderColor:a.palette.divider,textStyle:{color:a.palette.text.primary,fontSize:14},extraCssText:`box-shadow: ${a.shadows[2]}; border-radius: 4px;`,padding:[8,10]},visualMap:{show:!1,min:-12,max:12,pieces:[{min:Number.MIN_SAFE_INTEGER,max:-9,color:V[600]},{min:-9,max:-6,color:V[500]},{min:-6,max:-3,color:V[400]},{min:-3,max:-1,color:V[300]},{min:0,max:0,color:a.palette.grey[200]},{min:1,max:3,color:J[300]},{min:3,max:6,color:J[400]},{min:6,max:9,color:J[500]},{min:9,max:Number.MAX_SAFE_INTEGER,color:J[600]}],orient:"horizontal",left:"center",bottom:12,itemWidth:12,itemHeight:12,textStyle:{color:a.palette.text.secondary,fontSize:12}},calendar:{top:30,left:50,right:10,bottom:4,cellSize:[8,8],splitLine:{show:!1},itemStyle:{borderWidth:2,borderColor:a.palette.background.default,color:a.palette.background.default},dayLabel:{show:!0,firstDay:0,nameMap:["","Mon","","Wed","","Fri",""],position:"start",margin:4,fontSize:10,color:a.palette.text.primary,fontWeight:"400",width:20},monthLabel:{show:!0,nameMap:"cn",align:"left",color:a.palette.text.primary,fontWeight:"400",fontSize:12,position:"start",margin:4,width:30,padding:[0,2]},yearLabel:{show:!1},range:[E().subtract(11,"month").startOf("month").format("YYYY-MM-DD"),E().endOf("month").format("YYYY-MM-DD")],orient:"horizontal"},series:{type:"heatmap",coordinateSystem:"calendar",data:i.map(k=>[k.date,k.errorCount?-k.errorCount:k.successCount]),label:{show:!1},itemStyle:{borderWidth:2,borderColor:a.palette.background.default,borderRadius:4},emphasis:{itemStyle:{borderWidth:2,borderColor:Ke[200],color:"inherit"}}}}),[i,t,a]);return e.jsxs(e.Fragment,{children:[e.jsx(h,{ref:r,sx:{maxWidth:"1280px",border:"1px solid",borderColor:"divider",padding:"8px",overflowX:"auto"},children:e.jsx(h,{sx:{width:"1200px",height:"180px",position:"relative"},children:e.jsx(Et,{option:d,style:{height:"100%",width:"100%"},notMerge:!0,lazyUpdate:!1,opts:{renderer:"canvas"},onEvents:{click:l=>{l.componentType==="series"&&l.data&&c(l.data[0])}}})})}),e.jsx(h,{sx:{display:"flex",justifyContent:"flex-end",mt:1,mr:s?2:5,mb:2},children:e.jsxs(K,{direction:s?"column":"row",spacing:s?2:1,sx:{width:"100%",justifyContent:"flex-start",alignItems:s?"flex-start":"center"},children:[e.jsxs(K,{direction:"row",spacing:1,sx:{alignItems:"center"},children:[e.jsx(h,{sx:{width:32,height:12,borderRadius:.5,background:"linear-gradient(90deg, #8B5000 0%, #A36200 33%, #C17700 66%, #E29000 100%)"}}),e.jsx(j,{variant:"body2",sx:{color:"text.secondary"},children:t("storage.spaces.backup.failed")})]}),e.jsxs(K,{direction:"row",spacing:1,sx:{alignItems:"center"},children:[e.jsx(h,{sx:{width:32,height:12,borderRadius:.5,bgcolor:"grey.200",border:"1px solid",borderColor:"grey.200"}}),e.jsx(j,{variant:"body2",sx:{color:"text.secondary"},children:t("storage.spaces.backup.without")})]}),e.jsxs(K,{direction:"row",spacing:1,sx:{alignItems:"center"},children:[e.jsx(h,{sx:{width:32,height:12,borderRadius:.5,background:"linear-gradient(90deg, #9be9a8 0%, #40c463 33%, #30a14e 66%, #216e39 100%)"}}),e.jsx(j,{variant:"body2",sx:{color:"text.secondary"},children:t("storage.spaces.backup.succeeded")})]})]})})]})}const Nt=fe(({className:t,...n})=>e.jsx(ge,{...n,classes:{popper:t}}))(()=>({".MuiTooltip-tooltip":{backgroundColor:"transparent",padding:0,margin:0,boxShadow:"none",maxWidth:"none"},".MuiTooltip-arrow":{color:"rgba(230, 235, 245, 1)"}}));function Ae({status:t,message:n="",createdAt:o}){const{t:s}=D(),r=t===T.BACKUPS.STATUS.PROGRESS&&E().diff(o,"hours")>=T.BACKUPS.TIMEOUT_HOURS,a=r&&s("common.timeoutError"),c=t===T.BACKUPS.STATUS.PROGRESS&&!r,i=t===T.BACKUPS.STATUS.SUCCEEDED&&!r;return c?e.jsxs(j,{sx:{display:"inline-flex",alignItems:"center",fontSize:"14px"},children:[e.jsx(z,{sx:{marginRight:"4px"},size:"12px"}),s("common.progress")]}):i?e.jsx(q,{type:"success",children:s("common.succeeded")}):e.jsxs(h,{sx:{display:"inline-flex",alignItems:"center"},children:[e.jsx(q,{type:"error",children:s("common.failed")}),e.jsx(ge,{style:{display:"flex",alignItems:"center",flexShrink:0},title:n||a,children:e.jsx(be,{children:e.jsx(Ye,{style:{width:"24px",height:"24px"},color:"error"})})})]})}Ae.propTypes={status:u.string.isRequired,message:u.string,createdAt:u.string.isRequired};function ze({metadata:t={}}){const{t:n}=D();if(H(t))return e.jsx(q,{type:"success",children:n("common.succeeded")});const o=t.count||0,s=t.size||0,r=It(s,{iec:!0}),a=e.jsxs(h,{sx:{p:1,borderRadius:1,boxShadow:2,color:"black",backgroundColor:"white"},children:[e.jsxs(j,{variant:"body2",children:[n("common.fileCount"),": ",o]}),e.jsxs(j,{variant:"body2",children:[n("common.fileSize"),": ",r]})]});return e.jsxs(h,{sx:{display:"inline-flex",alignItems:"center"},children:[e.jsx(q,{type:"success",children:n("common.succeeded")}),e.jsx(Nt,{title:a,style:{display:"flex",alignItems:"center",flexShrink:0},placement:"left",children:e.jsx(be,{children:e.jsx(Fe,{style:{width:"24px",height:"24px"},color:"primary"})})})]})}ze.propTypes={metadata:u.object};function Oe(){const{t,locale:n}=D(),{spaceGateways:o,backups:s,backupsLoading:r}=U(),a=b.useMemo(()=>[{label:"DID Space",name:"target",options:{customBodyRenderLite:i=>{const{targetUrl:d,targetName:l,status:x,createdAt:g}=s[i],m=x===T.BACKUPS.STATUS.PROGRESS&&E().diff(g,"hours")>=T.BACKUPS.TIMEOUT_HOURS,p=x===T.BACKUPS.STATUS.SUCCEEDED&&!m,k=l||o.find(w=>d?.includes(xe(w?.endpoint)))?.name||"Unknown DID Space";return p?e.jsx(Ge,{href:d,target:"_blank",sx:{fontSize:"16px"},children:k}):e.jsx(j,{variant:"body1",sx:{fontSize:"16px"},children:k})}}},{label:t("common.strategy"),name:"strategy",options:{customBodyRender:i=>{const d=t(i===0?"common.auto":"common.manual");return e.jsx(q,{children:d})}}},{label:t("common.startTime"),name:"createdAt",options:{customBodyRender:i=>E(i).format("YYYY-MM-DD HH:mm:ss")}},{label:t("common.endTime"),name:"updatedAt",options:{customBodyRender:i=>H(i)?"":E(i).format("YYYY-MM-DD HH:mm:ss")}},{label:t("common.status"),name:"status",options:{customBodyRenderLite:i=>{const d=s?.[i]??{},{status:l,message:x,createdAt:g,metadata:m}=d,p=l===T.BACKUPS.STATUS.PROGRESS&&E().diff(g,"hours")>=T.BACKUPS.TIMEOUT_HOURS,k=l===T.BACKUPS.STATUS.PROGRESS&&!p,w=l===T.BACKUPS.STATUS.SUCCEEDED&&!p;return k?e.jsxs(j,{sx:{display:"inline-flex",alignItems:"center",fontSize:"14px"},children:[e.jsx(z,{sx:{marginRight:"4px"},size:"12px"}),t("common.progress")]}):w?e.jsx(ze,{metadata:m}):e.jsx(Ae,{status:l,message:x,createdAt:g})}}}],[s,o,t]),c=b.useMemo(()=>!s?.length,[s]);return e.jsx(e.Fragment,{children:c?e.jsx(h,{sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"100px",color:"#9397A1",marginTop:"16px",marginBottom:"24px"},children:t("storage.spaces.record.emptyData")}):e.jsx(rt,{title:"",loading:r,data:s,columns:a,emptyNode:t("storage.spaces.record.emptyData",n),options:{download:!1,filter:!1,print:!1,search:!1,viewColumns:!1}})})}function _t(){const{t}=D();return e.jsxs(h,{children:[e.jsxs(h,{sx:{display:"flex",gap:3,flexDirection:{xs:"column",md:"row"}},children:[e.jsxs(h,{sx:{display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",alignContent:"center",minWidth:240},children:[e.jsx(xt,{style:{cursor:"pointer",width:"150px",height:"100%",maxHeight:160}}),e.jsx(j,{sx:{my:2,textAlign:"center",color:"text.secondary"},children:t("storage.spaces.connect.provider")}),e.jsx(Re,{})]}),e.jsxs(h,{sx:{flexGrow:1,minWidth:0},children:[e.jsx(h,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:3},children:e.jsx(j,{sx:{fontSize:"1.2rem",fontWeight:"bold"},children:t("storage.spaces.backup.records")})}),e.jsx(ve,{})]})]}),e.jsx(Oe,{sx:{marginTop:"24px"}}),e.jsx(j,{sx:{fontSize:"1.2rem",fontWeight:"bold",mb:2,mt:2},children:t("common.dataStorage")}),e.jsx(Pe,{})]})}function Le({spaceGateway:t,onConfirm:n=()=>{},onCancel:o=()=>{}}){const{t:s}=D(),[r,a]=b.useState(!1),[c,i]=b.useState(!1),d=(g,m)=>{g?.preventDefault(),g?.stopPropagation(),a(m)},l=async g=>{try{g?.stopPropagation(),i(!0),await n?.(t),a(!1)}catch(m){console.error(m),B.error(`${s("storage.space.gateway.delete.failed")}: ${Q(m)}`)}finally{a(!1),i(!1)}},x=g=>{d(g,!1),o?.(g)};return e.jsxs(e.Fragment,{children:[e.jsxs(F,{color:"red",onClick:g=>d(g,!0),children:[e.jsx(Y,{style:{minWidth:24,color:"red"},children:e.jsx($e,{fontSize:"small"})}),e.jsx($,{style:{color:"red"},children:s("common.disconnect")})]}),e.jsx(it,{title:s("storage.spaces.gateway.delete.title"),open:r,confirmButton:{text:s("common.confirm"),props:{size:"small",variant:"contained",color:"error",loading:c}},cancelButton:{text:s("common.cancel"),props:{size:"small",variant:"outlined",disabled:c}},onConfirm:l,onCancel:x,children:e.jsx(j,{sx:{wordWrap:"break-word"},children:s("storage.spaces.gateway.delete.descForBackup",{name:`${t?.name}`})})})]})}Le.propTypes={spaceGateway:u.shape({name:u.string.isRequired,url:u.string.isRequired,protected:u.bool}).isRequired,onConfirm:u.func,onCancel:u.func};function Ue({spaceGateway:t,selected:n,onDelete:o=()=>{},onConnect:s=()=>{},enableSwitchToSpace:r=!0,backupInProgress:a=!1,...c}){const{abortBlockletBackup:i}=U(),[d,l]=b.useState(null),{t:x}=D(),[g,m]=b.useState(!1),p=(S,y)=>{S.stopPropagation(),S.preventDefault(),l(y&&S.currentTarget)},k=async S=>{try{m(!0),p(S,!1),await s(t)}catch(y){console.error(y),B.error(y.message)}finally{m(!1)}},w=async S=>{try{m(!0),p(S,!1),await i()}catch(y){console.error(y),B.error(y.message)}finally{m(!1)}};return e.jsxs(e.Fragment,{children:[g||t?.loading?e.jsx(z,{sx:{ml:1},size:"24px"}):e.jsx(qe,{"aria-label":"more","aria-controls":"actions-menu","aria-haspopup":"true","data-cy":"trigger-blocklet-actions",variant:"outlined",size:"small",onClick:S=>p(S,!0),...c,children:e.jsx(He,{})}),e.jsxs(Qe,{id:"simple-menu",anchorEl:d,keepMounted:!0,open:!!d,onClose:S=>p(S,!1),children:[e.jsxs(F,{onClick:S=>{p(S,!1),window.open(Se(t.endpoint?Ct(t.endpoint):t.url,{allowDomains:null}))},children:[e.jsx(Y,{style:{minWidth:24},children:e.jsx(Xe,{fontSize:"small"})}),e.jsx($,{children:x("common.open")})]}),e.jsxs(F,{onClick:S=>{p(S,!1),window.open(Se(wt(t.endpoint),{allowDomains:null}))},children:[e.jsx(Y,{style:{minWidth:24},children:e.jsx(Ve,{fontSize:"small"})}),e.jsx($,{children:x("storage.spaces.strategy.viewBackupFiles")})]}),!n&&r&&e.jsxs(F,{onClick:k,children:[e.jsx(Y,{style:{minWidth:24},children:e.jsx(Je,{fontSize:"small"})}),e.jsx($,{children:x("storage.spaces.connect.switchToSpace")})]}),a&&e.jsxs(F,{onClick:w,children:[e.jsx(Y,{style:{minWidth:24},children:e.jsx(Ze,{fontSize:"small"})}),e.jsx($,{children:x("storage.spaces.connect.abortBlockletBackup")})]}),!a&&e.jsx(Le,{spaceGateway:t,onConfirm:async()=>{l(null),await o?.(t)},onCancel:()=>l(null)})]})]})}Ue.propTypes={spaceGateway:u.shape({name:u.string.isRequired,url:u.string.isRequired,protected:u.bool,endpoint:u.string.isRequired,loading:u.bool}).isRequired,selected:u.bool.isRequired,enableSwitchToSpace:u.bool,onDelete:u.func,onConnect:u.func,backupInProgress:u.bool};const Wt=fe(({className:t,...n})=>e.jsx(ge,{...n,classes:{popper:t}}))(()=>({".MuiTooltip-tooltip":{backgroundColor:"transparent",padding:0,margin:0,boxShadow:"none",maxWidth:"none"},".MuiTooltip-arrow":{color:"rgba(230, 235, 245, 1)"}}));function Me({spaceGateway:t,spaceStatus:n,selected:o,onConnected:s=()=>{},onDeleted:r=()=>{},onBackedUp:a=()=>{}}){const{t:c,locale:i}=D(),{blocklet:d}=O(),{api:l,info:{did:x}}=L(),{appDid:g,appName:m,appDescription:p,scopes:k,appUrl:w,referrer:S}=De({blocklet:d}),{backupProgress:y,updateSpaceGateway:Z,deleteSpaceGateway:ee,refreshBackupSummary:te,refreshBackups:se}=U(),[_,M]=b.useState(!1),[I,P]=b.useState({open:!1,action:"one-click-authorization",checkTimeout:1e3*300,messages:{title:c("storage.spaces.authorize.title",{appName:m},i),scan:c("storage.spaces.authorize.scan",{appName:m},i),confirm:"",success:e.jsx(j,{gutterBottom:!0,children:c("storage.spaces.authorize.success")})},onClose:()=>{P(C=>({...C,open:!1}))}}),ne=o&&!_&&n===de.DISCONNECTED,oe=o&&!_&&!t.loading&&n===de.CONNECTED,G=o&&_&&n===de.CONNECTED&&y?.progress>=0,X=async()=>{try{if(await Bt(t?.endpoint)){await l.configBlocklet({input:{did:[d.meta.did],configs:[{key:N.BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_APP_BACKUP_ENDPOINT,value:t.endpoint}]}}),B.success(c("storage.spaces.connect.switchToSpaceSucceeded",{name:t.name?`(${t.name})`:""})),s?.(null,t);return}}catch(C){console.error(C),s?.(C,t);return}P(C=>({...C,open:!0,prefix:me(t.url,"space/api/did"),baseUrl:new URL(t.url).origin,checkFn:we.create({baseURL:me(t.url,"space")}).get,extraParams:{appDid:g,appName:m,appDescription:p,scopes:k,appUrl:w,referrer:S,nodeDid:x,spaceDid:t.did}}))},ae=async(C,f)=>{const A=f(C.endpoint),R=xe(A),v=C.space?f(C.space):{};if(t.did&&R!==t.did){P(Ne=>({...Ne,open:!1}));const W=c("storage.spaces.gateway.switch.failedForMismatchSpace",{name:v?.name?v.name:""});B.error(W),s?.(new Error(W),t);return}const ce={...t,name:v.name??"DID Space",did:v.did??xe(A),endpoint:A};await Z(ce),P(W=>({...W,open:!1})),s?.(null,ce)},re=async()=>{try{if(_)return;M(!0),await l.backupBlocklet({input:{appDid:d.appDid,to:"spaces"}})}catch(C){console.error(C),B.error(C.message),a?.(C,t)}finally{M(!0)}},ie=async()=>{try{await ee(t),B.success(c("storage.spaces.gateway.delete.succeeded",{name:t.name?`(${t.name})`:""})),r?.(null,t)}catch(C){console.error(C),r?.(C,t)}};return b.useEffect(()=>{y?.completed?(o&&(y?.progress===100?(B.success(c("storage.spaces.backupSuccessfully")),a?.(null,t)):y.message&&a?.(new Error(y?.message),t),y.progress=0,y.message=""),M(!1),te(),se()):y.progress&&M(!0)},[y]),e.jsxs(e.Fragment,{children:[e.jsxs(h,{sx:{display:"flex",alignItems:"center",".action-btn":{borderRadius:1,marginLeft:1}},children:[oe&&e.jsx(le,{className:"action-btn",variant:"outlined",size:"small",onClick:re,children:c("storage.spaces.strategy.backupNow")}),ne&&e.jsx(le,{className:"action-btn",variant:"outlined",size:"small",onClick:X,children:c("storage.spaces.disconnected.reconnectNow")}),G&&e.jsx(Wt,{title:y?.message&&e.jsx(h,{sx:{p:1,borderRadius:1,boxShadow:2,color:"black",backgroundColor:"white"},children:e.jsx(j,{variant:"body2",children:y.message})}),children:e.jsxs(le,{className:"action-btn",variant:"outlined",size:"small",sx:{minWidth:70},children:[e.jsx(z,{variant:"determinate",value:y?.progress,size:14,sx:{mr:1}}),y?.progress,"%"]})}),e.jsx(ot,{forceConnected:!1,saveConnect:!1,prefix:I.prefix,open:I.open,popup:!0,action:I.action,baseUrl:I.baseUrl,checkFn:I.checkFn,onSuccess:ae,onClose:I.onClose,checkTimeout:I.checkTimeout,extraParams:I.extraParams,messages:I.messages,locale:i},"get-endpoint")]}),e.jsx(Ue,{sx:{minWidth:32,padding:"2px 4px",ml:1},spaceGateway:t,selected:o,onDelete:ie,onConnect:X,enableSwitchToSpace:y?.completed||H(y?.message),backupInProgress:G})]})}Me.propTypes={spaceGateway:u.shape({did:u.string.isRequired,name:u.string.isRequired,url:u.string.isRequired,endpoint:u.string.isRequired,protected:u.bool,loading:u.bool}).isRequired,spaceStatus:u.string.isRequired,selected:u.bool.isRequired,onConnected:u.func,onDeleted:u.func,onBackedUp:u.func};function Kt({...t}){const{t:n}=D();return e.jsxs(h,{...t,children:[e.jsx(h,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:3},children:e.jsx(j,{sx:{fontSize:"1.2rem",fontWeight:"bold"},children:n("storage.spaces.backup.records")})}),e.jsx(ve,{}),e.jsx(Oe,{})]})}function Gt({...t}){const{t:n}=D(),{autoBackup:o,updateAutoBackup:s}=U(),r=async()=>{try{const a=!o?.enabled;await s({enabled:a}),B.success(n(a?"storage.spaces.autoBackup.enabled":"storage.spaces.autoBackup.disabled"))}catch(a){B.error(a.message)}};return e.jsx(Tt,{checked:!!o?.enabled,onChange:r,name:"enableWelcomePage",labelProps:{label:e.jsx(j,{sx:{marginRight:"8px"},children:e.jsx("span",{children:n("storage.spaces.autoBackup.title")})})},style:{...t.style}})}function Ft(){const{t}=D(),{spaceGateways:n,spaceGatewaysLoading:o,spaceGatewayIsSelected:s}=U(),r=o&&!n?.length,a=({spaceGateway:c,spaceStatus:i,selected:d,refresh:l})=>e.jsx(Me,{spaceGateway:c,spaceStatus:i,selected:d,onConnected:()=>l(),onBackedUp:x=>x&&l()});return e.jsxs(h,{sx:{display:"flex",flexDirection:"column"},children:[e.jsxs(h,{sx:{display:"flex",flexDirection:{xs:"column",md:"row"},gap:{xs:1,md:2},justifyContent:{xs:"center",md:"flex-start"},alignItems:{xs:"flex-start",md:"center"}},children:[e.jsx(j,{sx:{fontSize:"1.2rem",fontWeight:"bold",flexGrow:1},children:t("storage.spaces.connected.title")}),e.jsx(Gt,{}),e.jsx(Re,{})]}),e.jsx(h,{sx:{mt:2},children:r?e.jsx(h,{sx:{display:"flex",justifyContent:"center"},children:e.jsx(z,{})}):e.jsx(he,{container:!0,spacing:2,children:e.jsx(e.Fragment,{children:n.map(c=>e.jsx(he,{size:{xs:12,md:6},children:e.jsx(ft,{endpoint:c.endpoint,selected:s(c),action:a},c.endpoint)},c.endpoint))})})}),e.jsx(Kt,{sx:{marginTop:"24px"}}),e.jsx(j,{sx:{fontSize:"1.2rem",fontWeight:"bold",mb:2},children:t("common.dataStorage")}),e.jsx(Pe,{})]})}function Yt(){const{spaceGatewaysFirstLoading:t,spaceGateways:n}=U();return t?e.jsx(Be,{relative:"parent",children:e.jsx(z,{})}):H(n)?e.jsx(_t,{}):e.jsx(Ft,{})}function $t(){return e.jsx(Te,{children:e.jsx(Yt,{})})}function qt(){const{spaceGateway:t,settingStorageEndpoint:n,updateSpaceGateway:o,hasStorageEndpoint:s,loading:r,storageEndpoint:a}=Pt(),c=ue(()=>({display:"flex",alignItems:"center",justifyContent:"center",paddingTop:"16px"}));return r?e.jsx(Be,{relative:"parent",children:e.jsx(z,{})}):e.jsxs(h,{sx:{maxWidth:"md",position:"relative"},children:[s?e.jsx(gt,{spaceGateway:t,settingStorageEndpoint:n}):e.jsx(ht,{}),e.jsx(h,{sx:c,children:e.jsx(St,{onConnect:o,storageEndpoint:a})})]})}function Ht(){const{t}=D();return e.jsxs(Rt,{children:[e.jsxs(K,{spacing:1,sx:{marginBottom:2},children:[e.jsx(j,{sx:{fontSize:"1.2rem",fontWeight:"bold"},children:t("storage.appLevel.title")}),e.jsx(j,{sx:{color:"text.secondary"},children:t("storage.appLevel.description")})]}),e.jsx(qt,{})]})}function Qt({navOrientation:t="vertical",...n}){const{t:o,locale:s}=D(),{blocklet:r}=O(),a=lt({key:"md"}),[c,i]=et(),d=c.get("tab")||"backup",l=a?"horizontal":t,x=ue(()=>{const w=[{label:o("common.backup"),value:"backup"}],S=r?.capabilities?.didSpace;return(S===N.BLOCKLET_APP_SPACE_REQUIREMENT.REQUIRED||S===N.BLOCKLET_APP_SPACE_REQUIREMENT.REQUIRED_ON_SETUP)&&w.push({label:o("common.storage"),value:"storage"}),w},[s,l]),m=ue(()=>({backup:e.jsx($t,{}),storage:e.jsx(Ht,{})}))[d],p=w=>{i(S=>(w==="backup"?S.delete("tab"):S.set("tab",w),S))};if(x.length<=1)return e.jsx(pe,{children:m});const k=e.jsx(ct,{tabs:x,current:d,orientation:l,onChange:p,sx:[{borderRight:1,height:"100%",borderColor:"divider"},l==="horizontal"&&{borderRight:0}]});if(l==="vertical")return e.jsx(h,{...n,children:e.jsxs(K,{direction:{md:"column",lg:"row"},sx:{gap:2},children:[e.jsx(h,{sx:{flexShrink:0},children:e.jsx(ye,{left:k})}),e.jsx(h,{sx:{flexGrow:1,minWidth:0},children:e.jsx(pe,{sx:{mt:1},children:m})})]})});if(l==="horizontal")return e.jsxs(h,{...n,children:[e.jsx(ye,{left:k}),e.jsx(pe,{sx:{mt:2},children:m})]})}Qt.propTypes={navOrientation:u.oneOf(["vertical","horizontal"])};const pe=fe(h)`
3
3
  position: relative;
4
4
  min-height: 66vh;
@@ -1,6 +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-BPQ6AEW_.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-D507n6h6.js";import{r as C,i as qe,k as At}from"./vendor-react-CUXIiAnY.js";import{g as G,b as j,k as Ue,a as Wt,v as Lt,q as Nt,c as Bt}from"./vendor-hooks-fhL5FJET.js";import{ar as ie,at as ae,c as Pe,_ as He,aA as _t,as as ue,Y as qt,b6 as Ut,o as Ht}from"./index-Cx5JU0Ln.js";import{u as Fe}from"./team-CG74iq-4.js";import{u as $e}from"./use-mobile-ajdJIsoX.js";import{A as Ft}from"./actions-DhSvOHy-.js";import{u as Je}from"./session-CAOgTWka.js";import{f as E}from"./index-DBs9Ljax.js";import{v as Ce}from"./index-Ca4Ccmqm.js";import{e as Ve,A as $t,n as te}from"./vendor-utils-BSZ4yJws.js";import{F as Ae}from"./form-text-input-BFJU5Psq.js";import{e as Jt}from"./edit.svg-Dz9cVo7r.js";import{C as Vt}from"./lock.svg-BPCZ0CT3.js";import{D as Kt,a as Gt,b as Xt,M as Qt}from"./index-CG-mH6e1.js";import{c as Yt}from"./passport-Dsw-sETA.js";import{C as Zt}from"./click-to-copy-CAd3nEo4.js";import{I as er}from"./invitations-sELORD_h.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)`
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-BPQ6AEW_.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-r9bApERu.js";import{r as C,i as qe,k as At}from"./vendor-react-CUXIiAnY.js";import{g as G,b as j,k as Ue,a as Wt,v as Lt,q as Nt,c as Bt}from"./vendor-hooks-PN9SWiQm.js";import{ar as ie,at as ae,c as Pe,_ as He,aA as _t,as as ue,Y as qt,b6 as Ut,o as Ht}from"./index-jPmRCtiq.js";import{u as Fe}from"./team-Caq5y5Xs.js";import{u as $e}from"./use-mobile-ajdJIsoX.js";import{A as Ft}from"./actions-DhSvOHy-.js";import{u as Je}from"./session-L__eR8rN.js";import{f as E}from"./index-DBs9Ljax.js";import{v as Ce}from"./index-ySP_m_Ux.js";import{e as Ve,A as $t,n as te}from"./vendor-utils-BgSaqjGx.js";import{F as Ae}from"./form-text-input-Sp9mVO8Z.js";import{e as Jt}from"./edit.svg-Dz9cVo7r.js";import{C as Vt}from"./lock.svg-BPCZ0CT3.js";import{D as Kt,a as Gt,b as Xt,M as Qt}from"./index-BmFAdUmE.js";import{c as Yt}from"./passport-DnUeoVIR.js";import{C as Zt}from"./click-to-copy-BuSTGPjJ.js";import{I as er}from"./invitations-DgB-ff90.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
2
  font-weight: 500;
3
3
  .MuiButton-icon {
4
4
  margin-right: 4px;
5
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};
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>64){b(g("team.orgs.validate.nameTooLong",{length:64}));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{W as o,j as n,ak as h,f as y,bh as q,av as w,D as I}from"./vendor-mui-core-BPQ6AEW_.js";import{r as $}from"./vendor-react-CUXIiAnY.js";import{l as k,a3 as W,V as A,m as B,K as H}from"./vendor-ux-D507n6h6.js";import{aX as Y,aY as V,aZ as Z,a_ as C,k as K,a$ as P,b0 as X,b1 as G,am as J,b2 as N,b3 as Q}from"./index-Cx5JU0Ln.js";import{Y as U,I as ee,Z as ne}from"./vendor-utils-BSZ4yJws.js";import{a as oe}from"./vendor-hooks-fhL5FJET.js";function z({name:e="",logo:t="",description:i="",...c}){if(!e&&!t&&!i)return null;const d=$.isValidElement(t)?t:n.jsx("img",{src:t,alt:e});return n.jsxs(te,{...c,children:[n.jsxs("div",{children:[t&&n.jsx(h,{component:"a",href:"/",className:"footer-brand-logo",children:d}),e&&n.jsx("div",{className:"footer-brand-name",children:e})]}),i&&n.jsx("div",{className:"footer-brand-desc",children:i})]})}z.propTypes={name:o.node,logo:o.node,description:o.string};const te=k("div")`
1
+ import{W as o,j as n,ak as h,f as y,bh as q,av as w,D as I}from"./vendor-mui-core-BPQ6AEW_.js";import{r as $}from"./vendor-react-CUXIiAnY.js";import{l as k,a3 as W,V as A,m as B,K as H}from"./vendor-ux-r9bApERu.js";import{aX as Y,aY as V,aZ as Z,a_ as C,k as K,a$ as P,b0 as X,b1 as G,am as J,b2 as N,b3 as Q}from"./index-jPmRCtiq.js";import{Y as U,I as ee,Z as ne}from"./vendor-utils-BgSaqjGx.js";import{a as oe}from"./vendor-hooks-PN9SWiQm.js";function z({name:e="",logo:t="",description:i="",...c}){if(!e&&!t&&!i)return null;const d=$.isValidElement(t)?t:n.jsx("img",{src:t,alt:e});return n.jsxs(te,{...c,children:[n.jsxs("div",{children:[t&&n.jsx(h,{component:"a",href:"/",className:"footer-brand-logo",children:d}),e&&n.jsx("div",{className:"footer-brand-name",children:e})]}),i&&n.jsx("div",{className:"footer-brand-desc",children:i})]})}z.propTypes={name:o.node,logo:o.node,description:o.string};const te=k("div")`
2
2
  display: flex;
3
3
  flex-direction: column;
4
4
  font-size: 14px;
@@ -1,4 +1,4 @@
1
- import{V as ee,H as B,U as X,a7 as Ee,a8 as Ue,a9 as We,aa as Ve,p as K,J as je,b as ke,n as z,ab as Me,h as _e,i as Ne,j as Ie}from"./vendor-ux-D507n6h6.js";import{b as u,a as H,g as ie,c as $e}from"./vendor-hooks-fhL5FJET.js";import{r as C}from"./vendor-react-CUXIiAnY.js";import{j as e,ak as r,b6 as R,am as ce,y as O,z as F,Q as V,T as Y,I as le,a3 as oe,W as E,b1 as W,bb as qe,cb as Le,cE as He,at as Fe,D as ye,ah as Oe,cF as Be,a6 as be,cG as Je,a$ as Ze}from"./vendor-mui-core-BPQ6AEW_.js";import{_ as N,ac as M,Y as G,bc as se,c as ve,b7 as Ke,aA as Ge,Z as Ye}from"./index-Cx5JU0Ln.js";import{A as Z,Q as Qe,b as de,Z as Xe,n as Q,$ as et,C as tt,a as nt}from"./vendor-utils-BSZ4yJws.js";import{u as te,C as k,a as Ce}from"./index.esm-DTmS4tth.js";import{S as re}from"./switch-control-BFsTsyuN.js";import{S as y}from"./section-Cyr0YvGa.js";import{d as st}from"./keyboard-arrow-down-rounded-8U0_i9QO.js";import{u as ot}from"./index-C3cD5fjJ.js";import{v as it}from"./index-Ca4Ccmqm.js";import{r as rt}from"./base32-CnxuWLTI.js";import{C as at}from"./click-to-copy-CAd3nEo4.js";import{u as lt}from"./use-mobile-ajdJIsoX.js";import"./lottie-web-4koyQiv_.js";import"./vendor-arcblock-BL_VyzmH.js";import"./required-Btg6mEmX.js";const we={width:24,height:24,body:'<path fill="currentColor" d="M5 4v16V4v5v-5Zm3 10h2.675q.275-.575.638-1.075t.812-.925H8q-.425 0-.713.288T7 13q0 .425.288.713T8 14Zm0 4h2.075Q10 17.5 10 17t.075-1H8q-.425 0-.713.288T7 17q0 .425.288.713T8 18Zm-3 4q-.825 0-1.413-.588T3 20V4q0-.825.588-1.413T5 2h7.175q.4 0 .763.15t.637.425l4.85 4.85q.275.275.425.638t.15.762V10.3q-.475-.15-.975-.225T17 10V9h-4q-.425 0-.713-.288T12 8V4H5v16h5.675q.275.575.638 1.075t.812.925H5Zm12-10q2.075 0 3.538 1.463T22 17q0 2.075-1.463 3.538T17 22q-2.075 0-3.538-1.463T12 17q0-2.075 1.463-3.538T17 12Zm0 8q.275 0 .463-.188t.187-.462q0-.275-.187-.463T17 18.7q-.275 0-.463.188t-.187.462q0 .275.188.463T17 20Zm0-6q-.475 0-.875.238t-.65.637q-.1.15-.025.313t.25.237q.15.075.3 0t.275-.2q.125-.175.313-.275t.412-.1q.325 0 .563.213t.237.537q0 .275-.15.463t-.35.387q-.15.15-.313.3t-.287.35q-.075.15-.113.313t-.037.337q0 .225.125.413t.325.187q.2 0 .325-.15t.125-.35q0-.275.15-.488t.35-.412q.3-.275.525-.613t.225-.737q0-.675-.5-1.138T17 14Z"/>'},ue={enabled:!1,domain:"",clientId:"",clientSecret:""};function ct(){const{api:b}=N(),{blocklet:c}=M(),{t,locale:n}=ee(),o=c?.meta?.did,a=Object.assign({...ue},c?.settings?.oauth?.auth0||{}),{handleSubmit:x,control:i,formState:p,watch:d,reset:f}=te({defaultValues:Z(a,Object.keys(ue))}),l=d("enabled"),j=u(async s=>{try{const{blocklet:I}=await b.configOAuth({input:{did:o,oauth:JSON.stringify({auth0:s})}}),L=Object.assign({...ue},I?.settings?.oauth?.auth0||{});f(L),B.success(t("oauth.saveSuccess"))}catch(I){B.error(I.message||t("oauth.saveFailed"))}}),v=u(s=>s?.trim()?!0:t("oauth.auth0.domainDescription")),S=u(s=>s?.trim()?!0:t("oauth.auth0.clientIdDescription")),g=u(s=>s?.trim()?!0:t("oauth.auth0.clientSecretDescription")),w=u(()=>!0),h=H(()=>n==="zh"?"https://www.arcblock.io/blog/docs/did-connect/zh/oauth-config-auth0":"https://www.arcblock.io/blog/docs/did-connect/en/oauth-config-auth0",[n]);return e.jsx(r,{children:e.jsxs("form",{onSubmit:x(j),disabled:!0,children:[e.jsx(y,{title:e.jsxs(r,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx("span",{children:t("oauth.auth0.enable")}),e.jsx(ce,{title:t("oauth.viewDocument"),children:e.jsx(r,{component:"a",sx:{display:"inline-block",color:"inherit",fontSize:0,lineHeight:1},href:h,target:"_blank",rel:"noreferrer",children:e.jsx(X,{icon:we,fontSize:20})})})]}),mb:2.5,children:e.jsx(k,{name:"enabled",control:i,render:({field:s})=>e.jsx(R,{control:e.jsx(re,{sx:{ml:1},checked:s.value,...s})})})}),e.jsx(y,{title:t("oauth.auth0.domain"),children:e.jsx(k,{name:"domain",control:i,rules:{validate:l?v:w},render:({field:s})=>e.jsx(O,{fullWidth:!0,children:e.jsx(F,{...s,size:"small",label:t("oauth.auth0.domain"),error:!!p.errors[s.name],helperText:p.errors[s.name]?.message||" ",disabled:!l})})})}),e.jsx(y,{title:t("oauth.auth0.clientId"),children:e.jsx(k,{name:"clientId",control:i,rules:{validate:l?S:w},render:({field:s})=>e.jsx(O,{fullWidth:!0,children:e.jsx(F,{...s,size:"small",label:t("oauth.auth0.clientId"),error:!!p.errors[s.name],helperText:p.errors[s.name]?.message||" ",disabled:!l})})})}),e.jsx(y,{title:t("oauth.auth0.clientSecret"),children:e.jsx(k,{name:"clientSecret",control:i,rules:{validate:l?g:w},render:({field:s})=>e.jsx(O,{fullWidth:!0,children:e.jsx(F,{...s,size:"small",type:"password",label:t("oauth.auth0.clientSecret"),error:!!p.errors[s.name],helperText:p.errors[s.name]?.message||" ",disabled:!l})})})}),e.jsx(V,{type:"submit",variant:"contained",onSubmit:x(j),disabled:!p.isDirty,children:t("oauth.save")})]})})}const he={enabled:!1,clientId:"",clientSecret:""};function dt(){const{api:b}=N(),{blocklet:c}=M(),{t,locale:n}=ee(),o=c?.meta?.did,a=Object.assign({...he},c?.settings?.oauth?.github||{}),{handleSubmit:x,control:i,formState:p,watch:d,reset:f}=te({defaultValues:Z(a,Object.keys(he))}),l=d("enabled"),j=u(async h=>{try{const{blocklet:s}=await b.configOAuth({input:{did:o,oauth:JSON.stringify({github:h})}}),I=Object.assign({...he},s?.settings?.oauth?.github||{});f(I),B.success(t("oauth.saveSuccess"))}catch(s){B.error(s.message||t("oauth.saveFailed"))}}),v=u(h=>h?.trim()?!0:t("oauth.github.clientIdDescription")),S=u(h=>h?.trim()?!0:t("oauth.github.clientSecretDescription")),g=u(()=>!0),w=H(()=>n==="zh"?"https://www.arcblock.io/blog/docs/did-connect/zh/oauth-config-github":"https://www.arcblock.io/blog/docs/did-connect/en/oauth-config-github",[n]);return e.jsx(r,{children:e.jsxs("form",{onSubmit:x(j),disabled:!0,children:[e.jsx(y,{title:e.jsxs(r,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx("span",{children:t("oauth.github.enable")}),e.jsx(ce,{title:t("oauth.viewDocument"),children:e.jsx(r,{component:"a",sx:{display:"inline-block",color:"inherit",fontSize:0,lineHeight:1},href:w,target:"_blank",rel:"noreferrer",children:e.jsx(X,{icon:we,fontSize:20})})})]}),mb:2.5,sx:{"& .section-content":{alignItems:"center"}},children:e.jsx(k,{name:"enabled",control:i,sx:{alignItems:"center"},render:({field:h})=>e.jsx(R,{control:e.jsx(re,{sx:{ml:1},size:"small",checked:h.value,...h})})})}),e.jsx(y,{title:t("oauth.github.clientId"),children:e.jsx(k,{name:"clientId",control:i,rules:{validate:l?v:g},render:({field:h})=>e.jsx(O,{fullWidth:!0,children:e.jsx(F,{...h,size:"small",label:t("oauth.github.clientId"),error:!!p.errors[h.name],helperText:p.errors[h.name]?.message||" ",disabled:!l})})})}),e.jsx(y,{title:t("oauth.github.clientSecret"),children:e.jsx(k,{name:"clientSecret",control:i,rules:{validate:l?S:g},render:({field:h})=>e.jsx(O,{fullWidth:!0,children:e.jsx(F,{...h,size:"small",type:"password",label:t("oauth.github.clientSecret"),error:!!p.errors[h.name],helperText:p.errors[h.name]?.message||" ",disabled:!l})})})}),e.jsx(V,{type:"submit",variant:"contained",onSubmit:x(j),disabled:!p.isDirty,children:t("oauth.save")})]})})}const me={enabled:!1,clientId:"",clientSecret:""};function ut(){const{api:b}=N(),{blocklet:c}=M(),{t,locale:n}=ee(),o=c?.meta?.did,a=Object.assign({...me},c?.settings?.oauth?.google||{}),{handleSubmit:x,control:i,formState:p,watch:d,reset:f}=te({defaultValues:Z(a,Object.keys(me))}),l=d("enabled"),j=u(async h=>{try{const{blocklet:s}=await b.configOAuth({input:{did:o,oauth:JSON.stringify({google:h})}}),I=Object.assign({...me},s?.settings?.oauth?.google||{});f(I),B.success(t("oauth.saveSuccess"))}catch(s){B.error(s.message||t("oauth.saveFailed"))}}),v=u(h=>h?.trim()?!0:t("oauth.google.clientIdDescription")),S=u(h=>h?.trim()?!0:t("oauth.google.clientSecretDescription")),g=u(()=>!0),w=H(()=>n==="zh"?"https://www.arcblock.io/blog/docs/did-connect/zh/oauth-config-google":"https://www.arcblock.io/blog/docs/did-connect/en/oauth-config-google",[n]);return e.jsx(r,{children:e.jsxs("form",{onSubmit:x(j),disabled:!0,children:[e.jsx(y,{title:e.jsxs(r,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx("span",{children:t("oauth.google.enable")}),e.jsx(ce,{title:t("oauth.viewDocument"),children:e.jsx(r,{component:"a",sx:{display:"inline-block",color:"inherit",fontSize:0,lineHeight:1},href:w,target:"_blank",rel:"noreferrer",children:e.jsx(X,{icon:we,fontSize:20})})})]}),mb:2.5,children:e.jsx(k,{name:"enabled",control:i,render:({field:h})=>e.jsx(R,{control:e.jsx(re,{sx:{ml:1},checked:h.value,...h})})})}),e.jsx(y,{title:t("oauth.google.clientId"),children:e.jsx(k,{name:"clientId",control:i,rules:{validate:l?v:g},render:({field:h})=>e.jsx(O,{fullWidth:!0,children:e.jsx(F,{...h,size:"small",label:t("oauth.google.clientId"),error:!!p.errors[h.name],helperText:p.errors[h.name]?.message||" ",disabled:!l})})})}),e.jsx(y,{title:t("oauth.google.clientSecret"),children:e.jsx(k,{name:"clientSecret",control:i,rules:{validate:l?S:g},render:({field:h})=>e.jsx(O,{fullWidth:!0,children:e.jsx(F,{...h,size:"small",type:"password",label:t("oauth.google.clientSecret"),error:!!p.errors[h.name],helperText:p.errors[h.name]?.message||" ",disabled:!l})})})}),e.jsx(V,{type:"submit",variant:"contained",onSubmit:x(j),disabled:!p.isDirty,children:t("oauth.save")})]})})}const pe={enabled:!1,teamId:"",serviceId:"",keyId:"",authKey:"",bundleId:""};function ht(){const{api:b}=N(),{blocklet:c}=M(),{t}=ee(),n=c?.meta?.did,o=Object.assign({...pe},c?.settings?.oauth?.apple||{}),{handleSubmit:a,control:x,formState:i,watch:p,reset:d}=te({defaultValues:Z(o,Object.keys(pe))}),f=p("enabled"),l=u(async s=>{try{const{blocklet:I}=await b.configOAuth({input:{did:n,oauth:JSON.stringify({apple:s})}}),L=Object.assign({...pe},I?.settings?.oauth?.apple||{});d(L),B.success(t("oauth.saveSuccess"))}catch(I){B.error(I.message||t("oauth.saveFailed"))}}),j=u(s=>s?.trim()?!0:t("oauth.apple.teamIdDescription")),v=u(s=>s?.trim()?!0:t("oauth.apple.serviceIdDescription")),S=u(s=>s?.trim()?!0:t("oauth.apple.keyIdDescription")),g=u(s=>s?.trim()?!0:t("oauth.apple.authKeyDescription")),w=u(s=>s?.trim()?!0:t("oauth.apple.bundleIdDescription")),h=u(()=>!0);return e.jsx(r,{children:e.jsxs("form",{onSubmit:a(l),disabled:!0,children:[e.jsx(y,{title:t("oauth.apple.enable"),mb:2.5,children:e.jsx(k,{name:"enabled",control:x,render:({field:s})=>e.jsx(R,{control:e.jsx(re,{sx:{ml:1},checked:s.value,...s})})})}),e.jsx(y,{title:t("oauth.apple.teamId"),children:e.jsx(k,{name:"teamId",control:x,rules:{validate:f?j:h},render:({field:s})=>e.jsx(O,{fullWidth:!0,children:e.jsx(F,{...s,size:"small",label:t("oauth.apple.teamId"),error:!!i.errors[s.name],helperText:i.errors[s.name]?.message||" ",disabled:!f})})})}),e.jsx(y,{title:t("oauth.apple.bundleId"),children:e.jsx(k,{name:"bundleId",control:x,rules:{validate:f?w:h},render:({field:s})=>e.jsx(O,{fullWidth:!0,children:e.jsx(F,{...s,size:"small",label:t("oauth.apple.bundleId"),error:!!i.errors[s.name],helperText:i.errors[s.name]?.message||" ",disabled:!f})})})}),e.jsx(y,{title:t("oauth.apple.serviceId"),children:e.jsx(k,{name:"serviceId",control:x,rules:{validate:f?v:h},render:({field:s})=>e.jsx(O,{fullWidth:!0,children:e.jsx(F,{...s,size:"small",label:t("oauth.apple.serviceId"),error:!!i.errors[s.name],helperText:i.errors[s.name]?.message||" ",disabled:!f})})})}),e.jsx(y,{title:t("oauth.apple.keyId"),children:e.jsx(k,{name:"keyId",control:x,rules:{validate:f?S:h},render:({field:s})=>e.jsx(O,{fullWidth:!0,children:e.jsx(F,{...s,size:"small",label:t("oauth.apple.keyId"),error:!!i.errors[s.name],helperText:i.errors[s.name]?.message||" ",disabled:!f})})})}),e.jsx(y,{title:t("oauth.apple.authKey"),children:e.jsx(k,{name:"authKey",control:x,rules:{validate:f?g:h},render:({field:s})=>e.jsx(O,{fullWidth:!0,children:e.jsx(F,{...s,size:"small",type:"password",label:t("oauth.apple.authKey"),multiline:!0,rows:4,error:!!i.errors[s.name],helperText:i.errors[s.name]?.message||" ",disabled:!f})})})}),e.jsx(V,{type:"submit",variant:"contained",onSubmit:a(l),disabled:!i.isDirty,children:t("oauth.save")})]})})}const xe={enabled:!1,clientId:"",clientSecret:""};function mt(){const{api:b}=N(),{blocklet:c}=M(),{t}=ee(),n=c?.meta?.did,o=Object.assign({...xe},c?.settings?.oauth?.twitter||{}),{handleSubmit:a,control:x,formState:i,watch:p,reset:d}=te({defaultValues:Z(o,Object.keys(xe))}),f=p("enabled"),l=u(async g=>{try{const{blocklet:w}=await b.configOAuth({input:{did:n,oauth:JSON.stringify({twitter:g})}}),h=Object.assign({...xe},w?.settings?.oauth?.twitter||{});d(h),B.success(t("oauth.saveSuccess"))}catch(w){B.error(w.message||t("oauth.saveFailed"))}}),j=u(g=>g?.trim()?!0:t("oauth.twitter.clientIdDescription")),v=u(g=>g?.trim()?!0:t("oauth.twitter.clientSecretDescription")),S=u(()=>!0);return e.jsx(r,{children:e.jsxs("form",{onSubmit:a(l),disabled:!0,children:[e.jsx(y,{title:e.jsx(r,{sx:{display:"flex",alignItems:"center",gap:1},children:e.jsx("span",{children:t("oauth.twitter.enable")})}),mb:2.5,sx:{"& .section-content":{alignItems:"center"}},children:e.jsx(k,{name:"enabled",control:x,sx:{alignItems:"center"},render:({field:g})=>e.jsx(R,{control:e.jsx(re,{sx:{ml:1},size:"small",checked:g.value,...g})})})}),e.jsx(y,{title:t("oauth.twitter.clientId"),children:e.jsx(k,{name:"clientId",control:x,rules:{validate:f?j:S},render:({field:g})=>e.jsx(O,{fullWidth:!0,children:e.jsx(F,{...g,size:"small",label:t("oauth.twitter.clientId"),error:!!i.errors[g.name],helperText:i.errors[g.name]?.message||" ",disabled:!f})})})}),e.jsx(y,{title:t("oauth.twitter.clientSecret"),children:e.jsx(k,{name:"clientSecret",control:x,rules:{validate:f?v:S},render:({field:g})=>e.jsx(O,{fullWidth:!0,children:e.jsx(F,{...g,size:"small",type:"password",label:t("oauth.twitter.clientSecret"),error:!!i.errors[g.name],helperText:i.errors[g.name]?.message||" ",disabled:!f})})})}),e.jsx(V,{type:"submit",variant:"contained",onSubmit:a(l),disabled:!i.isDirty,children:t("oauth.save")})]})})}const pt={width:24,height:24,body:'<path fill="currentColor" d="M9 20q-.825 0-1.413-.588T7 18q0-.825.588-1.413T9 16q.825 0 1.413.588T11 18q0 .825-.588 1.413T9 20Zm6 0q-.825 0-1.413-.588T13 18q0-.825.588-1.413T15 16q.825 0 1.413.588T17 18q0 .825-.588 1.413T15 20Zm-6-6q-.825 0-1.413-.588T7 12q0-.825.588-1.413T9 10q.825 0 1.413.588T11 12q0 .825-.588 1.413T9 14Zm6 0q-.825 0-1.413-.588T13 12q0-.825.588-1.413T15 10q.825 0 1.413.588T17 12q0 .825-.588 1.413T15 14ZM9 8q-.825 0-1.413-.588T7 6q0-.825.588-1.413T9 4q.825 0 1.413.588T11 6q0 .825-.588 1.413T9 8Zm6 0q-.825 0-1.413-.588T13 6q0-.825.588-1.413T15 4q.825 0 1.413.588T17 6q0 .825-.588 1.413T15 8Z"/>'};function Re({id:b,title:c,children:t,index:n,onMove:o,defaultExpand:a=!1,onEnd:x,icon:i=null}){const[p,d]=C.useState(a),f=C.useRef(null),l=C.useRef(null),[{handlerId:j},v]=Ee({accept:"dragItem",collect(s){return{handlerId:s.getHandlerId()}},hover(s,I){if(!f.current)return;const L=s.index,m=n;if(L===m)return;const A=f.current?.getBoundingClientRect(),_=l.current?.getBoundingClientRect(),ae=(_.bottom-_.top)/2,$=I.getClientOffset().y-A.top;L<m&&$<ae||L>m&&$>ae||(o(L,m),s.index=m)}}),[{isDragging:S},g]=Ue({item:{index:n,type:"dragItem"},collect:s=>({isDragging:s.isDragging()}),end:x});g(l),v(f);const w=S?.5:1,h=u(s=>{s.preventDefault(),s.stopPropagation(),d(!p)});return e.jsxs(r,{ref:f,children:[e.jsxs(r,{sx:{cursor:"pointer","&:hover":{backgroundColor:"grey.100"}},ref:l,"data-handler-id":j,children:[e.jsxs(r,{sx:{py:2,px:1,opacity:w,display:"flex",alignItems:"center",gap:.5},draggable:!1,onClick:h,children:[e.jsx(r,{sx:{pointerEvents:"auto",cursor:"grab","&:active":{cursor:"grabbing"},fontSize:0,color:"text.hint","&:hover":{color:"text.secondary"}},children:e.jsx(X,{fontSize:20,icon:pt})}),e.jsx(r,{sx:{display:"flex",alignItems:"center",flexShrink:0,mr:.5,transform:"translateY(-1px)"},children:i}),e.jsx(Y,{sx:{flex:1},children:c}),e.jsx(le,{size:"small",sx:{pointerEvents:"auto",transform:p?"":"rotate(180deg)",transition:"transform 0.3s ease"},children:e.jsx(X,{icon:st,style:{transform:"scale(1.5)"}})})]}),e.jsx(oe,{})]}),e.jsx(r,{sx:{pl:4,py:2.5,display:p?"block":"none"},children:t})]})}Re.propTypes={title:E.string.isRequired,id:E.string.isRequired,children:E.node.isRequired,index:E.number.isRequired,onMove:E.func.isRequired,onEnd:E.func.isRequired,defaultExpand:E.bool,icon:E.any};const xt=[{name:"github",title:G.PROVIDER_NAME.github,icon:e.jsx(se,{provider:"github",sx:{width:20,height:20}}),component:e.jsx(dt,{})},{name:"google",title:G.PROVIDER_NAME.google,icon:e.jsx(se,{provider:"google",sx:{width:20,height:20}}),component:e.jsx(ut,{})},{name:"apple",title:G.PROVIDER_NAME.apple,icon:e.jsx(se,{provider:"apple",sx:{width:20,height:20}}),component:e.jsx(ht,{})},{name:"twitter",title:G.PROVIDER_NAME.twitter,icon:e.jsx(se,{provider:"twitter",sx:{width:20,height:20}}),component:e.jsx(mt,{})},{name:"auth0",title:G.PROVIDER_NAME.auth0,icon:e.jsx(se,{provider:"auth0",sx:{width:20,height:20}}),component:e.jsx(ct,{})}],ft=["github","google","apple","twitter","auth0"];function gt(){const{api:b}=N(),{blocklet:c}=M(),t=c?.meta?.did,n=c?.settings?.oauth||{},o=Object.keys(n).sort((l,j)=>n[l]?.order!==void 0&&n[j]?.order!==void 0?n[l].order-n[j].order:n[l]?.order!==void 0?-1:1);for(const l of ft)o.includes(l)||o.push(l);const a=ie(o.reduce((l,j,v)=>Object.assign(l,{[j]:v}),{})),x=H(()=>{const l=[...xt];return l.sort((j,v)=>a[j.name]-a[v.name]),l.map(j=>({...j,enabled:n[j.name]?.enabled??!1}))},[a.auth0,a.github,a.google]),i={};typeof window<"u"&&(i.context=window);const p=u(async l=>{const j={};Object.keys(l).forEach(v=>{j[v]={order:l[v]}}),await b.configOAuth({input:{did:t,oauth:JSON.stringify(j)}})}),d=u((l,j)=>{const v=x[l],S=x[j];a[v.name]=j,a[S.name]=l}),f=u(async()=>{await p(a)});return e.jsx(r,{sx:{".section-left":{width:"180px"}},children:e.jsx(We,{backend:Ve,...i,children:x.map((l,j)=>e.jsx(Re,{index:j,id:l.name,title:l.title,icon:l.icon,onMove:d,onEnd:f,defaultExpand:l.enabled,children:l.component},l.name))})})}const J={ttl:ve.SESSION_TTL,cacheTtl:ve.SESSION_CACHE_TTL,email:{enabled:!1,requireVerified:!1,requireUnique:!1,trustOauthProviders:!1,trustedIssuers:[],enableDomainBlackList:!1,domainBlackList:[],enableDomainWhiteList:!1,domainWhiteList:[]},phone:{enabled:!1,requireVerified:!1,requireUnique:!1,regionBlackList:[],trustedIssuers:[]},enableBlacklist:!1};function U(b){return e.jsx(ot,{...b,sx:{transform:"scale(0.75)"}})}function fe(b,c=!1){const t=c?b.ttl*86400:b.ttl/86400;return{...b,ttl:t}}function jt(){const{api:b}=N(),{blocklet:c}=M(),t=c?.meta?.did,n=Qe({},J,c?.settings?.session||{});de(n.ttl)&&(n.ttl=J.ttl),de(n.cacheTtl)&&(n.cacheTtl=J.cacheTtl),n.phone||(n.phone=J.phone),n.email||(n.email=J.email),de(n.enableBlacklist)&&(n.enableBlacklist=J.enableBlacklist);const{handleSubmit:o,control:a,formState:x,reset:i,watch:p}=te({defaultValues:Z(fe(n),["ttl","cacheTtl","email","phone","enableBlacklist"])}),{t:d}=ee(),f=p("email.enabled"),l=p("phone.enabled"),j=p("email.enableDomainBlackList"),v=p("email.enableDomainWhiteList"),{fields:S,append:g,remove:w}=Ce({control:a,name:"email.domainBlackList"}),{fields:h,append:s,remove:I}=Ce({control:a,name:"email.domainWhiteList"}),L=u(async m=>{try{const{blocklet:A}=await b.updateAppSessionConfig({input:{did:t,config:Xe(fe(m,!0),["phone"])}}),_=Object.assign({},J,Z(A?.settings?.session||{},["ttl","cacheTtl","email","phone","enableBlacklist"]));i(fe(_)),B.success(d("common.configSuccess"))}catch(A){B.error(A.message)}});return e.jsx(bt,{onSubmit:o(L),children:e.jsxs(W,{direction:"column",sx:{gap:6},children:[e.jsxs(r,{children:[e.jsxs(r,{children:[e.jsx(Y,{variant:"h6",sx:{fontWeight:600},children:d("blocklet.config.session.profile")}),e.jsx(r,{component:oe,sx:{my:3}})]}),e.jsxs(W,{sx:{gap:2},children:[e.jsx(y,{title:d("blocklet.config.session.fullNameEnabled"),sectionLeftSx:{width:"600px"},children:e.jsx(r,{sx:{alignSelf:"flex-start"},children:e.jsx(U,{disabled:!0,checked:!0})})}),e.jsx(y,{title:d("blocklet.config.session.avatarEnabled"),sectionLeftSx:{width:"600px"},children:e.jsx(r,{sx:{alignSelf:"flex-start"},children:e.jsx(U,{disabled:!0,checked:!0})})}),e.jsx(y,{title:d("blocklet.config.session.emailEnabled"),sectionLeftSx:{width:"600px"},children:e.jsx(r,{sx:{alignSelf:"flex-start"},children:e.jsx(k,{name:"email.enabled",control:a,render:({field:m})=>e.jsx(U,{...m,checked:m.value})})})}),f&&e.jsxs(W,{direction:"column",sx:{ml:2,gap:.5},children:[e.jsx(y,{title:d("blocklet.config.session.emailRequireVerified"),sectionLeftSx:{width:"600px"},children:e.jsx(r,{sx:{alignSelf:"flex-start"},children:e.jsx(k,{name:"email.requireVerified",control:a,render:({field:m})=>e.jsx(R,{sx:{ml:0},control:e.jsx(U,{...m,checked:m.value})})})})}),e.jsx(y,{title:d("blocklet.config.session.emailRequireUnique"),sectionLeftSx:{width:"600px"},children:e.jsx(r,{sx:{alignSelf:"flex-start"},children:e.jsx(k,{name:"email.requireUnique",control:a,render:({field:m})=>e.jsx(R,{sx:{ml:0},control:e.jsx(U,{...m,checked:m.value})})})})}),e.jsx(y,{title:d("blocklet.config.session.emailTrustOauthProviders"),sectionLeftSx:{width:"600px"},children:e.jsx(r,{sx:{alignSelf:"flex-start"},children:e.jsx(k,{name:"email.trustOauthProviders",control:a,render:({field:m})=>e.jsx(R,{sx:{ml:0},control:e.jsx(U,{...m,checked:m.value})})})})}),e.jsx(y,{title:d("blocklet.config.session.enableDomainBlackList"),sectionLeftSx:{width:"600px"},children:e.jsx(r,{sx:{alignSelf:"flex-start"},children:e.jsx(k,{name:"email.enableDomainBlackList",control:a,render:({field:m})=>e.jsx(R,{sx:{ml:0},control:e.jsx(U,{...m,checked:m.value})})})})}),j&&e.jsxs(r,{children:[S.map((m,A)=>e.jsxs(W,{direction:"row",sx:{alignItems:"center",my:1,maxWidth:"720px"},children:[e.jsx(k,{name:`email.domainBlackList.${A}`,control:a,render:_=>e.jsx(F,{..._.field,size:"small",fullWidth:!0})}),e.jsx(le,{onClick:()=>w(A),children:e.jsx(qe,{})})]},m.id)),e.jsx(V,{startIcon:e.jsx(Le,{}),onClick:()=>g(""),children:d("blocklet.config.session.addDomain")})]}),e.jsx(y,{title:d("blocklet.config.session.enableDomainWhiteList"),sectionLeftSx:{width:"600px"},children:e.jsx(r,{sx:{alignSelf:"flex-start"},children:e.jsx(k,{name:"email.enableDomainWhiteList",control:a,render:({field:m})=>e.jsx(R,{sx:{ml:0},control:e.jsx(U,{...m,checked:m.value})})})})}),v&&e.jsxs(r,{children:[h.map((m,A)=>e.jsxs(W,{direction:"row",sx:{alignItems:"center",my:1,maxWidth:"720px"},children:[e.jsx(k,{name:`email.domainWhiteList.${A}`,control:a,render:_=>e.jsx(F,{..._.field,size:"small",fullWidth:!0})}),e.jsx(le,{onClick:()=>I(A),children:e.jsx(qe,{})})]},m.id)),e.jsx(V,{startIcon:e.jsx(Le,{}),onClick:()=>s(""),children:d("blocklet.config.session.addDomain")})]})]}),e.jsxs(r,{sx:{display:"none"},children:[e.jsx(y,{title:d("blocklet.config.session.phoneEnabled"),sectionLeftSx:{width:"600px"},children:e.jsx(r,{sx:{alignSelf:"flex-start"},children:e.jsx(k,{name:"phone.enabled",control:a,disabled:!0,render:({field:m})=>e.jsx(R,{sx:{ml:0},control:e.jsx(U,{...m,checked:m.value})})})})}),l&&e.jsxs(W,{direction:"column",sx:{ml:2,mt:1},children:[e.jsx(y,{title:d("blocklet.config.session.phoneRequireVerified"),sectionLeftSx:{width:"600px"},children:e.jsx(r,{sx:{alignSelf:"flex-start"},children:e.jsx(k,{name:"phone.requireVerified",control:a,render:({field:m})=>e.jsx(R,{sx:{ml:0},control:e.jsx(U,{...m,checked:m.value})})})})}),e.jsx(y,{title:d("blocklet.config.session.phoneRequireUnique"),sectionLeftSx:{width:"600px"},children:e.jsx(r,{sx:{alignSelf:"flex-start"},children:e.jsx(k,{name:"phone.requireUnique",control:a,render:({field:m})=>e.jsx(R,{sx:{ml:0},control:e.jsx(U,{...m,checked:m.value})})})})})]})]})]})]}),e.jsxs(r,{children:[e.jsx(Y,{variant:"h6",sx:{fontWeight:600},children:d("blocklet.config.session.period")}),e.jsx(r,{component:oe,sx:{my:3}}),e.jsx(W,{direction:"column",spacing:2,children:e.jsx(k,{name:"ttl",control:a,rules:{min:1,max:30},render:({field:m})=>e.jsx(O,{fullWidth:!0,sx:{mb:2},children:e.jsx(y,{title:d("blocklet.config.session.ttl",{day:m.value}),sectionLeftSx:{width:"600px"},children:e.jsx(r,{sx:{width:"100%",maxWidth:500,px:2},children:e.jsx(He,{...m,defaultValue:7,step:1,marks:[{value:1,label:d("blocklet.config.session.day",{day:1})},{value:7,label:d("blocklet.config.session.days",{day:7})},{value:14,label:d("blocklet.config.session.days",{day:14})},{value:21,label:d("blocklet.config.session.days",{day:21})},{value:30,label:d("blocklet.config.session.days",{day:30})}],min:1,max:30,valueLabelDisplay:"auto"})})})})})})]}),e.jsxs(r,{children:[e.jsx(Y,{variant:"h6",sx:{fontWeight:600},children:d("blocklet.config.session.experimentalSettings")}),e.jsx(r,{component:oe,sx:{my:3}}),e.jsx(W,{direction:"column",spacing:2,children:e.jsx(y,{title:d("blocklet.config.session.enableBlacklist"),sectionLeftSx:{width:"600px"},children:e.jsx(r,{sx:{alignSelf:"flex-start"},children:e.jsx(k,{name:"enableBlacklist",control:a,render:({field:m})=>e.jsx(R,{sx:{ml:0},control:e.jsx(U,{...m,checked:m.value})})})})})})]}),e.jsx(r,{children:e.jsx(V,{type:"submit",variant:"contained",disabled:!x.isDirty,children:d("oauth.save")})})]})})}const bt=Fe.form`
1
+ import{V as ee,H as B,U as X,a7 as Ee,a8 as Ue,a9 as We,aa as Ve,p as K,J as je,b as ke,n as z,ab as Me,h as _e,i as Ne,j as Ie}from"./vendor-ux-r9bApERu.js";import{b as u,a as H,g as ie,c as $e}from"./vendor-hooks-PN9SWiQm.js";import{r as C}from"./vendor-react-CUXIiAnY.js";import{j as e,ak as r,b6 as R,am as ce,y as O,z as F,Q as V,T as Y,I as le,a3 as oe,W as E,b1 as W,bb as qe,cb as Le,cE as He,at as Fe,D as ye,ah as Oe,cF as Be,a6 as be,cG as Je,a$ as Ze}from"./vendor-mui-core-BPQ6AEW_.js";import{_ as N,ac as M,Y as G,bc as se,c as ve,b7 as Ke,aA as Ge,Z as Ye}from"./index-jPmRCtiq.js";import{A as Z,Q as Qe,b as de,Z as Xe,n as Q,$ as et,C as tt,a as nt}from"./vendor-utils-BgSaqjGx.js";import{u as te,C as k,a as Ce}from"./index.esm-DTmS4tth.js";import{S as re}from"./switch-control-D-yLpfsT.js";import{S as y}from"./section-Cyr0YvGa.js";import{d as st}from"./keyboard-arrow-down-rounded-8U0_i9QO.js";import{u as ot}from"./index-B7Hwfql4.js";import{v as it}from"./index-ySP_m_Ux.js";import{r as rt}from"./base32-eAS52qli.js";import{C as at}from"./click-to-copy-BuSTGPjJ.js";import{u as lt}from"./use-mobile-ajdJIsoX.js";import"./lottie-web-4koyQiv_.js";import"./vendor-arcblock-D8WYBDYe.js";import"./required-Btg6mEmX.js";const we={width:24,height:24,body:'<path fill="currentColor" d="M5 4v16V4v5v-5Zm3 10h2.675q.275-.575.638-1.075t.812-.925H8q-.425 0-.713.288T7 13q0 .425.288.713T8 14Zm0 4h2.075Q10 17.5 10 17t.075-1H8q-.425 0-.713.288T7 17q0 .425.288.713T8 18Zm-3 4q-.825 0-1.413-.588T3 20V4q0-.825.588-1.413T5 2h7.175q.4 0 .763.15t.637.425l4.85 4.85q.275.275.425.638t.15.762V10.3q-.475-.15-.975-.225T17 10V9h-4q-.425 0-.713-.288T12 8V4H5v16h5.675q.275.575.638 1.075t.812.925H5Zm12-10q2.075 0 3.538 1.463T22 17q0 2.075-1.463 3.538T17 22q-2.075 0-3.538-1.463T12 17q0-2.075 1.463-3.538T17 12Zm0 8q.275 0 .463-.188t.187-.462q0-.275-.187-.463T17 18.7q-.275 0-.463.188t-.187.462q0 .275.188.463T17 20Zm0-6q-.475 0-.875.238t-.65.637q-.1.15-.025.313t.25.237q.15.075.3 0t.275-.2q.125-.175.313-.275t.412-.1q.325 0 .563.213t.237.537q0 .275-.15.463t-.35.387q-.15.15-.313.3t-.287.35q-.075.15-.113.313t-.037.337q0 .225.125.413t.325.187q.2 0 .325-.15t.125-.35q0-.275.15-.488t.35-.412q.3-.275.525-.613t.225-.737q0-.675-.5-1.138T17 14Z"/>'},ue={enabled:!1,domain:"",clientId:"",clientSecret:""};function ct(){const{api:b}=N(),{blocklet:c}=M(),{t,locale:n}=ee(),o=c?.meta?.did,a=Object.assign({...ue},c?.settings?.oauth?.auth0||{}),{handleSubmit:x,control:i,formState:p,watch:d,reset:f}=te({defaultValues:Z(a,Object.keys(ue))}),l=d("enabled"),j=u(async s=>{try{const{blocklet:I}=await b.configOAuth({input:{did:o,oauth:JSON.stringify({auth0:s})}}),L=Object.assign({...ue},I?.settings?.oauth?.auth0||{});f(L),B.success(t("oauth.saveSuccess"))}catch(I){B.error(I.message||t("oauth.saveFailed"))}}),v=u(s=>s?.trim()?!0:t("oauth.auth0.domainDescription")),S=u(s=>s?.trim()?!0:t("oauth.auth0.clientIdDescription")),g=u(s=>s?.trim()?!0:t("oauth.auth0.clientSecretDescription")),w=u(()=>!0),h=H(()=>n==="zh"?"https://www.arcblock.io/blog/docs/did-connect/zh/oauth-config-auth0":"https://www.arcblock.io/blog/docs/did-connect/en/oauth-config-auth0",[n]);return e.jsx(r,{children:e.jsxs("form",{onSubmit:x(j),disabled:!0,children:[e.jsx(y,{title:e.jsxs(r,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx("span",{children:t("oauth.auth0.enable")}),e.jsx(ce,{title:t("oauth.viewDocument"),children:e.jsx(r,{component:"a",sx:{display:"inline-block",color:"inherit",fontSize:0,lineHeight:1},href:h,target:"_blank",rel:"noreferrer",children:e.jsx(X,{icon:we,fontSize:20})})})]}),mb:2.5,children:e.jsx(k,{name:"enabled",control:i,render:({field:s})=>e.jsx(R,{control:e.jsx(re,{sx:{ml:1},checked:s.value,...s})})})}),e.jsx(y,{title:t("oauth.auth0.domain"),children:e.jsx(k,{name:"domain",control:i,rules:{validate:l?v:w},render:({field:s})=>e.jsx(O,{fullWidth:!0,children:e.jsx(F,{...s,size:"small",label:t("oauth.auth0.domain"),error:!!p.errors[s.name],helperText:p.errors[s.name]?.message||" ",disabled:!l})})})}),e.jsx(y,{title:t("oauth.auth0.clientId"),children:e.jsx(k,{name:"clientId",control:i,rules:{validate:l?S:w},render:({field:s})=>e.jsx(O,{fullWidth:!0,children:e.jsx(F,{...s,size:"small",label:t("oauth.auth0.clientId"),error:!!p.errors[s.name],helperText:p.errors[s.name]?.message||" ",disabled:!l})})})}),e.jsx(y,{title:t("oauth.auth0.clientSecret"),children:e.jsx(k,{name:"clientSecret",control:i,rules:{validate:l?g:w},render:({field:s})=>e.jsx(O,{fullWidth:!0,children:e.jsx(F,{...s,size:"small",type:"password",label:t("oauth.auth0.clientSecret"),error:!!p.errors[s.name],helperText:p.errors[s.name]?.message||" ",disabled:!l})})})}),e.jsx(V,{type:"submit",variant:"contained",onSubmit:x(j),disabled:!p.isDirty,children:t("oauth.save")})]})})}const he={enabled:!1,clientId:"",clientSecret:""};function dt(){const{api:b}=N(),{blocklet:c}=M(),{t,locale:n}=ee(),o=c?.meta?.did,a=Object.assign({...he},c?.settings?.oauth?.github||{}),{handleSubmit:x,control:i,formState:p,watch:d,reset:f}=te({defaultValues:Z(a,Object.keys(he))}),l=d("enabled"),j=u(async h=>{try{const{blocklet:s}=await b.configOAuth({input:{did:o,oauth:JSON.stringify({github:h})}}),I=Object.assign({...he},s?.settings?.oauth?.github||{});f(I),B.success(t("oauth.saveSuccess"))}catch(s){B.error(s.message||t("oauth.saveFailed"))}}),v=u(h=>h?.trim()?!0:t("oauth.github.clientIdDescription")),S=u(h=>h?.trim()?!0:t("oauth.github.clientSecretDescription")),g=u(()=>!0),w=H(()=>n==="zh"?"https://www.arcblock.io/blog/docs/did-connect/zh/oauth-config-github":"https://www.arcblock.io/blog/docs/did-connect/en/oauth-config-github",[n]);return e.jsx(r,{children:e.jsxs("form",{onSubmit:x(j),disabled:!0,children:[e.jsx(y,{title:e.jsxs(r,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx("span",{children:t("oauth.github.enable")}),e.jsx(ce,{title:t("oauth.viewDocument"),children:e.jsx(r,{component:"a",sx:{display:"inline-block",color:"inherit",fontSize:0,lineHeight:1},href:w,target:"_blank",rel:"noreferrer",children:e.jsx(X,{icon:we,fontSize:20})})})]}),mb:2.5,sx:{"& .section-content":{alignItems:"center"}},children:e.jsx(k,{name:"enabled",control:i,sx:{alignItems:"center"},render:({field:h})=>e.jsx(R,{control:e.jsx(re,{sx:{ml:1},size:"small",checked:h.value,...h})})})}),e.jsx(y,{title:t("oauth.github.clientId"),children:e.jsx(k,{name:"clientId",control:i,rules:{validate:l?v:g},render:({field:h})=>e.jsx(O,{fullWidth:!0,children:e.jsx(F,{...h,size:"small",label:t("oauth.github.clientId"),error:!!p.errors[h.name],helperText:p.errors[h.name]?.message||" ",disabled:!l})})})}),e.jsx(y,{title:t("oauth.github.clientSecret"),children:e.jsx(k,{name:"clientSecret",control:i,rules:{validate:l?S:g},render:({field:h})=>e.jsx(O,{fullWidth:!0,children:e.jsx(F,{...h,size:"small",type:"password",label:t("oauth.github.clientSecret"),error:!!p.errors[h.name],helperText:p.errors[h.name]?.message||" ",disabled:!l})})})}),e.jsx(V,{type:"submit",variant:"contained",onSubmit:x(j),disabled:!p.isDirty,children:t("oauth.save")})]})})}const me={enabled:!1,clientId:"",clientSecret:""};function ut(){const{api:b}=N(),{blocklet:c}=M(),{t,locale:n}=ee(),o=c?.meta?.did,a=Object.assign({...me},c?.settings?.oauth?.google||{}),{handleSubmit:x,control:i,formState:p,watch:d,reset:f}=te({defaultValues:Z(a,Object.keys(me))}),l=d("enabled"),j=u(async h=>{try{const{blocklet:s}=await b.configOAuth({input:{did:o,oauth:JSON.stringify({google:h})}}),I=Object.assign({...me},s?.settings?.oauth?.google||{});f(I),B.success(t("oauth.saveSuccess"))}catch(s){B.error(s.message||t("oauth.saveFailed"))}}),v=u(h=>h?.trim()?!0:t("oauth.google.clientIdDescription")),S=u(h=>h?.trim()?!0:t("oauth.google.clientSecretDescription")),g=u(()=>!0),w=H(()=>n==="zh"?"https://www.arcblock.io/blog/docs/did-connect/zh/oauth-config-google":"https://www.arcblock.io/blog/docs/did-connect/en/oauth-config-google",[n]);return e.jsx(r,{children:e.jsxs("form",{onSubmit:x(j),disabled:!0,children:[e.jsx(y,{title:e.jsxs(r,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx("span",{children:t("oauth.google.enable")}),e.jsx(ce,{title:t("oauth.viewDocument"),children:e.jsx(r,{component:"a",sx:{display:"inline-block",color:"inherit",fontSize:0,lineHeight:1},href:w,target:"_blank",rel:"noreferrer",children:e.jsx(X,{icon:we,fontSize:20})})})]}),mb:2.5,children:e.jsx(k,{name:"enabled",control:i,render:({field:h})=>e.jsx(R,{control:e.jsx(re,{sx:{ml:1},checked:h.value,...h})})})}),e.jsx(y,{title:t("oauth.google.clientId"),children:e.jsx(k,{name:"clientId",control:i,rules:{validate:l?v:g},render:({field:h})=>e.jsx(O,{fullWidth:!0,children:e.jsx(F,{...h,size:"small",label:t("oauth.google.clientId"),error:!!p.errors[h.name],helperText:p.errors[h.name]?.message||" ",disabled:!l})})})}),e.jsx(y,{title:t("oauth.google.clientSecret"),children:e.jsx(k,{name:"clientSecret",control:i,rules:{validate:l?S:g},render:({field:h})=>e.jsx(O,{fullWidth:!0,children:e.jsx(F,{...h,size:"small",type:"password",label:t("oauth.google.clientSecret"),error:!!p.errors[h.name],helperText:p.errors[h.name]?.message||" ",disabled:!l})})})}),e.jsx(V,{type:"submit",variant:"contained",onSubmit:x(j),disabled:!p.isDirty,children:t("oauth.save")})]})})}const pe={enabled:!1,teamId:"",serviceId:"",keyId:"",authKey:"",bundleId:""};function ht(){const{api:b}=N(),{blocklet:c}=M(),{t}=ee(),n=c?.meta?.did,o=Object.assign({...pe},c?.settings?.oauth?.apple||{}),{handleSubmit:a,control:x,formState:i,watch:p,reset:d}=te({defaultValues:Z(o,Object.keys(pe))}),f=p("enabled"),l=u(async s=>{try{const{blocklet:I}=await b.configOAuth({input:{did:n,oauth:JSON.stringify({apple:s})}}),L=Object.assign({...pe},I?.settings?.oauth?.apple||{});d(L),B.success(t("oauth.saveSuccess"))}catch(I){B.error(I.message||t("oauth.saveFailed"))}}),j=u(s=>s?.trim()?!0:t("oauth.apple.teamIdDescription")),v=u(s=>s?.trim()?!0:t("oauth.apple.serviceIdDescription")),S=u(s=>s?.trim()?!0:t("oauth.apple.keyIdDescription")),g=u(s=>s?.trim()?!0:t("oauth.apple.authKeyDescription")),w=u(s=>s?.trim()?!0:t("oauth.apple.bundleIdDescription")),h=u(()=>!0);return e.jsx(r,{children:e.jsxs("form",{onSubmit:a(l),disabled:!0,children:[e.jsx(y,{title:t("oauth.apple.enable"),mb:2.5,children:e.jsx(k,{name:"enabled",control:x,render:({field:s})=>e.jsx(R,{control:e.jsx(re,{sx:{ml:1},checked:s.value,...s})})})}),e.jsx(y,{title:t("oauth.apple.teamId"),children:e.jsx(k,{name:"teamId",control:x,rules:{validate:f?j:h},render:({field:s})=>e.jsx(O,{fullWidth:!0,children:e.jsx(F,{...s,size:"small",label:t("oauth.apple.teamId"),error:!!i.errors[s.name],helperText:i.errors[s.name]?.message||" ",disabled:!f})})})}),e.jsx(y,{title:t("oauth.apple.bundleId"),children:e.jsx(k,{name:"bundleId",control:x,rules:{validate:f?w:h},render:({field:s})=>e.jsx(O,{fullWidth:!0,children:e.jsx(F,{...s,size:"small",label:t("oauth.apple.bundleId"),error:!!i.errors[s.name],helperText:i.errors[s.name]?.message||" ",disabled:!f})})})}),e.jsx(y,{title:t("oauth.apple.serviceId"),children:e.jsx(k,{name:"serviceId",control:x,rules:{validate:f?v:h},render:({field:s})=>e.jsx(O,{fullWidth:!0,children:e.jsx(F,{...s,size:"small",label:t("oauth.apple.serviceId"),error:!!i.errors[s.name],helperText:i.errors[s.name]?.message||" ",disabled:!f})})})}),e.jsx(y,{title:t("oauth.apple.keyId"),children:e.jsx(k,{name:"keyId",control:x,rules:{validate:f?S:h},render:({field:s})=>e.jsx(O,{fullWidth:!0,children:e.jsx(F,{...s,size:"small",label:t("oauth.apple.keyId"),error:!!i.errors[s.name],helperText:i.errors[s.name]?.message||" ",disabled:!f})})})}),e.jsx(y,{title:t("oauth.apple.authKey"),children:e.jsx(k,{name:"authKey",control:x,rules:{validate:f?g:h},render:({field:s})=>e.jsx(O,{fullWidth:!0,children:e.jsx(F,{...s,size:"small",type:"password",label:t("oauth.apple.authKey"),multiline:!0,rows:4,error:!!i.errors[s.name],helperText:i.errors[s.name]?.message||" ",disabled:!f})})})}),e.jsx(V,{type:"submit",variant:"contained",onSubmit:a(l),disabled:!i.isDirty,children:t("oauth.save")})]})})}const xe={enabled:!1,clientId:"",clientSecret:""};function mt(){const{api:b}=N(),{blocklet:c}=M(),{t}=ee(),n=c?.meta?.did,o=Object.assign({...xe},c?.settings?.oauth?.twitter||{}),{handleSubmit:a,control:x,formState:i,watch:p,reset:d}=te({defaultValues:Z(o,Object.keys(xe))}),f=p("enabled"),l=u(async g=>{try{const{blocklet:w}=await b.configOAuth({input:{did:n,oauth:JSON.stringify({twitter:g})}}),h=Object.assign({...xe},w?.settings?.oauth?.twitter||{});d(h),B.success(t("oauth.saveSuccess"))}catch(w){B.error(w.message||t("oauth.saveFailed"))}}),j=u(g=>g?.trim()?!0:t("oauth.twitter.clientIdDescription")),v=u(g=>g?.trim()?!0:t("oauth.twitter.clientSecretDescription")),S=u(()=>!0);return e.jsx(r,{children:e.jsxs("form",{onSubmit:a(l),disabled:!0,children:[e.jsx(y,{title:e.jsx(r,{sx:{display:"flex",alignItems:"center",gap:1},children:e.jsx("span",{children:t("oauth.twitter.enable")})}),mb:2.5,sx:{"& .section-content":{alignItems:"center"}},children:e.jsx(k,{name:"enabled",control:x,sx:{alignItems:"center"},render:({field:g})=>e.jsx(R,{control:e.jsx(re,{sx:{ml:1},size:"small",checked:g.value,...g})})})}),e.jsx(y,{title:t("oauth.twitter.clientId"),children:e.jsx(k,{name:"clientId",control:x,rules:{validate:f?j:S},render:({field:g})=>e.jsx(O,{fullWidth:!0,children:e.jsx(F,{...g,size:"small",label:t("oauth.twitter.clientId"),error:!!i.errors[g.name],helperText:i.errors[g.name]?.message||" ",disabled:!f})})})}),e.jsx(y,{title:t("oauth.twitter.clientSecret"),children:e.jsx(k,{name:"clientSecret",control:x,rules:{validate:f?v:S},render:({field:g})=>e.jsx(O,{fullWidth:!0,children:e.jsx(F,{...g,size:"small",type:"password",label:t("oauth.twitter.clientSecret"),error:!!i.errors[g.name],helperText:i.errors[g.name]?.message||" ",disabled:!f})})})}),e.jsx(V,{type:"submit",variant:"contained",onSubmit:a(l),disabled:!i.isDirty,children:t("oauth.save")})]})})}const pt={width:24,height:24,body:'<path fill="currentColor" d="M9 20q-.825 0-1.413-.588T7 18q0-.825.588-1.413T9 16q.825 0 1.413.588T11 18q0 .825-.588 1.413T9 20Zm6 0q-.825 0-1.413-.588T13 18q0-.825.588-1.413T15 16q.825 0 1.413.588T17 18q0 .825-.588 1.413T15 20Zm-6-6q-.825 0-1.413-.588T7 12q0-.825.588-1.413T9 10q.825 0 1.413.588T11 12q0 .825-.588 1.413T9 14Zm6 0q-.825 0-1.413-.588T13 12q0-.825.588-1.413T15 10q.825 0 1.413.588T17 12q0 .825-.588 1.413T15 14ZM9 8q-.825 0-1.413-.588T7 6q0-.825.588-1.413T9 4q.825 0 1.413.588T11 6q0 .825-.588 1.413T9 8Zm6 0q-.825 0-1.413-.588T13 6q0-.825.588-1.413T15 4q.825 0 1.413.588T17 6q0 .825-.588 1.413T15 8Z"/>'};function Re({id:b,title:c,children:t,index:n,onMove:o,defaultExpand:a=!1,onEnd:x,icon:i=null}){const[p,d]=C.useState(a),f=C.useRef(null),l=C.useRef(null),[{handlerId:j},v]=Ee({accept:"dragItem",collect(s){return{handlerId:s.getHandlerId()}},hover(s,I){if(!f.current)return;const L=s.index,m=n;if(L===m)return;const A=f.current?.getBoundingClientRect(),_=l.current?.getBoundingClientRect(),ae=(_.bottom-_.top)/2,$=I.getClientOffset().y-A.top;L<m&&$<ae||L>m&&$>ae||(o(L,m),s.index=m)}}),[{isDragging:S},g]=Ue({item:{index:n,type:"dragItem"},collect:s=>({isDragging:s.isDragging()}),end:x});g(l),v(f);const w=S?.5:1,h=u(s=>{s.preventDefault(),s.stopPropagation(),d(!p)});return e.jsxs(r,{ref:f,children:[e.jsxs(r,{sx:{cursor:"pointer","&:hover":{backgroundColor:"grey.100"}},ref:l,"data-handler-id":j,children:[e.jsxs(r,{sx:{py:2,px:1,opacity:w,display:"flex",alignItems:"center",gap:.5},draggable:!1,onClick:h,children:[e.jsx(r,{sx:{pointerEvents:"auto",cursor:"grab","&:active":{cursor:"grabbing"},fontSize:0,color:"text.hint","&:hover":{color:"text.secondary"}},children:e.jsx(X,{fontSize:20,icon:pt})}),e.jsx(r,{sx:{display:"flex",alignItems:"center",flexShrink:0,mr:.5,transform:"translateY(-1px)"},children:i}),e.jsx(Y,{sx:{flex:1},children:c}),e.jsx(le,{size:"small",sx:{pointerEvents:"auto",transform:p?"":"rotate(180deg)",transition:"transform 0.3s ease"},children:e.jsx(X,{icon:st,style:{transform:"scale(1.5)"}})})]}),e.jsx(oe,{})]}),e.jsx(r,{sx:{pl:4,py:2.5,display:p?"block":"none"},children:t})]})}Re.propTypes={title:E.string.isRequired,id:E.string.isRequired,children:E.node.isRequired,index:E.number.isRequired,onMove:E.func.isRequired,onEnd:E.func.isRequired,defaultExpand:E.bool,icon:E.any};const xt=[{name:"github",title:G.PROVIDER_NAME.github,icon:e.jsx(se,{provider:"github",sx:{width:20,height:20}}),component:e.jsx(dt,{})},{name:"google",title:G.PROVIDER_NAME.google,icon:e.jsx(se,{provider:"google",sx:{width:20,height:20}}),component:e.jsx(ut,{})},{name:"apple",title:G.PROVIDER_NAME.apple,icon:e.jsx(se,{provider:"apple",sx:{width:20,height:20}}),component:e.jsx(ht,{})},{name:"twitter",title:G.PROVIDER_NAME.twitter,icon:e.jsx(se,{provider:"twitter",sx:{width:20,height:20}}),component:e.jsx(mt,{})},{name:"auth0",title:G.PROVIDER_NAME.auth0,icon:e.jsx(se,{provider:"auth0",sx:{width:20,height:20}}),component:e.jsx(ct,{})}],ft=["github","google","apple","twitter","auth0"];function gt(){const{api:b}=N(),{blocklet:c}=M(),t=c?.meta?.did,n=c?.settings?.oauth||{},o=Object.keys(n).sort((l,j)=>n[l]?.order!==void 0&&n[j]?.order!==void 0?n[l].order-n[j].order:n[l]?.order!==void 0?-1:1);for(const l of ft)o.includes(l)||o.push(l);const a=ie(o.reduce((l,j,v)=>Object.assign(l,{[j]:v}),{})),x=H(()=>{const l=[...xt];return l.sort((j,v)=>a[j.name]-a[v.name]),l.map(j=>({...j,enabled:n[j.name]?.enabled??!1}))},[a.auth0,a.github,a.google]),i={};typeof window<"u"&&(i.context=window);const p=u(async l=>{const j={};Object.keys(l).forEach(v=>{j[v]={order:l[v]}}),await b.configOAuth({input:{did:t,oauth:JSON.stringify(j)}})}),d=u((l,j)=>{const v=x[l],S=x[j];a[v.name]=j,a[S.name]=l}),f=u(async()=>{await p(a)});return e.jsx(r,{sx:{".section-left":{width:"180px"}},children:e.jsx(We,{backend:Ve,...i,children:x.map((l,j)=>e.jsx(Re,{index:j,id:l.name,title:l.title,icon:l.icon,onMove:d,onEnd:f,defaultExpand:l.enabled,children:l.component},l.name))})})}const J={ttl:ve.SESSION_TTL,cacheTtl:ve.SESSION_CACHE_TTL,email:{enabled:!1,requireVerified:!1,requireUnique:!1,trustOauthProviders:!1,trustedIssuers:[],enableDomainBlackList:!1,domainBlackList:[],enableDomainWhiteList:!1,domainWhiteList:[]},phone:{enabled:!1,requireVerified:!1,requireUnique:!1,regionBlackList:[],trustedIssuers:[]},enableBlacklist:!1};function U(b){return e.jsx(ot,{...b,sx:{transform:"scale(0.75)"}})}function fe(b,c=!1){const t=c?b.ttl*86400:b.ttl/86400;return{...b,ttl:t}}function jt(){const{api:b}=N(),{blocklet:c}=M(),t=c?.meta?.did,n=Qe({},J,c?.settings?.session||{});de(n.ttl)&&(n.ttl=J.ttl),de(n.cacheTtl)&&(n.cacheTtl=J.cacheTtl),n.phone||(n.phone=J.phone),n.email||(n.email=J.email),de(n.enableBlacklist)&&(n.enableBlacklist=J.enableBlacklist);const{handleSubmit:o,control:a,formState:x,reset:i,watch:p}=te({defaultValues:Z(fe(n),["ttl","cacheTtl","email","phone","enableBlacklist"])}),{t:d}=ee(),f=p("email.enabled"),l=p("phone.enabled"),j=p("email.enableDomainBlackList"),v=p("email.enableDomainWhiteList"),{fields:S,append:g,remove:w}=Ce({control:a,name:"email.domainBlackList"}),{fields:h,append:s,remove:I}=Ce({control:a,name:"email.domainWhiteList"}),L=u(async m=>{try{const{blocklet:A}=await b.updateAppSessionConfig({input:{did:t,config:Xe(fe(m,!0),["phone"])}}),_=Object.assign({},J,Z(A?.settings?.session||{},["ttl","cacheTtl","email","phone","enableBlacklist"]));i(fe(_)),B.success(d("common.configSuccess"))}catch(A){B.error(A.message)}});return e.jsx(bt,{onSubmit:o(L),children:e.jsxs(W,{direction:"column",sx:{gap:6},children:[e.jsxs(r,{children:[e.jsxs(r,{children:[e.jsx(Y,{variant:"h6",sx:{fontWeight:600},children:d("blocklet.config.session.profile")}),e.jsx(r,{component:oe,sx:{my:3}})]}),e.jsxs(W,{sx:{gap:2},children:[e.jsx(y,{title:d("blocklet.config.session.fullNameEnabled"),sectionLeftSx:{width:"600px"},children:e.jsx(r,{sx:{alignSelf:"flex-start"},children:e.jsx(U,{disabled:!0,checked:!0})})}),e.jsx(y,{title:d("blocklet.config.session.avatarEnabled"),sectionLeftSx:{width:"600px"},children:e.jsx(r,{sx:{alignSelf:"flex-start"},children:e.jsx(U,{disabled:!0,checked:!0})})}),e.jsx(y,{title:d("blocklet.config.session.emailEnabled"),sectionLeftSx:{width:"600px"},children:e.jsx(r,{sx:{alignSelf:"flex-start"},children:e.jsx(k,{name:"email.enabled",control:a,render:({field:m})=>e.jsx(U,{...m,checked:m.value})})})}),f&&e.jsxs(W,{direction:"column",sx:{ml:2,gap:.5},children:[e.jsx(y,{title:d("blocklet.config.session.emailRequireVerified"),sectionLeftSx:{width:"600px"},children:e.jsx(r,{sx:{alignSelf:"flex-start"},children:e.jsx(k,{name:"email.requireVerified",control:a,render:({field:m})=>e.jsx(R,{sx:{ml:0},control:e.jsx(U,{...m,checked:m.value})})})})}),e.jsx(y,{title:d("blocklet.config.session.emailRequireUnique"),sectionLeftSx:{width:"600px"},children:e.jsx(r,{sx:{alignSelf:"flex-start"},children:e.jsx(k,{name:"email.requireUnique",control:a,render:({field:m})=>e.jsx(R,{sx:{ml:0},control:e.jsx(U,{...m,checked:m.value})})})})}),e.jsx(y,{title:d("blocklet.config.session.emailTrustOauthProviders"),sectionLeftSx:{width:"600px"},children:e.jsx(r,{sx:{alignSelf:"flex-start"},children:e.jsx(k,{name:"email.trustOauthProviders",control:a,render:({field:m})=>e.jsx(R,{sx:{ml:0},control:e.jsx(U,{...m,checked:m.value})})})})}),e.jsx(y,{title:d("blocklet.config.session.enableDomainBlackList"),sectionLeftSx:{width:"600px"},children:e.jsx(r,{sx:{alignSelf:"flex-start"},children:e.jsx(k,{name:"email.enableDomainBlackList",control:a,render:({field:m})=>e.jsx(R,{sx:{ml:0},control:e.jsx(U,{...m,checked:m.value})})})})}),j&&e.jsxs(r,{children:[S.map((m,A)=>e.jsxs(W,{direction:"row",sx:{alignItems:"center",my:1,maxWidth:"720px"},children:[e.jsx(k,{name:`email.domainBlackList.${A}`,control:a,render:_=>e.jsx(F,{..._.field,size:"small",fullWidth:!0})}),e.jsx(le,{onClick:()=>w(A),children:e.jsx(qe,{})})]},m.id)),e.jsx(V,{startIcon:e.jsx(Le,{}),onClick:()=>g(""),children:d("blocklet.config.session.addDomain")})]}),e.jsx(y,{title:d("blocklet.config.session.enableDomainWhiteList"),sectionLeftSx:{width:"600px"},children:e.jsx(r,{sx:{alignSelf:"flex-start"},children:e.jsx(k,{name:"email.enableDomainWhiteList",control:a,render:({field:m})=>e.jsx(R,{sx:{ml:0},control:e.jsx(U,{...m,checked:m.value})})})})}),v&&e.jsxs(r,{children:[h.map((m,A)=>e.jsxs(W,{direction:"row",sx:{alignItems:"center",my:1,maxWidth:"720px"},children:[e.jsx(k,{name:`email.domainWhiteList.${A}`,control:a,render:_=>e.jsx(F,{..._.field,size:"small",fullWidth:!0})}),e.jsx(le,{onClick:()=>I(A),children:e.jsx(qe,{})})]},m.id)),e.jsx(V,{startIcon:e.jsx(Le,{}),onClick:()=>s(""),children:d("blocklet.config.session.addDomain")})]})]}),e.jsxs(r,{sx:{display:"none"},children:[e.jsx(y,{title:d("blocklet.config.session.phoneEnabled"),sectionLeftSx:{width:"600px"},children:e.jsx(r,{sx:{alignSelf:"flex-start"},children:e.jsx(k,{name:"phone.enabled",control:a,disabled:!0,render:({field:m})=>e.jsx(R,{sx:{ml:0},control:e.jsx(U,{...m,checked:m.value})})})})}),l&&e.jsxs(W,{direction:"column",sx:{ml:2,mt:1},children:[e.jsx(y,{title:d("blocklet.config.session.phoneRequireVerified"),sectionLeftSx:{width:"600px"},children:e.jsx(r,{sx:{alignSelf:"flex-start"},children:e.jsx(k,{name:"phone.requireVerified",control:a,render:({field:m})=>e.jsx(R,{sx:{ml:0},control:e.jsx(U,{...m,checked:m.value})})})})}),e.jsx(y,{title:d("blocklet.config.session.phoneRequireUnique"),sectionLeftSx:{width:"600px"},children:e.jsx(r,{sx:{alignSelf:"flex-start"},children:e.jsx(k,{name:"phone.requireUnique",control:a,render:({field:m})=>e.jsx(R,{sx:{ml:0},control:e.jsx(U,{...m,checked:m.value})})})})})]})]})]})]}),e.jsxs(r,{children:[e.jsx(Y,{variant:"h6",sx:{fontWeight:600},children:d("blocklet.config.session.period")}),e.jsx(r,{component:oe,sx:{my:3}}),e.jsx(W,{direction:"column",spacing:2,children:e.jsx(k,{name:"ttl",control:a,rules:{min:1,max:30},render:({field:m})=>e.jsx(O,{fullWidth:!0,sx:{mb:2},children:e.jsx(y,{title:d("blocklet.config.session.ttl",{day:m.value}),sectionLeftSx:{width:"600px"},children:e.jsx(r,{sx:{width:"100%",maxWidth:500,px:2},children:e.jsx(He,{...m,defaultValue:7,step:1,marks:[{value:1,label:d("blocklet.config.session.day",{day:1})},{value:7,label:d("blocklet.config.session.days",{day:7})},{value:14,label:d("blocklet.config.session.days",{day:14})},{value:21,label:d("blocklet.config.session.days",{day:21})},{value:30,label:d("blocklet.config.session.days",{day:30})}],min:1,max:30,valueLabelDisplay:"auto"})})})})})})]}),e.jsxs(r,{children:[e.jsx(Y,{variant:"h6",sx:{fontWeight:600},children:d("blocklet.config.session.experimentalSettings")}),e.jsx(r,{component:oe,sx:{my:3}}),e.jsx(W,{direction:"column",spacing:2,children:e.jsx(y,{title:d("blocklet.config.session.enableBlacklist"),sectionLeftSx:{width:"600px"},children:e.jsx(r,{sx:{alignSelf:"flex-start"},children:e.jsx(k,{name:"enableBlacklist",control:a,render:({field:m})=>e.jsx(R,{sx:{ml:0},control:e.jsx(U,{...m,checked:m.value})})})})})})]}),e.jsx(r,{children:e.jsx(V,{type:"submit",variant:"contained",disabled:!x.isDirty,children:d("oauth.save")})})]})})}const bt=Fe.form`
2
2
  max-width: 1536px;
3
3
 
4
4
  .advanced-config {
@@ -1,4 +1,4 @@
1
- import{D as w1,J as K1,j as r,Y as Y1,$ as W1,I as q1,df as _1,ar as I1,ak as U,a$ as R,cW as y1,b1 as $1,am as B1,T,bD as e6,z as t6,cq as n6,a6,Q as r6}from"./vendor-mui-core-BPQ6AEW_.js";import{C as x,a as i6,a9 as S1,J as M,c as s6,I as o6,F as c6}from"./vendor-utils-BSZ4yJws.js";import{V as l6,I as F1,e as u6,A as H,l as C6,x as p6,b as d6,n as t1,aF as n1}from"./vendor-ux-D507n6h6.js";import{r as t}from"./vendor-react-CUXIiAnY.js";import{k as L1,b as v1,a as Z}from"./vendor-hooks-fhL5FJET.js";import{bj as Y,Z as W,bz as U1,bA as h6,v as m6,bs as E6,bf as g6}from"./index-Cx5JU0Ln.js";import{x as f6}from"./index-DRYJ0xIl.js";import{f as A6}from"./index-BojVbZw0.js";import{v as a1}from"./index-BIJNkmLb.js";const j=Y({});function D6({key:e}={key:"md"}){const n=w1();return K1(n.breakpoints.down(e))}var A=(e=>(e[e.NETWORK_ERROR=1001]="NETWORK_ERROR",e[e.UNAUTHORIZED=1002]="UNAUTHORIZED",e[e.EXPIRED=1003]="EXPIRED",e[e.PAST_DUE=1004]="PAST_DUE",e[e.INVALID=1005]="INVALID",e[e.UNIT_LIMIT=1006]="UNIT_LIMIT",e[e.CORS_BLOCKED=1007]="CORS_BLOCKED",e[e.INCOMPATIBLE=1008]="INCOMPATIBLE",e))(A||{}),O1=(e=>(e.DEFAULT="default",e.SUCCEEDED="succeeded",e.FAILED="failed",e.PENDING="pending",e))(O1||{}),F=(e=>(e.APP_DISCONNECTED="app-disconnected",e.APP_RESTORE="app-restore",e.APP_BACKUP="app-backup",e.APP_CONNECTED="app-connected",e.APP_OBJECTS_SYNC="app-objects-sync",e))(F||{});function x6({endpoint:e,deps:n=[]}){return L1(async()=>{if(!W(e))return;const{headers:a}=await j.head(e,{timeout:1e3*30,params:{withExtras:!0}}),[i,s,c,u,l,C,d,p,m,g]=[a["x-space-name"],a["x-subscription-id"],a["x-listable"]==="true",a["x-readable"]==="true",a["x-writeable"]==="true",a["x-space-version"],a["x-space-owner-did"],a["x-space-is-available"],a["x-error-code"],a["x-is-site-admin"]],h=i?decodeURIComponent(i):"";if(p===void 0||m===void 0){const f=c&&u&&l;return{version:C,name:h,subscriptionId:s,ownerDid:d||"",isAvailable:f,errorCode:f?0:A.UNAUTHORIZED,isSiteAdmin:g==="true"}}return{version:C,name:h,subscriptionId:s,ownerDid:d,isAvailable:p==="true",errorCode:parseInt(m,10),isSiteAdmin:g==="true"}},{refreshDeps:[e].concat(n),onError(a){console.error(a)}})}const w6=U1.flatten({common:{cancel:"Cancel",confirm:"Confirm",delete:"Delete",error:"Error",open:"Open",unknown:"Unknown",invalidUrl:"Invalid url: {url}",upgrade:"Upgrade",viewMore:"View More"},storage:{spaces:{authorize:{title:"Connect {appName} to DID Spaces",scan:"Use your DID Wallet to scan the QR code below to allow the app {appName} to connect to DID Spaces",success:"Connected successfully"},connect:{reconnect:"Reconnect Now",useSpaceGateway:"Connect using the DID Spaces gateway",useWallet:"Connect to DID Spaces",howToGetGatewayUrl:"How to get the url of did spaces",providerForStorage:"Please connect your DID Spaces"},connected:{title:"Connected DID Spaces",tag:"Connected"},disconnected:{tag:"Disconnected"},error:{tag:"Need Attention",blockedByCors:"Access blocked by CORS",unreachable:"DID Space is unreachable",expired:"DID Spaces has expired, click this link to re-subscribe",pastDue:"DID Spaces has unpaid bills, click this link to complete payment",invalid:"DID Spaces subscription anomaly, click this link to check",unitLimit:"DID Spaces free quota has been used up, click this link to pay for the upgrade",cors:`The connection request may fail due to CORS restrictions:
1
+ import{D as w1,J as K1,j as r,Y as Y1,$ as W1,I as q1,df as _1,ar as I1,ak as U,a$ as R,cW as y1,b1 as $1,am as B1,T,bD as e6,z as t6,cq as n6,a6,Q as r6}from"./vendor-mui-core-BPQ6AEW_.js";import{C as x,a as i6,a9 as S1,J as M,c as s6,I as o6,F as c6}from"./vendor-utils-BgSaqjGx.js";import{V as l6,I as F1,e as u6,A as H,l as C6,x as p6,b as d6,n as t1,aF as n1}from"./vendor-ux-r9bApERu.js";import{r as t}from"./vendor-react-CUXIiAnY.js";import{k as L1,b as v1,a as Z}from"./vendor-hooks-PN9SWiQm.js";import{bj as Y,Z as W,bz as U1,bA as h6,v as m6,bs as E6,bf as g6}from"./index-jPmRCtiq.js";import{x as f6}from"./index-DRYJ0xIl.js";import{f as A6}from"./index-BojVbZw0.js";import{v as a1}from"./index-CJ1z6qNA.js";const j=Y({});function D6({key:e}={key:"md"}){const n=w1();return K1(n.breakpoints.down(e))}var A=(e=>(e[e.NETWORK_ERROR=1001]="NETWORK_ERROR",e[e.UNAUTHORIZED=1002]="UNAUTHORIZED",e[e.EXPIRED=1003]="EXPIRED",e[e.PAST_DUE=1004]="PAST_DUE",e[e.INVALID=1005]="INVALID",e[e.UNIT_LIMIT=1006]="UNIT_LIMIT",e[e.CORS_BLOCKED=1007]="CORS_BLOCKED",e[e.INCOMPATIBLE=1008]="INCOMPATIBLE",e))(A||{}),O1=(e=>(e.DEFAULT="default",e.SUCCEEDED="succeeded",e.FAILED="failed",e.PENDING="pending",e))(O1||{}),F=(e=>(e.APP_DISCONNECTED="app-disconnected",e.APP_RESTORE="app-restore",e.APP_BACKUP="app-backup",e.APP_CONNECTED="app-connected",e.APP_OBJECTS_SYNC="app-objects-sync",e))(F||{});function x6({endpoint:e,deps:n=[]}){return L1(async()=>{if(!W(e))return;const{headers:a}=await j.head(e,{timeout:1e3*30,params:{withExtras:!0}}),[i,s,c,u,l,C,d,p,m,g]=[a["x-space-name"],a["x-subscription-id"],a["x-listable"]==="true",a["x-readable"]==="true",a["x-writeable"]==="true",a["x-space-version"],a["x-space-owner-did"],a["x-space-is-available"],a["x-error-code"],a["x-is-site-admin"]],h=i?decodeURIComponent(i):"";if(p===void 0||m===void 0){const f=c&&u&&l;return{version:C,name:h,subscriptionId:s,ownerDid:d||"",isAvailable:f,errorCode:f?0:A.UNAUTHORIZED,isSiteAdmin:g==="true"}}return{version:C,name:h,subscriptionId:s,ownerDid:d,isAvailable:p==="true",errorCode:parseInt(m,10),isSiteAdmin:g==="true"}},{refreshDeps:[e].concat(n),onError(a){console.error(a)}})}const w6=U1.flatten({common:{cancel:"Cancel",confirm:"Confirm",delete:"Delete",error:"Error",open:"Open",unknown:"Unknown",invalidUrl:"Invalid url: {url}",upgrade:"Upgrade",viewMore:"View More"},storage:{spaces:{authorize:{title:"Connect {appName} to DID Spaces",scan:"Use your DID Wallet to scan the QR code below to allow the app {appName} to connect to DID Spaces",success:"Connected successfully"},connect:{reconnect:"Reconnect Now",useSpaceGateway:"Connect using the DID Spaces gateway",useWallet:"Connect to DID Spaces",howToGetGatewayUrl:"How to get the url of did spaces",providerForStorage:"Please connect your DID Spaces"},connected:{title:"Connected DID Spaces",tag:"Connected"},disconnected:{tag:"Disconnected"},error:{tag:"Need Attention",blockedByCors:"Access blocked by CORS",unreachable:"DID Space is unreachable",expired:"DID Spaces has expired, click this link to re-subscribe",pastDue:"DID Spaces has unpaid bills, click this link to complete payment",invalid:"DID Spaces subscription anomaly, click this link to check",unitLimit:"DID Spaces free quota has been used up, click this link to pay for the upgrade",cors:`The connection request may fail due to CORS restrictions:
2
2
  1. Please contact the DID Space administrator to verify the relevant configuration.
3
3
  2. If you are the administrator, click the link below to view the detailed setup guide and resolve the issue.`,networkError:"DID Space is currently unreachable due to potential server issues, network problems, or maintenance. Please click the link to visit the homepage and check its status.",incompatible:`The current connection of DID Spaces version ({spaceVersion}) is not compatible with the component version ({expectVersion}). Please contact the administrator for adjustments.
4
4
  If you are the administrator, you can click the link below to take action.`},gateway:{add:{invalidUrl:"Invalid DID Spaces gateway url",label:"Enter the url of the DID Spaces",title:"Add DID Spaces"}},provideNFT:{title:"Please show the DID Spaces NFT for {appName}",scan:"Use your DID Wallet to scan the QR code below to allow the app {appName} show DID Spaces NFT",success:"Connected successfully"},helperText:{fixCorsError:"Fixing CORS Errors When Connecting to DID Spaces"}}},auditLog:{backup:{description:"A backup operation was completed {relativeTime}"},restore:{description:"A restore operation was completed {relativeTime}"},connected:{description:"A connection was established {relativeTime}"},disconnected:{description:"The connection was disconnected {relativeTime}"},objectsSync:{description:"{totalCount} objects ({size}) were synchronized {relativeTime}"}}}),I6=U1.flatten({common:{cancel:"取消",confirm:"确认",delete:"删除",error:"错误",open:"打开",unknown:"未知",invalidUrl:"无效的 url: {url}",upgrade:"升级",viewMore:"查看更多"},storage:{spaces:{authorize:{title:"连接 {appName} 至 DID Spaces",scan:"使用你的 DID Wallet 扫描下面的二维码以允许应用 {appName} 连接至 DID Spaces",success:"连接成功"},connect:{reconnect:"立即重连",useSpaceGateway:"使用 DID Spaces 网关连接",useWallet:"连接至 DID Spaces",howToGetGatewayUrl:"如何获取 DID Spaces 的网关地址",providerForStorage:"请连接您的 DID Spaces"},connected:{title:"已连接的 DID Spaces",tag:"已连接"},disconnected:{tag:"连接已断开"},error:{tag:"需要关注",blockedByCors:"因 CORS 限制,访问被阻止",unreachable:"DID Space 无法访问",expired:"DID Spaces 已过期,点击此链接重新订阅",pastDue:"DID Spaces 有未支付账单,点击此链接完成支付",invalid:"DID Spaces 订阅异常,点击此链接检查",unitLimit:"DID Spaces 免费额度已用完,点击此链接付费升级",cors:`连接请求可能因 CORS 限制而失败: