@abtnode/blocklet-services 1.16.44-beta-20250601-083116-288e5ea5 → 1.16.44-beta-20250603-231026-30a9d27f
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.
- package/api/index.js +14 -14
- package/api/libs/connect/session.js +1 -1
- package/api/libs/email.js +3 -1
- package/api/routes/openapi.js +1 -1
- package/api/routes/opencomponent.js +1 -1
- package/api/routes/openembed.js +1 -1
- package/api/services/dashboard/index.js +8 -0
- package/api/services/static.js +2 -1
- package/api/util/attach-shared-utils.js +5 -4
- package/dist/assets/AdapterDayjs-eMGLd9qK.js +3 -0
- package/dist/assets/{ArrowDropDown-D8DSLfND.js → ArrowDropDown-QAD1r6CI.js} +1 -1
- package/dist/assets/{CheckCircle-Dv9ESLSx.js → CheckCircle-DKl6wFCW.js} +1 -1
- package/dist/assets/{ChevronLeft-7uRDOkJ0.js → ChevronLeft-BTvoFtZ-.js} +1 -1
- package/dist/assets/{ChevronRight-DF2CPRSp.js → ChevronRight-CB-tzzK0.js} +1 -1
- package/dist/assets/{Community-BnAsVqMr.js → Community-vE_QnoqV.js} +1 -1
- package/dist/assets/{DeleteOutline-MvcW8wMe.js → DeleteOutline-D--wbiEJ.js} +1 -1
- package/dist/assets/{Done-NWTNth4h.js → Done-D5w4g3Ux.js} +1 -1
- package/dist/assets/{Download-4GZsn6dX.js → Download-CSPVh6pQ.js} +1 -1
- package/dist/assets/{Edit-rnQ_3wHK.js → Edit-Dp6PSucO.js} +1 -1
- package/dist/assets/{EditIcon-8BXW1OHp.js → EditIcon-DiM9RB8U.js} +1 -1
- package/dist/assets/{Error-RKBXSgDA.js → Error-7F2F0yXi.js} +1 -1
- package/dist/assets/{ExpandLess-DeQLEewB.js → ExpandLess-BiXZAaWu.js} +1 -1
- package/dist/assets/{Google-BFBQ7QOU.js → Google-B-pSveIB.js} +1 -1
- package/dist/assets/{Holiday-C4KRd5t6.js → Holiday-BnL2IwX3.js} +1 -1
- package/dist/assets/{Home-nxfCo0la.js → Home-BxZHmRym.js} +1 -1
- package/dist/assets/{InfoOutlined-DwH0ULaz.js → InfoOutlined-Bpx0eOkP.js} +1 -1
- package/dist/assets/{Launch-CKjiZEMR.js → Launch-akp2B3sE.js} +1 -1
- package/dist/assets/{LaunchOutlined-Mxl2EzJD.js → LaunchOutlined-BorUV5ev.js} +1 -1
- package/dist/assets/{LockIcon-DFb6sSpT.js → LockIcon-QnxDGvZv.js} +1 -1
- package/dist/assets/{Meeting-DCL_ygud.js → Meeting-BkjjPbp7.js} +1 -1
- package/dist/assets/{MoreHoriz-Bb60Z0iy.js → MoreHoriz-B0f55Tf5.js} +1 -1
- package/dist/assets/{OffSick-DvgkmCUP.js → OffSick-D2B01pyN.js} +1 -1
- package/dist/assets/{PlayArrow-DSHRafhE.js → PlayArrow-RuC30CX1.js} +1 -1
- package/dist/assets/{QuestionMarkCircle-DTGyWFVS.js → QuestionMarkCircle-BMcwgPWr.js} +1 -1
- package/dist/assets/{TuneOutlined-C_bRiMjO.js → TuneOutlined-D5FWo3d6.js} +1 -1
- package/dist/assets/{ViewList-B9N1x-5o.js → ViewList-BqZC98em.js} +1 -1
- package/dist/assets/{WorkingRemotely-CpchWcXV.js → WorkingRemotely-CxoGYC4d.js} +1 -1
- package/dist/assets/{access-control-B5entF50.js → access-control-D16cYs44.js} +1 -1
- package/dist/assets/{actions-t0ZB56yH.js → actions-DBL5WgL-.js} +1 -1
- package/dist/assets/{add-component-core-BS3YTsy5.js → add-component-core-Ci6stWWm.js} +1 -1
- package/dist/assets/{add-resource-DrFqIfnP.js → add-resource-T-ck3bbX.js} +1 -1
- package/dist/assets/{addon-DQC7Plj9.js → addon-DPZv8EDi.js} +1 -1
- package/dist/assets/advanced-JntBMn9H.js +14 -0
- package/dist/assets/api-DB7tZ-Xo.js +1 -0
- package/dist/assets/{appearance-Bf8ha2QN.js → appearance-CE1vlHo8.js} +1 -1
- package/dist/assets/{ar-CSZJf27k.js → ar-0ZkmCCuq.js} +1 -1
- package/dist/assets/{ar-CHiV3Onz.js → ar-4JMeO2Q-.js} +1 -1
- package/dist/assets/{audit-logs-BmFsZWcQ.js → audit-logs-CBPfzCJa.js} +2 -2
- package/dist/assets/authorize-tlwy4qUl.js +1 -0
- package/dist/assets/{base-chart-D6qRW4Yg.js → base-chart-C6ehpmPk.js} +1 -1
- package/dist/assets/{base32-CCf_iIfG.js → base32-BwYE-4Kz.js} +1 -1
- package/dist/assets/{branding-BsDB7rHi.js → branding-DJ40U0Xm.js} +1 -1
- package/dist/assets/{branding-DunUmlvH.js → branding-XgAIR_gl.js} +2 -2
- package/dist/assets/bundle-avatar-BmucN4PA.js +1 -0
- package/dist/assets/button-BJsVm63u.js +1 -0
- package/dist/assets/{click-to-copy-Fl7LHxeC.js → click-to-copy-BBibsDSl.js} +1 -1
- package/dist/assets/{cloneDeep-UpFQ2VNg.js → cloneDeep-IATUBtZS.js} +1 -1
- package/dist/assets/{collapse-dxBbW7k2.js → collapse-C0MB7y7w.js} +1 -1
- package/dist/assets/{complete-CxDgHoQk.js → complete-B4wczVx2.js} +2 -2
- package/dist/assets/{component-BnKz-jfM.js → component-CV3lHAEe.js} +1 -1
- package/dist/assets/{config-DuKJ9oR4.js → config-B54rVJFV.js} +2 -2
- package/dist/assets/{config-WLdkaHr-.js → config-kZ6x7NWW.js} +1 -1
- package/dist/assets/{config-navigation-CvCO7Fuh.js → config-navigation-BmHbVpEP.js} +6 -6
- package/dist/assets/{config-space-C_xex8-t.js → config-space-Jb7A7Enz.js} +1 -1
- package/dist/assets/{confirm-t4d18Hpz.js → confirm-C4WQNFCO.js} +1 -1
- package/dist/assets/connect-DkKsuEKO.js +5 -0
- package/dist/assets/connect-hIPRwQcf.js +1 -0
- package/dist/assets/{connect-to-r0pjWPe7.js → connect-to-DIyD6mug.js} +1 -1
- package/dist/assets/{content-layout-fV4nyVb5.js → content-layout-DuPlKBe3.js} +1 -1
- package/dist/assets/{dashboard-CEB4GFys.js → dashboard-RaW3OPWY.js} +15 -15
- package/dist/assets/{de-CA1MfHz7.js → de-DXX_rGJR.js} +1 -1
- package/dist/assets/{de-C-F2uwju.js → de-Dv_ApqsF.js} +1 -1
- package/dist/assets/{delete-confirm-DCJdTGPZ.js → delete-confirm-DF3sJ0OM.js} +1 -1
- package/dist/assets/did-address-C3GRjuMv.js +1 -0
- package/dist/assets/domain-EvKu7UZx.js +9 -0
- package/dist/assets/domain-action-card-Cw0Id2oz.js +28 -0
- package/dist/assets/domains-VgmaJPuO.js +1 -0
- package/dist/assets/dot-DGdAPqTT.js +7 -0
- package/dist/assets/{email-DY9qiGnc.js → email-CNAqXy-z.js} +2 -2
- package/dist/assets/{empty-spinner-BdaCO6xq.js → empty-spinner-DSwpCqdd.js} +1 -1
- package/dist/assets/{es-B2TJqtV4.js → es-D_uF0siv.js} +1 -1
- package/dist/assets/{es-CXgvF2gS.js → es-KnJQ_CSv.js} +1 -1
- package/dist/assets/exchange-passport-B7hlYcaO.js +1 -0
- package/dist/assets/{fr-DN38boH3.js → fr-DVFSQfDp.js} +1 -1
- package/dist/assets/{fr-CzO5Th4h.js → fr-k9jwmXxf.js} +1 -1
- package/dist/assets/{fuel-CMua6nrK.js → fuel-DZSZuXQ1.js} +1 -1
- package/dist/assets/gen-access-key-CbRadpV7.js +2 -0
- package/dist/assets/{get-safe-url-BRxk530J.js → get-safe-url-CISc2x16.js} +1 -1
- package/dist/assets/{get-safe-url-DHdoXqD0.js → get-safe-url-DvHrYSqa.js} +1 -1
- package/dist/assets/{hi-5tixPGqk.js → hi-Dqbq8i5Y.js} +1 -1
- package/dist/assets/{hi-lZ18vyMl.js → hi-yiTjSXz3.js} +1 -1
- package/dist/assets/{home-C2Db_IXV.js → home-frxjPVWF.js} +1 -1
- package/dist/assets/{id-CIDM1ypY.js → id-Bxr8o3Uo.js} +1 -1
- package/dist/assets/{id-QM66qYoI.js → id-Cd3xoDST.js} +1 -1
- package/dist/assets/{iframe-Bpfqnuq5.js → iframe-BiCAYvW4.js} +1 -1
- package/dist/assets/index-B1FE0ctv.js +1 -0
- package/dist/assets/index-BG0sHfGj.js +7 -0
- package/dist/assets/{index-BkScmF5I.js → index-BPMh7nrj.js} +1 -1
- package/dist/assets/{index-BchkF3oT.js → index-BQrNzvEP.js} +42 -17
- package/dist/assets/{index-RsjqbOR7.js → index-BXjOxZPH.js} +1 -1
- package/dist/assets/{index-iB7JyXwh.js → index-BoQJXOtZ.js} +1 -1
- package/dist/assets/index-BqpTOoPb.js +701 -0
- package/dist/assets/{index-B9IGWqlM.js → index-CM1gvdHf.js} +1 -1
- package/dist/assets/index-CM7AUwHU.js +6 -0
- package/dist/assets/{index-bu2nusyV.js → index-DFS_0wPj.js} +9 -9
- package/dist/assets/index-DG4t_95k.js +113 -0
- package/dist/assets/{index-D2uDBC1o.js → index-DU8cx_m6.js} +1 -1
- package/dist/assets/index-DU_MoKoU.js +99 -0
- package/dist/assets/{index-BmXcRfZR.js → index-DWgnwzKO.js} +1 -1
- package/dist/assets/index-DXHP7obk.js +55 -0
- package/dist/assets/{index-Bs1kxR8_.js → index-DZ-_hefE.js} +1 -1
- package/dist/assets/{index-BrhW0YAX.js → index-Da3DjtRv.js} +1 -1
- package/dist/assets/{index-DHmaMW97.js → index-Dsf-Dx7V.js} +1 -1
- package/dist/assets/{index-J3Tqz9ZT.js → index-KHBjePpP.js} +1 -1
- package/dist/assets/index-NqsjhbFu.js +1 -0
- package/dist/assets/index-Q6Li9wvf.js +284 -0
- package/dist/assets/{index-B7PoXGHo.js → index-RkKVgwr6.js} +9 -9
- package/dist/assets/{index-DH-xhSUy.js → index-ZxVQWz3M.js} +2 -2
- package/dist/assets/{index-ALHbqsn2.js → index-omqdu-uQ.js} +1 -1
- package/dist/assets/{index-HT1eRd1i.js → index-xC6Gp6MC.js} +4 -4
- package/dist/assets/{invitation-DqS1y9EI.js → invitation-DGUk8KYF.js} +5 -5
- package/dist/assets/invite-BfNfISvG.js +1 -0
- package/dist/assets/issue-passport-8wukrxMl.js +1 -0
- package/dist/assets/{item-CPlmWuOr.js → item-DPz661BP.js} +2 -2
- package/dist/assets/{ja-pJLB4V2E.js → ja-CJfcqkdo.js} +1 -1
- package/dist/assets/{ja-C8AmHPMo.js → ja-Cn7b_8vh.js} +1 -1
- package/dist/assets/{ko-xDWtmcv7.js → ko-BuxX0Qtk.js} +1 -1
- package/dist/assets/{ko-D2NP5Ixe.js → ko-BxAazRix.js} +1 -1
- package/dist/assets/{launch-result-message-FuvJDCvp.js → launch-result-message-DNgJY11G.js} +1 -1
- package/dist/assets/{layout-CneuYz3Y.js → layout-BmWP3Qk8.js} +1 -1
- package/dist/assets/list-04YITCFc.js +2 -0
- package/dist/assets/{list-DqFW_ONs.js → list-CVmWDI3k.js} +10 -10
- package/dist/assets/{list-header-xt282ZMS.js → list-header-D976e09p.js} +1 -1
- package/dist/assets/localization-BpRT0W0W.js +1 -0
- package/dist/assets/{log-B7EGR5B1.js → log-BRLMtVId.js} +1 -1
- package/dist/assets/{logger-C5_0IJ1n.js → logger-DAjuoBTQ.js} +1 -1
- package/dist/assets/login-FlwzktJ1.js +1 -0
- package/dist/assets/{login-oauth-callback-6CWB9fPF.js → login-oauth-callback-HckguQey.js} +1 -1
- package/dist/assets/{logo-uploader-BGnE-EpW.js → logo-uploader-C0nXePFF.js} +3 -3
- package/dist/assets/{lost-passport-BIGYYNZH.js → lost-passport-CxiuaqjL.js} +2 -2
- package/dist/assets/{omit-D2k92RIF.js → omit-CsI4VeYr.js} +1 -1
- package/dist/assets/{open-window-DAuoY35p.js → open-window-Ct0k45Ir.js} +1 -1
- package/dist/assets/{overview-DO_rMORL.js → overview-DqzTgTpr.js} +2 -2
- package/dist/assets/{page-header-CzGtYXZB.js → page-header-CVBmdH9B.js} +1 -1
- package/dist/assets/passport-item-EL16joTA.js +1 -0
- package/dist/assets/{permission-CG_0ilL-.js → permission-CMjo9z-z.js} +1 -1
- package/dist/assets/preferences-Dtk7H5V2.js +1 -0
- package/dist/assets/profile-embed-yHOg7opg.js +1 -0
- package/dist/assets/{pt-DSj10b9i.js → pt-B3PPKZk-.js} +1 -1
- package/dist/assets/{pt-D1apbJwE.js → pt-FpFCyI6v.js} +1 -1
- package/dist/assets/publish-resource-dRqof08I.js +1 -0
- package/dist/assets/{react-beautiful-dnd.esm-vqdGm7Q2.js → react-beautiful-dnd.esm-CaWQHB2l.js} +1 -1
- package/dist/assets/{ru-BNuzbw_f.js → ru-8o6MGLMc.js} +1 -1
- package/dist/assets/{ru-D2AG9Iea.js → ru-BuGIFp9h.js} +1 -1
- package/dist/assets/runtime-D5-pdz5h.js +1 -0
- package/dist/assets/{sanitize-CC0-oYfL.js → sanitize-qIr4ImjO.js} +1 -1
- package/dist/assets/sdk-b4mKK9kW.js +1 -0
- package/dist/assets/{section-Ccxg0x_Y.js → section-Bb547IGJ.js} +1 -1
- package/dist/assets/{security-BO4vz2A4.js → security-BTapYcba.js} +4 -4
- package/dist/assets/session-N9ogZkBO.js +1 -0
- package/dist/assets/setup-B5MRDSHj.js +30 -0
- package/dist/assets/{shorten-label-DPIZ5X7v.js → shorten-label-CTSJhlwO.js} +1 -1
- package/dist/assets/{simple-select-CN3fsa56.js → simple-select-cKQxVH3U.js} +1 -1
- package/dist/assets/{slicedToArray-DmqXMnHT.js → slicedToArray-CRrLoxQ4.js} +2 -2
- package/dist/assets/{spaces-WDzH-r9r.js → spaces-ClWdZraZ.js} +1 -1
- package/dist/assets/start-CGeLNOhk.js +187 -0
- package/dist/assets/{starting-progress-BWNdTquJ.js → starting-progress-COPiu29g.js} +1 -1
- package/dist/assets/status-C88kWBZ6.js +1 -0
- package/dist/assets/{step-actions-qe5T0fbR.js → step-actions-BmJstMo-.js} +1 -1
- package/dist/assets/{studio-COaDgEOK.js → studio-LXKuDXYf.js} +1 -1
- package/dist/assets/{switch-control-DvnJyz2a.js → switch-control-ByXecLFy.js} +1 -1
- package/dist/assets/{table-tips-3qAdlLSz.js → table-tips-CbVGFubR.js} +1 -1
- package/dist/assets/{th-CRGgyPc5.js → th-BafLD2wR.js} +1 -1
- package/dist/assets/{th-CsJSfFsn.js → th-ei5CkkZm.js} +1 -1
- package/dist/assets/{traffic-CSdm4uyu.js → traffic-CI_XKEvK.js} +1 -1
- package/dist/assets/transfer-DTyw3pJQ.js +16 -0
- package/dist/assets/{unsubscribe-BBPlZQOy.js → unsubscribe-T4w7NZUF.js} +1 -1
- package/dist/assets/use-blocklet-logo-BXak7BDs.js +2 -0
- package/dist/assets/{use-mobile-BAa0wi8o.js → use-mobile-CXU9YBvX.js} +1 -1
- package/dist/assets/{use-mobile-C21X4TYN.js → use-mobile-CiFFAdJf.js} +1 -1
- package/dist/assets/{use-server-logo-CxuMvwKh.js → use-server-logo-BbYHFDuK.js} +1 -1
- package/dist/assets/useAsync-QkUcWOv0.js +1 -0
- package/dist/assets/{useLocalStorage-DiA2Rpy-.js → useLocalStorage-COrhSWV-.js} +1 -1
- package/dist/assets/user-center-B27c6mFg.js +77 -0
- package/dist/assets/{util-CKnnktVh.js → util-Ayf5_DBX.js} +1 -1
- package/dist/assets/{util-SIt5hlfb.js → util-CHnqURNW.js} +1 -1
- package/dist/assets/{vendor-arcblock-BPZ1V4pg.js → vendor-arcblock-CATQui2x.js} +87 -87
- package/dist/assets/{vendor-hooks-BgUTpb6X.js → vendor-hooks-TMGmpw5W.js} +2 -2
- package/dist/assets/{vendor-mui-core-BV2FUxWJ.js → vendor-mui-core-wlbruq2I.js} +22 -22
- package/dist/assets/{vendor-mui-x-Bo-XOtzq.js → vendor-mui-x-BKgL6hAa.js} +1 -1
- package/dist/assets/vendor-utils-CxrPpJZS.js +208 -0
- package/dist/assets/vendor-ux-did-connect-Bh011lgb.js +2305 -0
- package/dist/assets/{vi-Ce8JEW56.js → vi-B1ypAqOQ.js} +1 -1
- package/dist/assets/{vi-IIi6v-et.js → vi-BMZxxaJ2.js} +1 -1
- package/dist/assets/wrap-locale-BBPjudJQ.js +1 -0
- package/dist/assets/{zh-DQX0RFjY.js → zh-DusA4qAT.js} +1 -1
- package/dist/assets/{zh-tw-C-FYOTmO.js → zh-tw-BMxcCLBp.js} +1 -1
- package/dist/assets/{zh-tw-6n1CYpHc.js → zh-tw-BO-QhSNP.js} +1 -1
- package/dist/assets/{zh-S-Nv5zr-.js → zh-vhAJ5xBV.js} +1 -1
- package/dist/index.html +6 -6
- package/dist/service-worker.js +2 -2
- package/package.json +45 -45
- package/dist/assets/AdapterDayjs-Dy2dI4ee.js +0 -3
- package/dist/assets/Email-BirbvqZ3.js +0 -1
- package/dist/assets/Location-DxPzfR_p.js +0 -1
- package/dist/assets/Phone-BkOMNOMO.js +0 -1
- package/dist/assets/Timezone-D91Of94T.js +0 -1
- package/dist/assets/advanced-DO1hLdXY.js +0 -14
- package/dist/assets/api-BjteVZFg.js +0 -1
- package/dist/assets/authorize-C1krxa_8.js +0 -1
- package/dist/assets/bundle-avatar-BTHmZ3_i.js +0 -1
- package/dist/assets/button-mmNFGQSs.js +0 -1
- package/dist/assets/connect-Cv9tvvms.js +0 -5
- package/dist/assets/connect-GdnRXixM.js +0 -1
- package/dist/assets/did-address-BJCF3XU3.js +0 -1
- package/dist/assets/domain-Dkw0nuHL.js +0 -9
- package/dist/assets/domain-action-card-DnB964Ah.js +0 -28
- package/dist/assets/domains-D6W7Zk5a.js +0 -1
- package/dist/assets/dot-DX56IFTM.js +0 -7
- package/dist/assets/exchange-passport-BOpw7kFp.js +0 -1
- package/dist/assets/gen-access-key-FrO6nmvQ.js +0 -2
- package/dist/assets/index-0epbdrMx.js +0 -55
- package/dist/assets/index-3aRBjK5P.js +0 -701
- package/dist/assets/index-ChEmNV9t.js +0 -6
- package/dist/assets/index-DESkMgoq.js +0 -113
- package/dist/assets/index-DIzYQ8YY.js +0 -1
- package/dist/assets/index-DTLUTgmo.js +0 -10
- package/dist/assets/index-DjmlNqL1.js +0 -1
- package/dist/assets/index-DkNMM_jp.js +0 -284
- package/dist/assets/index-Dq0Wocff.js +0 -1
- package/dist/assets/index-xbFMe1Dq.js +0 -99
- package/dist/assets/invite-Do31CPZ_.js +0 -1
- package/dist/assets/issue-passport-BawbYt3J.js +0 -1
- package/dist/assets/landing-page-k0HqFOEl.js +0 -1
- package/dist/assets/list-C3bba0fZ.js +0 -2
- package/dist/assets/localization-B18AVgXP.js +0 -1
- package/dist/assets/login-CmoMzUKP.js +0 -1
- package/dist/assets/passport-item-B0b6IIEi.js +0 -1
- package/dist/assets/preferences-nmcizF2n.js +0 -1
- package/dist/assets/profile-embed-D9vov7el.js +0 -1
- package/dist/assets/publish-resource-BAxsxiDk.js +0 -1
- package/dist/assets/runtime-4wAQAE28.js +0 -1
- package/dist/assets/sdk-DnmwcxEc.js +0 -1
- package/dist/assets/session-yHau46Qm.js +0 -1
- package/dist/assets/setup-C9eWBBt5.js +0 -30
- package/dist/assets/start-CvbMSa4N.js +0 -187
- package/dist/assets/status-B87zOhDx.js +0 -1
- package/dist/assets/transfer-DsmSmlf-.js +0 -16
- package/dist/assets/use-blocklet-logo-vRumIAeK.js +0 -2
- package/dist/assets/useAsync-Dv214fz8.js +0 -1
- package/dist/assets/useAsync-KYUBhVsb.js +0 -1
- package/dist/assets/user-center-p3JKDvby.js +0 -77
- package/dist/assets/vendor-utils-rHXShPKm.js +0 -208
- package/dist/assets/vendor-ux-did-connect-CJ8Q_v7u.js +0 -2296
- package/dist/assets/wrap-locale-Dz5tBqNC.js +0 -1
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import{j as e,H as h,ah as Je,T as C,ab as A,e as Ze,cF as Z,ae as G,cG as Ge,aa as j,al as W,s as ge,ad as Se,be as et,cH as ze,a9 as ye,q,b4 as Y,b5 as H,y as tt,ap as st,bb as Ae}from"./vendor-mui-core-BV2FUxWJ.js";import{l as nt,i as Pe,f as fe}from"./vendor-hooks-BgUTpb6X.js";import{r as y,h as ot}from"./vendor-react-DEoibe3W.js";import{c as _,J as rt,a0 as at,V as it,a1 as ct,n as lt,G as dt,a2 as ue,I as ut}from"./vendor-arcblock-BPZ1V4pg.js";import{a0 as D,a as T,b4 as pt,j as R,b9 as V,a9 as mt,r as je,bx as ft,B as pe,aq as ht,C as _e,au as xt}from"./vendor-ux-did-connect-CJ8Q_v7u.js";import{G as O,D as M,y as w,a3 as gt,af as St,aE as yt}from"./index-3aRBjK5P.js";import{u as jt}from"./use-mobile-BAa0wi8o.js";import{b as Q,d as Me,a7 as bt,I as Ct,E as Ue,A as he}from"./vendor-utils-rHXShPKm.js";import"./api-BjteVZFg.js";import{u as Ne,C as kt,D as Bt,a as Dt}from"./connect-to-r0pjWPe7.js";import{b as Et,c as wt,d as Tt,i as It,e as xe,f as Rt,h as vt,j as At}from"./spaces-WDzH-r9r.js";import{f as X}from"./index-8eXqqyHQ.js";import{I as Ot}from"./index-DHmaMW97.js";import{R as Lt}from"./index-J3Tqz9ZT.js";import{d as zt}from"./MoreHoriz-Bb60Z0iy.js";import{c as Pt}from"./dashboard-CEB4GFys.js";import{d as _t}from"./DeleteOutline-MvcW8wMe.js";import{g as Oe}from"./get-safe-url-DHdoXqD0.js";import{S as Mt}from"./switch-control-DvnJyz2a.js";import{C as Ut,u as Nt}from"./config-space-C_xex8-t.js";import{L as Le}from"./list-header-xt282ZMS.js";import"./lottie-web-jYmAQWuC.js";import"./useLocalStorage-DiA2Rpy-.js";import"./confirm-t4d18Hpz.js";import"./PlayArrow-DSHRafhE.js";import"./session-yHau46Qm.js";import"./use-blocklet-logo-vRumIAeK.js";import"./InfoOutlined-DwH0ULaz.js";import"./dot-DX56IFTM.js";import"./useAsync-Dv214fz8.js";import"./useSetState-CWq0AVWn.js";import"./use-mobile-C21X4TYN.js";async function Wt({blockletDid:t,nodeApi:r,spaceGateways:o}){let s=!1;const i=await Promise.all(o.map(async n=>{let{name:a}=n;const d=await Et(n.endpoint);return!Q(d)&&d!==a&&(a=d,s=!0),{...n,name:a}}));return s&&await Promise.all(i.filter(n=>n.did).map(n=>r.updateBlockletSpaceGateway({input:{did:t,where:{did:n.did},spaceGateway:{...n}}}))),i}function Ft({refresh:t}={}){var i;const{blocklet:r}=O(),o=(i=r==null?void 0:r.meta)==null?void 0:i.did,{api:s}=M();return nt(async()=>{if(!o)return[];const{spaceGateways:n}=await s.getBlockletSpaceGateways({input:{did:o}});return await Wt({blockletDid:o,nodeApi:s,spaceGateways:n})??[]},{refreshDeps:[o,t],onError(n){var a;(a=n==null?void 0:n.message)!=null&&a.includes("not logged")?console.warn(n):(console.error(n),D.error(X(n)))}})}function We({deps:t,setLoading:r,backupDate:o}={deps:[],setLoading:()=>{},backupDate:new Date}){var x;const{blocklet:s}=O(),[i,n]=y.useState([]),{api:a}=M(),[d,u]=y.useMemo(()=>o?[w(o).startOf("day").toISOString(),w(o).endOf("day").toISOString()]:[w().startOf("year").toISOString(),w().endOf("day").toISOString()],[o]),c=Me(async()=>{try{if(r(!0),!s){n([]);return}const{backups:p}=await a.getBlockletBackups({input:{did:s.meta.did,startTime:d,endTime:u}});n(p??[])}catch(p){console.error(p),D.error(X(p))}finally{r(!1)}},1e3);return Pe(async()=>{c()},[(x=s==null?void 0:s.meta)==null?void 0:x.did].concat(t)),{backups:i}}function Kt({appDid:t}){const{backups:r}=We(),[o,s]=y.useState({message:"",progress:0,completed:!1}),i=M(),{ws:{useSubscription:n}}=i;return n(_.BlockletEvents.backupProgress,a=>{t===(a==null?void 0:a.appDid)&&s(()=>({...a}))},[t]),y.useEffect(()=>{var a;if(r!=null&&r.length&&bt((a=r[0])==null?void 0:a.status)){const[d]=r;s(()=>({message:d.message,progress:d.progress,completed:d.progress>=100}))}},[r]),o}function $t({deps:t=[],setLoading:r=()=>{}}={}){var d;const{blocklet:o}=O(),[s,i]=y.useState([]),{api:n}=M(),a=y.useCallback(Me(async()=>{var u;if(!n||!((u=o==null?void 0:o.meta)!=null&&u.did)){i([]);return}try{r(!0);const c=w(),x=c.subtract(1,"year"),{summary:p}=await n.getBlockletBackupSummary({input:{did:o.meta.did,startTime:x.toISOString(),endTime:c.toISOString()}});i(Array.isArray(p)?p:[])}catch(c){console.error("Failed to fetch backup summary:",c),D.error(X(c)),i([])}finally{r(!1)}},1e3),[]);return Pe(async()=>(await a(),()=>{a.cancel()}),[(d=o==null?void 0:o.meta)==null?void 0:d.did].concat(t)),{backupSummary:s}}const Fe=y.createContext({}),{Provider:qt,Consumer:Ws}=Fe;function be({children:t}){var K;const{t:r}=T(),{api:o}=M(),{blocklet:s}=O(),[i,n]=y.useState(null),[a,d]=y.useState(!1),{data:u,loading:c,mutate:x}=Ft({refresh:a}),p=Ct(u),g=Kt({appDid:s==null?void 0:s.appDid}),f=y.useMemo(()=>wt(s==null?void 0:s.environments),[s==null?void 0:s.environments]),[b,B]=y.useState(!1),[S,l]=y.useState(!1),{backups:te}=We({deps:[S,i],setLoading:B,backupDate:i}),[se,ne]=y.useState(!1),{backupSummary:oe}=$t({deps:[se]}),[U,z]=y.useState(u==null?void 0:u.find(m=>m.endpoint===f)),I=(K=s==null?void 0:s.settings)==null?void 0:K.autoBackup,v=()=>{d(m=>!m)},re=()=>{ne(m=>!m)},ae=()=>{l(m=>!m)},F=async m=>{await o.updateAutoBackup({input:{did:s.meta.did,autoBackup:m}})},J=async()=>{await o.abortBlockletBackup({input:{appPid:s.meta.did}})},ie=async(m,N)=>{try{x(E=>{const P=[...E];return P.push({...m,loading:!0}),P}),await o.addBlockletSpaceGateway({input:{did:s.meta.did,spaceGateway:m}}),f!==N&&await o.configBlocklet({input:{did:[s.meta.did],configs:[{key:_.BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_APP_BACKUP_ENDPOINT,value:N}]}}),z(m),v(),D.success(r("storage.spaces.connectedWithName",{name:(m==null?void 0:m.name)??"DID Spaces"}))}catch(E){throw console.error(E),x(P=>[...P].filter(de=>de.did!==m.did)),E}},ce=async m=>{m&&(m.endpoint===f&&(await o.configBlocklet({input:{did:[s.meta.did],configs:[{key:_.BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_APP_BACKUP_ENDPOINT,value:""}]}}),I!=null&&I.enabled&&await F({enabled:!1})),await o.deleteBlockletSpaceGateway({input:{did:s.meta.did,spaceGatewayDid:m==null?void 0:m.did}}),x(N=>{const E=[...N];return E.splice(E.indexOf(m),1),E}),z(m),v())},le=async m=>{await Promise.all([o.updateBlockletSpaceGateway({input:{did:s.meta.did,where:{did:m.did},spaceGateway:m}}),f!==m.endpoint&&o.configBlocklet({input:{did:[s.meta.did],configs:[{key:_.BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_APP_BACKUP_ENDPOINT,value:m.endpoint}]}})]),D.success(r("storage.spaces.connectedWithName",{name:(m==null?void 0:m.name)??"DID Spaces"})),v()},k=m=>(m==null?void 0:m.endpoint)===f;return e.jsx(qt,{value:{spaceGateways:u||[],selectedSpaceGateway:U,addSpaceGateway:ie,deleteSpaceGateway:ce,updateSpaceGateway:le,refreshSpaceGateways:v,spaceGatewaysLoading:c,spaceGatewaysFirstLoading:p,spaceGatewayIsSelected:k,updateAutoBackup:F,abortBlockletBackup:J,backupEndpoint:f,backupProgress:g,backups:te,backupSummary:oe,refreshBackupSummary:re,refreshBackups:ae,setBackupDate:n,backupsLoading:b,autoBackup:I},children:t})}be.propTypes={children:h.any.isRequired};be.defaultProps={};function L(){return y.useContext(Fe)}function ee({...t}){const{blocklet:r}=O(),{info:o}=M(),{t:s}=T(),i=Ne({blocklet:r}),n=gt(o),{spaceGateways:a,addSpaceGateway:d}=L(),u={checkFn:Ue.create({baseURL:he(window.location.origin,St())}).get,webWalletUrl:n,extraParams:{appPid:r.appPid,appDid:i.appDid,appName:i.appName,appDescription:i.appDescription,appUrl:i.appUrl,referrer:i.referrer,scopes:i.scopes,nodeDid:o.did}},c=async({endpoint:p,name:g,did:f})=>{const b=await Tt(p);if(!await It(b)){D.error(s("storage.spaces.gateway.add.invalidUrl"));return}if(a.some(l=>l.endpoint===p)){D.error(s("storage.spaces.gateway.add.duplicate",{name:g}));return}await d({name:g,did:f,url:b,endpoint:p},p)},x=async({spaceGateway:p})=>{try{await c(p)}catch(g){console.error(g),D.error(X(g))}};return e.jsx(rt,{...t,options:u,onSuccess:x})}ee.propTypes={};ee.defaultProps={};function Ke({...t}){const{t:r}=y.useContext(pt),{blocklet:o,loadingDiskInfo:s,actions:i}=O();if(y.useEffect(()=>{i==null||i.refreshBlocklet({showError:!1,attachDiskInfo:!0})},[]),o.diskInfo){const n=(u,c,x)=>e.jsxs(C,{children:[u," ",e.jsx("strong",{children:c?yt(c):"empty"})]}),a=o.environments.reduce((u,c)=>(u[c.key]=c.value,u),{}),d=[{key:"appDir",name:r("blocklet.diskInfo.appDir"),value:n(a.BLOCKLET_APP_DIR,o.diskInfo.app)},{key:"dataDir",name:r("blocklet.diskInfo.dataDir"),value:n(a.BLOCKLET_DATA_DIR,o.diskInfo.data)},{key:"logDir",name:r("blocklet.diskInfo.logDir"),value:n(a.BLOCKLET_LOG_DIR,o.diskInfo.log)},{key:"cacheDir",name:r("blocklet.diskInfo.cacheDir"),value:n(a.BLOCKLET_CACHE_DIR,o.diskInfo.cache)}];return e.jsx(Yt,{component:"div",...t,children:d.map(u=>e.jsx(Ot,{valueComponent:"div",nameWidth:120,name:u.name,children:u.value},u.key))})}return s?e.jsx(A,{}):e.jsx(C,{children:r("blocklet.diskInfo.empty")})}const Yt=Je(C)``;function Ce(){const{t}=T(),{setBackupDate:r,backupSummary:o}=L(),s=at({key:"lg"}),i=y.useRef(null),n=Ze(),a=y.useCallback(c=>{r(c)},[r]),d=y.useMemo(()=>{const c=w().add(1,"day"),x=w().subtract(11,"month").startOf("month"),p=new Map(o.map(f=>[f.date,{date:f.date,successCount:f.successCount,errorCount:f.errorCount}])),g=[];for(let f=x.clone();w(f).isBefore(c);f=f.add(1,"day")){const b=f.format("YYYY-MM-DD");g.push(p.get(b)||{date:b,successCount:0,errorCount:0})}return g},[o]),u=y.useMemo(()=>({grid:{containLabel:!0,right:10,top:30,bottom:12},tooltip:{formatter:b=>{const{date:B,successCount:S,errorCount:l}=d[b.dataIndex]||{date:b.data[0],successCount:0,errorCount:0};return[`<div>${t("common.time")}: ${B}</div>`,`<div>${t("common.succeeded")}: ${S}</div>`,`<div>${t("common.failed")}: ${l}</div>`].join(`
|
|
2
|
-
`)},backgroundColor:n.palette.background.paper,borderColor:n.palette.divider,textStyle:{color:n.palette.text.primary,fontSize:14},extraCssText:`box-shadow: ${n.shadows[2]}; border-radius: 4px;`,padding:[8,10]},visualMap:{show:!1,min:-12,max:12,pieces:[{min:Number.MIN_SAFE_INTEGER,max:-9,color:Z[600]},{min:-9,max:-6,color:Z[500]},{min:-6,max:-3,color:Z[400]},{min:-3,max:-1,color:Z[300]},{min:0,max:0,color:n.palette.grey[200]},{min:1,max:3,color:G[300]},{min:3,max:6,color:G[400]},{min:6,max:9,color:G[500]},{min:9,max:Number.MAX_SAFE_INTEGER,color:G[600]}],orient:"horizontal",left:"center",bottom:12,itemWidth:12,itemHeight:12,textStyle:{color:n.palette.text.secondary,fontSize:12}},calendar:{top:30,left:50,right:10,bottom:4,cellSize:[8,8],splitLine:{show:!1},itemStyle:{borderWidth:2,borderColor:n.palette.background.default,color:n.palette.background.default},dayLabel:{show:!0,firstDay:0,nameMap:["","Mon","","Wed","","Fri",""],position:"start",margin:4,fontSize:10,color:n.palette.text.primary,fontWeight:"400",width:20},monthLabel:{show:!0,nameMap:"cn",align:"left",color:n.palette.text.primary,fontWeight:"400",fontSize:12,position:"start",margin:4,width:30,padding:[0,2]},yearLabel:{show:!1},range:[w().subtract(11,"month").startOf("month").format("YYYY-MM-DD"),w().endOf("month").format("YYYY-MM-DD")],orient:"horizontal"},series:{type:"heatmap",coordinateSystem:"calendar",data:d.map(b=>[b.date,b.errorCount?-b.errorCount:b.successCount]),label:{show:!1},itemStyle:{borderWidth:2,borderColor:n.palette.background.default,borderRadius:4},emphasis:{itemStyle:{borderWidth:2,borderColor:Ge[200],color:"inherit"}}}}),[d,t,n]);return e.jsxs(e.Fragment,{children:[e.jsx(j,{ref:i,sx:{maxWidth:"1280px",border:"1px solid",borderColor:"divider",padding:"8px",overflowX:"auto"},children:e.jsx(j,{sx:{width:"1200px",height:"180px",position:"relative"},children:e.jsx(Lt,{option:u,style:{height:"100%",width:"100%"},notMerge:!0,lazyUpdate:!1,opts:{renderer:"canvas"},onEvents:{click:c=>{c.componentType==="series"&&c.data&&a(c.data[0])}}})})}),e.jsx(j,{display:"flex",justifyContent:"flex-end",mt:1,mr:s?2:5,mb:2,children:e.jsxs(W,{direction:s?"column":"row",spacing:s?2:1,width:"100%",justifyContent:"flex-start",alignItems:s?"flex-start":"center",children:[e.jsxs(W,{direction:"row",alignItems:"center",spacing:1,children:[e.jsx(j,{width:32,height:12,borderRadius:.5,sx:{background:"linear-gradient(90deg, #8B5000 0%, #A36200 33%, #C17700 66%, #E29000 100%)"}}),e.jsx(C,{variant:"body2",color:"text.secondary",children:t("storage.spaces.backup.failed")})]}),e.jsxs(W,{direction:"row",alignItems:"center",spacing:1,children:[e.jsx(j,{width:32,height:12,borderRadius:.5,bgcolor:"grey.200",border:"1px solid",borderColor:"grey.200"}),e.jsx(C,{variant:"body2",color:"text.secondary",children:t("storage.spaces.backup.without")})]}),e.jsxs(W,{direction:"row",alignItems:"center",spacing:1,children:[e.jsx(j,{width:32,height:12,borderRadius:.5,sx:{background:"linear-gradient(90deg, #9be9a8 0%, #40c463 33%, #30a14e 66%, #216e39 100%)"}}),e.jsx(C,{variant:"body2",color:"text.secondary",children:t("storage.spaces.backup.succeeded")})]})]})})]})}Ce.propTypes={};const Ht=ge(({className:t,...r})=>e.jsx(Se,{...r,classes:{popper:t}}))(()=>({".MuiTooltip-tooltip":{backgroundColor:"transparent",padding:0,margin:0,boxShadow:"none",maxWidth:"none"},".MuiTooltip-arrow":{color:"rgba(230, 235, 245, 1)"}}));function ke({status:t,message:r,createdAt:o}){const{t:s}=T(),i=t===R.BACKUPS.STATUS.PROGRESS&&w().diff(o,"hours")>=R.BACKUPS.TIMEOUT_HOURS,n=i&&s("common.timeoutError"),a=t===R.BACKUPS.STATUS.PROGRESS&&!i,d=t===R.BACKUPS.STATUS.SUCCEEDED&&!i;return a?e.jsxs(C,{display:"inline-flex",alignItems:"center",fontSize:"14px",children:[e.jsx(A,{sx:{marginRight:"4px"},size:"12px"}),s("common.progress")]}):d?e.jsx(V,{type:"success",children:s("common.succeeded")}):e.jsxs(j,{display:"inline-flex",alignItems:"center",children:[e.jsx(V,{type:"error",children:s("common.failed")})," ",e.jsx(Se,{style:{display:"flex",alignItems:"center",flexShrink:0},title:r||n,children:e.jsx(ze,{children:e.jsx(it,{style:{width:"24px",height:"24px"},color:"error"})})})]})}ke.propTypes={status:h.string.isRequired,message:h.string,createdAt:h.string.isRequired};ke.defaultProps={message:""};function Be({metadata:t}){const{t:r}=T();if(Q(t))return e.jsx(V,{type:"success",children:r("common.succeeded")});const o=t.count||0,s=t.size||0,i=ct(s,{iec:!0}),n=e.jsxs(j,{p:1,sx:{color:"black",backgroundColor:"white"},borderRadius:1,boxShadow:2,children:[e.jsxs(C,{variant:"body2",children:[r("common.fileCount"),": ",o]}),e.jsxs(C,{variant:"body2",children:[r("common.fileSize"),": ",i]})]});return e.jsxs(j,{display:"inline-flex",alignItems:"center",children:[e.jsx(V,{type:"success",children:r("common.succeeded")})," ",e.jsx(Ht,{title:n,style:{display:"flex",alignItems:"center",flexShrink:0},placement:"left",children:e.jsx(ze,{children:e.jsx(lt,{style:{width:"24px",height:"24px"},color:"primary"})})})]})}Be.propTypes={metadata:h.object};Be.defaultProps={metadata:{}};function De(){const{t,locale:r}=T(),{spaceGateways:o,backups:s,backupsLoading:i}=L(),n=y.useMemo(()=>[{label:"DID Space",name:"target",options:{customBodyRenderLite:d=>{var B;const{targetUrl:u,targetName:c,status:x,createdAt:p}=s[d],g=x===R.BACKUPS.STATUS.PROGRESS&&w().diff(p,"hours")>=R.BACKUPS.TIMEOUT_HOURS,f=x===R.BACKUPS.STATUS.SUCCEEDED&&!g,b=c||((B=o.find(S=>u==null?void 0:u.includes(xe(S==null?void 0:S.endpoint))))==null?void 0:B.name)||"Unknown DID Space";return f?e.jsx(et,{fontSize:"16px",href:u,target:"_blank",children:b}):e.jsx(C,{variant:"body1",fontSize:"16px",children:b})}}},{label:t("common.strategy"),name:"strategy",options:{customBodyRender:d=>{const u=t(d===0?"common.auto":"common.manual");return e.jsx(V,{children:u})}}},{label:t("common.startTime"),name:"createdAt",options:{customBodyRender:d=>w(d).format("YYYY-MM-DD HH:mm:ss")}},{label:t("common.endTime"),name:"updatedAt",options:{customBodyRender:d=>Q(d)?"":w(d).format("YYYY-MM-DD HH:mm:ss")}},{label:t("common.status"),name:"status",options:{customBodyRenderLite:d=>{const u=(s==null?void 0:s[d])??{},{status:c,message:x,createdAt:p,metadata:g}=u,f=c===R.BACKUPS.STATUS.PROGRESS&&w().diff(p,"hours")>=R.BACKUPS.TIMEOUT_HOURS,b=c===R.BACKUPS.STATUS.PROGRESS&&!f,B=c===R.BACKUPS.STATUS.SUCCEEDED&&!f;return b?e.jsxs(C,{display:"inline-flex",alignItems:"center",fontSize:"14px",children:[e.jsx(A,{sx:{marginRight:"4px"},size:"12px"}),t("common.progress")]}):B?e.jsx(Be,{metadata:g}):e.jsx(ke,{status:c,message:x,createdAt:p})}}}],[s,o,t]),a=y.useMemo(()=>!(s!=null&&s.length),[s]);return e.jsx(e.Fragment,{children:a?e.jsx(j,{display:"flex",justifyContent:"center",alignItems:"center",height:"100px",color:"#9397A1",marginTop:"16px",marginBottom:"24px",children:t("storage.spaces.record.emptyData")}):e.jsx(mt,{title:"",loading:i,data:s,columns:n,emptyNode:t("storage.spaces.record.emptyData",r),options:{download:!1,filter:!1,print:!1,search:!1,viewColumns:!1}})})}De.propTypes={};function $e(){const{t}=T();return e.jsxs(j,{children:[e.jsxs(j,{display:"flex",gap:3,flexDirection:{xs:"column",md:"row"},children:[e.jsxs(j,{display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",alignContent:"center",minWidth:240,children:[e.jsx(dt,{style:{cursor:"pointer",width:"150px",height:"100%",maxHeight:160}}),e.jsx(C,{my:2,sx:{textAlign:"center",color:"text.secondary"},children:t("storage.spaces.connect.provider")}),e.jsx(ee,{})]}),e.jsxs(j,{sx:{flexGrow:1,minWidth:0},children:[e.jsx(j,{display:"flex",justifyContent:"space-between",alignItems:"center",mb:3,children:e.jsx(C,{fontSize:"1.2rem",fontWeight:"bold",children:t("storage.spaces.backup.records")})}),e.jsx(Ce,{})]})]}),e.jsx(De,{sx:{marginTop:"24px"}}),e.jsx(C,{fontSize:"1.2rem",fontWeight:"bold",mb:2,mt:2,children:t("common.dataStorage")}),e.jsx(Ke,{})]})}$e.propTypes={};var Ee={},Vt=ye;Object.defineProperty(Ee,"__esModule",{value:!0});var qe=Ee.default=void 0,Qt=Vt(je()),Xt=e;qe=Ee.default=(0,Qt.default)((0,Xt.jsx)("path",{d:"M6 6v2h8.59L5 17.59 6.41 19 16 9.41V18h2V6z"}),"ArrowOutward");var we={},Jt=ye;Object.defineProperty(we,"__esModule",{value:!0});var Ye=we.default=void 0,Zt=Jt(je()),Gt=e;Ye=we.default=(0,Zt.default)((0,Gt.jsx)("path",{d:"M14.69 2.21 4.33 11.49c-.64.58-.28 1.65.58 1.73L13 14l-4.85 6.76c-.22.31-.19.74.08 1.01.3.3.77.31 1.08.02l10.36-9.28c.64-.58.28-1.65-.58-1.73L11 10l4.85-6.76c.22-.31.19-.74-.08-1.01-.3-.3-.77-.31-1.08-.02"}),"ElectricBoltOutlined");var Te={},es=ye;Object.defineProperty(Te,"__esModule",{value:!0});var He=Te.default=void 0,ts=es(je()),ss=e;He=Te.default=(0,ts.default)((0,ss.jsx)("path",{d:"m9.17 6 2 2H20v10H4V6zM10 4H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2h-8z"}),"FolderOutlined");function Ie({spaceGateway:t,onConfirm:r,onCancel:o}){const{t:s}=T(),[i,n]=y.useState(!1),[a,d]=y.useState(!1),u=(p,g)=>{p==null||p.preventDefault(),p==null||p.stopPropagation(),n(g)},c=async p=>{try{p==null||p.stopPropagation(),d(!0),await(r==null?void 0:r(t)),n(!1)}catch(g){console.error(g),D.error(`${s("storage.space.gateway.delete.failed")}: ${X(g)}`)}finally{n(!1),d(!1)}},x=p=>{u(p,!1),o==null||o(p)};return e.jsxs(e.Fragment,{children:[e.jsxs(q,{color:"red",onClick:p=>u(p,!0),children:[e.jsx(Y,{style:{minWidth:24,color:"red"},children:e.jsx(_t,{fontSize:"small"})}),e.jsx(H,{style:{color:"red"},children:s("common.delete")})]}),e.jsx(ft,{title:s("storage.spaces.gateway.delete.title"),open:i,confirmButton:{text:s("common.confirm"),props:{size:"small",variant:"contained",color:"error",loading:a}},cancelButton:{text:s("common.cancel"),props:{size:"small",variant:"outlined",disabled:a}},onConfirm:c,onCancel:x,children:e.jsx(C,{sx:{wordWrap:"break-word"},children:s("storage.spaces.gateway.delete.descForBackup",{name:`${t==null?void 0:t.name}`})})})]})}Ie.propTypes={spaceGateway:h.shape({name:h.string.isRequired,url:h.string.isRequired,protected:h.bool}).isRequired,onConfirm:h.func,onCancel:h.func};Ie.defaultProps={onConfirm:()=>{},onCancel:()=>{}};function Re({spaceGateway:t,selected:r,onDelete:o,onConnect:s,enableSwitchToSpace:i,backupInProgress:n,...a}){const{abortBlockletBackup:d}=L(),[u,c]=y.useState(null),{t:x}=T(),[p,g]=y.useState(!1),f=(S,l)=>{S.stopPropagation(),S.preventDefault(),c(l&&S.currentTarget)},b=async S=>{try{g(!0),f(S,!1),await s(t)}catch(l){console.error(l),D.error(l.message)}finally{g(!1)}},B=async S=>{try{g(!0),f(S,!1),await d()}catch(l){console.error(l),D.error(l.message)}finally{g(!1)}};return e.jsxs(e.Fragment,{children:[p||t!=null&&t.loading?e.jsx(A,{sx:{ml:1},size:"24px"}):e.jsx(tt,{"aria-label":"more","aria-controls":"actions-menu","aria-haspopup":"true","data-cy":"trigger-blocklet-actions",variant:"outlined",size:"small",onClick:S=>f(S,!0),...a,children:e.jsx(zt,{})}),e.jsxs(st,{id:"simple-menu",anchorEl:u,keepMounted:!0,open:!!u,onClose:S=>f(S,!1),children:[e.jsxs(q,{onClick:S=>{f(S,!1),window.open(Oe(t.endpoint?Rt(t.endpoint):t.url,{allowDomains:null}))},children:[e.jsx(Y,{style:{minWidth:24},children:e.jsx(qe,{fontSize:"small"})}),e.jsx(H,{children:x("common.open")})]}),e.jsxs(q,{onClick:S=>{f(S,!1),window.open(Oe(vt(t.endpoint),{allowDomains:null}))},children:[e.jsx(Y,{style:{minWidth:24},children:e.jsx(He,{fontSize:"small"})}),e.jsx(H,{children:x("storage.spaces.strategy.viewBackupFiles")})]}),!r&&i&&e.jsxs(q,{onClick:b,children:[e.jsx(Y,{style:{minWidth:24},children:e.jsx(Ye,{fontSize:"small"})}),e.jsx(H,{children:x("storage.spaces.connect.switchToSpace")})]}),n&&e.jsxs(q,{onClick:B,children:[e.jsx(Y,{style:{minWidth:24},children:e.jsx(Pt,{fontSize:"small"})}),e.jsx(H,{children:x("storage.spaces.connect.abortBlockletBackup")})]}),!n&&e.jsx(Ie,{spaceGateway:t,onConfirm:async()=>{c(null),await(o==null?void 0:o(t))},onCancel:()=>c(null)})]})]})}Re.propTypes={spaceGateway:h.shape({name:h.string.isRequired,url:h.string.isRequired,protected:h.bool,endpoint:h.string.isRequired,loading:h.bool}).isRequired,selected:h.bool.isRequired,enableSwitchToSpace:h.bool,onDelete:h.func,onConnect:h.func,backupInProgress:h.bool};Re.defaultProps={onDelete:()=>{},onConnect:()=>{},enableSwitchToSpace:!0,backupInProgress:!1};const ns=ge(({className:t,...r})=>e.jsx(Se,{...r,classes:{popper:t}}))(()=>({".MuiTooltip-tooltip":{backgroundColor:"transparent",padding:0,margin:0,boxShadow:"none",maxWidth:"none"},".MuiTooltip-arrow":{color:"rgba(230, 235, 245, 1)"}}));function ve({spaceGateway:t,spaceStatus:r,selected:o,onConnected:s,onDeleted:i,onBackedUp:n}){const{t:a,locale:d}=T(),{blocklet:u}=O(),{api:c,info:{did:x}}=M(),{appDid:p,appName:g,appDescription:f,scopes:b,appUrl:B,referrer:S}=Ne({blocklet:u}),{backupProgress:l,updateSpaceGateway:te,deleteSpaceGateway:se,refreshBackupSummary:ne,refreshBackups:oe}=L(),[U,z]=y.useState(!1),[I,v]=y.useState({open:!1,action:"one-click-authorization",checkTimeout:1e3*300,messages:{title:a("storage.spaces.authorize.title",{appName:g},d),scan:a("storage.spaces.authorize.scan",{appName:g},d),confirm:"",success:e.jsx(C,{gutterBottom:!0,children:a("storage.spaces.authorize.success")})},onClose:()=>{v(k=>({...k,open:!1}))}}),re=o&&!U&&r===ue.DISCONNECTED,ae=o&&!U&&!t.loading&&r===ue.CONNECTED,F=o&&U&&r===ue.CONNECTED&&(l==null?void 0:l.progress)>=0,J=async()=>{try{if(await At(t==null?void 0:t.endpoint)){await c.configBlocklet({input:{did:[u.meta.did],configs:[{key:_.BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_APP_BACKUP_ENDPOINT,value:t.endpoint}]}}),D.success(a("storage.spaces.connect.switchToSpaceSucceeded",{name:t.name?`(${t.name})`:""})),s==null||s(null,t);return}}catch(k){console.error(k),s==null||s(k,t);return}v(k=>({...k,open:!0,prefix:he(t.url,"space/api/did"),baseUrl:new URL(t.url).origin,checkFn:Ue.create({baseURL:he(t.url,"space")}).get,extraParams:{appDid:p,appName:g,appDescription:f,scopes:b,appUrl:B,referrer:S,nodeDid:x,spaceDid:t.did}}))},ie=async(k,K)=>{const m=K(k.endpoint),N=xe(m),E=k.space?K(k.space):{};if(t.did&&N!==t.did){v(de=>({...de,open:!1}));const $=a("storage.spaces.gateway.switch.failedForMismatchSpace",{name:E!=null&&E.name?E.name:""});D.error($),s==null||s(new Error($),t);return}const P={...t,name:E.name??"DID Space",did:E.did??xe(m),endpoint:m};await te(P),v($=>({...$,open:!1})),s==null||s(null,P)},ce=async()=>{try{if(U)return;z(!0),await c.backupBlocklet({input:{appDid:u.appDid,to:"spaces"}})}catch(k){console.error(k),D.error(k.message),n==null||n(k,t)}finally{z(!0)}},le=async()=>{try{await se(t),D.success(a("storage.spaces.gateway.delete.succeeded",{name:t.name?`(${t.name})`:""})),i==null||i(null,t)}catch(k){console.error(k),i==null||i(k,t)}};return y.useEffect(()=>{l!=null&&l.completed?(o&&((l==null?void 0:l.progress)===100?(D.success(a("storage.spaces.backupSuccessfully")),n==null||n(null,t)):l.message&&(n==null||n(new Error(l==null?void 0:l.message),t)),l.progress=0,l.message=""),z(!1),setTimeout(()=>{ne(),oe()},1e3)):l.progress&&z(!0)},[l]),e.jsxs(e.Fragment,{children:[e.jsxs(j,{sx:{".action-btn":{borderRadius:1,marginLeft:1}},display:"flex",alignItems:"center",children:[ae&&e.jsx(pe,{className:"action-btn",variant:"outlined",size:"small",onClick:ce,children:a("storage.spaces.strategy.backupNow")}),re&&e.jsx(pe,{className:"action-btn",variant:"outlined",size:"small",onClick:J,children:a("storage.spaces.disconnected.reconnectNow")}),F&&e.jsx(ns,{title:(l==null?void 0:l.message)&&e.jsx(j,{p:1,sx:{color:"black",backgroundColor:"white"},borderRadius:1,boxShadow:2,children:e.jsx(C,{variant:"body2",children:l.message})}),children:e.jsxs(pe,{className:"action-btn",variant:"outlined",size:"small",sx:{minWidth:70},children:[e.jsx(A,{variant:"determinate",value:l==null?void 0:l.progress,size:14,sx:{mr:1}}),l==null?void 0:l.progress,"%"]})}),e.jsx(ht,{forceConnected:!1,saveConnect:!1,prefix:I.prefix,open:I.open,popup:!0,action:I.action,baseUrl:I.baseUrl,checkFn:I.checkFn,onSuccess:ie,onClose:I.onClose,checkTimeout:I.checkTimeout,extraParams:I.extraParams,messages:I.messages,locale:d},"get-endpoint")]}),e.jsx(Re,{sx:{minWidth:32,padding:"2px 4px",ml:1},spaceGateway:t,selected:o,onDelete:le,onConnect:J,enableSwitchToSpace:(l==null?void 0:l.completed)||Q(l==null?void 0:l.message),backupInProgress:F})]})}ve.propTypes={spaceGateway:h.shape({did:h.string.isRequired,name:h.string.isRequired,url:h.string.isRequired,endpoint:h.string.isRequired,protected:h.bool,loading:h.bool}).isRequired,spaceStatus:h.string.isRequired,selected:h.bool.isRequired,onConnected:h.func,onDeleted:h.func,onBackedUp:h.func};ve.defaultProps={onConnected:()=>{},onDeleted:()=>{},onBackedUp:()=>{}};function Ve({...t}){const{t:r}=T();return e.jsxs(j,{...t,children:[e.jsx(j,{display:"flex",justifyContent:"space-between",alignItems:"center",mb:3,children:e.jsx(C,{fontSize:"1.2rem",fontWeight:"bold",children:r("storage.spaces.backup.records")})}),e.jsx(Ce,{}),e.jsx(De,{})]})}Ve.propTypes={};function Qe({...t}){const{t:r}=T(),{autoBackup:o,updateAutoBackup:s}=L(),i=async()=>{try{const n=!(o!=null&&o.enabled);await s({enabled:n}),D.success(r(n?"storage.spaces.autoBackup.enabled":"storage.spaces.autoBackup.disabled"))}catch(n){D.error(n.message)}};return e.jsx(Mt,{checked:!!(o!=null&&o.enabled),onChange:i,name:"enableWelcomePage",labelProps:{label:e.jsx(C,{marginRight:"8px",children:e.jsx("span",{children:r("storage.spaces.autoBackup.title")})})},style:{...t.style}})}Qe.propTypes={};function os(){const{t}=T(),{spaceGateways:r,spaceGatewaysLoading:o,spaceGatewayIsSelected:s}=L(),i=o&&!(r!=null&&r.length),n=({spaceGateway:a,spaceStatus:d,selected:u,refresh:c})=>e.jsx(ve,{spaceGateway:a,spaceStatus:d,selected:u,onConnected:()=>c(),onBackedUp:x=>x&&c()});return e.jsxs(j,{display:"flex",flexDirection:"column",children:[e.jsxs(j,{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(C,{fontSize:"1.2rem",fontWeight:"bold",flexGrow:1,children:t("storage.spaces.connected.title")}),e.jsx(Qe,{}),e.jsx(ee,{})]}),e.jsx(j,{mt:2,children:i?e.jsx(j,{display:"flex",justifyContent:"center",children:e.jsx(A,{})}):e.jsx(Ae,{container:!0,spacing:2,children:e.jsx(e.Fragment,{children:r.map(a=>e.jsx(Ae,{item:!0,xs:12,md:6,children:e.jsx(ut,{endpoint:a.endpoint,selected:s(a),action:n},a.endpoint)}))})})}),e.jsx(Ve,{sx:{marginTop:"24px"}}),e.jsx(C,{fontSize:"1.2rem",fontWeight:"bold",mb:2,children:t("common.dataStorage")}),e.jsx(Ke,{})]})}function rs(){const{spaceGatewaysFirstLoading:t,spaceGateways:r}=L();return t?e.jsx(_e,{relative:"parent",children:e.jsx(A,{})}):Q(r)?e.jsx($e,{}):e.jsx(os,{})}function as(){return e.jsx(be,{children:e.jsx(rs,{})})}function is(){const{spaceGateway:t,settingStorageEndpoint:r,updateSpaceGateway:o,hasStorageEndpoint:s,loading:i,storageEndpoint:n}=Nt(),a=fe(()=>({display:"flex",alignItems:"center",justifyContent:"center",paddingTop:"16px"}));return i?e.jsx(_e,{relative:"parent",children:e.jsx(A,{})}):e.jsxs(j,{sx:{maxWidth:"md",position:"relative"},children:[s?e.jsx(kt,{spaceGateway:t,settingStorageEndpoint:r}):e.jsx(Bt,{}),e.jsx(j,{sx:a,children:e.jsx(Dt,{onConnect:o,storageEndpoint:n})})]})}function cs(){const{t}=T();return e.jsxs(Ut,{children:[e.jsxs(W,{spacing:1,marginBottom:2,children:[e.jsx(C,{fontSize:"1.2rem",fontWeight:"bold",children:t("storage.appLevel.title")}),e.jsx(C,{color:"text.secondary",children:t("storage.appLevel.description")})]}),e.jsx(is,{})]})}function Xe({navOrientation:t,...r}){const{t:o,locale:s}=T(),{blocklet:i}=O(),n=jt({key:"md"}),[a,d]=ot(),u=a.get("tab")||"backup",c=n?"horizontal":t,x=fe(()=>{var l;const B=[{label:o("common.backup"),value:"backup"}],S=(l=i==null?void 0:i.capabilities)==null?void 0:l.didSpace;return(S===_.BLOCKLET_APP_SPACE_REQUIREMENT.REQUIRED||S===_.BLOCKLET_APP_SPACE_REQUIREMENT.REQUIRED_ON_SETUP)&&B.push({label:o("common.storage"),value:"storage"}),B},[s,c]),g=fe(()=>({backup:e.jsx(as,{}),storage:e.jsx(cs,{})}))[u],f=B=>{d(S=>(B==="backup"?S.delete("tab"):S.set("tab",B),S))};if(x.length<=1)return e.jsx(me,{children:g});const b=e.jsx(xt,{tabs:x,current:u,orientation:c,onChange:f,sx:[{borderRight:1,height:"100%",borderColor:"divider"},c==="horizontal"&&{borderRight:0}]});if(c==="vertical")return e.jsx(j,{...r,children:e.jsxs(W,{direction:{md:"column",lg:"row"},gap:2,children:[e.jsx(j,{sx:{flexShrink:0},children:e.jsx(Le,{left:b})}),e.jsx(j,{sx:{flexGrow:1,minWidth:0},children:e.jsx(me,{sx:{mt:1},children:g})})]})});if(c==="horizontal")return e.jsxs(j,{...r,children:[e.jsx(Le,{left:b}),e.jsx(me,{sx:{mt:2},children:g})]})}Xe.propTypes={navOrientation:h.oneOf(["vertical","horizontal"])};Xe.defaultProps={navOrientation:"vertical"};const me=ge(j)`
|
|
3
|
-
position: relative;
|
|
4
|
-
min-height: 66vh;
|
|
5
|
-
overflow: hidden;
|
|
6
|
-
`;export{Xe as default};
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
import{g as Ut,r as C}from"./vendor-react-DEoibe3W.js";import{ah as ue,al as ht,j as e,aa as T,O as te,bs as ge,bt as We,bo as Y,ad as xt,H as x,a9 as Je,T as ae,E as Xe,bz as gt,bQ as qe,bR as Ke,y as Le,b3 as Me,ab as bt,bI as jt,Y as vt,cp as yt,m as Ht,bb as dt,br as Vt,bn as Yt,q as ut,bY as Gt,I as Jt}from"./vendor-mui-core-BV2FUxWJ.js";import{J as St,z as Xt,A as Qt,e as fe,aB as ye,C as Zt}from"./vendor-utils-rHXShPKm.js";import{q as es,a as re,a8 as Ct,a0 as K,W as ke,bW as ts,B as me,b4 as ss,au as wt,j as W,b9 as ns,r as Qe,bX as is,$ as Tt,a9 as Rt,bt as Ae,ao as Nt,Y as as,bA as rs}from"./vendor-ux-did-connect-CJ8Q_v7u.js";import{D as Ze,G as Et,aB as It,aC as Q,y as se,n as os,K as pt}from"./index-3aRBjK5P.js";import{a as Te,u as V,f as ce}from"./vendor-hooks-BgUTpb6X.js";import{a as et,b as ls}from"./dashboard-CEB4GFys.js";import{f as $e,i as cs,d as ds}from"./use-blocklet-logo-vRumIAeK.js";import{A as us,a as ps,d as fs,b as ms}from"./collapse-dxBbW7k2.js";import{S as ee}from"./section-Ccxg0x_Y.js";import{S as Re}from"./shorten-label-DPIZ5X7v.js";import{I as At}from"./index-DHmaMW97.js";import{R as Ot,A as hs,S as xs,a as gs,b as bs,B as js}from"./list-DqFW_ONs.js";import{W as vs}from"./did-address-BJCF3XU3.js";import{p as Dt}from"./util-CKnnktVh.js";import{D as ys,g as Ss}from"./traffic-CSdm4uyu.js";import{B as Lt}from"./bundle-avatar-BTHmZ3_i.js";import{u as Cs}from"./use-mobile-BAa0wi8o.js";import"./lottie-web-jYmAQWuC.js";import"./vendor-arcblock-BPZ1V4pg.js";import"./useLocalStorage-DiA2Rpy-.js";import"./index-8eXqqyHQ.js";import"./confirm-t4d18Hpz.js";import"./PlayArrow-DSHRafhE.js";import"./get-safe-url-DHdoXqD0.js";import"./session-yHau46Qm.js";import"./InfoOutlined-DwH0ULaz.js";import"./dot-DX56IFTM.js";import"./useAsync-Dv214fz8.js";import"./useSetState-CWq0AVWn.js";import"./use-mobile-C21X4TYN.js";import"./index-D2uDBC1o.js";import"./CheckCircle-Dv9ESLSx.js";import"./index-DTLUTgmo.js";import"./Phone-BkOMNOMO.js";import"./Location-DxPzfR_p.js";import"./Email-BirbvqZ3.js";import"./Timezone-D91Of94T.js";import"./base32-CCf_iIfG.js";import"./iframe-Bpfqnuq5.js";import"./LaunchOutlined-Mxl2EzJD.js";import"./ChevronLeft-7uRDOkJ0.js";import"./ChevronRight-DF2CPRSp.js";import"./index-iB7JyXwh.js";import"./base-chart-D6qRW4Yg.js";import"./index-J3Tqz9ZT.js";import"./vendor-mui-x-Bo-XOtzq.js";import"./AdapterDayjs-Dy2dI4ee.js";var Ue={exports:{}},He={exports:{}},Ve={exports:{}};(function(n,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=s;function s(r){return r==null}n.exports=t.default,n.exports.default=t.default})(Ve,Ve.exports);var ws=Ve.exports;(function(n,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=p;var s=o(es),r=o(ws);function o(h){return h&&h.__esModule?h:{default:h}}var l=/^(?:[-+]?(?:0|[1-9][0-9]*))$/,y=/^[-+]?[0-9]+$/;function p(h,i){(0,s.default)(h),i=i||{};var A=i.allow_leading_zeroes===!1?l:y,O=!i.hasOwnProperty("min")||(0,r.default)(i.min)||h>=i.min,R=!i.hasOwnProperty("max")||(0,r.default)(i.max)||h<=i.max,S=!i.hasOwnProperty("lt")||(0,r.default)(i.lt)||h<i.lt,D=!i.hasOwnProperty("gt")||(0,r.default)(i.gt)||h>i.gt;return A.test(h)&&O&&R&&S&&D}n.exports=t.default,n.exports.default=t.default})(He,He.exports);var Ts=He.exports;(function(n,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=o;var s=r(Ts);function r(l){return l&&l.__esModule?l:{default:l}}function o(l){return(0,s.default)(l,{allow_leading_zeroes:!1,min:0,max:65535})}n.exports=t.default,n.exports.default=t.default})(Ue,Ue.exports);var Rs=Ue.exports;const Ns=Ut(Rs),Fe={enabled:!1,secure:!1,from:"",host:"",port:"",user:"",password:"",companyName:"",companyLink:"",companyAddress:"",supportEmail:""};function Es(){var N,E,P;const{api:n}=Ze(),{blocklet:t}=Et(),{t:s}=re(),{confirmApi:r,confirmHolder:o}=Ct(),l=(N=t==null?void 0:t.meta)==null?void 0:N.did,y=Object.assign({...Fe},((P=(E=t==null?void 0:t.settings)==null?void 0:E.notification)==null?void 0:P.email)||{}),{handleSubmit:p,control:h,formState:i,watch:A,reset:O}=It({defaultValues:St(y,Object.keys(Fe))}),R=Te({testReceiver:"",testReceiverError:""}),S=A("enabled"),D=V(async(a,m,$=!0)=>{var U,oe;try{const{blocklet:le}=await n.configNotification({input:{did:l,notification:JSON.stringify({email:a})}}),pe=Object.assign({...Fe},((oe=(U=le==null?void 0:le.settings)==null?void 0:U.notification)==null?void 0:oe.email)||{});O(pe),$&&K.success(s("oauth.saveSuccess"))}catch(le){if($)K.error(le.message||s("oauth.saveFailed"));else throw le}}),G=V(async(a,m,$)=>{try{i.isDirty&&await D(a,m,!1),await n.sendEmail({input:{did:l,receiver:$,email:JSON.stringify({body:"Your SMTP configuration is correct!",title:"Test email",type:"notification"})}}),K.success(s("notification.email.testSuccess"))}catch(U){K.error(U.message||s("notification.email.testfailed"))}}),z=V((a,m)=>{R.testReceiver="",R.testReceiverError="",r.open({title:s("notification.email.testSendEmail"),content:()=>e.jsx(T,{sx:{width:"300px"},children:e.jsx(te,{sx:{mt:1},fullWidth:!0,name:"testReceiver",label:s("notification.email.inputTestReceiver"),value:R.testReceiver,onChange:$=>{R.testReceiver=$.target.value},error:!!R.testReceiverError,helperText:R.testReceiverError||" "})}),confirmButtonText:s("common.confirm"),cancelButtonText:s("common.cancel"),async onConfirm($){var oe;const U=(oe=R.testReceiver)==null?void 0:oe.trim();if(!U){R.testReceiverError=s("notification.email.receiverRequired");return}if(!ke(U)){R.testReceiverError=s("notification.email.receiverInvalid");return}R.testReceiverError="",await G(a,m,U),$()}})}),B=V(a=>{const m=a==null?void 0:a.trim();return m?ke(m)?!0:s("notification.email.fromInvalid"):s("notification.email.fromRequired")}),_=V(a=>{const m=a==null?void 0:a.trim();return m?$e(m,{require_host:!1,protocols:[]})?!0:s("notification.email.hostInvalid"):s("notification.email.hostRequired")}),M=V(a=>a?Ns(a)?!0:s("notification.email.portInvalid"):s("notification.email.portRequired")),J=V(a=>a!=null&&a.trim()?!0:s("notification.email.userRequired")),ie=V(a=>a!=null&&a.trim()?!0:s("notification.email.passwordRequired")),c=V(a=>a!=null&&a.trim()&&!$e(a,{protocols:["http","https"],require_protocol:!0})?s("notification.email.linkInvalid"):!0),g=V(a=>a!=null&&a.trim()&&!ke(a)?s("notification.email.emailInvalid"):!0),j=V(()=>!0);return e.jsxs(T,{children:[e.jsxs(Is,{component:"form",onSubmit:p(D),disabled:!0,sx:{".section-left":{width:"160px"}},children:[e.jsx(ee,{title:s("notification.email.enable"),my:2.5,children:e.jsx(Q,{name:"enabled",control:h,render:({field:a})=>e.jsx(ge,{control:e.jsx(We,{checked:a.value,...a})})})}),e.jsx(ee,{title:s("notification.email.from"),children:e.jsx(Q,{name:"from",control:h,rules:{validate:S?B:j},render:({field:a})=>{var m;return e.jsx(Y,{fullWidth:!0,children:e.jsx(te,{...a,size:"small",required:!0,label:s("notification.email.from"),error:!!i.errors[a.name],helperText:((m=i.errors[a.name])==null?void 0:m.message)||" ",disabled:!S})})}})}),e.jsx(ee,{title:s("notification.email.host"),children:e.jsx(Q,{name:"host",control:h,rules:{validate:S?_:j},render:({field:a})=>{var m;return e.jsx(Y,{fullWidth:!0,children:e.jsx(te,{...a,size:"small",required:!0,error:!!i.errors[a.name],label:s("notification.email.host"),helperText:((m=i.errors[a.name])==null?void 0:m.message)||" ",disabled:!S})})}})}),e.jsx(ee,{title:s("notification.email.port"),children:e.jsx(Q,{name:"port",control:h,rules:{validate:S?M:j},render:({field:a})=>{var m;return e.jsx(Y,{fullWidth:!0,children:e.jsx(te,{...a,size:"small",required:!0,type:"number",error:!!i.errors[a.name],label:s("notification.email.port"),helperText:((m=i.errors[a.name])==null?void 0:m.message)||" ",disabled:!S})})}})}),e.jsx(ee,{title:s("notification.email.user"),children:e.jsx(Q,{name:"user",control:h,rules:{validate:S?J:j},render:({field:a})=>{var m;return e.jsx(Y,{fullWidth:!0,children:e.jsx(te,{...a,size:"small",required:!0,error:!!i.errors[a.name],label:s("notification.email.user"),helperText:((m=i.errors[a.name])==null?void 0:m.message)||" ",disabled:!S})})}})}),e.jsx(ee,{title:s("notification.email.password"),children:e.jsx(Q,{name:"password",control:h,rules:{validate:S?ie:j},render:({field:a})=>{var m;return e.jsx(Y,{fullWidth:!0,children:e.jsx(te,{...a,size:"small",required:!0,type:"password",error:!!i.errors[a.name],label:s("notification.email.password"),helperText:((m=i.errors[a.name])==null?void 0:m.message)||" ",disabled:!S})})}})}),e.jsx(ee,{title:s("notification.email.secure"),children:e.jsx(Q,{name:"secure",control:h,rules:{validate:j},render:({field:a})=>e.jsx(Y,{fullWidth:!0,children:e.jsx(ge,{control:e.jsx(We,{checked:a.value,...a,disabled:!S})})})})}),e.jsxs(us,{children:[e.jsxs(ps,{expandIcon:e.jsx(fs,{fontSize:"small"}),"aria-controls":"panel1-content",id:"panel1-header",children:[s("notification.email.signature"),e.jsx(xt,{title:s("notification.email.signatureTooltip"),children:e.jsx(ts,{fontSize:"small",sx:{ml:1,cursor:"help"}})})]}),e.jsxs(ms,{children:[e.jsx(ee,{title:s("notification.email.companyName"),children:e.jsx(Q,{name:"companyName",control:h,rules:{validate:j},render:({field:a})=>{var m;return e.jsx(Y,{fullWidth:!0,children:e.jsx(te,{...a,size:"small",error:!!i.errors[a.name],label:s("notification.email.companyName"),helperText:((m=i.errors[a.name])==null?void 0:m.message)||" ",disabled:!S})})}})}),e.jsx(ee,{title:s("notification.email.companyLink"),children:e.jsx(Q,{name:"companyLink",control:h,rules:{validate:S?c:j},render:({field:a})=>{var m;return e.jsx(Y,{fullWidth:!0,children:e.jsx(te,{...a,size:"small",error:!!i.errors[a.name],label:s("notification.email.companyLink"),helperText:((m=i.errors[a.name])==null?void 0:m.message)||" ",disabled:!S})})}})}),e.jsx(ee,{title:s("notification.email.companyAddress"),children:e.jsx(Q,{name:"companyAddress",control:h,rules:{validate:j},render:({field:a})=>{var m;return e.jsx(Y,{fullWidth:!0,children:e.jsx(te,{...a,size:"small",error:!!i.errors[a.name],label:s("notification.email.companyAddress"),helperText:((m=i.errors[a.name])==null?void 0:m.message)||" ",disabled:!S})})}})}),e.jsx(ee,{title:s("notification.email.supportEmail"),children:e.jsx(Q,{name:"supportEmail",control:h,rules:{validate:S?g:j},render:({field:a})=>{var m;return e.jsx(Y,{fullWidth:!0,children:e.jsx(te,{...a,size:"small",type:"email",error:!!i.errors[a.name],label:s("notification.email.supportEmail"),helperText:((m=i.errors[a.name])==null?void 0:m.message)||" ",disabled:!S})})}})})]})]}),e.jsxs(T,{sx:{display:"flex",justifyContent:"flex-end",gap:2,mt:3},children:[e.jsx(me,{variant:"outlined",color:"warning",onClick:p(z),disabled:!S,children:s("oauth.runTest")}),e.jsx(me,{type:"submit",variant:"contained",disabled:!i.isDirty,children:s("oauth.save")})]})]}),o]})}const Is=ue(ht)``,Be={enabled:!1,endpoint:"",did:void 0,pushPath:void 0};function As(){var M,J,ie;const{api:n}=Ze(),{blocklet:t}=Et(),{t:s}=re(),{confirmApi:r,confirmHolder:o}=Ct(),l=(M=t==null?void 0:t.meta)==null?void 0:M.did,y=Object.assign({...Be},((ie=(J=t==null?void 0:t.settings)==null?void 0:J.notification)==null?void 0:ie.pushKit)||{}),{handleSubmit:p,control:h,formState:i,watch:A,reset:O}=It({defaultValues:St(y,Object.keys(Be))}),R=Te({testReceiver:"",testReceiverError:""}),S=A("enabled"),D=V(async(c,g,j=!0)=>{var N,E;try{const{blocklet:P}=await n.configNotification({input:{did:l,notification:JSON.stringify({pushKit:c})}}),a=Object.assign({...Be},((E=(N=P==null?void 0:P.settings)==null?void 0:N.notification)==null?void 0:E.pushKit)||{});O(a),j&&K.success(s("oauth.saveSuccess"))}catch(P){if(j)K.error(P.message||s("oauth.saveFailed"));else throw P}}),G=V(async(c,g)=>{var j,N,E;try{i.isDirty&&await D(c,g,!1);const P=(j=((t==null?void 0:t.configs)||[]).find($=>$.key==="BLOCKLET_APP_URL"))==null?void 0:j.value,a=Xt(Qt(P,"/.well-known/service/blocklet/logo"),{v:(N=t==null?void 0:t.meta)==null?void 0:N.version,t:new Date((t==null?void 0:t.updatedAt)||0).getTime()}),m={type:"passthrough",passthroughType:"messageStatus",data:{message:{title:"Test push-kit notification",body:"This is message from push-kit config test",sender:{did:t==null?void 0:t.appDid,fullName:(E=t==null?void 0:t.meta)==null?void 0:E.title,avatar:a}}}};await n.sendPush({input:{did:l,receiver:R.testReceiver,notification:JSON.stringify(m)}}),K.success(s("notification.pushKit.testSuccess"))}catch(P){K.error(P.message||s("notification.pushKit.testfailed"))}}),z=V((c,g)=>{R.testReceiverError="",r.open({title:s("notification.pushKit.testSend"),content:()=>e.jsx(T,{sx:{width:"450px",maxWidth:"100%"},children:e.jsx(te,{sx:{mt:1},fullWidth:!0,name:"testReceiver",label:s("notification.pushKit.inputTestReceiver"),value:R.testReceiver,onChange:j=>{R.testReceiver=j.target.value},error:!!R.testReceiverError,helperText:R.testReceiverError||" "})}),confirmButtonText:s("common.confirm"),cancelButtonText:s("common.cancel"),async onConfirm(j){var E;if(!((E=R.testReceiver)==null?void 0:E.trim())){R.testReceiverError=s("notification.pushKit.receiverRequired");return}R.testReceiverError="",await G(c,g),j()}})}),B=V(c=>{const g=c==null?void 0:c.trim();return g?$e(g)?!0:s("notification.pushKit.endpointInvalid"):s("notification.pushKit.endpointRequired")}),_=V(()=>!0);return e.jsxs(T,{children:[e.jsxs(Os,{component:"form",onSubmit:p(D),disabled:!0,sx:{".section-left":{width:"160px"}},children:[e.jsx(ee,{title:s("notification.pushKit.enable"),my:2.5,children:e.jsx(Q,{name:"enabled",control:h,render:({field:c})=>e.jsx(ge,{control:e.jsx(We,{checked:c.value,...c})})})}),e.jsx(ee,{title:s("notification.pushKit.endpoint"),children:e.jsx(Q,{name:"endpoint",control:h,rules:{validate:S?B:_},render:({field:c})=>{var g;return e.jsx(Y,{fullWidth:!0,children:e.jsx(te,{...c,size:"small",required:!0,label:s("notification.pushKit.endpoint"),error:!!i.errors[c.name],helperText:((g=i.errors[c.name])==null?void 0:g.message)||" ",disabled:!S})})}})}),e.jsxs(ee,{title:s("notification.pushKit.customOptions"),children:[e.jsx(Q,{name:"did",control:h,render:({field:c})=>{var g;return e.jsx(Y,{fullWidth:!0,children:e.jsx(te,{...c,size:"small",label:s("notification.pushKit.did"),error:!!i.errors[c.name],helperText:((g=i.errors[c.name])==null?void 0:g.message)||" ",disabled:!S})})}}),e.jsx(Q,{name:"pushPath",control:h,render:({field:c})=>{var g;return e.jsx(Y,{fullWidth:!0,children:e.jsx(te,{...c,size:"small",label:s("notification.pushKit.pushPath"),error:!!i.errors[c.name],helperText:((g=i.errors[c.name])==null?void 0:g.message)||" ",disabled:!S})})}})]}),e.jsxs(T,{sx:{display:"flex",justifyContent:"flex-end",gap:2,mt:3},children:[e.jsx(me,{variant:"outlined",color:"warning",onClick:p(z),disabled:!S,children:s("oauth.runTest")}),e.jsx(me,{type:"submit",variant:"contained",disabled:!i.isDirty,children:s("oauth.save")})]})]}),o]})}const Os=ue(ht)``,ft=[{label:e.jsx(T,{textAlign:"center",width:"100%",children:"Email"}),value:"email"},{label:e.jsx(T,{textAlign:"center",width:"100%",children:"Push Kit"}),value:"pushKit"}];function Ds(){const[n,t]=C.useState(ft[0].value),{locale:s}=C.useContext(ss),r=ce(()=>({email:e.jsx(Es,{}),pushKit:e.jsx(As,{})}),[s]),o=C.useMemo(()=>({padding:"10px 0"}),[]);return e.jsxs(T,{children:[e.jsx(wt,{tabs:ft,current:n,onChange:t}),e.jsx(T,{style:o,children:r[n]})]})}const Pt=C.createContext({}),{Provider:Ls,Consumer:oi}=Pt;function Ps({children:n,blocklet:t=""}){const{api:s,inService:r,ws:{useSubscription:o}}=Ze(),[l,y]=C.useState([]),[p,h]=C.useState({total:0,pageSize:20,pageCount:0,page:1}),i=ce(()=>{var c;return(c=t.meta)==null?void 0:c.did},[t]),[A,O]=C.useState([]),[R,S]=C.useState({}),D=ce(()=>l.length?new Set(l.map(c=>c.id)):new Set,[l]),G=async({page:c=1,pageSize:g=20,...j}={})=>{if(!i)return[];try{const N={paging:{page:c,pageSize:g},...j,teamDid:i,dateRange:j.dateRange?[se(j.dateRange[0]).toISOString(),se(j.dateRange[1]).toISOString()]:void 0},{dids:E,...P}=N;let a="";E&&E.includes("system")&&(a="system");const m=E?E.filter(oe=>oe!=="system"):[],$={...P,source:a,componentDids:m},U=await s.getNotificationSendLog({input:$});return S($),y(U.list),h(U.paging),U.list}catch(N){return K.error(N.message),[]}},z=async()=>{const c=await s.getNotificationComponents({input:{teamDid:i}});O(c.componentDids)},B=C.useCallback(c=>{const g=t.children.find(j=>{var N;return((N=j.meta)==null?void 0:N.did)===c});if(g)return g.ancestors=[t],g},[t]),_=async({notificationId:c,receivers:g,channels:j,...N})=>{await s.resendNotification({input:{teamDid:i,notificationId:c,receivers:g,channels:j.map(E=>E==="wallet"?W.NOTIFICATION_SEND_CHANNEL.WALLET:E==="pushKit"?W.NOTIFICATION_SEND_CHANNEL.PUSH:E),...N}})},M=C.useCallback(async c=>(await s.getUser({input:{teamDid:i,user:{did:c}}})).user,[s,i]),J=C.useCallback(async({page:c=1,pageSize:g=20,...j}={})=>{try{const N={paging:{page:c,pageSize:g},...j,userName:j.searchText||"",teamDid:i,dateRange:j.dateRange?[se(j.dateRange[0]).toISOString(),se(j.dateRange[1]).toISOString()]:void 0};return await s.getReceivers({input:N})}catch(N){throw K.error(N.message),N}},[s,i]);C.useEffect(()=>{i&&z()},[i]),o(W.EVENTS.NOTIFICATION_BLOCKLET_UPDATE,c=>{D.has(c.notificationId)&&G(R)},[D,R]),o(W.EVENTS.NOTIFICATION_BLOCKLET_CREATE,c=>{D.has(c.id)||G(R)},[D,R]);const ie={fetch:G,data:l,paging:p,blocklet:t,getComponent:B,resendNotification:_,getUser:M,componentDids:A,getReceivers:J,inService:r,teamDid:i};return e.jsx(Ls,{value:{notificationRecords:ie},children:n})}function tt(){const{notificationRecords:n}=C.useContext(Pt);return n}Ne.propTypes={severity:x.oneOf(Object.values(["info","success","error","warning"])).isRequired};const _s={info:"primary",success:"success",error:"error",warning:"warning"};function Ne({severity:n="info"}){return e.jsx(ns,{type:_s[n],children:n})}var st={},ks=Je;Object.defineProperty(st,"__esModule",{value:!0});var _t=st.default=void 0,Fs=ks(Qe()),Bs=e;_t=st.default=(0,Fs.default)((0,Bs.jsx)("path",{d:"M16.59 7.58 10 14.17l-3.59-3.58L5 12l5 5 8-8zM12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2m0 18c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8"}),"CheckCircleOutline");var nt={},zs=Je;Object.defineProperty(nt,"__esModule",{value:!0});var kt=nt.default=void 0,Ws=zs(Qe()),qs=e;kt=nt.default=(0,Ws.default)((0,qs.jsx)("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2M4 12c0-4.42 3.58-8 8-8 1.85 0 3.55.63 4.9 1.69L5.69 16.9C4.63 15.55 4 13.85 4 12m8 8c-1.85 0-3.55-.63-4.9-1.69L18.31 7.1C19.37 8.45 20 10.15 20 12c0 4.42-3.58 8-8 8"}),"Block");var it={},Ks=Je;Object.defineProperty(it,"__esModule",{value:!0});var Ft=it.default=void 0,Ms=Ks(Qe()),$s=e;Ft=it.default=(0,Ms.default)((0,$s.jsx)("path",{d:"M17.65 6.35C16.2 4.9 14.21 4 12 4c-4.42 0-7.99 3.58-7.99 8s3.57 8 7.99 8c3.73 0 6.84-2.55 7.73-6h-2.08c-.82 2.33-3.04 4-5.65 4-3.31 0-6-2.69-6-6s2.69-6 6-6c1.66 0 3.14.69 4.22 1.78L13 11h7V4z"}),"Refresh");const Us=(n,t,s="")=>{if(!s||!t)return"";switch(s){case W.NOTIFICATION_SEND_FAILED_REASON.USER_DISABLED:return n("notification.sendStatus.reason.disabled",{channel:t});case W.NOTIFICATION_SEND_FAILED_REASON.CHANNEL_UNAVAILABLE:return n("notification.sendStatus.reason.unavailable",{channel:t});case W.NOTIFICATION_SEND_FAILED_REASON.CHANNEL_DISABLED:return n("notification.sendStatus.reason.notSent",{channel:t});case W.NOTIFICATION_SEND_FAILED_REASON.NOT_ONLINE:return n("notification.sendStatus.reason.offline");default:return s}};function Bt(n,t,s={}){const{status:r,updatedAt:o,reason:l="",channel:y="wallet"}=s,p=o?n("notification.sendStatus.sentTime",{date:os(o,t)}):"",h=Us(n,y,l);return r===W.NOTIFICATION_SEND_STATUS.FAILED?{status:"failed",title:n("notification.sendStatus.failed"),sentTime:p,reason:h}:r===W.NOTIFICATION_SEND_STATUS.SENT?{status:"success",title:n("notification.sendStatus.success"),sentTime:p}:{status:"pending",title:n("notification.sendStatus.pending"),reason:h,sentTime:p}}const Ye={pending:"#aaaaaa",success:"#34BE74",failed:"#D0021B"},Ge=["wallet","pushKit","email"],mt=["info","success","error","warning"],zt=n=>{var s,r;const{settings:t}=n;return(r=(s=t==null?void 0:t.notification)==null?void 0:s.email)==null?void 0:r.enabled},Wt=n=>{var s,r;const{settings:t}=n;return(r=(s=t==null?void 0:t.notification)==null?void 0:s.pushKit)==null?void 0:r.enabled},Hs=(n,t)=>{const s=fe(t,"extra.notifications.email",!0);return{available:zt(n),enabled:s}},Vs=(n,t)=>{const s=fe(t,"extra.notifications.push",!0);return{available:Wt(n),enabled:s}},Ys=n=>({enabled:fe(n,"extra.notifications.wallet",!0)}),Gs=n=>({enabled:fe(n,"extra.webhooks",[]).length>0}),Ee=(n=3)=>new Promise(t=>{setTimeout(()=>{t()},n*1e3)}),Js=(n,t)=>t==="wallet"||t==="webhook"?[{channel:t,type:"enabled",pass:n("notification.sendStatus.reason.enabled",{channel:t}),fail:n("notification.sendStatus.reason.disabled",{channel:t})}]:t==="pushKit"||t==="email"?[{channel:t,type:"available",pass:n("notification.sendStatus.reason.available",{channel:t}),fail:n("notification.sendStatus.reason.unavailable",{channel:t})},{channel:t,type:"enabled",pass:n("notification.sendStatus.reason.enabled",{channel:t}),fail:n("notification.sendStatus.reason.disabled",{channel:t})}]:[],Ie=(n=[])=>{const t=se().startOf("day");return n.filter(s=>se(s.sendAt).isSame(t,"day")).length},Xs=(n,t="")=>{if(t&&Ge.includes(t)){const l=`${t}SendRecord`,y=fe(n,l,[]);return Ie(y)}const s=fe(n,"webhook",{}),r=Object.keys(s??{})??[];if(t&&r.includes(t)){const l=s[t]??[];return Ie(l)}const o={};return Ge.forEach(l=>{const y=`${l}SendRecord`,p=fe(n,y,[]),h=Ie(p);o[l]=h}),r.length>0&&r.forEach(l=>{const y=s[l]??[],p=Ie(y);o[l]=p}),o},Oe=(n,t,s)=>{if(!Array.isArray(n))throw new Error("Invalid filterList or index");return n[s].splice(t,1),n},De=(n,t)=>{if(!Array.isArray(t))throw new Error("filters must be an array");return t.length?!t.includes(n):!1},Qs=n=>{switch(n){case W.NOTIFICATION_SEND_CHANNEL.WALLET:return"Wallet";case W.NOTIFICATION_SEND_CHANNEL.PUSH:return"Push Kit";case W.NOTIFICATION_SEND_CHANNEL.EMAIL:return"Email";case W.NOTIFICATION_SEND_CHANNEL.WEBHOOK:return"Webhook";default:return""}},qt=()=>({components:{MUIDataTableFilter:{styleOverrides:{header:{marginBottom:0,p:{margin:0}},root:{"& .MuiGrid-container":{marginTop:0,"& .MuiGrid-item":{paddingTop:0}}}}},MuiPopover:{styleOverrides:{root:{"&.MuiPopover-root":{"& .MuiPaper-root:has(.filter-container)":{width:"420px"}}}}}}});function de({config:n,enableTooltip:t=!0,showTitle:s=!1,children:r}){const{status:o,title:l="",sentTime:y="",reason:p=""}=n,h=[l,p].filter(Boolean).join(", ");return e.jsx(xt,{title:t?e.jsxs(e.Fragment,{children:[e.jsx(ae,{color:"inherit",sx:{fontSize:12},children:h}),e.jsx("span",{children:y})]}):null,arrow:!0,placement:"top",children:e.jsxs(T,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"4px"},children:[e.jsxs(T,{position:"relative",minHeight:14,minWidth:14,display:"flex",alignItems:"center",justifyContent:"center",children:[e.jsx(T,{position:"absolute",width:"100%",height:"100%",borderRadius:"50%",bgcolor:Ye[o],style:{opacity:.15}}),e.jsx(T,{position:"absolute",width:"55%",height:"55%",borderRadius:"50%",bgcolor:Ye[o]})]}),e.jsx(ae,{color:"inherit",sx:{fontSize:12},children:s?l:r})]})})}de.propTypes={config:x.object.isRequired,enableTooltip:x.bool,showTitle:x.bool,children:x.node};de.defaultProps={enableTooltip:!0,showTitle:!1,children:null};Se.propTypes={list:x.array.isRequired,label:x.string.isRequired,onDelete:x.func};Se.defaultProps={onDelete:()=>{}};function Se({list:n,label:t,onDelete:s}){const{t:r,locale:o}=re();return e.jsxs(T,{display:"flex",gap:1,alignItems:"center",children:[e.jsxs(ae,{children:[t,": "]}),n.map(l=>{const y=Bt(r,o,{status:l});return e.jsx(Xe,{size:"small",label:e.jsx(T,{display:"flex",alignItems:"center",sx:{gap:"4px"},children:e.jsx(de,{config:y,enableTooltip:!1,children:y.title})}),onDelete:p=>s(p,l)},l)})]})}at.propTypes={filterList:x.array.isRequired,onChange:x.func.isRequired,index:x.number.isRequired,column:x.object.isRequired,filterValues:x.array.isRequired,label:x.string.isRequired,renderLabel:x.func.isRequired};function at({filterList:n,onChange:t,index:s,column:r,filterValues:o,label:l,renderLabel:y}){return e.jsxs(Y,{className:"filter-container",children:[e.jsx(gt,{component:"legend",children:l}),e.jsx(qe,{row:!0,children:o.map(p=>e.jsx(ge,{control:e.jsx(Ke,{checked:n[s].indexOf(p.value??p)>-1,onChange:h=>{const i=[...n];h.target.checked?i[s]=[...i[s],p.value??p]:i[s]=i[s].filter(A=>A!==(p.value??p)),t(i[s],s,r)},name:p.value??p}),label:e.jsx("span",{style:{display:"flex",alignItems:"center"},children:y(p)})},p.value??p))})]})}function ze(n){return e.jsx(at,{...n,renderLabel:t=>e.jsx(de,{enableTooltip:!1,config:{status:t.status},children:t.label})})}ve.propTypes={status:x.number.isRequired,updatedAt:x.string.isRequired,reason:x.string,channel:x.string,onResend:x.func};function ve({status:n,updatedAt:t,reason:s="",channel:r="wallet",onResend:o}){const{t:l,locale:y}=re(),p=Bt(l,y,{status:n,updatedAt:t,reason:s,channel:r});return e.jsxs(T,{display:"flex",alignItems:"center",gap:1,children:[e.jsx(de,{config:p,showTitle:!0}),p.status!=="success"&&e.jsx(Le,{className:"resend-btn",size:"small",startIcon:e.jsx(et,{}),sx:{fontSize:12,color:"rgba(0, 0, 0, 0.87)",fontWeight:400,".MuiButton-startIcon":{mr:"2px"}},onClick:o,children:l("notification.resend")})]})}rt.propTypes={value:x.array.isRequired,onChange:x.func};function rt({value:n,onChange:t}){const{locale:s}=re(),r=se().toDate(),[o,l]=C.useState(null),y=C.useCallback(i=>{l(o?null:i.currentTarget)},[o]),p=!!o,h=C.useCallback(i=>{if(!i.startDate||!i.endDate){K.error("Please select a date range");return}if(se(i.startDate).isAfter(i.endDate)||!se(i.startDate).isValid()||!se(i.endDate).isValid()){K.error("Invalid date range");return}t([i.startDate,i.endDate]),l(null)},[t]);return e.jsxs("div",{children:[e.jsx(ae,{component:"div",variant:"h5",color:"textPrimary",style:{fontSize:18,fontWeight:"bold"},mb:0,children:e.jsxs(Le,{onClick:y,variant:"outlined",size:"small",color:"inherit",children:[pt(n[0],s)," - ",pt(n[1],s)]})}),e.jsx(Me,{open:p,anchorEl:o,onClose:()=>{l(null)},anchorOrigin:{vertical:"bottom",horizontal:"left"},children:e.jsx(ys,{open:!0,maxDate:r,initialDateRange:{startDate:n[0],endDate:n[1]},toggle:y,definedRanges:Ss(r),onChange:h})})]})}ot.propTypes={itemComponent:x.elementType.isRequired};function ot({itemComponent:n,...t}){var o;const{t:s}=re();return!((o=t==null?void 0:t.filterList)!=null&&o.filter(l=>l.length).length)?null:e.jsxs(T,{display:"flex",gap:1,alignItems:"center",children:[e.jsx("div",{className:"toolbar-filter-title",children:s("notification.filter")}),e.jsx("div",{className:"toolbar-filter-content",children:e.jsx(is.TableFilterList,{...t,ItemComponent:n})})]})}function Pe({label:n,onDelete:t,canDelete:s=()=>!0,...r}){const o=t&&typeof t=="function"?t:void 0;let l=!0;return s&&typeof s=="function"&&(l=s({label:n,...r})),e.jsx(Xe,{label:n,variant:"outlined",...o&&l?{onDelete:o}:{}})}Pe.propTypes={label:x.string.isRequired,onDelete:x.func,canDelete:x.func};Pe.defaultProps={canDelete:()=>!0};const Zs=[{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}];lt.propTypes={loading:x.bool,onCancel:x.func,onConfirm:x.func};lt.defaultProps={loading:!1,onCancel:()=>{},onConfirm:()=>{}};function lt({loading:n=!1,onCancel:t,onConfirm:s}){const{t:r}=re(),[o,l]=C.useState(Zs),[y,p]=C.useState(!0),h=(A,O)=>{O.checked=A.target.checked;const R=o.map(S=>({...S,checked:S.value===O.value?O.checked:S.checked}));l(R)},i=A=>{A.stopPropagation(),s({channels:o.filter(O=>O.checked).map(O=>O.value),isResendFailedOnly:y})};return e.jsxs(T,{className:"resend-config",sx:{padding:"16px 24px"},children:[e.jsx(ae,{variant:"body1",component:"div",className:"check-title",sx:{fontWeight:700,mb:1},children:r("notification.config")}),e.jsx(T,{className:"choose-channel",children:e.jsxs(Y,{component:"fieldset",variant:"standard",children:[e.jsx(gt,{component:"legend",children:r("notification.selectChannels")}),e.jsx(qe,{sx:{display:"flex",flexDirection:"row",flexWrap:"wrap",gap:1},children:o.map(A=>e.jsx(ge,{control:e.jsx(Ke,{checked:A.checked,onChange:O=>h(O,A),name:A.value}),label:A.label},A.value))})]})}),e.jsx(T,{className:"resend-config-footer",children:e.jsx(qe,{children:e.jsx(ge,{control:e.jsx(Ke,{checked:y,onChange:A=>p(A.target.checked)}),label:r("notification.resendFailedOnly")})})}),e.jsxs(T,{display:"flex",justifyContent:"flex-end",gap:1,className:"resend-config-footer-tip",children:[e.jsx(Le,{onClick:A=>{A.stopPropagation(),t()},color:"inherit",children:r("common.cancel")}),e.jsxs(Le,{onClick:i,color:"primary",disabled:n,variant:"contained",autoFocus:!0,style:{marginLeft:8},children:[n&&e.jsx(bt,{size:16}),r("common.confirm")]})]})]})}Kt.propTypes={notificationId:x.string.isRequired,handleResend:x.func,resending:x.bool};function Kt({notificationId:n,handleResend:t,resending:s=!1}){const{t:r,locale:o}=re(),l=jt(),y=C.useMemo(()=>vt(l,qt()),[l]),{getReceivers:p,inService:h,teamDid:i,getUser:A,blocklet:O}=tt(),[R,S]=C.useState(!1),[D,G]=C.useState([]),z=Te({anchorEl:null,position:null}),B=Te({anchorEl:null,position:null}),[_,M]=C.useState(null),[J,ie]=C.useState({total:0,pageSize:10,pageCount:0,page:1}),[c,g]=C.useState({searchText:"",page:1,pageSize:10,walletSendStatus:[],pushKitSendStatus:[],emailSendStatus:[],dateRange:[se().subtract(1,"month").startOf("day").toDate(),se().endOf("day").toDate()]}),[j,N]=C.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"}],P=async()=>{if(!R&&n)try{S(!0);const d=await p({notificationId:n,...c}),u=d.list.map(f=>({...f,receiverUser:{...f.receiverUser,avatar:Dt(f.receiverUser.avatar,i,h)}}));G(u),ie(d.paging),S(!1)}catch(d){K.error(d.message),S(!1)}};C.useEffect(()=>{P()},[c]);const a=d=>{d.stopPropagation();const u=d.currentTarget;B.anchorEl=u;const f=u.getBoundingClientRect();B.position={top:f.top+window.scrollY,left:f.left+window.scrollX}},m=d=>d.data.length?e.jsx("div",{style:{display:"flex",alignItems:"center",padding:"10px"},children:e.jsx(me,{className:"resend-btn",size:"small",color:"primary",variant:"contained",startIcon:e.jsx(et,{}),sx:{".MuiButton-startIcon":{mr:"2px"}},onClick:a,children:r("notification.resend")})}):null,$={sort:!1,download:!1,print:!1,selectableRows:"multiple",searchPlaceholder:r("common.search"),searchAlwaysOpen:!1,filterType:"checkbox",searchDebounceTime:300,page:J.page-1,rowsPerPage:J.pageSize,count:J.total,searchText:c.searchText,tableBodyMaxHeight:"calc(80vh - 260px)",rowsSelected:j,onRowSelectionChange:(d,u)=>{N(u.map(f=>f.dataIndex))},customToolbarSelect:m},U=({page:d,rowsPerPage:u,searchText:f,filterList:L})=>{const[,q=[],Z=[],X=[]]=L;c.pageSize!==u?g(H=>({...H,pageSize:u,page:1})):c.page!==d+1?g(H=>({...H,page:d+1})):c.searchText!==f?g(H=>({...H,searchText:f,page:1})):ye(q,c.walletSendStatus)?ye(Z,c.pushKitSendStatus)?ye(X,c.emailSendStatus)||g(H=>({...H,emailSendStatus:X,page:1})):g(H=>({...H,pushKitSendStatus:Z,page:1})):g(H=>({...H,walletSendStatus:q,page:1}))},oe=C.useCallback(async(d,u)=>{if(!u)return!1;const f=await A(u);return f?d==="wallet"?Ys(f):d==="email"?Hs(O,f):d==="pushKit"?Vs(O,f):d==="webhook"?Gs(f):!0:!1},[A,O]),le=C.useCallback(d=>Js(r,d),[r]),pe=()=>{z.anchorEl=null,z.position=null,M(null)},be=()=>{B.anchorEl=null,B.position=null},je=async(d,u,f=!0,L="")=>{if(!(!u.length||!d.length))try{t(d,u,f,L),B.anchorEl||(await Ee(.5),pe())}catch(q){console.error("handleResend error",{error:q})}},v=async({channels:d,isResendFailedOnly:u})=>{const f=j.map(L=>D[L].receiver);await je(d,f,u),await Ee(.5),be(),N([])},b=async(d,u=[],f=!0)=>{try{await je(["webhook"],[d.receiver],f,u)}catch(L){K.error(L.response?L.response.statusText:L.message)}},w=async(d,u,f,L=[],q=!0)=>{if(d.stopPropagation(),Xs(u,f)>=4){K.warning(r("notification.resendLimit"));return}if(!Ge.includes(f)){await b(u,L,q);return}if(d){const X=d.currentTarget,H=X.getBoundingClientRect();z.anchorEl=X,z.position={top:H.top+window.scrollY,left:H.left+window.scrollX}}M({channel:f});try{const X=await oe(f,u.receiver);await Ee(1),M({channel:f,result:X}),(typeof X=="boolean"&&X||Zt(X)&&Object.values(X).every(H=>!!H))&&(await t([f],[u.receiver],q),B.anchorEl||(await Ee(.5),pe()))}catch(X){K.error(X.message)}},I=d=>{g(u=>({...u,dateRange:d,page:1}))},k=(d,u,f,L)=>{d.stopPropagation();const q=f.filter(Z=>Z!==u);g(Z=>({...Z,[L]:q,page:1}))},F=ce(()=>[{label:r("notification.receiver"),name:"receiver",width:200,options:{filter:!1,customBodyRenderLite:d=>{const{receiverUser:u,receiver:f}=D[d];return u?e.jsxs(T,{"data-cy":`member-name-${u.fullName}`,display:"flex",alignItems:"center",gap:1,justifyContent:"flex-start",children:[e.jsx(Tt,{src:`${u.avatar}?imageFilter=resize&w=48&h=48`,size:32,did:f,shape:"circle",style:{borderRadius:"100%",overflow:"hidden"}}),e.jsx(Re,{children:u.fullName})]},f):e.jsx(vs,{size:14,responsive:!1,compact:!0,copyable:!1,did:f})}}},{label:"Wallet",name:"walletSendStatus",width:200,options:{setCellProps:()=>({className:"sent-status-cell"}),filter:!0,filterType:"custom",filterList:c.walletSendStatus??[],customFilterListOptions:{render:d=>e.jsx(Se,{list:d,label:"Wallet",onDelete:(u,f)=>{u.stopPropagation(),k(u,f,F[1].options.filterList,"walletSendStatus")}}),update:Oe},filterOptions:{names:E,fullWidth:!0,logic:De,display:(d,u,f,L)=>e.jsx(ze,{label:"Wallet",filterList:d,onChange:u,index:f,column:L,filterValues:E})},customBodyRenderLite:d=>{const{walletSendStatus:u,walletSendAt:f,walletSendFailedReason:L}=D[d];return e.jsx(ve,{status:u,updatedAt:f,reason:L,channel:"wallet",onResend:q=>w(q,D[d],"wallet",[],!1)})}}},{label:"Push Kit",name:"pushKitSendStatus",width:200,options:{setCellProps:()=>({className:"sent-status-cell"}),customBodyRenderLite:d=>{const{pushKitSendStatus:u,pushKitSendAt:f,pushKitSendFailedReason:L}=D[d];return e.jsx(ve,{status:u,updatedAt:f,reason:L,channel:"pushkit",onResend:q=>w(q,D[d],"pushKit",[],!1)})},filter:!0,filterType:"custom",filterList:c.pushKitSendStatus??[],customFilterListOptions:{render:d=>e.jsx(Se,{list:d,label:"Push Kit",onDelete:(u,f)=>{u.stopPropagation(),k(u,f,F[2].options.filterList,"pushKitSendStatus")}}),update:Oe},filterOptions:{names:E,fullWidth:!0,logic:De,display:(d,u,f,L)=>e.jsx(ze,{label:"Push Kit",filterList:d,onChange:u,index:f,column:L,filterValues:E})}}},{label:"Email",name:"emailSendStatus",width:200,options:{setCellProps:()=>({className:"sent-status-cell"}),customBodyRenderLite:d=>{const{emailSendStatus:u,emailSendAt:f,emailSendFailedReason:L}=D[d];return e.jsx(ve,{status:u,updatedAt:f,reason:L,channel:"email",onResend:q=>w(q,D[d],"email",[],!1)})},filter:!0,filterType:"custom",filterList:c.emailSendStatus??[],customFilterListOptions:{render:d=>e.jsx(Se,{list:d,label:"Email",onDelete:(u,f)=>{u.stopPropagation(),k(u,f,F[3].options.filterList,"emailSendStatus")}}),update:Oe},filterOptions:{names:E,fullWidth:!0,logic:De,display:(d,u,f,L)=>e.jsx(ze,{label:"Email",filterList:d,onChange:u,index:f,column:L,filterValues:E})}}},{label:"Webhook",name:"webhook",width:200,options:{filter:!1,setCellProps:()=>({className:"sent-status-cell"}),customBodyRenderLite:d=>{const{webhook:u}=D[d];if(!u)return null;const f=Object.entries(u)[0];if(!f)return null;const[L,q]=f,Z=q[0];return e.jsx(T,{display:"flex",flexDirection:"column",gap:1,children:e.jsxs(T,{className:"webhook-item",fontSize:12,children:[e.jsx(Re,{maxLength:30,children:L},L),e.jsx(ve,{status:Z.status,updatedAt:Z.sendAt,reason:Z.failedReason,channel:"webhook",onResend:X=>w(X,D[d],"webhook",[L],!1)})]},L)})}}},{label:r("common.createdAt"),name:"createdAt",width:100,options:{filter:!1,customBodyRenderLite:d=>{const{createdAt:u}=D[d];return e.jsx(Ot,{value:u,locale:o,shouldUpdate:!0})}}}],[D,o,c,r]),ne=[e.jsx(rt,{value:c.dateRange,onChange:I},"date-picker"),e.jsx(me,{variant:"contained",size:"small",color:"primary",loading:R,startIcon:e.jsx(Ft,{}),onClick:()=>P(),sx:{".MuiButton-startIcon":{mr:"2px"}},style:{marginLeft:8},children:r("common.refresh")},"refresh")];return e.jsx(T,{sx:{overflow:"auto",".MuiTableCell-head":{whiteSpace:"nowrap",fontWeight:"bold"},".MuiTableCell-root":{paddingRight:"8px",whiteSpace:"nowrap"}},children:e.jsx(tn,{children:e.jsxs(yt,{theme:y,children:[e.jsx(Rt,{className:"receivers-table",locale:o,loading:R,columns:F,data:D,onChange:U,options:$,customButtons:ne,components:{TableFilterList:d=>e.jsx(ot,{...d,itemComponent:u=>e.jsx(Pe,{...u,canDelete:()=>!1})})}}),z.anchorEl&&e.jsx(Me,{open:!!z.anchorEl,anchorReference:"anchorPosition",anchorPosition:z.position,onClose:pe,anchorOrigin:{vertical:"center",horizontal:"right"},transformOrigin:{vertical:"center",horizontal:"left"},children:e.jsxs(sn,{children:[e.jsxs(ae,{variant:"body1",component:"div",className:"check-title",children:[_==null?void 0:_.channel," Checking"]}),e.jsx(T,{display:"flex",flexDirection:"column",sx:{gap:"4px"},children:le(_==null?void 0:_.channel).map(d=>{var q,Z;const{type:u,pass:f,fail:L}=d;return!(_!=null&&_.result)||(q=_==null?void 0:_.result)!=null&&q[u]?e.jsxs(ae,{variant:"body1",component:"div",className:"check-item",display:"flex",alignItems:"center",sx:{gap:"4px",color:(Z=_==null?void 0:_.result)!=null&&Z[u]?Ae.success.main:"inherit"},children:[_!=null&&_.result?e.jsx(_t,{}):e.jsx(bt,{size:12,sx:{color:Ae.primary.main}}),e.jsx("span",{children:f})]},u):e.jsxs(ae,{variant:"body1",component:"div",display:"flex",alignItems:"center",className:"check-item",sx:{gap:"4px",color:Ae.error.main},children:[e.jsx(kt,{}),e.jsx("span",{children:L})]},u)})})]})}),B.anchorEl&&e.jsx(Me,{open:!!B.anchorEl,anchorReference:"anchorPosition",anchorPosition:B.position,onClose:be,anchorOrigin:{vertical:"center",horizontal:"right"},transformOrigin:{vertical:"center",horizontal:"left"},children:e.jsx(lt,{loading:s,onCancel:be,onConfirm:v})})]})})})}const en=C.memo(Kt),tn=ue.div`
|
|
2
|
-
td.MuiTableCell-footer {
|
|
3
|
-
border: none !important;
|
|
4
|
-
}
|
|
5
|
-
.sent-status-cell {
|
|
6
|
-
.resend-btn {
|
|
7
|
-
display: none;
|
|
8
|
-
}
|
|
9
|
-
&:hover {
|
|
10
|
-
.resend-btn {
|
|
11
|
-
display: flex;
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
`,sn=ue.div`
|
|
16
|
-
padding: 8px 16px;
|
|
17
|
-
.check-title {
|
|
18
|
-
font-weight: 500;
|
|
19
|
-
margin-bottom: 8px;
|
|
20
|
-
&::first-letter {
|
|
21
|
-
text-transform: uppercase;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
.check-item {
|
|
25
|
-
svg {
|
|
26
|
-
font-size: 16px;
|
|
27
|
-
}
|
|
28
|
-
font-size: 12px;
|
|
29
|
-
}
|
|
30
|
-
`,Ce=n=>n>=1e6?`${(n/1e6).toFixed(1)}M`:n>=1e3?`${(n/1e3).toFixed(1)}K`:n;function nn(n){const{wallet:t,push:s,email:r,webhook:o}=n;return[{name:"Wallet",value:e.jsx(he,{item:t})},{name:"Push",value:e.jsx(he,{item:s})},{name:"Email",value:e.jsx(he,{item:r})},...o.total>0?[{name:"Webhook",value:e.jsx(he,{item:o,isWebhook:!0})}]:[]]}function an(n,t,s){const{wallet:r,push:o,email:l,webhook:y}=n;return[{name:"Wallet",value:e.jsx(xe,{loading:s,channel:W.NOTIFICATION_SEND_CHANNEL.WALLET,item:r,onResend:t})},{name:"Push",value:e.jsx(xe,{loading:s,channel:W.NOTIFICATION_SEND_CHANNEL.PUSH,item:o,onResend:t})},{name:"Email",value:e.jsx(xe,{loading:s,channel:W.NOTIFICATION_SEND_CHANNEL.EMAIL,item:l,onResend:t})},...y.total>0?[{name:"Webhook",value:e.jsx(xe,{loading:s,channel:W.NOTIFICATION_SEND_CHANNEL.WEBHOOK,item:y,isWebhook:!0,onResend:t})}]:[]]}_e.propTypes={statistics:x.object.isRequired,onResend:x.func,mode:x.oneOf(["simple","detail"]),resending:x.bool};_e.defaultProps={mode:"simple",onResend:()=>{},resending:!1};he.propTypes={item:x.object.isRequired,isWebhook:x.bool};he.defaultProps={isWebhook:!1};function he({item:n,isWebhook:t=!1}){const{t:s}=re(),r=t?n.success.length:n.success,o=n.total,l=r===o?"success":"failed";return e.jsx(T,{display:"flex",alignItems:"center",justifyContent:"flex-start",gap:2,children:e.jsx(T,{display:"flex",alignItems:"center",gap:1,children:e.jsxs(de,{config:{status:l},enableTooltip:!1,children:[Ce(r)," / ",Ce(o)," ",s("notification.sendStatus.success")]})})})}xe.propTypes={item:x.object.isRequired,isWebhook:x.bool,channel:x.string,onResend:x.func,loading:x.bool};xe.defaultProps={isWebhook:!1,channel:W.NOTIFICATION_SEND_CHANNEL.WALLET,onResend:()=>{},loading:!1};function xe({channel:n,item:t,isWebhook:s=!1,onResend:r,loading:o}){const{t:l}=re(),{success:y,failed:p,pending:h}=t,i=Qs(n),A=s?y.length:y,O=s?p.length:p,R=s?h.length:h,S=async B=>{B.stopPropagation();const _=s?[...new Set([...y,...p].map(M=>M))]:[];await r([n],[],!0,_)},D=A+O,G=D>0?A/D*100:0,z=D>0?O/D*100:0;return e.jsxs(rn,{successRatio:G,failedRatio:z,children:[e.jsxs(ae,{variant:"h6",children:[i," (",t.total,")"]}),e.jsxs(ae,{variant:"body1",sx:{mb:2},children:[e.jsx("span",{style:{color:Ye.success,fontWeight:600,fontSize:24},children:Ce(A)}),e.jsx("small",{style:{paddingLeft:4},children:l("notification.sendStatus.success")})]}),e.jsxs(T,{className:"unsent-area",children:[e.jsxs(T,{children:[e.jsxs(de,{config:{status:"failed"},enableTooltip:!1,children:[Ce(O)," ",l("notification.sendStatus.failed")]}),e.jsxs(de,{config:{status:"pending"},enableTooltip:!1,children:[Ce(R)," ",l("notification.sendStatus.pending")]})]}),O>0&&e.jsx(T,{className:"resend-btn",children:e.jsx(me,{size:"small",color:"primary",loading:o,variant:"contained",startIcon:e.jsx(et,{}),sx:{".MuiButton-startIcon":{mr:"2px"}},onClick:S,children:l("notification.resend")})})]})]})}function _e({statistics:n,mode:t="simple",onResend:s,resending:r}){const o=ce(()=>t==="simple"?nn(n):an(n,s,r),[n,t]);return t==="simple"?e.jsx("div",{children:o.map(l=>e.jsx(At,{style:{alignItems:"flex-start",marginBottom:t==="simple"?0:16},valueComponent:"div",nameWidth:100,name:l.name,children:l.value},l.name))}):e.jsx(dt,{container:!0,spacing:2,children:o.map(l=>e.jsx(dt,{item:!0,md:4,sm:6,xs:12,children:l.value},l.name))})}const rn=ue(T)`
|
|
31
|
-
display: flex;
|
|
32
|
-
flex-direction: column;
|
|
33
|
-
align-items: flex-start;
|
|
34
|
-
padding: 16px;
|
|
35
|
-
border-radius: 8px;
|
|
36
|
-
background: ${({successRatio:n,failedRatio:t,theme:s})=>n===0&&t===0?s.palette.grey[300]:`linear-gradient(to right, ${Ht(s.palette.success.light,.4)} ${n}%, ${s.palette.grey[100]} ${n}%)`};
|
|
37
|
-
transition: 'background 0.5s ease';
|
|
38
|
-
cursor: pointer;
|
|
39
|
-
.unsent-area {
|
|
40
|
-
width: 100%;
|
|
41
|
-
position: relative;
|
|
42
|
-
.resend-btn {
|
|
43
|
-
position: absolute;
|
|
44
|
-
right: 0;
|
|
45
|
-
bottom: 0;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
`;Mt.propTypes={notification:x.object.isRequired,onCancel:x.func,blocklet:x.object.isRequired,tab:x.string};function Mt({notification:n,onCancel:t=()=>{},blocklet:s,tab:r="info"}){const{t:o,locale:l}=re(),{getComponent:y,resendNotification:p}=tt(),[h,i]=C.useState(!1),A=ce(()=>y(n.componentDid)||s,[s,n.componentDid]),O=Te({tab:r||"info"}),R=C.useCallback(async(c,g,j=!0,N=[])=>{var a;if(!c.length||!n.id)return;const E=g.length>0?g:(a=n==null?void 0:n.receivers)==null?void 0:a.map(m=>m.receiver);if(!E.length)return;let P=[...c];if(P.includes(W.NOTIFICATION_SEND_CHANNEL.PUSH)&&!Wt(s)&&(K.warning(o("notification.sendStatus.reason.unavailable",{channel:"Push Kit"})),P=P.filter(m=>m!==W.NOTIFICATION_SEND_CHANNEL.PUSH)),P.includes(W.NOTIFICATION_SEND_CHANNEL.EMAIL)&&!zt(s)&&(K.warning(o("notification.sendStatus.reason.unavailable",{channel:"Email"})),P=P.filter(m=>m!==W.NOTIFICATION_SEND_CHANNEL.EMAIL)),!!P.length)try{i(!0),await p({notificationId:n.id,receivers:E,channels:P,resendFailedOnly:j,...P.includes("webhook")&&N.length?{webhookUrls:N}:{}}),K.success("Message has been sent!")}catch(m){console.error("handleResend error",{error:m}),K.error(m.response?m.response.statusText:m.message)}finally{i(!1)}},[s,n.id,n==null?void 0:n.receivers,p,o]),S=ce(()=>cs(n),[n]),D=ce(()=>ds(n),[n]),G=ce(()=>S?n==null?void 0:n.actorInfo:[],[n]),z=ce(()=>{var c;return(s==null?void 0:s.did)||((c=s==null?void 0:s.meta)==null?void 0:c.did)||""},[s]);function B(){return[{name:o("notification.from"),value:S&&D?e.jsx(hs,{actors:G,teamDid:z,size:32,showName:!0}):e.jsx(xs,{size:32,blocklet:A,showName:!0,hideDot:!0})},{name:o("notification.notificationTitle"),value:e.jsx(Re,{maxLength:50,children:n.title})},{name:o("notification.body"),value:S?e.jsx(gs,{notification:n,blocklet:s}):e.jsx(bs,{notification:n,rows:0})},{name:o("notification.severity"),value:e.jsx(Ne,{severity:n.severity})},{name:o("notification.createdAt"),value:e.jsx(as,{value:n.createdAt,locale:l,shouldUpdate:!0,type:"all"})}].map(g=>e.jsx(At,{style:{alignItems:"flex-start"},valueComponent:"div",nameWidth:120,name:g.name,children:g.value},g.name))}const _={info:{label:o("common.basicInfo"),value:"info",component:B},receivers:{label:o("notification.receiver"),value:"receivers"},statistics:{label:o("notification.statistics"),value:"statistics"}},M=Object.values(_).map(({label:c,value:g})=>({label:c,value:g})),J=_[O.tab]||_.info,ie=c=>{O.tab=c};return e.jsx(Nt,{title:o("notification.notificationDetails"),fullWidth:!0,maxWidth:"lg",onClose:()=>{O.tab="info",t()},open:!0,actionsPosition:"left",sx:{".ux-dialog_header":{paddingBottom:0},".MuiDialogContent-root":{paddingTop:0}},children:e.jsxs(ln,{children:[e.jsx(T,{mx:3,className:"tabs",children:e.jsx(wt,{tabs:M,current:O.tab,onChange:ie,scrollButtons:"auto"})}),e.jsxs("div",{className:"body",children:[O.tab==="receivers"&&e.jsx(en,{notificationId:n.id,resending:h,handleResend:R}),O.tab==="statistics"&&e.jsx(_e,{statistics:n.statistics,mode:"detail",resending:h,onResend:R}),O.tab==="info"&&e.jsx(J.component,{})]})]})})}const on=C.memo(Mt),ln=ue.div`
|
|
49
|
-
& > .notification-row {
|
|
50
|
-
padding: 0;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
.tabs {
|
|
54
|
-
margin: 0;
|
|
55
|
-
}
|
|
56
|
-
.body {
|
|
57
|
-
margin-top: 16px;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
.channel-item {
|
|
61
|
-
display: flex;
|
|
62
|
-
padding: 4px;
|
|
63
|
-
justify-content: flex-start;
|
|
64
|
-
align-items: center;
|
|
65
|
-
gap: 8px;
|
|
66
|
-
> p {
|
|
67
|
-
font-size: 15px;
|
|
68
|
-
}
|
|
69
|
-
.resend-btn {
|
|
70
|
-
svg {
|
|
71
|
-
font-size: 16px;
|
|
72
|
-
}
|
|
73
|
-
display: flex;
|
|
74
|
-
align-items: center;
|
|
75
|
-
font-size: 12px;
|
|
76
|
-
cursor: pointer;
|
|
77
|
-
&.disabled {
|
|
78
|
-
cursor: not-allowed;
|
|
79
|
-
color: ${Ae.text.disabled};
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
`;we.propTypes={blocklet:x.object,label:x.string};we.defaultProps={blocklet:null,label:""};const cn=ue.div`
|
|
84
|
-
display: flex;
|
|
85
|
-
justify-items: flex-start;
|
|
86
|
-
align-items: center;
|
|
87
|
-
gap: 8px;
|
|
88
|
-
.name {
|
|
89
|
-
display: block;
|
|
90
|
-
max-width: 260px;
|
|
91
|
-
white-space: nowrap;
|
|
92
|
-
overflow: hidden;
|
|
93
|
-
text-overflow: ellipsis;
|
|
94
|
-
}
|
|
95
|
-
`;function we({blocklet:n,label:t}){var s;return e.jsx(cn,{children:n?e.jsxs(e.Fragment,{children:[e.jsx(Lt,{size:24,blocklet:n,ancestors:n.ancestors}),e.jsx("span",{className:"name",children:n.title||((s=n.meta)==null?void 0:s.title)})]}):e.jsx("span",{className:"name",children:t})})}ct.propTypes={list:x.array.isRequired,label:x.string.isRequired,onDelete:x.func};ct.defaultProps={onDelete:()=>{}};function ct({list:n,label:t,onDelete:s}){return e.jsxs(T,{display:"flex",gap:1,alignItems:"center",children:[e.jsxs(ae,{children:[t,": "]}),n.map(r=>e.jsx(Xe,{size:"small",label:e.jsx(T,{display:"flex",alignItems:"center",sx:{gap:"4px"},children:e.jsx(Ne,{severity:r})}),onDelete:o=>s(o,r)},r))]})}function dn(n){return e.jsx(at,{...n,renderLabel:t=>e.jsx(Ne,{severity:t})})}function un({customTableButtons:n}){var je;const{t,locale:s}=re(),r=jt(),o=C.useMemo(()=>vt(r,qt()),[r]),[l,y]=C.useState(!1),{data:p,paging:h,blocklet:i,fetch:A,getComponent:O,componentDids:R,inService:S,teamDid:D}=tt(),G=C.useRef(null),[z,B]=C.useState(null),[_,M]=C.useState("info"),J=Cs(),[ie,c]=C.useState(!1),g=`notification-records-${(je=i.meta)==null?void 0:je.did}`,j=rs(g),[N,E]=C.useState({pageSize:j.rowsPerPage||10,page:j.page?j.page+1:1,dids:j.dids||[],dateRange:j.dateRange||[se().subtract(1,"month").startOf("day").toDate(),se().endOf("day").toDate()]}),P=ce(()=>{if(!i.children||!i.children.length)return[];const v=[];return i.children.forEach(b=>{var I;const w=b.did||((I=b.meta)==null?void 0:I.did);R.includes(w)&&(b.ancestors=[i],v.push(b))}),v},[R,i]),a=async v=>{try{y(!0),await A(v),y(!1)}finally{y(!1)}};C.useEffect(()=>{a(N)},[N]),C.useEffect(()=>{const v=p.find(b=>b.id===(z==null?void 0:z.id));z&&v&&B({...v})},[p]);const m=(v,b,w,I)=>{v.stopPropagation();const k=w.filter(F=>F!==b);E(F=>({...F,[I]:k,page:1}))},$=({page:v,rowsPerPage:b,filterList:w})=>{const[I=[],,,,k=[]]=w;N.pageSize!==b?E(F=>({...F,pageSize:b,page:1})):N.page!==v+1?E(F=>({...F,page:v+1})):ye(N.dids,I)?ye(N.severities,k)||E(F=>({...F,severities:k,page:1})):E(F=>({...F,dids:I,page:1}))},U=C.useCallback(()=>{B(null),M("info")},[]),oe=C.useCallback(()=>{A(N)},[A,N]),le=[{label:t("notification.from"),name:"sender",width:400,options:{filter:!0,filterType:"custom",customFilterListOptions:{render:v=>v.map((b,w)=>{var k;if(b==="system")return e.jsx("span",{children:t("notification.system")},`system-${w}`);const I=P.find(F=>{var d;return(F.did||((d=F.meta)==null?void 0:d.did))===b});return e.jsx(we,{blocklet:I,label:(I==null?void 0:I.title)||((k=I==null?void 0:I.meta)==null?void 0:k.title)},b)}),update:(v,b,w)=>(v[w].splice(b,1),v)},filterOptions:{names:P,logic:(v,b)=>b.length?!b.includes(v):!1,display:(v,b,w,I)=>e.jsxs(Y,{style:{width:"380px"},children:[e.jsx(Vt,{id:"demo-simple-select-label",style:{background:"#ffffff"},children:"Sender"}),e.jsxs(Yt,{multiple:!0,value:v[w],renderValue:k=>e.jsx(T,{display:"flex",gap:1,alignItems:"center",style:{overflow:"hidden",textOverflow:"ellipsis"},children:k.map(F=>{var d;if(F==="system")return e.jsx("span",{children:t("notification.system")},F);const ne=P.find(u=>{var L;return(u.did||((L=u.meta)==null?void 0:L.did))===F});return e.jsx(we,{blocklet:ne,label:(ne==null?void 0:ne.title)||((d=ne==null?void 0:ne.meta)==null?void 0:d.title)},F)})}),onChange:k=>{v[w]=k.target.value,b(v[w],w,I)},children:[e.jsx(ut,{value:"system",children:t("notification.system")}),P.map(k=>{var ne,d;const F=k.did||((ne=k.meta)==null?void 0:ne.did);return e.jsx(ut,{value:F,children:e.jsx(we,{blocklet:k,label:k.title||((d=k.meta)==null?void 0:d.title)})},F)})]})]})},customBodyRenderLite:v=>{var I,k;const b=p[v],w=O(b.componentDid);return e.jsxs(T,{display:"flex",alignItems:"center",gap:1,children:[w?e.jsx(Lt,{size:32,blocklet:w,ancestors:w.ancestors??[]}):e.jsx(js,{blocklet:i,size:32}),e.jsx(Re,{maxLength:50,children:((I=w==null?void 0:w.meta)==null?void 0:I.title)||((k=i==null?void 0:i.meta)==null?void 0:k.title)})]})}}},{label:t("notification.receiver"),name:"receivers",width:300,options:{filter:!1,customBodyRenderLite:v=>{const b=p[v],{receivers:w}=b;return e.jsx(Gt,{total:w.length,renderSurplus:I=>I<100?e.jsxs("span",{children:["+",I]}):e.jsx("span",{children:"99+"}),max:3,sx:{justifyContent:"flex-end",height:"32px",".MuiAvatar-root":{width:"32px",height:"32px",fontSize:"12px",border:0,zIndex:2}},onClick:I=>{I.stopPropagation(),B(b),M("receivers")},children:w.map(I=>{const{receiverUser:k}=I,F=Dt(k.avatar,D,S);return e.jsx(Tt,{alt:k.fullName,src:`${F}?imageFilter=resize&w=48&h=48`,size:32,did:I.receiver,shape:"circle",style:{borderRadius:"100%",overflow:"hidden"}},I.receiver)})})}}},{label:t("notification.statistics"),name:"statistics",width:400,options:{filter:!1,customBodyRenderLite:v=>{const b=p[v];return e.jsx(T,{onClick:w=>{w.stopPropagation(),B(b),M("statistics")},children:e.jsx(_e,{statistics:b.statistics})})}}},{label:t("notification.notificationPreview"),name:"data",options:{filter:!1,customBodyRenderLite:v=>{const b=p[v];return e.jsx(Re,{maxLength:50,children:b.title})}}},{label:t("notification.severity"),name:"severity",width:200,options:{setCellProps:()=>({className:"severity-cell"}),customBodyRenderLite:v=>{const b=p[v];return e.jsx(Ne,{severity:b.severity})},filter:!0,filterType:"custom",filterList:N.severities??[],customFilterListOptions:{render:v=>e.jsx(ct,{list:v,label:t("notification.severity"),onDelete:(b,w)=>{b.stopPropagation(),m(b,w,le[4].options.filterList,"severities")}}),update:Oe},filterOptions:{names:mt,fullWidth:!0,logic:De,display:(v,b,w,I)=>e.jsx(dn,{label:t("notification.severity"),filterList:v,onChange:b,index:w,column:I,filterValues:mt})}}},{label:t("common.createdAt"),name:"createdAt",width:300,options:{filter:!1,customBodyRenderLite:v=>{const{createdAt:b}=p[v];return e.jsx(Ot,{value:b,locale:s,shouldUpdate:!0})}}}],pe=v=>{E(b=>({...b,dateRange:v,page:1}))},be=[e.jsxs(T,{display:"flex",alignItems:"center",gap:1.5,children:[e.jsx(Jt,{onClick:()=>c(!0),sx:{p:J?0:void 0},children:e.jsx(ls,{})},"settings"),J?e.jsx(ae,{children:t("common.setting")}):null]}),...n||[]];return e.jsxs(T,{ref:G,sx:{overflow:"auto",".MuiTableCell-head":{whiteSpace:"nowrap",fontWeight:"bold"},".MuiTableCell-root":{paddingRight:"8px",whiteSpace:"nowrap"}},children:[e.jsx(pn,{children:e.jsx(yt,{theme:o,children:e.jsx(Rt,{className:"main-table",verticalKeyWidth:100,loading:l,locale:s,columns:le,data:p,durable:g,onChange:$,options:{sort:!1,download:!1,print:!1,search:!1,expandableRowsOnClick:!0,page:h.page-1,rowsPerPage:h.pageSize,count:h.total,...j,onRowClick:(v,{dataIndex:b})=>{B(p[b])}},customPreButtons:[e.jsx(rt,{value:N.dateRange,onChange:pe})],customButtons:be,components:{TableFilterList:v=>e.jsx(ot,{...v,itemComponent:b=>e.jsx(Pe,{...b,canDelete:w=>{var k;const I=(k=w==null?void 0:w.columnNames)==null?void 0:k[(w==null?void 0:w.index)||0];return(I==null?void 0:I.name)==="sender"}})})}})})}),z&&e.jsx(on,{refresh:oe,onCancel:U,notification:z,blocklet:i,tab:_}),e.jsx(Nt,{title:`${t("common.notification")} ${t("common.setting")}`,fullWidth:!0,maxWidth:"md",open:ie,onClose:()=>c(!1),PaperProps:{style:{minHeight:"500px"}},children:e.jsx(T,{sx:{mt:"-16px",overflowY:"hidden"},children:e.jsx(Ds,{})})})]})}const pn=ue.div`
|
|
96
|
-
td.MuiTableCell-footer {
|
|
97
|
-
border: none !important;
|
|
98
|
-
}
|
|
99
|
-
.sent-status-cell {
|
|
100
|
-
.resend-btn {
|
|
101
|
-
display: none;
|
|
102
|
-
}
|
|
103
|
-
&:hover {
|
|
104
|
-
.resend-btn {
|
|
105
|
-
display: flex;
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
.custom-toobar-btns {
|
|
111
|
-
gap: 4px;
|
|
112
|
-
}
|
|
113
|
-
`;$t.propTypes={blocklet:x.object.isRequired,customTableButtons:x.array};$t.defaultProps={customTableButtons:[]};function $t({blocklet:n={},customTableButtons:t}){return e.jsx(Ps,{blocklet:n,children:e.jsx(un,{customTableButtons:t})})}export{$t as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as B,a0 as q,bT as _,I as ge,bU as fe,a2 as je,a9 as ye,bA as we}from"./vendor-ux-did-connect-CJ8Q_v7u.js";import{t as ke,l as de,j as Ee}from"./vendor-hooks-BgUTpb6X.js";import{r as S,b as Q}from"./vendor-react-DEoibe3W.js";import{d as X}from"./InfoOutlined-DwH0ULaz.js";import{j as ve,B as Ce}from"./vendor-arcblock-BPZ1V4pg.js";import{U as Te,C as Se,I as Ie}from"./index-DTLUTgmo.js";import{D as F,aB as Re,aC as K,G as pe,y as De}from"./index-3aRBjK5P.js";import{u as U}from"./dashboard-CEB4GFys.js";import{u as ze}from"./use-mobile-BAa0wi8o.js";import{H as t,j as e,D as Pe,aj as Ae,t as We,aa as m,O as re,T as I,ab as M,ak as Z,z as Oe,y as H,bs as le,bR as Y,ad as $,L as J,A as G,bc as qe,E as L,I as ee,C as $e,bq as Le,al as z,cg as Be,X as Me,bb as V,bp as He,b4 as Ne,ch as Fe,ci as Ue,b5 as _e,an as Ke,c0 as Ye,s as ue,v as Ve,cj as Je,ck as Ge,cl as Qe,cm as Xe}from"./vendor-mui-core-BV2FUxWJ.js";import{d as Ze}from"./ExpandLess-DeQLEewB.js";import{b as he,z as et,A as tt}from"./vendor-utils-rHXShPKm.js";import{C as ot}from"./confirm-t4d18Hpz.js";import{A as st}from"./actions-t0ZB56yH.js";import{T as ae}from"./table-tips-3qAdlLSz.js";import"./lottie-web-jYmAQWuC.js";import"./Phone-BkOMNOMO.js";import"./Location-DxPzfR_p.js";import"./Email-BirbvqZ3.js";import"./Timezone-D91Of94T.js";import"./useLocalStorage-DiA2Rpy-.js";import"./index-8eXqqyHQ.js";import"./PlayArrow-DSHRafhE.js";import"./get-safe-url-DHdoXqD0.js";import"./session-yHau46Qm.js";import"./use-blocklet-logo-vRumIAeK.js";import"./dot-DX56IFTM.js";import"./useAsync-Dv214fz8.js";import"./useSetState-CWq0AVWn.js";import"./use-mobile-C21X4TYN.js";import"./MoreHoriz-Bb60Z0iy.js";const nt=o=>{var f,w;const[p,u]=S.useState(null),[E,s]=S.useState(!o),[R,c]=S.useState(null),{blocklet:a}=pe(),d=(w=(f=a==null?void 0:a.site)==null?void 0:f.domainAliases[0])==null?void 0:w.value,j=S.useMemo(()=>{const b={};return p&&(p.sources.forEach(l=>{b[l.did]={source:l,events:[],count:0}}),p.events.forEach(l=>{b[l.source]&&(b[l.source].events.push(l),b[l.source].count+=1)})),b},[p]),y=async()=>{try{if(s(!0),!d)return;const l=await(await fetch(`https://${d}/.well-known/service/openevent.json`)).json();u(l),c(null)}catch(b){c(b instanceof Error?b:new Error(String(b)))}finally{s(!1)}};return S.useEffect(()=>{y()},[d]),{openEvent:p,setOpenEvent:u,eventsBySource:j,loading:E,error:R,loadData:y}};function te({eventsBySource:o,selectedEvents:p,setSelectedEvents:u,error:E}){const{t:s}=B(),[R,c]=S.useState({}),a=S.useMemo(()=>{const l={};return Object.entries(o).forEach(([g,{events:h}])=>{const T=h.filter(x=>p[`${x.type}-${x.source}`]).length;l[g]=T}),l},[o,p]),d=S.useMemo(()=>Object.values(a).reduce((l,g)=>l+g,0),[a]),j=S.useMemo(()=>Object.values(o).reduce((l,{events:g})=>l+g.length,0),[o]),y=(l,g)=>{g.stopPropagation(),c({...R,[l]:!R[l]})},f=l=>{const g=`${l.type}-${l.source}`;u(h=>({...h,[g]:!h[g]}))},w=(l,g)=>{const h={};l.forEach(T=>{const x=`${T.type}-${T.source}`;h[x]=!g}),u(T=>({...T,...h}))},b=l=>{const g={};Object.values(o).forEach(({events:h})=>{h.forEach(T=>{const x=`${T.type}-${T.source}`;g[x]=l.target.checked})}),u(g)};return e.jsxs(m,{sx:{width:"100%"},children:[e.jsxs(m,{sx:{display:"flex",alignItems:"center",mb:1,mt:1},children:[e.jsx(le,{control:e.jsx(Y,{onChange:b,checked:d>0&&d===j}),label:e.jsxs(m,{sx:{display:"flex",alignItems:"center",cursor:"pointer"},children:[s("webhookEndpoint.selectAllEvents"),e.jsx(m,{sx:{display:"flex",alignItems:"center"},children:e.jsx($,{title:s("webhookEndpoint.selectAllEventsTooltip"),placement:"right",children:e.jsx(X,{fontSize:"small",sx:{ml:.5,cursor:"help"}})})})]}),sx:{m:0}}),d>0&&e.jsx(I,{variant:"body2",color:"primary",sx:{ml:"auto"},children:s("webhookEndpoint.selectedEventsCount",{count:d})})]}),e.jsx(m,{sx:{maxHeight:"50vh",overflow:"auto"},children:e.jsx(J,{disablePadding:!0,sx:{border:"1px solid",borderColor:"divider",borderRadius:"4px"},children:Object.entries(o).map(([l,{source:g,events:h,count:T}],x)=>{const D=a[l]>0,k=a[l]===h.length&&h.length>0,A=R[l];return e.jsxs(Q.Fragment,{children:[e.jsx(G,{sx:{borderBottom:({palette:n})=>x<Object.keys(o).length-1?`1px solid ${n.divider}`:"none",px:2,py:1.5,"&:hover":{bgcolor:"rgba(0, 0, 0, 0.02)"}},children:e.jsxs(m,{sx:{display:"flex",width:"100%",justifyContent:"space-between",alignItems:"center"},onClick:n=>{n.target.closest(".MuiFormControlLabel-root")||y(l,n)},children:[e.jsx(m,{sx:{display:"flex",alignItems:"center"},children:h.length>0&&e.jsx(le,{control:e.jsx(Y,{checked:k,indeterminate:D&&!k,onChange:n=>{n.stopPropagation(),w(h,k)}}),label:e.jsxs(m,{sx:{display:"flex",alignItems:"center",gap:1},children:[g.logo&&e.jsx(qe,{src:g.logo,sx:{width:24,height:24}}),e.jsx(m,{children:g.title||l}),D&&e.jsx(L,{label:s("webhookEndpoint.selectedCount",{count:a[l]}),size:"small",sx:{mt:"2px",height:"20px",fontSize:"12px",bgcolor:n=>`${n.palette.primary.main}20`,color:"primary.main",fontWeight:500}})]}),sx:{m:0,"& .MuiFormControlLabel-label":{flex:1}}})}),e.jsxs(m,{sx:{display:"flex",alignItems:"center"},children:[e.jsx(I,{variant:"body2",color:"text.secondary",sx:{mr:1},children:s("webhookEndpoint.eventsCount",{count:T})}),h.length>0&&e.jsx(ee,{size:"small",edge:"end",children:A?e.jsx(Ze,{}):e.jsx(ve,{})})]})]})}),h.length>0&&e.jsx($e,{in:A,timeout:"auto",unmountOnExit:!0,children:e.jsx(J,{disablePadding:!0,sx:{pl:2,pr:2,py:1,bgcolor:"rgba(0, 0, 0, 0.01)"},children:h.map(n=>{const r=`${n.type}-${n.source}`,i=!!p[r];return e.jsx(G,{dense:!0,sx:{py:.75},onClick:()=>f(n),children:e.jsxs(m,{sx:{display:"flex",alignItems:"flex-start",width:"100%"},children:[e.jsx(Y,{checked:i,sx:{mr:1}}),e.jsxs(m,{children:[e.jsx(I,{variant:"body1",sx:{cursor:"pointer"},children:n.type}),e.jsx(I,{variant:"caption",color:"text.disabled",sx:{display:"block",cursor:"pointer"},children:n.description})]})]})},r)})})})]},l)})})}),E&&e.jsx(Le,{error:!0,sx:{mt:1},children:E})]})}te.propTypes={eventsBySource:t.objectOf(t.shape({source:t.shape({did:t.string.isRequired,title:t.string,description:t.string,version:t.string,logo:t.string}).isRequired,events:t.arrayOf(t.shape({type:t.string.isRequired,description:t.string.isRequired,source:t.string.isRequired})).isRequired,count:t.number.isRequired})).isRequired,selectedEvents:t.objectOf(t.bool).isRequired,setSelectedEvents:t.func.isRequired,error:t.string};te.defaultProps={error:null};function oe({id:o,url:p,description:u,enabledEvents:E,onSubmit:s,onClose:R}){var n;const{t:c}=B(),[a,d]=S.useState({}),{teamDid:j}=U(),{api:y}=F(),{loading:f,error:w,eventsBySource:b}=nt(),{control:l,handleSubmit:g,formState:{errors:h},reset:T,setValue:x,trigger:D}=Re({defaultValues:{url:"",description:""}});S.useEffect(()=>{const r=Object.values(a).some(i=>i);x("selectedEvents",r?"valid":""),D("selectedEvents")},[a,x,D]);const k=()=>{d({}),T(),R()},A=async r=>{const i=Object.keys(a).filter(v=>a[v]),C={url:r.url,description:r.description,enabledEvents:i.map(v=>{const[P,O]=v.split("-");return!P||!O?null:{type:P,source:O}}).filter(Boolean)};try{if(o){const v=await y.updateWebhookEndpoint({input:{teamDid:j,id:o,data:C}});q.success(`${c("webhookEndpoint.updateWebhook")} ${c("webhookEndpoint.success")}`),s(v)}else{const v=await y.createWebhookEndpoint({input:{teamDid:j,input:C}});q.success(`${c("webhookEndpoint.createWebhook")} ${c("webhookEndpoint.success")}`),s(v)}}catch(v){q.error(v==null?void 0:v.message)}k()};return S.useEffect(()=>{T({url:p,description:u}),d(E.reduce((r,i)=>(r[`${i.type}-${i.source}`]=!0,r),{}))},[T,d,p,u,E]),e.jsx(Pe,{open:!0,onClose:k,maxWidth:"lg",fullWidth:!0,sx:{"& .MuiDialog-paper":{minHeight:600}},children:e.jsxs("form",{onSubmit:g(A),children:[e.jsx(Ae,{children:c(o?"webhookEndpoint.editWebhookTitle":"webhookEndpoint.createWebhookTitle")}),e.jsx(We,{children:e.jsxs(m,{sx:{display:"flex",flexDirection:"column",gap:2,mt:2},children:[e.jsx(K,{name:"url",control:l,rules:{required:c("webhookEndpoint.validation.urlRequired"),pattern:{value:/^(http|https):\/\/[^ "]+$/,message:c("webhookEndpoint.validation.urlInvalid")}},render:({field:r})=>{var i;return e.jsx(re,{...r,label:c("webhookEndpoint.url.label"),fullWidth:!0,error:!!h.url,helperText:(i=h.url)==null?void 0:i.message})}}),e.jsx(K,{name:"description",control:l,rules:{required:c("webhookEndpoint.validation.descriptionRequired")},render:({field:r})=>{var i;return e.jsx(re,{...r,label:c("webhookEndpoint.description.label"),fullWidth:!0,multiline:!0,minRows:2,maxRows:4,error:!!h.description,helperText:(i=h.description)==null?void 0:i.message})}}),e.jsx(K,{name:"selectedEvents",control:l,rules:{required:c("webhookEndpoint.validation.eventRequired")},render:({field:r})=>e.jsx("input",{type:"hidden",...r})}),!f&&b&&Object.keys(b).length>0&&e.jsx(te,{eventsBySource:b,selectedEvents:a,setSelectedEvents:d,error:(n=h.selectedEvents)==null?void 0:n.message}),!f&&(!b||Object.keys(b).length===0)&&e.jsx(I,{color:"text.secondary",children:c("webhookEndpoint.noAvailableEvents")}),f&&e.jsx(m,{sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"500px",width:"100%"},children:e.jsx(M,{size:20})}),w&&e.jsx(Z,{severity:"error",children:c("webhookEndpoint.loadingError",{message:w==null?void 0:w.message})})]})}),e.jsxs(Oe,{sx:{p:"8px 24px 24px"},children:[e.jsx(H,{onClick:k,children:c("common.cancel")}),e.jsx(H,{type:"submit",variant:"contained",color:"primary",children:c(o?"webhookEndpoint.updateWebhook":"webhookEndpoint.saveWebhook")})]})]})})}oe.propTypes={onSubmit:t.func.isRequired,id:t.string,url:t.string,description:t.string,enabledEvents:t.arrayOf(t.shape({type:t.string.isRequired,source:t.string.isRequired})),onClose:t.func};oe.defaultProps={id:null,url:"",description:"",enabledEvents:[],onClose:()=>{}};function xe(o){switch(o){case"enabled":return"success";case"disabled":default:return"default"}}const it=(o="en")=>o==="tw"?"zh":o;function N(o,p="YYYY-MM-DD HH:mm:ss",u="en"){return o?De(o).locale(it(u)).format(p):"-"}function rt(o){return typeof o=="number"?!1:he(o)}function lt(o){return o>=200&&o<300}function W(o){const p=rt(o.value);return e.jsxs(e.Fragment,{children:[e.jsxs(z,{direction:"column",alignItems:"flex-start",children:[e.jsxs(I,{component:"div",variant:"body1",mb:1,color:"text.primary",sx:{fontWeight:500},children:[o.label,!!o.tip&&e.jsx($,{title:o.tip,children:e.jsx(Be,{fontSize:"small"})})]}),e.jsx(I,{component:"div",variant:"body1",color:p?"text.disabled":"text.secondary",sx:{width:"100%",minHeight:"24px"},children:p?"-":o.value})]}),o.divider&&e.jsx(Me,{orientation:"vertical",flexItem:!0})]})}W.propTypes={label:t.oneOfType([t.string,t.node]).isRequired,value:t.oneOfType([t.string,t.node]).isRequired,tip:t.oneOfType([t.string,t.node]),divider:t.bool};W.defaultProps={tip:"",divider:!1};function se(o){return e.jsxs(z,{className:"section-header",direction:"row",justifyContent:"space-between",alignItems:"center",flexWrap:"wrap",gap:1,sx:{mb:o.mb,mt:o.mt,pb:1},children:[e.jsx(I,{variant:"h3",sx:{fontSize:{xs:"18px",md:"1.09375rem"}},component:"div",children:o.title}),o.children]})}se.propTypes={title:t.oneOfType([t.string,t.node]).isRequired,children:t.node,mb:t.number,mt:t.number};se.defaultProps={children:null,mb:1.5,mt:1.5};const at=o=>{const p={};return o.forEach(u=>{var s;const E=new Date(u.createdAt).toLocaleDateString();p[E]||(p[E]=[]),(s=p[E])==null||s.push(u)}),p};function ne({eventId:o,webhookEndpointId:p,event:u}){const{api:E}=F(),{t:s}=B(),{teamDid:R}=U(),{blocklet:c}=pe(),{data:a,loadMore:d,loadingMore:j,loading:y}=ke(x=>{const k=x?Math.ceil(x.list.length/15)+1:1;return E.getWebhookAttempts({input:{teamDid:R,input:{eventId:o,webhookId:p},paging:{page:k,pageSize:15}}})},{reloadDeps:[o,p]}),f=(a==null?void 0:a.list)||[],[w,b]=S.useState(null),l=at(f);S.useEffect(()=>{!w&&(a!=null&&a.list.length)&&b(a.list[0])},[a==null?void 0:a.list.length,w]);const g=x=>{b(x)};if(y)return e.jsx(M,{});const h=a&&a.list.length<a.paging.total,T=x=>{var D,k,A,n,r;if(x.responseBody&&((D=x.responseBody)!=null&&D.sessionId)&&((k=x.responseBody)!=null&&k.projectId)&&((A=x.responseBody)!=null&&A.agentId)){const i=(r=(n=c==null?void 0:c.site)==null?void 0:n.domainAliases[0])==null?void 0:r.value,C=(c.children||[]).find(P=>{var O;return((O=P==null?void 0:P.meta)==null?void 0:O.name)==="ai-studio"}),v=et(tt(`https://${i}`,(C==null?void 0:C.mountPoint)||"","projects",x.responseBody.projectId,"logs/main"),{sessionId:x.responseBody.sessionId,agentId:x.responseBody.agentId});return e.jsx(ee,{sx:{fontSize:20},onClick:()=>window.open(v,"_blank"),children:e.jsx(m,{component:ge,icon:fe})})}return null};return e.jsxs(V,{container:!0,spacing:{xs:0,md:1},sx:{height:1},children:[e.jsx(V,{item:!0,xs:12,md:4,height:1,children:he(Object.keys(l))?e.jsx(I,{color:"text.secondary",children:s("webhookEndpoint.waitingForEvents")}):e.jsxs(e.Fragment,{children:[e.jsx(J,{sx:{maxHeight:"calc(100% - 40px)",py:0,overflowY:"auto"},children:Object.entries(l).map(([x,D])=>e.jsxs(Q.Fragment,{children:[e.jsx(He,{children:x}),D.map(k=>e.jsxs(G,{sx:{cursor:"pointer"},onClick:()=>g(k),selected:w===k,secondaryAction:e.jsx(I,{color:"text.secondary",children:N(k.createdAt,"HH:mm:ss")}),children:[e.jsx(Ne,{sx:{minWidth:0,mr:1.5},children:lt(k.responseStatus)===!1?e.jsx(Fe,{color:"error"}):e.jsx(Ue,{color:"success"})}),e.jsx(_e,{primary:e.jsx(I,{color:"text.primary",children:k.event.type})})]},k.id))]},x))}),h&&e.jsx(m,{display:"flex",justifyContent:"center",alignItems:"center",width:1,children:e.jsx(H,{variant:"text",type:"button",color:"inherit",onClick:d,disabled:j,sx:{color:x=>x.palette.text.disabled},children:s(j?"webhookEndpoint.loadingMore":"webhookEndpoint.loadMore")})})]})}),e.jsxs(V,{item:!0,xs:12,md:8,height:1,children:[w&&e.jsxs(z,{height:1,overflow:"auto",direction:"column",spacing:2,sx:{pl:{xs:0,md:1},mt:{xs:2,md:0},borderLeft:{xs:"none"}},children:[e.jsxs(m,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(I,{variant:"h6",children:o?w.endpoint.url:w.event.type}),e.jsx(m,{children:T(w)})]}),e.jsxs(m,{children:[e.jsxs(I,{variant:"h6",children:[s("webhookEndpoint.response")," (",w.responseStatus,")"]}),e.jsx(_,{language:"json",children:JSON.stringify(w.responseBody,null,2)})]}),e.jsxs(m,{children:[e.jsx(z,{direction:"row",alignItems:"center",spacing:1,children:e.jsx(I,{variant:"h6",children:s("webhookEndpoint.request")})}),e.jsx(_,{language:"json",sx:{margin:0},children:JSON.stringify(w.event,null,2)})]})]}),(a==null?void 0:a.list.length)===0&&u&&e.jsxs(m,{children:[e.jsx(z,{direction:"row",alignItems:"center",spacing:1,children:e.jsx(I,{variant:"h6",children:s("webhookEndpoint.eventData")})}),e.jsx(_,{language:"json",sx:{margin:0},children:JSON.stringify(u.data,null,2)})]})]})]})}ne.propTypes={eventId:t.string,webhookEndpointId:t.string,event:t.shape({type:t.string,data:t.object,request:t.object,requestInfo:t.object})};ne.defaultProps={eventId:"",webhookEndpointId:"",event:null};function me({id:o,onClose:p}){var j,y,f,w;const{t:u}=B(),{api:E}=F(),{teamDid:s}=U(),{loading:R,error:c,data:a}=de(()=>E.getWebhookEndpoint({input:{teamDid:s,id:o}})),d=a==null?void 0:a.data;return c?e.jsx(Z,{severity:"error",children:c.message}):R||!d?e.jsx(m,{display:"flex",justifyContent:"center",alignItems:"center",height:1,width:1,children:e.jsx(M,{})}):e.jsxs(ct,{direction:"column",sx:{height:{xs:"auto",md:1}},children:[e.jsxs(m,{children:[e.jsxs(z,{direction:"row",justifyContent:"space-between",alignItems:"center",children:[e.jsx(z,{flex:1,width:0,children:e.jsxs(m,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(I,{variant:"h5",fontWeight:600,sx:{overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis"},children:d.description}),e.jsx($,{title:d.url,children:e.jsx(X,{sx:{fontSize:"16px",marginTop:"2px"}})})]})}),e.jsx(z,{direction:"row",alignItems:"center",children:e.jsx(ee,{edge:"end",color:"inherit",onClick:p,children:e.jsx(Ye,{})})})]}),e.jsx(m,{mt:2,children:e.jsxs(z,{className:"section-body",direction:{xs:"column",md:"row"},spacing:{xs:1,md:3},justifyContent:"flex-start",flexWrap:"wrap",sx:{pt:2,mt:2,borderTop:"1px solid #eee"},children:[e.jsx(W,{label:u("common.status"),value:e.jsx(L,{size:"small",variant:"filled",label:d.status,color:xe(d.status),sx:{borderRadius:"4px",lineHeight:"20px",textTransform:"capitalize"}}),divider:!0}),e.jsx(W,{label:u("webhookEndpoint.listen"),value:e.jsx($,{arrow:!0,title:e.jsx("ul",{style:{padding:0,margin:0},children:d.enabledEvents.map(b=>e.jsx("li",{style:{fontSize:"0.7875rem"},children:b==null?void 0:b.type},b))}),children:e.jsx(L,{size:"small",variant:"filled",label:u("webhookEndpoint.eventsCount",{count:d.enabledEvents.length}),sx:{borderRadius:"4px",lineHeight:"20px",textTransform:"capitalize"}})}),divider:!0}),e.jsx(W,{label:u("webhookEndpoint.version"),value:d.apiVersion,divider:!0}),e.jsx(W,{label:u("common.createdAt"),value:N(d.createdAt),divider:!0}),e.jsx(W,{label:u("common.updatedAt"),value:N(d.updatedAt),divider:!0}),e.jsx(W,{label:u("common.createdBy"),value:e.jsx($,{arrow:!0,title:(j=d.createUser)==null?void 0:j.did,children:e.jsx(L,{size:"small",variant:"filled",label:(y=d.createUser)==null?void 0:y.fullName,sx:{borderRadius:"4px",lineHeight:"20px",textTransform:"capitalize"}})}),divider:!0}),e.jsx(W,{label:u("common.updatedBy"),value:e.jsx($,{arrow:!0,title:(f=d.updateUser)==null?void 0:f.did,children:e.jsx(L,{size:"small",variant:"filled",label:(w=d.updateUser)==null?void 0:w.fullName,sx:{borderRadius:"4px",lineHeight:"20px",textTransform:"capitalize"}})})})]})})]}),e.jsxs(z,{className:"section",flex:1,height:0,overflow:"hidden",children:[e.jsx(se,{title:u("webhookEndpoint.attempts"),mb:0,mt:4}),e.jsx(z,{height:0,flex:1,overflow:"hidden",children:e.jsx(ne,{webhookEndpointId:d.id})})]})]})}me.propTypes={id:t.string.isRequired,onClose:t.func.isRequired};const ct=ue(z)``;function be({open:o,onClose:p,id:u}){return e.jsx(Ke,{anchor:"right",open:o,onClose:p,PaperProps:{sx:{width:"90vw",maxWidth:"1200px"}},children:e.jsx(m,{sx:{height:"100vh",p:3},children:e.jsx(me,{id:u,onClose:p})})})}be.propTypes={open:t.bool.isRequired,onClose:t.func.isRequired,id:t.string.isRequired};function ce(){return null}const ie=Q.memo(({options:o,columns:p,toolbar:u=!0,footer:E=!0,hasRowLink:s=!1,emptyNodeText:R="",...c})=>{const{locale:a}=B(),d=Ve(f=>f.breakpoints.down("md")),j={print:!1,download:!1,filter:!1,selectableRows:"none",rowsPerPage:d?5:10,rowsPerPageOptions:[5,10,20,50,100],searchDebounceTime:300,tableBodyHeight:"100%",loading:!0},y={};return u||(y.TableToolbar=ce),E||(y.TableFooter=ce),e.jsx(dt,{locale:a,options:{...j,...o},columns:(p||[]).map(f=>(f.options=f.options||{},f.options.filter=f.options.filter||!1,f.options.sort=f.options.sort||!1,f)),emptyNode:e.jsx(je,{children:R}),...c,components:y,hasRowLink:s,isMobile:d})});ie.propTypes={options:t.object,columns:t.array,toolbar:t.bool,footer:t.bool,hasRowLink:t.bool,emptyNodeText:t.node,durable:t.string,durableKeys:t.array,data:t.array,loading:t.bool,onChange:t.func,title:t.node,components:t.object};ie.defaultProps={options:{},columns:[],toolbar:!0,footer:!0,hasRowLink:!1,emptyNodeText:null,durable:"",durableKeys:[],data:[],loading:!1,onChange:()=>{},title:null,components:{}};const dt=ue(ye)``,pt=ie;function Ft(){const{teamDid:o}=U(),p=ze(),u=`webhook-endpoints-${o}`,E=we(u),{t:s,locale:R}=B(),{api:c}=F(),[a,d]=S.useState(""),[j,y]=S.useState({webhookDetail:{open:!1,id:null},createEdit:{open:!1,id:null,url:"",description:"",enabledEvents:[]},deleteConfirm:null}),[f,w]=Ee(u,{defaultValue:{pageSize:E.rowsPerPage||20,page:E.page?E.page+1:1}}),{loading:b,error:l,data:g,refresh:h}=de(()=>c.getWebhookEndpoints({input:{teamDid:o,paging:{page:f.page,pageSize:f.pageSize}}}));S.useEffect(()=>{h()},[f,h]);const T=S.useCallback(async(n,r)=>{try{await c.updateWebhookEndpoint({input:{teamDid:o,id:n.id,data:{status:r?"disabled":"enabled"}}}),h(),q.success(`${s(r?"webhookEndpoint.disable":"webhookEndpoint.enable")}${s("webhookEndpoint.success")}`)}catch(i){q.error(i==null?void 0:i.message)}},[c,o,h,s]),x=S.useCallback(async n=>{try{await c.deleteWebhookEndpoint({input:{teamDid:o,id:n}}),h(),y(r=>({...r,deleteConfirm:null})),q.success(`${s("common.delete")}${s("webhookEndpoint.success")}`)}catch(r){q.error(r==null?void 0:r.message)}},[c,o,h,s]),D=(n,r)=>{let i=n.page+1;const C=n.searchText||"";if(C!==a){d(C);return}if(r==="changePage"||r==="changeRowsPerPage"){r!=="changePage"&&(i=1);const v={page:i,pageSize:n.rowsPerPage};d(""),w(v)}};if(l)return e.jsx(Z,{severity:"error",children:l.message});if(b||!g)return e.jsx(m,{display:"flex",justifyContent:"center",alignItems:"center",width:1,height:500,children:e.jsx(M,{})});const k=((g==null?void 0:g.list)||[]).filter(n=>{if(!a)return!0;const r=a.toLowerCase();return n.description.toLowerCase().includes(r)||n.url.toLowerCase().includes(r)}),A=[{label:"URL",name:"url",options:{customBodyRenderLite:(n,r)=>{const i=k[r];return e.jsxs(m,{sx:{display:"flex",alignItems:"center",cursor:"pointer",gap:.5},children:[e.jsx(I,{variant:"body2",children:i.description}),e.jsx(m,{sx:{display:"flex"},onClick:C=>{C.stopPropagation()},children:e.jsx($,{title:i.url,children:e.jsx(X,{sx:{fontSize:"15px",marginTop:"1px"}})})})]})}}},{label:"Events",name:"events",options:{customBodyRenderLite:(n,r)=>{const i=k[r];return e.jsx(m,{sx:{display:"flex",alignItems:"center",gap:1,flexWrap:"wrap"},children:i.enabledEvents.map(C=>e.jsx(L,{size:"small",variant:"filled",label:C.type,sx:{borderRadius:"4px",textTransform:"capitalize"}},`${i.source}-${C.type}`))})}}},{label:s("common.status"),name:"status",options:{customBodyRenderLite:(n,r)=>{const i=k[r];return e.jsx(L,{size:"small",variant:"filled",label:s(`webhookEndpoint.${i==null?void 0:i.status}`),color:xe(i==null?void 0:i.status),sx:{borderRadius:"4px",textTransform:"capitalize"}},`status-${i.status}`)}}},{label:s("common.createdAt"),name:"createdAt",minWidth:200,options:{customBodyRender:n=>N(n)}},{label:s("common.createdBy"),name:"createUser",width:100,options:{customBodyRender:n=>n?e.jsx(Te,{showDid:!0,did:n==null?void 0:n.did,cardType:Se.Detailed,infoType:Ie.Minimal,sx:{border:0,padding:0}}):"-"}},{label:s("common.actions"),name:"actions",width:100,align:"center",verticalKeyAlign:"center",options:{customBodyRenderLite:(n,r)=>{const i=k[r],C=(i==null?void 0:i.status)==="enabled";return e.jsx(st,{actions:[{icon:C?e.jsx(Je,{}):e.jsx(Ge,{}),text:s(C?"webhookEndpoint.disable":"webhookEndpoint.enable"),onClick:v=>{v.stopPropagation(),T(i,C)}},{icon:e.jsx(Qe,{}),text:s("common.edit"),onClick:v=>{v.stopPropagation(),y(P=>({...P,createEdit:{open:!0,id:i.id,url:i.url,description:i.description,enabledEvents:i.enabledEvents}}))}},{icon:e.jsx(Xe,{}),text:s("common.delete"),onClick:v=>{v.stopPropagation(),y(P=>({...P,deleteConfirm:{title:s("webhookEndpoint.deleteWebhook.title"),description:s("webhookEndpoint.deleteWebhook.description"),confirm:s("common.confirm"),cancel:s("common.cancel"),onConfirm:()=>x(i.id),onCancel:()=>y(O=>({...O,deleteConfirm:null}))}}))}}]})}}}];return e.jsxs(m,{sx:{".custom-toobar-btns":{gap:"8px"},".custom-toobar-title .custom-toobar-title-inner>span":{display:"flex",alignItems:"center","white-space":"inherit",height:"100%"}},children:[p?e.jsx(ae,{title:s("webhookEndpoint.listTitle"),tooltipTitle:s("webhookEndpoint.tooltipTitle"),link:`https://www.arcblock.io/docs/blocklet-developer/${R}/webhook`}):null,e.jsx(pt,{durable:u,durableKeys:["page","rowsPerPage"],data:k,columns:A,options:{count:g.count,page:f.page-1,rowsPerPage:f.pageSize,viewColumns:!1,onRowClick:(n,{dataIndex:r})=>{const i=g.list[r];y(C=>({...C,webhookDetail:{open:!0,id:i.id}}))}},loading:b,onChange:D,emptyNodeText:e.jsx(z,{gap:1,children:s("webhookEndpoint.noWebhooksAdded")}),title:p?null:e.jsx(ae,{title:s("webhookEndpoint.listTitle"),tooltipTitle:s("webhookEndpoint.tooltipTitle"),link:`https://www.arcblock.io/docs/blocklet-developer/${R}/webhook`}),customButtons:[e.jsxs(H,{sx:{color:"common.white"},edge:"end",variant:"contained",color:"primary",onClick:()=>y(n=>({...n,createEdit:{...n.createEdit,open:!0}})),className:"rule-action",children:[b?e.jsx(M,{size:16}):e.jsx(Ce,{style:{fontSize:16}}),s("common.create")]},"add")]}),j.webhookDetail.open&&e.jsx(be,{open:!0,onClose:()=>y(n=>({...n,webhookDetail:{open:!1,id:null}})),id:j.webhookDetail.id}),j.createEdit.open&&e.jsx(oe,{onSubmit:h,...j.createEdit,onClose:()=>y(n=>({...n,createEdit:{id:null,url:"",description:"",enabledEvents:[],open:!1}}))}),j.deleteConfirm&&e.jsx(ot,{title:j.deleteConfirm.title,description:j.deleteConfirm.description,confirm:j.deleteConfirm.confirm,cancel:j.deleteConfirm.cancel,params:j.deleteConfirm.params,onConfirm:j.deleteConfirm.onConfirm,onCancel:j.deleteConfirm.onCancel})]})}export{Ft as default};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import{j as r,bc as W,aa as m,ad as P,bT as K,T as S,ah as Z,bb as R,e as k,w as V}from"./vendor-mui-core-BV2FUxWJ.js";import{r as x}from"./vendor-react-DEoibe3W.js";import{i as J,h as X,aL as q,$ as O,Z as G,I as Q,R as E}from"./vendor-ux-did-connect-CJ8Q_v7u.js";import{o as Y,C as ee,q as B,s as te}from"./vendor-arcblock-BPZ1V4pg.js";import{f as v,u as re}from"./vendor-hooks-BgUTpb6X.js";import{ai as T,A as ne,Z as ae}from"./vendor-utils-rHXShPKm.js";import oe from"./Phone-BkOMNOMO.js";import ie from"./Location-DxPzfR_p.js";import se from"./Email-BirbvqZ3.js";import L from"./Timezone-D91Of94T.js";let g=function(e){return e.AvatarOnly="AvatarOnly",e.Detailed="Detailed",e}({}),j=function(e){return e.NameOnly="NameOnly",e.Minimal="Minimal",e.Basic="Basic",e}({}),D=null;try{D=new J}catch(e){console.error("Failed to initialize BlockletSDK:",e),D=null}const H="ux_user_",le=60*60*1e3,ce=e=>{if(typeof sessionStorage>"u")return null;try{const t=`${H}${e}`,n=sessionStorage.getItem(t);if(!n)return null;const a=JSON.parse(n),s=a.timestamp||0;return Date.now()-s>le?(sessionStorage.removeItem(t),null):a.user}catch(t){return console.error(`Failed to load user cache for did ${e}:`,t),null}},de=(e,t)=>{if(!(typeof sessionStorage>"u"))try{const n=`${H}${e}`,a={user:t,timestamp:Date.now()};sessionStorage.setItem(n,JSON.stringify(a))}catch(n){console.error(`Failed to save user cache for did ${e}:`,n)}};function ue(e){if(!e)return null;let t="";return e.fullName?t=e.fullName.charAt(0).toUpperCase():e.email?t=e.email.split("@")[0].charAt(0).toUpperCase():t=e.did?e.did.charAt(0).toUpperCase():"?",t}function fe(e){if(!e||typeof e!="string")return!1;try{const t=X.toTypeInfo(e);return t.role!==void 0&&t.role!==q.types.RoleType.ROLE_APPLICATION}catch(t){return console.error("Failed to check if did is user did:",t),!1}}async function me(e){if(!e)return null;const t=ce(e);if(t)return t;if(!D)return null;try{const n=await D.user.getUserPublicInfo({did:e});return n&&de(e,n),n}catch(n){return console.error("Failed to get user by did:",n),null}}const M=(e,t=48,n=void 0,a=void 0,s=!1)=>{const o=i=>{a==null||a(e,i)};if(!e.avatar){const i=ue(e),{className:d,style:h,alt:p}=n||{};return r.jsx(W,{onClick:o,className:d,style:h,alt:p,sx:{width:t,height:t,fontSize:t*.4,cursor:s||a?"pointer":"default"},variant:"circular",children:i})}return r.jsx(m,{className:"user-card__avatar",display:"flex",children:r.jsx(O,{size:t,did:e.did,variant:"circle",style:{cursor:s||a?"pointer":"default"},onClick:o,src:e.avatar,alt:e.fullName||"",...n||{}})})},he=(e,t=120)=>e?r.jsx(m,{sx:{maxWidth:t},className:"user-card__top-right-content",children:e()}):null;function _({user:e,avatarSize:t,shouldShowHoverCard:n,renderCardContent:a,tooltipTitle:s,tooltipProps:o,avatarProps:i,onAvatarClick:d}){const h=M(e,t,i,d,n||!!s);return s?r.jsx(P,{enterDelay:200,title:s,placement:"bottom",...o??{},children:h}):n?r.jsx(P,{enterDelay:200,title:a?a():null,placement:"bottom",arrow:!1,TransitionComponent:K,PopperProps:{sx:{"& .MuiTooltip-tooltip":{backgroundColor:"transparent",p:0,maxWidth:500,zIndex:1e3}}},...o??{},children:h}):h}function xe(e){const{user:t,infoType:n,avatarSize:a=48,shouldShowHoverCard:s=!1,renderCardContent:o,...i}=e;return n===j.NameOnly?r.jsx(_,{user:t,avatarSize:a,shouldShowHoverCard:!1,renderCardContent:o,tooltipTitle:t.fullName||t.email||t.did,...i}):r.jsx(_,{user:t,avatarSize:a,shouldShowHoverCard:s,renderCardContent:o,...i})}function pe(e){const{user:t,avatarSize:n=48,onAvatarClick:a}=e;return r.jsxs(r.Fragment,{children:[M(t,n,e.avatarProps,a),r.jsx(S,{variant:"body1",children:t.fullName||t.email||t.did})]})}function ye(e){const{user:t,showDid:n,didProps:a,avatarSize:s,shouldShowHoverCard:o,renderCardContent:i,renderTopRightContent:d,topRightMaxWidth:h,avatarProps:p,shortenLabelProps:b,renderName:C,...w}=e;return r.jsxs(m,{display:"flex",justifyContent:"space-between",alignItems:"center",className:"user-card__avatar-content",children:[r.jsxs(m,{display:"flex",justifyContent:"flex-start",alignItems:"center",gap:1,flex:1,minWidth:0,children:[r.jsx(_,{user:t,avatarSize:s,shouldShowHoverCard:o,renderCardContent:i,avatarProps:p,...w}),r.jsxs(m,{children:[r.jsx(S,{variant:"subtitle1",fontWeight:500,color:"text.primary",className:"user-card__full-name-label",fontSize:18,noWrap:!0,sx:{lineHeight:1.1},children:C?C(t):r.jsx(Y,{sx:{fontWeight:500},...b,children:t.fullName||t.email||t.did})}),n&&t.did?r.jsx(G,{did:t.did,size:14,copyable:!0,compact:!0,locale:"en",sx:{lineHeight:1.5},...a??{}}):null]})]}),he(d,h)]})}const ge=x.memo(ye),be={timezone:L,email:se,phone:oe,location:ie,link:B};function Ce(e){return ae(e)}function I(e){return e?{filter:"brightness(0) saturate(100%) invert(1)"}:{}}const N={width:16,height:16};function ve({value:e}){const n=k().palette.mode==="dark";return r.jsxs(m,{display:"flex",alignItems:"center",gap:1,className:"user-card__timezone-field",children:[r.jsx(L,{...N,style:I(n)}),r.jsx(ee,{value:e,variant:"body2",color:"grey.800"})]})}function je({value:e}){const[t,n]=x.useState(!1),s=k().palette.mode==="dark",o=v(()=>{try{const d=new URL(e);return ne(d.origin,"favicon.ico")}catch{return""}},[e]),i=()=>{n(!0)};return r.jsxs(m,{display:"flex",alignItems:"center",gap:1,className:"user-card__link-field",children:[o&&!t?r.jsx("img",{src:o,alt:"site icon",style:{width:16,height:16,objectFit:"contain"},onError:i}):r.jsx(B,{...N,style:I(s)}),r.jsx(F,{variant:"body2",color:"grey.800",children:r.jsx(S,{component:"a",href:e,style:{textDecoration:"none",color:"inherit",fontSize:"inherit"},target:"_blank",variant:"body2",color:"grey.800",rel:"noopener noreferrer",children:Ce(e)})})]})}function U({field:e,value:t,children:n}){const a=be[e],o=k().palette.mode==="dark",i=I(o);return r.jsxs(m,{display:"flex",alignItems:"center",gap:1,className:`user-card__${e}-field`,children:[a?r.jsx(a,{...N,style:i}):r.jsx(Q,{icon:te,...N,...i}),r.jsx(F,{variant:"body2",color:"grey.800",children:n??t})]},e)}function Se({user:e,isFull:t=!1,renderFields:n}){var z;const a=v(()=>n??["bio","email","phone","location","timezone","link"],[n]),s=v(()=>a.includes("bio"),[a]),o=v(()=>e.metadata??{joinedAt:e==null?void 0:e.createdAt,email:e==null?void 0:e.email,phone:{country:"cn",phoneNumber:(e==null?void 0:e.phone)??""}},[e]),i=v(()=>e.address,[e.address]),d=x.useCallback(l=>{var f,c,u;if(!l)return"";switch(l){case"bio":return((f=e.metadata)==null?void 0:f.bio)||"";case"email":return o.email||e.email||"";case"phone":return((c=o.phone)==null?void 0:c.phoneNumber)||e.phone||"";case"location":return(i==null?void 0:i.city)||o.location||"";case"timezone":return o.timezone||"";case"link":return((u=o.links)==null?void 0:u.map(y=>y.url).filter(Boolean))||[];default:return e[l]||""}},[e,o,i]),{effectiveRenderCount:h}=x.useMemo(()=>{const l=a.filter(c=>{if(c==="bio")return!1;const u=d(c);return u==null||u===""?!1:T(u)?u.length>0:String(u).trim().length>0}),f=l.reduce((c,u)=>{const y=d(u);return c+(Array.isArray(y)?y.filter(A=>A&&String(A).trim()).length:1)},0);return{visibleFields:l,effectiveRenderCount:f}},[a,d]),p=h>4,b=re(l=>l!=null&&String(l).trim().length>0),C=x.useMemo(()=>{const l=[];return a.forEach(f=>{if(f==="bio")return;const c=d(f);c&&(T(c)?c.forEach((u,y)=>{b(u)&&l.push({field:f,value:u,key:`${f}-${y}`})}):b(c)&&l.push({field:f,value:c,key:f}))}),l},[a,d,b]);if(a.length===0)return null;const w=l=>{const{field:f,value:c,key:u}=l;switch(f){case"link":return r.jsx(je,{value:c},u);case"timezone":return r.jsx(ve,{value:c},u);case"email":return r.jsx(U,{field:f,value:c,children:r.jsx(S,{component:"a",href:`mailto:${c}`,rel:"noopener noreferrer",referrerPolicy:"no-referrer",style:{color:"inherit",textDecoration:"none",fontSize:"inherit"},children:c})});default:return r.jsx(U,{field:f,value:c},u)}};return r.jsxs(m,{mt:1,display:"flex",flexDirection:"column",gap:1.5,className:"user-card__basic-content",children:[s&&((z=e.metadata)==null?void 0:z.bio)&&r.jsx(F,{variant:"body2",color:"grey.800",className:"user-card__bio-field",children:e.metadata.bio}),p?r.jsx(R,{container:!0,spacing:.5,children:C.map(l=>r.jsx(R,{item:!0,xs:6,children:w(l)},l.key))}):r.jsx(m,{display:"flex",flexDirection:"column",gap:.5,children:C.map(l=>w(l))})]})}const F=Z(S)`
|
|
2
|
-
flex: 1;
|
|
3
|
-
display: -webkit-box;
|
|
4
|
-
line-height: 1.5;
|
|
5
|
-
-webkit-line-clamp: 1;
|
|
6
|
-
-webkit-box-orient: vertical;
|
|
7
|
-
overflow: hidden;
|
|
8
|
-
text-overflow: ellipsis;
|
|
9
|
-
word-break: break-word;
|
|
10
|
-
`;function we(e){const{user:t,avatarSize:n=40,renderCustomContent:a,isFull:s=!0,infoType:o=j.Minimal,renderFields:i,popupRenderFields:d,...h}=e;return r.jsxs(m,{display:"flex",flexDirection:"column",width:"100%",flex:1,height:"100%",children:[r.jsx(ge,{user:t,avatarSize:n,...h}),o===j.Basic&&r.jsx(Se,{user:t,isFull:s,renderFields:i}),r.jsx(m,{className:"user-card__footer",children:a&&r.jsx(m,{sx:{mt:1.5},children:a()})})]})}function $(e){const{infoType:t=j.Minimal}=e;switch(t){case j.NameOnly:return r.jsx(pe,{...e});default:return r.jsx(we,{...e})}}function De({children:e,sx:t}){const n=k();return r.jsx(m,{sx:E({p:2,backgroundColor:n.palette.background.paper,border:"1px solid",borderColor:"divider",borderRadius:1,maxWidth:500,minWidth:320,display:"flex"},t||null),children:e})}function Ne({children:e,cardType:t=g.Detailed,variant:n="box",containerRef:a,sx:s}){const o={minWidth:320,p:2,borderRadius:1,...t===g.Detailed?{border:"1px solid",borderColor:"divider"}:{}};return n==="paper"?r.jsx(V,{ref:a,elevation:0,sx:o,children:e}):r.jsx(m,{ref:a,sx:E(o,{display:"flex",alignItems:t===g.AvatarOnly?"center":"flex-start",gap:2},s||null),children:e})}function $e(e){const{cardType:t=g.Detailed,showHoverCard:n}=e,a=n!==void 0?n:t===g.AvatarOnly,s=x.useRef(null),[o,i]=x.useState(()=>e.user||null);if(x.useEffect(()=>{let h=!0;return e.user?i(e.user):e.did&&fe(e.did)&&!e.user&&me(e.did).then(p=>{h&&i(p||{fullName:"Anonymous",did:e.did,avatar:""})}),()=>{h=!1}},[e.did,e.user]),!o)return r.jsx(O,{did:e.did,size:e.avatarSize,...e.avatarProps});const d=()=>r.jsx(De,{sx:e.popupSx,children:r.jsx($,{...e,shouldShowHoverCard:!1,user:o,avatarProps:e.popupAvatarProps,shortenLabelProps:e.popupShortenLabelProps||e.shortenLabelProps,renderFields:e.popupRenderFields,renderName:e.popupRenderName,infoType:e.popupInfoType||e.infoType,didProps:e.popupDidProps||e.didProps,showDid:e.popupShowDid||e.showDid})});return t===g.AvatarOnly?r.jsx(xe,{...e,shouldShowHoverCard:a,renderCardContent:d,user:o}):r.jsx(Ne,{containerRef:s,cardType:t,sx:e.sx,children:r.jsx($,{...e,shouldShowHoverCard:a,renderCardContent:d,user:o})})}export{g as C,j as I,$e as U};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as t,ah as r}from"./vendor-mui-core-BV2FUxWJ.js";import{r as s}from"./vendor-react-DEoibe3W.js";import{b4 as a}from"./vendor-ux-did-connect-CJ8Q_v7u.js";import{R as e}from"./vendor-arcblock-BPZ1V4pg.js";import"./vendor-utils-rHXShPKm.js";import"./vendor-hooks-BgUTpb6X.js";import"./lottie-web-jYmAQWuC.js";function x(){const{t:o}=s.useContext(a);return t.jsx(n,{style:{paddingTop:"25vh"},children:t.jsx(e,{status:"404",description:o("noMatch.desc"),style:{backgroundColor:"transparent"}})})}const n=r.main``;export{x as default};
|