@abtnode/blocklet-services 1.16.49-beta-20250821-102221-1b7283d6 → 1.16.49-beta-20250822-070545-6d3344cc

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 (139) hide show
  1. package/api/routes/env.js +0 -1
  2. package/dist/assets/{access-control-CKo7ApzQ.js → access-control-VF0jIUag.js} +1 -1
  3. package/dist/assets/{add-component-core-2s4YrHkE.js → add-component-core-DPxKUwJB.js} +1 -1
  4. package/dist/assets/{add-resource-B5ESeEdz.js → add-resource-DuOqQFR-.js} +1 -1
  5. package/dist/assets/{addon-Cbd_t8fg.js → addon-CosTdlat.js} +1 -1
  6. package/dist/assets/{advanced-Bgj7amLL.js → advanced-B9TR0x_M.js} +1 -1
  7. package/dist/assets/{aigne-D5HIKgzm.js → aigne-C7JPp9u1.js} +1 -1
  8. package/dist/assets/{appearance-_Bk4EnMK.js → appearance-Byekpih2.js} +1 -1
  9. package/dist/assets/{ar-BvKie2ZN.js → ar-fE5SSTrt.js} +1 -1
  10. package/dist/assets/{arrow-down.svg-DaFWY5aq.js → arrow-down.svg-lBR1lfm2.js} +1 -1
  11. package/dist/assets/{audit-logs-Bh4pY_tu.js → audit-logs-BTyQcfWp.js} +1 -1
  12. package/dist/assets/{authorize--3SKB1wC.js → authorize-BbCQomqp.js} +1 -1
  13. package/dist/assets/{base32-BkgeFkJa.js → base32-D7JDMggs.js} +1 -1
  14. package/dist/assets/{bind-account-CoQBu2J9.js → bind-account-B-fdpRuH.js} +1 -1
  15. package/dist/assets/{branding-Spk8WElf.js → branding-Bp4tsvug.js} +1 -1
  16. package/dist/assets/{branding-7dpJRuU0.js → branding-CXO5C9Lb.js} +1 -1
  17. package/dist/assets/{branding-CuAzEVpH.js → branding-DKOBu_eV.js} +2 -2
  18. package/dist/assets/{bundle-avatar-CopjjSKq.js → bundle-avatar-FLzOZWlh.js} +1 -1
  19. package/dist/assets/{complete-BJT8H_Qd.js → complete-CnjLDP7N.js} +1 -1
  20. package/dist/assets/{component-Ds8koLEG.js → component-Dogt0tzj.js} +3 -3
  21. package/dist/assets/{config-DE3v72_z.js → config-B5Y8LOpp.js} +1 -1
  22. package/dist/assets/{config-CPOsDUsI.js → config-BxiVjVAu.js} +1 -1
  23. package/dist/assets/{config-_-5NHvON.js → config-gL555Qh4.js} +1 -1
  24. package/dist/assets/{config-navigation-C-4ZP-lf.js → config-navigation-CveewaP3.js} +3 -3
  25. package/dist/assets/{config-space-CtK2sF5f.js → config-space-h6V3UKMc.js} +1 -1
  26. package/dist/assets/{confirm-Bax75YdO.js → confirm-C9tgdTJT.js} +1 -1
  27. package/dist/assets/{connect-DY6itK40.js → connect-CYT-S8fi.js} +1 -1
  28. package/dist/assets/{connect-Csks8pFO.js → connect-Cx2VNYgu.js} +1 -1
  29. package/dist/assets/{connect-to-DBq3ktB8.js → connect-to-DiEQlFbF.js} +1 -1
  30. package/dist/assets/{dashboard-CbwKTvVC.js → dashboard-D1d9MQbs.js} +3 -3
  31. package/dist/assets/{de-C9BQPFcm.js → de-Byq6SyWJ.js} +1 -1
  32. package/dist/assets/{delete-confirm-Db0zAWAY.js → delete-confirm-XVeEePxy.js} +1 -1
  33. package/dist/assets/{domain-CHD8k2pC.js → domain-CV6OAKYE.js} +1 -1
  34. package/dist/assets/{domain-action-card-DtOm7RPt.js → domain-action-card-BXYZu_pS.js} +1 -1
  35. package/dist/assets/{domains-CePn01LF.js → domains-DrF1lJas.js} +1 -1
  36. package/dist/assets/{email-B1F9_dDw.js → email-CniDyVLQ.js} +1 -1
  37. package/dist/assets/engine-hsJUTQxh.js +1 -0
  38. package/dist/assets/{es-DPjcV6cX.js → es-Q8J1CCMS.js} +1 -1
  39. package/dist/assets/{exchange-passport-B90C9g4T.js → exchange-passport-BnNDAYeY.js} +1 -1
  40. package/dist/assets/{form-o2cQtSfF.js → form-BndJ7ZnS.js} +1 -1
  41. package/dist/assets/{fr-ButkVdgL.js → fr-8njRrvuV.js} +1 -1
  42. package/dist/assets/{fuel-mxa8OZsa.js → fuel-BTh7B67H.js} +1 -1
  43. package/dist/assets/{gen-access-key-BgQp83Fx.js → gen-access-key-CbaepD9-.js} +1 -1
  44. package/dist/assets/{gen-simple-access-key-DbEHuHKs.js → gen-simple-access-key-mJK0zx1B.js} +1 -1
  45. package/dist/assets/{get-safe-url-BNFAIq84.js → get-safe-url-Bpq2IOGY.js} +1 -1
  46. package/dist/assets/{hdkey-Dszfv2Lm.js → hdkey-BpKJbkt5.js} +1 -1
  47. package/dist/assets/hi-JUTdfcRr.js +5 -0
  48. package/dist/assets/{home-C03NbY1T.js → home-BwLLSjzW.js} +1 -1
  49. package/dist/assets/{id-B6zyYCjr.js → id-CrtgRPeX.js} +1 -1
  50. package/dist/assets/{iframe-CZx2enRR.js → iframe-CbjzikLk.js} +1 -1
  51. package/dist/assets/{index-B5ss4uTe.js → index-0VNYJQln.js} +1 -1
  52. package/dist/assets/{index-TDbD3rO2.js → index-B5t6TkeL.js} +4 -4
  53. package/dist/assets/{index-B2R6qrmp.js → index-B9sHaKla.js} +1 -1
  54. package/dist/assets/{index-DQ5bllFt.js → index-BH6jQqKY.js} +1 -1
  55. package/dist/assets/{index-CrDQcn26.js → index-BKiTWpo1.js} +1 -1
  56. package/dist/assets/{index-R8yzPJ8-.js → index-BY2dcTa4.js} +1 -1
  57. package/dist/assets/{index-DGpFay7j.js → index-Bk02VaQE.js} +1 -1
  58. package/dist/assets/{index-D_t0hM3n.js → index-BtHQU9Nx.js} +1 -1
  59. package/dist/assets/{index-CJubEPJw.js → index-BxU3q403.js} +3 -3
  60. package/dist/assets/{index-BUlqbV5J.js → index-C4e0bu4c.js} +1 -1
  61. package/dist/assets/{index-CLmp-nsJ.js → index-Ca4b_pCt.js} +1 -1
  62. package/dist/assets/{index-MgFhlLet.js → index-Cd2DJL-w.js} +1 -1
  63. package/dist/assets/{index-CZjtHtZ4.js → index-CjfYhb8W.js} +1 -1
  64. package/dist/assets/{index-BF7bSwjJ.js → index-CuQBOJqN.js} +6 -6
  65. package/dist/assets/{index-BhhsbfbV.js → index-DEu06Btv.js} +1 -1
  66. package/dist/assets/{index-wKz_l66R.js → index-DzSOofQf.js} +1 -1
  67. package/dist/assets/{index-DO8dY30H.js → index-DzqNo2lD.js} +1 -1
  68. package/dist/assets/{index-_fIzCi4b.js → index-JixySlIT.js} +1 -1
  69. package/dist/assets/{index-DKALSagn.js → index-SbRD4xbu.js} +1 -1
  70. package/dist/assets/{index-CcHUYWYZ.js → index-ew1if2W6.js} +1 -1
  71. package/dist/assets/{index-D9F9PzFc.js → index-hXRVhE3g.js} +1 -1
  72. package/dist/assets/{index-DnMPdyj-.js → index-pAv7g5o_.js} +1 -1
  73. package/dist/assets/{index-CqAqyoyD.js → index-yi4PlkyH.js} +1 -1
  74. package/dist/assets/{invitation-Py8TsLWL.js → invitation-CsvJMPo7.js} +1 -1
  75. package/dist/assets/{invite-CrcJXNQ_.js → invite-DEEX5t_7.js} +1 -1
  76. package/dist/assets/{isURL-CH4qUEqk.js → isURL-Cuto2_sB.js} +1 -1
  77. package/dist/assets/{issue-passport-BrCzpb_k.js → issue-passport-BuT9-mlQ.js} +1 -1
  78. package/dist/assets/{item-pMF7ItdE.js → item-CEYjCEHD.js} +1 -1
  79. package/dist/assets/{ja-5mnOXG6B.js → ja-BDFhRccP.js} +1 -1
  80. package/dist/assets/{ko-Msmkvh9O.js → ko-Dde62QRb.js} +1 -1
  81. package/dist/assets/{landing-page-tr6cY26r.js → landing-page-CbZO5p-X.js} +1 -1
  82. package/dist/assets/{layout-BTWkyZIA.js → layout-BOMMbsdq.js} +1 -1
  83. package/dist/assets/{list-D9c57rY9.js → list-CIIZmkmF.js} +3 -3
  84. package/dist/assets/{list-u8QyXkOA.js → list-CcfeNfGu.js} +1 -1
  85. package/dist/assets/{localization-DiI2Nbuc.js → localization-DNJagVoT.js} +1 -1
  86. package/dist/assets/{log-atnf1Umh.js → log-CHaoSWXc.js} +1 -1
  87. package/dist/assets/{login-CKylUR0F.js → login-C0FSm4ep.js} +1 -1
  88. package/dist/assets/{login-oauth-callback-5DVKz_Jh.js → login-oauth-callback-DJxlMwXZ.js} +1 -1
  89. package/dist/assets/{logo-uploader-DbxANvEK.js → logo-uploader-C0ihL7E6.js} +2 -2
  90. package/dist/assets/{lost-passport-pzKFXIgF.js → lost-passport-BoAvHfI_.js} +1 -1
  91. package/dist/assets/{open-window-DM0S-jzk.js → open-window-BNY_OfK6.js} +1 -1
  92. package/dist/assets/{over-due-invoice-payment-CvZTMHvs.js → over-due-invoice-payment-DXbfRbJ6.js} +1 -1
  93. package/dist/assets/{overview-phdRvAI_.js → overview-DpF1loGs.js} +1 -1
  94. package/dist/assets/{passport-item-Ml3CykE7.js → passport-item-VXkf3FVk.js} +1 -1
  95. package/dist/assets/{permission-D9Anejwj.js → permission-DeQz9qFD.js} +1 -1
  96. package/dist/assets/{preferences-DClQtBed.js → preferences-C7TivEto.js} +1 -1
  97. package/dist/assets/{profile-embed-CIuOCLMD.js → profile-embed-Dzt59MHT.js} +1 -1
  98. package/dist/assets/pt-C4nfuExm.js +5 -0
  99. package/dist/assets/{publish-resource-DrVZkMgt.js → publish-resource-BSY6p0as.js} +1 -1
  100. package/dist/assets/ru-B4GtNlEa.js +5 -0
  101. package/dist/assets/{runtime-BfAbZoi3.js → runtime-B01d8fEk.js} +1 -1
  102. package/dist/assets/sdk-ZTxfQBV1.js +1 -0
  103. package/dist/assets/{security-DulYEnHf.js → security-sVehajDA.js} +1 -1
  104. package/dist/assets/{session-COCrt-qG.js → session-Bk6ebojT.js} +1 -1
  105. package/dist/assets/{setup-CHgFauXU.js → setup-B9yaqoQM.js} +1 -1
  106. package/dist/assets/{spaces-CvL1Uwkd.js → spaces-HwfT17d7.js} +1 -1
  107. package/dist/assets/{start-BhGEcDw9.js → start-4J_Dh_zH.js} +1 -1
  108. package/dist/assets/{status-v5BitGK5.js → status-B1AV3yPH.js} +1 -1
  109. package/dist/assets/{step-actions-C48J0mE1.js → step-actions-YjxSTbIE.js} +1 -1
  110. package/dist/assets/{studio-iYVCEWav.js → studio-Cx6j_6QU.js} +1 -1
  111. package/dist/assets/{team-BVaQVRGX.js → team-Dl23XmaY.js} +1 -1
  112. package/dist/assets/th-BkShd6jD.js +5 -0
  113. package/dist/assets/{traffic-CMbIGtyi.js → traffic-O-wVx65-.js} +1 -1
  114. package/dist/assets/{transfer-WHnS-w5n.js → transfer-gEq9B27K.js} +1 -1
  115. package/dist/assets/{unsubscribe-flFhRa0X.js → unsubscribe-vpGsla5T.js} +1 -1
  116. package/dist/assets/{use-app-logo-Cb6MS9by.js → use-app-logo-7cjs_pn8.js} +1 -1
  117. package/dist/assets/{user-center-BrV7Sqsj.js → user-center-DtJ32yjF.js} +3 -3
  118. package/dist/assets/{user-sessions-DMHiVE2_.js → user-sessions-CFxn5EHL.js} +1 -1
  119. package/dist/assets/{util-CmTchaCE.js → util-Ca2jlZN4.js} +1 -1
  120. package/dist/assets/{util-CU3dCXzc.js → util-o8U4JIlX.js} +1 -1
  121. package/dist/assets/vi-C1PSP5SP.js +5 -0
  122. package/dist/assets/{wait-connect-bu1NVn-9.js → wait-connect-DPAxcgcf.js} +1 -1
  123. package/dist/assets/{wizard-E9dqLz0c.js → wizard-072KuoFQ.js} +1 -1
  124. package/dist/assets/{wizard-components-DRUX-bqp.js → wizard-components-Dx5C9E35.js} +2 -2
  125. package/dist/assets/wrap-locale-BQM6_LkP.js +1 -0
  126. package/dist/assets/{zh-CwK2Wb9a.js → zh-C_fDhC3R.js} +1 -1
  127. package/dist/assets/{zh-BG6k4eXG.js → zh-gAK37O_Y.js} +1 -1
  128. package/dist/assets/{zh-tw-6SDy5fyY.js → zh-tw-BGfyObps.js} +1 -1
  129. package/dist/index.html +1 -1
  130. package/dist/service-worker.js +1 -1
  131. package/package.json +23 -23
  132. package/dist/assets/engine-UogTYMtu.js +0 -1
  133. package/dist/assets/hi-CLqQ4LHH.js +0 -5
  134. package/dist/assets/pt-D1bjCfHu.js +0 -5
  135. package/dist/assets/ru-DcnfcUY4.js +0 -5
  136. package/dist/assets/sdk-DkOKBbdA.js +0 -1
  137. package/dist/assets/th-C2mNGstJ.js +0 -5
  138. package/dist/assets/vi-C4AydA45.js +0 -5
  139. package/dist/assets/wrap-locale-C1S0zrtd.js +0 -1
@@ -1 +1 @@
1
- import{r as l}from"./vendor-react-Dvs43sk9.js";import{T as C,$ as E,L,N as M}from"./vendor-ux-B7q8W4Pg.js";import{k as y}from"./vendor-hooks-BRXKH6Nb.js";import{j as e,ak as s,a6 as $,aX as w,b1 as P,y as W,x as _,bb as B,M as N,T as z,a$ as A,I as D,bc as K,Q as F,W as U}from"./vendor-mui-core-B7zoO8f5.js";import{c as S,Z as k}from"./index-BF7bSwjJ.js";import{a as q}from"./api-IUmhrtIY.js";import{T as V}from"./table-tips-BP283GGZ.js";import{u as G}from"./team-BVaQVRGX.js";import{u as H}from"./session-COCrt-qG.js";import"./vendor-utils-DtY42AM-.js";import"./lottie-web-4koyQiv_.js";import"./vendor-arcblock-B7AoUs4o.js";import"./use-mobile-C_DcJ5SZ.js";import"./isURL-CH4qUEqk.js";import"./use-app-logo-Cb6MS9by.js";function T({endpoint:i}){const[t,a]=l.useState("mcp-link"),x=k(),{api:h}=k(),{teamDid:m}=G(),{t:c,locale:p}=C(),{session:r}=H(),{data:u,run:o,loading:g}=y(()=>{const f={owner:S.SERVER_ROLES.ADMIN}[r?.user?.role]||r?.user?.role;return h.createAccessKey({input:{teamDid:m,passport:f,authType:"simple",remark:"Generated by MCP Servers"}})},{manual:!0}),{imgPrefix:n}=x,j=l.useMemo(()=>[{icon:e.jsx(s,{sx:{width:20,height:20},children:"🔗"}),value:"mcp-link",label:"MCP Link"},{icon:e.jsx(s,{component:"img",src:`${n}/mcp/claude.webp`,alt:"Claude",sx:{width:20,height:20}}),value:"claude",label:"Claude"},{icon:e.jsx(s,{component:"img",src:`${n}/mcp/cursor.png`,alt:"Cursor",sx:{width:20,height:20}}),value:"cursor",label:"Cursor"},{icon:e.jsx(s,{component:"img",src:`${n}/mcp/cline.png`,alt:"Cline",sx:{width:20,height:20}}),value:"cline",label:"Cline"},{icon:e.jsx(s,{component:"img",src:`${n}/mcp/roocline.png`,alt:"Roo Cline",sx:{width:20,height:20}}),value:"roo-cline",label:"Roo Cline"},{icon:e.jsx(s,{component:"img",src:`${n}/mcp/windsurf.png`,alt:"Windsurf",sx:{width:20,height:20}}),value:"windsurf",label:"Windsurf"},{icon:e.jsx(s,{component:"img",src:`${n}/mcp/witsy.png`,alt:"Witsy",sx:{width:20,height:20}}),value:"witsy",label:"Witsy"}],[n]),v=j.find(d=>d.value===t),b=l.useMemo(()=>u?.data?.accessKeySecret,[u]),R=l.useMemo(()=>!b&&t!=="mcp-link",[b,t]),I=d=>{const f=`npx @blocklet/install-mcp@latest i ${i} --client ${d} --streamableHTTP --oauth2Bearer ${b}`;switch(d){case"cursor":case"claude":case"cline":case"roo-cline":case"windsurf":case"witsy":return f;case"mcp-link":default:return i}};return e.jsxs(s,{className:"mcp-servers-container",children:[e.jsx(L,{tabs:j,current:t,onChange:a,scrollButtons:"auto",iconPosition:"start"}),e.jsxs(s,{children:[e.jsxs(s,{sx:{display:"flex",alignItems:"center",gap:.5},children:[e.jsx(z,{component:"span",variant:"h6",sx:{fontWeight:"bold",my:2},children:t==="mcp-link"?v?.label:`${v?.label} ${c("installCommand")}`}),t!=="mcp-link"&&e.jsx(A,{href:`https://www.arcblock.io/docs/blocklet-developer/${p}/mcp-${t}`,target:"_blank",rel:"noopener noreferrer",children:e.jsx(D,{size:"small",children:e.jsx(K,{fontSize:"small"})})})]}),e.jsxs(s,{className:"mcp-servers-codeblock",sx:{position:"relative","& pre":{borderRadius:1},"& .codeblock__inner":{overflow:"auto !important",borderRadius:1}},children:[e.jsx(M,{code:I(t),language:"shell",style:{margin:0}}),R&&e.jsx(s,{sx:{position:"absolute",top:0,right:0,left:0,bottom:0,display:"flex",alignItems:"center",justifyContent:"center",bgcolor:"action.active",backdropFilter:"blur(3px)",WebkitBackdropFilter:"blur(3px)",zIndex:1},children:g?e.jsx($,{}):e.jsx(F,{variant:"contained",color:"primary",onClick:o,size:"small",children:`${c("common.generate")} ${c("command")}`})})]})]})]})}T.propTypes={endpoint:U.string.isRequired};function ce(){const[i,t]=l.useState(null),{t:a,locale:x}=C(),h=`${window?.blocklet?.appUrl}${S.WELLKNOWN_SERVICE_PATH_PREFIX}/mcp/servers`,{data:m,loading:c,error:p}=y(()=>Promise.all([q.get(h)])),r=l.useMemo(()=>m?.[0]?.data?.servers||[],[m]);l.useEffect(()=>{r?.length&&t(r.find(o=>o.did===window?.blocklet?.did)||r[0])},[r]);const u=o=>{const g=o.target.value;t(r.find(n=>n.did===g))};return c?e.jsx(s,{children:e.jsx($,{})}):p?e.jsx(w,{color:"error",children:p?.message}):r?.length?e.jsxs(P,{sx:{gap:2,maxWidth:1200},children:[e.jsx(V,{title:a("mcp.listTitle"),tooltipTitle:a("mcp.tooltipTitle"),link:`https://www.arcblock.io/docs/blocklet-developer/${x}/mcp-server`}),e.jsxs(W,{fullWidth:!0,children:[e.jsx(_,{id:"server-select-label",children:a("mcp.available")}),e.jsx(B,{labelId:"server-select-label",value:i?.did||"",label:a("mcp.available"),onChange:u,children:r.map(o=>e.jsx(N,{value:o.did,children:e.jsxs(s,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(E,{variant:"rounded",shape:"square",did:o.did,src:o.logo,size:20}),e.jsx(s,{sx:{fontSize:14},children:o.name})]})},o.did))})]}),i&&e.jsx(T,{endpoint:i.endpoint})]}):e.jsx(w,{color:"warning",children:a("mcp.noServer")})}export{ce as default};
1
+ import{r as l}from"./vendor-react-Dvs43sk9.js";import{T as C,$ as E,L,N as M}from"./vendor-ux-B7q8W4Pg.js";import{k as y}from"./vendor-hooks-BRXKH6Nb.js";import{j as e,ak as s,a6 as $,aX as w,b1 as P,y as W,x as _,bb as B,M as N,T as z,a$ as A,I as D,bc as K,Q as F,W as U}from"./vendor-mui-core-B7zoO8f5.js";import{c as S,Z as k}from"./index-CuQBOJqN.js";import{a as q}from"./api-IUmhrtIY.js";import{T as V}from"./table-tips-BP283GGZ.js";import{u as G}from"./team-Dl23XmaY.js";import{u as H}from"./session-Bk6ebojT.js";import"./vendor-utils-DtY42AM-.js";import"./lottie-web-4koyQiv_.js";import"./vendor-arcblock-B7AoUs4o.js";import"./use-mobile-C_DcJ5SZ.js";import"./isURL-Cuto2_sB.js";import"./use-app-logo-7cjs_pn8.js";function T({endpoint:i}){const[t,a]=l.useState("mcp-link"),x=k(),{api:h}=k(),{teamDid:m}=G(),{t:c,locale:p}=C(),{session:r}=H(),{data:u,run:o,loading:g}=y(()=>{const f={owner:S.SERVER_ROLES.ADMIN}[r?.user?.role]||r?.user?.role;return h.createAccessKey({input:{teamDid:m,passport:f,authType:"simple",remark:"Generated by MCP Servers"}})},{manual:!0}),{imgPrefix:n}=x,j=l.useMemo(()=>[{icon:e.jsx(s,{sx:{width:20,height:20},children:"🔗"}),value:"mcp-link",label:"MCP Link"},{icon:e.jsx(s,{component:"img",src:`${n}/mcp/claude.webp`,alt:"Claude",sx:{width:20,height:20}}),value:"claude",label:"Claude"},{icon:e.jsx(s,{component:"img",src:`${n}/mcp/cursor.png`,alt:"Cursor",sx:{width:20,height:20}}),value:"cursor",label:"Cursor"},{icon:e.jsx(s,{component:"img",src:`${n}/mcp/cline.png`,alt:"Cline",sx:{width:20,height:20}}),value:"cline",label:"Cline"},{icon:e.jsx(s,{component:"img",src:`${n}/mcp/roocline.png`,alt:"Roo Cline",sx:{width:20,height:20}}),value:"roo-cline",label:"Roo Cline"},{icon:e.jsx(s,{component:"img",src:`${n}/mcp/windsurf.png`,alt:"Windsurf",sx:{width:20,height:20}}),value:"windsurf",label:"Windsurf"},{icon:e.jsx(s,{component:"img",src:`${n}/mcp/witsy.png`,alt:"Witsy",sx:{width:20,height:20}}),value:"witsy",label:"Witsy"}],[n]),v=j.find(d=>d.value===t),b=l.useMemo(()=>u?.data?.accessKeySecret,[u]),R=l.useMemo(()=>!b&&t!=="mcp-link",[b,t]),I=d=>{const f=`npx @blocklet/install-mcp@latest i ${i} --client ${d} --streamableHTTP --oauth2Bearer ${b}`;switch(d){case"cursor":case"claude":case"cline":case"roo-cline":case"windsurf":case"witsy":return f;case"mcp-link":default:return i}};return e.jsxs(s,{className:"mcp-servers-container",children:[e.jsx(L,{tabs:j,current:t,onChange:a,scrollButtons:"auto",iconPosition:"start"}),e.jsxs(s,{children:[e.jsxs(s,{sx:{display:"flex",alignItems:"center",gap:.5},children:[e.jsx(z,{component:"span",variant:"h6",sx:{fontWeight:"bold",my:2},children:t==="mcp-link"?v?.label:`${v?.label} ${c("installCommand")}`}),t!=="mcp-link"&&e.jsx(A,{href:`https://www.arcblock.io/docs/blocklet-developer/${p}/mcp-${t}`,target:"_blank",rel:"noopener noreferrer",children:e.jsx(D,{size:"small",children:e.jsx(K,{fontSize:"small"})})})]}),e.jsxs(s,{className:"mcp-servers-codeblock",sx:{position:"relative","& pre":{borderRadius:1},"& .codeblock__inner":{overflow:"auto !important",borderRadius:1}},children:[e.jsx(M,{code:I(t),language:"shell",style:{margin:0}}),R&&e.jsx(s,{sx:{position:"absolute",top:0,right:0,left:0,bottom:0,display:"flex",alignItems:"center",justifyContent:"center",bgcolor:"action.active",backdropFilter:"blur(3px)",WebkitBackdropFilter:"blur(3px)",zIndex:1},children:g?e.jsx($,{}):e.jsx(F,{variant:"contained",color:"primary",onClick:o,size:"small",children:`${c("common.generate")} ${c("command")}`})})]})]})]})}T.propTypes={endpoint:U.string.isRequired};function ce(){const[i,t]=l.useState(null),{t:a,locale:x}=C(),h=`${window?.blocklet?.appUrl}${S.WELLKNOWN_SERVICE_PATH_PREFIX}/mcp/servers`,{data:m,loading:c,error:p}=y(()=>Promise.all([q.get(h)])),r=l.useMemo(()=>m?.[0]?.data?.servers||[],[m]);l.useEffect(()=>{r?.length&&t(r.find(o=>o.did===window?.blocklet?.did)||r[0])},[r]);const u=o=>{const g=o.target.value;t(r.find(n=>n.did===g))};return c?e.jsx(s,{children:e.jsx($,{})}):p?e.jsx(w,{color:"error",children:p?.message}):r?.length?e.jsxs(P,{sx:{gap:2,maxWidth:1200},children:[e.jsx(V,{title:a("mcp.listTitle"),tooltipTitle:a("mcp.tooltipTitle"),link:`https://www.arcblock.io/docs/blocklet-developer/${x}/mcp-server`}),e.jsxs(W,{fullWidth:!0,children:[e.jsx(_,{id:"server-select-label",children:a("mcp.available")}),e.jsx(B,{labelId:"server-select-label",value:i?.did||"",label:a("mcp.available"),onChange:u,children:r.map(o=>e.jsx(N,{value:o.did,children:e.jsxs(s,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(E,{variant:"rounded",shape:"square",did:o.did,src:o.logo,size:20}),e.jsx(s,{sx:{fontSize:14},children:o.name})]})},o.did))})]}),i&&e.jsx(T,{endpoint:i.endpoint})]}):e.jsx(w,{color:"warning",children:a("mcp.noServer")})}export{ce as default};
@@ -1,4 +1,4 @@
1
- import{j as a,D as M,T as _,cg as T,Q as W,ch as q,aV as X,ak as h,ci as Y,aU as Z,av as B,f as C,b_ as J,cj as K}from"./vendor-mui-core-B7zoO8f5.js";import{r as d,k as L,L as z,n as ee,o as ae}from"./vendor-react-Dvs43sk9.js";import{H as E,aS as te}from"./index-BF7bSwjJ.js";import{e as ie}from"./vendor-hooks-BRXKH6Nb.js";import{M as re,l as m,af as S,ag as A}from"./vendor-ux-B7q8W4Pg.js";import{z as oe}from"./vendor-arcblock-B7AoUs4o.js";const H=d.createContext(null),se=e=>{const i=d.use(H);return d.useLayoutEffect(()=>{},[]),i};function le({children:e=void 0,...i}){const[t,r]=d.useState({inFullPage:!1,showToggleButton:!1,headerVisibleInFullPage:!0,footerVisibleInFullPage:!1,sidebarVisibleInFullPage:!1}),s=()=>{r(o=>({...o,inFullPage:!o.inFullPage}))},l=d.useMemo(()=>({...t,headerVisible:!t.inFullPage||t.headerVisibleInFullPage,footerVisible:!t.inFullPage||t.footerVisibleInFullPage,sidebarVisible:!t.inFullPage||t.sidebarVisibleInFullPage,toggleFullPage:s,configure:o=>r(n=>({...n,...o}))}),[t]);return a.jsx(H,{value:l,...i,children:e})}function ne({name:e,size:i=36,alt:t="",color:r="#000000",prefix:s="/images",showBadge:l=!1,style:o={},...n}){const c=`${s}/${e}-${r.replace(/^#/,"")}.png`;return a.jsxs(de,{style:{width:i,height:i},children:[a.jsx(re,{width:i,height:i,alt:t||e,src:c,style:Object.assign({width:i},o),...n}),l&&a.jsx("i",{className:"badge-point"})]})}const de=m("div")`
1
+ import{j as a,D as M,T as _,cg as T,Q as W,ch as q,aV as X,ak as h,ci as Y,aU as Z,av as B,f as C,b_ as J,cj as K}from"./vendor-mui-core-B7zoO8f5.js";import{r as d,k as L,L as z,n as ee,o as ae}from"./vendor-react-Dvs43sk9.js";import{H as E,aS as te}from"./index-CuQBOJqN.js";import{e as ie}from"./vendor-hooks-BRXKH6Nb.js";import{M as re,l as m,af as S,ag as A}from"./vendor-ux-B7q8W4Pg.js";import{z as oe}from"./vendor-arcblock-B7AoUs4o.js";const H=d.createContext(null),se=e=>{const i=d.use(H);return d.useLayoutEffect(()=>{},[]),i};function le({children:e=void 0,...i}){const[t,r]=d.useState({inFullPage:!1,showToggleButton:!1,headerVisibleInFullPage:!0,footerVisibleInFullPage:!1,sidebarVisibleInFullPage:!1}),s=()=>{r(o=>({...o,inFullPage:!o.inFullPage}))},l=d.useMemo(()=>({...t,headerVisible:!t.inFullPage||t.headerVisibleInFullPage,footerVisible:!t.inFullPage||t.footerVisibleInFullPage,sidebarVisible:!t.inFullPage||t.sidebarVisibleInFullPage,toggleFullPage:s,configure:o=>r(n=>({...n,...o}))}),[t]);return a.jsx(H,{value:l,...i,children:e})}function ne({name:e,size:i=36,alt:t="",color:r="#000000",prefix:s="/images",showBadge:l=!1,style:o={},...n}){const c=`${s}/${e}-${r.replace(/^#/,"")}.png`;return a.jsxs(de,{style:{width:i,height:i},children:[a.jsx(re,{width:i,height:i,alt:t||e,src:c,style:Object.assign({width:i},o),...n}),l&&a.jsx("i",{className:"badge-point"})]})}const de=m("div")`
2
2
  position: relative;
3
3
  .badge-point {
4
4
  position: absolute;
@@ -1 +1 @@
1
- import{j as a,T as j,ak as c,D as S,P as b}from"./vendor-mui-core-B7zoO8f5.js";import{r as x}from"./vendor-react-Dvs43sk9.js";import{aX as m,aY as w,aZ as P,a_ as T,a$ as D,b0 as N}from"./index-BF7bSwjJ.js";import{C as y,$ as z}from"./vendor-ux-B7q8W4Pg.js";var d=(r=>(r.AvatarOnly="AvatarOnly",r.Detailed="Detailed",r))(d||{}),p=(r=>(r.NameOnly="NameOnly",r.Minimal="Minimal",r.Basic="Basic",r))(p||{});function O(r){const{user:e,infoType:n,avatarSize:s=48,shouldShowHoverCard:i=!1,renderCardContent:o,...l}=r;return n===p.NameOnly?a.jsx(m,{user:e,avatarSize:s,shouldShowHoverCard:!1,renderCardContent:o,tooltipTitle:e.fullName||e.email||e.did,...l}):a.jsx(m,{user:e,avatarSize:s,shouldShowHoverCard:i,renderCardContent:o,...l})}function R(r){const{user:e,avatarSize:n=48,onAvatarClick:s}=r;return a.jsxs(a.Fragment,{children:[w(e,n,r.avatarProps,s),a.jsx(j,{variant:"body1",children:e.fullName||e.email||e.did})]})}function g({...r}){const{user:e,avatarSize:n=40,renderCustomContent:s,infoType:i=p.Minimal,renderFields:o,popupRenderFields:l,...u}=r;return a.jsxs(c,{sx:{display:"flex",flexDirection:"column",width:"100%",flex:1,height:"100%"},children:[a.jsx(P,{user:e,avatarSize:n,...u}),i===p.Basic&&a.jsx(T,{user:e,renderFields:o}),a.jsx(c,{className:"user-card__footer",children:s&&a.jsx(c,{sx:{mt:1.5},children:s()})})]})}function v({...r}){const{infoType:e=p.Minimal}=r;switch(e){case p.NameOnly:return a.jsx(R,{...r});default:return a.jsx(g,{...r})}}function A({children:r,sx:e={}}){const n=S();return a.jsx(c,{sx:y({p:2,backgroundColor:n.palette.background.paper,border:"1px solid",borderColor:"divider",borderRadius:1,maxWidth:500,minWidth:320,display:"flex"},e||null),children:r})}function F({children:r,cardType:e=d.Detailed,variant:n="box",containerRef:s=void 0,sx:i={}}){const o={minWidth:320,p:2,borderRadius:1,...e===d.Detailed?{border:"1px solid",borderColor:"divider"}:{}};return n==="paper"?a.jsx(b,{ref:s,elevation:0,sx:o,children:r}):a.jsx(c,{ref:s,sx:y(o,{display:"flex",alignItems:e===d.AvatarOnly?"center":"flex-start",gap:2},i||null),children:r})}function M(r){const{cardType:e=d.Detailed,showHoverCard:n}=r,s=n!==void 0?n:e===d.AvatarOnly,i=x.useRef(null),[o,l]=x.useState(()=>r.user||null);x.useEffect(()=>{let t=!0;return r.user?l(r.user):r.did&&D(r.did)&&!r.user&&N(r.did).then(f=>{t&&l(f||{fullName:"Anonymous",did:r.did,avatar:""})}),()=>{t=!1}},[r.did,r.user]);const u=x.useMemo(()=>{if(!o)return null;const{avatar:t="",...f}=o;if(t){const C=t.split("?")[1]||"";return{...f,avatar:C?t:`${t}?imageFilter=resize&w=48&h=48`}}return o},[o]);if(!u)return a.jsx(z,{did:r.did,size:r.avatarSize,useProxyFallback:!0,...r.avatarProps});const h=()=>a.jsx(A,{sx:r.popupSx,children:a.jsx(v,{...r,shouldShowHoverCard:!1,user:u,avatarProps:r.popupAvatarProps,shortenLabelProps:r.popupShortenLabelProps||r.shortenLabelProps,renderFields:r.popupRenderFields,renderName:r.popupRenderName,infoType:r.popupInfoType||r.infoType,didProps:r.popupDidProps||r.didProps,showDid:r.popupShowDid||r.showDid})});return e===d.AvatarOnly?a.jsx(O,{...r,shouldShowHoverCard:s,renderCardContent:h,user:u}):a.jsx(F,{containerRef:i,cardType:e,sx:r.sx,children:a.jsx(v,{...r,shouldShowHoverCard:s,renderCardContent:h,user:u})})}export{M as B,p as a,d as l};
1
+ import{j as a,T as j,ak as c,D as S,P as b}from"./vendor-mui-core-B7zoO8f5.js";import{r as x}from"./vendor-react-Dvs43sk9.js";import{aX as m,aY as w,aZ as P,a_ as T,a$ as D,b0 as N}from"./index-CuQBOJqN.js";import{C as y,$ as z}from"./vendor-ux-B7q8W4Pg.js";var d=(r=>(r.AvatarOnly="AvatarOnly",r.Detailed="Detailed",r))(d||{}),p=(r=>(r.NameOnly="NameOnly",r.Minimal="Minimal",r.Basic="Basic",r))(p||{});function O(r){const{user:e,infoType:n,avatarSize:s=48,shouldShowHoverCard:i=!1,renderCardContent:o,...l}=r;return n===p.NameOnly?a.jsx(m,{user:e,avatarSize:s,shouldShowHoverCard:!1,renderCardContent:o,tooltipTitle:e.fullName||e.email||e.did,...l}):a.jsx(m,{user:e,avatarSize:s,shouldShowHoverCard:i,renderCardContent:o,...l})}function R(r){const{user:e,avatarSize:n=48,onAvatarClick:s}=r;return a.jsxs(a.Fragment,{children:[w(e,n,r.avatarProps,s),a.jsx(j,{variant:"body1",children:e.fullName||e.email||e.did})]})}function g({...r}){const{user:e,avatarSize:n=40,renderCustomContent:s,infoType:i=p.Minimal,renderFields:o,popupRenderFields:l,...u}=r;return a.jsxs(c,{sx:{display:"flex",flexDirection:"column",width:"100%",flex:1,height:"100%"},children:[a.jsx(P,{user:e,avatarSize:n,...u}),i===p.Basic&&a.jsx(T,{user:e,renderFields:o}),a.jsx(c,{className:"user-card__footer",children:s&&a.jsx(c,{sx:{mt:1.5},children:s()})})]})}function v({...r}){const{infoType:e=p.Minimal}=r;switch(e){case p.NameOnly:return a.jsx(R,{...r});default:return a.jsx(g,{...r})}}function A({children:r,sx:e={}}){const n=S();return a.jsx(c,{sx:y({p:2,backgroundColor:n.palette.background.paper,border:"1px solid",borderColor:"divider",borderRadius:1,maxWidth:500,minWidth:320,display:"flex"},e||null),children:r})}function F({children:r,cardType:e=d.Detailed,variant:n="box",containerRef:s=void 0,sx:i={}}){const o={minWidth:320,p:2,borderRadius:1,...e===d.Detailed?{border:"1px solid",borderColor:"divider"}:{}};return n==="paper"?a.jsx(b,{ref:s,elevation:0,sx:o,children:r}):a.jsx(c,{ref:s,sx:y(o,{display:"flex",alignItems:e===d.AvatarOnly?"center":"flex-start",gap:2},i||null),children:r})}function M(r){const{cardType:e=d.Detailed,showHoverCard:n}=r,s=n!==void 0?n:e===d.AvatarOnly,i=x.useRef(null),[o,l]=x.useState(()=>r.user||null);x.useEffect(()=>{let t=!0;return r.user?l(r.user):r.did&&D(r.did)&&!r.user&&N(r.did).then(f=>{t&&l(f||{fullName:"Anonymous",did:r.did,avatar:""})}),()=>{t=!1}},[r.did,r.user]);const u=x.useMemo(()=>{if(!o)return null;const{avatar:t="",...f}=o;if(t){const C=t.split("?")[1]||"";return{...f,avatar:C?t:`${t}?imageFilter=resize&w=48&h=48`}}return o},[o]);if(!u)return a.jsx(z,{did:r.did,size:r.avatarSize,useProxyFallback:!0,...r.avatarProps});const h=()=>a.jsx(A,{sx:r.popupSx,children:a.jsx(v,{...r,shouldShowHoverCard:!1,user:u,avatarProps:r.popupAvatarProps,shortenLabelProps:r.popupShortenLabelProps||r.shortenLabelProps,renderFields:r.popupRenderFields,renderName:r.popupRenderName,infoType:r.popupInfoType||r.infoType,didProps:r.popupDidProps||r.didProps,showDid:r.popupShowDid||r.showDid})});return e===d.AvatarOnly?a.jsx(O,{...r,shouldShowHoverCard:s,renderCardContent:h,user:u}):a.jsx(F,{containerRef:i,cardType:e,sx:r.sx,children:a.jsx(v,{...r,shouldShowHoverCard:s,renderCardContent:h,user:u})})}export{M as B,p as a,d as l};
@@ -1,4 +1,4 @@
1
- import{T as M,H as q,aa as N,N as Y,a9 as ve,ab as Ce,ah as Se}from"./vendor-ux-B7q8W4Pg.js";import{s as Te,k as le,t as Ie}from"./vendor-hooks-BRXKH6Nb.js";import{r as E,a as ae}from"./vendor-react-Dvs43sk9.js";import{j as e,Y as Re,bB as We,$ as ze,ak as p,z as se,T as C,a6 as F,aX as te,R as De,Q as H,b6 as ne,am as P,bd as _,a5 as J,V as Z,S as G,b4 as Oe,U as L,I as B,cm as Ae,bf as Pe,a7 as $e,F as qe,W as t,b1 as R,a3 as ce,c1 as ee,cn as Le,aO as Me,aP as Be,co as Fe,cp as He,cq as Ne,s as oe,aU as Ue,aj as _e,J as Ke,cr as Ve,aZ as Ye,cl as Je,c9 as Qe,ck as Xe}from"./vendor-mui-core-B7zoO8f5.js";import{B as de,a as pe,l as ue}from"./index-DO8dY30H.js";import{Z as K,c as xe,ao as Ze,a8 as Ge,b8 as Q}from"./index-BF7bSwjJ.js";import{u as V}from"./team-BVaQVRGX.js";import{u as et}from"./use-mobile-C_DcJ5SZ.js";import{u as tt,C as X}from"./index.esm-JPZAjt0x.js";import{C as he,a as me,J as ot}from"./vendor-utils-DtY42AM-.js";import{C as st}from"./confirm-Bax75YdO.js";import{A as nt}from"./actions-Bf4UKTeu.js";import{T as ie}from"./table-tips-BP283GGZ.js";import"./lottie-web-4koyQiv_.js";import"./vendor-arcblock-B7AoUs4o.js";import"./session-COCrt-qG.js";import"./isURL-CH4qUEqk.js";import"./use-app-logo-Cb6MS9by.js";import"./index-DBs9Ljax.js";const it=i=>{const[u,c]=E.useState(null),[b,r]=E.useState(!0),[w,x]=E.useState(null),j=window.blocklet?.appUrl,l=E.useMemo(()=>{const g={};return u&&(u.sources.forEach(y=>{g[y.did]={source:y,events:[],count:0}}),u.events.forEach(y=>{g[y.source]&&(g[y.source].events.push(y),g[y.source].count+=1)})),g},[u]),f=async()=>{try{if(r(!0),!j)return;const y=await(await fetch(he(j,xe.WELLKNOWN_SERVICE_PATH_PREFIX,"/openevent.json"))).json();c(y),x(null)}catch(g){x(g instanceof Error?g:new Error(String(g)))}finally{r(!1)}};return E.useEffect(()=>{f()},[j]),{openEvent:u,setOpenEvent:c,eventsBySource:l,loading:b,error:w,loadData:f}};function ge({eventsBySource:i,selectedEvents:u,setSelectedEvents:c,error:b=null}){const{t:r}=M(),[w,x]=E.useState({}),j=E.useMemo(()=>{const n={};return Object.entries(i).forEach(([a,{events:m}])=>{const v=m.filter(S=>u[`${S.type}-${S.source}`]).length;n[a]=v}),n},[i,u]),l=E.useMemo(()=>Object.values(j).reduce((n,a)=>n+a,0),[j]),f=E.useMemo(()=>Object.values(i).reduce((n,{events:a})=>n+a.length,0),[i]),g=(n,a)=>{a.stopPropagation(),x({...w,[n]:!w[n]})},y=n=>{const a=`${n.type}-${n.source}`;c(m=>({...m,[a]:!m[a]}))},z=(n,a)=>{const m={};n.forEach(v=>{const S=`${v.type}-${v.source}`;m[S]=!a}),c(v=>({...v,...m}))},T=n=>{const a={};Object.values(i).forEach(({events:m})=>{m.forEach(v=>{const S=`${v.type}-${v.source}`;a[S]=n.target.checked})}),c(a)};return e.jsxs(p,{sx:{width:"100%"},children:[e.jsxs(p,{sx:{display:"flex",alignItems:"center",mb:1,mt:1},children:[e.jsx(ne,{control:e.jsx(J,{onChange:T,checked:l>0&&l===f}),label:e.jsxs(p,{sx:{display:"flex",alignItems:"center",cursor:"pointer"},children:[r("webhookEndpoint.selectAllEvents"),e.jsx(p,{sx:{display:"flex",alignItems:"center"},children:e.jsx(P,{title:r("webhookEndpoint.selectAllEventsTooltip"),placement:"right",children:e.jsx(_,{fontSize:"small",sx:{ml:.5,cursor:"help"}})})})]}),sx:{m:0}}),l>0&&e.jsx(C,{variant:"body2",color:"primary",sx:{ml:"auto"},children:r("webhookEndpoint.selectedEventsCount",{count:l})})]}),e.jsx(p,{sx:{maxHeight:"50vh",overflow:"auto"},children:e.jsx(Z,{disablePadding:!0,sx:{border:"1px solid",borderColor:"divider",borderRadius:"4px"},children:Object.entries(i).map(([n,{source:a,events:m,count:v}],S)=>{const D=j[n]>0,I=j[n]===m.length&&m.length>0,O=w[n];return e.jsxs(ae.Fragment,{children:[e.jsx(G,{sx:{borderBottom:({palette:o})=>S<Object.keys(i).length-1?`1px solid ${o.divider}`:"none",px:2,py:1.5,"&:hover":{bgcolor:"rgba(0, 0, 0, 0.02)"}},children:e.jsxs(p,{sx:{display:"flex",width:"100%",justifyContent:"space-between",alignItems:"center"},onClick:o=>{o.target.closest(".MuiFormControlLabel-root")||g(n,o)},children:[e.jsx(p,{sx:{display:"flex",alignItems:"center"},children:m.length>0&&e.jsx(ne,{control:e.jsx(J,{checked:I,indeterminate:D&&!I,onChange:o=>{o.stopPropagation(),z(m,I)}}),label:e.jsxs(p,{sx:{display:"flex",alignItems:"center",gap:1},children:[a.logo&&e.jsx(Oe,{src:a.logo,sx:{width:24,height:24}}),e.jsx(p,{children:a.title||n}),D&&e.jsx(L,{label:r("webhookEndpoint.selectedCount",{count:j[n]}),size:"small",sx:{mt:"2px",height:"20px",fontSize:"12px",bgcolor:o=>`${o.palette.primary.main}20`,color:"primary.main",fontWeight:500}})]}),sx:{m:0,"& .MuiFormControlLabel-label":{flex:1}}})}),e.jsxs(p,{sx:{display:"flex",alignItems:"center"},children:[e.jsx(C,{variant:"body2",sx:{color:"text.secondary",mr:1},children:r("webhookEndpoint.eventsCount",{count:v})}),m.length>0&&e.jsx(B,{size:"small",edge:"end",children:O?e.jsx(Ae,{}):e.jsx(Pe,{})})]})]})}),m.length>0&&e.jsx($e,{in:O,timeout:"auto",unmountOnExit:!0,children:e.jsx(Z,{disablePadding:!0,sx:{pl:2,pr:2,py:1,bgcolor:"rgba(0, 0, 0, 0.01)"},children:m.map(o=>{const d=`${o.type}-${o.source}`,s=!!u[d];return e.jsx(G,{dense:!0,sx:{py:.75},onClick:()=>y(o),children:e.jsxs(p,{sx:{display:"flex",alignItems:"flex-start",width:"100%"},children:[e.jsx(J,{checked:s,sx:{mr:1}}),e.jsxs(p,{children:[e.jsx(C,{variant:"body1",sx:{cursor:"pointer",color:"text.primary"},children:o.type}),e.jsx(C,{variant:"caption",sx:{color:"text.secondary",display:"block",cursor:"pointer"},children:o.description})]})]})},d)})})})]},n)})})}),b&&e.jsx(qe,{error:!0,sx:{mt:1},children:b})]})}ge.propTypes={eventsBySource:t.objectOf(t.shape({source:t.shape({did:t.string.isRequired,title:t.string,description:t.string,version:t.string,logo:t.string}).isRequired,events:t.arrayOf(t.shape({type:t.string.isRequired,description:t.string.isRequired,source:t.string.isRequired})).isRequired,count:t.number.isRequired})).isRequired,selectedEvents:t.objectOf(t.bool).isRequired,setSelectedEvents:t.func.isRequired,error:t.string};function fe({id:i=null,url:u="",description:c="",enabledEvents:b=[],onSubmit:r,onClose:w=()=>{}}){const{t:x}=M(),[j,l]=E.useState({}),{teamDid:f}=V(),{api:g}=K(),{loading:y,error:z,eventsBySource:T}=it(),{control:n,handleSubmit:a,formState:{errors:m},reset:v,setValue:S,trigger:D}=tt({defaultValues:{url:"",description:""}});E.useEffect(()=>{const o=Object.values(j).some(d=>d);S("selectedEvents",o?"valid":""),D("selectedEvents")},[j,S,D]);const I=()=>{l({}),v(),w()},O=async o=>{const d=Object.keys(j).filter(h=>j[h]),s={url:o.url,description:o.description,enabledEvents:d.map(h=>{const[k,W]=h.split("-");return!k||!W?null:{type:k,source:W}}).filter(Boolean)};try{if(i){const h=await g.updateWebhookEndpoint({input:{teamDid:f,id:i,data:s}});q.success(`${x("webhookEndpoint.updateWebhook")} ${x("webhookEndpoint.success")}`),r(h)}else{const h=await g.createWebhookEndpoint({input:{teamDid:f,input:s}});q.success(`${x("webhookEndpoint.createWebhook")} ${x("webhookEndpoint.success")}`),r(h)}}catch(h){q.error(h?.message)}I()};return E.useEffect(()=>{v({url:u,description:c}),l(b.reduce((o,d)=>(o[`${d.type}-${d.source}`]=!0,o),{}))},[v,l,u,c,b]),e.jsx(Re,{open:!0,onClose:I,maxWidth:"lg",fullWidth:!0,sx:{"& .MuiDialog-paper":{minHeight:600}},children:e.jsxs("form",{onSubmit:a(O),children:[e.jsx(We,{children:x(i?"webhookEndpoint.editWebhookTitle":"webhookEndpoint.createWebhookTitle")}),e.jsx(ze,{children:e.jsxs(p,{sx:{display:"flex",flexDirection:"column",gap:2,mt:2},children:[e.jsx(X,{name:"url",control:n,rules:{required:x("webhookEndpoint.validation.urlRequired"),pattern:{value:/^(http|https):\/\/[^ "]+$/,message:x("webhookEndpoint.validation.urlInvalid")}},render:({field:o})=>e.jsx(se,{...o,label:x("webhookEndpoint.url.label"),fullWidth:!0,error:!!m.url,helperText:m.url?.message})}),e.jsx(X,{name:"description",control:n,rules:{required:x("webhookEndpoint.validation.descriptionRequired")},render:({field:o})=>e.jsx(se,{...o,label:x("webhookEndpoint.description.label"),fullWidth:!0,multiline:!0,minRows:2,maxRows:4,error:!!m.description,helperText:m.description?.message})}),e.jsx(X,{name:"selectedEvents",control:n,rules:{required:x("webhookEndpoint.validation.eventRequired")},render:({field:o})=>e.jsx("input",{type:"hidden",...o})}),!y&&T&&Object.keys(T).length>0&&e.jsx(ge,{eventsBySource:T,selectedEvents:j,setSelectedEvents:l,error:m.selectedEvents?.message}),!y&&(!T||Object.keys(T).length===0)&&e.jsx(C,{sx:{color:"text.secondary"},children:x("webhookEndpoint.noAvailableEvents")}),y&&e.jsx(p,{sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"500px",width:"100%"},children:e.jsx(F,{size:20})}),z&&e.jsx(te,{severity:"error",children:x("webhookEndpoint.loadingError",{message:z?.message})})]})}),e.jsxs(De,{sx:{p:"8px 24px 24px"},children:[e.jsx(H,{onClick:I,children:x("common.cancel")}),e.jsx(H,{type:"submit",variant:"contained",color:"primary",children:x(i?"webhookEndpoint.updateWebhook":"webhookEndpoint.saveWebhook")})]})]})})}fe.propTypes={onSubmit:t.func.isRequired,id:t.string,url:t.string,description:t.string,enabledEvents:t.arrayOf(t.shape({type:t.string.isRequired,source:t.string.isRequired})),onClose:t.func};function be(i){switch(i){case"enabled":return"success";case"disabled":default:return"default"}}const rt=(i="en")=>i==="tw"?"zh":i;function U(i,u="YYYY-MM-DD HH:mm:ss",c="en"){return i?Ze(i).locale(rt(c)).format(u):"-"}function lt(i){return typeof i=="number"?!1:me(i)}function at(i){return i>=200&&i<300}function A({value:i,label:u,tip:c="",divider:b=!1}){const r=lt(i);return e.jsxs(e.Fragment,{children:[e.jsxs(R,{direction:"column",alignItems:"flex-start",children:[e.jsxs(C,{component:"div",variant:"body1",mb:1,color:"text.primary",sx:{fontWeight:500},children:[u,!!c&&e.jsx(P,{title:c,children:e.jsx(_,{fontSize:"small"})})]}),e.jsx(C,{component:"div",variant:"body1",color:r?"text.disabled":"text.secondary",sx:{width:"100%",minHeight:"24px"},children:r?"-":i})]}),b&&e.jsx(ce,{orientation:"vertical",flexItem:!0})]})}A.propTypes={label:t.oneOfType([t.string,t.node]).isRequired,value:t.oneOfType([t.string,t.node]).isRequired,tip:t.oneOfType([t.string,t.node]),divider:t.bool};function je({title:i,children:u=null,mb:c=1.5,mt:b=1.5}){return e.jsxs(R,{className:"section-header",direction:"row",sx:{justifyContent:"space-between",alignItems:"center",flexWrap:"wrap",gap:1,mb:c,mt:b,pb:1},children:[e.jsx(C,{variant:"h3",sx:{fontSize:{xs:"18px",md:"1.09375rem"}},component:"div",children:i}),u]})}je.propTypes={title:t.oneOfType([t.string,t.node]).isRequired,children:t.node,mb:t.number,mt:t.number};const ct={width:24,height:24,body:'<path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M20 11A8.1 8.1 0 0 0 4.5 9M4 5v4h4m-4 4a8.1 8.1 0 0 0 15.5 2m.5 4v-4h-4"/>'},dt=i=>{const u={};return i.forEach(c=>{const b=new Date(c.createdAt).toLocaleDateString();u[b]||(u[b]=[]),u[b]?.push(c)}),u};function ye({eventId:i="",webhookEndpointId:u="",event:c=null}){const{api:b,ws:{useSubscription:r}}=K(),{t:w}=M(),{teamDid:x}=V(),{blocklet:j}=Ge(),{data:l,loadMore:f,loadingMore:g,loading:y,mutate:z}=Te(s=>{const k=s?Math.ceil(s.list.length/15)+1:1;return b.getWebhookAttempts({input:{teamDid:x,input:{eventId:i,webhookId:u},paging:{page:k,pageSize:15}}})},{reloadDeps:[i,u]}),T=l?.list||[],[n,a]=E.useState(null),[m,v]=E.useState(!1),S=dt(T);if(E.useEffect(()=>{!n&&l?.list.length&&a(l.list[0])},[l?.list.length,n]),r(xe.EVENTS.WEBHOOK_ATTEMPT,s=>{z(h=>{if(h.list.find(W=>W.id===s.id)){const W=h.list.map($=>$.id===s.id?{...$,...s}:$);return{...h,list:W}}return s.endpoint=h.list[0]?.endpoint,s.event=h.list[0]?.event,{...h,list:[s,...h.list]}})},[]),y)return e.jsx(F,{});const D=l&&l.list.length<l.paging.total,I=async()=>{n&&(v(!0),await b.retryWebhookAttempt({input:{teamDid:x,eventId:n.event.id,webhookId:u,attemptId:n.id}}).finally(()=>{setTimeout(()=>{v(!1)},1e3)}))},O=s=>{if(s.responseBody&&s.responseBody?.sessionId&&s.responseBody?.projectId&&s.responseBody?.agentId){const h=j?.site?.domainAliases[0]?.value,k=(j.children||[]).find($=>$?.meta?.name==="ai-studio"),W=ot(he(`https://${h}`,k?.mountPoint||"","projects",s.responseBody.projectId,"logs/main"),{sessionId:s.responseBody.sessionId,agentId:s.responseBody.agentId});return e.jsx(B,{sx:{fontSize:20},onClick:()=>window.open(W,"_blank"),children:e.jsx(p,{component:N,icon:Q})})}return null},o=s=>s.status==="pending"?e.jsx(Fe,{color:"warning"}):at(s.responseStatus)?e.jsx(He,{color:"success"}):e.jsx(Ne,{color:"error"}),d=n?.triggeredFrom&&(l?.list||[]).find(s=>s.id===n.triggeredFrom);return e.jsxs(pt,{container:!0,spacing:{xs:0,md:1},sx:{height:1},children:[e.jsx(ee,{size:{xs:12,md:4},sx:{height:1},children:me(Object.keys(S))?e.jsx(C,{sx:{color:"text.secondary"},children:w("webhookEndpoint.waitingForEvents")}):e.jsxs(e.Fragment,{children:[e.jsx(Z,{sx:{maxHeight:"calc(100% - 40px)",py:0,overflowY:"auto"},children:Object.entries(S).map(([s,h])=>e.jsxs(ae.Fragment,{children:[e.jsx(Le,{sx:{p:0},children:s}),h.map(k=>e.jsxs(G,{sx:{cursor:"pointer",px:1},onClick:()=>a(k),selected:n&&n?.id===k?.id,secondaryAction:e.jsx(C,{sx:{color:"text.secondary"},children:U(k.createdAt,"HH:mm:ss")}),children:[e.jsx(Me,{sx:{minWidth:0,mr:1.5},children:o(k)}),e.jsx(Be,{primary:e.jsx(C,{sx:{color:"text.primary"},children:k.event.type})})]},k.id))]},s))}),D&&e.jsx(p,{sx:{display:"flex",justifyContent:"center",alignItems:"center",width:1},children:e.jsx(H,{variant:"text",type:"button",color:"inherit",onClick:f,disabled:g,sx:{color:s=>s.palette.text.disabled},children:w(g?"webhookEndpoint.loadingMore":"webhookEndpoint.loadMore")})})]})}),e.jsxs(ee,{size:{xs:12,md:8},sx:{height:1},children:[n&&e.jsxs(R,{direction:"column",spacing:2,sx:{height:1,overflow:"auto",pl:{xs:0,md:1},mt:{xs:2,md:0},borderLeft:{xs:"none"}},children:[e.jsxs(p,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs(p,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(C,{variant:"h4",children:w(`common.${n.status}`)}),e.jsx(p,{children:O(n)})]}),e.jsxs(p,{sx:{display:"flex",alignItems:"center",gap:1},children:[d&&e.jsx(P,{placement:"left",title:e.jsxs(R,{onClick:()=>a(d),sx:{gap:1,cursor:"pointer",".did-address-text":{color:"common.white"}},children:[e.jsx(de,{showDid:!0,did:n.triggeredBy,cardType:ue.Detailed,infoType:pe.Minimal,sx:{border:0,padding:0,minWidth:0,".MuiTypography-root":{color:"common.white",fontWeight:400}}}),e.jsx(ce,{}),e.jsxs(p,{sx:{display:"flex",flexDirection:"column"},children:[e.jsx(C,{variant:"body2",sx:{color:"primary.main"},children:w("webhookEndpoint.triggeredFrom")}),e.jsxs(p,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(C,{variant:"body2",children:n.id}),e.jsx(B,{onClick:()=>a(d),children:e.jsx(p,{component:N,icon:Q,sx:{fontSize:16,color:"common.white"}})})]})]})]}),slotProps:{tooltip:{sx:{maxWidth:400}}},children:e.jsx(B,{onClick:()=>a(d),children:e.jsx(p,{component:N,icon:Q,sx:{fontSize:16}})})}),e.jsxs(H,{variant:"outlined",color:"primary",size:"small",onClick:I,disabled:m,children:[e.jsx(p,{component:N,icon:ct,sx:{fontSize:16,animation:m?"spin 1s linear infinite":"none",mr:.5}}),w("notification.resend")]})]})]}),e.jsxs(p,{children:[e.jsxs(C,{variant:"h6",children:[w("webhookEndpoint.response")," (",n.responseStatus,")"]}),e.jsx(Y,{language:"json",children:JSON.stringify(n.responseBody,null,2)})]}),e.jsxs(p,{children:[e.jsx(R,{direction:"row",spacing:1,sx:{alignItems:"center"},children:e.jsx(C,{variant:"h6",children:w("webhookEndpoint.request")})}),e.jsx(Y,{language:"json",sx:{margin:0},children:JSON.stringify(n.event,null,2)})]})]}),l?.list.length===0&&c&&e.jsxs(p,{children:[e.jsx(R,{direction:"row",spacing:1,sx:{alignItems:"center"},children:e.jsx(C,{variant:"h6",children:w("webhookEndpoint.eventData")})}),e.jsx(Y,{language:"json",sx:{margin:0},children:JSON.stringify(c.data,null,2)})]})]})]})}ye.propTypes={eventId:t.string,webhookEndpointId:t.string,event:t.shape({type:t.string,data:t.object,request:t.object,requestInfo:t.object})};const pt=oe(ee)`
1
+ import{T as M,H as q,aa as N,N as Y,a9 as ve,ab as Ce,ah as Se}from"./vendor-ux-B7q8W4Pg.js";import{s as Te,k as le,t as Ie}from"./vendor-hooks-BRXKH6Nb.js";import{r as E,a as ae}from"./vendor-react-Dvs43sk9.js";import{j as e,Y as Re,bB as We,$ as ze,ak as p,z as se,T as C,a6 as F,aX as te,R as De,Q as H,b6 as ne,am as P,bd as _,a5 as J,V as Z,S as G,b4 as Oe,U as L,I as B,cm as Ae,bf as Pe,a7 as $e,F as qe,W as t,b1 as R,a3 as ce,c1 as ee,cn as Le,aO as Me,aP as Be,co as Fe,cp as He,cq as Ne,s as oe,aU as Ue,aj as _e,J as Ke,cr as Ve,aZ as Ye,cl as Je,c9 as Qe,ck as Xe}from"./vendor-mui-core-B7zoO8f5.js";import{B as de,a as pe,l as ue}from"./index-DzqNo2lD.js";import{Z as K,c as xe,ao as Ze,a8 as Ge,b8 as Q}from"./index-CuQBOJqN.js";import{u as V}from"./team-Dl23XmaY.js";import{u as et}from"./use-mobile-C_DcJ5SZ.js";import{u as tt,C as X}from"./index.esm-JPZAjt0x.js";import{C as he,a as me,J as ot}from"./vendor-utils-DtY42AM-.js";import{C as st}from"./confirm-C9tgdTJT.js";import{A as nt}from"./actions-Bf4UKTeu.js";import{T as ie}from"./table-tips-BP283GGZ.js";import"./lottie-web-4koyQiv_.js";import"./vendor-arcblock-B7AoUs4o.js";import"./session-Bk6ebojT.js";import"./isURL-Cuto2_sB.js";import"./use-app-logo-7cjs_pn8.js";import"./index-DBs9Ljax.js";const it=i=>{const[u,c]=E.useState(null),[b,r]=E.useState(!0),[w,x]=E.useState(null),j=window.blocklet?.appUrl,l=E.useMemo(()=>{const g={};return u&&(u.sources.forEach(y=>{g[y.did]={source:y,events:[],count:0}}),u.events.forEach(y=>{g[y.source]&&(g[y.source].events.push(y),g[y.source].count+=1)})),g},[u]),f=async()=>{try{if(r(!0),!j)return;const y=await(await fetch(he(j,xe.WELLKNOWN_SERVICE_PATH_PREFIX,"/openevent.json"))).json();c(y),x(null)}catch(g){x(g instanceof Error?g:new Error(String(g)))}finally{r(!1)}};return E.useEffect(()=>{f()},[j]),{openEvent:u,setOpenEvent:c,eventsBySource:l,loading:b,error:w,loadData:f}};function ge({eventsBySource:i,selectedEvents:u,setSelectedEvents:c,error:b=null}){const{t:r}=M(),[w,x]=E.useState({}),j=E.useMemo(()=>{const n={};return Object.entries(i).forEach(([a,{events:m}])=>{const v=m.filter(S=>u[`${S.type}-${S.source}`]).length;n[a]=v}),n},[i,u]),l=E.useMemo(()=>Object.values(j).reduce((n,a)=>n+a,0),[j]),f=E.useMemo(()=>Object.values(i).reduce((n,{events:a})=>n+a.length,0),[i]),g=(n,a)=>{a.stopPropagation(),x({...w,[n]:!w[n]})},y=n=>{const a=`${n.type}-${n.source}`;c(m=>({...m,[a]:!m[a]}))},z=(n,a)=>{const m={};n.forEach(v=>{const S=`${v.type}-${v.source}`;m[S]=!a}),c(v=>({...v,...m}))},T=n=>{const a={};Object.values(i).forEach(({events:m})=>{m.forEach(v=>{const S=`${v.type}-${v.source}`;a[S]=n.target.checked})}),c(a)};return e.jsxs(p,{sx:{width:"100%"},children:[e.jsxs(p,{sx:{display:"flex",alignItems:"center",mb:1,mt:1},children:[e.jsx(ne,{control:e.jsx(J,{onChange:T,checked:l>0&&l===f}),label:e.jsxs(p,{sx:{display:"flex",alignItems:"center",cursor:"pointer"},children:[r("webhookEndpoint.selectAllEvents"),e.jsx(p,{sx:{display:"flex",alignItems:"center"},children:e.jsx(P,{title:r("webhookEndpoint.selectAllEventsTooltip"),placement:"right",children:e.jsx(_,{fontSize:"small",sx:{ml:.5,cursor:"help"}})})})]}),sx:{m:0}}),l>0&&e.jsx(C,{variant:"body2",color:"primary",sx:{ml:"auto"},children:r("webhookEndpoint.selectedEventsCount",{count:l})})]}),e.jsx(p,{sx:{maxHeight:"50vh",overflow:"auto"},children:e.jsx(Z,{disablePadding:!0,sx:{border:"1px solid",borderColor:"divider",borderRadius:"4px"},children:Object.entries(i).map(([n,{source:a,events:m,count:v}],S)=>{const D=j[n]>0,I=j[n]===m.length&&m.length>0,O=w[n];return e.jsxs(ae.Fragment,{children:[e.jsx(G,{sx:{borderBottom:({palette:o})=>S<Object.keys(i).length-1?`1px solid ${o.divider}`:"none",px:2,py:1.5,"&:hover":{bgcolor:"rgba(0, 0, 0, 0.02)"}},children:e.jsxs(p,{sx:{display:"flex",width:"100%",justifyContent:"space-between",alignItems:"center"},onClick:o=>{o.target.closest(".MuiFormControlLabel-root")||g(n,o)},children:[e.jsx(p,{sx:{display:"flex",alignItems:"center"},children:m.length>0&&e.jsx(ne,{control:e.jsx(J,{checked:I,indeterminate:D&&!I,onChange:o=>{o.stopPropagation(),z(m,I)}}),label:e.jsxs(p,{sx:{display:"flex",alignItems:"center",gap:1},children:[a.logo&&e.jsx(Oe,{src:a.logo,sx:{width:24,height:24}}),e.jsx(p,{children:a.title||n}),D&&e.jsx(L,{label:r("webhookEndpoint.selectedCount",{count:j[n]}),size:"small",sx:{mt:"2px",height:"20px",fontSize:"12px",bgcolor:o=>`${o.palette.primary.main}20`,color:"primary.main",fontWeight:500}})]}),sx:{m:0,"& .MuiFormControlLabel-label":{flex:1}}})}),e.jsxs(p,{sx:{display:"flex",alignItems:"center"},children:[e.jsx(C,{variant:"body2",sx:{color:"text.secondary",mr:1},children:r("webhookEndpoint.eventsCount",{count:v})}),m.length>0&&e.jsx(B,{size:"small",edge:"end",children:O?e.jsx(Ae,{}):e.jsx(Pe,{})})]})]})}),m.length>0&&e.jsx($e,{in:O,timeout:"auto",unmountOnExit:!0,children:e.jsx(Z,{disablePadding:!0,sx:{pl:2,pr:2,py:1,bgcolor:"rgba(0, 0, 0, 0.01)"},children:m.map(o=>{const d=`${o.type}-${o.source}`,s=!!u[d];return e.jsx(G,{dense:!0,sx:{py:.75},onClick:()=>y(o),children:e.jsxs(p,{sx:{display:"flex",alignItems:"flex-start",width:"100%"},children:[e.jsx(J,{checked:s,sx:{mr:1}}),e.jsxs(p,{children:[e.jsx(C,{variant:"body1",sx:{cursor:"pointer",color:"text.primary"},children:o.type}),e.jsx(C,{variant:"caption",sx:{color:"text.secondary",display:"block",cursor:"pointer"},children:o.description})]})]})},d)})})})]},n)})})}),b&&e.jsx(qe,{error:!0,sx:{mt:1},children:b})]})}ge.propTypes={eventsBySource:t.objectOf(t.shape({source:t.shape({did:t.string.isRequired,title:t.string,description:t.string,version:t.string,logo:t.string}).isRequired,events:t.arrayOf(t.shape({type:t.string.isRequired,description:t.string.isRequired,source:t.string.isRequired})).isRequired,count:t.number.isRequired})).isRequired,selectedEvents:t.objectOf(t.bool).isRequired,setSelectedEvents:t.func.isRequired,error:t.string};function fe({id:i=null,url:u="",description:c="",enabledEvents:b=[],onSubmit:r,onClose:w=()=>{}}){const{t:x}=M(),[j,l]=E.useState({}),{teamDid:f}=V(),{api:g}=K(),{loading:y,error:z,eventsBySource:T}=it(),{control:n,handleSubmit:a,formState:{errors:m},reset:v,setValue:S,trigger:D}=tt({defaultValues:{url:"",description:""}});E.useEffect(()=>{const o=Object.values(j).some(d=>d);S("selectedEvents",o?"valid":""),D("selectedEvents")},[j,S,D]);const I=()=>{l({}),v(),w()},O=async o=>{const d=Object.keys(j).filter(h=>j[h]),s={url:o.url,description:o.description,enabledEvents:d.map(h=>{const[k,W]=h.split("-");return!k||!W?null:{type:k,source:W}}).filter(Boolean)};try{if(i){const h=await g.updateWebhookEndpoint({input:{teamDid:f,id:i,data:s}});q.success(`${x("webhookEndpoint.updateWebhook")} ${x("webhookEndpoint.success")}`),r(h)}else{const h=await g.createWebhookEndpoint({input:{teamDid:f,input:s}});q.success(`${x("webhookEndpoint.createWebhook")} ${x("webhookEndpoint.success")}`),r(h)}}catch(h){q.error(h?.message)}I()};return E.useEffect(()=>{v({url:u,description:c}),l(b.reduce((o,d)=>(o[`${d.type}-${d.source}`]=!0,o),{}))},[v,l,u,c,b]),e.jsx(Re,{open:!0,onClose:I,maxWidth:"lg",fullWidth:!0,sx:{"& .MuiDialog-paper":{minHeight:600}},children:e.jsxs("form",{onSubmit:a(O),children:[e.jsx(We,{children:x(i?"webhookEndpoint.editWebhookTitle":"webhookEndpoint.createWebhookTitle")}),e.jsx(ze,{children:e.jsxs(p,{sx:{display:"flex",flexDirection:"column",gap:2,mt:2},children:[e.jsx(X,{name:"url",control:n,rules:{required:x("webhookEndpoint.validation.urlRequired"),pattern:{value:/^(http|https):\/\/[^ "]+$/,message:x("webhookEndpoint.validation.urlInvalid")}},render:({field:o})=>e.jsx(se,{...o,label:x("webhookEndpoint.url.label"),fullWidth:!0,error:!!m.url,helperText:m.url?.message})}),e.jsx(X,{name:"description",control:n,rules:{required:x("webhookEndpoint.validation.descriptionRequired")},render:({field:o})=>e.jsx(se,{...o,label:x("webhookEndpoint.description.label"),fullWidth:!0,multiline:!0,minRows:2,maxRows:4,error:!!m.description,helperText:m.description?.message})}),e.jsx(X,{name:"selectedEvents",control:n,rules:{required:x("webhookEndpoint.validation.eventRequired")},render:({field:o})=>e.jsx("input",{type:"hidden",...o})}),!y&&T&&Object.keys(T).length>0&&e.jsx(ge,{eventsBySource:T,selectedEvents:j,setSelectedEvents:l,error:m.selectedEvents?.message}),!y&&(!T||Object.keys(T).length===0)&&e.jsx(C,{sx:{color:"text.secondary"},children:x("webhookEndpoint.noAvailableEvents")}),y&&e.jsx(p,{sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"500px",width:"100%"},children:e.jsx(F,{size:20})}),z&&e.jsx(te,{severity:"error",children:x("webhookEndpoint.loadingError",{message:z?.message})})]})}),e.jsxs(De,{sx:{p:"8px 24px 24px"},children:[e.jsx(H,{onClick:I,children:x("common.cancel")}),e.jsx(H,{type:"submit",variant:"contained",color:"primary",children:x(i?"webhookEndpoint.updateWebhook":"webhookEndpoint.saveWebhook")})]})]})})}fe.propTypes={onSubmit:t.func.isRequired,id:t.string,url:t.string,description:t.string,enabledEvents:t.arrayOf(t.shape({type:t.string.isRequired,source:t.string.isRequired})),onClose:t.func};function be(i){switch(i){case"enabled":return"success";case"disabled":default:return"default"}}const rt=(i="en")=>i==="tw"?"zh":i;function U(i,u="YYYY-MM-DD HH:mm:ss",c="en"){return i?Ze(i).locale(rt(c)).format(u):"-"}function lt(i){return typeof i=="number"?!1:me(i)}function at(i){return i>=200&&i<300}function A({value:i,label:u,tip:c="",divider:b=!1}){const r=lt(i);return e.jsxs(e.Fragment,{children:[e.jsxs(R,{direction:"column",alignItems:"flex-start",children:[e.jsxs(C,{component:"div",variant:"body1",mb:1,color:"text.primary",sx:{fontWeight:500},children:[u,!!c&&e.jsx(P,{title:c,children:e.jsx(_,{fontSize:"small"})})]}),e.jsx(C,{component:"div",variant:"body1",color:r?"text.disabled":"text.secondary",sx:{width:"100%",minHeight:"24px"},children:r?"-":i})]}),b&&e.jsx(ce,{orientation:"vertical",flexItem:!0})]})}A.propTypes={label:t.oneOfType([t.string,t.node]).isRequired,value:t.oneOfType([t.string,t.node]).isRequired,tip:t.oneOfType([t.string,t.node]),divider:t.bool};function je({title:i,children:u=null,mb:c=1.5,mt:b=1.5}){return e.jsxs(R,{className:"section-header",direction:"row",sx:{justifyContent:"space-between",alignItems:"center",flexWrap:"wrap",gap:1,mb:c,mt:b,pb:1},children:[e.jsx(C,{variant:"h3",sx:{fontSize:{xs:"18px",md:"1.09375rem"}},component:"div",children:i}),u]})}je.propTypes={title:t.oneOfType([t.string,t.node]).isRequired,children:t.node,mb:t.number,mt:t.number};const ct={width:24,height:24,body:'<path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M20 11A8.1 8.1 0 0 0 4.5 9M4 5v4h4m-4 4a8.1 8.1 0 0 0 15.5 2m.5 4v-4h-4"/>'},dt=i=>{const u={};return i.forEach(c=>{const b=new Date(c.createdAt).toLocaleDateString();u[b]||(u[b]=[]),u[b]?.push(c)}),u};function ye({eventId:i="",webhookEndpointId:u="",event:c=null}){const{api:b,ws:{useSubscription:r}}=K(),{t:w}=M(),{teamDid:x}=V(),{blocklet:j}=Ge(),{data:l,loadMore:f,loadingMore:g,loading:y,mutate:z}=Te(s=>{const k=s?Math.ceil(s.list.length/15)+1:1;return b.getWebhookAttempts({input:{teamDid:x,input:{eventId:i,webhookId:u},paging:{page:k,pageSize:15}}})},{reloadDeps:[i,u]}),T=l?.list||[],[n,a]=E.useState(null),[m,v]=E.useState(!1),S=dt(T);if(E.useEffect(()=>{!n&&l?.list.length&&a(l.list[0])},[l?.list.length,n]),r(xe.EVENTS.WEBHOOK_ATTEMPT,s=>{z(h=>{if(h.list.find(W=>W.id===s.id)){const W=h.list.map($=>$.id===s.id?{...$,...s}:$);return{...h,list:W}}return s.endpoint=h.list[0]?.endpoint,s.event=h.list[0]?.event,{...h,list:[s,...h.list]}})},[]),y)return e.jsx(F,{});const D=l&&l.list.length<l.paging.total,I=async()=>{n&&(v(!0),await b.retryWebhookAttempt({input:{teamDid:x,eventId:n.event.id,webhookId:u,attemptId:n.id}}).finally(()=>{setTimeout(()=>{v(!1)},1e3)}))},O=s=>{if(s.responseBody&&s.responseBody?.sessionId&&s.responseBody?.projectId&&s.responseBody?.agentId){const h=j?.site?.domainAliases[0]?.value,k=(j.children||[]).find($=>$?.meta?.name==="ai-studio"),W=ot(he(`https://${h}`,k?.mountPoint||"","projects",s.responseBody.projectId,"logs/main"),{sessionId:s.responseBody.sessionId,agentId:s.responseBody.agentId});return e.jsx(B,{sx:{fontSize:20},onClick:()=>window.open(W,"_blank"),children:e.jsx(p,{component:N,icon:Q})})}return null},o=s=>s.status==="pending"?e.jsx(Fe,{color:"warning"}):at(s.responseStatus)?e.jsx(He,{color:"success"}):e.jsx(Ne,{color:"error"}),d=n?.triggeredFrom&&(l?.list||[]).find(s=>s.id===n.triggeredFrom);return e.jsxs(pt,{container:!0,spacing:{xs:0,md:1},sx:{height:1},children:[e.jsx(ee,{size:{xs:12,md:4},sx:{height:1},children:me(Object.keys(S))?e.jsx(C,{sx:{color:"text.secondary"},children:w("webhookEndpoint.waitingForEvents")}):e.jsxs(e.Fragment,{children:[e.jsx(Z,{sx:{maxHeight:"calc(100% - 40px)",py:0,overflowY:"auto"},children:Object.entries(S).map(([s,h])=>e.jsxs(ae.Fragment,{children:[e.jsx(Le,{sx:{p:0},children:s}),h.map(k=>e.jsxs(G,{sx:{cursor:"pointer",px:1},onClick:()=>a(k),selected:n&&n?.id===k?.id,secondaryAction:e.jsx(C,{sx:{color:"text.secondary"},children:U(k.createdAt,"HH:mm:ss")}),children:[e.jsx(Me,{sx:{minWidth:0,mr:1.5},children:o(k)}),e.jsx(Be,{primary:e.jsx(C,{sx:{color:"text.primary"},children:k.event.type})})]},k.id))]},s))}),D&&e.jsx(p,{sx:{display:"flex",justifyContent:"center",alignItems:"center",width:1},children:e.jsx(H,{variant:"text",type:"button",color:"inherit",onClick:f,disabled:g,sx:{color:s=>s.palette.text.disabled},children:w(g?"webhookEndpoint.loadingMore":"webhookEndpoint.loadMore")})})]})}),e.jsxs(ee,{size:{xs:12,md:8},sx:{height:1},children:[n&&e.jsxs(R,{direction:"column",spacing:2,sx:{height:1,overflow:"auto",pl:{xs:0,md:1},mt:{xs:2,md:0},borderLeft:{xs:"none"}},children:[e.jsxs(p,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs(p,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(C,{variant:"h4",children:w(`common.${n.status}`)}),e.jsx(p,{children:O(n)})]}),e.jsxs(p,{sx:{display:"flex",alignItems:"center",gap:1},children:[d&&e.jsx(P,{placement:"left",title:e.jsxs(R,{onClick:()=>a(d),sx:{gap:1,cursor:"pointer",".did-address-text":{color:"common.white"}},children:[e.jsx(de,{showDid:!0,did:n.triggeredBy,cardType:ue.Detailed,infoType:pe.Minimal,sx:{border:0,padding:0,minWidth:0,".MuiTypography-root":{color:"common.white",fontWeight:400}}}),e.jsx(ce,{}),e.jsxs(p,{sx:{display:"flex",flexDirection:"column"},children:[e.jsx(C,{variant:"body2",sx:{color:"primary.main"},children:w("webhookEndpoint.triggeredFrom")}),e.jsxs(p,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(C,{variant:"body2",children:n.id}),e.jsx(B,{onClick:()=>a(d),children:e.jsx(p,{component:N,icon:Q,sx:{fontSize:16,color:"common.white"}})})]})]})]}),slotProps:{tooltip:{sx:{maxWidth:400}}},children:e.jsx(B,{onClick:()=>a(d),children:e.jsx(p,{component:N,icon:Q,sx:{fontSize:16}})})}),e.jsxs(H,{variant:"outlined",color:"primary",size:"small",onClick:I,disabled:m,children:[e.jsx(p,{component:N,icon:ct,sx:{fontSize:16,animation:m?"spin 1s linear infinite":"none",mr:.5}}),w("notification.resend")]})]})]}),e.jsxs(p,{children:[e.jsxs(C,{variant:"h6",children:[w("webhookEndpoint.response")," (",n.responseStatus,")"]}),e.jsx(Y,{language:"json",children:JSON.stringify(n.responseBody,null,2)})]}),e.jsxs(p,{children:[e.jsx(R,{direction:"row",spacing:1,sx:{alignItems:"center"},children:e.jsx(C,{variant:"h6",children:w("webhookEndpoint.request")})}),e.jsx(Y,{language:"json",sx:{margin:0},children:JSON.stringify(n.event,null,2)})]})]}),l?.list.length===0&&c&&e.jsxs(p,{children:[e.jsx(R,{direction:"row",spacing:1,sx:{alignItems:"center"},children:e.jsx(C,{variant:"h6",children:w("webhookEndpoint.eventData")})}),e.jsx(Y,{language:"json",sx:{margin:0},children:JSON.stringify(c.data,null,2)})]})]})]})}ye.propTypes={eventId:t.string,webhookEndpointId:t.string,event:t.shape({type:t.string,data:t.object,request:t.object,requestInfo:t.object})};const pt=oe(ee)`
2
2
  @keyframes spin {
3
3
  to {
4
4
  transform: rotate(360deg);
@@ -1,5 +1,5 @@
1
1
  const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/lottie-react.esm-M5fKy3fg.js","assets/vendor-react-Dvs43sk9.js"])))=>i.map(i=>d[i]);
2
- import{j as e,ak as s,c1 as h,T as k,z as V,bp as G,b6 as U,bq as q,c8 as O,Q as R,at as I,ar as B,c9 as X,ca as J,cb as W,I as H,cc as K,D as Y,aj as Q}from"./vendor-mui-core-B7zoO8f5.js";import{r as j}from"./vendor-react-Dvs43sk9.js";import{p as Z,g as N,u as ee,j as te,e as oe}from"./vendor-hooks-BRXKH6Nb.js";import{a6 as re,R as ie,_ as C}from"./vendor-ux-B7q8W4Pg.js";import{X as se}from"./vendor-utils-DtY42AM-.js";import{getAIKitComponent as ne}from"./index-CJubEPJw.js";import"./lottie-web-4koyQiv_.js";import"./index-BF7bSwjJ.js";import"./vendor-arcblock-B7AoUs4o.js";import"./index-BPy8_fa2.js";import"./index-DRYJ0xIl.js";const T=j.createContext({}),D=()=>j.useContext(T);function ae({children:o,restrictions:f,i18n:d,theme:r}){const[n,b]=Z({loading:!1}),c=i=>b(g=>({...g,loading:i})),x=j.useMemo(()=>({...n,onLoading:c,restrictions:f,i18n:d}),[n]);return e.jsx(re,{theme:r,children:e.jsx(T.Provider,{value:x,children:o})})}const le=["1024x1024","1024x1792","1792x1024"],de=["256x256","512x512","1024x1024"],ce=[{label:"DALL·E 3",value:"dall-e-3"},{label:"DALL·E 2",value:"dall-e-2"}];function pe({onSubmit:o}){const{loading:f,i18n:d}=D(),r=N({model:"dall-e-3",prompt:"",size:"1024x1024",number:1}),n=()=>{const i=JSON.parse(JSON.stringify(r));Object.values(r).every(y=>!!y)&&o(i)},{run:b}=ee(n,{wait:500}),c={width:"100%",pl:1,pr:1},x=r.model==="dall-e-2"?de:le;return e.jsxs(xe,{onSubmit:i=>i.preventDefault(),children:[e.jsx(s,{sx:{flex:1,overflowY:"auto",overflowX:"hidden",m:2,mb:0},children:e.jsxs(h,{container:!0,sx:{gap:2.5},children:[e.jsxs(h,{size:12,children:[e.jsx(k,{gutterBottom:!0,className:"title label",sx:{color:"text.primary"},children:d("aiImagePrompt")}),e.jsx(V,{sx:{width:1,mt:1},size:"small",type:"text",required:!0,placeholder:d("aiImagePromptTip"),multiline:!0,minRows:5,maxRows:6,value:r.prompt??"",onChange:i=>{i.stopPropagation(),r.prompt=i.target.value},slotProps:{htmlInput:{maxLength:1e3}}})]}),e.jsxs(h,{size:12,children:[e.jsx(k,{gutterBottom:!0,className:"title label",sx:{color:"text.primary"},children:`${d("aiImageModel")}`}),e.jsx(G,{row:!0,sx:{".MuiFormControlLabel-label":{fontSize:"12px",color:"text.primary"}},value:r.model,onChange:i=>{r.number=1,r.size="1024x1024",r.model=i.target.value},children:ce.map(i=>e.jsx(U,{value:i.value,control:e.jsx(q,{size:"small"}),label:i.label},i.label))})]}),e.jsxs(h,{size:12,children:[e.jsx(k,{gutterBottom:!0,className:"title label",sx:{color:"text.primary"},children:`${d("aiImageSize")}: ${r.size}`}),e.jsx(h,{container:!0,sx:{gap:2.5,pt:1},children:e.jsx(s,{sx:{flex:1},children:e.jsx(s,{...c,children:e.jsx(O,{size:"small",min:0,max:x.length-1,step:1,value:x.findIndex(i=>i==r.size),onChange:(i,g)=>{r.size=x[g]}})})})})]}),r.model==="dall-e-2"&&e.jsxs(h,{size:12,children:[e.jsx(k,{gutterBottom:!0,className:"title label",sx:{color:"text.primary"},children:`${d("aiImageNumber")}: ${r.number}`}),e.jsx(s,{...c,children:e.jsx(O,{size:"small",defaultValue:1,valueLabelDisplay:"auto",step:1,min:1,max:10,value:r.number,onChange:(i,g)=>{i.stopPropagation(),r.number=Number(g)}})})]})]})}),e.jsx(R,{sx:{m:2,transition:"all 0.3s"},className:"submit-ai",variant:"contained",onClick:b,disabled:f,children:d(f?"aiImageGenerating":"aiImageGenerate")},f?"loading-submit":"submit")]})}const xe=I(s)`
2
+ import{j as e,ak as s,c1 as h,T as k,z as V,bp as G,b6 as U,bq as q,c8 as O,Q as R,at as I,ar as B,c9 as X,ca as J,cb as W,I as H,cc as K,D as Y,aj as Q}from"./vendor-mui-core-B7zoO8f5.js";import{r as j}from"./vendor-react-Dvs43sk9.js";import{p as Z,g as N,u as ee,j as te,e as oe}from"./vendor-hooks-BRXKH6Nb.js";import{a6 as re,R as ie,_ as C}from"./vendor-ux-B7q8W4Pg.js";import{X as se}from"./vendor-utils-DtY42AM-.js";import{getAIKitComponent as ne}from"./index-BxU3q403.js";import"./lottie-web-4koyQiv_.js";import"./index-CuQBOJqN.js";import"./vendor-arcblock-B7AoUs4o.js";import"./index-BPy8_fa2.js";import"./index-DRYJ0xIl.js";const T=j.createContext({}),D=()=>j.useContext(T);function ae({children:o,restrictions:f,i18n:d,theme:r}){const[n,b]=Z({loading:!1}),c=i=>b(g=>({...g,loading:i})),x=j.useMemo(()=>({...n,onLoading:c,restrictions:f,i18n:d}),[n]);return e.jsx(re,{theme:r,children:e.jsx(T.Provider,{value:x,children:o})})}const le=["1024x1024","1024x1792","1792x1024"],de=["256x256","512x512","1024x1024"],ce=[{label:"DALL·E 3",value:"dall-e-3"},{label:"DALL·E 2",value:"dall-e-2"}];function pe({onSubmit:o}){const{loading:f,i18n:d}=D(),r=N({model:"dall-e-3",prompt:"",size:"1024x1024",number:1}),n=()=>{const i=JSON.parse(JSON.stringify(r));Object.values(r).every(y=>!!y)&&o(i)},{run:b}=ee(n,{wait:500}),c={width:"100%",pl:1,pr:1},x=r.model==="dall-e-2"?de:le;return e.jsxs(xe,{onSubmit:i=>i.preventDefault(),children:[e.jsx(s,{sx:{flex:1,overflowY:"auto",overflowX:"hidden",m:2,mb:0},children:e.jsxs(h,{container:!0,sx:{gap:2.5},children:[e.jsxs(h,{size:12,children:[e.jsx(k,{gutterBottom:!0,className:"title label",sx:{color:"text.primary"},children:d("aiImagePrompt")}),e.jsx(V,{sx:{width:1,mt:1},size:"small",type:"text",required:!0,placeholder:d("aiImagePromptTip"),multiline:!0,minRows:5,maxRows:6,value:r.prompt??"",onChange:i=>{i.stopPropagation(),r.prompt=i.target.value},slotProps:{htmlInput:{maxLength:1e3}}})]}),e.jsxs(h,{size:12,children:[e.jsx(k,{gutterBottom:!0,className:"title label",sx:{color:"text.primary"},children:`${d("aiImageModel")}`}),e.jsx(G,{row:!0,sx:{".MuiFormControlLabel-label":{fontSize:"12px",color:"text.primary"}},value:r.model,onChange:i=>{r.number=1,r.size="1024x1024",r.model=i.target.value},children:ce.map(i=>e.jsx(U,{value:i.value,control:e.jsx(q,{size:"small"}),label:i.label},i.label))})]}),e.jsxs(h,{size:12,children:[e.jsx(k,{gutterBottom:!0,className:"title label",sx:{color:"text.primary"},children:`${d("aiImageSize")}: ${r.size}`}),e.jsx(h,{container:!0,sx:{gap:2.5,pt:1},children:e.jsx(s,{sx:{flex:1},children:e.jsx(s,{...c,children:e.jsx(O,{size:"small",min:0,max:x.length-1,step:1,value:x.findIndex(i=>i==r.size),onChange:(i,g)=>{r.size=x[g]}})})})})]}),r.model==="dall-e-2"&&e.jsxs(h,{size:12,children:[e.jsx(k,{gutterBottom:!0,className:"title label",sx:{color:"text.primary"},children:`${d("aiImageNumber")}: ${r.number}`}),e.jsx(s,{...c,children:e.jsx(O,{size:"small",defaultValue:1,valueLabelDisplay:"auto",step:1,min:1,max:10,value:r.number,onChange:(i,g)=>{i.stopPropagation(),r.number=Number(g)}})})]})]})}),e.jsx(R,{sx:{m:2,transition:"all 0.3s"},className:"submit-ai",variant:"contained",onClick:b,disabled:f,children:d(f?"aiImageGenerating":"aiImageGenerate")},f?"loading-submit":"submit")]})}const xe=I(s)`
3
3
  display: flex;
4
4
  flex-direction: column;
5
5
  height: 100%;
@@ -1,4 +1,4 @@
1
- import{r as b}from"./vendor-react-Dvs43sk9.js";import{j as e,y as V,x as G,bb as X,M as Q,ak as d,W as u,a6 as ke,ck as ve,b1 as Z,z as U,b6 as we,a5 as Te,at as P,T as N,cl as Ae,c9 as Ke,aX as Re}from"./vendor-mui-core-B7zoO8f5.js";import{T as D,a5 as B,D as F,G as De,F as ie,N as H,H as Se,ah as Ie,C as Be,ai as $e,ab as Ee,a9 as Ne}from"./vendor-ux-B7q8W4Pg.js";import{f as _e}from"./index-DBs9Ljax.js";import{B as ae,a as re,l as ce}from"./index-DO8dY30H.js";import{r as le}from"./passport-item-Ml3CykE7.js";import{c as L,Z as I,p as Pe,aE as We,a8 as Le,K as z,f as ze}from"./index-BF7bSwjJ.js";import{u as W}from"./team-BVaQVRGX.js";import{T as de}from"./index-MgFhlLet.js";import{C as pe}from"./confirm-Bax75YdO.js";import{R as qe,C as _}from"./vendor-utils-DtY42AM-.js";import{u as Me}from"./session-COCrt-qG.js";import{C as O}from"./click-to-copy-CVpUD4ji.js";import{f as Ue}from"./index-BojVbZw0.js";import{D as Fe}from"./delete-confirm-Db0zAWAY.js";import{P as He}from"./permission-D9Anejwj.js";import{B as Oe}from"./bundle-avatar-CopjjSKq.js";import{W as Ve}from"./did-address-CcsL3-Qm.js";import{A as Ge}from"./actions-Bf4UKTeu.js";import{u as Xe}from"./use-mobile-C_DcJ5SZ.js";import{T as oe}from"./table-tips-BP283GGZ.js";import{q as Qe}from"./vendor-hooks-BRXKH6Nb.js";import"./lottie-web-4koyQiv_.js";import"./util-CmTchaCE.js";import"./base32-BkgeFkJa.js";import"./vendor-arcblock-B7AoUs4o.js";import"./isURL-CH4qUEqk.js";import"./use-app-logo-Cb6MS9by.js";import"./arrow-down.svg-DaFWY5aq.js";import"./vendor-mui-x-Qph0dQcg.js";import"./AdapterDayjs-VDBijwaM.js";function J({value:s}){const{t,locale:n}=D(),i=new Date;return new Date(s)<i?e.jsxs("span",{style:{color:"red"},children:[e.jsx(B,{value:s,locale:n}),`${t("setting.accessKey.expired",{time:""})}`]}):e.jsx(B,{mode:"daysLeft",value:s,locale:n,type:"all"})}J.propTypes={value:u.string.isRequired};function Y({value:s,onChange:t,...n}){const{t:i}=D(),o=b.useMemo(()=>[{value:"signature",title:i("setting.accessKey.signature"),description:i("setting.accessKey.signatureDesc")},{value:"simple",title:i("setting.accessKey.simple"),description:i("setting.accessKey.simpleDesc")}],[i]);return e.jsxs(V,{style:{width:"100%"},variant:"outlined",...n,children:[e.jsx(G,{children:i("setting.accessKey.authType")}),e.jsx(X,{value:s,onChange:t,fullWidth:!0,label:i("setting.accessKey.authType"),children:o.map(c=>e.jsx(Q,{value:c.value,children:e.jsxs(d,{children:[e.jsx("span",{children:c.title}),e.jsx(d,{sx:{maxWidth:510,fontSize:12,color:"#999",whiteSpace:"normal"},children:c.description})]})},c.value))})]})}Y.propTypes={value:u.string.isRequired,onChange:u.func.isRequired};const ee=()=>{const s=L.RBAC_CONFIG.roles.filter(o=>o.passport),{inService:t}=I(),{roles:n}=W(),i=[...s,...t?n:[]];return qe(i,"name").filter(o=>o.name!==L.ROLES.OWNER)};function me(){const{session:s}=Me(),t=ee();return b.useMemo(()=>{if(!s?.user?.role)return[];if(["owner","admin"].includes(s.user.role))return t;const i=t.filter(c=>c.name==="guest");return[...t.filter(c=>c.name!=="guest").filter(c=>s.user.passports.find(g=>g.role===c.name)),...i]},[t,s?.user?.passports,s?.user?.role])}function ue({onCreate:s=()=>{},remark:t=""}){const{api:n}=I(),{teamDid:i}=W(),{t:o}=D(),[c,g]=b.useState(!1),[x,v]=b.useState(null),p=me(),K=()=>{g(!1),v(null)},h=async l=>{const{remark:C,passport:y,authType:a}=l;g(!0);const w=await n.createAccessKey({input:{teamDid:i,remark:C.trim(),passport:y,expireAt:l.expireAt?new Date(l.expireAt).getTime():null,authType:a}}),{data:R}=w;s(R),v(null),g(!1)},m={title:`${o("common.create")} ${o("accessKey")}`,description:(l,C,y)=>e.jsxs(Z,{sx:{gap:3},children:[e.jsx(U,{label:o("setting.accessKey.tip"),autoComplete:"off",variant:"outlined",name:"remark",fullWidth:!0,autoFocus:!0,margin:"dense",value:l.remark,onChange:a=>{C({...l,remark:a.target.value,__disableConfirm:!l.passport||!a.target.value.trim()}),a.target.value.trim()?y(""):y(o("setting.accessKey.remarkInvalid"))},slotProps:{htmlInput:{"data-cy":"remark-input"}}}),e.jsxs(V,{style:{width:"100%"},variant:"outlined",children:[e.jsx(G,{children:o("setting.accessKey.passport")}),e.jsx(X,{"data-cy":"create-access-key-select-passport",value:l.passport,onChange:a=>{const w=a.target.value;y(null),C({...l,passport:w,__disableConfirm:!l.remark||!w})},fullWidth:!0,label:o("setting.accessKey.passport"),disabled:c,children:p.map(a=>e.jsx(Q,{value:a.name,"data-cy":`create-access-key-passport-option-${a.name}`,children:e.jsxs(d,{children:[e.jsx("span",{children:a.title||a.name}),e.jsx(d,{sx:{maxWidth:440,fontSize:12,color:"#999",whiteSpace:"normal",textAlign:"justify"},children:a.description})]})},a.name))})]}),e.jsx(Y,{value:l.authType,onChange:a=>{C({...l,authType:a.target.value})}}),e.jsx(de,{placeholder:o("setting.accessKey.expireTime"),value:l.expireAt,onChange:a=>{C({...l,expireAt:a,__disableConfirm:!l.passport||!l.remark||!a})}})]}),confirm:o("common.confirm"),cancel:o("common.cancel"),color:"primary",params:{remark:t,authType:"signature",__disableConfirm:!t.trim()},onConfirm:h,onCancel:K};return e.jsxs(e.Fragment,{children:[e.jsxs(F,{sx:{color:"common.white"},edge:"end",variant:"contained",color:"primary","data-cy":"add-access-key-btn",onClick:()=>v(m),className:"rule-action",children:[c?e.jsx(ke,{size:16}):e.jsx(ve,{style:{fontSize:16}}),o("common.create")]}),x&&e.jsx(pe,{title:x.title,description:x.description,confirm:x.confirm,color:x.color,cancel:x.cancel,params:x.params,onConfirm:x.onConfirm,onCancel:x.onCancel})]})}ue.propTypes={remark:u.string,onCreate:u.func};function xe({onConfirm:s=()=>{},accessKeyId:t,accessKeySecret:n,hideSecret:i=!0}){const{t:o}=b.useContext(De),[c,g]=b.useState(!1),[x,v]=b.useState(()=>i),p=I(),K=()=>{v(!x)},h=y=>{g(y.target.checked)},m=_(window.location.origin,p?.info?.routing?.adminPath),l=b.useMemo(()=>i?`const Client = require('@blocklet/server-js');
1
+ import{r as b}from"./vendor-react-Dvs43sk9.js";import{j as e,y as V,x as G,bb as X,M as Q,ak as d,W as u,a6 as ke,ck as ve,b1 as Z,z as U,b6 as we,a5 as Te,at as P,T as N,cl as Ae,c9 as Ke,aX as Re}from"./vendor-mui-core-B7zoO8f5.js";import{T as D,a5 as B,D as F,G as De,F as ie,N as H,H as Se,ah as Ie,C as Be,ai as $e,ab as Ee,a9 as Ne}from"./vendor-ux-B7q8W4Pg.js";import{f as _e}from"./index-DBs9Ljax.js";import{B as ae,a as re,l as ce}from"./index-DzqNo2lD.js";import{r as le}from"./passport-item-VXkf3FVk.js";import{c as L,Z as I,p as Pe,aE as We,a8 as Le,K as z,f as ze}from"./index-CuQBOJqN.js";import{u as W}from"./team-Dl23XmaY.js";import{T as de}from"./index-Cd2DJL-w.js";import{C as pe}from"./confirm-C9tgdTJT.js";import{R as qe,C as _}from"./vendor-utils-DtY42AM-.js";import{u as Me}from"./session-Bk6ebojT.js";import{C as O}from"./click-to-copy-CVpUD4ji.js";import{f as Ue}from"./index-BojVbZw0.js";import{D as Fe}from"./delete-confirm-XVeEePxy.js";import{P as He}from"./permission-DeQz9qFD.js";import{B as Oe}from"./bundle-avatar-FLzOZWlh.js";import{W as Ve}from"./did-address-CcsL3-Qm.js";import{A as Ge}from"./actions-Bf4UKTeu.js";import{u as Xe}from"./use-mobile-C_DcJ5SZ.js";import{T as oe}from"./table-tips-BP283GGZ.js";import{q as Qe}from"./vendor-hooks-BRXKH6Nb.js";import"./lottie-web-4koyQiv_.js";import"./util-Ca2jlZN4.js";import"./base32-D7JDMggs.js";import"./vendor-arcblock-B7AoUs4o.js";import"./isURL-Cuto2_sB.js";import"./use-app-logo-7cjs_pn8.js";import"./arrow-down.svg-lBR1lfm2.js";import"./vendor-mui-x-Qph0dQcg.js";import"./AdapterDayjs-VDBijwaM.js";function J({value:s}){const{t,locale:n}=D(),i=new Date;return new Date(s)<i?e.jsxs("span",{style:{color:"red"},children:[e.jsx(B,{value:s,locale:n}),`${t("setting.accessKey.expired",{time:""})}`]}):e.jsx(B,{mode:"daysLeft",value:s,locale:n,type:"all"})}J.propTypes={value:u.string.isRequired};function Y({value:s,onChange:t,...n}){const{t:i}=D(),o=b.useMemo(()=>[{value:"signature",title:i("setting.accessKey.signature"),description:i("setting.accessKey.signatureDesc")},{value:"simple",title:i("setting.accessKey.simple"),description:i("setting.accessKey.simpleDesc")}],[i]);return e.jsxs(V,{style:{width:"100%"},variant:"outlined",...n,children:[e.jsx(G,{children:i("setting.accessKey.authType")}),e.jsx(X,{value:s,onChange:t,fullWidth:!0,label:i("setting.accessKey.authType"),children:o.map(c=>e.jsx(Q,{value:c.value,children:e.jsxs(d,{children:[e.jsx("span",{children:c.title}),e.jsx(d,{sx:{maxWidth:510,fontSize:12,color:"#999",whiteSpace:"normal"},children:c.description})]})},c.value))})]})}Y.propTypes={value:u.string.isRequired,onChange:u.func.isRequired};const ee=()=>{const s=L.RBAC_CONFIG.roles.filter(o=>o.passport),{inService:t}=I(),{roles:n}=W(),i=[...s,...t?n:[]];return qe(i,"name").filter(o=>o.name!==L.ROLES.OWNER)};function me(){const{session:s}=Me(),t=ee();return b.useMemo(()=>{if(!s?.user?.role)return[];if(["owner","admin"].includes(s.user.role))return t;const i=t.filter(c=>c.name==="guest");return[...t.filter(c=>c.name!=="guest").filter(c=>s.user.passports.find(g=>g.role===c.name)),...i]},[t,s?.user?.passports,s?.user?.role])}function ue({onCreate:s=()=>{},remark:t=""}){const{api:n}=I(),{teamDid:i}=W(),{t:o}=D(),[c,g]=b.useState(!1),[x,v]=b.useState(null),p=me(),K=()=>{g(!1),v(null)},h=async l=>{const{remark:C,passport:y,authType:a}=l;g(!0);const w=await n.createAccessKey({input:{teamDid:i,remark:C.trim(),passport:y,expireAt:l.expireAt?new Date(l.expireAt).getTime():null,authType:a}}),{data:R}=w;s(R),v(null),g(!1)},m={title:`${o("common.create")} ${o("accessKey")}`,description:(l,C,y)=>e.jsxs(Z,{sx:{gap:3},children:[e.jsx(U,{label:o("setting.accessKey.tip"),autoComplete:"off",variant:"outlined",name:"remark",fullWidth:!0,autoFocus:!0,margin:"dense",value:l.remark,onChange:a=>{C({...l,remark:a.target.value,__disableConfirm:!l.passport||!a.target.value.trim()}),a.target.value.trim()?y(""):y(o("setting.accessKey.remarkInvalid"))},slotProps:{htmlInput:{"data-cy":"remark-input"}}}),e.jsxs(V,{style:{width:"100%"},variant:"outlined",children:[e.jsx(G,{children:o("setting.accessKey.passport")}),e.jsx(X,{"data-cy":"create-access-key-select-passport",value:l.passport,onChange:a=>{const w=a.target.value;y(null),C({...l,passport:w,__disableConfirm:!l.remark||!w})},fullWidth:!0,label:o("setting.accessKey.passport"),disabled:c,children:p.map(a=>e.jsx(Q,{value:a.name,"data-cy":`create-access-key-passport-option-${a.name}`,children:e.jsxs(d,{children:[e.jsx("span",{children:a.title||a.name}),e.jsx(d,{sx:{maxWidth:440,fontSize:12,color:"#999",whiteSpace:"normal",textAlign:"justify"},children:a.description})]})},a.name))})]}),e.jsx(Y,{value:l.authType,onChange:a=>{C({...l,authType:a.target.value})}}),e.jsx(de,{placeholder:o("setting.accessKey.expireTime"),value:l.expireAt,onChange:a=>{C({...l,expireAt:a,__disableConfirm:!l.passport||!l.remark||!a})}})]}),confirm:o("common.confirm"),cancel:o("common.cancel"),color:"primary",params:{remark:t,authType:"signature",__disableConfirm:!t.trim()},onConfirm:h,onCancel:K};return e.jsxs(e.Fragment,{children:[e.jsxs(F,{sx:{color:"common.white"},edge:"end",variant:"contained",color:"primary","data-cy":"add-access-key-btn",onClick:()=>v(m),className:"rule-action",children:[c?e.jsx(ke,{size:16}):e.jsx(ve,{style:{fontSize:16}}),o("common.create")]}),x&&e.jsx(pe,{title:x.title,description:x.description,confirm:x.confirm,color:x.color,cancel:x.cancel,params:x.params,onConfirm:x.onConfirm,onCancel:x.onCancel})]})}ue.propTypes={remark:u.string,onCreate:u.func};function xe({onConfirm:s=()=>{},accessKeyId:t,accessKeySecret:n,hideSecret:i=!0}){const{t:o}=b.useContext(De),[c,g]=b.useState(!1),[x,v]=b.useState(()=>i),p=I(),K=()=>{v(!x)},h=y=>{g(y.target.checked)},m=_(window.location.origin,p?.info?.routing?.adminPath),l=b.useMemo(()=>i?`const Client = require('@blocklet/server-js');
2
2
  const ensureServerEndpoint = require('@abtnode/util/lib/ensure-server-endpoint');
3
3
  const { joinURL } = require('ufo');
4
4
 
@@ -1,4 +1,4 @@
1
- import{g as Wt,r as v}from"./vendor-react-Dvs43sk9.js";import{j as e,ak as y,z as Q,b6 as me,be as Ke,y as V,am as ut,d1 as Bt,bm as Kt,at as ae,b1 as mt,W as h,T as ee,U as Ge,d2 as pt,b5 as qe,a5 as Me,Q as Fe,d3 as Je,aN as Ue,a6 as ft,D as ht,d4 as qt,ad as xt,d5 as Mt,d6 as Ut,c1 as st,n as Ht,x as $t,bb as Vt,M as it,cz as Gt,I as Jt,d7 as Yt}from"./vendor-mui-core-B7zoO8f5.js";import{A as gt,J as Xt,C as Qt,e as le,F as Zt,a4 as je}from"./vendor-utils-DtY42AM-.js";import{T as te,H as M,D as ce,G as en,L as bt,ak as tn,aJ as nn,y as jt,$ as vt,ab as yt,aK as Oe,F as St,a5 as sn,ah as an}from"./vendor-ux-B7q8W4Pg.js";import{aF as rn,Z as Ye,a8 as Ct,aU as Rt,M as _e,c as _,ao as Z,p as on,aO as at}from"./index-BF7bSwjJ.js";import{g as ye,b as $,a as se}from"./vendor-hooks-BRXKH6Nb.js";import{u as wt,C as Y}from"./index.esm-JPZAjt0x.js";import{i as He}from"./isURL-CH4qUEqk.js";import{S as X}from"./section-Dq8SB7lh.js";import{A as ln,a as cn,b as dn}from"./collapse-C-BNkgS6.js";import{S as Se}from"./shorten-label-BHlFrl9P.js";import{v as Tt}from"./index-Bzij4iIk.js";import{R as Nt,A as un,S as mn,a as pn,B as fn}from"./list-u8QyXkOA.js";import{j as hn,c as xn,N as gn}from"./team-BVaQVRGX.js";import{W as bn}from"./did-address-CcsL3-Qm.js";import{p as It}from"./util-CmTchaCE.js";import{D as jn,g as vn}from"./traffic-CMbIGtyi.js";import{B as Et}from"./bundle-avatar-CopjjSKq.js";import{u as yn}from"./use-mobile-C_DcJ5SZ.js";import"./lottie-web-4koyQiv_.js";import"./vendor-arcblock-B7AoUs4o.js";import"./required-CobBjKC9.js";import"./server-logo-notext.svg-CKQB0tIp.js";import"./index-DO8dY30H.js";import"./session-COCrt-qG.js";import"./use-app-logo-Cb6MS9by.js";import"./base32-BkgeFkJa.js";import"./useAsyncRetry-D4-sRZN-.js";import"./useAsync-BrMo9m7W.js";import"./iframe-CZx2enRR.js";import"./index-DQmcrxe_.js";import"./index-DBs9Ljax.js";import"./base-chart-DZz4r8-E.js";import"./index-DT3k66ox.js";import"./vendor-mui-x-Qph0dQcg.js";import"./AdapterDayjs-VDBijwaM.js";var Te={exports:{}},Ne={exports:{}},Ie={exports:{}},rt;function Sn(){return rt||(rt=1,function(n,s){Object.defineProperty(s,"__esModule",{value:!0}),s.default=t;function t(r){return r==null}n.exports=s.default,n.exports.default=s.default}(Ie,Ie.exports)),Ie.exports}var ot;function Cn(){return ot||(ot=1,function(n,s){Object.defineProperty(s,"__esModule",{value:!0}),s.default=u;var t=o(rn()),r=o(Sn());function o(p){return p&&p.__esModule?p:{default:p}}var l=/^(?:[-+]?(?:0|[1-9][0-9]*))$/,b=/^[-+]?[0-9]+$/;function u(p,i){(0,t.default)(p),i=i||{};var N=i.allow_leading_zeroes===!1?l:b,I=!i.hasOwnProperty("min")||(0,r.default)(i.min)||p>=i.min,S=!i.hasOwnProperty("max")||(0,r.default)(i.max)||p<=i.max,j=!i.hasOwnProperty("lt")||(0,r.default)(i.lt)||p<i.lt,E=!i.hasOwnProperty("gt")||(0,r.default)(i.gt)||p>i.gt;return N.test(p)&&I&&S&&j&&E}n.exports=s.default,n.exports.default=s.default}(Ne,Ne.exports)),Ne.exports}var lt;function Rn(){return lt||(lt=1,function(n,s){Object.defineProperty(s,"__esModule",{value:!0}),s.default=o;var t=r(Cn());function r(l){return l&&l.__esModule?l:{default:l}}function o(l){return(0,t.default)(l,{allow_leading_zeroes:!1,min:0,max:65535})}n.exports=s.default,n.exports.default=s.default}(Te,Te.exports)),Te.exports}var wn=Rn();const Tn=Wt(wn),ze={enabled:!1,secure:!1,from:"",host:"",port:"",user:"",password:"",companyName:"",companyLink:"",companyAddress:"",supportEmail:""};function Nn(){const{api:n}=Ye(),{blocklet:s}=Ct(),{t}=te(),{confirmApi:r,confirmHolder:o}=Rt(),l=s?.meta?.did,b=Object.assign({...ze},s?.settings?.notification?.email||{}),{handleSubmit:u,control:p,formState:i,watch:N,reset:I}=wt({defaultValues:gt(b,Object.keys(ze))}),S=ye({testReceiver:"",testReceiverError:""}),j=N("enabled"),E=$(async(a,T,k=!0)=>{try{const{blocklet:D}=await n.configNotification({input:{did:l,notification:JSON.stringify({email:a})}}),re=Object.assign({...ze},D?.settings?.notification?.email||{});I(re),k&&M.success(t("oauth.saveSuccess"))}catch(D){if(k)M.error(D.message||t("oauth.saveFailed"));else throw D}}),G=$(async(a,T,k)=>{try{i.isDirty&&await E(a,T,!1),await n.sendEmail({input:{did:l,receiver:k,email:JSON.stringify({body:"Your SMTP configuration is correct!",title:"Test email",type:"notification"})}}),M.success(t("notification.email.testSuccess"))}catch(D){M.error(D.message||t("notification.email.testfailed"))}}),z=$((a,T)=>{S.testReceiver="",S.testReceiverError="",r.open({title:t("notification.email.testSendEmail"),content:()=>e.jsx(y,{sx:{width:"300px"},children:e.jsx(Q,{sx:{mt:1},fullWidth:!0,name:"testReceiver",label:t("notification.email.inputTestReceiver"),value:S.testReceiver,onChange:k=>{S.testReceiver=k.target.value},error:!!S.testReceiverError,helperText:S.testReceiverError||" "})}),confirmButtonText:t("common.confirm"),cancelButtonText:t("common.cancel"),async onConfirm(k){const D=S.testReceiver?.trim();if(!D){S.testReceiverError=t("notification.email.receiverRequired");return}if(!_e(D)){S.testReceiverError=t("notification.email.receiverInvalid");return}S.testReceiverError="",await G(a,T,D),k()}})}),F=$(a=>{const T=a?.trim();return T?_e(T)?!0:t("notification.email.fromInvalid"):t("notification.email.fromRequired")}),B=$(a=>{const T=a?.trim();return T?He(T,{require_host:!1,protocols:[]})?!0:t("notification.email.hostInvalid"):t("notification.email.hostRequired")}),R=$(a=>a?Tn(a)?!0:t("notification.email.portInvalid"):t("notification.email.portRequired")),K=$(a=>a?.trim()?!0:t("notification.email.userRequired")),q=$(a=>a?.trim()?!0:t("notification.email.passwordRequired")),f=$(a=>a?.trim()&&!He(a,{protocols:["http","https"],require_protocol:!0})?t("notification.email.linkInvalid"):!0),w=$(a=>a?.trim()&&!_e(a)?t("notification.email.emailInvalid"):!0),C=$(()=>!0);return e.jsxs(y,{children:[e.jsxs(In,{component:"form",onSubmit:u(E),disabled:!0,sx:{".section-left":{width:"160px"}},children:[e.jsx(X,{title:t("notification.email.enable"),my:2.5,children:e.jsx(Y,{name:"enabled",control:p,render:({field:a})=>e.jsx(me,{control:e.jsx(Ke,{checked:a.value,...a})})})}),e.jsx(X,{title:t("notification.email.from"),children:e.jsx(Y,{name:"from",control:p,rules:{validate:j?F:C},render:({field:a})=>e.jsx(V,{fullWidth:!0,children:e.jsx(Q,{...a,size:"small",required:!0,label:t("notification.email.from"),error:!!i.errors[a.name],helperText:i.errors[a.name]?.message||" ",disabled:!j})})})}),e.jsx(X,{title:t("notification.email.host"),children:e.jsx(Y,{name:"host",control:p,rules:{validate:j?B:C},render:({field:a})=>e.jsx(V,{fullWidth:!0,children:e.jsx(Q,{...a,size:"small",required:!0,error:!!i.errors[a.name],label:t("notification.email.host"),helperText:i.errors[a.name]?.message||" ",disabled:!j})})})}),e.jsx(X,{title:t("notification.email.port"),children:e.jsx(Y,{name:"port",control:p,rules:{validate:j?R:C},render:({field:a})=>e.jsx(V,{fullWidth:!0,children:e.jsx(Q,{...a,size:"small",required:!0,type:"number",error:!!i.errors[a.name],label:t("notification.email.port"),helperText:i.errors[a.name]?.message||" ",disabled:!j})})})}),e.jsx(X,{title:t("notification.email.user"),children:e.jsx(Y,{name:"user",control:p,rules:{validate:j?K:C},render:({field:a})=>e.jsx(V,{fullWidth:!0,children:e.jsx(Q,{...a,size:"small",required:!0,error:!!i.errors[a.name],label:t("notification.email.user"),helperText:i.errors[a.name]?.message||" ",disabled:!j})})})}),e.jsx(X,{title:t("notification.email.password"),children:e.jsx(Y,{name:"password",control:p,rules:{validate:j?q:C},render:({field:a})=>e.jsx(V,{fullWidth:!0,children:e.jsx(Q,{...a,size:"small",required:!0,type:"password",error:!!i.errors[a.name],label:t("notification.email.password"),helperText:i.errors[a.name]?.message||" ",disabled:!j})})})}),e.jsx(X,{title:t("notification.email.secure"),children:e.jsx(Y,{name:"secure",control:p,rules:{validate:C},render:({field:a})=>e.jsx(V,{fullWidth:!0,children:e.jsx(me,{control:e.jsx(Ke,{checked:a.value,...a,disabled:!j})})})})}),e.jsxs(ln,{children:[e.jsxs(cn,{expandIcon:e.jsx(Kt,{fontSize:"small"}),"aria-controls":"panel1-content",id:"panel1-header",children:[t("notification.email.signature"),e.jsx(ut,{title:t("notification.email.signatureTooltip"),children:e.jsx(Bt,{fontSize:"small",sx:{ml:1,cursor:"help"}})})]}),e.jsxs(dn,{children:[e.jsx(X,{title:t("notification.email.companyName"),children:e.jsx(Y,{name:"companyName",control:p,rules:{validate:C},render:({field:a})=>e.jsx(V,{fullWidth:!0,children:e.jsx(Q,{...a,size:"small",error:!!i.errors[a.name],label:t("notification.email.companyName"),helperText:i.errors[a.name]?.message||" ",disabled:!j})})})}),e.jsx(X,{title:t("notification.email.companyLink"),children:e.jsx(Y,{name:"companyLink",control:p,rules:{validate:j?f:C},render:({field:a})=>e.jsx(V,{fullWidth:!0,children:e.jsx(Q,{...a,size:"small",error:!!i.errors[a.name],label:t("notification.email.companyLink"),helperText:i.errors[a.name]?.message||" ",disabled:!j})})})}),e.jsx(X,{title:t("notification.email.companyAddress"),children:e.jsx(Y,{name:"companyAddress",control:p,rules:{validate:C},render:({field:a})=>e.jsx(V,{fullWidth:!0,children:e.jsx(Q,{...a,size:"small",error:!!i.errors[a.name],label:t("notification.email.companyAddress"),helperText:i.errors[a.name]?.message||" ",disabled:!j})})})}),e.jsx(X,{title:t("notification.email.supportEmail"),children:e.jsx(Y,{name:"supportEmail",control:p,rules:{validate:j?w:C},render:({field:a})=>e.jsx(V,{fullWidth:!0,children:e.jsx(Q,{...a,size:"small",type:"email",error:!!i.errors[a.name],label:t("notification.email.supportEmail"),helperText:i.errors[a.name]?.message||" ",disabled:!j})})})})]})]}),e.jsxs(y,{sx:{display:"flex",justifyContent:"flex-end",gap:2,mt:3},children:[e.jsx(ce,{variant:"outlined",color:"warning",onClick:u(z),disabled:!j,children:t("oauth.runTest")}),e.jsx(ce,{type:"submit",variant:"contained",disabled:!i.isDirty,children:t("oauth.save")})]})]}),o]})}const In=ae(mt)``,We={enabled:!1,endpoint:"",did:void 0,pushPath:void 0};function En(){const{api:n}=Ye(),{blocklet:s}=Ct(),{t}=te(),{confirmApi:r,confirmHolder:o}=Rt(),l=s?.meta?.did,b=Object.assign({...We},s?.settings?.notification?.pushKit||{}),{handleSubmit:u,control:p,formState:i,watch:N,reset:I}=wt({defaultValues:gt(b,Object.keys(We))}),S=ye({testReceiver:"",testReceiverError:""}),j=N("enabled"),E=$(async(R,K,q=!0)=>{try{const{blocklet:f}=await n.configNotification({input:{did:l,notification:JSON.stringify({pushKit:R})}}),w=Object.assign({...We},f?.settings?.notification?.pushKit||{});I(w),q&&M.success(t("oauth.saveSuccess"))}catch(f){if(q)M.error(f.message||t("oauth.saveFailed"));else throw f}}),G=$(async(R,K)=>{try{i.isDirty&&await E(R,K,!1);const q=(s?.configs||[]).find(C=>C.key==="BLOCKLET_APP_URL")?.value,f=Xt(Qt(q,_.WELLKNOWN_SERVICE_PATH_PREFIX,"/blocklet/logo"),{v:s?.meta?.version,t:new Date(s?.updatedAt||0).getTime()}),w={type:"passthrough",passthroughType:"messageStatus",data:{message:{title:"Test push-kit notification",body:"This is message from push-kit config test",sender:{did:s?.appDid,fullName:s?.meta?.title,avatar:f}}}};await n.sendPush({input:{did:l,receiver:S.testReceiver,notification:JSON.stringify(w)}}),M.success(t("notification.pushKit.testSuccess"))}catch(q){M.error(q.message||t("notification.pushKit.testfailed"))}}),z=$((R,K)=>{S.testReceiverError="",r.open({title:t("notification.pushKit.testSend"),content:()=>e.jsx(y,{sx:{width:"450px",maxWidth:"100%"},children:e.jsx(Q,{sx:{mt:1},fullWidth:!0,name:"testReceiver",label:t("notification.pushKit.inputTestReceiver"),value:S.testReceiver,onChange:q=>{S.testReceiver=q.target.value},error:!!S.testReceiverError,helperText:S.testReceiverError||" "})}),confirmButtonText:t("common.confirm"),cancelButtonText:t("common.cancel"),async onConfirm(q){if(!S.testReceiver?.trim()){S.testReceiverError=t("notification.pushKit.receiverRequired");return}S.testReceiverError="",await G(R,K),q()}})}),F=$(R=>{const K=R?.trim();return K?He(K)?!0:t("notification.pushKit.endpointInvalid"):t("notification.pushKit.endpointRequired")}),B=$(()=>!0);return e.jsxs(y,{children:[e.jsxs(An,{component:"form",onSubmit:u(E),disabled:!0,sx:{".section-left":{width:"160px"}},children:[e.jsx(X,{title:t("notification.pushKit.enable"),my:2.5,children:e.jsx(Y,{name:"enabled",control:p,render:({field:R})=>e.jsx(me,{control:e.jsx(Ke,{checked:R.value,...R})})})}),e.jsx(X,{title:t("notification.pushKit.endpoint"),children:e.jsx(Y,{name:"endpoint",control:p,rules:{validate:j?F:B},render:({field:R})=>e.jsx(V,{fullWidth:!0,children:e.jsx(Q,{...R,size:"small",required:!0,label:t("notification.pushKit.endpoint"),error:!!i.errors[R.name],helperText:i.errors[R.name]?.message||" ",disabled:!j})})})}),e.jsxs(X,{title:t("notification.pushKit.customOptions"),children:[e.jsx(Y,{name:"did",control:p,render:({field:R})=>e.jsx(V,{fullWidth:!0,children:e.jsx(Q,{...R,size:"small",label:t("notification.pushKit.did"),error:!!i.errors[R.name],helperText:i.errors[R.name]?.message||" ",disabled:!j})})}),e.jsx(Y,{name:"pushPath",control:p,render:({field:R})=>e.jsx(V,{fullWidth:!0,children:e.jsx(Q,{...R,size:"small",label:t("notification.pushKit.pushPath"),error:!!i.errors[R.name],helperText:i.errors[R.name]?.message||" ",disabled:!j})})})]}),e.jsxs(y,{sx:{display:"flex",justifyContent:"flex-end",gap:2,mt:3},children:[e.jsx(ce,{variant:"outlined",color:"warning",onClick:u(z),disabled:!j,children:t("oauth.runTest")}),e.jsx(ce,{type:"submit",variant:"contained",disabled:!i.isDirty,children:t("oauth.save")})]})]}),o]})}const An=ae(mt)``,ct=[{label:e.jsx(y,{sx:{textAlign:"center",width:"100%"},children:"Email"}),value:"email"},{label:e.jsx(y,{sx:{textAlign:"center",width:"100%"},children:"Push Kit"}),value:"pushKit"}];function On(){const[n,s]=v.useState(ct[0].value),{locale:t}=v.useContext(en),r=se(()=>({email:e.jsx(Nn,{}),pushKit:e.jsx(En,{})}),[t]),o=v.useMemo(()=>({padding:"10px 0"}),[]);return e.jsxs(y,{children:[e.jsx(bt,{tabs:ct,current:n,onChange:s}),e.jsx(y,{style:o,children:r[n]})]})}const At=v.createContext({}),{Provider:kn,Consumer:Ws}=At;function Dn({children:n,blocklet:s=""}){const{api:t,inService:r,ws:{useSubscription:o}}=Ye(),[l,b]=v.useState([]),[u,p]=v.useState({total:0,pageSize:20,pageCount:0,page:1}),i=se(()=>s.meta?.did,[s]),[N,I]=v.useState([]),[S,j]=v.useState({}),E=se(()=>l.length?new Set(l.map(f=>f.id)):new Set,[l]),G=async({page:f=1,pageSize:w=20,...C}={})=>{if(!i)return[];try{const a={paging:{page:f,pageSize:w},...C,teamDid:i,dateRange:C.dateRange?[Z(C.dateRange[0]).toISOString(),Z(C.dateRange[1]).toISOString()]:void 0},{dids:T,...k}=a;let D="";T&&T.includes("system")&&(D="system");const re=T?T.filter(pe=>pe!=="system"):[],ue={...k,source:D,componentDids:re},oe=await t.getNotificationSendLog({input:ue});return j(ue),b(oe.list),p(oe.paging),oe.list}catch(a){return M.error(a.message),[]}},z=async()=>{const f=await t.getNotificationComponents({input:{teamDid:i}});I(f.componentDids)},F=v.useCallback(f=>{const w=s.children.find(C=>C.meta?.did===f);if(w)return w.ancestors=[s],w},[s]),B=async({notificationId:f,receivers:w,channels:C,...a})=>{await t.resendNotification({input:{teamDid:i,notificationId:f,receivers:w,channels:C.map(T=>T==="wallet"?_.NOTIFICATION_SEND_CHANNEL.WALLET:T==="pushKit"?_.NOTIFICATION_SEND_CHANNEL.PUSH:T),...a}})},R=v.useCallback(async f=>(await t.getUser({input:{teamDid:i,user:{did:f}}})).user,[t,i]),K=v.useCallback(async({page:f=1,pageSize:w=20,...C}={})=>{try{const a={paging:{page:f,pageSize:w},...C,userName:C.searchText||"",teamDid:i,dateRange:C.dateRange?[Z(C.dateRange[0]).toISOString(),Z(C.dateRange[1]).toISOString()]:void 0};return await t.getReceivers({input:a})}catch(a){throw M.error(a.message),a}},[t,i]);v.useEffect(()=>{i&&z()},[i]),o(_.EVENTS.NOTIFICATION_BLOCKLET_UPDATE,f=>{E.has(f.notificationId)&&G(S)},[E,S]),o(_.EVENTS.NOTIFICATION_BLOCKLET_CREATE,f=>{E.has(f.id)||G(S)},[E,S]);const q={fetch:G,data:l,paging:u,blocklet:s,getComponent:F,resendNotification:B,getUser:R,componentDids:N,getReceivers:K,inService:r,teamDid:i};return e.jsx(kn,{value:{notificationRecords:q},children:n})}function Xe(){const{notificationRecords:n}=v.useContext(At);return n}Ce.propTypes={severity:h.oneOf(Object.values(["info","success","error","warning"])).isRequired};const Ln={info:"primary",success:"success",error:"error",warning:"warning"};function Ce({severity:n="info"}){return e.jsx(tn,{type:Ln[n],children:n})}const Pn=(n,s,t="")=>{if(!t||!s)return"";switch(t){case _.NOTIFICATION_SEND_FAILED_REASON.USER_DISABLED:return n("notification.sendStatus.reason.disabled",{channel:s});case _.NOTIFICATION_SEND_FAILED_REASON.CHANNEL_UNAVAILABLE:return n("notification.sendStatus.reason.unavailable",{channel:s});case _.NOTIFICATION_SEND_FAILED_REASON.CHANNEL_DISABLED:return n("notification.sendStatus.reason.notSent",{channel:s});case _.NOTIFICATION_SEND_FAILED_REASON.NOT_ONLINE:return n("notification.sendStatus.reason.offline");default:return t}};function Ot(n,s,t={}){const{status:r,updatedAt:o,reason:l="",channel:b="wallet"}=t,u=o?n("notification.sendStatus.sentTime",{date:on(o,s)}):"",p=Pn(n,b,l);return r===_.NOTIFICATION_SEND_STATUS.FAILED?{status:"failed",title:n("notification.sendStatus.failed"),sentTime:u,reason:p}:r===_.NOTIFICATION_SEND_STATUS.SENT?{status:"success",title:n("notification.sendStatus.success"),sentTime:u}:{status:"pending",title:n("notification.sendStatus.pending"),reason:p,sentTime:u}}const $e={pending:"#aaaaaa",success:"#34BE74",failed:"#D0021B"},Ve=["wallet","pushKit","email"],dt=["info","success","error","warning"],kt=n=>{const{settings:s}=n;return s?.notification?.email?.enabled},Dt=n=>{const{settings:s}=n;return s?.notification?.pushKit?.enabled},Fn=(n,s)=>{const t=le(s,"extra.notifications.email",!0);return{available:kt(n),enabled:t}},_n=(n,s)=>{const t=le(s,"extra.notifications.push",!0);return{available:Dt(n),enabled:t}},zn=n=>({enabled:le(n,"extra.notifications.wallet",!0)}),Wn=n=>({enabled:le(n,"extra.webhooks",[]).length>0}),Ee=(n=3)=>new Promise(s=>{setTimeout(()=>{s()},n*1e3)}),Bn=(n,s)=>s==="wallet"||s==="webhook"?[{channel:s,type:"enabled",pass:n("notification.sendStatus.reason.enabled",{channel:s}),fail:n("notification.sendStatus.reason.disabled",{channel:s})}]:s==="pushKit"||s==="email"?[{channel:s,type:"available",pass:n("notification.sendStatus.reason.available",{channel:s}),fail:n("notification.sendStatus.reason.unavailable",{channel:s})},{channel:s,type:"enabled",pass:n("notification.sendStatus.reason.enabled",{channel:s}),fail:n("notification.sendStatus.reason.disabled",{channel:s})}]:[],Ae=(n=[])=>{const s=Z().startOf("day");return n.filter(t=>Z(t.sendAt).isSame(s,"day")).length},Kn=(n,s="")=>{if(s&&Ve.includes(s)){const l=`${s}SendRecord`,b=le(n,l,[]);return Ae(b)}const t=le(n,"webhook",{}),r=Object.keys(t??{})??[];if(s&&r.includes(s)){const l=t[s]??[];return Ae(l)}const o={};return Ve.forEach(l=>{const b=`${l}SendRecord`,u=le(n,b,[]),p=Ae(u);o[l]=p}),r.length>0&&r.forEach(l=>{const b=t[l]??[],u=Ae(b);o[l]=u}),o},ke=(n,s,t)=>{if(!Array.isArray(n))throw new Error("Invalid filterList or index");return n[t].splice(s,1),n},De=(n,s)=>{if(!Array.isArray(s))throw new Error("filters must be an array");return s.length?!s.includes(n):!1},qn=n=>{switch(n){case _.NOTIFICATION_SEND_CHANNEL.WALLET:return"Wallet";case _.NOTIFICATION_SEND_CHANNEL.PUSH:return"Push Kit";case _.NOTIFICATION_SEND_CHANNEL.EMAIL:return"Email";case _.NOTIFICATION_SEND_CHANNEL.WEBHOOK:return"Webhook";default:return""}},Lt=()=>({components:{MUIDataTableFilter:{styleOverrides:{header:{marginBottom:0,p:{margin:0}},root:{"& .MuiGrid-container":{marginTop:0,"& .MuiGrid-item":{paddingTop:0}}}}},MuiPopover:{styleOverrides:{root:{"&.MuiPopover-root":{"& .MuiPaper-root:has(.filter-container)":{width:"420px"}}}}}}});function de({config:n,enableTooltip:s=!0,showTitle:t=!1,children:r=null}){const{status:o,title:l="",sentTime:b="",reason:u=""}=n,p=[l,u].filter(Boolean).join(", ");return e.jsx(ut,{title:s?e.jsxs(e.Fragment,{children:[e.jsx(ee,{color:"inherit",sx:{fontSize:12},children:p}),e.jsx("span",{children:b})]}):null,arrow:!0,placement:"top",children:e.jsxs(y,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"4px"},children:[e.jsxs(y,{sx:{position:"relative",minHeight:14,minWidth:14,display:"flex",alignItems:"center",justifyContent:"center"},children:[e.jsx(y,{style:{opacity:.15},sx:{position:"absolute",width:"100%",height:"100%",borderRadius:"50%",bgcolor:$e[o]}}),e.jsx(y,{sx:{position:"absolute",width:"55%",height:"55%",borderRadius:"50%",bgcolor:$e[o]}})]}),e.jsx(ee,{color:"inherit",sx:{fontSize:12},children:t?l:r})]})})}de.propTypes={config:h.object.isRequired,enableTooltip:h.bool,showTitle:h.bool,children:h.node};Le.propTypes={list:h.array.isRequired,label:h.string.isRequired,onDelete:h.func};function Le({list:n,label:s,onDelete:t=()=>{}}){const{t:r,locale:o}=te();return e.jsxs(y,{sx:{display:"flex",gap:1,alignItems:"center"},children:[e.jsxs(ee,{children:[s,": "]}),n.map(l=>{const b=Ot(r,o,{status:l});return e.jsx(Ge,{size:"small",label:e.jsx(y,{sx:{display:"flex",alignItems:"center",gap:"4px"},children:e.jsx(de,{config:b,enableTooltip:!1,children:b.title})}),onDelete:u=>t(u,l)},l)})]})}Qe.propTypes={filterList:h.array.isRequired,onChange:h.func.isRequired,index:h.number.isRequired,column:h.object.isRequired,filterValues:h.array.isRequired,label:h.string.isRequired,renderLabel:h.func.isRequired};function Qe({filterList:n,onChange:s,index:t,column:r,filterValues:o,label:l,renderLabel:b}){return e.jsxs(V,{className:"filter-container",children:[e.jsx(pt,{component:"legend",children:l}),e.jsx(qe,{row:!0,children:o.map(u=>e.jsx(me,{control:e.jsx(Me,{checked:n[t].indexOf(u.value??u)>-1,onChange:p=>{const i=[...n];p.target.checked?i[t]=[...i[t],u.value??u]:i[t]=i[t].filter(N=>N!==(u.value??u)),s(i[t],t,r)},name:u.value??u}),label:e.jsx("span",{style:{display:"flex",alignItems:"center"},children:b(u)})},u.value??u))})]})}function Be(n){return e.jsx(Qe,{...n,renderLabel:s=>e.jsx(de,{enableTooltip:!1,config:{status:s.status},children:s.label})})}xe.propTypes={status:h.number.isRequired,updatedAt:h.string.isRequired,reason:h.string,channel:h.string,onResend:h.func};function xe({status:n,updatedAt:s,reason:t="",channel:r="wallet",onResend:o}){const{t:l,locale:b}=te(),u=Ot(l,b,{status:n,updatedAt:s,reason:t,channel:r});return e.jsxs(y,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(de,{config:u,showTitle:!0}),u.status!=="success"&&e.jsx(Fe,{className:"resend-btn",size:"small",startIcon:e.jsx(Je,{}),sx:{fontSize:12,color:"rgba(0, 0, 0, 0.87)",fontWeight:400,".MuiButton-startIcon":{mr:"2px"}},onClick:o,children:l("notification.resend")})]})}Ze.propTypes={value:h.array.isRequired,onChange:h.func};function Ze({value:n,onChange:s}){const{locale:t}=te(),r=Z().toDate(),[o,l]=v.useState(null),b=v.useCallback(i=>{l(o?null:i.currentTarget)},[o]),u=!!o,p=v.useCallback(i=>{if(!i.startDate||!i.endDate){M.error("Please select a date range");return}if(Z(i.startDate).isAfter(i.endDate)||!Z(i.startDate).isValid()||!Z(i.endDate).isValid()){M.error("Invalid date range");return}s([i.startDate,i.endDate]),l(null)},[s]);return e.jsxs("div",{children:[e.jsx(ee,{component:"div",variant:"h5",color:"textPrimary",style:{fontSize:18,fontWeight:"bold"},sx:{mb:0},children:e.jsxs(Fe,{onClick:b,variant:"outlined",size:"small",color:"inherit",children:[at(n[0],t)," - ",at(n[1],t)]})}),e.jsx(Ue,{open:u,anchorEl:o,onClose:()=>{l(null)},anchorOrigin:{vertical:"bottom",horizontal:"left"},children:e.jsx(jn,{open:!0,maxDate:r,initialDateRange:{startDate:n[0],endDate:n[1]},toggle:b,definedRanges:vn(r),onChange:p})})]})}et.propTypes={itemComponent:h.elementType.isRequired};function et({itemComponent:n,...s}){const{t}=te();return!s?.filterList?.filter(o=>o.length).length?null:e.jsxs(y,{sx:{display:"flex",gap:1,alignItems:"center"},children:[e.jsx("div",{className:"toolbar-filter-title",children:t("notification.filter")}),e.jsx("div",{className:"toolbar-filter-content",children:e.jsx(nn.TableFilterList,{...s,ItemComponent:n})})]})}function tt({label:n,onDelete:s,canDelete:t=()=>!0,...r}){const o=s&&typeof s=="function"?s:void 0;let l=!0;return t&&typeof t=="function"&&(l=t({label:n,...r})),e.jsx(Ge,{label:n,variant:"outlined",...o&&l?{onDelete:o}:{}})}tt.propTypes={label:h.string.isRequired,onDelete:h.func,canDelete:h.func};const Mn=[{label:"Wallet",value:"app",checked:!0},{label:"Email",value:"email",checked:!0},{label:"Push Kit",value:"push",checked:!0},{label:"Webhook",value:"webhook",checked:!0}];Pt.propTypes={loading:h.bool,onCancel:h.func,onConfirm:h.func};function Pt({loading:n=!1,onCancel:s=()=>{},onConfirm:t=()=>{}}){const{t:r}=te(),[o,l]=v.useState(Mn),[b,u]=v.useState(!0),p=(N,I)=>{I.checked=N.target.checked;const S=o.map(j=>({...j,checked:j.value===I.value?I.checked:j.checked}));l(S)},i=N=>{N.stopPropagation(),t({channels:o.filter(I=>I.checked).map(I=>I.value),isResendFailedOnly:b})};return e.jsxs(y,{className:"resend-config",sx:{padding:"16px 24px"},children:[e.jsx(ee,{variant:"body1",component:"div",className:"check-title",sx:{fontWeight:700,mb:1},children:r("notification.config")}),e.jsx(y,{className:"choose-channel",children:e.jsxs(V,{component:"fieldset",variant:"standard",children:[e.jsx(pt,{component:"legend",children:r("notification.selectChannels")}),e.jsx(qe,{sx:{display:"flex",flexDirection:"row",flexWrap:"wrap",gap:1},children:o.map(N=>e.jsx(me,{control:e.jsx(Me,{checked:N.checked,onChange:I=>p(I,N),name:N.value}),label:N.label},N.value))})]})}),e.jsx(y,{className:"resend-config-footer",children:e.jsx(qe,{children:e.jsx(me,{control:e.jsx(Me,{checked:b,onChange:N=>u(N.target.checked)}),label:r("notification.resendFailedOnly")})})}),e.jsxs(y,{className:"resend-config-footer-tip",sx:{display:"flex",justifyContent:"flex-end",gap:1},children:[e.jsx(Fe,{onClick:N=>{N.stopPropagation(),s()},color:"inherit",children:r("common.cancel")}),e.jsxs(Fe,{onClick:i,color:"primary",disabled:n,variant:"contained",autoFocus:!0,style:{marginLeft:8},children:[n&&e.jsx(ft,{size:16}),r("common.confirm")]})]})]})}Ft.propTypes={notificationId:h.string.isRequired,handleResend:h.func,resending:h.bool};function Ft({notificationId:n,handleResend:s,resending:t=!1}){const{t:r,locale:o}=te(),l=ht(),b=v.useMemo(()=>jt(l,Lt()),[l]),{getReceivers:u,inService:p,teamDid:i,getUser:N,blocklet:I}=Xe(),[S,j]=v.useState(!1),[E,G]=v.useState([]),z=ye({anchorEl:null,position:null}),F=ye({anchorEl:null,position:null}),[B,R]=v.useState(null),[K,q]=v.useState({total:0,pageSize:10,pageCount:0,page:1}),[f,w]=v.useState({searchText:"",page:1,pageSize:10,walletSendStatus:[],pushKitSendStatus:[],emailSendStatus:[],dateRange:[Z().subtract(1,"month").startOf("day").toDate(),Z().endOf("day").toDate()]}),[C,a]=v.useState([]),T=[{label:r("notification.sendStatus.pending"),value:0,status:"pending"},{label:r("notification.sendStatus.success"),value:1,status:"success"},{label:r("notification.sendStatus.failed"),value:2,status:"failed"}],k=async()=>{if(!S&&n)try{j(!0);const c=await u({notificationId:n,...f}),d=c.list.map(m=>({...m,receiverUser:{...m.receiverUser,avatar:It(m.receiverUser.avatar,i,p)}}));G(d),q(c.paging),j(!1)}catch(c){M.error(c.message),j(!1)}};v.useEffect(()=>{k()},[f]);const D=c=>{c.stopPropagation();const d=c.currentTarget;F.anchorEl=d;const m=d.getBoundingClientRect();F.position={top:m.top+window.scrollY,left:m.left+window.scrollX}},re=c=>c.data.length?e.jsx("div",{style:{display:"flex",alignItems:"center",padding:"10px"},children:e.jsx(ce,{className:"resend-btn",size:"small",color:"primary",variant:"contained",startIcon:e.jsx(Je,{}),sx:{".MuiButton-startIcon":{mr:"2px"}},onClick:D,children:r("notification.resend")})}):null,ue={sort:!1,download:!1,print:!1,selectableRows:"multiple",searchPlaceholder:r("common.search"),searchAlwaysOpen:!1,filterType:"checkbox",searchDebounceTime:300,page:K.page-1,rowsPerPage:K.pageSize,count:K.total,searchText:f.searchText,tableBodyMaxHeight:"calc(80vh - 260px)",rowsSelected:C,onRowSelectionChange:(c,d)=>{a(d.map(m=>m.dataIndex))},customToolbarSelect:re},oe=({page:c,rowsPerPage:d,searchText:m,filterList:O})=>{const[,U=[],ne=[],J=[]]=O;f.pageSize!==d?w(H=>({...H,pageSize:d,page:1})):f.page!==c+1?w(H=>({...H,page:c+1})):f.searchText!==m?w(H=>({...H,searchText:m,page:1})):je(U,f.walletSendStatus)?je(ne,f.pushKitSendStatus)?je(J,f.emailSendStatus)||w(H=>({...H,emailSendStatus:J,page:1})):w(H=>({...H,pushKitSendStatus:ne,page:1})):w(H=>({...H,walletSendStatus:U,page:1}))},pe=v.useCallback(async(c,d)=>{if(!d)return!1;const m=await N(d);return m?c==="wallet"?zn(m):c==="email"?Fn(I,m):c==="pushKit"?_n(I,m):c==="webhook"?Wn(m):!0:!1},[N,I]),Re=v.useCallback(c=>Bn(r,c),[r]),fe=()=>{z.anchorEl=null,z.position=null,R(null)},he=()=>{F.anchorEl=null,F.position=null},g=async(c,d,m=!0,O="")=>{if(!(!d.length||!c.length))try{s(c,d,m,O),F.anchorEl||(await Ee(.5),fe())}catch(U){console.error("handleResend error",{error:U})}},x=async({channels:c,isResendFailedOnly:d})=>{const m=C.map(O=>E[O].receiver);await g(c,m,d),await Ee(.5),he(),a([])},A=async(c,d=[],m=!0)=>{try{await g(["webhook"],[c.receiver],m,d)}catch(O){M.error(O.response?O.response.statusText:O.message)}},L=async(c,d,m,O=[],U=!0)=>{if(c.stopPropagation(),Kn(d,m)>=4){M.warning(r("notification.resendLimit"));return}if(!Ve.includes(m)){await A(d,O,U);return}if(c){const J=c.currentTarget,H=J.getBoundingClientRect();z.anchorEl=J,z.position={top:H.top+window.scrollY,left:H.left+window.scrollX}}R({channel:m});try{const J=await pe(m,d.receiver);await Ee(1),R({channel:m,result:J}),(typeof J=="boolean"&&J||Zt(J)&&Object.values(J).every(H=>!!H))&&(await s([m],[d.receiver],U),F.anchorEl||(await Ee(.5),fe()))}catch(J){M.error(J.message)}},W=c=>{w(d=>({...d,dateRange:c,page:1}))},P=(c,d,m,O)=>{c.stopPropagation();const U=m.filter(ne=>ne!==d);w(ne=>({...ne,[O]:U,page:1}))},ie=se(()=>[{label:r("notification.receiver"),name:"receiver",width:200,options:{filter:!1,customBodyRenderLite:c=>{const{receiverUser:d,receiver:m}=E[c];return d?e.jsxs(y,{"data-cy":`member-name-${d.fullName}`,sx:{display:"flex",alignItems:"center",gap:1,justifyContent:"flex-start"},children:[e.jsx(vt,{src:`${d.avatar}?imageFilter=resize&w=48&h=48`,size:32,did:m,shape:"circle",style:{borderRadius:"100%",overflow:"hidden"}}),e.jsx(Se,{children:d.fullName})]},m):e.jsx(bn,{size:14,responsive:!1,compact:!0,copyable:!1,did:m})}}},{label:"Wallet",name:"walletSendStatus",width:200,options:{setCellProps:()=>({className:"sent-status-cell"}),filter:!0,filterType:"custom",filterList:f.walletSendStatus??[],customFilterListOptions:{render:c=>e.jsx(Le,{list:c,label:"Wallet",onDelete:(d,m)=>{d.stopPropagation(),P(d,m,ie[1].options.filterList,"walletSendStatus")}}),update:ke},filterOptions:{names:T,fullWidth:!0,logic:De,display:(c,d,m,O)=>e.jsx(Be,{label:"Wallet",filterList:c,onChange:d,index:m,column:O,filterValues:T})},customBodyRenderLite:c=>{const{walletSendStatus:d,walletSendAt:m,walletSendFailedReason:O}=E[c];return e.jsx(xe,{status:d,updatedAt:m,reason:O,channel:"wallet",onResend:U=>L(U,E[c],"wallet",[],!1)})}}},{label:"Push Kit",name:"pushKitSendStatus",width:200,options:{setCellProps:()=>({className:"sent-status-cell"}),customBodyRenderLite:c=>{const{pushKitSendStatus:d,pushKitSendAt:m,pushKitSendFailedReason:O}=E[c];return e.jsx(xe,{status:d,updatedAt:m,reason:O,channel:"pushkit",onResend:U=>L(U,E[c],"pushKit",[],!1)})},filter:!0,filterType:"custom",filterList:f.pushKitSendStatus??[],customFilterListOptions:{render:c=>e.jsx(Le,{list:c,label:"Push Kit",onDelete:(d,m)=>{d.stopPropagation(),P(d,m,ie[2].options.filterList,"pushKitSendStatus")}}),update:ke},filterOptions:{names:T,fullWidth:!0,logic:De,display:(c,d,m,O)=>e.jsx(Be,{label:"Push Kit",filterList:c,onChange:d,index:m,column:O,filterValues:T})}}},{label:"Email",name:"emailSendStatus",width:200,options:{setCellProps:()=>({className:"sent-status-cell"}),customBodyRenderLite:c=>{const{emailSendStatus:d,emailSendAt:m,emailSendFailedReason:O}=E[c];return e.jsx(xe,{status:d,updatedAt:m,reason:O,channel:"email",onResend:U=>L(U,E[c],"email",[],!1)})},filter:!0,filterType:"custom",filterList:f.emailSendStatus??[],customFilterListOptions:{render:c=>e.jsx(Le,{list:c,label:"Email",onDelete:(d,m)=>{d.stopPropagation(),P(d,m,ie[3].options.filterList,"emailSendStatus")}}),update:ke},filterOptions:{names:T,fullWidth:!0,logic:De,display:(c,d,m,O)=>e.jsx(Be,{label:"Email",filterList:c,onChange:d,index:m,column:O,filterValues:T})}}},{label:"Webhook",name:"webhook",width:200,options:{filter:!1,setCellProps:()=>({className:"sent-status-cell"}),customBodyRenderLite:c=>{const{webhook:d}=E[c];if(!d)return null;const m=Object.entries(d)[0];if(!m)return null;const[O,U]=m,ne=U[0];return e.jsx(y,{sx:{display:"flex",flexDirection:"column",gap:1},children:e.jsxs(y,{className:"webhook-item",sx:{fontSize:12},children:[e.jsx(Se,{maxLength:30,children:O},O),e.jsx(xe,{status:ne.status,updatedAt:ne.sendAt,reason:ne.failedReason,channel:"webhook",onResend:J=>L(J,E[c],"webhook",[O],!1)})]},O)})}}},{label:r("common.createdAt"),name:"createdAt",width:100,options:{filter:!1,customBodyRenderLite:c=>{const{createdAt:d}=E[c];return e.jsx(Nt,{value:d,locale:o,shouldUpdate:!0})}}}],[E,o,f,r]),we=[e.jsx(Ze,{value:f.dateRange,onChange:W},"date-picker"),e.jsx(ce,{variant:"contained",size:"small",color:"primary",loading:S,startIcon:e.jsx(qt,{}),onClick:()=>k(),sx:{".MuiButton-startIcon":{mr:"2px"}},style:{marginLeft:8},children:r("common.refresh")},"refresh")];return e.jsx(y,{sx:{overflow:"auto",".MuiTableCell-head":{whiteSpace:"nowrap",fontWeight:"bold"},".MuiTableCell-root":{paddingRight:"8px",whiteSpace:"nowrap"}},children:e.jsx(Hn,{children:e.jsxs(xt,{theme:b,children:[e.jsx(yt,{className:"receivers-table",locale:o,loading:S,columns:ie,data:E,onChange:oe,options:ue,customButtons:we,components:{TableFilterList:c=>e.jsx(et,{...c,itemComponent:d=>e.jsx(tt,{...d,canDelete:()=>!1})})}}),z.anchorEl&&e.jsx(Ue,{open:!!z.anchorEl,anchorReference:"anchorPosition",anchorPosition:z.position,onClose:fe,anchorOrigin:{vertical:"center",horizontal:"right"},transformOrigin:{vertical:"center",horizontal:"left"},children:e.jsxs($n,{children:[e.jsxs(ee,{variant:"body1",component:"div",className:"check-title",children:[B?.channel," Checking"]}),e.jsx(y,{sx:{display:"flex",flexDirection:"column",gap:"4px"},children:Re(B?.channel).map(c=>{const{type:d,pass:m,fail:O}=c;return!B?.result||B?.result?.[d]?e.jsxs(ee,{variant:"body1",component:"div",className:"check-item",sx:{display:"flex",alignItems:"center",gap:"4px",color:B?.result?.[d]?Oe.success.main:"inherit"},children:[B?.result?e.jsx(Mt,{}):e.jsx(ft,{size:12,sx:{color:Oe.primary.main}}),e.jsx("span",{children:m})]},d):e.jsxs(ee,{variant:"body1",component:"div",className:"check-item",sx:{display:"flex",alignItems:"center",gap:"4px",color:Oe.error.main},children:[e.jsx(Ut,{}),e.jsx("span",{children:O})]},d)})})]})}),F.anchorEl&&e.jsx(Ue,{open:!!F.anchorEl,anchorReference:"anchorPosition",anchorPosition:F.position,onClose:he,anchorOrigin:{vertical:"center",horizontal:"right"},transformOrigin:{vertical:"center",horizontal:"left"},children:e.jsx(Pt,{loading:t,onCancel:he,onConfirm:x})})]})})})}const Un=v.memo(Ft),Hn=ae.div`
1
+ import{g as Wt,r as v}from"./vendor-react-Dvs43sk9.js";import{j as e,ak as y,z as Q,b6 as me,be as Ke,y as V,am as ut,d1 as Bt,bm as Kt,at as ae,b1 as mt,W as h,T as ee,U as Ge,d2 as pt,b5 as qe,a5 as Me,Q as Fe,d3 as Je,aN as Ue,a6 as ft,D as ht,d4 as qt,ad as xt,d5 as Mt,d6 as Ut,c1 as st,n as Ht,x as $t,bb as Vt,M as it,cz as Gt,I as Jt,d7 as Yt}from"./vendor-mui-core-B7zoO8f5.js";import{A as gt,J as Xt,C as Qt,e as le,F as Zt,a4 as je}from"./vendor-utils-DtY42AM-.js";import{T as te,H as M,D as ce,G as en,L as bt,ak as tn,aJ as nn,y as jt,$ as vt,ab as yt,aK as Oe,F as St,a5 as sn,ah as an}from"./vendor-ux-B7q8W4Pg.js";import{aF as rn,Z as Ye,a8 as Ct,aU as Rt,M as _e,c as _,ao as Z,p as on,aO as at}from"./index-CuQBOJqN.js";import{g as ye,b as $,a as se}from"./vendor-hooks-BRXKH6Nb.js";import{u as wt,C as Y}from"./index.esm-JPZAjt0x.js";import{i as He}from"./isURL-Cuto2_sB.js";import{S as X}from"./section-Dq8SB7lh.js";import{A as ln,a as cn,b as dn}from"./collapse-C-BNkgS6.js";import{S as Se}from"./shorten-label-BHlFrl9P.js";import{v as Tt}from"./index-Bzij4iIk.js";import{R as Nt,A as un,S as mn,a as pn,B as fn}from"./list-CcfeNfGu.js";import{j as hn,c as xn,N as gn}from"./team-Dl23XmaY.js";import{W as bn}from"./did-address-CcsL3-Qm.js";import{p as It}from"./util-Ca2jlZN4.js";import{D as jn,g as vn}from"./traffic-O-wVx65-.js";import{B as Et}from"./bundle-avatar-FLzOZWlh.js";import{u as yn}from"./use-mobile-C_DcJ5SZ.js";import"./lottie-web-4koyQiv_.js";import"./vendor-arcblock-B7AoUs4o.js";import"./required-CobBjKC9.js";import"./server-logo-notext.svg-CKQB0tIp.js";import"./index-DzqNo2lD.js";import"./session-Bk6ebojT.js";import"./use-app-logo-7cjs_pn8.js";import"./base32-D7JDMggs.js";import"./useAsyncRetry-D4-sRZN-.js";import"./useAsync-BrMo9m7W.js";import"./iframe-CbjzikLk.js";import"./index-DQmcrxe_.js";import"./index-DBs9Ljax.js";import"./base-chart-DZz4r8-E.js";import"./index-DT3k66ox.js";import"./vendor-mui-x-Qph0dQcg.js";import"./AdapterDayjs-VDBijwaM.js";var Te={exports:{}},Ne={exports:{}},Ie={exports:{}},rt;function Sn(){return rt||(rt=1,function(n,s){Object.defineProperty(s,"__esModule",{value:!0}),s.default=t;function t(r){return r==null}n.exports=s.default,n.exports.default=s.default}(Ie,Ie.exports)),Ie.exports}var ot;function Cn(){return ot||(ot=1,function(n,s){Object.defineProperty(s,"__esModule",{value:!0}),s.default=u;var t=o(rn()),r=o(Sn());function o(p){return p&&p.__esModule?p:{default:p}}var l=/^(?:[-+]?(?:0|[1-9][0-9]*))$/,b=/^[-+]?[0-9]+$/;function u(p,i){(0,t.default)(p),i=i||{};var N=i.allow_leading_zeroes===!1?l:b,I=!i.hasOwnProperty("min")||(0,r.default)(i.min)||p>=i.min,S=!i.hasOwnProperty("max")||(0,r.default)(i.max)||p<=i.max,j=!i.hasOwnProperty("lt")||(0,r.default)(i.lt)||p<i.lt,E=!i.hasOwnProperty("gt")||(0,r.default)(i.gt)||p>i.gt;return N.test(p)&&I&&S&&j&&E}n.exports=s.default,n.exports.default=s.default}(Ne,Ne.exports)),Ne.exports}var lt;function Rn(){return lt||(lt=1,function(n,s){Object.defineProperty(s,"__esModule",{value:!0}),s.default=o;var t=r(Cn());function r(l){return l&&l.__esModule?l:{default:l}}function o(l){return(0,t.default)(l,{allow_leading_zeroes:!1,min:0,max:65535})}n.exports=s.default,n.exports.default=s.default}(Te,Te.exports)),Te.exports}var wn=Rn();const Tn=Wt(wn),ze={enabled:!1,secure:!1,from:"",host:"",port:"",user:"",password:"",companyName:"",companyLink:"",companyAddress:"",supportEmail:""};function Nn(){const{api:n}=Ye(),{blocklet:s}=Ct(),{t}=te(),{confirmApi:r,confirmHolder:o}=Rt(),l=s?.meta?.did,b=Object.assign({...ze},s?.settings?.notification?.email||{}),{handleSubmit:u,control:p,formState:i,watch:N,reset:I}=wt({defaultValues:gt(b,Object.keys(ze))}),S=ye({testReceiver:"",testReceiverError:""}),j=N("enabled"),E=$(async(a,T,k=!0)=>{try{const{blocklet:D}=await n.configNotification({input:{did:l,notification:JSON.stringify({email:a})}}),re=Object.assign({...ze},D?.settings?.notification?.email||{});I(re),k&&M.success(t("oauth.saveSuccess"))}catch(D){if(k)M.error(D.message||t("oauth.saveFailed"));else throw D}}),G=$(async(a,T,k)=>{try{i.isDirty&&await E(a,T,!1),await n.sendEmail({input:{did:l,receiver:k,email:JSON.stringify({body:"Your SMTP configuration is correct!",title:"Test email",type:"notification"})}}),M.success(t("notification.email.testSuccess"))}catch(D){M.error(D.message||t("notification.email.testfailed"))}}),z=$((a,T)=>{S.testReceiver="",S.testReceiverError="",r.open({title:t("notification.email.testSendEmail"),content:()=>e.jsx(y,{sx:{width:"300px"},children:e.jsx(Q,{sx:{mt:1},fullWidth:!0,name:"testReceiver",label:t("notification.email.inputTestReceiver"),value:S.testReceiver,onChange:k=>{S.testReceiver=k.target.value},error:!!S.testReceiverError,helperText:S.testReceiverError||" "})}),confirmButtonText:t("common.confirm"),cancelButtonText:t("common.cancel"),async onConfirm(k){const D=S.testReceiver?.trim();if(!D){S.testReceiverError=t("notification.email.receiverRequired");return}if(!_e(D)){S.testReceiverError=t("notification.email.receiverInvalid");return}S.testReceiverError="",await G(a,T,D),k()}})}),F=$(a=>{const T=a?.trim();return T?_e(T)?!0:t("notification.email.fromInvalid"):t("notification.email.fromRequired")}),B=$(a=>{const T=a?.trim();return T?He(T,{require_host:!1,protocols:[]})?!0:t("notification.email.hostInvalid"):t("notification.email.hostRequired")}),R=$(a=>a?Tn(a)?!0:t("notification.email.portInvalid"):t("notification.email.portRequired")),K=$(a=>a?.trim()?!0:t("notification.email.userRequired")),q=$(a=>a?.trim()?!0:t("notification.email.passwordRequired")),f=$(a=>a?.trim()&&!He(a,{protocols:["http","https"],require_protocol:!0})?t("notification.email.linkInvalid"):!0),w=$(a=>a?.trim()&&!_e(a)?t("notification.email.emailInvalid"):!0),C=$(()=>!0);return e.jsxs(y,{children:[e.jsxs(In,{component:"form",onSubmit:u(E),disabled:!0,sx:{".section-left":{width:"160px"}},children:[e.jsx(X,{title:t("notification.email.enable"),my:2.5,children:e.jsx(Y,{name:"enabled",control:p,render:({field:a})=>e.jsx(me,{control:e.jsx(Ke,{checked:a.value,...a})})})}),e.jsx(X,{title:t("notification.email.from"),children:e.jsx(Y,{name:"from",control:p,rules:{validate:j?F:C},render:({field:a})=>e.jsx(V,{fullWidth:!0,children:e.jsx(Q,{...a,size:"small",required:!0,label:t("notification.email.from"),error:!!i.errors[a.name],helperText:i.errors[a.name]?.message||" ",disabled:!j})})})}),e.jsx(X,{title:t("notification.email.host"),children:e.jsx(Y,{name:"host",control:p,rules:{validate:j?B:C},render:({field:a})=>e.jsx(V,{fullWidth:!0,children:e.jsx(Q,{...a,size:"small",required:!0,error:!!i.errors[a.name],label:t("notification.email.host"),helperText:i.errors[a.name]?.message||" ",disabled:!j})})})}),e.jsx(X,{title:t("notification.email.port"),children:e.jsx(Y,{name:"port",control:p,rules:{validate:j?R:C},render:({field:a})=>e.jsx(V,{fullWidth:!0,children:e.jsx(Q,{...a,size:"small",required:!0,type:"number",error:!!i.errors[a.name],label:t("notification.email.port"),helperText:i.errors[a.name]?.message||" ",disabled:!j})})})}),e.jsx(X,{title:t("notification.email.user"),children:e.jsx(Y,{name:"user",control:p,rules:{validate:j?K:C},render:({field:a})=>e.jsx(V,{fullWidth:!0,children:e.jsx(Q,{...a,size:"small",required:!0,error:!!i.errors[a.name],label:t("notification.email.user"),helperText:i.errors[a.name]?.message||" ",disabled:!j})})})}),e.jsx(X,{title:t("notification.email.password"),children:e.jsx(Y,{name:"password",control:p,rules:{validate:j?q:C},render:({field:a})=>e.jsx(V,{fullWidth:!0,children:e.jsx(Q,{...a,size:"small",required:!0,type:"password",error:!!i.errors[a.name],label:t("notification.email.password"),helperText:i.errors[a.name]?.message||" ",disabled:!j})})})}),e.jsx(X,{title:t("notification.email.secure"),children:e.jsx(Y,{name:"secure",control:p,rules:{validate:C},render:({field:a})=>e.jsx(V,{fullWidth:!0,children:e.jsx(me,{control:e.jsx(Ke,{checked:a.value,...a,disabled:!j})})})})}),e.jsxs(ln,{children:[e.jsxs(cn,{expandIcon:e.jsx(Kt,{fontSize:"small"}),"aria-controls":"panel1-content",id:"panel1-header",children:[t("notification.email.signature"),e.jsx(ut,{title:t("notification.email.signatureTooltip"),children:e.jsx(Bt,{fontSize:"small",sx:{ml:1,cursor:"help"}})})]}),e.jsxs(dn,{children:[e.jsx(X,{title:t("notification.email.companyName"),children:e.jsx(Y,{name:"companyName",control:p,rules:{validate:C},render:({field:a})=>e.jsx(V,{fullWidth:!0,children:e.jsx(Q,{...a,size:"small",error:!!i.errors[a.name],label:t("notification.email.companyName"),helperText:i.errors[a.name]?.message||" ",disabled:!j})})})}),e.jsx(X,{title:t("notification.email.companyLink"),children:e.jsx(Y,{name:"companyLink",control:p,rules:{validate:j?f:C},render:({field:a})=>e.jsx(V,{fullWidth:!0,children:e.jsx(Q,{...a,size:"small",error:!!i.errors[a.name],label:t("notification.email.companyLink"),helperText:i.errors[a.name]?.message||" ",disabled:!j})})})}),e.jsx(X,{title:t("notification.email.companyAddress"),children:e.jsx(Y,{name:"companyAddress",control:p,rules:{validate:C},render:({field:a})=>e.jsx(V,{fullWidth:!0,children:e.jsx(Q,{...a,size:"small",error:!!i.errors[a.name],label:t("notification.email.companyAddress"),helperText:i.errors[a.name]?.message||" ",disabled:!j})})})}),e.jsx(X,{title:t("notification.email.supportEmail"),children:e.jsx(Y,{name:"supportEmail",control:p,rules:{validate:j?w:C},render:({field:a})=>e.jsx(V,{fullWidth:!0,children:e.jsx(Q,{...a,size:"small",type:"email",error:!!i.errors[a.name],label:t("notification.email.supportEmail"),helperText:i.errors[a.name]?.message||" ",disabled:!j})})})})]})]}),e.jsxs(y,{sx:{display:"flex",justifyContent:"flex-end",gap:2,mt:3},children:[e.jsx(ce,{variant:"outlined",color:"warning",onClick:u(z),disabled:!j,children:t("oauth.runTest")}),e.jsx(ce,{type:"submit",variant:"contained",disabled:!i.isDirty,children:t("oauth.save")})]})]}),o]})}const In=ae(mt)``,We={enabled:!1,endpoint:"",did:void 0,pushPath:void 0};function En(){const{api:n}=Ye(),{blocklet:s}=Ct(),{t}=te(),{confirmApi:r,confirmHolder:o}=Rt(),l=s?.meta?.did,b=Object.assign({...We},s?.settings?.notification?.pushKit||{}),{handleSubmit:u,control:p,formState:i,watch:N,reset:I}=wt({defaultValues:gt(b,Object.keys(We))}),S=ye({testReceiver:"",testReceiverError:""}),j=N("enabled"),E=$(async(R,K,q=!0)=>{try{const{blocklet:f}=await n.configNotification({input:{did:l,notification:JSON.stringify({pushKit:R})}}),w=Object.assign({...We},f?.settings?.notification?.pushKit||{});I(w),q&&M.success(t("oauth.saveSuccess"))}catch(f){if(q)M.error(f.message||t("oauth.saveFailed"));else throw f}}),G=$(async(R,K)=>{try{i.isDirty&&await E(R,K,!1);const q=(s?.configs||[]).find(C=>C.key==="BLOCKLET_APP_URL")?.value,f=Xt(Qt(q,_.WELLKNOWN_SERVICE_PATH_PREFIX,"/blocklet/logo"),{v:s?.meta?.version,t:new Date(s?.updatedAt||0).getTime()}),w={type:"passthrough",passthroughType:"messageStatus",data:{message:{title:"Test push-kit notification",body:"This is message from push-kit config test",sender:{did:s?.appDid,fullName:s?.meta?.title,avatar:f}}}};await n.sendPush({input:{did:l,receiver:S.testReceiver,notification:JSON.stringify(w)}}),M.success(t("notification.pushKit.testSuccess"))}catch(q){M.error(q.message||t("notification.pushKit.testfailed"))}}),z=$((R,K)=>{S.testReceiverError="",r.open({title:t("notification.pushKit.testSend"),content:()=>e.jsx(y,{sx:{width:"450px",maxWidth:"100%"},children:e.jsx(Q,{sx:{mt:1},fullWidth:!0,name:"testReceiver",label:t("notification.pushKit.inputTestReceiver"),value:S.testReceiver,onChange:q=>{S.testReceiver=q.target.value},error:!!S.testReceiverError,helperText:S.testReceiverError||" "})}),confirmButtonText:t("common.confirm"),cancelButtonText:t("common.cancel"),async onConfirm(q){if(!S.testReceiver?.trim()){S.testReceiverError=t("notification.pushKit.receiverRequired");return}S.testReceiverError="",await G(R,K),q()}})}),F=$(R=>{const K=R?.trim();return K?He(K)?!0:t("notification.pushKit.endpointInvalid"):t("notification.pushKit.endpointRequired")}),B=$(()=>!0);return e.jsxs(y,{children:[e.jsxs(An,{component:"form",onSubmit:u(E),disabled:!0,sx:{".section-left":{width:"160px"}},children:[e.jsx(X,{title:t("notification.pushKit.enable"),my:2.5,children:e.jsx(Y,{name:"enabled",control:p,render:({field:R})=>e.jsx(me,{control:e.jsx(Ke,{checked:R.value,...R})})})}),e.jsx(X,{title:t("notification.pushKit.endpoint"),children:e.jsx(Y,{name:"endpoint",control:p,rules:{validate:j?F:B},render:({field:R})=>e.jsx(V,{fullWidth:!0,children:e.jsx(Q,{...R,size:"small",required:!0,label:t("notification.pushKit.endpoint"),error:!!i.errors[R.name],helperText:i.errors[R.name]?.message||" ",disabled:!j})})})}),e.jsxs(X,{title:t("notification.pushKit.customOptions"),children:[e.jsx(Y,{name:"did",control:p,render:({field:R})=>e.jsx(V,{fullWidth:!0,children:e.jsx(Q,{...R,size:"small",label:t("notification.pushKit.did"),error:!!i.errors[R.name],helperText:i.errors[R.name]?.message||" ",disabled:!j})})}),e.jsx(Y,{name:"pushPath",control:p,render:({field:R})=>e.jsx(V,{fullWidth:!0,children:e.jsx(Q,{...R,size:"small",label:t("notification.pushKit.pushPath"),error:!!i.errors[R.name],helperText:i.errors[R.name]?.message||" ",disabled:!j})})})]}),e.jsxs(y,{sx:{display:"flex",justifyContent:"flex-end",gap:2,mt:3},children:[e.jsx(ce,{variant:"outlined",color:"warning",onClick:u(z),disabled:!j,children:t("oauth.runTest")}),e.jsx(ce,{type:"submit",variant:"contained",disabled:!i.isDirty,children:t("oauth.save")})]})]}),o]})}const An=ae(mt)``,ct=[{label:e.jsx(y,{sx:{textAlign:"center",width:"100%"},children:"Email"}),value:"email"},{label:e.jsx(y,{sx:{textAlign:"center",width:"100%"},children:"Push Kit"}),value:"pushKit"}];function On(){const[n,s]=v.useState(ct[0].value),{locale:t}=v.useContext(en),r=se(()=>({email:e.jsx(Nn,{}),pushKit:e.jsx(En,{})}),[t]),o=v.useMemo(()=>({padding:"10px 0"}),[]);return e.jsxs(y,{children:[e.jsx(bt,{tabs:ct,current:n,onChange:s}),e.jsx(y,{style:o,children:r[n]})]})}const At=v.createContext({}),{Provider:kn,Consumer:Ws}=At;function Dn({children:n,blocklet:s=""}){const{api:t,inService:r,ws:{useSubscription:o}}=Ye(),[l,b]=v.useState([]),[u,p]=v.useState({total:0,pageSize:20,pageCount:0,page:1}),i=se(()=>s.meta?.did,[s]),[N,I]=v.useState([]),[S,j]=v.useState({}),E=se(()=>l.length?new Set(l.map(f=>f.id)):new Set,[l]),G=async({page:f=1,pageSize:w=20,...C}={})=>{if(!i)return[];try{const a={paging:{page:f,pageSize:w},...C,teamDid:i,dateRange:C.dateRange?[Z(C.dateRange[0]).toISOString(),Z(C.dateRange[1]).toISOString()]:void 0},{dids:T,...k}=a;let D="";T&&T.includes("system")&&(D="system");const re=T?T.filter(pe=>pe!=="system"):[],ue={...k,source:D,componentDids:re},oe=await t.getNotificationSendLog({input:ue});return j(ue),b(oe.list),p(oe.paging),oe.list}catch(a){return M.error(a.message),[]}},z=async()=>{const f=await t.getNotificationComponents({input:{teamDid:i}});I(f.componentDids)},F=v.useCallback(f=>{const w=s.children.find(C=>C.meta?.did===f);if(w)return w.ancestors=[s],w},[s]),B=async({notificationId:f,receivers:w,channels:C,...a})=>{await t.resendNotification({input:{teamDid:i,notificationId:f,receivers:w,channels:C.map(T=>T==="wallet"?_.NOTIFICATION_SEND_CHANNEL.WALLET:T==="pushKit"?_.NOTIFICATION_SEND_CHANNEL.PUSH:T),...a}})},R=v.useCallback(async f=>(await t.getUser({input:{teamDid:i,user:{did:f}}})).user,[t,i]),K=v.useCallback(async({page:f=1,pageSize:w=20,...C}={})=>{try{const a={paging:{page:f,pageSize:w},...C,userName:C.searchText||"",teamDid:i,dateRange:C.dateRange?[Z(C.dateRange[0]).toISOString(),Z(C.dateRange[1]).toISOString()]:void 0};return await t.getReceivers({input:a})}catch(a){throw M.error(a.message),a}},[t,i]);v.useEffect(()=>{i&&z()},[i]),o(_.EVENTS.NOTIFICATION_BLOCKLET_UPDATE,f=>{E.has(f.notificationId)&&G(S)},[E,S]),o(_.EVENTS.NOTIFICATION_BLOCKLET_CREATE,f=>{E.has(f.id)||G(S)},[E,S]);const q={fetch:G,data:l,paging:u,blocklet:s,getComponent:F,resendNotification:B,getUser:R,componentDids:N,getReceivers:K,inService:r,teamDid:i};return e.jsx(kn,{value:{notificationRecords:q},children:n})}function Xe(){const{notificationRecords:n}=v.useContext(At);return n}Ce.propTypes={severity:h.oneOf(Object.values(["info","success","error","warning"])).isRequired};const Ln={info:"primary",success:"success",error:"error",warning:"warning"};function Ce({severity:n="info"}){return e.jsx(tn,{type:Ln[n],children:n})}const Pn=(n,s,t="")=>{if(!t||!s)return"";switch(t){case _.NOTIFICATION_SEND_FAILED_REASON.USER_DISABLED:return n("notification.sendStatus.reason.disabled",{channel:s});case _.NOTIFICATION_SEND_FAILED_REASON.CHANNEL_UNAVAILABLE:return n("notification.sendStatus.reason.unavailable",{channel:s});case _.NOTIFICATION_SEND_FAILED_REASON.CHANNEL_DISABLED:return n("notification.sendStatus.reason.notSent",{channel:s});case _.NOTIFICATION_SEND_FAILED_REASON.NOT_ONLINE:return n("notification.sendStatus.reason.offline");default:return t}};function Ot(n,s,t={}){const{status:r,updatedAt:o,reason:l="",channel:b="wallet"}=t,u=o?n("notification.sendStatus.sentTime",{date:on(o,s)}):"",p=Pn(n,b,l);return r===_.NOTIFICATION_SEND_STATUS.FAILED?{status:"failed",title:n("notification.sendStatus.failed"),sentTime:u,reason:p}:r===_.NOTIFICATION_SEND_STATUS.SENT?{status:"success",title:n("notification.sendStatus.success"),sentTime:u}:{status:"pending",title:n("notification.sendStatus.pending"),reason:p,sentTime:u}}const $e={pending:"#aaaaaa",success:"#34BE74",failed:"#D0021B"},Ve=["wallet","pushKit","email"],dt=["info","success","error","warning"],kt=n=>{const{settings:s}=n;return s?.notification?.email?.enabled},Dt=n=>{const{settings:s}=n;return s?.notification?.pushKit?.enabled},Fn=(n,s)=>{const t=le(s,"extra.notifications.email",!0);return{available:kt(n),enabled:t}},_n=(n,s)=>{const t=le(s,"extra.notifications.push",!0);return{available:Dt(n),enabled:t}},zn=n=>({enabled:le(n,"extra.notifications.wallet",!0)}),Wn=n=>({enabled:le(n,"extra.webhooks",[]).length>0}),Ee=(n=3)=>new Promise(s=>{setTimeout(()=>{s()},n*1e3)}),Bn=(n,s)=>s==="wallet"||s==="webhook"?[{channel:s,type:"enabled",pass:n("notification.sendStatus.reason.enabled",{channel:s}),fail:n("notification.sendStatus.reason.disabled",{channel:s})}]:s==="pushKit"||s==="email"?[{channel:s,type:"available",pass:n("notification.sendStatus.reason.available",{channel:s}),fail:n("notification.sendStatus.reason.unavailable",{channel:s})},{channel:s,type:"enabled",pass:n("notification.sendStatus.reason.enabled",{channel:s}),fail:n("notification.sendStatus.reason.disabled",{channel:s})}]:[],Ae=(n=[])=>{const s=Z().startOf("day");return n.filter(t=>Z(t.sendAt).isSame(s,"day")).length},Kn=(n,s="")=>{if(s&&Ve.includes(s)){const l=`${s}SendRecord`,b=le(n,l,[]);return Ae(b)}const t=le(n,"webhook",{}),r=Object.keys(t??{})??[];if(s&&r.includes(s)){const l=t[s]??[];return Ae(l)}const o={};return Ve.forEach(l=>{const b=`${l}SendRecord`,u=le(n,b,[]),p=Ae(u);o[l]=p}),r.length>0&&r.forEach(l=>{const b=t[l]??[],u=Ae(b);o[l]=u}),o},ke=(n,s,t)=>{if(!Array.isArray(n))throw new Error("Invalid filterList or index");return n[t].splice(s,1),n},De=(n,s)=>{if(!Array.isArray(s))throw new Error("filters must be an array");return s.length?!s.includes(n):!1},qn=n=>{switch(n){case _.NOTIFICATION_SEND_CHANNEL.WALLET:return"Wallet";case _.NOTIFICATION_SEND_CHANNEL.PUSH:return"Push Kit";case _.NOTIFICATION_SEND_CHANNEL.EMAIL:return"Email";case _.NOTIFICATION_SEND_CHANNEL.WEBHOOK:return"Webhook";default:return""}},Lt=()=>({components:{MUIDataTableFilter:{styleOverrides:{header:{marginBottom:0,p:{margin:0}},root:{"& .MuiGrid-container":{marginTop:0,"& .MuiGrid-item":{paddingTop:0}}}}},MuiPopover:{styleOverrides:{root:{"&.MuiPopover-root":{"& .MuiPaper-root:has(.filter-container)":{width:"420px"}}}}}}});function de({config:n,enableTooltip:s=!0,showTitle:t=!1,children:r=null}){const{status:o,title:l="",sentTime:b="",reason:u=""}=n,p=[l,u].filter(Boolean).join(", ");return e.jsx(ut,{title:s?e.jsxs(e.Fragment,{children:[e.jsx(ee,{color:"inherit",sx:{fontSize:12},children:p}),e.jsx("span",{children:b})]}):null,arrow:!0,placement:"top",children:e.jsxs(y,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"4px"},children:[e.jsxs(y,{sx:{position:"relative",minHeight:14,minWidth:14,display:"flex",alignItems:"center",justifyContent:"center"},children:[e.jsx(y,{style:{opacity:.15},sx:{position:"absolute",width:"100%",height:"100%",borderRadius:"50%",bgcolor:$e[o]}}),e.jsx(y,{sx:{position:"absolute",width:"55%",height:"55%",borderRadius:"50%",bgcolor:$e[o]}})]}),e.jsx(ee,{color:"inherit",sx:{fontSize:12},children:t?l:r})]})})}de.propTypes={config:h.object.isRequired,enableTooltip:h.bool,showTitle:h.bool,children:h.node};Le.propTypes={list:h.array.isRequired,label:h.string.isRequired,onDelete:h.func};function Le({list:n,label:s,onDelete:t=()=>{}}){const{t:r,locale:o}=te();return e.jsxs(y,{sx:{display:"flex",gap:1,alignItems:"center"},children:[e.jsxs(ee,{children:[s,": "]}),n.map(l=>{const b=Ot(r,o,{status:l});return e.jsx(Ge,{size:"small",label:e.jsx(y,{sx:{display:"flex",alignItems:"center",gap:"4px"},children:e.jsx(de,{config:b,enableTooltip:!1,children:b.title})}),onDelete:u=>t(u,l)},l)})]})}Qe.propTypes={filterList:h.array.isRequired,onChange:h.func.isRequired,index:h.number.isRequired,column:h.object.isRequired,filterValues:h.array.isRequired,label:h.string.isRequired,renderLabel:h.func.isRequired};function Qe({filterList:n,onChange:s,index:t,column:r,filterValues:o,label:l,renderLabel:b}){return e.jsxs(V,{className:"filter-container",children:[e.jsx(pt,{component:"legend",children:l}),e.jsx(qe,{row:!0,children:o.map(u=>e.jsx(me,{control:e.jsx(Me,{checked:n[t].indexOf(u.value??u)>-1,onChange:p=>{const i=[...n];p.target.checked?i[t]=[...i[t],u.value??u]:i[t]=i[t].filter(N=>N!==(u.value??u)),s(i[t],t,r)},name:u.value??u}),label:e.jsx("span",{style:{display:"flex",alignItems:"center"},children:b(u)})},u.value??u))})]})}function Be(n){return e.jsx(Qe,{...n,renderLabel:s=>e.jsx(de,{enableTooltip:!1,config:{status:s.status},children:s.label})})}xe.propTypes={status:h.number.isRequired,updatedAt:h.string.isRequired,reason:h.string,channel:h.string,onResend:h.func};function xe({status:n,updatedAt:s,reason:t="",channel:r="wallet",onResend:o}){const{t:l,locale:b}=te(),u=Ot(l,b,{status:n,updatedAt:s,reason:t,channel:r});return e.jsxs(y,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(de,{config:u,showTitle:!0}),u.status!=="success"&&e.jsx(Fe,{className:"resend-btn",size:"small",startIcon:e.jsx(Je,{}),sx:{fontSize:12,color:"rgba(0, 0, 0, 0.87)",fontWeight:400,".MuiButton-startIcon":{mr:"2px"}},onClick:o,children:l("notification.resend")})]})}Ze.propTypes={value:h.array.isRequired,onChange:h.func};function Ze({value:n,onChange:s}){const{locale:t}=te(),r=Z().toDate(),[o,l]=v.useState(null),b=v.useCallback(i=>{l(o?null:i.currentTarget)},[o]),u=!!o,p=v.useCallback(i=>{if(!i.startDate||!i.endDate){M.error("Please select a date range");return}if(Z(i.startDate).isAfter(i.endDate)||!Z(i.startDate).isValid()||!Z(i.endDate).isValid()){M.error("Invalid date range");return}s([i.startDate,i.endDate]),l(null)},[s]);return e.jsxs("div",{children:[e.jsx(ee,{component:"div",variant:"h5",color:"textPrimary",style:{fontSize:18,fontWeight:"bold"},sx:{mb:0},children:e.jsxs(Fe,{onClick:b,variant:"outlined",size:"small",color:"inherit",children:[at(n[0],t)," - ",at(n[1],t)]})}),e.jsx(Ue,{open:u,anchorEl:o,onClose:()=>{l(null)},anchorOrigin:{vertical:"bottom",horizontal:"left"},children:e.jsx(jn,{open:!0,maxDate:r,initialDateRange:{startDate:n[0],endDate:n[1]},toggle:b,definedRanges:vn(r),onChange:p})})]})}et.propTypes={itemComponent:h.elementType.isRequired};function et({itemComponent:n,...s}){const{t}=te();return!s?.filterList?.filter(o=>o.length).length?null:e.jsxs(y,{sx:{display:"flex",gap:1,alignItems:"center"},children:[e.jsx("div",{className:"toolbar-filter-title",children:t("notification.filter")}),e.jsx("div",{className:"toolbar-filter-content",children:e.jsx(nn.TableFilterList,{...s,ItemComponent:n})})]})}function tt({label:n,onDelete:s,canDelete:t=()=>!0,...r}){const o=s&&typeof s=="function"?s:void 0;let l=!0;return t&&typeof t=="function"&&(l=t({label:n,...r})),e.jsx(Ge,{label:n,variant:"outlined",...o&&l?{onDelete:o}:{}})}tt.propTypes={label:h.string.isRequired,onDelete:h.func,canDelete:h.func};const Mn=[{label:"Wallet",value:"app",checked:!0},{label:"Email",value:"email",checked:!0},{label:"Push Kit",value:"push",checked:!0},{label:"Webhook",value:"webhook",checked:!0}];Pt.propTypes={loading:h.bool,onCancel:h.func,onConfirm:h.func};function Pt({loading:n=!1,onCancel:s=()=>{},onConfirm:t=()=>{}}){const{t:r}=te(),[o,l]=v.useState(Mn),[b,u]=v.useState(!0),p=(N,I)=>{I.checked=N.target.checked;const S=o.map(j=>({...j,checked:j.value===I.value?I.checked:j.checked}));l(S)},i=N=>{N.stopPropagation(),t({channels:o.filter(I=>I.checked).map(I=>I.value),isResendFailedOnly:b})};return e.jsxs(y,{className:"resend-config",sx:{padding:"16px 24px"},children:[e.jsx(ee,{variant:"body1",component:"div",className:"check-title",sx:{fontWeight:700,mb:1},children:r("notification.config")}),e.jsx(y,{className:"choose-channel",children:e.jsxs(V,{component:"fieldset",variant:"standard",children:[e.jsx(pt,{component:"legend",children:r("notification.selectChannels")}),e.jsx(qe,{sx:{display:"flex",flexDirection:"row",flexWrap:"wrap",gap:1},children:o.map(N=>e.jsx(me,{control:e.jsx(Me,{checked:N.checked,onChange:I=>p(I,N),name:N.value}),label:N.label},N.value))})]})}),e.jsx(y,{className:"resend-config-footer",children:e.jsx(qe,{children:e.jsx(me,{control:e.jsx(Me,{checked:b,onChange:N=>u(N.target.checked)}),label:r("notification.resendFailedOnly")})})}),e.jsxs(y,{className:"resend-config-footer-tip",sx:{display:"flex",justifyContent:"flex-end",gap:1},children:[e.jsx(Fe,{onClick:N=>{N.stopPropagation(),s()},color:"inherit",children:r("common.cancel")}),e.jsxs(Fe,{onClick:i,color:"primary",disabled:n,variant:"contained",autoFocus:!0,style:{marginLeft:8},children:[n&&e.jsx(ft,{size:16}),r("common.confirm")]})]})]})}Ft.propTypes={notificationId:h.string.isRequired,handleResend:h.func,resending:h.bool};function Ft({notificationId:n,handleResend:s,resending:t=!1}){const{t:r,locale:o}=te(),l=ht(),b=v.useMemo(()=>jt(l,Lt()),[l]),{getReceivers:u,inService:p,teamDid:i,getUser:N,blocklet:I}=Xe(),[S,j]=v.useState(!1),[E,G]=v.useState([]),z=ye({anchorEl:null,position:null}),F=ye({anchorEl:null,position:null}),[B,R]=v.useState(null),[K,q]=v.useState({total:0,pageSize:10,pageCount:0,page:1}),[f,w]=v.useState({searchText:"",page:1,pageSize:10,walletSendStatus:[],pushKitSendStatus:[],emailSendStatus:[],dateRange:[Z().subtract(1,"month").startOf("day").toDate(),Z().endOf("day").toDate()]}),[C,a]=v.useState([]),T=[{label:r("notification.sendStatus.pending"),value:0,status:"pending"},{label:r("notification.sendStatus.success"),value:1,status:"success"},{label:r("notification.sendStatus.failed"),value:2,status:"failed"}],k=async()=>{if(!S&&n)try{j(!0);const c=await u({notificationId:n,...f}),d=c.list.map(m=>({...m,receiverUser:{...m.receiverUser,avatar:It(m.receiverUser.avatar,i,p)}}));G(d),q(c.paging),j(!1)}catch(c){M.error(c.message),j(!1)}};v.useEffect(()=>{k()},[f]);const D=c=>{c.stopPropagation();const d=c.currentTarget;F.anchorEl=d;const m=d.getBoundingClientRect();F.position={top:m.top+window.scrollY,left:m.left+window.scrollX}},re=c=>c.data.length?e.jsx("div",{style:{display:"flex",alignItems:"center",padding:"10px"},children:e.jsx(ce,{className:"resend-btn",size:"small",color:"primary",variant:"contained",startIcon:e.jsx(Je,{}),sx:{".MuiButton-startIcon":{mr:"2px"}},onClick:D,children:r("notification.resend")})}):null,ue={sort:!1,download:!1,print:!1,selectableRows:"multiple",searchPlaceholder:r("common.search"),searchAlwaysOpen:!1,filterType:"checkbox",searchDebounceTime:300,page:K.page-1,rowsPerPage:K.pageSize,count:K.total,searchText:f.searchText,tableBodyMaxHeight:"calc(80vh - 260px)",rowsSelected:C,onRowSelectionChange:(c,d)=>{a(d.map(m=>m.dataIndex))},customToolbarSelect:re},oe=({page:c,rowsPerPage:d,searchText:m,filterList:O})=>{const[,U=[],ne=[],J=[]]=O;f.pageSize!==d?w(H=>({...H,pageSize:d,page:1})):f.page!==c+1?w(H=>({...H,page:c+1})):f.searchText!==m?w(H=>({...H,searchText:m,page:1})):je(U,f.walletSendStatus)?je(ne,f.pushKitSendStatus)?je(J,f.emailSendStatus)||w(H=>({...H,emailSendStatus:J,page:1})):w(H=>({...H,pushKitSendStatus:ne,page:1})):w(H=>({...H,walletSendStatus:U,page:1}))},pe=v.useCallback(async(c,d)=>{if(!d)return!1;const m=await N(d);return m?c==="wallet"?zn(m):c==="email"?Fn(I,m):c==="pushKit"?_n(I,m):c==="webhook"?Wn(m):!0:!1},[N,I]),Re=v.useCallback(c=>Bn(r,c),[r]),fe=()=>{z.anchorEl=null,z.position=null,R(null)},he=()=>{F.anchorEl=null,F.position=null},g=async(c,d,m=!0,O="")=>{if(!(!d.length||!c.length))try{s(c,d,m,O),F.anchorEl||(await Ee(.5),fe())}catch(U){console.error("handleResend error",{error:U})}},x=async({channels:c,isResendFailedOnly:d})=>{const m=C.map(O=>E[O].receiver);await g(c,m,d),await Ee(.5),he(),a([])},A=async(c,d=[],m=!0)=>{try{await g(["webhook"],[c.receiver],m,d)}catch(O){M.error(O.response?O.response.statusText:O.message)}},L=async(c,d,m,O=[],U=!0)=>{if(c.stopPropagation(),Kn(d,m)>=4){M.warning(r("notification.resendLimit"));return}if(!Ve.includes(m)){await A(d,O,U);return}if(c){const J=c.currentTarget,H=J.getBoundingClientRect();z.anchorEl=J,z.position={top:H.top+window.scrollY,left:H.left+window.scrollX}}R({channel:m});try{const J=await pe(m,d.receiver);await Ee(1),R({channel:m,result:J}),(typeof J=="boolean"&&J||Zt(J)&&Object.values(J).every(H=>!!H))&&(await s([m],[d.receiver],U),F.anchorEl||(await Ee(.5),fe()))}catch(J){M.error(J.message)}},W=c=>{w(d=>({...d,dateRange:c,page:1}))},P=(c,d,m,O)=>{c.stopPropagation();const U=m.filter(ne=>ne!==d);w(ne=>({...ne,[O]:U,page:1}))},ie=se(()=>[{label:r("notification.receiver"),name:"receiver",width:200,options:{filter:!1,customBodyRenderLite:c=>{const{receiverUser:d,receiver:m}=E[c];return d?e.jsxs(y,{"data-cy":`member-name-${d.fullName}`,sx:{display:"flex",alignItems:"center",gap:1,justifyContent:"flex-start"},children:[e.jsx(vt,{src:`${d.avatar}?imageFilter=resize&w=48&h=48`,size:32,did:m,shape:"circle",style:{borderRadius:"100%",overflow:"hidden"}}),e.jsx(Se,{children:d.fullName})]},m):e.jsx(bn,{size:14,responsive:!1,compact:!0,copyable:!1,did:m})}}},{label:"Wallet",name:"walletSendStatus",width:200,options:{setCellProps:()=>({className:"sent-status-cell"}),filter:!0,filterType:"custom",filterList:f.walletSendStatus??[],customFilterListOptions:{render:c=>e.jsx(Le,{list:c,label:"Wallet",onDelete:(d,m)=>{d.stopPropagation(),P(d,m,ie[1].options.filterList,"walletSendStatus")}}),update:ke},filterOptions:{names:T,fullWidth:!0,logic:De,display:(c,d,m,O)=>e.jsx(Be,{label:"Wallet",filterList:c,onChange:d,index:m,column:O,filterValues:T})},customBodyRenderLite:c=>{const{walletSendStatus:d,walletSendAt:m,walletSendFailedReason:O}=E[c];return e.jsx(xe,{status:d,updatedAt:m,reason:O,channel:"wallet",onResend:U=>L(U,E[c],"wallet",[],!1)})}}},{label:"Push Kit",name:"pushKitSendStatus",width:200,options:{setCellProps:()=>({className:"sent-status-cell"}),customBodyRenderLite:c=>{const{pushKitSendStatus:d,pushKitSendAt:m,pushKitSendFailedReason:O}=E[c];return e.jsx(xe,{status:d,updatedAt:m,reason:O,channel:"pushkit",onResend:U=>L(U,E[c],"pushKit",[],!1)})},filter:!0,filterType:"custom",filterList:f.pushKitSendStatus??[],customFilterListOptions:{render:c=>e.jsx(Le,{list:c,label:"Push Kit",onDelete:(d,m)=>{d.stopPropagation(),P(d,m,ie[2].options.filterList,"pushKitSendStatus")}}),update:ke},filterOptions:{names:T,fullWidth:!0,logic:De,display:(c,d,m,O)=>e.jsx(Be,{label:"Push Kit",filterList:c,onChange:d,index:m,column:O,filterValues:T})}}},{label:"Email",name:"emailSendStatus",width:200,options:{setCellProps:()=>({className:"sent-status-cell"}),customBodyRenderLite:c=>{const{emailSendStatus:d,emailSendAt:m,emailSendFailedReason:O}=E[c];return e.jsx(xe,{status:d,updatedAt:m,reason:O,channel:"email",onResend:U=>L(U,E[c],"email",[],!1)})},filter:!0,filterType:"custom",filterList:f.emailSendStatus??[],customFilterListOptions:{render:c=>e.jsx(Le,{list:c,label:"Email",onDelete:(d,m)=>{d.stopPropagation(),P(d,m,ie[3].options.filterList,"emailSendStatus")}}),update:ke},filterOptions:{names:T,fullWidth:!0,logic:De,display:(c,d,m,O)=>e.jsx(Be,{label:"Email",filterList:c,onChange:d,index:m,column:O,filterValues:T})}}},{label:"Webhook",name:"webhook",width:200,options:{filter:!1,setCellProps:()=>({className:"sent-status-cell"}),customBodyRenderLite:c=>{const{webhook:d}=E[c];if(!d)return null;const m=Object.entries(d)[0];if(!m)return null;const[O,U]=m,ne=U[0];return e.jsx(y,{sx:{display:"flex",flexDirection:"column",gap:1},children:e.jsxs(y,{className:"webhook-item",sx:{fontSize:12},children:[e.jsx(Se,{maxLength:30,children:O},O),e.jsx(xe,{status:ne.status,updatedAt:ne.sendAt,reason:ne.failedReason,channel:"webhook",onResend:J=>L(J,E[c],"webhook",[O],!1)})]},O)})}}},{label:r("common.createdAt"),name:"createdAt",width:100,options:{filter:!1,customBodyRenderLite:c=>{const{createdAt:d}=E[c];return e.jsx(Nt,{value:d,locale:o,shouldUpdate:!0})}}}],[E,o,f,r]),we=[e.jsx(Ze,{value:f.dateRange,onChange:W},"date-picker"),e.jsx(ce,{variant:"contained",size:"small",color:"primary",loading:S,startIcon:e.jsx(qt,{}),onClick:()=>k(),sx:{".MuiButton-startIcon":{mr:"2px"}},style:{marginLeft:8},children:r("common.refresh")},"refresh")];return e.jsx(y,{sx:{overflow:"auto",".MuiTableCell-head":{whiteSpace:"nowrap",fontWeight:"bold"},".MuiTableCell-root":{paddingRight:"8px",whiteSpace:"nowrap"}},children:e.jsx(Hn,{children:e.jsxs(xt,{theme:b,children:[e.jsx(yt,{className:"receivers-table",locale:o,loading:S,columns:ie,data:E,onChange:oe,options:ue,customButtons:we,components:{TableFilterList:c=>e.jsx(et,{...c,itemComponent:d=>e.jsx(tt,{...d,canDelete:()=>!1})})}}),z.anchorEl&&e.jsx(Ue,{open:!!z.anchorEl,anchorReference:"anchorPosition",anchorPosition:z.position,onClose:fe,anchorOrigin:{vertical:"center",horizontal:"right"},transformOrigin:{vertical:"center",horizontal:"left"},children:e.jsxs($n,{children:[e.jsxs(ee,{variant:"body1",component:"div",className:"check-title",children:[B?.channel," Checking"]}),e.jsx(y,{sx:{display:"flex",flexDirection:"column",gap:"4px"},children:Re(B?.channel).map(c=>{const{type:d,pass:m,fail:O}=c;return!B?.result||B?.result?.[d]?e.jsxs(ee,{variant:"body1",component:"div",className:"check-item",sx:{display:"flex",alignItems:"center",gap:"4px",color:B?.result?.[d]?Oe.success.main:"inherit"},children:[B?.result?e.jsx(Mt,{}):e.jsx(ft,{size:12,sx:{color:Oe.primary.main}}),e.jsx("span",{children:m})]},d):e.jsxs(ee,{variant:"body1",component:"div",className:"check-item",sx:{display:"flex",alignItems:"center",gap:"4px",color:Oe.error.main},children:[e.jsx(Ut,{}),e.jsx("span",{children:O})]},d)})})]})}),F.anchorEl&&e.jsx(Ue,{open:!!F.anchorEl,anchorReference:"anchorPosition",anchorPosition:F.position,onClose:he,anchorOrigin:{vertical:"center",horizontal:"right"},transformOrigin:{vertical:"center",horizontal:"left"},children:e.jsx(Pt,{loading:t,onCancel:he,onConfirm:x})})]})})})}const Un=v.memo(Ft),Hn=ae.div`
2
2
  td.MuiTableCell-footer {
3
3
  border: none !important;
4
4
  }