@abtnode/blocklet-services 1.16.52-beta-20251008-114302-27406d2c → 1.16.53-beta-20251009-103017-c7694a7e

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 (123) hide show
  1. package/dist/assets/{access-control-DmggL7jZ.js → access-control-CTocOnrY.js} +1 -1
  2. package/dist/assets/{add-component-core-DWKb11rZ.js → add-component-core-ChMhkX_e.js} +1 -1
  3. package/dist/assets/{add-resource-CIE_Ytx_.js → add-resource-BQMxE4TR.js} +1 -1
  4. package/dist/assets/{addon-DHl2cxRr.js → addon-B1SOMf-o.js} +1 -1
  5. package/dist/assets/{advanced-BSm5CLLg.js → advanced-BeUvs5a-.js} +1 -1
  6. package/dist/assets/{aigne-BaADN_Ge.js → aigne-BFbK-Dx1.js} +1 -1
  7. package/dist/assets/{appearance-BUZooc3t.js → appearance-BjJHVOrD.js} +1 -1
  8. package/dist/assets/{arrow-down.svg-Di8Y-JsX.js → arrow-down.svg-CnYWDYHP.js} +1 -1
  9. package/dist/assets/{audit-logs-eECPB5oA.js → audit-logs-CYyFSo7D.js} +1 -1
  10. package/dist/assets/{authorize-0PkXj9UT.js → authorize-C9NR3hcn.js} +1 -1
  11. package/dist/assets/{bind-account-DP1UFrvX.js → bind-account-EzHCVNcL.js} +1 -1
  12. package/dist/assets/{branding-CAzTSYks.js → branding-C6k_gnic.js} +1 -1
  13. package/dist/assets/{branding-BkGIm8P3.js → branding-D14MEcTS.js} +1 -1
  14. package/dist/assets/{branding-CbllXHP7.js → branding-iucefL5d.js} +1 -1
  15. package/dist/assets/{bundle-avatar-sZTyiJPk.js → bundle-avatar-Bbip6Pw_.js} +1 -1
  16. package/dist/assets/{complete-mBrYJnVB.js → complete-DBBI-G-v.js} +1 -1
  17. package/dist/assets/{component-CnoEGL3c.js → component-BuKDir1W.js} +2 -2
  18. package/dist/assets/{config-C75mhsiC.js → config-B7yZVsVx.js} +1 -1
  19. package/dist/assets/{config-xHTw-lTo.js → config-CGESXcGy.js} +1 -1
  20. package/dist/assets/{config-navigation-DWOLS3z9.js → config-navigation-Ci4sw2Mg.js} +2 -2
  21. package/dist/assets/{config-space-BhJD7jRS.js → config-space-CIxZdD1U.js} +1 -1
  22. package/dist/assets/{config-Bkb5q4ut.js → config-uTQPBtNY.js} +1 -1
  23. package/dist/assets/{confirm-CbKYjtHR.js → confirm-CRSsToIg.js} +1 -1
  24. package/dist/assets/{connect--3Rc5BLv.js → connect-BA-e5Sky.js} +1 -1
  25. package/dist/assets/{connect-2JyiC0Xu.js → connect-D_SRcELW.js} +1 -1
  26. package/dist/assets/{connect-to-jAGN3h14.js → connect-to-DPxJtWAi.js} +1 -1
  27. package/dist/assets/{dashboard-Bl5ef4iX.js → dashboard-CdEA39BJ.js} +2 -2
  28. package/dist/assets/{delete-confirm-DwRy8bv4.js → delete-confirm-BOL7KX0x.js} +1 -1
  29. package/dist/assets/{domain-BRz6giPY.js → domain-C02xJ2j2.js} +1 -1
  30. package/dist/assets/{domain-action-card-BkD9wIWF.js → domain-action-card-BYDa5XpT.js} +1 -1
  31. package/dist/assets/{domains-CNFr3aJ9.js → domains-CeH-Is8l.js} +1 -1
  32. package/dist/assets/{email-CeJztQEY.js → email-CgqDRKYJ.js} +1 -1
  33. package/dist/assets/engine-Dde2jLpF.js +1 -0
  34. package/dist/assets/{exchange-passport-gkmIW3RX.js → exchange-passport-SXEaleiF.js} +1 -1
  35. package/dist/assets/{form-Dv0kmMaX.js → form-kOntOXIX.js} +1 -1
  36. package/dist/assets/{fuel-CUYeoZDd.js → fuel-DvIA5Tre.js} +1 -1
  37. package/dist/assets/{gen-access-key-SE9pLi9q.js → gen-access-key-D6gAc7bG.js} +1 -1
  38. package/dist/assets/{gen-simple-access-key-CSKqRGTV.js → gen-simple-access-key-BfvI0i1-.js} +1 -1
  39. package/dist/assets/{get-safe-url-sB_Gq16A.js → get-safe-url-BVWVLDco.js} +1 -1
  40. package/dist/assets/{home-BnT7J-uf.js → home-Bbu96BmU.js} +1 -1
  41. package/dist/assets/{iframe-DsSE-oEM.js → iframe-B-WaBiaG.js} +1 -1
  42. package/dist/assets/{index-PgN3JS_8.js → index-B0HVlpUv.js} +1 -1
  43. package/dist/assets/{index-CM4RAJ4n.js → index-B5ctIRcA.js} +1 -1
  44. package/dist/assets/{index-BcQQWjIN.js → index-B9UOYoTi.js} +1 -1
  45. package/dist/assets/{index-BEC672yJ.js → index-BPjsO-fA.js} +1 -1
  46. package/dist/assets/{index-CgGF98-I.js → index-BWkRqWUV.js} +1 -1
  47. package/dist/assets/{index-DZsbm1LJ.js → index-Bne2IVDb.js} +2 -2
  48. package/dist/assets/{index-DmYn3vUs.js → index-BqNVAj3b.js} +1 -1
  49. package/dist/assets/{index-BtpIrTNZ.js → index-BtyqZ8ix.js} +1 -1
  50. package/dist/assets/{index-BMQaM_ON.js → index-BwK-dbsY.js} +1 -1
  51. package/dist/assets/{index-0863PXVJ.js → index-C5weIh5R.js} +4 -4
  52. package/dist/assets/{index-C3yfW-2l.js → index-CCGTCthU.js} +1 -1
  53. package/dist/assets/{index-3WoNnYUW.js → index-CW83LAem.js} +1 -1
  54. package/dist/assets/{index-UrBf_SB9.js → index-ChG9_ZZV.js} +1 -1
  55. package/dist/assets/{index-BPURBp6_.js → index-CsM_pYF8.js} +1 -1
  56. package/dist/assets/{index-DvDgqPNe.js → index-CuH2SZN0.js} +1 -1
  57. package/dist/assets/{index-Dy8Kzeqi.js → index-Czh1GNRc.js} +1 -1
  58. package/dist/assets/{index-gv-XKOxx.js → index-DI0tEMGN.js} +1 -1
  59. package/dist/assets/{index-WBm9SNDx.js → index-DeWjB4q9.js} +1 -1
  60. package/dist/assets/{index-Cn4da4ZP.js → index-Dn2h6APz.js} +1 -1
  61. package/dist/assets/{index-mXteQQPA.js → index-DtY0rQzd.js} +3 -3
  62. package/dist/assets/{index-2fKHLT0z.js → index-EE_leCro.js} +1 -1
  63. package/dist/assets/{index-CKsdJhzZ.js → index-KhL4--33.js} +1 -1
  64. package/dist/assets/{index-B6_ijjdG.js → index-MSxXwe2g.js} +1 -1
  65. package/dist/assets/{index-C8Q2YcwS.js → index-MjpHZ4K2.js} +1 -1
  66. package/dist/assets/{index-CMvQOzZf.js → index-pSrG3Rtm.js} +1 -1
  67. package/dist/assets/{index-B5D1W27l.js → index-yyZ56Avq.js} +1 -1
  68. package/dist/assets/{invitation-D8EnCl9v.js → invitation-DvFWKTOM.js} +1 -1
  69. package/dist/assets/{invitations-CRg01RPR.js → invitations-CD5qt7h8.js} +1 -1
  70. package/dist/assets/{invite-62TCTCVU.js → invite-CMqMLqon.js} +1 -1
  71. package/dist/assets/{isURL-DbBjhWuw.js → isURL-Drc7oe8g.js} +1 -1
  72. package/dist/assets/{issue-passport-hXFTyGgX.js → issue-passport-BR40SDVR.js} +1 -1
  73. package/dist/assets/{item-BJo9HqUj.js → item-DwykRAIj.js} +1 -1
  74. package/dist/assets/{landing-page-CC5bHMck.js → landing-page-BTu1Wo51.js} +1 -1
  75. package/dist/assets/{layout-ByznRMFd.js → layout-_Ka_GN5x.js} +1 -1
  76. package/dist/assets/{list-Bx2-rBf0.js → list-C4b_Znkz.js} +1 -1
  77. package/dist/assets/{list-9Jqi3lQE.js → list-TG9HMVa3.js} +1 -1
  78. package/dist/assets/{localization-CFDfUyEy.js → localization-CqBu9Ts-.js} +1 -1
  79. package/dist/assets/{log-DCvCOn17.js → log-BFOgPn13.js} +1 -1
  80. package/dist/assets/{login-f_fCkRk4.js → login-CUoIcXNe.js} +1 -1
  81. package/dist/assets/{login-oauth-callback-C24AF8iv.js → login-oauth-callback-BuNQ-CRv.js} +1 -1
  82. package/dist/assets/{logo-uploader-lmGtrzV4.js → logo-uploader-l9C8sEUo.js} +1 -1
  83. package/dist/assets/{lost-passport-Dswad9ou.js → lost-passport-lnqu8OpR.js} +1 -1
  84. package/dist/assets/{open-window-DarxerYh.js → open-window-B52q5qrk.js} +1 -1
  85. package/dist/assets/{over-due-invoice-payment-Bof_qZPj.js → over-due-invoice-payment-DKbbN5W7.js} +1 -1
  86. package/dist/assets/{overview-3AanlBU3.js → overview-BITUbq3E.js} +1 -1
  87. package/dist/assets/{passport-NHswVCpX.js → passport-WPJBoZJA.js} +1 -1
  88. package/dist/assets/{passport-item-CIkdGD7k.js → passport-item-gIxDDwjF.js} +1 -1
  89. package/dist/assets/{permission-C6ZxgW4_.js → permission-BeGf253a.js} +1 -1
  90. package/dist/assets/{preferences-c_uf0vV_.js → preferences-D0Ol69r8.js} +1 -1
  91. package/dist/assets/{profile-embed-zfqLFKjJ.js → profile-embed-YGIFeQVj.js} +1 -1
  92. package/dist/assets/{publish-resource-C-rSUOye.js → publish-resource-fDNwoZVu.js} +1 -1
  93. package/dist/assets/{runtime-C43nnM4D.js → runtime-DPpYl0V4.js} +1 -1
  94. package/dist/assets/sdk-Jn7q4_AB.js +1 -0
  95. package/dist/assets/{security-DrN96KLp.js → security-Jp9VavjR.js} +1 -1
  96. package/dist/assets/{session-BU5Mzwxi.js → session-DEBZccHT.js} +1 -1
  97. package/dist/assets/{setup-Boeg5oQO.js → setup-3SRIuMWN.js} +1 -1
  98. package/dist/assets/{spaces-DOKeNRJF.js → spaces-_v4BsoCo.js} +1 -1
  99. package/dist/assets/{start-D12bNg0Z.js → start-BaF8jQQs.js} +1 -1
  100. package/dist/assets/{starting-progress-CCgq7_fl.js → starting-progress-Bdr1122s.js} +1 -1
  101. package/dist/assets/{status-q9lLrXQc.js → status-Kru479eT.js} +1 -1
  102. package/dist/assets/{step-actions-q6EMp_pM.js → step-actions-z2PSGmvy.js} +1 -1
  103. package/dist/assets/{studio-Cwi9XV2J.js → studio-C8Cis2HF.js} +1 -1
  104. package/dist/assets/{team-8eI9KzkS.js → team-DjK1LiLV.js} +1 -1
  105. package/dist/assets/{traffic-C-k1EeLv.js → traffic-CxwOXUbM.js} +1 -1
  106. package/dist/assets/{transfer-DkQcWtDu.js → transfer-M0yRAOWx.js} +1 -1
  107. package/dist/assets/{unsubscribe-DEQjVih1.js → unsubscribe-CULX4z09.js} +1 -1
  108. package/dist/assets/{use-app-logo-CPtVQ5QR.js → use-app-logo-BOmNYQgU.js} +1 -1
  109. package/dist/assets/{user-center-Bi3mP5L8.js → user-center-1elUCI9j.js} +2 -2
  110. package/dist/assets/{user-follower-ov8u2bSJ.js → user-follower-CYu4VkvK.js} +1 -1
  111. package/dist/assets/{user-sessions-CgEW_AWu.js → user-sessions-B_eqpmUt.js} +1 -1
  112. package/dist/assets/{util-6epwbzsz.js → util-DUiP0chO.js} +1 -1
  113. package/dist/assets/{util-D8_x37fq.js → util-DY1uHmM4.js} +1 -1
  114. package/dist/assets/{wait-connect-BAJddb0h.js → wait-connect-DMl1x3Ld.js} +1 -1
  115. package/dist/assets/{wizard-hHM4x0st.js → wizard-Cq7OgF_R.js} +1 -1
  116. package/dist/assets/{wizard-components-B_tklig-.js → wizard-components-CseIhcl0.js} +1 -1
  117. package/dist/assets/{wrap-locale-DAwNWfLv.js → wrap-locale-DtJXVWeM.js} +1 -1
  118. package/dist/assets/{zh-CNEGT1hb.js → zh-DS2mQXmf.js} +1 -1
  119. package/dist/index.html +1 -1
  120. package/dist/service-worker.js +1 -1
  121. package/package.json +23 -23
  122. package/dist/assets/engine-B4S5pKzm.js +0 -1
  123. package/dist/assets/sdk-CJ48BTlZ.js +0 -1
@@ -1,4 +1,4 @@
1
- import{j as e,ak as m,b4 as st,W as h,ar as A,cx as ot,a$ as it,T as L,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 kt,x as Dt,bc as Mt,M as zt}from"./vendor-mui-core-DRxbhqaK.js";import{T as N,H as O,j as Be,I as Se,P as Re,k as _e,c as Rt,a0 as Et,b as ge,n as Ee}from"./vendor-ux-B9VfuZTg.js";import{r as C,i as qe,k as Wt}from"./vendor-react-Dvs43sk9.js";import{g as G,b as y,k as Ue,a as At,v as Lt,o as Nt,c as Bt}from"./vendor-hooks-BlA8TRnZ.js";import{B as ie,l as ae,o as ue}from"./index-UrBf_SB9.js";import{u as He}from"./team-8eI9KzkS.js";import{c as Pe,X as Fe,aW as _t,V as qt,b7 as Ut,o as Ht}from"./index-0863PXVJ.js";import{u as $e}from"./use-mobile-BQQpAf3i.js";import{A as Ft}from"./actions-B4VXcSRp.js";import{u as Je}from"./session-BU5Mzwxi.js";import{f as E}from"./index-DBs9Ljax.js";import{v as Ce}from"./index-Ba9-ArMT.js";import{e as Ke,A as $t,n as te}from"./vendor-utils-CUDP56Ff.js";import{F as We}from"./form-text-input-CwOsIY5R.js";import{e as Jt}from"./edit.svg-DycWG9v3.js";import{C as Kt}from"./lock.svg-COUP8tyO.js";import{D as Vt,a as Gt,b as Xt,M as Qt}from"./index-gv-XKOxx.js";import{c as Yt}from"./passport-NHswVCpX.js";import{C as Zt}from"./click-to-copy-CO6UIqva.js";import{I as er}from"./invitations-CRg01RPR.js";function Ve({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]})]})}Ve.propTypes={members:h.array.isRequired,total:h.number.isRequired};function Ge({org:t={},loading:o=!1}){const{t:a,locale:i}=N();return t.id?o?e.jsxs(m,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(A,{variant:"text",width:50,height:24}),e.jsx(A,{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(L,{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(A,{variant:"text",width:25,height:25}):e.jsx(L,{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(L,{variant:"h4",sx:{overflow:"hidden",display:"-webkit-box",WebkitLineClamp:1,WebkitBoxOrient:"vertical",textOverflow:"ellipsis"},children:o?e.jsx(A,{variant:"text",width:"10%",height:24}):t.name||"-"}),e.jsx(L,{variant:"body1",sx:{fontSize:14,lineHeight:1.2,overflow:"hidden",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical"},children:o?e.jsx(A,{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(A,{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:Er}=Qe,we={type:"",org:{},paging:{page:1,pageSize:10}};function nr({children:t,editable:o=!0,mode:a="user-center",id:i=""}){const{t:r}=N(),{api:s}=Fe(),{teamDid:u}=He(),{session:b}=Je(),[g,v]=C.useState(!1),[I,c]=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"}))}),k=G({mode:"",org:null}),j=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=y(async({org:n={},type:l="",paging:p={page:1,pageSize:10}})=>{try{v(!0);const R=await s.getOrgs({input:{teamDid:u,paging:p,org:n,...l?{type:l}:{}}});return z.all={org:n,paging:p,type:l},R}catch(R){console.error(R),O.error(E(R));return}finally{v(!1)}}),M=y(async({org:n={},paging:l={page:1,pageSize:10}})=>{try{v(!0);const p=await s.getOrgs({input:{teamDid:u,paging:l,org:n,type:"owned"}});return c(p?.paging?.total||0),z.myCreated={org:n,paging:l,type:"owned"},p}catch(p){console.error(p),O.error(E(p));return}finally{v(!1)}}),W=y(async({org:n={},paging:l={page:1,pageSize:10}})=>{try{v(!0);const p=await s.getOrgs({input:{teamDid:u,paging:l,org:n,type:"joined"}});return z.myJoined={org:n,paging:l,type:"joined"},p}catch(p){console.error(p),O.error(E(p));return}finally{v(!1)}}),D=y(()=>{T(n=>n+1)}),F=y(async n=>{try{await s.deleteOrg({input:{teamDid:u,id:n.id}}),D()}catch(l){console.error(l),O.error(E(l))}}),pe=y(n=>new Promise((l,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(),l()},onCancel:()=>{p()}})})),xe=y(async n=>{try{await s.updateOrg({input:{teamDid:u,org:n}}),O.success(r("team.orgs.mutate.updateSuccess"))}catch(l){console.error(l),O.error(E(l))}}),ee=y(async n=>{try{await s.createOrg({input:{teamDid:u,name:n.name,description:n.description}}),O.success(r("team.orgs.mutate.createSuccess")),D()}catch(l){console.error(l),O.error(E(l))}}),K=y(async(n,l=f.membersPaging)=>{try{const p=await s.getOrgMembers({input:{teamDid:u,orgId:n,paging:l}});f.members=p.users,f.membersPaging=p.paging}catch(p){console.error(p),O.error(E(p))}}),ne=y(async(n,l={page:1,pageSize:10})=>{try{const p=await s.getInvitations({input:{teamDid:u,orgId:n,paging:l}});f.invitations=p.invitations}catch(p){console.error(p),O.error(E(p))}}),Q=y(async n=>{try{const l=await s.getRoles({input:{teamDid:u,orgId:n}});f.roles=l.roles,j.roles=l.roles}catch(l){console.error(l),O.error(E(l))}}),he=y(async(n,l)=>{try{await s.removeOrgMember({input:{teamDid:u,orgId:n,userDid:l}}),O.success(r("team.orgs.invite.removeSuccess")),Promise.all([K(n),ne(n)])}catch(p){console.error(p),O.error(E(p))}}),Y=y((n,l)=>{const{user:p,status:R}=l,$=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=y(async n=>{try{const l=await s.getOrg({input:{teamDid:u,id:n}});f.org=l.org,f.error=null,f.editable=o?l?.org?.ownerDid===x:!1}catch(l){f.error=E(l),console.error(l),O.error(E(l))}}),fe=y(n=>{if(!U?.enabled){O.error(r("team.orgs.mutate.orgNotEnabled"));return}k.org=n,k.mode="update"}),be=y(()=>{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}k.org={},k.mode="create"}),ve=y(({org:n,open:l=!1,mode:p="list"})=>{if(l&&n){if(j.org=n,j.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 j.mode="list",j.org=null,j.roles=[],j.inviteLink="";j.showInvite=l}),Me=y(({org:n,open:l=!1})=>{j.showInviting=l,j.org=l?n:null}),V=y(()=>{k.org=null,k.mode=""}),d=y(async n=>{try{if(f.loading=!0,await se(n),f.error)return;f.editable?await Promise.all([K(n),ne(n),Q(n)]):await Promise.all([K(n),Q(n)])}catch(l){console.error(l)}finally{f.loading=!1}}),P=y(async({userDids:n,role:l,email:p,inviteType:R})=>{try{const{org:$}=j||{};if(!$)throw new Error(400,"Org is not found");j.loading=!0;const ye=await s.inviteMembersToOrg({input:{userDids:n,email:p,teamDid:u,orgId:$.id,role:l,inviteType:R}}),{failedDids:le,inviteLink:je}=ye.data||{};R==="external"?j.inviteLink=je:le.length?O.success(r("team.orgs.invite.failed",{count:le.length})):O.success(r("team.orgs.invite.success")),j.mode==="detail"?d($.id):D()}catch($){console.error($),O.error(E($))}finally{j.loading=!1}}),B=y(({org:n,mode:l="create",open:p=!1,item:R=null})=>{S.visible=p,S.org=p?n:null,S.mode=p?l:"create",S.item=p&&l==="update"?R:null});C.useEffect(()=>{i&&d(i)},[i,d]);const q={editable:o,refresh:D,refreshTrigger:w,loading:g,mode:a,teamDid:u,onTriggerEditOrg:fe,onTriggerCreateOrg:be,onCancelMutateOrg:V,mutationParams:k,inviteParams:{...j,onTriggerInviteDialog:ve,onTriggerInvitingDialog:Me},orgDetail:{...f,refresh:d},passportParams:{...S,onTriggerPassportDialog:B},requests:{getAllOrgs:re,getMyCreatedOrgs:M,getMyJoinedOrgs:W,deleteOrg:pe,updateOrg:xe,createOrg:ee,getOrgMembers:K,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(A,{variant:"circular",width:32,height:32})}),e.jsxs(m,{sx:{flex:1},children:[e.jsx(A,{variant:"text",width:a.name,height:20,sx:{mb:.5}}),e.jsx(A,{variant:"text",width:a.info,height:16,sx:{mb:.25}})]})]})}Ye.propTypes={index:h.number};function sr(){const{t,locale:o}=N(),{orgDetail:a,requests:i}=_(),{org:r,members:s,loading:u,editable:b,membersPaging:g}=a||{},v=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))},c=[{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,k=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&&!k?()=>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:j=>{j.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:k=[]}=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:[k.map(j=>e.jsx(Z,{label:j.title,size:"small",sx:{flexShrink:0}},j.id)),x.status==="inviting"?e.jsx(Z,{label:t("common.inviting"),size:"small",sx:{backgroundColor:ce(v.palette.warning.main,.15),color:v.palette.warning.dark,flexShrink:0}}):e.jsx(Z,{label:t("team.orgs.active"),size:"small",sx:{backgroundColor:ce(v.palette.success.main,.15),color:v.palette.success.dark,flexShrink:0}}),x.updatedAt&&e.jsxs(L,{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:[k.map(j=>e.jsx(Z,{label:j.title,size:"small"},j.id)),x.status==="inviting"?e.jsx(Z,{label:t("common.inviting"),size:"small",sx:{backgroundColor:ce(v.palette.warning.main,.15),color:v.palette.warning.dark}}):e.jsx(Z,{label:t("team.orgs.active"),size:"small",sx:{backgroundColor:ce(v.palette.success.main,.15),color:v.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(L,{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:c,loading:u,onChange:I,locale:o,options:w})})}function or(){const{t}=N(),{orgDetail:o,inviteParams:a}=_(),{invitations:i,editable:r,org:s}=o||{};return r?e.jsxs(m,{sx:{display:"flex",gap:1},children:[e.jsxs(J,{variant:"outlined",style:{flexShrink:0},color:"primary",size:"small",onClick:()=>{a.onTriggerInvitingDialog({org:s,open:!0})},children:[e.jsx(Re,{style:{height:"1em",marginRight:4},icon:"tabler:user"}),t("common.inviting"),i.length?` (${i.length})`:""]}),e.jsx(J,{variant:"contained",size:"small",onClick:()=>{a.onTriggerInviteDialog({org:s,open:!0,mode:"detail"})},startIcon:e.jsx(Re,{style:{fontSize:14},icon:"tabler:user-plus"}),children:t("common.invite")})]}):null}function ke({children:t,...o}){const a=$e(),[i,r]=C.useState(!1),s=y(()=>{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})}ke.propTypes=de.propTypes;ke.defaultProps=de.defaultProps;function ir(){const{orgDetail:t,requests:o}=_(),{org:a,loading:i,editable:r}=t||{},{t:s,locale:u}=N(),b=qe(),g=C.useMemo(()=>{const{settings:c={}}=window.blocklet||{};return Ke(c,"org.maxMemberPerOrg",100)},[]),v=y(async(c,w)=>{const T={...$t(a,["id","name","description"]),[c]:w};await o.updateOrg(T),t.refresh(T.id)}),I=y(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(We,{style:{marginTop:0},disabled:i,loading:i,initialValue:a.name,onSubmit:c=>v("name",c)}):a.name},a.name),e.jsx(Ce,{valueComponent:"div",nameWidth:180,name:s("common.description"),children:r?e.jsx(We,{style:{marginTop:0},disabled:i,loading:i,initialValue:a.description,type:"textarea",rows:3,onSubmit:c=>v("description",c)}):a.description},a.description),e.jsx(Ce,{valueComponent:"div",nameWidth:180,name:e.jsxs(L,{sx:{display:"flex",alignItems:"center",gap:.5},children:[s("team.orgs.invite.maxMembers"),e.jsx(ke,{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(Vt,{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(Kt,{}):e.jsx(Jt,{})}):null,passportProps:{issuer:i.name,issuerDid:i.ownerDid,ownerDid:i.ownerDid,preferredColor:b}},g.name))}),s&&e.jsx(Xt,{onCancel:()=>u(!1),roles:a,onSuccess:()=>{u(!1),o.getOrgRoles(i.id)},onDelete:()=>{u(!1),o.getOrgRoles(i.id)},mode:"update",roleName:s.name,item:s,orgId:i.id,hasPermission:r})]})}function lr(){const{t}=N(),{orgDetail:o,passportParams:a}=_(),{org:i,editable:r}=o||{};return r?e.jsx(m,{sx:{display:"flex",gap:1},children:e.jsx(J,{variant:"contained",size:"small",onClick:()=>{a.onTriggerPassportDialog({org:i,open:!0})},startIcon:e.jsx(xt,{}),children:t("team.passport.create.title")})}):null}function cr(){const{teamDid:t,passportParams:o,requests:a}=_(),{visible:i,org:r}=o||{};return i?e.jsx(Qt,{teamDid:t,orgId:r.id,onCancel:()=>o.onTriggerPassportDialog({open:!1}),onSuccess:()=>{o.onTriggerPassportDialog({open:!1}),a.getOrgRoles(r.id)}}):null}function De({id:t="",inDialog:o=!1}){const{orgDetail:a}=_(),{t:i}=N(),[r,s]=C.useState("members"),{org:u,loading:b,refresh:g,error:v}=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]),v)return e.jsx(_e,{children:v});if(!u)return null;const c=()=>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:c()}),e.jsxs(m,{sx:{mt:2},children:[r==="members"&&e.jsx(sr,{}),r==="settings"&&e.jsx(ir,{}),r==="passports"&&e.jsx(ar,{})]})]})]})]})}De.propTypes={id:h.string,inDialog:h.bool};function dr(){const{t,locale:o}=C.useContext(Rt),{teamDid:a}=He(),i=C.useRef(null),[r,s]=C.useState(null),[u,b]=C.useState(0),g=$e(),v=`orgs-${a}`,I=Et(v),c=G({searchText:I.searchText||"",pageSize:I.rowsPerPage||10,page:1}),{editable:w,loading:T,requests:f,onTriggerEditOrg:x,onTriggerCreateOrg:z,refreshTrigger:k}=_(),{data:j,refresh:S}=Ue(async()=>{const M={};c.searchText&&(M.name=c.searchText,M.description=c.searchText);const{orgs:W,paging:D}=await f.getAllOrgs({org:M,paging:{page:c.page,pageSize:c.pageSize}});return b(D.total),W},{refreshDeps:[a,c.page,c.pageSize,c.searchText],onError:M=>{O.error(E(M))}}),U=({page:M,rowsPerPage:W,searchText:D})=>{c.pageSize!==W?(c.pageSize=W,c.page=1):c.page!==M+1?c.page=M+1:c.searchText!==D&&(c.searchText=D,c.page=1)};C.useEffect(()=>{k>0&&S&&S()},[k,S]);const H=[{label:t("common.orgs"),name:"name"},{label:t("common.members"),name:"members",options:{customBodyRender:(M,{rowIndex:W})=>{const D=j[W];return e.jsx(Ve,{members:D.members,total:D.membersCount})}}},{label:t("team.orgs.description"),name:"description"},{label:t("common.createdBy"),name:"owner",options:{customBodyRender:(M,{rowIndex:W})=>{const D=j[W];return e.jsx(m,{children:e.jsx(ie,{showHoverCard:!1,avatarSize:32,did:D.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:W})=>{const D=j[W];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(D)}},{icon:e.jsx(oe,{}),text:t("common.delete"),onClick:F=>{F.stopPropagation(),f.deleteOrg(D)}}]})})}}}],X={sort:!1,download:!1,filter:!1,print:!1,expandableRowsOnClick:!0,onRowClick(M,W,D){if(i.current?.contains(D.target)){const F=j[W.dataIndex];s(F)}},page:c.page-1,rowsPerPage:c.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:j||[],locale:o,durable:v,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(De,{id:r.id,inDialog:!0})})]})}function Ze({org:t,onInviteUser:o=te,onDelete:a=te,onClick:i=te,loading:r=!1,editable:s=!0}){const{t:u}=N(),{session:b}=Je(),g=C.useMemo(()=>b?.user?.did===t.ownerDid,[b?.user?.did,t.ownerDid]),v=()=>s?e.jsxs(e.Fragment,{children:[e.jsx(Ae,{variant:"outlined",size:"small",startIcon:e.jsx(jt,{style:{fontSize:16}}),onClick:c=>{c.stopPropagation(),o?.(t)},children:u("common.invite")}),e.jsx(Ae,{variant:"contained",color:"error",size:"small",startIcon:e.jsx(oe,{style:{fontSize:16}}),onClick:c=>{c.stopPropagation(),a?.(t)},children:u("common.delete")})]}):null,I=y(()=>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(A,{variant:"text",width:"100%",height:24}):e.jsx(L,{variant:"h4",sx:{fontWeight:600},children:t.name}),r?e.jsx(A,{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(L,{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(A,{variant:"text",width:"100%",height:24}),e.jsx(A,{variant:"text",width:"80%",height:24})]}):t.description}),e.jsxs(m,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[r?e.jsx(A,{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(A,{variant:"text",width:50,height:24}),e.jsx(A,{variant:"text",width:50,height:24})]}):v()})]})]})]})})}Ze.propTypes={org:h.object.isRequired,onInviteUser:h.func,onDelete:h.func,onClick:h.func,loading:h.bool,editable:h.bool};const Ae=Ct(J)`
1
+ import{j as e,ak as m,b4 as st,W as h,ar as A,cx as ot,a$ as it,T as L,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 kt,x as Dt,bc as Mt,M as zt}from"./vendor-mui-core-DRxbhqaK.js";import{T as N,H as O,j as Be,I as Se,P as Re,k as _e,c as Rt,a0 as Et,b as ge,n as Ee}from"./vendor-ux-B9VfuZTg.js";import{r as C,i as qe,k as Wt}from"./vendor-react-Dvs43sk9.js";import{g as G,b as y,k as Ue,a as At,v as Lt,o as Nt,c as Bt}from"./vendor-hooks-BlA8TRnZ.js";import{B as ie,l as ae,o as ue}from"./index-ChG9_ZZV.js";import{u as He}from"./team-DjK1LiLV.js";import{c as Pe,X as Fe,aW as _t,V as qt,b7 as Ut,o as Ht}from"./index-C5weIh5R.js";import{u as $e}from"./use-mobile-BQQpAf3i.js";import{A as Ft}from"./actions-B4VXcSRp.js";import{u as Je}from"./session-DEBZccHT.js";import{f as E}from"./index-DBs9Ljax.js";import{v as Ce}from"./index-Ba9-ArMT.js";import{e as Ke,A as $t,n as te}from"./vendor-utils-CUDP56Ff.js";import{F as We}from"./form-text-input-CwOsIY5R.js";import{e as Jt}from"./edit.svg-DycWG9v3.js";import{C as Kt}from"./lock.svg-COUP8tyO.js";import{D as Vt,a as Gt,b as Xt,M as Qt}from"./index-DI0tEMGN.js";import{c as Yt}from"./passport-WPJBoZJA.js";import{C as Zt}from"./click-to-copy-CO6UIqva.js";import{I as er}from"./invitations-CD5qt7h8.js";function Ve({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]})]})}Ve.propTypes={members:h.array.isRequired,total:h.number.isRequired};function Ge({org:t={},loading:o=!1}){const{t:a,locale:i}=N();return t.id?o?e.jsxs(m,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(A,{variant:"text",width:50,height:24}),e.jsx(A,{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(L,{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(A,{variant:"text",width:25,height:25}):e.jsx(L,{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(L,{variant:"h4",sx:{overflow:"hidden",display:"-webkit-box",WebkitLineClamp:1,WebkitBoxOrient:"vertical",textOverflow:"ellipsis"},children:o?e.jsx(A,{variant:"text",width:"10%",height:24}):t.name||"-"}),e.jsx(L,{variant:"body1",sx:{fontSize:14,lineHeight:1.2,overflow:"hidden",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical"},children:o?e.jsx(A,{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(A,{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:Er}=Qe,we={type:"",org:{},paging:{page:1,pageSize:10}};function nr({children:t,editable:o=!0,mode:a="user-center",id:i=""}){const{t:r}=N(),{api:s}=Fe(),{teamDid:u}=He(),{session:b}=Je(),[g,v]=C.useState(!1),[I,c]=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"}))}),k=G({mode:"",org:null}),j=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=y(async({org:n={},type:l="",paging:p={page:1,pageSize:10}})=>{try{v(!0);const R=await s.getOrgs({input:{teamDid:u,paging:p,org:n,...l?{type:l}:{}}});return z.all={org:n,paging:p,type:l},R}catch(R){console.error(R),O.error(E(R));return}finally{v(!1)}}),M=y(async({org:n={},paging:l={page:1,pageSize:10}})=>{try{v(!0);const p=await s.getOrgs({input:{teamDid:u,paging:l,org:n,type:"owned"}});return c(p?.paging?.total||0),z.myCreated={org:n,paging:l,type:"owned"},p}catch(p){console.error(p),O.error(E(p));return}finally{v(!1)}}),W=y(async({org:n={},paging:l={page:1,pageSize:10}})=>{try{v(!0);const p=await s.getOrgs({input:{teamDid:u,paging:l,org:n,type:"joined"}});return z.myJoined={org:n,paging:l,type:"joined"},p}catch(p){console.error(p),O.error(E(p));return}finally{v(!1)}}),D=y(()=>{T(n=>n+1)}),F=y(async n=>{try{await s.deleteOrg({input:{teamDid:u,id:n.id}}),D()}catch(l){console.error(l),O.error(E(l))}}),pe=y(n=>new Promise((l,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(),l()},onCancel:()=>{p()}})})),xe=y(async n=>{try{await s.updateOrg({input:{teamDid:u,org:n}}),O.success(r("team.orgs.mutate.updateSuccess"))}catch(l){console.error(l),O.error(E(l))}}),ee=y(async n=>{try{await s.createOrg({input:{teamDid:u,name:n.name,description:n.description}}),O.success(r("team.orgs.mutate.createSuccess")),D()}catch(l){console.error(l),O.error(E(l))}}),K=y(async(n,l=f.membersPaging)=>{try{const p=await s.getOrgMembers({input:{teamDid:u,orgId:n,paging:l}});f.members=p.users,f.membersPaging=p.paging}catch(p){console.error(p),O.error(E(p))}}),ne=y(async(n,l={page:1,pageSize:10})=>{try{const p=await s.getInvitations({input:{teamDid:u,orgId:n,paging:l}});f.invitations=p.invitations}catch(p){console.error(p),O.error(E(p))}}),Q=y(async n=>{try{const l=await s.getRoles({input:{teamDid:u,orgId:n}});f.roles=l.roles,j.roles=l.roles}catch(l){console.error(l),O.error(E(l))}}),he=y(async(n,l)=>{try{await s.removeOrgMember({input:{teamDid:u,orgId:n,userDid:l}}),O.success(r("team.orgs.invite.removeSuccess")),Promise.all([K(n),ne(n)])}catch(p){console.error(p),O.error(E(p))}}),Y=y((n,l)=>{const{user:p,status:R}=l,$=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=y(async n=>{try{const l=await s.getOrg({input:{teamDid:u,id:n}});f.org=l.org,f.error=null,f.editable=o?l?.org?.ownerDid===x:!1}catch(l){f.error=E(l),console.error(l),O.error(E(l))}}),fe=y(n=>{if(!U?.enabled){O.error(r("team.orgs.mutate.orgNotEnabled"));return}k.org=n,k.mode="update"}),be=y(()=>{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}k.org={},k.mode="create"}),ve=y(({org:n,open:l=!1,mode:p="list"})=>{if(l&&n){if(j.org=n,j.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 j.mode="list",j.org=null,j.roles=[],j.inviteLink="";j.showInvite=l}),Me=y(({org:n,open:l=!1})=>{j.showInviting=l,j.org=l?n:null}),V=y(()=>{k.org=null,k.mode=""}),d=y(async n=>{try{if(f.loading=!0,await se(n),f.error)return;f.editable?await Promise.all([K(n),ne(n),Q(n)]):await Promise.all([K(n),Q(n)])}catch(l){console.error(l)}finally{f.loading=!1}}),P=y(async({userDids:n,role:l,email:p,inviteType:R})=>{try{const{org:$}=j||{};if(!$)throw new Error(400,"Org is not found");j.loading=!0;const ye=await s.inviteMembersToOrg({input:{userDids:n,email:p,teamDid:u,orgId:$.id,role:l,inviteType:R}}),{failedDids:le,inviteLink:je}=ye.data||{};R==="external"?j.inviteLink=je:le.length?O.success(r("team.orgs.invite.failed",{count:le.length})):O.success(r("team.orgs.invite.success")),j.mode==="detail"?d($.id):D()}catch($){console.error($),O.error(E($))}finally{j.loading=!1}}),B=y(({org:n,mode:l="create",open:p=!1,item:R=null})=>{S.visible=p,S.org=p?n:null,S.mode=p?l:"create",S.item=p&&l==="update"?R:null});C.useEffect(()=>{i&&d(i)},[i,d]);const q={editable:o,refresh:D,refreshTrigger:w,loading:g,mode:a,teamDid:u,onTriggerEditOrg:fe,onTriggerCreateOrg:be,onCancelMutateOrg:V,mutationParams:k,inviteParams:{...j,onTriggerInviteDialog:ve,onTriggerInvitingDialog:Me},orgDetail:{...f,refresh:d},passportParams:{...S,onTriggerPassportDialog:B},requests:{getAllOrgs:re,getMyCreatedOrgs:M,getMyJoinedOrgs:W,deleteOrg:pe,updateOrg:xe,createOrg:ee,getOrgMembers:K,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(A,{variant:"circular",width:32,height:32})}),e.jsxs(m,{sx:{flex:1},children:[e.jsx(A,{variant:"text",width:a.name,height:20,sx:{mb:.5}}),e.jsx(A,{variant:"text",width:a.info,height:16,sx:{mb:.25}})]})]})}Ye.propTypes={index:h.number};function sr(){const{t,locale:o}=N(),{orgDetail:a,requests:i}=_(),{org:r,members:s,loading:u,editable:b,membersPaging:g}=a||{},v=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))},c=[{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,k=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&&!k?()=>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:j=>{j.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:k=[]}=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:[k.map(j=>e.jsx(Z,{label:j.title,size:"small",sx:{flexShrink:0}},j.id)),x.status==="inviting"?e.jsx(Z,{label:t("common.inviting"),size:"small",sx:{backgroundColor:ce(v.palette.warning.main,.15),color:v.palette.warning.dark,flexShrink:0}}):e.jsx(Z,{label:t("team.orgs.active"),size:"small",sx:{backgroundColor:ce(v.palette.success.main,.15),color:v.palette.success.dark,flexShrink:0}}),x.updatedAt&&e.jsxs(L,{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:[k.map(j=>e.jsx(Z,{label:j.title,size:"small"},j.id)),x.status==="inviting"?e.jsx(Z,{label:t("common.inviting"),size:"small",sx:{backgroundColor:ce(v.palette.warning.main,.15),color:v.palette.warning.dark}}):e.jsx(Z,{label:t("team.orgs.active"),size:"small",sx:{backgroundColor:ce(v.palette.success.main,.15),color:v.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(L,{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:c,loading:u,onChange:I,locale:o,options:w})})}function or(){const{t}=N(),{orgDetail:o,inviteParams:a}=_(),{invitations:i,editable:r,org:s}=o||{};return r?e.jsxs(m,{sx:{display:"flex",gap:1},children:[e.jsxs(J,{variant:"outlined",style:{flexShrink:0},color:"primary",size:"small",onClick:()=>{a.onTriggerInvitingDialog({org:s,open:!0})},children:[e.jsx(Re,{style:{height:"1em",marginRight:4},icon:"tabler:user"}),t("common.inviting"),i.length?` (${i.length})`:""]}),e.jsx(J,{variant:"contained",size:"small",onClick:()=>{a.onTriggerInviteDialog({org:s,open:!0,mode:"detail"})},startIcon:e.jsx(Re,{style:{fontSize:14},icon:"tabler:user-plus"}),children:t("common.invite")})]}):null}function ke({children:t,...o}){const a=$e(),[i,r]=C.useState(!1),s=y(()=>{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})}ke.propTypes=de.propTypes;ke.defaultProps=de.defaultProps;function ir(){const{orgDetail:t,requests:o}=_(),{org:a,loading:i,editable:r}=t||{},{t:s,locale:u}=N(),b=qe(),g=C.useMemo(()=>{const{settings:c={}}=window.blocklet||{};return Ke(c,"org.maxMemberPerOrg",100)},[]),v=y(async(c,w)=>{const T={...$t(a,["id","name","description"]),[c]:w};await o.updateOrg(T),t.refresh(T.id)}),I=y(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(We,{style:{marginTop:0},disabled:i,loading:i,initialValue:a.name,onSubmit:c=>v("name",c)}):a.name},a.name),e.jsx(Ce,{valueComponent:"div",nameWidth:180,name:s("common.description"),children:r?e.jsx(We,{style:{marginTop:0},disabled:i,loading:i,initialValue:a.description,type:"textarea",rows:3,onSubmit:c=>v("description",c)}):a.description},a.description),e.jsx(Ce,{valueComponent:"div",nameWidth:180,name:e.jsxs(L,{sx:{display:"flex",alignItems:"center",gap:.5},children:[s("team.orgs.invite.maxMembers"),e.jsx(ke,{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(Vt,{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(Kt,{}):e.jsx(Jt,{})}):null,passportProps:{issuer:i.name,issuerDid:i.ownerDid,ownerDid:i.ownerDid,preferredColor:b}},g.name))}),s&&e.jsx(Xt,{onCancel:()=>u(!1),roles:a,onSuccess:()=>{u(!1),o.getOrgRoles(i.id)},onDelete:()=>{u(!1),o.getOrgRoles(i.id)},mode:"update",roleName:s.name,item:s,orgId:i.id,hasPermission:r})]})}function lr(){const{t}=N(),{orgDetail:o,passportParams:a}=_(),{org:i,editable:r}=o||{};return r?e.jsx(m,{sx:{display:"flex",gap:1},children:e.jsx(J,{variant:"contained",size:"small",onClick:()=>{a.onTriggerPassportDialog({org:i,open:!0})},startIcon:e.jsx(xt,{}),children:t("team.passport.create.title")})}):null}function cr(){const{teamDid:t,passportParams:o,requests:a}=_(),{visible:i,org:r}=o||{};return i?e.jsx(Qt,{teamDid:t,orgId:r.id,onCancel:()=>o.onTriggerPassportDialog({open:!1}),onSuccess:()=>{o.onTriggerPassportDialog({open:!1}),a.getOrgRoles(r.id)}}):null}function De({id:t="",inDialog:o=!1}){const{orgDetail:a}=_(),{t:i}=N(),[r,s]=C.useState("members"),{org:u,loading:b,refresh:g,error:v}=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]),v)return e.jsx(_e,{children:v});if(!u)return null;const c=()=>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:c()}),e.jsxs(m,{sx:{mt:2},children:[r==="members"&&e.jsx(sr,{}),r==="settings"&&e.jsx(ir,{}),r==="passports"&&e.jsx(ar,{})]})]})]})]})}De.propTypes={id:h.string,inDialog:h.bool};function dr(){const{t,locale:o}=C.useContext(Rt),{teamDid:a}=He(),i=C.useRef(null),[r,s]=C.useState(null),[u,b]=C.useState(0),g=$e(),v=`orgs-${a}`,I=Et(v),c=G({searchText:I.searchText||"",pageSize:I.rowsPerPage||10,page:1}),{editable:w,loading:T,requests:f,onTriggerEditOrg:x,onTriggerCreateOrg:z,refreshTrigger:k}=_(),{data:j,refresh:S}=Ue(async()=>{const M={};c.searchText&&(M.name=c.searchText,M.description=c.searchText);const{orgs:W,paging:D}=await f.getAllOrgs({org:M,paging:{page:c.page,pageSize:c.pageSize}});return b(D.total),W},{refreshDeps:[a,c.page,c.pageSize,c.searchText],onError:M=>{O.error(E(M))}}),U=({page:M,rowsPerPage:W,searchText:D})=>{c.pageSize!==W?(c.pageSize=W,c.page=1):c.page!==M+1?c.page=M+1:c.searchText!==D&&(c.searchText=D,c.page=1)};C.useEffect(()=>{k>0&&S&&S()},[k,S]);const H=[{label:t("common.orgs"),name:"name"},{label:t("common.members"),name:"members",options:{customBodyRender:(M,{rowIndex:W})=>{const D=j[W];return e.jsx(Ve,{members:D.members,total:D.membersCount})}}},{label:t("team.orgs.description"),name:"description"},{label:t("common.createdBy"),name:"owner",options:{customBodyRender:(M,{rowIndex:W})=>{const D=j[W];return e.jsx(m,{children:e.jsx(ie,{showHoverCard:!1,avatarSize:32,did:D.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:W})=>{const D=j[W];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(D)}},{icon:e.jsx(oe,{}),text:t("common.delete"),onClick:F=>{F.stopPropagation(),f.deleteOrg(D)}}]})})}}}],X={sort:!1,download:!1,filter:!1,print:!1,expandableRowsOnClick:!0,onRowClick(M,W,D){if(i.current?.contains(D.target)){const F=j[W.dataIndex];s(F)}},page:c.page-1,rowsPerPage:c.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:j||[],locale:o,durable:v,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(De,{id:r.id,inDialog:!0})})]})}function Ze({org:t,onInviteUser:o=te,onDelete:a=te,onClick:i=te,loading:r=!1,editable:s=!0}){const{t:u}=N(),{session:b}=Je(),g=C.useMemo(()=>b?.user?.did===t.ownerDid,[b?.user?.did,t.ownerDid]),v=()=>s?e.jsxs(e.Fragment,{children:[e.jsx(Ae,{variant:"outlined",size:"small",startIcon:e.jsx(jt,{style:{fontSize:16}}),onClick:c=>{c.stopPropagation(),o?.(t)},children:u("common.invite")}),e.jsx(Ae,{variant:"contained",color:"error",size:"small",startIcon:e.jsx(oe,{style:{fontSize:16}}),onClick:c=>{c.stopPropagation(),a?.(t)},children:u("common.delete")})]}):null,I=y(()=>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(A,{variant:"text",width:"100%",height:24}):e.jsx(L,{variant:"h4",sx:{fontWeight:600},children:t.name}),r?e.jsx(A,{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(L,{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(A,{variant:"text",width:"100%",height:24}),e.jsx(A,{variant:"text",width:"80%",height:24})]}):t.description}),e.jsxs(m,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[r?e.jsx(A,{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(A,{variant:"text",width:50,height:24}),e.jsx(A,{variant:"text",width:50,height:24})]}):v()})]})]})]})})}Ze.propTypes={org:h.object.isRequired,onInviteUser:h.func,onDelete:h.func,onClick:h.func,loading:h.bool,editable:h.bool};const Ae=Ct(J)`
2
2
  font-weight: 500;
3
3
  .MuiButton-icon {
4
4
  margin-right: 4px;
@@ -1,4 +1,4 @@
1
- import{r as v,g as We,a as qe}from"./vendor-react-Dvs43sk9.js";import{g as Ue,k as Z}from"./vendor-hooks-BlA8TRnZ.js";import{j as e,ak as t,at as W,b1 as K,a6 as B,aX as He,am as G,co as Ge,U as Ke,T as F,a3 as Ye,W as S,z as O,M as X,I as _,cp as ge,cb as je,A as Ve,x as Ze,c3 as Xe,c4 as ee,bw as Je,F as Qe,bc as es,s as ss}from"./vendor-mui-core-DRxbhqaK.js";import{T as A,b as $,p as ts,j as ae,I as se,H as D,n as N,k as re,O as ye,x as ve,a3 as as,a0 as rs}from"./vendor-ux-B9VfuZTg.js";import{X as P,o as os,_ as be,c as M,B as Q,a9 as ns,e as is,V as ls,$ as V,b6 as cs}from"./index-0863PXVJ.js";import{W as oe}from"./did-address-DnFNwELW.js";import{u as z}from"./team-8eI9KzkS.js";import{a as ne,r as ie,b as le,c as Se,d as J,e as ds,u as ps,f as us}from"./passport-item-CIkdGD7k.js";import{p as Ce}from"./util-6epwbzsz.js";import{u as ms}from"./use-mobile-BQQpAf3i.js";import{v as H}from"./index-Y8LQew4k.js";import{w as q,P as fs}from"./permission-C6ZxgW4_.js";import{C as xs}from"./Google-E3u2a9g7.js";import{c as hs}from"./create-passport-svg-n0J1kwzH.js";import{A as gs}from"./vendor-arcblock-DeeG8u0h.js";import{G as Y,_ as js}from"./vendor-utils-CUDP56Ff.js";import{e as Te}from"./edit.svg-DycWG9v3.js";import{H as ce,P as ys}from"./index-gv-XKOxx.js";import{C as we}from"./confirm-CbKYjtHR.js";import{L as Ie}from"./list-header-DMpz8A8v.js";import{f as te}from"./index-DBs9Ljax.js";import{u as vs}from"./useSetState-DFuQZPPV.js";import"./lottie-web-4koyQiv_.js";import"./session-BU5Mzwxi.js";import"./isURL-DbBjhWuw.js";import"./use-app-logo-CPtVQ5QR.js";import"./index-UrBf_SB9.js";import"./base32-BK7MXAD4.js";import"./cloneDeep-LRq4Ya2k.js";import"./lock.svg-COUP8tyO.js";const me="info";function De({createPassportSvg:c,passport:s,onCancel:p,onSwitchPassport:u=()=>{}}){const{t:f}=A(),i=Ue({tab:me}),d={info:{label:f("common.basicInfo"),value:me,component:()=>e.jsx(Pe,{passport:s,createPassportSvg:c})},logs:{label:f("common.logs"),value:"logs",component:()=>e.jsx(Ae,{passport:s})},related:{label:f("team.passport.related"),value:"related",component:()=>e.jsx(Le,{passport:s,onSwitchPassport:u})}},l=Object.values(d).map(({label:h,value:m})=>({label:h,value:m})).filter(h=>h.value==="related"?s.parentDid:!0),r=d[i.tab]||d.info,n=h=>{i.tab=h};return e.jsx($,{title:f("common.passport"),onClose:p,open:!0,PaperProps:{style:{maxWidth:800,minHeight:"80vh"}},fullWidth:!0,children:e.jsxs(bs,{children:[e.jsx(t,{className:"tabs",children:e.jsx(ts,{tabs:l,current:i.tab,onChange:n,scrollButtons:"auto"})}),e.jsx(t,{className:"body",children:e.jsx(r.component,{})})]})})}De.propTypes={createPassportSvg:S.func.isRequired,passport:S.object.isRequired,onCancel:S.func.isRequired,onSwitchPassport:S.func};const bs=W(t)`
1
+ import{r as v,g as We,a as qe}from"./vendor-react-Dvs43sk9.js";import{g as Ue,k as Z}from"./vendor-hooks-BlA8TRnZ.js";import{j as e,ak as t,at as W,b1 as K,a6 as B,aX as He,am as G,co as Ge,U as Ke,T as F,a3 as Ye,W as S,z as O,M as X,I as _,cp as ge,cb as je,A as Ve,x as Ze,c3 as Xe,c4 as ee,bw as Je,F as Qe,bc as es,s as ss}from"./vendor-mui-core-DRxbhqaK.js";import{T as A,b as $,p as ts,j as ae,I as se,H as D,n as N,k as re,O as ye,x as ve,a3 as as,a0 as rs}from"./vendor-ux-B9VfuZTg.js";import{X as P,o as os,_ as be,c as M,B as Q,a9 as ns,e as is,V as ls,$ as V,b6 as cs}from"./index-C5weIh5R.js";import{W as oe}from"./did-address-DnFNwELW.js";import{u as z}from"./team-DjK1LiLV.js";import{a as ne,r as ie,b as le,c as Se,d as J,e as ds,u as ps,f as us}from"./passport-item-gIxDDwjF.js";import{p as Ce}from"./util-DUiP0chO.js";import{u as ms}from"./use-mobile-BQQpAf3i.js";import{v as H}from"./index-Y8LQew4k.js";import{w as q,P as fs}from"./permission-BeGf253a.js";import{C as xs}from"./Google-E3u2a9g7.js";import{c as hs}from"./create-passport-svg-n0J1kwzH.js";import{A as gs}from"./vendor-arcblock-DeeG8u0h.js";import{G as Y,_ as js}from"./vendor-utils-CUDP56Ff.js";import{e as Te}from"./edit.svg-DycWG9v3.js";import{H as ce,P as ys}from"./index-DI0tEMGN.js";import{C as we}from"./confirm-CRSsToIg.js";import{L as Ie}from"./list-header-DMpz8A8v.js";import{f as te}from"./index-DBs9Ljax.js";import{u as vs}from"./useSetState-DFuQZPPV.js";import"./lottie-web-4koyQiv_.js";import"./session-DEBZccHT.js";import"./isURL-Drc7oe8g.js";import"./use-app-logo-BOmNYQgU.js";import"./index-ChG9_ZZV.js";import"./base32-BK7MXAD4.js";import"./cloneDeep-LRq4Ya2k.js";import"./lock.svg-COUP8tyO.js";const me="info";function De({createPassportSvg:c,passport:s,onCancel:p,onSwitchPassport:u=()=>{}}){const{t:f}=A(),i=Ue({tab:me}),d={info:{label:f("common.basicInfo"),value:me,component:()=>e.jsx(Pe,{passport:s,createPassportSvg:c})},logs:{label:f("common.logs"),value:"logs",component:()=>e.jsx(Ae,{passport:s})},related:{label:f("team.passport.related"),value:"related",component:()=>e.jsx(Le,{passport:s,onSwitchPassport:u})}},l=Object.values(d).map(({label:h,value:m})=>({label:h,value:m})).filter(h=>h.value==="related"?s.parentDid:!0),r=d[i.tab]||d.info,n=h=>{i.tab=h};return e.jsx($,{title:f("common.passport"),onClose:p,open:!0,PaperProps:{style:{maxWidth:800,minHeight:"80vh"}},fullWidth:!0,children:e.jsxs(bs,{children:[e.jsx(t,{className:"tabs",children:e.jsx(ts,{tabs:l,current:i.tab,onChange:n,scrollButtons:"auto"})}),e.jsx(t,{className:"body",children:e.jsx(r.component,{})})]})})}De.propTypes={createPassportSvg:S.func.isRequired,passport:S.object.isRequired,onCancel:S.func.isRequired,onSwitchPassport:S.func};const bs=W(t)`
2
2
  margin-top: -16px;
3
3
 
4
4
  .tabs {
@@ -1,4 +1,4 @@
1
- import{D as w1,J as K1,j as r,Y as Y1,$ as W1,I as q1,dg 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-DRxbhqaK.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-CUDP56Ff.js";import{T as l6,G as F1,f as u6,J as H,l as C6,x as p6,b as d6,n as t1,aF as n1}from"./vendor-ux-B9VfuZTg.js";import{r as t}from"./vendor-react-Dvs43sk9.js";import{k as L1,b as v1,a as Z}from"./vendor-hooks-BlA8TRnZ.js";import{bg as Y,W,bA as U1,bB as h6,t as m6,bp as E6,bw as g6}from"./index-0863PXVJ.js";import{x as f6}from"./index-DRYJ0xIl.js";import{f as A6}from"./index-BojVbZw0.js";import{v as a1}from"./index-Y8LQew4k.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,dg 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-DRxbhqaK.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-CUDP56Ff.js";import{T as l6,G as F1,f as u6,J as H,l as C6,x as p6,b as d6,n as t1,aF as n1}from"./vendor-ux-B9VfuZTg.js";import{r as t}from"./vendor-react-Dvs43sk9.js";import{k as L1,b as v1,a as Z}from"./vendor-hooks-BlA8TRnZ.js";import{bg as Y,W,bA as U1,bB as h6,t as m6,bp as E6,bw as g6}from"./index-C5weIh5R.js";import{x as f6}from"./index-DRYJ0xIl.js";import{f as A6}from"./index-BojVbZw0.js";import{v as a1}from"./index-Y8LQew4k.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 限制而失败:
@@ -1,4 +1,4 @@
1
- import{g as Wt,r as v}from"./vendor-react-Dvs43sk9.js";import{j as e,ak as y,z as Q,b6 as me,bg as qe,y as V,am as ut,d2 as Bt,bn as qt,at as ae,b1 as mt,W as h,T as ee,U as Je,d3 as pt,b5 as Ke,a5 as Me,Q as Fe,d4 as Ge,aN as Ue,a6 as ft,D as ht,d5 as Kt,ad as xt,d6 as Mt,d7 as Ut,c2 as st,n as Ht,x as $t,bc as Vt,M as it,cw as Jt,I as Gt,d8 as Yt}from"./vendor-mui-core-DRxbhqaK.js";import{A as gt,J as Xt,C as Qt,e as le,F as Zt,a3 as je}from"./vendor-utils-CUDP56Ff.js";import{T as te,H as M,n as ce,c as en,p as bt,a3 as tn,au as nn,m as jt,$ as vt,j as yt,av as Ae,b as St,I as sn,a0 as an}from"./vendor-ux-B9VfuZTg.js";import{aD as rn,X as Ye,a9 as Ct,aW as wt,J as _e,c as _,_ as Z,o as on,aL as at}from"./index-0863PXVJ.js";import{g as ye,b as $,a as se}from"./vendor-hooks-BlA8TRnZ.js";import{u as Rt,C as Y}from"./index.esm-JPZAjt0x.js";import{i as He}from"./isURL-DbBjhWuw.js";import{S as X}from"./section-ZPKr6_ii.js";import{A as ln,a as cn,b as dn}from"./collapse-DJGzUM1Q.js";import{S as Se}from"./shorten-label-DVy6K5I7.js";import{v as Tt}from"./index-Ba9-ArMT.js";import{R as Nt,A as un,S as mn,a as pn,B as fn}from"./list-9Jqi3lQE.js";import{j as hn,c as xn,N as gn}from"./team-8eI9KzkS.js";import{W as bn}from"./did-address-DnFNwELW.js";import{p as It}from"./util-6epwbzsz.js";import{D as jn,g as vn}from"./traffic-C-k1EeLv.js";import{B as Et}from"./bundle-avatar-sZTyiJPk.js";import{u as yn}from"./use-mobile-BQQpAf3i.js";import"./lottie-web-4koyQiv_.js";import"./vendor-arcblock-DeeG8u0h.js";import"./required-BT8zXV8U.js";import"./server-logo-notext.svg-CKQB0tIp.js";import"./index-UrBf_SB9.js";import"./session-BU5Mzwxi.js";import"./use-app-logo-CPtVQ5QR.js";import"./base32-BK7MXAD4.js";import"./useAsyncRetry-EEjDgDMR.js";import"./useAsync-DVtDVEv6.js";import"./iframe-DsSE-oEM.js";import"./index-B6gW9Yjq.js";import"./index-DBs9Ljax.js";import"./base-chart-UFWO9a3P.js";import"./index-3ePiAFIp.js";import"./vendor-mui-x-Qp6zkx78.js";import"./AdapterDayjs-Bp0ir26R.js";var Te={exports:{}},Ne={exports:{}},Ie={exports:{}},rt;function Sn(){return rt||(rt=1,function(n,s){Object.defineProperty(s,"__esModule",{value:!0}),s.default=t;function t(r){return r==null}n.exports=s.default,n.exports.default=s.default}(Ie,Ie.exports)),Ie.exports}var ot;function Cn(){return ot||(ot=1,function(n,s){Object.defineProperty(s,"__esModule",{value:!0}),s.default=u;var t=o(rn()),r=o(Sn());function o(p){return p&&p.__esModule?p:{default:p}}var l=/^(?:[-+]?(?:0|[1-9][0-9]*))$/,b=/^[-+]?[0-9]+$/;function u(p,i){(0,t.default)(p),i=i||{};var N=i.allow_leading_zeroes===!1?l:b,I=!i.hasOwnProperty("min")||(0,r.default)(i.min)||p>=i.min,S=!i.hasOwnProperty("max")||(0,r.default)(i.max)||p<=i.max,j=!i.hasOwnProperty("lt")||(0,r.default)(i.lt)||p<i.lt,E=!i.hasOwnProperty("gt")||(0,r.default)(i.gt)||p>i.gt;return N.test(p)&&I&&S&&j&&E}n.exports=s.default,n.exports.default=s.default}(Ne,Ne.exports)),Ne.exports}var lt;function wn(){return lt||(lt=1,function(n,s){Object.defineProperty(s,"__esModule",{value:!0}),s.default=o;var t=r(Cn());function r(l){return l&&l.__esModule?l:{default:l}}function o(l){return(0,t.default)(l,{allow_leading_zeroes:!1,min:0,max:65535})}n.exports=s.default,n.exports.default=s.default}(Te,Te.exports)),Te.exports}var Rn=wn();const Tn=Wt(Rn),ze={enabled:!1,secure:!1,from:"",host:"",port:"",user:"",password:"",companyName:"",companyLink:"",companyAddress:"",supportEmail:""};function Nn(){const{api:n}=Ye(),{blocklet:s}=Ct(),{t}=te(),{confirmApi:r,confirmHolder:o}=wt(),l=s?.meta?.did,b=Object.assign({...ze},s?.settings?.notification?.email||{}),{handleSubmit:u,control:p,formState:i,watch:N,reset:I}=Rt({defaultValues:gt(b,Object.keys(ze))}),S=ye({testReceiver:"",testReceiverError:""}),j=N("enabled"),E=$(async(a,T,O=!0)=>{try{const{blocklet:D}=await n.configNotification({input:{did:l,notification:JSON.stringify({email:a})}}),re=Object.assign({...ze},D?.settings?.notification?.email||{});I(re),O&&M.success(t("oauth.saveSuccess"))}catch(D){if(O)M.error(D.message||t("oauth.saveFailed"));else throw D}}),J=$(async(a,T,O)=>{try{i.isDirty&&await E(a,T,!1),await n.sendEmail({input:{did:l,receiver:O,email:JSON.stringify({body:"Your SMTP configuration is correct!",title:"Test email",type:"notification",attachments:[{type:"link",data:{url:"https://community.arcblock.io",title:"Community",image:"https://community.arcblock.io/.well-known/service/blocklet/logo-rect-dark",utm:{campaign:"test-campaign"}}}],utm:{content:"test-email-button"}})}}),M.success(t("notification.email.testSuccess"))}catch(D){M.error(D.message||t("notification.email.testfailed"))}}),z=$((a,T)=>{S.testReceiver=localStorage.getItem("test-receiver")||"",S.testReceiverError="",r.open({title:t("notification.email.testSendEmail"),content:()=>e.jsx(y,{sx:{width:"300px"},children:e.jsx(Q,{sx:{mt:1},fullWidth:!0,name:"testReceiver",label:t("notification.email.inputTestReceiver"),value:S.testReceiver,onChange:O=>{S.testReceiver=O.target.value},error:!!S.testReceiverError,helperText:S.testReceiverError||" "})}),confirmButtonText:t("common.confirm"),cancelButtonText:t("common.cancel"),async onConfirm(O){const D=S.testReceiver?.trim();if(!D){S.testReceiverError=t("notification.email.receiverRequired");return}if(!_e(D)){S.testReceiverError=t("notification.email.receiverInvalid");return}S.testReceiverError="",await J(a,T,D),O()}})}),F=$(a=>{const T=a?.trim();return T?_e(T)?!0:t("notification.email.fromInvalid"):t("notification.email.fromRequired")}),B=$(a=>{const T=a?.trim();return T?He(T,{require_host:!1,protocols:[]})?!0:t("notification.email.hostInvalid"):t("notification.email.hostRequired")}),w=$(a=>a?Tn(a)?!0:t("notification.email.portInvalid"):t("notification.email.portRequired")),q=$(a=>a?.trim()?!0:t("notification.email.userRequired")),K=$(a=>a?.trim()?!0:t("notification.email.passwordRequired")),f=$(a=>a?.trim()&&!He(a,{protocols:["http","https"],require_protocol:!0})?t("notification.email.linkInvalid"):!0),R=$(a=>a?.trim()&&!_e(a)?t("notification.email.emailInvalid"):!0),C=$(()=>!0);return e.jsxs(y,{children:[e.jsxs(In,{component:"form",onSubmit:u(E),disabled:!0,sx:{".section-left":{width:"160px"}},children:[e.jsx(X,{title:t("notification.email.enable"),my:2.5,children:e.jsx(Y,{name:"enabled",control:p,render:({field:a})=>e.jsx(me,{control:e.jsx(qe,{checked:a.value,...a})})})}),e.jsx(X,{title:t("notification.email.from"),children:e.jsx(Y,{name:"from",control:p,rules:{validate:j?F:C},render:({field:a})=>e.jsx(V,{fullWidth:!0,children:e.jsx(Q,{...a,size:"small",required:!0,label:t("notification.email.from"),error:!!i.errors[a.name],helperText:i.errors[a.name]?.message||" ",disabled:!j})})})}),e.jsx(X,{title:t("notification.email.host"),children:e.jsx(Y,{name:"host",control:p,rules:{validate:j?B:C},render:({field:a})=>e.jsx(V,{fullWidth:!0,children:e.jsx(Q,{...a,size:"small",required:!0,error:!!i.errors[a.name],label:t("notification.email.host"),helperText:i.errors[a.name]?.message||" ",disabled:!j})})})}),e.jsx(X,{title:t("notification.email.port"),children:e.jsx(Y,{name:"port",control:p,rules:{validate:j?w:C},render:({field:a})=>e.jsx(V,{fullWidth:!0,children:e.jsx(Q,{...a,size:"small",required:!0,type:"number",error:!!i.errors[a.name],label:t("notification.email.port"),helperText:i.errors[a.name]?.message||" ",disabled:!j})})})}),e.jsx(X,{title:t("notification.email.user"),children:e.jsx(Y,{name:"user",control:p,rules:{validate:j?q:C},render:({field:a})=>e.jsx(V,{fullWidth:!0,children:e.jsx(Q,{...a,size:"small",required:!0,error:!!i.errors[a.name],label:t("notification.email.user"),helperText:i.errors[a.name]?.message||" ",disabled:!j})})})}),e.jsx(X,{title:t("notification.email.password"),children:e.jsx(Y,{name:"password",control:p,rules:{validate:j?K:C},render:({field:a})=>e.jsx(V,{fullWidth:!0,children:e.jsx(Q,{...a,size:"small",required:!0,type:"password",error:!!i.errors[a.name],label:t("notification.email.password"),helperText:i.errors[a.name]?.message||" ",disabled:!j})})})}),e.jsx(X,{title:t("notification.email.secure"),children:e.jsx(Y,{name:"secure",control:p,rules:{validate:C},render:({field:a})=>e.jsx(V,{fullWidth:!0,children:e.jsx(me,{control:e.jsx(qe,{checked:a.value,...a,disabled:!j})})})})}),e.jsxs(ln,{children:[e.jsxs(cn,{expandIcon:e.jsx(qt,{fontSize:"small"}),"aria-controls":"panel1-content",id:"panel1-header",children:[t("notification.email.signature"),e.jsx(ut,{title:t("notification.email.signatureTooltip"),children:e.jsx(Bt,{fontSize:"small",sx:{ml:1,cursor:"help"}})})]}),e.jsxs(dn,{children:[e.jsx(X,{title:t("notification.email.companyName"),children:e.jsx(Y,{name:"companyName",control:p,rules:{validate:C},render:({field:a})=>e.jsx(V,{fullWidth:!0,children:e.jsx(Q,{...a,size:"small",error:!!i.errors[a.name],label:t("notification.email.companyName"),helperText:i.errors[a.name]?.message||" ",disabled:!j})})})}),e.jsx(X,{title:t("notification.email.companyLink"),children:e.jsx(Y,{name:"companyLink",control:p,rules:{validate:j?f:C},render:({field:a})=>e.jsx(V,{fullWidth:!0,children:e.jsx(Q,{...a,size:"small",error:!!i.errors[a.name],label:t("notification.email.companyLink"),helperText:i.errors[a.name]?.message||" ",disabled:!j})})})}),e.jsx(X,{title:t("notification.email.companyAddress"),children:e.jsx(Y,{name:"companyAddress",control:p,rules:{validate:C},render:({field:a})=>e.jsx(V,{fullWidth:!0,children:e.jsx(Q,{...a,size:"small",error:!!i.errors[a.name],label:t("notification.email.companyAddress"),helperText:i.errors[a.name]?.message||" ",disabled:!j})})})}),e.jsx(X,{title:t("notification.email.supportEmail"),children:e.jsx(Y,{name:"supportEmail",control:p,rules:{validate:j?R:C},render:({field:a})=>e.jsx(V,{fullWidth:!0,children:e.jsx(Q,{...a,size:"small",type:"email",error:!!i.errors[a.name],label:t("notification.email.supportEmail"),helperText:i.errors[a.name]?.message||" ",disabled:!j})})})})]})]}),e.jsxs(y,{sx:{display:"flex",justifyContent:"flex-end",gap:2,mt:3},children:[e.jsx(ce,{variant:"outlined",color:"warning",onClick:u(z),disabled:!j,children:t("oauth.runTest")}),e.jsx(ce,{type:"submit",variant:"contained",disabled:!i.isDirty,children:t("oauth.save")})]})]}),o]})}const In=ae(mt)``,We={enabled:!1,endpoint:"",did:void 0,pushPath:void 0};function En(){const{api:n}=Ye(),{blocklet:s}=Ct(),{t}=te(),{confirmApi:r,confirmHolder:o}=wt(),l=s?.meta?.did,b=Object.assign({...We},s?.settings?.notification?.pushKit||{}),{handleSubmit:u,control:p,formState:i,watch:N,reset:I}=Rt({defaultValues:gt(b,Object.keys(We))}),S=ye({testReceiver:"",testReceiverError:""}),j=N("enabled"),E=$(async(w,q,K=!0)=>{try{const{blocklet:f}=await n.configNotification({input:{did:l,notification:JSON.stringify({pushKit:w})}}),R=Object.assign({...We},f?.settings?.notification?.pushKit||{});I(R),K&&M.success(t("oauth.saveSuccess"))}catch(f){if(K)M.error(f.message||t("oauth.saveFailed"));else throw f}}),J=$(async(w,q)=>{try{i.isDirty&&await E(w,q,!1);const K=(s?.configs||[]).find(C=>C.key==="BLOCKLET_APP_URL")?.value,f=Xt(Qt(K,_.WELLKNOWN_SERVICE_PATH_PREFIX,"/blocklet/logo"),{v:s?.meta?.version,t:new Date(s?.updatedAt||0).getTime()}),R={type:"passthrough",passthroughType:"messageStatus",data:{message:{title:"Test push-kit notification",body:"This is message from push-kit config test",sender:{did:s?.appDid,fullName:s?.meta?.title,avatar:f}}}};await n.sendPush({input:{did:l,receiver:S.testReceiver,notification:JSON.stringify(R)}}),M.success(t("notification.pushKit.testSuccess"))}catch(K){M.error(K.message||t("notification.pushKit.testfailed"))}}),z=$((w,q)=>{S.testReceiverError="",r.open({title:t("notification.pushKit.testSend"),content:()=>e.jsx(y,{sx:{width:"450px",maxWidth:"100%"},children:e.jsx(Q,{sx:{mt:1},fullWidth:!0,name:"testReceiver",label:t("notification.pushKit.inputTestReceiver"),value:S.testReceiver,onChange:K=>{S.testReceiver=K.target.value},error:!!S.testReceiverError,helperText:S.testReceiverError||" "})}),confirmButtonText:t("common.confirm"),cancelButtonText:t("common.cancel"),async onConfirm(K){if(!S.testReceiver?.trim()){S.testReceiverError=t("notification.pushKit.receiverRequired");return}S.testReceiverError="",await J(w,q),K()}})}),F=$(w=>{const q=w?.trim();return q?He(q)?!0:t("notification.pushKit.endpointInvalid"):t("notification.pushKit.endpointRequired")}),B=$(()=>!0);return e.jsxs(y,{children:[e.jsxs(kn,{component:"form",onSubmit:u(E),disabled:!0,sx:{".section-left":{width:"160px"}},children:[e.jsx(X,{title:t("notification.pushKit.enable"),my:2.5,children:e.jsx(Y,{name:"enabled",control:p,render:({field:w})=>e.jsx(me,{control:e.jsx(qe,{checked:w.value,...w})})})}),e.jsx(X,{title:t("notification.pushKit.endpoint"),children:e.jsx(Y,{name:"endpoint",control:p,rules:{validate:j?F:B},render:({field:w})=>e.jsx(V,{fullWidth:!0,children:e.jsx(Q,{...w,size:"small",required:!0,label:t("notification.pushKit.endpoint"),error:!!i.errors[w.name],helperText:i.errors[w.name]?.message||" ",disabled:!j})})})}),e.jsxs(X,{title:t("notification.pushKit.customOptions"),children:[e.jsx(Y,{name:"did",control:p,render:({field:w})=>e.jsx(V,{fullWidth:!0,children:e.jsx(Q,{...w,size:"small",label:t("notification.pushKit.did"),error:!!i.errors[w.name],helperText:i.errors[w.name]?.message||" ",disabled:!j})})}),e.jsx(Y,{name:"pushPath",control:p,render:({field:w})=>e.jsx(V,{fullWidth:!0,children:e.jsx(Q,{...w,size:"small",label:t("notification.pushKit.pushPath"),error:!!i.errors[w.name],helperText:i.errors[w.name]?.message||" ",disabled:!j})})})]}),e.jsxs(y,{sx:{display:"flex",justifyContent:"flex-end",gap:2,mt:3},children:[e.jsx(ce,{variant:"outlined",color:"warning",onClick:u(z),disabled:!j,children:t("oauth.runTest")}),e.jsx(ce,{type:"submit",variant:"contained",disabled:!i.isDirty,children:t("oauth.save")})]})]}),o]})}const kn=ae(mt)``,ct=[{label:e.jsx(y,{sx:{textAlign:"center",width:"100%"},children:"Email"}),value:"email"},{label:e.jsx(y,{sx:{textAlign:"center",width:"100%"},children:"Push Kit"}),value:"pushKit"}];function An(){const[n,s]=v.useState(ct[0].value),{locale:t}=v.useContext(en),r=se(()=>({email:e.jsx(Nn,{}),pushKit:e.jsx(En,{})}),[t]),o=v.useMemo(()=>({padding:"10px 0"}),[]);return e.jsxs(y,{children:[e.jsx(bt,{tabs:ct,current:n,onChange:s}),e.jsx(y,{style:o,children:r[n]})]})}const kt=v.createContext({}),{Provider:On,Consumer:Ws}=kt;function Dn({children:n,blocklet:s=""}){const{api:t,inService:r,ws:{useSubscription:o}}=Ye(),[l,b]=v.useState([]),[u,p]=v.useState({total:0,pageSize:20,pageCount:0,page:1}),i=se(()=>s.meta?.did,[s]),[N,I]=v.useState([]),[S,j]=v.useState({}),E=se(()=>l.length?new Set(l.map(f=>f.id)):new Set,[l]),J=async({page:f=1,pageSize:R=20,...C}={})=>{if(!i)return[];try{const a={paging:{page:f,pageSize:R},...C,teamDid:i,dateRange:C.dateRange?[Z(C.dateRange[0]).toISOString(),Z(C.dateRange[1]).toISOString()]:void 0},{dids:T,...O}=a;let D="";T&&T.includes("system")&&(D="system");const re=T?T.filter(pe=>pe!=="system"):[],ue={...O,source:D,componentDids:re},oe=await t.getNotificationSendLog({input:ue});return j(ue),b(oe.list),p(oe.paging),oe.list}catch(a){return M.error(a.message),[]}},z=async()=>{const f=await t.getNotificationComponents({input:{teamDid:i}});I(f.componentDids)},F=v.useCallback(f=>{const R=s.children.find(C=>C.meta?.did===f);if(R)return R.ancestors=[s],R},[s]),B=async({notificationId:f,receivers:R,channels:C,...a})=>{await t.resendNotification({input:{teamDid:i,notificationId:f,receivers:R,channels:C.map(T=>T==="wallet"?_.NOTIFICATION_SEND_CHANNEL.WALLET:T==="pushKit"?_.NOTIFICATION_SEND_CHANNEL.PUSH:T),...a}})},w=v.useCallback(async f=>(await t.getUser({input:{teamDid:i,user:{did:f},options:{enableConnectedAccount:!0}}})).user,[t,i]),q=v.useCallback(async({page:f=1,pageSize:R=20,...C}={})=>{try{const a={paging:{page:f,pageSize:R},...C,userName:C.searchText||"",teamDid:i,dateRange:C.dateRange?[Z(C.dateRange[0]).toISOString(),Z(C.dateRange[1]).toISOString()]:void 0};return await t.getReceivers({input:a})}catch(a){throw M.error(a.message),a}},[t,i]);v.useEffect(()=>{i&&z()},[i]),o(_.EVENTS.NOTIFICATION_BLOCKLET_UPDATE,f=>{E.has(f.notificationId)&&J(S)},[E,S]),o(_.EVENTS.NOTIFICATION_BLOCKLET_CREATE,f=>{E.has(f.id)||J(S)},[E,S]);const K={fetch:J,data:l,paging:u,blocklet:s,getComponent:F,resendNotification:B,getUser:w,componentDids:N,getReceivers:q,inService:r,teamDid:i};return e.jsx(On,{value:{notificationRecords:K},children:n})}function Xe(){const{notificationRecords:n}=v.useContext(kt);return n}Ce.propTypes={severity:h.oneOf(Object.values(["info","success","error","warning"])).isRequired};const Ln={info:"primary",success:"success",error:"error",warning:"warning"};function Ce({severity:n="info"}){return e.jsx(tn,{type:Ln[n],children:n})}const Pn=(n,s,t="")=>{if(!t||!s)return"";switch(t){case _.NOTIFICATION_SEND_FAILED_REASON.USER_DISABLED:return n("notification.sendStatus.reason.disabled",{channel:s});case _.NOTIFICATION_SEND_FAILED_REASON.CHANNEL_UNAVAILABLE:return n("notification.sendStatus.reason.unavailable",{channel:s});case _.NOTIFICATION_SEND_FAILED_REASON.CHANNEL_DISABLED:return n("notification.sendStatus.reason.notSent",{channel:s});case _.NOTIFICATION_SEND_FAILED_REASON.NOT_ONLINE:return n("notification.sendStatus.reason.offline");default:return t}};function At(n,s,t={}){const{status:r,updatedAt:o,reason:l="",channel:b="wallet"}=t,u=o?n("notification.sendStatus.sentTime",{date:on(o,s)}):"",p=Pn(n,b,l);return r===_.NOTIFICATION_SEND_STATUS.FAILED?{status:"failed",title:n("notification.sendStatus.failed"),sentTime:u,reason:p}:r===_.NOTIFICATION_SEND_STATUS.SENT?{status:"success",title:n("notification.sendStatus.success"),sentTime:u}:{status:"pending",title:n("notification.sendStatus.pending"),reason:p,sentTime:u}}const $e={pending:"#aaaaaa",success:"#34BE74",failed:"#D0021B"},Ve=["wallet","pushKit","email"],dt=["info","success","error","warning"],Ot=n=>{const{settings:s}=n;return s?.notification?.email?.enabled},Dt=n=>{const{settings:s}=n;return s?.notification?.pushKit?.enabled},Fn=(n,s)=>{const t=le(s,"extra.notifications.email",!0);return{available:Ot(n),enabled:t}},_n=(n,s)=>{const t=le(s,"extra.notifications.push",!0);return{available:Dt(n),enabled:t}},zn=n=>({enabled:le(n,"extra.notifications.wallet",!0)}),Wn=n=>({enabled:le(n,"extra.webhooks",[]).length>0}),Ee=(n=3)=>new Promise(s=>{setTimeout(()=>{s()},n*1e3)}),Bn=(n,s)=>s==="wallet"||s==="webhook"?[{channel:s,type:"enabled",pass:n("notification.sendStatus.reason.enabled",{channel:s}),fail:n("notification.sendStatus.reason.disabled",{channel:s})}]:s==="pushKit"||s==="email"?[{channel:s,type:"available",pass:n("notification.sendStatus.reason.available",{channel:s}),fail:n("notification.sendStatus.reason.unavailable",{channel:s})},{channel:s,type:"enabled",pass:n("notification.sendStatus.reason.enabled",{channel:s}),fail:n("notification.sendStatus.reason.disabled",{channel:s})}]:[],ke=(n=[])=>{const s=Z().startOf("day");return n.filter(t=>Z(t.sendAt).isSame(s,"day")).length},qn=(n,s="")=>{if(s&&Ve.includes(s)){const l=`${s}SendRecord`,b=le(n,l,[]);return ke(b)}const t=le(n,"webhook",{}),r=Object.keys(t??{})??[];if(s&&r.includes(s)){const l=t[s]??[];return ke(l)}const o={};return Ve.forEach(l=>{const b=`${l}SendRecord`,u=le(n,b,[]),p=ke(u);o[l]=p}),r.length>0&&r.forEach(l=>{const b=t[l]??[],u=ke(b);o[l]=u}),o},Oe=(n,s,t)=>{if(!Array.isArray(n))throw new Error("Invalid filterList or index");return n[t].splice(s,1),n},De=(n,s)=>{if(!Array.isArray(s))throw new Error("filters must be an array");return s.length?!s.includes(n):!1},Kn=n=>{switch(n){case _.NOTIFICATION_SEND_CHANNEL.WALLET:return"Wallet";case _.NOTIFICATION_SEND_CHANNEL.PUSH:return"Push Kit";case _.NOTIFICATION_SEND_CHANNEL.EMAIL:return"Email";case _.NOTIFICATION_SEND_CHANNEL.WEBHOOK:return"Webhook";default:return""}},Lt=()=>({components:{MUIDataTableFilter:{styleOverrides:{header:{marginBottom:0,p:{margin:0}},root:{"& .MuiGrid-container":{marginTop:0,"& .MuiGrid-item":{paddingTop:0}}}}},MuiPopover:{styleOverrides:{root:{"&.MuiPopover-root":{"& .MuiPaper-root:has(.filter-container)":{width:"420px"}}}}}}});function de({config:n,enableTooltip:s=!0,showTitle:t=!1,children:r=null}){const{status:o,title:l="",sentTime:b="",reason:u=""}=n,p=[l,u].filter(Boolean).join(", ");return e.jsx(ut,{title:s?e.jsxs(e.Fragment,{children:[e.jsx(ee,{color:"inherit",sx:{fontSize:12},children:p}),e.jsx("span",{children:b})]}):null,arrow:!0,placement:"top",children:e.jsxs(y,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"4px"},children:[e.jsxs(y,{sx:{position:"relative",minHeight:14,minWidth:14,display:"flex",alignItems:"center",justifyContent:"center"},children:[e.jsx(y,{style:{opacity:.15},sx:{position:"absolute",width:"100%",height:"100%",borderRadius:"50%",bgcolor:$e[o]}}),e.jsx(y,{sx:{position:"absolute",width:"55%",height:"55%",borderRadius:"50%",bgcolor:$e[o]}})]}),e.jsx(ee,{color:"inherit",sx:{fontSize:12},children:t?l:r})]})})}de.propTypes={config:h.object.isRequired,enableTooltip:h.bool,showTitle:h.bool,children:h.node};Le.propTypes={list:h.array.isRequired,label:h.string.isRequired,onDelete:h.func};function Le({list:n,label:s,onDelete:t=()=>{}}){const{t:r,locale:o}=te();return e.jsxs(y,{sx:{display:"flex",gap:1,alignItems:"center"},children:[e.jsxs(ee,{children:[s,": "]}),n.map(l=>{const b=At(r,o,{status:l});return e.jsx(Je,{size:"small",label:e.jsx(y,{sx:{display:"flex",alignItems:"center",gap:"4px"},children:e.jsx(de,{config:b,enableTooltip:!1,children:b.title})}),onDelete:u=>t(u,l)},l)})]})}Qe.propTypes={filterList:h.array.isRequired,onChange:h.func.isRequired,index:h.number.isRequired,column:h.object.isRequired,filterValues:h.array.isRequired,label:h.string.isRequired,renderLabel:h.func.isRequired};function Qe({filterList:n,onChange:s,index:t,column:r,filterValues:o,label:l,renderLabel:b}){return e.jsxs(V,{className:"filter-container",children:[e.jsx(pt,{component:"legend",children:l}),e.jsx(Ke,{row:!0,children:o.map(u=>e.jsx(me,{control:e.jsx(Me,{checked:n[t].indexOf(u.value??u)>-1,onChange:p=>{const i=[...n];p.target.checked?i[t]=[...i[t],u.value??u]:i[t]=i[t].filter(N=>N!==(u.value??u)),s(i[t],t,r)},name:u.value??u}),label:e.jsx("span",{style:{display:"flex",alignItems:"center"},children:b(u)})},u.value??u))})]})}function Be(n){return e.jsx(Qe,{...n,renderLabel:s=>e.jsx(de,{enableTooltip:!1,config:{status:s.status},children:s.label})})}xe.propTypes={status:h.number.isRequired,updatedAt:h.string.isRequired,reason:h.string,channel:h.string,onResend:h.func};function xe({status:n,updatedAt:s,reason:t="",channel:r="wallet",onResend:o}){const{t:l,locale:b}=te(),u=At(l,b,{status:n,updatedAt:s,reason:t,channel:r});return e.jsxs(y,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(de,{config:u,showTitle:!0}),u.status!=="success"&&e.jsx(Fe,{className:"resend-btn",size:"small",startIcon:e.jsx(Ge,{}),sx:{fontSize:12,color:"rgba(0, 0, 0, 0.87)",fontWeight:400,".MuiButton-startIcon":{mr:"2px"}},onClick:o,children:l("notification.resend")})]})}Ze.propTypes={value:h.array.isRequired,onChange:h.func};function Ze({value:n,onChange:s}){const{locale:t}=te(),r=Z().toDate(),[o,l]=v.useState(null),b=v.useCallback(i=>{l(o?null:i.currentTarget)},[o]),u=!!o,p=v.useCallback(i=>{if(!i.startDate||!i.endDate){M.error("Please select a date range");return}if(Z(i.startDate).isAfter(i.endDate)||!Z(i.startDate).isValid()||!Z(i.endDate).isValid()){M.error("Invalid date range");return}s([i.startDate,i.endDate]),l(null)},[s]);return e.jsxs("div",{children:[e.jsx(ee,{component:"div",variant:"h5",color:"textPrimary",style:{fontSize:18,fontWeight:"bold"},sx:{mb:0},children:e.jsxs(Fe,{onClick:b,variant:"outlined",size:"small",color:"inherit",children:[at(n[0],t)," - ",at(n[1],t)]})}),e.jsx(Ue,{open:u,anchorEl:o,onClose:()=>{l(null)},anchorOrigin:{vertical:"bottom",horizontal:"left"},children:e.jsx(jn,{open:!0,maxDate:r,initialDateRange:{startDate:n[0],endDate:n[1]},toggle:b,definedRanges:vn(r),onChange:p})})]})}et.propTypes={itemComponent:h.elementType.isRequired};function et({itemComponent:n,...s}){const{t}=te();return!s?.filterList?.filter(o=>o.length).length?null:e.jsxs(y,{sx:{display:"flex",gap:1,alignItems:"center"},children:[e.jsx("div",{className:"toolbar-filter-title",children:t("notification.filter")}),e.jsx("div",{className:"toolbar-filter-content",children:e.jsx(nn.TableFilterList,{...s,ItemComponent:n})})]})}function tt({label:n,onDelete:s,canDelete:t=()=>!0,...r}){const o=s&&typeof s=="function"?s:void 0;let l=!0;return t&&typeof t=="function"&&(l=t({label:n,...r})),e.jsx(Je,{label:n,variant:"outlined",...o&&l?{onDelete:o}:{}})}tt.propTypes={label:h.string.isRequired,onDelete:h.func,canDelete:h.func};const Mn=[{label:"Wallet",value:"app",checked:!0},{label:"Email",value:"email",checked:!0},{label:"Push Kit",value:"push",checked:!0},{label:"Webhook",value:"webhook",checked:!0}];Pt.propTypes={loading:h.bool,onCancel:h.func,onConfirm:h.func};function Pt({loading:n=!1,onCancel:s=()=>{},onConfirm:t=()=>{}}){const{t:r}=te(),[o,l]=v.useState(Mn),[b,u]=v.useState(!0),p=(N,I)=>{I.checked=N.target.checked;const S=o.map(j=>({...j,checked:j.value===I.value?I.checked:j.checked}));l(S)},i=N=>{N.stopPropagation(),t({channels:o.filter(I=>I.checked).map(I=>I.value),isResendFailedOnly:b})};return e.jsxs(y,{className:"resend-config",sx:{padding:"16px 24px"},children:[e.jsx(ee,{variant:"body1",component:"div",className:"check-title",sx:{fontWeight:700,mb:1},children:r("notification.config")}),e.jsx(y,{className:"choose-channel",children:e.jsxs(V,{component:"fieldset",variant:"standard",children:[e.jsx(pt,{component:"legend",children:r("notification.selectChannels")}),e.jsx(Ke,{sx:{display:"flex",flexDirection:"row",flexWrap:"wrap",gap:1},children:o.map(N=>e.jsx(me,{control:e.jsx(Me,{checked:N.checked,onChange:I=>p(I,N),name:N.value}),label:N.label},N.value))})]})}),e.jsx(y,{className:"resend-config-footer",children:e.jsx(Ke,{children:e.jsx(me,{control:e.jsx(Me,{checked:b,onChange:N=>u(N.target.checked)}),label:r("notification.resendFailedOnly")})})}),e.jsxs(y,{className:"resend-config-footer-tip",sx:{display:"flex",justifyContent:"flex-end",gap:1},children:[e.jsx(Fe,{onClick:N=>{N.stopPropagation(),s()},color:"inherit",children:r("common.cancel")}),e.jsxs(Fe,{onClick:i,color:"primary",disabled:n,variant:"contained",autoFocus:!0,style:{marginLeft:8},children:[n&&e.jsx(ft,{size:16}),r("common.confirm")]})]})]})}Ft.propTypes={notificationId:h.string.isRequired,handleResend:h.func,resending:h.bool};function Ft({notificationId:n,handleResend:s,resending:t=!1}){const{t:r,locale:o}=te(),l=ht(),b=v.useMemo(()=>jt(l,Lt()),[l]),{getReceivers:u,inService:p,teamDid:i,getUser:N,blocklet:I}=Xe(),[S,j]=v.useState(!1),[E,J]=v.useState([]),z=ye({anchorEl:null,position:null}),F=ye({anchorEl:null,position:null}),[B,w]=v.useState(null),[q,K]=v.useState({total:0,pageSize:10,pageCount:0,page:1}),[f,R]=v.useState({searchText:"",page:1,pageSize:10,walletSendStatus:[],pushKitSendStatus:[],emailSendStatus:[],dateRange:[Z().subtract(1,"month").startOf("day").toDate(),Z().endOf("day").toDate()]}),[C,a]=v.useState([]),T=[{label:r("notification.sendStatus.pending"),value:0,status:"pending"},{label:r("notification.sendStatus.success"),value:1,status:"success"},{label:r("notification.sendStatus.failed"),value:2,status:"failed"}],O=async()=>{if(!S&&n)try{j(!0);const c=await u({notificationId:n,...f}),d=c.list.map(m=>({...m,receiverUser:{...m.receiverUser,avatar:It(m.receiverUser.avatar,i,p)}}));J(d),K(c.paging),j(!1)}catch(c){M.error(c.message),j(!1)}};v.useEffect(()=>{O()},[f]);const D=c=>{c.stopPropagation();const d=c.currentTarget;F.anchorEl=d;const m=d.getBoundingClientRect();F.position={top:m.top+window.scrollY,left:m.left+window.scrollX}},re=c=>c.data.length?e.jsx("div",{style:{display:"flex",alignItems:"center",padding:"10px"},children:e.jsx(ce,{className:"resend-btn",size:"small",color:"primary",variant:"contained",startIcon:e.jsx(Ge,{}),sx:{".MuiButton-startIcon":{mr:"2px"}},onClick:D,children:r("notification.resend")})}):null,ue={sort:!1,download:!1,print:!1,selectableRows:"multiple",searchPlaceholder:r("common.search"),searchAlwaysOpen:!1,filterType:"checkbox",searchDebounceTime:300,page:q.page-1,rowsPerPage:q.pageSize,count:q.total,searchText:f.searchText,tableBodyMaxHeight:"calc(80vh - 260px)",rowsSelected:C,onRowSelectionChange:(c,d)=>{a(d.map(m=>m.dataIndex))},customToolbarSelect:re},oe=({page:c,rowsPerPage:d,searchText:m,filterList:A})=>{const[,U=[],ne=[],G=[]]=A;f.pageSize!==d?R(H=>({...H,pageSize:d,page:1})):f.page!==c+1?R(H=>({...H,page:c+1})):f.searchText!==m?R(H=>({...H,searchText:m,page:1})):je(U,f.walletSendStatus)?je(ne,f.pushKitSendStatus)?je(G,f.emailSendStatus)||R(H=>({...H,emailSendStatus:G,page:1})):R(H=>({...H,pushKitSendStatus:ne,page:1})):R(H=>({...H,walletSendStatus:U,page:1}))},pe=v.useCallback(async(c,d)=>{if(!d)return!1;const m=await N(d);return m?c==="wallet"?zn(m):c==="email"?Fn(I,m):c==="pushKit"?_n(I,m):c==="webhook"?Wn(m):!0:!1},[N,I]),we=v.useCallback(c=>Bn(r,c),[r]),fe=()=>{z.anchorEl=null,z.position=null,w(null)},he=()=>{F.anchorEl=null,F.position=null},g=async(c,d,m=!0,A="")=>{if(!(!d.length||!c.length))try{s(c,d,m,A),F.anchorEl||(await Ee(.5),fe())}catch(U){console.error("handleResend error",{error:U})}},x=async({channels:c,isResendFailedOnly:d})=>{const m=C.map(A=>E[A].receiver);await g(c,m,d),await Ee(.5),he(),a([])},k=async(c,d=[],m=!0)=>{try{await g(["webhook"],[c.receiver],m,d)}catch(A){M.error(A.response?A.response.statusText:A.message)}},L=async(c,d,m,A=[],U=!0)=>{if(c.stopPropagation(),qn(d,m)>=4){M.warning(r("notification.resendLimit"));return}if(!Ve.includes(m)){await k(d,A,U);return}if(c){const G=c.currentTarget,H=G.getBoundingClientRect();z.anchorEl=G,z.position={top:H.top+window.scrollY,left:H.left+window.scrollX}}w({channel:m});try{const G=await pe(m,d.receiver);await Ee(1),w({channel:m,result:G}),(typeof G=="boolean"&&G||Zt(G)&&Object.values(G).every(H=>!!H))&&(await s([m],[d.receiver],U),F.anchorEl||(await Ee(.5),fe()))}catch(G){M.error(G.message)}},W=c=>{R(d=>({...d,dateRange:c,page:1}))},P=(c,d,m,A)=>{c.stopPropagation();const U=m.filter(ne=>ne!==d);R(ne=>({...ne,[A]:U,page:1}))},ie=se(()=>[{label:r("notification.receiver"),name:"receiver",width:200,options:{filter:!1,customBodyRenderLite:c=>{const{receiverUser:d,receiver:m}=E[c];return d?e.jsxs(y,{"data-cy":`member-name-${d.fullName}`,sx:{display:"flex",alignItems:"center",gap:1,justifyContent:"flex-start"},children:[e.jsx(vt,{src:`${d.avatar}?imageFilter=resize&w=48&h=48`,size:32,did:m,shape:"circle",style:{borderRadius:"100%",overflow:"hidden"}}),e.jsx(Se,{children:d.fullName})]},m):e.jsx(bn,{size:14,responsive:!1,compact:!0,copyable:!1,did:m})}}},{label:"Wallet",name:"walletSendStatus",width:200,options:{setCellProps:()=>({className:"sent-status-cell"}),filter:!0,filterType:"custom",filterList:f.walletSendStatus??[],customFilterListOptions:{render:c=>e.jsx(Le,{list:c,label:"Wallet",onDelete:(d,m)=>{d.stopPropagation(),P(d,m,ie[1].options.filterList,"walletSendStatus")}}),update:Oe},filterOptions:{names:T,fullWidth:!0,logic:De,display:(c,d,m,A)=>e.jsx(Be,{label:"Wallet",filterList:c,onChange:d,index:m,column:A,filterValues:T})},customBodyRenderLite:c=>{const{walletSendStatus:d,walletSendAt:m,walletSendFailedReason:A}=E[c];return e.jsx(xe,{status:d,updatedAt:m,reason:A,channel:"wallet",onResend:U=>L(U,E[c],"wallet",[],!1)})}}},{label:"Push Kit",name:"pushKitSendStatus",width:200,options:{setCellProps:()=>({className:"sent-status-cell"}),customBodyRenderLite:c=>{const{pushKitSendStatus:d,pushKitSendAt:m,pushKitSendFailedReason:A}=E[c];return e.jsx(xe,{status:d,updatedAt:m,reason:A,channel:"pushkit",onResend:U=>L(U,E[c],"pushKit",[],!1)})},filter:!0,filterType:"custom",filterList:f.pushKitSendStatus??[],customFilterListOptions:{render:c=>e.jsx(Le,{list:c,label:"Push Kit",onDelete:(d,m)=>{d.stopPropagation(),P(d,m,ie[2].options.filterList,"pushKitSendStatus")}}),update:Oe},filterOptions:{names:T,fullWidth:!0,logic:De,display:(c,d,m,A)=>e.jsx(Be,{label:"Push Kit",filterList:c,onChange:d,index:m,column:A,filterValues:T})}}},{label:"Email",name:"emailSendStatus",width:200,options:{setCellProps:()=>({className:"sent-status-cell"}),customBodyRenderLite:c=>{const{emailSendStatus:d,emailSendAt:m,emailSendFailedReason:A}=E[c];return e.jsx(xe,{status:d,updatedAt:m,reason:A,channel:"email",onResend:U=>L(U,E[c],"email",[],!1)})},filter:!0,filterType:"custom",filterList:f.emailSendStatus??[],customFilterListOptions:{render:c=>e.jsx(Le,{list:c,label:"Email",onDelete:(d,m)=>{d.stopPropagation(),P(d,m,ie[3].options.filterList,"emailSendStatus")}}),update:Oe},filterOptions:{names:T,fullWidth:!0,logic:De,display:(c,d,m,A)=>e.jsx(Be,{label:"Email",filterList:c,onChange:d,index:m,column:A,filterValues:T})}}},{label:"Webhook",name:"webhook",width:200,options:{filter:!1,setCellProps:()=>({className:"sent-status-cell"}),customBodyRenderLite:c=>{const{webhook:d}=E[c];if(!d)return null;const m=Object.entries(d)[0];if(!m)return null;const[A,U]=m,ne=U[0];return e.jsx(y,{sx:{display:"flex",flexDirection:"column",gap:1},children:e.jsxs(y,{className:"webhook-item",sx:{fontSize:12},children:[e.jsx(Se,{maxLength:30,children:A},A),e.jsx(xe,{status:ne.status,updatedAt:ne.sendAt,reason:ne.failedReason,channel:"webhook",onResend:G=>L(G,E[c],"webhook",[A],!1)})]},A)})}}},{label:r("common.createdAt"),name:"createdAt",width:100,options:{filter:!1,customBodyRenderLite:c=>{const{createdAt:d}=E[c];return e.jsx(Nt,{value:d,locale:o,shouldUpdate:!0})}}}],[E,o,f,r]),Re=[e.jsx(Ze,{value:f.dateRange,onChange:W},"date-picker"),e.jsx(ce,{variant:"contained",size:"small",color:"primary",loading:S,startIcon:e.jsx(Kt,{}),onClick:()=>O(),sx:{".MuiButton-startIcon":{mr:"2px"}},style:{marginLeft:8},children:r("common.refresh")},"refresh")];return e.jsx(y,{sx:{overflow:"auto",".MuiTableCell-head":{whiteSpace:"nowrap",fontWeight:"bold"},".MuiTableCell-root":{paddingRight:"8px",whiteSpace:"nowrap"}},children:e.jsx(Hn,{children:e.jsxs(xt,{theme:b,children:[e.jsx(yt,{className:"receivers-table",locale:o,loading:S,columns:ie,data:E,onChange:oe,options:ue,customButtons:Re,components:{TableFilterList:c=>e.jsx(et,{...c,itemComponent:d=>e.jsx(tt,{...d,canDelete:()=>!1})})}}),z.anchorEl&&e.jsx(Ue,{open:!!z.anchorEl,anchorReference:"anchorPosition",anchorPosition:z.position,onClose:fe,anchorOrigin:{vertical:"center",horizontal:"right"},transformOrigin:{vertical:"center",horizontal:"left"},children:e.jsxs($n,{children:[e.jsxs(ee,{variant:"body1",component:"div",className:"check-title",children:[B?.channel," Checking"]}),e.jsx(y,{sx:{display:"flex",flexDirection:"column",gap:"4px"},children:we(B?.channel).map(c=>{const{type:d,pass:m,fail:A}=c;return!B?.result||B?.result?.[d]?e.jsxs(ee,{variant:"body1",component:"div",className:"check-item",sx:{display:"flex",alignItems:"center",gap:"4px",color:B?.result?.[d]?Ae.success.main:"inherit"},children:[B?.result?e.jsx(Mt,{}):e.jsx(ft,{size:12,sx:{color:Ae.primary.main}}),e.jsx("span",{children:m})]},d):e.jsxs(ee,{variant:"body1",component:"div",className:"check-item",sx:{display:"flex",alignItems:"center",gap:"4px",color:Ae.error.main},children:[e.jsx(Ut,{}),e.jsx("span",{children:A})]},d)})})]})}),F.anchorEl&&e.jsx(Ue,{open:!!F.anchorEl,anchorReference:"anchorPosition",anchorPosition:F.position,onClose:he,anchorOrigin:{vertical:"center",horizontal:"right"},transformOrigin:{vertical:"center",horizontal:"left"},children:e.jsx(Pt,{loading:t,onCancel:he,onConfirm:x})})]})})})}const Un=v.memo(Ft),Hn=ae.div`
1
+ import{g as Wt,r as v}from"./vendor-react-Dvs43sk9.js";import{j as e,ak as y,z as Q,b6 as me,bg as qe,y as V,am as ut,d2 as Bt,bn as qt,at as ae,b1 as mt,W as h,T as ee,U as Je,d3 as pt,b5 as Ke,a5 as Me,Q as Fe,d4 as Ge,aN as Ue,a6 as ft,D as ht,d5 as Kt,ad as xt,d6 as Mt,d7 as Ut,c2 as st,n as Ht,x as $t,bc as Vt,M as it,cw as Jt,I as Gt,d8 as Yt}from"./vendor-mui-core-DRxbhqaK.js";import{A as gt,J as Xt,C as Qt,e as le,F as Zt,a3 as je}from"./vendor-utils-CUDP56Ff.js";import{T as te,H as M,n as ce,c as en,p as bt,a3 as tn,au as nn,m as jt,$ as vt,j as yt,av as Ae,b as St,I as sn,a0 as an}from"./vendor-ux-B9VfuZTg.js";import{aD as rn,X as Ye,a9 as Ct,aW as wt,J as _e,c as _,_ as Z,o as on,aL as at}from"./index-C5weIh5R.js";import{g as ye,b as $,a as se}from"./vendor-hooks-BlA8TRnZ.js";import{u as Rt,C as Y}from"./index.esm-JPZAjt0x.js";import{i as He}from"./isURL-Drc7oe8g.js";import{S as X}from"./section-ZPKr6_ii.js";import{A as ln,a as cn,b as dn}from"./collapse-DJGzUM1Q.js";import{S as Se}from"./shorten-label-DVy6K5I7.js";import{v as Tt}from"./index-Ba9-ArMT.js";import{R as Nt,A as un,S as mn,a as pn,B as fn}from"./list-TG9HMVa3.js";import{j as hn,c as xn,N as gn}from"./team-DjK1LiLV.js";import{W as bn}from"./did-address-DnFNwELW.js";import{p as It}from"./util-DUiP0chO.js";import{D as jn,g as vn}from"./traffic-CxwOXUbM.js";import{B as Et}from"./bundle-avatar-Bbip6Pw_.js";import{u as yn}from"./use-mobile-BQQpAf3i.js";import"./lottie-web-4koyQiv_.js";import"./vendor-arcblock-DeeG8u0h.js";import"./required-BT8zXV8U.js";import"./server-logo-notext.svg-CKQB0tIp.js";import"./index-ChG9_ZZV.js";import"./session-DEBZccHT.js";import"./use-app-logo-BOmNYQgU.js";import"./base32-BK7MXAD4.js";import"./useAsyncRetry-EEjDgDMR.js";import"./useAsync-DVtDVEv6.js";import"./iframe-B-WaBiaG.js";import"./index-B6gW9Yjq.js";import"./index-DBs9Ljax.js";import"./base-chart-UFWO9a3P.js";import"./index-3ePiAFIp.js";import"./vendor-mui-x-Qp6zkx78.js";import"./AdapterDayjs-Bp0ir26R.js";var Te={exports:{}},Ne={exports:{}},Ie={exports:{}},rt;function Sn(){return rt||(rt=1,function(n,s){Object.defineProperty(s,"__esModule",{value:!0}),s.default=t;function t(r){return r==null}n.exports=s.default,n.exports.default=s.default}(Ie,Ie.exports)),Ie.exports}var ot;function Cn(){return ot||(ot=1,function(n,s){Object.defineProperty(s,"__esModule",{value:!0}),s.default=u;var t=o(rn()),r=o(Sn());function o(p){return p&&p.__esModule?p:{default:p}}var l=/^(?:[-+]?(?:0|[1-9][0-9]*))$/,b=/^[-+]?[0-9]+$/;function u(p,i){(0,t.default)(p),i=i||{};var N=i.allow_leading_zeroes===!1?l:b,I=!i.hasOwnProperty("min")||(0,r.default)(i.min)||p>=i.min,S=!i.hasOwnProperty("max")||(0,r.default)(i.max)||p<=i.max,j=!i.hasOwnProperty("lt")||(0,r.default)(i.lt)||p<i.lt,E=!i.hasOwnProperty("gt")||(0,r.default)(i.gt)||p>i.gt;return N.test(p)&&I&&S&&j&&E}n.exports=s.default,n.exports.default=s.default}(Ne,Ne.exports)),Ne.exports}var lt;function wn(){return lt||(lt=1,function(n,s){Object.defineProperty(s,"__esModule",{value:!0}),s.default=o;var t=r(Cn());function r(l){return l&&l.__esModule?l:{default:l}}function o(l){return(0,t.default)(l,{allow_leading_zeroes:!1,min:0,max:65535})}n.exports=s.default,n.exports.default=s.default}(Te,Te.exports)),Te.exports}var Rn=wn();const Tn=Wt(Rn),ze={enabled:!1,secure:!1,from:"",host:"",port:"",user:"",password:"",companyName:"",companyLink:"",companyAddress:"",supportEmail:""};function Nn(){const{api:n}=Ye(),{blocklet:s}=Ct(),{t}=te(),{confirmApi:r,confirmHolder:o}=wt(),l=s?.meta?.did,b=Object.assign({...ze},s?.settings?.notification?.email||{}),{handleSubmit:u,control:p,formState:i,watch:N,reset:I}=Rt({defaultValues:gt(b,Object.keys(ze))}),S=ye({testReceiver:"",testReceiverError:""}),j=N("enabled"),E=$(async(a,T,O=!0)=>{try{const{blocklet:D}=await n.configNotification({input:{did:l,notification:JSON.stringify({email:a})}}),re=Object.assign({...ze},D?.settings?.notification?.email||{});I(re),O&&M.success(t("oauth.saveSuccess"))}catch(D){if(O)M.error(D.message||t("oauth.saveFailed"));else throw D}}),J=$(async(a,T,O)=>{try{i.isDirty&&await E(a,T,!1),await n.sendEmail({input:{did:l,receiver:O,email:JSON.stringify({body:"Your SMTP configuration is correct!",title:"Test email",type:"notification",attachments:[{type:"link",data:{url:"https://community.arcblock.io",title:"Community",image:"https://community.arcblock.io/.well-known/service/blocklet/logo-rect-dark",utm:{campaign:"test-campaign"}}}],utm:{content:"test-email-button"}})}}),M.success(t("notification.email.testSuccess"))}catch(D){M.error(D.message||t("notification.email.testfailed"))}}),z=$((a,T)=>{S.testReceiver=localStorage.getItem("test-receiver")||"",S.testReceiverError="",r.open({title:t("notification.email.testSendEmail"),content:()=>e.jsx(y,{sx:{width:"300px"},children:e.jsx(Q,{sx:{mt:1},fullWidth:!0,name:"testReceiver",label:t("notification.email.inputTestReceiver"),value:S.testReceiver,onChange:O=>{S.testReceiver=O.target.value},error:!!S.testReceiverError,helperText:S.testReceiverError||" "})}),confirmButtonText:t("common.confirm"),cancelButtonText:t("common.cancel"),async onConfirm(O){const D=S.testReceiver?.trim();if(!D){S.testReceiverError=t("notification.email.receiverRequired");return}if(!_e(D)){S.testReceiverError=t("notification.email.receiverInvalid");return}S.testReceiverError="",await J(a,T,D),O()}})}),F=$(a=>{const T=a?.trim();return T?_e(T)?!0:t("notification.email.fromInvalid"):t("notification.email.fromRequired")}),B=$(a=>{const T=a?.trim();return T?He(T,{require_host:!1,protocols:[]})?!0:t("notification.email.hostInvalid"):t("notification.email.hostRequired")}),w=$(a=>a?Tn(a)?!0:t("notification.email.portInvalid"):t("notification.email.portRequired")),q=$(a=>a?.trim()?!0:t("notification.email.userRequired")),K=$(a=>a?.trim()?!0:t("notification.email.passwordRequired")),f=$(a=>a?.trim()&&!He(a,{protocols:["http","https"],require_protocol:!0})?t("notification.email.linkInvalid"):!0),R=$(a=>a?.trim()&&!_e(a)?t("notification.email.emailInvalid"):!0),C=$(()=>!0);return e.jsxs(y,{children:[e.jsxs(In,{component:"form",onSubmit:u(E),disabled:!0,sx:{".section-left":{width:"160px"}},children:[e.jsx(X,{title:t("notification.email.enable"),my:2.5,children:e.jsx(Y,{name:"enabled",control:p,render:({field:a})=>e.jsx(me,{control:e.jsx(qe,{checked:a.value,...a})})})}),e.jsx(X,{title:t("notification.email.from"),children:e.jsx(Y,{name:"from",control:p,rules:{validate:j?F:C},render:({field:a})=>e.jsx(V,{fullWidth:!0,children:e.jsx(Q,{...a,size:"small",required:!0,label:t("notification.email.from"),error:!!i.errors[a.name],helperText:i.errors[a.name]?.message||" ",disabled:!j})})})}),e.jsx(X,{title:t("notification.email.host"),children:e.jsx(Y,{name:"host",control:p,rules:{validate:j?B:C},render:({field:a})=>e.jsx(V,{fullWidth:!0,children:e.jsx(Q,{...a,size:"small",required:!0,error:!!i.errors[a.name],label:t("notification.email.host"),helperText:i.errors[a.name]?.message||" ",disabled:!j})})})}),e.jsx(X,{title:t("notification.email.port"),children:e.jsx(Y,{name:"port",control:p,rules:{validate:j?w:C},render:({field:a})=>e.jsx(V,{fullWidth:!0,children:e.jsx(Q,{...a,size:"small",required:!0,type:"number",error:!!i.errors[a.name],label:t("notification.email.port"),helperText:i.errors[a.name]?.message||" ",disabled:!j})})})}),e.jsx(X,{title:t("notification.email.user"),children:e.jsx(Y,{name:"user",control:p,rules:{validate:j?q:C},render:({field:a})=>e.jsx(V,{fullWidth:!0,children:e.jsx(Q,{...a,size:"small",required:!0,error:!!i.errors[a.name],label:t("notification.email.user"),helperText:i.errors[a.name]?.message||" ",disabled:!j})})})}),e.jsx(X,{title:t("notification.email.password"),children:e.jsx(Y,{name:"password",control:p,rules:{validate:j?K:C},render:({field:a})=>e.jsx(V,{fullWidth:!0,children:e.jsx(Q,{...a,size:"small",required:!0,type:"password",error:!!i.errors[a.name],label:t("notification.email.password"),helperText:i.errors[a.name]?.message||" ",disabled:!j})})})}),e.jsx(X,{title:t("notification.email.secure"),children:e.jsx(Y,{name:"secure",control:p,rules:{validate:C},render:({field:a})=>e.jsx(V,{fullWidth:!0,children:e.jsx(me,{control:e.jsx(qe,{checked:a.value,...a,disabled:!j})})})})}),e.jsxs(ln,{children:[e.jsxs(cn,{expandIcon:e.jsx(qt,{fontSize:"small"}),"aria-controls":"panel1-content",id:"panel1-header",children:[t("notification.email.signature"),e.jsx(ut,{title:t("notification.email.signatureTooltip"),children:e.jsx(Bt,{fontSize:"small",sx:{ml:1,cursor:"help"}})})]}),e.jsxs(dn,{children:[e.jsx(X,{title:t("notification.email.companyName"),children:e.jsx(Y,{name:"companyName",control:p,rules:{validate:C},render:({field:a})=>e.jsx(V,{fullWidth:!0,children:e.jsx(Q,{...a,size:"small",error:!!i.errors[a.name],label:t("notification.email.companyName"),helperText:i.errors[a.name]?.message||" ",disabled:!j})})})}),e.jsx(X,{title:t("notification.email.companyLink"),children:e.jsx(Y,{name:"companyLink",control:p,rules:{validate:j?f:C},render:({field:a})=>e.jsx(V,{fullWidth:!0,children:e.jsx(Q,{...a,size:"small",error:!!i.errors[a.name],label:t("notification.email.companyLink"),helperText:i.errors[a.name]?.message||" ",disabled:!j})})})}),e.jsx(X,{title:t("notification.email.companyAddress"),children:e.jsx(Y,{name:"companyAddress",control:p,rules:{validate:C},render:({field:a})=>e.jsx(V,{fullWidth:!0,children:e.jsx(Q,{...a,size:"small",error:!!i.errors[a.name],label:t("notification.email.companyAddress"),helperText:i.errors[a.name]?.message||" ",disabled:!j})})})}),e.jsx(X,{title:t("notification.email.supportEmail"),children:e.jsx(Y,{name:"supportEmail",control:p,rules:{validate:j?R:C},render:({field:a})=>e.jsx(V,{fullWidth:!0,children:e.jsx(Q,{...a,size:"small",type:"email",error:!!i.errors[a.name],label:t("notification.email.supportEmail"),helperText:i.errors[a.name]?.message||" ",disabled:!j})})})})]})]}),e.jsxs(y,{sx:{display:"flex",justifyContent:"flex-end",gap:2,mt:3},children:[e.jsx(ce,{variant:"outlined",color:"warning",onClick:u(z),disabled:!j,children:t("oauth.runTest")}),e.jsx(ce,{type:"submit",variant:"contained",disabled:!i.isDirty,children:t("oauth.save")})]})]}),o]})}const In=ae(mt)``,We={enabled:!1,endpoint:"",did:void 0,pushPath:void 0};function En(){const{api:n}=Ye(),{blocklet:s}=Ct(),{t}=te(),{confirmApi:r,confirmHolder:o}=wt(),l=s?.meta?.did,b=Object.assign({...We},s?.settings?.notification?.pushKit||{}),{handleSubmit:u,control:p,formState:i,watch:N,reset:I}=Rt({defaultValues:gt(b,Object.keys(We))}),S=ye({testReceiver:"",testReceiverError:""}),j=N("enabled"),E=$(async(w,q,K=!0)=>{try{const{blocklet:f}=await n.configNotification({input:{did:l,notification:JSON.stringify({pushKit:w})}}),R=Object.assign({...We},f?.settings?.notification?.pushKit||{});I(R),K&&M.success(t("oauth.saveSuccess"))}catch(f){if(K)M.error(f.message||t("oauth.saveFailed"));else throw f}}),J=$(async(w,q)=>{try{i.isDirty&&await E(w,q,!1);const K=(s?.configs||[]).find(C=>C.key==="BLOCKLET_APP_URL")?.value,f=Xt(Qt(K,_.WELLKNOWN_SERVICE_PATH_PREFIX,"/blocklet/logo"),{v:s?.meta?.version,t:new Date(s?.updatedAt||0).getTime()}),R={type:"passthrough",passthroughType:"messageStatus",data:{message:{title:"Test push-kit notification",body:"This is message from push-kit config test",sender:{did:s?.appDid,fullName:s?.meta?.title,avatar:f}}}};await n.sendPush({input:{did:l,receiver:S.testReceiver,notification:JSON.stringify(R)}}),M.success(t("notification.pushKit.testSuccess"))}catch(K){M.error(K.message||t("notification.pushKit.testfailed"))}}),z=$((w,q)=>{S.testReceiverError="",r.open({title:t("notification.pushKit.testSend"),content:()=>e.jsx(y,{sx:{width:"450px",maxWidth:"100%"},children:e.jsx(Q,{sx:{mt:1},fullWidth:!0,name:"testReceiver",label:t("notification.pushKit.inputTestReceiver"),value:S.testReceiver,onChange:K=>{S.testReceiver=K.target.value},error:!!S.testReceiverError,helperText:S.testReceiverError||" "})}),confirmButtonText:t("common.confirm"),cancelButtonText:t("common.cancel"),async onConfirm(K){if(!S.testReceiver?.trim()){S.testReceiverError=t("notification.pushKit.receiverRequired");return}S.testReceiverError="",await J(w,q),K()}})}),F=$(w=>{const q=w?.trim();return q?He(q)?!0:t("notification.pushKit.endpointInvalid"):t("notification.pushKit.endpointRequired")}),B=$(()=>!0);return e.jsxs(y,{children:[e.jsxs(kn,{component:"form",onSubmit:u(E),disabled:!0,sx:{".section-left":{width:"160px"}},children:[e.jsx(X,{title:t("notification.pushKit.enable"),my:2.5,children:e.jsx(Y,{name:"enabled",control:p,render:({field:w})=>e.jsx(me,{control:e.jsx(qe,{checked:w.value,...w})})})}),e.jsx(X,{title:t("notification.pushKit.endpoint"),children:e.jsx(Y,{name:"endpoint",control:p,rules:{validate:j?F:B},render:({field:w})=>e.jsx(V,{fullWidth:!0,children:e.jsx(Q,{...w,size:"small",required:!0,label:t("notification.pushKit.endpoint"),error:!!i.errors[w.name],helperText:i.errors[w.name]?.message||" ",disabled:!j})})})}),e.jsxs(X,{title:t("notification.pushKit.customOptions"),children:[e.jsx(Y,{name:"did",control:p,render:({field:w})=>e.jsx(V,{fullWidth:!0,children:e.jsx(Q,{...w,size:"small",label:t("notification.pushKit.did"),error:!!i.errors[w.name],helperText:i.errors[w.name]?.message||" ",disabled:!j})})}),e.jsx(Y,{name:"pushPath",control:p,render:({field:w})=>e.jsx(V,{fullWidth:!0,children:e.jsx(Q,{...w,size:"small",label:t("notification.pushKit.pushPath"),error:!!i.errors[w.name],helperText:i.errors[w.name]?.message||" ",disabled:!j})})})]}),e.jsxs(y,{sx:{display:"flex",justifyContent:"flex-end",gap:2,mt:3},children:[e.jsx(ce,{variant:"outlined",color:"warning",onClick:u(z),disabled:!j,children:t("oauth.runTest")}),e.jsx(ce,{type:"submit",variant:"contained",disabled:!i.isDirty,children:t("oauth.save")})]})]}),o]})}const kn=ae(mt)``,ct=[{label:e.jsx(y,{sx:{textAlign:"center",width:"100%"},children:"Email"}),value:"email"},{label:e.jsx(y,{sx:{textAlign:"center",width:"100%"},children:"Push Kit"}),value:"pushKit"}];function An(){const[n,s]=v.useState(ct[0].value),{locale:t}=v.useContext(en),r=se(()=>({email:e.jsx(Nn,{}),pushKit:e.jsx(En,{})}),[t]),o=v.useMemo(()=>({padding:"10px 0"}),[]);return e.jsxs(y,{children:[e.jsx(bt,{tabs:ct,current:n,onChange:s}),e.jsx(y,{style:o,children:r[n]})]})}const kt=v.createContext({}),{Provider:On,Consumer:Ws}=kt;function Dn({children:n,blocklet:s=""}){const{api:t,inService:r,ws:{useSubscription:o}}=Ye(),[l,b]=v.useState([]),[u,p]=v.useState({total:0,pageSize:20,pageCount:0,page:1}),i=se(()=>s.meta?.did,[s]),[N,I]=v.useState([]),[S,j]=v.useState({}),E=se(()=>l.length?new Set(l.map(f=>f.id)):new Set,[l]),J=async({page:f=1,pageSize:R=20,...C}={})=>{if(!i)return[];try{const a={paging:{page:f,pageSize:R},...C,teamDid:i,dateRange:C.dateRange?[Z(C.dateRange[0]).toISOString(),Z(C.dateRange[1]).toISOString()]:void 0},{dids:T,...O}=a;let D="";T&&T.includes("system")&&(D="system");const re=T?T.filter(pe=>pe!=="system"):[],ue={...O,source:D,componentDids:re},oe=await t.getNotificationSendLog({input:ue});return j(ue),b(oe.list),p(oe.paging),oe.list}catch(a){return M.error(a.message),[]}},z=async()=>{const f=await t.getNotificationComponents({input:{teamDid:i}});I(f.componentDids)},F=v.useCallback(f=>{const R=s.children.find(C=>C.meta?.did===f);if(R)return R.ancestors=[s],R},[s]),B=async({notificationId:f,receivers:R,channels:C,...a})=>{await t.resendNotification({input:{teamDid:i,notificationId:f,receivers:R,channels:C.map(T=>T==="wallet"?_.NOTIFICATION_SEND_CHANNEL.WALLET:T==="pushKit"?_.NOTIFICATION_SEND_CHANNEL.PUSH:T),...a}})},w=v.useCallback(async f=>(await t.getUser({input:{teamDid:i,user:{did:f},options:{enableConnectedAccount:!0}}})).user,[t,i]),q=v.useCallback(async({page:f=1,pageSize:R=20,...C}={})=>{try{const a={paging:{page:f,pageSize:R},...C,userName:C.searchText||"",teamDid:i,dateRange:C.dateRange?[Z(C.dateRange[0]).toISOString(),Z(C.dateRange[1]).toISOString()]:void 0};return await t.getReceivers({input:a})}catch(a){throw M.error(a.message),a}},[t,i]);v.useEffect(()=>{i&&z()},[i]),o(_.EVENTS.NOTIFICATION_BLOCKLET_UPDATE,f=>{E.has(f.notificationId)&&J(S)},[E,S]),o(_.EVENTS.NOTIFICATION_BLOCKLET_CREATE,f=>{E.has(f.id)||J(S)},[E,S]);const K={fetch:J,data:l,paging:u,blocklet:s,getComponent:F,resendNotification:B,getUser:w,componentDids:N,getReceivers:q,inService:r,teamDid:i};return e.jsx(On,{value:{notificationRecords:K},children:n})}function Xe(){const{notificationRecords:n}=v.useContext(kt);return n}Ce.propTypes={severity:h.oneOf(Object.values(["info","success","error","warning"])).isRequired};const Ln={info:"primary",success:"success",error:"error",warning:"warning"};function Ce({severity:n="info"}){return e.jsx(tn,{type:Ln[n],children:n})}const Pn=(n,s,t="")=>{if(!t||!s)return"";switch(t){case _.NOTIFICATION_SEND_FAILED_REASON.USER_DISABLED:return n("notification.sendStatus.reason.disabled",{channel:s});case _.NOTIFICATION_SEND_FAILED_REASON.CHANNEL_UNAVAILABLE:return n("notification.sendStatus.reason.unavailable",{channel:s});case _.NOTIFICATION_SEND_FAILED_REASON.CHANNEL_DISABLED:return n("notification.sendStatus.reason.notSent",{channel:s});case _.NOTIFICATION_SEND_FAILED_REASON.NOT_ONLINE:return n("notification.sendStatus.reason.offline");default:return t}};function At(n,s,t={}){const{status:r,updatedAt:o,reason:l="",channel:b="wallet"}=t,u=o?n("notification.sendStatus.sentTime",{date:on(o,s)}):"",p=Pn(n,b,l);return r===_.NOTIFICATION_SEND_STATUS.FAILED?{status:"failed",title:n("notification.sendStatus.failed"),sentTime:u,reason:p}:r===_.NOTIFICATION_SEND_STATUS.SENT?{status:"success",title:n("notification.sendStatus.success"),sentTime:u}:{status:"pending",title:n("notification.sendStatus.pending"),reason:p,sentTime:u}}const $e={pending:"#aaaaaa",success:"#34BE74",failed:"#D0021B"},Ve=["wallet","pushKit","email"],dt=["info","success","error","warning"],Ot=n=>{const{settings:s}=n;return s?.notification?.email?.enabled},Dt=n=>{const{settings:s}=n;return s?.notification?.pushKit?.enabled},Fn=(n,s)=>{const t=le(s,"extra.notifications.email",!0);return{available:Ot(n),enabled:t}},_n=(n,s)=>{const t=le(s,"extra.notifications.push",!0);return{available:Dt(n),enabled:t}},zn=n=>({enabled:le(n,"extra.notifications.wallet",!0)}),Wn=n=>({enabled:le(n,"extra.webhooks",[]).length>0}),Ee=(n=3)=>new Promise(s=>{setTimeout(()=>{s()},n*1e3)}),Bn=(n,s)=>s==="wallet"||s==="webhook"?[{channel:s,type:"enabled",pass:n("notification.sendStatus.reason.enabled",{channel:s}),fail:n("notification.sendStatus.reason.disabled",{channel:s})}]:s==="pushKit"||s==="email"?[{channel:s,type:"available",pass:n("notification.sendStatus.reason.available",{channel:s}),fail:n("notification.sendStatus.reason.unavailable",{channel:s})},{channel:s,type:"enabled",pass:n("notification.sendStatus.reason.enabled",{channel:s}),fail:n("notification.sendStatus.reason.disabled",{channel:s})}]:[],ke=(n=[])=>{const s=Z().startOf("day");return n.filter(t=>Z(t.sendAt).isSame(s,"day")).length},qn=(n,s="")=>{if(s&&Ve.includes(s)){const l=`${s}SendRecord`,b=le(n,l,[]);return ke(b)}const t=le(n,"webhook",{}),r=Object.keys(t??{})??[];if(s&&r.includes(s)){const l=t[s]??[];return ke(l)}const o={};return Ve.forEach(l=>{const b=`${l}SendRecord`,u=le(n,b,[]),p=ke(u);o[l]=p}),r.length>0&&r.forEach(l=>{const b=t[l]??[],u=ke(b);o[l]=u}),o},Oe=(n,s,t)=>{if(!Array.isArray(n))throw new Error("Invalid filterList or index");return n[t].splice(s,1),n},De=(n,s)=>{if(!Array.isArray(s))throw new Error("filters must be an array");return s.length?!s.includes(n):!1},Kn=n=>{switch(n){case _.NOTIFICATION_SEND_CHANNEL.WALLET:return"Wallet";case _.NOTIFICATION_SEND_CHANNEL.PUSH:return"Push Kit";case _.NOTIFICATION_SEND_CHANNEL.EMAIL:return"Email";case _.NOTIFICATION_SEND_CHANNEL.WEBHOOK:return"Webhook";default:return""}},Lt=()=>({components:{MUIDataTableFilter:{styleOverrides:{header:{marginBottom:0,p:{margin:0}},root:{"& .MuiGrid-container":{marginTop:0,"& .MuiGrid-item":{paddingTop:0}}}}},MuiPopover:{styleOverrides:{root:{"&.MuiPopover-root":{"& .MuiPaper-root:has(.filter-container)":{width:"420px"}}}}}}});function de({config:n,enableTooltip:s=!0,showTitle:t=!1,children:r=null}){const{status:o,title:l="",sentTime:b="",reason:u=""}=n,p=[l,u].filter(Boolean).join(", ");return e.jsx(ut,{title:s?e.jsxs(e.Fragment,{children:[e.jsx(ee,{color:"inherit",sx:{fontSize:12},children:p}),e.jsx("span",{children:b})]}):null,arrow:!0,placement:"top",children:e.jsxs(y,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"4px"},children:[e.jsxs(y,{sx:{position:"relative",minHeight:14,minWidth:14,display:"flex",alignItems:"center",justifyContent:"center"},children:[e.jsx(y,{style:{opacity:.15},sx:{position:"absolute",width:"100%",height:"100%",borderRadius:"50%",bgcolor:$e[o]}}),e.jsx(y,{sx:{position:"absolute",width:"55%",height:"55%",borderRadius:"50%",bgcolor:$e[o]}})]}),e.jsx(ee,{color:"inherit",sx:{fontSize:12},children:t?l:r})]})})}de.propTypes={config:h.object.isRequired,enableTooltip:h.bool,showTitle:h.bool,children:h.node};Le.propTypes={list:h.array.isRequired,label:h.string.isRequired,onDelete:h.func};function Le({list:n,label:s,onDelete:t=()=>{}}){const{t:r,locale:o}=te();return e.jsxs(y,{sx:{display:"flex",gap:1,alignItems:"center"},children:[e.jsxs(ee,{children:[s,": "]}),n.map(l=>{const b=At(r,o,{status:l});return e.jsx(Je,{size:"small",label:e.jsx(y,{sx:{display:"flex",alignItems:"center",gap:"4px"},children:e.jsx(de,{config:b,enableTooltip:!1,children:b.title})}),onDelete:u=>t(u,l)},l)})]})}Qe.propTypes={filterList:h.array.isRequired,onChange:h.func.isRequired,index:h.number.isRequired,column:h.object.isRequired,filterValues:h.array.isRequired,label:h.string.isRequired,renderLabel:h.func.isRequired};function Qe({filterList:n,onChange:s,index:t,column:r,filterValues:o,label:l,renderLabel:b}){return e.jsxs(V,{className:"filter-container",children:[e.jsx(pt,{component:"legend",children:l}),e.jsx(Ke,{row:!0,children:o.map(u=>e.jsx(me,{control:e.jsx(Me,{checked:n[t].indexOf(u.value??u)>-1,onChange:p=>{const i=[...n];p.target.checked?i[t]=[...i[t],u.value??u]:i[t]=i[t].filter(N=>N!==(u.value??u)),s(i[t],t,r)},name:u.value??u}),label:e.jsx("span",{style:{display:"flex",alignItems:"center"},children:b(u)})},u.value??u))})]})}function Be(n){return e.jsx(Qe,{...n,renderLabel:s=>e.jsx(de,{enableTooltip:!1,config:{status:s.status},children:s.label})})}xe.propTypes={status:h.number.isRequired,updatedAt:h.string.isRequired,reason:h.string,channel:h.string,onResend:h.func};function xe({status:n,updatedAt:s,reason:t="",channel:r="wallet",onResend:o}){const{t:l,locale:b}=te(),u=At(l,b,{status:n,updatedAt:s,reason:t,channel:r});return e.jsxs(y,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(de,{config:u,showTitle:!0}),u.status!=="success"&&e.jsx(Fe,{className:"resend-btn",size:"small",startIcon:e.jsx(Ge,{}),sx:{fontSize:12,color:"rgba(0, 0, 0, 0.87)",fontWeight:400,".MuiButton-startIcon":{mr:"2px"}},onClick:o,children:l("notification.resend")})]})}Ze.propTypes={value:h.array.isRequired,onChange:h.func};function Ze({value:n,onChange:s}){const{locale:t}=te(),r=Z().toDate(),[o,l]=v.useState(null),b=v.useCallback(i=>{l(o?null:i.currentTarget)},[o]),u=!!o,p=v.useCallback(i=>{if(!i.startDate||!i.endDate){M.error("Please select a date range");return}if(Z(i.startDate).isAfter(i.endDate)||!Z(i.startDate).isValid()||!Z(i.endDate).isValid()){M.error("Invalid date range");return}s([i.startDate,i.endDate]),l(null)},[s]);return e.jsxs("div",{children:[e.jsx(ee,{component:"div",variant:"h5",color:"textPrimary",style:{fontSize:18,fontWeight:"bold"},sx:{mb:0},children:e.jsxs(Fe,{onClick:b,variant:"outlined",size:"small",color:"inherit",children:[at(n[0],t)," - ",at(n[1],t)]})}),e.jsx(Ue,{open:u,anchorEl:o,onClose:()=>{l(null)},anchorOrigin:{vertical:"bottom",horizontal:"left"},children:e.jsx(jn,{open:!0,maxDate:r,initialDateRange:{startDate:n[0],endDate:n[1]},toggle:b,definedRanges:vn(r),onChange:p})})]})}et.propTypes={itemComponent:h.elementType.isRequired};function et({itemComponent:n,...s}){const{t}=te();return!s?.filterList?.filter(o=>o.length).length?null:e.jsxs(y,{sx:{display:"flex",gap:1,alignItems:"center"},children:[e.jsx("div",{className:"toolbar-filter-title",children:t("notification.filter")}),e.jsx("div",{className:"toolbar-filter-content",children:e.jsx(nn.TableFilterList,{...s,ItemComponent:n})})]})}function tt({label:n,onDelete:s,canDelete:t=()=>!0,...r}){const o=s&&typeof s=="function"?s:void 0;let l=!0;return t&&typeof t=="function"&&(l=t({label:n,...r})),e.jsx(Je,{label:n,variant:"outlined",...o&&l?{onDelete:o}:{}})}tt.propTypes={label:h.string.isRequired,onDelete:h.func,canDelete:h.func};const Mn=[{label:"Wallet",value:"app",checked:!0},{label:"Email",value:"email",checked:!0},{label:"Push Kit",value:"push",checked:!0},{label:"Webhook",value:"webhook",checked:!0}];Pt.propTypes={loading:h.bool,onCancel:h.func,onConfirm:h.func};function Pt({loading:n=!1,onCancel:s=()=>{},onConfirm:t=()=>{}}){const{t:r}=te(),[o,l]=v.useState(Mn),[b,u]=v.useState(!0),p=(N,I)=>{I.checked=N.target.checked;const S=o.map(j=>({...j,checked:j.value===I.value?I.checked:j.checked}));l(S)},i=N=>{N.stopPropagation(),t({channels:o.filter(I=>I.checked).map(I=>I.value),isResendFailedOnly:b})};return e.jsxs(y,{className:"resend-config",sx:{padding:"16px 24px"},children:[e.jsx(ee,{variant:"body1",component:"div",className:"check-title",sx:{fontWeight:700,mb:1},children:r("notification.config")}),e.jsx(y,{className:"choose-channel",children:e.jsxs(V,{component:"fieldset",variant:"standard",children:[e.jsx(pt,{component:"legend",children:r("notification.selectChannels")}),e.jsx(Ke,{sx:{display:"flex",flexDirection:"row",flexWrap:"wrap",gap:1},children:o.map(N=>e.jsx(me,{control:e.jsx(Me,{checked:N.checked,onChange:I=>p(I,N),name:N.value}),label:N.label},N.value))})]})}),e.jsx(y,{className:"resend-config-footer",children:e.jsx(Ke,{children:e.jsx(me,{control:e.jsx(Me,{checked:b,onChange:N=>u(N.target.checked)}),label:r("notification.resendFailedOnly")})})}),e.jsxs(y,{className:"resend-config-footer-tip",sx:{display:"flex",justifyContent:"flex-end",gap:1},children:[e.jsx(Fe,{onClick:N=>{N.stopPropagation(),s()},color:"inherit",children:r("common.cancel")}),e.jsxs(Fe,{onClick:i,color:"primary",disabled:n,variant:"contained",autoFocus:!0,style:{marginLeft:8},children:[n&&e.jsx(ft,{size:16}),r("common.confirm")]})]})]})}Ft.propTypes={notificationId:h.string.isRequired,handleResend:h.func,resending:h.bool};function Ft({notificationId:n,handleResend:s,resending:t=!1}){const{t:r,locale:o}=te(),l=ht(),b=v.useMemo(()=>jt(l,Lt()),[l]),{getReceivers:u,inService:p,teamDid:i,getUser:N,blocklet:I}=Xe(),[S,j]=v.useState(!1),[E,J]=v.useState([]),z=ye({anchorEl:null,position:null}),F=ye({anchorEl:null,position:null}),[B,w]=v.useState(null),[q,K]=v.useState({total:0,pageSize:10,pageCount:0,page:1}),[f,R]=v.useState({searchText:"",page:1,pageSize:10,walletSendStatus:[],pushKitSendStatus:[],emailSendStatus:[],dateRange:[Z().subtract(1,"month").startOf("day").toDate(),Z().endOf("day").toDate()]}),[C,a]=v.useState([]),T=[{label:r("notification.sendStatus.pending"),value:0,status:"pending"},{label:r("notification.sendStatus.success"),value:1,status:"success"},{label:r("notification.sendStatus.failed"),value:2,status:"failed"}],O=async()=>{if(!S&&n)try{j(!0);const c=await u({notificationId:n,...f}),d=c.list.map(m=>({...m,receiverUser:{...m.receiverUser,avatar:It(m.receiverUser.avatar,i,p)}}));J(d),K(c.paging),j(!1)}catch(c){M.error(c.message),j(!1)}};v.useEffect(()=>{O()},[f]);const D=c=>{c.stopPropagation();const d=c.currentTarget;F.anchorEl=d;const m=d.getBoundingClientRect();F.position={top:m.top+window.scrollY,left:m.left+window.scrollX}},re=c=>c.data.length?e.jsx("div",{style:{display:"flex",alignItems:"center",padding:"10px"},children:e.jsx(ce,{className:"resend-btn",size:"small",color:"primary",variant:"contained",startIcon:e.jsx(Ge,{}),sx:{".MuiButton-startIcon":{mr:"2px"}},onClick:D,children:r("notification.resend")})}):null,ue={sort:!1,download:!1,print:!1,selectableRows:"multiple",searchPlaceholder:r("common.search"),searchAlwaysOpen:!1,filterType:"checkbox",searchDebounceTime:300,page:q.page-1,rowsPerPage:q.pageSize,count:q.total,searchText:f.searchText,tableBodyMaxHeight:"calc(80vh - 260px)",rowsSelected:C,onRowSelectionChange:(c,d)=>{a(d.map(m=>m.dataIndex))},customToolbarSelect:re},oe=({page:c,rowsPerPage:d,searchText:m,filterList:A})=>{const[,U=[],ne=[],G=[]]=A;f.pageSize!==d?R(H=>({...H,pageSize:d,page:1})):f.page!==c+1?R(H=>({...H,page:c+1})):f.searchText!==m?R(H=>({...H,searchText:m,page:1})):je(U,f.walletSendStatus)?je(ne,f.pushKitSendStatus)?je(G,f.emailSendStatus)||R(H=>({...H,emailSendStatus:G,page:1})):R(H=>({...H,pushKitSendStatus:ne,page:1})):R(H=>({...H,walletSendStatus:U,page:1}))},pe=v.useCallback(async(c,d)=>{if(!d)return!1;const m=await N(d);return m?c==="wallet"?zn(m):c==="email"?Fn(I,m):c==="pushKit"?_n(I,m):c==="webhook"?Wn(m):!0:!1},[N,I]),we=v.useCallback(c=>Bn(r,c),[r]),fe=()=>{z.anchorEl=null,z.position=null,w(null)},he=()=>{F.anchorEl=null,F.position=null},g=async(c,d,m=!0,A="")=>{if(!(!d.length||!c.length))try{s(c,d,m,A),F.anchorEl||(await Ee(.5),fe())}catch(U){console.error("handleResend error",{error:U})}},x=async({channels:c,isResendFailedOnly:d})=>{const m=C.map(A=>E[A].receiver);await g(c,m,d),await Ee(.5),he(),a([])},k=async(c,d=[],m=!0)=>{try{await g(["webhook"],[c.receiver],m,d)}catch(A){M.error(A.response?A.response.statusText:A.message)}},L=async(c,d,m,A=[],U=!0)=>{if(c.stopPropagation(),qn(d,m)>=4){M.warning(r("notification.resendLimit"));return}if(!Ve.includes(m)){await k(d,A,U);return}if(c){const G=c.currentTarget,H=G.getBoundingClientRect();z.anchorEl=G,z.position={top:H.top+window.scrollY,left:H.left+window.scrollX}}w({channel:m});try{const G=await pe(m,d.receiver);await Ee(1),w({channel:m,result:G}),(typeof G=="boolean"&&G||Zt(G)&&Object.values(G).every(H=>!!H))&&(await s([m],[d.receiver],U),F.anchorEl||(await Ee(.5),fe()))}catch(G){M.error(G.message)}},W=c=>{R(d=>({...d,dateRange:c,page:1}))},P=(c,d,m,A)=>{c.stopPropagation();const U=m.filter(ne=>ne!==d);R(ne=>({...ne,[A]:U,page:1}))},ie=se(()=>[{label:r("notification.receiver"),name:"receiver",width:200,options:{filter:!1,customBodyRenderLite:c=>{const{receiverUser:d,receiver:m}=E[c];return d?e.jsxs(y,{"data-cy":`member-name-${d.fullName}`,sx:{display:"flex",alignItems:"center",gap:1,justifyContent:"flex-start"},children:[e.jsx(vt,{src:`${d.avatar}?imageFilter=resize&w=48&h=48`,size:32,did:m,shape:"circle",style:{borderRadius:"100%",overflow:"hidden"}}),e.jsx(Se,{children:d.fullName})]},m):e.jsx(bn,{size:14,responsive:!1,compact:!0,copyable:!1,did:m})}}},{label:"Wallet",name:"walletSendStatus",width:200,options:{setCellProps:()=>({className:"sent-status-cell"}),filter:!0,filterType:"custom",filterList:f.walletSendStatus??[],customFilterListOptions:{render:c=>e.jsx(Le,{list:c,label:"Wallet",onDelete:(d,m)=>{d.stopPropagation(),P(d,m,ie[1].options.filterList,"walletSendStatus")}}),update:Oe},filterOptions:{names:T,fullWidth:!0,logic:De,display:(c,d,m,A)=>e.jsx(Be,{label:"Wallet",filterList:c,onChange:d,index:m,column:A,filterValues:T})},customBodyRenderLite:c=>{const{walletSendStatus:d,walletSendAt:m,walletSendFailedReason:A}=E[c];return e.jsx(xe,{status:d,updatedAt:m,reason:A,channel:"wallet",onResend:U=>L(U,E[c],"wallet",[],!1)})}}},{label:"Push Kit",name:"pushKitSendStatus",width:200,options:{setCellProps:()=>({className:"sent-status-cell"}),customBodyRenderLite:c=>{const{pushKitSendStatus:d,pushKitSendAt:m,pushKitSendFailedReason:A}=E[c];return e.jsx(xe,{status:d,updatedAt:m,reason:A,channel:"pushkit",onResend:U=>L(U,E[c],"pushKit",[],!1)})},filter:!0,filterType:"custom",filterList:f.pushKitSendStatus??[],customFilterListOptions:{render:c=>e.jsx(Le,{list:c,label:"Push Kit",onDelete:(d,m)=>{d.stopPropagation(),P(d,m,ie[2].options.filterList,"pushKitSendStatus")}}),update:Oe},filterOptions:{names:T,fullWidth:!0,logic:De,display:(c,d,m,A)=>e.jsx(Be,{label:"Push Kit",filterList:c,onChange:d,index:m,column:A,filterValues:T})}}},{label:"Email",name:"emailSendStatus",width:200,options:{setCellProps:()=>({className:"sent-status-cell"}),customBodyRenderLite:c=>{const{emailSendStatus:d,emailSendAt:m,emailSendFailedReason:A}=E[c];return e.jsx(xe,{status:d,updatedAt:m,reason:A,channel:"email",onResend:U=>L(U,E[c],"email",[],!1)})},filter:!0,filterType:"custom",filterList:f.emailSendStatus??[],customFilterListOptions:{render:c=>e.jsx(Le,{list:c,label:"Email",onDelete:(d,m)=>{d.stopPropagation(),P(d,m,ie[3].options.filterList,"emailSendStatus")}}),update:Oe},filterOptions:{names:T,fullWidth:!0,logic:De,display:(c,d,m,A)=>e.jsx(Be,{label:"Email",filterList:c,onChange:d,index:m,column:A,filterValues:T})}}},{label:"Webhook",name:"webhook",width:200,options:{filter:!1,setCellProps:()=>({className:"sent-status-cell"}),customBodyRenderLite:c=>{const{webhook:d}=E[c];if(!d)return null;const m=Object.entries(d)[0];if(!m)return null;const[A,U]=m,ne=U[0];return e.jsx(y,{sx:{display:"flex",flexDirection:"column",gap:1},children:e.jsxs(y,{className:"webhook-item",sx:{fontSize:12},children:[e.jsx(Se,{maxLength:30,children:A},A),e.jsx(xe,{status:ne.status,updatedAt:ne.sendAt,reason:ne.failedReason,channel:"webhook",onResend:G=>L(G,E[c],"webhook",[A],!1)})]},A)})}}},{label:r("common.createdAt"),name:"createdAt",width:100,options:{filter:!1,customBodyRenderLite:c=>{const{createdAt:d}=E[c];return e.jsx(Nt,{value:d,locale:o,shouldUpdate:!0})}}}],[E,o,f,r]),Re=[e.jsx(Ze,{value:f.dateRange,onChange:W},"date-picker"),e.jsx(ce,{variant:"contained",size:"small",color:"primary",loading:S,startIcon:e.jsx(Kt,{}),onClick:()=>O(),sx:{".MuiButton-startIcon":{mr:"2px"}},style:{marginLeft:8},children:r("common.refresh")},"refresh")];return e.jsx(y,{sx:{overflow:"auto",".MuiTableCell-head":{whiteSpace:"nowrap",fontWeight:"bold"},".MuiTableCell-root":{paddingRight:"8px",whiteSpace:"nowrap"}},children:e.jsx(Hn,{children:e.jsxs(xt,{theme:b,children:[e.jsx(yt,{className:"receivers-table",locale:o,loading:S,columns:ie,data:E,onChange:oe,options:ue,customButtons:Re,components:{TableFilterList:c=>e.jsx(et,{...c,itemComponent:d=>e.jsx(tt,{...d,canDelete:()=>!1})})}}),z.anchorEl&&e.jsx(Ue,{open:!!z.anchorEl,anchorReference:"anchorPosition",anchorPosition:z.position,onClose:fe,anchorOrigin:{vertical:"center",horizontal:"right"},transformOrigin:{vertical:"center",horizontal:"left"},children:e.jsxs($n,{children:[e.jsxs(ee,{variant:"body1",component:"div",className:"check-title",children:[B?.channel," Checking"]}),e.jsx(y,{sx:{display:"flex",flexDirection:"column",gap:"4px"},children:we(B?.channel).map(c=>{const{type:d,pass:m,fail:A}=c;return!B?.result||B?.result?.[d]?e.jsxs(ee,{variant:"body1",component:"div",className:"check-item",sx:{display:"flex",alignItems:"center",gap:"4px",color:B?.result?.[d]?Ae.success.main:"inherit"},children:[B?.result?e.jsx(Mt,{}):e.jsx(ft,{size:12,sx:{color:Ae.primary.main}}),e.jsx("span",{children:m})]},d):e.jsxs(ee,{variant:"body1",component:"div",className:"check-item",sx:{display:"flex",alignItems:"center",gap:"4px",color:Ae.error.main},children:[e.jsx(Ut,{}),e.jsx("span",{children:A})]},d)})})]})}),F.anchorEl&&e.jsx(Ue,{open:!!F.anchorEl,anchorReference:"anchorPosition",anchorPosition:F.position,onClose:he,anchorOrigin:{vertical:"center",horizontal:"right"},transformOrigin:{vertical:"center",horizontal:"left"},children:e.jsx(Pt,{loading:t,onCancel:he,onConfirm:x})})]})})})}const Un=v.memo(Ft),Hn=ae.div`
2
2
  td.MuiTableCell-footer {
3
3
  border: none !important;
4
4
  }