@abtnode/blocklet-services 1.17.8 → 1.17.9

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 (128) hide show
  1. package/dist/assets/{Google-CG1lv5ol.js → Google-BpkBLSiL.js} +1 -1
  2. package/dist/assets/{access-control-CWoVUHgh.js → access-control-BIhY5wfd.js} +1 -1
  3. package/dist/assets/{actions-rfPaFLCj.js → actions-Cqfaor6G.js} +1 -1
  4. package/dist/assets/{add-component-core-D0UktG5E.js → add-component-core-B8HzULLJ.js} +1 -1
  5. package/dist/assets/{add-resource-B7lRLkA_.js → add-resource-CEddRkJz.js} +1 -1
  6. package/dist/assets/{advanced-ymKehsrI.js → advanced-DkQUAOtW.js} +1 -1
  7. package/dist/assets/{aigne-yDpeUg7z.js → aigne-BXMpb7iF.js} +1 -1
  8. package/dist/assets/{appearance-CG-6r2py.js → appearance-xmocGS9K.js} +1 -1
  9. package/dist/assets/{audit-logs-C-OsN7ub.js → audit-logs-BJPoC3sp.js} +1 -1
  10. package/dist/assets/{authorize-DjikDURs.js → authorize-CeTEulz5.js} +1 -1
  11. package/dist/assets/{base32-BFSrw7-h.js → base32-Cx5Qjcq5.js} +1 -1
  12. package/dist/assets/{bind-account-BVdU9BOU.js → bind-account-Dpc4iwR3.js} +1 -1
  13. package/dist/assets/{branding-D6MicIet.js → branding-Bz1ajNEX.js} +1 -1
  14. package/dist/assets/{branding-C42_zeHW.js → branding-OeU_TRNz.js} +1 -1
  15. package/dist/assets/{branding-CqLoLW7D.js → branding-vz6onXUa.js} +1 -1
  16. package/dist/assets/{bundle-avatar-7Wt_FbiF.js → bundle-avatar-CQ5BcuIS.js} +1 -1
  17. package/dist/assets/{complete-ziHMeIgC.js → complete-RloCU6Dp.js} +1 -1
  18. package/dist/assets/{component-Djqgi00F.js → component-Cjmzo-fv.js} +2 -2
  19. package/dist/assets/{config-Bko_B6fT.js → config-Bb4cFHRC.js} +1 -1
  20. package/dist/assets/{config-BQiW0tZA.js → config-CJmL1lNg.js} +1 -1
  21. package/dist/assets/{config-navigation-BwAXHqA4.js → config-navigation-CV6BVvIo.js} +2 -2
  22. package/dist/assets/{config-DtX2hGRq.js → config-rELfdDu6.js} +1 -1
  23. package/dist/assets/{config-space-DMk4apM9.js → config-space-CjtdFXkd.js} +1 -1
  24. package/dist/assets/{confirm-BMWka5pp.js → confirm-DhDNorbd.js} +1 -1
  25. package/dist/assets/{connect-D7P92kCs.js → connect-DrvWw6WK.js} +1 -1
  26. package/dist/assets/{connect-BP5XU00d.js → connect-J76vh4nC.js} +1 -1
  27. package/dist/assets/{connect-CzwZd1QL.js → connect-pvi_9C1U.js} +1 -1
  28. package/dist/assets/{connect-to-D5tNZXTo.js → connect-to-BRIhV6_s.js} +1 -1
  29. package/dist/assets/{dashboard-BZs_YRr4.js → dashboard-OrVG8J2E.js} +2 -2
  30. package/dist/assets/{delete-confirm-CwOFci6r.js → delete-confirm-C0N4quT9.js} +1 -1
  31. package/dist/assets/{domain-CvkFdrHE.js → domain-DRBQmuep.js} +1 -1
  32. package/dist/assets/{domain-action-card-D9LF4Rpy.js → domain-action-card-BXg1GQv4.js} +1 -1
  33. package/dist/assets/{domains-BeQB_OAv.js → domains-ClxiW6KS.js} +1 -1
  34. package/dist/assets/{email-DmH_Ukt2.js → email-QHwvdq0F.js} +1 -1
  35. package/dist/assets/engine-BmJsBu5Z.js +1 -0
  36. package/dist/assets/{exchange-passport-CidDSOuv.js → exchange-passport-_nLFQuN2.js} +1 -1
  37. package/dist/assets/{federated-detail-dialog-CkIKuPwA.js → federated-detail-dialog-B3FXukx8.js} +1 -1
  38. package/dist/assets/{form-DwiizKm1.js → form-BEZi0to4.js} +1 -1
  39. package/dist/assets/{fuel-D1KEpJ7m.js → fuel-D3ouL-7h.js} +1 -1
  40. package/dist/assets/{gen-access-key-rsAO4mAP.js → gen-access-key-DDpUJQ6-.js} +1 -1
  41. package/dist/assets/{gen-simple-access-key-DGcsvu3t.js → gen-simple-access-key-BTB-PYVK.js} +1 -1
  42. package/dist/assets/{get-safe-url-C1Ml6qBb.js → get-safe-url-uxJSMQTF.js} +1 -1
  43. package/dist/assets/{home-DKIZCHrI.js → home-BuvlMo1H.js} +1 -1
  44. package/dist/assets/{iframe-eNnbtEC_.js → iframe-CVEnFycA.js} +1 -1
  45. package/dist/assets/{index-DliNbpRr.js → index--yN2lwQm.js} +1 -1
  46. package/dist/assets/{index-BDz_o8O7.js → index-8APBdkv_.js} +1 -1
  47. package/dist/assets/{index-BVgxwS3B.js → index-BLYrVxV3.js} +1 -1
  48. package/dist/assets/{index-3rd8tEjJ.js → index-BLi7-52u.js} +1 -1
  49. package/dist/assets/{index-CPwDD0Vr.js → index-BaK_cJO7.js} +1 -1
  50. package/dist/assets/{index-B4YwAnux.js → index-Bz8EYhmA.js} +1 -1
  51. package/dist/assets/{index-DtobDjZ_.js → index-C0ZPC8OS.js} +1 -1
  52. package/dist/assets/{index-BjD8juw_.js → index-C2_MQP4T.js} +1 -1
  53. package/dist/assets/{index-BKqykGJ0.js → index-C2jYGrXX.js} +1 -1
  54. package/dist/assets/{index-ChjBQq8c.js → index-C9rUhDwd.js} +1 -1
  55. package/dist/assets/{index-fulV4VYn.js → index-CBR-Vn-z.js} +1 -1
  56. package/dist/assets/{index-BqN4XYa3.js → index-CEH7q22l.js} +1 -1
  57. package/dist/assets/{index-QkGGubJA.js → index-CNX69Q5e.js} +1 -1
  58. package/dist/assets/{index-qy92cIq_.js → index-CUa0qHck.js} +1 -1
  59. package/dist/assets/{index-DPBkkhMC.js → index-CZWagtq4.js} +1 -1
  60. package/dist/assets/{index-C_8V6Zdm.js → index-C_LVs1QE.js} +1 -1
  61. package/dist/assets/{index-CRVOCdMR.js → index-CbgqxO1V.js} +1 -1
  62. package/dist/assets/{index-BgdIPmn8.js → index-CeSwZI3Q.js} +1 -1
  63. package/dist/assets/{index-DOtXGGiB.js → index-CeaSaqPE.js} +1 -1
  64. package/dist/assets/{index-DcM4ljaV.js → index-CgSpL7jz.js} +4 -4
  65. package/dist/assets/{index-dA_JPQDw.js → index-CiGaRVW9.js} +1 -1
  66. package/dist/assets/{index-6ovPLp0y.js → index-D0mTUcjJ.js} +2 -2
  67. package/dist/assets/{index-BtpVtm9d.js → index-DI80KOep.js} +1 -1
  68. package/dist/assets/{index-EZZK7Nyo.js → index-DwaBdfGv.js} +3 -3
  69. package/dist/assets/{index-CEsBpdP3.js → index-DzOChX1R.js} +1 -1
  70. package/dist/assets/{index-rwBbhEdR.js → index-WAnZs-pf.js} +1 -1
  71. package/dist/assets/{index-DjpY9R14.js → index-_llkmI7F.js} +1 -1
  72. package/dist/assets/{index-t0K-45aJ.js → index-k0OLPTEM.js} +1 -1
  73. package/dist/assets/{info-outline-rounded-CxbBCZbx.js → info-outline-rounded-CmLwPXzn.js} +1 -1
  74. package/dist/assets/{invitation-tRY9vnXE.js → invitation-CcqRXA0x.js} +1 -1
  75. package/dist/assets/{invitations-Db5hitbJ.js → invitations-Rtn4ZgkA.js} +1 -1
  76. package/dist/assets/{invite-FhylBBBB.js → invite-BVCWrw1u.js} +1 -1
  77. package/dist/assets/{issue-passport-BMFNH3nj.js → issue-passport-D9KC0G_A.js} +1 -1
  78. package/dist/assets/{item-CHfrpFLz.js → item-Cno3GsuG.js} +1 -1
  79. package/dist/assets/{layout-ej-JNJCP.js → layout-DkUZePxy.js} +1 -1
  80. package/dist/assets/{list-CIMWgr08.js → list-BaZEqvv_.js} +1 -1
  81. package/dist/assets/{list-DX9meaEq.js → list-qpUoyhan.js} +1 -1
  82. package/dist/assets/{localization-DJF_aQrB.js → localization-VWhLouBc.js} +1 -1
  83. package/dist/assets/{log-C-XJlJmX.js → log-CGsJ5N6b.js} +1 -1
  84. package/dist/assets/{login-WWa0obto.js → login-BUZAiJi7.js} +1 -1
  85. package/dist/assets/{login-oauth-callback-558tm7Kk.js → login-oauth-callback-D7IVWJCK.js} +1 -1
  86. package/dist/assets/{logo-uploader-C_AnxhNP.js → logo-uploader-CEZXDf8O.js} +1 -1
  87. package/dist/assets/{lost-passport-DauVMfLO.js → lost-passport-BShdkOY2.js} +1 -1
  88. package/dist/assets/{metadata-CbEG9b2n.js → metadata-iEUnwzkK.js} +1 -1
  89. package/dist/assets/{open-window-hkynwoL5.js → open-window-CKutfNqx.js} +1 -1
  90. package/dist/assets/{over-due-invoice-payment-CPLJV5KG.js → over-due-invoice-payment-D6491JHf.js} +1 -1
  91. package/dist/assets/{overview-JVbZ7hCB.js → overview-ns7CHx6H.js} +1 -1
  92. package/dist/assets/{passport-bxIQRuHM.js → passport-2AVRJTQK.js} +1 -1
  93. package/dist/assets/{passport-item-C7svpOMT.js → passport-item-CeYGFFGn.js} +1 -1
  94. package/dist/assets/{permission-CiRkLVwn.js → permission-C2bdzuoM.js} +1 -1
  95. package/dist/assets/{preferences-DgvuFkNS.js → preferences-Bm3lpvWM.js} +1 -1
  96. package/dist/assets/{profile-embed-DyHkusY5.js → profile-embed-CBiaNgfm.js} +1 -1
  97. package/dist/assets/{publish-resource-DqQSmKCy.js → publish-resource-Cb8cFftb.js} +1 -1
  98. package/dist/assets/{runtime-OuwOSzER.js → runtime-W3sVCToB.js} +1 -1
  99. package/dist/assets/sdk-CuoW9qgj.js +1 -0
  100. package/dist/assets/{security-DwWYfqfY.js → security-FuAWjgqg.js} +1 -1
  101. package/dist/assets/{session-D6Z4R7oi.js → session-BEf_KK-i.js} +1 -1
  102. package/dist/assets/{setup-N7vDP87_.js → setup-BUrG-d2H.js} +1 -1
  103. package/dist/assets/{spaces-B8t2gKsu.js → spaces-DiyZ082O.js} +1 -1
  104. package/dist/assets/{start-D0WlW7li.js → start-Rwj2OQ5m.js} +1 -1
  105. package/dist/assets/{starting-progress--6NzzPU1.js → starting-progress-s-XqSluO.js} +1 -1
  106. package/dist/assets/{status-DI89bjlc.js → status-CTDbw135.js} +1 -1
  107. package/dist/assets/{step-actions-D0ooBDiZ.js → step-actions-Ezqn_AMv.js} +1 -1
  108. package/dist/assets/{studio-fGrv4L1C.js → studio-CYIn9aNz.js} +1 -1
  109. package/dist/assets/{team-sypU8pIA.js → team-Bso_Sjaa.js} +1 -1
  110. package/dist/assets/{traffic-CB937Mlw.js → traffic-BqxYiIWh.js} +1 -1
  111. package/dist/assets/{transfer-C29v213E.js → transfer-OPn3RlKK.js} +1 -1
  112. package/dist/assets/{unsubscribe-D4mqt-ru.js → unsubscribe-CdltWhMv.js} +1 -1
  113. package/dist/assets/{use-app-logo-Dt5Rf_oh.js → use-app-logo-DcBQK--f.js} +1 -1
  114. package/dist/assets/{user-center-BNVLcFuw.js → user-center-Bc5-qHT9.js} +2 -2
  115. package/dist/assets/{user-follower-BF8dghPj.js → user-follower-D8zGIprF.js} +1 -1
  116. package/dist/assets/{util-BKm61knf.js → util-CIgNPQhV.js} +1 -1
  117. package/dist/assets/{util-C7ejGMZd.js → util-Cz5-V-1E.js} +1 -1
  118. package/dist/assets/{utils-yU0z64Pf.js → utils-CWRBZd9l.js} +1 -1
  119. package/dist/assets/{wait-connect-B1z3SEpN.js → wait-connect-2CirehkG.js} +1 -1
  120. package/dist/assets/{wallet-hidden-topbar-SQtOXLKg.js → wallet-hidden-topbar-CZaZNW94.js} +1 -1
  121. package/dist/assets/{wizard-components-Dxf0c0dt.js → wizard-components-BwA5watz.js} +1 -1
  122. package/dist/assets/{wizard-DwUESHQa.js → wizard-xTNgKfB7.js} +1 -1
  123. package/dist/assets/{wrap-locale-Ck3xud_e.js → wrap-locale-AxlzuLIu.js} +1 -1
  124. package/dist/assets/{zh-oZCQbfAf.js → zh-BYHnQ2ca.js} +1 -1
  125. package/dist/index.html +1 -1
  126. package/package.json +23 -23
  127. package/dist/assets/engine-CvxZhwAf.js +0 -1
  128. package/dist/assets/sdk-BDbUPswI.js +0 -1
@@ -1,4 +1,4 @@
1
- import{r as x}from"./vendor-react-DX7tU9aY.js";import{j as e,X as d,an as xt,al as R,T as X,V as Oe,z as Be,b5 as Ye,bP as ke,bK as De,a6 as Le,R as Re,dI as Fe,aL as Ne,a7 as Je,G as Qe,cD as bt,ae as Ze,e7 as yt,e8 as jt,aT as ae,a_ as $e,n as vt,L as St,y as wt,bN as Rt,M as _e,cB as Ct}from"./vendor-mui-core-CDEc-eG6.js";import{e as ee,l as Tt,J as pe}from"./vendor-utils-_C9URqjS.js";import{a3 as $,bp as kt,aa as J,dF as Dt,w as et,a7 as tt,bk as Ee,b3 as st,c6 as ye,b1 as Lt,br as Nt,bA as Et,bS as It}from"./vendor-ux-PO0jFgJf.js";import{X as At,M as U,ah as He,c_ as q,A as Pt,c$ as Ve,d0 as ge,a3 as Ge}from"./index-DcM4ljaV.js";import{a as Y,i as Ie}from"./vendor-hooks-Ca2cSNuD.js";import{S as me}from"./shorten-label-CEQFm35C.js";import{v as nt}from"./index-BEbBg3NW.js";import{R as at,A as Ot,S as Bt,a as Ft,B as zt}from"./list-CIMWgr08.js";import{i as Wt,e as Mt,N as Kt}from"./team-sypU8pIA.js";import{W as qt}from"./did-address-BNKX5oDP.js";import{p as it}from"./util-BKm61knf.js";import{D as Ut,g as $t}from"./traffic-CB937Mlw.js";import{B as ot}from"./bundle-avatar-7Wt_FbiF.js";import"./vendor-arcblock-BVQTtbN-.js";import"./server-logo-notext.svg-CtPRYaCm.js";import"./session-D6Z4R7oi.js";import"./purify.es-HRjpPm7y.js";import"./wallet-hidden-topbar-SQtOXLKg.js";import"./theme-mode-toggle-WRMGhjzA.js";import"./use-mobile-DKWj9MJD.js";import"./index-BVgxwS3B.js";import"./isURL-CpQHQuaa.js";import"./isIP-BBY240SU.js";import"./use-blocklet-logo-nVOJALp0.js";import"./use-app-logo-Dt5Rf_oh.js";import"./base32-BFSrw7-h.js";import"./useAsyncRetry-DOQg_SXs.js";import"./useAsync-10WR8h3k.js";import"./iframe-eNnbtEC_.js";import"./index-DMv6sUCJ.js";import"./index-DBs9Ljax.js";import"./base-chart-CeRp7fHy.js";import"./index-DlYWPFit.js";import"./vendor-mui-x-Bk3pxGrO.js";import"./AdapterDayjs-DtK6vYWP.js";const rt=x.createContext({}),{Provider:_t,Consumer:Qs}=rt;function Ht({children:t,blocklet:s=""}){const{api:n,inService:r,ws:{useSubscription:i}}=At(),[l,b]=x.useState([]),[m,v]=x.useState({total:0,pageSize:20,pageCount:0,page:1}),h=Y(()=>s.meta?.did,[s]),[y,S]=x.useState([]),[O,P]=x.useState({}),C=Y(()=>l.length?new Set(l.map(p=>p.id)):new Set,[l]),_=async({page:p=1,pageSize:g=20,...k}={})=>{if(!h)return[];try{const N={paging:{page:p,pageSize:g},...k,teamDid:h,dateRange:k.dateRange?[U(k.dateRange[0]).toISOString(),U(k.dateRange[1]).toISOString()]:void 0},{dids:E,...z}=N;let B="";E&&E.includes("system")&&(B="system");const ie=E?E.filter(oe=>oe!=="system"):[],se={...z,source:B,componentDids:ie},Z=await n.getNotificationSendLog({input:se});return P(se),b(Z.list),v(Z.paging),Z.list}catch(N){return $.error(N.message),[]}},M=async()=>{const p=await n.getNotificationComponents({input:{teamDid:h}});S(p.componentDids)},I=x.useCallback(p=>{const g=s.children.find(k=>k.meta?.did===p);if(g)return g.ancestors=[s],g},[s]),A=async({notificationId:p,receivers:g,channels:k,...N})=>{await n.resendNotification({input:{teamDid:h,notificationId:p,receivers:g,channels:k.map(E=>E==="wallet"?q.WALLET:E==="pushKit"?q.PUSH:E),...N}})},H=x.useCallback(async p=>(await n.getUser({input:{teamDid:h,user:{did:p},options:{enableConnectedAccount:!0}}})).user,[n,h]),V=x.useCallback(async({page:p=1,pageSize:g=20,...k}={})=>{try{const N={paging:{page:p,pageSize:g},...k,userName:k.searchText||"",teamDid:h,dateRange:k.dateRange?[U(k.dateRange[0]).toISOString(),U(k.dateRange[1]).toISOString()]:void 0};return await n.getReceivers({input:N})}catch(N){throw $.error(N.message),N}},[n,h]);x.useEffect(()=>{h&&M()},[h]),i(He.NOTIFICATION_BLOCKLET_UPDATE,p=>{C.has(p.notificationId)&&_(O)},[C,O]),i(He.NOTIFICATION_BLOCKLET_CREATE,p=>{C.has(p.id)||_(O)},[C,O]);const Q={fetch:_,data:l,paging:m,blocklet:s,getComponent:I,resendNotification:A,getUser:H,componentDids:y,getReceivers:V,inService:r,teamDid:h};return e.jsx(_t,{value:{notificationRecords:Q},children:t})}function ze(){const{notificationRecords:t}=x.useContext(rt);return t}he.propTypes={severity:d.oneOf(Object.values(["info","success","error","warning"])).isRequired};const Vt={info:"primary",success:"success",error:"error",warning:"warning"};function he({severity:t="info"}){return e.jsx(kt,{type:Vt[t],children:t})}const Gt=(t,s,n="")=>{if(!n||!s)return"";switch(n){case ge.USER_DISABLED:return t("notification.sendStatus.reason.disabled",{channel:s});case ge.CHANNEL_UNAVAILABLE:return t("notification.sendStatus.reason.unavailable",{channel:s});case ge.CHANNEL_DISABLED:return t("notification.sendStatus.reason.notSent",{channel:s});case ge.NOT_ONLINE:return t("notification.sendStatus.reason.offline");default:return n}};function lt(t,s,n={}){const{status:r,updatedAt:i,reason:l="",channel:b="wallet"}=n,m=i?t("notification.sendStatus.sentTime",{date:Pt(i,s)}):"",v=Gt(t,b,l);return r===Ve.FAILED?{status:"failed",title:t("notification.sendStatus.failed"),sentTime:m,reason:v}:r===Ve.SENT?{status:"success",title:t("notification.sendStatus.success"),sentTime:m}:{status:"pending",title:t("notification.sendStatus.pending"),reason:v,sentTime:m}}const Ae={pending:"#aaaaaa",success:"#34BE74",failed:"#D0021B"},Pe=["wallet","pushKit","email"],Xe=["info","success","error","warning"],ct=t=>{const{settings:s}=t;return s?.notification?.email?.enabled},dt=t=>{const{settings:s}=t;return s?.notification?.pushKit?.enabled},Xt=(t,s)=>{const n=ee(s,"extra.notifications.email",!0);return{available:ct(t),enabled:n}},Yt=(t,s)=>{const n=ee(s,"extra.notifications.push",!0);return{available:dt(t),enabled:n}},Jt=t=>({enabled:ee(t,"extra.notifications.wallet",!0)}),Qt=t=>({enabled:ee(t,"extra.webhooks",[]).length>0}),xe=(t=3)=>new Promise(s=>{setTimeout(()=>{s()},t*1e3)}),Zt=(t,s)=>s==="wallet"||s==="webhook"?[{channel:s,type:"enabled",pass:t("notification.sendStatus.reason.enabled",{channel:s}),fail:t("notification.sendStatus.reason.disabled",{channel:s})}]:s==="pushKit"||s==="email"?[{channel:s,type:"available",pass:t("notification.sendStatus.reason.available",{channel:s}),fail:t("notification.sendStatus.reason.unavailable",{channel:s})},{channel:s,type:"enabled",pass:t("notification.sendStatus.reason.enabled",{channel:s}),fail:t("notification.sendStatus.reason.disabled",{channel:s})}]:[],be=(t=[])=>{const s=U().startOf("day");return t.filter(n=>U(n.sendAt).isSame(s,"day")).length},es=(t,s="")=>{if(s&&Pe.includes(s)){const l=`${s}SendRecord`,b=ee(t,l,[]);return be(b)}const n=ee(t,"webhook",{}),r=Object.keys(n??{})??[];if(s&&r.includes(s)){const l=n[s]??[];return be(l)}const i={};return Pe.forEach(l=>{const b=`${l}SendRecord`,m=ee(t,b,[]),v=be(m);i[l]=v}),r.length>0&&r.forEach(l=>{const b=n[l]??[],m=be(b);i[l]=m}),i},je=(t,s,n)=>{if(!Array.isArray(t))throw new Error("Invalid filterList or index");return t[n].splice(s,1),t},ve=(t,s)=>{if(!Array.isArray(s))throw new Error("filters must be an array");return s.length?!s.includes(t):!1},ts=t=>{switch(t){case q.WALLET:return"Wallet";case q.PUSH:return"Push Kit";case q.EMAIL:return"Email";case q.WEBHOOK:return"Webhook";default:return""}},ut=()=>({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 te({config:t,enableTooltip:s=!0,showTitle:n=!1,children:r=null}){const{status:i,title:l="",sentTime:b="",reason:m=""}=t,v=[l,m].filter(Boolean).join(", ");return e.jsx(xt,{title:s?e.jsxs(e.Fragment,{children:[e.jsx(X,{color:"inherit",sx:{fontSize:12},children:v}),e.jsx("span",{children:b})]}):null,arrow:!0,placement:"top",children:e.jsxs(R,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"4px"},children:[e.jsxs(R,{sx:{position:"relative",minHeight:14,minWidth:14,display:"flex",alignItems:"center",justifyContent:"center"},children:[e.jsx(R,{style:{opacity:.15},sx:{position:"absolute",width:"100%",height:"100%",borderRadius:"50%",bgcolor:Ae[i]}}),e.jsx(R,{sx:{position:"absolute",width:"55%",height:"55%",borderRadius:"50%",bgcolor:Ae[i]}})]}),e.jsx(X,{color:"inherit",sx:{fontSize:12},children:n?l:r})]})})}te.propTypes={config:d.object.isRequired,enableTooltip:d.bool,showTitle:d.bool,children:d.node};Se.propTypes={list:d.array.isRequired,label:d.string.isRequired,onDelete:d.func};function Se({list:t,label:s,onDelete:n=()=>{}}){const{t:r,locale:i}=J();return e.jsxs(R,{sx:{display:"flex",gap:1,alignItems:"center"},children:[e.jsxs(X,{children:[s,": "]}),t.map(l=>{const b=lt(r,i,{status:l});return e.jsx(Oe,{size:"small",label:e.jsx(R,{sx:{display:"flex",alignItems:"center",gap:"4px"},children:e.jsx(te,{config:b,enableTooltip:!1,children:b.title})}),onDelete:m=>n(m,l)},l)})]})}We.propTypes={filterList:d.array.isRequired,onChange:d.func.isRequired,index:d.number.isRequired,column:d.object.isRequired,filterValues:d.array.isRequired,label:d.string.isRequired,renderLabel:d.func.isRequired};function We({filterList:t,onChange:s,index:n,column:r,filterValues:i,label:l,renderLabel:b}){return e.jsxs(Be,{className:"filter-container",children:[e.jsx(Ye,{component:"legend",children:l}),e.jsx(ke,{row:!0,children:i.map(m=>e.jsx(De,{control:e.jsx(Le,{checked:t[n].indexOf(m.value??m)>-1,onChange:v=>{const h=[...t];v.target.checked?h[n]=[...h[n],m.value??m]:h[n]=h[n].filter(y=>y!==(m.value??m)),s(h[n],n,r)},name:m.value??m}),label:e.jsx("span",{style:{display:"flex",alignItems:"center"},children:b(m)})},m.value??m))})]})}function Te(t){return e.jsx(We,{...t,renderLabel:s=>e.jsx(te,{enableTooltip:!1,config:{status:s.status},children:s.label})})}ce.propTypes={status:d.number.isRequired,updatedAt:d.string.isRequired,reason:d.string,channel:d.string,onResend:d.func};function ce({status:t,updatedAt:s,reason:n="",channel:r="wallet",onResend:i}){const{t:l,locale:b}=J(),m=lt(l,b,{status:t,updatedAt:s,reason:n,channel:r});return e.jsxs(R,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(te,{config:m,showTitle:!0}),m.status!=="success"&&e.jsx(Re,{className:"resend-btn",size:"small",startIcon:e.jsx(Fe,{}),sx:{fontSize:12,color:"rgba(0, 0, 0, 0.87)",fontWeight:400,".MuiButton-startIcon":{mr:"2px"}},onClick:i,children:l("notification.resend")})]})}Me.propTypes={value:d.array.isRequired,onChange:d.func};function Me({value:t,onChange:s}){const{locale:n}=J(),r=U().toDate(),[i,l]=x.useState(null),b=x.useCallback(h=>{l(i?null:h.currentTarget)},[i]),m=!!i,v=x.useCallback(h=>{if(!h.startDate||!h.endDate){$.error("Please select a date range");return}if(U(h.startDate).isAfter(h.endDate)||!U(h.startDate).isValid()||!U(h.endDate).isValid()){$.error("Invalid date range");return}s([h.startDate,h.endDate]),l(null)},[s]);return e.jsxs("div",{children:[e.jsx(X,{component:"div",variant:"h5",color:"textPrimary",style:{fontSize:18,fontWeight:"bold"},sx:{mb:0},children:e.jsxs(Re,{onClick:b,variant:"outlined",size:"small",color:"inherit",children:[Ge(t[0],n)," - ",Ge(t[1],n)]})}),e.jsx(Ne,{open:m,anchorEl:i,onClose:()=>{l(null)},anchorOrigin:{vertical:"bottom",horizontal:"left"},children:e.jsx(Ut,{open:!0,maxDate:r,initialDateRange:{startDate:t[0],endDate:t[1]},toggle:b,definedRanges:$t(r),onChange:v})})]})}Ke.propTypes={itemComponent:d.elementType.isRequired};function Ke({itemComponent:t,...s}){const{t:n}=J();return!s?.filterList?.filter(i=>i.length).length?null:e.jsxs(R,{sx:{display:"flex",gap:1,alignItems:"center"},children:[e.jsx("div",{className:"toolbar-filter-title",children:n("notification.filter")}),e.jsx("div",{className:"toolbar-filter-content",children:e.jsx(Dt.TableFilterList,{...s,ItemComponent:t})})]})}function qe({label:t,onDelete:s,canDelete:n=()=>!0,...r}){const i=s&&typeof s=="function"?s:void 0;let l=!0;return n&&typeof n=="function"&&(l=n({label:t,...r})),e.jsx(Oe,{label:t,variant:"outlined",...i&&l?{onDelete:i}:{}})}qe.propTypes={label:d.string.isRequired,onDelete:d.func,canDelete:d.func};const ss=[{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:d.bool,onCancel:d.func,onConfirm:d.func};function pt({loading:t=!1,onCancel:s=()=>{},onConfirm:n=()=>{}}){const{t:r}=J(),[i,l]=x.useState(ss),[b,m]=x.useState(!0),v=(y,S)=>{S.checked=y.target.checked;const O=i.map(P=>({...P,checked:P.value===S.value?S.checked:P.checked}));l(O)},h=y=>{y.stopPropagation(),n({channels:i.filter(S=>S.checked).map(S=>S.value),isResendFailedOnly:b})};return e.jsxs(R,{className:"resend-config",sx:{padding:"16px 24px"},children:[e.jsx(X,{variant:"body1",component:"div",className:"check-title",sx:{fontWeight:700,mb:1},children:r("notification.config")}),e.jsx(R,{className:"choose-channel",children:e.jsxs(Be,{component:"fieldset",variant:"standard",children:[e.jsx(Ye,{component:"legend",children:r("notification.selectChannels")}),e.jsx(ke,{sx:{display:"flex",flexDirection:"row",flexWrap:"wrap",gap:1},children:i.map(y=>e.jsx(De,{control:e.jsx(Le,{checked:y.checked,onChange:S=>v(S,y),name:y.value}),label:y.label},y.value))})]})}),e.jsx(R,{className:"resend-config-footer",children:e.jsx(ke,{children:e.jsx(De,{control:e.jsx(Le,{checked:b,onChange:y=>m(y.target.checked)}),label:r("notification.resendFailedOnly")})})}),e.jsxs(R,{className:"resend-config-footer-tip",sx:{display:"flex",justifyContent:"flex-end",gap:1},children:[e.jsx(Re,{onClick:y=>{y.stopPropagation(),s()},color:"inherit",children:r("common.cancel")}),e.jsxs(Re,{onClick:h,color:"primary",disabled:t,variant:"contained",autoFocus:!0,style:{marginLeft:8},children:[t&&e.jsx(Je,{size:16}),r("common.confirm")]})]})]})}ft.propTypes={notificationId:d.string.isRequired,handleResend:d.func,resending:d.bool};function ft({notificationId:t,handleResend:s,resending:n=!1}){const{t:r,locale:i}=J(),l=Qe(),b=x.useMemo(()=>et(l,ut()),[l]),{getReceivers:m,inService:v,teamDid:h,getUser:y,blocklet:S}=ze(),[O,P]=x.useState(!1),[C,_]=x.useState([]),M=Ie({anchorEl:null,position:null}),I=Ie({anchorEl:null,position:null}),[A,H]=x.useState(null),[V,Q]=x.useState({total:0,pageSize:10,pageCount:0,page:1}),[p,g]=x.useState({searchText:"",page:1,pageSize:10,walletSendStatus:[],pushKitSendStatus:[],emailSendStatus:[],dateRange:[U().subtract(1,"month").startOf("day").toDate(),U().endOf("day").toDate()]}),[k,N]=x.useState([]),E=[{label:r("notification.sendStatus.pending"),value:0,status:"pending"},{label:r("notification.sendStatus.success"),value:1,status:"success"},{label:r("notification.sendStatus.failed"),value:2,status:"failed"}],z=async()=>{if(!O&&t)try{P(!0);const a=await m({notificationId:t,...p}),o=a.list.map(c=>({...c,receiverUser:{...c.receiverUser,avatar:it(c.receiverUser.avatar,h,v)}}));_(o),Q(a.paging),P(!1)}catch(a){$.error(a.message),P(!1)}};x.useEffect(()=>{z()},[p]);const B=a=>{a.stopPropagation();const o=a.currentTarget;I.anchorEl=o;const c=o.getBoundingClientRect();I.position={top:c.top+window.scrollY,left:c.left+window.scrollX}},ie=a=>a.data.length?e.jsx("div",{style:{display:"flex",alignItems:"center",padding:"10px"},children:e.jsx(Ee,{className:"resend-btn",size:"small",color:"primary",variant:"contained",startIcon:e.jsx(Fe,{}),sx:{".MuiButton-startIcon":{mr:"2px"}},onClick:B,children:r("notification.resend")})}):null,se={sort:!1,download:!1,print:!1,selectableRows:"multiple",searchPlaceholder:r("common.search"),searchAlwaysOpen:!1,filterType:"checkbox",searchDebounceTime:300,page:V.page-1,rowsPerPage:V.pageSize,count:V.total,searchText:p.searchText,tableBodyMaxHeight:"calc(80vh - 260px)",rowsSelected:k,onRowSelectionChange:(a,o)=>{N(o.map(c=>c.dataIndex))},customToolbarSelect:ie},Z=({page:a,rowsPerPage:o,searchText:c,filterList:w})=>{const[,F=[],G=[],K=[]]=w;p.pageSize!==o?g(W=>({...W,pageSize:o,page:1})):p.page!==a+1?g(W=>({...W,page:a+1})):p.searchText!==c?g(W=>({...W,searchText:c,page:1})):pe(F,p.walletSendStatus)?pe(G,p.pushKitSendStatus)?pe(K,p.emailSendStatus)||g(W=>({...W,emailSendStatus:K,page:1})):g(W=>({...W,pushKitSendStatus:G,page:1})):g(W=>({...W,walletSendStatus:F,page:1}))},oe=x.useCallback(async(a,o)=>{if(!o)return!1;const c=await y(o);return c?a==="wallet"?Jt(c):a==="email"?Xt(S,c):a==="pushKit"?Yt(S,c):a==="webhook"?Qt(c):!0:!1},[y,S]),Ce=x.useCallback(a=>Zt(r,a),[r]),f=()=>{M.anchorEl=null,M.position=null,H(null)},u=()=>{I.anchorEl=null,I.position=null},j=async(a,o,c=!0,w="")=>{if(!(!o.length||!a.length))try{s(a,o,c,w),I.anchorEl||(await xe(.5),f())}catch(F){console.error("handleResend error",{error:F})}},D=async({channels:a,isResendFailedOnly:o})=>{const c=k.map(w=>C[w].receiver);await j(a,c,o),await xe(.5),u(),N([])},L=async(a,o=[],c=!0)=>{try{await j(["webhook"],[a.receiver],c,o)}catch(w){$.error(w.response?w.response.statusText:w.message)}},T=async(a,o,c,w=[],F=!0)=>{if(a.stopPropagation(),es(o,c)>=4){$.warning(r("notification.resendLimit"));return}if(!Pe.includes(c)){await L(o,w,F);return}if(a){const K=a.currentTarget,W=K.getBoundingClientRect();M.anchorEl=K,M.position={top:W.top+window.scrollY,left:W.left+window.scrollX}}H({channel:c});try{const K=await oe(c,o.receiver);await xe(1),H({channel:c,result:K}),(typeof K=="boolean"&&K||Tt(K)&&Object.values(K).every(W=>!!W))&&(await s([c],[o.receiver],F),I.anchorEl||(await xe(.5),f()))}catch(K){$.error(K.message)}},re=a=>{g(o=>({...o,dateRange:a,page:1}))},ne=(a,o,c,w)=>{a.stopPropagation();const F=c.filter(G=>G!==o);g(G=>({...G,[w]:F,page:1}))},le=Y(()=>[{label:r("notification.receiver"),name:"receiver",width:200,options:{filter:!1,customBodyRenderLite:a=>{const{receiverUser:o,receiver:c}=C[a];return o?e.jsxs(R,{"data-cy":`member-name-${o.fullName}`,sx:{display:"flex",alignItems:"center",gap:1,justifyContent:"flex-start"},children:[e.jsx(tt,{src:`${o.avatar}?imageFilter=resize&w=48&h=48`,size:32,did:c,shape:"circle",style:{borderRadius:"100%",overflow:"hidden"}}),e.jsx(me,{children:o.fullName})]},c):e.jsx(qt,{size:14,responsive:!1,compact:!0,copyable:!1,did:c})}}},{label:"Wallet",name:"walletSendStatus",width:200,options:{setCellProps:()=>({className:"sent-status-cell"}),filter:!0,filterType:"custom",filterList:p.walletSendStatus??[],customFilterListOptions:{render:a=>e.jsx(Se,{list:a,label:"Wallet",onDelete:(o,c)=>{o.stopPropagation(),ne(o,c,le[1].options.filterList,"walletSendStatus")}}),update:je},filterOptions:{names:E,fullWidth:!0,logic:ve,display:(a,o,c,w)=>e.jsx(Te,{label:"Wallet",filterList:a,onChange:o,index:c,column:w,filterValues:E})},customBodyRenderLite:a=>{const{walletSendStatus:o,walletSendAt:c,walletSendFailedReason:w}=C[a];return e.jsx(ce,{status:o,updatedAt:c,reason:w,channel:"wallet",onResend:F=>T(F,C[a],"wallet",[],!1)})}}},{label:"Push Kit",name:"pushKitSendStatus",width:200,options:{setCellProps:()=>({className:"sent-status-cell"}),customBodyRenderLite:a=>{const{pushKitSendStatus:o,pushKitSendAt:c,pushKitSendFailedReason:w}=C[a];return e.jsx(ce,{status:o,updatedAt:c,reason:w,channel:"pushkit",onResend:F=>T(F,C[a],"pushKit",[],!1)})},filter:!0,filterType:"custom",filterList:p.pushKitSendStatus??[],customFilterListOptions:{render:a=>e.jsx(Se,{list:a,label:"Push Kit",onDelete:(o,c)=>{o.stopPropagation(),ne(o,c,le[2].options.filterList,"pushKitSendStatus")}}),update:je},filterOptions:{names:E,fullWidth:!0,logic:ve,display:(a,o,c,w)=>e.jsx(Te,{label:"Push Kit",filterList:a,onChange:o,index:c,column:w,filterValues:E})}}},{label:"Email",name:"emailSendStatus",width:200,options:{setCellProps:()=>({className:"sent-status-cell"}),customBodyRenderLite:a=>{const{emailSendStatus:o,emailSendAt:c,emailSendFailedReason:w}=C[a];return e.jsx(ce,{status:o,updatedAt:c,reason:w,channel:"email",onResend:F=>T(F,C[a],"email",[],!1)})},filter:!0,filterType:"custom",filterList:p.emailSendStatus??[],customFilterListOptions:{render:a=>e.jsx(Se,{list:a,label:"Email",onDelete:(o,c)=>{o.stopPropagation(),ne(o,c,le[3].options.filterList,"emailSendStatus")}}),update:je},filterOptions:{names:E,fullWidth:!0,logic:ve,display:(a,o,c,w)=>e.jsx(Te,{label:"Email",filterList:a,onChange:o,index:c,column:w,filterValues:E})}}},{label:"Webhook",name:"webhook",width:200,options:{filter:!1,setCellProps:()=>({className:"sent-status-cell"}),customBodyRenderLite:a=>{const{webhook:o}=C[a];if(!o)return null;const c=Object.entries(o)[0];if(!c)return null;const[w,F]=c,G=F[0];return e.jsx(R,{sx:{display:"flex",flexDirection:"column",gap:1},children:e.jsxs(R,{className:"webhook-item",sx:{fontSize:12},children:[e.jsx(me,{maxLength:30,children:w},w),e.jsx(ce,{status:G.status,updatedAt:G.sendAt,reason:G.failedReason,channel:"webhook",onResend:K=>T(K,C[a],"webhook",[w],!1)})]},w)})}}},{label:r("common.createdAt"),name:"createdAt",width:100,options:{filter:!1,customBodyRenderLite:a=>{const{createdAt:o}=C[a];return e.jsx(at,{value:o,locale:i,shouldUpdate:!0})}}}],[C,i,p,r]),gt=[e.jsx(Me,{value:p.dateRange,onChange:re},"date-picker"),e.jsx(Ee,{variant:"contained",size:"small",color:"primary",loading:O,startIcon:e.jsx(bt,{}),onClick:()=>z(),sx:{".MuiButton-startIcon":{mr:"2px"}},style:{marginLeft:8},children:r("common.refresh")},"refresh")];return e.jsx(R,{sx:{overflow:"auto",".MuiTableCell-head":{whiteSpace:"nowrap",fontWeight:"bold"},".MuiTableCell-root":{paddingRight:"8px",whiteSpace:"nowrap"}},children:e.jsx(as,{children:e.jsxs(Ze,{theme:b,children:[e.jsx(st,{className:"receivers-table",locale:i,loading:O,columns:le,data:C,onChange:Z,options:se,customButtons:gt,components:{TableFilterList:a=>e.jsx(Ke,{...a,itemComponent:o=>e.jsx(qe,{...o,canDelete:()=>!1})})}}),M.anchorEl&&e.jsx(Ne,{open:!!M.anchorEl,anchorReference:"anchorPosition",anchorPosition:M.position,onClose:f,anchorOrigin:{vertical:"center",horizontal:"right"},transformOrigin:{vertical:"center",horizontal:"left"},children:e.jsxs(is,{children:[e.jsxs(X,{variant:"body1",component:"div",className:"check-title",children:[A?.channel," Checking"]}),e.jsx(R,{sx:{display:"flex",flexDirection:"column",gap:"4px"},children:Ce(A?.channel).map(a=>{const{type:o,pass:c,fail:w}=a;return!A?.result||A?.result?.[o]?e.jsxs(X,{variant:"body1",component:"div",className:"check-item",sx:{display:"flex",alignItems:"center",gap:"4px",color:A?.result?.[o]?ye.success.main:"inherit"},children:[A?.result?e.jsx(yt,{}):e.jsx(Je,{size:12,sx:{color:ye.primary.main}}),e.jsx("span",{children:c})]},o):e.jsxs(X,{variant:"body1",component:"div",className:"check-item",sx:{display:"flex",alignItems:"center",gap:"4px",color:ye.error.main},children:[e.jsx(jt,{}),e.jsx("span",{children:w})]},o)})})]})}),I.anchorEl&&e.jsx(Ne,{open:!!I.anchorEl,anchorReference:"anchorPosition",anchorPosition:I.position,onClose:u,anchorOrigin:{vertical:"center",horizontal:"right"},transformOrigin:{vertical:"center",horizontal:"left"},children:e.jsx(pt,{loading:n,onCancel:u,onConfirm:D})})]})})})}const ns=x.memo(ft),as=ae.div`
1
+ import{r as x}from"./vendor-react-DX7tU9aY.js";import{j as e,X as d,an as xt,al as R,T as X,V as Oe,z as Be,b5 as Ye,bP as ke,bK as De,a6 as Le,R as Re,dI as Fe,aL as Ne,a7 as Je,G as Qe,cD as bt,ae as Ze,e7 as yt,e8 as jt,aT as ae,a_ as $e,n as vt,L as St,y as wt,bN as Rt,M as _e,cB as Ct}from"./vendor-mui-core-CDEc-eG6.js";import{e as ee,l as Tt,J as pe}from"./vendor-utils-_C9URqjS.js";import{a3 as $,bp as kt,aa as J,dF as Dt,w as et,a7 as tt,bk as Ee,b3 as st,c6 as ye,b1 as Lt,br as Nt,bA as Et,bS as It}from"./vendor-ux-PO0jFgJf.js";import{X as At,M as U,ah as He,c_ as q,A as Pt,c$ as Ve,d0 as ge,a3 as Ge}from"./index-CgSpL7jz.js";import{a as Y,i as Ie}from"./vendor-hooks-Ca2cSNuD.js";import{S as me}from"./shorten-label-CEQFm35C.js";import{v as nt}from"./index-BEbBg3NW.js";import{R as at,A as Ot,S as Bt,a as Ft,B as zt}from"./list-BaZEqvv_.js";import{i as Wt,e as Mt,N as Kt}from"./team-Bso_Sjaa.js";import{W as qt}from"./did-address-BNKX5oDP.js";import{p as it}from"./util-CIgNPQhV.js";import{D as Ut,g as $t}from"./traffic-BqxYiIWh.js";import{B as ot}from"./bundle-avatar-CQ5BcuIS.js";import"./vendor-arcblock-BVQTtbN-.js";import"./server-logo-notext.svg-CtPRYaCm.js";import"./session-BEf_KK-i.js";import"./purify.es-HRjpPm7y.js";import"./wallet-hidden-topbar-CZaZNW94.js";import"./theme-mode-toggle-WRMGhjzA.js";import"./use-mobile-DKWj9MJD.js";import"./index-BLYrVxV3.js";import"./isURL-CpQHQuaa.js";import"./isIP-BBY240SU.js";import"./use-blocklet-logo-nVOJALp0.js";import"./use-app-logo-DcBQK--f.js";import"./base32-Cx5Qjcq5.js";import"./useAsyncRetry-DOQg_SXs.js";import"./useAsync-10WR8h3k.js";import"./iframe-CVEnFycA.js";import"./index-DMv6sUCJ.js";import"./index-DBs9Ljax.js";import"./base-chart-CeRp7fHy.js";import"./index-DlYWPFit.js";import"./vendor-mui-x-Bk3pxGrO.js";import"./AdapterDayjs-DtK6vYWP.js";const rt=x.createContext({}),{Provider:_t,Consumer:Qs}=rt;function Ht({children:t,blocklet:s=""}){const{api:n,inService:r,ws:{useSubscription:i}}=At(),[l,b]=x.useState([]),[m,v]=x.useState({total:0,pageSize:20,pageCount:0,page:1}),h=Y(()=>s.meta?.did,[s]),[y,S]=x.useState([]),[O,P]=x.useState({}),C=Y(()=>l.length?new Set(l.map(p=>p.id)):new Set,[l]),_=async({page:p=1,pageSize:g=20,...k}={})=>{if(!h)return[];try{const N={paging:{page:p,pageSize:g},...k,teamDid:h,dateRange:k.dateRange?[U(k.dateRange[0]).toISOString(),U(k.dateRange[1]).toISOString()]:void 0},{dids:E,...z}=N;let B="";E&&E.includes("system")&&(B="system");const ie=E?E.filter(oe=>oe!=="system"):[],se={...z,source:B,componentDids:ie},Z=await n.getNotificationSendLog({input:se});return P(se),b(Z.list),v(Z.paging),Z.list}catch(N){return $.error(N.message),[]}},M=async()=>{const p=await n.getNotificationComponents({input:{teamDid:h}});S(p.componentDids)},I=x.useCallback(p=>{const g=s.children.find(k=>k.meta?.did===p);if(g)return g.ancestors=[s],g},[s]),A=async({notificationId:p,receivers:g,channels:k,...N})=>{await n.resendNotification({input:{teamDid:h,notificationId:p,receivers:g,channels:k.map(E=>E==="wallet"?q.WALLET:E==="pushKit"?q.PUSH:E),...N}})},H=x.useCallback(async p=>(await n.getUser({input:{teamDid:h,user:{did:p},options:{enableConnectedAccount:!0}}})).user,[n,h]),V=x.useCallback(async({page:p=1,pageSize:g=20,...k}={})=>{try{const N={paging:{page:p,pageSize:g},...k,userName:k.searchText||"",teamDid:h,dateRange:k.dateRange?[U(k.dateRange[0]).toISOString(),U(k.dateRange[1]).toISOString()]:void 0};return await n.getReceivers({input:N})}catch(N){throw $.error(N.message),N}},[n,h]);x.useEffect(()=>{h&&M()},[h]),i(He.NOTIFICATION_BLOCKLET_UPDATE,p=>{C.has(p.notificationId)&&_(O)},[C,O]),i(He.NOTIFICATION_BLOCKLET_CREATE,p=>{C.has(p.id)||_(O)},[C,O]);const Q={fetch:_,data:l,paging:m,blocklet:s,getComponent:I,resendNotification:A,getUser:H,componentDids:y,getReceivers:V,inService:r,teamDid:h};return e.jsx(_t,{value:{notificationRecords:Q},children:t})}function ze(){const{notificationRecords:t}=x.useContext(rt);return t}he.propTypes={severity:d.oneOf(Object.values(["info","success","error","warning"])).isRequired};const Vt={info:"primary",success:"success",error:"error",warning:"warning"};function he({severity:t="info"}){return e.jsx(kt,{type:Vt[t],children:t})}const Gt=(t,s,n="")=>{if(!n||!s)return"";switch(n){case ge.USER_DISABLED:return t("notification.sendStatus.reason.disabled",{channel:s});case ge.CHANNEL_UNAVAILABLE:return t("notification.sendStatus.reason.unavailable",{channel:s});case ge.CHANNEL_DISABLED:return t("notification.sendStatus.reason.notSent",{channel:s});case ge.NOT_ONLINE:return t("notification.sendStatus.reason.offline");default:return n}};function lt(t,s,n={}){const{status:r,updatedAt:i,reason:l="",channel:b="wallet"}=n,m=i?t("notification.sendStatus.sentTime",{date:Pt(i,s)}):"",v=Gt(t,b,l);return r===Ve.FAILED?{status:"failed",title:t("notification.sendStatus.failed"),sentTime:m,reason:v}:r===Ve.SENT?{status:"success",title:t("notification.sendStatus.success"),sentTime:m}:{status:"pending",title:t("notification.sendStatus.pending"),reason:v,sentTime:m}}const Ae={pending:"#aaaaaa",success:"#34BE74",failed:"#D0021B"},Pe=["wallet","pushKit","email"],Xe=["info","success","error","warning"],ct=t=>{const{settings:s}=t;return s?.notification?.email?.enabled},dt=t=>{const{settings:s}=t;return s?.notification?.pushKit?.enabled},Xt=(t,s)=>{const n=ee(s,"extra.notifications.email",!0);return{available:ct(t),enabled:n}},Yt=(t,s)=>{const n=ee(s,"extra.notifications.push",!0);return{available:dt(t),enabled:n}},Jt=t=>({enabled:ee(t,"extra.notifications.wallet",!0)}),Qt=t=>({enabled:ee(t,"extra.webhooks",[]).length>0}),xe=(t=3)=>new Promise(s=>{setTimeout(()=>{s()},t*1e3)}),Zt=(t,s)=>s==="wallet"||s==="webhook"?[{channel:s,type:"enabled",pass:t("notification.sendStatus.reason.enabled",{channel:s}),fail:t("notification.sendStatus.reason.disabled",{channel:s})}]:s==="pushKit"||s==="email"?[{channel:s,type:"available",pass:t("notification.sendStatus.reason.available",{channel:s}),fail:t("notification.sendStatus.reason.unavailable",{channel:s})},{channel:s,type:"enabled",pass:t("notification.sendStatus.reason.enabled",{channel:s}),fail:t("notification.sendStatus.reason.disabled",{channel:s})}]:[],be=(t=[])=>{const s=U().startOf("day");return t.filter(n=>U(n.sendAt).isSame(s,"day")).length},es=(t,s="")=>{if(s&&Pe.includes(s)){const l=`${s}SendRecord`,b=ee(t,l,[]);return be(b)}const n=ee(t,"webhook",{}),r=Object.keys(n??{})??[];if(s&&r.includes(s)){const l=n[s]??[];return be(l)}const i={};return Pe.forEach(l=>{const b=`${l}SendRecord`,m=ee(t,b,[]),v=be(m);i[l]=v}),r.length>0&&r.forEach(l=>{const b=n[l]??[],m=be(b);i[l]=m}),i},je=(t,s,n)=>{if(!Array.isArray(t))throw new Error("Invalid filterList or index");return t[n].splice(s,1),t},ve=(t,s)=>{if(!Array.isArray(s))throw new Error("filters must be an array");return s.length?!s.includes(t):!1},ts=t=>{switch(t){case q.WALLET:return"Wallet";case q.PUSH:return"Push Kit";case q.EMAIL:return"Email";case q.WEBHOOK:return"Webhook";default:return""}},ut=()=>({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 te({config:t,enableTooltip:s=!0,showTitle:n=!1,children:r=null}){const{status:i,title:l="",sentTime:b="",reason:m=""}=t,v=[l,m].filter(Boolean).join(", ");return e.jsx(xt,{title:s?e.jsxs(e.Fragment,{children:[e.jsx(X,{color:"inherit",sx:{fontSize:12},children:v}),e.jsx("span",{children:b})]}):null,arrow:!0,placement:"top",children:e.jsxs(R,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"4px"},children:[e.jsxs(R,{sx:{position:"relative",minHeight:14,minWidth:14,display:"flex",alignItems:"center",justifyContent:"center"},children:[e.jsx(R,{style:{opacity:.15},sx:{position:"absolute",width:"100%",height:"100%",borderRadius:"50%",bgcolor:Ae[i]}}),e.jsx(R,{sx:{position:"absolute",width:"55%",height:"55%",borderRadius:"50%",bgcolor:Ae[i]}})]}),e.jsx(X,{color:"inherit",sx:{fontSize:12},children:n?l:r})]})})}te.propTypes={config:d.object.isRequired,enableTooltip:d.bool,showTitle:d.bool,children:d.node};Se.propTypes={list:d.array.isRequired,label:d.string.isRequired,onDelete:d.func};function Se({list:t,label:s,onDelete:n=()=>{}}){const{t:r,locale:i}=J();return e.jsxs(R,{sx:{display:"flex",gap:1,alignItems:"center"},children:[e.jsxs(X,{children:[s,": "]}),t.map(l=>{const b=lt(r,i,{status:l});return e.jsx(Oe,{size:"small",label:e.jsx(R,{sx:{display:"flex",alignItems:"center",gap:"4px"},children:e.jsx(te,{config:b,enableTooltip:!1,children:b.title})}),onDelete:m=>n(m,l)},l)})]})}We.propTypes={filterList:d.array.isRequired,onChange:d.func.isRequired,index:d.number.isRequired,column:d.object.isRequired,filterValues:d.array.isRequired,label:d.string.isRequired,renderLabel:d.func.isRequired};function We({filterList:t,onChange:s,index:n,column:r,filterValues:i,label:l,renderLabel:b}){return e.jsxs(Be,{className:"filter-container",children:[e.jsx(Ye,{component:"legend",children:l}),e.jsx(ke,{row:!0,children:i.map(m=>e.jsx(De,{control:e.jsx(Le,{checked:t[n].indexOf(m.value??m)>-1,onChange:v=>{const h=[...t];v.target.checked?h[n]=[...h[n],m.value??m]:h[n]=h[n].filter(y=>y!==(m.value??m)),s(h[n],n,r)},name:m.value??m}),label:e.jsx("span",{style:{display:"flex",alignItems:"center"},children:b(m)})},m.value??m))})]})}function Te(t){return e.jsx(We,{...t,renderLabel:s=>e.jsx(te,{enableTooltip:!1,config:{status:s.status},children:s.label})})}ce.propTypes={status:d.number.isRequired,updatedAt:d.string.isRequired,reason:d.string,channel:d.string,onResend:d.func};function ce({status:t,updatedAt:s,reason:n="",channel:r="wallet",onResend:i}){const{t:l,locale:b}=J(),m=lt(l,b,{status:t,updatedAt:s,reason:n,channel:r});return e.jsxs(R,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(te,{config:m,showTitle:!0}),m.status!=="success"&&e.jsx(Re,{className:"resend-btn",size:"small",startIcon:e.jsx(Fe,{}),sx:{fontSize:12,color:"rgba(0, 0, 0, 0.87)",fontWeight:400,".MuiButton-startIcon":{mr:"2px"}},onClick:i,children:l("notification.resend")})]})}Me.propTypes={value:d.array.isRequired,onChange:d.func};function Me({value:t,onChange:s}){const{locale:n}=J(),r=U().toDate(),[i,l]=x.useState(null),b=x.useCallback(h=>{l(i?null:h.currentTarget)},[i]),m=!!i,v=x.useCallback(h=>{if(!h.startDate||!h.endDate){$.error("Please select a date range");return}if(U(h.startDate).isAfter(h.endDate)||!U(h.startDate).isValid()||!U(h.endDate).isValid()){$.error("Invalid date range");return}s([h.startDate,h.endDate]),l(null)},[s]);return e.jsxs("div",{children:[e.jsx(X,{component:"div",variant:"h5",color:"textPrimary",style:{fontSize:18,fontWeight:"bold"},sx:{mb:0},children:e.jsxs(Re,{onClick:b,variant:"outlined",size:"small",color:"inherit",children:[Ge(t[0],n)," - ",Ge(t[1],n)]})}),e.jsx(Ne,{open:m,anchorEl:i,onClose:()=>{l(null)},anchorOrigin:{vertical:"bottom",horizontal:"left"},children:e.jsx(Ut,{open:!0,maxDate:r,initialDateRange:{startDate:t[0],endDate:t[1]},toggle:b,definedRanges:$t(r),onChange:v})})]})}Ke.propTypes={itemComponent:d.elementType.isRequired};function Ke({itemComponent:t,...s}){const{t:n}=J();return!s?.filterList?.filter(i=>i.length).length?null:e.jsxs(R,{sx:{display:"flex",gap:1,alignItems:"center"},children:[e.jsx("div",{className:"toolbar-filter-title",children:n("notification.filter")}),e.jsx("div",{className:"toolbar-filter-content",children:e.jsx(Dt.TableFilterList,{...s,ItemComponent:t})})]})}function qe({label:t,onDelete:s,canDelete:n=()=>!0,...r}){const i=s&&typeof s=="function"?s:void 0;let l=!0;return n&&typeof n=="function"&&(l=n({label:t,...r})),e.jsx(Oe,{label:t,variant:"outlined",...i&&l?{onDelete:i}:{}})}qe.propTypes={label:d.string.isRequired,onDelete:d.func,canDelete:d.func};const ss=[{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:d.bool,onCancel:d.func,onConfirm:d.func};function pt({loading:t=!1,onCancel:s=()=>{},onConfirm:n=()=>{}}){const{t:r}=J(),[i,l]=x.useState(ss),[b,m]=x.useState(!0),v=(y,S)=>{S.checked=y.target.checked;const O=i.map(P=>({...P,checked:P.value===S.value?S.checked:P.checked}));l(O)},h=y=>{y.stopPropagation(),n({channels:i.filter(S=>S.checked).map(S=>S.value),isResendFailedOnly:b})};return e.jsxs(R,{className:"resend-config",sx:{padding:"16px 24px"},children:[e.jsx(X,{variant:"body1",component:"div",className:"check-title",sx:{fontWeight:700,mb:1},children:r("notification.config")}),e.jsx(R,{className:"choose-channel",children:e.jsxs(Be,{component:"fieldset",variant:"standard",children:[e.jsx(Ye,{component:"legend",children:r("notification.selectChannels")}),e.jsx(ke,{sx:{display:"flex",flexDirection:"row",flexWrap:"wrap",gap:1},children:i.map(y=>e.jsx(De,{control:e.jsx(Le,{checked:y.checked,onChange:S=>v(S,y),name:y.value}),label:y.label},y.value))})]})}),e.jsx(R,{className:"resend-config-footer",children:e.jsx(ke,{children:e.jsx(De,{control:e.jsx(Le,{checked:b,onChange:y=>m(y.target.checked)}),label:r("notification.resendFailedOnly")})})}),e.jsxs(R,{className:"resend-config-footer-tip",sx:{display:"flex",justifyContent:"flex-end",gap:1},children:[e.jsx(Re,{onClick:y=>{y.stopPropagation(),s()},color:"inherit",children:r("common.cancel")}),e.jsxs(Re,{onClick:h,color:"primary",disabled:t,variant:"contained",autoFocus:!0,style:{marginLeft:8},children:[t&&e.jsx(Je,{size:16}),r("common.confirm")]})]})]})}ft.propTypes={notificationId:d.string.isRequired,handleResend:d.func,resending:d.bool};function ft({notificationId:t,handleResend:s,resending:n=!1}){const{t:r,locale:i}=J(),l=Qe(),b=x.useMemo(()=>et(l,ut()),[l]),{getReceivers:m,inService:v,teamDid:h,getUser:y,blocklet:S}=ze(),[O,P]=x.useState(!1),[C,_]=x.useState([]),M=Ie({anchorEl:null,position:null}),I=Ie({anchorEl:null,position:null}),[A,H]=x.useState(null),[V,Q]=x.useState({total:0,pageSize:10,pageCount:0,page:1}),[p,g]=x.useState({searchText:"",page:1,pageSize:10,walletSendStatus:[],pushKitSendStatus:[],emailSendStatus:[],dateRange:[U().subtract(1,"month").startOf("day").toDate(),U().endOf("day").toDate()]}),[k,N]=x.useState([]),E=[{label:r("notification.sendStatus.pending"),value:0,status:"pending"},{label:r("notification.sendStatus.success"),value:1,status:"success"},{label:r("notification.sendStatus.failed"),value:2,status:"failed"}],z=async()=>{if(!O&&t)try{P(!0);const a=await m({notificationId:t,...p}),o=a.list.map(c=>({...c,receiverUser:{...c.receiverUser,avatar:it(c.receiverUser.avatar,h,v)}}));_(o),Q(a.paging),P(!1)}catch(a){$.error(a.message),P(!1)}};x.useEffect(()=>{z()},[p]);const B=a=>{a.stopPropagation();const o=a.currentTarget;I.anchorEl=o;const c=o.getBoundingClientRect();I.position={top:c.top+window.scrollY,left:c.left+window.scrollX}},ie=a=>a.data.length?e.jsx("div",{style:{display:"flex",alignItems:"center",padding:"10px"},children:e.jsx(Ee,{className:"resend-btn",size:"small",color:"primary",variant:"contained",startIcon:e.jsx(Fe,{}),sx:{".MuiButton-startIcon":{mr:"2px"}},onClick:B,children:r("notification.resend")})}):null,se={sort:!1,download:!1,print:!1,selectableRows:"multiple",searchPlaceholder:r("common.search"),searchAlwaysOpen:!1,filterType:"checkbox",searchDebounceTime:300,page:V.page-1,rowsPerPage:V.pageSize,count:V.total,searchText:p.searchText,tableBodyMaxHeight:"calc(80vh - 260px)",rowsSelected:k,onRowSelectionChange:(a,o)=>{N(o.map(c=>c.dataIndex))},customToolbarSelect:ie},Z=({page:a,rowsPerPage:o,searchText:c,filterList:w})=>{const[,F=[],G=[],K=[]]=w;p.pageSize!==o?g(W=>({...W,pageSize:o,page:1})):p.page!==a+1?g(W=>({...W,page:a+1})):p.searchText!==c?g(W=>({...W,searchText:c,page:1})):pe(F,p.walletSendStatus)?pe(G,p.pushKitSendStatus)?pe(K,p.emailSendStatus)||g(W=>({...W,emailSendStatus:K,page:1})):g(W=>({...W,pushKitSendStatus:G,page:1})):g(W=>({...W,walletSendStatus:F,page:1}))},oe=x.useCallback(async(a,o)=>{if(!o)return!1;const c=await y(o);return c?a==="wallet"?Jt(c):a==="email"?Xt(S,c):a==="pushKit"?Yt(S,c):a==="webhook"?Qt(c):!0:!1},[y,S]),Ce=x.useCallback(a=>Zt(r,a),[r]),f=()=>{M.anchorEl=null,M.position=null,H(null)},u=()=>{I.anchorEl=null,I.position=null},j=async(a,o,c=!0,w="")=>{if(!(!o.length||!a.length))try{s(a,o,c,w),I.anchorEl||(await xe(.5),f())}catch(F){console.error("handleResend error",{error:F})}},D=async({channels:a,isResendFailedOnly:o})=>{const c=k.map(w=>C[w].receiver);await j(a,c,o),await xe(.5),u(),N([])},L=async(a,o=[],c=!0)=>{try{await j(["webhook"],[a.receiver],c,o)}catch(w){$.error(w.response?w.response.statusText:w.message)}},T=async(a,o,c,w=[],F=!0)=>{if(a.stopPropagation(),es(o,c)>=4){$.warning(r("notification.resendLimit"));return}if(!Pe.includes(c)){await L(o,w,F);return}if(a){const K=a.currentTarget,W=K.getBoundingClientRect();M.anchorEl=K,M.position={top:W.top+window.scrollY,left:W.left+window.scrollX}}H({channel:c});try{const K=await oe(c,o.receiver);await xe(1),H({channel:c,result:K}),(typeof K=="boolean"&&K||Tt(K)&&Object.values(K).every(W=>!!W))&&(await s([c],[o.receiver],F),I.anchorEl||(await xe(.5),f()))}catch(K){$.error(K.message)}},re=a=>{g(o=>({...o,dateRange:a,page:1}))},ne=(a,o,c,w)=>{a.stopPropagation();const F=c.filter(G=>G!==o);g(G=>({...G,[w]:F,page:1}))},le=Y(()=>[{label:r("notification.receiver"),name:"receiver",width:200,options:{filter:!1,customBodyRenderLite:a=>{const{receiverUser:o,receiver:c}=C[a];return o?e.jsxs(R,{"data-cy":`member-name-${o.fullName}`,sx:{display:"flex",alignItems:"center",gap:1,justifyContent:"flex-start"},children:[e.jsx(tt,{src:`${o.avatar}?imageFilter=resize&w=48&h=48`,size:32,did:c,shape:"circle",style:{borderRadius:"100%",overflow:"hidden"}}),e.jsx(me,{children:o.fullName})]},c):e.jsx(qt,{size:14,responsive:!1,compact:!0,copyable:!1,did:c})}}},{label:"Wallet",name:"walletSendStatus",width:200,options:{setCellProps:()=>({className:"sent-status-cell"}),filter:!0,filterType:"custom",filterList:p.walletSendStatus??[],customFilterListOptions:{render:a=>e.jsx(Se,{list:a,label:"Wallet",onDelete:(o,c)=>{o.stopPropagation(),ne(o,c,le[1].options.filterList,"walletSendStatus")}}),update:je},filterOptions:{names:E,fullWidth:!0,logic:ve,display:(a,o,c,w)=>e.jsx(Te,{label:"Wallet",filterList:a,onChange:o,index:c,column:w,filterValues:E})},customBodyRenderLite:a=>{const{walletSendStatus:o,walletSendAt:c,walletSendFailedReason:w}=C[a];return e.jsx(ce,{status:o,updatedAt:c,reason:w,channel:"wallet",onResend:F=>T(F,C[a],"wallet",[],!1)})}}},{label:"Push Kit",name:"pushKitSendStatus",width:200,options:{setCellProps:()=>({className:"sent-status-cell"}),customBodyRenderLite:a=>{const{pushKitSendStatus:o,pushKitSendAt:c,pushKitSendFailedReason:w}=C[a];return e.jsx(ce,{status:o,updatedAt:c,reason:w,channel:"pushkit",onResend:F=>T(F,C[a],"pushKit",[],!1)})},filter:!0,filterType:"custom",filterList:p.pushKitSendStatus??[],customFilterListOptions:{render:a=>e.jsx(Se,{list:a,label:"Push Kit",onDelete:(o,c)=>{o.stopPropagation(),ne(o,c,le[2].options.filterList,"pushKitSendStatus")}}),update:je},filterOptions:{names:E,fullWidth:!0,logic:ve,display:(a,o,c,w)=>e.jsx(Te,{label:"Push Kit",filterList:a,onChange:o,index:c,column:w,filterValues:E})}}},{label:"Email",name:"emailSendStatus",width:200,options:{setCellProps:()=>({className:"sent-status-cell"}),customBodyRenderLite:a=>{const{emailSendStatus:o,emailSendAt:c,emailSendFailedReason:w}=C[a];return e.jsx(ce,{status:o,updatedAt:c,reason:w,channel:"email",onResend:F=>T(F,C[a],"email",[],!1)})},filter:!0,filterType:"custom",filterList:p.emailSendStatus??[],customFilterListOptions:{render:a=>e.jsx(Se,{list:a,label:"Email",onDelete:(o,c)=>{o.stopPropagation(),ne(o,c,le[3].options.filterList,"emailSendStatus")}}),update:je},filterOptions:{names:E,fullWidth:!0,logic:ve,display:(a,o,c,w)=>e.jsx(Te,{label:"Email",filterList:a,onChange:o,index:c,column:w,filterValues:E})}}},{label:"Webhook",name:"webhook",width:200,options:{filter:!1,setCellProps:()=>({className:"sent-status-cell"}),customBodyRenderLite:a=>{const{webhook:o}=C[a];if(!o)return null;const c=Object.entries(o)[0];if(!c)return null;const[w,F]=c,G=F[0];return e.jsx(R,{sx:{display:"flex",flexDirection:"column",gap:1},children:e.jsxs(R,{className:"webhook-item",sx:{fontSize:12},children:[e.jsx(me,{maxLength:30,children:w},w),e.jsx(ce,{status:G.status,updatedAt:G.sendAt,reason:G.failedReason,channel:"webhook",onResend:K=>T(K,C[a],"webhook",[w],!1)})]},w)})}}},{label:r("common.createdAt"),name:"createdAt",width:100,options:{filter:!1,customBodyRenderLite:a=>{const{createdAt:o}=C[a];return e.jsx(at,{value:o,locale:i,shouldUpdate:!0})}}}],[C,i,p,r]),gt=[e.jsx(Me,{value:p.dateRange,onChange:re},"date-picker"),e.jsx(Ee,{variant:"contained",size:"small",color:"primary",loading:O,startIcon:e.jsx(bt,{}),onClick:()=>z(),sx:{".MuiButton-startIcon":{mr:"2px"}},style:{marginLeft:8},children:r("common.refresh")},"refresh")];return e.jsx(R,{sx:{overflow:"auto",".MuiTableCell-head":{whiteSpace:"nowrap",fontWeight:"bold"},".MuiTableCell-root":{paddingRight:"8px",whiteSpace:"nowrap"}},children:e.jsx(as,{children:e.jsxs(Ze,{theme:b,children:[e.jsx(st,{className:"receivers-table",locale:i,loading:O,columns:le,data:C,onChange:Z,options:se,customButtons:gt,components:{TableFilterList:a=>e.jsx(Ke,{...a,itemComponent:o=>e.jsx(qe,{...o,canDelete:()=>!1})})}}),M.anchorEl&&e.jsx(Ne,{open:!!M.anchorEl,anchorReference:"anchorPosition",anchorPosition:M.position,onClose:f,anchorOrigin:{vertical:"center",horizontal:"right"},transformOrigin:{vertical:"center",horizontal:"left"},children:e.jsxs(is,{children:[e.jsxs(X,{variant:"body1",component:"div",className:"check-title",children:[A?.channel," Checking"]}),e.jsx(R,{sx:{display:"flex",flexDirection:"column",gap:"4px"},children:Ce(A?.channel).map(a=>{const{type:o,pass:c,fail:w}=a;return!A?.result||A?.result?.[o]?e.jsxs(X,{variant:"body1",component:"div",className:"check-item",sx:{display:"flex",alignItems:"center",gap:"4px",color:A?.result?.[o]?ye.success.main:"inherit"},children:[A?.result?e.jsx(yt,{}):e.jsx(Je,{size:12,sx:{color:ye.primary.main}}),e.jsx("span",{children:c})]},o):e.jsxs(X,{variant:"body1",component:"div",className:"check-item",sx:{display:"flex",alignItems:"center",gap:"4px",color:ye.error.main},children:[e.jsx(jt,{}),e.jsx("span",{children:w})]},o)})})]})}),I.anchorEl&&e.jsx(Ne,{open:!!I.anchorEl,anchorReference:"anchorPosition",anchorPosition:I.position,onClose:u,anchorOrigin:{vertical:"center",horizontal:"right"},transformOrigin:{vertical:"center",horizontal:"left"},children:e.jsx(pt,{loading:n,onCancel:u,onConfirm:D})})]})})})}const ns=x.memo(ft),as=ae.div`
2
2
  td.MuiTableCell-footer {
3
3
  border: none !important;
4
4
  }
@@ -1,4 +1,4 @@
1
- import{j as o,al as f,X as n,f as y,bR as A,aS as v,G as B}from"./vendor-mui-core-CDEc-eG6.js";import{r as N}from"./vendor-react-DX7tU9aY.js";import{l as b,bR as H,aa as V,w as W,D as G}from"./vendor-ux-PO0jFgJf.js";import{k as P}from"./fallback-DAsXuNMP.js";import{M as X}from"./use-blocklet-logo-nVOJALp0.js";import{ah as Y,h as J,E as K}from"./vendor-utils-_C9URqjS.js";import{a as Q}from"./vendor-hooks-Ca2cSNuD.js";import{M as O,p as U}from"./index-B4YwAnux.js";import{u as Z}from"./use-mobile-DKWj9MJD.js";import{k as ee,S as ne,n as oe,L as te,N as C,p as ie}from"./wallet-hidden-topbar-SQtOXLKg.js";function E({name:e="",logo:t="",description:i="",...p}){if(!e&&!t&&!i)return null;const c=N.isValidElement(t)?t:o.jsx("img",{src:t,alt:e});return o.jsxs(re,{...p,children:[o.jsxs("div",{children:[t&&o.jsx(f,{component:"a",href:"/",className:"footer-brand-logo",children:c}),e&&o.jsx("div",{className:"footer-brand-name",children:e})]}),i&&o.jsx("div",{className:"footer-brand-desc",children:i})]})}E.propTypes={name:n.node,logo:n.node,description:n.string};const re=b("div")`
1
+ import{j as o,al as f,X as n,f as y,bR as A,aS as v,G as B}from"./vendor-mui-core-CDEc-eG6.js";import{r as N}from"./vendor-react-DX7tU9aY.js";import{l as b,bR as H,aa as V,w as W,D as G}from"./vendor-ux-PO0jFgJf.js";import{k as P}from"./fallback-DAsXuNMP.js";import{M as X}from"./use-blocklet-logo-nVOJALp0.js";import{ah as Y,h as J,E as K}from"./vendor-utils-_C9URqjS.js";import{a as Q}from"./vendor-hooks-Ca2cSNuD.js";import{M as O,p as U}from"./index-Bz8EYhmA.js";import{u as Z}from"./use-mobile-DKWj9MJD.js";import{k as ee,S as ne,n as oe,L as te,N as C,p as ie}from"./wallet-hidden-topbar-CZaZNW94.js";function E({name:e="",logo:t="",description:i="",...p}){if(!e&&!t&&!i)return null;const c=N.isValidElement(t)?t:o.jsx("img",{src:t,alt:e});return o.jsxs(re,{...p,children:[o.jsxs("div",{children:[t&&o.jsx(f,{component:"a",href:"/",className:"footer-brand-logo",children:c}),e&&o.jsx("div",{className:"footer-brand-name",children:e})]}),i&&o.jsx("div",{className:"footer-brand-desc",children:i})]})}E.propTypes={name:n.node,logo:n.node,description:n.string};const re=b("div")`
2
2
  display: flex;
3
3
  flex-direction: column;
4
4
  font-size: 14px;
@@ -1 +1 @@
1
- import{r as W}from"./index-BVgxwS3B.js";import{w as L,B as k}from"./vendor-utils-_C9URqjS.js";import{cs as I,aO as C,aL as V}from"./index-DcM4ljaV.js";import{c5 as U}from"./vendor-ux-PO0jFgJf.js";var O={},q={},J;function F(){if(J)return q;J=1;var K=Object.create,u=Object.defineProperty,i=Object.getOwnPropertyDescriptor,y=Object.getOwnPropertyNames,g=Object.getPrototypeOf,m=Object.prototype.hasOwnProperty,l=(t,f,d,T)=>{if(f&&typeof f=="object"||typeof f=="function")for(var w=y(f),e=0,s=w.length,r;e<s;e++)r=w[e],!m.call(t,r)&&r!==d&&u(t,r,{get:(n=>f[n]).bind(null,r),enumerable:!(T=i(f,r))||T.enumerable});return t},p=(t,f,d)=>(d=t!=null?K(g(t)):{},l(f||!t||!t.__esModule?u(d,"default",{value:t,enumerable:!0}):d,t));return q.__toESM=p,q}var R={},x={},M;function Y(){if(M)return x;M=1;var K=Object.create,u=Object.defineProperty,i=Object.getOwnPropertyDescriptor,y=Object.getOwnPropertyNames,g=Object.getPrototypeOf,m=Object.prototype.hasOwnProperty,l=(t,f,d,T)=>{if(f&&typeof f=="object"||typeof f=="function")for(var w=y(f),e=0,s=w.length,r;e<s;e++)r=w[e],!m.call(t,r)&&r!==d&&u(t,r,{get:(n=>f[n]).bind(null,r),enumerable:!(T=i(f,r))||T.enumerable});return t},p=(t,f,d)=>(d=t!=null?K(g(t)):{},l(f||!t||!t.__esModule?u(d,"default",{value:t,enumerable:!0}):d,t));return x.__toESM=p,x}var P;function G(){if(P)return R;P=1;const K=Y();let u=W(),i=C(),y=V(),g=L();g=K.__toESM(g);let m=I();m=K.__toESM(m);let l=U();l=K.__toESM(l);const p=(0,g.default)("@arcblock/jwt"),t="1.1.0",f=i.Hasher.SHA3.hash256;async function d(s,r,n={},h=!0,o="1.0.0"){if((0,u.isValid)(s)===!1)throw new Error("Cannot do sign with invalid signer");const a=(0,u.toTypeInfo)(s),c={[i.types.KeyType.SECP256K1]:{alg:"ES256K",type:"JWT"},[i.types.KeyType.ED25519]:{alg:"Ed25519",type:"JWT"},[i.types.KeyType.ETHEREUM]:{alg:"Ethereum",type:"JWT"},[i.types.KeyType.PASSKEY]:{alg:"Passkey",type:"JWT"}};if(a.pk===void 0)throw new Error("Cannot determine key type from signer");const _=c[a.pk],H=(0,y.toBase64)((0,m.default)(_)),E=Math.floor(Date.now()/1e3),b={iss:(0,u.toDid)(s),iat:String(E),nbf:String(E),exp:String(E+300),version:o,...n||{}};Object.keys(b).forEach(S=>{(typeof b[S]>"u"||b[S]==null||b[S]==="")&&delete b[S]});const B=(0,y.toBase64)((0,m.default)(b));p("sign.body",b);const D=(0,y.toHex)(`${H}.${B}`),N=l.default.coerce(o),v=N&&l.default.gte(N.version,t)?f(D):D;return h?[H,B,(0,y.toBase64)((0,i.getSigner)(a.pk).sign(v,r))].join("."):`${H}.${B}`}async function T(s,r,n={}){return d(s,r,n,!!r,"1.1.0")}function w(s,r=!0){const[n,h,o]=s.split("."),a=JSON.parse((0,y.fromBase64)(n).toString()),c=JSON.parse((0,y.fromBase64)(h).toString()),_=k.from(Uint8Array.from((0,y.fromBase64)(o))).toString("hex");return r?c:{header:a,body:c,signature:`0x${(0,u.toStrictHex)(_)}`}}async function e(s,r,n){const{tolerance:h,enforceTimestamp:o,signerKey:a}=Object.assign({tolerance:5,enforceTimestamp:!0,signerKey:"iss"},n);try{const[c,_]=s.split("."),{header:H,body:E,signature:b}=w(s,!1);if(!b)return p("verify.error.emptySig"),!1;if(!H.alg)return p("verify.error.emptyAlg"),!1;const B=E[a];if(!B)return p("verify.error.emptySignerDid"),!1;if((0,u.isFromPublicKey)(B,r)===!1)return p("verify.error.signerDidAndPkNotMatch"),!1;if(o){const v=Math.ceil(Date.now()/1e3),S=Number(E.exp)||0,j=Number(E.iat)||0,$=Number(E.nbf)||0;if(p("verify.enforceTimestamp",{now:v,exp:S,iat:j,nbf:$}),S&&S+h<v)return p("verify.error.expired"),!1;if(j&&j>v&&j-v>h)return p("verify.error.issuedAt"),!1;if($&&$>v&&$-v>h)return p("verify.error.notBefore"),!1}const D={secp256k1:(0,i.getSigner)(i.types.KeyType.SECP256K1),es256k:(0,i.getSigner)(i.types.KeyType.SECP256K1),ed25519:(0,i.getSigner)(i.types.KeyType.ED25519),ethereum:(0,i.getSigner)(i.types.KeyType.ETHEREUM),passkey:(0,i.getSigner)(i.types.KeyType.PASSKEY)},N=H.alg.toLowerCase();if(D[N]){const v=(0,y.toHex)(`${c}.${_}`),S=E.version?l.default.coerce(E.version):null,j=S?S.version:"";return j&&j===t?D[N].verify(f(v),b,r):D[N].verify(v,b,r)}return p("verify.error.crypto"),!1}catch(c){return p("verify.error.exception"),p(c),!1}}return R.decode=w,R.sign=d,R.signV2=T,R.verify=e,R}var A;function ee(){if(A)return O;A=1;const K=F();let u=W(),i=G();i=K.__toESM(i);let y=C(),g=V();const m=u.DidType;function l(e,s="default"){const r=(0,u.DidType)(s),n=(0,y.getSigner)(r.pk),h=(0,y.getHasher)(r.hash);return{type:r,secretKey:e.sk,publicKey:e.pk,address:e.pk?(0,u.fromPublicKey)(e.pk,r):e.address,hash(o,a=1,c="hex"){return h(o,a,c)},async sign(o,a=!0,c="hex"){if(!e.sk)throw new Error("Cannot sign data without a secretKey");if(a){const _=h(o,1);return n.sign(_,e.sk,c)}return n.sign(o,e.sk,c)},async verify(o,a,c=!0,_){if(!e.pk)throw new Error("Cannot verify data without a publicKey");const H=c?h(o,1):o;return n.verify(H,a,e.pk,_)},ethHash(o){if(typeof n.ethHash!="function")throw new Error("ethHash is not supported by signer");return n.ethHash(o)},async signETH(o,a=!0){if(!e.sk)throw new Error("Cannot sign data without a secretKey");if(typeof n.ethHash!="function"||typeof n.ethSign!="function")throw new Error("ethSign is not supported by signer");return a?n.ethSign(n.ethHash(o),(0,g.toHex)(e.sk)):n.ethSign(o,(0,g.toHex)(e.sk))},ethSign(o,a=!0){return this.signETH(o,a)},async ethVerify(o,a,c=!0){if(typeof n.ethHash!="function"||typeof n.ethRecover!="function")throw new Error("ethVerify is not supported by signer");const _=c?n.ethHash(o):o;return n.ethRecover(_,a)===this.address},async signJWT(o={},a=!0,c="1.0.0"){if(!e.sk)throw new Error("Cannot sign JWT without a secretKey");return i.sign(this.address,e.sk,o,a,c)},toAddress(){return e.pk?(0,u.fromPublicKey)(e.pk,r):e.address},toJSON(){return{type:u.DidType.toJSON(r),sk:e.sk?(0,g.toHex)(e.sk):"",pk:e.pk?(0,g.toHex)(e.pk):"",address:this.address}}}}function p(e,s="default"){const r=(0,u.DidType)(s);return l({sk:e,pk:(0,y.getSigner)(r.pk).getPublicKey(e)},r)}function t(e,s="default"){return l({pk:e},(0,u.DidType)(s))}function f(e){return l({address:(0,u.toAddress)(e)},(0,u.toTypeInfo)(e))}function d(e="default"){const s=(0,u.DidType)(e),r=(0,y.getSigner)(s.pk).genKeyPair();return l({sk:r.secretKey,pk:r.publicKey},s)}function T(e){return l(e,u.DidType.fromJSON(e.type))}function w(e,s=!0){return!(!e||typeof e!="object"||typeof e.verify!="function"||typeof e.toAddress!="function"||typeof e.toJSON!="function"||!e.type||!e.publicKey||s&&typeof e.sign!="function")}return O.Wallet=l,O.WalletType=m,O.fromAddress=f,O.fromJSON=T,O.fromPublicKey=t,O.fromRandom=d,O.fromSecretKey=p,O.isValid=w,O}export{ee as r};
1
+ import{r as W}from"./index-BLYrVxV3.js";import{w as L,B as k}from"./vendor-utils-_C9URqjS.js";import{cs as I,aO as C,aL as V}from"./index-CgSpL7jz.js";import{c5 as U}from"./vendor-ux-PO0jFgJf.js";var O={},q={},J;function F(){if(J)return q;J=1;var K=Object.create,u=Object.defineProperty,i=Object.getOwnPropertyDescriptor,y=Object.getOwnPropertyNames,g=Object.getPrototypeOf,m=Object.prototype.hasOwnProperty,l=(t,f,d,T)=>{if(f&&typeof f=="object"||typeof f=="function")for(var w=y(f),e=0,s=w.length,r;e<s;e++)r=w[e],!m.call(t,r)&&r!==d&&u(t,r,{get:(n=>f[n]).bind(null,r),enumerable:!(T=i(f,r))||T.enumerable});return t},p=(t,f,d)=>(d=t!=null?K(g(t)):{},l(f||!t||!t.__esModule?u(d,"default",{value:t,enumerable:!0}):d,t));return q.__toESM=p,q}var R={},x={},M;function Y(){if(M)return x;M=1;var K=Object.create,u=Object.defineProperty,i=Object.getOwnPropertyDescriptor,y=Object.getOwnPropertyNames,g=Object.getPrototypeOf,m=Object.prototype.hasOwnProperty,l=(t,f,d,T)=>{if(f&&typeof f=="object"||typeof f=="function")for(var w=y(f),e=0,s=w.length,r;e<s;e++)r=w[e],!m.call(t,r)&&r!==d&&u(t,r,{get:(n=>f[n]).bind(null,r),enumerable:!(T=i(f,r))||T.enumerable});return t},p=(t,f,d)=>(d=t!=null?K(g(t)):{},l(f||!t||!t.__esModule?u(d,"default",{value:t,enumerable:!0}):d,t));return x.__toESM=p,x}var P;function G(){if(P)return R;P=1;const K=Y();let u=W(),i=C(),y=V(),g=L();g=K.__toESM(g);let m=I();m=K.__toESM(m);let l=U();l=K.__toESM(l);const p=(0,g.default)("@arcblock/jwt"),t="1.1.0",f=i.Hasher.SHA3.hash256;async function d(s,r,n={},h=!0,o="1.0.0"){if((0,u.isValid)(s)===!1)throw new Error("Cannot do sign with invalid signer");const a=(0,u.toTypeInfo)(s),c={[i.types.KeyType.SECP256K1]:{alg:"ES256K",type:"JWT"},[i.types.KeyType.ED25519]:{alg:"Ed25519",type:"JWT"},[i.types.KeyType.ETHEREUM]:{alg:"Ethereum",type:"JWT"},[i.types.KeyType.PASSKEY]:{alg:"Passkey",type:"JWT"}};if(a.pk===void 0)throw new Error("Cannot determine key type from signer");const _=c[a.pk],H=(0,y.toBase64)((0,m.default)(_)),E=Math.floor(Date.now()/1e3),b={iss:(0,u.toDid)(s),iat:String(E),nbf:String(E),exp:String(E+300),version:o,...n||{}};Object.keys(b).forEach(S=>{(typeof b[S]>"u"||b[S]==null||b[S]==="")&&delete b[S]});const B=(0,y.toBase64)((0,m.default)(b));p("sign.body",b);const D=(0,y.toHex)(`${H}.${B}`),N=l.default.coerce(o),v=N&&l.default.gte(N.version,t)?f(D):D;return h?[H,B,(0,y.toBase64)((0,i.getSigner)(a.pk).sign(v,r))].join("."):`${H}.${B}`}async function T(s,r,n={}){return d(s,r,n,!!r,"1.1.0")}function w(s,r=!0){const[n,h,o]=s.split("."),a=JSON.parse((0,y.fromBase64)(n).toString()),c=JSON.parse((0,y.fromBase64)(h).toString()),_=k.from(Uint8Array.from((0,y.fromBase64)(o))).toString("hex");return r?c:{header:a,body:c,signature:`0x${(0,u.toStrictHex)(_)}`}}async function e(s,r,n){const{tolerance:h,enforceTimestamp:o,signerKey:a}=Object.assign({tolerance:5,enforceTimestamp:!0,signerKey:"iss"},n);try{const[c,_]=s.split("."),{header:H,body:E,signature:b}=w(s,!1);if(!b)return p("verify.error.emptySig"),!1;if(!H.alg)return p("verify.error.emptyAlg"),!1;const B=E[a];if(!B)return p("verify.error.emptySignerDid"),!1;if((0,u.isFromPublicKey)(B,r)===!1)return p("verify.error.signerDidAndPkNotMatch"),!1;if(o){const v=Math.ceil(Date.now()/1e3),S=Number(E.exp)||0,j=Number(E.iat)||0,$=Number(E.nbf)||0;if(p("verify.enforceTimestamp",{now:v,exp:S,iat:j,nbf:$}),S&&S+h<v)return p("verify.error.expired"),!1;if(j&&j>v&&j-v>h)return p("verify.error.issuedAt"),!1;if($&&$>v&&$-v>h)return p("verify.error.notBefore"),!1}const D={secp256k1:(0,i.getSigner)(i.types.KeyType.SECP256K1),es256k:(0,i.getSigner)(i.types.KeyType.SECP256K1),ed25519:(0,i.getSigner)(i.types.KeyType.ED25519),ethereum:(0,i.getSigner)(i.types.KeyType.ETHEREUM),passkey:(0,i.getSigner)(i.types.KeyType.PASSKEY)},N=H.alg.toLowerCase();if(D[N]){const v=(0,y.toHex)(`${c}.${_}`),S=E.version?l.default.coerce(E.version):null,j=S?S.version:"";return j&&j===t?D[N].verify(f(v),b,r):D[N].verify(v,b,r)}return p("verify.error.crypto"),!1}catch(c){return p("verify.error.exception"),p(c),!1}}return R.decode=w,R.sign=d,R.signV2=T,R.verify=e,R}var A;function ee(){if(A)return O;A=1;const K=F();let u=W(),i=G();i=K.__toESM(i);let y=C(),g=V();const m=u.DidType;function l(e,s="default"){const r=(0,u.DidType)(s),n=(0,y.getSigner)(r.pk),h=(0,y.getHasher)(r.hash);return{type:r,secretKey:e.sk,publicKey:e.pk,address:e.pk?(0,u.fromPublicKey)(e.pk,r):e.address,hash(o,a=1,c="hex"){return h(o,a,c)},async sign(o,a=!0,c="hex"){if(!e.sk)throw new Error("Cannot sign data without a secretKey");if(a){const _=h(o,1);return n.sign(_,e.sk,c)}return n.sign(o,e.sk,c)},async verify(o,a,c=!0,_){if(!e.pk)throw new Error("Cannot verify data without a publicKey");const H=c?h(o,1):o;return n.verify(H,a,e.pk,_)},ethHash(o){if(typeof n.ethHash!="function")throw new Error("ethHash is not supported by signer");return n.ethHash(o)},async signETH(o,a=!0){if(!e.sk)throw new Error("Cannot sign data without a secretKey");if(typeof n.ethHash!="function"||typeof n.ethSign!="function")throw new Error("ethSign is not supported by signer");return a?n.ethSign(n.ethHash(o),(0,g.toHex)(e.sk)):n.ethSign(o,(0,g.toHex)(e.sk))},ethSign(o,a=!0){return this.signETH(o,a)},async ethVerify(o,a,c=!0){if(typeof n.ethHash!="function"||typeof n.ethRecover!="function")throw new Error("ethVerify is not supported by signer");const _=c?n.ethHash(o):o;return n.ethRecover(_,a)===this.address},async signJWT(o={},a=!0,c="1.0.0"){if(!e.sk)throw new Error("Cannot sign JWT without a secretKey");return i.sign(this.address,e.sk,o,a,c)},toAddress(){return e.pk?(0,u.fromPublicKey)(e.pk,r):e.address},toJSON(){return{type:u.DidType.toJSON(r),sk:e.sk?(0,g.toHex)(e.sk):"",pk:e.pk?(0,g.toHex)(e.pk):"",address:this.address}}}}function p(e,s="default"){const r=(0,u.DidType)(s);return l({sk:e,pk:(0,y.getSigner)(r.pk).getPublicKey(e)},r)}function t(e,s="default"){return l({pk:e},(0,u.DidType)(s))}function f(e){return l({address:(0,u.toAddress)(e)},(0,u.toTypeInfo)(e))}function d(e="default"){const s=(0,u.DidType)(e),r=(0,y.getSigner)(s.pk).genKeyPair();return l({sk:r.secretKey,pk:r.publicKey},s)}function T(e){return l(e,u.DidType.fromJSON(e.type))}function w(e,s=!0){return!(!e||typeof e!="object"||typeof e.verify!="function"||typeof e.toAddress!="function"||typeof e.toJSON!="function"||!e.type||!e.publicKey||s&&typeof e.sign!="function")}return O.Wallet=l,O.WalletType=m,O.fromAddress=f,O.fromJSON=T,O.fromPublicKey=t,O.fromRandom=d,O.fromSecretKey=p,O.isValid=w,O}export{ee as r};
@@ -1,4 +1,4 @@
1
- import{j as e,X as m,a7 as L,T as j,aT as Ne,G as _e,ea as V,ap as J,eb as We,al as h,b3 as G,bb as Ge,s as fe,ec as be,bd as Fe,an as ge,cF as Ye,M as Y,aM as K,bB as Ke,aN as $,R as $e,ce as qe,aP as He,ed as Qe,ee as Xe,ef as Ve,dG as Je,a_ as he}from"./vendor-mui-core-CDEc-eG6.js";import{r as Ze,p as ke,a as ue}from"./vendor-hooks-Ca2cSNuD.js";import{r as b,j as et}from"./vendor-react-DX7tU9aY.js";import{V as M,X as N,M as E,F as U,bs as tt,bJ as st,ab as ot,cr as I,w as nt}from"./index-DcM4ljaV.js";import{a3 as D,aa as B,bj as at,bp as q,b3 as rt,R as it,bk as le,br as ct}from"./vendor-ux-PO0jFgJf.js";import{u as lt}from"./use-mobile-CnCzXOEv.js";import{a as H,d as je,p as dt,c as pt,D as Ce,y as me}from"./vendor-utils-_C9URqjS.js";import{o as we}from"./vendor-arcblock-BVQTtbN-.js";import{a as ut,u as mt,c as xt,D as de,b as ft}from"./index-BgdIPmn8.js";import"./index-BojVbZw0.js";import"./api-Bo6lutcq.js";import{u as De,C as gt,D as ht,a as St}from"./connect-to-D5tNZXTo.js";import{c as yt,g as bt,d as kt,i as jt,e as xe,f as Ct,h as wt,j as Dt}from"./spaces-B8t2gKsu.js";import{f as Q}from"./index-DBs9Ljax.js";import{v as Bt}from"./index-BEbBg3NW.js";import{a as Et}from"./dashboard-BZs_YRr4.js";import{E as Tt}from"./index-DlYWPFit.js";import{x as It}from"./index-D29L5UKE.js";import{g as Se}from"./get-safe-url-C1Ml6qBb.js";import{S as Rt}from"./switch-control-BfU6EhtX.js";import{C as vt,u as zt}from"./config-space-DMk4apM9.js";import{L as ye}from"./list-header-BKicL0iB.js";import"./index-BY7bAdcP.js";import"./session-D6Z4R7oi.js";import"./team-sypU8pIA.js";import"./purify.es-HRjpPm7y.js";import"./wallet-hidden-topbar-SQtOXLKg.js";import"./theme-mode-toggle-WRMGhjzA.js";import"./use-mobile-DKWj9MJD.js";import"./index-BVgxwS3B.js";import"./isURL-CpQHQuaa.js";import"./isIP-BBY240SU.js";import"./use-blocklet-logo-nVOJALp0.js";import"./use-app-logo-Dt5Rf_oh.js";import"./useAsyncRetry-DOQg_SXs.js";import"./useAsync-10WR8h3k.js";import"./useSetState-CUbypYGT.js";import"./fallback-DAsXuNMP.js";import"./index-BtpVtm9d.js";import"./nav-menu-CFJ8S6L5.js";import"./zh-oZCQbfAf.js";import"./over-due-invoice-payment-CPLJV5KG.js";import"./useLocalStorage-CSvyQkk-.js";import"./confirm-BMWka5pp.js";import"./passport-bxIQRuHM.js";import"./create-passport-svg-DNOT-xbE.js";import"./provider-icon-BHmm2FYJ.js";import"./google-icon-vNOJy67F.js";import"./passkey-rounded-_WDHIZVd.js";import"./index-BObu-fIz.js";async function Ot({blockletDid:t,nodeApi:n,spaceGateways:a}){let s=!1;const r=await Promise.all(a.map(async o=>{let{name:c}=o;const i=await yt(o.endpoint);return!H(i)&&i!==c&&(c=i,s=!0),{...o,name:c}}));return s&&await Promise.all(r.filter(o=>o.did).map(o=>n.updateBlockletSpaceGateway({input:{did:t,where:{did:o.did},spaceGateway:{...o}}}))),r}function Lt({refresh:t}={}){const{blocklet:n}=M(),a=n?.meta?.did,{api:s}=N();return Ze(async()=>{if(!a)return[];const{spaceGateways:r}=await s.getBlockletSpaceGateways({input:{did:a}});return await Ot({blockletDid:a,nodeApi:s,spaceGateways:r})??[]},{refreshDeps:[a,t],onError(r){r?.message?.includes("not logged")?console.warn(r):(console.error(r),D.error(Q(r)))}})}function Be({deps:t,setLoading:n,backupDate:a}={deps:[],setLoading:()=>{},backupDate:new Date}){const{blocklet:s}=M(),[r,o]=b.useState([]),{api:c}=N(),[i,d]=b.useMemo(()=>a?[E(a).startOf("day").toISOString(),E(a).endOf("day").toISOString()]:[E().startOf("year").toISOString(),E().endOf("day").toISOString()],[a]),l=je(async()=>{try{if(n(!0),!s){o([]);return}const{backups:x}=await c.getBlockletBackups({input:{did:s.meta.did,startTime:i,endTime:d}});o(x??[])}catch(x){console.error(x),D.error(Q(x))}finally{n(!1)}},1e3);return ke(async()=>{l()},[s?.meta?.did].concat(t)),{backups:r}}function Pt({appDid:t}){const{backups:n}=Be(),[a,s]=b.useState({message:"",progress:0,completed:!1}),r=N(),{ws:{useSubscription:o}}=r;return o(U.BlockletEvents.backupProgress,c=>{t===c?.appDid&&s(()=>({...c}))},[t]),b.useEffect(()=>{if(n?.length&&dt(n[0]?.status)){const[c]=n;s(()=>({message:c.message,progress:c.progress,completed:c.progress>=100}))}},[n]),a}function At({deps:t=[],setLoading:n=()=>{}}={}){const{blocklet:a}=M(),[s,r]=b.useState([]),{api:o}=N(),c=b.useCallback(je(async()=>{if(!o||!a?.meta?.did){r([]);return}try{n(!0);const i=E(),d=i.subtract(1,"year"),{summary:l}=await o.getBlockletBackupSummary({input:{did:a.meta.did,startTime:d.toISOString(),endTime:i.toISOString()}}),x=Array.isArray(l)?l.map(p=>({...p,successCount:+p.successCount,errorCount:+p.errorCount})):[];r(x)}catch(i){console.error("Failed to fetch backup summary:",i),D.error(Q(i)),r([])}finally{n(!1)}},1e3),[]);return ke(async()=>(await c(),()=>{c.cancel()}),[a?.meta?.did].concat(t)),{backupSummary:s}}const Ee=b.createContext({}),{Provider:Ut,Consumer:$s}=Ee;function Te({children:t}){const{t:n}=B(),{api:a}=N(),{blocklet:s}=M(),[r,o]=b.useState(null),[c,i]=b.useState(!1),{data:d,loading:l,mutate:x}=Lt({refresh:c}),p=pt(d),f=Pt({appDid:s?.appDid}),u=b.useMemo(()=>bt(s?.environments),[s?.environments]),[k,w]=b.useState(!1),[S,y]=b.useState(0),{backups:Z}=Be({deps:[S,r],setLoading:w,backupDate:r}),[ee,te]=b.useState(0),{backupSummary:se}=At({deps:[ee]}),[_,A]=b.useState(d?.find(g=>g.endpoint===u)),T=s?.settings?.autoBackup,v=()=>{i(g=>!g)},oe=()=>{te(g=>g+1)},ne=()=>{y(g=>g+1)},F=async g=>{await a.updateAutoBackup({input:{did:s.meta.did,autoBackup:g}})},X=async()=>{await a.abortBlockletBackup({input:{appPid:s.meta.did}})},ae=async(g,O)=>{try{x(R=>{const z=[...R];return z.push({...g,loading:!0}),z}),await a.addBlockletSpaceGateway({input:{did:s.meta.did,spaceGateway:g}}),u!==O&&await a.configBlocklet({input:{did:[s.meta.did],configs:[{key:U.BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_APP_BACKUP_ENDPOINT,value:O}]}}),A(g),v(),D.success(n("storage.spaces.connectedWithName",{name:g?.name??"DID Spaces"}))}catch(R){throw console.error(R),x(z=>[...z].filter(W=>W.did!==g.did)),R}},re=async g=>{g&&(g.endpoint===u&&(await a.configBlocklet({input:{did:[s.meta.did],configs:[{key:U.BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_APP_BACKUP_ENDPOINT,value:""}]}}),T?.enabled&&await F({enabled:!1})),await a.deleteBlockletSpaceGateway({input:{did:s.meta.did,spaceGatewayDid:g?.did}}),x(O=>{const R=[...O];return R.splice(R.indexOf(g),1),R}),A(g),v())},ie=async g=>{await Promise.all([a.updateBlockletSpaceGateway({input:{did:s.meta.did,where:{did:g.did},spaceGateway:g}}),u!==g.endpoint&&a.configBlocklet({input:{did:[s.meta.did],configs:[{key:U.BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_APP_BACKUP_ENDPOINT,value:g.endpoint}]}})]),D.success(n("storage.spaces.connectedWithName",{name:g?.name??"DID Spaces"})),v()},C=g=>g?.endpoint===u;return e.jsx(Ut,{value:{spaceGateways:d||[],selectedSpaceGateway:_,addSpaceGateway:ae,deleteSpaceGateway:re,updateSpaceGateway:ie,refreshSpaceGateways:v,spaceGatewaysLoading:l,spaceGatewaysFirstLoading:p,spaceGatewayIsSelected:C,updateAutoBackup:F,abortBlockletBackup:X,backupEndpoint:u,backupProgress:f,backups:Z,backupSummary:se,refreshBackupSummary:oe,refreshBackups:ne,setBackupDate:o,backupsLoading:k,autoBackup:T},children:t})}Te.propTypes={children:m.any.isRequired};function P(){return b.useContext(Ee)}function Ie({...t}){const{blocklet:n}=M(),{info:a}=N(),{t:s}=B(),r=De({blocklet:n}),o=tt(a),{spaceGateways:c,addSpaceGateway:i}=P(),d={checkFn:Ce.create({baseURL:me(window.location.origin,st())}).get,webWalletUrl:o,extraParams:{appPid:n.appPid,appDid:r.appDid,appName:r.appName,appDescription:r.appDescription,appUrl:r.appUrl,referrer:r.referrer,scopes:r.scopes,nodeDid:a.did}},l=async({endpoint:p,name:f,did:u})=>{const k=await kt(p);if(!await jt(k)){D.error(s("storage.spaces.gateway.add.invalidUrl"));return}if(c.some(y=>y.endpoint===p)){D.error(s("storage.spaces.gateway.add.duplicate",{name:f}));return}await i({name:f,did:u,url:k,endpoint:p},p)},x=async({spaceGateway:p})=>{try{await l(p)}catch(f){console.error(f),D.error(Q(f))}};return e.jsx(ut,{...t,connectScope:"app",options:d,onSuccess:x})}function Re({...t}){const{t:n}=b.useContext(at),{blocklet:a,loading:s}=Et();if(a?.diskInfo){const r=(i,d,l)=>e.jsxs(j,{children:[i," ",e.jsx("strong",{children:d?ot(d):"empty"})]}),o=a.environments.reduce((i,d)=>(i[d.key]=d.value,i),{}),c=[{key:"appDir",name:n("blocklet.diskInfo.appDir"),value:r(o.BLOCKLET_APP_DIR,a.diskInfo.app)},{key:"dataDir",name:n("blocklet.diskInfo.dataDir"),value:r(o.BLOCKLET_DATA_DIR,a.diskInfo.data)},{key:"logDir",name:n("blocklet.diskInfo.logDir"),value:r(o.BLOCKLET_LOG_DIR,a.diskInfo.log)},{key:"cacheDir",name:n("blocklet.diskInfo.cacheDir"),value:r(o.BLOCKLET_CACHE_DIR,a.diskInfo.cache)}];return e.jsx(Mt,{component:"div",...t,children:c.map(i=>e.jsx(Bt,{valueComponent:"div",nameWidth:120,name:i.name,children:i.value},i.key))})}return s?e.jsx(L,{}):e.jsx(j,{children:n("blocklet.diskInfo.empty")})}const Mt=Ne(j)``;function ve(){const{t}=B(),{setBackupDate:n,backupSummary:a}=P(),s=mt({key:"lg"}),r=b.useRef(null),o=_e(),c=b.useCallback(l=>{n(l)},[n]),i=b.useMemo(()=>{const l=E().add(1,"day"),x=l.subtract(1,"year"),p=new Map(a.map(u=>[u.date,{date:u.date,successCount:u.successCount,errorCount:u.errorCount}])),f=[];for(let u=x.clone();E(u).isBefore(l);u=u.add(1,"day")){const k=u.format("YYYY-MM-DD");f.push(p.get(k)||{date:k,successCount:0,errorCount:0})}return f},[a]),d=b.useMemo(()=>({grid:{containLabel:!0,right:10,top:30,bottom:12},tooltip:{formatter:k=>{const{date:w,successCount:S,errorCount:y}=i[k.dataIndex]||{date:k.data[0],successCount:0,errorCount:0};return[`<div>${t("common.time")}: ${w}</div>`,`<div>${t("common.succeeded")}: ${S}</div>`,`<div>${t("common.failed")}: ${y}</div>`].join(`
1
+ import{j as e,X as m,a7 as L,T as j,aT as Ne,G as _e,ea as V,ap as J,eb as We,al as h,b3 as G,bb as Ge,s as fe,ec as be,bd as Fe,an as ge,cF as Ye,M as Y,aM as K,bB as Ke,aN as $,R as $e,ce as qe,aP as He,ed as Qe,ee as Xe,ef as Ve,dG as Je,a_ as he}from"./vendor-mui-core-CDEc-eG6.js";import{r as Ze,p as ke,a as ue}from"./vendor-hooks-Ca2cSNuD.js";import{r as b,j as et}from"./vendor-react-DX7tU9aY.js";import{V as M,X as N,M as E,F as U,bs as tt,bJ as st,ab as ot,cr as I,w as nt}from"./index-CgSpL7jz.js";import{a3 as D,aa as B,bj as at,bp as q,b3 as rt,R as it,bk as le,br as ct}from"./vendor-ux-PO0jFgJf.js";import{u as lt}from"./use-mobile-CnCzXOEv.js";import{a as H,d as je,p as dt,c as pt,D as Ce,y as me}from"./vendor-utils-_C9URqjS.js";import{o as we}from"./vendor-arcblock-BVQTtbN-.js";import{a as ut,u as mt,c as xt,D as de,b as ft}from"./index-CeSwZI3Q.js";import"./index-BojVbZw0.js";import"./api-Bo6lutcq.js";import{u as De,C as gt,D as ht,a as St}from"./connect-to-BRIhV6_s.js";import{c as yt,g as bt,d as kt,i as jt,e as xe,f as Ct,h as wt,j as Dt}from"./spaces-DiyZ082O.js";import{f as Q}from"./index-DBs9Ljax.js";import{v as Bt}from"./index-BEbBg3NW.js";import{a as Et}from"./dashboard-OrVG8J2E.js";import{E as Tt}from"./index-DlYWPFit.js";import{x as It}from"./index-D29L5UKE.js";import{g as Se}from"./get-safe-url-uxJSMQTF.js";import{S as Rt}from"./switch-control-BfU6EhtX.js";import{C as vt,u as zt}from"./config-space-CjtdFXkd.js";import{L as ye}from"./list-header-BKicL0iB.js";import"./index-BY7bAdcP.js";import"./session-BEf_KK-i.js";import"./team-Bso_Sjaa.js";import"./purify.es-HRjpPm7y.js";import"./wallet-hidden-topbar-CZaZNW94.js";import"./theme-mode-toggle-WRMGhjzA.js";import"./use-mobile-DKWj9MJD.js";import"./index-BLYrVxV3.js";import"./isURL-CpQHQuaa.js";import"./isIP-BBY240SU.js";import"./use-blocklet-logo-nVOJALp0.js";import"./use-app-logo-DcBQK--f.js";import"./useAsyncRetry-DOQg_SXs.js";import"./useAsync-10WR8h3k.js";import"./useSetState-CUbypYGT.js";import"./fallback-DAsXuNMP.js";import"./index-DI80KOep.js";import"./nav-menu-CFJ8S6L5.js";import"./zh-BYHnQ2ca.js";import"./over-due-invoice-payment-D6491JHf.js";import"./useLocalStorage-CSvyQkk-.js";import"./confirm-DhDNorbd.js";import"./passport-2AVRJTQK.js";import"./create-passport-svg-DNOT-xbE.js";import"./provider-icon-BHmm2FYJ.js";import"./google-icon-vNOJy67F.js";import"./passkey-rounded-_WDHIZVd.js";import"./index-BObu-fIz.js";async function Ot({blockletDid:t,nodeApi:n,spaceGateways:a}){let s=!1;const r=await Promise.all(a.map(async o=>{let{name:c}=o;const i=await yt(o.endpoint);return!H(i)&&i!==c&&(c=i,s=!0),{...o,name:c}}));return s&&await Promise.all(r.filter(o=>o.did).map(o=>n.updateBlockletSpaceGateway({input:{did:t,where:{did:o.did},spaceGateway:{...o}}}))),r}function Lt({refresh:t}={}){const{blocklet:n}=M(),a=n?.meta?.did,{api:s}=N();return Ze(async()=>{if(!a)return[];const{spaceGateways:r}=await s.getBlockletSpaceGateways({input:{did:a}});return await Ot({blockletDid:a,nodeApi:s,spaceGateways:r})??[]},{refreshDeps:[a,t],onError(r){r?.message?.includes("not logged")?console.warn(r):(console.error(r),D.error(Q(r)))}})}function Be({deps:t,setLoading:n,backupDate:a}={deps:[],setLoading:()=>{},backupDate:new Date}){const{blocklet:s}=M(),[r,o]=b.useState([]),{api:c}=N(),[i,d]=b.useMemo(()=>a?[E(a).startOf("day").toISOString(),E(a).endOf("day").toISOString()]:[E().startOf("year").toISOString(),E().endOf("day").toISOString()],[a]),l=je(async()=>{try{if(n(!0),!s){o([]);return}const{backups:x}=await c.getBlockletBackups({input:{did:s.meta.did,startTime:i,endTime:d}});o(x??[])}catch(x){console.error(x),D.error(Q(x))}finally{n(!1)}},1e3);return ke(async()=>{l()},[s?.meta?.did].concat(t)),{backups:r}}function Pt({appDid:t}){const{backups:n}=Be(),[a,s]=b.useState({message:"",progress:0,completed:!1}),r=N(),{ws:{useSubscription:o}}=r;return o(U.BlockletEvents.backupProgress,c=>{t===c?.appDid&&s(()=>({...c}))},[t]),b.useEffect(()=>{if(n?.length&&dt(n[0]?.status)){const[c]=n;s(()=>({message:c.message,progress:c.progress,completed:c.progress>=100}))}},[n]),a}function At({deps:t=[],setLoading:n=()=>{}}={}){const{blocklet:a}=M(),[s,r]=b.useState([]),{api:o}=N(),c=b.useCallback(je(async()=>{if(!o||!a?.meta?.did){r([]);return}try{n(!0);const i=E(),d=i.subtract(1,"year"),{summary:l}=await o.getBlockletBackupSummary({input:{did:a.meta.did,startTime:d.toISOString(),endTime:i.toISOString()}}),x=Array.isArray(l)?l.map(p=>({...p,successCount:+p.successCount,errorCount:+p.errorCount})):[];r(x)}catch(i){console.error("Failed to fetch backup summary:",i),D.error(Q(i)),r([])}finally{n(!1)}},1e3),[]);return ke(async()=>(await c(),()=>{c.cancel()}),[a?.meta?.did].concat(t)),{backupSummary:s}}const Ee=b.createContext({}),{Provider:Ut,Consumer:$s}=Ee;function Te({children:t}){const{t:n}=B(),{api:a}=N(),{blocklet:s}=M(),[r,o]=b.useState(null),[c,i]=b.useState(!1),{data:d,loading:l,mutate:x}=Lt({refresh:c}),p=pt(d),f=Pt({appDid:s?.appDid}),u=b.useMemo(()=>bt(s?.environments),[s?.environments]),[k,w]=b.useState(!1),[S,y]=b.useState(0),{backups:Z}=Be({deps:[S,r],setLoading:w,backupDate:r}),[ee,te]=b.useState(0),{backupSummary:se}=At({deps:[ee]}),[_,A]=b.useState(d?.find(g=>g.endpoint===u)),T=s?.settings?.autoBackup,v=()=>{i(g=>!g)},oe=()=>{te(g=>g+1)},ne=()=>{y(g=>g+1)},F=async g=>{await a.updateAutoBackup({input:{did:s.meta.did,autoBackup:g}})},X=async()=>{await a.abortBlockletBackup({input:{appPid:s.meta.did}})},ae=async(g,O)=>{try{x(R=>{const z=[...R];return z.push({...g,loading:!0}),z}),await a.addBlockletSpaceGateway({input:{did:s.meta.did,spaceGateway:g}}),u!==O&&await a.configBlocklet({input:{did:[s.meta.did],configs:[{key:U.BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_APP_BACKUP_ENDPOINT,value:O}]}}),A(g),v(),D.success(n("storage.spaces.connectedWithName",{name:g?.name??"DID Spaces"}))}catch(R){throw console.error(R),x(z=>[...z].filter(W=>W.did!==g.did)),R}},re=async g=>{g&&(g.endpoint===u&&(await a.configBlocklet({input:{did:[s.meta.did],configs:[{key:U.BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_APP_BACKUP_ENDPOINT,value:""}]}}),T?.enabled&&await F({enabled:!1})),await a.deleteBlockletSpaceGateway({input:{did:s.meta.did,spaceGatewayDid:g?.did}}),x(O=>{const R=[...O];return R.splice(R.indexOf(g),1),R}),A(g),v())},ie=async g=>{await Promise.all([a.updateBlockletSpaceGateway({input:{did:s.meta.did,where:{did:g.did},spaceGateway:g}}),u!==g.endpoint&&a.configBlocklet({input:{did:[s.meta.did],configs:[{key:U.BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_APP_BACKUP_ENDPOINT,value:g.endpoint}]}})]),D.success(n("storage.spaces.connectedWithName",{name:g?.name??"DID Spaces"})),v()},C=g=>g?.endpoint===u;return e.jsx(Ut,{value:{spaceGateways:d||[],selectedSpaceGateway:_,addSpaceGateway:ae,deleteSpaceGateway:re,updateSpaceGateway:ie,refreshSpaceGateways:v,spaceGatewaysLoading:l,spaceGatewaysFirstLoading:p,spaceGatewayIsSelected:C,updateAutoBackup:F,abortBlockletBackup:X,backupEndpoint:u,backupProgress:f,backups:Z,backupSummary:se,refreshBackupSummary:oe,refreshBackups:ne,setBackupDate:o,backupsLoading:k,autoBackup:T},children:t})}Te.propTypes={children:m.any.isRequired};function P(){return b.useContext(Ee)}function Ie({...t}){const{blocklet:n}=M(),{info:a}=N(),{t:s}=B(),r=De({blocklet:n}),o=tt(a),{spaceGateways:c,addSpaceGateway:i}=P(),d={checkFn:Ce.create({baseURL:me(window.location.origin,st())}).get,webWalletUrl:o,extraParams:{appPid:n.appPid,appDid:r.appDid,appName:r.appName,appDescription:r.appDescription,appUrl:r.appUrl,referrer:r.referrer,scopes:r.scopes,nodeDid:a.did}},l=async({endpoint:p,name:f,did:u})=>{const k=await kt(p);if(!await jt(k)){D.error(s("storage.spaces.gateway.add.invalidUrl"));return}if(c.some(y=>y.endpoint===p)){D.error(s("storage.spaces.gateway.add.duplicate",{name:f}));return}await i({name:f,did:u,url:k,endpoint:p},p)},x=async({spaceGateway:p})=>{try{await l(p)}catch(f){console.error(f),D.error(Q(f))}};return e.jsx(ut,{...t,connectScope:"app",options:d,onSuccess:x})}function Re({...t}){const{t:n}=b.useContext(at),{blocklet:a,loading:s}=Et();if(a?.diskInfo){const r=(i,d,l)=>e.jsxs(j,{children:[i," ",e.jsx("strong",{children:d?ot(d):"empty"})]}),o=a.environments.reduce((i,d)=>(i[d.key]=d.value,i),{}),c=[{key:"appDir",name:n("blocklet.diskInfo.appDir"),value:r(o.BLOCKLET_APP_DIR,a.diskInfo.app)},{key:"dataDir",name:n("blocklet.diskInfo.dataDir"),value:r(o.BLOCKLET_DATA_DIR,a.diskInfo.data)},{key:"logDir",name:n("blocklet.diskInfo.logDir"),value:r(o.BLOCKLET_LOG_DIR,a.diskInfo.log)},{key:"cacheDir",name:n("blocklet.diskInfo.cacheDir"),value:r(o.BLOCKLET_CACHE_DIR,a.diskInfo.cache)}];return e.jsx(Mt,{component:"div",...t,children:c.map(i=>e.jsx(Bt,{valueComponent:"div",nameWidth:120,name:i.name,children:i.value},i.key))})}return s?e.jsx(L,{}):e.jsx(j,{children:n("blocklet.diskInfo.empty")})}const Mt=Ne(j)``;function ve(){const{t}=B(),{setBackupDate:n,backupSummary:a}=P(),s=mt({key:"lg"}),r=b.useRef(null),o=_e(),c=b.useCallback(l=>{n(l)},[n]),i=b.useMemo(()=>{const l=E().add(1,"day"),x=l.subtract(1,"year"),p=new Map(a.map(u=>[u.date,{date:u.date,successCount:u.successCount,errorCount:u.errorCount}])),f=[];for(let u=x.clone();E(u).isBefore(l);u=u.add(1,"day")){const k=u.format("YYYY-MM-DD");f.push(p.get(k)||{date:k,successCount:0,errorCount:0})}return f},[a]),d=b.useMemo(()=>({grid:{containLabel:!0,right:10,top:30,bottom:12},tooltip:{formatter:k=>{const{date:w,successCount:S,errorCount:y}=i[k.dataIndex]||{date:k.data[0],successCount:0,errorCount:0};return[`<div>${t("common.time")}: ${w}</div>`,`<div>${t("common.succeeded")}: ${S}</div>`,`<div>${t("common.failed")}: ${y}</div>`].join(`
2
2
  `)},backgroundColor:o.palette.background.paper,borderColor:o.palette.divider,textStyle:{color:o.palette.text.primary,fontSize:14},extraCssText:`box-shadow: ${o.shadows[2]}; border-radius: 4px;`,padding:[8,10]},visualMap:{show:!1,min:-12,max:12,pieces:[{min:Number.MIN_SAFE_INTEGER,max:-9,color:V[600]},{min:-9,max:-6,color:V[500]},{min:-6,max:-3,color:V[400]},{min:-3,max:-1,color:V[300]},{min:0,max:0,color:o.palette.grey[200]},{min:1,max:3,color:J[300]},{min:3,max:6,color:J[400]},{min:6,max:9,color:J[500]},{min:9,max:Number.MAX_SAFE_INTEGER,color:J[600]}],orient:"horizontal",left:"center",bottom:12,itemWidth:12,itemHeight:12,textStyle:{color:o.palette.text.secondary,fontSize:12}},calendar:{top:30,left:50,right:10,bottom:4,cellSize:[8,8],splitLine:{show:!1},itemStyle:{borderWidth:2,borderColor:o.palette.background.default,color:o.palette.background.default},dayLabel:{show:!0,firstDay:0,nameMap:["","Mon","","Wed","","Fri",""],position:"start",margin:4,fontSize:10,color:o.palette.text.primary,fontWeight:"400",width:20},monthLabel:{show:!0,nameMap:"cn",align:"left",color:o.palette.text.primary,fontWeight:"400",fontSize:12,position:"start",margin:4,width:30,padding:[0,2]},yearLabel:{show:!1},range:[E().subtract(11,"month").startOf("month").format("YYYY-MM-DD"),E().endOf("month").format("YYYY-MM-DD")],orient:"horizontal"},series:{type:"heatmap",coordinateSystem:"calendar",data:i.map(k=>[k.date,k.errorCount?-k.errorCount:k.successCount]),label:{show:!1},itemStyle:{borderWidth:2,borderColor:o.palette.background.default,borderRadius:4},emphasis:{itemStyle:{borderWidth:2,borderColor:We[200],color:"inherit"}}}}),[i,t,o]);return e.jsxs(e.Fragment,{children:[e.jsx(h,{ref:r,sx:{maxWidth:"1280px",border:"1px solid",borderColor:"divider",padding:"8px",overflowX:"auto"},children:e.jsx(h,{sx:{width:"1200px",height:"180px",position:"relative"},children:e.jsx(Tt,{option:d,style:{height:"100%",width:"100%"},notMerge:!0,lazyUpdate:!1,opts:{renderer:"canvas"},onEvents:{click:l=>{l.componentType==="series"&&l.data&&c(l.data[0])}}})})}),e.jsx(h,{sx:{display:"flex",justifyContent:"flex-end",mt:1,mr:s?2:5,mb:2},children:e.jsxs(G,{direction:s?"column":"row",spacing:s?2:1,sx:{width:"100%",justifyContent:"flex-start",alignItems:s?"flex-start":"center"},children:[e.jsxs(G,{direction:"row",spacing:1,sx:{alignItems:"center"},children:[e.jsx(h,{sx:{width:32,height:12,borderRadius:.5,background:"linear-gradient(90deg, #8B5000 0%, #A36200 33%, #C17700 66%, #E29000 100%)"}}),e.jsx(j,{variant:"body2",sx:{color:"text.secondary"},children:t("storage.spaces.backup.failed")})]}),e.jsxs(G,{direction:"row",spacing:1,sx:{alignItems:"center"},children:[e.jsx(h,{sx:{width:32,height:12,borderRadius:.5,bgcolor:"grey.200",border:"1px solid",borderColor:"grey.200"}}),e.jsx(j,{variant:"body2",sx:{color:"text.secondary"},children:t("storage.spaces.backup.without")})]}),e.jsxs(G,{direction:"row",spacing:1,sx:{alignItems:"center"},children:[e.jsx(h,{sx:{width:32,height:12,borderRadius:.5,background:"linear-gradient(90deg, #9be9a8 0%, #40c463 33%, #30a14e 66%, #216e39 100%)"}}),e.jsx(j,{variant:"body2",sx:{color:"text.secondary"},children:t("storage.spaces.backup.succeeded")})]})]})})]})}const Nt=fe(({className:t,...n})=>e.jsx(ge,{...n,classes:{popper:t}}))(()=>({".MuiTooltip-tooltip":{backgroundColor:"transparent",padding:0,margin:0,boxShadow:"none",maxWidth:"none"},".MuiTooltip-arrow":{color:"rgba(230, 235, 245, 1)"}}));function ze({status:t,message:n="",createdAt:a}){const{t:s}=B(),r=t===I.STATUS.PROGRESS&&E().diff(a,"hours")>=I.TIMEOUT_HOURS,o=r&&s("common.timeoutError"),c=t===I.STATUS.PROGRESS&&!r,i=t===I.STATUS.SUCCEEDED&&!r;return c?e.jsxs(j,{sx:{display:"inline-flex",alignItems:"center",fontSize:"14px"},children:[e.jsx(L,{sx:{marginRight:"4px"},size:"12px"}),s("common.progress")]}):i?e.jsx(q,{type:"success",children:s("common.succeeded")}):e.jsxs(h,{sx:{display:"inline-flex",alignItems:"center"},children:[e.jsx(q,{type:"error",children:s("common.failed")}),e.jsx(ge,{style:{display:"flex",alignItems:"center",flexShrink:0},title:n||o,children:e.jsx(be,{children:e.jsx(Ye,{style:{width:"24px",height:"24px"},color:"error"})})})]})}ze.propTypes={status:m.string.isRequired,message:m.string,createdAt:m.string.isRequired};function Oe({metadata:t={}}){const{t:n}=B();if(H(t))return e.jsx(q,{type:"success",children:n("common.succeeded")});const a=t.count||0,s=t.size||0,r=It(s,{iec:!0}),o=e.jsxs(h,{sx:{p:1,borderRadius:1,boxShadow:2,color:"black",backgroundColor:"white"},children:[e.jsxs(j,{variant:"body2",children:[n("common.fileCount"),": ",a]}),e.jsxs(j,{variant:"body2",children:[n("common.fileSize"),": ",r]})]});return e.jsxs(h,{sx:{display:"inline-flex",alignItems:"center"},children:[e.jsx(q,{type:"success",children:n("common.succeeded")}),e.jsx(Nt,{title:o,style:{display:"flex",alignItems:"center",flexShrink:0},placement:"left",children:e.jsx(be,{children:e.jsx(Fe,{style:{width:"24px",height:"24px"},color:"primary"})})})]})}Oe.propTypes={metadata:m.object};function Le(){const{t,locale:n}=B(),{spaceGateways:a,backups:s,backupsLoading:r}=P(),o=b.useMemo(()=>[{label:"DID Space",name:"target",options:{customBodyRenderLite:i=>{const{targetUrl:d,targetName:l,status:x,createdAt:p}=s[i],f=x===I.STATUS.PROGRESS&&E().diff(p,"hours")>=I.TIMEOUT_HOURS,u=x===I.STATUS.SUCCEEDED&&!f,k=l||a.find(w=>d?.includes(xe(w?.endpoint)))?.name||"Unknown DID Space";return u?e.jsx(Ge,{href:d,target:"_blank",sx:{fontSize:"16px"},children:k}):e.jsx(j,{variant:"body1",sx:{fontSize:"16px"},children:k})}}},{label:t("common.strategy"),name:"strategy",options:{customBodyRender:i=>{const d=t(i===0?"common.auto":"common.manual");return e.jsx(q,{children:d})}}},{label:t("common.startTime"),name:"createdAt",options:{customBodyRender:i=>E(i).format("YYYY-MM-DD HH:mm:ss")}},{label:t("common.endTime"),name:"updatedAt",options:{customBodyRender:i=>H(i)?"":E(i).format("YYYY-MM-DD HH:mm:ss")}},{label:t("common.status"),name:"status",options:{customBodyRenderLite:i=>{const d=s?.[i]??{},{status:l,message:x,createdAt:p,metadata:f}=d,u=l===I.STATUS.PROGRESS&&E().diff(p,"hours")>=I.TIMEOUT_HOURS,k=l===I.STATUS.PROGRESS&&!u,w=l===I.STATUS.SUCCEEDED&&!u;return k?e.jsxs(j,{sx:{display:"inline-flex",alignItems:"center",fontSize:"14px"},children:[e.jsx(L,{sx:{marginRight:"4px"},size:"12px"}),t("common.progress")]}):w?e.jsx(Oe,{metadata:f}):e.jsx(ze,{status:l,message:x,createdAt:p})}}}],[s,a,t]),c=b.useMemo(()=>!s?.length,[s]);return e.jsx(e.Fragment,{children:c?e.jsx(h,{sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"100px",color:"#9397A1",marginTop:"16px",marginBottom:"24px"},children:t("storage.spaces.record.emptyData")}):e.jsx(rt,{title:"",loading:r,data:s,columns:o,emptyNode:t("storage.spaces.record.emptyData",n),options:{download:!1,filter:!1,print:!1,search:!1,viewColumns:!1}})})}function _t(){const{t}=B();return e.jsxs(h,{children:[e.jsxs(h,{sx:{display:"flex",gap:3,flexDirection:{xs:"column",md:"row"}},children:[e.jsxs(h,{sx:{display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",alignContent:"center",minWidth:240},children:[e.jsx(xt,{style:{cursor:"pointer",width:"150px",height:"100%",maxHeight:160}}),e.jsx(j,{sx:{my:2,textAlign:"center",color:"text.secondary"},children:t("storage.spaces.connect.provider")}),e.jsx(Ie,{})]}),e.jsxs(h,{sx:{flexGrow:1,minWidth:0},children:[e.jsx(h,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:3},children:e.jsx(j,{sx:{fontSize:"1.2rem",fontWeight:"bold"},children:t("storage.spaces.backup.records")})}),e.jsx(ve,{})]})]}),e.jsx(Le,{sx:{marginTop:"24px"}}),e.jsx(j,{sx:{fontSize:"1.2rem",fontWeight:"bold",mb:2,mt:2},children:t("common.dataStorage")}),e.jsx(Re,{})]})}function Pe({spaceGateway:t,onConfirm:n=()=>{},onCancel:a=()=>{}}){const{t:s}=B(),[r,o]=b.useState(!1),[c,i]=b.useState(!1),d=(p,f)=>{p?.preventDefault(),p?.stopPropagation(),o(f)},l=async p=>{try{p?.stopPropagation(),i(!0),await n?.(t),o(!1)}catch(f){console.error(f),D.error(`${s("storage.space.gateway.delete.failed")}: ${Q(f)}`)}finally{o(!1),i(!1)}},x=p=>{d(p,!1),a?.(p)};return e.jsxs(e.Fragment,{children:[e.jsxs(Y,{color:"red",onClick:p=>d(p,!0),children:[e.jsx(K,{style:{minWidth:24,color:"red"},children:e.jsx(Ke,{fontSize:"small"})}),e.jsx($,{style:{color:"red"},children:s("common.disconnect")})]}),e.jsx(it,{title:s("storage.spaces.gateway.delete.title"),open:r,confirmButton:{text:s("common.confirm"),props:{size:"small",variant:"contained",color:"error",loading:c}},cancelButton:{text:s("common.cancel"),props:{size:"small",variant:"outlined",disabled:c}},onConfirm:l,onCancel:x,children:e.jsx(j,{sx:{wordWrap:"break-word"},children:s("storage.spaces.gateway.delete.descForBackup",{name:`${t?.name}`})})})]})}Pe.propTypes={spaceGateway:m.shape({name:m.string.isRequired,url:m.string.isRequired,protected:m.bool}).isRequired,onConfirm:m.func,onCancel:m.func};function Ae({spaceGateway:t,selected:n,onDelete:a=()=>{},onConnect:s=()=>{},enableSwitchToSpace:r=!0,backupInProgress:o=!1,...c}){const{abortBlockletBackup:i}=P(),[d,l]=b.useState(null),{t:x}=B(),[p,f]=b.useState(!1),u=(S,y)=>{S.stopPropagation(),S.preventDefault(),l(y&&S.currentTarget)},k=async S=>{try{f(!0),u(S,!1),await s(t)}catch(y){console.error(y),D.error(y.message)}finally{f(!1)}},w=async S=>{try{f(!0),u(S,!1),await i()}catch(y){console.error(y),D.error(y.message)}finally{f(!1)}};return e.jsxs(e.Fragment,{children:[p||t?.loading?e.jsx(L,{sx:{ml:1},size:"24px"}):e.jsx($e,{"aria-label":"more","aria-controls":"actions-menu","aria-haspopup":"true","data-cy":"trigger-blocklet-actions",variant:"outlined",size:"small",onClick:S=>u(S,!0),...c,children:e.jsx(qe,{})}),e.jsxs(He,{id:"simple-menu",anchorEl:d,keepMounted:!0,open:!!d,onClose:S=>u(S,!1),children:[e.jsxs(Y,{onClick:S=>{u(S,!1),window.open(Se(t.endpoint?Ct(t.endpoint):t.url,{allowDomains:null}))},children:[e.jsx(K,{style:{minWidth:24},children:e.jsx(Qe,{fontSize:"small"})}),e.jsx($,{children:x("common.open")})]}),e.jsxs(Y,{onClick:S=>{u(S,!1),window.open(Se(wt(t.endpoint),{allowDomains:null}))},children:[e.jsx(K,{style:{minWidth:24},children:e.jsx(Xe,{fontSize:"small"})}),e.jsx($,{children:x("storage.spaces.strategy.viewBackupFiles")})]}),!n&&r&&e.jsxs(Y,{onClick:k,children:[e.jsx(K,{style:{minWidth:24},children:e.jsx(Ve,{fontSize:"small"})}),e.jsx($,{children:x("storage.spaces.connect.switchToSpace")})]}),o&&e.jsxs(Y,{onClick:w,children:[e.jsx(K,{style:{minWidth:24},children:e.jsx(Je,{fontSize:"small"})}),e.jsx($,{children:x("storage.spaces.connect.abortBlockletBackup")})]}),!o&&e.jsx(Pe,{spaceGateway:t,onConfirm:async()=>{l(null),await a?.(t)},onCancel:()=>l(null)})]})]})}Ae.propTypes={spaceGateway:m.shape({name:m.string.isRequired,url:m.string.isRequired,protected:m.bool,endpoint:m.string.isRequired,loading:m.bool}).isRequired,selected:m.bool.isRequired,enableSwitchToSpace:m.bool,onDelete:m.func,onConnect:m.func,backupInProgress:m.bool};const Wt=fe(({className:t,...n})=>e.jsx(ge,{...n,classes:{popper:t}}))(()=>({".MuiTooltip-tooltip":{backgroundColor:"transparent",padding:0,margin:0,boxShadow:"none",maxWidth:"none"},".MuiTooltip-arrow":{color:"rgba(230, 235, 245, 1)"}}));function Ue({spaceGateway:t,spaceStatus:n,selected:a,onConnected:s=()=>{},onDeleted:r=()=>{},onBackedUp:o=()=>{}}){const{t:c,locale:i}=B(),{blocklet:d}=M(),{api:l,info:{did:x}}=N(),{appDid:p,appName:f,appDescription:u,scopes:k,appUrl:w,referrer:S}=De({blocklet:d}),{backupProgress:y,updateSpaceGateway:Z,deleteSpaceGateway:ee,refreshBackupSummary:te,refreshBackups:se}=P(),[_,A]=b.useState(!1),[T,v]=b.useState({open:!1,action:"one-click-authorization",checkTimeout:1e3*300,messages:{title:c("storage.spaces.authorize.title",{appName:f},i),scan:c("storage.spaces.authorize.scan",{appName:f},i),confirm:"",success:e.jsx(j,{gutterBottom:!0,children:c("storage.spaces.authorize.success")})},onClose:()=>{v(C=>({...C,open:!1}))}}),oe=a&&!_&&n===de.DISCONNECTED,ne=a&&!_&&!t.loading&&n===de.CONNECTED,F=a&&_&&n===de.CONNECTED&&y?.progress>=0,X=async()=>{try{if(await Dt(t?.endpoint)){await l.configBlocklet({input:{did:[d.meta.did],configs:[{key:U.BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_APP_BACKUP_ENDPOINT,value:t.endpoint}]}}),D.success(c("storage.spaces.connect.switchToSpaceSucceeded",{name:t.name?`(${t.name})`:""})),s?.(null,t);return}}catch(C){console.error(C),s?.(C,t);return}v(C=>({...C,open:!0,prefix:me(t.url,"space/api/did"),baseUrl:new URL(t.url).origin,checkFn:Ce.create({baseURL:me(t.url,"space")}).get,extraParams:{appDid:p,appName:f,appDescription:u,scopes:k,appUrl:w,referrer:S,nodeDid:x,spaceDid:t.did}}))},ae=async(C,g)=>{const O=g(C.endpoint),R=xe(O),z=C.space?g(C.space):{};if(t.did&&R!==t.did){v(Me=>({...Me,open:!1}));const W=c("storage.spaces.gateway.switch.failedForMismatchSpace",{name:z?.name?z.name:""});D.error(W),s?.(new Error(W),t);return}const ce={...t,name:z.name??"DID Space",did:z.did??xe(O),endpoint:O};await Z(ce),v(W=>({...W,open:!1})),s?.(null,ce)},re=async()=>{try{if(_)return;A(!0),await l.backupBlocklet({input:{appDid:d.appDid,to:"spaces"}})}catch(C){console.error(C),D.error(C.message),o?.(C,t)}finally{A(!0)}},ie=async()=>{try{await ee(t),D.success(c("storage.spaces.gateway.delete.succeeded",{name:t.name?`(${t.name})`:""})),r?.(null,t)}catch(C){console.error(C),r?.(C,t)}};return b.useEffect(()=>{y?.completed?(a&&(y?.progress===100?(D.success(c("storage.spaces.backupSuccessfully")),o?.(null,t)):y.message&&o?.(new Error(y?.message),t),y.progress=0,y.message=""),A(!1),te(),se()):y.progress&&A(!0)},[y]),e.jsxs(e.Fragment,{children:[e.jsxs(h,{sx:{display:"flex",alignItems:"center",".action-btn":{borderRadius:1,marginLeft:1}},children:[ne&&e.jsx(le,{className:"action-btn",variant:"outlined",size:"small",onClick:re,children:c("storage.spaces.strategy.backupNow")}),oe&&e.jsx(le,{className:"action-btn",variant:"outlined",size:"small",onClick:X,children:c("storage.spaces.disconnected.reconnectNow")}),F&&e.jsx(Wt,{title:y?.message&&e.jsx(h,{sx:{p:1,borderRadius:1,boxShadow:2,color:"black",backgroundColor:"white"},children:e.jsx(j,{variant:"body2",children:y.message})}),children:e.jsxs(le,{className:"action-btn",variant:"outlined",size:"small",sx:{minWidth:70},children:[e.jsx(L,{variant:"determinate",value:y?.progress,size:14,sx:{mr:1}}),y?.progress,"%"]})}),e.jsx(nt,{forceConnected:!1,saveConnect:!1,prefix:T.prefix,open:T.open,popup:!0,action:T.action,baseUrl:T.baseUrl,checkFn:T.checkFn,onSuccess:ae,onClose:T.onClose,checkTimeout:T.checkTimeout,extraParams:T.extraParams,messages:T.messages,locale:i},"get-endpoint")]}),e.jsx(Ae,{sx:{minWidth:32,padding:"2px 4px",ml:1},spaceGateway:t,selected:a,onDelete:ie,onConnect:X,enableSwitchToSpace:y?.completed||H(y?.message),backupInProgress:F})]})}Ue.propTypes={spaceGateway:m.shape({did:m.string.isRequired,name:m.string.isRequired,url:m.string.isRequired,endpoint:m.string.isRequired,protected:m.bool,loading:m.bool}).isRequired,spaceStatus:m.string.isRequired,selected:m.bool.isRequired,onConnected:m.func,onDeleted:m.func,onBackedUp:m.func};function Gt({...t}){const{t:n}=B();return e.jsxs(h,{...t,children:[e.jsx(h,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:3},children:e.jsx(j,{sx:{fontSize:"1.2rem",fontWeight:"bold"},children:n("storage.spaces.backup.records")})}),e.jsx(ve,{}),e.jsx(Le,{})]})}function Ft({...t}){const{t:n}=B(),{autoBackup:a,updateAutoBackup:s}=P(),r=async()=>{try{const o=!a?.enabled;await s({enabled:o}),D.success(n(o?"storage.spaces.autoBackup.enabled":"storage.spaces.autoBackup.disabled"))}catch(o){D.error(o.message)}};return e.jsx(Rt,{checked:!!a?.enabled,onChange:r,name:"enableWelcomePage",labelProps:{label:e.jsx(j,{sx:{marginRight:"8px"},children:e.jsx("span",{children:n("storage.spaces.autoBackup.title")})})},style:{...t.style}})}function Yt(){const{t}=B(),{spaceGateways:n,spaceGatewaysLoading:a,spaceGatewayIsSelected:s}=P(),r=a&&!n?.length,o=({spaceGateway:c,spaceStatus:i,selected:d,refresh:l})=>e.jsx(Ue,{spaceGateway:c,spaceStatus:i,selected:d,onConnected:()=>l(),onBackedUp:x=>x&&l()});return e.jsxs(h,{sx:{display:"flex",flexDirection:"column"},children:[e.jsxs(h,{sx:{display:"flex",flexDirection:{xs:"column",md:"row"},gap:{xs:1,md:2},justifyContent:{xs:"center",md:"flex-start"},alignItems:{xs:"flex-start",md:"center"}},children:[e.jsx(j,{sx:{fontSize:"1.2rem",fontWeight:"bold",flexGrow:1},children:t("storage.spaces.connected.title")}),e.jsx(Ft,{}),e.jsx(Ie,{})]}),e.jsx(h,{sx:{mt:2},children:r?e.jsx(h,{sx:{display:"flex",justifyContent:"center"},children:e.jsx(L,{})}):e.jsx(he,{container:!0,spacing:2,children:e.jsx(e.Fragment,{children:n.map(c=>e.jsx(he,{size:{xs:12,md:6},children:e.jsx(ft,{endpoint:c.endpoint,selected:s(c),action:o},c.endpoint)},c.endpoint))})})}),e.jsx(Gt,{sx:{marginTop:"24px"}}),e.jsx(j,{sx:{fontSize:"1.2rem",fontWeight:"bold",mb:2},children:t("common.dataStorage")}),e.jsx(Re,{})]})}function Kt(){const{spaceGatewaysFirstLoading:t,spaceGateways:n}=P();return t?e.jsx(we,{relative:"parent",children:e.jsx(L,{})}):H(n)?e.jsx(_t,{}):e.jsx(Yt,{})}function $t(){return e.jsx(Te,{children:e.jsx(Kt,{})})}function qt(){const{spaceGateway:t,settingStorageEndpoint:n,updateSpaceGateway:a,hasStorageEndpoint:s,loading:r,storageEndpoint:o}=zt(),c=ue(()=>({display:"flex",alignItems:"center",justifyContent:"center",paddingTop:"16px"}));return r?e.jsx(we,{relative:"parent",children:e.jsx(L,{})}):e.jsxs(h,{sx:{maxWidth:"md",position:"relative"},children:[s?e.jsx(gt,{spaceGateway:t,settingStorageEndpoint:n}):e.jsx(ht,{}),e.jsx(h,{sx:c,children:e.jsx(St,{onConnect:a,storageEndpoint:o})})]})}function Ht(){const{t}=B();return e.jsxs(vt,{children:[e.jsxs(G,{spacing:1,sx:{marginBottom:2},children:[e.jsx(j,{sx:{fontSize:"1.2rem",fontWeight:"bold"},children:t("storage.appLevel.title")}),e.jsx(j,{sx:{color:"text.secondary"},children:t("storage.appLevel.description")})]}),e.jsx(qt,{})]})}function Qt({navOrientation:t="vertical",...n}){const{t:a,locale:s}=B(),{blocklet:r}=M(),o=lt({key:"md"}),[c,i]=et(),d=c.get("tab")||"backup",l=o?"horizontal":t,x=ue(()=>{const w=[{label:a("common.backup"),value:"backup"}],S=r?.capabilities?.didSpace;return(S===U.BLOCKLET_APP_SPACE_REQUIREMENT.REQUIRED||S===U.BLOCKLET_APP_SPACE_REQUIREMENT.REQUIRED_ON_SETUP)&&w.push({label:a("common.storage"),value:"storage"}),w},[s,l]),f=ue(()=>({backup:e.jsx($t,{}),storage:e.jsx(Ht,{})}))[d],u=w=>{i(S=>(w==="backup"?S.delete("tab"):S.set("tab",w),S))};if(x.length<=1)return e.jsx(pe,{children:f});const k=e.jsx(ct,{tabs:x,current:d,orientation:l,onChange:u,sx:[{borderRight:1,height:"100%",borderColor:"divider"},l==="horizontal"&&{borderRight:0}]});if(l==="vertical")return e.jsx(h,{...n,children:e.jsxs(G,{direction:{md:"column",lg:"row"},sx:{gap:2},children:[e.jsx(h,{sx:{flexShrink:0},children:e.jsx(ye,{left:k})}),e.jsx(h,{sx:{flexGrow:1,minWidth:0},children:e.jsx(pe,{sx:{mt:1},children:f})})]})});if(l==="horizontal")return e.jsxs(h,{...n,children:[e.jsx(ye,{left:k}),e.jsx(pe,{sx:{mt:2},children:f})]})}Qt.propTypes={navOrientation:m.oneOf(["vertical","horizontal"])};const pe=fe(h)`
3
3
  position: relative;
4
4
  min-height: 66vh;
@@ -1 +1 @@
1
- import{r as p}from"./vendor-react-DX7tU9aY.js";import{j as a,z as b,X as t,A,M as E,al as I}from"./vendor-mui-core-CDEc-eG6.js";import{a as j}from"./vendor-hooks-Ca2cSNuD.js";import{M as r}from"./index-DcM4ljaV.js";import{aa as y}from"./vendor-ux-PO0jFgJf.js";import{t as C}from"./arrow-down.svg-Dz9H9vM-.js";import{L as O,D as H}from"./vendor-mui-x-Bk3pxGrO.js";import{A as R}from"./AdapterDayjs-DtK6vYWP.js";function v({value:n=null,onChange:i,error:l=!1,helperText:c="",label:h="",timezone:e="",minDateTime:f=null}){const d=j(()=>{let s=r();return n&&(s=e?r(n).tz(e):r(n)),s},[n,e]),m=s=>{const T=e?r(s).tz(e):r(s);i(new Date(T.format("YYYY-MM-DD HH:mm:00")))};return a.jsx(O,{dateAdapter:R,children:a.jsx(b,{fullWidth:!0,error:l,children:a.jsx(H,{label:h,minDateTime:f,value:d,onChange:m,slotProps:{textField:{error:l,helperText:l?c:""}},format:"YYYY-MM-DD HH:mm"})})})}v.propTypes={value:t.oneOfType([t.string,t.instanceOf(Date)]),onChange:t.func.isRequired,error:t.bool,helperText:t.string,label:t.string,timezone:t.string,minDateTime:t.instanceOf(Date)};function U(n){return a.jsx(C,{...n,width:20,height:20})}const u={MINUTES_30:1800*1e3,HOUR_1:3600*1e3,HOURS_3:10800*1e3,DAY_1:1440*60*1e3,DAYS_7:10080*60*1e3,DAYS_30:720*60*60*1e3};function $({placeholder:n="",value:i="",onChange:l,timezone:c="",showError:h=!0}){const{t:e}=y(),[f,d]=p.useState(i||""),[m,s]=p.useState(null),[T,M]=p.useState(null),x=p.useMemo(()=>[{value:u.MINUTES_30,label:`30 ${e("common.minutes")}`},{value:u.HOUR_1,label:`1 ${e("common.hour")}`},{value:u.HOURS_3,label:`3 ${e("common.hours")}`},{value:u.DAY_1,label:`1 ${e("common.day")}`},{value:u.DAYS_7,label:`7 ${e("common.days")}`},{value:u.DAYS_30,label:`30 ${e("common.days")}`},{value:"custom",label:e("common.custom")}],[e]),Y=o=>{if(d(o),o==="custom"){const D=c?r().tz(c):r(),S=D.add(1,"day").toDate();M(D),s(S),l(S)}else l(new Date(Date.now()+o))},_=o=>{s(o),l(o)};p.useEffect(()=>{i&&(x.find(D=>r(D.value).isSame(i))||(d("custom"),s(i)))},[]);const g=j(()=>h?!!(!m||r(m).isBefore(r())):!1,[m,e]);return a.jsxs(a.Fragment,{children:[a.jsx(b,{fullWidth:!0,children:a.jsx(A,{select:!0,value:f,label:n||e("team.passport.passportExpireTime"),onChange:o=>Y(o.target.value),variant:"outlined",slotProps:{select:{IconComponent:U}},sx:{"& .MuiInputLabel-root":{width:"calc(100% - 46px)"}},children:x.map(o=>a.jsx(E,{value:o.value,children:o.label},o.value))})}),f==="custom"&&a.jsx(I,{children:a.jsx(v,{value:m,onChange:_,label:e("team.passport.customExpireTime"),timezone:c,error:!!g,helperText:g?e("team.passport.customExpireTimeIsInvalid"):void 0,minDateTime:T})})]})}$.propTypes={value:t.oneOfType([t.string,t.instanceOf(Date)]),onChange:t.func.isRequired,timezone:t.string,placeholder:t.string,showError:t.bool};export{$ as T};
1
+ import{r as p}from"./vendor-react-DX7tU9aY.js";import{j as a,z as b,X as t,A,M as E,al as I}from"./vendor-mui-core-CDEc-eG6.js";import{a as j}from"./vendor-hooks-Ca2cSNuD.js";import{M as r}from"./index-CgSpL7jz.js";import{aa as y}from"./vendor-ux-PO0jFgJf.js";import{t as C}from"./arrow-down.svg-Dz9H9vM-.js";import{L as O,D as H}from"./vendor-mui-x-Bk3pxGrO.js";import{A as R}from"./AdapterDayjs-DtK6vYWP.js";function v({value:n=null,onChange:i,error:l=!1,helperText:c="",label:h="",timezone:e="",minDateTime:f=null}){const d=j(()=>{let s=r();return n&&(s=e?r(n).tz(e):r(n)),s},[n,e]),m=s=>{const T=e?r(s).tz(e):r(s);i(new Date(T.format("YYYY-MM-DD HH:mm:00")))};return a.jsx(O,{dateAdapter:R,children:a.jsx(b,{fullWidth:!0,error:l,children:a.jsx(H,{label:h,minDateTime:f,value:d,onChange:m,slotProps:{textField:{error:l,helperText:l?c:""}},format:"YYYY-MM-DD HH:mm"})})})}v.propTypes={value:t.oneOfType([t.string,t.instanceOf(Date)]),onChange:t.func.isRequired,error:t.bool,helperText:t.string,label:t.string,timezone:t.string,minDateTime:t.instanceOf(Date)};function U(n){return a.jsx(C,{...n,width:20,height:20})}const u={MINUTES_30:1800*1e3,HOUR_1:3600*1e3,HOURS_3:10800*1e3,DAY_1:1440*60*1e3,DAYS_7:10080*60*1e3,DAYS_30:720*60*60*1e3};function $({placeholder:n="",value:i="",onChange:l,timezone:c="",showError:h=!0}){const{t:e}=y(),[f,d]=p.useState(i||""),[m,s]=p.useState(null),[T,M]=p.useState(null),x=p.useMemo(()=>[{value:u.MINUTES_30,label:`30 ${e("common.minutes")}`},{value:u.HOUR_1,label:`1 ${e("common.hour")}`},{value:u.HOURS_3,label:`3 ${e("common.hours")}`},{value:u.DAY_1,label:`1 ${e("common.day")}`},{value:u.DAYS_7,label:`7 ${e("common.days")}`},{value:u.DAYS_30,label:`30 ${e("common.days")}`},{value:"custom",label:e("common.custom")}],[e]),Y=o=>{if(d(o),o==="custom"){const D=c?r().tz(c):r(),S=D.add(1,"day").toDate();M(D),s(S),l(S)}else l(new Date(Date.now()+o))},_=o=>{s(o),l(o)};p.useEffect(()=>{i&&(x.find(D=>r(D.value).isSame(i))||(d("custom"),s(i)))},[]);const g=j(()=>h?!!(!m||r(m).isBefore(r())):!1,[m,e]);return a.jsxs(a.Fragment,{children:[a.jsx(b,{fullWidth:!0,children:a.jsx(A,{select:!0,value:f,label:n||e("team.passport.passportExpireTime"),onChange:o=>Y(o.target.value),variant:"outlined",slotProps:{select:{IconComponent:U}},sx:{"& .MuiInputLabel-root":{width:"calc(100% - 46px)"}},children:x.map(o=>a.jsx(E,{value:o.value,children:o.label},o.value))})}),f==="custom"&&a.jsx(I,{children:a.jsx(v,{value:m,onChange:_,label:e("team.passport.customExpireTime"),timezone:c,error:!!g,helperText:g?e("team.passport.customExpireTimeIsInvalid"):void 0,minDateTime:T})})]})}$.propTypes={value:t.oneOfType([t.string,t.instanceOf(Date)]),onChange:t.func.isRequired,timezone:t.string,placeholder:t.string,showError:t.bool};export{$ as T};