@abtnode/blocklet-services 1.16.53-beta-20251011-095147-8bd212c5 → 1.16.53-beta-20251013-005429-ca3b05de

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 (125) hide show
  1. package/api/index.js +8 -17
  2. package/api/util/federated.js +10 -5
  3. package/dist/assets/{access-control-C2aF8l7f.js → access-control-7gWIJZpX.js} +1 -1
  4. package/dist/assets/{add-component-core-DaSlPT-f.js → add-component-core-C43eXvX3.js} +1 -1
  5. package/dist/assets/{add-resource-BbsAiWlt.js → add-resource-DT9p1SVt.js} +1 -1
  6. package/dist/assets/{addon-FUH-lSq2.js → addon-iuYOVe1l.js} +1 -1
  7. package/dist/assets/{advanced-C5U4taie.js → advanced-CbrPzmPw.js} +1 -1
  8. package/dist/assets/{aigne-eGqt4yLH.js → aigne-SLmG9KvJ.js} +1 -1
  9. package/dist/assets/{appearance-COFOsk8H.js → appearance-Ck3ODt4R.js} +1 -1
  10. package/dist/assets/{arrow-down.svg-BIpNdtOh.js → arrow-down.svg-ByD_YKms.js} +1 -1
  11. package/dist/assets/{audit-logs-mrNr9NEV.js → audit-logs-RI_HNLsi.js} +1 -1
  12. package/dist/assets/{authorize-DNMdsHLY.js → authorize-C9O917EK.js} +1 -1
  13. package/dist/assets/{bind-account-DHM0aKm4.js → bind-account-DomcrIoC.js} +1 -1
  14. package/dist/assets/{branding-Ds21HJPv.js → branding-CuyMYlwl.js} +1 -1
  15. package/dist/assets/{branding-DCFBnIuE.js → branding-DtTT8LEA.js} +1 -1
  16. package/dist/assets/{branding-C8c4AQBL.js → branding-F6Ls_sBm.js} +1 -1
  17. package/dist/assets/{bundle-avatar-YluGbYkj.js → bundle-avatar-BZh2UMH9.js} +1 -1
  18. package/dist/assets/{complete-ci8dXkdd.js → complete-BuJ7B50g.js} +1 -1
  19. package/dist/assets/{component-CktAV437.js → component-D1cVQ2BQ.js} +2 -2
  20. package/dist/assets/{config-BE0FYeHo.js → config-BlJVgRLh.js} +3 -3
  21. package/dist/assets/{config-hlI_P1F8.js → config-CoBMDXIe.js} +1 -1
  22. package/dist/assets/{config-BDvrfPci.js → config-D8oltJzP.js} +1 -1
  23. package/dist/assets/{config-navigation-D8-g7qAt.js → config-navigation-BmFKLKYy.js} +2 -2
  24. package/dist/assets/{config-space-BLuDOEKJ.js → config-space-CIl0FJy6.js} +1 -1
  25. package/dist/assets/{confirm-Cs-v9Ueu.js → confirm-nzje1i_c.js} +1 -1
  26. package/dist/assets/{connect-Do64lcqi.js → connect-DNK092nY.js} +1 -1
  27. package/dist/assets/{connect-DZzHQL_N.js → connect-DyVkSvx0.js} +1 -1
  28. package/dist/assets/{connect-to-D-Tb_fXt.js → connect-to-BB7Snd6q.js} +1 -1
  29. package/dist/assets/{dashboard-DcdBCHRL.js → dashboard-DA1_SonP.js} +2 -2
  30. package/dist/assets/{delete-confirm-D-H3beUW.js → delete-confirm-BoyKK_sh.js} +1 -1
  31. package/dist/assets/{domain-D1iCGb9_.js → domain-CxT85hKF.js} +1 -1
  32. package/dist/assets/{domain-action-card-dl9BP1dq.js → domain-action-card-k3lim42n.js} +1 -1
  33. package/dist/assets/{domains-VJkxJvLu.js → domains-Dls2DqVC.js} +1 -1
  34. package/dist/assets/{email-CXQwvoco.js → email-DtG_yIEc.js} +1 -1
  35. package/dist/assets/engine-hb4NRjVe.js +1 -0
  36. package/dist/assets/{exchange-passport-By4W6XDH.js → exchange-passport-5PcjWpqT.js} +1 -1
  37. package/dist/assets/{form-B_F_xaXO.js → form-DgDq3Zmy.js} +1 -1
  38. package/dist/assets/{fuel-CW2Evrsd.js → fuel-BywHsiUk.js} +1 -1
  39. package/dist/assets/{gen-access-key-DlPCMbg5.js → gen-access-key-CDwRDR7-.js} +1 -1
  40. package/dist/assets/{gen-simple-access-key-DGvoYxjH.js → gen-simple-access-key-DGsX2Fkj.js} +1 -1
  41. package/dist/assets/{get-safe-url-rD2TSrmk.js → get-safe-url-D-OGuIko.js} +1 -1
  42. package/dist/assets/{home-B4ti5g0W.js → home-Cylh8bGb.js} +1 -1
  43. package/dist/assets/{iframe-BI7fZAER.js → iframe-BPsu-Uyg.js} +1 -1
  44. package/dist/assets/{index-BmZkZYAT.js → index--aKykvS5.js} +1 -1
  45. package/dist/assets/{index-DeRE90O3.js → index-4905JE5e.js} +1 -1
  46. package/dist/assets/{index-4foCOGch.js → index-8b6B9BvP.js} +1 -1
  47. package/dist/assets/{index-DeRDwip-.js → index-B2RPurN4.js} +1 -1
  48. package/dist/assets/{index-DbJX8mTu.js → index-BEDCOb-P.js} +1 -1
  49. package/dist/assets/{index-CM-I96vs.js → index-BMvhWz0X.js} +1 -1
  50. package/dist/assets/{index-Bxd2Cj9Z.js → index-BcnVhON2.js} +1 -1
  51. package/dist/assets/{index-8x51s8zo.js → index-BnQ-_yld.js} +3 -3
  52. package/dist/assets/{index-B8GEVW-7.js → index-C-qSsYu-.js} +1 -1
  53. package/dist/assets/{index-B3Wj0Nic.js → index-CAQ09npc.js} +1 -1
  54. package/dist/assets/{index-B5MKa5ov.js → index-CDZZTyLs.js} +2 -2
  55. package/dist/assets/{index-Ffd9R2jw.js → index-CVvmswkh.js} +1 -1
  56. package/dist/assets/{index-DHsKHttK.js → index-CXsAtHLa.js} +1 -1
  57. package/dist/assets/{index-Dy82BFhx.js → index-CfenaAVg.js} +1 -1
  58. package/dist/assets/{index-Bm6372dL.js → index-Cx7Xa7nl.js} +1 -1
  59. package/dist/assets/{index-CWPu1V9G.js → index-D0uQb3TR.js} +1 -1
  60. package/dist/assets/{index-D-SgeZ2f.js → index-D84o3DbN.js} +1 -1
  61. package/dist/assets/{index-DgBkBy0d.js → index-DM1_TaRl.js} +1 -1
  62. package/dist/assets/{index-CE80LF06.js → index-DccCgoC4.js} +1 -1
  63. package/dist/assets/{index-kYJKn2jR.js → index-Dkx4Mp12.js} +3 -3
  64. package/dist/assets/{index-OE1287Me.js → index-DwSKcE0X.js} +1 -1
  65. package/dist/assets/{index-Ha4kS6kt.js → index-TVXfiYCu.js} +1 -1
  66. package/dist/assets/{index-CwiCg7Wy.js → index-hl-qhRoV.js} +1 -1
  67. package/dist/assets/{index-D46_FTfy.js → index-kYu0y26a.js} +1 -1
  68. package/dist/assets/{index-Bdipd-mG.js → index-spmYO3Ab.js} +1 -1
  69. package/dist/assets/{index-kK-2wGsh.js → index-v2QpDA9k.js} +1 -1
  70. package/dist/assets/{invitation-uW2SRspc.js → invitation-C5kJotVc.js} +1 -1
  71. package/dist/assets/{invitations-BKP1NV2c.js → invitations-BkQFdqNe.js} +1 -1
  72. package/dist/assets/{invite-Cyj0TX33.js → invite-Bi9qMn-u.js} +1 -1
  73. package/dist/assets/{isURL-DOKl6zP6.js → isURL-GpP7YPNs.js} +1 -1
  74. package/dist/assets/{issue-passport-jS72R6Y9.js → issue-passport-CHdu1O5B.js} +1 -1
  75. package/dist/assets/{item-6E9xBb8C.js → item-CQIw46yu.js} +1 -1
  76. package/dist/assets/{landing-page-CfBuAqix.js → landing-page-CjXwLn6s.js} +1 -1
  77. package/dist/assets/{layout-Yt1Ps3ty.js → layout-3MwmBHGM.js} +1 -1
  78. package/dist/assets/{list-CWTC1dNA.js → list-6KE7wBaX.js} +1 -1
  79. package/dist/assets/{list-CbJU6aON.js → list-D_RZEh7_.js} +1 -1
  80. package/dist/assets/{localization-BWvCdRh6.js → localization-BvU49oVa.js} +1 -1
  81. package/dist/assets/{log-D8J_RKs2.js → log-BKfIwEBs.js} +1 -1
  82. package/dist/assets/{login-DqfZ0aMJ.js → login-Br-iz4HM.js} +1 -1
  83. package/dist/assets/{login-oauth-callback-BHyWL0cZ.js → login-oauth-callback-CMnHoqWF.js} +1 -1
  84. package/dist/assets/{logo-uploader-CN181syA.js → logo-uploader-DPSSz4_-.js} +1 -1
  85. package/dist/assets/{lost-passport-BQSFuIDg.js → lost-passport-DePdm4wz.js} +1 -1
  86. package/dist/assets/{open-window-CVPA9xdu.js → open-window-Br_pb9ZW.js} +1 -1
  87. package/dist/assets/{over-due-invoice-payment-gqfc7YHA.js → over-due-invoice-payment-uxF9-1cS.js} +1 -1
  88. package/dist/assets/{overview-BfjhNxe0.js → overview-D8Gh5IS7.js} +1 -1
  89. package/dist/assets/{passport-C9JudxNO.js → passport-B-GT6j4L.js} +1 -1
  90. package/dist/assets/{passport-item-VF3cWzrN.js → passport-item-YF9RfQH3.js} +1 -1
  91. package/dist/assets/{permission-B4abezk1.js → permission-uKfC5D9f.js} +1 -1
  92. package/dist/assets/{preferences-C_XdWNfF.js → preferences-D3ILj2f_.js} +1 -1
  93. package/dist/assets/{profile-embed-QqF7FA6v.js → profile-embed-BFD-Tozn.js} +1 -1
  94. package/dist/assets/{publish-resource-H7eMW32y.js → publish-resource-CV4t0PFh.js} +1 -1
  95. package/dist/assets/{runtime-8vm1QUk_.js → runtime-jHV-CQxJ.js} +1 -1
  96. package/dist/assets/sdk-CByZ4_g5.js +1 -0
  97. package/dist/assets/{security-Dw-d-MTv.js → security-YOGcIKde.js} +1 -1
  98. package/dist/assets/{session-C838MSz1.js → session-DsIBYEWF.js} +1 -1
  99. package/dist/assets/{setup-DegA44sL.js → setup-TVwmAqcY.js} +1 -1
  100. package/dist/assets/{spaces-M_qE7wW_.js → spaces-C0dI3K7C.js} +1 -1
  101. package/dist/assets/{start-BVg7NHO7.js → start-D9z9VSK_.js} +1 -1
  102. package/dist/assets/{starting-progress-Bc97wy6x.js → starting-progress-C1bqyLSx.js} +1 -1
  103. package/dist/assets/{status-QhfaNvgn.js → status-DLtYYu_o.js} +1 -1
  104. package/dist/assets/{step-actions-DTwta5X_.js → step-actions-C6BvFfMg.js} +1 -1
  105. package/dist/assets/{studio-BKBKyaGG.js → studio-CazjgR33.js} +1 -1
  106. package/dist/assets/{team-BxHvUIQ6.js → team-geqUb8FM.js} +1 -1
  107. package/dist/assets/{traffic-bm4qFOVU.js → traffic-DzzcWvVK.js} +1 -1
  108. package/dist/assets/{transfer-BrMoTS5Z.js → transfer-CTqNDZDy.js} +1 -1
  109. package/dist/assets/{unsubscribe-B27dQ-V0.js → unsubscribe-D-R1qemO.js} +1 -1
  110. package/dist/assets/{use-app-logo-ezyDWOV9.js → use-app-logo-DCgwdb4C.js} +1 -1
  111. package/dist/assets/{user-center-uDx2x7Sm.js → user-center-1Ikjxl4_.js} +2 -2
  112. package/dist/assets/{user-follower-CxhX_9BD.js → user-follower-B4ZDD-Mm.js} +1 -1
  113. package/dist/assets/{user-sessions-B3zzrErP.js → user-sessions-DOAxWAOa.js} +1 -1
  114. package/dist/assets/{util-B8m2D-S9.js → util-DKVr8C5h.js} +1 -1
  115. package/dist/assets/{util-k7U_iSB6.js → util-FgS2GkyL.js} +1 -1
  116. package/dist/assets/{wait-connect-DhEi-ni_.js → wait-connect-DgVeMAoQ.js} +1 -1
  117. package/dist/assets/{wizard-obzJ3sCB.js → wizard-Du2TbNOA.js} +1 -1
  118. package/dist/assets/{wizard-components-BZT4jikM.js → wizard-components-BrC7AMh4.js} +1 -1
  119. package/dist/assets/{wrap-locale-CaI-lUtp.js → wrap-locale-vk5eIzsH.js} +1 -1
  120. package/dist/assets/{zh-dnVpNwG1.js → zh-CecJnvFy.js} +1 -1
  121. package/dist/index.html +1 -1
  122. package/dist/service-worker.js +1 -1
  123. package/package.json +23 -23
  124. package/dist/assets/engine-OnFdHI4e.js +0 -1
  125. package/dist/assets/sdk-DRBI7AWf.js +0 -1
@@ -1,4 +1,4 @@
1
- import{j as e,W as u,a6 as z,T as j,at as _e,D as We,cH as J,ao as V,cI as Ke,ak as h,b1 as K,a$ as Ge,s as fe,cJ as be,co as Fe,am as ge,cq as Ye,M as F,aO as Y,bX as $e,aP as $,Q as qe,be as He,aR as Qe,cK as Xe,cL as Je,cM as Ve,cN as Ze,c2 as he}from"./vendor-mui-core-DRxbhqaK.js";import{k as ke,j as je,a as ue}from"./vendor-hooks-BlA8TRnZ.js";import{r as b,u as et}from"./vendor-react-Dvs43sk9.js";import{a9 as O,X as U,_ as E,V as N,aJ as tt,aK as st,aB as nt,c as I,t as ot}from"./index-kYJKn2jR.js";import{H as B,T as D,c as at,a3 as q,j as rt,U as it,n as le,p as ct}from"./vendor-ux-B9VfuZTg.js";import{u as lt}from"./use-mobile-BQQpAf3i.js";import{a as H,d as Ce,a0 as dt,c as pt,D as we,C as me}from"./vendor-utils-CUDP56Ff.js";import{o as Be}from"./vendor-arcblock-DeeG8u0h.js";import{b as ut,u as mt,D as xt,c as de,a as ft}from"./index-Ha4kS6kt.js";import"./index-Y8LQew4k.js";import"./index-BojVbZw0.js";import"./api-rC33aBSs.js";import{u as De,C as gt,D as ht,a as St}from"./connect-to-D-Tb_fXt.js";import{b as yt,c as bt,d as kt,i as jt,e as xe,f as Ct,h as wt,j as Bt}from"./spaces-M_qE7wW_.js";import{f as Q}from"./index-DBs9Ljax.js";import{v as Dt}from"./index-Ba9-ArMT.js";import{E as Et}from"./index-3ePiAFIp.js";import{x as Tt}from"./index-DRYJ0xIl.js";import{g as Se}from"./get-safe-url-rD2TSrmk.js";import{S as It}from"./switch-control-DEpBEl7-.js";import{C as Rt,u as Pt}from"./config-space-BLuDOEKJ.js";import{L as ye}from"./list-header-DMpz8A8v.js";import"./lottie-web-4koyQiv_.js";import"./index-DlrQ2HQP.js";async function At({blockletDid:t,nodeApi:n,spaceGateways:o}){let s=!1;const r=await Promise.all(o.map(async a=>{let{name:c}=a;const i=await yt(a.endpoint);return!H(i)&&i!==c&&(c=i,s=!0),{...a,name:c}}));return s&&await Promise.all(r.filter(a=>a.did).map(a=>n.updateBlockletSpaceGateway({input:{did:t,where:{did:a.did},spaceGateway:{...a}}}))),r}function vt({refresh:t}={}){const{blocklet:n}=O(),o=n?.meta?.did,{api:s}=U();return ke(async()=>{if(!o)return[];const{spaceGateways:r}=await s.getBlockletSpaceGateways({input:{did:o}});return await At({blockletDid:o,nodeApi:s,spaceGateways:r})??[]},{refreshDeps:[o,t],onError(r){r?.message?.includes("not logged")?console.warn(r):(console.error(r),B.error(Q(r)))}})}function Ee({deps:t,setLoading:n,backupDate:o}={deps:[],setLoading:()=>{},backupDate:new Date}){const{blocklet:s}=O(),[r,a]=b.useState([]),{api:c}=U(),[i,d]=b.useMemo(()=>o?[E(o).startOf("day").toISOString(),E(o).endOf("day").toISOString()]:[E().startOf("year").toISOString(),E().endOf("day").toISOString()],[o]),l=Ce(async()=>{try{if(n(!0),!s){a([]);return}const{backups:x}=await c.getBlockletBackups({input:{did:s.meta.did,startTime:i,endTime:d}});a(x??[])}catch(x){console.error(x),B.error(Q(x))}finally{n(!1)}},1e3);return je(async()=>{l()},[s?.meta?.did].concat(t)),{backups:r}}function zt({appDid:t}){const{backups:n}=Ee(),[o,s]=b.useState({message:"",progress:0,completed:!1}),r=U(),{ws:{useSubscription:a}}=r;return a(N.BlockletEvents.backupProgress,c=>{t===c?.appDid&&s(()=>({...c}))},[t]),b.useEffect(()=>{if(n?.length&&dt(n[0]?.status)){const[c]=n;s(()=>({message:c.message,progress:c.progress,completed:c.progress>=100}))}},[n]),o}function Ot({deps:t=[],setLoading:n=()=>{}}={}){const{blocklet:o}=O(),[s,r]=b.useState([]),{api:a}=U(),c=b.useCallback(Ce(async()=>{if(!a||!o?.meta?.did){r([]);return}try{n(!0);const i=E(),d=i.subtract(1,"year"),{summary:l}=await a.getBlockletBackupSummary({input:{did:o.meta.did,startTime:d.toISOString(),endTime:i.toISOString()}});r(Array.isArray(l)?l:[])}catch(i){console.error("Failed to fetch backup summary:",i),B.error(Q(i)),r([])}finally{n(!1)}},1e3),[]);return je(async()=>(await c(),()=>{c.cancel()}),[o?.meta?.did].concat(t)),{backupSummary:s}}const Te=b.createContext({}),{Provider:Ut,Consumer:bs}=Te;function Ie({children:t}){const{t:n}=D(),{api:o}=U(),{blocklet:s}=O(),[r,a]=b.useState(null),[c,i]=b.useState(!1),{data:d,loading:l,mutate:x}=vt({refresh:c}),g=pt(d),m=zt({appDid:s?.appDid}),p=b.useMemo(()=>bt(s?.environments),[s?.environments]),[k,w]=b.useState(!1),[S,y]=b.useState(0),{backups:Z}=Ee({deps:[S,r],setLoading:w,backupDate:r}),[ee,te]=b.useState(0),{backupSummary:se}=Ot({deps:[ee]}),[_,M]=b.useState(d?.find(f=>f.endpoint===p)),T=s?.settings?.autoBackup,P=()=>{i(f=>!f)},ne=()=>{te(f=>f+1)},oe=()=>{y(f=>f+1)},G=async f=>{await o.updateAutoBackup({input:{did:s.meta.did,autoBackup:f}})},X=async()=>{await o.abortBlockletBackup({input:{appPid:s.meta.did}})},ae=async(f,v)=>{try{x(R=>{const A=[...R];return A.push({...f,loading:!0}),A}),await o.addBlockletSpaceGateway({input:{did:s.meta.did,spaceGateway:f}}),p!==v&&await o.configBlocklet({input:{did:[s.meta.did],configs:[{key:N.BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_APP_BACKUP_ENDPOINT,value:v}]}}),M(f),P(),B.success(n("storage.spaces.connectedWithName",{name:f?.name??"DID Spaces"}))}catch(R){throw console.error(R),x(A=>[...A].filter(W=>W.did!==f.did)),R}},re=async f=>{f&&(f.endpoint===p&&(await o.configBlocklet({input:{did:[s.meta.did],configs:[{key:N.BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_APP_BACKUP_ENDPOINT,value:""}]}}),T?.enabled&&await G({enabled:!1})),await o.deleteBlockletSpaceGateway({input:{did:s.meta.did,spaceGatewayDid:f?.did}}),x(v=>{const R=[...v];return R.splice(R.indexOf(f),1),R}),M(f),P())},ie=async f=>{await Promise.all([o.updateBlockletSpaceGateway({input:{did:s.meta.did,where:{did:f.did},spaceGateway:f}}),p!==f.endpoint&&o.configBlocklet({input:{did:[s.meta.did],configs:[{key:N.BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_APP_BACKUP_ENDPOINT,value:f.endpoint}]}})]),B.success(n("storage.spaces.connectedWithName",{name:f?.name??"DID Spaces"})),P()},C=f=>f?.endpoint===p;return e.jsx(Ut,{value:{spaceGateways:d||[],selectedSpaceGateway:_,addSpaceGateway:ae,deleteSpaceGateway:re,updateSpaceGateway:ie,refreshSpaceGateways:P,spaceGatewaysLoading:l,spaceGatewaysFirstLoading:g,spaceGatewayIsSelected:C,updateAutoBackup:G,abortBlockletBackup:X,backupEndpoint:p,backupProgress:m,backups:Z,backupSummary:se,refreshBackupSummary:ne,refreshBackups:oe,setBackupDate:a,backupsLoading:k,autoBackup:T},children:t})}Ie.propTypes={children:u.any.isRequired};function L(){return b.useContext(Te)}function Re({...t}){const{blocklet:n}=O(),{info:o}=U(),{t:s}=D(),r=De({blocklet:n}),a=tt(o),{spaceGateways:c,addSpaceGateway:i}=L(),d={checkFn:we.create({baseURL:me(window.location.origin,st())}).get,webWalletUrl:a,extraParams:{appPid:n.appPid,appDid:r.appDid,appName:r.appName,appDescription:r.appDescription,appUrl:r.appUrl,referrer:r.referrer,scopes:r.scopes,nodeDid:o.did}},l=async({endpoint:g,name:m,did:p})=>{const k=await kt(g);if(!await jt(k)){B.error(s("storage.spaces.gateway.add.invalidUrl"));return}if(c.some(y=>y.endpoint===g)){B.error(s("storage.spaces.gateway.add.duplicate",{name:m}));return}await i({name:m,did:p,url:k,endpoint:g},g)},x=async({spaceGateway:g})=>{try{await l(g)}catch(m){console.error(m),B.error(Q(m))}};return e.jsx(ut,{...t,connectScope:"app",options:d,onSuccess:x})}function Lt(){const{api:t}=U(),{blocklet:n}=O(),{data:o,loading:s}=ke(()=>t.getBlocklet({input:{did:n?.meta?.did,attachDiskInfo:!0,attachRuntimeInfo:!0}}),{ready:!!n?.meta?.did,refreshDeps:[n?.meta?.did]});return{blocklet:o?.blocklet??null,loading:s}}function Pe({...t}){const{t:n}=b.useContext(at),{blocklet:o,loading:s}=Lt();if(o?.diskInfo){const r=(i,d,l)=>e.jsxs(j,{children:[i," ",e.jsx("strong",{children:d?nt(d):"empty"})]}),a=o.environments.reduce((i,d)=>(i[d.key]=d.value,i),{}),c=[{key:"appDir",name:n("blocklet.diskInfo.appDir"),value:r(a.BLOCKLET_APP_DIR,o.diskInfo.app)},{key:"dataDir",name:n("blocklet.diskInfo.dataDir"),value:r(a.BLOCKLET_DATA_DIR,o.diskInfo.data)},{key:"logDir",name:n("blocklet.diskInfo.logDir"),value:r(a.BLOCKLET_LOG_DIR,o.diskInfo.log)},{key:"cacheDir",name:n("blocklet.diskInfo.cacheDir"),value:r(a.BLOCKLET_CACHE_DIR,o.diskInfo.cache)}];return e.jsx(Mt,{component:"div",...t,children:c.map(i=>e.jsx(Dt,{valueComponent:"div",nameWidth:120,name:i.name,children:i.value},i.key))})}return s?e.jsx(z,{}):e.jsx(j,{children:n("blocklet.diskInfo.empty")})}const Mt=_e(j)``;function Ae(){const{t}=D(),{setBackupDate:n,backupSummary:o}=L(),s=mt({key:"lg"}),r=b.useRef(null),a=We(),c=b.useCallback(l=>{n(l)},[n]),i=b.useMemo(()=>{const l=E().add(1,"day"),x=l.subtract(1,"year"),g=new Map(o.map(p=>[p.date,{date:p.date,successCount:p.successCount,errorCount:p.errorCount}])),m=[];for(let p=x.clone();E(p).isBefore(l);p=p.add(1,"day")){const k=p.format("YYYY-MM-DD");m.push(g.get(k)||{date:k,successCount:0,errorCount:0})}return m},[o]),d=b.useMemo(()=>({grid:{containLabel:!0,right:10,top:30,bottom:12},tooltip:{formatter:k=>{const{date:w,successCount:S,errorCount:y}=i[k.dataIndex]||{date:k.data[0],successCount:0,errorCount:0};return[`<div>${t("common.time")}: ${w}</div>`,`<div>${t("common.succeeded")}: ${S}</div>`,`<div>${t("common.failed")}: ${y}</div>`].join(`
1
+ import{j as e,W as u,a6 as z,T as j,at as _e,D as We,cH as J,ao as V,cI as Ke,ak as h,b1 as K,a$ as Ge,s as fe,cJ as be,co as Fe,am as ge,cq as Ye,M as F,aO as Y,bX as $e,aP as $,Q as qe,be as He,aR as Qe,cK as Xe,cL as Je,cM as Ve,cN as Ze,c2 as he}from"./vendor-mui-core-DRxbhqaK.js";import{k as ke,j as je,a as ue}from"./vendor-hooks-BlA8TRnZ.js";import{r as b,u as et}from"./vendor-react-Dvs43sk9.js";import{a9 as O,X as U,_ as E,V as N,aJ as tt,aK as st,aB as nt,c as I,t as ot}from"./index-Dkx4Mp12.js";import{H as B,T as D,c as at,a3 as q,j as rt,U as it,n as le,p as ct}from"./vendor-ux-B9VfuZTg.js";import{u as lt}from"./use-mobile-BQQpAf3i.js";import{a as H,d as Ce,a0 as dt,c as pt,D as we,C as me}from"./vendor-utils-CUDP56Ff.js";import{o as Be}from"./vendor-arcblock-DeeG8u0h.js";import{b as ut,u as mt,D as xt,c as de,a as ft}from"./index-TVXfiYCu.js";import"./index-Y8LQew4k.js";import"./index-BojVbZw0.js";import"./api-rC33aBSs.js";import{u as De,C as gt,D as ht,a as St}from"./connect-to-BB7Snd6q.js";import{b as yt,c as bt,d as kt,i as jt,e as xe,f as Ct,h as wt,j as Bt}from"./spaces-C0dI3K7C.js";import{f as Q}from"./index-DBs9Ljax.js";import{v as Dt}from"./index-Ba9-ArMT.js";import{E as Et}from"./index-3ePiAFIp.js";import{x as Tt}from"./index-DRYJ0xIl.js";import{g as Se}from"./get-safe-url-D-OGuIko.js";import{S as It}from"./switch-control-DEpBEl7-.js";import{C as Rt,u as Pt}from"./config-space-CIl0FJy6.js";import{L as ye}from"./list-header-DMpz8A8v.js";import"./lottie-web-4koyQiv_.js";import"./index-DlrQ2HQP.js";async function At({blockletDid:t,nodeApi:n,spaceGateways:o}){let s=!1;const r=await Promise.all(o.map(async a=>{let{name:c}=a;const i=await yt(a.endpoint);return!H(i)&&i!==c&&(c=i,s=!0),{...a,name:c}}));return s&&await Promise.all(r.filter(a=>a.did).map(a=>n.updateBlockletSpaceGateway({input:{did:t,where:{did:a.did},spaceGateway:{...a}}}))),r}function vt({refresh:t}={}){const{blocklet:n}=O(),o=n?.meta?.did,{api:s}=U();return ke(async()=>{if(!o)return[];const{spaceGateways:r}=await s.getBlockletSpaceGateways({input:{did:o}});return await At({blockletDid:o,nodeApi:s,spaceGateways:r})??[]},{refreshDeps:[o,t],onError(r){r?.message?.includes("not logged")?console.warn(r):(console.error(r),B.error(Q(r)))}})}function Ee({deps:t,setLoading:n,backupDate:o}={deps:[],setLoading:()=>{},backupDate:new Date}){const{blocklet:s}=O(),[r,a]=b.useState([]),{api:c}=U(),[i,d]=b.useMemo(()=>o?[E(o).startOf("day").toISOString(),E(o).endOf("day").toISOString()]:[E().startOf("year").toISOString(),E().endOf("day").toISOString()],[o]),l=Ce(async()=>{try{if(n(!0),!s){a([]);return}const{backups:x}=await c.getBlockletBackups({input:{did:s.meta.did,startTime:i,endTime:d}});a(x??[])}catch(x){console.error(x),B.error(Q(x))}finally{n(!1)}},1e3);return je(async()=>{l()},[s?.meta?.did].concat(t)),{backups:r}}function zt({appDid:t}){const{backups:n}=Ee(),[o,s]=b.useState({message:"",progress:0,completed:!1}),r=U(),{ws:{useSubscription:a}}=r;return a(N.BlockletEvents.backupProgress,c=>{t===c?.appDid&&s(()=>({...c}))},[t]),b.useEffect(()=>{if(n?.length&&dt(n[0]?.status)){const[c]=n;s(()=>({message:c.message,progress:c.progress,completed:c.progress>=100}))}},[n]),o}function Ot({deps:t=[],setLoading:n=()=>{}}={}){const{blocklet:o}=O(),[s,r]=b.useState([]),{api:a}=U(),c=b.useCallback(Ce(async()=>{if(!a||!o?.meta?.did){r([]);return}try{n(!0);const i=E(),d=i.subtract(1,"year"),{summary:l}=await a.getBlockletBackupSummary({input:{did:o.meta.did,startTime:d.toISOString(),endTime:i.toISOString()}});r(Array.isArray(l)?l:[])}catch(i){console.error("Failed to fetch backup summary:",i),B.error(Q(i)),r([])}finally{n(!1)}},1e3),[]);return je(async()=>(await c(),()=>{c.cancel()}),[o?.meta?.did].concat(t)),{backupSummary:s}}const Te=b.createContext({}),{Provider:Ut,Consumer:bs}=Te;function Ie({children:t}){const{t:n}=D(),{api:o}=U(),{blocklet:s}=O(),[r,a]=b.useState(null),[c,i]=b.useState(!1),{data:d,loading:l,mutate:x}=vt({refresh:c}),g=pt(d),m=zt({appDid:s?.appDid}),p=b.useMemo(()=>bt(s?.environments),[s?.environments]),[k,w]=b.useState(!1),[S,y]=b.useState(0),{backups:Z}=Ee({deps:[S,r],setLoading:w,backupDate:r}),[ee,te]=b.useState(0),{backupSummary:se}=Ot({deps:[ee]}),[_,M]=b.useState(d?.find(f=>f.endpoint===p)),T=s?.settings?.autoBackup,P=()=>{i(f=>!f)},ne=()=>{te(f=>f+1)},oe=()=>{y(f=>f+1)},G=async f=>{await o.updateAutoBackup({input:{did:s.meta.did,autoBackup:f}})},X=async()=>{await o.abortBlockletBackup({input:{appPid:s.meta.did}})},ae=async(f,v)=>{try{x(R=>{const A=[...R];return A.push({...f,loading:!0}),A}),await o.addBlockletSpaceGateway({input:{did:s.meta.did,spaceGateway:f}}),p!==v&&await o.configBlocklet({input:{did:[s.meta.did],configs:[{key:N.BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_APP_BACKUP_ENDPOINT,value:v}]}}),M(f),P(),B.success(n("storage.spaces.connectedWithName",{name:f?.name??"DID Spaces"}))}catch(R){throw console.error(R),x(A=>[...A].filter(W=>W.did!==f.did)),R}},re=async f=>{f&&(f.endpoint===p&&(await o.configBlocklet({input:{did:[s.meta.did],configs:[{key:N.BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_APP_BACKUP_ENDPOINT,value:""}]}}),T?.enabled&&await G({enabled:!1})),await o.deleteBlockletSpaceGateway({input:{did:s.meta.did,spaceGatewayDid:f?.did}}),x(v=>{const R=[...v];return R.splice(R.indexOf(f),1),R}),M(f),P())},ie=async f=>{await Promise.all([o.updateBlockletSpaceGateway({input:{did:s.meta.did,where:{did:f.did},spaceGateway:f}}),p!==f.endpoint&&o.configBlocklet({input:{did:[s.meta.did],configs:[{key:N.BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_APP_BACKUP_ENDPOINT,value:f.endpoint}]}})]),B.success(n("storage.spaces.connectedWithName",{name:f?.name??"DID Spaces"})),P()},C=f=>f?.endpoint===p;return e.jsx(Ut,{value:{spaceGateways:d||[],selectedSpaceGateway:_,addSpaceGateway:ae,deleteSpaceGateway:re,updateSpaceGateway:ie,refreshSpaceGateways:P,spaceGatewaysLoading:l,spaceGatewaysFirstLoading:g,spaceGatewayIsSelected:C,updateAutoBackup:G,abortBlockletBackup:X,backupEndpoint:p,backupProgress:m,backups:Z,backupSummary:se,refreshBackupSummary:ne,refreshBackups:oe,setBackupDate:a,backupsLoading:k,autoBackup:T},children:t})}Ie.propTypes={children:u.any.isRequired};function L(){return b.useContext(Te)}function Re({...t}){const{blocklet:n}=O(),{info:o}=U(),{t:s}=D(),r=De({blocklet:n}),a=tt(o),{spaceGateways:c,addSpaceGateway:i}=L(),d={checkFn:we.create({baseURL:me(window.location.origin,st())}).get,webWalletUrl:a,extraParams:{appPid:n.appPid,appDid:r.appDid,appName:r.appName,appDescription:r.appDescription,appUrl:r.appUrl,referrer:r.referrer,scopes:r.scopes,nodeDid:o.did}},l=async({endpoint:g,name:m,did:p})=>{const k=await kt(g);if(!await jt(k)){B.error(s("storage.spaces.gateway.add.invalidUrl"));return}if(c.some(y=>y.endpoint===g)){B.error(s("storage.spaces.gateway.add.duplicate",{name:m}));return}await i({name:m,did:p,url:k,endpoint:g},g)},x=async({spaceGateway:g})=>{try{await l(g)}catch(m){console.error(m),B.error(Q(m))}};return e.jsx(ut,{...t,connectScope:"app",options:d,onSuccess:x})}function Lt(){const{api:t}=U(),{blocklet:n}=O(),{data:o,loading:s}=ke(()=>t.getBlocklet({input:{did:n?.meta?.did,attachDiskInfo:!0,attachRuntimeInfo:!0}}),{ready:!!n?.meta?.did,refreshDeps:[n?.meta?.did]});return{blocklet:o?.blocklet??null,loading:s}}function Pe({...t}){const{t:n}=b.useContext(at),{blocklet:o,loading:s}=Lt();if(o?.diskInfo){const r=(i,d,l)=>e.jsxs(j,{children:[i," ",e.jsx("strong",{children:d?nt(d):"empty"})]}),a=o.environments.reduce((i,d)=>(i[d.key]=d.value,i),{}),c=[{key:"appDir",name:n("blocklet.diskInfo.appDir"),value:r(a.BLOCKLET_APP_DIR,o.diskInfo.app)},{key:"dataDir",name:n("blocklet.diskInfo.dataDir"),value:r(a.BLOCKLET_DATA_DIR,o.diskInfo.data)},{key:"logDir",name:n("blocklet.diskInfo.logDir"),value:r(a.BLOCKLET_LOG_DIR,o.diskInfo.log)},{key:"cacheDir",name:n("blocklet.diskInfo.cacheDir"),value:r(a.BLOCKLET_CACHE_DIR,o.diskInfo.cache)}];return e.jsx(Mt,{component:"div",...t,children:c.map(i=>e.jsx(Dt,{valueComponent:"div",nameWidth:120,name:i.name,children:i.value},i.key))})}return s?e.jsx(z,{}):e.jsx(j,{children:n("blocklet.diskInfo.empty")})}const Mt=_e(j)``;function Ae(){const{t}=D(),{setBackupDate:n,backupSummary:o}=L(),s=mt({key:"lg"}),r=b.useRef(null),a=We(),c=b.useCallback(l=>{n(l)},[n]),i=b.useMemo(()=>{const l=E().add(1,"day"),x=l.subtract(1,"year"),g=new Map(o.map(p=>[p.date,{date:p.date,successCount:p.successCount,errorCount:p.errorCount}])),m=[];for(let p=x.clone();E(p).isBefore(l);p=p.add(1,"day")){const k=p.format("YYYY-MM-DD");m.push(g.get(k)||{date:k,successCount:0,errorCount:0})}return m},[o]),d=b.useMemo(()=>({grid:{containLabel:!0,right:10,top:30,bottom:12},tooltip:{formatter:k=>{const{date:w,successCount:S,errorCount:y}=i[k.dataIndex]||{date:k.data[0],successCount:0,errorCount:0};return[`<div>${t("common.time")}: ${w}</div>`,`<div>${t("common.succeeded")}: ${S}</div>`,`<div>${t("common.failed")}: ${y}</div>`].join(`
2
2
  `)},backgroundColor:a.palette.background.paper,borderColor:a.palette.divider,textStyle:{color:a.palette.text.primary,fontSize:14},extraCssText:`box-shadow: ${a.shadows[2]}; border-radius: 4px;`,padding:[8,10]},visualMap:{show:!1,min:-12,max:12,pieces:[{min:Number.MIN_SAFE_INTEGER,max:-9,color:J[600]},{min:-9,max:-6,color:J[500]},{min:-6,max:-3,color:J[400]},{min:-3,max:-1,color:J[300]},{min:0,max:0,color:a.palette.grey[200]},{min:1,max:3,color:V[300]},{min:3,max:6,color:V[400]},{min:6,max:9,color:V[500]},{min:9,max:Number.MAX_SAFE_INTEGER,color:V[600]}],orient:"horizontal",left:"center",bottom:12,itemWidth:12,itemHeight:12,textStyle:{color:a.palette.text.secondary,fontSize:12}},calendar:{top:30,left:50,right:10,bottom:4,cellSize:[8,8],splitLine:{show:!1},itemStyle:{borderWidth:2,borderColor:a.palette.background.default,color:a.palette.background.default},dayLabel:{show:!0,firstDay:0,nameMap:["","Mon","","Wed","","Fri",""],position:"start",margin:4,fontSize:10,color:a.palette.text.primary,fontWeight:"400",width:20},monthLabel:{show:!0,nameMap:"cn",align:"left",color:a.palette.text.primary,fontWeight:"400",fontSize:12,position:"start",margin:4,width:30,padding:[0,2]},yearLabel:{show:!1},range:[E().subtract(11,"month").startOf("month").format("YYYY-MM-DD"),E().endOf("month").format("YYYY-MM-DD")],orient:"horizontal"},series:{type:"heatmap",coordinateSystem:"calendar",data:i.map(k=>[k.date,k.errorCount?-k.errorCount:k.successCount]),label:{show:!1},itemStyle:{borderWidth:2,borderColor:a.palette.background.default,borderRadius:4},emphasis:{itemStyle:{borderWidth:2,borderColor:Ke[200],color:"inherit"}}}}),[i,t,a]);return e.jsxs(e.Fragment,{children:[e.jsx(h,{ref:r,sx:{maxWidth:"1280px",border:"1px solid",borderColor:"divider",padding:"8px",overflowX:"auto"},children:e.jsx(h,{sx:{width:"1200px",height:"180px",position:"relative"},children:e.jsx(Et,{option:d,style:{height:"100%",width:"100%"},notMerge:!0,lazyUpdate:!1,opts:{renderer:"canvas"},onEvents:{click:l=>{l.componentType==="series"&&l.data&&c(l.data[0])}}})})}),e.jsx(h,{sx:{display:"flex",justifyContent:"flex-end",mt:1,mr:s?2:5,mb:2},children:e.jsxs(K,{direction:s?"column":"row",spacing:s?2:1,sx:{width:"100%",justifyContent:"flex-start",alignItems:s?"flex-start":"center"},children:[e.jsxs(K,{direction:"row",spacing:1,sx:{alignItems:"center"},children:[e.jsx(h,{sx:{width:32,height:12,borderRadius:.5,background:"linear-gradient(90deg, #8B5000 0%, #A36200 33%, #C17700 66%, #E29000 100%)"}}),e.jsx(j,{variant:"body2",sx:{color:"text.secondary"},children:t("storage.spaces.backup.failed")})]}),e.jsxs(K,{direction:"row",spacing:1,sx:{alignItems:"center"},children:[e.jsx(h,{sx:{width:32,height:12,borderRadius:.5,bgcolor:"grey.200",border:"1px solid",borderColor:"grey.200"}}),e.jsx(j,{variant:"body2",sx:{color:"text.secondary"},children:t("storage.spaces.backup.without")})]}),e.jsxs(K,{direction:"row",spacing:1,sx:{alignItems:"center"},children:[e.jsx(h,{sx:{width:32,height:12,borderRadius:.5,background:"linear-gradient(90deg, #9be9a8 0%, #40c463 33%, #30a14e 66%, #216e39 100%)"}}),e.jsx(j,{variant:"body2",sx:{color:"text.secondary"},children:t("storage.spaces.backup.succeeded")})]})]})})]})}const Nt=fe(({className:t,...n})=>e.jsx(ge,{...n,classes:{popper:t}}))(()=>({".MuiTooltip-tooltip":{backgroundColor:"transparent",padding:0,margin:0,boxShadow:"none",maxWidth:"none"},".MuiTooltip-arrow":{color:"rgba(230, 235, 245, 1)"}}));function ve({status:t,message:n="",createdAt:o}){const{t:s}=D(),r=t===I.BACKUPS.STATUS.PROGRESS&&E().diff(o,"hours")>=I.BACKUPS.TIMEOUT_HOURS,a=r&&s("common.timeoutError"),c=t===I.BACKUPS.STATUS.PROGRESS&&!r,i=t===I.BACKUPS.STATUS.SUCCEEDED&&!r;return c?e.jsxs(j,{sx:{display:"inline-flex",alignItems:"center",fontSize:"14px"},children:[e.jsx(z,{sx:{marginRight:"4px"},size:"12px"}),s("common.progress")]}):i?e.jsx(q,{type:"success",children:s("common.succeeded")}):e.jsxs(h,{sx:{display:"inline-flex",alignItems:"center"},children:[e.jsx(q,{type:"error",children:s("common.failed")}),e.jsx(ge,{style:{display:"flex",alignItems:"center",flexShrink:0},title:n||a,children:e.jsx(be,{children:e.jsx(Ye,{style:{width:"24px",height:"24px"},color:"error"})})})]})}ve.propTypes={status:u.string.isRequired,message:u.string,createdAt:u.string.isRequired};function ze({metadata:t={}}){const{t:n}=D();if(H(t))return e.jsx(q,{type:"success",children:n("common.succeeded")});const o=t.count||0,s=t.size||0,r=Tt(s,{iec:!0}),a=e.jsxs(h,{sx:{p:1,borderRadius:1,boxShadow:2,color:"black",backgroundColor:"white"},children:[e.jsxs(j,{variant:"body2",children:[n("common.fileCount"),": ",o]}),e.jsxs(j,{variant:"body2",children:[n("common.fileSize"),": ",r]})]});return e.jsxs(h,{sx:{display:"inline-flex",alignItems:"center"},children:[e.jsx(q,{type:"success",children:n("common.succeeded")}),e.jsx(Nt,{title:a,style:{display:"flex",alignItems:"center",flexShrink:0},placement:"left",children:e.jsx(be,{children:e.jsx(Fe,{style:{width:"24px",height:"24px"},color:"primary"})})})]})}ze.propTypes={metadata:u.object};function Oe(){const{t,locale:n}=D(),{spaceGateways:o,backups:s,backupsLoading:r}=L(),a=b.useMemo(()=>[{label:"DID Space",name:"target",options:{customBodyRenderLite:i=>{const{targetUrl:d,targetName:l,status:x,createdAt:g}=s[i],m=x===I.BACKUPS.STATUS.PROGRESS&&E().diff(g,"hours")>=I.BACKUPS.TIMEOUT_HOURS,p=x===I.BACKUPS.STATUS.SUCCEEDED&&!m,k=l||o.find(w=>d?.includes(xe(w?.endpoint)))?.name||"Unknown DID Space";return p?e.jsx(Ge,{href:d,target:"_blank",sx:{fontSize:"16px"},children:k}):e.jsx(j,{variant:"body1",sx:{fontSize:"16px"},children:k})}}},{label:t("common.strategy"),name:"strategy",options:{customBodyRender:i=>{const d=t(i===0?"common.auto":"common.manual");return e.jsx(q,{children:d})}}},{label:t("common.startTime"),name:"createdAt",options:{customBodyRender:i=>E(i).format("YYYY-MM-DD HH:mm:ss")}},{label:t("common.endTime"),name:"updatedAt",options:{customBodyRender:i=>H(i)?"":E(i).format("YYYY-MM-DD HH:mm:ss")}},{label:t("common.status"),name:"status",options:{customBodyRenderLite:i=>{const d=s?.[i]??{},{status:l,message:x,createdAt:g,metadata:m}=d,p=l===I.BACKUPS.STATUS.PROGRESS&&E().diff(g,"hours")>=I.BACKUPS.TIMEOUT_HOURS,k=l===I.BACKUPS.STATUS.PROGRESS&&!p,w=l===I.BACKUPS.STATUS.SUCCEEDED&&!p;return k?e.jsxs(j,{sx:{display:"inline-flex",alignItems:"center",fontSize:"14px"},children:[e.jsx(z,{sx:{marginRight:"4px"},size:"12px"}),t("common.progress")]}):w?e.jsx(ze,{metadata:m}):e.jsx(ve,{status:l,message:x,createdAt:g})}}}],[s,o,t]),c=b.useMemo(()=>!s?.length,[s]);return e.jsx(e.Fragment,{children:c?e.jsx(h,{sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"100px",color:"#9397A1",marginTop:"16px",marginBottom:"24px"},children:t("storage.spaces.record.emptyData")}):e.jsx(rt,{title:"",loading:r,data:s,columns:a,emptyNode:t("storage.spaces.record.emptyData",n),options:{download:!1,filter:!1,print:!1,search:!1,viewColumns:!1}})})}function _t(){const{t}=D();return e.jsxs(h,{children:[e.jsxs(h,{sx:{display:"flex",gap:3,flexDirection:{xs:"column",md:"row"}},children:[e.jsxs(h,{sx:{display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",alignContent:"center",minWidth:240},children:[e.jsx(xt,{style:{cursor:"pointer",width:"150px",height:"100%",maxHeight:160}}),e.jsx(j,{sx:{my:2,textAlign:"center",color:"text.secondary"},children:t("storage.spaces.connect.provider")}),e.jsx(Re,{})]}),e.jsxs(h,{sx:{flexGrow:1,minWidth:0},children:[e.jsx(h,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:3},children:e.jsx(j,{sx:{fontSize:"1.2rem",fontWeight:"bold"},children:t("storage.spaces.backup.records")})}),e.jsx(Ae,{})]})]}),e.jsx(Oe,{sx:{marginTop:"24px"}}),e.jsx(j,{sx:{fontSize:"1.2rem",fontWeight:"bold",mb:2,mt:2},children:t("common.dataStorage")}),e.jsx(Pe,{})]})}function Ue({spaceGateway:t,onConfirm:n=()=>{},onCancel:o=()=>{}}){const{t:s}=D(),[r,a]=b.useState(!1),[c,i]=b.useState(!1),d=(g,m)=>{g?.preventDefault(),g?.stopPropagation(),a(m)},l=async g=>{try{g?.stopPropagation(),i(!0),await n?.(t),a(!1)}catch(m){console.error(m),B.error(`${s("storage.space.gateway.delete.failed")}: ${Q(m)}`)}finally{a(!1),i(!1)}},x=g=>{d(g,!1),o?.(g)};return e.jsxs(e.Fragment,{children:[e.jsxs(F,{color:"red",onClick:g=>d(g,!0),children:[e.jsx(Y,{style:{minWidth:24,color:"red"},children:e.jsx($e,{fontSize:"small"})}),e.jsx($,{style:{color:"red"},children:s("common.disconnect")})]}),e.jsx(it,{title:s("storage.spaces.gateway.delete.title"),open:r,confirmButton:{text:s("common.confirm"),props:{size:"small",variant:"contained",color:"error",loading:c}},cancelButton:{text:s("common.cancel"),props:{size:"small",variant:"outlined",disabled:c}},onConfirm:l,onCancel:x,children:e.jsx(j,{sx:{wordWrap:"break-word"},children:s("storage.spaces.gateway.delete.descForBackup",{name:`${t?.name}`})})})]})}Ue.propTypes={spaceGateway:u.shape({name:u.string.isRequired,url:u.string.isRequired,protected:u.bool}).isRequired,onConfirm:u.func,onCancel:u.func};function Le({spaceGateway:t,selected:n,onDelete:o=()=>{},onConnect:s=()=>{},enableSwitchToSpace:r=!0,backupInProgress:a=!1,...c}){const{abortBlockletBackup:i}=L(),[d,l]=b.useState(null),{t:x}=D(),[g,m]=b.useState(!1),p=(S,y)=>{S.stopPropagation(),S.preventDefault(),l(y&&S.currentTarget)},k=async S=>{try{m(!0),p(S,!1),await s(t)}catch(y){console.error(y),B.error(y.message)}finally{m(!1)}},w=async S=>{try{m(!0),p(S,!1),await i()}catch(y){console.error(y),B.error(y.message)}finally{m(!1)}};return e.jsxs(e.Fragment,{children:[g||t?.loading?e.jsx(z,{sx:{ml:1},size:"24px"}):e.jsx(qe,{"aria-label":"more","aria-controls":"actions-menu","aria-haspopup":"true","data-cy":"trigger-blocklet-actions",variant:"outlined",size:"small",onClick:S=>p(S,!0),...c,children:e.jsx(He,{})}),e.jsxs(Qe,{id:"simple-menu",anchorEl:d,keepMounted:!0,open:!!d,onClose:S=>p(S,!1),children:[e.jsxs(F,{onClick:S=>{p(S,!1),window.open(Se(t.endpoint?Ct(t.endpoint):t.url,{allowDomains:null}))},children:[e.jsx(Y,{style:{minWidth:24},children:e.jsx(Xe,{fontSize:"small"})}),e.jsx($,{children:x("common.open")})]}),e.jsxs(F,{onClick:S=>{p(S,!1),window.open(Se(wt(t.endpoint),{allowDomains:null}))},children:[e.jsx(Y,{style:{minWidth:24},children:e.jsx(Je,{fontSize:"small"})}),e.jsx($,{children:x("storage.spaces.strategy.viewBackupFiles")})]}),!n&&r&&e.jsxs(F,{onClick:k,children:[e.jsx(Y,{style:{minWidth:24},children:e.jsx(Ve,{fontSize:"small"})}),e.jsx($,{children:x("storage.spaces.connect.switchToSpace")})]}),a&&e.jsxs(F,{onClick:w,children:[e.jsx(Y,{style:{minWidth:24},children:e.jsx(Ze,{fontSize:"small"})}),e.jsx($,{children:x("storage.spaces.connect.abortBlockletBackup")})]}),!a&&e.jsx(Ue,{spaceGateway:t,onConfirm:async()=>{l(null),await o?.(t)},onCancel:()=>l(null)})]})]})}Le.propTypes={spaceGateway:u.shape({name:u.string.isRequired,url:u.string.isRequired,protected:u.bool,endpoint:u.string.isRequired,loading:u.bool}).isRequired,selected:u.bool.isRequired,enableSwitchToSpace:u.bool,onDelete:u.func,onConnect:u.func,backupInProgress:u.bool};const Wt=fe(({className:t,...n})=>e.jsx(ge,{...n,classes:{popper:t}}))(()=>({".MuiTooltip-tooltip":{backgroundColor:"transparent",padding:0,margin:0,boxShadow:"none",maxWidth:"none"},".MuiTooltip-arrow":{color:"rgba(230, 235, 245, 1)"}}));function Me({spaceGateway:t,spaceStatus:n,selected:o,onConnected:s=()=>{},onDeleted:r=()=>{},onBackedUp:a=()=>{}}){const{t:c,locale:i}=D(),{blocklet:d}=O(),{api:l,info:{did:x}}=U(),{appDid:g,appName:m,appDescription:p,scopes:k,appUrl:w,referrer:S}=De({blocklet:d}),{backupProgress:y,updateSpaceGateway:Z,deleteSpaceGateway:ee,refreshBackupSummary:te,refreshBackups:se}=L(),[_,M]=b.useState(!1),[T,P]=b.useState({open:!1,action:"one-click-authorization",checkTimeout:1e3*300,messages:{title:c("storage.spaces.authorize.title",{appName:m},i),scan:c("storage.spaces.authorize.scan",{appName:m},i),confirm:"",success:e.jsx(j,{gutterBottom:!0,children:c("storage.spaces.authorize.success")})},onClose:()=>{P(C=>({...C,open:!1}))}}),ne=o&&!_&&n===de.DISCONNECTED,oe=o&&!_&&!t.loading&&n===de.CONNECTED,G=o&&_&&n===de.CONNECTED&&y?.progress>=0,X=async()=>{try{if(await Bt(t?.endpoint)){await l.configBlocklet({input:{did:[d.meta.did],configs:[{key:N.BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_APP_BACKUP_ENDPOINT,value:t.endpoint}]}}),B.success(c("storage.spaces.connect.switchToSpaceSucceeded",{name:t.name?`(${t.name})`:""})),s?.(null,t);return}}catch(C){console.error(C),s?.(C,t);return}P(C=>({...C,open:!0,prefix:me(t.url,"space/api/did"),baseUrl:new URL(t.url).origin,checkFn:we.create({baseURL:me(t.url,"space")}).get,extraParams:{appDid:g,appName:m,appDescription:p,scopes:k,appUrl:w,referrer:S,nodeDid:x,spaceDid:t.did}}))},ae=async(C,f)=>{const v=f(C.endpoint),R=xe(v),A=C.space?f(C.space):{};if(t.did&&R!==t.did){P(Ne=>({...Ne,open:!1}));const W=c("storage.spaces.gateway.switch.failedForMismatchSpace",{name:A?.name?A.name:""});B.error(W),s?.(new Error(W),t);return}const ce={...t,name:A.name??"DID Space",did:A.did??xe(v),endpoint:v};await Z(ce),P(W=>({...W,open:!1})),s?.(null,ce)},re=async()=>{try{if(_)return;M(!0),await l.backupBlocklet({input:{appDid:d.appDid,to:"spaces"}})}catch(C){console.error(C),B.error(C.message),a?.(C,t)}finally{M(!0)}},ie=async()=>{try{await ee(t),B.success(c("storage.spaces.gateway.delete.succeeded",{name:t.name?`(${t.name})`:""})),r?.(null,t)}catch(C){console.error(C),r?.(C,t)}};return b.useEffect(()=>{y?.completed?(o&&(y?.progress===100?(B.success(c("storage.spaces.backupSuccessfully")),a?.(null,t)):y.message&&a?.(new Error(y?.message),t),y.progress=0,y.message=""),M(!1),te(),se()):y.progress&&M(!0)},[y]),e.jsxs(e.Fragment,{children:[e.jsxs(h,{sx:{display:"flex",alignItems:"center",".action-btn":{borderRadius:1,marginLeft:1}},children:[oe&&e.jsx(le,{className:"action-btn",variant:"outlined",size:"small",onClick:re,children:c("storage.spaces.strategy.backupNow")}),ne&&e.jsx(le,{className:"action-btn",variant:"outlined",size:"small",onClick:X,children:c("storage.spaces.disconnected.reconnectNow")}),G&&e.jsx(Wt,{title:y?.message&&e.jsx(h,{sx:{p:1,borderRadius:1,boxShadow:2,color:"black",backgroundColor:"white"},children:e.jsx(j,{variant:"body2",children:y.message})}),children:e.jsxs(le,{className:"action-btn",variant:"outlined",size:"small",sx:{minWidth:70},children:[e.jsx(z,{variant:"determinate",value:y?.progress,size:14,sx:{mr:1}}),y?.progress,"%"]})}),e.jsx(ot,{forceConnected:!1,saveConnect:!1,prefix:T.prefix,open:T.open,popup:!0,action:T.action,baseUrl:T.baseUrl,checkFn:T.checkFn,onSuccess:ae,onClose:T.onClose,checkTimeout:T.checkTimeout,extraParams:T.extraParams,messages:T.messages,locale:i},"get-endpoint")]}),e.jsx(Le,{sx:{minWidth:32,padding:"2px 4px",ml:1},spaceGateway:t,selected:o,onDelete:ie,onConnect:X,enableSwitchToSpace:y?.completed||H(y?.message),backupInProgress:G})]})}Me.propTypes={spaceGateway:u.shape({did:u.string.isRequired,name:u.string.isRequired,url:u.string.isRequired,endpoint:u.string.isRequired,protected:u.bool,loading:u.bool}).isRequired,spaceStatus:u.string.isRequired,selected:u.bool.isRequired,onConnected:u.func,onDeleted:u.func,onBackedUp:u.func};function Kt({...t}){const{t:n}=D();return e.jsxs(h,{...t,children:[e.jsx(h,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:3},children:e.jsx(j,{sx:{fontSize:"1.2rem",fontWeight:"bold"},children:n("storage.spaces.backup.records")})}),e.jsx(Ae,{}),e.jsx(Oe,{})]})}function Gt({...t}){const{t:n}=D(),{autoBackup:o,updateAutoBackup:s}=L(),r=async()=>{try{const a=!o?.enabled;await s({enabled:a}),B.success(n(a?"storage.spaces.autoBackup.enabled":"storage.spaces.autoBackup.disabled"))}catch(a){B.error(a.message)}};return e.jsx(It,{checked:!!o?.enabled,onChange:r,name:"enableWelcomePage",labelProps:{label:e.jsx(j,{sx:{marginRight:"8px"},children:e.jsx("span",{children:n("storage.spaces.autoBackup.title")})})},style:{...t.style}})}function Ft(){const{t}=D(),{spaceGateways:n,spaceGatewaysLoading:o,spaceGatewayIsSelected:s}=L(),r=o&&!n?.length,a=({spaceGateway:c,spaceStatus:i,selected:d,refresh:l})=>e.jsx(Me,{spaceGateway:c,spaceStatus:i,selected:d,onConnected:()=>l(),onBackedUp:x=>x&&l()});return e.jsxs(h,{sx:{display:"flex",flexDirection:"column"},children:[e.jsxs(h,{sx:{display:"flex",flexDirection:{xs:"column",md:"row"},gap:{xs:1,md:2},justifyContent:{xs:"center",md:"flex-start"},alignItems:{xs:"flex-start",md:"center"}},children:[e.jsx(j,{sx:{fontSize:"1.2rem",fontWeight:"bold",flexGrow:1},children:t("storage.spaces.connected.title")}),e.jsx(Gt,{}),e.jsx(Re,{})]}),e.jsx(h,{sx:{mt:2},children:r?e.jsx(h,{sx:{display:"flex",justifyContent:"center"},children:e.jsx(z,{})}):e.jsx(he,{container:!0,spacing:2,children:e.jsx(e.Fragment,{children:n.map(c=>e.jsx(he,{size:{xs:12,md:6},children:e.jsx(ft,{endpoint:c.endpoint,selected:s(c),action:a},c.endpoint)},c.endpoint))})})}),e.jsx(Kt,{sx:{marginTop:"24px"}}),e.jsx(j,{sx:{fontSize:"1.2rem",fontWeight:"bold",mb:2},children:t("common.dataStorage")}),e.jsx(Pe,{})]})}function Yt(){const{spaceGatewaysFirstLoading:t,spaceGateways:n}=L();return t?e.jsx(Be,{relative:"parent",children:e.jsx(z,{})}):H(n)?e.jsx(_t,{}):e.jsx(Ft,{})}function $t(){return e.jsx(Ie,{children:e.jsx(Yt,{})})}function qt(){const{spaceGateway:t,settingStorageEndpoint:n,updateSpaceGateway:o,hasStorageEndpoint:s,loading:r,storageEndpoint:a}=Pt(),c=ue(()=>({display:"flex",alignItems:"center",justifyContent:"center",paddingTop:"16px"}));return r?e.jsx(Be,{relative:"parent",children:e.jsx(z,{})}):e.jsxs(h,{sx:{maxWidth:"md",position:"relative"},children:[s?e.jsx(gt,{spaceGateway:t,settingStorageEndpoint:n}):e.jsx(ht,{}),e.jsx(h,{sx:c,children:e.jsx(St,{onConnect:o,storageEndpoint:a})})]})}function Ht(){const{t}=D();return e.jsxs(Rt,{children:[e.jsxs(K,{spacing:1,sx:{marginBottom:2},children:[e.jsx(j,{sx:{fontSize:"1.2rem",fontWeight:"bold"},children:t("storage.appLevel.title")}),e.jsx(j,{sx:{color:"text.secondary"},children:t("storage.appLevel.description")})]}),e.jsx(qt,{})]})}function Qt({navOrientation:t="vertical",...n}){const{t:o,locale:s}=D(),{blocklet:r}=O(),a=lt({key:"md"}),[c,i]=et(),d=c.get("tab")||"backup",l=a?"horizontal":t,x=ue(()=>{const w=[{label:o("common.backup"),value:"backup"}],S=r?.capabilities?.didSpace;return(S===N.BLOCKLET_APP_SPACE_REQUIREMENT.REQUIRED||S===N.BLOCKLET_APP_SPACE_REQUIREMENT.REQUIRED_ON_SETUP)&&w.push({label:o("common.storage"),value:"storage"}),w},[s,l]),m=ue(()=>({backup:e.jsx($t,{}),storage:e.jsx(Ht,{})}))[d],p=w=>{i(S=>(w==="backup"?S.delete("tab"):S.set("tab",w),S))};if(x.length<=1)return e.jsx(pe,{children:m});const k=e.jsx(ct,{tabs:x,current:d,orientation:l,onChange:p,sx:[{borderRight:1,height:"100%",borderColor:"divider"},l==="horizontal"&&{borderRight:0}]});if(l==="vertical")return e.jsx(h,{...n,children:e.jsxs(K,{direction:{md:"column",lg:"row"},sx:{gap:2},children:[e.jsx(h,{sx:{flexShrink:0},children:e.jsx(ye,{left:k})}),e.jsx(h,{sx:{flexGrow:1,minWidth:0},children:e.jsx(pe,{sx:{mt:1},children:m})})]})});if(l==="horizontal")return e.jsxs(h,{...n,children:[e.jsx(ye,{left:k}),e.jsx(pe,{sx:{mt:2},children:m})]})}Qt.propTypes={navOrientation:u.oneOf(["vertical","horizontal"])};const pe=fe(h)`
3
3
  position: relative;
4
4
  min-height: 66vh;
@@ -1,4 +1,4 @@
1
- import{T as M,H as q,P as N,q as Y,k as ve,j as Ce,a0 as Se}from"./vendor-ux-B9VfuZTg.js";import{o as Te,k as le,t as Ie}from"./vendor-hooks-BlA8TRnZ.js";import{r as E,a as ae}from"./vendor-react-Dvs43sk9.js";import{j as e,Y as Re,bC 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 $,bf as _,a5 as J,V as G,S as Z,b4 as Oe,U as L,I as B,ci as Pe,bh as $e,a7 as Ae,F as qe,W as t,b1 as R,a3 as ce,c2 as ee,cj as Le,aO as Me,aP as Be,ck as Fe,cl as He,cm as Ne,s as oe,aU as Ue,aj as _e,J as Ke,cn as Ve,aZ as Ye,cc as Je,bb as Qe,cb as Xe}from"./vendor-mui-core-DRxbhqaK.js";import{B as de,o as pe,l as ue}from"./index-DeRDwip-.js";import{X as K,c as xe,_ as Ge,a9 as Ze,b5 as Q}from"./index-kYJKn2jR.js";import{u as V}from"./team-BxHvUIQ6.js";import{u as et}from"./use-mobile-BQQpAf3i.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-CUDP56Ff.js";import{C as st}from"./confirm-Cs-v9Ueu.js";import{A as nt}from"./actions-B4VXcSRp.js";import{T as ie}from"./table-tips-rCE1XKlc.js";import"./lottie-web-4koyQiv_.js";import"./vendor-arcblock-DeeG8u0h.js";import"./session-C838MSz1.js";import"./isURL-DOKl6zP6.js";import"./use-app-logo-ezyDWOV9.js";import"./index-DBs9Ljax.js";const it=i=>{const[u,c]=E.useState(null),[f,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]),b=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(()=>{b()},[j]),{openEvent:u,setOpenEvent:c,eventsBySource:l,loading:f,error:w,loadData:b}};function ge({eventsBySource:i,selectedEvents:u,setSelectedEvents:c,error:f=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]),b=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===b}),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($,{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(G,{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(Z,{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(Pe,{}):e.jsx($e,{})})]})]})}),m.length>0&&e.jsx(Ae,{in:O,timeout:"auto",unmountOnExit:!0,children:e.jsx(G,{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(Z,{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)})})}),f&&e.jsx(qe,{error:!0,sx:{mt:1},children:f})]})}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 be({id:i=null,url:u="",description:c="",enabledEvents:f=[],onSubmit:r,onClose:w=()=>{}}){const{t:x}=M(),[j,l]=E.useState({}),{teamDid:b}=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:b,id:i,data:s}});q.success(`${x("webhookEndpoint.updateWebhook")} ${x("webhookEndpoint.success")}`),r(h)}else{const h=await g.createWebhookEndpoint({input:{teamDid:b,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(f.reduce((o,d)=>(o[`${d.type}-${d.source}`]=!0,o),{}))},[v,l,u,c,f]),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")})]})]})})}be.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 fe(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?Ge(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 P({value:i,label:u,tip:c="",divider:f=!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($,{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})]}),f&&e.jsx(ce,{orientation:"vertical",flexItem:!0})]})}P.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:f=1.5}){return e.jsxs(R,{className:"section-header",direction:"row",sx:{justifyContent:"space-between",alignItems:"center",flexWrap:"wrap",gap:1,mb:c,mt:f,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 f=new Date(c.createdAt).toLocaleDateString();u[f]||(u[f]=[]),u[f]?.push(c)}),u};function ye({eventId:i="",webhookEndpointId:u="",event:c=null}){const{api:f,ws:{useSubscription:r}}=K(),{t:w}=M(),{teamDid:x}=V(),{blocklet:j}=Ze(),{data:l,loadMore:b,loadingMore:g,loading:y,mutate:z}=Te(s=>{const k=s?Math.ceil(s.list.length/15)+1:1;return f.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(A=>A.id===s.id?{...A,...s}:A);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 f.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(A=>A?.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(G,{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(Z,{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:b,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($,{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,P as N,q as Y,k as ve,j as Ce,a0 as Se}from"./vendor-ux-B9VfuZTg.js";import{o as Te,k as le,t as Ie}from"./vendor-hooks-BlA8TRnZ.js";import{r as E,a as ae}from"./vendor-react-Dvs43sk9.js";import{j as e,Y as Re,bC 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 $,bf as _,a5 as J,V as G,S as Z,b4 as Oe,U as L,I as B,ci as Pe,bh as $e,a7 as Ae,F as qe,W as t,b1 as R,a3 as ce,c2 as ee,cj as Le,aO as Me,aP as Be,ck as Fe,cl as He,cm as Ne,s as oe,aU as Ue,aj as _e,J as Ke,cn as Ve,aZ as Ye,cc as Je,bb as Qe,cb as Xe}from"./vendor-mui-core-DRxbhqaK.js";import{B as de,o as pe,l as ue}from"./index-B2RPurN4.js";import{X as K,c as xe,_ as Ge,a9 as Ze,b5 as Q}from"./index-Dkx4Mp12.js";import{u as V}from"./team-geqUb8FM.js";import{u as et}from"./use-mobile-BQQpAf3i.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-CUDP56Ff.js";import{C as st}from"./confirm-nzje1i_c.js";import{A as nt}from"./actions-B4VXcSRp.js";import{T as ie}from"./table-tips-rCE1XKlc.js";import"./lottie-web-4koyQiv_.js";import"./vendor-arcblock-DeeG8u0h.js";import"./session-DsIBYEWF.js";import"./isURL-GpP7YPNs.js";import"./use-app-logo-DCgwdb4C.js";import"./index-DBs9Ljax.js";const it=i=>{const[u,c]=E.useState(null),[f,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]),b=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(()=>{b()},[j]),{openEvent:u,setOpenEvent:c,eventsBySource:l,loading:f,error:w,loadData:b}};function ge({eventsBySource:i,selectedEvents:u,setSelectedEvents:c,error:f=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]),b=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===b}),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($,{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(G,{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(Z,{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(Pe,{}):e.jsx($e,{})})]})]})}),m.length>0&&e.jsx(Ae,{in:O,timeout:"auto",unmountOnExit:!0,children:e.jsx(G,{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(Z,{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)})})}),f&&e.jsx(qe,{error:!0,sx:{mt:1},children:f})]})}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 be({id:i=null,url:u="",description:c="",enabledEvents:f=[],onSubmit:r,onClose:w=()=>{}}){const{t:x}=M(),[j,l]=E.useState({}),{teamDid:b}=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:b,id:i,data:s}});q.success(`${x("webhookEndpoint.updateWebhook")} ${x("webhookEndpoint.success")}`),r(h)}else{const h=await g.createWebhookEndpoint({input:{teamDid:b,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(f.reduce((o,d)=>(o[`${d.type}-${d.source}`]=!0,o),{}))},[v,l,u,c,f]),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")})]})]})})}be.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 fe(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?Ge(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 P({value:i,label:u,tip:c="",divider:f=!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($,{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})]}),f&&e.jsx(ce,{orientation:"vertical",flexItem:!0})]})}P.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:f=1.5}){return e.jsxs(R,{className:"section-header",direction:"row",sx:{justifyContent:"space-between",alignItems:"center",flexWrap:"wrap",gap:1,mb:c,mt:f,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 f=new Date(c.createdAt).toLocaleDateString();u[f]||(u[f]=[]),u[f]?.push(c)}),u};function ye({eventId:i="",webhookEndpointId:u="",event:c=null}){const{api:f,ws:{useSubscription:r}}=K(),{t:w}=M(),{teamDid:x}=V(),{blocklet:j}=Ze(),{data:l,loadMore:b,loadingMore:g,loading:y,mutate:z}=Te(s=>{const k=s?Math.ceil(s.list.length/15)+1:1;return f.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(A=>A.id===s.id?{...A,...s}:A);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 f.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(A=>A?.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(G,{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(Z,{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:b,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($,{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,4 +1,4 @@
1
- import{r as u}from"./vendor-react-Dvs43sk9.js";import{W as o,j as e,ak as j,aN as L,z as A,at as K,bn as B,I as P,a6 as W,bF as M,aj as X,bG as G}from"./vendor-mui-core-DRxbhqaK.js";import{C as H}from"./Google-E3u2a9g7.js";import{c as U}from"./vendor-ux-B9VfuZTg.js";import{c as Y}from"./create-passport-svg-n0J1kwzH.js";import{A as $}from"./vendor-arcblock-DeeG8u0h.js";import{e as J}from"./index-kYJKn2jR.js";import{R as Q}from"./required-BT8zXV8U.js";import{F as Z}from"./form-wrapper-Dt1iJZge.js";import{L as v}from"./logo-uploader-CN181syA.js";import{A as ee,a as ne,b as te}from"./collapse-DJGzUM1Q.js";const S={description:o.string,editing:o.bool,onChange:o.func,required:o.bool,value:o.any,componentProps:o.object,render:o.func,renderFormItem:o.func};function T({editing:n,value:s,onChange:l}){const[i,c]=u.useState(!1),m=u.useRef(),f=u.useRef(s);u.useEffect(()=>{let a=null;return n&&(a=setTimeout(()=>{c(!0)},50)),()=>{clearTimeout(a)}},[n]);const h=a=>{f.current=a,l(a)},b=()=>{c(!1),l(f.current)},y=e.jsx(j,{className:"form-item-input slot",sx:{px:1},children:e.jsxs(j,{sx:{display:"flex",alignItems:"center"},children:[s,s!=="auto"&&e.jsx("div",{style:{marginLeft:4,backgroundColor:s,width:"1em",height:"1em",borderRadius:"0.2em"}})]})}),p=e.jsxs(j,{onKeyDown:b,sx:{display:"flex",flexGrow:1,alignItems:"center",height:"40px"},children:[e.jsx(j,{onClick:()=>c(!0),sx:{display:"flex",alignItems:"center"},children:e.jsx("div",{ref:m,style:{flexShrink:0,marginLeft:"8px",backgroundColor:s,width:"32px",height:"32px",boxSizing:"border-box",borderRadius:"8px",border:"1px solid #eee",cursor:s==="auto"?"default":"pointer"}})}),e.jsx(L,{open:i,anchorEl:m.current,onClose:()=>c(!1),anchorOrigin:{vertical:"bottom",horizontal:"center"},transformOrigin:{vertical:"top",horizontal:"center"},children:e.jsx(H,{color:s,onChange:a=>h(a.hex)})})]});return n?p:y}T.propTypes=S;function D({editing:n,description:s,value:l,onChange:i,componentProps:c={},...m}){const{placeholder:f}=c,h=u.useRef(l),{t:b}=u.useContext(U),y=a=>{a.key==="Enter"&&i(h.current,"confirm")},p=a=>{h.current=a,i(a)};return n?e.jsx(A,{style:{flex:1},fullWidth:!0,value:l,onChange:a=>{a.persist(),p(a.target.value)},autoFocus:!0,size:"small",variant:"outlined",placeholder:s||f,onKeyDown:y,...m}):e.jsx(j,{className:"form-item-input slot",sx:{px:1},children:l||e.jsx("span",{className:"placeholder",children:b("common.requiredInputPlaceholder",{name:s||f})})})}D.propTypes=S;function O({editing:n,value:s,onChange:l,componentProps:i,...c}){const{blocklet:m}=i,f=s==="auto"?$(m.appDid):s;return e.jsxs(j,{sx:{display:"flex",alignItems:"center"},children:[e.jsx("div",{style:{width:96,marginRight:12},dangerouslySetInnerHTML:{__html:Y({title:"Owner",issuer:J.getDisplayName(m),issuerDid:m.appDid,ownerName:"Your Name",ownerDid:m.appDid,preferredColor:s||"auto"})}}),e.jsx(T,{...c,editing:n,value:n?f:s,onChange:l,componentProps:i})]})}O.propTypes={...S,componentProps:o.shape({blocklet:o.object.isRequired}).isRequired};const re=G`
1
+ import{r as u}from"./vendor-react-Dvs43sk9.js";import{W as o,j as e,ak as j,aN as L,z as A,at as K,bn as B,I as P,a6 as W,bF as M,aj as X,bG as G}from"./vendor-mui-core-DRxbhqaK.js";import{C as H}from"./Google-E3u2a9g7.js";import{c as U}from"./vendor-ux-B9VfuZTg.js";import{c as Y}from"./create-passport-svg-n0J1kwzH.js";import{A as $}from"./vendor-arcblock-DeeG8u0h.js";import{e as J}from"./index-Dkx4Mp12.js";import{R as Q}from"./required-BT8zXV8U.js";import{F as Z}from"./form-wrapper-Dt1iJZge.js";import{L as v}from"./logo-uploader-DPSSz4_-.js";import{A as ee,a as ne,b as te}from"./collapse-DJGzUM1Q.js";const S={description:o.string,editing:o.bool,onChange:o.func,required:o.bool,value:o.any,componentProps:o.object,render:o.func,renderFormItem:o.func};function T({editing:n,value:s,onChange:l}){const[i,c]=u.useState(!1),m=u.useRef(),f=u.useRef(s);u.useEffect(()=>{let a=null;return n&&(a=setTimeout(()=>{c(!0)},50)),()=>{clearTimeout(a)}},[n]);const h=a=>{f.current=a,l(a)},b=()=>{c(!1),l(f.current)},y=e.jsx(j,{className:"form-item-input slot",sx:{px:1},children:e.jsxs(j,{sx:{display:"flex",alignItems:"center"},children:[s,s!=="auto"&&e.jsx("div",{style:{marginLeft:4,backgroundColor:s,width:"1em",height:"1em",borderRadius:"0.2em"}})]})}),p=e.jsxs(j,{onKeyDown:b,sx:{display:"flex",flexGrow:1,alignItems:"center",height:"40px"},children:[e.jsx(j,{onClick:()=>c(!0),sx:{display:"flex",alignItems:"center"},children:e.jsx("div",{ref:m,style:{flexShrink:0,marginLeft:"8px",backgroundColor:s,width:"32px",height:"32px",boxSizing:"border-box",borderRadius:"8px",border:"1px solid #eee",cursor:s==="auto"?"default":"pointer"}})}),e.jsx(L,{open:i,anchorEl:m.current,onClose:()=>c(!1),anchorOrigin:{vertical:"bottom",horizontal:"center"},transformOrigin:{vertical:"top",horizontal:"center"},children:e.jsx(H,{color:s,onChange:a=>h(a.hex)})})]});return n?p:y}T.propTypes=S;function D({editing:n,description:s,value:l,onChange:i,componentProps:c={},...m}){const{placeholder:f}=c,h=u.useRef(l),{t:b}=u.useContext(U),y=a=>{a.key==="Enter"&&i(h.current,"confirm")},p=a=>{h.current=a,i(a)};return n?e.jsx(A,{style:{flex:1},fullWidth:!0,value:l,onChange:a=>{a.persist(),p(a.target.value)},autoFocus:!0,size:"small",variant:"outlined",placeholder:s||f,onKeyDown:y,...m}):e.jsx(j,{className:"form-item-input slot",sx:{px:1},children:l||e.jsx("span",{className:"placeholder",children:b("common.requiredInputPlaceholder",{name:s||f})})})}D.propTypes=S;function O({editing:n,value:s,onChange:l,componentProps:i,...c}){const{blocklet:m}=i,f=s==="auto"?$(m.appDid):s;return e.jsxs(j,{sx:{display:"flex",alignItems:"center"},children:[e.jsx("div",{style:{width:96,marginRight:12},dangerouslySetInnerHTML:{__html:Y({title:"Owner",issuer:J.getDisplayName(m),issuerDid:m.appDid,ownerName:"Your Name",ownerDid:m.appDid,preferredColor:s||"auto"})}}),e.jsx(T,{...c,editing:n,value:n?f:s,onChange:l,componentProps:i})]})}O.propTypes={...S,componentProps:o.shape({blocklet:o.object.isRequired}).isRequired};const re=G`
2
2
  0%, 100% {
3
3
  transform: scale(1) translateX(0);
4
4
  }
@@ -1,4 +1,4 @@
1
- import{j as t,a6 as f,ak as r,at as j,W as n}from"./vendor-mui-core-DRxbhqaK.js";import{r as h}from"./vendor-react-Dvs43sk9.js";import{c as S,n as p}from"./vendor-ux-B9VfuZTg.js";import{a as C}from"./page-header-DvSb4Cmz.js";import{a9 as g}from"./index-kYJKn2jR.js";import{o as b}from"./vendor-arcblock-DeeG8u0h.js";import{u as k}from"./config-space-BLuDOEKJ.js";import{C as y,D as v,a as w}from"./connect-to-D-Tb_fXt.js";import{S as c}from"./step-actions-DTwta5X_.js";import{S as E}from"./layout-Yt1Ps3ty.js";import"./vendor-utils-CUDP56Ff.js";import"./vendor-hooks-BlA8TRnZ.js";import"./lottie-web-4koyQiv_.js";import"./spaces-M_qE7wW_.js";import"./api-rC33aBSs.js";import"./index-Ha4kS6kt.js";import"./index-DRYJ0xIl.js";import"./index-BojVbZw0.js";import"./index-Y8LQew4k.js";import"./index-DBs9Ljax.js";import"./use-mobile-D6YQgajG.js";import"./content-layout-B9tc9LCL.js";function T({onNext:a=()=>{},onPrevious:d=()=>{}}){const{t:e}=h.useContext(S),{blocklet:o}=g(),{spaceGateway:m,settingStorageEndpoint:l,updateSpaceGateway:u,hasStorageEndpoint:x,loading:i,storageEndpoint:s}=k();return i?t.jsx(b,{relative:"parent",children:t.jsx(f,{})}):t.jsxs(B,{children:[t.jsx("div",{className:"header",children:t.jsx(C,{title:e("setup.didSpace.title"),subTitle:e("setup.didSpace.subTitle"),onClickBack:d})}),t.jsxs(r,{className:"form-container",sx:{width:"100%",maxWidth:"720px"},children:[x?t.jsx(y,{spaceGateway:m,settingStorageEndpoint:l}):t.jsx(v,{}),o?.capabilities?.didSpace&&t.jsx(r,{sx:{display:"flex",alignItems:"center",justifyContent:"center",paddingTop:"24px"},children:t.jsx(w,{onConnect:u,storageEndpoint:s})})]}),o?.capabilities?.didSpace==="required"&&t.jsx(c,{mt:8,children:t.jsx(p,{loading:i,variant:"contained",disabled:i||!s,onClick:()=>a(),children:e("setup.continue")})}),o?.capabilities?.didSpace==="optional"&&t.jsx(c,{blocklet:o,onStartNow:()=>a("complete"),children:t.jsx(p,{className:"start-now",loading:i,variant:"contained",disabled:i,onClick:()=>a(),children:e(s?"setup.continue":"setup.skip")})})]})}T.propTypes={onNext:n.func,onPrevious:n.func};const B=j(E)`
1
+ import{j as t,a6 as f,ak as r,at as j,W as n}from"./vendor-mui-core-DRxbhqaK.js";import{r as h}from"./vendor-react-Dvs43sk9.js";import{c as S,n as p}from"./vendor-ux-B9VfuZTg.js";import{a as C}from"./page-header-DvSb4Cmz.js";import{a9 as g}from"./index-Dkx4Mp12.js";import{o as b}from"./vendor-arcblock-DeeG8u0h.js";import{u as k}from"./config-space-CIl0FJy6.js";import{C as y,D as v,a as w}from"./connect-to-BB7Snd6q.js";import{S as c}from"./step-actions-C6BvFfMg.js";import{S as E}from"./layout-3MwmBHGM.js";import"./vendor-utils-CUDP56Ff.js";import"./vendor-hooks-BlA8TRnZ.js";import"./lottie-web-4koyQiv_.js";import"./spaces-C0dI3K7C.js";import"./api-rC33aBSs.js";import"./index-TVXfiYCu.js";import"./index-DRYJ0xIl.js";import"./index-BojVbZw0.js";import"./index-Y8LQew4k.js";import"./index-DBs9Ljax.js";import"./use-mobile-D6YQgajG.js";import"./content-layout-B9tc9LCL.js";function T({onNext:a=()=>{},onPrevious:d=()=>{}}){const{t:e}=h.useContext(S),{blocklet:o}=g(),{spaceGateway:m,settingStorageEndpoint:l,updateSpaceGateway:u,hasStorageEndpoint:x,loading:i,storageEndpoint:s}=k();return i?t.jsx(b,{relative:"parent",children:t.jsx(f,{})}):t.jsxs(B,{children:[t.jsx("div",{className:"header",children:t.jsx(C,{title:e("setup.didSpace.title"),subTitle:e("setup.didSpace.subTitle"),onClickBack:d})}),t.jsxs(r,{className:"form-container",sx:{width:"100%",maxWidth:"720px"},children:[x?t.jsx(y,{spaceGateway:m,settingStorageEndpoint:l}):t.jsx(v,{}),o?.capabilities?.didSpace&&t.jsx(r,{sx:{display:"flex",alignItems:"center",justifyContent:"center",paddingTop:"24px"},children:t.jsx(w,{onConnect:u,storageEndpoint:s})})]}),o?.capabilities?.didSpace==="required"&&t.jsx(c,{mt:8,children:t.jsx(p,{loading:i,variant:"contained",disabled:i||!s,onClick:()=>a(),children:e("setup.continue")})}),o?.capabilities?.didSpace==="optional"&&t.jsx(c,{blocklet:o,onStartNow:()=>a("complete"),children:t.jsx(p,{className:"start-now",loading:i,variant:"contained",disabled:i,onClick:()=>a(),children:e(s?"setup.continue":"setup.skip")})})]})}T.propTypes={onNext:n.func,onPrevious:n.func};const B=j(E)`
2
2
  height: 100%;
3
3
  overflow-y: auto;
4
4
  `;export{T as default};
@@ -1,4 +1,4 @@
1
- import{r as v,g as We,a as qe}from"./vendor-react-Dvs43sk9.js";import{g as Ue,k as Z}from"./vendor-hooks-BlA8TRnZ.js";import{j as e,ak as t,at as W,b1 as K,a6 as B,aX as He,am as G,co as Ge,U as Ke,T as F,a3 as Ye,W as S,z as O,M as X,I as _,cp as ge,cb as je,A as Ve,x as Ze,c3 as Xe,c4 as ee,bw as Je,F as Qe,bc as es,s as ss}from"./vendor-mui-core-DRxbhqaK.js";import{T as A,b as $,p as ts,j as ae,I as se,H as D,n as N,k as re,O as ye,x as ve,a3 as as,a0 as rs}from"./vendor-ux-B9VfuZTg.js";import{X as P,o as os,_ as be,c as M,B as Q,a9 as ns,e as is,V as ls,$ as V,b6 as cs}from"./index-kYJKn2jR.js";import{W as oe}from"./did-address-DnFNwELW.js";import{u as z}from"./team-BxHvUIQ6.js";import{a as ne,r as ie,b as le,c as Se,d as J,e as ds,u as ps,f as us}from"./passport-item-VF3cWzrN.js";import{p as Ce}from"./util-B8m2D-S9.js";import{u as ms}from"./use-mobile-BQQpAf3i.js";import{v as H}from"./index-Y8LQew4k.js";import{w as q,P as fs}from"./permission-B4abezk1.js";import{C as xs}from"./Google-E3u2a9g7.js";import{c as hs}from"./create-passport-svg-n0J1kwzH.js";import{A as gs}from"./vendor-arcblock-DeeG8u0h.js";import{G as Y,_ as js}from"./vendor-utils-CUDP56Ff.js";import{e as Te}from"./edit.svg-DycWG9v3.js";import{H as ce,P as ys}from"./index-Ffd9R2jw.js";import{C as we}from"./confirm-Cs-v9Ueu.js";import{L as Ie}from"./list-header-DMpz8A8v.js";import{f as te}from"./index-DBs9Ljax.js";import{u as vs}from"./useSetState-DFuQZPPV.js";import"./lottie-web-4koyQiv_.js";import"./session-C838MSz1.js";import"./isURL-DOKl6zP6.js";import"./use-app-logo-ezyDWOV9.js";import"./index-DeRDwip-.js";import"./base32-BK7MXAD4.js";import"./cloneDeep-LRq4Ya2k.js";import"./lock.svg-COUP8tyO.js";const me="info";function De({createPassportSvg:c,passport:s,onCancel:p,onSwitchPassport:u=()=>{}}){const{t:f}=A(),i=Ue({tab:me}),d={info:{label:f("common.basicInfo"),value:me,component:()=>e.jsx(Pe,{passport:s,createPassportSvg:c})},logs:{label:f("common.logs"),value:"logs",component:()=>e.jsx(Ae,{passport:s})},related:{label:f("team.passport.related"),value:"related",component:()=>e.jsx(Le,{passport:s,onSwitchPassport:u})}},l=Object.values(d).map(({label:h,value:m})=>({label:h,value:m})).filter(h=>h.value==="related"?s.parentDid:!0),r=d[i.tab]||d.info,n=h=>{i.tab=h};return e.jsx($,{title:f("common.passport"),onClose:p,open:!0,PaperProps:{style:{maxWidth:800,minHeight:"80vh"}},fullWidth:!0,children:e.jsxs(bs,{children:[e.jsx(t,{className:"tabs",children:e.jsx(ts,{tabs:l,current:i.tab,onChange:n,scrollButtons:"auto"})}),e.jsx(t,{className:"body",children:e.jsx(r.component,{})})]})})}De.propTypes={createPassportSvg:S.func.isRequired,passport:S.object.isRequired,onCancel:S.func.isRequired,onSwitchPassport:S.func};const bs=W(t)`
1
+ import{r as v,g as We,a as qe}from"./vendor-react-Dvs43sk9.js";import{g as Ue,k as Z}from"./vendor-hooks-BlA8TRnZ.js";import{j as e,ak as t,at as W,b1 as K,a6 as B,aX as He,am as G,co as Ge,U as Ke,T as F,a3 as Ye,W as S,z as O,M as X,I as _,cp as ge,cb as je,A as Ve,x as Ze,c3 as Xe,c4 as ee,bw as Je,F as Qe,bc as es,s as ss}from"./vendor-mui-core-DRxbhqaK.js";import{T as A,b as $,p as ts,j as ae,I as se,H as D,n as N,k as re,O as ye,x as ve,a3 as as,a0 as rs}from"./vendor-ux-B9VfuZTg.js";import{X as P,o as os,_ as be,c as M,B as Q,a9 as ns,e as is,V as ls,$ as V,b6 as cs}from"./index-Dkx4Mp12.js";import{W as oe}from"./did-address-DnFNwELW.js";import{u as z}from"./team-geqUb8FM.js";import{a as ne,r as ie,b as le,c as Se,d as J,e as ds,u as ps,f as us}from"./passport-item-YF9RfQH3.js";import{p as Ce}from"./util-DKVr8C5h.js";import{u as ms}from"./use-mobile-BQQpAf3i.js";import{v as H}from"./index-Y8LQew4k.js";import{w as q,P as fs}from"./permission-uKfC5D9f.js";import{C as xs}from"./Google-E3u2a9g7.js";import{c as hs}from"./create-passport-svg-n0J1kwzH.js";import{A as gs}from"./vendor-arcblock-DeeG8u0h.js";import{G as Y,_ as js}from"./vendor-utils-CUDP56Ff.js";import{e as Te}from"./edit.svg-DycWG9v3.js";import{H as ce,P as ys}from"./index-CVvmswkh.js";import{C as we}from"./confirm-nzje1i_c.js";import{L as Ie}from"./list-header-DMpz8A8v.js";import{f as te}from"./index-DBs9Ljax.js";import{u as vs}from"./useSetState-DFuQZPPV.js";import"./lottie-web-4koyQiv_.js";import"./session-DsIBYEWF.js";import"./isURL-GpP7YPNs.js";import"./use-app-logo-DCgwdb4C.js";import"./index-B2RPurN4.js";import"./base32-BK7MXAD4.js";import"./cloneDeep-LRq4Ya2k.js";import"./lock.svg-COUP8tyO.js";const me="info";function De({createPassportSvg:c,passport:s,onCancel:p,onSwitchPassport:u=()=>{}}){const{t:f}=A(),i=Ue({tab:me}),d={info:{label:f("common.basicInfo"),value:me,component:()=>e.jsx(Pe,{passport:s,createPassportSvg:c})},logs:{label:f("common.logs"),value:"logs",component:()=>e.jsx(Ae,{passport:s})},related:{label:f("team.passport.related"),value:"related",component:()=>e.jsx(Le,{passport:s,onSwitchPassport:u})}},l=Object.values(d).map(({label:h,value:m})=>({label:h,value:m})).filter(h=>h.value==="related"?s.parentDid:!0),r=d[i.tab]||d.info,n=h=>{i.tab=h};return e.jsx($,{title:f("common.passport"),onClose:p,open:!0,PaperProps:{style:{maxWidth:800,minHeight:"80vh"}},fullWidth:!0,children:e.jsxs(bs,{children:[e.jsx(t,{className:"tabs",children:e.jsx(ts,{tabs:l,current:i.tab,onChange:n,scrollButtons:"auto"})}),e.jsx(t,{className:"body",children:e.jsx(r.component,{})})]})})}De.propTypes={createPassportSvg:S.func.isRequired,passport:S.object.isRequired,onCancel:S.func.isRequired,onSwitchPassport:S.func};const bs=W(t)`
2
2
  margin-top: -16px;
3
3
 
4
4
  .tabs {
@@ -1,4 +1,4 @@
1
- import{r as g}from"./vendor-react-Dvs43sk9.js";import{j as e,y as V,x as X,bc as G,M as Q,ak as m,W as x,a6 as ke,cb as ve,b1 as J,z as U,b6 as Te,a5 as Ae,at as P,T as E,cc as Ke,bb as Re,aX as De}from"./vendor-mui-core-DRxbhqaK.js";import{T as D,I as $,n as F,c as Se,b as oe,q as H,H as Ie,a0 as $e,o as Be,a1 as Ne,j as Ee,k as _e}from"./vendor-ux-B9VfuZTg.js";import{f as Pe}from"./index-DBs9Ljax.js";import{B as ie,o as ae,l as re}from"./index-DeRDwip-.js";import{a as ce}from"./passport-item-VF3cWzrN.js";import{c as z,X as I,o as We,aC as ze,a9 as qe,e as Me}from"./index-kYJKn2jR.js";import{u as W}from"./team-BxHvUIQ6.js";import{l as le}from"./arrow-down.svg-BIpNdtOh.js";import{T as de}from"./index-CE80LF06.js";import{C as pe}from"./confirm-Cs-v9Ueu.js";import{R as Le,C as _}from"./vendor-utils-CUDP56Ff.js";import{u as Ue}from"./session-C838MSz1.js";import{C as O}from"./click-to-copy-CO6UIqva.js";import{f as Fe}from"./index-BojVbZw0.js";import{D as He}from"./delete-confirm-D-H3beUW.js";import{P as Oe}from"./permission-B4abezk1.js";import{l as q}from"./vendor-arcblock-DeeG8u0h.js";import{B as Ve}from"./bundle-avatar-YluGbYkj.js";import{W as Xe}from"./did-address-DnFNwELW.js";import{u as me}from"./use-mobile-BQQpAf3i.js";import{A as Ge}from"./actions-B4VXcSRp.js";import{T as ne}from"./table-tips-rCE1XKlc.js";import{s as Qe}from"./vendor-hooks-BlA8TRnZ.js";import"./lottie-web-4koyQiv_.js";import"./util-B8m2D-S9.js";import"./base32-BK7MXAD4.js";import"./isURL-DOKl6zP6.js";import"./use-app-logo-ezyDWOV9.js";import"./vendor-mui-x-Qp6zkx78.js";import"./AdapterDayjs-Bp0ir26R.js";function Y({value:s}){const{t,locale:n}=D(),a=new Date;return new Date(s)<a?e.jsxs("span",{style:{color:"red"},children:[e.jsx($,{value:s,locale:n}),`${t("setting.accessKey.expired",{time:""})}`]}):e.jsx($,{mode:"daysLeft",value:s,locale:n,type:"all"})}Y.propTypes={value:x.string.isRequired};function Z({value:s,onChange:t,...n}){const{t:a}=D(),o=g.useMemo(()=>[{value:"signature",title:a("setting.accessKey.signature"),description:a("setting.accessKey.signatureDesc")},{value:"simple",title:a("setting.accessKey.simple"),description:a("setting.accessKey.simpleDesc")}],[a]);return e.jsxs(V,{style:{width:"100%"},variant:"outlined",...n,children:[e.jsx(X,{children:a("setting.accessKey.authType")}),e.jsx(G,{value:s,onChange:t,fullWidth:!0,label:a("setting.accessKey.authType"),IconComponent:l=>e.jsx(le,{...l,width:20,height:20}),children:o.map(l=>e.jsx(Q,{value:l.value,children:e.jsxs(m,{children:[e.jsx("span",{children:l.title}),e.jsx(m,{sx:{maxWidth:510,fontSize:12,color:"#999",whiteSpace:"normal"},children:l.description})]})},l.value))})]})}Z.propTypes={value:x.string.isRequired,onChange:x.func.isRequired};const ee=()=>{const s=z.RBAC_CONFIG.roles.filter(o=>o.passport),{inService:t}=I(),{roles:n}=W(),a=[...s,...t?n:[]];return Le(a,"name").filter(o=>o.name!==z.ROLES.OWNER)};function ue(){const{session:s}=Ue(),t=ee();return g.useMemo(()=>{if(!s?.user?.role)return[];if(["owner","admin"].includes(s.user.role))return t;const a=t.filter(l=>l.name==="guest");return[...t.filter(l=>l.name!=="guest").filter(l=>s.user.passports.find(b=>b.role===l.name)),...a]},[t,s?.user?.passports,s?.user?.role])}function xe({onCreate:s=()=>{},remark:t=""}){const{api:n}=I(),{teamDid:a}=W(),{t:o}=D(),[l,b]=g.useState(!1),[p,j]=g.useState(null),u=ue(),K=()=>{b(!1),j(null)},C=async c=>{const{remark:w,passport:h,authType:i}=c;b(!0);const v=await n.createAccessKey({input:{teamDid:a,remark:w.trim(),passport:h,expireAt:c.expireAt?new Date(c.expireAt).getTime():null,authType:i}}),{data:R}=v;s(R),j(null),b(!1)},d={title:`${o("common.create")} ${o("accessKey")}`,description:(c,w,h)=>e.jsxs(J,{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:c.remark,onChange:i=>{w({...c,remark:i.target.value,__disableConfirm:!c.passport||!i.target.value.trim()}),i.target.value.trim()?h(""):h(o("setting.accessKey.remarkInvalid"))},slotProps:{htmlInput:{"data-cy":"remark-input"}}}),e.jsxs(V,{style:{width:"100%"},variant:"outlined",children:[e.jsx(X,{sx:{width:"calc(100% - 46px)"},children:o("setting.accessKey.passport")}),e.jsx(G,{"data-cy":"create-access-key-select-passport",value:c.passport,onChange:i=>{const v=i.target.value;h(null),w({...c,passport:v,__disableConfirm:!c.remark||!v})},fullWidth:!0,label:o("setting.accessKey.passport"),disabled:l,IconComponent:i=>e.jsx(le,{...i,width:20,height:20}),children:u.map(i=>e.jsx(Q,{value:i.name,"data-cy":`create-access-key-passport-option-${i.name}`,children:e.jsxs(m,{children:[e.jsx("span",{children:i.title||i.name}),e.jsx(m,{sx:{maxWidth:440,fontSize:12,color:"#999",whiteSpace:"normal",textAlign:"justify"},children:i.description})]})},i.name))})]}),e.jsx(Z,{value:c.authType,onChange:i=>{w({...c,authType:i.target.value})}}),e.jsx(de,{placeholder:o("setting.accessKey.expireTime"),value:c.expireAt,onChange:i=>{w({...c,expireAt:i,__disableConfirm:!c.passport||!c.remark||!i})}})]}),confirm:o("common.confirm"),cancel:o("common.cancel"),color:"primary",params:{remark:t,authType:"signature",__disableConfirm:!t.trim()},onConfirm:C,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:()=>j(d),className:"rule-action",children:[l?e.jsx(ke,{size:16}):e.jsx(ve,{style:{fontSize:16}}),o("common.create")]}),p&&e.jsx(pe,{title:p.title,description:p.description,confirm:p.confirm,color:p.color,cancel:p.cancel,params:p.params,onConfirm:p.onConfirm,onCancel:p.onCancel})]})}xe.propTypes={remark:x.string,onCreate:x.func};function fe({onConfirm:s=()=>{},accessKeyId:t,accessKeySecret:n,hideSecret:a=!0}){const{t:o}=g.useContext(Se),[l,b]=g.useState(!1),[p,j]=g.useState(()=>a),u=I(),K=()=>{j(!p)},C=h=>{b(h.target.checked)},d=_(window.location.origin,u?.info?.routing?.adminPath),c=g.useMemo(()=>a?`const Client = require('@blocklet/server-js');
1
+ import{r as g}from"./vendor-react-Dvs43sk9.js";import{j as e,y as V,x as X,bc as G,M as Q,ak as m,W as x,a6 as ke,cb as ve,b1 as J,z as U,b6 as Te,a5 as Ae,at as P,T as E,cc as Ke,bb as Re,aX as De}from"./vendor-mui-core-DRxbhqaK.js";import{T as D,I as $,n as F,c as Se,b as oe,q as H,H as Ie,a0 as $e,o as Be,a1 as Ne,j as Ee,k as _e}from"./vendor-ux-B9VfuZTg.js";import{f as Pe}from"./index-DBs9Ljax.js";import{B as ie,o as ae,l as re}from"./index-B2RPurN4.js";import{a as ce}from"./passport-item-YF9RfQH3.js";import{c as z,X as I,o as We,aC as ze,a9 as qe,e as Me}from"./index-Dkx4Mp12.js";import{u as W}from"./team-geqUb8FM.js";import{l as le}from"./arrow-down.svg-ByD_YKms.js";import{T as de}from"./index-DccCgoC4.js";import{C as pe}from"./confirm-nzje1i_c.js";import{R as Le,C as _}from"./vendor-utils-CUDP56Ff.js";import{u as Ue}from"./session-DsIBYEWF.js";import{C as O}from"./click-to-copy-CO6UIqva.js";import{f as Fe}from"./index-BojVbZw0.js";import{D as He}from"./delete-confirm-BoyKK_sh.js";import{P as Oe}from"./permission-uKfC5D9f.js";import{l as q}from"./vendor-arcblock-DeeG8u0h.js";import{B as Ve}from"./bundle-avatar-BZh2UMH9.js";import{W as Xe}from"./did-address-DnFNwELW.js";import{u as me}from"./use-mobile-BQQpAf3i.js";import{A as Ge}from"./actions-B4VXcSRp.js";import{T as ne}from"./table-tips-rCE1XKlc.js";import{s as Qe}from"./vendor-hooks-BlA8TRnZ.js";import"./lottie-web-4koyQiv_.js";import"./util-DKVr8C5h.js";import"./base32-BK7MXAD4.js";import"./isURL-GpP7YPNs.js";import"./use-app-logo-DCgwdb4C.js";import"./vendor-mui-x-Qp6zkx78.js";import"./AdapterDayjs-Bp0ir26R.js";function Y({value:s}){const{t,locale:n}=D(),a=new Date;return new Date(s)<a?e.jsxs("span",{style:{color:"red"},children:[e.jsx($,{value:s,locale:n}),`${t("setting.accessKey.expired",{time:""})}`]}):e.jsx($,{mode:"daysLeft",value:s,locale:n,type:"all"})}Y.propTypes={value:x.string.isRequired};function Z({value:s,onChange:t,...n}){const{t:a}=D(),o=g.useMemo(()=>[{value:"signature",title:a("setting.accessKey.signature"),description:a("setting.accessKey.signatureDesc")},{value:"simple",title:a("setting.accessKey.simple"),description:a("setting.accessKey.simpleDesc")}],[a]);return e.jsxs(V,{style:{width:"100%"},variant:"outlined",...n,children:[e.jsx(X,{children:a("setting.accessKey.authType")}),e.jsx(G,{value:s,onChange:t,fullWidth:!0,label:a("setting.accessKey.authType"),IconComponent:l=>e.jsx(le,{...l,width:20,height:20}),children:o.map(l=>e.jsx(Q,{value:l.value,children:e.jsxs(m,{children:[e.jsx("span",{children:l.title}),e.jsx(m,{sx:{maxWidth:510,fontSize:12,color:"#999",whiteSpace:"normal"},children:l.description})]})},l.value))})]})}Z.propTypes={value:x.string.isRequired,onChange:x.func.isRequired};const ee=()=>{const s=z.RBAC_CONFIG.roles.filter(o=>o.passport),{inService:t}=I(),{roles:n}=W(),a=[...s,...t?n:[]];return Le(a,"name").filter(o=>o.name!==z.ROLES.OWNER)};function ue(){const{session:s}=Ue(),t=ee();return g.useMemo(()=>{if(!s?.user?.role)return[];if(["owner","admin"].includes(s.user.role))return t;const a=t.filter(l=>l.name==="guest");return[...t.filter(l=>l.name!=="guest").filter(l=>s.user.passports.find(b=>b.role===l.name)),...a]},[t,s?.user?.passports,s?.user?.role])}function xe({onCreate:s=()=>{},remark:t=""}){const{api:n}=I(),{teamDid:a}=W(),{t:o}=D(),[l,b]=g.useState(!1),[p,j]=g.useState(null),u=ue(),K=()=>{b(!1),j(null)},C=async c=>{const{remark:w,passport:h,authType:i}=c;b(!0);const v=await n.createAccessKey({input:{teamDid:a,remark:w.trim(),passport:h,expireAt:c.expireAt?new Date(c.expireAt).getTime():null,authType:i}}),{data:R}=v;s(R),j(null),b(!1)},d={title:`${o("common.create")} ${o("accessKey")}`,description:(c,w,h)=>e.jsxs(J,{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:c.remark,onChange:i=>{w({...c,remark:i.target.value,__disableConfirm:!c.passport||!i.target.value.trim()}),i.target.value.trim()?h(""):h(o("setting.accessKey.remarkInvalid"))},slotProps:{htmlInput:{"data-cy":"remark-input"}}}),e.jsxs(V,{style:{width:"100%"},variant:"outlined",children:[e.jsx(X,{sx:{width:"calc(100% - 46px)"},children:o("setting.accessKey.passport")}),e.jsx(G,{"data-cy":"create-access-key-select-passport",value:c.passport,onChange:i=>{const v=i.target.value;h(null),w({...c,passport:v,__disableConfirm:!c.remark||!v})},fullWidth:!0,label:o("setting.accessKey.passport"),disabled:l,IconComponent:i=>e.jsx(le,{...i,width:20,height:20}),children:u.map(i=>e.jsx(Q,{value:i.name,"data-cy":`create-access-key-passport-option-${i.name}`,children:e.jsxs(m,{children:[e.jsx("span",{children:i.title||i.name}),e.jsx(m,{sx:{maxWidth:440,fontSize:12,color:"#999",whiteSpace:"normal",textAlign:"justify"},children:i.description})]})},i.name))})]}),e.jsx(Z,{value:c.authType,onChange:i=>{w({...c,authType:i.target.value})}}),e.jsx(de,{placeholder:o("setting.accessKey.expireTime"),value:c.expireAt,onChange:i=>{w({...c,expireAt:i,__disableConfirm:!c.passport||!c.remark||!i})}})]}),confirm:o("common.confirm"),cancel:o("common.cancel"),color:"primary",params:{remark:t,authType:"signature",__disableConfirm:!t.trim()},onConfirm:C,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:()=>j(d),className:"rule-action",children:[l?e.jsx(ke,{size:16}):e.jsx(ve,{style:{fontSize:16}}),o("common.create")]}),p&&e.jsx(pe,{title:p.title,description:p.description,confirm:p.confirm,color:p.color,cancel:p.cancel,params:p.params,onConfirm:p.onConfirm,onCancel:p.onCancel})]})}xe.propTypes={remark:x.string,onCreate:x.func};function fe({onConfirm:s=()=>{},accessKeyId:t,accessKeySecret:n,hideSecret:a=!0}){const{t:o}=g.useContext(Se),[l,b]=g.useState(!1),[p,j]=g.useState(()=>a),u=I(),K=()=>{j(!p)},C=h=>{b(h.target.checked)},d=_(window.location.origin,u?.info?.routing?.adminPath),c=g.useMemo(()=>a?`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 +1 @@
1
- import{r as p}from"./vendor-react-Dvs43sk9.js";import{j as a,y as b,W as t,z as y,M as E,ak as I}from"./vendor-mui-core-DRxbhqaK.js";import{a as j}from"./vendor-hooks-BlA8TRnZ.js";import{_ as r}from"./index-kYJKn2jR.js";import{T as A}from"./vendor-ux-B9VfuZTg.js";import{l as C}from"./arrow-down.svg-BIpNdtOh.js";import{L as O,D as H}from"./vendor-mui-x-Qp6zkx78.js";import{A as R}from"./AdapterDayjs-Bp0ir26R.js";function v({value:s=null,onChange:i,error:l=!1,helperText:c="",label:T="",timezone:e="",minDateTime:f=null}){const d=j(()=>{let n=r();return s&&(n=e?r(s).tz(e):r(s)),n},[s,e]),m=n=>{const h=e?r(n).tz(e):r(n);i(new Date(h.format("YYYY-MM-DD HH:mm:00")))};return a.jsx(O,{dateAdapter:R,children:a.jsx(b,{fullWidth:!0,error:l,children:a.jsx(H,{label:T,minDateTime:f,value:d,onChange:m,slotProps:{textField:{error:l,helperText:l?c:""}},format:"YYYY-MM-DD HH:mm"})})})}v.propTypes={value:t.oneOfType([t.string,t.instanceOf(Date)]),onChange:t.func.isRequired,error:t.bool,helperText:t.string,label:t.string,timezone:t.string,minDateTime:t.instanceOf(Date)};function U(s){return a.jsx(C,{...s,width:20,height:20})}const u={MINUTES_30:30*60*1e3,HOUR_1:60*60*1e3,HOURS_3:3*60*60*1e3,DAY_1:24*60*60*1e3,DAYS_7:7*24*60*60*1e3,DAYS_30:30*24*60*60*1e3};function $({placeholder:s="",value:i="",onChange:l,timezone:c="",showError:T=!0}){const{t:e}=A(),[f,d]=p.useState(i||""),[m,n]=p.useState(null),[h,Y]=p.useState(null),x=p.useMemo(()=>[{value:u.MINUTES_30,label:`30 ${e("common.minutes")}`},{value:u.HOUR_1,label:`1 ${e("common.hour")}`},{value:u.HOURS_3,label:`3 ${e("common.hours")}`},{value:u.DAY_1,label:`1 ${e("common.day")}`},{value:u.DAYS_7,label:`7 ${e("common.days")}`},{value:u.DAYS_30,label:`30 ${e("common.days")}`},{value:"custom",label:e("common.custom")}],[e]),_=o=>{if(d(o),o==="custom"){const D=c?r().tz(c):r(),S=D.add(1,"day").toDate();Y(D),n(S),l(S)}else l(new Date(Date.now()+o))},M=o=>{n(o),l(o)};p.useEffect(()=>{i&&(x.find(D=>r(D.value).isSame(i))||(d("custom"),n(i)))},[]);const g=j(()=>T?!!(!m||r(m).isBefore(r())):!1,[m,e]);return a.jsxs(a.Fragment,{children:[a.jsx(b,{fullWidth:!0,children:a.jsx(y,{select:!0,value:f,label:s||e("team.passport.passportExpireTime"),onChange:o=>_(o.target.value),variant:"outlined",slotProps:{select:{IconComponent:U}},sx:{"& .MuiInputLabel-root":{width:"calc(100% - 46px)"}},children:x.map(o=>a.jsx(E,{value:o.value,children:o.label},o.value))})}),f==="custom"&&a.jsx(I,{children:a.jsx(v,{value:m,onChange:M,label:e("team.passport.customExpireTime"),timezone:c,error:!!g,helperText:g?e("team.passport.customExpireTimeIsInvalid"):void 0,minDateTime:h})})]})}$.propTypes={value:t.oneOfType([t.string,t.instanceOf(Date)]),onChange:t.func.isRequired,timezone:t.string,placeholder:t.string,showError:t.bool};export{$ as T};
1
+ import{r as p}from"./vendor-react-Dvs43sk9.js";import{j as a,y as b,W as t,z as y,M as E,ak as I}from"./vendor-mui-core-DRxbhqaK.js";import{a as j}from"./vendor-hooks-BlA8TRnZ.js";import{_ as r}from"./index-Dkx4Mp12.js";import{T as A}from"./vendor-ux-B9VfuZTg.js";import{l as C}from"./arrow-down.svg-ByD_YKms.js";import{L as O,D as H}from"./vendor-mui-x-Qp6zkx78.js";import{A as R}from"./AdapterDayjs-Bp0ir26R.js";function v({value:s=null,onChange:i,error:l=!1,helperText:c="",label:T="",timezone:e="",minDateTime:f=null}){const d=j(()=>{let n=r();return s&&(n=e?r(s).tz(e):r(s)),n},[s,e]),m=n=>{const h=e?r(n).tz(e):r(n);i(new Date(h.format("YYYY-MM-DD HH:mm:00")))};return a.jsx(O,{dateAdapter:R,children:a.jsx(b,{fullWidth:!0,error:l,children:a.jsx(H,{label:T,minDateTime:f,value:d,onChange:m,slotProps:{textField:{error:l,helperText:l?c:""}},format:"YYYY-MM-DD HH:mm"})})})}v.propTypes={value:t.oneOfType([t.string,t.instanceOf(Date)]),onChange:t.func.isRequired,error:t.bool,helperText:t.string,label:t.string,timezone:t.string,minDateTime:t.instanceOf(Date)};function U(s){return a.jsx(C,{...s,width:20,height:20})}const u={MINUTES_30:30*60*1e3,HOUR_1:60*60*1e3,HOURS_3:3*60*60*1e3,DAY_1:24*60*60*1e3,DAYS_7:7*24*60*60*1e3,DAYS_30:30*24*60*60*1e3};function $({placeholder:s="",value:i="",onChange:l,timezone:c="",showError:T=!0}){const{t:e}=A(),[f,d]=p.useState(i||""),[m,n]=p.useState(null),[h,Y]=p.useState(null),x=p.useMemo(()=>[{value:u.MINUTES_30,label:`30 ${e("common.minutes")}`},{value:u.HOUR_1,label:`1 ${e("common.hour")}`},{value:u.HOURS_3,label:`3 ${e("common.hours")}`},{value:u.DAY_1,label:`1 ${e("common.day")}`},{value:u.DAYS_7,label:`7 ${e("common.days")}`},{value:u.DAYS_30,label:`30 ${e("common.days")}`},{value:"custom",label:e("common.custom")}],[e]),_=o=>{if(d(o),o==="custom"){const D=c?r().tz(c):r(),S=D.add(1,"day").toDate();Y(D),n(S),l(S)}else l(new Date(Date.now()+o))},M=o=>{n(o),l(o)};p.useEffect(()=>{i&&(x.find(D=>r(D.value).isSame(i))||(d("custom"),n(i)))},[]);const g=j(()=>T?!!(!m||r(m).isBefore(r())):!1,[m,e]);return a.jsxs(a.Fragment,{children:[a.jsx(b,{fullWidth:!0,children:a.jsx(y,{select:!0,value:f,label:s||e("team.passport.passportExpireTime"),onChange:o=>_(o.target.value),variant:"outlined",slotProps:{select:{IconComponent:U}},sx:{"& .MuiInputLabel-root":{width:"calc(100% - 46px)"}},children:x.map(o=>a.jsx(E,{value:o.value,children:o.label},o.value))})}),f==="custom"&&a.jsx(I,{children:a.jsx(v,{value:m,onChange:M,label:e("team.passport.customExpireTime"),timezone:c,error:!!g,helperText:g?e("team.passport.customExpireTimeIsInvalid"):void 0,minDateTime:h})})]})}$.propTypes={value:t.oneOfType([t.string,t.instanceOf(Date)]),onChange:t.func.isRequired,timezone:t.string,placeholder:t.string,showError:t.bool};export{$ as T};