@abtnode/webapp 1.16.49-beta-20250812-040454-05aece54 → 1.16.49-beta-20250814-091924-eb162407

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (205) hide show
  1. package/blocklet.js +1 -1
  2. package/blocklet.yml +1 -1
  3. package/dist/assets/{AdapterDayjs-Ct0VTXw3.js → AdapterDayjs-DI9xVdft.js} +1 -1
  4. package/dist/assets/{Add-xsnJutmq.js → Add-CVnnproP.js} +1 -1
  5. package/dist/assets/ArrowDropDown-CAKNo0Ke.js +1 -0
  6. package/dist/assets/{Autocomplete-B8LzLUZe.js → Autocomplete-bScEq7nv.js} +1 -1
  7. package/dist/assets/{Breadcrumbs-BDzy2bld.js → Breadcrumbs-DT_W7m-v.js} +1 -1
  8. package/dist/assets/{ButtonGroup-2OIq-PXC.js → ButtonGroup-DGPsEPvC.js} +1 -1
  9. package/dist/assets/{CSSTransition-RdSxc12C.js → CSSTransition-Mlf9GCd4.js} +1 -1
  10. package/dist/assets/{CallMerge-DxChMRnd.js → CallMerge-DhNwNe9k.js} +1 -1
  11. package/dist/assets/{CardContent-D4kbuto4.js → CardContent-DL3tHEH2.js} +1 -1
  12. package/dist/assets/{ChevronLeft-KRG-fuZi.js → ChevronLeft-BT5CPukw.js} +1 -1
  13. package/dist/assets/{ChevronRight-BmsIaZOg.js → ChevronRight-BgaDG7TR.js} +1 -1
  14. package/dist/assets/{Clear-ClOZ_U5s.js → Clear-BhAooNeY.js} +1 -1
  15. package/dist/assets/{DeleteOutline-D00EO6C8.js → DeleteOutline-B1JtcD-N.js} +1 -1
  16. package/dist/assets/{Done-BTVTKjDk.js → Done-C9mrBMtJ.js} +1 -1
  17. package/dist/assets/{Edit-DXMp4A9G.js → Edit-B0-Hz2aR.js} +1 -1
  18. package/dist/assets/{ErrorOutline-C6AxgGOX.js → ErrorOutline-CGGfWx_o.js} +1 -1
  19. package/dist/assets/{FilterList-TV3SGdIn.js → FilterList-DOXHRdqB.js} +1 -1
  20. package/dist/assets/{Google-BuIv4wD3.js → Google-C4H347Z_.js} +1 -1
  21. package/dist/assets/{HelpOutline-B7Ct-krn.js → HelpOutline-BQaPhaiu.js} +1 -1
  22. package/dist/assets/{Launch-BvjA_9TZ.js → Launch-fyJtRy6i.js} +1 -1
  23. package/dist/assets/{Link-Uzugo-zp.js → Link-COlmHskq.js} +1 -1
  24. package/dist/assets/{ListItemButton-BBR__ebu.js → ListItemButton-RWQDDTnG.js} +1 -1
  25. package/dist/assets/{ListSubheader-CW_V4Z24.js → ListSubheader-CiNw6aDZ.js} +1 -1
  26. package/dist/assets/{LoadingButton-Y_0rPcsy.js → LoadingButton-Bny-Ce3e.js} +1 -1
  27. package/dist/assets/{MoreVert-DrzE5AUf.js → MoreVert-4uLUnU4a.js} +1 -1
  28. package/dist/assets/{OpenInNew-53sNi7bT.js → OpenInNew-xlkHjYWh.js} +1 -1
  29. package/dist/assets/{Refresh-02-oGzO6.js → Refresh-BGMud3C4.js} +1 -1
  30. package/dist/assets/{Search-7wyvQCyz.js → Search-B2m_yoTb.js} +1 -1
  31. package/dist/assets/{Slider-DACfJuWn.js → Slider-CN0w52zi.js} +1 -1
  32. package/dist/assets/{Stepper-ZBVUR9pb.js → Stepper-CA3sQBnX.js} +1 -1
  33. package/dist/assets/{Switch-D8Y_AkUP.js → Switch-D7_wVs3b.js} +1 -1
  34. package/dist/assets/{TableSearch-j7mUrdaA.js → TableSearch-DznuAnMT.js} +1 -1
  35. package/dist/assets/{ToggleButtonGroup-CWiKD-9f.js → ToggleButtonGroup-BWR5Vk9N.js} +1 -1
  36. package/dist/assets/{Verified-COnwjqrJ.js → Verified-B3KteJlV.js} +1 -1
  37. package/dist/assets/{VerifiedUser-DnX0aEPL.js → VerifiedUser-BNTtiyBh.js} +1 -1
  38. package/dist/assets/{ViewList-_K538mHc.js → ViewList-CfEu2OH2.js} +1 -1
  39. package/dist/assets/{_createAggregator-Dt3Ih0i2.js → _createAggregator-BOYHBI4S.js} +1 -1
  40. package/dist/assets/{actions-Cxap2JOs.js → actions-3PI2MAhn.js} +1 -1
  41. package/dist/assets/{actions-DRuv-pyx.js → actions-B3YDAeKX.js} +1 -1
  42. package/dist/assets/{agreement-DqRsm6CV.js → agreement-DaZzRmJq.js} +1 -1
  43. package/dist/assets/api-0rpyoHFy.js +1 -0
  44. package/dist/assets/{appearance-Bm7cllFQ.js → appearance-CSh14DEi.js} +1 -1
  45. package/dist/assets/{ar-BrkwppMS.js → ar-RVOyZ73G.js} +1 -1
  46. package/dist/assets/{audit-logs-ClrCXrBK.js → audit-logs-BuYaIzSU.js} +1 -1
  47. package/dist/assets/{base-chart-vZbN8YRn.js → base-chart-DnUu5MKP.js} +1 -1
  48. package/dist/assets/{blocklet-CSWEnHbv.js → blocklet-Cu7NUdbv.js} +1 -1
  49. package/dist/assets/chain-E2cyGnLe.js +6 -0
  50. package/dist/assets/{click-to-copy-B94Iq4_S.js → click-to-copy-CxQtWx0h.js} +1 -1
  51. package/dist/assets/client-BXRk5e6n.js +1 -0
  52. package/dist/assets/cloneDeep-tKXvm490.js +1 -0
  53. package/dist/assets/{collapse-Dezh2CAn.js → collapse-CbgK57uT.js} +1 -1
  54. package/dist/assets/{config-navigation-BXm4eTU9.js → config-navigation-2_jvzm3v.js} +3 -3
  55. package/dist/assets/{connect-to-Dyd-KizX.js → connect-to-0_BuJVlh.js} +1 -1
  56. package/dist/assets/{cssMode-B6wVTcZ6.js → cssMode-0W5CQRUU.js} +1 -1
  57. package/dist/assets/{de-DjoPhrWS.js → de-BXIXPwxt.js} +1 -1
  58. package/dist/assets/{delete-confirm-BzjquUay.js → delete-confirm-C0N0xOLi.js} +1 -1
  59. package/dist/assets/{depsEqual-DIBRq7Fr.js → depsEqual-CUUy9J_f.js} +1 -1
  60. package/dist/assets/{detail-DFtAGu9W.js → detail-D-Bf2X4b.js} +3 -3
  61. package/dist/assets/{domains-BKhbtqSe.js → domains-CHxeY5RL.js} +2 -2
  62. package/dist/assets/download-BkhmhYof.js +96 -0
  63. package/dist/assets/{edit.svg-Ad7pR1Ko.js → edit.svg-D_iaZeMd.js} +1 -1
  64. package/dist/assets/emotion-cache.browser.esm-C7Q3LdH3.js +1 -0
  65. package/dist/assets/engine-dEDx1XcI.js +1 -0
  66. package/dist/assets/{es-BLM6BW2Z.js → es-DJvu101w.js} +1 -1
  67. package/dist/assets/{fr-DM9fauTH.js → fr-D9eGKSnG.js} +1 -1
  68. package/dist/assets/{freemarker2-sCWMHP7f.js → freemarker2-DvgRVbdQ.js} +1 -1
  69. package/dist/assets/{get-safe-url-CXm2qbfD.js → get-safe-url-CzLgUUoe.js} +1 -1
  70. package/dist/assets/getValidReactChildren-BPfGVQXT.js +1 -0
  71. package/dist/assets/{graphqlMode-NDLjYpwF.js → graphqlMode-C8_O-uAu.js} +2 -2
  72. package/dist/assets/{handlebars-D5m3wM2h.js → handlebars-0aZLf-3v.js} +1 -1
  73. package/dist/assets/{hi-DgD0hgry.js → hi-CSHwUi_Z.js} +1 -1
  74. package/dist/assets/{html-CnanFkII.js → html-C1ZSp3l7.js} +1 -1
  75. package/dist/assets/{html-title-Bv34eYvs.js → html-title-SrM7nvGF.js} +1 -1
  76. package/dist/assets/{htmlMode-Dti9PEXK.js → htmlMode-gYGBWxiU.js} +1 -1
  77. package/dist/assets/{id-DRypmlkS.js → id-Dc-m_i57.js} +1 -1
  78. package/dist/assets/{iframe-B3SxZf1n.js → iframe-wtq3Nwgj.js} +1 -1
  79. package/dist/assets/{index-B_2YBbna.js → index--7YJtOHn.js} +1 -1
  80. package/dist/assets/{index-DiP98lQ7.js → index-8P_2QTeY.js} +1 -1
  81. package/dist/assets/{index-D-M7NZke.js → index-A_F5pDpL.js} +1 -1
  82. package/dist/assets/{index-PBerjRVW.js → index-B79IIkxS.js} +1 -1
  83. package/dist/assets/{index-DBvsoi5Z.js → index-B8-doyNt.js} +1 -1
  84. package/dist/assets/index-BF40lbZk.js +1 -0
  85. package/dist/assets/{index-Cf_UuTrD.js → index-BbeYSCv2.js} +11 -11
  86. package/dist/assets/{index-CWYVBDEB.js → index-Bd8NAHyz.js} +1 -1
  87. package/dist/assets/{index-B9Ylk5Gm.js → index-BkxxTjwn.js} +3 -3
  88. package/dist/assets/{index-BcnRn-Tc.js → index-BmoaGkjb.js} +1 -1
  89. package/dist/assets/{index-cjrclHNq.js → index-Bni_Ys-s.js} +1 -1
  90. package/dist/assets/{index-CFj27rKT.js → index-Bs5MwZ8m.js} +9 -9
  91. package/dist/assets/{index-DiXR_x6S.js → index-C-dz_3rV.js} +1 -1
  92. package/dist/assets/{index-JWFVT8uF.js → index-C1GrPwce.js} +1 -1
  93. package/dist/assets/{index-CCbDqQl1.js → index-C1wmQ0Zo.js} +1 -1
  94. package/dist/assets/{index-DE8jtmRi.js → index-CH5ejNx-.js} +1 -1
  95. package/dist/assets/{index-DHo8_7tw.js → index-CZIqg2zk.js} +1 -1
  96. package/dist/assets/{index-Bls5HB_P.js → index-Ci-Y8hhj.js} +1 -1
  97. package/dist/assets/{index-DDnvl7tL.js → index-Cudh2gAg.js} +1 -1
  98. package/dist/assets/{index-4YU_ikpW.js → index-D3_cCsAg.js} +1 -1
  99. package/dist/assets/index-D87cFICD.js +602 -0
  100. package/dist/assets/{index-efuh0Sux.js → index-DAF7Se3z.js} +1 -1
  101. package/dist/assets/{index-DNRbXVNA.js → index-DB5FEYbg.js} +1 -1
  102. package/dist/assets/{index-Bvj_iHG0.js → index-DBeu8uE9.js} +1 -1
  103. package/dist/assets/{index-D2dk65xX.js → index-DKjIcWre.js} +179 -179
  104. package/dist/assets/{index-Blaj76Z0.js → index-DKmzn8Kb.js} +1 -1
  105. package/dist/assets/{index-d42V1PV6.js → index-DQKEmYJ_.js} +1 -1
  106. package/dist/assets/{index-DFXj2mzy.js → index-DalCI32l.js} +1 -1
  107. package/dist/assets/{index-5QQWHLxz.js → index-DcXHOQmT.js} +1 -1
  108. package/dist/assets/{index-BXeAZx39.js → index-Di5JV_Tq.js} +1 -1
  109. package/dist/assets/{index-DpI-XQ1l.js → index-DpFF3qPe.js} +1 -1
  110. package/dist/assets/{index-20ehiOeZ.js → index-DpomJ3B2.js} +1 -1
  111. package/dist/assets/{index-DglyPV4Y.js → index-DzwCNtkH.js} +2 -2
  112. package/dist/assets/{index-BvA1-xFo.js → index-EZeJbEA-.js} +1 -1
  113. package/dist/assets/{index-DBGC5o42.js → index-NgbD3BmD.js} +1 -1
  114. package/dist/assets/{index-HNAwOsYz.js → index-OgF41Wtt.js} +1 -1
  115. package/dist/assets/index-PN_nwwOK.js +11 -0
  116. package/dist/assets/{index-9ZjKwjlW.js → index-WS73yyaB.js} +1 -1
  117. package/dist/assets/{index-D4dcj0uz.js → index-XAVc9qct.js} +1 -1
  118. package/dist/assets/{index-D_KMww7L.js → index-aSpvnapu.js} +1 -1
  119. package/dist/assets/{index-k42VQ_AF.js → index-cjRmiM--.js} +1 -1
  120. package/dist/assets/{index-B3l3haQa.js → index-poSKx1_l.js} +1 -1
  121. package/dist/assets/{index-kKVyr3jd.js → index-s23nDSrM.js} +1 -1
  122. package/dist/assets/{index-C_rTOaKu.js → index-w3jat0wp.js} +3 -3
  123. package/dist/assets/{index-6PyJTHfC.js → index-yLKT0_F8.js} +3 -3
  124. package/dist/assets/{index.esm-DXYSp_08.js → index.esm-CJDPJkDt.js} +1 -1
  125. package/dist/assets/{install-from-url-CNnVXR83.js → install-from-url-D1-y2Ocl.js} +1 -1
  126. package/dist/assets/{invitation-DOJxBbSJ.js → invitation-BMRYQXIS.js} +1 -1
  127. package/dist/assets/{is-path-prefix-equal-DMtF094s.js → is-path-prefix-equal-Dgzej_r-.js} +1 -1
  128. package/dist/assets/{item-B5y2JEkY.js → item-BsKeRM2B.js} +1 -1
  129. package/dist/assets/{ja-BgI9SuxS.js → ja-DuWRl1OM.js} +1 -1
  130. package/dist/assets/{javascript-RMUsL7C4.js → javascript-CEWuth7z.js} +1 -1
  131. package/dist/assets/{jsonMode-BdWDqW6d.js → jsonMode-CojUuIYC.js} +1 -1
  132. package/dist/assets/{ko-DxWYUlEG.js → ko-YalU3HfD.js} +1 -1
  133. package/dist/assets/{liquid-Br_d4nY3.js → liquid-CUYg6HPR.js} +1 -1
  134. package/dist/assets/{list-header-BKASZXQp.js → list-header-EJjQPfjY.js} +1 -1
  135. package/dist/assets/{log-DfyebCKD.js → log-4LBvbsKM.js} +1 -1
  136. package/dist/assets/{lottie-react.esm-DH7e7xCE.js → lottie-react.esm-D4MXwFwS.js} +1 -1
  137. package/dist/assets/{mdx-BWMokGXT.js → mdx-wR19-wIn.js} +1 -1
  138. package/dist/assets/{memory-EbVEVJ3v.js → memory-B705BOtR.js} +1 -1
  139. package/dist/assets/{metric-DF4CaZpP.js → metric-eprOGNso.js} +1 -1
  140. package/dist/assets/omit-w4TE1hrN.js +1 -0
  141. package/dist/assets/{overview-Iijq_Ko4.js → overview-DCsPIpC8.js} +1 -1
  142. package/dist/assets/{permission-Br1rNOjb.js → permission-Bbk6yXJh.js} +1 -1
  143. package/dist/assets/{preference-DZ8p0ZAt.js → preference-BonbggI8.js} +3 -3
  144. package/dist/assets/{pt-DeehC2Gk.js → pt-B3IRBzK6.js} +1 -1
  145. package/dist/assets/{python-Drb_6EJR.js → python-DM7kU4Q6.js} +1 -1
  146. package/dist/assets/{raf-schd.esm-DBpZPfTe.js → raf-schd.esm-z0ZD9lfq.js} +1 -1
  147. package/dist/assets/{razor-CqhXoL3w.js → razor-BLEva8Ev.js} +1 -1
  148. package/dist/assets/{rotate-session-key-sbLLFax2.js → rotate-session-key-RX_GGtS5.js} +1 -1
  149. package/dist/assets/{ru-DGlqMwrt.js → ru-BEEcST35.js} +1 -1
  150. package/dist/assets/{runtime-Gcr9Fi-g.js → runtime-iRG91DG9.js} +1 -1
  151. package/dist/assets/schema-D4jtQyjN.js +1 -0
  152. package/dist/assets/sdk-MiTc38GP.js +1 -0
  153. package/dist/assets/{service-wMVBEYj5.js → service-DbTssqgb.js} +1 -1
  154. package/dist/assets/{shorten-label-COTK-Aqe.js → shorten-label--oSKNWUo.js} +1 -1
  155. package/dist/assets/{simple-select-Jvgt7OyG.js → simple-select-DnZ0Wokk.js} +1 -1
  156. package/dist/assets/{spaces-Ds86J12r.js → spaces-aCe1kYiI.js} +1 -1
  157. package/dist/assets/{status-DSta50m1.js → status-5AJjPzHg.js} +1 -1
  158. package/dist/assets/{status-CikSPd5y.js → status-CCSCecRC.js} +1 -1
  159. package/dist/assets/{switch-control-BcMqvX98.js → switch-control-DOm8qAmq.js} +1 -1
  160. package/dist/assets/{table-icons-BaaufujD.js → table-icons-GjIbys6_.js} +1 -1
  161. package/dist/assets/{team-WiS8_opu.js → team-Dw7hS6Bc.js} +1 -1
  162. package/dist/assets/{th-DH3YSYWo.js → th-DYSyn_pj.js} +1 -1
  163. package/dist/assets/{toLower-J-761LZs.js → toLower-BinVt74l.js} +1 -1
  164. package/dist/assets/toUpper-anXo-ggR.js +1 -0
  165. package/dist/assets/{traffic-i-oajLGo.js → traffic-MGLusjBr.js} +1 -1
  166. package/dist/assets/{tsMode-BqPXeNK6.js → tsMode-C-zh41uv.js} +1 -1
  167. package/dist/assets/{typescript-BeMpQ1cp.js → typescript-BIzegp0-.js} +1 -1
  168. package/dist/assets/{url-evaluation-BHlD72Za.js → url-evaluation-fJhr4k6U.js} +1 -1
  169. package/dist/assets/{url-join-Be8UMYxb.js → url-join-DlomnNeb.js} +1 -1
  170. package/dist/assets/{use-mobile-DKnUPYLh.js → use-mobile-BgyIeM_C.js} +1 -1
  171. package/dist/assets/{use-mobile-CFKbUUod.js → use-mobile-CjprZz34.js} +1 -1
  172. package/dist/assets/{useAsync-BvyaX1xb.js → useAsync-BiLMNSAI.js} +1 -1
  173. package/dist/assets/{useAsyncRetry-COLHYiqH.js → useAsyncRetry-BT3DBK7F.js} +1 -1
  174. package/dist/assets/{useLocalStorage-CcnFSYKq.js → useLocalStorage-DYsBBPSS.js} +1 -1
  175. package/dist/assets/{useThemeProps-12AJ9O-O.js → useThemeProps-Sm38RiTN.js} +1 -1
  176. package/dist/assets/{util-BN8LJS24.js → util-D4si24OH.js} +1 -1
  177. package/dist/assets/{vi-B-WRpo9V.js → vi-BvKqvojn.js} +1 -1
  178. package/dist/assets/{wait-container-BeVXHkhI.js → wait-container-DufqEdNT.js} +1 -1
  179. package/dist/assets/{without-wallet-Ciw14vC_.js → without-wallet-BAMPTN5t.js} +1 -1
  180. package/dist/assets/wrap-locale-CO874YZ_.js +1 -0
  181. package/dist/assets/{xml-CPmGSa9a.js → xml-ShorgZ4K.js} +1 -1
  182. package/dist/assets/{yaml-Bgt1uL1Q.js → yaml-BLdL0c9B.js} +1 -1
  183. package/dist/assets/{zh-jdBEl5u8.js → zh-BaEjqGHy.js} +1 -1
  184. package/dist/assets/{zh-tw-2esms75_.js → zh-tw-xcyHbP3V.js} +1 -1
  185. package/dist/index.html +136 -2
  186. package/dist/service-worker.js +1 -1
  187. package/package.json +1 -1
  188. package/dist/assets/ArrowDropDown-BKRskDGW.js +0 -1
  189. package/dist/assets/api-CNS9XStH.js +0 -1
  190. package/dist/assets/chain-DApQ_02_.js +0 -6
  191. package/dist/assets/client-CRwMqq4a.js +0 -1
  192. package/dist/assets/cloneDeep-XzHe1lBt.js +0 -1
  193. package/dist/assets/download-1sZ_L4eJ.css +0 -32
  194. package/dist/assets/download-B60HlzLV.js +0 -94
  195. package/dist/assets/emotion-cache.browser.esm-xd7x6o_F.js +0 -1
  196. package/dist/assets/engine-6r3-G42f.js +0 -1
  197. package/dist/assets/getValidReactChildren-Dx-rXSuI.js +0 -1
  198. package/dist/assets/index-BvZ7ueS0.js +0 -602
  199. package/dist/assets/index-Djt_Uvu7.js +0 -1
  200. package/dist/assets/index-DyWKbsNy.js +0 -11
  201. package/dist/assets/omit-DCOcIQME.js +0 -1
  202. package/dist/assets/schema-CtGZqsss.js +0 -1
  203. package/dist/assets/sdk-bmyf6_R7.js +0 -1
  204. package/dist/assets/toUpper-DndvmnJP.js +0 -1
  205. package/dist/assets/wrap-locale-B-zny1Rh.js +0 -1
@@ -1 +1 @@
1
- import{aG as le,j as e,ht as ce,bd as ue,bn as Y,m as Z,fL as ee,fc as te,aP as re,cr as u,H as S,hu as M,N as R,t as x,hv as V,aU as H,Q as p,az as de,v as N,s as ie,aV as ne,z as me,y as fe,E as he,r as U,g as xe,by as pe}from"./index-D2dk65xX.js";import{T as ve}from"./html-title-Bv34eYvs.js";import{u as se,C as m}from"./index.esm-DXYSp_08.js";import{S as h,A as je,a as be,b as ge,c as ye}from"./collapse-Dezh2CAn.js";import{u as ae}from"./blocklet-CSWEnHbv.js";import{S as $}from"./Switch-D8Y_AkUP.js";const Re=le(e.jsx("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2m1 17h-2v-2h2zm2.07-7.75-.9.92C13.45 12.9 13 13.5 13 15h-2v-.5c0-1.1.45-2.1 1.17-2.83l1.24-1.26c.37-.36.59-.86.59-1.41 0-1.1-.9-2-2-2s-2 .9-2 2H8c0-2.21 1.79-4 4-4s4 1.79 4 4c0 .88-.36 1.68-.93 2.25"}));var K={exports:{}},O={exports:{}},z={exports:{}},J;function Te(){return J||(J=1,function(c,s){Object.defineProperty(s,"__esModule",{value:!0}),s.default=t;function t(d){return d==null}c.exports=s.default,c.exports.default=s.default}(z,z.exports)),z.exports}var Q;function Ee(){return Q||(Q=1,function(c,s){Object.defineProperty(s,"__esModule",{value:!0}),s.default=k;var t=b(ce()),d=b(Te());function b(n){return n&&n.__esModule?n:{default:n}}var f=/^(?:[-+]?(?:0|[1-9][0-9]*))$/,P=/^[-+]?[0-9]+$/;function k(n,i){(0,t.default)(n),i=i||{};var _=i.allow_leading_zeroes===!1?f:P,q=!i.hasOwnProperty("min")||(0,d.default)(i.min)||n>=i.min,l=!i.hasOwnProperty("max")||(0,d.default)(i.max)||n<=i.max,a=!i.hasOwnProperty("lt")||(0,d.default)(i.lt)||n<i.lt,C=!i.hasOwnProperty("gt")||(0,d.default)(i.gt)||n>i.gt;return _.test(n)&&q&&l&&a&&C}c.exports=s.default,c.exports.default=s.default}(O,O.exports)),O.exports}var G;function we(){return G||(G=1,function(c,s){Object.defineProperty(s,"__esModule",{value:!0}),s.default=b;var t=d(Ee());function d(f){return f&&f.__esModule?f:{default:f}}function b(f){return(0,t.default)(f,{allow_leading_zeroes:!1,min:0,max:65535})}c.exports=s.default,c.exports.default=s.default}(K,K.exports)),K.exports}var Se=we();const ke=ue(Se),B={enabled:!1,secure:!1,from:"",host:"",port:"",user:"",password:"",companyName:"",companyLink:"",companyAddress:"",supportEmail:""};function Ce(){const{api:c}=Y(),{blocklet:s}=ae(),{t}=Z(),{confirmApi:d,confirmHolder:b}=ee(),f=s?.meta?.did,P=Object.assign({...B},s?.settings?.notification?.email||{}),{handleSubmit:k,control:n,formState:i,watch:_,reset:q}=se({defaultValues:te(P,Object.keys(B))}),l=re({testReceiver:"",testReceiverError:""}),a=_("enabled"),C=u(async(r,g,w=!0)=>{try{const{blocklet:y}=await c.configNotification({input:{did:f,notification:JSON.stringify({email:r})}}),oe=Object.assign({...B},y?.settings?.notification?.email||{});q(oe),w&&S.success(t("oauth.saveSuccess"))}catch(y){if(w)S.error(y.message||t("oauth.saveFailed"));else throw y}}),W=u(async(r,g,w)=>{try{i.isDirty&&await C(r,g,!1),await c.sendEmail({input:{did:f,receiver:w,email:JSON.stringify({body:"Your SMTP configuration is correct!",title:"Test email",type:"notification"})}}),S.success(t("notification.email.testSuccess"))}catch(y){S.error(y.message||t("notification.email.testfailed"))}}),A=u((r,g)=>{l.testReceiver="",l.testReceiverError="",d.open({title:t("notification.email.testSendEmail"),content:()=>e.jsx(R,{sx:{width:"300px"},children:e.jsx(x,{sx:{mt:1},fullWidth:!0,name:"testReceiver",label:t("notification.email.inputTestReceiver"),value:l.testReceiver,onChange:w=>{l.testReceiver=w.target.value},error:!!l.testReceiverError,helperText:l.testReceiverError||" "})}),confirmButtonText:t("common.confirm"),cancelButtonText:t("common.cancel"),async onConfirm(w){const y=l.testReceiver?.trim();if(!y){l.testReceiverError=t("notification.email.receiverRequired");return}if(!M(y)){l.testReceiverError=t("notification.email.receiverInvalid");return}l.testReceiverError="",await W(r,g,y),w()}})}),F=u(r=>{const g=r?.trim();return g?M(g)?!0:t("notification.email.fromInvalid"):t("notification.email.fromRequired")}),L=u(r=>{const g=r?.trim();return g?V(g,{require_host:!1,protocols:[]})?!0:t("notification.email.hostInvalid"):t("notification.email.hostRequired")}),o=u(r=>r?ke(r)?!0:t("notification.email.portInvalid"):t("notification.email.portRequired")),T=u(r=>r?.trim()?!0:t("notification.email.userRequired")),v=u(r=>r?.trim()?!0:t("notification.email.passwordRequired")),E=u(r=>r?.trim()&&!V(r,{protocols:["http","https"],require_protocol:!0})?t("notification.email.linkInvalid"):!0),I=u(r=>r?.trim()&&!M(r)?t("notification.email.emailInvalid"):!0),j=u(()=>!0);return e.jsxs(R,{children:[e.jsxs(Pe,{component:"form",onSubmit:k(C),disabled:!0,sx:{".section-left":{width:"160px"}},children:[e.jsx(h,{title:t("notification.email.enable"),my:2.5,children:e.jsx(m,{name:"enabled",control:n,render:({field:r})=>e.jsx(H,{control:e.jsx($,{checked:r.value,...r})})})}),e.jsx(h,{title:t("notification.email.from"),children:e.jsx(m,{name:"from",control:n,rules:{validate:a?F:j},render:({field:r})=>e.jsx(p,{fullWidth:!0,children:e.jsx(x,{...r,size:"small",required:!0,label:t("notification.email.from"),error:!!i.errors[r.name],helperText:i.errors[r.name]?.message||" ",disabled:!a})})})}),e.jsx(h,{title:t("notification.email.host"),children:e.jsx(m,{name:"host",control:n,rules:{validate:a?L:j},render:({field:r})=>e.jsx(p,{fullWidth:!0,children:e.jsx(x,{...r,size:"small",required:!0,error:!!i.errors[r.name],label:t("notification.email.host"),helperText:i.errors[r.name]?.message||" ",disabled:!a})})})}),e.jsx(h,{title:t("notification.email.port"),children:e.jsx(m,{name:"port",control:n,rules:{validate:a?o:j},render:({field:r})=>e.jsx(p,{fullWidth:!0,children:e.jsx(x,{...r,size:"small",required:!0,type:"number",error:!!i.errors[r.name],label:t("notification.email.port"),helperText:i.errors[r.name]?.message||" ",disabled:!a})})})}),e.jsx(h,{title:t("notification.email.user"),children:e.jsx(m,{name:"user",control:n,rules:{validate:a?T:j},render:({field:r})=>e.jsx(p,{fullWidth:!0,children:e.jsx(x,{...r,size:"small",required:!0,error:!!i.errors[r.name],label:t("notification.email.user"),helperText:i.errors[r.name]?.message||" ",disabled:!a})})})}),e.jsx(h,{title:t("notification.email.password"),children:e.jsx(m,{name:"password",control:n,rules:{validate:a?v:j},render:({field:r})=>e.jsx(p,{fullWidth:!0,children:e.jsx(x,{...r,size:"small",required:!0,type:"password",error:!!i.errors[r.name],label:t("notification.email.password"),helperText:i.errors[r.name]?.message||" ",disabled:!a})})})}),e.jsx(h,{title:t("notification.email.secure"),children:e.jsx(m,{name:"secure",control:n,rules:{validate:j},render:({field:r})=>e.jsx(p,{fullWidth:!0,children:e.jsx(H,{control:e.jsx($,{checked:r.value,...r,disabled:!a})})})})}),e.jsxs(je,{children:[e.jsxs(be,{expandIcon:e.jsx(ge,{fontSize:"small"}),"aria-controls":"panel1-content",id:"panel1-header",children:[t("notification.email.signature"),e.jsx(de,{title:t("notification.email.signatureTooltip"),children:e.jsx(Re,{fontSize:"small",sx:{ml:1,cursor:"help"}})})]}),e.jsxs(ye,{children:[e.jsx(h,{title:t("notification.email.companyName"),children:e.jsx(m,{name:"companyName",control:n,rules:{validate:j},render:({field:r})=>e.jsx(p,{fullWidth:!0,children:e.jsx(x,{...r,size:"small",error:!!i.errors[r.name],label:t("notification.email.companyName"),helperText:i.errors[r.name]?.message||" ",disabled:!a})})})}),e.jsx(h,{title:t("notification.email.companyLink"),children:e.jsx(m,{name:"companyLink",control:n,rules:{validate:a?E:j},render:({field:r})=>e.jsx(p,{fullWidth:!0,children:e.jsx(x,{...r,size:"small",error:!!i.errors[r.name],label:t("notification.email.companyLink"),helperText:i.errors[r.name]?.message||" ",disabled:!a})})})}),e.jsx(h,{title:t("notification.email.companyAddress"),children:e.jsx(m,{name:"companyAddress",control:n,rules:{validate:j},render:({field:r})=>e.jsx(p,{fullWidth:!0,children:e.jsx(x,{...r,size:"small",error:!!i.errors[r.name],label:t("notification.email.companyAddress"),helperText:i.errors[r.name]?.message||" ",disabled:!a})})})}),e.jsx(h,{title:t("notification.email.supportEmail"),children:e.jsx(m,{name:"supportEmail",control:n,rules:{validate:a?I:j},render:({field:r})=>e.jsx(p,{fullWidth:!0,children:e.jsx(x,{...r,size:"small",type:"email",error:!!i.errors[r.name],label:t("notification.email.supportEmail"),helperText:i.errors[r.name]?.message||" ",disabled:!a})})})})]})]}),e.jsxs(R,{sx:{display:"flex",justifyContent:"flex-end",gap:2,mt:3},children:[e.jsx(N,{variant:"outlined",color:"warning",onClick:k(A),disabled:!a,children:t("oauth.runTest")}),e.jsx(N,{type:"submit",variant:"contained",disabled:!i.isDirty,children:t("oauth.save")})]})]}),b]})}const Pe=ie(ne)``,D={enabled:!1,endpoint:"",did:void 0,pushPath:void 0};function _e(){const{api:c}=Y(),{blocklet:s}=ae(),{t}=Z(),{confirmApi:d,confirmHolder:b}=ee(),f=s?.meta?.did,P=Object.assign({...D},s?.settings?.notification?.pushKit||{}),{handleSubmit:k,control:n,formState:i,watch:_,reset:q}=se({defaultValues:te(P,Object.keys(D))}),l=re({testReceiver:"",testReceiverError:""}),a=_("enabled"),C=u(async(o,T,v=!0)=>{try{const{blocklet:E}=await c.configNotification({input:{did:f,notification:JSON.stringify({pushKit:o})}}),I=Object.assign({...D},E?.settings?.notification?.pushKit||{});q(I),v&&S.success(t("oauth.saveSuccess"))}catch(E){if(v)S.error(E.message||t("oauth.saveFailed"));else throw E}}),W=u(async(o,T)=>{try{i.isDirty&&await C(o,T,!1);const v=(s?.configs||[]).find(j=>j.key==="BLOCKLET_APP_URL")?.value,E=me(fe(v,he.WELLKNOWN_SERVICE_PATH_PREFIX,"/blocklet/logo"),{v:s?.meta?.version,t:new Date(s?.updatedAt||0).getTime()}),I={type:"passthrough",passthroughType:"messageStatus",data:{message:{title:"Test push-kit notification",body:"This is message from push-kit config test",sender:{did:s?.appDid,fullName:s?.meta?.title,avatar:E}}}};await c.sendPush({input:{did:f,receiver:l.testReceiver,notification:JSON.stringify(I)}}),S.success(t("notification.pushKit.testSuccess"))}catch(v){S.error(v.message||t("notification.pushKit.testfailed"))}}),A=u((o,T)=>{l.testReceiverError="",d.open({title:t("notification.pushKit.testSend"),content:()=>e.jsx(R,{sx:{width:"450px",maxWidth:"100%"},children:e.jsx(x,{sx:{mt:1},fullWidth:!0,name:"testReceiver",label:t("notification.pushKit.inputTestReceiver"),value:l.testReceiver,onChange:v=>{l.testReceiver=v.target.value},error:!!l.testReceiverError,helperText:l.testReceiverError||" "})}),confirmButtonText:t("common.confirm"),cancelButtonText:t("common.cancel"),async onConfirm(v){if(!l.testReceiver?.trim()){l.testReceiverError=t("notification.pushKit.receiverRequired");return}l.testReceiverError="",await W(o,T),v()}})}),F=u(o=>{const T=o?.trim();return T?V(T)?!0:t("notification.pushKit.endpointInvalid"):t("notification.pushKit.endpointRequired")}),L=u(()=>!0);return e.jsxs(R,{children:[e.jsxs(qe,{component:"form",onSubmit:k(C),disabled:!0,sx:{".section-left":{width:"160px"}},children:[e.jsx(h,{title:t("notification.pushKit.enable"),my:2.5,children:e.jsx(m,{name:"enabled",control:n,render:({field:o})=>e.jsx(H,{control:e.jsx($,{checked:o.value,...o})})})}),e.jsx(h,{title:t("notification.pushKit.endpoint"),children:e.jsx(m,{name:"endpoint",control:n,rules:{validate:a?F:L},render:({field:o})=>e.jsx(p,{fullWidth:!0,children:e.jsx(x,{...o,size:"small",required:!0,label:t("notification.pushKit.endpoint"),error:!!i.errors[o.name],helperText:i.errors[o.name]?.message||" ",disabled:!a})})})}),e.jsxs(h,{title:t("notification.pushKit.customOptions"),children:[e.jsx(m,{name:"did",control:n,render:({field:o})=>e.jsx(p,{fullWidth:!0,children:e.jsx(x,{...o,size:"small",label:t("notification.pushKit.did"),error:!!i.errors[o.name],helperText:i.errors[o.name]?.message||" ",disabled:!a})})}),e.jsx(m,{name:"pushPath",control:n,render:({field:o})=>e.jsx(p,{fullWidth:!0,children:e.jsx(x,{...o,size:"small",label:t("notification.pushKit.pushPath"),error:!!i.errors[o.name],helperText:i.errors[o.name]?.message||" ",disabled:!a})})})]}),e.jsxs(R,{sx:{display:"flex",justifyContent:"flex-end",gap:2,mt:3},children:[e.jsx(N,{variant:"outlined",color:"warning",onClick:k(A),disabled:!a,children:t("oauth.runTest")}),e.jsx(N,{type:"submit",variant:"contained",disabled:!i.isDirty,children:t("oauth.save")})]})]}),b]})}const qe=ie(ne)``,X=[{label:e.jsx(R,{sx:{textAlign:"center",width:"100%"},children:"Email"}),value:"email"},{label:e.jsx(R,{sx:{textAlign:"center",width:"100%"},children:"Push Kit"}),value:"pushKit"}];function Ae(){const[c,s]=U.useState(X[0].value),{locale:t}=U.useContext(xe),d=pe(()=>({email:e.jsx(Ce,{}),pushKit:e.jsx(_e,{})}),[t]),b=U.useMemo(()=>({padding:"10px 0"}),[]);return e.jsxs(R,{children:[e.jsx(ve,{tabs:X,current:c,onChange:s}),e.jsx(R,{style:b,children:d[c]})]})}export{Ae as B};
1
+ import{aG as le,j as e,hu as ce,bd as ue,bn as Y,m as Z,fL as ee,fc as te,aP as re,cr as u,H as S,hv as M,N as R,t as x,hw as V,aU as H,Q as p,az as de,v as N,s as ie,aV as ne,z as me,y as fe,E as he,r as U,g as xe,by as pe}from"./index-DKjIcWre.js";import{T as ve}from"./html-title-SrM7nvGF.js";import{u as se,C as m}from"./index.esm-CJDPJkDt.js";import{S as h,A as je,a as be,b as ge,c as ye}from"./collapse-CbgK57uT.js";import{u as ae}from"./blocklet-Cu7NUdbv.js";import{S as $}from"./Switch-D7_wVs3b.js";const Re=le(e.jsx("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2m1 17h-2v-2h2zm2.07-7.75-.9.92C13.45 12.9 13 13.5 13 15h-2v-.5c0-1.1.45-2.1 1.17-2.83l1.24-1.26c.37-.36.59-.86.59-1.41 0-1.1-.9-2-2-2s-2 .9-2 2H8c0-2.21 1.79-4 4-4s4 1.79 4 4c0 .88-.36 1.68-.93 2.25"}));var K={exports:{}},O={exports:{}},z={exports:{}},J;function Te(){return J||(J=1,function(c,s){Object.defineProperty(s,"__esModule",{value:!0}),s.default=t;function t(d){return d==null}c.exports=s.default,c.exports.default=s.default}(z,z.exports)),z.exports}var Q;function we(){return Q||(Q=1,function(c,s){Object.defineProperty(s,"__esModule",{value:!0}),s.default=k;var t=b(ce()),d=b(Te());function b(n){return n&&n.__esModule?n:{default:n}}var f=/^(?:[-+]?(?:0|[1-9][0-9]*))$/,P=/^[-+]?[0-9]+$/;function k(n,i){(0,t.default)(n),i=i||{};var _=i.allow_leading_zeroes===!1?f:P,q=!i.hasOwnProperty("min")||(0,d.default)(i.min)||n>=i.min,l=!i.hasOwnProperty("max")||(0,d.default)(i.max)||n<=i.max,a=!i.hasOwnProperty("lt")||(0,d.default)(i.lt)||n<i.lt,C=!i.hasOwnProperty("gt")||(0,d.default)(i.gt)||n>i.gt;return _.test(n)&&q&&l&&a&&C}c.exports=s.default,c.exports.default=s.default}(O,O.exports)),O.exports}var G;function Ee(){return G||(G=1,function(c,s){Object.defineProperty(s,"__esModule",{value:!0}),s.default=b;var t=d(we());function d(f){return f&&f.__esModule?f:{default:f}}function b(f){return(0,t.default)(f,{allow_leading_zeroes:!1,min:0,max:65535})}c.exports=s.default,c.exports.default=s.default}(K,K.exports)),K.exports}var Se=Ee();const ke=ue(Se),B={enabled:!1,secure:!1,from:"",host:"",port:"",user:"",password:"",companyName:"",companyLink:"",companyAddress:"",supportEmail:""};function Ce(){const{api:c}=Y(),{blocklet:s}=ae(),{t}=Z(),{confirmApi:d,confirmHolder:b}=ee(),f=s?.meta?.did,P=Object.assign({...B},s?.settings?.notification?.email||{}),{handleSubmit:k,control:n,formState:i,watch:_,reset:q}=se({defaultValues:te(P,Object.keys(B))}),l=re({testReceiver:"",testReceiverError:""}),a=_("enabled"),C=u(async(r,g,E=!0)=>{try{const{blocklet:y}=await c.configNotification({input:{did:f,notification:JSON.stringify({email:r})}}),oe=Object.assign({...B},y?.settings?.notification?.email||{});q(oe),E&&S.success(t("oauth.saveSuccess"))}catch(y){if(E)S.error(y.message||t("oauth.saveFailed"));else throw y}}),W=u(async(r,g,E)=>{try{i.isDirty&&await C(r,g,!1),await c.sendEmail({input:{did:f,receiver:E,email:JSON.stringify({body:"Your SMTP configuration is correct!",title:"Test email",type:"notification"})}}),S.success(t("notification.email.testSuccess"))}catch(y){S.error(y.message||t("notification.email.testfailed"))}}),A=u((r,g)=>{l.testReceiver="",l.testReceiverError="",d.open({title:t("notification.email.testSendEmail"),content:()=>e.jsx(R,{sx:{width:"300px"},children:e.jsx(x,{sx:{mt:1},fullWidth:!0,name:"testReceiver",label:t("notification.email.inputTestReceiver"),value:l.testReceiver,onChange:E=>{l.testReceiver=E.target.value},error:!!l.testReceiverError,helperText:l.testReceiverError||" "})}),confirmButtonText:t("common.confirm"),cancelButtonText:t("common.cancel"),async onConfirm(E){const y=l.testReceiver?.trim();if(!y){l.testReceiverError=t("notification.email.receiverRequired");return}if(!M(y)){l.testReceiverError=t("notification.email.receiverInvalid");return}l.testReceiverError="",await W(r,g,y),E()}})}),F=u(r=>{const g=r?.trim();return g?M(g)?!0:t("notification.email.fromInvalid"):t("notification.email.fromRequired")}),L=u(r=>{const g=r?.trim();return g?V(g,{require_host:!1,protocols:[]})?!0:t("notification.email.hostInvalid"):t("notification.email.hostRequired")}),o=u(r=>r?ke(r)?!0:t("notification.email.portInvalid"):t("notification.email.portRequired")),T=u(r=>r?.trim()?!0:t("notification.email.userRequired")),v=u(r=>r?.trim()?!0:t("notification.email.passwordRequired")),w=u(r=>r?.trim()&&!V(r,{protocols:["http","https"],require_protocol:!0})?t("notification.email.linkInvalid"):!0),I=u(r=>r?.trim()&&!M(r)?t("notification.email.emailInvalid"):!0),j=u(()=>!0);return e.jsxs(R,{children:[e.jsxs(Pe,{component:"form",onSubmit:k(C),disabled:!0,sx:{".section-left":{width:"160px"}},children:[e.jsx(h,{title:t("notification.email.enable"),my:2.5,children:e.jsx(m,{name:"enabled",control:n,render:({field:r})=>e.jsx(H,{control:e.jsx($,{checked:r.value,...r})})})}),e.jsx(h,{title:t("notification.email.from"),children:e.jsx(m,{name:"from",control:n,rules:{validate:a?F:j},render:({field:r})=>e.jsx(p,{fullWidth:!0,children:e.jsx(x,{...r,size:"small",required:!0,label:t("notification.email.from"),error:!!i.errors[r.name],helperText:i.errors[r.name]?.message||" ",disabled:!a})})})}),e.jsx(h,{title:t("notification.email.host"),children:e.jsx(m,{name:"host",control:n,rules:{validate:a?L:j},render:({field:r})=>e.jsx(p,{fullWidth:!0,children:e.jsx(x,{...r,size:"small",required:!0,error:!!i.errors[r.name],label:t("notification.email.host"),helperText:i.errors[r.name]?.message||" ",disabled:!a})})})}),e.jsx(h,{title:t("notification.email.port"),children:e.jsx(m,{name:"port",control:n,rules:{validate:a?o:j},render:({field:r})=>e.jsx(p,{fullWidth:!0,children:e.jsx(x,{...r,size:"small",required:!0,type:"number",error:!!i.errors[r.name],label:t("notification.email.port"),helperText:i.errors[r.name]?.message||" ",disabled:!a})})})}),e.jsx(h,{title:t("notification.email.user"),children:e.jsx(m,{name:"user",control:n,rules:{validate:a?T:j},render:({field:r})=>e.jsx(p,{fullWidth:!0,children:e.jsx(x,{...r,size:"small",required:!0,error:!!i.errors[r.name],label:t("notification.email.user"),helperText:i.errors[r.name]?.message||" ",disabled:!a})})})}),e.jsx(h,{title:t("notification.email.password"),children:e.jsx(m,{name:"password",control:n,rules:{validate:a?v:j},render:({field:r})=>e.jsx(p,{fullWidth:!0,children:e.jsx(x,{...r,size:"small",required:!0,type:"password",error:!!i.errors[r.name],label:t("notification.email.password"),helperText:i.errors[r.name]?.message||" ",disabled:!a})})})}),e.jsx(h,{title:t("notification.email.secure"),children:e.jsx(m,{name:"secure",control:n,rules:{validate:j},render:({field:r})=>e.jsx(p,{fullWidth:!0,children:e.jsx(H,{control:e.jsx($,{checked:r.value,...r,disabled:!a})})})})}),e.jsxs(je,{children:[e.jsxs(be,{expandIcon:e.jsx(ge,{fontSize:"small"}),"aria-controls":"panel1-content",id:"panel1-header",children:[t("notification.email.signature"),e.jsx(de,{title:t("notification.email.signatureTooltip"),children:e.jsx(Re,{fontSize:"small",sx:{ml:1,cursor:"help"}})})]}),e.jsxs(ye,{children:[e.jsx(h,{title:t("notification.email.companyName"),children:e.jsx(m,{name:"companyName",control:n,rules:{validate:j},render:({field:r})=>e.jsx(p,{fullWidth:!0,children:e.jsx(x,{...r,size:"small",error:!!i.errors[r.name],label:t("notification.email.companyName"),helperText:i.errors[r.name]?.message||" ",disabled:!a})})})}),e.jsx(h,{title:t("notification.email.companyLink"),children:e.jsx(m,{name:"companyLink",control:n,rules:{validate:a?w:j},render:({field:r})=>e.jsx(p,{fullWidth:!0,children:e.jsx(x,{...r,size:"small",error:!!i.errors[r.name],label:t("notification.email.companyLink"),helperText:i.errors[r.name]?.message||" ",disabled:!a})})})}),e.jsx(h,{title:t("notification.email.companyAddress"),children:e.jsx(m,{name:"companyAddress",control:n,rules:{validate:j},render:({field:r})=>e.jsx(p,{fullWidth:!0,children:e.jsx(x,{...r,size:"small",error:!!i.errors[r.name],label:t("notification.email.companyAddress"),helperText:i.errors[r.name]?.message||" ",disabled:!a})})})}),e.jsx(h,{title:t("notification.email.supportEmail"),children:e.jsx(m,{name:"supportEmail",control:n,rules:{validate:a?I:j},render:({field:r})=>e.jsx(p,{fullWidth:!0,children:e.jsx(x,{...r,size:"small",type:"email",error:!!i.errors[r.name],label:t("notification.email.supportEmail"),helperText:i.errors[r.name]?.message||" ",disabled:!a})})})})]})]}),e.jsxs(R,{sx:{display:"flex",justifyContent:"flex-end",gap:2,mt:3},children:[e.jsx(N,{variant:"outlined",color:"warning",onClick:k(A),disabled:!a,children:t("oauth.runTest")}),e.jsx(N,{type:"submit",variant:"contained",disabled:!i.isDirty,children:t("oauth.save")})]})]}),b]})}const Pe=ie(ne)``,D={enabled:!1,endpoint:"",did:void 0,pushPath:void 0};function _e(){const{api:c}=Y(),{blocklet:s}=ae(),{t}=Z(),{confirmApi:d,confirmHolder:b}=ee(),f=s?.meta?.did,P=Object.assign({...D},s?.settings?.notification?.pushKit||{}),{handleSubmit:k,control:n,formState:i,watch:_,reset:q}=se({defaultValues:te(P,Object.keys(D))}),l=re({testReceiver:"",testReceiverError:""}),a=_("enabled"),C=u(async(o,T,v=!0)=>{try{const{blocklet:w}=await c.configNotification({input:{did:f,notification:JSON.stringify({pushKit:o})}}),I=Object.assign({...D},w?.settings?.notification?.pushKit||{});q(I),v&&S.success(t("oauth.saveSuccess"))}catch(w){if(v)S.error(w.message||t("oauth.saveFailed"));else throw w}}),W=u(async(o,T)=>{try{i.isDirty&&await C(o,T,!1);const v=(s?.configs||[]).find(j=>j.key==="BLOCKLET_APP_URL")?.value,w=me(fe(v,he.WELLKNOWN_SERVICE_PATH_PREFIX,"/blocklet/logo"),{v:s?.meta?.version,t:new Date(s?.updatedAt||0).getTime()}),I={type:"passthrough",passthroughType:"messageStatus",data:{message:{title:"Test push-kit notification",body:"This is message from push-kit config test",sender:{did:s?.appDid,fullName:s?.meta?.title,avatar:w}}}};await c.sendPush({input:{did:f,receiver:l.testReceiver,notification:JSON.stringify(I)}}),S.success(t("notification.pushKit.testSuccess"))}catch(v){S.error(v.message||t("notification.pushKit.testfailed"))}}),A=u((o,T)=>{l.testReceiverError="",d.open({title:t("notification.pushKit.testSend"),content:()=>e.jsx(R,{sx:{width:"450px",maxWidth:"100%"},children:e.jsx(x,{sx:{mt:1},fullWidth:!0,name:"testReceiver",label:t("notification.pushKit.inputTestReceiver"),value:l.testReceiver,onChange:v=>{l.testReceiver=v.target.value},error:!!l.testReceiverError,helperText:l.testReceiverError||" "})}),confirmButtonText:t("common.confirm"),cancelButtonText:t("common.cancel"),async onConfirm(v){if(!l.testReceiver?.trim()){l.testReceiverError=t("notification.pushKit.receiverRequired");return}l.testReceiverError="",await W(o,T),v()}})}),F=u(o=>{const T=o?.trim();return T?V(T)?!0:t("notification.pushKit.endpointInvalid"):t("notification.pushKit.endpointRequired")}),L=u(()=>!0);return e.jsxs(R,{children:[e.jsxs(qe,{component:"form",onSubmit:k(C),disabled:!0,sx:{".section-left":{width:"160px"}},children:[e.jsx(h,{title:t("notification.pushKit.enable"),my:2.5,children:e.jsx(m,{name:"enabled",control:n,render:({field:o})=>e.jsx(H,{control:e.jsx($,{checked:o.value,...o})})})}),e.jsx(h,{title:t("notification.pushKit.endpoint"),children:e.jsx(m,{name:"endpoint",control:n,rules:{validate:a?F:L},render:({field:o})=>e.jsx(p,{fullWidth:!0,children:e.jsx(x,{...o,size:"small",required:!0,label:t("notification.pushKit.endpoint"),error:!!i.errors[o.name],helperText:i.errors[o.name]?.message||" ",disabled:!a})})})}),e.jsxs(h,{title:t("notification.pushKit.customOptions"),children:[e.jsx(m,{name:"did",control:n,render:({field:o})=>e.jsx(p,{fullWidth:!0,children:e.jsx(x,{...o,size:"small",label:t("notification.pushKit.did"),error:!!i.errors[o.name],helperText:i.errors[o.name]?.message||" ",disabled:!a})})}),e.jsx(m,{name:"pushPath",control:n,render:({field:o})=>e.jsx(p,{fullWidth:!0,children:e.jsx(x,{...o,size:"small",label:t("notification.pushKit.pushPath"),error:!!i.errors[o.name],helperText:i.errors[o.name]?.message||" ",disabled:!a})})})]}),e.jsxs(R,{sx:{display:"flex",justifyContent:"flex-end",gap:2,mt:3},children:[e.jsx(N,{variant:"outlined",color:"warning",onClick:k(A),disabled:!a,children:t("oauth.runTest")}),e.jsx(N,{type:"submit",variant:"contained",disabled:!i.isDirty,children:t("oauth.save")})]})]}),b]})}const qe=ie(ne)``,X=[{label:e.jsx(R,{sx:{textAlign:"center",width:"100%"},children:"Email"}),value:"email"},{label:e.jsx(R,{sx:{textAlign:"center",width:"100%"},children:"Push Kit"}),value:"pushKit"}];function Ae(){const[c,s]=U.useState(X[0].value),{locale:t}=U.useContext(xe),d=pe(()=>({email:e.jsx(Ce,{}),pushKit:e.jsx(_e,{})}),[t]),b=U.useMemo(()=>({padding:"10px 0"}),[]);return e.jsxs(R,{children:[e.jsx(ve,{tabs:X,current:c,onChange:s}),e.jsx(R,{style:b,children:d[c]})]})}export{Ae as B};
@@ -1,4 +1,4 @@
1
- import{bX as We,bW as Ge,r as h,bY as Fe,j as e,b8 as ee,b_ as Ke,cb as J,b$ as $e,bU as Ye,cd as He,aG as he,O as q,bn as N,cq as qe,H as B,Y as V,bf as D,fB as Ce,aQ as we,b as M,iZ as Ve,m as E,gw as Qe,o as m,x as Xe,ax as Be,y as fe,al as Ze,g as Je,C as A,T as j,i as et,s as tt,f as st,i_ as X,hT as Z,i$ as ot,N as S,aV as G,E as T,L as nt,p as H,dk as at,az as Se,U as K,aF as $,a9 as Y,a5 as rt,dH as it,gm as ct,a$ as lt,v as pe,w as dt,G as be,Z as De,by as xe,B as pt}from"./index-D2dk65xX.js";import{T as ut}from"./html-title-Bv34eYvs.js";import{u as U}from"./blocklet-CSWEnHbv.js";import{u as mt}from"./use-mobile-DKnUPYLh.js";import{c as Ee,d as ft,e as xt,f as gt,g as ue,h as ht,b as St,u as yt,C as bt,D as kt,a as jt}from"./connect-to-Dyd-KizX.js";import"./index-efuh0Sux.js";import"./index-BojVbZw0.js";import"./api-CNS9XStH.js";import{d as Ct,a as wt,g as Bt,i as Dt,e as ge,f as Et,h as It,j as Tt}from"./spaces-Ds86J12r.js";import{v as Rt}from"./index-DpI-XQ1l.js";import{E as zt}from"./index-Bls5HB_P.js";import{H as vt}from"./HelpOutline-B7Ct-krn.js";import{H as Pt}from"./index-B3l3haQa.js";import{x as At}from"./index-DRYJ0xIl.js";import{c as Ut}from"./actions-Cxap2JOs.js";import{D as Lt}from"./DeleteOutline-D00EO6C8.js";import{g as ke}from"./get-safe-url-CXm2qbfD.js";import{S as Ot}from"./switch-control-BcMqvX98.js";import{L as je}from"./list-header-BKASZXQp.js";import"./OpenInNew-53sNi7bT.js";import"./ButtonGroup-2OIq-PXC.js";import"./getValidReactChildren-Dx-rXSuI.js";import"./FilterList-TV3SGdIn.js";import"./CSSTransition-RdSxc12C.js";import"./emotion-cache.browser.esm-xd7x6o_F.js";import"./index-20ehiOeZ.js";import"./redux-DfszZyTl.js";import"./typeof-QjJsDpFa.js";import"./depsEqual-DIBRq7Fr.js";import"./index-JWFVT8uF.js";import"./TableSearch-j7mUrdaA.js";import"./Search-7wyvQCyz.js";import"./Clear-ClOZ_U5s.js";import"./MoreVert-DrzE5AUf.js";import"./useLocalStorage-CcnFSYKq.js";import"./url-evaluation-BHlD72Za.js";import"./permission-Br1rNOjb.js";import"./Switch-D8Y_AkUP.js";function Mt(t){return We("MuiIcon",t)}Ge("MuiIcon",["root","colorPrimary","colorSecondary","colorAction","colorError","colorDisabled","fontSizeInherit","fontSizeSmall","fontSizeMedium","fontSizeLarge"]);const Nt=t=>{const{color:s,fontSize:n,classes:o}=t,r={root:["root",s!=="inherit"&&`color${J(s)}`,`fontSize${J(n)}`]};return $e(r,Mt,o)},_t=ee("span",{name:"MuiIcon",slot:"Root",overridesResolver:(t,s)=>{const{ownerState:n}=t;return[s.root,n.color!=="inherit"&&s[`color${J(n.color)}`],s[`fontSize${J(n.fontSize)}`]]}})(Ye(({theme:t})=>({userSelect:"none",width:"1em",height:"1em",overflow:"hidden",display:"inline-block",textAlign:"center",flexShrink:0,variants:[{props:{fontSize:"inherit"},style:{fontSize:"inherit"}},{props:{fontSize:"small"},style:{fontSize:t.typography.pxToRem(20)}},{props:{fontSize:"medium"},style:{fontSize:t.typography.pxToRem(24)}},{props:{fontSize:"large"},style:{fontSize:t.typography.pxToRem(36)}},{props:{color:"action"},style:{color:(t.vars||t).palette.action.active}},{props:{color:"disabled"},style:{color:(t.vars||t).palette.action.disabled}},{props:{color:"inherit"},style:{color:void 0}},...Object.entries(t.palette).filter(He()).map(([s])=>({props:{color:s},style:{color:(t.vars||t).palette[s].main}}))]}))),ye=h.forwardRef(function(s,n){const o=Fe({props:s,name:"MuiIcon"}),{baseClassName:r="material-icons",className:a,color:i="inherit",component:c="span",fontSize:d="medium",...l}=o,p={...o,baseClassName:r,color:i,component:c,fontSize:d},f=Nt(p);return e.jsx(_t,{as:c,className:Ke(r,"notranslate",f.root,a),ownerState:p,"aria-hidden":!0,ref:n,...l})});ye.muiName="Icon";const Wt=he(e.jsx("path",{d:"M6 6v2h8.59L5 17.59 6.41 19 16 9.41V18h2V6z"})),Gt=he(e.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"})),Ft=he(e.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"}));async function Kt({blockletDid:t,nodeApi:s,spaceGateways:n}){let o=!1;const r=await Promise.all(n.map(async a=>{let{name:i}=a;const c=await Ct(a.endpoint);return!q(c)&&c!==i&&(i=c,o=!0),{...a,name:i}}));return o&&await Promise.all(r.filter(a=>a.did).map(a=>s.updateBlockletSpaceGateway({input:{did:t,where:{did:a.did},spaceGateway:{...a}}}))),r}function $t({refresh:t}={}){const{blocklet:s}=U(),n=s?.meta?.did,{api:o}=N();return qe(async()=>{if(!n)return[];const{spaceGateways:r}=await o.getBlockletSpaceGateways({input:{did:n}});return await Kt({blockletDid:n,nodeApi:o,spaceGateways:r})??[]},{refreshDeps:[n,t],onError(r){r?.message?.includes("not logged")?console.warn(r):(console.error(r),B.error(V(r)))}})}function Ie({deps:t,setLoading:s,backupDate:n}={deps:[],setLoading:()=>{},backupDate:new Date}){const{blocklet:o}=U(),[r,a]=h.useState([]),{api:i}=N(),[c,d]=h.useMemo(()=>n?[D(n).startOf("day").toISOString(),D(n).endOf("day").toISOString()]:[D().startOf("year").toISOString(),D().endOf("day").toISOString()],[n]),l=Ce(async()=>{try{if(s(!0),!o){a([]);return}const{backups:p}=await i.getBlockletBackups({input:{did:o.meta.did,startTime:c,endTime:d}});a(p??[])}catch(p){console.error(p),B.error(V(p))}finally{s(!1)}},1e3);return we(async()=>{l()},[o?.meta?.did].concat(t)),{backups:r}}function Yt({appDid:t}){const{backups:s}=Ie(),[n,o]=h.useState({message:"",progress:0,completed:!1}),r=N(),{ws:{useSubscription:a}}=r;return a(M.BlockletEvents.backupProgress,i=>{t===i?.appDid&&o(()=>({...i}))},[t]),h.useEffect(()=>{if(s?.length&&Ve(s[0]?.status)){const[i]=s;o(()=>({message:i.message,progress:i.progress,completed:i.progress>=100}))}},[s]),n}function Ht({deps:t=[],setLoading:s=()=>{}}={}){const{blocklet:n}=U(),[o,r]=h.useState([]),{api:a}=N(),i=h.useCallback(Ce(async()=>{if(!a||!n?.meta?.did){r([]);return}try{s(!0);const c=D(),d=c.subtract(1,"year"),{summary:l}=await a.getBlockletBackupSummary({input:{did:n.meta.did,startTime:d.toISOString(),endTime:c.toISOString()}});r(Array.isArray(l)?l:[])}catch(c){console.error("Failed to fetch backup summary:",c),B.error(V(c)),r([])}finally{s(!1)}},1e3),[]);return we(async()=>(await i(),()=>{i.cancel()}),[n?.meta?.did].concat(t)),{backupSummary:o}}const Te=h.createContext({}),{Provider:qt,Consumer:$s}=Te;function Re({children:t}){const{t:s}=E(),{api:n}=N(),{blocklet:o}=U(),[r,a]=h.useState(null),[i,c]=h.useState(!1),{data:d,loading:l,mutate:p}=$t({refresh:i}),f=Qe(d),x=Yt({appDid:o?.appDid}),u=h.useMemo(()=>wt(o?.environments),[o?.environments]),[k,w]=h.useState(!1),[y,b]=h.useState(!1),{backups:te}=Ie({deps:[y,r],setLoading:w,backupDate:r}),[se,oe]=h.useState(!1),{backupSummary:ne}=Ht({deps:[se]}),[_,O]=h.useState(d?.find(g=>g.endpoint===u)),I=o?.settings?.autoBackup,z=()=>{c(g=>!g)},ae=()=>{oe(g=>!g)},re=()=>{b(g=>!g)},F=async g=>{await n.updateAutoBackup({input:{did:o.meta.did,autoBackup:g}})},Q=async()=>{await n.abortBlockletBackup({input:{appPid:o.meta.did}})},ie=async(g,P)=>{try{p(R=>{const v=[...R];return v.push({...g,loading:!0}),v}),await n.addBlockletSpaceGateway({input:{did:o.meta.did,spaceGateway:g}}),u!==P&&await n.configBlocklet({input:{did:[o.meta.did],configs:[{key:M.BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_APP_BACKUP_ENDPOINT,value:P}]}}),O(g),z(),B.success(s("storage.spaces.connectedWithName",{name:g?.name??"DID Spaces"}))}catch(R){throw console.error(R),p(v=>[...v].filter(W=>W.did!==g.did)),R}},ce=async g=>{g&&(g.endpoint===u&&(await n.configBlocklet({input:{did:[o.meta.did],configs:[{key:M.BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_APP_BACKUP_ENDPOINT,value:""}]}}),I?.enabled&&await F({enabled:!1})),await n.deleteBlockletSpaceGateway({input:{did:o.meta.did,spaceGatewayDid:g?.did}}),p(P=>{const R=[...P];return R.splice(R.indexOf(g),1),R}),O(g),z())},le=async g=>{await Promise.all([n.updateBlockletSpaceGateway({input:{did:o.meta.did,where:{did:g.did},spaceGateway:g}}),u!==g.endpoint&&n.configBlocklet({input:{did:[o.meta.did],configs:[{key:M.BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_APP_BACKUP_ENDPOINT,value:g.endpoint}]}})]),B.success(s("storage.spaces.connectedWithName",{name:g?.name??"DID Spaces"})),z()},C=g=>g?.endpoint===u;return e.jsx(qt,{value:{spaceGateways:d||[],selectedSpaceGateway:_,addSpaceGateway:ie,deleteSpaceGateway:ce,updateSpaceGateway:le,refreshSpaceGateways:z,spaceGatewaysLoading:l,spaceGatewaysFirstLoading:f,spaceGatewayIsSelected:C,updateAutoBackup:F,abortBlockletBackup:Q,backupEndpoint:u,backupProgress:x,backups:te,backupSummary:ne,refreshBackupSummary:ae,refreshBackups:re,setBackupDate:a,backupsLoading:k,autoBackup:I},children:t})}Re.propTypes={children:m.any.isRequired};function L(){return h.useContext(Te)}function ze({...t}){const{blocklet:s}=U(),{info:n}=N(),{t:o}=E(),r=Ee({blocklet:s}),a=Xe(n),{spaceGateways:i,addSpaceGateway:c}=L(),d={checkFn:Be.create({baseURL:fe(window.location.origin,Ze())}).get,webWalletUrl:a,extraParams:{appPid:s.appPid,appDid:r.appDid,appName:r.appName,appDescription:r.appDescription,appUrl:r.appUrl,referrer:r.referrer,scopes:r.scopes,nodeDid:n.did}},l=async({endpoint:f,name:x,did:u})=>{const k=await Bt(f);if(!await Dt(k)){B.error(o("storage.spaces.gateway.add.invalidUrl"));return}if(i.some(b=>b.endpoint===f)){B.error(o("storage.spaces.gateway.add.duplicate",{name:x}));return}await c({name:x,did:u,url:k,endpoint:f},f)},p=async({spaceGateway:f})=>{try{await l(f)}catch(x){console.error(x),B.error(V(x))}};return e.jsx(ft,{...t,connectScope:"app",options:d,onSuccess:p})}function ve({...t}){const{t:s}=h.useContext(Je),{blocklet:n,loadingDiskInfo:o,actions:r}=U();if(h.useEffect(()=>{r?.refreshBlocklet({showError:!1,attachDiskInfo:!0})},[]),n.diskInfo){const a=(d,l,p)=>e.jsxs(j,{children:[d," ",e.jsx("strong",{children:l?et(l):"empty"})]}),i=n.environments.reduce((d,l)=>(d[l.key]=l.value,d),{}),c=[{key:"appDir",name:s("blocklet.diskInfo.appDir"),value:a(i.BLOCKLET_APP_DIR,n.diskInfo.app)},{key:"dataDir",name:s("blocklet.diskInfo.dataDir"),value:a(i.BLOCKLET_DATA_DIR,n.diskInfo.data)},{key:"logDir",name:s("blocklet.diskInfo.logDir"),value:a(i.BLOCKLET_LOG_DIR,n.diskInfo.log)},{key:"cacheDir",name:s("blocklet.diskInfo.cacheDir"),value:a(i.BLOCKLET_CACHE_DIR,n.diskInfo.cache)}];return e.jsx(Vt,{component:"div",...t,children:c.map(d=>e.jsx(Rt,{valueComponent:"div",nameWidth:120,name:d.name,children:d.value},d.key))})}return o?e.jsx(A,{}):e.jsx(j,{children:s("blocklet.diskInfo.empty")})}const Vt=tt(j)``;function Pe(){const{t}=E(),{setBackupDate:s,backupSummary:n}=L(),o=xt({key:"lg"}),r=h.useRef(null),a=st(),i=h.useCallback(l=>{s(l)},[s]),c=h.useMemo(()=>{const l=D().add(1,"day"),p=D().subtract(11,"month").startOf("month"),f=new Map(n.map(u=>[u.date,{date:u.date,successCount:u.successCount,errorCount:u.errorCount}])),x=[];for(let u=p.clone();D(u).isBefore(l);u=u.add(1,"day")){const k=u.format("YYYY-MM-DD");x.push(f.get(k)||{date:k,successCount:0,errorCount:0})}return x},[n]),d=h.useMemo(()=>({grid:{containLabel:!0,right:10,top:30,bottom:12},tooltip:{formatter:k=>{const{date:w,successCount:y,errorCount:b}=c[k.dataIndex]||{date:k.data[0],successCount:0,errorCount:0};return[`<div>${t("common.time")}: ${w}</div>`,`<div>${t("common.succeeded")}: ${y}</div>`,`<div>${t("common.failed")}: ${b}</div>`].join(`
1
+ import{bX as We,bW as Ge,r as h,bY as Fe,j as e,b8 as ee,b_ as Ke,cb as J,b$ as $e,bU as Ye,cd as He,aG as he,O as q,bn as N,cq as qe,H as B,Y as V,bf as D,fB as Ce,aQ as we,b as M,i_ as Ve,m as E,gw as Qe,o as m,x as Xe,ax as Be,y as fe,al as Ze,g as Je,C as A,T as j,i as et,s as tt,f as st,i$ as X,hU as Z,j0 as ot,N as S,aV as G,E as T,L as nt,p as H,dk as at,az as Se,U as K,aF as $,a9 as Y,a5 as rt,dH as it,gm as ct,a$ as lt,v as pe,w as dt,G as be,Z as De,by as xe,B as pt}from"./index-DKjIcWre.js";import{T as ut}from"./html-title-SrM7nvGF.js";import{u as U}from"./blocklet-Cu7NUdbv.js";import{u as mt}from"./use-mobile-BgyIeM_C.js";import{c as Ee,d as ft,e as xt,f as gt,g as ue,h as ht,b as St,u as yt,C as bt,D as kt,a as jt}from"./connect-to-0_BuJVlh.js";import"./index-DAF7Se3z.js";import"./index-BojVbZw0.js";import"./api-0rpyoHFy.js";import{d as Ct,a as wt,g as Bt,i as Dt,e as ge,f as Et,h as It,j as Tt}from"./spaces-aCe1kYiI.js";import{v as Rt}from"./index-DpFF3qPe.js";import{E as zt}from"./index-Ci-Y8hhj.js";import{H as vt}from"./HelpOutline-BQaPhaiu.js";import{H as Pt}from"./index-poSKx1_l.js";import{x as At}from"./index-DRYJ0xIl.js";import{c as Ut}from"./actions-3PI2MAhn.js";import{D as Lt}from"./DeleteOutline-B1JtcD-N.js";import{g as ke}from"./get-safe-url-CzLgUUoe.js";import{S as Ot}from"./switch-control-DOm8qAmq.js";import{L as je}from"./list-header-EJjQPfjY.js";import"./OpenInNew-xlkHjYWh.js";import"./ButtonGroup-DGPsEPvC.js";import"./getValidReactChildren-BPfGVQXT.js";import"./FilterList-DOXHRdqB.js";import"./CSSTransition-Mlf9GCd4.js";import"./emotion-cache.browser.esm-C7Q3LdH3.js";import"./index-DpomJ3B2.js";import"./redux-DfszZyTl.js";import"./typeof-QjJsDpFa.js";import"./depsEqual-CUUy9J_f.js";import"./index-C1GrPwce.js";import"./TableSearch-DznuAnMT.js";import"./Search-B2m_yoTb.js";import"./Clear-BhAooNeY.js";import"./MoreVert-4uLUnU4a.js";import"./useLocalStorage-DYsBBPSS.js";import"./url-evaluation-fJhr4k6U.js";import"./permission-Bbk6yXJh.js";import"./Switch-D7_wVs3b.js";function Mt(t){return We("MuiIcon",t)}Ge("MuiIcon",["root","colorPrimary","colorSecondary","colorAction","colorError","colorDisabled","fontSizeInherit","fontSizeSmall","fontSizeMedium","fontSizeLarge"]);const Nt=t=>{const{color:s,fontSize:n,classes:o}=t,r={root:["root",s!=="inherit"&&`color${J(s)}`,`fontSize${J(n)}`]};return $e(r,Mt,o)},_t=ee("span",{name:"MuiIcon",slot:"Root",overridesResolver:(t,s)=>{const{ownerState:n}=t;return[s.root,n.color!=="inherit"&&s[`color${J(n.color)}`],s[`fontSize${J(n.fontSize)}`]]}})(Ye(({theme:t})=>({userSelect:"none",width:"1em",height:"1em",overflow:"hidden",display:"inline-block",textAlign:"center",flexShrink:0,variants:[{props:{fontSize:"inherit"},style:{fontSize:"inherit"}},{props:{fontSize:"small"},style:{fontSize:t.typography.pxToRem(20)}},{props:{fontSize:"medium"},style:{fontSize:t.typography.pxToRem(24)}},{props:{fontSize:"large"},style:{fontSize:t.typography.pxToRem(36)}},{props:{color:"action"},style:{color:(t.vars||t).palette.action.active}},{props:{color:"disabled"},style:{color:(t.vars||t).palette.action.disabled}},{props:{color:"inherit"},style:{color:void 0}},...Object.entries(t.palette).filter(He()).map(([s])=>({props:{color:s},style:{color:(t.vars||t).palette[s].main}}))]}))),ye=h.forwardRef(function(s,n){const o=Fe({props:s,name:"MuiIcon"}),{baseClassName:r="material-icons",className:a,color:i="inherit",component:c="span",fontSize:d="medium",...l}=o,p={...o,baseClassName:r,color:i,component:c,fontSize:d},f=Nt(p);return e.jsx(_t,{as:c,className:Ke(r,"notranslate",f.root,a),ownerState:p,"aria-hidden":!0,ref:n,...l})});ye.muiName="Icon";const Wt=he(e.jsx("path",{d:"M6 6v2h8.59L5 17.59 6.41 19 16 9.41V18h2V6z"})),Gt=he(e.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"})),Ft=he(e.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"}));async function Kt({blockletDid:t,nodeApi:s,spaceGateways:n}){let o=!1;const r=await Promise.all(n.map(async a=>{let{name:i}=a;const c=await Ct(a.endpoint);return!q(c)&&c!==i&&(i=c,o=!0),{...a,name:i}}));return o&&await Promise.all(r.filter(a=>a.did).map(a=>s.updateBlockletSpaceGateway({input:{did:t,where:{did:a.did},spaceGateway:{...a}}}))),r}function $t({refresh:t}={}){const{blocklet:s}=U(),n=s?.meta?.did,{api:o}=N();return qe(async()=>{if(!n)return[];const{spaceGateways:r}=await o.getBlockletSpaceGateways({input:{did:n}});return await Kt({blockletDid:n,nodeApi:o,spaceGateways:r})??[]},{refreshDeps:[n,t],onError(r){r?.message?.includes("not logged")?console.warn(r):(console.error(r),B.error(V(r)))}})}function Ie({deps:t,setLoading:s,backupDate:n}={deps:[],setLoading:()=>{},backupDate:new Date}){const{blocklet:o}=U(),[r,a]=h.useState([]),{api:i}=N(),[c,d]=h.useMemo(()=>n?[D(n).startOf("day").toISOString(),D(n).endOf("day").toISOString()]:[D().startOf("year").toISOString(),D().endOf("day").toISOString()],[n]),l=Ce(async()=>{try{if(s(!0),!o){a([]);return}const{backups:p}=await i.getBlockletBackups({input:{did:o.meta.did,startTime:c,endTime:d}});a(p??[])}catch(p){console.error(p),B.error(V(p))}finally{s(!1)}},1e3);return we(async()=>{l()},[o?.meta?.did].concat(t)),{backups:r}}function Yt({appDid:t}){const{backups:s}=Ie(),[n,o]=h.useState({message:"",progress:0,completed:!1}),r=N(),{ws:{useSubscription:a}}=r;return a(M.BlockletEvents.backupProgress,i=>{t===i?.appDid&&o(()=>({...i}))},[t]),h.useEffect(()=>{if(s?.length&&Ve(s[0]?.status)){const[i]=s;o(()=>({message:i.message,progress:i.progress,completed:i.progress>=100}))}},[s]),n}function Ht({deps:t=[],setLoading:s=()=>{}}={}){const{blocklet:n}=U(),[o,r]=h.useState([]),{api:a}=N(),i=h.useCallback(Ce(async()=>{if(!a||!n?.meta?.did){r([]);return}try{s(!0);const c=D(),d=c.subtract(1,"year"),{summary:l}=await a.getBlockletBackupSummary({input:{did:n.meta.did,startTime:d.toISOString(),endTime:c.toISOString()}});r(Array.isArray(l)?l:[])}catch(c){console.error("Failed to fetch backup summary:",c),B.error(V(c)),r([])}finally{s(!1)}},1e3),[]);return we(async()=>(await i(),()=>{i.cancel()}),[n?.meta?.did].concat(t)),{backupSummary:o}}const Te=h.createContext({}),{Provider:qt,Consumer:$s}=Te;function Re({children:t}){const{t:s}=E(),{api:n}=N(),{blocklet:o}=U(),[r,a]=h.useState(null),[i,c]=h.useState(!1),{data:d,loading:l,mutate:p}=$t({refresh:i}),f=Qe(d),x=Yt({appDid:o?.appDid}),u=h.useMemo(()=>wt(o?.environments),[o?.environments]),[k,w]=h.useState(!1),[y,b]=h.useState(!1),{backups:te}=Ie({deps:[y,r],setLoading:w,backupDate:r}),[se,oe]=h.useState(!1),{backupSummary:ne}=Ht({deps:[se]}),[_,O]=h.useState(d?.find(g=>g.endpoint===u)),I=o?.settings?.autoBackup,z=()=>{c(g=>!g)},ae=()=>{oe(g=>!g)},re=()=>{b(g=>!g)},F=async g=>{await n.updateAutoBackup({input:{did:o.meta.did,autoBackup:g}})},Q=async()=>{await n.abortBlockletBackup({input:{appPid:o.meta.did}})},ie=async(g,P)=>{try{p(R=>{const v=[...R];return v.push({...g,loading:!0}),v}),await n.addBlockletSpaceGateway({input:{did:o.meta.did,spaceGateway:g}}),u!==P&&await n.configBlocklet({input:{did:[o.meta.did],configs:[{key:M.BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_APP_BACKUP_ENDPOINT,value:P}]}}),O(g),z(),B.success(s("storage.spaces.connectedWithName",{name:g?.name??"DID Spaces"}))}catch(R){throw console.error(R),p(v=>[...v].filter(W=>W.did!==g.did)),R}},ce=async g=>{g&&(g.endpoint===u&&(await n.configBlocklet({input:{did:[o.meta.did],configs:[{key:M.BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_APP_BACKUP_ENDPOINT,value:""}]}}),I?.enabled&&await F({enabled:!1})),await n.deleteBlockletSpaceGateway({input:{did:o.meta.did,spaceGatewayDid:g?.did}}),p(P=>{const R=[...P];return R.splice(R.indexOf(g),1),R}),O(g),z())},le=async g=>{await Promise.all([n.updateBlockletSpaceGateway({input:{did:o.meta.did,where:{did:g.did},spaceGateway:g}}),u!==g.endpoint&&n.configBlocklet({input:{did:[o.meta.did],configs:[{key:M.BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_APP_BACKUP_ENDPOINT,value:g.endpoint}]}})]),B.success(s("storage.spaces.connectedWithName",{name:g?.name??"DID Spaces"})),z()},C=g=>g?.endpoint===u;return e.jsx(qt,{value:{spaceGateways:d||[],selectedSpaceGateway:_,addSpaceGateway:ie,deleteSpaceGateway:ce,updateSpaceGateway:le,refreshSpaceGateways:z,spaceGatewaysLoading:l,spaceGatewaysFirstLoading:f,spaceGatewayIsSelected:C,updateAutoBackup:F,abortBlockletBackup:Q,backupEndpoint:u,backupProgress:x,backups:te,backupSummary:ne,refreshBackupSummary:ae,refreshBackups:re,setBackupDate:a,backupsLoading:k,autoBackup:I},children:t})}Re.propTypes={children:m.any.isRequired};function L(){return h.useContext(Te)}function ze({...t}){const{blocklet:s}=U(),{info:n}=N(),{t:o}=E(),r=Ee({blocklet:s}),a=Xe(n),{spaceGateways:i,addSpaceGateway:c}=L(),d={checkFn:Be.create({baseURL:fe(window.location.origin,Ze())}).get,webWalletUrl:a,extraParams:{appPid:s.appPid,appDid:r.appDid,appName:r.appName,appDescription:r.appDescription,appUrl:r.appUrl,referrer:r.referrer,scopes:r.scopes,nodeDid:n.did}},l=async({endpoint:f,name:x,did:u})=>{const k=await Bt(f);if(!await Dt(k)){B.error(o("storage.spaces.gateway.add.invalidUrl"));return}if(i.some(b=>b.endpoint===f)){B.error(o("storage.spaces.gateway.add.duplicate",{name:x}));return}await c({name:x,did:u,url:k,endpoint:f},f)},p=async({spaceGateway:f})=>{try{await l(f)}catch(x){console.error(x),B.error(V(x))}};return e.jsx(ft,{...t,connectScope:"app",options:d,onSuccess:p})}function ve({...t}){const{t:s}=h.useContext(Je),{blocklet:n,loadingDiskInfo:o,actions:r}=U();if(h.useEffect(()=>{r?.refreshBlocklet({showError:!1,attachDiskInfo:!0})},[]),n.diskInfo){const a=(d,l,p)=>e.jsxs(j,{children:[d," ",e.jsx("strong",{children:l?et(l):"empty"})]}),i=n.environments.reduce((d,l)=>(d[l.key]=l.value,d),{}),c=[{key:"appDir",name:s("blocklet.diskInfo.appDir"),value:a(i.BLOCKLET_APP_DIR,n.diskInfo.app)},{key:"dataDir",name:s("blocklet.diskInfo.dataDir"),value:a(i.BLOCKLET_DATA_DIR,n.diskInfo.data)},{key:"logDir",name:s("blocklet.diskInfo.logDir"),value:a(i.BLOCKLET_LOG_DIR,n.diskInfo.log)},{key:"cacheDir",name:s("blocklet.diskInfo.cacheDir"),value:a(i.BLOCKLET_CACHE_DIR,n.diskInfo.cache)}];return e.jsx(Vt,{component:"div",...t,children:c.map(d=>e.jsx(Rt,{valueComponent:"div",nameWidth:120,name:d.name,children:d.value},d.key))})}return o?e.jsx(A,{}):e.jsx(j,{children:s("blocklet.diskInfo.empty")})}const Vt=tt(j)``;function Pe(){const{t}=E(),{setBackupDate:s,backupSummary:n}=L(),o=xt({key:"lg"}),r=h.useRef(null),a=st(),i=h.useCallback(l=>{s(l)},[s]),c=h.useMemo(()=>{const l=D().add(1,"day"),p=D().subtract(11,"month").startOf("month"),f=new Map(n.map(u=>[u.date,{date:u.date,successCount:u.successCount,errorCount:u.errorCount}])),x=[];for(let u=p.clone();D(u).isBefore(l);u=u.add(1,"day")){const k=u.format("YYYY-MM-DD");x.push(f.get(k)||{date:k,successCount:0,errorCount:0})}return x},[n]),d=h.useMemo(()=>({grid:{containLabel:!0,right:10,top:30,bottom:12},tooltip:{formatter:k=>{const{date:w,successCount:y,errorCount:b}=c[k.dataIndex]||{date:k.data[0],successCount:0,errorCount:0};return[`<div>${t("common.time")}: ${w}</div>`,`<div>${t("common.succeeded")}: ${y}</div>`,`<div>${t("common.failed")}: ${b}</div>`].join(`
2
2
  `)},backgroundColor:a.palette.background.paper,borderColor:a.palette.divider,textStyle:{color:a.palette.text.primary,fontSize:14},extraCssText:`box-shadow: ${a.shadows[2]}; border-radius: 4px;`,padding:[8,10]},visualMap:{show:!1,min:-12,max:12,pieces:[{min:Number.MIN_SAFE_INTEGER,max:-9,color:X[600]},{min:-9,max:-6,color:X[500]},{min:-6,max:-3,color:X[400]},{min:-3,max:-1,color:X[300]},{min:0,max:0,color:a.palette.grey[200]},{min:1,max:3,color:Z[300]},{min:3,max:6,color:Z[400]},{min:6,max:9,color:Z[500]},{min:9,max:Number.MAX_SAFE_INTEGER,color:Z[600]}],orient:"horizontal",left:"center",bottom:12,itemWidth:12,itemHeight:12,textStyle:{color:a.palette.text.secondary,fontSize:12}},calendar:{top:30,left:50,right:10,bottom:4,cellSize:[8,8],splitLine:{show:!1},itemStyle:{borderWidth:2,borderColor:a.palette.background.default,color:a.palette.background.default},dayLabel:{show:!0,firstDay:0,nameMap:["","Mon","","Wed","","Fri",""],position:"start",margin:4,fontSize:10,color:a.palette.text.primary,fontWeight:"400",width:20},monthLabel:{show:!0,nameMap:"cn",align:"left",color:a.palette.text.primary,fontWeight:"400",fontSize:12,position:"start",margin:4,width:30,padding:[0,2]},yearLabel:{show:!1},range:[D().subtract(11,"month").startOf("month").format("YYYY-MM-DD"),D().endOf("month").format("YYYY-MM-DD")],orient:"horizontal"},series:{type:"heatmap",coordinateSystem:"calendar",data:c.map(k=>[k.date,k.errorCount?-k.errorCount:k.successCount]),label:{show:!1},itemStyle:{borderWidth:2,borderColor:a.palette.background.default,borderRadius:4},emphasis:{itemStyle:{borderWidth:2,borderColor:ot[200],color:"inherit"}}}}),[c,t,a]);return e.jsxs(e.Fragment,{children:[e.jsx(S,{ref:r,sx:{maxWidth:"1280px",border:"1px solid",borderColor:"divider",padding:"8px",overflowX:"auto"},children:e.jsx(S,{sx:{width:"1200px",height:"180px",position:"relative"},children:e.jsx(zt,{option:d,style:{height:"100%",width:"100%"},notMerge:!0,lazyUpdate:!1,opts:{renderer:"canvas"},onEvents:{click:l=>{l.componentType==="series"&&l.data&&i(l.data[0])}}})})}),e.jsx(S,{sx:{display:"flex",justifyContent:"flex-end",mt:1,mr:o?2:5,mb:2},children:e.jsxs(G,{direction:o?"column":"row",spacing:o?2:1,sx:{width:"100%",justifyContent:"flex-start",alignItems:o?"flex-start":"center"},children:[e.jsxs(G,{direction:"row",spacing:1,sx:{alignItems:"center"},children:[e.jsx(S,{sx:{width:32,height:12,borderRadius:.5,background:"linear-gradient(90deg, #8B5000 0%, #A36200 33%, #C17700 66%, #E29000 100%)"}}),e.jsx(j,{variant:"body2",sx:{color:"text.secondary"},children:t("storage.spaces.backup.failed")})]}),e.jsxs(G,{direction:"row",spacing:1,sx:{alignItems:"center"},children:[e.jsx(S,{sx:{width:32,height:12,borderRadius:.5,bgcolor:"grey.200",border:"1px solid",borderColor:"grey.200"}}),e.jsx(j,{variant:"body2",sx:{color:"text.secondary"},children:t("storage.spaces.backup.without")})]}),e.jsxs(G,{direction:"row",spacing:1,sx:{alignItems:"center"},children:[e.jsx(S,{sx:{width:32,height:12,borderRadius:.5,background:"linear-gradient(90deg, #9be9a8 0%, #40c463 33%, #30a14e 66%, #216e39 100%)"}}),e.jsx(j,{variant:"body2",sx:{color:"text.secondary"},children:t("storage.spaces.backup.succeeded")})]})]})})]})}const Qt=ee(({className:t,...s})=>e.jsx(Se,{...s,classes:{popper:t}}))(()=>({".MuiTooltip-tooltip":{backgroundColor:"transparent",padding:0,margin:0,boxShadow:"none",maxWidth:"none"},".MuiTooltip-arrow":{color:"rgba(230, 235, 245, 1)"}}));function Ae({status:t,message:s="",createdAt:n}){const{t:o}=E(),r=t===T.BACKUPS.STATUS.PROGRESS&&D().diff(n,"hours")>=T.BACKUPS.TIMEOUT_HOURS,a=r&&o("common.timeoutError"),i=t===T.BACKUPS.STATUS.PROGRESS&&!r,c=t===T.BACKUPS.STATUS.SUCCEEDED&&!r;return i?e.jsxs(j,{sx:{display:"inline-flex",alignItems:"center",fontSize:"14px"},children:[e.jsx(A,{sx:{marginRight:"4px"},size:"12px"}),o("common.progress")]}):c?e.jsx(H,{type:"success",children:o("common.succeeded")}):e.jsxs(S,{sx:{display:"inline-flex",alignItems:"center"},children:[e.jsx(H,{type:"error",children:o("common.failed")}),e.jsx(Se,{style:{display:"flex",alignItems:"center",flexShrink:0},title:s||a,children:e.jsx(ye,{children:e.jsx(vt,{style:{width:"24px",height:"24px"},color:"error"})})})]})}Ae.propTypes={status:m.string.isRequired,message:m.string,createdAt:m.string.isRequired};function Ue({metadata:t={}}){const{t:s}=E();if(q(t))return e.jsx(H,{type:"success",children:s("common.succeeded")});const n=t.count||0,o=t.size||0,r=At(o,{iec:!0}),a=e.jsxs(S,{sx:{p:1,borderRadius:1,boxShadow:2,color:"black",backgroundColor:"white"},children:[e.jsxs(j,{variant:"body2",children:[s("common.fileCount"),": ",n]}),e.jsxs(j,{variant:"body2",children:[s("common.fileSize"),": ",r]})]});return e.jsxs(S,{sx:{display:"inline-flex",alignItems:"center"},children:[e.jsx(H,{type:"success",children:s("common.succeeded")}),e.jsx(Qt,{title:a,style:{display:"flex",alignItems:"center",flexShrink:0},placement:"left",children:e.jsx(ye,{children:e.jsx(at,{style:{width:"24px",height:"24px"},color:"primary"})})})]})}Ue.propTypes={metadata:m.object};function Le(){const{t,locale:s}=E(),{spaceGateways:n,backups:o,backupsLoading:r}=L(),a=h.useMemo(()=>[{label:"DID Space",name:"target",options:{customBodyRenderLite:c=>{const{targetUrl:d,targetName:l,status:p,createdAt:f}=o[c],x=p===T.BACKUPS.STATUS.PROGRESS&&D().diff(f,"hours")>=T.BACKUPS.TIMEOUT_HOURS,u=p===T.BACKUPS.STATUS.SUCCEEDED&&!x,k=l||n.find(w=>d?.includes(ge(w?.endpoint)))?.name||"Unknown DID Space";return u?e.jsx(nt,{href:d,target:"_blank",sx:{fontSize:"16px"},children:k}):e.jsx(j,{variant:"body1",sx:{fontSize:"16px"},children:k})}}},{label:t("common.strategy"),name:"strategy",options:{customBodyRender:c=>{const d=t(c===0?"common.auto":"common.manual");return e.jsx(H,{children:d})}}},{label:t("common.startTime"),name:"createdAt",options:{customBodyRender:c=>D(c).format("YYYY-MM-DD HH:mm:ss")}},{label:t("common.endTime"),name:"updatedAt",options:{customBodyRender:c=>q(c)?"":D(c).format("YYYY-MM-DD HH:mm:ss")}},{label:t("common.status"),name:"status",options:{customBodyRenderLite:c=>{const d=o?.[c]??{},{status:l,message:p,createdAt:f,metadata:x}=d,u=l===T.BACKUPS.STATUS.PROGRESS&&D().diff(f,"hours")>=T.BACKUPS.TIMEOUT_HOURS,k=l===T.BACKUPS.STATUS.PROGRESS&&!u,w=l===T.BACKUPS.STATUS.SUCCEEDED&&!u;return k?e.jsxs(j,{sx:{display:"inline-flex",alignItems:"center",fontSize:"14px"},children:[e.jsx(A,{sx:{marginRight:"4px"},size:"12px"}),t("common.progress")]}):w?e.jsx(Ue,{metadata:x}):e.jsx(Ae,{status:l,message:p,createdAt:f})}}}],[o,n,t]),i=h.useMemo(()=>!o?.length,[o]);return e.jsx(e.Fragment,{children:i?e.jsx(S,{sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"100px",color:"#9397A1",marginTop:"16px",marginBottom:"24px"},children:t("storage.spaces.record.emptyData")}):e.jsx(Pt,{title:"",loading:r,data:o,columns:a,emptyNode:t("storage.spaces.record.emptyData",s),options:{download:!1,filter:!1,print:!1,search:!1,viewColumns:!1}})})}function Xt(){const{t}=E();return e.jsxs(S,{children:[e.jsxs(S,{sx:{display:"flex",gap:3,flexDirection:{xs:"column",md:"row"}},children:[e.jsxs(S,{sx:{display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",alignContent:"center",minWidth:240},children:[e.jsx(gt,{style:{cursor:"pointer",width:"150px",height:"100%",maxHeight:160}}),e.jsx(j,{sx:{my:2,textAlign:"center",color:"text.secondary"},children:t("storage.spaces.connect.provider")}),e.jsx(ze,{})]}),e.jsxs(S,{sx:{flexGrow:1,minWidth:0},children:[e.jsx(S,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:3},children:e.jsx(j,{sx:{fontSize:"1.2rem",fontWeight:"bold"},children:t("storage.spaces.backup.records")})}),e.jsx(Pe,{})]})]}),e.jsx(Le,{sx:{marginTop:"24px"}}),e.jsx(j,{sx:{fontSize:"1.2rem",fontWeight:"bold",mb:2,mt:2},children:t("common.dataStorage")}),e.jsx(ve,{})]})}function Oe({spaceGateway:t,onConfirm:s=()=>{},onCancel:n=()=>{}}){const{t:o}=E(),[r,a]=h.useState(!1),[i,c]=h.useState(!1),d=(f,x)=>{f?.preventDefault(),f?.stopPropagation(),a(x)},l=async f=>{try{f?.stopPropagation(),c(!0),await s?.(t),a(!1)}catch(x){console.error(x),B.error(`${o("storage.space.gateway.delete.failed")}: ${V(x)}`)}finally{a(!1),c(!1)}},p=f=>{d(f,!1),n?.(f)};return e.jsxs(e.Fragment,{children:[e.jsxs(K,{color:"red",onClick:f=>d(f,!0),children:[e.jsx($,{style:{minWidth:24,color:"red"},children:e.jsx(Lt,{fontSize:"small"})}),e.jsx(Y,{style:{color:"red"},children:o("common.disconnect")})]}),e.jsx(rt,{title:o("storage.spaces.gateway.delete.title"),open:r,confirmButton:{text:o("common.confirm"),props:{size:"small",variant:"contained",color:"error",loading:i}},cancelButton:{text:o("common.cancel"),props:{size:"small",variant:"outlined",disabled:i}},onConfirm:l,onCancel:p,children:e.jsx(j,{sx:{wordWrap:"break-word"},children:o("storage.spaces.gateway.delete.descForBackup",{name:`${t?.name}`})})})]})}Oe.propTypes={spaceGateway:m.shape({name:m.string.isRequired,url:m.string.isRequired,protected:m.bool}).isRequired,onConfirm:m.func,onCancel:m.func};function Me({spaceGateway:t,selected:s,onDelete:n=()=>{},onConnect:o=()=>{},enableSwitchToSpace:r=!0,backupInProgress:a=!1,...i}){const{abortBlockletBackup:c}=L(),[d,l]=h.useState(null),{t:p}=E(),[f,x]=h.useState(!1),u=(y,b)=>{y.stopPropagation(),y.preventDefault(),l(b&&y.currentTarget)},k=async y=>{try{x(!0),u(y,!1),await o(t)}catch(b){console.error(b),B.error(b.message)}finally{x(!1)}},w=async y=>{try{x(!0),u(y,!1),await c()}catch(b){console.error(b),B.error(b.message)}finally{x(!1)}};return e.jsxs(e.Fragment,{children:[f||t?.loading?e.jsx(A,{sx:{ml:1},size:"24px"}):e.jsx(it,{"aria-label":"more","aria-controls":"actions-menu","aria-haspopup":"true","data-cy":"trigger-blocklet-actions",variant:"outlined",size:"small",onClick:y=>u(y,!0),...i,children:e.jsx(ct,{})}),e.jsxs(lt,{id:"simple-menu",anchorEl:d,keepMounted:!0,open:!!d,onClose:y=>u(y,!1),children:[e.jsxs(K,{onClick:y=>{u(y,!1),window.open(ke(t.endpoint?Et(t.endpoint):t.url,{allowDomains:null}))},children:[e.jsx($,{style:{minWidth:24},children:e.jsx(Wt,{fontSize:"small"})}),e.jsx(Y,{children:p("common.open")})]}),e.jsxs(K,{onClick:y=>{u(y,!1),window.open(ke(It(t.endpoint),{allowDomains:null}))},children:[e.jsx($,{style:{minWidth:24},children:e.jsx(Ft,{fontSize:"small"})}),e.jsx(Y,{children:p("storage.spaces.strategy.viewBackupFiles")})]}),!s&&r&&e.jsxs(K,{onClick:k,children:[e.jsx($,{style:{minWidth:24},children:e.jsx(Gt,{fontSize:"small"})}),e.jsx(Y,{children:p("storage.spaces.connect.switchToSpace")})]}),a&&e.jsxs(K,{onClick:w,children:[e.jsx($,{style:{minWidth:24},children:e.jsx(Ut,{fontSize:"small"})}),e.jsx(Y,{children:p("storage.spaces.connect.abortBlockletBackup")})]}),!a&&e.jsx(Oe,{spaceGateway:t,onConfirm:async()=>{l(null),await n?.(t)},onCancel:()=>l(null)})]})]})}Me.propTypes={spaceGateway:m.shape({name:m.string.isRequired,url:m.string.isRequired,protected:m.bool,endpoint:m.string.isRequired,loading:m.bool}).isRequired,selected:m.bool.isRequired,enableSwitchToSpace:m.bool,onDelete:m.func,onConnect:m.func,backupInProgress:m.bool};const Zt=ee(({className:t,...s})=>e.jsx(Se,{...s,classes:{popper:t}}))(()=>({".MuiTooltip-tooltip":{backgroundColor:"transparent",padding:0,margin:0,boxShadow:"none",maxWidth:"none"},".MuiTooltip-arrow":{color:"rgba(230, 235, 245, 1)"}}));function Ne({spaceGateway:t,spaceStatus:s,selected:n,onConnected:o=()=>{},onDeleted:r=()=>{},onBackedUp:a=()=>{}}){const{t:i,locale:c}=E(),{blocklet:d}=U(),{api:l,info:{did:p}}=N(),{appDid:f,appName:x,appDescription:u,scopes:k,appUrl:w,referrer:y}=Ee({blocklet:d}),{backupProgress:b,updateSpaceGateway:te,deleteSpaceGateway:se,refreshBackupSummary:oe,refreshBackups:ne}=L(),[_,O]=h.useState(!1),[I,z]=h.useState({open:!1,action:"one-click-authorization",checkTimeout:1e3*300,messages:{title:i("storage.spaces.authorize.title",{appName:x},c),scan:i("storage.spaces.authorize.scan",{appName:x},c),confirm:"",success:e.jsx(j,{gutterBottom:!0,children:i("storage.spaces.authorize.success")})},onClose:()=>{z(C=>({...C,open:!1}))}}),ae=n&&!_&&s===ue.DISCONNECTED,re=n&&!_&&!t.loading&&s===ue.CONNECTED,F=n&&_&&s===ue.CONNECTED&&b?.progress>=0,Q=async()=>{try{if(await Tt(t?.endpoint)){await l.configBlocklet({input:{did:[d.meta.did],configs:[{key:M.BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_APP_BACKUP_ENDPOINT,value:t.endpoint}]}}),B.success(i("storage.spaces.connect.switchToSpaceSucceeded",{name:t.name?`(${t.name})`:""})),o?.(null,t);return}}catch(C){console.error(C),o?.(C,t);return}z(C=>({...C,open:!0,prefix:fe(t.url,"space/api/did"),baseUrl:new URL(t.url).origin,checkFn:Be.create({baseURL:fe(t.url,"space")}).get,extraParams:{appDid:f,appName:x,appDescription:u,scopes:k,appUrl:w,referrer:y,nodeDid:p,spaceDid:t.did}}))},ie=async(C,g)=>{const P=g(C.endpoint),R=ge(P),v=C.space?g(C.space):{};if(t.did&&R!==t.did){z(_e=>({..._e,open:!1}));const W=i("storage.spaces.gateway.switch.failedForMismatchSpace",{name:v?.name?v.name:""});B.error(W),o?.(new Error(W),t);return}const de={...t,name:v.name??"DID Space",did:v.did??ge(P),endpoint:P};await te(de),z(W=>({...W,open:!1})),o?.(null,de)},ce=async()=>{try{if(_)return;O(!0),await l.backupBlocklet({input:{appDid:d.appDid,to:"spaces"}})}catch(C){console.error(C),B.error(C.message),a?.(C,t)}finally{O(!0)}},le=async()=>{try{await se(t),B.success(i("storage.spaces.gateway.delete.succeeded",{name:t.name?`(${t.name})`:""})),r?.(null,t)}catch(C){console.error(C),r?.(C,t)}};return h.useEffect(()=>{b?.completed?(n&&(b?.progress===100?(B.success(i("storage.spaces.backupSuccessfully")),a?.(null,t)):b.message&&a?.(new Error(b?.message),t),b.progress=0,b.message=""),O(!1),setTimeout(()=>{oe(),ne()},1e3)):b.progress&&O(!0)},[b]),e.jsxs(e.Fragment,{children:[e.jsxs(S,{sx:{display:"flex",alignItems:"center",".action-btn":{borderRadius:1,marginLeft:1}},children:[re&&e.jsx(pe,{className:"action-btn",variant:"outlined",size:"small",onClick:ce,children:i("storage.spaces.strategy.backupNow")}),ae&&e.jsx(pe,{className:"action-btn",variant:"outlined",size:"small",onClick:Q,children:i("storage.spaces.disconnected.reconnectNow")}),F&&e.jsx(Zt,{title:b?.message&&e.jsx(S,{sx:{p:1,borderRadius:1,boxShadow:2,color:"black",backgroundColor:"white"},children:e.jsx(j,{variant:"body2",children:b.message})}),children:e.jsxs(pe,{className:"action-btn",variant:"outlined",size:"small",sx:{minWidth:70},children:[e.jsx(A,{variant:"determinate",value:b?.progress,size:14,sx:{mr:1}}),b?.progress,"%"]})}),e.jsx(dt,{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:c},"get-endpoint")]}),e.jsx(Me,{sx:{minWidth:32,padding:"2px 4px",ml:1},spaceGateway:t,selected:n,onDelete:le,onConnect:Q,enableSwitchToSpace:b?.completed||q(b?.message),backupInProgress:F})]})}Ne.propTypes={spaceGateway:m.shape({did:m.string.isRequired,name:m.string.isRequired,url:m.string.isRequired,endpoint:m.string.isRequired,protected:m.bool,loading:m.bool}).isRequired,spaceStatus:m.string.isRequired,selected:m.bool.isRequired,onConnected:m.func,onDeleted:m.func,onBackedUp:m.func};function Jt({...t}){const{t:s}=E();return e.jsxs(S,{...t,children:[e.jsx(S,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:3},children:e.jsx(j,{sx:{fontSize:"1.2rem",fontWeight:"bold"},children:s("storage.spaces.backup.records")})}),e.jsx(Pe,{}),e.jsx(Le,{})]})}function es({...t}){const{t:s}=E(),{autoBackup:n,updateAutoBackup:o}=L(),r=async()=>{try{const a=!n?.enabled;await o({enabled:a}),B.success(s(a?"storage.spaces.autoBackup.enabled":"storage.spaces.autoBackup.disabled"))}catch(a){B.error(a.message)}};return e.jsx(Ot,{checked:!!n?.enabled,onChange:r,name:"enableWelcomePage",labelProps:{label:e.jsx(j,{sx:{marginRight:"8px"},children:e.jsx("span",{children:s("storage.spaces.autoBackup.title")})})},style:{...t.style}})}function ts(){const{t}=E(),{spaceGateways:s,spaceGatewaysLoading:n,spaceGatewayIsSelected:o}=L(),r=n&&!s?.length,a=({spaceGateway:i,spaceStatus:c,selected:d,refresh:l})=>e.jsx(Ne,{spaceGateway:i,spaceStatus:c,selected:d,onConnected:()=>l(),onBackedUp:p=>p&&l()});return e.jsxs(S,{sx:{display:"flex",flexDirection:"column"},children:[e.jsxs(S,{sx:{display:"flex",flexDirection:{xs:"column",md:"row"},gap:{xs:1,md:2},justifyContent:{xs:"center",md:"flex-start"},alignItems:{xs:"flex-start",md:"center"}},children:[e.jsx(j,{sx:{fontSize:"1.2rem",fontWeight:"bold",flexGrow:1},children:t("storage.spaces.connected.title")}),e.jsx(es,{}),e.jsx(ze,{})]}),e.jsx(S,{sx:{mt:2},children:r?e.jsx(S,{sx:{display:"flex",justifyContent:"center"},children:e.jsx(A,{})}):e.jsx(be,{container:!0,spacing:2,children:e.jsx(e.Fragment,{children:s.map(i=>e.jsx(be,{size:{xs:12,md:6},children:e.jsx(ht,{endpoint:i.endpoint,selected:o(i),action:a},i.endpoint)},i.endpoint))})})}),e.jsx(Jt,{sx:{marginTop:"24px"}}),e.jsx(j,{sx:{fontSize:"1.2rem",fontWeight:"bold",mb:2},children:t("common.dataStorage")}),e.jsx(ve,{})]})}function ss(){const{spaceGatewaysFirstLoading:t,spaceGateways:s}=L();return t?e.jsx(De,{relative:"parent",children:e.jsx(A,{})}):q(s)?e.jsx(Xt,{}):e.jsx(ts,{})}function os(){return e.jsx(Re,{children:e.jsx(ss,{})})}function ns(){const{spaceGateway:t,settingStorageEndpoint:s,updateSpaceGateway:n,hasStorageEndpoint:o,loading:r,storageEndpoint:a}=yt(),i=xe(()=>({display:"flex",alignItems:"center",justifyContent:"center",paddingTop:"16px"}));return r?e.jsx(De,{relative:"parent",children:e.jsx(A,{})}):e.jsxs(S,{sx:{maxWidth:"md",position:"relative"},children:[o?e.jsx(bt,{spaceGateway:t,settingStorageEndpoint:s}):e.jsx(kt,{}),e.jsx(S,{sx:i,children:e.jsx(jt,{onConnect:n,storageEndpoint:a})})]})}function as(){const{t}=E();return e.jsxs(St,{children:[e.jsxs(G,{spacing:1,sx:{marginBottom:2},children:[e.jsx(j,{sx:{fontSize:"1.2rem",fontWeight:"bold"},children:t("storage.appLevel.title")}),e.jsx(j,{sx:{color:"text.secondary"},children:t("storage.appLevel.description")})]}),e.jsx(ns,{})]})}function rs({navOrientation:t="vertical",...s}){const{t:n,locale:o}=E(),{blocklet:r}=U(),a=mt({key:"md"}),[i,c]=pt(),d=i.get("tab")||"backup",l=a?"horizontal":t,p=xe(()=>{const w=[{label:n("common.backup"),value:"backup"}],y=r?.capabilities?.didSpace;return(y===M.BLOCKLET_APP_SPACE_REQUIREMENT.REQUIRED||y===M.BLOCKLET_APP_SPACE_REQUIREMENT.REQUIRED_ON_SETUP)&&w.push({label:n("common.storage"),value:"storage"}),w},[o,l]),x=xe(()=>({backup:e.jsx(os,{}),storage:e.jsx(as,{})}))[d],u=w=>{c(y=>(w==="backup"?y.delete("tab"):y.set("tab",w),y))};if(p.length<=1)return e.jsx(me,{children:x});const k=e.jsx(ut,{tabs:p,current:d,orientation:l,onChange:u,sx:[{borderRight:1,height:"100%",borderColor:"divider"},l==="horizontal"&&{borderRight:0}]});if(l==="vertical")return e.jsx(S,{...s,children:e.jsxs(G,{direction:{md:"column",lg:"row"},sx:{gap:2},children:[e.jsx(S,{sx:{flexShrink:0},children:e.jsx(je,{left:k})}),e.jsx(S,{sx:{flexGrow:1,minWidth:0},children:e.jsx(me,{sx:{mt:1},children:x})})]})});if(l==="horizontal")return e.jsxs(S,{...s,children:[e.jsx(je,{left:k}),e.jsx(me,{sx:{mt:2},children:x})]})}rs.propTypes={navOrientation:m.oneOf(["vertical","horizontal"])};const me=ee(S)`
3
3
  position: relative;
4
4
  min-height: 66vh;
@@ -1,4 +1,4 @@
1
- import{ak as ee,A as T,r as f,a as te,b as se,m as S,u as j,x as oe,aw as A,J as F,j as t,w as q,ax as re,T as R,y as k,$,o as m,ay as ne,az as ae,v as _,C as N,aA as ie,H as O,Y as W,aB as le,aC as ce,N as B,aD as ue,E as de,L as pe,aE as he,aa as fe,s as M,a7 as me,a8 as ge,aF as xe,a9 as be}from"./index-D2dk65xX.js";import{u as L}from"./useLocalStorage-CcnFSYKq.js";import{C as ke,c as ye,e as Se,_ as je,a as we,d as ve,s as Pe,S as z,b as Re,A as Ce}from"./item-B5y2JEkY.js";import{e as D}from"./engine-6r3-G42f.js";import{g as U}from"./get-safe-url-CXm2qbfD.js";import{P as V}from"./permission-Br1rNOjb.js";import{A as Le}from"./ArrowDropDown-BKRskDGW.js";import{B as Ee}from"./Breadcrumbs-BDzy2bld.js";import"./ChevronLeft-KRG-fuZi.js";import"./ChevronRight-BmsIaZOg.js";import"./Search-7wyvQCyz.js";import"./index-JWFVT8uF.js";import"./blocklet-CSWEnHbv.js";import"./Autocomplete-B8LzLUZe.js";import"./ListSubheader-CW_V4Z24.js";import"./Verified-COnwjqrJ.js";import"./VerifiedUser-DnX0aEPL.js";import"./Add-xsnJutmq.js";import"./Launch-BvjA_9TZ.js";import"./Done-BTVTKjDk.js";import"./DeleteOutline-D00EO6C8.js";import"./delete-confirm-BzjquUay.js";import"./click-to-copy-B94Iq4_S.js";import"./MoreVert-DrzE5AUf.js";import"./ButtonGroup-2OIq-PXC.js";import"./getValidReactChildren-Dx-rXSuI.js";function De(e){const n=ee(),l=T(),[s,r]=L(`sid:blocklet:purchase:${e}`),[i,c]=f.useState(!1),[u,a]=f.useState(null),d=()=>{const{pathname:o,searchParams:g}=new URL(window.location.href),x=window.env&&window.env.apiPrefix?window.env.apiPrefix:"/";g.get("sid")&&(r(""),l(o.replace(x,"/"),{replace:!0}))},p=!!(n.get("assetDid")&&s&&n.get("sid")===s);return te(se.BlockletEvents.purchaseChange,o=>{o.did===e&&(a(o.session),["declined","confirmed","error"].includes(o.session.status)&&(c(!0),setTimeout(d,2e3)))}),f.useEffect(()=>{u&&u.id!==s&&r(u.id)},[u]),{hasCompleted:i,hasPurchased:p,session:u,setSession:a,doRedirect:d}}function Be(e){setTimeout(()=>{window.location.href=U(e,{allowDomains:null})},1e3)}function H({meta:e,onCancel:n,handlePaySuccess:l=Be,storeUrl:s}){const{t:r}=S(),{info:i}=j(),[c,u]=f.useState("both"),[a,d]=f.useState(1),p=oe(i),o=A(e,i,s),g=P=>{P!==c&&u(P)},x=()=>{c&&(d(2),c==="verify"&&(window.location.href=U(o)))},w=(P,E)=>{E!=="backdropClick"&&n()},b=()=>{l(o)},h=F.getDisplayName({meta:e});if(c==="purchase"&&a===2)return t.jsx(q,{open:!0,popup:!0,baseUrl:s,action:"acquire-asset",checkFn:re.create({baseURL:k(s,"/store")}).get,onSuccess:b,onClose:n,checkTimeout:60*5e3,extraParams:{factory:e.nftFactory},webWalletUrl:p,disableClose:!0,saveConnect:!1,showDownload:!1,messages:{title:r("store.purchase.auth.title",{name:h}),scan:r("store.purchase.auth.scan"),confirm:r("store.purchase.auth.confirm"),success:t.jsxs(t.Fragment,{children:[t.jsx(R,{gutterBottom:!0,children:r("store.purchase.auth.success")}),t.jsxs(R,{variant:"subtitle2",children:[" ",r("store.purchase.autoLaunch",{name:h})]})]})}});const v=$;return t.jsx(v,{title:r("store.purchase.title",{name:h}),disableEscapeKeyDown:!0,open:!0,fullWidth:!0,onClose:w,children:t.jsx("div",{style:{marginBottom:16},children:t.jsx(ke,{action:c,onNext:x,onSelect:g})})})}H.propTypes={...ye,storeUrl:m.string.isRequired,handlePaySuccess:m.func};function K({meta:e,buttonText:n,storeUrl:l,isResource:s=!1}){const{t:r}=S(),i=T(),{info:c}=j(),{api:u}=ne(),a=F.isFreeBlocklet(e)===!1,[d,p]=f.useState(!1),{hasPurchased:o}=De(e.did),[g,x]=f.useState(!1),[w]=L("instant-blocklet-install",!1),[b,h]=f.useState(!1),v=f.useMemo(()=>d?r(a?"blocklet.status.purchasing":"blocklet.status.waiting"):"",[d,r,a]),P=f.useMemo(()=>s?r("blocklet.status.resource"):a?n.purchase:n.launch,[a,n,s]),E=y=>{y.preventDefault(),y.stopPropagation();try{if(p(!0),a){x(!0);return}if(w){h(!0);return}if(!a){const C=A(e,c,l);window.location.href=U(C)}}catch(C){O.error(W(C),{autoHideDuration:5e3}),console.error("Blocklet installed failed",C)}finally{p(!1)}},Q=()=>{p(!1),x(!1)},X=y=>{p(!1),h(!1),i(`/blocklets/${y.appDid}/components`)},Z=()=>{p(!1),h(!1)};return t.jsxs(t.Fragment,{children:[t.jsx(Se,{children:t.jsx(V,{permission:"mutate_blocklets",children:y=>t.jsx(ae,{title:s?r("launchBlocklet.error.resourceBlocklet"):"",children:t.jsx(_,{onClick:E,size:"small",sx:{cursor:s?"not-allowed":"pointer",overflow:"hidden"},disabled:!!(v||!y),variant:"outlined",color:"primary","data-cy":"install-blocklet",children:v?t.jsxs(t.Fragment,{children:[t.jsx(N,{size:16,style:{marginRight:3}}),v]}):P},e.did)})})}),(o||g)&&t.jsx(H,{method:"launch",meta:e,mode:"both",onCancel:Q,storeUrl:l}),b&&t.jsx(q,{popup:!0,open:!0,forceConnected:!1,className:"launch-from-url-auth",action:"launch-free-blocklet-by-session",checkFn:u.get,checkTimeout:5*60*1e3,onSuccess:X,extraParams:{title:e.title,blockletMetaUrl:decodeURIComponent(ie(l,e.did).trim())},messages:{title:r("setup.keyPair.title"),scan:r("setup.keyPair.scan"),confirm:r("setup.keyPair.confirm"),success:r("setup.keyPair.success")},onClose:Z})]})}K.propTypes={isResource:m.bool,meta:m.object.isRequired,buttonText:m.shape({purchase:m.string.isRequired,launch:m.string.isRequired}).isRequired,storeUrl:m.string.isRequired};const Ue=(e,n,l)=>{const s=fe(n);return k(l,`/blocklets/${e.did}/?server-url=${s}`)},I=({meta:e,attribute:n,value:l})=>e._formatted?e._formatted[n]:l,Ie=(e,n)=>{if(!e||!n)return"";try{return k(n,e)}catch(l){return console.warn("Failed to construct avatar URL:",l),""}};function G({blocklet:e,endpoint:n="",serverVersion:l=""}){const{t:s}=S(),r=j();let i=k(r.imgPrefix,"blocklet.png");const c=n;if(c.startsWith("http")&&e.logo)i=k(c,ue(e.did,e.logo,e.version));else{let g=(window.env.apiPrefix||"/").replace(/^\/+/,"").replace(/\/+$/,"");g&&(g=`/${g}`),i=k(g,`/blocklet/logo/${e.did}`)}try{const o=new URL(i);o.searchParams.set("v",e.version||+new Date),i=o.href}catch{}const u=r?.info.mode!==de.NODE_MODES.SERVERLESS,a=o=>o.currentTarget.contains(o.target)?!0:(o.preventDefault(),!1),d={meta:e,buttonText:{purchase:s("common.purchase"),launch:s("common.launch")},storeUrl:c};let p=null;return u&&(p=t.jsx("div",{style:{display:"flex",alignItems:"center"},children:t.jsx(we,{serverVersion:l,requirementVersion:e.requirements?.server,size:"small",children:t.jsx(K,{isResource:!(D.hasStartEngine(e)||D.isGatewayBlocklet(e)||D.isPackBlocklet(e)),...d})})})),t.jsx(pe,{href:Ue(e,r.info,n),style:{color:"initial",textDecoration:"none"},onClick:a,target:"_blank",children:t.jsx(Te,{title:I({meta:e,attribute:"title",value:e.title||e.name}),did:e.did,description:I({meta:e,attribute:"description",value:e.description}),cover:e.logo?i:"",version:e.version,onButtonClick:null,icons:e.docker?.image?[{key:"docker",icon:t.jsx(B,{sx:{display:"flex",color:"primary.main"},children:t.jsx(he,{icon:ve})}),title:s("blocklet.dockerImage")}]:[],official:e.isOfficial?{tooltip:s("blocklet.component.isOfficial")}:void 0,author:e.owner.fullName,avatar:Ie(e.owner.avatar,n),download:e.stats.downloads,button:p})})}G.propTypes={blocklet:m.object.isRequired,serverVersion:m.string,endpoint:m.string};function Y({storeUrl:e,handleSearchSelect:n=null,extraFilter:l=void 0,...s}){const{locale:r}=S(),i=j(),[c,u]=f.useState({}),a=o=>{u(o)},d=e,p=i?.info?.version;return f.useEffect(()=>{u({})},[d]),t.jsx(le,{FallbackComponent:ce,resetKeys:[d],children:t.jsx(B,{...s,sx:{"& .title-bar":{pt:0},".blocklet-list":{mt:0},"& h2":{display:"none"}},children:t.jsx(je,{layout:{showExplore:!1,showTitle:!0},blockletRender:o=>t.jsx(G,{...o,endpoint:d}),baseSearch:!0,endpoint:d,locale:r,onFilterChange:a,onSearchSelect:n,filters:c,extraFilter:l,serverVersion:p})})})}Y.propTypes={storeUrl:m.string.isRequired,handleSearchSelect:m.func,extraFilter:m.func};const Te=M(Pe)`
1
+ import{ak as ee,A as T,r as f,a as te,b as se,m as S,u as j,x as oe,aw as A,J as F,j as t,w as q,ax as re,T as R,y as k,$,o as m,ay as ne,az as ae,v as _,C as N,aA as ie,H as O,Y as W,aB as le,aC as ce,N as B,aD as ue,E as de,L as pe,aE as he,aa as fe,s as M,a7 as me,a8 as ge,aF as xe,a9 as be}from"./index-DKjIcWre.js";import{u as L}from"./useLocalStorage-DYsBBPSS.js";import{C as ke,c as ye,e as Se,_ as je,a as we,d as ve,s as Pe,S as z,b as Re,A as Ce}from"./item-BsKeRM2B.js";import{e as D}from"./engine-dEDx1XcI.js";import{g as U}from"./get-safe-url-CzLgUUoe.js";import{P as V}from"./permission-Bbk6yXJh.js";import{A as Le}from"./ArrowDropDown-CAKNo0Ke.js";import{B as Ee}from"./Breadcrumbs-DT_W7m-v.js";import"./ChevronLeft-BT5CPukw.js";import"./ChevronRight-BgaDG7TR.js";import"./Search-B2m_yoTb.js";import"./index-C1GrPwce.js";import"./blocklet-Cu7NUdbv.js";import"./Autocomplete-bScEq7nv.js";import"./ListSubheader-CiNw6aDZ.js";import"./Verified-B3KteJlV.js";import"./VerifiedUser-BNTtiyBh.js";import"./Add-CVnnproP.js";import"./Launch-fyJtRy6i.js";import"./Done-C9mrBMtJ.js";import"./DeleteOutline-B1JtcD-N.js";import"./delete-confirm-C0N0xOLi.js";import"./click-to-copy-CxQtWx0h.js";import"./MoreVert-4uLUnU4a.js";import"./ButtonGroup-DGPsEPvC.js";import"./getValidReactChildren-BPfGVQXT.js";function De(e){const n=ee(),l=T(),[s,r]=L(`sid:blocklet:purchase:${e}`),[i,c]=f.useState(!1),[u,a]=f.useState(null),d=()=>{const{pathname:o,searchParams:g}=new URL(window.location.href),x=window.env&&window.env.apiPrefix?window.env.apiPrefix:"/";g.get("sid")&&(r(""),l(o.replace(x,"/"),{replace:!0}))},p=!!(n.get("assetDid")&&s&&n.get("sid")===s);return te(se.BlockletEvents.purchaseChange,o=>{o.did===e&&(a(o.session),["declined","confirmed","error"].includes(o.session.status)&&(c(!0),setTimeout(d,2e3)))}),f.useEffect(()=>{u&&u.id!==s&&r(u.id)},[u]),{hasCompleted:i,hasPurchased:p,session:u,setSession:a,doRedirect:d}}function Be(e){setTimeout(()=>{window.location.href=U(e,{allowDomains:null})},1e3)}function H({meta:e,onCancel:n,handlePaySuccess:l=Be,storeUrl:s}){const{t:r}=S(),{info:i}=j(),[c,u]=f.useState("both"),[a,d]=f.useState(1),p=oe(i),o=A(e,i,s),g=P=>{P!==c&&u(P)},x=()=>{c&&(d(2),c==="verify"&&(window.location.href=U(o)))},w=(P,E)=>{E!=="backdropClick"&&n()},b=()=>{l(o)},h=F.getDisplayName({meta:e});if(c==="purchase"&&a===2)return t.jsx(q,{open:!0,popup:!0,baseUrl:s,action:"acquire-asset",checkFn:re.create({baseURL:k(s,"/store")}).get,onSuccess:b,onClose:n,checkTimeout:60*5e3,extraParams:{factory:e.nftFactory},webWalletUrl:p,disableClose:!0,saveConnect:!1,showDownload:!1,messages:{title:r("store.purchase.auth.title",{name:h}),scan:r("store.purchase.auth.scan"),confirm:r("store.purchase.auth.confirm"),success:t.jsxs(t.Fragment,{children:[t.jsx(R,{gutterBottom:!0,children:r("store.purchase.auth.success")}),t.jsxs(R,{variant:"subtitle2",children:[" ",r("store.purchase.autoLaunch",{name:h})]})]})}});const v=$;return t.jsx(v,{title:r("store.purchase.title",{name:h}),disableEscapeKeyDown:!0,open:!0,fullWidth:!0,onClose:w,children:t.jsx("div",{style:{marginBottom:16},children:t.jsx(ke,{action:c,onNext:x,onSelect:g})})})}H.propTypes={...ye,storeUrl:m.string.isRequired,handlePaySuccess:m.func};function K({meta:e,buttonText:n,storeUrl:l,isResource:s=!1}){const{t:r}=S(),i=T(),{info:c}=j(),{api:u}=ne(),a=F.isFreeBlocklet(e)===!1,[d,p]=f.useState(!1),{hasPurchased:o}=De(e.did),[g,x]=f.useState(!1),[w]=L("instant-blocklet-install",!1),[b,h]=f.useState(!1),v=f.useMemo(()=>d?r(a?"blocklet.status.purchasing":"blocklet.status.waiting"):"",[d,r,a]),P=f.useMemo(()=>s?r("blocklet.status.resource"):a?n.purchase:n.launch,[a,n,s]),E=y=>{y.preventDefault(),y.stopPropagation();try{if(p(!0),a){x(!0);return}if(w){h(!0);return}if(!a){const C=A(e,c,l);window.location.href=U(C)}}catch(C){O.error(W(C),{autoHideDuration:5e3}),console.error("Blocklet installed failed",C)}finally{p(!1)}},Q=()=>{p(!1),x(!1)},X=y=>{p(!1),h(!1),i(`/blocklets/${y.appDid}/components`)},Z=()=>{p(!1),h(!1)};return t.jsxs(t.Fragment,{children:[t.jsx(Se,{children:t.jsx(V,{permission:"mutate_blocklets",children:y=>t.jsx(ae,{title:s?r("launchBlocklet.error.resourceBlocklet"):"",children:t.jsx(_,{onClick:E,size:"small",sx:{cursor:s?"not-allowed":"pointer",overflow:"hidden"},disabled:!!(v||!y),variant:"outlined",color:"primary","data-cy":"install-blocklet",children:v?t.jsxs(t.Fragment,{children:[t.jsx(N,{size:16,style:{marginRight:3}}),v]}):P},e.did)})})}),(o||g)&&t.jsx(H,{method:"launch",meta:e,mode:"both",onCancel:Q,storeUrl:l}),b&&t.jsx(q,{popup:!0,open:!0,forceConnected:!1,className:"launch-from-url-auth",action:"launch-free-blocklet-by-session",checkFn:u.get,checkTimeout:5*60*1e3,onSuccess:X,extraParams:{title:e.title,blockletMetaUrl:decodeURIComponent(ie(l,e.did).trim())},messages:{title:r("setup.keyPair.title"),scan:r("setup.keyPair.scan"),confirm:r("setup.keyPair.confirm"),success:r("setup.keyPair.success")},onClose:Z})]})}K.propTypes={isResource:m.bool,meta:m.object.isRequired,buttonText:m.shape({purchase:m.string.isRequired,launch:m.string.isRequired}).isRequired,storeUrl:m.string.isRequired};const Ue=(e,n,l)=>{const s=fe(n);return k(l,`/blocklets/${e.did}/?server-url=${s}`)},I=({meta:e,attribute:n,value:l})=>e._formatted?e._formatted[n]:l,Ie=(e,n)=>{if(!e||!n)return"";try{return k(n,e)}catch(l){return console.warn("Failed to construct avatar URL:",l),""}};function G({blocklet:e,endpoint:n="",serverVersion:l=""}){const{t:s}=S(),r=j();let i=k(r.imgPrefix,"blocklet.png");const c=n;if(c.startsWith("http")&&e.logo)i=k(c,ue(e.did,e.logo,e.version));else{let g=(window.env.apiPrefix||"/").replace(/^\/+/,"").replace(/\/+$/,"");g&&(g=`/${g}`),i=k(g,`/blocklet/logo/${e.did}`)}try{const o=new URL(i);o.searchParams.set("v",e.version||+new Date),i=o.href}catch{}const u=r?.info.mode!==de.NODE_MODES.SERVERLESS,a=o=>o.currentTarget.contains(o.target)?!0:(o.preventDefault(),!1),d={meta:e,buttonText:{purchase:s("common.purchase"),launch:s("common.launch")},storeUrl:c};let p=null;return u&&(p=t.jsx("div",{style:{display:"flex",alignItems:"center"},children:t.jsx(we,{serverVersion:l,requirementVersion:e.requirements?.server,size:"small",children:t.jsx(K,{isResource:!(D.hasStartEngine(e)||D.isGatewayBlocklet(e)||D.isPackBlocklet(e)),...d})})})),t.jsx(pe,{href:Ue(e,r.info,n),style:{color:"initial",textDecoration:"none"},onClick:a,target:"_blank",children:t.jsx(Te,{title:I({meta:e,attribute:"title",value:e.title||e.name}),did:e.did,description:I({meta:e,attribute:"description",value:e.description}),cover:e.logo?i:"",version:e.version,onButtonClick:null,icons:e.docker?.image?[{key:"docker",icon:t.jsx(B,{sx:{display:"flex",color:"primary.main"},children:t.jsx(he,{icon:ve})}),title:s("blocklet.dockerImage")}]:[],official:e.isOfficial?{tooltip:s("blocklet.component.isOfficial")}:void 0,author:e.owner.fullName,avatar:Ie(e.owner.avatar,n),download:e.stats.downloads,button:p})})}G.propTypes={blocklet:m.object.isRequired,serverVersion:m.string,endpoint:m.string};function Y({storeUrl:e,handleSearchSelect:n=null,extraFilter:l=void 0,...s}){const{locale:r}=S(),i=j(),[c,u]=f.useState({}),a=o=>{u(o)},d=e,p=i?.info?.version;return f.useEffect(()=>{u({})},[d]),t.jsx(le,{FallbackComponent:ce,resetKeys:[d],children:t.jsx(B,{...s,sx:{"& .title-bar":{pt:0},".blocklet-list":{mt:0},"& h2":{display:"none"}},children:t.jsx(je,{layout:{showExplore:!1,showTitle:!0},blockletRender:o=>t.jsx(G,{...o,endpoint:d}),baseSearch:!0,endpoint:d,locale:r,onFilterChange:a,onSearchSelect:n,filters:c,extraFilter:l,serverVersion:p})})})}Y.propTypes={storeUrl:m.string.isRequired,handleSearchSelect:m.func,extraFilter:m.func};const Te=M(Pe)`
2
2
  .ms-highlight {
3
3
  color: ${e=>e.theme.palette.primary.main};
4
4
  }
@@ -1 +1 @@
1
- import{j as e,cB as j,N as v,A as P,r as a,g as S,ay as w,u as k,x as b,f as E,aP as K,dh as W,cr as i,b7 as _,w as N,Z as U,C as B,di as R,dj as z}from"./index-D2dk65xX.js";import{p as c}from"./index-DyWKbsNy.js";function o({children:r,...s}){return e.jsx(j,{...s,did:window?.blocklet?.appPid||window?.env?.appPid,children:e.jsx(v,{sx:{maxWidth:"100%",height:"100%"},children:r})})}function L(){const r=P(),{t:s,locale:d}=a.useContext(S),{api:l}=w(),{info:u}=k(),p=b(u),f=E(),n=K({ready:!1,success:!1,error:null,invalidSession:!1}),h=W(),m=()=>{try{const t=new URL(window.location.href);if(t.hash.includes("invalid")){n.invalidSession=!0;return}const g=t.searchParams.get("__connect_url__"),y=R(g);if(!z(y))throw new Error;n.ready=!0}catch{n.invalidSession=!0,r("#invalid",{replace:!0})}};a.useLayoutEffect(()=>m(),[]);const x=i(t=>{n.error=t.message,r("#invalid",{replace:!0})}),C=i(()=>{n.success=!0});if(n.invalidSession)return e.jsx(o,{children:e.jsx(c,{style:{backgroundColor:"transparent"},status:"error",title:s("didConnect.common.invalidSession"),description:s("didConnect.common.invalidSessionDesc")})});if(n.error){const t=n.error;return e.jsx(o,{children:e.jsx(c,{style:{backgroundColor:"transparent"},status:"error",title:s("didConnect.common.connectionError"),description:t})})}return n.success?e.jsx(o,{children:e.jsx(c,{style:{backgroundColor:"transparent"},status:"info",icon:e.jsx(_,{style:{color:f.palette.success.main,fontSize:72}}),title:s("didConnect.genKeyPair.success"),description:s("didConnect.genKeyPair.successDesc")})}):n.ready?e.jsx(o,{children:e.jsx(N,{className:"connect",action:"gen-key-pair",checkFn:l.get,checkTimeout:10*60*1e3,extraParams:{sourceAppPid:h?.appPid,forceSwitch:!0},saveConnect:!1,forceConnected:!1,webWalletUrl:p,onSuccess:C,onError:x,locale:d,messages:{title:s("didConnect.genKeyPair.title"),scan:s("didConnect.genKeyPair.scan"),confirm:s("auth.confirm"),success:s("didConnect.genKeyPair.success")},popup:!0,open:!0,hideCloseButton:!0})},"ready"):e.jsx(U,{children:e.jsx(B,{})})}export{L as default};
1
+ import{j as e,cB as j,N as v,A as P,r as a,g as S,ay as w,u as k,x as b,f as E,aP as K,dh as W,cr as i,b7 as _,w as N,Z as U,C as B,di as R,dj as z}from"./index-DKjIcWre.js";import{p as c}from"./index-PN_nwwOK.js";function o({children:r,...s}){return e.jsx(j,{...s,did:window?.blocklet?.appPid||window?.env?.appPid,children:e.jsx(v,{sx:{maxWidth:"100%",height:"100%"},children:r})})}function L(){const r=P(),{t:s,locale:d}=a.useContext(S),{api:l}=w(),{info:u}=k(),p=b(u),f=E(),n=K({ready:!1,success:!1,error:null,invalidSession:!1}),h=W(),m=()=>{try{const t=new URL(window.location.href);if(t.hash.includes("invalid")){n.invalidSession=!0;return}const g=t.searchParams.get("__connect_url__"),y=R(g);if(!z(y))throw new Error;n.ready=!0}catch{n.invalidSession=!0,r("#invalid",{replace:!0})}};a.useLayoutEffect(()=>m(),[]);const x=i(t=>{n.error=t.message,r("#invalid",{replace:!0})}),C=i(()=>{n.success=!0});if(n.invalidSession)return e.jsx(o,{children:e.jsx(c,{style:{backgroundColor:"transparent"},status:"error",title:s("didConnect.common.invalidSession"),description:s("didConnect.common.invalidSessionDesc")})});if(n.error){const t=n.error;return e.jsx(o,{children:e.jsx(c,{style:{backgroundColor:"transparent"},status:"error",title:s("didConnect.common.connectionError"),description:t})})}return n.success?e.jsx(o,{children:e.jsx(c,{style:{backgroundColor:"transparent"},status:"info",icon:e.jsx(_,{style:{color:f.palette.success.main,fontSize:72}}),title:s("didConnect.genKeyPair.success"),description:s("didConnect.genKeyPair.successDesc")})}):n.ready?e.jsx(o,{children:e.jsx(N,{className:"connect",action:"gen-key-pair",checkFn:l.get,checkTimeout:10*60*1e3,extraParams:{sourceAppPid:h?.appPid,forceSwitch:!0},saveConnect:!1,forceConnected:!1,webWalletUrl:p,onSuccess:C,onError:x,locale:d,messages:{title:s("didConnect.genKeyPair.title"),scan:s("didConnect.genKeyPair.scan"),confirm:s("auth.confirm"),success:s("didConnect.genKeyPair.success")},popup:!0,open:!0,hideCloseButton:!0})},"ready"):e.jsx(U,{children:e.jsx(B,{})})}export{L as default};
@@ -1 +1 @@
1
- import{eG as D}from"./index-D2dk65xX.js";function f(e){return e===null?"null":Array.isArray(e)?"array":typeof e}function $(e){return f(e)==="object"}function re(e){return Array.isArray(e)&&e.length>0&&e.every(m=>"message"in m)}function Y(e,m){return e.length<124?e:m}const ne="graphql-transport-ws";var g;(function(e){e[e.InternalServerError=4500]="InternalServerError",e[e.InternalClientError=4005]="InternalClientError",e[e.BadRequest=4400]="BadRequest",e[e.BadResponse=4004]="BadResponse",e[e.Unauthorized=4401]="Unauthorized",e[e.Forbidden=4403]="Forbidden",e[e.SubprotocolNotAcceptable=4406]="SubprotocolNotAcceptable",e[e.ConnectionInitialisationTimeout=4408]="ConnectionInitialisationTimeout",e[e.ConnectionAcknowledgementTimeout=4504]="ConnectionAcknowledgementTimeout",e[e.SubscriberAlreadyExists=4409]="SubscriberAlreadyExists",e[e.TooManyInitialisationRequests=4429]="TooManyInitialisationRequests"})(g||(g={}));var c;(function(e){e.ConnectionInit="connection_init",e.ConnectionAck="connection_ack",e.Ping="ping",e.Pong="pong",e.Subscribe="subscribe",e.Next="next",e.Error="error",e.Complete="complete"})(c||(c={}));function v(e){if(!$(e))throw new Error(`Message is expected to be an object, but got ${f(e)}`);if(!e.type)throw new Error("Message is missing the 'type' property");if(typeof e.type!="string")throw new Error(`Message is expects the 'type' property to be a string, but got ${f(e.type)}`);switch(e.type){case c.ConnectionInit:case c.ConnectionAck:case c.Ping:case c.Pong:{if(e.payload!=null&&!$(e.payload))throw new Error(`"${e.type}" message expects the 'payload' property to be an object or nullish or missing, but got "${e.payload}"`);break}case c.Subscribe:{if(typeof e.id!="string")throw new Error(`"${e.type}" message expects the 'id' property to be a string, but got ${f(e.id)}`);if(!e.id)throw new Error(`"${e.type}" message requires a non-empty 'id' property`);if(!$(e.payload))throw new Error(`"${e.type}" message expects the 'payload' property to be an object, but got ${f(e.payload)}`);if(typeof e.payload.query!="string")throw new Error(`"${e.type}" message payload expects the 'query' property to be a string, but got ${f(e.payload.query)}`);if(e.payload.variables!=null&&!$(e.payload.variables))throw new Error(`"${e.type}" message payload expects the 'variables' property to be a an object or nullish or missing, but got ${f(e.payload.variables)}`);if(e.payload.operationName!=null&&f(e.payload.operationName)!=="string")throw new Error(`"${e.type}" message payload expects the 'operationName' property to be a string or nullish or missing, but got ${f(e.payload.operationName)}`);if(e.payload.extensions!=null&&!$(e.payload.extensions))throw new Error(`"${e.type}" message payload expects the 'extensions' property to be a an object or nullish or missing, but got ${f(e.payload.extensions)}`);break}case c.Next:{if(typeof e.id!="string")throw new Error(`"${e.type}" message expects the 'id' property to be a string, but got ${f(e.id)}`);if(!e.id)throw new Error(`"${e.type}" message requires a non-empty 'id' property`);if(!$(e.payload))throw new Error(`"${e.type}" message expects the 'payload' property to be an object, but got ${f(e.payload)}`);break}case c.Error:{if(typeof e.id!="string")throw new Error(`"${e.type}" message expects the 'id' property to be a string, but got ${f(e.id)}`);if(!e.id)throw new Error(`"${e.type}" message requires a non-empty 'id' property`);if(!re(e.payload))throw new Error(`"${e.type}" message expects the 'payload' property to be an array of GraphQL errors, but got ${JSON.stringify(e.payload)}`);break}case c.Complete:{if(typeof e.id!="string")throw new Error(`"${e.type}" message expects the 'id' property to be a string, but got ${f(e.id)}`);if(!e.id)throw new Error(`"${e.type}" message requires a non-empty 'id' property`);break}default:throw new Error(`Invalid message 'type' property "${e.type}"`)}return e}function oe(e,m){return v(typeof e=="string"?JSON.parse(e,m):e)}function W(e,m){return v(e),JSON.stringify(e,m)}var A=function(e){return this instanceof A?(this.v=e,this):new A(e)},ie=function(e,m,R){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var M=R.apply(e,m||[]),b,w=[];return b={},E("next"),E("throw"),E("return"),b[Symbol.asyncIterator]=function(){return this},b;function E(u){M[u]&&(b[u]=function(r){return new Promise(function(S,L){w.push([u,r,S,L])>1||I(u,r)})})}function I(u,r){try{q(M[u](r))}catch(S){G(w[0][3],S)}}function q(u){u.value instanceof A?Promise.resolve(u.value.v).then(z,F):G(w[0][2],u)}function z(u){I("next",u)}function F(u){I("throw",u)}function G(u,r){u(r),w.shift(),w.length&&I(w[0][0],w[0][1])}};function pe(e){const{url:m,connectionParams:R,lazy:M=!0,onNonLazyError:b=console.error,lazyCloseTimeout:w=0,keepAlive:E=0,disablePong:I,connectionAckWaitTimeout:q=0,retryAttempts:z=5,retryWait:F=async function(a){let t=1e3;for(let o=0;o<a;o++)t*=2;await new Promise(o=>setTimeout(o,t+Math.floor(Math.random()*2700+300)))},shouldRetry:G=J,isFatalConnectionProblem:u,on:r,webSocketImpl:S,generateID:L=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,a=>{const t=Math.random()*16|0;return(a=="x"?t:t&3|8).toString(16)})},jsonMessageReplacer:U,jsonMessageReviver:ee}=e;let T;if(S){if(!ae(S))throw new Error("Invalid WebSocket implementation provided");T=S}else typeof WebSocket<"u"?T=WebSocket:typeof D<"u"?T=D.WebSocket||D.MozWebSocket:typeof window<"u"&&(T=window.WebSocket||window.MozWebSocket);if(!T)throw new Error("WebSocket implementation missing; on Node you can `import WebSocket from 'ws';` and pass `webSocketImpl: WebSocket` to `createClient`");const N=T,d=(()=>{const n=(()=>{const t={};return{on(o,s){return t[o]=s,()=>{delete t[o]}},emit(o){var s;"id"in o&&((s=t[o.id])===null||s===void 0||s.call(t,o))}}})(),a={connecting:r?.connecting?[r.connecting]:[],opened:r?.opened?[r.opened]:[],connected:r?.connected?[r.connected]:[],ping:r?.ping?[r.ping]:[],pong:r?.pong?[r.pong]:[],message:r?.message?[n.emit,r.message]:[n.emit],closed:r?.closed?[r.closed]:[],error:r?.error?[r.error]:[]};return{onMessage:n.on,on(t,o){const s=a[t];return s.push(o),()=>{s.splice(s.indexOf(o),1)}},emit(t,...o){for(const s of[...a[t]])s(...o)}}})();function Q(n){const a=[d.on("error",t=>{a.forEach(o=>o()),n(t)}),d.on("closed",t=>{a.forEach(o=>o()),n(t)})]}let h,k=0,H,O=!1,j=0,C=!1;async function K(){clearTimeout(H);const[n,a]=await(h??(h=new Promise((s,y)=>(async()=>{if(O){if(await F(j),!k)return h=void 0,y({code:1e3,reason:"All Subscriptions Gone"});j++}d.emit("connecting",O);const i=new N(typeof m=="function"?await m():m,ne);let x,_;function B(){isFinite(E)&&E>0&&(clearTimeout(_),_=setTimeout(()=>{i.readyState===N.OPEN&&(i.send(W({type:c.Ping})),d.emit("ping",!1,void 0))},E))}Q(l=>{h=void 0,clearTimeout(x),clearTimeout(_),y(l),l instanceof Z&&(i.close(4499,"Terminated"),i.onerror=null,i.onclose=null)}),i.onerror=l=>d.emit("error",l),i.onclose=l=>d.emit("closed",l),i.onopen=async()=>{try{d.emit("opened",i);const l=typeof R=="function"?await R():R;if(i.readyState!==N.OPEN)return;i.send(W(l?{type:c.ConnectionInit,payload:l}:{type:c.ConnectionInit},U)),isFinite(q)&&q>0&&(x=setTimeout(()=>{i.close(g.ConnectionAcknowledgementTimeout,"Connection acknowledgement timeout")},q)),B()}catch(l){d.emit("error",l),i.close(g.InternalClientError,Y(l instanceof Error?l.message:new Error(l).message,"Internal client error"))}};let P=!1;i.onmessage=({data:l})=>{try{const p=oe(l,ee);if(d.emit("message",p),p.type==="ping"||p.type==="pong"){d.emit(p.type,!0,p.payload),p.type==="pong"?B():I||(i.send(W(p.payload?{type:c.Pong,payload:p.payload}:{type:c.Pong})),d.emit("pong",!1,p.payload));return}if(P)return;if(p.type!==c.ConnectionAck)throw new Error(`First message cannot be of type ${p.type}`);clearTimeout(x),P=!0,d.emit("connected",i,p.payload,O),O=!1,j=0,s([i,new Promise((ce,te)=>Q(te))])}catch(p){i.onmessage=null,d.emit("error",p),i.close(g.BadResponse,Y(p instanceof Error?p.message:new Error(p).message,"Bad response"))}}})())));n.readyState===N.CLOSING&&await a;let t=()=>{};const o=new Promise(s=>t=s);return[n,t,Promise.race([o.then(()=>{if(!k){const s=()=>n.close(1e3,"Normal Closure");isFinite(w)&&w>0?H=setTimeout(()=>{n.readyState===N.OPEN&&s()},w):s()}}),a])]}function V(n){if(J(n)&&(se(n.code)||[g.InternalServerError,g.InternalClientError,g.BadRequest,g.BadResponse,g.Unauthorized,g.SubprotocolNotAcceptable,g.SubscriberAlreadyExists,g.TooManyInitialisationRequests].includes(n.code)))throw n;if(C)return!1;if(J(n)&&n.code===1e3)return k>0;if(!z||j>=z||!G(n)||u?.(n))throw n;return O=!0}M||(async()=>{for(k++;;)try{const[,,n]=await K();await n}catch(n){try{if(!V(n))return}catch(a){return b?.(a)}}})();function X(n,a){const t=L(n);let o=!1,s=!1,y=()=>{k--,o=!0};return(async()=>{for(k++;;)try{const[i,x,_]=await K();if(o)return x();const B=d.onMessage(t,P=>{switch(P.type){case c.Next:{a.next(P.payload);return}case c.Error:{s=!0,o=!0,a.error(P.payload),y();return}case c.Complete:{o=!0,y();return}}});i.send(W({id:t,type:c.Subscribe,payload:n},U)),y=()=>{!o&&i.readyState===N.OPEN&&i.send(W({id:t,type:c.Complete},U)),k--,o=!0,x()},await _.finally(B);return}catch(i){if(!V(i))return}})().then(()=>{s||a.complete()}).catch(i=>{a.error(i)}),()=>{o||y()}}return{on:d.on,subscribe:X,iterate(n){const a=[],t={done:!1,error:null,resolve:()=>{}},o=X(n,{next(y){a.push(y),t.resolve()},error(y){t.done=!0,t.error=y,t.resolve()},complete(){t.done=!0,t.resolve()}}),s=function(){return ie(this,arguments,function*(){for(;;){for(a.length||(yield A(new Promise(x=>t.resolve=x)));a.length;)yield yield A(a.shift());if(t.error)throw t.error;if(t.done)return yield A(void 0)}})}();return s.throw=async y=>(t.done||(t.done=!0,t.error=y,t.resolve()),{done:!0,value:void 0}),s.return=async()=>(o(),{done:!0,value:void 0}),s},async dispose(){if(C=!0,h){const[n]=await h;n.close(1e3,"Normal Closure")}},terminate(){h&&d.emit("closed",new Z)}}}class Z extends Error{constructor(){super(...arguments),this.name="TerminatedCloseEvent",this.message="4499: Terminated",this.code=4499,this.reason="Terminated",this.wasClean=!1}}function J(e){return $(e)&&"code"in e&&"reason"in e}function se(e){return[1e3,1001,1006,1005,1012,1013,1014].includes(e)?!1:e>=1e3&&e<=1999}function ae(e){return typeof e=="function"&&"constructor"in e&&"CLOSED"in e&&"CLOSING"in e&&"CONNECTING"in e&&"OPEN"in e}export{g as CloseCode,ne as GRAPHQL_TRANSPORT_WS_PROTOCOL,c as MessageType,Z as TerminatedCloseEvent,pe as createClient,oe as parseMessage,W as stringifyMessage,v as validateMessage};
1
+ import{eG as D}from"./index-DKjIcWre.js";function f(e){return e===null?"null":Array.isArray(e)?"array":typeof e}function $(e){return f(e)==="object"}function re(e){return Array.isArray(e)&&e.length>0&&e.every(m=>"message"in m)}function Y(e,m){return e.length<124?e:m}const ne="graphql-transport-ws";var g;(function(e){e[e.InternalServerError=4500]="InternalServerError",e[e.InternalClientError=4005]="InternalClientError",e[e.BadRequest=4400]="BadRequest",e[e.BadResponse=4004]="BadResponse",e[e.Unauthorized=4401]="Unauthorized",e[e.Forbidden=4403]="Forbidden",e[e.SubprotocolNotAcceptable=4406]="SubprotocolNotAcceptable",e[e.ConnectionInitialisationTimeout=4408]="ConnectionInitialisationTimeout",e[e.ConnectionAcknowledgementTimeout=4504]="ConnectionAcknowledgementTimeout",e[e.SubscriberAlreadyExists=4409]="SubscriberAlreadyExists",e[e.TooManyInitialisationRequests=4429]="TooManyInitialisationRequests"})(g||(g={}));var c;(function(e){e.ConnectionInit="connection_init",e.ConnectionAck="connection_ack",e.Ping="ping",e.Pong="pong",e.Subscribe="subscribe",e.Next="next",e.Error="error",e.Complete="complete"})(c||(c={}));function v(e){if(!$(e))throw new Error(`Message is expected to be an object, but got ${f(e)}`);if(!e.type)throw new Error("Message is missing the 'type' property");if(typeof e.type!="string")throw new Error(`Message is expects the 'type' property to be a string, but got ${f(e.type)}`);switch(e.type){case c.ConnectionInit:case c.ConnectionAck:case c.Ping:case c.Pong:{if(e.payload!=null&&!$(e.payload))throw new Error(`"${e.type}" message expects the 'payload' property to be an object or nullish or missing, but got "${e.payload}"`);break}case c.Subscribe:{if(typeof e.id!="string")throw new Error(`"${e.type}" message expects the 'id' property to be a string, but got ${f(e.id)}`);if(!e.id)throw new Error(`"${e.type}" message requires a non-empty 'id' property`);if(!$(e.payload))throw new Error(`"${e.type}" message expects the 'payload' property to be an object, but got ${f(e.payload)}`);if(typeof e.payload.query!="string")throw new Error(`"${e.type}" message payload expects the 'query' property to be a string, but got ${f(e.payload.query)}`);if(e.payload.variables!=null&&!$(e.payload.variables))throw new Error(`"${e.type}" message payload expects the 'variables' property to be a an object or nullish or missing, but got ${f(e.payload.variables)}`);if(e.payload.operationName!=null&&f(e.payload.operationName)!=="string")throw new Error(`"${e.type}" message payload expects the 'operationName' property to be a string or nullish or missing, but got ${f(e.payload.operationName)}`);if(e.payload.extensions!=null&&!$(e.payload.extensions))throw new Error(`"${e.type}" message payload expects the 'extensions' property to be a an object or nullish or missing, but got ${f(e.payload.extensions)}`);break}case c.Next:{if(typeof e.id!="string")throw new Error(`"${e.type}" message expects the 'id' property to be a string, but got ${f(e.id)}`);if(!e.id)throw new Error(`"${e.type}" message requires a non-empty 'id' property`);if(!$(e.payload))throw new Error(`"${e.type}" message expects the 'payload' property to be an object, but got ${f(e.payload)}`);break}case c.Error:{if(typeof e.id!="string")throw new Error(`"${e.type}" message expects the 'id' property to be a string, but got ${f(e.id)}`);if(!e.id)throw new Error(`"${e.type}" message requires a non-empty 'id' property`);if(!re(e.payload))throw new Error(`"${e.type}" message expects the 'payload' property to be an array of GraphQL errors, but got ${JSON.stringify(e.payload)}`);break}case c.Complete:{if(typeof e.id!="string")throw new Error(`"${e.type}" message expects the 'id' property to be a string, but got ${f(e.id)}`);if(!e.id)throw new Error(`"${e.type}" message requires a non-empty 'id' property`);break}default:throw new Error(`Invalid message 'type' property "${e.type}"`)}return e}function oe(e,m){return v(typeof e=="string"?JSON.parse(e,m):e)}function W(e,m){return v(e),JSON.stringify(e,m)}var A=function(e){return this instanceof A?(this.v=e,this):new A(e)},ie=function(e,m,R){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var M=R.apply(e,m||[]),b,w=[];return b={},E("next"),E("throw"),E("return"),b[Symbol.asyncIterator]=function(){return this},b;function E(u){M[u]&&(b[u]=function(r){return new Promise(function(S,L){w.push([u,r,S,L])>1||I(u,r)})})}function I(u,r){try{q(M[u](r))}catch(S){G(w[0][3],S)}}function q(u){u.value instanceof A?Promise.resolve(u.value.v).then(z,F):G(w[0][2],u)}function z(u){I("next",u)}function F(u){I("throw",u)}function G(u,r){u(r),w.shift(),w.length&&I(w[0][0],w[0][1])}};function pe(e){const{url:m,connectionParams:R,lazy:M=!0,onNonLazyError:b=console.error,lazyCloseTimeout:w=0,keepAlive:E=0,disablePong:I,connectionAckWaitTimeout:q=0,retryAttempts:z=5,retryWait:F=async function(a){let t=1e3;for(let o=0;o<a;o++)t*=2;await new Promise(o=>setTimeout(o,t+Math.floor(Math.random()*2700+300)))},shouldRetry:G=J,isFatalConnectionProblem:u,on:r,webSocketImpl:S,generateID:L=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,a=>{const t=Math.random()*16|0;return(a=="x"?t:t&3|8).toString(16)})},jsonMessageReplacer:U,jsonMessageReviver:ee}=e;let T;if(S){if(!ae(S))throw new Error("Invalid WebSocket implementation provided");T=S}else typeof WebSocket<"u"?T=WebSocket:typeof D<"u"?T=D.WebSocket||D.MozWebSocket:typeof window<"u"&&(T=window.WebSocket||window.MozWebSocket);if(!T)throw new Error("WebSocket implementation missing; on Node you can `import WebSocket from 'ws';` and pass `webSocketImpl: WebSocket` to `createClient`");const N=T,d=(()=>{const n=(()=>{const t={};return{on(o,s){return t[o]=s,()=>{delete t[o]}},emit(o){var s;"id"in o&&((s=t[o.id])===null||s===void 0||s.call(t,o))}}})(),a={connecting:r?.connecting?[r.connecting]:[],opened:r?.opened?[r.opened]:[],connected:r?.connected?[r.connected]:[],ping:r?.ping?[r.ping]:[],pong:r?.pong?[r.pong]:[],message:r?.message?[n.emit,r.message]:[n.emit],closed:r?.closed?[r.closed]:[],error:r?.error?[r.error]:[]};return{onMessage:n.on,on(t,o){const s=a[t];return s.push(o),()=>{s.splice(s.indexOf(o),1)}},emit(t,...o){for(const s of[...a[t]])s(...o)}}})();function Q(n){const a=[d.on("error",t=>{a.forEach(o=>o()),n(t)}),d.on("closed",t=>{a.forEach(o=>o()),n(t)})]}let h,k=0,H,O=!1,j=0,C=!1;async function K(){clearTimeout(H);const[n,a]=await(h??(h=new Promise((s,y)=>(async()=>{if(O){if(await F(j),!k)return h=void 0,y({code:1e3,reason:"All Subscriptions Gone"});j++}d.emit("connecting",O);const i=new N(typeof m=="function"?await m():m,ne);let x,_;function B(){isFinite(E)&&E>0&&(clearTimeout(_),_=setTimeout(()=>{i.readyState===N.OPEN&&(i.send(W({type:c.Ping})),d.emit("ping",!1,void 0))},E))}Q(l=>{h=void 0,clearTimeout(x),clearTimeout(_),y(l),l instanceof Z&&(i.close(4499,"Terminated"),i.onerror=null,i.onclose=null)}),i.onerror=l=>d.emit("error",l),i.onclose=l=>d.emit("closed",l),i.onopen=async()=>{try{d.emit("opened",i);const l=typeof R=="function"?await R():R;if(i.readyState!==N.OPEN)return;i.send(W(l?{type:c.ConnectionInit,payload:l}:{type:c.ConnectionInit},U)),isFinite(q)&&q>0&&(x=setTimeout(()=>{i.close(g.ConnectionAcknowledgementTimeout,"Connection acknowledgement timeout")},q)),B()}catch(l){d.emit("error",l),i.close(g.InternalClientError,Y(l instanceof Error?l.message:new Error(l).message,"Internal client error"))}};let P=!1;i.onmessage=({data:l})=>{try{const p=oe(l,ee);if(d.emit("message",p),p.type==="ping"||p.type==="pong"){d.emit(p.type,!0,p.payload),p.type==="pong"?B():I||(i.send(W(p.payload?{type:c.Pong,payload:p.payload}:{type:c.Pong})),d.emit("pong",!1,p.payload));return}if(P)return;if(p.type!==c.ConnectionAck)throw new Error(`First message cannot be of type ${p.type}`);clearTimeout(x),P=!0,d.emit("connected",i,p.payload,O),O=!1,j=0,s([i,new Promise((ce,te)=>Q(te))])}catch(p){i.onmessage=null,d.emit("error",p),i.close(g.BadResponse,Y(p instanceof Error?p.message:new Error(p).message,"Bad response"))}}})())));n.readyState===N.CLOSING&&await a;let t=()=>{};const o=new Promise(s=>t=s);return[n,t,Promise.race([o.then(()=>{if(!k){const s=()=>n.close(1e3,"Normal Closure");isFinite(w)&&w>0?H=setTimeout(()=>{n.readyState===N.OPEN&&s()},w):s()}}),a])]}function V(n){if(J(n)&&(se(n.code)||[g.InternalServerError,g.InternalClientError,g.BadRequest,g.BadResponse,g.Unauthorized,g.SubprotocolNotAcceptable,g.SubscriberAlreadyExists,g.TooManyInitialisationRequests].includes(n.code)))throw n;if(C)return!1;if(J(n)&&n.code===1e3)return k>0;if(!z||j>=z||!G(n)||u?.(n))throw n;return O=!0}M||(async()=>{for(k++;;)try{const[,,n]=await K();await n}catch(n){try{if(!V(n))return}catch(a){return b?.(a)}}})();function X(n,a){const t=L(n);let o=!1,s=!1,y=()=>{k--,o=!0};return(async()=>{for(k++;;)try{const[i,x,_]=await K();if(o)return x();const B=d.onMessage(t,P=>{switch(P.type){case c.Next:{a.next(P.payload);return}case c.Error:{s=!0,o=!0,a.error(P.payload),y();return}case c.Complete:{o=!0,y();return}}});i.send(W({id:t,type:c.Subscribe,payload:n},U)),y=()=>{!o&&i.readyState===N.OPEN&&i.send(W({id:t,type:c.Complete},U)),k--,o=!0,x()},await _.finally(B);return}catch(i){if(!V(i))return}})().then(()=>{s||a.complete()}).catch(i=>{a.error(i)}),()=>{o||y()}}return{on:d.on,subscribe:X,iterate(n){const a=[],t={done:!1,error:null,resolve:()=>{}},o=X(n,{next(y){a.push(y),t.resolve()},error(y){t.done=!0,t.error=y,t.resolve()},complete(){t.done=!0,t.resolve()}}),s=function(){return ie(this,arguments,function*(){for(;;){for(a.length||(yield A(new Promise(x=>t.resolve=x)));a.length;)yield yield A(a.shift());if(t.error)throw t.error;if(t.done)return yield A(void 0)}})}();return s.throw=async y=>(t.done||(t.done=!0,t.error=y,t.resolve()),{done:!0,value:void 0}),s.return=async()=>(o(),{done:!0,value:void 0}),s},async dispose(){if(C=!0,h){const[n]=await h;n.close(1e3,"Normal Closure")}},terminate(){h&&d.emit("closed",new Z)}}}class Z extends Error{constructor(){super(...arguments),this.name="TerminatedCloseEvent",this.message="4499: Terminated",this.code=4499,this.reason="Terminated",this.wasClean=!1}}function J(e){return $(e)&&"code"in e&&"reason"in e}function se(e){return[1e3,1001,1006,1005,1012,1013,1014].includes(e)?!1:e>=1e3&&e<=1999}function ae(e){return typeof e=="function"&&"constructor"in e&&"CLOSED"in e&&"CLOSING"in e&&"CONNECTING"in e&&"OPEN"in e}export{g as CloseCode,ne as GRAPHQL_TRANSPORT_WS_PROTOCOL,c as MessageType,Z as TerminatedCloseEvent,pe as createClient,oe as parseMessage,W as stringifyMessage,v as validateMessage};
@@ -0,0 +1 @@
1
+ import{c0 as c,r as _,cr as f,g_ as S,cR as r}from"./index-DKjIcWre.js";var m=function(n){var a=c(_.useState(n),2),u=a[0],o=a[1],i=f(function(t){o(function(e){var s=S(t)?t(e):t;return s?r(r({},e),s):e})});return[u,i]};export{m as u};