@abtnode/blocklet-services 1.16.45-beta-20250620-082630-c0c76051 → 1.16.45-beta-20250624-134945-a23c15fc
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/api/index.js +1 -0
- package/dist/assets/{AdapterDayjs-T0keO70D.js → AdapterDayjs-DPGZ06jw.js} +1 -1
- package/dist/assets/{ArrowDropDown-DKq28w-B.js → ArrowDropDown-BRjvameu.js} +1 -1
- package/dist/assets/{CheckCircle-DYKWpCjc.js → CheckCircle-s6iPVCo6.js} +1 -1
- package/dist/assets/{ChevronLeft-C5ZElVOZ.js → ChevronLeft-CMWjvJzl.js} +1 -1
- package/dist/assets/{ChevronRight-BDtG7F9C.js → ChevronRight-BvGLpFbz.js} +1 -1
- package/dist/assets/{DeleteOutline-CYuYysba.js → DeleteOutline-CZy9YJmZ.js} +1 -1
- package/dist/assets/{Done-C4iTqhTW.js → Done-ANHHWPOL.js} +1 -1
- package/dist/assets/{Download-CkjiFBw2.js → Download-BOwjcgZ3.js} +1 -1
- package/dist/assets/{Edit-D-oqMZ6h.js → Edit-DI_6xJCL.js} +1 -1
- package/dist/assets/{Error-Dt1QvSlR.js → Error-C_wmKEzR.js} +1 -1
- package/dist/assets/{ExpandLess-CRv5O8qM.js → ExpandLess-CDM2P9kE.js} +1 -1
- package/dist/assets/{Google-DboCD85r.js → Google-BO9divfd.js} +1 -1
- package/dist/assets/{Home-CROW9qUz.js → Home-BCeQyZgM.js} +1 -1
- package/dist/assets/{InfoOutlined-B5f3YRb4.js → InfoOutlined-CRqiKRaY.js} +1 -1
- package/dist/assets/{Launch-Cy-UlooC.js → Launch-WjfnHu3Q.js} +1 -1
- package/dist/assets/{LaunchOutlined-Bcn_86ca.js → LaunchOutlined-DD-CBO2C.js} +1 -1
- package/dist/assets/{MoreHoriz-H_VQNQ9b.js → MoreHoriz-D2G1BR_j.js} +1 -1
- package/dist/assets/{PlayArrow-DZsdEeq_.js → PlayArrow-DLymwoC2.js} +1 -1
- package/dist/assets/{TuneOutlined-GyTVf3HU.js → TuneOutlined-DeQKb3nj.js} +1 -1
- package/dist/assets/{ViewList-D0tVfaVX.js → ViewList-BhbcPArj.js} +1 -1
- package/dist/assets/{access-control-C9hWo6TU.js → access-control-BwZXbzhK.js} +1 -1
- package/dist/assets/{actions-BgkGoToI.js → actions-BAixAheW.js} +1 -1
- package/dist/assets/add-component-core-ExhcVQ0D.js +768 -0
- package/dist/assets/{add-resource-YRx2pKzx.js → add-resource-BG-amVdp.js} +1 -1
- package/dist/assets/{addon-DZBLWIf7.js → addon-D7Eawt60.js} +1 -1
- package/dist/assets/{advanced-C9eBqn30.js → advanced-neAeEOLu.js} +1 -1
- package/dist/assets/{appearance-DzftIlmu.js → appearance-B2ZPQ1TJ.js} +1 -1
- package/dist/assets/ar-BN95HEFs.js +7 -0
- package/dist/assets/{audit-logs-Cljb9yLV.js → audit-logs-B7WzzNCo.js} +1 -1
- package/dist/assets/{authorize-BS4vDs5i.js → authorize-Bk0btugo.js} +1 -1
- package/dist/assets/{base32-Cbt7-U8e.js → base32-kNwk0OEz.js} +1 -1
- package/dist/assets/{branding-uCV5ZREf.js → branding-CLZf514m.js} +2 -2
- package/dist/assets/{branding-BuuaXyqZ.js → branding-CM3w7b9c.js} +1 -1
- package/dist/assets/{bundle-avatar-CH2OoDP-.js → bundle-avatar-NjLcf8la.js} +1 -1
- package/dist/assets/{button-ogiWKbo_.js → button-DhAI_y8t.js} +1 -1
- package/dist/assets/{click-to-copy-D0HginOX.js → click-to-copy-Q6B8UnF1.js} +1 -1
- package/dist/assets/{collapse-D4xd-ptF.js → collapse-B1s6QHCm.js} +1 -1
- package/dist/assets/{complete-D2In_TeH.js → complete-BGbK1STn.js} +1 -1
- package/dist/assets/{component-DN1QsNYm.js → component-BKEHSLyn.js} +110 -81
- package/dist/assets/{config-DEbtcbH9.js → config-CwY8zv8V.js} +1 -1
- package/dist/assets/{config-DS_kGhWk.js → config-Dv--ET9N.js} +1 -1
- package/dist/assets/{config-navigation-BB2LlxWl.js → config-navigation-Cmb8QFnC.js} +3 -3
- package/dist/assets/{config-space-DlQnLPiY.js → config-space-ChP6tztJ.js} +1 -1
- package/dist/assets/{confirm-Bbp7EOHO.js → confirm-DrIfevZQ.js} +1 -1
- package/dist/assets/{connect-CtbQgg8c.js → connect-D_bwW55Y.js} +1 -1
- package/dist/assets/{connect-hUOpYByL.js → connect-f41b9wKv.js} +1 -1
- package/dist/assets/{connect-to-EzXJLWP1.js → connect-to-BMgSpYfM.js} +1 -1
- package/dist/assets/{dashboard-CpxtvWAW.js → dashboard-Cpd1IklF.js} +3 -3
- package/dist/assets/de-BmXl3Jnb.js +7 -0
- package/dist/assets/{delete-confirm-BdthpUzC.js → delete-confirm-DYG8CWSB.js} +1 -1
- package/dist/assets/{did-address-DFiM35OM.js → did-address-uKFe7d9V.js} +1 -1
- package/dist/assets/{domain-C7iO-bfS.js → domain-CunmRVp2.js} +1 -1
- package/dist/assets/{domain-action-card-CqcqlPAn.js → domain-action-card-Dzf6si5U.js} +1 -1
- package/dist/assets/domains-CWSUTDgJ.js +1 -0
- package/dist/assets/{email-CH6lvIGE.js → email-BvDqqXub.js} +1 -1
- package/dist/assets/es-C0fHeuzj.js +9 -0
- package/dist/assets/{exchange-passport-F8-Xn3rX.js → exchange-passport-DckgOVoA.js} +1 -1
- package/dist/assets/fr-CO0NFjy0.js +7 -0
- package/dist/assets/{fuel-BRI4NZNF.js → fuel-DtREt_8O.js} +1 -1
- package/dist/assets/{gen-access-key-CjcE_UoL.js → gen-access-key-Ct3FGVE9.js} +1 -1
- package/dist/assets/{get-safe-url-BS4IIyYC.js → get-safe-url-CJEvMc5P.js} +1 -1
- package/dist/assets/{get-safe-url-CuT70yLx.js → get-safe-url-DNGUXA66.js} +1 -1
- package/dist/assets/hi-Cms3dwY-.js +5 -0
- package/dist/assets/{home-B7IeN8M_.js → home-DyrzEdv2.js} +1 -1
- package/dist/assets/id-Bo8dj7EE.js +7 -0
- package/dist/assets/{iframe-DYXqfKJj.js → iframe-CaeDKfYB.js} +1 -1
- package/dist/assets/{index-BEyvIdTp.js → index-B1dgnXJh.js} +1 -1
- package/dist/assets/{index-BW2DapLf.js → index-B2lZxLm9.js} +3 -3
- package/dist/assets/{index-DyCrJT9-.js → index-BBsJrATj.js} +1 -1
- package/dist/assets/{index-ZdwmM3LS.js → index-BDWfKVVU.js} +1 -1
- package/dist/assets/{index-BMCGWiyM.js → index-BRdhpmU2.js} +7 -7
- package/dist/assets/{index-0KJGv8YB.js → index-BfZya8qo.js} +1 -1
- package/dist/assets/{index-Dl0q_c7r.js → index-CF76kaIz.js} +1 -1
- package/dist/assets/{index-CqrC0g0e.js → index-C_ENS0dl.js} +1 -1
- package/dist/assets/index-CcYwTst5.js +110 -0
- package/dist/assets/{index-DhXQuL-K.js → index-CkctlESe.js} +1 -1
- package/dist/assets/{index-DECQi8Vb.js → index-Cle-zfXD.js} +1 -1
- package/dist/assets/{index-ClFIRXfV.js → index-Cu4BdzAo.js} +1 -1
- package/dist/assets/{index-BAtw7eB6.js → index-CuDTJqx_.js} +1 -1
- package/dist/assets/{index-D6ye_M7F.js → index-D2lFJ3sU.js} +1 -1
- package/dist/assets/{index-DDI23z2P.js → index-DBZhb75O.js} +1 -1
- package/dist/assets/{index-mitJwLHE.js → index-DCD3ZWse.js} +4 -4
- package/dist/assets/{index-Dj3HMPh8.js → index-D_F1ag51.js} +1 -1
- package/dist/assets/{index-DeekZg9t.js → index-mDCgbH0P.js} +1 -1
- package/dist/assets/{index-WjR0qttM.js → index-oDHaQu27.js} +1 -1
- package/dist/assets/{invitation-D7jOoJzU.js → invitation-DxxODOR-.js} +1 -1
- package/dist/assets/{invite-BiE9G1lr.js → invite-CI0E7UGP.js} +1 -1
- package/dist/assets/{issue-passport-BxmBoE32.js → issue-passport-CqP-uLPp.js} +1 -1
- package/dist/assets/{item-BuWWRgL8.js → item-DG5gNLUw.js} +1 -1
- package/dist/assets/ja-zaAhH8mE.js +9 -0
- package/dist/assets/ko-CoZQ7a7T.js +9 -0
- package/dist/assets/{layout-Balq-c2F.js → layout-D-TZFmkw.js} +1 -1
- package/dist/assets/{list-DBhbLnjZ.js → list-CDkARaW2.js} +2 -2
- package/dist/assets/{list-C4l_W2F_.js → list-D3co1lE_.js} +1 -1
- package/dist/assets/localization-DdPHn52Y.js +1 -0
- package/dist/assets/{log-CcBqhBEJ.js → log-Befdpc-G.js} +1 -1
- package/dist/assets/{logger-tBhN561y.js → logger-DueMU2XV.js} +1 -1
- package/dist/assets/{login-BF1AdZ-L.js → login-BBSSJs7f.js} +1 -1
- package/dist/assets/{login-oauth-callback-Cv5MlgIc.js → login-oauth-callback-CVwRxsRg.js} +1 -1
- package/dist/assets/{logo-uploader-C1N-bsM2.js → logo-uploader-B-M7yFxC.js} +3 -3
- package/dist/assets/{lost-passport-C2Km75Ka.js → lost-passport-BAJU8v9K.js} +1 -1
- package/dist/assets/{open-window-uY95lBbB.js → open-window-DTfKdl9d.js} +1 -1
- package/dist/assets/{overview-BgK_P3ko.js → overview-oelilgIt.js} +1 -1
- package/dist/assets/{page-header-CiTTXRdM.js → page-header-BfzUNAXD.js} +1 -1
- package/dist/assets/{passport-item-fJ88Wv4t.js → passport-item-BZ2PDs40.js} +1 -1
- package/dist/assets/{permission-CQWJVo4a.js → permission-pKosyod0.js} +1 -1
- package/dist/assets/{preferences-Uz2t9auQ.js → preferences-xjKgRqmh.js} +1 -1
- package/dist/assets/{profile-embed-C7ypVv2q.js → profile-embed-QQJQ7iQM.js} +1 -1
- package/dist/assets/pt-D4wJ-rZD.js +5 -0
- package/dist/assets/{publish-resource-DLqFuWGv.js → publish-resource-DI9RoK5q.js} +1 -1
- package/dist/assets/{react-beautiful-dnd.esm-DMJVQVbv.js → react-beautiful-dnd.esm-D4AqzL2w.js} +1 -1
- package/dist/assets/ru-CmWrzb7M.js +5 -0
- package/dist/assets/{runtime-XL6C0WHV.js → runtime-wFrO-XwO.js} +1 -1
- package/dist/assets/sdk-Dv5_9dL5.js +1 -0
- package/dist/assets/{security-C5-rO801.js → security-Muzez6Sy.js} +1 -1
- package/dist/assets/{session-BDyIB4uh.js → session-DocEIP6S.js} +1 -1
- package/dist/assets/{setup-Dpq6lpy4.js → setup-CEV9qa6q.js} +3 -3
- package/dist/assets/{spaces-BR4I2U0t.js → spaces-CCo1ZRC-.js} +1 -1
- package/dist/assets/{start-BTmB0MgK.js → start-D1wx_swP.js} +1 -1
- package/dist/assets/{starting-progress-BsYL_5xB.js → starting-progress-BdIQ-div.js} +1 -1
- package/dist/assets/{status-D8GKQyA3.js → status-DmvoK-2H.js} +1 -1
- package/dist/assets/{step-actions-njetG0Iy.js → step-actions-BIy9iLaD.js} +1 -1
- package/dist/assets/{studio-DSEHQtAw.js → studio-CGisGAXN.js} +1 -1
- package/dist/assets/{switch-control-BCB3_Ctk.js → switch-control-DuXtjpWN.js} +1 -1
- package/dist/assets/{table-tips-Cjv8HIcF.js → table-tips-ClAYiT8W.js} +1 -1
- package/dist/assets/th-DkqBkRH_.js +5 -0
- package/dist/assets/{traffic-DAzuj4ZR.js → traffic-BZEjFNTD.js} +1 -1
- package/dist/assets/{transfer-NRpeYO3B.js → transfer-BrPnaaOx.js} +1 -1
- package/dist/assets/{unsubscribe-CBvTeTZf.js → unsubscribe-D4NKMBZT.js} +1 -1
- package/dist/assets/{use-blocklet-logo-DwwmdicD.js → use-blocklet-logo-Due3V0N2.js} +1 -1
- package/dist/assets/{useLocalStorage-iQ2AmaOA.js → useLocalStorage-D_xU3zzI.js} +1 -1
- package/dist/assets/{user-center-CCOO4S3Y.js → user-center-D1KDLD8O.js} +3 -3
- package/dist/assets/{util-paKPrRHx.js → util-YJ_KBZfa.js} +1 -1
- package/dist/assets/{util-BK7oThoq.js → util-lAtUh3oi.js} +1 -1
- package/dist/assets/{vendor-arcblock-f1tICt1E.js → vendor-arcblock-BUFJsma5.js} +3 -3
- package/dist/assets/{vendor-ux-did-connect-BbCim3WZ.js → vendor-ux-did-connect-mISLpoxA.js} +1 -1
- package/dist/assets/vi-D4Y0EZ10.js +5 -0
- package/dist/assets/wrap-locale-BGuH0-0r.js +1 -0
- package/dist/assets/{zh-DJTjvgj8.js → zh-CXbCDXZ8.js} +1 -1
- package/dist/assets/zh-tw-DaTNZcVC.js +9 -0
- package/dist/index.html +3 -3
- package/dist/service-worker.js +1 -1
- package/package.json +22 -22
- package/dist/assets/add-component-core-CpBArNQj.js +0 -768
- package/dist/assets/ar-DLXKKOGO.js +0 -7
- package/dist/assets/de-CnbmrteH.js +0 -7
- package/dist/assets/domains-z_Wu9ucc.js +0 -1
- package/dist/assets/es-C7oXJBWv.js +0 -9
- package/dist/assets/fr-DzleTcLj.js +0 -7
- package/dist/assets/hi-B24wH0bs.js +0 -5
- package/dist/assets/id-BIjW1vW9.js +0 -7
- package/dist/assets/index-D7U3pqVe.js +0 -110
- package/dist/assets/ja-mu0bc5Fx.js +0 -9
- package/dist/assets/ko-CSWdQF8q.js +0 -9
- package/dist/assets/localization-crkTHEvo.js +0 -1
- package/dist/assets/pt-Odg8daEV.js +0 -5
- package/dist/assets/ru-OkiNIvy3.js +0 -5
- package/dist/assets/sdk-D3QR4FNa.js +0 -1
- package/dist/assets/th-esLoaeiE.js +0 -5
- package/dist/assets/vi-BF6u6-98.js +0 -5
- package/dist/assets/wrap-locale-BLcZ6jMd.js +0 -1
- package/dist/assets/zh-tw-B7cFexwg.js +0 -9
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as _,a3 as q,k as ve,r as se,br as Ee,bs as Ce,bt as Se,I as U,b_ as Q,b$ as X,a5 as Me,ac as Le,bI as _e}from"./vendor-ux-did-connect-BbCim3WZ.js";import{t as Be,l as Te,j as Fe}from"./vendor-hooks-DqdmWCmo.js";import{r as C,b as ie}from"./vendor-react-DEoibe3W.js";import{d as re}from"./InfoOutlined-B5f3YRb4.js";import{i as He,v as Ne}from"./vendor-arcblock-f1tICt1E.js";import{D as V,aC as Ue,aD as Z,G as Ie,y as Ke}from"./index-BMCGWiyM.js";import{u as Y}from"./dashboard-CpxtvWAW.js";import{u as Ve}from"./use-mobile-DwzRjjku.js";import{H as o,j as e,D as Ye,aj as Je,t as Ge,aa as d,O as je,T as S,ab as H,ak as le,z as Qe,y as N,bs as ye,bR as ee,ad as A,L as te,A as oe,aq as Xe,E as M,I as F,C as Ze,bq as et,al as D,cg as tt,X as Re,a9 as ae,s as de,as as ne,bp as ot,b7 as nt,b8 as st,an as it,b$ as rt,v as lt,ch as at,ci as dt,cj as ct,ck as ut}from"./vendor-mui-core-Bq8gXTan.js";import{d as pt}from"./ExpandLess-CRv5O8qM.js";import{b as De,z as ht,A as xt}from"./vendor-utils-BfZ4tlod.js";import{C as mt}from"./confirm-Bbp7EOHO.js";import{A as ft}from"./actions-BgkGoToI.js";import{T as we}from"./table-tips-Cjv8HIcF.js";import"./lottie-web-jYmAQWuC.js";import"./useLocalStorage-iQ2AmaOA.js";import"./index-8eXqqyHQ.js";import"./PlayArrow-DZsdEeq_.js";import"./get-safe-url-CuT70yLx.js";import"./session-BDyIB4uh.js";import"./use-blocklet-logo-DwwmdicD.js";import"./dot-4jhL56kz.js";import"./useAsync-C62uE2pS.js";import"./useSetState-CWq0AVWn.js";import"./use-mobile-CtTQsfXN.js";import"./MoreHoriz-H_VQNQ9b.js";const gt=s=>{var b,T;const[c,p]=C.useState(null),[v,l]=C.useState(!s),[k,u]=C.useState(null),{blocklet:f}=Ie(),i=(T=(b=f==null?void 0:f.site)==null?void 0:b.domainAliases[0])==null?void 0:T.value,y=C.useMemo(()=>{const j={};return c&&(c.sources.forEach(n=>{j[n.did]={source:n,events:[],count:0}}),c.events.forEach(n=>{j[n.source]&&(j[n.source].events.push(n),j[n.source].count+=1)})),j},[c]),w=async()=>{try{if(l(!0),!i)return;const n=await(await fetch(`https://${i}${ve.WELLKNOWN_SERVICE_PATH_PREFIX}/openevent.json`)).json();p(n),u(null)}catch(j){u(j instanceof Error?j:new Error(String(j)))}finally{l(!1)}};return C.useEffect(()=>{w()},[i]),{openEvent:c,setOpenEvent:p,eventsBySource:y,loading:v,error:k,loadData:w}};function ce({eventsBySource:s,selectedEvents:c,setSelectedEvents:p,error:v}){const{t:l}=_(),[k,u]=C.useState({}),f=C.useMemo(()=>{const n={};return Object.entries(s).forEach(([h,{events:x}])=>{const E=x.filter(I=>c[`${I.type}-${I.source}`]).length;n[h]=E}),n},[s,c]),i=C.useMemo(()=>Object.values(f).reduce((n,h)=>n+h,0),[f]),y=C.useMemo(()=>Object.values(s).reduce((n,{events:h})=>n+h.length,0),[s]),w=(n,h)=>{h.stopPropagation(),u({...k,[n]:!k[n]})},b=n=>{const h=`${n.type}-${n.source}`;p(x=>({...x,[h]:!x[h]}))},T=(n,h)=>{const x={};n.forEach(E=>{const I=`${E.type}-${E.source}`;x[I]=!h}),p(E=>({...E,...x}))},j=n=>{const h={};Object.values(s).forEach(({events:x})=>{x.forEach(E=>{const I=`${E.type}-${E.source}`;h[I]=n.target.checked})}),p(h)};return e.jsxs(d,{sx:{width:"100%"},children:[e.jsxs(d,{sx:{display:"flex",alignItems:"center",mb:1,mt:1},children:[e.jsx(ye,{control:e.jsx(ee,{onChange:j,checked:i>0&&i===y}),label:e.jsxs(d,{sx:{display:"flex",alignItems:"center",cursor:"pointer"},children:[l("webhookEndpoint.selectAllEvents"),e.jsx(d,{sx:{display:"flex",alignItems:"center"},children:e.jsx(A,{title:l("webhookEndpoint.selectAllEventsTooltip"),placement:"right",children:e.jsx(re,{fontSize:"small",sx:{ml:.5,cursor:"help"}})})})]}),sx:{m:0}}),i>0&&e.jsx(S,{variant:"body2",color:"primary",sx:{ml:"auto"},children:l("webhookEndpoint.selectedEventsCount",{count:i})})]}),e.jsx(d,{sx:{maxHeight:"50vh",overflow:"auto"},children:e.jsx(te,{disablePadding:!0,sx:{border:"1px solid",borderColor:"divider",borderRadius:"4px"},children:Object.entries(s).map(([n,{source:h,events:x,count:E}],I)=>{const O=f[n]>0,R=f[n]===x.length&&x.length>0,$=k[n];return e.jsxs(ie.Fragment,{children:[e.jsx(oe,{sx:{borderBottom:({palette:r})=>I<Object.keys(s).length-1?`1px solid ${r.divider}`:"none",px:2,py:1.5,"&:hover":{bgcolor:"rgba(0, 0, 0, 0.02)"}},children:e.jsxs(d,{sx:{display:"flex",width:"100%",justifyContent:"space-between",alignItems:"center"},onClick:r=>{r.target.closest(".MuiFormControlLabel-root")||w(n,r)},children:[e.jsx(d,{sx:{display:"flex",alignItems:"center"},children:x.length>0&&e.jsx(ye,{control:e.jsx(ee,{checked:R,indeterminate:O&&!R,onChange:r=>{r.stopPropagation(),T(x,R)}}),label:e.jsxs(d,{sx:{display:"flex",alignItems:"center",gap:1},children:[h.logo&&e.jsx(Xe,{src:h.logo,sx:{width:24,height:24}}),e.jsx(d,{children:h.title||n}),O&&e.jsx(M,{label:l("webhookEndpoint.selectedCount",{count:f[n]}),size:"small",sx:{mt:"2px",height:"20px",fontSize:"12px",bgcolor:r=>`${r.palette.primary.main}20`,color:"primary.main",fontWeight:500}})]}),sx:{m:0,"& .MuiFormControlLabel-label":{flex:1}}})}),e.jsxs(d,{sx:{display:"flex",alignItems:"center"},children:[e.jsx(S,{variant:"body2",color:"text.secondary",sx:{mr:1},children:l("webhookEndpoint.eventsCount",{count:E})}),x.length>0&&e.jsx(F,{size:"small",edge:"end",children:$?e.jsx(pt,{}):e.jsx(He,{})})]})]})}),x.length>0&&e.jsx(Ze,{in:$,timeout:"auto",unmountOnExit:!0,children:e.jsx(te,{disablePadding:!0,sx:{pl:2,pr:2,py:1,bgcolor:"rgba(0, 0, 0, 0.01)"},children:x.map(r=>{const a=`${r.type}-${r.source}`,t=!!c[a];return e.jsx(oe,{dense:!0,sx:{py:.75},onClick:()=>b(r),children:e.jsxs(d,{sx:{display:"flex",alignItems:"flex-start",width:"100%"},children:[e.jsx(ee,{checked:t,sx:{mr:1}}),e.jsxs(d,{children:[e.jsx(S,{variant:"body1",sx:{cursor:"pointer",color:"text.primary"},children:r.type}),e.jsx(S,{variant:"caption",color:"text.secondary",sx:{display:"block",cursor:"pointer"},children:r.description})]})]})},a)})})})]},n)})})}),v&&e.jsx(et,{error:!0,sx:{mt:1},children:v})]})}ce.propTypes={eventsBySource:o.objectOf(o.shape({source:o.shape({did:o.string.isRequired,title:o.string,description:o.string,version:o.string,logo:o.string}).isRequired,events:o.arrayOf(o.shape({type:o.string.isRequired,description:o.string.isRequired,source:o.string.isRequired})).isRequired,count:o.number.isRequired})).isRequired,selectedEvents:o.objectOf(o.bool).isRequired,setSelectedEvents:o.func.isRequired,error:o.string};ce.defaultProps={error:null};function ue({id:s,url:c,description:p,enabledEvents:v,onSubmit:l,onClose:k}){var r;const{t:u}=_(),[f,i]=C.useState({}),{teamDid:y}=Y(),{api:w}=V(),{loading:b,error:T,eventsBySource:j}=gt(),{control:n,handleSubmit:h,formState:{errors:x},reset:E,setValue:I,trigger:O}=Ue({defaultValues:{url:"",description:""}});C.useEffect(()=>{const a=Object.values(f).some(t=>t);I("selectedEvents",a?"valid":""),O("selectedEvents")},[f,I,O]);const R=()=>{i({}),E(),k()},$=async a=>{const t=Object.keys(f).filter(m=>f[m]),g={url:a.url,description:a.description,enabledEvents:t.map(m=>{const[P,z]=m.split("-");return!P||!z?null:{type:P,source:z}}).filter(Boolean)};try{if(s){const m=await w.updateWebhookEndpoint({input:{teamDid:y,id:s,data:g}});q.success(`${u("webhookEndpoint.updateWebhook")} ${u("webhookEndpoint.success")}`),l(m)}else{const m=await w.createWebhookEndpoint({input:{teamDid:y,input:g}});q.success(`${u("webhookEndpoint.createWebhook")} ${u("webhookEndpoint.success")}`),l(m)}}catch(m){q.error(m==null?void 0:m.message)}R()};return C.useEffect(()=>{E({url:c,description:p}),i(v.reduce((a,t)=>(a[`${t.type}-${t.source}`]=!0,a),{}))},[E,i,c,p,v]),e.jsx(Ye,{open:!0,onClose:R,maxWidth:"lg",fullWidth:!0,sx:{"& .MuiDialog-paper":{minHeight:600}},children:e.jsxs("form",{onSubmit:h($),children:[e.jsx(Je,{children:u(s?"webhookEndpoint.editWebhookTitle":"webhookEndpoint.createWebhookTitle")}),e.jsx(Ge,{children:e.jsxs(d,{sx:{display:"flex",flexDirection:"column",gap:2,mt:2},children:[e.jsx(Z,{name:"url",control:n,rules:{required:u("webhookEndpoint.validation.urlRequired"),pattern:{value:/^(http|https):\/\/[^ "]+$/,message:u("webhookEndpoint.validation.urlInvalid")}},render:({field:a})=>{var t;return e.jsx(je,{...a,label:u("webhookEndpoint.url.label"),fullWidth:!0,error:!!x.url,helperText:(t=x.url)==null?void 0:t.message})}}),e.jsx(Z,{name:"description",control:n,rules:{required:u("webhookEndpoint.validation.descriptionRequired")},render:({field:a})=>{var t;return e.jsx(je,{...a,label:u("webhookEndpoint.description.label"),fullWidth:!0,multiline:!0,minRows:2,maxRows:4,error:!!x.description,helperText:(t=x.description)==null?void 0:t.message})}}),e.jsx(Z,{name:"selectedEvents",control:n,rules:{required:u("webhookEndpoint.validation.eventRequired")},render:({field:a})=>e.jsx("input",{type:"hidden",...a})}),!b&&j&&Object.keys(j).length>0&&e.jsx(ce,{eventsBySource:j,selectedEvents:f,setSelectedEvents:i,error:(r=x.selectedEvents)==null?void 0:r.message}),!b&&(!j||Object.keys(j).length===0)&&e.jsx(S,{color:"text.secondary",children:u("webhookEndpoint.noAvailableEvents")}),b&&e.jsx(d,{sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"500px",width:"100%"},children:e.jsx(H,{size:20})}),T&&e.jsx(le,{severity:"error",children:u("webhookEndpoint.loadingError",{message:T==null?void 0:T.message})})]})}),e.jsxs(Qe,{sx:{p:"8px 24px 24px"},children:[e.jsx(N,{onClick:R,children:u("common.cancel")}),e.jsx(N,{type:"submit",variant:"contained",color:"primary",children:u(s?"webhookEndpoint.updateWebhook":"webhookEndpoint.saveWebhook")})]})]})})}ue.propTypes={onSubmit:o.func.isRequired,id:o.string,url:o.string,description:o.string,enabledEvents:o.arrayOf(o.shape({type:o.string.isRequired,source:o.string.isRequired})),onClose:o.func};ue.defaultProps={id:null,url:"",description:"",enabledEvents:[],onClose:()=>{}};function Pe(s){switch(s){case"enabled":return"success";case"disabled":default:return"default"}}const bt=(s="en")=>s==="tw"?"zh":s;function K(s,c="YYYY-MM-DD HH:mm:ss",p="en"){return s?Ke(s).locale(bt(p)).format(c):"-"}function jt(s){return typeof s=="number"?!1:De(s)}function yt(s){return s>=200&&s<300}function W(s){const c=jt(s.value);return e.jsxs(e.Fragment,{children:[e.jsxs(D,{direction:"column",alignItems:"flex-start",children:[e.jsxs(S,{component:"div",variant:"body1",mb:1,color:"text.primary",sx:{fontWeight:500},children:[s.label,!!s.tip&&e.jsx(A,{title:s.tip,children:e.jsx(tt,{fontSize:"small"})})]}),e.jsx(S,{component:"div",variant:"body1",color:c?"text.disabled":"text.secondary",sx:{width:"100%",minHeight:"24px"},children:c?"-":s.value})]}),s.divider&&e.jsx(Re,{orientation:"vertical",flexItem:!0})]})}W.propTypes={label:o.oneOfType([o.string,o.node]).isRequired,value:o.oneOfType([o.string,o.node]).isRequired,tip:o.oneOfType([o.string,o.node]),divider:o.bool};W.defaultProps={tip:"",divider:!1};function pe(s){return e.jsxs(D,{className:"section-header",direction:"row",justifyContent:"space-between",alignItems:"center",flexWrap:"wrap",gap:1,sx:{mb:s.mb,mt:s.mt,pb:1},children:[e.jsx(S,{variant:"h3",sx:{fontSize:{xs:"18px",md:"1.09375rem"}},component:"div",children:s.title}),s.children]})}pe.propTypes={title:o.oneOfType([o.string,o.node]).isRequired,children:o.node,mb:o.number,mt:o.number};pe.defaultProps={children:null,mb:1.5,mt:1.5};var he={},wt=ae;Object.defineProperty(he,"__esModule",{value:!0});var ze=he.default=void 0,kt=wt(se()),vt=e;ze=he.default=(0,kt.default)((0,vt.jsx)("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2M7 13.5c-.83 0-1.5-.67-1.5-1.5s.67-1.5 1.5-1.5 1.5.67 1.5 1.5-.67 1.5-1.5 1.5m5 0c-.83 0-1.5-.67-1.5-1.5s.67-1.5 1.5-1.5 1.5.67 1.5 1.5-.67 1.5-1.5 1.5m5 0c-.83 0-1.5-.67-1.5-1.5s.67-1.5 1.5-1.5 1.5.67 1.5 1.5-.67 1.5-1.5 1.5"}),"Pending");var xe={},Et=ae;Object.defineProperty(xe,"__esModule",{value:!0});var Oe=xe.default=void 0,Ct=Et(se()),St=e;Oe=xe.default=(0,Ct.default)((0,St.jsx)("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2m0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8m4.59-12.42L10 14.17l-2.59-2.58L6 13l4 4 8-8z"}),"CheckCircleOutlined");var me={},Tt=ae;Object.defineProperty(me,"__esModule",{value:!0});var We=me.default=void 0,It=Tt(se()),Rt=e;We=me.default=(0,It.default)((0,Rt.jsx)("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2m1 15h-2v-2h2zm0-4h-2V7h2z"}),"ErrorOutlined");const Dt={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"/>'},Pt=s=>{const c={};return s.forEach(p=>{var l;const v=new Date(p.createdAt).toLocaleDateString();c[v]||(c[v]=[]),(l=c[v])==null||l.push(p)}),c};function fe({eventId:s,webhookEndpointId:c,event:p}){const{api:v,ws:{useSubscription:l}}=V(),{t:k}=_(),{teamDid:u}=Y(),{blocklet:f}=Ie(),{data:i,loadMore:y,loadingMore:w,loading:b,mutate:T}=Be(t=>{const m=t?Math.ceil(t.list.length/15)+1:1;return v.getWebhookAttempts({input:{teamDid:u,input:{eventId:s,webhookId:c},paging:{page:m,pageSize:15}}})},{reloadDeps:[s,c]}),j=(i==null?void 0:i.list)||[],[n,h]=C.useState(null),[x,E]=C.useState(!1),I=Pt(j);if(C.useEffect(()=>{!n&&(i!=null&&i.list.length)&&h(i.list[0])},[i==null?void 0:i.list.length,n]),l(ve.EVENTS.WEBHOOK_ATTEMPT,t=>{T(g=>{var P,z;if(g.list.find(L=>L.id===t.id)){const L=g.list.map(B=>B.id===t.id?{...B,...t}:B);return{...g,list:L}}return t.endpoint=(P=g.list[0])==null?void 0:P.endpoint,t.event=(z=g.list[0])==null?void 0:z.event,{...g,list:[t,...g.list]}})},[]),b)return e.jsx(H,{});const O=i&&i.list.length<i.paging.total,R=async()=>{n&&(E(!0),await v.retryWebhookAttempt({input:{teamDid:u,eventId:n.event.id,webhookId:c,attemptId:n.id}}).finally(()=>{setTimeout(()=>{E(!1)},1e3)}))},$=t=>{var g,m,P,z,L;if(t.responseBody&&((g=t.responseBody)!=null&&g.sessionId)&&((m=t.responseBody)!=null&&m.projectId)&&((P=t.responseBody)!=null&&P.agentId)){const B=(L=(z=f==null?void 0:f.site)==null?void 0:z.domainAliases[0])==null?void 0:L.value,J=(f.children||[]).find(G=>{var be;return((be=G==null?void 0:G.meta)==null?void 0:be.name)==="ai-studio"}),qe=ht(xt(`https://${B}`,(J==null?void 0:J.mountPoint)||"","projects",t.responseBody.projectId,"logs/main"),{sessionId:t.responseBody.sessionId,agentId:t.responseBody.agentId});return e.jsx(F,{sx:{fontSize:20},onClick:()=>window.open(qe,"_blank"),children:e.jsx(d,{component:U,icon:Q})})}return null},r=t=>t.status==="pending"?e.jsx(ze,{color:"warning"}):yt(t.responseStatus)?e.jsx(Oe,{color:"success"}):e.jsx(We,{color:"error"}),a=(n==null?void 0:n.triggeredFrom)&&((i==null?void 0:i.list)||[]).find(t=>t.id===n.triggeredFrom);return e.jsxs(zt,{container:!0,spacing:{xs:0,md:1},sx:{height:1},children:[e.jsx(ne,{item:!0,xs:12,md:4,height:1,children:De(Object.keys(I))?e.jsx(S,{color:"text.secondary",children:k("webhookEndpoint.waitingForEvents")}):e.jsxs(e.Fragment,{children:[e.jsx(te,{sx:{maxHeight:"calc(100% - 40px)",py:0,overflowY:"auto"},children:Object.entries(I).map(([t,g])=>e.jsxs(ie.Fragment,{children:[e.jsx(ot,{sx:{p:0},children:t}),g.map(m=>e.jsxs(oe,{sx:{cursor:"pointer",px:1},onClick:()=>h(m),selected:n&&(n==null?void 0:n.id)===(m==null?void 0:m.id),secondaryAction:e.jsx(S,{color:"text.secondary",children:K(m.createdAt,"HH:mm:ss")}),children:[e.jsx(nt,{sx:{minWidth:0,mr:1.5},children:r(m)}),e.jsx(st,{primary:e.jsx(S,{color:"text.primary",children:m.event.type})})]},m.id))]},t))}),O&&e.jsx(d,{display:"flex",justifyContent:"center",alignItems:"center",width:1,children:e.jsx(N,{variant:"text",type:"button",color:"inherit",onClick:y,disabled:w,sx:{color:t=>t.palette.text.disabled},children:k(w?"webhookEndpoint.loadingMore":"webhookEndpoint.loadMore")})})]})}),e.jsxs(ne,{item:!0,xs:12,md:8,height:1,children:[n&&e.jsxs(D,{height:1,overflow:"auto",direction:"column",spacing:2,sx:{pl:{xs:0,md:1},mt:{xs:2,md:0},borderLeft:{xs:"none"}},children:[e.jsxs(d,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs(d,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(S,{variant:"h4",children:k(`common.${n.status}`)}),e.jsx(d,{children:$(n)})]}),e.jsxs(d,{sx:{display:"flex",alignItems:"center",gap:1},children:[a&&e.jsx(A,{componentsProps:{tooltip:{sx:{maxWidth:400}}},placement:"left",title:e.jsxs(D,{gap:1,sx:{cursor:"pointer",".did-address-text":{color:"common.white"}},onClick:()=>h(a),children:[e.jsx(Ee,{showDid:!0,did:n.triggeredBy,cardType:Ce.Detailed,infoType:Se.Minimal,sx:{border:0,padding:0,minWidth:0,".MuiTypography-root":{color:"common.white",fontWeight:400}}}),e.jsx(Re,{}),e.jsxs(d,{sx:{display:"flex",flexDirection:"column"},children:[e.jsx(S,{variant:"body2",sx:{color:"primary.main"},children:k("webhookEndpoint.triggeredFrom")}),e.jsxs(d,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(S,{variant:"body2",children:n.id}),e.jsx(F,{onClick:()=>h(a),children:e.jsx(d,{component:U,icon:Q,sx:{fontSize:16,color:"common.white"}})})]})]})]}),children:e.jsx(F,{onClick:()=>h(a),children:e.jsx(d,{component:U,icon:Q,sx:{fontSize:16}})})}),e.jsxs(N,{variant:"outlined",color:"primary",size:"small",onClick:R,disabled:x,children:[e.jsx(d,{component:U,icon:Dt,sx:{fontSize:16,animation:x?"spin 1s linear infinite":"none",mr:.5}}),k("notification.resend")]})]})]}),e.jsxs(d,{children:[e.jsxs(S,{variant:"h6",children:[k("webhookEndpoint.response")," (",n.responseStatus,")"]}),e.jsx(X,{language:"json",children:JSON.stringify(n.responseBody,null,2)})]}),e.jsxs(d,{children:[e.jsx(D,{direction:"row",alignItems:"center",spacing:1,children:e.jsx(S,{variant:"h6",children:k("webhookEndpoint.request")})}),e.jsx(X,{language:"json",sx:{margin:0},children:JSON.stringify(n.event,null,2)})]})]}),(i==null?void 0:i.list.length)===0&&p&&e.jsxs(d,{children:[e.jsx(D,{direction:"row",alignItems:"center",spacing:1,children:e.jsx(S,{variant:"h6",children:k("webhookEndpoint.eventData")})}),e.jsx(X,{language:"json",sx:{margin:0},children:JSON.stringify(p.data,null,2)})]})]})]})}fe.propTypes={eventId:o.string,webhookEndpointId:o.string,event:o.shape({type:o.string,data:o.object,request:o.object,requestInfo:o.object})};fe.defaultProps={eventId:"",webhookEndpointId:"",event:null};const zt=de(ne)`
|
|
1
|
+
import{a as _,a3 as q,k as ve,r as se,br as Ee,bs as Ce,bt as Se,I as U,b_ as Q,b$ as X,a5 as Me,ac as Le,bI as _e}from"./vendor-ux-did-connect-mISLpoxA.js";import{t as Be,l as Te,j as Fe}from"./vendor-hooks-DqdmWCmo.js";import{r as C,b as ie}from"./vendor-react-DEoibe3W.js";import{d as re}from"./InfoOutlined-CRqiKRaY.js";import{i as He,v as Ne}from"./vendor-arcblock-BUFJsma5.js";import{D as V,aC as Ue,aD as Z,G as Ie,y as Ke}from"./index-BRdhpmU2.js";import{u as Y}from"./dashboard-Cpd1IklF.js";import{u as Ve}from"./use-mobile-DwzRjjku.js";import{H as o,j as e,D as Ye,aj as Je,t as Ge,aa as d,O as je,T as S,ab as H,ak as le,z as Qe,y as N,bs as ye,bR as ee,ad as A,L as te,A as oe,aq as Xe,E as M,I as F,C as Ze,bq as et,al as D,cg as tt,X as Re,a9 as ae,s as de,as as ne,bp as ot,b7 as nt,b8 as st,an as it,b$ as rt,v as lt,ch as at,ci as dt,cj as ct,ck as ut}from"./vendor-mui-core-Bq8gXTan.js";import{d as pt}from"./ExpandLess-CDM2P9kE.js";import{b as De,z as ht,A as xt}from"./vendor-utils-BfZ4tlod.js";import{C as mt}from"./confirm-DrIfevZQ.js";import{A as ft}from"./actions-BAixAheW.js";import{T as we}from"./table-tips-ClAYiT8W.js";import"./lottie-web-jYmAQWuC.js";import"./useLocalStorage-D_xU3zzI.js";import"./index-8eXqqyHQ.js";import"./PlayArrow-DLymwoC2.js";import"./get-safe-url-CJEvMc5P.js";import"./session-DocEIP6S.js";import"./use-blocklet-logo-Due3V0N2.js";import"./dot-4jhL56kz.js";import"./useAsync-C62uE2pS.js";import"./useSetState-CWq0AVWn.js";import"./use-mobile-CtTQsfXN.js";import"./MoreHoriz-D2G1BR_j.js";const gt=s=>{var b,T;const[c,p]=C.useState(null),[v,l]=C.useState(!s),[k,u]=C.useState(null),{blocklet:f}=Ie(),i=(T=(b=f==null?void 0:f.site)==null?void 0:b.domainAliases[0])==null?void 0:T.value,y=C.useMemo(()=>{const j={};return c&&(c.sources.forEach(n=>{j[n.did]={source:n,events:[],count:0}}),c.events.forEach(n=>{j[n.source]&&(j[n.source].events.push(n),j[n.source].count+=1)})),j},[c]),w=async()=>{try{if(l(!0),!i)return;const n=await(await fetch(`https://${i}${ve.WELLKNOWN_SERVICE_PATH_PREFIX}/openevent.json`)).json();p(n),u(null)}catch(j){u(j instanceof Error?j:new Error(String(j)))}finally{l(!1)}};return C.useEffect(()=>{w()},[i]),{openEvent:c,setOpenEvent:p,eventsBySource:y,loading:v,error:k,loadData:w}};function ce({eventsBySource:s,selectedEvents:c,setSelectedEvents:p,error:v}){const{t:l}=_(),[k,u]=C.useState({}),f=C.useMemo(()=>{const n={};return Object.entries(s).forEach(([h,{events:x}])=>{const E=x.filter(I=>c[`${I.type}-${I.source}`]).length;n[h]=E}),n},[s,c]),i=C.useMemo(()=>Object.values(f).reduce((n,h)=>n+h,0),[f]),y=C.useMemo(()=>Object.values(s).reduce((n,{events:h})=>n+h.length,0),[s]),w=(n,h)=>{h.stopPropagation(),u({...k,[n]:!k[n]})},b=n=>{const h=`${n.type}-${n.source}`;p(x=>({...x,[h]:!x[h]}))},T=(n,h)=>{const x={};n.forEach(E=>{const I=`${E.type}-${E.source}`;x[I]=!h}),p(E=>({...E,...x}))},j=n=>{const h={};Object.values(s).forEach(({events:x})=>{x.forEach(E=>{const I=`${E.type}-${E.source}`;h[I]=n.target.checked})}),p(h)};return e.jsxs(d,{sx:{width:"100%"},children:[e.jsxs(d,{sx:{display:"flex",alignItems:"center",mb:1,mt:1},children:[e.jsx(ye,{control:e.jsx(ee,{onChange:j,checked:i>0&&i===y}),label:e.jsxs(d,{sx:{display:"flex",alignItems:"center",cursor:"pointer"},children:[l("webhookEndpoint.selectAllEvents"),e.jsx(d,{sx:{display:"flex",alignItems:"center"},children:e.jsx(A,{title:l("webhookEndpoint.selectAllEventsTooltip"),placement:"right",children:e.jsx(re,{fontSize:"small",sx:{ml:.5,cursor:"help"}})})})]}),sx:{m:0}}),i>0&&e.jsx(S,{variant:"body2",color:"primary",sx:{ml:"auto"},children:l("webhookEndpoint.selectedEventsCount",{count:i})})]}),e.jsx(d,{sx:{maxHeight:"50vh",overflow:"auto"},children:e.jsx(te,{disablePadding:!0,sx:{border:"1px solid",borderColor:"divider",borderRadius:"4px"},children:Object.entries(s).map(([n,{source:h,events:x,count:E}],I)=>{const O=f[n]>0,R=f[n]===x.length&&x.length>0,$=k[n];return e.jsxs(ie.Fragment,{children:[e.jsx(oe,{sx:{borderBottom:({palette:r})=>I<Object.keys(s).length-1?`1px solid ${r.divider}`:"none",px:2,py:1.5,"&:hover":{bgcolor:"rgba(0, 0, 0, 0.02)"}},children:e.jsxs(d,{sx:{display:"flex",width:"100%",justifyContent:"space-between",alignItems:"center"},onClick:r=>{r.target.closest(".MuiFormControlLabel-root")||w(n,r)},children:[e.jsx(d,{sx:{display:"flex",alignItems:"center"},children:x.length>0&&e.jsx(ye,{control:e.jsx(ee,{checked:R,indeterminate:O&&!R,onChange:r=>{r.stopPropagation(),T(x,R)}}),label:e.jsxs(d,{sx:{display:"flex",alignItems:"center",gap:1},children:[h.logo&&e.jsx(Xe,{src:h.logo,sx:{width:24,height:24}}),e.jsx(d,{children:h.title||n}),O&&e.jsx(M,{label:l("webhookEndpoint.selectedCount",{count:f[n]}),size:"small",sx:{mt:"2px",height:"20px",fontSize:"12px",bgcolor:r=>`${r.palette.primary.main}20`,color:"primary.main",fontWeight:500}})]}),sx:{m:0,"& .MuiFormControlLabel-label":{flex:1}}})}),e.jsxs(d,{sx:{display:"flex",alignItems:"center"},children:[e.jsx(S,{variant:"body2",color:"text.secondary",sx:{mr:1},children:l("webhookEndpoint.eventsCount",{count:E})}),x.length>0&&e.jsx(F,{size:"small",edge:"end",children:$?e.jsx(pt,{}):e.jsx(He,{})})]})]})}),x.length>0&&e.jsx(Ze,{in:$,timeout:"auto",unmountOnExit:!0,children:e.jsx(te,{disablePadding:!0,sx:{pl:2,pr:2,py:1,bgcolor:"rgba(0, 0, 0, 0.01)"},children:x.map(r=>{const a=`${r.type}-${r.source}`,t=!!c[a];return e.jsx(oe,{dense:!0,sx:{py:.75},onClick:()=>b(r),children:e.jsxs(d,{sx:{display:"flex",alignItems:"flex-start",width:"100%"},children:[e.jsx(ee,{checked:t,sx:{mr:1}}),e.jsxs(d,{children:[e.jsx(S,{variant:"body1",sx:{cursor:"pointer",color:"text.primary"},children:r.type}),e.jsx(S,{variant:"caption",color:"text.secondary",sx:{display:"block",cursor:"pointer"},children:r.description})]})]})},a)})})})]},n)})})}),v&&e.jsx(et,{error:!0,sx:{mt:1},children:v})]})}ce.propTypes={eventsBySource:o.objectOf(o.shape({source:o.shape({did:o.string.isRequired,title:o.string,description:o.string,version:o.string,logo:o.string}).isRequired,events:o.arrayOf(o.shape({type:o.string.isRequired,description:o.string.isRequired,source:o.string.isRequired})).isRequired,count:o.number.isRequired})).isRequired,selectedEvents:o.objectOf(o.bool).isRequired,setSelectedEvents:o.func.isRequired,error:o.string};ce.defaultProps={error:null};function ue({id:s,url:c,description:p,enabledEvents:v,onSubmit:l,onClose:k}){var r;const{t:u}=_(),[f,i]=C.useState({}),{teamDid:y}=Y(),{api:w}=V(),{loading:b,error:T,eventsBySource:j}=gt(),{control:n,handleSubmit:h,formState:{errors:x},reset:E,setValue:I,trigger:O}=Ue({defaultValues:{url:"",description:""}});C.useEffect(()=>{const a=Object.values(f).some(t=>t);I("selectedEvents",a?"valid":""),O("selectedEvents")},[f,I,O]);const R=()=>{i({}),E(),k()},$=async a=>{const t=Object.keys(f).filter(m=>f[m]),g={url:a.url,description:a.description,enabledEvents:t.map(m=>{const[P,z]=m.split("-");return!P||!z?null:{type:P,source:z}}).filter(Boolean)};try{if(s){const m=await w.updateWebhookEndpoint({input:{teamDid:y,id:s,data:g}});q.success(`${u("webhookEndpoint.updateWebhook")} ${u("webhookEndpoint.success")}`),l(m)}else{const m=await w.createWebhookEndpoint({input:{teamDid:y,input:g}});q.success(`${u("webhookEndpoint.createWebhook")} ${u("webhookEndpoint.success")}`),l(m)}}catch(m){q.error(m==null?void 0:m.message)}R()};return C.useEffect(()=>{E({url:c,description:p}),i(v.reduce((a,t)=>(a[`${t.type}-${t.source}`]=!0,a),{}))},[E,i,c,p,v]),e.jsx(Ye,{open:!0,onClose:R,maxWidth:"lg",fullWidth:!0,sx:{"& .MuiDialog-paper":{minHeight:600}},children:e.jsxs("form",{onSubmit:h($),children:[e.jsx(Je,{children:u(s?"webhookEndpoint.editWebhookTitle":"webhookEndpoint.createWebhookTitle")}),e.jsx(Ge,{children:e.jsxs(d,{sx:{display:"flex",flexDirection:"column",gap:2,mt:2},children:[e.jsx(Z,{name:"url",control:n,rules:{required:u("webhookEndpoint.validation.urlRequired"),pattern:{value:/^(http|https):\/\/[^ "]+$/,message:u("webhookEndpoint.validation.urlInvalid")}},render:({field:a})=>{var t;return e.jsx(je,{...a,label:u("webhookEndpoint.url.label"),fullWidth:!0,error:!!x.url,helperText:(t=x.url)==null?void 0:t.message})}}),e.jsx(Z,{name:"description",control:n,rules:{required:u("webhookEndpoint.validation.descriptionRequired")},render:({field:a})=>{var t;return e.jsx(je,{...a,label:u("webhookEndpoint.description.label"),fullWidth:!0,multiline:!0,minRows:2,maxRows:4,error:!!x.description,helperText:(t=x.description)==null?void 0:t.message})}}),e.jsx(Z,{name:"selectedEvents",control:n,rules:{required:u("webhookEndpoint.validation.eventRequired")},render:({field:a})=>e.jsx("input",{type:"hidden",...a})}),!b&&j&&Object.keys(j).length>0&&e.jsx(ce,{eventsBySource:j,selectedEvents:f,setSelectedEvents:i,error:(r=x.selectedEvents)==null?void 0:r.message}),!b&&(!j||Object.keys(j).length===0)&&e.jsx(S,{color:"text.secondary",children:u("webhookEndpoint.noAvailableEvents")}),b&&e.jsx(d,{sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"500px",width:"100%"},children:e.jsx(H,{size:20})}),T&&e.jsx(le,{severity:"error",children:u("webhookEndpoint.loadingError",{message:T==null?void 0:T.message})})]})}),e.jsxs(Qe,{sx:{p:"8px 24px 24px"},children:[e.jsx(N,{onClick:R,children:u("common.cancel")}),e.jsx(N,{type:"submit",variant:"contained",color:"primary",children:u(s?"webhookEndpoint.updateWebhook":"webhookEndpoint.saveWebhook")})]})]})})}ue.propTypes={onSubmit:o.func.isRequired,id:o.string,url:o.string,description:o.string,enabledEvents:o.arrayOf(o.shape({type:o.string.isRequired,source:o.string.isRequired})),onClose:o.func};ue.defaultProps={id:null,url:"",description:"",enabledEvents:[],onClose:()=>{}};function Pe(s){switch(s){case"enabled":return"success";case"disabled":default:return"default"}}const bt=(s="en")=>s==="tw"?"zh":s;function K(s,c="YYYY-MM-DD HH:mm:ss",p="en"){return s?Ke(s).locale(bt(p)).format(c):"-"}function jt(s){return typeof s=="number"?!1:De(s)}function yt(s){return s>=200&&s<300}function W(s){const c=jt(s.value);return e.jsxs(e.Fragment,{children:[e.jsxs(D,{direction:"column",alignItems:"flex-start",children:[e.jsxs(S,{component:"div",variant:"body1",mb:1,color:"text.primary",sx:{fontWeight:500},children:[s.label,!!s.tip&&e.jsx(A,{title:s.tip,children:e.jsx(tt,{fontSize:"small"})})]}),e.jsx(S,{component:"div",variant:"body1",color:c?"text.disabled":"text.secondary",sx:{width:"100%",minHeight:"24px"},children:c?"-":s.value})]}),s.divider&&e.jsx(Re,{orientation:"vertical",flexItem:!0})]})}W.propTypes={label:o.oneOfType([o.string,o.node]).isRequired,value:o.oneOfType([o.string,o.node]).isRequired,tip:o.oneOfType([o.string,o.node]),divider:o.bool};W.defaultProps={tip:"",divider:!1};function pe(s){return e.jsxs(D,{className:"section-header",direction:"row",justifyContent:"space-between",alignItems:"center",flexWrap:"wrap",gap:1,sx:{mb:s.mb,mt:s.mt,pb:1},children:[e.jsx(S,{variant:"h3",sx:{fontSize:{xs:"18px",md:"1.09375rem"}},component:"div",children:s.title}),s.children]})}pe.propTypes={title:o.oneOfType([o.string,o.node]).isRequired,children:o.node,mb:o.number,mt:o.number};pe.defaultProps={children:null,mb:1.5,mt:1.5};var he={},wt=ae;Object.defineProperty(he,"__esModule",{value:!0});var ze=he.default=void 0,kt=wt(se()),vt=e;ze=he.default=(0,kt.default)((0,vt.jsx)("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2M7 13.5c-.83 0-1.5-.67-1.5-1.5s.67-1.5 1.5-1.5 1.5.67 1.5 1.5-.67 1.5-1.5 1.5m5 0c-.83 0-1.5-.67-1.5-1.5s.67-1.5 1.5-1.5 1.5.67 1.5 1.5-.67 1.5-1.5 1.5m5 0c-.83 0-1.5-.67-1.5-1.5s.67-1.5 1.5-1.5 1.5.67 1.5 1.5-.67 1.5-1.5 1.5"}),"Pending");var xe={},Et=ae;Object.defineProperty(xe,"__esModule",{value:!0});var Oe=xe.default=void 0,Ct=Et(se()),St=e;Oe=xe.default=(0,Ct.default)((0,St.jsx)("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2m0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8m4.59-12.42L10 14.17l-2.59-2.58L6 13l4 4 8-8z"}),"CheckCircleOutlined");var me={},Tt=ae;Object.defineProperty(me,"__esModule",{value:!0});var We=me.default=void 0,It=Tt(se()),Rt=e;We=me.default=(0,It.default)((0,Rt.jsx)("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2m1 15h-2v-2h2zm0-4h-2V7h2z"}),"ErrorOutlined");const Dt={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"/>'},Pt=s=>{const c={};return s.forEach(p=>{var l;const v=new Date(p.createdAt).toLocaleDateString();c[v]||(c[v]=[]),(l=c[v])==null||l.push(p)}),c};function fe({eventId:s,webhookEndpointId:c,event:p}){const{api:v,ws:{useSubscription:l}}=V(),{t:k}=_(),{teamDid:u}=Y(),{blocklet:f}=Ie(),{data:i,loadMore:y,loadingMore:w,loading:b,mutate:T}=Be(t=>{const m=t?Math.ceil(t.list.length/15)+1:1;return v.getWebhookAttempts({input:{teamDid:u,input:{eventId:s,webhookId:c},paging:{page:m,pageSize:15}}})},{reloadDeps:[s,c]}),j=(i==null?void 0:i.list)||[],[n,h]=C.useState(null),[x,E]=C.useState(!1),I=Pt(j);if(C.useEffect(()=>{!n&&(i!=null&&i.list.length)&&h(i.list[0])},[i==null?void 0:i.list.length,n]),l(ve.EVENTS.WEBHOOK_ATTEMPT,t=>{T(g=>{var P,z;if(g.list.find(L=>L.id===t.id)){const L=g.list.map(B=>B.id===t.id?{...B,...t}:B);return{...g,list:L}}return t.endpoint=(P=g.list[0])==null?void 0:P.endpoint,t.event=(z=g.list[0])==null?void 0:z.event,{...g,list:[t,...g.list]}})},[]),b)return e.jsx(H,{});const O=i&&i.list.length<i.paging.total,R=async()=>{n&&(E(!0),await v.retryWebhookAttempt({input:{teamDid:u,eventId:n.event.id,webhookId:c,attemptId:n.id}}).finally(()=>{setTimeout(()=>{E(!1)},1e3)}))},$=t=>{var g,m,P,z,L;if(t.responseBody&&((g=t.responseBody)!=null&&g.sessionId)&&((m=t.responseBody)!=null&&m.projectId)&&((P=t.responseBody)!=null&&P.agentId)){const B=(L=(z=f==null?void 0:f.site)==null?void 0:z.domainAliases[0])==null?void 0:L.value,J=(f.children||[]).find(G=>{var be;return((be=G==null?void 0:G.meta)==null?void 0:be.name)==="ai-studio"}),qe=ht(xt(`https://${B}`,(J==null?void 0:J.mountPoint)||"","projects",t.responseBody.projectId,"logs/main"),{sessionId:t.responseBody.sessionId,agentId:t.responseBody.agentId});return e.jsx(F,{sx:{fontSize:20},onClick:()=>window.open(qe,"_blank"),children:e.jsx(d,{component:U,icon:Q})})}return null},r=t=>t.status==="pending"?e.jsx(ze,{color:"warning"}):yt(t.responseStatus)?e.jsx(Oe,{color:"success"}):e.jsx(We,{color:"error"}),a=(n==null?void 0:n.triggeredFrom)&&((i==null?void 0:i.list)||[]).find(t=>t.id===n.triggeredFrom);return e.jsxs(zt,{container:!0,spacing:{xs:0,md:1},sx:{height:1},children:[e.jsx(ne,{item:!0,xs:12,md:4,height:1,children:De(Object.keys(I))?e.jsx(S,{color:"text.secondary",children:k("webhookEndpoint.waitingForEvents")}):e.jsxs(e.Fragment,{children:[e.jsx(te,{sx:{maxHeight:"calc(100% - 40px)",py:0,overflowY:"auto"},children:Object.entries(I).map(([t,g])=>e.jsxs(ie.Fragment,{children:[e.jsx(ot,{sx:{p:0},children:t}),g.map(m=>e.jsxs(oe,{sx:{cursor:"pointer",px:1},onClick:()=>h(m),selected:n&&(n==null?void 0:n.id)===(m==null?void 0:m.id),secondaryAction:e.jsx(S,{color:"text.secondary",children:K(m.createdAt,"HH:mm:ss")}),children:[e.jsx(nt,{sx:{minWidth:0,mr:1.5},children:r(m)}),e.jsx(st,{primary:e.jsx(S,{color:"text.primary",children:m.event.type})})]},m.id))]},t))}),O&&e.jsx(d,{display:"flex",justifyContent:"center",alignItems:"center",width:1,children:e.jsx(N,{variant:"text",type:"button",color:"inherit",onClick:y,disabled:w,sx:{color:t=>t.palette.text.disabled},children:k(w?"webhookEndpoint.loadingMore":"webhookEndpoint.loadMore")})})]})}),e.jsxs(ne,{item:!0,xs:12,md:8,height:1,children:[n&&e.jsxs(D,{height:1,overflow:"auto",direction:"column",spacing:2,sx:{pl:{xs:0,md:1},mt:{xs:2,md:0},borderLeft:{xs:"none"}},children:[e.jsxs(d,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs(d,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(S,{variant:"h4",children:k(`common.${n.status}`)}),e.jsx(d,{children:$(n)})]}),e.jsxs(d,{sx:{display:"flex",alignItems:"center",gap:1},children:[a&&e.jsx(A,{componentsProps:{tooltip:{sx:{maxWidth:400}}},placement:"left",title:e.jsxs(D,{gap:1,sx:{cursor:"pointer",".did-address-text":{color:"common.white"}},onClick:()=>h(a),children:[e.jsx(Ee,{showDid:!0,did:n.triggeredBy,cardType:Ce.Detailed,infoType:Se.Minimal,sx:{border:0,padding:0,minWidth:0,".MuiTypography-root":{color:"common.white",fontWeight:400}}}),e.jsx(Re,{}),e.jsxs(d,{sx:{display:"flex",flexDirection:"column"},children:[e.jsx(S,{variant:"body2",sx:{color:"primary.main"},children:k("webhookEndpoint.triggeredFrom")}),e.jsxs(d,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(S,{variant:"body2",children:n.id}),e.jsx(F,{onClick:()=>h(a),children:e.jsx(d,{component:U,icon:Q,sx:{fontSize:16,color:"common.white"}})})]})]})]}),children:e.jsx(F,{onClick:()=>h(a),children:e.jsx(d,{component:U,icon:Q,sx:{fontSize:16}})})}),e.jsxs(N,{variant:"outlined",color:"primary",size:"small",onClick:R,disabled:x,children:[e.jsx(d,{component:U,icon:Dt,sx:{fontSize:16,animation:x?"spin 1s linear infinite":"none",mr:.5}}),k("notification.resend")]})]})]}),e.jsxs(d,{children:[e.jsxs(S,{variant:"h6",children:[k("webhookEndpoint.response")," (",n.responseStatus,")"]}),e.jsx(X,{language:"json",children:JSON.stringify(n.responseBody,null,2)})]}),e.jsxs(d,{children:[e.jsx(D,{direction:"row",alignItems:"center",spacing:1,children:e.jsx(S,{variant:"h6",children:k("webhookEndpoint.request")})}),e.jsx(X,{language:"json",sx:{margin:0},children:JSON.stringify(n.event,null,2)})]})]}),(i==null?void 0:i.list.length)===0&&p&&e.jsxs(d,{children:[e.jsx(D,{direction:"row",alignItems:"center",spacing:1,children:e.jsx(S,{variant:"h6",children:k("webhookEndpoint.eventData")})}),e.jsx(X,{language:"json",sx:{margin:0},children:JSON.stringify(p.data,null,2)})]})]})]})}fe.propTypes={eventId:o.string,webhookEndpointId:o.string,event:o.shape({type:o.string,data:o.object,request:o.object,requestInfo:o.object})};fe.defaultProps={eventId:"",webhookEndpointId:"",event:null};const zt=de(ne)`
|
|
2
2
|
@keyframes spin {
|
|
3
3
|
to {
|
|
4
4
|
transform: rotate(360deg);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as se,a3 as U,cd as Me,ce as Ve,I as K,cb as $e,cc as Ne,ai as He,ah as Je,cf as Ke,bd as Ce,k as oe,r as Ae,bb as G,cg as xe,ar as ge,B as z,b$ as Ge,ab as Ze,ch as Xe,ac as Ye,a8 as Qe,a5 as et,ax as De}from"./vendor-ux-did-connect-BbCim3WZ.js";import{u as p,a as ae,b as te,c as tt}from"./vendor-hooks-DqdmWCmo.js";import{r as P}from"./vendor-react-DEoibe3W.js";import{j as e,aa as u,bs as _,bo as E,O,y as $,H,T as ne,I as ie,X as le,ah as Oe,al as V,cG as nt,a9 as Be,e as je,ab as fe,a7 as ze,ad as st,ap as at}from"./vendor-mui-core-Bq8gXTan.js";import{Z as rt,v as qe,B as ot,c as it}from"./vendor-arcblock-f1tICt1E.js";import{J as Y,a9 as lt,c as Fe,D as ct,n as X,aJ as dt,A as ut,b as mt}from"./vendor-utils-BfZ4tlod.js";import{D as J,G as N,aC as re,aD as I,aL as Re}from"./index-BMCGWiyM.js";import{S as ce}from"./switch-control-BCB3_Ctk.js";import{S as C}from"./section-BDMQAX_r.js";import{K as pt}from"./keyboard-arrow-down-rounded-DadBVmpO.js";import{I as ht}from"./index-DDI23z2P.js";import{b as xt}from"./base32-Cbt7-U8e.js";import{u as ft}from"./use-mobile-DwzRjjku.js";import"./lottie-web-jYmAQWuC.js";const de={enabled:!1,domain:"",clientId:"",clientSecret:""};function gt(){var v,S,i;const{api:j}=J(),{blocklet:o}=N(),{t:n}=se(),s=(v=o==null?void 0:o.meta)==null?void 0:v.did,w=Object.assign({...de},((i=(S=o==null?void 0:o.settings)==null?void 0:S.oauth)==null?void 0:i.auth0)||{}),{handleSubmit:t,control:f,formState:c,watch:h,reset:l}=re({defaultValues:Y(w,Object.keys(de))}),d=h("enabled"),k=p(async r=>{var L,a;try{const{blocklet:b}=await j.configOAuth({input:{did:s,oauth:JSON.stringify({auth0:r})}}),m=Object.assign({...de},((a=(L=b==null?void 0:b.settings)==null?void 0:L.oauth)==null?void 0:a.auth0)||{});l(m),U.success(n("oauth.saveSuccess"))}catch(b){U.error(b.message||n("oauth.saveFailed"))}}),T=p(r=>r!=null&&r.trim()?!0:n("oauth.auth0.domainDescription")),x=p(r=>r!=null&&r.trim()?!0:n("oauth.auth0.clientIdDescription")),g=p(r=>r!=null&&r.trim()?!0:n("oauth.auth0.clientSecretDescription")),y=p(()=>!0);return e.jsx(u,{children:e.jsxs("form",{onSubmit:t(k),disabled:!0,children:[e.jsx(C,{title:n("oauth.auth0.enable"),mb:2.5,children:e.jsx(I,{name:"enabled",control:f,render:({field:r})=>e.jsx(_,{control:e.jsx(ce,{sx:{ml:1},checked:r.value,...r})})})}),e.jsx(C,{title:n("oauth.auth0.domain"),children:e.jsx(I,{name:"domain",control:f,rules:{validate:d?T:y},render:({field:r})=>{var L;return e.jsx(E,{fullWidth:!0,children:e.jsx(O,{...r,size:"small",label:n("oauth.auth0.domain"),error:!!c.errors[r.name],helperText:((L=c.errors[r.name])==null?void 0:L.message)||" ",disabled:!d})})}})}),e.jsx(C,{title:n("oauth.auth0.clientId"),children:e.jsx(I,{name:"clientId",control:f,rules:{validate:d?x:y},render:({field:r})=>{var L;return e.jsx(E,{fullWidth:!0,children:e.jsx(O,{...r,size:"small",label:n("oauth.auth0.clientId"),error:!!c.errors[r.name],helperText:((L=c.errors[r.name])==null?void 0:L.message)||" ",disabled:!d})})}})}),e.jsx(C,{title:n("oauth.auth0.clientSecret"),children:e.jsx(I,{name:"clientSecret",control:f,rules:{validate:d?g:y},render:({field:r})=>{var L;return e.jsx(E,{fullWidth:!0,children:e.jsx(O,{...r,size:"small",type:"password",label:n("oauth.auth0.clientSecret"),error:!!c.errors[r.name],helperText:((L=c.errors[r.name])==null?void 0:L.message)||" ",disabled:!d})})}})}),e.jsx($,{type:"submit",variant:"contained",onSubmit:t(k),disabled:!c.isDirty,children:n("oauth.save")})]})})}const ue={enabled:!1,clientId:"",clientSecret:""};function jt(){var y,v,S;const{api:j}=J(),{blocklet:o}=N(),{t:n}=se(),s=(y=o==null?void 0:o.meta)==null?void 0:y.did,w=Object.assign({...ue},((S=(v=o==null?void 0:o.settings)==null?void 0:v.oauth)==null?void 0:S.github)||{}),{handleSubmit:t,control:f,formState:c,watch:h,reset:l}=re({defaultValues:Y(w,Object.keys(ue))}),d=h("enabled"),k=p(async i=>{var r,L;try{const{blocklet:a}=await j.configOAuth({input:{did:s,oauth:JSON.stringify({github:i})}}),b=Object.assign({...ue},((L=(r=a==null?void 0:a.settings)==null?void 0:r.oauth)==null?void 0:L.github)||{});l(b),U.success(n("oauth.saveSuccess"))}catch(a){U.error(a.message||n("oauth.saveFailed"))}}),T=p(i=>i!=null&&i.trim()?!0:n("oauth.github.clientIdDescription")),x=p(i=>i!=null&&i.trim()?!0:n("oauth.github.clientSecretDescription")),g=p(()=>!0);return e.jsx(u,{children:e.jsxs("form",{onSubmit:t(k),disabled:!0,children:[e.jsx(C,{title:n("oauth.github.enable"),mb:2.5,children:e.jsx(I,{name:"enabled",control:f,render:({field:i})=>e.jsx(_,{control:e.jsx(ce,{sx:{ml:1},checked:i.value,...i})})})}),e.jsx(C,{title:n("oauth.github.clientId"),children:e.jsx(I,{name:"clientId",control:f,rules:{validate:d?T:g},render:({field:i})=>{var r;return e.jsx(E,{fullWidth:!0,children:e.jsx(O,{...i,size:"small",label:n("oauth.github.clientId"),error:!!c.errors[i.name],helperText:((r=c.errors[i.name])==null?void 0:r.message)||" ",disabled:!d})})}})}),e.jsx(C,{title:n("oauth.github.clientSecret"),children:e.jsx(I,{name:"clientSecret",control:f,rules:{validate:d?x:g},render:({field:i})=>{var r;return e.jsx(E,{fullWidth:!0,children:e.jsx(O,{...i,size:"small",type:"password",label:n("oauth.github.clientSecret"),error:!!c.errors[i.name],helperText:((r=c.errors[i.name])==null?void 0:r.message)||" ",disabled:!d})})}})}),e.jsx($,{type:"submit",variant:"contained",onSubmit:t(k),disabled:!c.isDirty,children:n("oauth.save")})]})})}const me={enabled:!1,clientId:"",clientSecret:""};function bt(){var y,v,S;const{api:j}=J(),{blocklet:o}=N(),{t:n}=se(),s=(y=o==null?void 0:o.meta)==null?void 0:y.did,w=Object.assign({...me},((S=(v=o==null?void 0:o.settings)==null?void 0:v.oauth)==null?void 0:S.google)||{}),{handleSubmit:t,control:f,formState:c,watch:h,reset:l}=re({defaultValues:Y(w,Object.keys(me))}),d=h("enabled"),k=p(async i=>{var r,L;try{const{blocklet:a}=await j.configOAuth({input:{did:s,oauth:JSON.stringify({google:i})}}),b=Object.assign({...me},((L=(r=a==null?void 0:a.settings)==null?void 0:r.oauth)==null?void 0:L.google)||{});l(b),U.success(n("oauth.saveSuccess"))}catch(a){U.error(a.message||n("oauth.saveFailed"))}}),T=p(i=>i!=null&&i.trim()?!0:n("oauth.google.clientIdDescription")),x=p(i=>i!=null&&i.trim()?!0:n("oauth.google.clientSecretDescription")),g=p(()=>!0);return e.jsx(u,{children:e.jsxs("form",{onSubmit:t(k),disabled:!0,children:[e.jsx(C,{title:n("oauth.google.enable"),mb:2.5,children:e.jsx(I,{name:"enabled",control:f,render:({field:i})=>e.jsx(_,{control:e.jsx(ce,{sx:{ml:1},checked:i.value,...i})})})}),e.jsx(C,{title:n("oauth.google.clientId"),children:e.jsx(I,{name:"clientId",control:f,rules:{validate:d?T:g},render:({field:i})=>{var r;return e.jsx(E,{fullWidth:!0,children:e.jsx(O,{...i,size:"small",label:n("oauth.google.clientId"),error:!!c.errors[i.name],helperText:((r=c.errors[i.name])==null?void 0:r.message)||" ",disabled:!d})})}})}),e.jsx(C,{title:n("oauth.google.clientSecret"),children:e.jsx(I,{name:"clientSecret",control:f,rules:{validate:d?x:g},render:({field:i})=>{var r;return e.jsx(E,{fullWidth:!0,children:e.jsx(O,{...i,size:"small",type:"password",label:n("oauth.google.clientSecret"),error:!!c.errors[i.name],helperText:((r=c.errors[i.name])==null?void 0:r.message)||" ",disabled:!d})})}})}),e.jsx($,{type:"submit",variant:"contained",onSubmit:t(k),disabled:!c.isDirty,children:n("oauth.save")})]})})}const pe={enabled:!1,teamId:"",serviceId:"",keyId:"",authKey:"",bundleId:""};function vt(){var i,r,L;const{api:j}=J(),{blocklet:o}=N(),{t:n}=se(),s=(i=o==null?void 0:o.meta)==null?void 0:i.did,w=Object.assign({...pe},((L=(r=o==null?void 0:o.settings)==null?void 0:r.oauth)==null?void 0:L.apple)||{}),{handleSubmit:t,control:f,formState:c,watch:h,reset:l}=re({defaultValues:Y(w,Object.keys(pe))}),d=h("enabled"),k=p(async a=>{var b,m;try{const{blocklet:R}=await j.configOAuth({input:{did:s,oauth:JSON.stringify({apple:a})}}),A=Object.assign({...pe},((m=(b=R==null?void 0:R.settings)==null?void 0:b.oauth)==null?void 0:m.apple)||{});l(A),U.success(n("oauth.saveSuccess"))}catch(R){U.error(R.message||n("oauth.saveFailed"))}}),T=p(a=>a!=null&&a.trim()?!0:n("oauth.apple.teamIdDescription")),x=p(a=>a!=null&&a.trim()?!0:n("oauth.apple.serviceIdDescription")),g=p(a=>a!=null&&a.trim()?!0:n("oauth.apple.keyIdDescription")),y=p(a=>a!=null&&a.trim()?!0:n("oauth.apple.authKeyDescription")),v=p(a=>a!=null&&a.trim()?!0:n("oauth.apple.bundleIdDescription")),S=p(()=>!0);return e.jsx(u,{children:e.jsxs("form",{onSubmit:t(k),disabled:!0,children:[e.jsx(C,{title:n("oauth.apple.enable"),mb:2.5,children:e.jsx(I,{name:"enabled",control:f,render:({field:a})=>e.jsx(_,{control:e.jsx(ce,{sx:{ml:1},checked:a.value,...a})})})}),e.jsx(C,{title:n("oauth.apple.teamId"),children:e.jsx(I,{name:"teamId",control:f,rules:{validate:d?T:S},render:({field:a})=>{var b;return e.jsx(E,{fullWidth:!0,children:e.jsx(O,{...a,size:"small",label:n("oauth.apple.teamId"),error:!!c.errors[a.name],helperText:((b=c.errors[a.name])==null?void 0:b.message)||" ",disabled:!d})})}})}),e.jsx(C,{title:n("oauth.apple.bundleId"),children:e.jsx(I,{name:"bundleId",control:f,rules:{validate:d?v:S},render:({field:a})=>{var b;return e.jsx(E,{fullWidth:!0,children:e.jsx(O,{...a,size:"small",label:n("oauth.apple.bundleId"),error:!!c.errors[a.name],helperText:((b=c.errors[a.name])==null?void 0:b.message)||" ",disabled:!d})})}})}),e.jsx(C,{title:n("oauth.apple.serviceId"),children:e.jsx(I,{name:"serviceId",control:f,rules:{validate:d?x:S},render:({field:a})=>{var b;return e.jsx(E,{fullWidth:!0,children:e.jsx(O,{...a,size:"small",label:n("oauth.apple.serviceId"),error:!!c.errors[a.name],helperText:((b=c.errors[a.name])==null?void 0:b.message)||" ",disabled:!d})})}})}),e.jsx(C,{title:n("oauth.apple.keyId"),children:e.jsx(I,{name:"keyId",control:f,rules:{validate:d?g:S},render:({field:a})=>{var b;return e.jsx(E,{fullWidth:!0,children:e.jsx(O,{...a,size:"small",label:n("oauth.apple.keyId"),error:!!c.errors[a.name],helperText:((b=c.errors[a.name])==null?void 0:b.message)||" ",disabled:!d})})}})}),e.jsx(C,{title:n("oauth.apple.authKey"),children:e.jsx(I,{name:"authKey",control:f,rules:{validate:d?y:S},render:({field:a})=>{var b;return e.jsx(E,{fullWidth:!0,children:e.jsx(O,{...a,size:"small",type:"password",label:n("oauth.apple.authKey"),multiline:!0,rows:4,error:!!c.errors[a.name],helperText:((b=c.errors[a.name])==null?void 0:b.message)||" ",disabled:!d})})}})}),e.jsx($,{type:"submit",variant:"contained",onSubmit:t(k),disabled:!c.isDirty,children:n("oauth.save")})]})})}const yt={width:24,height:24,body:'<path fill="currentColor" d="M9 20q-.825 0-1.413-.588T7 18q0-.825.588-1.413T9 16q.825 0 1.413.588T11 18q0 .825-.588 1.413T9 20Zm6 0q-.825 0-1.413-.588T13 18q0-.825.588-1.413T15 16q.825 0 1.413.588T17 18q0 .825-.588 1.413T15 20Zm-6-6q-.825 0-1.413-.588T7 12q0-.825.588-1.413T9 10q.825 0 1.413.588T11 12q0 .825-.588 1.413T9 14Zm6 0q-.825 0-1.413-.588T13 12q0-.825.588-1.413T15 10q.825 0 1.413.588T17 12q0 .825-.588 1.413T15 14ZM9 8q-.825 0-1.413-.588T7 6q0-.825.588-1.413T9 4q.825 0 1.413.588T11 6q0 .825-.588 1.413T9 8Zm6 0q-.825 0-1.413-.588T13 6q0-.825.588-1.413T15 4q.825 0 1.413.588T17 6q0 .825-.588 1.413T15 8Z"/>'};function be({title:j,id:o,children:n,index:s,onMove:w,defaultExpand:t,onEnd:f}){const[c,h]=P.useState(t),l=P.useRef(null),d=P.useRef(null),[{handlerId:k},T]=Me({accept:"dragItem",collect(S){return{handlerId:S.getHandlerId()}},hover(S,i){var M,Q;if(!l.current)return;const r=S.index,L=s;if(r===L)return;const a=(M=l.current)==null?void 0:M.getBoundingClientRect(),b=(Q=d.current)==null?void 0:Q.getBoundingClientRect(),m=(b.bottom-b.top)/2,A=i.getClientOffset().y-a.top;r<L&&A<m||r>L&&A>m||(w(r,L),S.index=L)}}),[{isDragging:x},g]=Ve({item:{index:s,type:"dragItem"},collect:S=>({isDragging:S.isDragging()}),end:f});g(d),T(l);const y=x?.5:1,v=p(S=>{S.preventDefault(),S.stopPropagation(),h(!c)});return e.jsxs(u,{ref:l,children:[e.jsxs(u,{sx:{cursor:"pointer","&:hover":{backgroundColor:"grey.100"}},ref:d,"data-handler-id":k,children:[e.jsxs(u,{sx:{py:2,px:1,opacity:y,display:"flex",alignItems:"center",gap:.5},draggable:!1,onClick:v,children:[e.jsx(u,{sx:{pointerEvents:"auto",cursor:"grab","&:active":{cursor:"grabbing"},fontSize:0,color:"text.hint","&:hover":{color:"text.secondary"}},children:e.jsx(K,{fontSize:20,icon:yt})}),e.jsx(ne,{sx:{flex:1},children:j}),e.jsx(ie,{size:"small",sx:{pointerEvents:"auto",transform:c?"":"rotate(180deg)",transition:"transform 0.3s ease"},children:e.jsx(K,{icon:pt,style:{transform:"scale(1.5)"}})})]}),e.jsx(le,{})]}),e.jsx(u,{sx:{pl:4,py:2.5,display:c?"block":"none"},children:n})]})}be.propTypes={title:H.string.isRequired,id:H.string.isRequired,children:H.node.isRequired,index:H.number.isRequired,onMove:H.func.isRequired,onEnd:H.func.isRequired,defaultExpand:H.bool};be.defaultProps={defaultExpand:!1};const St=[{name:"github",title:"GitHub",icon:e.jsx(K,{icon:rt}),component:e.jsx(jt,{})},{name:"google",title:"Google",icon:e.jsx(K,{icon:He}),component:e.jsx(bt,{})},{name:"apple",title:"Apple",icon:e.jsx(K,{icon:Je}),component:e.jsx(vt,{})},{name:"auth0",title:"Auth0",icon:e.jsx(K,{icon:Ke}),component:e.jsx(gt,{})}],wt=["github","google","apple","auth0"];function kt(){var k,T;const{api:j}=J(),{blocklet:o}=N(),n=(k=o==null?void 0:o.meta)==null?void 0:k.did,s=((T=o==null?void 0:o.settings)==null?void 0:T.oauth)||{},w=Object.keys(s).sort((x,g)=>{var y,v,S;return((y=s[x])==null?void 0:y.order)!==void 0&&((v=s[g])==null?void 0:v.order)!==void 0?s[x].order-s[g].order:((S=s[x])==null?void 0:S.order)!==void 0?-1:1});for(const x of wt)w.includes(x)||w.push(x);const t=ae(w.reduce((x,g,y)=>Object.assign(x,{[g]:y}),{})),f=te(()=>{const x=[...St];return x.sort((g,y)=>t[g.name]-t[y.name]),x},[t.auth0,t.github,t.google]),c={};typeof window<"u"&&(c.context=window);const h=p(async x=>{const g={};Object.keys(x).forEach(y=>{g[y]={order:x[y]}}),await j.configOAuth({input:{did:n,oauth:JSON.stringify(g)}})}),l=p((x,g)=>{const y=f[x],v=f[g];t[y.name]=g,t[v.name]=x}),d=p(async()=>{await h(t)});return e.jsx(u,{sx:{".section-left":{width:"160px"}},children:e.jsx($e,{backend:Ne,...c,children:f.map((x,g)=>e.jsx(be,{index:g,id:x.name,title:x.title,icon:x.icon,onMove:l,onEnd:d,defaultExpand:x.enabled,children:x.component},x.name))})})}const Z={ttl:oe.SESSION_TTL,cacheTtl:oe.SESSION_CACHE_TTL,email:{enabled:!1,requireVerified:!1,requireUnique:!1,trustOauthProviders:!1,trustedIssuers:[],enableDomainBlackList:!1,domainBlackList:[],enableDomainWhiteList:!1,domainWhiteList:[]},phone:{enabled:!1,requireVerified:!1,requireUnique:!1,regionBlackList:[],trustedIssuers:[]}};function W(j){return e.jsx(ot,{...j,sx:{transform:"scale(0.75)"}})}function he(j,o=!1){const n=o?j.ttl*86400:j.ttl/86400;return{...j,ttl:n}}function Lt(){var a,b;const{api:j}=J(),{blocklet:o}=N(),n=(a=o==null?void 0:o.meta)==null?void 0:a.did,s=lt({},Z,((b=o==null?void 0:o.settings)==null?void 0:b.session)||{});Fe(s.ttl)&&(s.ttl=Z.ttl),Fe(s.cacheTtl)&&(s.cacheTtl=Z.cacheTtl),s.phone||(s.phone=Z.phone),s.email||(s.email=Z.email);const{handleSubmit:w,control:t,formState:f,reset:c,watch:h}=re({defaultValues:Y(he(s),["ttl","cacheTtl","email","phone"])}),{t:l}=se(),d=h("email.enabled"),k=h("phone.enabled"),T=h("email.enableDomainBlackList"),x=h("email.enableDomainWhiteList"),{fields:g,append:y,remove:v}=Re({control:t,name:"email.domainBlackList"}),{fields:S,append:i,remove:r}=Re({control:t,name:"email.domainWhiteList"}),L=p(async m=>{var R;try{const{blocklet:A}=await j.updateAppSessionConfig({input:{did:n,config:ct(he(m,!0),["phone"])}}),M=Object.assign({},Z,Y(((R=A==null?void 0:A.settings)==null?void 0:R.session)||{},["ttl","cacheTtl","email","phone"]));c(he(M)),U.success(l("common.configSuccess"))}catch(A){U.error(A.message)}});return e.jsx(Tt,{onSubmit:w(L),children:e.jsxs(V,{direction:"column",gap:6,children:[e.jsxs(u,{children:[e.jsxs(u,{children:[e.jsx(ne,{variant:"h6",fontWeight:600,children:l("blocklet.config.session.profile")}),e.jsx(u,{component:le,my:3})]}),e.jsxs(V,{gap:2,children:[e.jsx(C,{title:l("blocklet.config.session.fullNameEnabled"),sectionLeftSx:{width:"600px"},children:e.jsx(u,{sx:{alignSelf:"flex-start"},children:e.jsx(W,{disabled:!0,checked:!0})})}),e.jsx(C,{title:l("blocklet.config.session.avatarEnabled"),sectionLeftSx:{width:"600px"},children:e.jsx(u,{sx:{alignSelf:"flex-start"},children:e.jsx(W,{disabled:!0,checked:!0})})}),e.jsx(C,{title:l("blocklet.config.session.emailEnabled"),sectionLeftSx:{width:"600px"},children:e.jsx(u,{sx:{alignSelf:"flex-start"},children:e.jsx(I,{name:"email.enabled",control:t,render:({field:m})=>e.jsx(W,{...m,checked:m.value})})})}),d&&e.jsxs(V,{direction:"column",ml:2,children:[e.jsx(C,{title:l("blocklet.config.session.emailRequireVerified"),sectionLeftSx:{width:"600px"},children:e.jsx(u,{sx:{alignSelf:"flex-start"},children:e.jsx(I,{name:"email.requireVerified",control:t,render:({field:m})=>e.jsx(_,{sx:{mt:1},control:e.jsx(W,{...m,checked:m.value})})})})}),e.jsx(C,{title:l("blocklet.config.session.emailRequireUnique"),sectionLeftSx:{width:"600px"},children:e.jsx(u,{sx:{alignSelf:"flex-start"},children:e.jsx(I,{name:"email.requireUnique",control:t,render:({field:m})=>e.jsx(_,{sx:{mt:1},control:e.jsx(W,{...m,checked:m.value})})})})}),e.jsx(C,{title:l("blocklet.config.session.emailTrustOauthProviders"),sectionLeftSx:{width:"600px"},children:e.jsx(u,{sx:{alignSelf:"flex-start"},children:e.jsx(I,{name:"email.trustOauthProviders",control:t,render:({field:m})=>e.jsx(_,{sx:{mt:1},control:e.jsx(W,{...m,checked:m.value})})})})}),e.jsx(C,{title:l("blocklet.config.session.enableDomainBlackList"),sectionLeftSx:{width:"600px"},children:e.jsx(u,{sx:{alignSelf:"flex-start"},children:e.jsx(I,{name:"email.enableDomainBlackList",control:t,render:({field:m})=>e.jsx(_,{sx:{mt:1},control:e.jsx(W,{...m,checked:m.value})})})})}),T&&e.jsxs(u,{children:[g.map((m,R)=>e.jsxs(V,{direction:"row",alignItems:"center",my:1,maxWidth:"720px",children:[e.jsx(I,{name:`email.domainBlackList.${R}`,control:t,render:A=>e.jsx(O,{...A.field,size:"small",fullWidth:!0})}),e.jsx(ie,{onClick:()=>v(R),children:e.jsx(Ce,{})})]},m.id)),e.jsx($,{startIcon:e.jsx(qe,{}),onClick:()=>y(""),children:l("blocklet.config.session.addDomain")})]}),e.jsx(C,{title:l("blocklet.config.session.enableDomainWhiteList"),sectionLeftSx:{width:"600px"},children:e.jsx(u,{sx:{alignSelf:"flex-start"},children:e.jsx(I,{name:"email.enableDomainWhiteList",control:t,render:({field:m})=>e.jsx(_,{sx:{mt:1},control:e.jsx(W,{...m,checked:m.value})})})})}),x&&e.jsxs(u,{children:[S.map((m,R)=>e.jsxs(V,{direction:"row",alignItems:"center",my:1,maxWidth:"720px",children:[e.jsx(I,{name:`email.domainWhiteList.${R}`,control:t,render:A=>e.jsx(O,{...A.field,size:"small",fullWidth:!0})}),e.jsx(ie,{onClick:()=>r(R),children:e.jsx(Ce,{})})]},m.id)),e.jsx($,{startIcon:e.jsx(qe,{}),onClick:()=>i(""),children:l("blocklet.config.session.addDomain")})]})]}),e.jsxs(u,{sx:{display:"none"},children:[e.jsx(C,{title:l("blocklet.config.session.phoneEnabled"),sectionLeftSx:{width:"600px"},children:e.jsx(u,{sx:{alignSelf:"flex-start"},children:e.jsx(I,{name:"phone.enabled",control:t,disabled:!0,render:({field:m})=>e.jsx(_,{sx:{mt:1},control:e.jsx(W,{...m,checked:m.value})})})})}),k&&e.jsxs(V,{direction:"column",ml:2,mt:1,children:[e.jsx(C,{title:l("blocklet.config.session.phoneRequireVerified"),sectionLeftSx:{width:"600px"},children:e.jsx(u,{sx:{alignSelf:"flex-start"},children:e.jsx(I,{name:"phone.requireVerified",control:t,render:({field:m})=>e.jsx(_,{control:e.jsx(W,{...m,checked:m.value})})})})}),e.jsx(C,{title:l("blocklet.config.session.phoneRequireUnique"),sectionLeftSx:{width:"600px"},children:e.jsx(u,{sx:{alignSelf:"flex-start"},children:e.jsx(I,{name:"phone.requireUnique",control:t,render:({field:m})=>e.jsx(_,{control:e.jsx(W,{...m,checked:m.value})})})})})]})]})]})]}),e.jsxs(u,{children:[e.jsx(ne,{variant:"h6",fontWeight:600,children:l("blocklet.config.session.period")}),e.jsx(u,{component:le,my:3}),e.jsx(V,{direction:"column",spacing:2,children:e.jsx(I,{name:"ttl",control:t,rules:{min:1,max:30},render:({field:m})=>e.jsx(E,{fullWidth:!0,sx:{mb:2},children:e.jsx(C,{title:l("blocklet.config.session.ttl",{day:m.value}),sectionLeftSx:{width:"600px"},children:e.jsx(u,{sx:{width:"100%",maxWidth:500,px:1.5},children:e.jsx(nt,{...m,defaultValue:7,step:1,marks:[{value:1,label:l("blocklet.config.session.day",{day:1})},{value:7,label:l("blocklet.config.session.days",{day:7})},{value:14,label:l("blocklet.config.session.days",{day:14})},{value:21,label:l("blocklet.config.session.days",{day:21})},{value:30,label:l("blocklet.config.session.days",{day:30})}],min:1,max:30,valueLabelDisplay:"auto"})})})})})})]}),e.jsx(u,{children:e.jsx($,{type:"submit",variant:"contained",disabled:!f.isDirty,children:l("oauth.save")})})]})})}const Tt=Oe.form`
|
|
1
|
+
import{a as se,a3 as U,cd as Me,ce as Ve,I as K,cb as $e,cc as Ne,ai as He,ah as Je,cf as Ke,bd as Ce,k as oe,r as Ae,bb as G,cg as xe,ar as ge,B as z,b$ as Ge,ab as Ze,ch as Xe,ac as Ye,a8 as Qe,a5 as et,ax as De}from"./vendor-ux-did-connect-mISLpoxA.js";import{u as p,a as ae,b as te,c as tt}from"./vendor-hooks-DqdmWCmo.js";import{r as P}from"./vendor-react-DEoibe3W.js";import{j as e,aa as u,bs as _,bo as E,O,y as $,H,T as ne,I as ie,X as le,ah as Oe,al as V,cG as nt,a9 as Be,e as je,ab as fe,a7 as ze,ad as st,ap as at}from"./vendor-mui-core-Bq8gXTan.js";import{Z as rt,v as qe,B as ot,c as it}from"./vendor-arcblock-BUFJsma5.js";import{J as Y,a9 as lt,c as Fe,D as ct,n as X,aJ as dt,A as ut,b as mt}from"./vendor-utils-BfZ4tlod.js";import{D as J,G as N,aC as re,aD as I,aL as Re}from"./index-BRdhpmU2.js";import{S as ce}from"./switch-control-DuXtjpWN.js";import{S as C}from"./section-BDMQAX_r.js";import{K as pt}from"./keyboard-arrow-down-rounded-DadBVmpO.js";import{I as ht}from"./index-DBZhb75O.js";import{b as xt}from"./base32-kNwk0OEz.js";import{u as ft}from"./use-mobile-DwzRjjku.js";import"./lottie-web-jYmAQWuC.js";const de={enabled:!1,domain:"",clientId:"",clientSecret:""};function gt(){var v,S,i;const{api:j}=J(),{blocklet:o}=N(),{t:n}=se(),s=(v=o==null?void 0:o.meta)==null?void 0:v.did,w=Object.assign({...de},((i=(S=o==null?void 0:o.settings)==null?void 0:S.oauth)==null?void 0:i.auth0)||{}),{handleSubmit:t,control:f,formState:c,watch:h,reset:l}=re({defaultValues:Y(w,Object.keys(de))}),d=h("enabled"),k=p(async r=>{var L,a;try{const{blocklet:b}=await j.configOAuth({input:{did:s,oauth:JSON.stringify({auth0:r})}}),m=Object.assign({...de},((a=(L=b==null?void 0:b.settings)==null?void 0:L.oauth)==null?void 0:a.auth0)||{});l(m),U.success(n("oauth.saveSuccess"))}catch(b){U.error(b.message||n("oauth.saveFailed"))}}),T=p(r=>r!=null&&r.trim()?!0:n("oauth.auth0.domainDescription")),x=p(r=>r!=null&&r.trim()?!0:n("oauth.auth0.clientIdDescription")),g=p(r=>r!=null&&r.trim()?!0:n("oauth.auth0.clientSecretDescription")),y=p(()=>!0);return e.jsx(u,{children:e.jsxs("form",{onSubmit:t(k),disabled:!0,children:[e.jsx(C,{title:n("oauth.auth0.enable"),mb:2.5,children:e.jsx(I,{name:"enabled",control:f,render:({field:r})=>e.jsx(_,{control:e.jsx(ce,{sx:{ml:1},checked:r.value,...r})})})}),e.jsx(C,{title:n("oauth.auth0.domain"),children:e.jsx(I,{name:"domain",control:f,rules:{validate:d?T:y},render:({field:r})=>{var L;return e.jsx(E,{fullWidth:!0,children:e.jsx(O,{...r,size:"small",label:n("oauth.auth0.domain"),error:!!c.errors[r.name],helperText:((L=c.errors[r.name])==null?void 0:L.message)||" ",disabled:!d})})}})}),e.jsx(C,{title:n("oauth.auth0.clientId"),children:e.jsx(I,{name:"clientId",control:f,rules:{validate:d?x:y},render:({field:r})=>{var L;return e.jsx(E,{fullWidth:!0,children:e.jsx(O,{...r,size:"small",label:n("oauth.auth0.clientId"),error:!!c.errors[r.name],helperText:((L=c.errors[r.name])==null?void 0:L.message)||" ",disabled:!d})})}})}),e.jsx(C,{title:n("oauth.auth0.clientSecret"),children:e.jsx(I,{name:"clientSecret",control:f,rules:{validate:d?g:y},render:({field:r})=>{var L;return e.jsx(E,{fullWidth:!0,children:e.jsx(O,{...r,size:"small",type:"password",label:n("oauth.auth0.clientSecret"),error:!!c.errors[r.name],helperText:((L=c.errors[r.name])==null?void 0:L.message)||" ",disabled:!d})})}})}),e.jsx($,{type:"submit",variant:"contained",onSubmit:t(k),disabled:!c.isDirty,children:n("oauth.save")})]})})}const ue={enabled:!1,clientId:"",clientSecret:""};function jt(){var y,v,S;const{api:j}=J(),{blocklet:o}=N(),{t:n}=se(),s=(y=o==null?void 0:o.meta)==null?void 0:y.did,w=Object.assign({...ue},((S=(v=o==null?void 0:o.settings)==null?void 0:v.oauth)==null?void 0:S.github)||{}),{handleSubmit:t,control:f,formState:c,watch:h,reset:l}=re({defaultValues:Y(w,Object.keys(ue))}),d=h("enabled"),k=p(async i=>{var r,L;try{const{blocklet:a}=await j.configOAuth({input:{did:s,oauth:JSON.stringify({github:i})}}),b=Object.assign({...ue},((L=(r=a==null?void 0:a.settings)==null?void 0:r.oauth)==null?void 0:L.github)||{});l(b),U.success(n("oauth.saveSuccess"))}catch(a){U.error(a.message||n("oauth.saveFailed"))}}),T=p(i=>i!=null&&i.trim()?!0:n("oauth.github.clientIdDescription")),x=p(i=>i!=null&&i.trim()?!0:n("oauth.github.clientSecretDescription")),g=p(()=>!0);return e.jsx(u,{children:e.jsxs("form",{onSubmit:t(k),disabled:!0,children:[e.jsx(C,{title:n("oauth.github.enable"),mb:2.5,children:e.jsx(I,{name:"enabled",control:f,render:({field:i})=>e.jsx(_,{control:e.jsx(ce,{sx:{ml:1},checked:i.value,...i})})})}),e.jsx(C,{title:n("oauth.github.clientId"),children:e.jsx(I,{name:"clientId",control:f,rules:{validate:d?T:g},render:({field:i})=>{var r;return e.jsx(E,{fullWidth:!0,children:e.jsx(O,{...i,size:"small",label:n("oauth.github.clientId"),error:!!c.errors[i.name],helperText:((r=c.errors[i.name])==null?void 0:r.message)||" ",disabled:!d})})}})}),e.jsx(C,{title:n("oauth.github.clientSecret"),children:e.jsx(I,{name:"clientSecret",control:f,rules:{validate:d?x:g},render:({field:i})=>{var r;return e.jsx(E,{fullWidth:!0,children:e.jsx(O,{...i,size:"small",type:"password",label:n("oauth.github.clientSecret"),error:!!c.errors[i.name],helperText:((r=c.errors[i.name])==null?void 0:r.message)||" ",disabled:!d})})}})}),e.jsx($,{type:"submit",variant:"contained",onSubmit:t(k),disabled:!c.isDirty,children:n("oauth.save")})]})})}const me={enabled:!1,clientId:"",clientSecret:""};function bt(){var y,v,S;const{api:j}=J(),{blocklet:o}=N(),{t:n}=se(),s=(y=o==null?void 0:o.meta)==null?void 0:y.did,w=Object.assign({...me},((S=(v=o==null?void 0:o.settings)==null?void 0:v.oauth)==null?void 0:S.google)||{}),{handleSubmit:t,control:f,formState:c,watch:h,reset:l}=re({defaultValues:Y(w,Object.keys(me))}),d=h("enabled"),k=p(async i=>{var r,L;try{const{blocklet:a}=await j.configOAuth({input:{did:s,oauth:JSON.stringify({google:i})}}),b=Object.assign({...me},((L=(r=a==null?void 0:a.settings)==null?void 0:r.oauth)==null?void 0:L.google)||{});l(b),U.success(n("oauth.saveSuccess"))}catch(a){U.error(a.message||n("oauth.saveFailed"))}}),T=p(i=>i!=null&&i.trim()?!0:n("oauth.google.clientIdDescription")),x=p(i=>i!=null&&i.trim()?!0:n("oauth.google.clientSecretDescription")),g=p(()=>!0);return e.jsx(u,{children:e.jsxs("form",{onSubmit:t(k),disabled:!0,children:[e.jsx(C,{title:n("oauth.google.enable"),mb:2.5,children:e.jsx(I,{name:"enabled",control:f,render:({field:i})=>e.jsx(_,{control:e.jsx(ce,{sx:{ml:1},checked:i.value,...i})})})}),e.jsx(C,{title:n("oauth.google.clientId"),children:e.jsx(I,{name:"clientId",control:f,rules:{validate:d?T:g},render:({field:i})=>{var r;return e.jsx(E,{fullWidth:!0,children:e.jsx(O,{...i,size:"small",label:n("oauth.google.clientId"),error:!!c.errors[i.name],helperText:((r=c.errors[i.name])==null?void 0:r.message)||" ",disabled:!d})})}})}),e.jsx(C,{title:n("oauth.google.clientSecret"),children:e.jsx(I,{name:"clientSecret",control:f,rules:{validate:d?x:g},render:({field:i})=>{var r;return e.jsx(E,{fullWidth:!0,children:e.jsx(O,{...i,size:"small",type:"password",label:n("oauth.google.clientSecret"),error:!!c.errors[i.name],helperText:((r=c.errors[i.name])==null?void 0:r.message)||" ",disabled:!d})})}})}),e.jsx($,{type:"submit",variant:"contained",onSubmit:t(k),disabled:!c.isDirty,children:n("oauth.save")})]})})}const pe={enabled:!1,teamId:"",serviceId:"",keyId:"",authKey:"",bundleId:""};function vt(){var i,r,L;const{api:j}=J(),{blocklet:o}=N(),{t:n}=se(),s=(i=o==null?void 0:o.meta)==null?void 0:i.did,w=Object.assign({...pe},((L=(r=o==null?void 0:o.settings)==null?void 0:r.oauth)==null?void 0:L.apple)||{}),{handleSubmit:t,control:f,formState:c,watch:h,reset:l}=re({defaultValues:Y(w,Object.keys(pe))}),d=h("enabled"),k=p(async a=>{var b,m;try{const{blocklet:R}=await j.configOAuth({input:{did:s,oauth:JSON.stringify({apple:a})}}),A=Object.assign({...pe},((m=(b=R==null?void 0:R.settings)==null?void 0:b.oauth)==null?void 0:m.apple)||{});l(A),U.success(n("oauth.saveSuccess"))}catch(R){U.error(R.message||n("oauth.saveFailed"))}}),T=p(a=>a!=null&&a.trim()?!0:n("oauth.apple.teamIdDescription")),x=p(a=>a!=null&&a.trim()?!0:n("oauth.apple.serviceIdDescription")),g=p(a=>a!=null&&a.trim()?!0:n("oauth.apple.keyIdDescription")),y=p(a=>a!=null&&a.trim()?!0:n("oauth.apple.authKeyDescription")),v=p(a=>a!=null&&a.trim()?!0:n("oauth.apple.bundleIdDescription")),S=p(()=>!0);return e.jsx(u,{children:e.jsxs("form",{onSubmit:t(k),disabled:!0,children:[e.jsx(C,{title:n("oauth.apple.enable"),mb:2.5,children:e.jsx(I,{name:"enabled",control:f,render:({field:a})=>e.jsx(_,{control:e.jsx(ce,{sx:{ml:1},checked:a.value,...a})})})}),e.jsx(C,{title:n("oauth.apple.teamId"),children:e.jsx(I,{name:"teamId",control:f,rules:{validate:d?T:S},render:({field:a})=>{var b;return e.jsx(E,{fullWidth:!0,children:e.jsx(O,{...a,size:"small",label:n("oauth.apple.teamId"),error:!!c.errors[a.name],helperText:((b=c.errors[a.name])==null?void 0:b.message)||" ",disabled:!d})})}})}),e.jsx(C,{title:n("oauth.apple.bundleId"),children:e.jsx(I,{name:"bundleId",control:f,rules:{validate:d?v:S},render:({field:a})=>{var b;return e.jsx(E,{fullWidth:!0,children:e.jsx(O,{...a,size:"small",label:n("oauth.apple.bundleId"),error:!!c.errors[a.name],helperText:((b=c.errors[a.name])==null?void 0:b.message)||" ",disabled:!d})})}})}),e.jsx(C,{title:n("oauth.apple.serviceId"),children:e.jsx(I,{name:"serviceId",control:f,rules:{validate:d?x:S},render:({field:a})=>{var b;return e.jsx(E,{fullWidth:!0,children:e.jsx(O,{...a,size:"small",label:n("oauth.apple.serviceId"),error:!!c.errors[a.name],helperText:((b=c.errors[a.name])==null?void 0:b.message)||" ",disabled:!d})})}})}),e.jsx(C,{title:n("oauth.apple.keyId"),children:e.jsx(I,{name:"keyId",control:f,rules:{validate:d?g:S},render:({field:a})=>{var b;return e.jsx(E,{fullWidth:!0,children:e.jsx(O,{...a,size:"small",label:n("oauth.apple.keyId"),error:!!c.errors[a.name],helperText:((b=c.errors[a.name])==null?void 0:b.message)||" ",disabled:!d})})}})}),e.jsx(C,{title:n("oauth.apple.authKey"),children:e.jsx(I,{name:"authKey",control:f,rules:{validate:d?y:S},render:({field:a})=>{var b;return e.jsx(E,{fullWidth:!0,children:e.jsx(O,{...a,size:"small",type:"password",label:n("oauth.apple.authKey"),multiline:!0,rows:4,error:!!c.errors[a.name],helperText:((b=c.errors[a.name])==null?void 0:b.message)||" ",disabled:!d})})}})}),e.jsx($,{type:"submit",variant:"contained",onSubmit:t(k),disabled:!c.isDirty,children:n("oauth.save")})]})})}const yt={width:24,height:24,body:'<path fill="currentColor" d="M9 20q-.825 0-1.413-.588T7 18q0-.825.588-1.413T9 16q.825 0 1.413.588T11 18q0 .825-.588 1.413T9 20Zm6 0q-.825 0-1.413-.588T13 18q0-.825.588-1.413T15 16q.825 0 1.413.588T17 18q0 .825-.588 1.413T15 20Zm-6-6q-.825 0-1.413-.588T7 12q0-.825.588-1.413T9 10q.825 0 1.413.588T11 12q0 .825-.588 1.413T9 14Zm6 0q-.825 0-1.413-.588T13 12q0-.825.588-1.413T15 10q.825 0 1.413.588T17 12q0 .825-.588 1.413T15 14ZM9 8q-.825 0-1.413-.588T7 6q0-.825.588-1.413T9 4q.825 0 1.413.588T11 6q0 .825-.588 1.413T9 8Zm6 0q-.825 0-1.413-.588T13 6q0-.825.588-1.413T15 4q.825 0 1.413.588T17 6q0 .825-.588 1.413T15 8Z"/>'};function be({title:j,id:o,children:n,index:s,onMove:w,defaultExpand:t,onEnd:f}){const[c,h]=P.useState(t),l=P.useRef(null),d=P.useRef(null),[{handlerId:k},T]=Me({accept:"dragItem",collect(S){return{handlerId:S.getHandlerId()}},hover(S,i){var M,Q;if(!l.current)return;const r=S.index,L=s;if(r===L)return;const a=(M=l.current)==null?void 0:M.getBoundingClientRect(),b=(Q=d.current)==null?void 0:Q.getBoundingClientRect(),m=(b.bottom-b.top)/2,A=i.getClientOffset().y-a.top;r<L&&A<m||r>L&&A>m||(w(r,L),S.index=L)}}),[{isDragging:x},g]=Ve({item:{index:s,type:"dragItem"},collect:S=>({isDragging:S.isDragging()}),end:f});g(d),T(l);const y=x?.5:1,v=p(S=>{S.preventDefault(),S.stopPropagation(),h(!c)});return e.jsxs(u,{ref:l,children:[e.jsxs(u,{sx:{cursor:"pointer","&:hover":{backgroundColor:"grey.100"}},ref:d,"data-handler-id":k,children:[e.jsxs(u,{sx:{py:2,px:1,opacity:y,display:"flex",alignItems:"center",gap:.5},draggable:!1,onClick:v,children:[e.jsx(u,{sx:{pointerEvents:"auto",cursor:"grab","&:active":{cursor:"grabbing"},fontSize:0,color:"text.hint","&:hover":{color:"text.secondary"}},children:e.jsx(K,{fontSize:20,icon:yt})}),e.jsx(ne,{sx:{flex:1},children:j}),e.jsx(ie,{size:"small",sx:{pointerEvents:"auto",transform:c?"":"rotate(180deg)",transition:"transform 0.3s ease"},children:e.jsx(K,{icon:pt,style:{transform:"scale(1.5)"}})})]}),e.jsx(le,{})]}),e.jsx(u,{sx:{pl:4,py:2.5,display:c?"block":"none"},children:n})]})}be.propTypes={title:H.string.isRequired,id:H.string.isRequired,children:H.node.isRequired,index:H.number.isRequired,onMove:H.func.isRequired,onEnd:H.func.isRequired,defaultExpand:H.bool};be.defaultProps={defaultExpand:!1};const St=[{name:"github",title:"GitHub",icon:e.jsx(K,{icon:rt}),component:e.jsx(jt,{})},{name:"google",title:"Google",icon:e.jsx(K,{icon:He}),component:e.jsx(bt,{})},{name:"apple",title:"Apple",icon:e.jsx(K,{icon:Je}),component:e.jsx(vt,{})},{name:"auth0",title:"Auth0",icon:e.jsx(K,{icon:Ke}),component:e.jsx(gt,{})}],wt=["github","google","apple","auth0"];function kt(){var k,T;const{api:j}=J(),{blocklet:o}=N(),n=(k=o==null?void 0:o.meta)==null?void 0:k.did,s=((T=o==null?void 0:o.settings)==null?void 0:T.oauth)||{},w=Object.keys(s).sort((x,g)=>{var y,v,S;return((y=s[x])==null?void 0:y.order)!==void 0&&((v=s[g])==null?void 0:v.order)!==void 0?s[x].order-s[g].order:((S=s[x])==null?void 0:S.order)!==void 0?-1:1});for(const x of wt)w.includes(x)||w.push(x);const t=ae(w.reduce((x,g,y)=>Object.assign(x,{[g]:y}),{})),f=te(()=>{const x=[...St];return x.sort((g,y)=>t[g.name]-t[y.name]),x},[t.auth0,t.github,t.google]),c={};typeof window<"u"&&(c.context=window);const h=p(async x=>{const g={};Object.keys(x).forEach(y=>{g[y]={order:x[y]}}),await j.configOAuth({input:{did:n,oauth:JSON.stringify(g)}})}),l=p((x,g)=>{const y=f[x],v=f[g];t[y.name]=g,t[v.name]=x}),d=p(async()=>{await h(t)});return e.jsx(u,{sx:{".section-left":{width:"160px"}},children:e.jsx($e,{backend:Ne,...c,children:f.map((x,g)=>e.jsx(be,{index:g,id:x.name,title:x.title,icon:x.icon,onMove:l,onEnd:d,defaultExpand:x.enabled,children:x.component},x.name))})})}const Z={ttl:oe.SESSION_TTL,cacheTtl:oe.SESSION_CACHE_TTL,email:{enabled:!1,requireVerified:!1,requireUnique:!1,trustOauthProviders:!1,trustedIssuers:[],enableDomainBlackList:!1,domainBlackList:[],enableDomainWhiteList:!1,domainWhiteList:[]},phone:{enabled:!1,requireVerified:!1,requireUnique:!1,regionBlackList:[],trustedIssuers:[]}};function W(j){return e.jsx(ot,{...j,sx:{transform:"scale(0.75)"}})}function he(j,o=!1){const n=o?j.ttl*86400:j.ttl/86400;return{...j,ttl:n}}function Lt(){var a,b;const{api:j}=J(),{blocklet:o}=N(),n=(a=o==null?void 0:o.meta)==null?void 0:a.did,s=lt({},Z,((b=o==null?void 0:o.settings)==null?void 0:b.session)||{});Fe(s.ttl)&&(s.ttl=Z.ttl),Fe(s.cacheTtl)&&(s.cacheTtl=Z.cacheTtl),s.phone||(s.phone=Z.phone),s.email||(s.email=Z.email);const{handleSubmit:w,control:t,formState:f,reset:c,watch:h}=re({defaultValues:Y(he(s),["ttl","cacheTtl","email","phone"])}),{t:l}=se(),d=h("email.enabled"),k=h("phone.enabled"),T=h("email.enableDomainBlackList"),x=h("email.enableDomainWhiteList"),{fields:g,append:y,remove:v}=Re({control:t,name:"email.domainBlackList"}),{fields:S,append:i,remove:r}=Re({control:t,name:"email.domainWhiteList"}),L=p(async m=>{var R;try{const{blocklet:A}=await j.updateAppSessionConfig({input:{did:n,config:ct(he(m,!0),["phone"])}}),M=Object.assign({},Z,Y(((R=A==null?void 0:A.settings)==null?void 0:R.session)||{},["ttl","cacheTtl","email","phone"]));c(he(M)),U.success(l("common.configSuccess"))}catch(A){U.error(A.message)}});return e.jsx(Tt,{onSubmit:w(L),children:e.jsxs(V,{direction:"column",gap:6,children:[e.jsxs(u,{children:[e.jsxs(u,{children:[e.jsx(ne,{variant:"h6",fontWeight:600,children:l("blocklet.config.session.profile")}),e.jsx(u,{component:le,my:3})]}),e.jsxs(V,{gap:2,children:[e.jsx(C,{title:l("blocklet.config.session.fullNameEnabled"),sectionLeftSx:{width:"600px"},children:e.jsx(u,{sx:{alignSelf:"flex-start"},children:e.jsx(W,{disabled:!0,checked:!0})})}),e.jsx(C,{title:l("blocklet.config.session.avatarEnabled"),sectionLeftSx:{width:"600px"},children:e.jsx(u,{sx:{alignSelf:"flex-start"},children:e.jsx(W,{disabled:!0,checked:!0})})}),e.jsx(C,{title:l("blocklet.config.session.emailEnabled"),sectionLeftSx:{width:"600px"},children:e.jsx(u,{sx:{alignSelf:"flex-start"},children:e.jsx(I,{name:"email.enabled",control:t,render:({field:m})=>e.jsx(W,{...m,checked:m.value})})})}),d&&e.jsxs(V,{direction:"column",ml:2,children:[e.jsx(C,{title:l("blocklet.config.session.emailRequireVerified"),sectionLeftSx:{width:"600px"},children:e.jsx(u,{sx:{alignSelf:"flex-start"},children:e.jsx(I,{name:"email.requireVerified",control:t,render:({field:m})=>e.jsx(_,{sx:{mt:1},control:e.jsx(W,{...m,checked:m.value})})})})}),e.jsx(C,{title:l("blocklet.config.session.emailRequireUnique"),sectionLeftSx:{width:"600px"},children:e.jsx(u,{sx:{alignSelf:"flex-start"},children:e.jsx(I,{name:"email.requireUnique",control:t,render:({field:m})=>e.jsx(_,{sx:{mt:1},control:e.jsx(W,{...m,checked:m.value})})})})}),e.jsx(C,{title:l("blocklet.config.session.emailTrustOauthProviders"),sectionLeftSx:{width:"600px"},children:e.jsx(u,{sx:{alignSelf:"flex-start"},children:e.jsx(I,{name:"email.trustOauthProviders",control:t,render:({field:m})=>e.jsx(_,{sx:{mt:1},control:e.jsx(W,{...m,checked:m.value})})})})}),e.jsx(C,{title:l("blocklet.config.session.enableDomainBlackList"),sectionLeftSx:{width:"600px"},children:e.jsx(u,{sx:{alignSelf:"flex-start"},children:e.jsx(I,{name:"email.enableDomainBlackList",control:t,render:({field:m})=>e.jsx(_,{sx:{mt:1},control:e.jsx(W,{...m,checked:m.value})})})})}),T&&e.jsxs(u,{children:[g.map((m,R)=>e.jsxs(V,{direction:"row",alignItems:"center",my:1,maxWidth:"720px",children:[e.jsx(I,{name:`email.domainBlackList.${R}`,control:t,render:A=>e.jsx(O,{...A.field,size:"small",fullWidth:!0})}),e.jsx(ie,{onClick:()=>v(R),children:e.jsx(Ce,{})})]},m.id)),e.jsx($,{startIcon:e.jsx(qe,{}),onClick:()=>y(""),children:l("blocklet.config.session.addDomain")})]}),e.jsx(C,{title:l("blocklet.config.session.enableDomainWhiteList"),sectionLeftSx:{width:"600px"},children:e.jsx(u,{sx:{alignSelf:"flex-start"},children:e.jsx(I,{name:"email.enableDomainWhiteList",control:t,render:({field:m})=>e.jsx(_,{sx:{mt:1},control:e.jsx(W,{...m,checked:m.value})})})})}),x&&e.jsxs(u,{children:[S.map((m,R)=>e.jsxs(V,{direction:"row",alignItems:"center",my:1,maxWidth:"720px",children:[e.jsx(I,{name:`email.domainWhiteList.${R}`,control:t,render:A=>e.jsx(O,{...A.field,size:"small",fullWidth:!0})}),e.jsx(ie,{onClick:()=>r(R),children:e.jsx(Ce,{})})]},m.id)),e.jsx($,{startIcon:e.jsx(qe,{}),onClick:()=>i(""),children:l("blocklet.config.session.addDomain")})]})]}),e.jsxs(u,{sx:{display:"none"},children:[e.jsx(C,{title:l("blocklet.config.session.phoneEnabled"),sectionLeftSx:{width:"600px"},children:e.jsx(u,{sx:{alignSelf:"flex-start"},children:e.jsx(I,{name:"phone.enabled",control:t,disabled:!0,render:({field:m})=>e.jsx(_,{sx:{mt:1},control:e.jsx(W,{...m,checked:m.value})})})})}),k&&e.jsxs(V,{direction:"column",ml:2,mt:1,children:[e.jsx(C,{title:l("blocklet.config.session.phoneRequireVerified"),sectionLeftSx:{width:"600px"},children:e.jsx(u,{sx:{alignSelf:"flex-start"},children:e.jsx(I,{name:"phone.requireVerified",control:t,render:({field:m})=>e.jsx(_,{control:e.jsx(W,{...m,checked:m.value})})})})}),e.jsx(C,{title:l("blocklet.config.session.phoneRequireUnique"),sectionLeftSx:{width:"600px"},children:e.jsx(u,{sx:{alignSelf:"flex-start"},children:e.jsx(I,{name:"phone.requireUnique",control:t,render:({field:m})=>e.jsx(_,{control:e.jsx(W,{...m,checked:m.value})})})})})]})]})]})]}),e.jsxs(u,{children:[e.jsx(ne,{variant:"h6",fontWeight:600,children:l("blocklet.config.session.period")}),e.jsx(u,{component:le,my:3}),e.jsx(V,{direction:"column",spacing:2,children:e.jsx(I,{name:"ttl",control:t,rules:{min:1,max:30},render:({field:m})=>e.jsx(E,{fullWidth:!0,sx:{mb:2},children:e.jsx(C,{title:l("blocklet.config.session.ttl",{day:m.value}),sectionLeftSx:{width:"600px"},children:e.jsx(u,{sx:{width:"100%",maxWidth:500,px:1.5},children:e.jsx(nt,{...m,defaultValue:7,step:1,marks:[{value:1,label:l("blocklet.config.session.day",{day:1})},{value:7,label:l("blocklet.config.session.days",{day:7})},{value:14,label:l("blocklet.config.session.days",{day:14})},{value:21,label:l("blocklet.config.session.days",{day:21})},{value:30,label:l("blocklet.config.session.days",{day:30})}],min:1,max:30,valueLabelDisplay:"auto"})})})})})})]}),e.jsx(u,{children:e.jsx($,{type:"submit",variant:"contained",disabled:!f.isDirty,children:l("oauth.save")})})]})})}const Tt=Oe.form`
|
|
2
2
|
max-width: 1536px;
|
|
3
3
|
|
|
4
4
|
.advanced-config {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/lottie-react.esm-D2t-u0YU.js","assets/vendor-react-DEoibe3W.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{j as e,aa as n,as as g,T as z,O as U,bu as q,bs as H,bv as W,cG as N,y as O,ah as I,ai as B,ck as J,dy as X,dz as K,I as Y,dA as Q,e as Z,b$ as ee}from"./vendor-mui-core-Bq8gXTan.js";import{r as b}from"./vendor-react-DEoibe3W.js";import{H as te,a as E,f as re,i as ie,d as oe}from"./vendor-hooks-DqdmWCmo.js";import{T as ae,bH as se,_}from"./vendor-ux-did-connect-
|
|
2
|
+
import{j as e,aa as n,as as g,T as z,O as U,bu as q,bs as H,bv as W,cG as N,y as O,ah as I,ai as B,ck as J,dy as X,dz as K,I as Y,dA as Q,e as Z,b$ as ee}from"./vendor-mui-core-Bq8gXTan.js";import{r as b}from"./vendor-react-DEoibe3W.js";import{H as te,a as E,f as re,i as ie,d as oe}from"./vendor-hooks-DqdmWCmo.js";import{T as ae,bH as se,_}from"./vendor-ux-did-connect-mISLpoxA.js";import{aP as ne}from"./vendor-utils-BfZ4tlod.js";import{getAIKitComponent as le}from"./index-B2lZxLm9.js";import"./lottie-web-jYmAQWuC.js";import"./vendor-arcblock-BUFJsma5.js";import"./index-BxJZWVOT.js";import"./index-BRdhpmU2.js";import"./index-DVQCgvFb.js";const F=b.createContext({}),D=()=>b.useContext(F);function de({children:t,restrictions:c,i18n:s,theme:o}){const[l,f]=te({loading:!1}),x=a=>f(j=>({...j,loading:a})),m=b.useMemo(()=>({...l,onLoading:x,restrictions:c,i18n:s}),[l]);return e.jsx(ae,{theme:o,children:e.jsx(F.Provider,{value:m,children:t})})}const ce=["1024x1024","1024x1792","1792x1024"],xe=["256x256","512x512","1024x1024"],ue=[{label:"DALL·E 3",value:"dall-e-3"},{label:"DALL·E 2",value:"dall-e-2"}];function pe({onSubmit:t}){const{loading:c,i18n:s}=D(),o=E({model:"dall-e-3",prompt:"",size:"1024x1024",number:1}),l=()=>{const a=JSON.parse(JSON.stringify(o));Object.values(o).every(y=>!!y)&&t(a)},{run:f}=re(l,{wait:500}),x={width:"100%",pl:1,pr:1},m=o.model==="dall-e-2"?xe:ce;return e.jsxs(me,{onSubmit:a=>a.preventDefault(),children:[e.jsx(n,{sx:{flex:1,overflowY:"auto",overflowX:"hidden",m:2,mb:0},children:e.jsxs(g,{container:!0,gap:2.5,children:[e.jsxs(g,{item:!0,xs:12,children:[e.jsx(z,{gutterBottom:!0,className:"title label",color:"text.primary",children:s("aiImagePrompt")}),e.jsx(U,{sx:{width:1,mt:1},size:"small",type:"text",required:!0,placeholder:s("aiImagePromptTip"),multiline:!0,minRows:5,maxRows:6,value:o.prompt??"",onChange:a=>{a.stopPropagation(),o.prompt=a.target.value},inputProps:{maxLength:1e3}})]}),e.jsxs(g,{item:!0,xs:12,children:[e.jsx(z,{gutterBottom:!0,className:"title label",color:"text.primary",children:`${s("aiImageModel")}`}),e.jsx(q,{row:!0,sx:{".MuiFormControlLabel-label":{fontSize:"12px",color:"text.primary"}},value:o.model,onChange:a=>{o.number=1,o.size="1024x1024",o.model=a.target.value},children:ue.map(a=>e.jsx(H,{value:a.value,control:e.jsx(W,{size:"small"}),label:a.label},a.label))})]}),e.jsxs(g,{item:!0,xs:12,children:[e.jsx(z,{gutterBottom:!0,className:"title label",color:"text.primary",children:`${s("aiImageSize")}: ${o.size}`}),e.jsx(g,{container:!0,sx:{gap:2.5,pt:1},children:e.jsx(n,{flex:1,children:e.jsx(n,{...x,children:e.jsx(N,{size:"small",min:0,max:m.length-1,step:1,value:m.findIndex(a=>a==o.size),onChange:(a,j)=>{o.size=m[j]}})})})})]}),o.model==="dall-e-2"&&e.jsxs(g,{item:!0,xs:12,children:[e.jsx(z,{gutterBottom:!0,className:"title label",color:"text.primary",children:`${s("aiImageNumber")}: ${o.number}`}),e.jsx(n,{...x,children:e.jsx(N,{size:"small",defaultValue:1,valueLabelDisplay:"auto",step:1,min:1,max:10,value:o.number,onChange:(a,j)=>{a.stopPropagation(),o.number=Number(j)}})})]})]})}),e.jsx(O,{sx:{m:2,transition:"all 0.3s"},className:"submit-ai",variant:"contained",onClick:f,disabled:c,children:s(c?"aiImageGenerating":"aiImageGenerate")},c?"loading-submit":"submit")]})}const me=I(n)`
|
|
3
3
|
display: flex;
|
|
4
4
|
flex-direction: column;
|
|
5
5
|
height: 100%;
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import{r as C}from"./vendor-react-DEoibe3W.js";import{a as I,$,k as W,B as F,bb as Te,ar as me,b$ as H,a3 as ve,aI as q,br as ue,bs as xe,bt as fe,bI as Ke,cg as we,bd as Ae,ac as Se,a5 as De}from"./vendor-ux-did-connect-mISLpoxA.js";import{d as Ie}from"./Edit-DI_6xJCL.js";import{f as Re}from"./index-8eXqqyHQ.js";import{r as ye}from"./passport-item-BZ2PDs40.js";import{D as R,n as O,aN as $e,G as Be,f as Pe}from"./index-BRdhpmU2.js";import{u as N}from"./dashboard-Cpd1IklF.js";import{j as e,H as f,bo as X,br as Q,bn as J,q as Y,aa as g,al as Z,O as V,ab as _e,bs as Ne,bR as Ee,ah as E,T as P,ad as de,ak as Le}from"./vendor-mui-core-Bq8gXTan.js";import{v as We,K as Ue}from"./vendor-arcblock-BUFJsma5.js";import{T as he}from"./index-oDHaQu27.js";import{C as ge}from"./confirm-DrIfevZQ.js";import{a1 as qe,A as _}from"./vendor-utils-BfZ4tlod.js";import{C as G}from"./click-to-copy-Q6B8UnF1.js";import{D as ze}from"./delete-confirm-DYG8CWSB.js";import{P as Me}from"./permission-pKosyod0.js";import{B as Fe}from"./bundle-avatar-NjLcf8la.js";import{W as He}from"./did-address-uKFe7d9V.js";import{A as Oe}from"./actions-BAixAheW.js";import{u as Ve}from"./use-mobile-DwzRjjku.js";import{T as pe}from"./table-tips-ClAYiT8W.js";import{y as Ge}from"./vendor-hooks-DqdmWCmo.js";import"./lottie-web-jYmAQWuC.js";import"./util-YJ_KBZfa.js";import"./base32-kNwk0OEz.js";import"./useLocalStorage-D_xU3zzI.js";import"./PlayArrow-DLymwoC2.js";import"./get-safe-url-CJEvMc5P.js";import"./session-DocEIP6S.js";import"./use-blocklet-logo-Due3V0N2.js";import"./InfoOutlined-CRqiKRaY.js";import"./dot-4jhL56kz.js";import"./useAsync-C62uE2pS.js";import"./useSetState-CWq0AVWn.js";import"./use-mobile-CtTQsfXN.js";import"./vendor-mui-x-1nqAyytV.js";import"./AdapterDayjs-DPGZ06jw.js";import"./MoreHoriz-D2G1BR_j.js";function ee({value:t}){const{t:s,locale:m}=I(),c=new Date;return new Date(t)<c?e.jsxs("span",{style:{color:"red"},children:[e.jsx($,{value:t,locale:m}),`${s("setting.accessKey.expired",{time:""})}`]}):e.jsx($,{value:t,locale:m,type:"all"})}ee.propTypes={value:f.string.isRequired};function te({value:t,onChange:s,...m}){const{t:c}=I(),r=C.useMemo(()=>[{value:"signature",title:c("setting.accessKey.signature"),description:c("setting.accessKey.signatureDesc")},{value:"simple",title:c("setting.accessKey.simple"),description:c("setting.accessKey.simpleDesc")}],[c]);return e.jsxs(X,{style:{width:"100%"},variant:"outlined",...m,children:[e.jsx(Q,{children:c("setting.accessKey.authType")}),e.jsx(J,{value:t,onChange:s,fullWidth:!0,label:c("setting.accessKey.authType"),children:r.map(i=>e.jsx(Y,{value:i.value,children:e.jsxs(g,{children:[e.jsx("span",{children:i.title}),e.jsx(g,{maxWidth:510,fontSize:12,color:"#999",whiteSpace:"normal",children:i.description})]})},i.value))})]})}te.propTypes={value:f.string.isRequired,onChange:f.func.isRequired};const U=()=>{const t=W.RBAC_CONFIG.roles.filter(r=>r.passport),{inService:s}=R(),{roles:m}=N(),c=[...t,...s?m:[]];return qe(c,"name").filter(r=>r.name!==W.ROLES.OWNER)};function se(t){const{remark:s,onCreate:m}=t,{api:c}=R(),{teamDid:r}=N(),{t:i}=I(),[b,j]=C.useState(!1),[y,k]=C.useState(null),d=U(),w=()=>{j(!1),k(null)},v=async n=>{const{remark:x,passport:h,authType:o}=n;j(!0);const l=await c.createAccessKey({input:{teamDid:r,remark:x.trim(),passport:h,expireAt:n.expireAt?new Date(n.expireAt).getTime():null,authType:o}}),{data:K}=l;m(K),k(null),j(!1)},u={title:`${i("common.create")} ${i("accessKey")}`,description:(n,x,h)=>e.jsxs(Z,{gap:3,children:[e.jsx(V,{label:i("setting.accessKey.tip"),autoComplete:"off",variant:"outlined",name:"remark",inputProps:{"data-cy":"remark-input"},fullWidth:!0,autoFocus:!0,margin:"dense",value:n.remark,onChange:o=>{x({...n,remark:o.target.value,__disableConfirm:!n.passport||!o.target.value.trim()}),o.target.value.trim()?h(""):h(i("setting.accessKey.remarkInvalid"))}}),e.jsxs(X,{style:{width:"100%"},variant:"outlined",children:[e.jsx(Q,{children:i("setting.accessKey.passport")}),e.jsx(J,{"data-cy":"create-access-key-select-passport",value:n.passport,onChange:o=>{const l=o.target.value;h(null),x({...n,passport:l,__disableConfirm:!n.remark||!l})},fullWidth:!0,label:i("setting.accessKey.passport"),disabled:b,children:d.map(o=>e.jsx(Y,{value:o.name,"data-cy":`create-access-key-passport-option-${o.name}`,children:e.jsxs(g,{children:[e.jsx("span",{children:o.title||o.name}),e.jsx(g,{maxWidth:440,fontSize:12,color:"#999",whiteSpace:"normal",textAlign:"justify",children:o.description})]})},o.name))})]}),e.jsx(te,{value:n.authType,onChange:o=>{x({...n,authType:o.target.value})}}),e.jsx(he,{placeholder:i("setting.accessKey.expireTime"),value:n.expireAt,onChange:o=>{x({...n,expireAt:o,__disableConfirm:!n.passport||!n.remark||!o})}})]}),confirm:i("common.confirm"),cancel:i("common.cancel"),color:"primary",params:{remark:s,authType:"signature",__disableConfirm:!s.trim()},onConfirm:v,onCancel:w};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:()=>k(u),className:"rule-action",children:[b?e.jsx(_e,{size:16}):e.jsx(We,{style:{fontSize:16}}),i("common.create")]}),y&&e.jsx(ge,{title:y.title,description:y.description,confirm:y.confirm,color:y.color,cancel:y.cancel,params:y.params,onConfirm:y.onConfirm,onCancel:y.onCancel})]})}se.propTypes={remark:f.string,onCreate:f.func};se.defaultProps={onCreate:()=>{},remark:""};function ne(t){var h,o;const{onConfirm:s,accessKeyId:m,accessKeySecret:c,hideSecret:r}=t,{t:i}=C.useContext(Te),[b,j]=C.useState(!1),[y,k]=C.useState(()=>r),d=R(),w=()=>{k(!y)},v=l=>{j(l.target.checked)},u=_(window.location.origin,(o=(h=d==null?void 0:d.info)==null?void 0:h.routing)==null?void 0:o.adminPath),n=C.useMemo(()=>{var l,K,p,D;return r?`const Client = require('@abtnode/client');
|
|
2
|
+
const ensureServerEndpoint = require('@abtnode/util/lib/ensure-server-endpoint');
|
|
3
|
+
const { joinURL } = require('ufo');
|
|
4
|
+
|
|
5
|
+
const { endpoint } = await ensureServerEndpoint("${d.inService?(K=window.blocklet)==null?void 0:K.appUrl:u}");
|
|
6
|
+
const fullEndpoint = joinURL(endpoint, '/api/gql');
|
|
7
|
+
|
|
8
|
+
const client = new Client(fullEndpoint);
|
|
9
|
+
client.setAuthAccessKey({
|
|
10
|
+
accessKeyId: "${m}",
|
|
11
|
+
accessKeySecret: "${c}",
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
const rootDid = '${((p=window.blocklet)==null?void 0:p.appId)||((D=window.blocklet)==null?void 0:D.appPid)||"{rootDid}"}';
|
|
15
|
+
const result = await client.getBlocklet(
|
|
16
|
+
{ input: { did: rootDid, attachRuntimeInfo: false } },
|
|
17
|
+
{ headers: { 'x-access-blocklet': rootDid } }
|
|
18
|
+
);
|
|
19
|
+
`:d.inService?`curl -H "Authorization: Bearer ${c}" "${_((l=window.blocklet)==null?void 0:l.appUrl,W.WELLKNOWN_SERVICE_PATH_PREFIX,"/api/did/session")}"`:`curl -H "Authorization: Bearer ${c}" "${_(u,"/api/did/session")}"`},[r,m,c,d.inService,u]),x=C.useMemo(()=>{var l;return r?`blocklet deploy --endpoint ${d.inService?(l=window.blocklet)==null?void 0:l.appUrl:u} --access-key ${m} --access-secret ${c} {blockletPath}/.blocklet/bundle;`:null},[r,m,c,d.inService,u]);return e.jsxs(me,{title:i("common.createSuccess"),fullWidth:!0,open:!0,disableEscapeKeyDown:!0,onClose:s,showCloseButton:!1,actions:e.jsx("div",{children:e.jsx(F,{disabled:r?!b:!1,onClick:s,color:"primary",autoFocus:!0,variant:"contained","data-cy":"submit-confirm-dialog",children:i("common.confirm")})}),"aria-labelledby":"simple-dialog-title",children:[e.jsx("div",{children:e.jsx(Xe,{children:i(r?"setting.accessKey.saveSecretTip":"setting.accessKey.viewSecret")})}),e.jsx("div",{style:{marginTop:"20px"}}),e.jsxs(M,{children:[e.jsx(z,{children:i("setting.accessKey.accessKeyId")}),e.jsx(G,{children:m})]}),e.jsxs(M,{children:[e.jsx(z,{children:i("setting.accessKey.accessKeySecret")}),y?e.jsx(F,{"data-cy":"show-secret-btn",color:"primary",onClick:w,children:i("setting.accessKey.showSecret")}):e.jsx(G,{children:c})]}),!y&&e.jsxs(M,{children:[e.jsx(z,{children:`Access Key ${i("setting.accessKey.usage")}`}),e.jsx(H,{code:n,language:"shell"}),x&&e.jsx(H,{code:x,language:"shell"})]}),r&&e.jsx("div",{children:e.jsx(Ne,{value:"end",disabled:y,control:e.jsx(Ee,{checked:b,onChange:v}),label:i("setting.accessKey.iKnow"),labelPlacement:"end"})})]})}ne.propTypes={accessKeyId:f.string.isRequired,accessKeySecret:f.string.isRequired,onConfirm:f.func,hideSecret:f.bool};ne.defaultProps={onConfirm:()=>{},hideSecret:!0};const z=E.div`
|
|
20
|
+
display: flex;
|
|
21
|
+
justify-content: space-between;
|
|
22
|
+
align-items: center;
|
|
23
|
+
font-size: 16px;
|
|
24
|
+
margin-bottom: 8px;
|
|
25
|
+
`,M=E.div`
|
|
26
|
+
margin-bottom: 24px;
|
|
27
|
+
`,Xe=E.div`
|
|
28
|
+
font-size: 16px;
|
|
29
|
+
font-weight: bold;
|
|
30
|
+
`;function oe(t){const{t:s,locale:m}=I(),{api:c}=R(),{teamDid:r}=N(),{accessKeyId:i,time:b,remark:j,onDelete:y=()=>{},onClose:k=()=>{}}=t,d=()=>{k()},w=async()=>{try{await c.deleteAccessKey({input:{teamDid:r,accessKeyId:i}}),y()}catch(n){ve.error(n==null?void 0:n.message)}finally{d()}},v=n=>({key:`<b>${i}</b>`,name:`<b>${j}</b>`,time:O(n,m),timeAge:Ue(new Date(n),$e(m))}),u={keyName:j,title:s("setting.accessKey.title"),description:b?`${s("setting.accessKey.description",v(b))}`:`${s("setting.accessKey.descriptionNoTime",{key:`<b>${i}</b>`,name:`<b>${j}</b>`})}`,confirmPlaceholder:s("setting.accessKey.confirm_desc",{name:j}),confirm:s("common.delConfirm"),cancel:s("common.cancel"),onConfirm:w,onCancel:d};return e.jsx(ze,{keyName:u.keyName,title:u.title,description:u.description,confirmPlaceholder:u.confirmPlaceholder,confirm:u.confirm,cancel:u.cancel,params:u.params,onConfirm:u.onConfirm,onCancel:u.onCancel})}oe.propTypes={accessKeyId:f.string.isRequired,time:f.string.isRequired,remark:f.string.isRequired,onDelete:f.func,onClose:f.func};oe.defaultProps={onDelete:()=>{},onClose:()=>{}};function ie(t){const{accessKeyId:s,remark:m,onUpdate:c,passport:r,expireAt:i,authType:b,onClose:j}=t,{api:y}=R(),{teamDid:k}=N(),{t:d}=I(),[w,v]=C.useState(!1),u=U(),n=()=>{v(!1),j()},x=async o=>{const{accessKeyId:l,remark:K="",passport:p,expireAt:D,authType:L}=o;v(!0),await y.updateAccessKey({input:{teamDid:k,accessKeyId:l,remark:K.trim(),passport:p,expireAt:D?new Date(D).getTime():null,authType:L}}),c(),n()},h={title:`${d("common.update")} ${d("accessKey")}`,description:(o,l,K)=>e.jsxs(Z,{gap:3,children:[e.jsx(V,{label:d("setting.accessKey.accessKeyId"),autoComplete:"off",variant:"outlined",name:"accessKeyId",fullWidth:!0,autoFocus:!0,margin:"dense",value:o.accessKeyId,disabled:!0}),e.jsx(V,{label:d("common.remark"),autoComplete:"off",variant:"outlined",name:"remark",fullWidth:!0,autoFocus:!0,value:o.remark,onChange:p=>{l({...o,remark:p.target.value,__disableConfirm:!p.target.value.trim()}),p.target.value.trim()?K(""):K(d("setting.accessKey.remarkInvalid"))}}),e.jsxs(X,{style:{width:"100%"},variant:"outlined",children:[e.jsx(Q,{children:d("setting.accessKey.passport")}),e.jsx(J,{"data-cy":"update-access-key-select-passport",value:o.passport,onChange:p=>{const D=p.target.value;K(null),l({...o,passport:D,__disableConfirm:!o.remark||!D})},fullWidth:!0,label:d("setting.accessKey.passport"),disabled:w,children:u.map(p=>e.jsx(Y,{value:p.name,"data-cy":`update-access-key-passport-option-${p.name}`,children:e.jsxs(g,{children:[e.jsx("span",{children:p.title||p.name}),e.jsx(g,{maxWidth:440,fontSize:12,color:"#999",whiteSpace:"normal",textAlign:"justify",children:p.description})]})},p.name))})]}),e.jsx(te,{disabled:!0,value:o.authType,onChange:p=>{l({...o,authType:p.target.value})}}),e.jsx(he,{placeholder:d("setting.accessKey.expireTime"),value:o.expireAt,onChange:p=>{l({...o,expireAt:p,__disableConfirm:!o.passport||!o.remark||!p})}})]}),confirm:d("common.confirm"),cancel:d("common.cancel"),color:"primary",params:{accessKeyId:s,remark:m,passport:r,expireAt:i,authType:b},onConfirm:x,onCancel:n};return e.jsx(ge,{title:h.title,description:h.description,confirm:h.confirm,color:h.color,cancel:h.cancel,params:h.params,onConfirm:h.onConfirm,onCancel:h.onCancel})}ie.propTypes={accessKeyId:f.string.isRequired,remark:f.string,passport:f.string,expireAt:f.string,authType:f.string,onUpdate:f.func,onClose:f.func};ie.defaultProps={onUpdate:()=>{},remark:"",passport:"",expireAt:"",authType:"signature",onClose:()=>{}};function ae({accessKey:t,onCancel:s}){const{t:m}=I();return e.jsx(me,{title:m("accessKey"),onClose:s,open:!0,PaperProps:{style:{maxWidth:800}},fullWidth:!0,children:e.jsx(Qe,{children:e.jsx(be,{accessKey:t})})})}ae.propTypes={accessKey:f.object.isRequired,onCancel:f.func.isRequired};ae.defaultProps={};const Qe=E(g)`
|
|
31
|
+
margin-top: -16px;
|
|
32
|
+
|
|
33
|
+
.tabs {
|
|
34
|
+
margin-left: 0;
|
|
35
|
+
margin-right: 0;
|
|
36
|
+
}
|
|
37
|
+
`;function be({accessKey:t}){var w,v,u;const{t:s,locale:m}=I(),{blocklet:c}=Be(),r=R(),i=U(),b=((c==null?void 0:c.children)||[]).find(n=>{var x;return((x=n==null?void 0:n.meta)==null?void 0:x.did)===t.componentDid}),j=i.find(n=>n.name===t.passport),y=j?j.title:t.passport,k=C.useMemo(()=>{var n,x,h;return r.inService?`curl -H "Authorization: Bearer blocklet-${q.toBase58(t.accessKeyPublic)}" "${_((n=window.blocklet)==null?void 0:n.appUrl,W.WELLKNOWN_SERVICE_PATH_PREFIX,"/api/did/session")}"`:`curl -H "Authorization: Bearer blocklet-${q.toBase58(t.accessKeyPublic)}" "${_(window.location.origin,(h=(x=r==null?void 0:r.info)==null?void 0:x.routing)==null?void 0:h.adminPath,"/api/did/session")}"`},[t.accessKeyPublic,r.inService,(v=(w=r==null?void 0:r.info)==null?void 0:w.routing)==null?void 0:v.adminPath]),d=[{title:s("common.baseInfo"),items:[{label:s("setting.accessKey.accessKeyId"),content:e.jsx(He,{did:t.accessKeyId,showQrcode:!0})},...t.authType==="simple"?[{label:s("setting.accessKey.accessKeySecret"),content:e.jsx(G,{children:`blocklet-${q.toBase58(t.accessKeyPublic)}`})}]:[],{label:s("common.role"),content:e.jsx(g,{children:ye(y,t.passport)})},{label:s("common.createdVia"),content:t.createdVia},{label:s("common.createdBy"),content:t.createdBy?e.jsx(ue,{showDid:!0,did:t.createdBy,cardType:xe.Detailed,infoType:fe.Minimal,sx:{border:0,padding:0}}):"-"}]},{title:s("common.timeInfo"),items:[{label:s("common.createdAt"),content:t.createdAt?e.jsx($,{value:t.createdAt,type:"all",locale:m}):"-"},{label:s("common.lastUsedAt"),content:t.lastUsedAt?e.jsx($,{value:t.lastUsedAt,type:"all",locale:m}):"-"},{label:s("common.expiredAt"),content:t.expireAt?e.jsx(ee,{value:t.expireAt}):s("common.neverExpired")}]},{title:s("common.otherInfo"),items:[{label:s("setting.accessKey.authType"),content:t.authType},{label:s("common.remark"),content:t.remark},...t.authType!=="signature"?[{label:s("setting.accessKey.resourceType"),content:t.resourceType||"-"},{label:s("setting.accessKey.resourceId"),content:t.resourceId||"-"}]:[],...b?[{label:s("setting.accessKey.component"),content:e.jsxs(g,{width:{xs:250,sm:400},display:"flex",alignItems:"center",children:[e.jsx(Fe,{blocklet:b,ancestors:[c]}),e.jsx(g,{ml:"16px",sx:{minWidth:0},children:e.jsxs(g,{className:"component-header",children:[e.jsx(g,{className:"component-name",children:Pe.getDisplayName(b,!0)}),e.jsx(g,{className:"component-version",children:(u=b==null?void 0:b.meta)==null?void 0:u.version})]})})]},b)}]:[],t.authType!=="signature"?{label:s("setting.accessKey.usage"),content:e.jsx(H,{code:k,language:"shell"})}:null].filter(Boolean)}];return e.jsx(Je,{gap:3,children:e.jsx(g,{className:"info-area",children:d.map(n=>e.jsxs(g,{mb:3,children:[e.jsx(P,{variant:"h6",sx:{mb:1.5},children:n.title}),e.jsx(g,{className:"info-grid",children:n.items.map(x=>e.jsxs(g,{className:"info-item",children:[e.jsx(g,{className:"info-label",children:e.jsx(P,{variant:"subtitle2",color:"textSecondary",children:x.label})}),e.jsx(g,{sx:{flex:1,minWidth:0},children:x.content})]},x.label))})]},n.title))})})}be.propTypes={accessKey:f.object.isRequired};const Je=E(Z)`
|
|
38
|
+
.info-card {
|
|
39
|
+
margin-bottom: 24px;
|
|
40
|
+
overflow: hidden;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.card-content {
|
|
44
|
+
display: flex;
|
|
45
|
+
gap: 32px;
|
|
46
|
+
padding: 24px;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.passport-image {
|
|
50
|
+
width: 150px;
|
|
51
|
+
flex-shrink: 0;
|
|
52
|
+
transition: transform 0.2s ease-in-out;
|
|
53
|
+
cursor: pointer;
|
|
54
|
+
|
|
55
|
+
&:hover {
|
|
56
|
+
transform: scale(1.05);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.info-area {
|
|
61
|
+
flex: 1;
|
|
62
|
+
display: flex;
|
|
63
|
+
flex-direction: column;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.info-header {
|
|
67
|
+
padding-bottom: 16px;
|
|
68
|
+
border-bottom: 1px solid #eee;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.info-grid {
|
|
72
|
+
display: flex;
|
|
73
|
+
flex-direction: column;
|
|
74
|
+
gap: 12px;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.info-item {
|
|
78
|
+
display: flex;
|
|
79
|
+
gap: 8px;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.info-label {
|
|
83
|
+
display: flex;
|
|
84
|
+
align-items: center;
|
|
85
|
+
gap: 8px;
|
|
86
|
+
width: 140px;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.logs-card {
|
|
90
|
+
.card-header {
|
|
91
|
+
display: flex;
|
|
92
|
+
align-items: center;
|
|
93
|
+
gap: 8px;
|
|
94
|
+
padding: 16px 24px;
|
|
95
|
+
border-bottom: 1px solid #eee;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
.MuiTimeline-root {
|
|
99
|
+
padding: 24px;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
.MuiTimelineContent-root {
|
|
103
|
+
padding: 0px 16px;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
.MuiTimelineDot-root {
|
|
107
|
+
margin: 0;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
`;function _t(){var ce,le;const{t,locale:s}=I(),{api:m,inService:c}=R(),{teamDid:r}=N(),[i,b]=C.useState({}),[j,y]=C.useState(null),[k,d]=C.useState(null),[w,v]=C.useState(null),u=Ve(),n=U(),x=C.useRef(null),h=`access-keys-${r}`,o=Ke(h),[l,K]=C.useState({searchText:o.searchText||"",pageSize:o.rowsPerPage||10,page:1}),p=Ge(async()=>await m.getAccessKeys({input:{teamDid:r,paging:{page:l.page,pageSize:l.pageSize}}}),[l.page,l.pageSize]),{loading:D,error:L}=p,B=C.useMemo(()=>{var a;return((a=p.value)==null?void 0:a.list)||[]},[(ce=p.value)==null?void 0:ce.list]),je=C.useMemo(()=>[{label:t("common.name"),name:"remark",options:{customBodyRender:(a,{rowIndex:A})=>{const S=B[A];return e.jsx(g,{display:"flex",alignItems:"center",gap:2,children:e.jsx(P,{children:S.remark||"N/A"})})}}},{label:"Access Key ID",name:"accessKeyId",options:{customBodyRender:a=>e.jsx(we,{showDidLogo:!1,children:a})}},{label:t("common.role"),name:"passport",options:{customBodyRender:a=>{const A=n.find(T=>T.name===a),S=A?A.title:a;return e.jsx(g,{children:ye(S,a)})}}},{label:t("common.createdVia"),name:"createdVia",options:{customBodyRender:a=>e.jsx(P,{children:a})}},{label:t("setting.accessKey.authType"),name:"authType",options:{customBodyRender:a=>e.jsx(P,{children:t(`setting.accessKey.${a}`)})}},{label:t("common.createdAt"),name:"createdAt",options:{customBodyRender:a=>e.jsx(de,{title:O(a,s),children:a?e.jsx($,{value:a,locale:s}):"-"})}},{label:t("common.lastUsedAt"),name:"lastUsedAt",options:{customBodyRender:a=>e.jsx(de,{title:O(a,s),children:a?e.jsx($,{value:a,locale:s}):"-"})}},{label:t("common.expiredAt"),name:"expireAt",options:{customBodyRender:a=>a?e.jsx(ee,{value:a}):t("common.neverExpired")}},{label:t("common.createdBy"),name:"createdBy",width:100,options:{customBodyRender:a=>a?e.jsx(ue,{showDid:!0,did:a,cardType:xe.Detailed,infoType:fe.Minimal,sx:{border:0,padding:0}}):"-"}},{label:t("common.actions"),name:"actions",width:100,align:"center",verticalKeyAlign:"center",options:{customBodyRender:(a,{rowIndex:A})=>{const S=B[A];return e.jsx(Oe,{"data-cy":"access-key-actions",actions:[{icon:e.jsx(Ie,{}),text:t("common.edit"),onClick:T=>{T.stopPropagation(),v(S)}},{icon:e.jsx(Ae,{}),text:t("common.delete"),onClick:T=>{T.stopPropagation(),d(S)}}]})}}}],[B,s,t,n,d,v]),Ce=({page:a,rowsPerPage:A,searchText:S})=>{l.pageSize!==A?K(T=>({...T,searchText:"",pageSize:A,page:1})):l.page!==a+1?K(T=>({...T,searchText:"",page:a+1})):l.searchText!==S&&K(T=>({...T,searchText:S,page:1}))},re=l.searchText?B.filter(a=>a.accessKeyId.toLowerCase().includes(l.searchText.toLowerCase())||(a.remark||"").toLowerCase().includes(l.searchText.toLowerCase())):B;return L?e.jsx(Le,{severity:"error",children:Re(L)}):e.jsxs(g,{ref:x,sx:{".custom-toobar-btns":{gap:"8px"},".custom-toobar-title .custom-toobar-title-inner>span":{display:"flex",alignItems:"center","white-space":"inherit",height:"100%"}},children:[u?e.jsx(pe,{title:t("setting.accessKey.listTitle"),tooltipTitle:t("setting.accessKey.tooltipTitle"),link:`https://www.arcblock.io/docs/blocklet-developer/${s}/access-key`}):null,e.jsx(Se,{durable:h,durableKeys:["page","rowsPerPage"],data:re,columns:je,options:{sort:!1,download:!1,filter:!1,print:!1,viewColumns:!1,page:l.page-1,rowsPerPage:l.pageSize,count:((le=p.value)==null?void 0:le.count)||0,searchDebounceTime:600,onRowClick(a,{dataIndex:A},S){var T;if((T=x.current)!=null&&T.contains(S.target)){const ke=re[A];y(ke)}}},loading:D,onChange:Ce,title:u?null:e.jsx(pe,{title:t("setting.accessKey.listTitle"),tooltipTitle:t("setting.accessKey.tooltipTitle"),link:`https://www.arcblock.io/docs/blocklet-developer/${s}/access-key`}),customButtons:[e.jsx(Me,{permission:c?"":"mutate_accessKey",children:e.jsx(se,{onCreate:a=>{const{accessKeyId:A,accessKeySecret:S,authType:T}=a;b({show:!0,accessKeyId:A,accessKeySecret:S,authType:T})}})})],emptyNode:e.jsx(De,{children:t("oauth.client.empty")})}),i.show&&e.jsx(ne,{hideSecret:i.authType==="signature",onConfirm:()=>{p.retry(),b({show:!1})},...i}),j&&e.jsx(ae,{onCancel:()=>y(null),accessKey:j}),k&&e.jsx(oe,{accessKeyId:k.accessKeyId,time:k.lastUsedAt,remark:k.remark||"N/A",onDelete:p.retry,onClose:()=>d(null)}),w&&e.jsx(ie,{...w,onUpdate:p.retry,onClose:()=>v(null)})]})}export{_t as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{g as Ut,r as C}from"./vendor-react-DEoibe3W.js";import{ah as ue,al as ht,j as e,aa as T,O as te,bs as ge,bt as We,bo as G,ad as xt,H as x,a9 as Je,T as ae,E as Xe,bz as gt,bQ as Ke,bR as qe,y as Le,b6 as Me,ab as bt,bI as jt,Y as vt,cn as yt,m as Ht,as as dt,br as Vt,bn as Gt,q as ut,bX as Yt,I as Jt}from"./vendor-mui-core-Bq8gXTan.js";import{J as St,z as Xt,A as Qt,e as fe,aB as ye,C as Zt}from"./vendor-utils-BfZ4tlod.js";import{y as es,a as re,ab as Ct,a3 as q,X as ke,c1 as ts,B as me,k as W,bb as ss,ax as wt,bg as ns,r as Qe,c2 as is,a2 as Tt,ac as Rt,bB as Oe,ar as Nt,$ as as,bI as rs}from"./vendor-ux-did-connect-BbCim3WZ.js";import{D as Ze,G as Et,aC as It,aD as Q,y as se,n as os,K as pt}from"./index-BMCGWiyM.js";import{a as Te,u as V,b as ce}from"./vendor-hooks-DqdmWCmo.js";import{a as et,b as ls}from"./dashboard-CpxtvWAW.js";import{f as $e,i as cs,d as ds}from"./use-blocklet-logo-DwwmdicD.js";import{A as us,a as ps,d as fs,b as ms}from"./collapse-D4xd-ptF.js";import{S as ee}from"./section-BDMQAX_r.js";import{S as Re}from"./shorten-label-BQvbtscf.js";import{I as Ot}from"./index-DDI23z2P.js";import{R as At,A as hs,S as xs,a as gs,b as bs,B as js}from"./list-C4l_W2F_.js";import{W as vs}from"./did-address-DFiM35OM.js";import{p as Dt}from"./util-paKPrRHx.js";import{D as ys,g as Ss}from"./traffic-DAzuj4ZR.js";import{B as Lt}from"./bundle-avatar-CH2OoDP-.js";import{u as Cs}from"./use-mobile-DwzRjjku.js";import"./lottie-web-jYmAQWuC.js";import"./vendor-arcblock-f1tICt1E.js";import"./useLocalStorage-iQ2AmaOA.js";import"./index-8eXqqyHQ.js";import"./confirm-Bbp7EOHO.js";import"./PlayArrow-DZsdEeq_.js";import"./get-safe-url-CuT70yLx.js";import"./session-BDyIB4uh.js";import"./InfoOutlined-B5f3YRb4.js";import"./dot-4jhL56kz.js";import"./useAsync-C62uE2pS.js";import"./useSetState-CWq0AVWn.js";import"./use-mobile-CtTQsfXN.js";import"./index-DEZojGsm.js";import"./CheckCircle-DYKWpCjc.js";import"./base32-Cbt7-U8e.js";import"./iframe-DYXqfKJj.js";import"./LaunchOutlined-Bcn_86ca.js";import"./ChevronLeft-C5ZElVOZ.js";import"./ChevronRight-BDtG7F9C.js";import"./index-B2NkqENf.js";import"./base-chart-CoApVzod.js";import"./index-w4f-mlFt.js";import"./vendor-mui-x-1nqAyytV.js";import"./AdapterDayjs-T0keO70D.js";var Ue={exports:{}},He={exports:{}},Ve={exports:{}};(function(n,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=s;function s(r){return r==null}n.exports=t.default,n.exports.default=t.default})(Ve,Ve.exports);var ws=Ve.exports;(function(n,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=p;var s=o(es),r=o(ws);function o(h){return h&&h.__esModule?h:{default:h}}var l=/^(?:[-+]?(?:0|[1-9][0-9]*))$/,y=/^[-+]?[0-9]+$/;function p(h,i){(0,s.default)(h),i=i||{};var O=i.allow_leading_zeroes===!1?l:y,A=!i.hasOwnProperty("min")||(0,r.default)(i.min)||h>=i.min,R=!i.hasOwnProperty("max")||(0,r.default)(i.max)||h<=i.max,S=!i.hasOwnProperty("lt")||(0,r.default)(i.lt)||h<i.lt,D=!i.hasOwnProperty("gt")||(0,r.default)(i.gt)||h>i.gt;return O.test(h)&&A&&R&&S&&D}n.exports=t.default,n.exports.default=t.default})(He,He.exports);var Ts=He.exports;(function(n,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=o;var s=r(Ts);function r(l){return l&&l.__esModule?l:{default:l}}function o(l){return(0,s.default)(l,{allow_leading_zeroes:!1,min:0,max:65535})}n.exports=t.default,n.exports.default=t.default})(Ue,Ue.exports);var Rs=Ue.exports;const Ns=Ut(Rs),Fe={enabled:!1,secure:!1,from:"",host:"",port:"",user:"",password:"",companyName:"",companyLink:"",companyAddress:"",supportEmail:""};function Es(){var N,E,P;const{api:n}=Ze(),{blocklet:t}=Et(),{t:s}=re(),{confirmApi:r,confirmHolder:o}=Ct(),l=(N=t==null?void 0:t.meta)==null?void 0:N.did,y=Object.assign({...Fe},((P=(E=t==null?void 0:t.settings)==null?void 0:E.notification)==null?void 0:P.email)||{}),{handleSubmit:p,control:h,formState:i,watch:O,reset:A}=It({defaultValues:St(y,Object.keys(Fe))}),R=Te({testReceiver:"",testReceiverError:""}),S=O("enabled"),D=V(async(a,m,$=!0)=>{var U,oe;try{const{blocklet:le}=await n.configNotification({input:{did:l,notification:JSON.stringify({email:a})}}),pe=Object.assign({...Fe},((oe=(U=le==null?void 0:le.settings)==null?void 0:U.notification)==null?void 0:oe.email)||{});A(pe),$&&q.success(s("oauth.saveSuccess"))}catch(le){if($)q.error(le.message||s("oauth.saveFailed"));else throw le}}),Y=V(async(a,m,$)=>{try{i.isDirty&&await D(a,m,!1),await n.sendEmail({input:{did:l,receiver:$,email:JSON.stringify({body:"Your SMTP configuration is correct!",title:"Test email",type:"notification"})}}),q.success(s("notification.email.testSuccess"))}catch(U){q.error(U.message||s("notification.email.testfailed"))}}),z=V((a,m)=>{R.testReceiver="",R.testReceiverError="",r.open({title:s("notification.email.testSendEmail"),content:()=>e.jsx(T,{sx:{width:"300px"},children:e.jsx(te,{sx:{mt:1},fullWidth:!0,name:"testReceiver",label:s("notification.email.inputTestReceiver"),value:R.testReceiver,onChange:$=>{R.testReceiver=$.target.value},error:!!R.testReceiverError,helperText:R.testReceiverError||" "})}),confirmButtonText:s("common.confirm"),cancelButtonText:s("common.cancel"),async onConfirm($){var oe;const U=(oe=R.testReceiver)==null?void 0:oe.trim();if(!U){R.testReceiverError=s("notification.email.receiverRequired");return}if(!ke(U)){R.testReceiverError=s("notification.email.receiverInvalid");return}R.testReceiverError="",await Y(a,m,U),$()}})}),B=V(a=>{const m=a==null?void 0:a.trim();return m?ke(m)?!0:s("notification.email.fromInvalid"):s("notification.email.fromRequired")}),_=V(a=>{const m=a==null?void 0:a.trim();return m?$e(m,{require_host:!1,protocols:[]})?!0:s("notification.email.hostInvalid"):s("notification.email.hostRequired")}),M=V(a=>a?Ns(a)?!0:s("notification.email.portInvalid"):s("notification.email.portRequired")),J=V(a=>a!=null&&a.trim()?!0:s("notification.email.userRequired")),ie=V(a=>a!=null&&a.trim()?!0:s("notification.email.passwordRequired")),c=V(a=>a!=null&&a.trim()&&!$e(a,{protocols:["http","https"],require_protocol:!0})?s("notification.email.linkInvalid"):!0),g=V(a=>a!=null&&a.trim()&&!ke(a)?s("notification.email.emailInvalid"):!0),j=V(()=>!0);return e.jsxs(T,{children:[e.jsxs(Is,{component:"form",onSubmit:p(D),disabled:!0,sx:{".section-left":{width:"160px"}},children:[e.jsx(ee,{title:s("notification.email.enable"),my:2.5,children:e.jsx(Q,{name:"enabled",control:h,render:({field:a})=>e.jsx(ge,{control:e.jsx(We,{checked:a.value,...a})})})}),e.jsx(ee,{title:s("notification.email.from"),children:e.jsx(Q,{name:"from",control:h,rules:{validate:S?B:j},render:({field:a})=>{var m;return e.jsx(G,{fullWidth:!0,children:e.jsx(te,{...a,size:"small",required:!0,label:s("notification.email.from"),error:!!i.errors[a.name],helperText:((m=i.errors[a.name])==null?void 0:m.message)||" ",disabled:!S})})}})}),e.jsx(ee,{title:s("notification.email.host"),children:e.jsx(Q,{name:"host",control:h,rules:{validate:S?_:j},render:({field:a})=>{var m;return e.jsx(G,{fullWidth:!0,children:e.jsx(te,{...a,size:"small",required:!0,error:!!i.errors[a.name],label:s("notification.email.host"),helperText:((m=i.errors[a.name])==null?void 0:m.message)||" ",disabled:!S})})}})}),e.jsx(ee,{title:s("notification.email.port"),children:e.jsx(Q,{name:"port",control:h,rules:{validate:S?M:j},render:({field:a})=>{var m;return e.jsx(G,{fullWidth:!0,children:e.jsx(te,{...a,size:"small",required:!0,type:"number",error:!!i.errors[a.name],label:s("notification.email.port"),helperText:((m=i.errors[a.name])==null?void 0:m.message)||" ",disabled:!S})})}})}),e.jsx(ee,{title:s("notification.email.user"),children:e.jsx(Q,{name:"user",control:h,rules:{validate:S?J:j},render:({field:a})=>{var m;return e.jsx(G,{fullWidth:!0,children:e.jsx(te,{...a,size:"small",required:!0,error:!!i.errors[a.name],label:s("notification.email.user"),helperText:((m=i.errors[a.name])==null?void 0:m.message)||" ",disabled:!S})})}})}),e.jsx(ee,{title:s("notification.email.password"),children:e.jsx(Q,{name:"password",control:h,rules:{validate:S?ie:j},render:({field:a})=>{var m;return e.jsx(G,{fullWidth:!0,children:e.jsx(te,{...a,size:"small",required:!0,type:"password",error:!!i.errors[a.name],label:s("notification.email.password"),helperText:((m=i.errors[a.name])==null?void 0:m.message)||" ",disabled:!S})})}})}),e.jsx(ee,{title:s("notification.email.secure"),children:e.jsx(Q,{name:"secure",control:h,rules:{validate:j},render:({field:a})=>e.jsx(G,{fullWidth:!0,children:e.jsx(ge,{control:e.jsx(We,{checked:a.value,...a,disabled:!S})})})})}),e.jsxs(us,{children:[e.jsxs(ps,{expandIcon:e.jsx(fs,{fontSize:"small"}),"aria-controls":"panel1-content",id:"panel1-header",children:[s("notification.email.signature"),e.jsx(xt,{title:s("notification.email.signatureTooltip"),children:e.jsx(ts,{fontSize:"small",sx:{ml:1,cursor:"help"}})})]}),e.jsxs(ms,{children:[e.jsx(ee,{title:s("notification.email.companyName"),children:e.jsx(Q,{name:"companyName",control:h,rules:{validate:j},render:({field:a})=>{var m;return e.jsx(G,{fullWidth:!0,children:e.jsx(te,{...a,size:"small",error:!!i.errors[a.name],label:s("notification.email.companyName"),helperText:((m=i.errors[a.name])==null?void 0:m.message)||" ",disabled:!S})})}})}),e.jsx(ee,{title:s("notification.email.companyLink"),children:e.jsx(Q,{name:"companyLink",control:h,rules:{validate:S?c:j},render:({field:a})=>{var m;return e.jsx(G,{fullWidth:!0,children:e.jsx(te,{...a,size:"small",error:!!i.errors[a.name],label:s("notification.email.companyLink"),helperText:((m=i.errors[a.name])==null?void 0:m.message)||" ",disabled:!S})})}})}),e.jsx(ee,{title:s("notification.email.companyAddress"),children:e.jsx(Q,{name:"companyAddress",control:h,rules:{validate:j},render:({field:a})=>{var m;return e.jsx(G,{fullWidth:!0,children:e.jsx(te,{...a,size:"small",error:!!i.errors[a.name],label:s("notification.email.companyAddress"),helperText:((m=i.errors[a.name])==null?void 0:m.message)||" ",disabled:!S})})}})}),e.jsx(ee,{title:s("notification.email.supportEmail"),children:e.jsx(Q,{name:"supportEmail",control:h,rules:{validate:S?g:j},render:({field:a})=>{var m;return e.jsx(G,{fullWidth:!0,children:e.jsx(te,{...a,size:"small",type:"email",error:!!i.errors[a.name],label:s("notification.email.supportEmail"),helperText:((m=i.errors[a.name])==null?void 0:m.message)||" ",disabled:!S})})}})})]})]}),e.jsxs(T,{sx:{display:"flex",justifyContent:"flex-end",gap:2,mt:3},children:[e.jsx(me,{variant:"outlined",color:"warning",onClick:p(z),disabled:!S,children:s("oauth.runTest")}),e.jsx(me,{type:"submit",variant:"contained",disabled:!i.isDirty,children:s("oauth.save")})]})]}),o]})}const Is=ue(ht)``,Be={enabled:!1,endpoint:"",did:void 0,pushPath:void 0};function Os(){var M,J,ie;const{api:n}=Ze(),{blocklet:t}=Et(),{t:s}=re(),{confirmApi:r,confirmHolder:o}=Ct(),l=(M=t==null?void 0:t.meta)==null?void 0:M.did,y=Object.assign({...Be},((ie=(J=t==null?void 0:t.settings)==null?void 0:J.notification)==null?void 0:ie.pushKit)||{}),{handleSubmit:p,control:h,formState:i,watch:O,reset:A}=It({defaultValues:St(y,Object.keys(Be))}),R=Te({testReceiver:"",testReceiverError:""}),S=O("enabled"),D=V(async(c,g,j=!0)=>{var N,E;try{const{blocklet:P}=await n.configNotification({input:{did:l,notification:JSON.stringify({pushKit:c})}}),a=Object.assign({...Be},((E=(N=P==null?void 0:P.settings)==null?void 0:N.notification)==null?void 0:E.pushKit)||{});A(a),j&&q.success(s("oauth.saveSuccess"))}catch(P){if(j)q.error(P.message||s("oauth.saveFailed"));else throw P}}),Y=V(async(c,g)=>{var j,N,E;try{i.isDirty&&await D(c,g,!1);const P=(j=((t==null?void 0:t.configs)||[]).find($=>$.key==="BLOCKLET_APP_URL"))==null?void 0:j.value,a=Xt(Qt(P,W.WELLKNOWN_SERVICE_PATH_PREFIX,"/blocklet/logo"),{v:(N=t==null?void 0:t.meta)==null?void 0:N.version,t:new Date((t==null?void 0:t.updatedAt)||0).getTime()}),m={type:"passthrough",passthroughType:"messageStatus",data:{message:{title:"Test push-kit notification",body:"This is message from push-kit config test",sender:{did:t==null?void 0:t.appDid,fullName:(E=t==null?void 0:t.meta)==null?void 0:E.title,avatar:a}}}};await n.sendPush({input:{did:l,receiver:R.testReceiver,notification:JSON.stringify(m)}}),q.success(s("notification.pushKit.testSuccess"))}catch(P){q.error(P.message||s("notification.pushKit.testfailed"))}}),z=V((c,g)=>{R.testReceiverError="",r.open({title:s("notification.pushKit.testSend"),content:()=>e.jsx(T,{sx:{width:"450px",maxWidth:"100%"},children:e.jsx(te,{sx:{mt:1},fullWidth:!0,name:"testReceiver",label:s("notification.pushKit.inputTestReceiver"),value:R.testReceiver,onChange:j=>{R.testReceiver=j.target.value},error:!!R.testReceiverError,helperText:R.testReceiverError||" "})}),confirmButtonText:s("common.confirm"),cancelButtonText:s("common.cancel"),async onConfirm(j){var E;if(!((E=R.testReceiver)==null?void 0:E.trim())){R.testReceiverError=s("notification.pushKit.receiverRequired");return}R.testReceiverError="",await Y(c,g),j()}})}),B=V(c=>{const g=c==null?void 0:c.trim();return g?$e(g)?!0:s("notification.pushKit.endpointInvalid"):s("notification.pushKit.endpointRequired")}),_=V(()=>!0);return e.jsxs(T,{children:[e.jsxs(As,{component:"form",onSubmit:p(D),disabled:!0,sx:{".section-left":{width:"160px"}},children:[e.jsx(ee,{title:s("notification.pushKit.enable"),my:2.5,children:e.jsx(Q,{name:"enabled",control:h,render:({field:c})=>e.jsx(ge,{control:e.jsx(We,{checked:c.value,...c})})})}),e.jsx(ee,{title:s("notification.pushKit.endpoint"),children:e.jsx(Q,{name:"endpoint",control:h,rules:{validate:S?B:_},render:({field:c})=>{var g;return e.jsx(G,{fullWidth:!0,children:e.jsx(te,{...c,size:"small",required:!0,label:s("notification.pushKit.endpoint"),error:!!i.errors[c.name],helperText:((g=i.errors[c.name])==null?void 0:g.message)||" ",disabled:!S})})}})}),e.jsxs(ee,{title:s("notification.pushKit.customOptions"),children:[e.jsx(Q,{name:"did",control:h,render:({field:c})=>{var g;return e.jsx(G,{fullWidth:!0,children:e.jsx(te,{...c,size:"small",label:s("notification.pushKit.did"),error:!!i.errors[c.name],helperText:((g=i.errors[c.name])==null?void 0:g.message)||" ",disabled:!S})})}}),e.jsx(Q,{name:"pushPath",control:h,render:({field:c})=>{var g;return e.jsx(G,{fullWidth:!0,children:e.jsx(te,{...c,size:"small",label:s("notification.pushKit.pushPath"),error:!!i.errors[c.name],helperText:((g=i.errors[c.name])==null?void 0:g.message)||" ",disabled:!S})})}})]}),e.jsxs(T,{sx:{display:"flex",justifyContent:"flex-end",gap:2,mt:3},children:[e.jsx(me,{variant:"outlined",color:"warning",onClick:p(z),disabled:!S,children:s("oauth.runTest")}),e.jsx(me,{type:"submit",variant:"contained",disabled:!i.isDirty,children:s("oauth.save")})]})]}),o]})}const As=ue(ht)``,ft=[{label:e.jsx(T,{textAlign:"center",width:"100%",children:"Email"}),value:"email"},{label:e.jsx(T,{textAlign:"center",width:"100%",children:"Push Kit"}),value:"pushKit"}];function Ds(){const[n,t]=C.useState(ft[0].value),{locale:s}=C.useContext(ss),r=ce(()=>({email:e.jsx(Es,{}),pushKit:e.jsx(Os,{})}),[s]),o=C.useMemo(()=>({padding:"10px 0"}),[]);return e.jsxs(T,{children:[e.jsx(wt,{tabs:ft,current:n,onChange:t}),e.jsx(T,{style:o,children:r[n]})]})}const Pt=C.createContext({}),{Provider:Ls,Consumer:si}=Pt;function Ps({children:n,blocklet:t=""}){const{api:s,inService:r,ws:{useSubscription:o}}=Ze(),[l,y]=C.useState([]),[p,h]=C.useState({total:0,pageSize:20,pageCount:0,page:1}),i=ce(()=>{var c;return(c=t.meta)==null?void 0:c.did},[t]),[O,A]=C.useState([]),[R,S]=C.useState({}),D=ce(()=>l.length?new Set(l.map(c=>c.id)):new Set,[l]),Y=async({page:c=1,pageSize:g=20,...j}={})=>{if(!i)return[];try{const N={paging:{page:c,pageSize:g},...j,teamDid:i,dateRange:j.dateRange?[se(j.dateRange[0]).toISOString(),se(j.dateRange[1]).toISOString()]:void 0},{dids:E,...P}=N;let a="";E&&E.includes("system")&&(a="system");const m=E?E.filter(oe=>oe!=="system"):[],$={...P,source:a,componentDids:m},U=await s.getNotificationSendLog({input:$});return S($),y(U.list),h(U.paging),U.list}catch(N){return q.error(N.message),[]}},z=async()=>{const c=await s.getNotificationComponents({input:{teamDid:i}});A(c.componentDids)},B=C.useCallback(c=>{const g=t.children.find(j=>{var N;return((N=j.meta)==null?void 0:N.did)===c});if(g)return g.ancestors=[t],g},[t]),_=async({notificationId:c,receivers:g,channels:j,...N})=>{await s.resendNotification({input:{teamDid:i,notificationId:c,receivers:g,channels:j.map(E=>E==="wallet"?W.NOTIFICATION_SEND_CHANNEL.WALLET:E==="pushKit"?W.NOTIFICATION_SEND_CHANNEL.PUSH:E),...N}})},M=C.useCallback(async c=>(await s.getUser({input:{teamDid:i,user:{did:c}}})).user,[s,i]),J=C.useCallback(async({page:c=1,pageSize:g=20,...j}={})=>{try{const N={paging:{page:c,pageSize:g},...j,userName:j.searchText||"",teamDid:i,dateRange:j.dateRange?[se(j.dateRange[0]).toISOString(),se(j.dateRange[1]).toISOString()]:void 0};return await s.getReceivers({input:N})}catch(N){throw q.error(N.message),N}},[s,i]);C.useEffect(()=>{i&&z()},[i]),o(W.EVENTS.NOTIFICATION_BLOCKLET_UPDATE,c=>{D.has(c.notificationId)&&Y(R)},[D,R]),o(W.EVENTS.NOTIFICATION_BLOCKLET_CREATE,c=>{D.has(c.id)||Y(R)},[D,R]);const ie={fetch:Y,data:l,paging:p,blocklet:t,getComponent:B,resendNotification:_,getUser:M,componentDids:O,getReceivers:J,inService:r,teamDid:i};return e.jsx(Ls,{value:{notificationRecords:ie},children:n})}function tt(){const{notificationRecords:n}=C.useContext(Pt);return n}Ne.propTypes={severity:x.oneOf(Object.values(["info","success","error","warning"])).isRequired};const _s={info:"primary",success:"success",error:"error",warning:"warning"};function Ne({severity:n="info"}){return e.jsx(ns,{type:_s[n],children:n})}var st={},ks=Je;Object.defineProperty(st,"__esModule",{value:!0});var _t=st.default=void 0,Fs=ks(Qe()),Bs=e;_t=st.default=(0,Fs.default)((0,Bs.jsx)("path",{d:"M16.59 7.58 10 14.17l-3.59-3.58L5 12l5 5 8-8zM12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2m0 18c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8"}),"CheckCircleOutline");var nt={},zs=Je;Object.defineProperty(nt,"__esModule",{value:!0});var kt=nt.default=void 0,Ws=zs(Qe()),Ks=e;kt=nt.default=(0,Ws.default)((0,Ks.jsx)("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2M4 12c0-4.42 3.58-8 8-8 1.85 0 3.55.63 4.9 1.69L5.69 16.9C4.63 15.55 4 13.85 4 12m8 8c-1.85 0-3.55-.63-4.9-1.69L18.31 7.1C19.37 8.45 20 10.15 20 12c0 4.42-3.58 8-8 8"}),"Block");var it={},qs=Je;Object.defineProperty(it,"__esModule",{value:!0});var Ft=it.default=void 0,Ms=qs(Qe()),$s=e;Ft=it.default=(0,Ms.default)((0,$s.jsx)("path",{d:"M17.65 6.35C16.2 4.9 14.21 4 12 4c-4.42 0-7.99 3.58-7.99 8s3.57 8 7.99 8c3.73 0 6.84-2.55 7.73-6h-2.08c-.82 2.33-3.04 4-5.65 4-3.31 0-6-2.69-6-6s2.69-6 6-6c1.66 0 3.14.69 4.22 1.78L13 11h7V4z"}),"Refresh");const Us=(n,t,s="")=>{if(!s||!t)return"";switch(s){case W.NOTIFICATION_SEND_FAILED_REASON.USER_DISABLED:return n("notification.sendStatus.reason.disabled",{channel:t});case W.NOTIFICATION_SEND_FAILED_REASON.CHANNEL_UNAVAILABLE:return n("notification.sendStatus.reason.unavailable",{channel:t});case W.NOTIFICATION_SEND_FAILED_REASON.CHANNEL_DISABLED:return n("notification.sendStatus.reason.notSent",{channel:t});case W.NOTIFICATION_SEND_FAILED_REASON.NOT_ONLINE:return n("notification.sendStatus.reason.offline");default:return s}};function Bt(n,t,s={}){const{status:r,updatedAt:o,reason:l="",channel:y="wallet"}=s,p=o?n("notification.sendStatus.sentTime",{date:os(o,t)}):"",h=Us(n,y,l);return r===W.NOTIFICATION_SEND_STATUS.FAILED?{status:"failed",title:n("notification.sendStatus.failed"),sentTime:p,reason:h}:r===W.NOTIFICATION_SEND_STATUS.SENT?{status:"success",title:n("notification.sendStatus.success"),sentTime:p}:{status:"pending",title:n("notification.sendStatus.pending"),reason:h,sentTime:p}}const Ge={pending:"#aaaaaa",success:"#34BE74",failed:"#D0021B"},Ye=["wallet","pushKit","email"],mt=["info","success","error","warning"],zt=n=>{var s,r;const{settings:t}=n;return(r=(s=t==null?void 0:t.notification)==null?void 0:s.email)==null?void 0:r.enabled},Wt=n=>{var s,r;const{settings:t}=n;return(r=(s=t==null?void 0:t.notification)==null?void 0:s.pushKit)==null?void 0:r.enabled},Hs=(n,t)=>{const s=fe(t,"extra.notifications.email",!0);return{available:zt(n),enabled:s}},Vs=(n,t)=>{const s=fe(t,"extra.notifications.push",!0);return{available:Wt(n),enabled:s}},Gs=n=>({enabled:fe(n,"extra.notifications.wallet",!0)}),Ys=n=>({enabled:fe(n,"extra.webhooks",[]).length>0}),Ee=(n=3)=>new Promise(t=>{setTimeout(()=>{t()},n*1e3)}),Js=(n,t)=>t==="wallet"||t==="webhook"?[{channel:t,type:"enabled",pass:n("notification.sendStatus.reason.enabled",{channel:t}),fail:n("notification.sendStatus.reason.disabled",{channel:t})}]:t==="pushKit"||t==="email"?[{channel:t,type:"available",pass:n("notification.sendStatus.reason.available",{channel:t}),fail:n("notification.sendStatus.reason.unavailable",{channel:t})},{channel:t,type:"enabled",pass:n("notification.sendStatus.reason.enabled",{channel:t}),fail:n("notification.sendStatus.reason.disabled",{channel:t})}]:[],Ie=(n=[])=>{const t=se().startOf("day");return n.filter(s=>se(s.sendAt).isSame(t,"day")).length},Xs=(n,t="")=>{if(t&&Ye.includes(t)){const l=`${t}SendRecord`,y=fe(n,l,[]);return Ie(y)}const s=fe(n,"webhook",{}),r=Object.keys(s??{})??[];if(t&&r.includes(t)){const l=s[t]??[];return Ie(l)}const o={};return Ye.forEach(l=>{const y=`${l}SendRecord`,p=fe(n,y,[]),h=Ie(p);o[l]=h}),r.length>0&&r.forEach(l=>{const y=s[l]??[],p=Ie(y);o[l]=p}),o},Ae=(n,t,s)=>{if(!Array.isArray(n))throw new Error("Invalid filterList or index");return n[s].splice(t,1),n},De=(n,t)=>{if(!Array.isArray(t))throw new Error("filters must be an array");return t.length?!t.includes(n):!1},Qs=n=>{switch(n){case W.NOTIFICATION_SEND_CHANNEL.WALLET:return"Wallet";case W.NOTIFICATION_SEND_CHANNEL.PUSH:return"Push Kit";case W.NOTIFICATION_SEND_CHANNEL.EMAIL:return"Email";case W.NOTIFICATION_SEND_CHANNEL.WEBHOOK:return"Webhook";default:return""}},Kt=()=>({components:{MUIDataTableFilter:{styleOverrides:{header:{marginBottom:0,p:{margin:0}},root:{"& .MuiGrid-container":{marginTop:0,"& .MuiGrid-item":{paddingTop:0}}}}},MuiPopover:{styleOverrides:{root:{"&.MuiPopover-root":{"& .MuiPaper-root:has(.filter-container)":{width:"420px"}}}}}}});function de({config:n,enableTooltip:t=!0,showTitle:s=!1,children:r}){const{status:o,title:l="",sentTime:y="",reason:p=""}=n,h=[l,p].filter(Boolean).join(", ");return e.jsx(xt,{title:t?e.jsxs(e.Fragment,{children:[e.jsx(ae,{color:"inherit",sx:{fontSize:12},children:h}),e.jsx("span",{children:y})]}):null,arrow:!0,placement:"top",children:e.jsxs(T,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"4px"},children:[e.jsxs(T,{position:"relative",minHeight:14,minWidth:14,display:"flex",alignItems:"center",justifyContent:"center",children:[e.jsx(T,{position:"absolute",width:"100%",height:"100%",borderRadius:"50%",bgcolor:Ge[o],style:{opacity:.15}}),e.jsx(T,{position:"absolute",width:"55%",height:"55%",borderRadius:"50%",bgcolor:Ge[o]})]}),e.jsx(ae,{color:"inherit",sx:{fontSize:12},children:s?l:r})]})})}de.propTypes={config:x.object.isRequired,enableTooltip:x.bool,showTitle:x.bool,children:x.node};de.defaultProps={enableTooltip:!0,showTitle:!1,children:null};Se.propTypes={list:x.array.isRequired,label:x.string.isRequired,onDelete:x.func};Se.defaultProps={onDelete:()=>{}};function Se({list:n,label:t,onDelete:s}){const{t:r,locale:o}=re();return e.jsxs(T,{display:"flex",gap:1,alignItems:"center",children:[e.jsxs(ae,{children:[t,": "]}),n.map(l=>{const y=Bt(r,o,{status:l});return e.jsx(Xe,{size:"small",label:e.jsx(T,{display:"flex",alignItems:"center",sx:{gap:"4px"},children:e.jsx(de,{config:y,enableTooltip:!1,children:y.title})}),onDelete:p=>s(p,l)},l)})]})}at.propTypes={filterList:x.array.isRequired,onChange:x.func.isRequired,index:x.number.isRequired,column:x.object.isRequired,filterValues:x.array.isRequired,label:x.string.isRequired,renderLabel:x.func.isRequired};function at({filterList:n,onChange:t,index:s,column:r,filterValues:o,label:l,renderLabel:y}){return e.jsxs(G,{className:"filter-container",children:[e.jsx(gt,{component:"legend",children:l}),e.jsx(Ke,{row:!0,children:o.map(p=>e.jsx(ge,{control:e.jsx(qe,{checked:n[s].indexOf(p.value??p)>-1,onChange:h=>{const i=[...n];h.target.checked?i[s]=[...i[s],p.value??p]:i[s]=i[s].filter(O=>O!==(p.value??p)),t(i[s],s,r)},name:p.value??p}),label:e.jsx("span",{style:{display:"flex",alignItems:"center"},children:y(p)})},p.value??p))})]})}function ze(n){return e.jsx(at,{...n,renderLabel:t=>e.jsx(de,{enableTooltip:!1,config:{status:t.status},children:t.label})})}ve.propTypes={status:x.number.isRequired,updatedAt:x.string.isRequired,reason:x.string,channel:x.string,onResend:x.func};function ve({status:n,updatedAt:t,reason:s="",channel:r="wallet",onResend:o}){const{t:l,locale:y}=re(),p=Bt(l,y,{status:n,updatedAt:t,reason:s,channel:r});return e.jsxs(T,{display:"flex",alignItems:"center",gap:1,children:[e.jsx(de,{config:p,showTitle:!0}),p.status!=="success"&&e.jsx(Le,{className:"resend-btn",size:"small",startIcon:e.jsx(et,{}),sx:{fontSize:12,color:"rgba(0, 0, 0, 0.87)",fontWeight:400,".MuiButton-startIcon":{mr:"2px"}},onClick:o,children:l("notification.resend")})]})}rt.propTypes={value:x.array.isRequired,onChange:x.func};function rt({value:n,onChange:t}){const{locale:s}=re(),r=se().toDate(),[o,l]=C.useState(null),y=C.useCallback(i=>{l(o?null:i.currentTarget)},[o]),p=!!o,h=C.useCallback(i=>{if(!i.startDate||!i.endDate){q.error("Please select a date range");return}if(se(i.startDate).isAfter(i.endDate)||!se(i.startDate).isValid()||!se(i.endDate).isValid()){q.error("Invalid date range");return}t([i.startDate,i.endDate]),l(null)},[t]);return e.jsxs("div",{children:[e.jsx(ae,{component:"div",variant:"h5",color:"textPrimary",style:{fontSize:18,fontWeight:"bold"},mb:0,children:e.jsxs(Le,{onClick:y,variant:"outlined",size:"small",color:"inherit",children:[pt(n[0],s)," - ",pt(n[1],s)]})}),e.jsx(Me,{open:p,anchorEl:o,onClose:()=>{l(null)},anchorOrigin:{vertical:"bottom",horizontal:"left"},children:e.jsx(ys,{open:!0,maxDate:r,initialDateRange:{startDate:n[0],endDate:n[1]},toggle:y,definedRanges:Ss(r),onChange:h})})]})}ot.propTypes={itemComponent:x.elementType.isRequired};function ot({itemComponent:n,...t}){var o;const{t:s}=re();return!((o=t==null?void 0:t.filterList)!=null&&o.filter(l=>l.length).length)?null:e.jsxs(T,{display:"flex",gap:1,alignItems:"center",children:[e.jsx("div",{className:"toolbar-filter-title",children:s("notification.filter")}),e.jsx("div",{className:"toolbar-filter-content",children:e.jsx(is.TableFilterList,{...t,ItemComponent:n})})]})}function Pe({label:n,onDelete:t,canDelete:s=()=>!0,...r}){const o=t&&typeof t=="function"?t:void 0;let l=!0;return s&&typeof s=="function"&&(l=s({label:n,...r})),e.jsx(Xe,{label:n,variant:"outlined",...o&&l?{onDelete:o}:{}})}Pe.propTypes={label:x.string.isRequired,onDelete:x.func,canDelete:x.func};Pe.defaultProps={canDelete:()=>!0};const Zs=[{label:"Wallet",value:"app",checked:!0},{label:"Email",value:"email",checked:!0},{label:"Push Kit",value:"push",checked:!0},{label:"Webhook",value:"webhook",checked:!0}];lt.propTypes={loading:x.bool,onCancel:x.func,onConfirm:x.func};lt.defaultProps={loading:!1,onCancel:()=>{},onConfirm:()=>{}};function lt({loading:n=!1,onCancel:t,onConfirm:s}){const{t:r}=re(),[o,l]=C.useState(Zs),[y,p]=C.useState(!0),h=(O,A)=>{A.checked=O.target.checked;const R=o.map(S=>({...S,checked:S.value===A.value?A.checked:S.checked}));l(R)},i=O=>{O.stopPropagation(),s({channels:o.filter(A=>A.checked).map(A=>A.value),isResendFailedOnly:y})};return e.jsxs(T,{className:"resend-config",sx:{padding:"16px 24px"},children:[e.jsx(ae,{variant:"body1",component:"div",className:"check-title",sx:{fontWeight:700,mb:1},children:r("notification.config")}),e.jsx(T,{className:"choose-channel",children:e.jsxs(G,{component:"fieldset",variant:"standard",children:[e.jsx(gt,{component:"legend",children:r("notification.selectChannels")}),e.jsx(Ke,{sx:{display:"flex",flexDirection:"row",flexWrap:"wrap",gap:1},children:o.map(O=>e.jsx(ge,{control:e.jsx(qe,{checked:O.checked,onChange:A=>h(A,O),name:O.value}),label:O.label},O.value))})]})}),e.jsx(T,{className:"resend-config-footer",children:e.jsx(Ke,{children:e.jsx(ge,{control:e.jsx(qe,{checked:y,onChange:O=>p(O.target.checked)}),label:r("notification.resendFailedOnly")})})}),e.jsxs(T,{display:"flex",justifyContent:"flex-end",gap:1,className:"resend-config-footer-tip",children:[e.jsx(Le,{onClick:O=>{O.stopPropagation(),t()},color:"inherit",children:r("common.cancel")}),e.jsxs(Le,{onClick:i,color:"primary",disabled:n,variant:"contained",autoFocus:!0,style:{marginLeft:8},children:[n&&e.jsx(bt,{size:16}),r("common.confirm")]})]})]})}qt.propTypes={notificationId:x.string.isRequired,handleResend:x.func,resending:x.bool};function qt({notificationId:n,handleResend:t,resending:s=!1}){const{t:r,locale:o}=re(),l=jt(),y=C.useMemo(()=>vt(l,Kt()),[l]),{getReceivers:p,inService:h,teamDid:i,getUser:O,blocklet:A}=tt(),[R,S]=C.useState(!1),[D,Y]=C.useState([]),z=Te({anchorEl:null,position:null}),B=Te({anchorEl:null,position:null}),[_,M]=C.useState(null),[J,ie]=C.useState({total:0,pageSize:10,pageCount:0,page:1}),[c,g]=C.useState({searchText:"",page:1,pageSize:10,walletSendStatus:[],pushKitSendStatus:[],emailSendStatus:[],dateRange:[se().subtract(1,"month").startOf("day").toDate(),se().endOf("day").toDate()]}),[j,N]=C.useState([]),E=[{label:r("notification.sendStatus.pending"),value:0,status:"pending"},{label:r("notification.sendStatus.success"),value:1,status:"success"},{label:r("notification.sendStatus.failed"),value:2,status:"failed"}],P=async()=>{if(!R&&n)try{S(!0);const d=await p({notificationId:n,...c}),u=d.list.map(f=>({...f,receiverUser:{...f.receiverUser,avatar:Dt(f.receiverUser.avatar,i,h)}}));Y(u),ie(d.paging),S(!1)}catch(d){q.error(d.message),S(!1)}};C.useEffect(()=>{P()},[c]);const a=d=>{d.stopPropagation();const u=d.currentTarget;B.anchorEl=u;const f=u.getBoundingClientRect();B.position={top:f.top+window.scrollY,left:f.left+window.scrollX}},m=d=>d.data.length?e.jsx("div",{style:{display:"flex",alignItems:"center",padding:"10px"},children:e.jsx(me,{className:"resend-btn",size:"small",color:"primary",variant:"contained",startIcon:e.jsx(et,{}),sx:{".MuiButton-startIcon":{mr:"2px"}},onClick:a,children:r("notification.resend")})}):null,$={sort:!1,download:!1,print:!1,selectableRows:"multiple",searchPlaceholder:r("common.search"),searchAlwaysOpen:!1,filterType:"checkbox",searchDebounceTime:300,page:J.page-1,rowsPerPage:J.pageSize,count:J.total,searchText:c.searchText,tableBodyMaxHeight:"calc(80vh - 260px)",rowsSelected:j,onRowSelectionChange:(d,u)=>{N(u.map(f=>f.dataIndex))},customToolbarSelect:m},U=({page:d,rowsPerPage:u,searchText:f,filterList:L})=>{const[,K=[],Z=[],X=[]]=L;c.pageSize!==u?g(H=>({...H,pageSize:u,page:1})):c.page!==d+1?g(H=>({...H,page:d+1})):c.searchText!==f?g(H=>({...H,searchText:f,page:1})):ye(K,c.walletSendStatus)?ye(Z,c.pushKitSendStatus)?ye(X,c.emailSendStatus)||g(H=>({...H,emailSendStatus:X,page:1})):g(H=>({...H,pushKitSendStatus:Z,page:1})):g(H=>({...H,walletSendStatus:K,page:1}))},oe=C.useCallback(async(d,u)=>{if(!u)return!1;const f=await O(u);return f?d==="wallet"?Gs(f):d==="email"?Hs(A,f):d==="pushKit"?Vs(A,f):d==="webhook"?Ys(f):!0:!1},[O,A]),le=C.useCallback(d=>Js(r,d),[r]),pe=()=>{z.anchorEl=null,z.position=null,M(null)},be=()=>{B.anchorEl=null,B.position=null},je=async(d,u,f=!0,L="")=>{if(!(!u.length||!d.length))try{t(d,u,f,L),B.anchorEl||(await Ee(.5),pe())}catch(K){console.error("handleResend error",{error:K})}},v=async({channels:d,isResendFailedOnly:u})=>{const f=j.map(L=>D[L].receiver);await je(d,f,u),await Ee(.5),be(),N([])},b=async(d,u=[],f=!0)=>{try{await je(["webhook"],[d.receiver],f,u)}catch(L){q.error(L.response?L.response.statusText:L.message)}},w=async(d,u,f,L=[],K=!0)=>{if(d.stopPropagation(),Xs(u,f)>=4){q.warning(r("notification.resendLimit"));return}if(!Ye.includes(f)){await b(u,L,K);return}if(d){const X=d.currentTarget,H=X.getBoundingClientRect();z.anchorEl=X,z.position={top:H.top+window.scrollY,left:H.left+window.scrollX}}M({channel:f});try{const X=await oe(f,u.receiver);await Ee(1),M({channel:f,result:X}),(typeof X=="boolean"&&X||Zt(X)&&Object.values(X).every(H=>!!H))&&(await t([f],[u.receiver],K),B.anchorEl||(await Ee(.5),pe()))}catch(X){q.error(X.message)}},I=d=>{g(u=>({...u,dateRange:d,page:1}))},k=(d,u,f,L)=>{d.stopPropagation();const K=f.filter(Z=>Z!==u);g(Z=>({...Z,[L]:K,page:1}))},F=ce(()=>[{label:r("notification.receiver"),name:"receiver",width:200,options:{filter:!1,customBodyRenderLite:d=>{const{receiverUser:u,receiver:f}=D[d];return u?e.jsxs(T,{"data-cy":`member-name-${u.fullName}`,display:"flex",alignItems:"center",gap:1,justifyContent:"flex-start",children:[e.jsx(Tt,{src:`${u.avatar}?imageFilter=resize&w=48&h=48`,size:32,did:f,shape:"circle",style:{borderRadius:"100%",overflow:"hidden"}}),e.jsx(Re,{children:u.fullName})]},f):e.jsx(vs,{size:14,responsive:!1,compact:!0,copyable:!1,did:f})}}},{label:"Wallet",name:"walletSendStatus",width:200,options:{setCellProps:()=>({className:"sent-status-cell"}),filter:!0,filterType:"custom",filterList:c.walletSendStatus??[],customFilterListOptions:{render:d=>e.jsx(Se,{list:d,label:"Wallet",onDelete:(u,f)=>{u.stopPropagation(),k(u,f,F[1].options.filterList,"walletSendStatus")}}),update:Ae},filterOptions:{names:E,fullWidth:!0,logic:De,display:(d,u,f,L)=>e.jsx(ze,{label:"Wallet",filterList:d,onChange:u,index:f,column:L,filterValues:E})},customBodyRenderLite:d=>{const{walletSendStatus:u,walletSendAt:f,walletSendFailedReason:L}=D[d];return e.jsx(ve,{status:u,updatedAt:f,reason:L,channel:"wallet",onResend:K=>w(K,D[d],"wallet",[],!1)})}}},{label:"Push Kit",name:"pushKitSendStatus",width:200,options:{setCellProps:()=>({className:"sent-status-cell"}),customBodyRenderLite:d=>{const{pushKitSendStatus:u,pushKitSendAt:f,pushKitSendFailedReason:L}=D[d];return e.jsx(ve,{status:u,updatedAt:f,reason:L,channel:"pushkit",onResend:K=>w(K,D[d],"pushKit",[],!1)})},filter:!0,filterType:"custom",filterList:c.pushKitSendStatus??[],customFilterListOptions:{render:d=>e.jsx(Se,{list:d,label:"Push Kit",onDelete:(u,f)=>{u.stopPropagation(),k(u,f,F[2].options.filterList,"pushKitSendStatus")}}),update:Ae},filterOptions:{names:E,fullWidth:!0,logic:De,display:(d,u,f,L)=>e.jsx(ze,{label:"Push Kit",filterList:d,onChange:u,index:f,column:L,filterValues:E})}}},{label:"Email",name:"emailSendStatus",width:200,options:{setCellProps:()=>({className:"sent-status-cell"}),customBodyRenderLite:d=>{const{emailSendStatus:u,emailSendAt:f,emailSendFailedReason:L}=D[d];return e.jsx(ve,{status:u,updatedAt:f,reason:L,channel:"email",onResend:K=>w(K,D[d],"email",[],!1)})},filter:!0,filterType:"custom",filterList:c.emailSendStatus??[],customFilterListOptions:{render:d=>e.jsx(Se,{list:d,label:"Email",onDelete:(u,f)=>{u.stopPropagation(),k(u,f,F[3].options.filterList,"emailSendStatus")}}),update:Ae},filterOptions:{names:E,fullWidth:!0,logic:De,display:(d,u,f,L)=>e.jsx(ze,{label:"Email",filterList:d,onChange:u,index:f,column:L,filterValues:E})}}},{label:"Webhook",name:"webhook",width:200,options:{filter:!1,setCellProps:()=>({className:"sent-status-cell"}),customBodyRenderLite:d=>{const{webhook:u}=D[d];if(!u)return null;const f=Object.entries(u)[0];if(!f)return null;const[L,K]=f,Z=K[0];return e.jsx(T,{display:"flex",flexDirection:"column",gap:1,children:e.jsxs(T,{className:"webhook-item",fontSize:12,children:[e.jsx(Re,{maxLength:30,children:L},L),e.jsx(ve,{status:Z.status,updatedAt:Z.sendAt,reason:Z.failedReason,channel:"webhook",onResend:X=>w(X,D[d],"webhook",[L],!1)})]},L)})}}},{label:r("common.createdAt"),name:"createdAt",width:100,options:{filter:!1,customBodyRenderLite:d=>{const{createdAt:u}=D[d];return e.jsx(At,{value:u,locale:o,shouldUpdate:!0})}}}],[D,o,c,r]),ne=[e.jsx(rt,{value:c.dateRange,onChange:I},"date-picker"),e.jsx(me,{variant:"contained",size:"small",color:"primary",loading:R,startIcon:e.jsx(Ft,{}),onClick:()=>P(),sx:{".MuiButton-startIcon":{mr:"2px"}},style:{marginLeft:8},children:r("common.refresh")},"refresh")];return e.jsx(T,{sx:{overflow:"auto",".MuiTableCell-head":{whiteSpace:"nowrap",fontWeight:"bold"},".MuiTableCell-root":{paddingRight:"8px",whiteSpace:"nowrap"}},children:e.jsx(tn,{children:e.jsxs(yt,{theme:y,children:[e.jsx(Rt,{className:"receivers-table",locale:o,loading:R,columns:F,data:D,onChange:U,options:$,customButtons:ne,components:{TableFilterList:d=>e.jsx(ot,{...d,itemComponent:u=>e.jsx(Pe,{...u,canDelete:()=>!1})})}}),z.anchorEl&&e.jsx(Me,{open:!!z.anchorEl,anchorReference:"anchorPosition",anchorPosition:z.position,onClose:pe,anchorOrigin:{vertical:"center",horizontal:"right"},transformOrigin:{vertical:"center",horizontal:"left"},children:e.jsxs(sn,{children:[e.jsxs(ae,{variant:"body1",component:"div",className:"check-title",children:[_==null?void 0:_.channel," Checking"]}),e.jsx(T,{display:"flex",flexDirection:"column",sx:{gap:"4px"},children:le(_==null?void 0:_.channel).map(d=>{var K,Z;const{type:u,pass:f,fail:L}=d;return!(_!=null&&_.result)||(K=_==null?void 0:_.result)!=null&&K[u]?e.jsxs(ae,{variant:"body1",component:"div",className:"check-item",display:"flex",alignItems:"center",sx:{gap:"4px",color:(Z=_==null?void 0:_.result)!=null&&Z[u]?Oe.success.main:"inherit"},children:[_!=null&&_.result?e.jsx(_t,{}):e.jsx(bt,{size:12,sx:{color:Oe.primary.main}}),e.jsx("span",{children:f})]},u):e.jsxs(ae,{variant:"body1",component:"div",display:"flex",alignItems:"center",className:"check-item",sx:{gap:"4px",color:Oe.error.main},children:[e.jsx(kt,{}),e.jsx("span",{children:L})]},u)})})]})}),B.anchorEl&&e.jsx(Me,{open:!!B.anchorEl,anchorReference:"anchorPosition",anchorPosition:B.position,onClose:be,anchorOrigin:{vertical:"center",horizontal:"right"},transformOrigin:{vertical:"center",horizontal:"left"},children:e.jsx(lt,{loading:s,onCancel:be,onConfirm:v})})]})})})}const en=C.memo(qt),tn=ue.div`
|
|
1
|
+
import{g as Ut,r as C}from"./vendor-react-DEoibe3W.js";import{ah as ue,al as ht,j as e,aa as T,O as te,bs as ge,bt as We,bo as G,ad as xt,H as x,a9 as Je,T as ae,E as Xe,bz as gt,bQ as Ke,bR as qe,y as Le,b6 as Me,ab as bt,bI as jt,Y as vt,cn as yt,m as Ht,as as dt,br as Vt,bn as Gt,q as ut,bX as Yt,I as Jt}from"./vendor-mui-core-Bq8gXTan.js";import{J as St,z as Xt,A as Qt,e as fe,aB as ye,C as Zt}from"./vendor-utils-BfZ4tlod.js";import{y as es,a as re,ab as Ct,a3 as q,X as ke,c1 as ts,B as me,k as W,bb as ss,ax as wt,bg as ns,r as Qe,c2 as is,a2 as Tt,ac as Rt,bB as Oe,ar as Nt,$ as as,bI as rs}from"./vendor-ux-did-connect-mISLpoxA.js";import{D as Ze,G as Et,aC as It,aD as Q,y as se,n as os,K as pt}from"./index-BRdhpmU2.js";import{a as Te,u as V,b as ce}from"./vendor-hooks-DqdmWCmo.js";import{a as et,b as ls}from"./dashboard-Cpd1IklF.js";import{f as $e,i as cs,d as ds}from"./use-blocklet-logo-Due3V0N2.js";import{A as us,a as ps,d as fs,b as ms}from"./collapse-B1s6QHCm.js";import{S as ee}from"./section-BDMQAX_r.js";import{S as Re}from"./shorten-label-BQvbtscf.js";import{I as Ot}from"./index-DBZhb75O.js";import{R as At,A as hs,S as xs,a as gs,b as bs,B as js}from"./list-D3co1lE_.js";import{W as vs}from"./did-address-uKFe7d9V.js";import{p as Dt}from"./util-YJ_KBZfa.js";import{D as ys,g as Ss}from"./traffic-BZEjFNTD.js";import{B as Lt}from"./bundle-avatar-NjLcf8la.js";import{u as Cs}from"./use-mobile-DwzRjjku.js";import"./lottie-web-jYmAQWuC.js";import"./vendor-arcblock-BUFJsma5.js";import"./useLocalStorage-D_xU3zzI.js";import"./index-8eXqqyHQ.js";import"./confirm-DrIfevZQ.js";import"./PlayArrow-DLymwoC2.js";import"./get-safe-url-CJEvMc5P.js";import"./session-DocEIP6S.js";import"./InfoOutlined-CRqiKRaY.js";import"./dot-4jhL56kz.js";import"./useAsync-C62uE2pS.js";import"./useSetState-CWq0AVWn.js";import"./use-mobile-CtTQsfXN.js";import"./index-DEZojGsm.js";import"./CheckCircle-s6iPVCo6.js";import"./base32-kNwk0OEz.js";import"./iframe-CaeDKfYB.js";import"./LaunchOutlined-DD-CBO2C.js";import"./ChevronLeft-CMWjvJzl.js";import"./ChevronRight-BvGLpFbz.js";import"./index-B2NkqENf.js";import"./base-chart-CoApVzod.js";import"./index-w4f-mlFt.js";import"./vendor-mui-x-1nqAyytV.js";import"./AdapterDayjs-DPGZ06jw.js";var Ue={exports:{}},He={exports:{}},Ve={exports:{}};(function(n,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=s;function s(r){return r==null}n.exports=t.default,n.exports.default=t.default})(Ve,Ve.exports);var ws=Ve.exports;(function(n,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=p;var s=o(es),r=o(ws);function o(h){return h&&h.__esModule?h:{default:h}}var l=/^(?:[-+]?(?:0|[1-9][0-9]*))$/,y=/^[-+]?[0-9]+$/;function p(h,i){(0,s.default)(h),i=i||{};var O=i.allow_leading_zeroes===!1?l:y,A=!i.hasOwnProperty("min")||(0,r.default)(i.min)||h>=i.min,R=!i.hasOwnProperty("max")||(0,r.default)(i.max)||h<=i.max,S=!i.hasOwnProperty("lt")||(0,r.default)(i.lt)||h<i.lt,D=!i.hasOwnProperty("gt")||(0,r.default)(i.gt)||h>i.gt;return O.test(h)&&A&&R&&S&&D}n.exports=t.default,n.exports.default=t.default})(He,He.exports);var Ts=He.exports;(function(n,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=o;var s=r(Ts);function r(l){return l&&l.__esModule?l:{default:l}}function o(l){return(0,s.default)(l,{allow_leading_zeroes:!1,min:0,max:65535})}n.exports=t.default,n.exports.default=t.default})(Ue,Ue.exports);var Rs=Ue.exports;const Ns=Ut(Rs),Fe={enabled:!1,secure:!1,from:"",host:"",port:"",user:"",password:"",companyName:"",companyLink:"",companyAddress:"",supportEmail:""};function Es(){var N,E,P;const{api:n}=Ze(),{blocklet:t}=Et(),{t:s}=re(),{confirmApi:r,confirmHolder:o}=Ct(),l=(N=t==null?void 0:t.meta)==null?void 0:N.did,y=Object.assign({...Fe},((P=(E=t==null?void 0:t.settings)==null?void 0:E.notification)==null?void 0:P.email)||{}),{handleSubmit:p,control:h,formState:i,watch:O,reset:A}=It({defaultValues:St(y,Object.keys(Fe))}),R=Te({testReceiver:"",testReceiverError:""}),S=O("enabled"),D=V(async(a,m,$=!0)=>{var U,oe;try{const{blocklet:le}=await n.configNotification({input:{did:l,notification:JSON.stringify({email:a})}}),pe=Object.assign({...Fe},((oe=(U=le==null?void 0:le.settings)==null?void 0:U.notification)==null?void 0:oe.email)||{});A(pe),$&&q.success(s("oauth.saveSuccess"))}catch(le){if($)q.error(le.message||s("oauth.saveFailed"));else throw le}}),Y=V(async(a,m,$)=>{try{i.isDirty&&await D(a,m,!1),await n.sendEmail({input:{did:l,receiver:$,email:JSON.stringify({body:"Your SMTP configuration is correct!",title:"Test email",type:"notification"})}}),q.success(s("notification.email.testSuccess"))}catch(U){q.error(U.message||s("notification.email.testfailed"))}}),z=V((a,m)=>{R.testReceiver="",R.testReceiverError="",r.open({title:s("notification.email.testSendEmail"),content:()=>e.jsx(T,{sx:{width:"300px"},children:e.jsx(te,{sx:{mt:1},fullWidth:!0,name:"testReceiver",label:s("notification.email.inputTestReceiver"),value:R.testReceiver,onChange:$=>{R.testReceiver=$.target.value},error:!!R.testReceiverError,helperText:R.testReceiverError||" "})}),confirmButtonText:s("common.confirm"),cancelButtonText:s("common.cancel"),async onConfirm($){var oe;const U=(oe=R.testReceiver)==null?void 0:oe.trim();if(!U){R.testReceiverError=s("notification.email.receiverRequired");return}if(!ke(U)){R.testReceiverError=s("notification.email.receiverInvalid");return}R.testReceiverError="",await Y(a,m,U),$()}})}),B=V(a=>{const m=a==null?void 0:a.trim();return m?ke(m)?!0:s("notification.email.fromInvalid"):s("notification.email.fromRequired")}),_=V(a=>{const m=a==null?void 0:a.trim();return m?$e(m,{require_host:!1,protocols:[]})?!0:s("notification.email.hostInvalid"):s("notification.email.hostRequired")}),M=V(a=>a?Ns(a)?!0:s("notification.email.portInvalid"):s("notification.email.portRequired")),J=V(a=>a!=null&&a.trim()?!0:s("notification.email.userRequired")),ie=V(a=>a!=null&&a.trim()?!0:s("notification.email.passwordRequired")),c=V(a=>a!=null&&a.trim()&&!$e(a,{protocols:["http","https"],require_protocol:!0})?s("notification.email.linkInvalid"):!0),g=V(a=>a!=null&&a.trim()&&!ke(a)?s("notification.email.emailInvalid"):!0),j=V(()=>!0);return e.jsxs(T,{children:[e.jsxs(Is,{component:"form",onSubmit:p(D),disabled:!0,sx:{".section-left":{width:"160px"}},children:[e.jsx(ee,{title:s("notification.email.enable"),my:2.5,children:e.jsx(Q,{name:"enabled",control:h,render:({field:a})=>e.jsx(ge,{control:e.jsx(We,{checked:a.value,...a})})})}),e.jsx(ee,{title:s("notification.email.from"),children:e.jsx(Q,{name:"from",control:h,rules:{validate:S?B:j},render:({field:a})=>{var m;return e.jsx(G,{fullWidth:!0,children:e.jsx(te,{...a,size:"small",required:!0,label:s("notification.email.from"),error:!!i.errors[a.name],helperText:((m=i.errors[a.name])==null?void 0:m.message)||" ",disabled:!S})})}})}),e.jsx(ee,{title:s("notification.email.host"),children:e.jsx(Q,{name:"host",control:h,rules:{validate:S?_:j},render:({field:a})=>{var m;return e.jsx(G,{fullWidth:!0,children:e.jsx(te,{...a,size:"small",required:!0,error:!!i.errors[a.name],label:s("notification.email.host"),helperText:((m=i.errors[a.name])==null?void 0:m.message)||" ",disabled:!S})})}})}),e.jsx(ee,{title:s("notification.email.port"),children:e.jsx(Q,{name:"port",control:h,rules:{validate:S?M:j},render:({field:a})=>{var m;return e.jsx(G,{fullWidth:!0,children:e.jsx(te,{...a,size:"small",required:!0,type:"number",error:!!i.errors[a.name],label:s("notification.email.port"),helperText:((m=i.errors[a.name])==null?void 0:m.message)||" ",disabled:!S})})}})}),e.jsx(ee,{title:s("notification.email.user"),children:e.jsx(Q,{name:"user",control:h,rules:{validate:S?J:j},render:({field:a})=>{var m;return e.jsx(G,{fullWidth:!0,children:e.jsx(te,{...a,size:"small",required:!0,error:!!i.errors[a.name],label:s("notification.email.user"),helperText:((m=i.errors[a.name])==null?void 0:m.message)||" ",disabled:!S})})}})}),e.jsx(ee,{title:s("notification.email.password"),children:e.jsx(Q,{name:"password",control:h,rules:{validate:S?ie:j},render:({field:a})=>{var m;return e.jsx(G,{fullWidth:!0,children:e.jsx(te,{...a,size:"small",required:!0,type:"password",error:!!i.errors[a.name],label:s("notification.email.password"),helperText:((m=i.errors[a.name])==null?void 0:m.message)||" ",disabled:!S})})}})}),e.jsx(ee,{title:s("notification.email.secure"),children:e.jsx(Q,{name:"secure",control:h,rules:{validate:j},render:({field:a})=>e.jsx(G,{fullWidth:!0,children:e.jsx(ge,{control:e.jsx(We,{checked:a.value,...a,disabled:!S})})})})}),e.jsxs(us,{children:[e.jsxs(ps,{expandIcon:e.jsx(fs,{fontSize:"small"}),"aria-controls":"panel1-content",id:"panel1-header",children:[s("notification.email.signature"),e.jsx(xt,{title:s("notification.email.signatureTooltip"),children:e.jsx(ts,{fontSize:"small",sx:{ml:1,cursor:"help"}})})]}),e.jsxs(ms,{children:[e.jsx(ee,{title:s("notification.email.companyName"),children:e.jsx(Q,{name:"companyName",control:h,rules:{validate:j},render:({field:a})=>{var m;return e.jsx(G,{fullWidth:!0,children:e.jsx(te,{...a,size:"small",error:!!i.errors[a.name],label:s("notification.email.companyName"),helperText:((m=i.errors[a.name])==null?void 0:m.message)||" ",disabled:!S})})}})}),e.jsx(ee,{title:s("notification.email.companyLink"),children:e.jsx(Q,{name:"companyLink",control:h,rules:{validate:S?c:j},render:({field:a})=>{var m;return e.jsx(G,{fullWidth:!0,children:e.jsx(te,{...a,size:"small",error:!!i.errors[a.name],label:s("notification.email.companyLink"),helperText:((m=i.errors[a.name])==null?void 0:m.message)||" ",disabled:!S})})}})}),e.jsx(ee,{title:s("notification.email.companyAddress"),children:e.jsx(Q,{name:"companyAddress",control:h,rules:{validate:j},render:({field:a})=>{var m;return e.jsx(G,{fullWidth:!0,children:e.jsx(te,{...a,size:"small",error:!!i.errors[a.name],label:s("notification.email.companyAddress"),helperText:((m=i.errors[a.name])==null?void 0:m.message)||" ",disabled:!S})})}})}),e.jsx(ee,{title:s("notification.email.supportEmail"),children:e.jsx(Q,{name:"supportEmail",control:h,rules:{validate:S?g:j},render:({field:a})=>{var m;return e.jsx(G,{fullWidth:!0,children:e.jsx(te,{...a,size:"small",type:"email",error:!!i.errors[a.name],label:s("notification.email.supportEmail"),helperText:((m=i.errors[a.name])==null?void 0:m.message)||" ",disabled:!S})})}})})]})]}),e.jsxs(T,{sx:{display:"flex",justifyContent:"flex-end",gap:2,mt:3},children:[e.jsx(me,{variant:"outlined",color:"warning",onClick:p(z),disabled:!S,children:s("oauth.runTest")}),e.jsx(me,{type:"submit",variant:"contained",disabled:!i.isDirty,children:s("oauth.save")})]})]}),o]})}const Is=ue(ht)``,Be={enabled:!1,endpoint:"",did:void 0,pushPath:void 0};function Os(){var M,J,ie;const{api:n}=Ze(),{blocklet:t}=Et(),{t:s}=re(),{confirmApi:r,confirmHolder:o}=Ct(),l=(M=t==null?void 0:t.meta)==null?void 0:M.did,y=Object.assign({...Be},((ie=(J=t==null?void 0:t.settings)==null?void 0:J.notification)==null?void 0:ie.pushKit)||{}),{handleSubmit:p,control:h,formState:i,watch:O,reset:A}=It({defaultValues:St(y,Object.keys(Be))}),R=Te({testReceiver:"",testReceiverError:""}),S=O("enabled"),D=V(async(c,g,j=!0)=>{var N,E;try{const{blocklet:P}=await n.configNotification({input:{did:l,notification:JSON.stringify({pushKit:c})}}),a=Object.assign({...Be},((E=(N=P==null?void 0:P.settings)==null?void 0:N.notification)==null?void 0:E.pushKit)||{});A(a),j&&q.success(s("oauth.saveSuccess"))}catch(P){if(j)q.error(P.message||s("oauth.saveFailed"));else throw P}}),Y=V(async(c,g)=>{var j,N,E;try{i.isDirty&&await D(c,g,!1);const P=(j=((t==null?void 0:t.configs)||[]).find($=>$.key==="BLOCKLET_APP_URL"))==null?void 0:j.value,a=Xt(Qt(P,W.WELLKNOWN_SERVICE_PATH_PREFIX,"/blocklet/logo"),{v:(N=t==null?void 0:t.meta)==null?void 0:N.version,t:new Date((t==null?void 0:t.updatedAt)||0).getTime()}),m={type:"passthrough",passthroughType:"messageStatus",data:{message:{title:"Test push-kit notification",body:"This is message from push-kit config test",sender:{did:t==null?void 0:t.appDid,fullName:(E=t==null?void 0:t.meta)==null?void 0:E.title,avatar:a}}}};await n.sendPush({input:{did:l,receiver:R.testReceiver,notification:JSON.stringify(m)}}),q.success(s("notification.pushKit.testSuccess"))}catch(P){q.error(P.message||s("notification.pushKit.testfailed"))}}),z=V((c,g)=>{R.testReceiverError="",r.open({title:s("notification.pushKit.testSend"),content:()=>e.jsx(T,{sx:{width:"450px",maxWidth:"100%"},children:e.jsx(te,{sx:{mt:1},fullWidth:!0,name:"testReceiver",label:s("notification.pushKit.inputTestReceiver"),value:R.testReceiver,onChange:j=>{R.testReceiver=j.target.value},error:!!R.testReceiverError,helperText:R.testReceiverError||" "})}),confirmButtonText:s("common.confirm"),cancelButtonText:s("common.cancel"),async onConfirm(j){var E;if(!((E=R.testReceiver)==null?void 0:E.trim())){R.testReceiverError=s("notification.pushKit.receiverRequired");return}R.testReceiverError="",await Y(c,g),j()}})}),B=V(c=>{const g=c==null?void 0:c.trim();return g?$e(g)?!0:s("notification.pushKit.endpointInvalid"):s("notification.pushKit.endpointRequired")}),_=V(()=>!0);return e.jsxs(T,{children:[e.jsxs(As,{component:"form",onSubmit:p(D),disabled:!0,sx:{".section-left":{width:"160px"}},children:[e.jsx(ee,{title:s("notification.pushKit.enable"),my:2.5,children:e.jsx(Q,{name:"enabled",control:h,render:({field:c})=>e.jsx(ge,{control:e.jsx(We,{checked:c.value,...c})})})}),e.jsx(ee,{title:s("notification.pushKit.endpoint"),children:e.jsx(Q,{name:"endpoint",control:h,rules:{validate:S?B:_},render:({field:c})=>{var g;return e.jsx(G,{fullWidth:!0,children:e.jsx(te,{...c,size:"small",required:!0,label:s("notification.pushKit.endpoint"),error:!!i.errors[c.name],helperText:((g=i.errors[c.name])==null?void 0:g.message)||" ",disabled:!S})})}})}),e.jsxs(ee,{title:s("notification.pushKit.customOptions"),children:[e.jsx(Q,{name:"did",control:h,render:({field:c})=>{var g;return e.jsx(G,{fullWidth:!0,children:e.jsx(te,{...c,size:"small",label:s("notification.pushKit.did"),error:!!i.errors[c.name],helperText:((g=i.errors[c.name])==null?void 0:g.message)||" ",disabled:!S})})}}),e.jsx(Q,{name:"pushPath",control:h,render:({field:c})=>{var g;return e.jsx(G,{fullWidth:!0,children:e.jsx(te,{...c,size:"small",label:s("notification.pushKit.pushPath"),error:!!i.errors[c.name],helperText:((g=i.errors[c.name])==null?void 0:g.message)||" ",disabled:!S})})}})]}),e.jsxs(T,{sx:{display:"flex",justifyContent:"flex-end",gap:2,mt:3},children:[e.jsx(me,{variant:"outlined",color:"warning",onClick:p(z),disabled:!S,children:s("oauth.runTest")}),e.jsx(me,{type:"submit",variant:"contained",disabled:!i.isDirty,children:s("oauth.save")})]})]}),o]})}const As=ue(ht)``,ft=[{label:e.jsx(T,{textAlign:"center",width:"100%",children:"Email"}),value:"email"},{label:e.jsx(T,{textAlign:"center",width:"100%",children:"Push Kit"}),value:"pushKit"}];function Ds(){const[n,t]=C.useState(ft[0].value),{locale:s}=C.useContext(ss),r=ce(()=>({email:e.jsx(Es,{}),pushKit:e.jsx(Os,{})}),[s]),o=C.useMemo(()=>({padding:"10px 0"}),[]);return e.jsxs(T,{children:[e.jsx(wt,{tabs:ft,current:n,onChange:t}),e.jsx(T,{style:o,children:r[n]})]})}const Pt=C.createContext({}),{Provider:Ls,Consumer:si}=Pt;function Ps({children:n,blocklet:t=""}){const{api:s,inService:r,ws:{useSubscription:o}}=Ze(),[l,y]=C.useState([]),[p,h]=C.useState({total:0,pageSize:20,pageCount:0,page:1}),i=ce(()=>{var c;return(c=t.meta)==null?void 0:c.did},[t]),[O,A]=C.useState([]),[R,S]=C.useState({}),D=ce(()=>l.length?new Set(l.map(c=>c.id)):new Set,[l]),Y=async({page:c=1,pageSize:g=20,...j}={})=>{if(!i)return[];try{const N={paging:{page:c,pageSize:g},...j,teamDid:i,dateRange:j.dateRange?[se(j.dateRange[0]).toISOString(),se(j.dateRange[1]).toISOString()]:void 0},{dids:E,...P}=N;let a="";E&&E.includes("system")&&(a="system");const m=E?E.filter(oe=>oe!=="system"):[],$={...P,source:a,componentDids:m},U=await s.getNotificationSendLog({input:$});return S($),y(U.list),h(U.paging),U.list}catch(N){return q.error(N.message),[]}},z=async()=>{const c=await s.getNotificationComponents({input:{teamDid:i}});A(c.componentDids)},B=C.useCallback(c=>{const g=t.children.find(j=>{var N;return((N=j.meta)==null?void 0:N.did)===c});if(g)return g.ancestors=[t],g},[t]),_=async({notificationId:c,receivers:g,channels:j,...N})=>{await s.resendNotification({input:{teamDid:i,notificationId:c,receivers:g,channels:j.map(E=>E==="wallet"?W.NOTIFICATION_SEND_CHANNEL.WALLET:E==="pushKit"?W.NOTIFICATION_SEND_CHANNEL.PUSH:E),...N}})},M=C.useCallback(async c=>(await s.getUser({input:{teamDid:i,user:{did:c}}})).user,[s,i]),J=C.useCallback(async({page:c=1,pageSize:g=20,...j}={})=>{try{const N={paging:{page:c,pageSize:g},...j,userName:j.searchText||"",teamDid:i,dateRange:j.dateRange?[se(j.dateRange[0]).toISOString(),se(j.dateRange[1]).toISOString()]:void 0};return await s.getReceivers({input:N})}catch(N){throw q.error(N.message),N}},[s,i]);C.useEffect(()=>{i&&z()},[i]),o(W.EVENTS.NOTIFICATION_BLOCKLET_UPDATE,c=>{D.has(c.notificationId)&&Y(R)},[D,R]),o(W.EVENTS.NOTIFICATION_BLOCKLET_CREATE,c=>{D.has(c.id)||Y(R)},[D,R]);const ie={fetch:Y,data:l,paging:p,blocklet:t,getComponent:B,resendNotification:_,getUser:M,componentDids:O,getReceivers:J,inService:r,teamDid:i};return e.jsx(Ls,{value:{notificationRecords:ie},children:n})}function tt(){const{notificationRecords:n}=C.useContext(Pt);return n}Ne.propTypes={severity:x.oneOf(Object.values(["info","success","error","warning"])).isRequired};const _s={info:"primary",success:"success",error:"error",warning:"warning"};function Ne({severity:n="info"}){return e.jsx(ns,{type:_s[n],children:n})}var st={},ks=Je;Object.defineProperty(st,"__esModule",{value:!0});var _t=st.default=void 0,Fs=ks(Qe()),Bs=e;_t=st.default=(0,Fs.default)((0,Bs.jsx)("path",{d:"M16.59 7.58 10 14.17l-3.59-3.58L5 12l5 5 8-8zM12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2m0 18c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8"}),"CheckCircleOutline");var nt={},zs=Je;Object.defineProperty(nt,"__esModule",{value:!0});var kt=nt.default=void 0,Ws=zs(Qe()),Ks=e;kt=nt.default=(0,Ws.default)((0,Ks.jsx)("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2M4 12c0-4.42 3.58-8 8-8 1.85 0 3.55.63 4.9 1.69L5.69 16.9C4.63 15.55 4 13.85 4 12m8 8c-1.85 0-3.55-.63-4.9-1.69L18.31 7.1C19.37 8.45 20 10.15 20 12c0 4.42-3.58 8-8 8"}),"Block");var it={},qs=Je;Object.defineProperty(it,"__esModule",{value:!0});var Ft=it.default=void 0,Ms=qs(Qe()),$s=e;Ft=it.default=(0,Ms.default)((0,$s.jsx)("path",{d:"M17.65 6.35C16.2 4.9 14.21 4 12 4c-4.42 0-7.99 3.58-7.99 8s3.57 8 7.99 8c3.73 0 6.84-2.55 7.73-6h-2.08c-.82 2.33-3.04 4-5.65 4-3.31 0-6-2.69-6-6s2.69-6 6-6c1.66 0 3.14.69 4.22 1.78L13 11h7V4z"}),"Refresh");const Us=(n,t,s="")=>{if(!s||!t)return"";switch(s){case W.NOTIFICATION_SEND_FAILED_REASON.USER_DISABLED:return n("notification.sendStatus.reason.disabled",{channel:t});case W.NOTIFICATION_SEND_FAILED_REASON.CHANNEL_UNAVAILABLE:return n("notification.sendStatus.reason.unavailable",{channel:t});case W.NOTIFICATION_SEND_FAILED_REASON.CHANNEL_DISABLED:return n("notification.sendStatus.reason.notSent",{channel:t});case W.NOTIFICATION_SEND_FAILED_REASON.NOT_ONLINE:return n("notification.sendStatus.reason.offline");default:return s}};function Bt(n,t,s={}){const{status:r,updatedAt:o,reason:l="",channel:y="wallet"}=s,p=o?n("notification.sendStatus.sentTime",{date:os(o,t)}):"",h=Us(n,y,l);return r===W.NOTIFICATION_SEND_STATUS.FAILED?{status:"failed",title:n("notification.sendStatus.failed"),sentTime:p,reason:h}:r===W.NOTIFICATION_SEND_STATUS.SENT?{status:"success",title:n("notification.sendStatus.success"),sentTime:p}:{status:"pending",title:n("notification.sendStatus.pending"),reason:h,sentTime:p}}const Ge={pending:"#aaaaaa",success:"#34BE74",failed:"#D0021B"},Ye=["wallet","pushKit","email"],mt=["info","success","error","warning"],zt=n=>{var s,r;const{settings:t}=n;return(r=(s=t==null?void 0:t.notification)==null?void 0:s.email)==null?void 0:r.enabled},Wt=n=>{var s,r;const{settings:t}=n;return(r=(s=t==null?void 0:t.notification)==null?void 0:s.pushKit)==null?void 0:r.enabled},Hs=(n,t)=>{const s=fe(t,"extra.notifications.email",!0);return{available:zt(n),enabled:s}},Vs=(n,t)=>{const s=fe(t,"extra.notifications.push",!0);return{available:Wt(n),enabled:s}},Gs=n=>({enabled:fe(n,"extra.notifications.wallet",!0)}),Ys=n=>({enabled:fe(n,"extra.webhooks",[]).length>0}),Ee=(n=3)=>new Promise(t=>{setTimeout(()=>{t()},n*1e3)}),Js=(n,t)=>t==="wallet"||t==="webhook"?[{channel:t,type:"enabled",pass:n("notification.sendStatus.reason.enabled",{channel:t}),fail:n("notification.sendStatus.reason.disabled",{channel:t})}]:t==="pushKit"||t==="email"?[{channel:t,type:"available",pass:n("notification.sendStatus.reason.available",{channel:t}),fail:n("notification.sendStatus.reason.unavailable",{channel:t})},{channel:t,type:"enabled",pass:n("notification.sendStatus.reason.enabled",{channel:t}),fail:n("notification.sendStatus.reason.disabled",{channel:t})}]:[],Ie=(n=[])=>{const t=se().startOf("day");return n.filter(s=>se(s.sendAt).isSame(t,"day")).length},Xs=(n,t="")=>{if(t&&Ye.includes(t)){const l=`${t}SendRecord`,y=fe(n,l,[]);return Ie(y)}const s=fe(n,"webhook",{}),r=Object.keys(s??{})??[];if(t&&r.includes(t)){const l=s[t]??[];return Ie(l)}const o={};return Ye.forEach(l=>{const y=`${l}SendRecord`,p=fe(n,y,[]),h=Ie(p);o[l]=h}),r.length>0&&r.forEach(l=>{const y=s[l]??[],p=Ie(y);o[l]=p}),o},Ae=(n,t,s)=>{if(!Array.isArray(n))throw new Error("Invalid filterList or index");return n[s].splice(t,1),n},De=(n,t)=>{if(!Array.isArray(t))throw new Error("filters must be an array");return t.length?!t.includes(n):!1},Qs=n=>{switch(n){case W.NOTIFICATION_SEND_CHANNEL.WALLET:return"Wallet";case W.NOTIFICATION_SEND_CHANNEL.PUSH:return"Push Kit";case W.NOTIFICATION_SEND_CHANNEL.EMAIL:return"Email";case W.NOTIFICATION_SEND_CHANNEL.WEBHOOK:return"Webhook";default:return""}},Kt=()=>({components:{MUIDataTableFilter:{styleOverrides:{header:{marginBottom:0,p:{margin:0}},root:{"& .MuiGrid-container":{marginTop:0,"& .MuiGrid-item":{paddingTop:0}}}}},MuiPopover:{styleOverrides:{root:{"&.MuiPopover-root":{"& .MuiPaper-root:has(.filter-container)":{width:"420px"}}}}}}});function de({config:n,enableTooltip:t=!0,showTitle:s=!1,children:r}){const{status:o,title:l="",sentTime:y="",reason:p=""}=n,h=[l,p].filter(Boolean).join(", ");return e.jsx(xt,{title:t?e.jsxs(e.Fragment,{children:[e.jsx(ae,{color:"inherit",sx:{fontSize:12},children:h}),e.jsx("span",{children:y})]}):null,arrow:!0,placement:"top",children:e.jsxs(T,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"4px"},children:[e.jsxs(T,{position:"relative",minHeight:14,minWidth:14,display:"flex",alignItems:"center",justifyContent:"center",children:[e.jsx(T,{position:"absolute",width:"100%",height:"100%",borderRadius:"50%",bgcolor:Ge[o],style:{opacity:.15}}),e.jsx(T,{position:"absolute",width:"55%",height:"55%",borderRadius:"50%",bgcolor:Ge[o]})]}),e.jsx(ae,{color:"inherit",sx:{fontSize:12},children:s?l:r})]})})}de.propTypes={config:x.object.isRequired,enableTooltip:x.bool,showTitle:x.bool,children:x.node};de.defaultProps={enableTooltip:!0,showTitle:!1,children:null};Se.propTypes={list:x.array.isRequired,label:x.string.isRequired,onDelete:x.func};Se.defaultProps={onDelete:()=>{}};function Se({list:n,label:t,onDelete:s}){const{t:r,locale:o}=re();return e.jsxs(T,{display:"flex",gap:1,alignItems:"center",children:[e.jsxs(ae,{children:[t,": "]}),n.map(l=>{const y=Bt(r,o,{status:l});return e.jsx(Xe,{size:"small",label:e.jsx(T,{display:"flex",alignItems:"center",sx:{gap:"4px"},children:e.jsx(de,{config:y,enableTooltip:!1,children:y.title})}),onDelete:p=>s(p,l)},l)})]})}at.propTypes={filterList:x.array.isRequired,onChange:x.func.isRequired,index:x.number.isRequired,column:x.object.isRequired,filterValues:x.array.isRequired,label:x.string.isRequired,renderLabel:x.func.isRequired};function at({filterList:n,onChange:t,index:s,column:r,filterValues:o,label:l,renderLabel:y}){return e.jsxs(G,{className:"filter-container",children:[e.jsx(gt,{component:"legend",children:l}),e.jsx(Ke,{row:!0,children:o.map(p=>e.jsx(ge,{control:e.jsx(qe,{checked:n[s].indexOf(p.value??p)>-1,onChange:h=>{const i=[...n];h.target.checked?i[s]=[...i[s],p.value??p]:i[s]=i[s].filter(O=>O!==(p.value??p)),t(i[s],s,r)},name:p.value??p}),label:e.jsx("span",{style:{display:"flex",alignItems:"center"},children:y(p)})},p.value??p))})]})}function ze(n){return e.jsx(at,{...n,renderLabel:t=>e.jsx(de,{enableTooltip:!1,config:{status:t.status},children:t.label})})}ve.propTypes={status:x.number.isRequired,updatedAt:x.string.isRequired,reason:x.string,channel:x.string,onResend:x.func};function ve({status:n,updatedAt:t,reason:s="",channel:r="wallet",onResend:o}){const{t:l,locale:y}=re(),p=Bt(l,y,{status:n,updatedAt:t,reason:s,channel:r});return e.jsxs(T,{display:"flex",alignItems:"center",gap:1,children:[e.jsx(de,{config:p,showTitle:!0}),p.status!=="success"&&e.jsx(Le,{className:"resend-btn",size:"small",startIcon:e.jsx(et,{}),sx:{fontSize:12,color:"rgba(0, 0, 0, 0.87)",fontWeight:400,".MuiButton-startIcon":{mr:"2px"}},onClick:o,children:l("notification.resend")})]})}rt.propTypes={value:x.array.isRequired,onChange:x.func};function rt({value:n,onChange:t}){const{locale:s}=re(),r=se().toDate(),[o,l]=C.useState(null),y=C.useCallback(i=>{l(o?null:i.currentTarget)},[o]),p=!!o,h=C.useCallback(i=>{if(!i.startDate||!i.endDate){q.error("Please select a date range");return}if(se(i.startDate).isAfter(i.endDate)||!se(i.startDate).isValid()||!se(i.endDate).isValid()){q.error("Invalid date range");return}t([i.startDate,i.endDate]),l(null)},[t]);return e.jsxs("div",{children:[e.jsx(ae,{component:"div",variant:"h5",color:"textPrimary",style:{fontSize:18,fontWeight:"bold"},mb:0,children:e.jsxs(Le,{onClick:y,variant:"outlined",size:"small",color:"inherit",children:[pt(n[0],s)," - ",pt(n[1],s)]})}),e.jsx(Me,{open:p,anchorEl:o,onClose:()=>{l(null)},anchorOrigin:{vertical:"bottom",horizontal:"left"},children:e.jsx(ys,{open:!0,maxDate:r,initialDateRange:{startDate:n[0],endDate:n[1]},toggle:y,definedRanges:Ss(r),onChange:h})})]})}ot.propTypes={itemComponent:x.elementType.isRequired};function ot({itemComponent:n,...t}){var o;const{t:s}=re();return!((o=t==null?void 0:t.filterList)!=null&&o.filter(l=>l.length).length)?null:e.jsxs(T,{display:"flex",gap:1,alignItems:"center",children:[e.jsx("div",{className:"toolbar-filter-title",children:s("notification.filter")}),e.jsx("div",{className:"toolbar-filter-content",children:e.jsx(is.TableFilterList,{...t,ItemComponent:n})})]})}function Pe({label:n,onDelete:t,canDelete:s=()=>!0,...r}){const o=t&&typeof t=="function"?t:void 0;let l=!0;return s&&typeof s=="function"&&(l=s({label:n,...r})),e.jsx(Xe,{label:n,variant:"outlined",...o&&l?{onDelete:o}:{}})}Pe.propTypes={label:x.string.isRequired,onDelete:x.func,canDelete:x.func};Pe.defaultProps={canDelete:()=>!0};const Zs=[{label:"Wallet",value:"app",checked:!0},{label:"Email",value:"email",checked:!0},{label:"Push Kit",value:"push",checked:!0},{label:"Webhook",value:"webhook",checked:!0}];lt.propTypes={loading:x.bool,onCancel:x.func,onConfirm:x.func};lt.defaultProps={loading:!1,onCancel:()=>{},onConfirm:()=>{}};function lt({loading:n=!1,onCancel:t,onConfirm:s}){const{t:r}=re(),[o,l]=C.useState(Zs),[y,p]=C.useState(!0),h=(O,A)=>{A.checked=O.target.checked;const R=o.map(S=>({...S,checked:S.value===A.value?A.checked:S.checked}));l(R)},i=O=>{O.stopPropagation(),s({channels:o.filter(A=>A.checked).map(A=>A.value),isResendFailedOnly:y})};return e.jsxs(T,{className:"resend-config",sx:{padding:"16px 24px"},children:[e.jsx(ae,{variant:"body1",component:"div",className:"check-title",sx:{fontWeight:700,mb:1},children:r("notification.config")}),e.jsx(T,{className:"choose-channel",children:e.jsxs(G,{component:"fieldset",variant:"standard",children:[e.jsx(gt,{component:"legend",children:r("notification.selectChannels")}),e.jsx(Ke,{sx:{display:"flex",flexDirection:"row",flexWrap:"wrap",gap:1},children:o.map(O=>e.jsx(ge,{control:e.jsx(qe,{checked:O.checked,onChange:A=>h(A,O),name:O.value}),label:O.label},O.value))})]})}),e.jsx(T,{className:"resend-config-footer",children:e.jsx(Ke,{children:e.jsx(ge,{control:e.jsx(qe,{checked:y,onChange:O=>p(O.target.checked)}),label:r("notification.resendFailedOnly")})})}),e.jsxs(T,{display:"flex",justifyContent:"flex-end",gap:1,className:"resend-config-footer-tip",children:[e.jsx(Le,{onClick:O=>{O.stopPropagation(),t()},color:"inherit",children:r("common.cancel")}),e.jsxs(Le,{onClick:i,color:"primary",disabled:n,variant:"contained",autoFocus:!0,style:{marginLeft:8},children:[n&&e.jsx(bt,{size:16}),r("common.confirm")]})]})]})}qt.propTypes={notificationId:x.string.isRequired,handleResend:x.func,resending:x.bool};function qt({notificationId:n,handleResend:t,resending:s=!1}){const{t:r,locale:o}=re(),l=jt(),y=C.useMemo(()=>vt(l,Kt()),[l]),{getReceivers:p,inService:h,teamDid:i,getUser:O,blocklet:A}=tt(),[R,S]=C.useState(!1),[D,Y]=C.useState([]),z=Te({anchorEl:null,position:null}),B=Te({anchorEl:null,position:null}),[_,M]=C.useState(null),[J,ie]=C.useState({total:0,pageSize:10,pageCount:0,page:1}),[c,g]=C.useState({searchText:"",page:1,pageSize:10,walletSendStatus:[],pushKitSendStatus:[],emailSendStatus:[],dateRange:[se().subtract(1,"month").startOf("day").toDate(),se().endOf("day").toDate()]}),[j,N]=C.useState([]),E=[{label:r("notification.sendStatus.pending"),value:0,status:"pending"},{label:r("notification.sendStatus.success"),value:1,status:"success"},{label:r("notification.sendStatus.failed"),value:2,status:"failed"}],P=async()=>{if(!R&&n)try{S(!0);const d=await p({notificationId:n,...c}),u=d.list.map(f=>({...f,receiverUser:{...f.receiverUser,avatar:Dt(f.receiverUser.avatar,i,h)}}));Y(u),ie(d.paging),S(!1)}catch(d){q.error(d.message),S(!1)}};C.useEffect(()=>{P()},[c]);const a=d=>{d.stopPropagation();const u=d.currentTarget;B.anchorEl=u;const f=u.getBoundingClientRect();B.position={top:f.top+window.scrollY,left:f.left+window.scrollX}},m=d=>d.data.length?e.jsx("div",{style:{display:"flex",alignItems:"center",padding:"10px"},children:e.jsx(me,{className:"resend-btn",size:"small",color:"primary",variant:"contained",startIcon:e.jsx(et,{}),sx:{".MuiButton-startIcon":{mr:"2px"}},onClick:a,children:r("notification.resend")})}):null,$={sort:!1,download:!1,print:!1,selectableRows:"multiple",searchPlaceholder:r("common.search"),searchAlwaysOpen:!1,filterType:"checkbox",searchDebounceTime:300,page:J.page-1,rowsPerPage:J.pageSize,count:J.total,searchText:c.searchText,tableBodyMaxHeight:"calc(80vh - 260px)",rowsSelected:j,onRowSelectionChange:(d,u)=>{N(u.map(f=>f.dataIndex))},customToolbarSelect:m},U=({page:d,rowsPerPage:u,searchText:f,filterList:L})=>{const[,K=[],Z=[],X=[]]=L;c.pageSize!==u?g(H=>({...H,pageSize:u,page:1})):c.page!==d+1?g(H=>({...H,page:d+1})):c.searchText!==f?g(H=>({...H,searchText:f,page:1})):ye(K,c.walletSendStatus)?ye(Z,c.pushKitSendStatus)?ye(X,c.emailSendStatus)||g(H=>({...H,emailSendStatus:X,page:1})):g(H=>({...H,pushKitSendStatus:Z,page:1})):g(H=>({...H,walletSendStatus:K,page:1}))},oe=C.useCallback(async(d,u)=>{if(!u)return!1;const f=await O(u);return f?d==="wallet"?Gs(f):d==="email"?Hs(A,f):d==="pushKit"?Vs(A,f):d==="webhook"?Ys(f):!0:!1},[O,A]),le=C.useCallback(d=>Js(r,d),[r]),pe=()=>{z.anchorEl=null,z.position=null,M(null)},be=()=>{B.anchorEl=null,B.position=null},je=async(d,u,f=!0,L="")=>{if(!(!u.length||!d.length))try{t(d,u,f,L),B.anchorEl||(await Ee(.5),pe())}catch(K){console.error("handleResend error",{error:K})}},v=async({channels:d,isResendFailedOnly:u})=>{const f=j.map(L=>D[L].receiver);await je(d,f,u),await Ee(.5),be(),N([])},b=async(d,u=[],f=!0)=>{try{await je(["webhook"],[d.receiver],f,u)}catch(L){q.error(L.response?L.response.statusText:L.message)}},w=async(d,u,f,L=[],K=!0)=>{if(d.stopPropagation(),Xs(u,f)>=4){q.warning(r("notification.resendLimit"));return}if(!Ye.includes(f)){await b(u,L,K);return}if(d){const X=d.currentTarget,H=X.getBoundingClientRect();z.anchorEl=X,z.position={top:H.top+window.scrollY,left:H.left+window.scrollX}}M({channel:f});try{const X=await oe(f,u.receiver);await Ee(1),M({channel:f,result:X}),(typeof X=="boolean"&&X||Zt(X)&&Object.values(X).every(H=>!!H))&&(await t([f],[u.receiver],K),B.anchorEl||(await Ee(.5),pe()))}catch(X){q.error(X.message)}},I=d=>{g(u=>({...u,dateRange:d,page:1}))},k=(d,u,f,L)=>{d.stopPropagation();const K=f.filter(Z=>Z!==u);g(Z=>({...Z,[L]:K,page:1}))},F=ce(()=>[{label:r("notification.receiver"),name:"receiver",width:200,options:{filter:!1,customBodyRenderLite:d=>{const{receiverUser:u,receiver:f}=D[d];return u?e.jsxs(T,{"data-cy":`member-name-${u.fullName}`,display:"flex",alignItems:"center",gap:1,justifyContent:"flex-start",children:[e.jsx(Tt,{src:`${u.avatar}?imageFilter=resize&w=48&h=48`,size:32,did:f,shape:"circle",style:{borderRadius:"100%",overflow:"hidden"}}),e.jsx(Re,{children:u.fullName})]},f):e.jsx(vs,{size:14,responsive:!1,compact:!0,copyable:!1,did:f})}}},{label:"Wallet",name:"walletSendStatus",width:200,options:{setCellProps:()=>({className:"sent-status-cell"}),filter:!0,filterType:"custom",filterList:c.walletSendStatus??[],customFilterListOptions:{render:d=>e.jsx(Se,{list:d,label:"Wallet",onDelete:(u,f)=>{u.stopPropagation(),k(u,f,F[1].options.filterList,"walletSendStatus")}}),update:Ae},filterOptions:{names:E,fullWidth:!0,logic:De,display:(d,u,f,L)=>e.jsx(ze,{label:"Wallet",filterList:d,onChange:u,index:f,column:L,filterValues:E})},customBodyRenderLite:d=>{const{walletSendStatus:u,walletSendAt:f,walletSendFailedReason:L}=D[d];return e.jsx(ve,{status:u,updatedAt:f,reason:L,channel:"wallet",onResend:K=>w(K,D[d],"wallet",[],!1)})}}},{label:"Push Kit",name:"pushKitSendStatus",width:200,options:{setCellProps:()=>({className:"sent-status-cell"}),customBodyRenderLite:d=>{const{pushKitSendStatus:u,pushKitSendAt:f,pushKitSendFailedReason:L}=D[d];return e.jsx(ve,{status:u,updatedAt:f,reason:L,channel:"pushkit",onResend:K=>w(K,D[d],"pushKit",[],!1)})},filter:!0,filterType:"custom",filterList:c.pushKitSendStatus??[],customFilterListOptions:{render:d=>e.jsx(Se,{list:d,label:"Push Kit",onDelete:(u,f)=>{u.stopPropagation(),k(u,f,F[2].options.filterList,"pushKitSendStatus")}}),update:Ae},filterOptions:{names:E,fullWidth:!0,logic:De,display:(d,u,f,L)=>e.jsx(ze,{label:"Push Kit",filterList:d,onChange:u,index:f,column:L,filterValues:E})}}},{label:"Email",name:"emailSendStatus",width:200,options:{setCellProps:()=>({className:"sent-status-cell"}),customBodyRenderLite:d=>{const{emailSendStatus:u,emailSendAt:f,emailSendFailedReason:L}=D[d];return e.jsx(ve,{status:u,updatedAt:f,reason:L,channel:"email",onResend:K=>w(K,D[d],"email",[],!1)})},filter:!0,filterType:"custom",filterList:c.emailSendStatus??[],customFilterListOptions:{render:d=>e.jsx(Se,{list:d,label:"Email",onDelete:(u,f)=>{u.stopPropagation(),k(u,f,F[3].options.filterList,"emailSendStatus")}}),update:Ae},filterOptions:{names:E,fullWidth:!0,logic:De,display:(d,u,f,L)=>e.jsx(ze,{label:"Email",filterList:d,onChange:u,index:f,column:L,filterValues:E})}}},{label:"Webhook",name:"webhook",width:200,options:{filter:!1,setCellProps:()=>({className:"sent-status-cell"}),customBodyRenderLite:d=>{const{webhook:u}=D[d];if(!u)return null;const f=Object.entries(u)[0];if(!f)return null;const[L,K]=f,Z=K[0];return e.jsx(T,{display:"flex",flexDirection:"column",gap:1,children:e.jsxs(T,{className:"webhook-item",fontSize:12,children:[e.jsx(Re,{maxLength:30,children:L},L),e.jsx(ve,{status:Z.status,updatedAt:Z.sendAt,reason:Z.failedReason,channel:"webhook",onResend:X=>w(X,D[d],"webhook",[L],!1)})]},L)})}}},{label:r("common.createdAt"),name:"createdAt",width:100,options:{filter:!1,customBodyRenderLite:d=>{const{createdAt:u}=D[d];return e.jsx(At,{value:u,locale:o,shouldUpdate:!0})}}}],[D,o,c,r]),ne=[e.jsx(rt,{value:c.dateRange,onChange:I},"date-picker"),e.jsx(me,{variant:"contained",size:"small",color:"primary",loading:R,startIcon:e.jsx(Ft,{}),onClick:()=>P(),sx:{".MuiButton-startIcon":{mr:"2px"}},style:{marginLeft:8},children:r("common.refresh")},"refresh")];return e.jsx(T,{sx:{overflow:"auto",".MuiTableCell-head":{whiteSpace:"nowrap",fontWeight:"bold"},".MuiTableCell-root":{paddingRight:"8px",whiteSpace:"nowrap"}},children:e.jsx(tn,{children:e.jsxs(yt,{theme:y,children:[e.jsx(Rt,{className:"receivers-table",locale:o,loading:R,columns:F,data:D,onChange:U,options:$,customButtons:ne,components:{TableFilterList:d=>e.jsx(ot,{...d,itemComponent:u=>e.jsx(Pe,{...u,canDelete:()=>!1})})}}),z.anchorEl&&e.jsx(Me,{open:!!z.anchorEl,anchorReference:"anchorPosition",anchorPosition:z.position,onClose:pe,anchorOrigin:{vertical:"center",horizontal:"right"},transformOrigin:{vertical:"center",horizontal:"left"},children:e.jsxs(sn,{children:[e.jsxs(ae,{variant:"body1",component:"div",className:"check-title",children:[_==null?void 0:_.channel," Checking"]}),e.jsx(T,{display:"flex",flexDirection:"column",sx:{gap:"4px"},children:le(_==null?void 0:_.channel).map(d=>{var K,Z;const{type:u,pass:f,fail:L}=d;return!(_!=null&&_.result)||(K=_==null?void 0:_.result)!=null&&K[u]?e.jsxs(ae,{variant:"body1",component:"div",className:"check-item",display:"flex",alignItems:"center",sx:{gap:"4px",color:(Z=_==null?void 0:_.result)!=null&&Z[u]?Oe.success.main:"inherit"},children:[_!=null&&_.result?e.jsx(_t,{}):e.jsx(bt,{size:12,sx:{color:Oe.primary.main}}),e.jsx("span",{children:f})]},u):e.jsxs(ae,{variant:"body1",component:"div",display:"flex",alignItems:"center",className:"check-item",sx:{gap:"4px",color:Oe.error.main},children:[e.jsx(kt,{}),e.jsx("span",{children:L})]},u)})})]})}),B.anchorEl&&e.jsx(Me,{open:!!B.anchorEl,anchorReference:"anchorPosition",anchorPosition:B.position,onClose:be,anchorOrigin:{vertical:"center",horizontal:"right"},transformOrigin:{vertical:"center",horizontal:"left"},children:e.jsx(lt,{loading:s,onCancel:be,onConfirm:v})})]})})})}const en=C.memo(qt),tn=ue.div`
|
|
2
2
|
td.MuiTableCell-footer {
|
|
3
3
|
border: none !important;
|
|
4
4
|
}
|