@abtnode/blocklet-services 1.16.42-beta-20250415-222652-04c5d2fe → 1.16.42-beta-20250416-010627-a89e72e0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (135) hide show
  1. package/dist/assets/{AdapterDayjs-BLBXeg9J.js → AdapterDayjs-B7fWFwN5.js} +1 -1
  2. package/dist/assets/{ArrowDropDown--dAaadP8.js → ArrowDropDown-DO9H_COV.js} +1 -1
  3. package/dist/assets/{CheckCircle-Av1UotA-.js → CheckCircle-B_wWOO2P.js} +1 -1
  4. package/dist/assets/{ChevronLeft-De8Da-PB.js → ChevronLeft-BdrBCIFt.js} +1 -1
  5. package/dist/assets/{ChevronRight-CQOI2CyK.js → ChevronRight-CO9My6tF.js} +1 -1
  6. package/dist/assets/{DeleteOutline-Cgoi-K0i.js → DeleteOutline-7AloJjcV.js} +1 -1
  7. package/dist/assets/{Done-BYuUlh_s.js → Done-BXISjL2g.js} +1 -1
  8. package/dist/assets/{Download-DUKR_Wkm.js → Download-B0rKRcTB.js} +1 -1
  9. package/dist/assets/{Edit-D2RQMivt.js → Edit-C1mcIe4c.js} +1 -1
  10. package/dist/assets/{Error-By0ZMWzh.js → Error-BnWmSZ5k.js} +1 -1
  11. package/dist/assets/{ExpandLess-BNGLjxae.js → ExpandLess-DRlih5VO.js} +1 -1
  12. package/dist/assets/{Google-tZCjvU7D.js → Google-1eG1YH-u.js} +1 -1
  13. package/dist/assets/{InfoOutlined-DSoJjRQo.js → InfoOutlined-DO0_Vjz-.js} +1 -1
  14. package/dist/assets/{Launch-B161pSEw.js → Launch-CIC8rZgo.js} +1 -1
  15. package/dist/assets/{LaunchOutlined-wehxIahb.js → LaunchOutlined-CkYWJcA9.js} +1 -1
  16. package/dist/assets/{MoreHoriz-Bo_R2nuS.js → MoreHoriz-B8cBSV22.js} +1 -1
  17. package/dist/assets/{PlayArrow-D38lbyGo.js → PlayArrow-NjIpSDwJ.js} +1 -1
  18. package/dist/assets/{TuneOutlined-DMMtKa6E.js → TuneOutlined-Bry0vSC0.js} +1 -1
  19. package/dist/assets/{ViewList-CMIoKrN6.js → ViewList-BzGRahvc.js} +1 -1
  20. package/dist/assets/{access-control-DLD9n3S7.js → access-control-7Ih10vY9.js} +1 -1
  21. package/dist/assets/{actions-CMsM02NP.js → actions-BOikuUJD.js} +1 -1
  22. package/dist/assets/{add-component-core-FnU4dwXM.js → add-component-core-DRJSzr-6.js} +1 -1
  23. package/dist/assets/{add-resource-CubCXHBS.js → add-resource-VgacdokL.js} +1 -1
  24. package/dist/assets/{addon-5JaI2ctX.js → addon-F4fsk4Yi.js} +1 -1
  25. package/dist/assets/{advanced-D4wfoh0v.js → advanced-a-1InjKG.js} +1 -1
  26. package/dist/assets/{appearance-BUsj4DWC.js → appearance-BWtF9DZd.js} +1 -1
  27. package/dist/assets/{audit-logs-rk_iUYcM.js → audit-logs-DqFf6jS-.js} +1 -1
  28. package/dist/assets/{authorize-CDJXjmiI.js → authorize-BKpxW7YW.js} +1 -1
  29. package/dist/assets/{base32-BhlNgZPk.js → base32-CQfYcymN.js} +1 -1
  30. package/dist/assets/{branding-BBbE2Klb.js → branding--Qk4aIi4.js} +1 -1
  31. package/dist/assets/{branding-JQ1914RB.js → branding-DoPxX3nU.js} +2 -2
  32. package/dist/assets/{bundle-avatar-woUZoGoi.js → bundle-avatar-DNxC8z4b.js} +1 -1
  33. package/dist/assets/{button-Rx3uHycr.js → button-leITu2bm.js} +1 -1
  34. package/dist/assets/{click-to-copy-BxZJa7n5.js → click-to-copy-Cygm8U3_.js} +1 -1
  35. package/dist/assets/{complete-KnPBZq-P.js → complete-Cnzbqj4O.js} +1 -1
  36. package/dist/assets/{component-fD-EGTLm.js → component-BBRNk4Tr.js} +1 -1
  37. package/dist/assets/{config-8xeoVfWN.js → config-Ba-WdcGO.js} +1 -1
  38. package/dist/assets/{config-DbqQgRSU.js → config-Dko9yBri.js} +1 -1
  39. package/dist/assets/{config-navigation-DrgPbe5I.js → config-navigation-CDw3CW3J.js} +3 -3
  40. package/dist/assets/{config-space-DZ9w_4_9.js → config-space-CSSDG-WO.js} +1 -1
  41. package/dist/assets/{confirm-_RIb3OmR.js → confirm-BX8_-j-l.js} +1 -1
  42. package/dist/assets/{connect-CPIImVme.js → connect-ByA6PdRd.js} +1 -1
  43. package/dist/assets/connect-DBfZH_8M.js +5 -0
  44. package/dist/assets/{connect-to-BdhN0BHi.js → connect-to-yIsMDJbM.js} +1 -1
  45. package/dist/assets/{dashboard-vsk4QHJ1.js → dashboard-oxsbu66O.js} +3 -3
  46. package/dist/assets/{delete-confirm-DaoAi4Gz.js → delete-confirm-C0cAQSXq.js} +1 -1
  47. package/dist/assets/{did-address-CGHn52xI.js → did-address-GAxLGeWB.js} +1 -1
  48. package/dist/assets/domain-BB7h2xMD.js +9 -0
  49. package/dist/assets/{domain-action-card-9r42-rWK.js → domain-action-card-BKzC5bbv.js} +2 -2
  50. package/dist/assets/domains-CQPZJx98.js +1 -0
  51. package/dist/assets/{email-fp1LVcF6.js → email-B9kMynU0.js} +1 -1
  52. package/dist/assets/{exchange-passport-DIyhYtFS.js → exchange-passport-CgO3iLVh.js} +1 -1
  53. package/dist/assets/{fuel-aGwI1uP2.js → fuel-C6fpJHcg.js} +1 -1
  54. package/dist/assets/{gen-access-key-DMS1kzry.js → gen-access-key-jNw5st5h.js} +1 -1
  55. package/dist/assets/{get-safe-url-DMordnyN.js → get-safe-url-CRmmLBFf.js} +1 -1
  56. package/dist/assets/{get-safe-url-DW2Z07ex.js → get-safe-url-ZRaKUVld.js} +1 -1
  57. package/dist/assets/{home-B_gUzcjU.js → home-AJ00GuT0.js} +1 -1
  58. package/dist/assets/{iframe-BEanRyio.js → iframe-C4N_8Wwh.js} +1 -1
  59. package/dist/assets/{index-BjN8LAYh.js → index-8Co4tmLR.js} +4 -4
  60. package/dist/assets/{index-DbpVrp8z.js → index-B5bNvBjf.js} +1 -1
  61. package/dist/assets/{index-D22lazSG.js → index-B64a4BbE.js} +3 -3
  62. package/dist/assets/{index-D2EAXstd.js → index-BP62CTBB.js} +1 -1
  63. package/dist/assets/{index-D22ZWGxu.js → index-BRz2myBK.js} +1 -1
  64. package/dist/assets/{index-D_gSWW1P.js → index-BS5tohCn.js} +1 -1
  65. package/dist/assets/{index-C0hr4pkt.js → index-BSlpaPEE.js} +1 -1
  66. package/dist/assets/{index-DUQK_NaI.js → index-C1H5SEVx.js} +1 -1
  67. package/dist/assets/{index-CbW18ndN.js → index-CNl-IhR2.js} +1 -1
  68. package/dist/assets/{index-CFJtmMCn.js → index-Cv9H4C1K.js} +1 -1
  69. package/dist/assets/{index-BmexzVQt.js → index-CyBxUW5e.js} +1 -1
  70. package/dist/assets/{index-4rY7Xp2W.js → index-D6v3bOtJ.js} +1 -1
  71. package/dist/assets/{index-xa5W6ExD.js → index-DIckhHU5.js} +1 -1
  72. package/dist/assets/{index-CcjD0qiY.js → index-DKLLCs8G.js} +1 -1
  73. package/dist/assets/{index-DBZZ-U66.js → index-Dc-Oeqo9.js} +1 -1
  74. package/dist/assets/{index-CFkRKsyT.js → index-DyO7bYXp.js} +1 -1
  75. package/dist/assets/{index-BDNlzmD0.js → index-EBUaBME3.js} +1 -1
  76. package/dist/assets/{index-AhbLOD9c.js → index-PfRsNX8F.js} +1 -1
  77. package/dist/assets/{index-BPa_QtWl.js → index-tjRN_EVx.js} +3 -3
  78. package/dist/assets/{invitation-D-l4US6a.js → invitation-DVbBeS8B.js} +1 -1
  79. package/dist/assets/{invite-DPswrm4J.js → invite-t8rB5ZWZ.js} +1 -1
  80. package/dist/assets/{issue-passport-AJghkFHK.js → issue-passport-CSlA5ioP.js} +1 -1
  81. package/dist/assets/{item-zk7clNKz.js → item--dgEgBvz.js} +1 -1
  82. package/dist/assets/{landing-page-D13wALfk.js → landing-page-aHOyrHWC.js} +1 -1
  83. package/dist/assets/{layout-aS-gjZH3.js → layout-B4YOjaNK.js} +1 -1
  84. package/dist/assets/{list-CJt5nOcn.js → list-Bny5F0T2.js} +1 -1
  85. package/dist/assets/localization-DS_PbFVL.js +1 -0
  86. package/dist/assets/{log-DFaz-U9x.js → log-CP1_Zl5R.js} +1 -1
  87. package/dist/assets/{logger-DXlQ8ejK.js → logger-B9-TWjbH.js} +1 -1
  88. package/dist/assets/{login-DKSu0ge6.js → login-C8k7kmim.js} +1 -1
  89. package/dist/assets/{login-oauth-callback-CP7cNspN.js → login-oauth-callback-DqejBHsA.js} +1 -1
  90. package/dist/assets/{logo-uploader-B7i5QemW.js → logo-uploader-zhddoC5p.js} +3 -3
  91. package/dist/assets/{lost-passport-QRUn4RXe.js → lost-passport-Croi_0xR.js} +1 -1
  92. package/dist/assets/{open-window-B6LZyZAW.js → open-window-plauGxNl.js} +1 -1
  93. package/dist/assets/{overview-B3A_5sHO.js → overview-C8MR_9r7.js} +1 -1
  94. package/dist/assets/{page-header-DUh_2MUQ.js → page-header-Cu9lHawO.js} +1 -1
  95. package/dist/assets/{passport-item-BY6VS7Ot.js → passport-item-DDktLU4q.js} +1 -1
  96. package/dist/assets/{permission-DKFJEWNH.js → permission-C5Df-sxb.js} +1 -1
  97. package/dist/assets/{preferences-CA76rfbp.js → preferences-BUVHMy7R.js} +1 -1
  98. package/dist/assets/{profile-embed-DHFHXO1W.js → profile-embed-BKX2YBaX.js} +1 -1
  99. package/dist/assets/{publish-resource-rxvf6s83.js → publish-resource-tDbEc2CN.js} +1 -1
  100. package/dist/assets/{react-beautiful-dnd.esm-D0nBCaor.js → react-beautiful-dnd.esm-BQ3hEDNY.js} +1 -1
  101. package/dist/assets/{relative-time-BK3hjJNN.js → relative-time-DESntOZH.js} +1 -1
  102. package/dist/assets/{runtime-D_bXZ0w0.js → runtime-8Gq50HDL.js} +1 -1
  103. package/dist/assets/sdk-DRKovxXZ.js +1 -0
  104. package/dist/assets/{security-DEmFjZiu.js → security-CRd92J54.js} +1 -1
  105. package/dist/assets/{session-DB9Du-lc.js → session-DaQ4KCFD.js} +1 -1
  106. package/dist/assets/setup-DXwqTfxV.js +19 -0
  107. package/dist/assets/{spaces-25E9GQ6_.js → spaces-D1rqZVaX.js} +1 -1
  108. package/dist/assets/{start-DfEUlPuS.js → start-Df0wvo1-.js} +1 -1
  109. package/dist/assets/{status-CUyAteC9.js → status-D7e11K9q.js} +1 -1
  110. package/dist/assets/{step-actions-CAgwlOEY.js → step-actions-BAf7tRyq.js} +1 -1
  111. package/dist/assets/{studio-2U2-FOOC.js → studio-CJpRZ6Af.js} +1 -1
  112. package/dist/assets/{switch-control-DwTxPESj.js → switch-control-DPANzJ8H.js} +1 -1
  113. package/dist/assets/{traffic-B94bYvtf.js → traffic-Brsh4OZD.js} +1 -1
  114. package/dist/assets/{transfer-DWjvJtPs.js → transfer-CBAuvpGA.js} +1 -1
  115. package/dist/assets/{unsubscribe-CTZlUfqc.js → unsubscribe-Cyuj6w2n.js} +1 -1
  116. package/dist/assets/useAsync-BmW5cnbx.js +1 -0
  117. package/dist/assets/useAsync-DkPaceIy.js +1 -0
  118. package/dist/assets/{useAsyncRetry-BBomZj1z.js → useAsyncRetry-k063P8TB.js} +2 -2
  119. package/dist/assets/{useLocalStorage-DKl7XFfI.js → useLocalStorage-BXnF_60k.js} +1 -1
  120. package/dist/assets/{user-center-Du6EtGgy.js → user-center-DOyIfHWq.js} +1 -1
  121. package/dist/assets/{util-BEvdQ5nP.js → util-C9b90o5T.js} +1 -1
  122. package/dist/assets/{util-DkIhTuT7.js → util-Csa0tyHO.js} +1 -1
  123. package/dist/assets/{vendor-arcblock-ACo-BN0q.js → vendor-arcblock-BtlDhznp.js} +1 -1
  124. package/dist/assets/{vendor-ux-did-connect-DOjsg91L.js → vendor-ux-did-connect-CiLSrCOH.js} +1 -1
  125. package/dist/assets/{wrap-locale-DjpRZNtr.js → wrap-locale--aKPMOdK.js} +1 -1
  126. package/dist/index.html +3 -3
  127. package/dist/service-worker.js +1 -1
  128. package/package.json +41 -42
  129. package/dist/assets/connect-CJOq1BXE.js +0 -5
  130. package/dist/assets/domain-BJUSWYGQ.js +0 -9
  131. package/dist/assets/domains-BNDFk-7R.js +0 -1
  132. package/dist/assets/localization-Us9buoy1.js +0 -1
  133. package/dist/assets/sdk-Hg_BMu_u.js +0 -1
  134. package/dist/assets/setup-kkb6SvQ7.js +0 -19
  135. package/dist/assets/useAsync-DKE0K0bz.js +0 -1
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-D22lazSG.js","assets/vendor-ux-did-connect-DOjsg91L.js","assets/vendor-react-DoD83n6N.js","assets/vendor-utils-CTIzdAFg.js","assets/vendor-mui-core-DxD1UA4o.js","assets/vendor-hooks-BwVH-TAd.js","assets/lottie-web-B6s7dDoL.js","assets/vendor-ux-did-connect-2GapMFC4.css","assets/vendor-arcblock-ACo-BN0q.js","assets/index-C-7MyHbp.js","assets/index-BPa_QtWl.js","assets/index-tUQxVYYQ.js","assets/index-AgKpYdvC.css"])))=>i.map(i=>d[i]);
2
- import{r as j,k as gt,l as tt,L as xe,g as Rs,u as vs,h as Cs,i as ct}from"./vendor-react-DoD83n6N.js";import{a8 as ke,j as e,v as Le,aa as c,bl as wo,H as i,ab as me,I as ce,T as L,c0 as So,D as ot,ag as ge,au as ws,bO as Ge,aj as Io,bs as Xe,bw as ht,y as ne,a9 as Ye,P as Do,G as To,w as jt,a6 as _o,M as Po,q as fe,X as Ss,ai as $o,t as qo,bR as Is,N as Ve,z as Lo,O as se,ak as Se,av as Ds,L as Ts,A as _s,b5 as Ps,U as No,W as Qe,bB as $s,bC as qs,c1 as Ls,c2 as Ns,bn as ft,bo as As,bq as Es,bu as zs,bv as at}from"./vendor-mui-core-DxD1UA4o.js";import{z as ye,C as Ee,aa as Bs,a2 as Os,f as ro,ab as lo}from"./index-BPa_QtWl.js";import{r as Re,p as Y,u as oe,bM as Ao,l as Ws,B as Me,b3 as Eo,V as zo,b1 as Bo,am as Ms,bN as Vs,a5 as kt,Y as U,a1 as Us,h as ae,bO as Fs,b6 as Hs,g as qe,ak as yt,aq as Js}from"./vendor-ux-did-connect-DOjsg91L.js";import{B as Rt,c as ue,l as Gs,I as Xs,_ as Oo,J as De,p as Ys}from"./vendor-arcblock-ACo-BN0q.js";import{d as Qs}from"./Error-By0ZMWzh.js";import{C as vt}from"./confirm-_RIb3OmR.js";import{u as Ue}from"./session-DB9Du-lc.js";import{W as io}from"./did-address-CGHn52xI.js";import{E as Fe}from"./empty-spinner-Ict2ItjU.js";import{B as Ct}from"./bundle-avatar-woUZoGoi.js";import{S as je}from"./shorten-label-CwDvu4_S.js";import{L as wt}from"./list-header-Bm8u_Z_p.js";import{Z as Zs,y as be,I as St,D as Wo}from"./vendor-utils-CTIzdAFg.js";import{d as Ks}from"./Download-DUKR_Wkm.js";import{C as Mo}from"./click-to-copy-BxZJa7n5.js";import{Q as en}from"./QuestionMarkCircle-B4EnwYju.js";import{u as tn}from"./vendor-hooks-BwVH-TAd.js";import{_ as Ie}from"./useSetState-BL3ktMon.js";import{c as It}from"./index-tUQxVYYQ.js";import{E as Dt}from"./index-D1fVmwHN.js";import"./api-3sG9at7i.js";import{d as on}from"./ChevronRight-CQOI2CyK.js";import{T as sn,a as nn}from"./vendor-mui-x-Bit8yv3W.js";import{d as co}from"./DeleteOutline-Cgoi-K0i.js";import{D as ao,C as uo,P as po}from"./react-beautiful-dnd.esm-D0nBCaor.js";import{c as rn,A as Vo,u as ln,S as cn,U as an,a as dt,b as Uo,n as dn,e as un,f as ho,g as pn,h as hn}from"./item-zk7clNKz.js";import{d as fn}from"./ArrowDropDown--dAaadP8.js";import{f as Ne}from"./format-error-LAoTjvJe.js";import{d as bn}from"./Launch-B161pSEw.js";import{M as xn}from"./index-O2l0NSUF.js";import{r as mn}from"./index-DkPKxdcu.js";import{d as gn}from"./Done-BYuUlh_s.js";import"./lottie-web-B6s7dDoL.js";import"./raf-schd.esm-GV-XhwE0.js";import"./delete-confirm-DaoAi4Gz.js";import"./get-safe-url-DMordnyN.js";var Tt={},jn=ke;Object.defineProperty(Tt,"__esModule",{value:!0});var Fo=Tt.default=void 0,kn=jn(Re()),yn=e;Fo=Tt.default=(0,kn.default)((0,yn.jsx)("path",{d:"M19 3H5c-1.11 0-2 .9-2 2v14c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2m-2 10h-4v4h-2v-4H7v-2h4V7h2v4h4z"}),"AddBox");var _t={},Rn=ke;Object.defineProperty(_t,"__esModule",{value:!0});var Ho=_t.default=void 0,vn=Rn(Re()),Cn=e;Ho=_t.default=(0,vn.default)((0,Cn.jsx)("path",{d:"M14 2H6c-1.1 0-2 .9-2 2v16c0 1.1.89 2 1.99 2H15v-8h5V8zm-1 7V3.5L18.5 9zm4 12.66V16h5.66v2h-2.24l2.95 2.95-1.41 1.41L19 19.41v2.24h-2z"}),"FileOpen");var Pt={},wn=ke;Object.defineProperty(Pt,"__esModule",{value:!0});var Jo=Pt.default=void 0,Sn=wn(Re()),In=e;Jo=Pt.default=(0,Sn.default)((0,In.jsx)("path",{d:"M11 18h2v-2h-2zm1-16C6.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 8m0-14c-2.21 0-4 1.79-4 4h2c0-1.1.9-2 2-2s2 .9 2 2c0 2-3 1.75-3 5h2c0-2.25 3-2.5 3-5 0-2.21-1.79-4-4-4"}),"HelpOutlineOutlined");function $t({did:t,projectId:o,title:s,logo:r,describe:l}){const n=`${`${Y.WELLKNOWN_SERVICE_PATH_PREFIX}/api/project/${t}/${o}/logo/upload`}/${r}`,[u,d]=j.useState(!1),f=Le(x=>x.breakpoints.down("md"));return e.jsxs(c,{sx:{display:"flex",flexDirection:"row",color:u?"primary.main":"grey.900",gap:1},onPointerEnter:()=>d(!0),onPointerLeave:()=>d(!1),children:[e.jsx(wo,{sx:{borderRadius:1},src:n}),e.jsxs(c,{children:[e.jsx(je,{hiddenTip:!0,maxLength:"24",sx:{fontSize:"14px",fontWeight:"500",color:f?"primary.main":""},children:s||"/"}),e.jsx(je,{hiddenTip:!0,maxLength:"58",sx:{fontSize:"12px",color:f||u?"primary.main":"grey.700"},children:l||"/"})]})]})}$t.propTypes={projectId:i.string.isRequired,did:i.string.isRequired,title:i.string.isRequired,logo:i.string.isRequired,describe:i.string.isRequired};function qt({initUrl:t}){const o=gt(),s=(t==null?void 0:t.searchParams.get("tenantScope"))||"",{t:r,locale:l}=oe(),{api:a}=ye(),{api:n}=Ue(),[u,d]=j.useState(!0),{blocklet:f}=Ee(),[x,S]=j.useState(null),[C,p]=j.useState(!1),h=Le(g=>g.breakpoints.down("xl")),R=Le(g=>g.breakpoints.down("md")),{componentDid:w=""}=tt(),[k,I]=j.useState(null),v=`publish-${f.meta.did}`,D=Ao(v),[_,q]=j.useState({searchText:D.searchText||"",pageSize:D.rowsPerPage||10,page:1}),E=()=>{a.getProjects({input:{did:f.meta.did,componentDid:w,tenantScope:s}}).then(g=>{const N=(g==null?void 0:g.projects)||[];d(!1),I(N)}).catch(g=>{d(!1),U.error(g.message)})},M=()=>{o(`${Y.UNOWNED_DID}/create/none`,{replace:!0})},$=g=>{S(g)},Q=()=>{d(!1),p(!0)},O=()=>{p(!1),S(null)},m=g=>{U.error(g.message),p(!1),S(null)},b=g=>{if(!(g!=null&&g.deleted)){U.error("Delete project failed");return}E(),p(!1),S(null)};j.useEffect(()=>{E()},[]);const y=j.useMemo(()=>{var N;if(!_.searchText)return k;let g=(N=_.searchText)==null?void 0:N.trim();return g?(g=Ws.toAddress(g).toLocaleLowerCase(),k.filter(H=>H.blockletTitle.toLowerCase().includes(g)||H.blockletDid.toLowerCase().includes(g))):k},[k,_.searchText]);if(!k&&u)return e.jsx(c,{sx:{display:"flex",justifyContent:"center",alignItems:"center",marginTop:"40px"},children:e.jsx(Fe,{})});if(!k)return null;if(!k.length)return e.jsxs(c,{display:"flex",flexDirection:"column",alignItems:"center",pt:10,children:[e.jsx(c,{sx:{fontSize:20,fontWeight:"bold",mb:3},children:r("blocklet.publish.blockletEmptyTip")}),e.jsx(c,{sx:{fontSize:14,color:"text.secondary",mb:3},children:r("blocklet.publish.createBlockletTip")}),e.jsx(Me,{onClick:M,variant:"contained",children:r("blocklet.publish.createBlocklet")})]});const W=[{label:"Blocklet",name:"blockletTitle",minWidth:160,options:{customBodyRenderLite:g=>{const N=k[g];return e.jsx(xe,{to:`${N.id}`,children:e.jsx($t,{did:f.meta.did,projectId:N.id,logo:N.blockletLogo,title:N.blockletTitle,describe:N.blockletDescription})})}}},{label:"Version",name:"blockletVersion",options:{searchable:!1,customBodyRender:g=>g?e.jsx(Eo,{type:"success",children:g}):""}},{label:"DID",name:"blockletDid",options:{customBodyRender:g=>g?e.jsx(io,{size:14,compact:!0,responsive:!1,did:g}):null}},h||w?null:{label:r("common.createdBy"),name:"createdBy",options:{customBodyRender:g=>g?e.jsx(io,{onClick:()=>{o(`/.well-known/service/admin/members?did=${g}`)},style:{cursor:"pointer"},size:14,compact:!0,copyable:!1,showQrcode:!1,responsive:!1,did:g}):null}},h||w?null:{label:r("common.scope"),name:"componentDid",options:{customBodyRender:g=>{const N=(f.children||[]).find(H=>H.meta.did===g);return N?e.jsxs(c,{display:"flex",alignItems:"center",justifyContent:"flex-start",children:[e.jsx(Ct,{size:14,blocklet:N,ancestors:[f]}),e.jsx(c,{ml:.5,sx:{ml:.5,color:"text.primary",fontSize:14},children:N.meta.title})]},g):""}}},h||s?null:{label:r("blocklet.publish.tenantScope"),name:"tenantScope",options:{customBodyRender:g=>e.jsx(c,{ml:.5,sx:{ml:.5,color:"text.primary",fontSize:14},children:e.jsx(je,{children:g})})}},{label:r("common.updatedAt"),name:"updatedAt",options:{searchable:!1,customBodyRender:g=>e.jsx(zo,{value:Number(g),locale:l})}},{label:r("common.actions"),name:"actions",options:{searchable:!1,customBodyRenderLite:g=>{const N=k[g];return e.jsxs(c,{display:"flex",children:[e.jsx(xe,{to:`${N.id}/new-release/${N.lastReleaseId}`,children:e.jsx(me,{title:r("blocklet.publish.createRelease"),placement:"top",children:e.jsx(ce,{color:"primary","aria-label":"create",children:e.jsx(Fo,{style:{fontSize:18}})})})}),!!N.lastReleaseId&&e.jsx(me,{title:r("blocklet.publish.viewLastRelease",{name:N.blockletTitle}),placement:"top",children:e.jsx(ce,{color:"secondary","aria-label":"create",children:e.jsx(xe,{style:{display:"flex"},to:`${N.id}/view/${N.lastReleaseId}`,children:e.jsx(Ho,{sx:{fontSize:18}})})})}),e.jsx(me,{title:r("blocklet.publish.delete",{name:N.blockletTitle}),placement:"top",children:e.jsx(ce,{color:"primary","aria-label":"delete",onClick:()=>$(N),children:e.jsx(Bo,{sx:{fontSize:18}})})})]})}}}].filter(Boolean),z=({page:g,rowsPerPage:N,searchText:H})=>{_.pageSize!==N?q(J=>({...J,searchText:"",pageSize:N,page:1})):_.page!==g+1?q(J=>({...J,searchText:"",page:g+1})):_.searchText!==H&&q(J=>({...J,searchText:H,page:1}))},G=C?e.jsx(Ms,{open:!0,popup:!0,onClose:O,action:"check-has-project-id",locale:l,checkFn:n.get,saveConnect:!1,forceConnected:!1,checkTimeout:5*60*1e3,onSuccess:b,onError:m,extraParams:{projectId:x.id,did:f.meta.did,name:x.blockletTitle},messages:{title:r("blocklet.publish.deleteProject.title",{name:x.blockletTitle}),scan:r("blocklet.publish.deleteProject.scan",{name:x.blockletTitle}),confirm:r("blocklet.publish.deleteProject.confirm"),success:r("blocklet.publish.deleteProject.success")}}):null;return e.jsxs(c,{children:[e.jsx(wt,{sx:{mb:2},left:e.jsxs(c,{display:"flex",flexDirection:"row",alignItems:"center",children:[e.jsx(c,{sx:{fontSize:"1.2rem",fontWeight:"bold"},children:r("common.blockletStudio")}),e.jsx(me,{title:r("blocklet.publish.createBlockletTip"),arrow:!0,placement:"right",children:e.jsx(Jo,{sx:{opacity:.6,fontSize:"1.1em",ml:1}})})]}),actions:e.jsxs(e.Fragment,{children:[e.jsx(Vs,{options:{searchPlaceholder:r("blocklet.list.searchPlaceholder"),searchDebounceTime:600,searchAlwaysOpen:R},search:_.searchText,searchText:_.searchText,searchTextUpdate:g=>q(N=>({...N,searchText:g})),searchClose:()=>q(g=>({...g,searchText:""})),onSearchOpen:()=>{}}),e.jsxs(Me,{onClick:M,variant:"contained",children:[e.jsx(Rt,{style:{fontSize:"1.3em",marginRight:4}}),r("blocklet.publish.createBlocklet")]})]})}),e.jsx(kt,{className:"main-table",locale:l,data:y,columns:W,options:{search:!1,sort:!1,download:!1,filter:!1,print:!1,viewColumns:!1,searchAlwaysOpen:!0,rowsPerPageOptions:[10,20,50,100]},durable:v,onChange:z}),x&&e.jsx(vt,{title:`${r("common.delete")} ${x.blockletTitle}`,description:r("blocklet.publish.deleteProject.description"),confirm:r("common.confirm"),onConfirm:Q,onCancel:()=>S(null),children:e.jsx(c,{sx:{marginTop:2},children:[r("blocklet.publish.deleteProject.tip1"),r("blocklet.publish.deleteProject.tip2"),r("blocklet.publish.deleteProject.tip3")].map(g=>e.jsxs(c,{sx:{display:"flex",marginTop:1,flexDirection:"row",alignItems:"flex-start"},children:[e.jsx(Qs,{color:"warning",sx:{marginRight:1,fontSize:20,marginTop:"2px"}}),e.jsx(L,{component:"span",variant:"inherit",color:"text.secondary",children:g})]}))})}),G]})}qt.propTypes={initUrl:i.object};qt.defaultProps={initUrl:null};var Lt={},Dn=ke;Object.defineProperty(Lt,"__esModule",{value:!0});var Go=Lt.default=void 0,Tn=Dn(Re()),fo=e;Go=Lt.default=(0,Tn.default)([(0,fo.jsx)("path",{d:"M20 17H4V5h8V3H4c-1.11 0-2 .89-2 2v12c0 1.1.89 2 2 2h4v2h8v-2h4c1.1 0 2-.9 2-2v-3h-2z"},"0"),(0,fo.jsx)("path",{d:"m17 14 5-5-1.41-1.41L18 10.17V3h-2v7.17l-2.59-2.58L12 9z"},"1")],"InstallDesktop");const _n=(t,o)=>{if(!t)return"";try{return o?JSON.parse(t)[o]:JSON.parse(t)}catch{}return t},Xo=_n;function Pn(){var m;const{t,locale:o}=oe(),{projectId:s}=tt(),{api:r}=ye(),[l,a]=j.useState(!0),{blocklet:n}=Ee(),u=Le(b=>b.breakpoints.down("md")),[d,f]=j.useState(null),[x,S]=j.useState(null),[C,p]=j.useState(null),h=(m=window.env)==null?void 0:m.serverEndpoint,R=`releases-${n.meta.did}-${s}`,w=Ao(R),[k,I]=j.useState({searchText:w.searchText||"",pageSize:w.rowsPerPage||10,page:1}),v=()=>{r.getReleases({input:{did:n.meta.did,projectId:s}}).then(b=>{const y=(b==null?void 0:b.releases)||[];a(!1),f(y)}).catch(b=>{a(!1),U.error(b.message)})},D=()=>{r.doBatchQuery({getProject:{input:{did:n.meta.did,projectId:s}},getReleases:{input:{did:n.meta.did,projectId:s}}}).then(b=>{S(b.getProject.project||{}),f(b.getReleases.releases||[]),a(!1)}).catch(b=>{a(!1),U.error(b.message)})};j.useEffect(()=>{D()},[]);const[_,q]=j.useState(""),E=()=>{a(!1);const b=C.id;r.deleteRelease({input:{did:n.meta.did,projectId:s,releaseId:b}}).then(()=>{a(!1),v(),U.success(t("common.removeSuccess")),p(null)}).catch(y=>{a(!1),U.error(y.message)})},M=b=>{p(b)};if(!d&&l)return e.jsx(c,{sx:{display:"flex",justifyContent:"center",alignItems:"center",marginTop:"40px"},children:e.jsx(Fe,{})});if(!d)return null;const $=e.jsxs(So,{className:"breadcrumbs","aria-label":"breadcrumb",children:[e.jsx(xe,{to:"..",children:t("common.blockletStudio")}),e.jsx(L,{color:"text.primary",children:e.jsx(je,{maxLength:u?6:30,children:x.blockletTitle})})]});if(!d.length)return e.jsxs(e.Fragment,{children:[$,e.jsxs(c,{display:"flex",flexDirection:"column",alignItems:"center",pt:10,children:[e.jsx(c,{sx:{fontSize:20,fontWeight:"bold",mb:3},children:t("blocklet.publish.releaseEmptyTip")}),e.jsx(c,{sx:{fontSize:14,color:"text.secondary",mb:3},children:t("blocklet.publish.createReleaseTip")}),e.jsx(xe,{to:"create/none",children:e.jsx(Me,{variant:"contained",children:t("blocklet.publish.createRelease")})})]})]});const Q=[{label:t("common.version"),name:"blockletVersion",minWidth:160,options:{customBodyRenderLite:b=>{const y=d[b];return e.jsx(xe,{to:`view/${y.id}`,children:e.jsx($t,{did:n.meta.did,projectId:x.id,logo:y.blockletLogo,title:y.blockletVersion,describe:y.blockletTitle})})}}},{label:t("blocklet.publish.releaseNote"),name:"note",options:{customBodyRenderLite:b=>{const y=d[b];return e.jsx(L,{className:"note",children:Xo(y.note,"note")})}}},{label:t("common.status"),name:"status",options:{customBodyRender:b=>e.jsx(Eo,{type:b==="published"?"success":"warning",children:b==="published"?"Released":Zs(b)})}},{label:t("common.lastPublishedAt"),name:"updatedAt",options:{customBodyRenderLite:b=>{const y=d[b];return y.status!==ue.PROJECT.RELEASE_STATUS.published?"":e.jsx(zo,{value:Number(y.updatedAt),locale:o})}}},{label:t("common.actions"),name:"actions",options:{customBodyRenderLite:b=>{var N;const y=d[b];let W="",z="";const G=y.status==="published";if(G){const H=be(h,`/api/project/${n.meta.did}/${x.id}/${x.lastReleaseId}/release/blocklet.json`),J=new URL(h);J.pathname=be(J.pathname,"/launch-blocklet/agreement"),J.searchParams.set("blocklet_meta_url",H),W=J.href,z=be(`${Y.WELLKNOWN_SERVICE_PATH_PREFIX}/api/project/${n.meta.did}/${x.id}/${x.lastReleaseId}/download/${(x.lastReleaseFiles||[])[0]}`)}const g=(N=x.blockletComponents)!=null&&N.some(H=>H.included)||y.uploadedResource?"pack":"resource";return e.jsxs(c,{display:"flex",alignItems:"center",children:[G&&g==="pack"&&e.jsx(me,{title:t("blocklet.publish.install",{name:x.blockletTitle}),placement:"top",children:e.jsx(ce,{color:"secondary","aria-label":"create",children:e.jsx("a",{style:{display:"flex"},href:W,target:"_blank",rel:"noreferrer",children:e.jsx(Go,{sx:{fontSize:18}})})})}),G&&e.jsx(me,{title:t("blocklet.publish.download",{name:x.blockletTitle}),placement:"top",children:e.jsx(ce,{color:"primary","aria-label":"download",children:e.jsx("a",{style:{display:"flex"},href:z,children:e.jsx(Ks,{sx:{fontSize:18}})})})}),e.jsx(me,{title:t("blocklet.publish.delete",{name:x.blockletTitle}),placement:"top",children:e.jsx(ce,{color:"primary","aria-label":"delete",onClick:()=>M(y),children:e.jsx(Bo,{sx:{fontSize:18}})})})]})}}}],O=({page:b,rowsPerPage:y,searchText:W})=>{k.pageSize!==y?I(z=>({...z,searchText:"",pageSize:y,page:1})):k.page!==b+1?I(z=>({...z,searchText:"",page:b+1})):k.searchText!==W&&I(z=>({...z,searchText:W,page:1}))};return e.jsxs($n,{children:[e.jsx(wt,{sx:{mb:2},left:$,actions:e.jsxs(e.Fragment,{children:[e.jsx(Me,{variant:"outlined",onClick:()=>{const b=be(h,`/api/project/${n.meta.did}/${s}/blocklet.json`);q(b)},children:t("blocklet.publish.copyInstallUrl")}),e.jsx(xe,{to:"new-release/none",children:e.jsxs(Me,{variant:"contained",children:[e.jsx(Rt,{style:{fontSize:"1.3em",marginRight:4}}),t("blocklet.publish.createRelease")]})})]})}),e.jsx(ot,{fullWidth:!0,maxWidth:"sm",open:_,onClose:()=>q(""),children:e.jsxs(c,{sx:{py:5,px:4,wordBreak:"break-all"},children:[e.jsx(L,{variant:"h6",sx:{mb:2},children:t("blocklet.publish.installResourceTip")}),e.jsx(Mo,{children:_}),e.jsxs(L,{sx:{mt:2},children:[t("blocklet.publish.installResourceTip2"),e.jsx("a",{style:{marginLeft:4},href:"https://www.arcblock.io/docs/blocklet-developer/how-to-use-install-url",target:"_blank",rel:"noreferrer",children:t("blocklet.publish.installResourceHelp")})]})]})}),e.jsx(kt,{className:"main-table",verticalKeyWidth:100,locale:o,data:d,columns:Q,durable:R,options:{sort:!1,download:!1,filter:!1,print:!1,search:!1},onChange:O}),C&&e.jsx(vt,{title:t(`${t("common.delete")} ${C.blockletVersion}`),description:t("blocklet.publish.deleteReleaseTip"),confirm:t("common.confirm"),onConfirm:E,onCancel:()=>p(null)})]})}const $n=ge(c)`
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-B64a4BbE.js","assets/vendor-ux-did-connect-CiLSrCOH.js","assets/vendor-react-DoD83n6N.js","assets/vendor-utils-CTIzdAFg.js","assets/vendor-mui-core-DxD1UA4o.js","assets/vendor-hooks-BwVH-TAd.js","assets/lottie-web-B6s7dDoL.js","assets/vendor-ux-did-connect-2GapMFC4.css","assets/vendor-arcblock-BtlDhznp.js","assets/index-C-7MyHbp.js","assets/index-tjRN_EVx.js","assets/index-tUQxVYYQ.js","assets/index-AgKpYdvC.css"])))=>i.map(i=>d[i]);
2
+ import{r as j,k as gt,l as tt,L as xe,g as Rs,u as vs,h as Cs,i as ct}from"./vendor-react-DoD83n6N.js";import{a8 as ke,j as e,v as Le,aa as c,bl as wo,H as i,ab as me,I as ce,T as L,c0 as So,D as ot,ag as ge,au as ws,bO as Ge,aj as Io,bs as Xe,bw as ht,y as ne,a9 as Ye,P as Do,G as To,w as jt,a6 as _o,M as Po,q as fe,X as Ss,ai as $o,t as qo,bR as Is,N as Ve,z as Lo,O as se,ak as Se,av as Ds,L as Ts,A as _s,b5 as Ps,U as No,W as Qe,bB as $s,bC as qs,c1 as Ls,c2 as Ns,bn as ft,bo as As,bq as Es,bu as zs,bv as at}from"./vendor-mui-core-DxD1UA4o.js";import{z as ye,C as Ee,aa as Bs,a2 as Os,f as ro,ab as lo}from"./index-tjRN_EVx.js";import{r as Re,p as Y,u as oe,bM as Ao,l as Ws,B as Me,b3 as Eo,V as zo,b1 as Bo,am as Ms,bN as Vs,a5 as kt,Y as U,a1 as Us,h as ae,bO as Fs,b6 as Hs,g as qe,ak as yt,aq as Js}from"./vendor-ux-did-connect-CiLSrCOH.js";import{B as Rt,c as ue,l as Gs,I as Xs,_ as Oo,J as De,p as Ys}from"./vendor-arcblock-BtlDhznp.js";import{d as Qs}from"./Error-BnWmSZ5k.js";import{C as vt}from"./confirm-BX8_-j-l.js";import{u as Ue}from"./session-DaQ4KCFD.js";import{W as io}from"./did-address-GAxLGeWB.js";import{E as Fe}from"./empty-spinner-Ict2ItjU.js";import{B as Ct}from"./bundle-avatar-DNxC8z4b.js";import{S as je}from"./shorten-label-CwDvu4_S.js";import{L as wt}from"./list-header-Bm8u_Z_p.js";import{Z as Zs,y as be,I as St,D as Wo}from"./vendor-utils-CTIzdAFg.js";import{d as Ks}from"./Download-B0rKRcTB.js";import{C as Mo}from"./click-to-copy-Cygm8U3_.js";import{Q as en}from"./QuestionMarkCircle-B4EnwYju.js";import{u as tn}from"./vendor-hooks-BwVH-TAd.js";import{_ as Ie}from"./useSetState-BL3ktMon.js";import{c as It}from"./index-tUQxVYYQ.js";import{E as Dt}from"./index-D1fVmwHN.js";import"./api-3sG9at7i.js";import{d as on}from"./ChevronRight-CO9My6tF.js";import{T as sn,a as nn}from"./vendor-mui-x-Bit8yv3W.js";import{d as co}from"./DeleteOutline-7AloJjcV.js";import{D as ao,C as uo,P as po}from"./react-beautiful-dnd.esm-BQ3hEDNY.js";import{c as rn,A as Vo,u as ln,S as cn,U as an,a as dt,b as Uo,n as dn,e as un,f as ho,g as pn,h as hn}from"./item--dgEgBvz.js";import{d as fn}from"./ArrowDropDown-DO9H_COV.js";import{f as Ne}from"./format-error-LAoTjvJe.js";import{d as bn}from"./Launch-CIC8rZgo.js";import{M as xn}from"./index-O2l0NSUF.js";import{r as mn}from"./index-DkPKxdcu.js";import{d as gn}from"./Done-BXISjL2g.js";import"./lottie-web-B6s7dDoL.js";import"./raf-schd.esm-GV-XhwE0.js";import"./delete-confirm-C0cAQSXq.js";import"./get-safe-url-ZRaKUVld.js";var Tt={},jn=ke;Object.defineProperty(Tt,"__esModule",{value:!0});var Fo=Tt.default=void 0,kn=jn(Re()),yn=e;Fo=Tt.default=(0,kn.default)((0,yn.jsx)("path",{d:"M19 3H5c-1.11 0-2 .9-2 2v14c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2m-2 10h-4v4h-2v-4H7v-2h4V7h2v4h4z"}),"AddBox");var _t={},Rn=ke;Object.defineProperty(_t,"__esModule",{value:!0});var Ho=_t.default=void 0,vn=Rn(Re()),Cn=e;Ho=_t.default=(0,vn.default)((0,Cn.jsx)("path",{d:"M14 2H6c-1.1 0-2 .9-2 2v16c0 1.1.89 2 1.99 2H15v-8h5V8zm-1 7V3.5L18.5 9zm4 12.66V16h5.66v2h-2.24l2.95 2.95-1.41 1.41L19 19.41v2.24h-2z"}),"FileOpen");var Pt={},wn=ke;Object.defineProperty(Pt,"__esModule",{value:!0});var Jo=Pt.default=void 0,Sn=wn(Re()),In=e;Jo=Pt.default=(0,Sn.default)((0,In.jsx)("path",{d:"M11 18h2v-2h-2zm1-16C6.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 8m0-14c-2.21 0-4 1.79-4 4h2c0-1.1.9-2 2-2s2 .9 2 2c0 2-3 1.75-3 5h2c0-2.25 3-2.5 3-5 0-2.21-1.79-4-4-4"}),"HelpOutlineOutlined");function $t({did:t,projectId:o,title:s,logo:r,describe:l}){const n=`${`${Y.WELLKNOWN_SERVICE_PATH_PREFIX}/api/project/${t}/${o}/logo/upload`}/${r}`,[u,d]=j.useState(!1),f=Le(x=>x.breakpoints.down("md"));return e.jsxs(c,{sx:{display:"flex",flexDirection:"row",color:u?"primary.main":"grey.900",gap:1},onPointerEnter:()=>d(!0),onPointerLeave:()=>d(!1),children:[e.jsx(wo,{sx:{borderRadius:1},src:n}),e.jsxs(c,{children:[e.jsx(je,{hiddenTip:!0,maxLength:"24",sx:{fontSize:"14px",fontWeight:"500",color:f?"primary.main":""},children:s||"/"}),e.jsx(je,{hiddenTip:!0,maxLength:"58",sx:{fontSize:"12px",color:f||u?"primary.main":"grey.700"},children:l||"/"})]})]})}$t.propTypes={projectId:i.string.isRequired,did:i.string.isRequired,title:i.string.isRequired,logo:i.string.isRequired,describe:i.string.isRequired};function qt({initUrl:t}){const o=gt(),s=(t==null?void 0:t.searchParams.get("tenantScope"))||"",{t:r,locale:l}=oe(),{api:a}=ye(),{api:n}=Ue(),[u,d]=j.useState(!0),{blocklet:f}=Ee(),[x,S]=j.useState(null),[C,p]=j.useState(!1),h=Le(g=>g.breakpoints.down("xl")),R=Le(g=>g.breakpoints.down("md")),{componentDid:w=""}=tt(),[k,I]=j.useState(null),v=`publish-${f.meta.did}`,D=Ao(v),[_,q]=j.useState({searchText:D.searchText||"",pageSize:D.rowsPerPage||10,page:1}),E=()=>{a.getProjects({input:{did:f.meta.did,componentDid:w,tenantScope:s}}).then(g=>{const N=(g==null?void 0:g.projects)||[];d(!1),I(N)}).catch(g=>{d(!1),U.error(g.message)})},M=()=>{o(`${Y.UNOWNED_DID}/create/none`,{replace:!0})},$=g=>{S(g)},Q=()=>{d(!1),p(!0)},O=()=>{p(!1),S(null)},m=g=>{U.error(g.message),p(!1),S(null)},b=g=>{if(!(g!=null&&g.deleted)){U.error("Delete project failed");return}E(),p(!1),S(null)};j.useEffect(()=>{E()},[]);const y=j.useMemo(()=>{var N;if(!_.searchText)return k;let g=(N=_.searchText)==null?void 0:N.trim();return g?(g=Ws.toAddress(g).toLocaleLowerCase(),k.filter(H=>H.blockletTitle.toLowerCase().includes(g)||H.blockletDid.toLowerCase().includes(g))):k},[k,_.searchText]);if(!k&&u)return e.jsx(c,{sx:{display:"flex",justifyContent:"center",alignItems:"center",marginTop:"40px"},children:e.jsx(Fe,{})});if(!k)return null;if(!k.length)return e.jsxs(c,{display:"flex",flexDirection:"column",alignItems:"center",pt:10,children:[e.jsx(c,{sx:{fontSize:20,fontWeight:"bold",mb:3},children:r("blocklet.publish.blockletEmptyTip")}),e.jsx(c,{sx:{fontSize:14,color:"text.secondary",mb:3},children:r("blocklet.publish.createBlockletTip")}),e.jsx(Me,{onClick:M,variant:"contained",children:r("blocklet.publish.createBlocklet")})]});const W=[{label:"Blocklet",name:"blockletTitle",minWidth:160,options:{customBodyRenderLite:g=>{const N=k[g];return e.jsx(xe,{to:`${N.id}`,children:e.jsx($t,{did:f.meta.did,projectId:N.id,logo:N.blockletLogo,title:N.blockletTitle,describe:N.blockletDescription})})}}},{label:"Version",name:"blockletVersion",options:{searchable:!1,customBodyRender:g=>g?e.jsx(Eo,{type:"success",children:g}):""}},{label:"DID",name:"blockletDid",options:{customBodyRender:g=>g?e.jsx(io,{size:14,compact:!0,responsive:!1,did:g}):null}},h||w?null:{label:r("common.createdBy"),name:"createdBy",options:{customBodyRender:g=>g?e.jsx(io,{onClick:()=>{o(`/.well-known/service/admin/members?did=${g}`)},style:{cursor:"pointer"},size:14,compact:!0,copyable:!1,showQrcode:!1,responsive:!1,did:g}):null}},h||w?null:{label:r("common.scope"),name:"componentDid",options:{customBodyRender:g=>{const N=(f.children||[]).find(H=>H.meta.did===g);return N?e.jsxs(c,{display:"flex",alignItems:"center",justifyContent:"flex-start",children:[e.jsx(Ct,{size:14,blocklet:N,ancestors:[f]}),e.jsx(c,{ml:.5,sx:{ml:.5,color:"text.primary",fontSize:14},children:N.meta.title})]},g):""}}},h||s?null:{label:r("blocklet.publish.tenantScope"),name:"tenantScope",options:{customBodyRender:g=>e.jsx(c,{ml:.5,sx:{ml:.5,color:"text.primary",fontSize:14},children:e.jsx(je,{children:g})})}},{label:r("common.updatedAt"),name:"updatedAt",options:{searchable:!1,customBodyRender:g=>e.jsx(zo,{value:Number(g),locale:l})}},{label:r("common.actions"),name:"actions",options:{searchable:!1,customBodyRenderLite:g=>{const N=k[g];return e.jsxs(c,{display:"flex",children:[e.jsx(xe,{to:`${N.id}/new-release/${N.lastReleaseId}`,children:e.jsx(me,{title:r("blocklet.publish.createRelease"),placement:"top",children:e.jsx(ce,{color:"primary","aria-label":"create",children:e.jsx(Fo,{style:{fontSize:18}})})})}),!!N.lastReleaseId&&e.jsx(me,{title:r("blocklet.publish.viewLastRelease",{name:N.blockletTitle}),placement:"top",children:e.jsx(ce,{color:"secondary","aria-label":"create",children:e.jsx(xe,{style:{display:"flex"},to:`${N.id}/view/${N.lastReleaseId}`,children:e.jsx(Ho,{sx:{fontSize:18}})})})}),e.jsx(me,{title:r("blocklet.publish.delete",{name:N.blockletTitle}),placement:"top",children:e.jsx(ce,{color:"primary","aria-label":"delete",onClick:()=>$(N),children:e.jsx(Bo,{sx:{fontSize:18}})})})]})}}}].filter(Boolean),z=({page:g,rowsPerPage:N,searchText:H})=>{_.pageSize!==N?q(J=>({...J,searchText:"",pageSize:N,page:1})):_.page!==g+1?q(J=>({...J,searchText:"",page:g+1})):_.searchText!==H&&q(J=>({...J,searchText:H,page:1}))},G=C?e.jsx(Ms,{open:!0,popup:!0,onClose:O,action:"check-has-project-id",locale:l,checkFn:n.get,saveConnect:!1,forceConnected:!1,checkTimeout:5*60*1e3,onSuccess:b,onError:m,extraParams:{projectId:x.id,did:f.meta.did,name:x.blockletTitle},messages:{title:r("blocklet.publish.deleteProject.title",{name:x.blockletTitle}),scan:r("blocklet.publish.deleteProject.scan",{name:x.blockletTitle}),confirm:r("blocklet.publish.deleteProject.confirm"),success:r("blocklet.publish.deleteProject.success")}}):null;return e.jsxs(c,{children:[e.jsx(wt,{sx:{mb:2},left:e.jsxs(c,{display:"flex",flexDirection:"row",alignItems:"center",children:[e.jsx(c,{sx:{fontSize:"1.2rem",fontWeight:"bold"},children:r("common.blockletStudio")}),e.jsx(me,{title:r("blocklet.publish.createBlockletTip"),arrow:!0,placement:"right",children:e.jsx(Jo,{sx:{opacity:.6,fontSize:"1.1em",ml:1}})})]}),actions:e.jsxs(e.Fragment,{children:[e.jsx(Vs,{options:{searchPlaceholder:r("blocklet.list.searchPlaceholder"),searchDebounceTime:600,searchAlwaysOpen:R},search:_.searchText,searchText:_.searchText,searchTextUpdate:g=>q(N=>({...N,searchText:g})),searchClose:()=>q(g=>({...g,searchText:""})),onSearchOpen:()=>{}}),e.jsxs(Me,{onClick:M,variant:"contained",children:[e.jsx(Rt,{style:{fontSize:"1.3em",marginRight:4}}),r("blocklet.publish.createBlocklet")]})]})}),e.jsx(kt,{className:"main-table",locale:l,data:y,columns:W,options:{search:!1,sort:!1,download:!1,filter:!1,print:!1,viewColumns:!1,searchAlwaysOpen:!0,rowsPerPageOptions:[10,20,50,100]},durable:v,onChange:z}),x&&e.jsx(vt,{title:`${r("common.delete")} ${x.blockletTitle}`,description:r("blocklet.publish.deleteProject.description"),confirm:r("common.confirm"),onConfirm:Q,onCancel:()=>S(null),children:e.jsx(c,{sx:{marginTop:2},children:[r("blocklet.publish.deleteProject.tip1"),r("blocklet.publish.deleteProject.tip2"),r("blocklet.publish.deleteProject.tip3")].map(g=>e.jsxs(c,{sx:{display:"flex",marginTop:1,flexDirection:"row",alignItems:"flex-start"},children:[e.jsx(Qs,{color:"warning",sx:{marginRight:1,fontSize:20,marginTop:"2px"}}),e.jsx(L,{component:"span",variant:"inherit",color:"text.secondary",children:g})]}))})}),G]})}qt.propTypes={initUrl:i.object};qt.defaultProps={initUrl:null};var Lt={},Dn=ke;Object.defineProperty(Lt,"__esModule",{value:!0});var Go=Lt.default=void 0,Tn=Dn(Re()),fo=e;Go=Lt.default=(0,Tn.default)([(0,fo.jsx)("path",{d:"M20 17H4V5h8V3H4c-1.11 0-2 .89-2 2v12c0 1.1.89 2 2 2h4v2h8v-2h4c1.1 0 2-.9 2-2v-3h-2z"},"0"),(0,fo.jsx)("path",{d:"m17 14 5-5-1.41-1.41L18 10.17V3h-2v7.17l-2.59-2.58L12 9z"},"1")],"InstallDesktop");const _n=(t,o)=>{if(!t)return"";try{return o?JSON.parse(t)[o]:JSON.parse(t)}catch{}return t},Xo=_n;function Pn(){var m;const{t,locale:o}=oe(),{projectId:s}=tt(),{api:r}=ye(),[l,a]=j.useState(!0),{blocklet:n}=Ee(),u=Le(b=>b.breakpoints.down("md")),[d,f]=j.useState(null),[x,S]=j.useState(null),[C,p]=j.useState(null),h=(m=window.env)==null?void 0:m.serverEndpoint,R=`releases-${n.meta.did}-${s}`,w=Ao(R),[k,I]=j.useState({searchText:w.searchText||"",pageSize:w.rowsPerPage||10,page:1}),v=()=>{r.getReleases({input:{did:n.meta.did,projectId:s}}).then(b=>{const y=(b==null?void 0:b.releases)||[];a(!1),f(y)}).catch(b=>{a(!1),U.error(b.message)})},D=()=>{r.doBatchQuery({getProject:{input:{did:n.meta.did,projectId:s}},getReleases:{input:{did:n.meta.did,projectId:s}}}).then(b=>{S(b.getProject.project||{}),f(b.getReleases.releases||[]),a(!1)}).catch(b=>{a(!1),U.error(b.message)})};j.useEffect(()=>{D()},[]);const[_,q]=j.useState(""),E=()=>{a(!1);const b=C.id;r.deleteRelease({input:{did:n.meta.did,projectId:s,releaseId:b}}).then(()=>{a(!1),v(),U.success(t("common.removeSuccess")),p(null)}).catch(y=>{a(!1),U.error(y.message)})},M=b=>{p(b)};if(!d&&l)return e.jsx(c,{sx:{display:"flex",justifyContent:"center",alignItems:"center",marginTop:"40px"},children:e.jsx(Fe,{})});if(!d)return null;const $=e.jsxs(So,{className:"breadcrumbs","aria-label":"breadcrumb",children:[e.jsx(xe,{to:"..",children:t("common.blockletStudio")}),e.jsx(L,{color:"text.primary",children:e.jsx(je,{maxLength:u?6:30,children:x.blockletTitle})})]});if(!d.length)return e.jsxs(e.Fragment,{children:[$,e.jsxs(c,{display:"flex",flexDirection:"column",alignItems:"center",pt:10,children:[e.jsx(c,{sx:{fontSize:20,fontWeight:"bold",mb:3},children:t("blocklet.publish.releaseEmptyTip")}),e.jsx(c,{sx:{fontSize:14,color:"text.secondary",mb:3},children:t("blocklet.publish.createReleaseTip")}),e.jsx(xe,{to:"create/none",children:e.jsx(Me,{variant:"contained",children:t("blocklet.publish.createRelease")})})]})]});const Q=[{label:t("common.version"),name:"blockletVersion",minWidth:160,options:{customBodyRenderLite:b=>{const y=d[b];return e.jsx(xe,{to:`view/${y.id}`,children:e.jsx($t,{did:n.meta.did,projectId:x.id,logo:y.blockletLogo,title:y.blockletVersion,describe:y.blockletTitle})})}}},{label:t("blocklet.publish.releaseNote"),name:"note",options:{customBodyRenderLite:b=>{const y=d[b];return e.jsx(L,{className:"note",children:Xo(y.note,"note")})}}},{label:t("common.status"),name:"status",options:{customBodyRender:b=>e.jsx(Eo,{type:b==="published"?"success":"warning",children:b==="published"?"Released":Zs(b)})}},{label:t("common.lastPublishedAt"),name:"updatedAt",options:{customBodyRenderLite:b=>{const y=d[b];return y.status!==ue.PROJECT.RELEASE_STATUS.published?"":e.jsx(zo,{value:Number(y.updatedAt),locale:o})}}},{label:t("common.actions"),name:"actions",options:{customBodyRenderLite:b=>{var N;const y=d[b];let W="",z="";const G=y.status==="published";if(G){const H=be(h,`/api/project/${n.meta.did}/${x.id}/${x.lastReleaseId}/release/blocklet.json`),J=new URL(h);J.pathname=be(J.pathname,"/launch-blocklet/agreement"),J.searchParams.set("blocklet_meta_url",H),W=J.href,z=be(`${Y.WELLKNOWN_SERVICE_PATH_PREFIX}/api/project/${n.meta.did}/${x.id}/${x.lastReleaseId}/download/${(x.lastReleaseFiles||[])[0]}`)}const g=(N=x.blockletComponents)!=null&&N.some(H=>H.included)||y.uploadedResource?"pack":"resource";return e.jsxs(c,{display:"flex",alignItems:"center",children:[G&&g==="pack"&&e.jsx(me,{title:t("blocklet.publish.install",{name:x.blockletTitle}),placement:"top",children:e.jsx(ce,{color:"secondary","aria-label":"create",children:e.jsx("a",{style:{display:"flex"},href:W,target:"_blank",rel:"noreferrer",children:e.jsx(Go,{sx:{fontSize:18}})})})}),G&&e.jsx(me,{title:t("blocklet.publish.download",{name:x.blockletTitle}),placement:"top",children:e.jsx(ce,{color:"primary","aria-label":"download",children:e.jsx("a",{style:{display:"flex"},href:z,children:e.jsx(Ks,{sx:{fontSize:18}})})})}),e.jsx(me,{title:t("blocklet.publish.delete",{name:x.blockletTitle}),placement:"top",children:e.jsx(ce,{color:"primary","aria-label":"delete",onClick:()=>M(y),children:e.jsx(Bo,{sx:{fontSize:18}})})})]})}}}],O=({page:b,rowsPerPage:y,searchText:W})=>{k.pageSize!==y?I(z=>({...z,searchText:"",pageSize:y,page:1})):k.page!==b+1?I(z=>({...z,searchText:"",page:b+1})):k.searchText!==W&&I(z=>({...z,searchText:W,page:1}))};return e.jsxs($n,{children:[e.jsx(wt,{sx:{mb:2},left:$,actions:e.jsxs(e.Fragment,{children:[e.jsx(Me,{variant:"outlined",onClick:()=>{const b=be(h,`/api/project/${n.meta.did}/${s}/blocklet.json`);q(b)},children:t("blocklet.publish.copyInstallUrl")}),e.jsx(xe,{to:"new-release/none",children:e.jsxs(Me,{variant:"contained",children:[e.jsx(Rt,{style:{fontSize:"1.3em",marginRight:4}}),t("blocklet.publish.createRelease")]})})]})}),e.jsx(ot,{fullWidth:!0,maxWidth:"sm",open:_,onClose:()=>q(""),children:e.jsxs(c,{sx:{py:5,px:4,wordBreak:"break-all"},children:[e.jsx(L,{variant:"h6",sx:{mb:2},children:t("blocklet.publish.installResourceTip")}),e.jsx(Mo,{children:_}),e.jsxs(L,{sx:{mt:2},children:[t("blocklet.publish.installResourceTip2"),e.jsx("a",{style:{marginLeft:4},href:"https://www.arcblock.io/docs/blocklet-developer/how-to-use-install-url",target:"_blank",rel:"noreferrer",children:t("blocklet.publish.installResourceHelp")})]})]})}),e.jsx(kt,{className:"main-table",verticalKeyWidth:100,locale:o,data:d,columns:Q,durable:R,options:{sort:!1,download:!1,filter:!1,print:!1,search:!1},onChange:O}),C&&e.jsx(vt,{title:t(`${t("common.delete")} ${C.blockletVersion}`),description:t("blocklet.publish.deleteReleaseTip"),confirm:t("common.confirm"),onConfirm:E,onCancel:()=>p(null)})]})}const $n=ge(c)`
3
3
  .main-table > div:first-child {
4
4
  display: none;
5
5
  }
@@ -125,7 +125,7 @@ import{r as j,k as gt,l as tt,L as xe,g as Rs,u as vs,h as Cs,i as ct}from"./ven
125
125
  background: #fff;
126
126
  z-index: 10;
127
127
  }
128
- `;var Mt={},sr=ke;Object.defineProperty(Mt,"__esModule",{value:!0});var bt=Mt.default=void 0,nr=sr(Re()),rr=e;bt=Mt.default=(0,nr.default)((0,rr.jsx)("path",{d:"M11 18c0 1.1-.9 2-2 2s-2-.9-2-2 .9-2 2-2 2 .9 2 2m-2-8c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2m0-6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2m6 4c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2m0 2c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2m0 6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2"}),"DragIndicator");const go="lastWantToConnectStoreId";function lr(t){var u,d;const[o,s]=j.useState(null),{session:r}=Ue(),l=j.useCallback(f=>{s(f),localStorage.setItem(go,f==null?void 0:f.id)},[s]),a=j.useMemo(()=>{var C,p,h,R;const f=localStorage.getItem(go),x=f?(((C=t==null?void 0:t.settings)==null?void 0:C.storeList)||[]).find(w=>w.id===f):null;if(x)return x;let S=(((p=t==null?void 0:t.settings)==null?void 0:p.storeList)||[]).find(w=>{var k;return!(w.id!==Y.BLOCKLET_STORE.id||w.scope&&w.scope!=="studio"&&w.scope!==((k=r==null?void 0:r.user)==null?void 0:k.did))});return S||(S=(R=(h=t==null?void 0:t.settings)==null?void 0:h.storeList)==null?void 0:R[0]),S},[(u=t==null?void 0:t.settings)==null?void 0:u.storeList,(d=r==null?void 0:r.user)==null?void 0:d.did]);return[o||a||{},l]}const pt={};async function es(t,{interval:o=1e3,maxDuration:s=120*1e3,intervalFirst:r=4e3,timerKey:l=""}){pt[l]&&clearTimeout(pt[l]),await new Promise(u=>setTimeout(u,r));const a=Date.now(),n=async(u,d)=>{try{const f=await t();u(f)}catch(f){Date.now()-a>s?d(f):l?pt[l]=setTimeout(()=>n(u,d),o):setTimeout(()=>n(u,d),o)}};return new Promise(n)}function ir(){return Math.random().toString(36).slice(2)+Math.random().toString(36).slice(2)+`${Date.now()}`.slice(-6)}function cr(t,{did:o,projectId:s,messageId:r}){return es(async()=>{var a;const l=await t.getProject({input:{did:o,projectId:s,messageId:r}});if(!((a=l==null?void 0:l.project)!=null&&a.blockletDid))throw new Error("Connected store not found");return l.project.blockletDid},{timerKey:"connect-studio"})}function ar(t,{did:o,projectId:s,storeId:r}){return es(async()=>{var n,u;const l=await t.getProject({input:{did:o,projectId:s,messageId:""}});if(!((u=(n=l==null?void 0:l.project)==null?void 0:n.connectedStores)!=null&&u.length))throw new Error("Connected store not found");if(!l.project.connectedStores.find(d=>d.storeId===r))throw new Error("Connected store not found")},{timerKey:`connect-store-${r}`})}const dr=({fromBlocklet:t,nodeInfo:o,blocklet:s,userDid:r})=>{var n,u;const l=t?(n=s==null?void 0:s.meta)==null?void 0:n.did:o==null?void 0:o.did;let a=t?((u=s==null?void 0:s.settings)==null?void 0:u.storeList)||[]:(o==null?void 0:o.blockletRegistryList)||[];return Array.isArray(a)||(a=[]),a=a.filter(d=>d.protected||!d.scope||d.scope==="studio"||d.scope===r),{teamDid:l,storeList:a}},Vt=dr;function Ut({blocklet:t,store:o={},onChangeStore:s,onClick:r,disabled:l,loading:a,componentDid:n}){var m,b,y;const{t:u}=oe(),{session:d}=Ue(),{api:f,info:x,inService:S}=ye(),C=Ee(),[p,h]=j.useState(!1),R=j.useRef(null),[w,k]=j.useState(!1),[I,v]=j.useState(null),D=W=>{s(W),h(!1)},_=()=>{h(!p)},q=W=>{R.current&&R.current.contains(W.target)||h(!1)},E=()=>{k(!0)},M=()=>{k(!1)},$=async()=>{var W;if(I)try{await f.deleteBlockletStore({input:{teamDid:t.meta.did,url:I.url,projectId:"",scope:I.scope||"studio"}}),await((W=C==null?void 0:C.actions)==null?void 0:W.refreshBlocklet())}catch(z){U.error(`Remove Blocklet Store Error: ${Ne(z)}`)}finally{v(null)}},{storeList:Q}=Vt({fromBlocklet:S,blocklet:t,nodeInfo:x,componentDid:n,userDid:(m=d==null?void 0:d.user)==null?void 0:m.did}),O=(b=t==null?void 0:t.meta)==null?void 0:b.did;return e.jsxs(e.Fragment,{children:[e.jsxs(ht,{disabled:l,ref:R,variant:"contained",color:"primary","aria-label":"Button group with connect store",children:[e.jsxs(ne,{onClick:r,children:[a&&e.jsx(Ye,{size:14,sx:{mr:.5}}),`${u("common.connect")} ${o.name||""}`]}),e.jsx(ne,{size:"small","aria-controls":p?"split-button-menu":void 0,"aria-expanded":p?"true":void 0,"aria-label":"select merge strategy","aria-haspopup":"menu",onClick:_,children:e.jsx(fn,{})})]}),e.jsx(Do,{sx:{zIndex:10},open:p,anchorEl:R.current,placement:"bottom-end",role:void 0,transition:!0,disablePortal:!0,children:({TransitionProps:W})=>e.jsx(To,{...W,style:{transformOrigin:"center top"},children:e.jsx(jt,{children:e.jsx(_o,{onClickAway:q,children:e.jsxs(Po,{id:"split-button-menu",autoFocusItem:!0,sx:{maxHeight:300,overflowY:"auto",zIndex:10},children:[Q==null?void 0:Q.map(z=>{var G;return e.jsxs(fe,{selected:z.id===(o==null?void 0:o.id),sx:{height:56},onClick:()=>D(z),children:[e.jsxs(c,{children:[e.jsx(je,{sx:{fontSize:"16px"},maxLength:24,children:z.name}),e.jsx(je,{sx:{fontSize:"13px",opacity:.6},maxLength:30,children:z.url})]}),rn({store:z,userDid:(G=d==null?void 0:d.user)==null?void 0:G.did})&&e.jsx(ce,{sx:{ml:1},onClick:g=>{g.preventDefault(),g.stopPropagation(),v(z)},children:e.jsx(ae,{icon:"ic:outline-delete"})})]},z.url)}),e.jsx(Ss,{}),e.jsxs(fe,{onClick:E,children:[e.jsx(Rt,{font:!0}),e.jsx(L,{variant:"inherit",children:u("store.blockletRegistry.addRegistry")})]})]})})})})}),w&&e.jsx(Vo,{hiddenChildren:!0,open:!0,onClose:M,teamDid:O,storeList:Q,scope:"studio",onAdd:(y=C==null?void 0:C.actions)==null?void 0:y.refreshBlocklet}),I&&e.jsx(vt,{displayError:!0,title:`${u("common.delete")} ${I.name}`,description:u("blocklet.publish.deleteStoreTip",{name:I.name}),confirm:u("common.confirm"),onConfirm:$,onCancel:()=>v(null)})]})}Ut.propTypes={store:i.object,blocklet:i.object,onChangeStore:i.func.isRequired,onClick:i.func.isRequired,loading:i.bool.isRequired,disabled:i.bool.isRequired,componentDid:i.string.isRequired,projectType:i.string.isRequired,getData:i.func.isRequired};Ut.defaultProps={store:null,blocklet:null};const ur=(t,o,s)=>{const r=`${Y.WELLKNOWN_SERVICE_PATH_PREFIX}/api/project/${o.meta.did}/${s}/logo/upload`,l=`${Y.WELLKNOWN_SERVICE_PATH_PREFIX}/api/project/${o.meta.did}/${s}/screenshot/upload`,a=t!=null&&t.blockletLogo?`${r}/${t.blockletLogo}`:`${Y.WELLKNOWN_SERVICE_PATH_PREFIX}/static/images/logo.png`,n=((t==null?void 0:t.blockletScreenshots)||[]).filter(Boolean).map(u=>`${l}/${u}`);return{logoUrl:a,screenshotUrls:n,uploadLogoPrefix:r,uploadScreenshotPrefix:l}},ts=ur,pr=t=>{const o=t.includes("youtube.com")||t.includes("youtu.be"),s=t.includes("vimeo.com");return o||s};function st({url:t,style:o,controls:s,modestbranding:r}){var u;const{t:l}=oe(),a=t.includes("youtube.com")||t.includes("youtu.be"),n=t.includes("vimeo.com");if(a){const d=((u=t.split("v=")[1])==null?void 0:u.split("&")[0])||t.split("/").pop();return e.jsx("div",{style:{position:"relative",width:"100%",paddingTop:"56.25%",pointerEvents:(o==null?void 0:o.pointerEvents)||"auto"},children:e.jsx("iframe",{src:`https://www.youtube.com/embed/${d}?modestbranding=${r}&controls=${s}&rel=0`,title:"YouTube video player",style:{position:"absolute",top:0,left:0,width:"100%",height:"100%",border:"none",...o},allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0})})}if(n){const d=t.split("/").pop();return e.jsx("div",{style:{position:"relative",width:"100%",paddingTop:"56.25%",pointerEvents:o.pointerEvents||"auto"},children:e.jsx("iframe",{src:`https://player.vimeo.com/video/${d}`,title:"Vimeo video player",style:{position:"absolute",top:0,left:0,width:"100%",height:"100%",border:"none",...o},allow:"autoplay; fullscreen; picture-in-picture",allowFullScreen:!0})})}return e.jsx(c,{style:{position:"relative",width:"100%",paddingTop:"56.25%"},children:e.jsxs(c,{style:{position:"absolute",top:0,left:0,width:"100%",height:"100%",border:"none",backgroundColor:"rgba(0, 0, 0, 0.04)",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",...o},allow:"autoplay; fullscreen; picture-in-picture",allowFullScreen:!0,children:[e.jsx(ae,{icon:"carbon:video-off",style:{fontSize:40,marginBottom:"10px",opacity:.5}}),e.jsx(L,{variant:"body1",sx:{opacity:.5},children:l("studio.videoDialogNoSrc")})]})})}st.propTypes={url:i.string.isRequired,style:i.object,controls:i.number,modestbranding:i.number};st.defaultProps={style:{},controls:1,modestbranding:1};function os({setParams:t,onClose:o,params:s}){const{t:r}=oe(),[l,a]=j.useState(""),n=l&&s.blockletVideos.includes(l),u=pr(l),d=()=>{t(f=>{const x=[...f.blockletVideos];return x.push(l),{...f,blockletVideos:x}}),o()};return e.jsxs(ot,{open:!0,fullWidth:!0,maxWidth:"sm",children:[e.jsx($o,{children:r("studio.videoDialogTitle")}),e.jsxs(qo,{children:[e.jsx(Is,{fullWidth:!0,value:l,onChange:f=>a(f.target.value),placeholder:r("studio.videoInputLabel"),endAdornment:l?e.jsx(Ve,{position:"end",children:e.jsx(ce,{onClick:()=>a(""),children:e.jsx(Hs,{})})}):null,error:n}),n&&e.jsx(L,{variant:"body2",color:"error",children:r("studio.duplicateVideo")}),e.jsx(st,{url:l,style:{marginTop:"20px",borderRadius:"4px"}})]}),e.jsxs(Lo,{children:[e.jsx(ne,{onClick:()=>o(),children:r("studio.cancel")}),e.jsx(ne,{disabled:!u||n,onClick:d,children:r("studio.confirm")})]})]})}os.propTypes={onClose:i.func.isRequired,params:i.object.isRequired,setParams:i.func.isRequired};function xt({errors:t,storeList:o,...s}){const{t:r}=oe();return e.jsxs(c,{...s,color:"warning.main",fontSize:"14px",sx:{border:"1px solid rgba(214, 164, 64, 0.34)",borderRadius:"4px",py:2,px:1.5,position:"relative"},children:[e.jsx(L,{variant:"caption",sx:{fontWeight:"bold",position:"absolute",top:-10,left:12,backgroundColor:"white",px:1,width:"fit-content"},children:r("blocklet.publish.storeRule.warning")}),t&&Object.entries(t).map(([l,a])=>{const n=Object.values(a),u=o.find(d=>d.url===l);return n.length>0&&e.jsxs(c,{children:[e.jsx(me,{title:l,children:e.jsx(c,{component:"span",sx:{cursor:"pointer"},children:u.name})}),n.map(d=>e.jsx(c,{component:"li",ml:2,breakWords:!0,children:d},d))]},l)})]})}xt.propTypes={errors:i.object.isRequired,storeList:i.array.isRequired};const jo=j.lazy(()=>Oo(()=>import("./index-D22lazSG.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12])).then(t=>({default:t.Uploader})));function ss({projectId:t,readOnly:o,loading:s,blocklet:r,params:l,setParams:a,paramsErrTip:n,setParamsErrTip:u,warning:d,setLoading:f,initUrl:x,initLogoUrl:S,setInitLogoUrl:C,componentDid:p}){const{t:h,locale:R}=oe(),{api:w}=ye(),k=gt(),I=j.useRef(null),v=j.useRef(null),[D,_]=lr(r),[q,E]=j.useState(!1),M=ln({messageType:"connect-store-message",onOpen:()=>f(!0),onClose:()=>f(!1)}),$=async P=>{const F=setTimeout(()=>{f(!1)},2e4),X=await cr(w,P);f(!1),clearTimeout(F),window.parent.postMessage({event:"studioDialog.connected",componentDid:p},"*"),k(window.location.pathname.replace(`${Y.UNOWNED_DID}/create`,`${X}/create`),{replace:!0})},Q=()=>{if(!l.blockletTitle){U.error(h("blocklet.publish.errorTip.noTitle"));return}if(!(D!=null&&D.url)){U.error(h("blocklet.publish.noStoreSelected"));return}const P=ir();M(async(F,X)=>{var ee,Z,ie;try{const K=await w.connectByStudio({input:{did:(ee=r==null?void 0:r.meta)==null?void 0:ee.did,blockletTitle:l==null?void 0:l.blockletTitle,storeUrl:D.url,storeId:D.id,storeName:D.name,type:((Z=l==null?void 0:l.blockletComponents)==null?void 0:Z.length)>0?"pack":"resource",componentDid:p,messageId:P,tenantScope:(x==null?void 0:x.searchParams.get("tenantScope"))||""}});if(!(K!=null&&K.url)){U.error("failed to connect to store");return}X(K.url),$({did:(ie=r==null?void 0:r.meta)==null?void 0:ie.did,projectId:"",messageId:P})}catch(K){const de=Ne(K);U.error(de),f(!1)}})},{logoUrl:O,screenshotUrls:m,uploadLogoPrefix:b,uploadScreenshotPrefix:y}=ts(l,r,t),{logoErrors:W,screenshotErrors:z,storeList:G,hasLogoWarning:g,hasScreenshotWarning:N}=d,H=()=>o?!1:!t||t===Y.UNOWNED_DID?(U.error(h("blocklet.publish.errorTip.noFirstDid")),!1):!0,J=P=>{if(!P.destination)return;const F=Array.from(l.blockletScreenshots),[X]=F.splice(P.source.index,1);F.splice(P.destination.index,0,X),a(ee=>({...ee,blockletScreenshots:F}))},ze=P=>{if(!P.destination)return;const F=Array.from(l.blockletVideos),[X]=F.splice(P.source.index,1);F.splice(P.destination.index,0,X),a(ee=>({...ee,blockletVideos:F}))};return e.jsxs(hr,{children:[e.jsx(c,{display:"flex",className:"section",children:e.jsxs(c,{sx:{flex:1},children:[e.jsx(se,{disabled:s||o,label:`Blocklet ${h("common.title")}`,placeholder:`Blocklet ${h("common.title")}`,InputProps:{"data-cy":"blocklet-title",readOnly:o},autoComplete:"off",variant:"outlined",fullWidth:!0,required:!0,value:l.blockletTitle||"",onChange:P=>{u({blockletTitle:""}),a({blockletTitle:P.target.value})},error:!!n.blockletTitle,helperText:n.blockletTitle||""}),e.jsx(se,{required:!0,label:"Blocklet DID",fullWidth:!0,readonly:!0,disabled:!0,autoComplete:"off",variant:"outlined",InputProps:{"data-cy":"export-blocklet-did",endAdornment:t===Y.UNOWNED_DID&&e.jsx(Ve,{position:"end",children:e.jsx(Ut,{blocklet:r,store:D,componentDid:p,onChangeStore:_,disabled:!l.blockletTitle||o||s,loading:s,onClick:Q})})},error:!!n.projectId,helperText:n.projectId||"",value:t===Y.UNOWNED_DID?"":`did:abt:${t}`,sx:{mt:3}}),e.jsx(se,{disabled:s||o,label:`Blocklet ${h("common.description")}`,placeholder:`Blocklet ${h("common.description")}`,InputProps:{"data-cy":"blocklet-description",readOnly:o},required:!0,autoComplete:"off",variant:"outlined",fullWidth:!0,value:l.blockletDescription||"",onChange:P=>{u({blockletDescription:""}),a({blockletDescription:P.target.value})},error:!!n.blockletDescription,helperText:n.blockletDescription||"",sx:{mt:3}}),e.jsx(se,{disabled:s||o,label:`Blocklet ${h("common.homepageTip")}`,placeholder:`Blocklet ${h("common.homepageTip")}`,InputProps:{"data-cy":"blocklet-homepage",readOnly:o},autoComplete:"off",variant:"outlined",fullWidth:!0,value:l.blockletHomepage||"",onChange:P=>{P.target.value&&!/^(http|https):\/\//.test(P.target.value)?u({blockletHomepage:h("blocklet.publish.errorTip.invalidUrl")}):u({blockletHomepage:""}),a({blockletHomepage:P.target.value})},error:!!n.blockletHomepage,helperText:n.blockletHomepage||"",sx:{mt:3}}),e.jsx(se,{disabled:s||o,label:`Blocklet ${h("common.community")}`,placeholder:`Blocklet ${h("common.community")}`,InputProps:{"data-cy":"blocklet-community",readOnly:o},autoComplete:"off",variant:"outlined",fullWidth:!0,value:l.blockletCommunity||"",onChange:P=>{P.target.value&&!/^(http|https):\/\//.test(P.target.value)?u({blockletCommunity:h("blocklet.publish.errorTip.invalidUrl")}):u({blockletCommunity:""}),a({blockletCommunity:P.target.value})},error:!!n.blockletCommunity,helperText:n.blockletCommunity||"",sx:{mt:3}}),e.jsx(se,{disabled:s||o,label:`Blocklet ${h("common.support")}`,placeholder:`Blocklet ${h("common.support")}`,InputProps:{"data-cy":"blocklet-support",readOnly:o},autoComplete:"off",variant:"outlined",fullWidth:!0,value:l.blockletSupport||"",onChange:P=>{P.target.value&&!/^(http|https):\/\//.test(P.target.value)&&!/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/.test(P.target.value)?u({blockletSupport:h("blocklet.publish.errorTip.invalidUrlOrEmail")}):u({blockletSupport:""}),a({blockletSupport:P.target.value})},error:!!n.blockletSupport,helperText:n.blockletSupport||"",sx:{mt:3}}),e.jsx(se,{disabled:s||o,label:`Blocklet ${h("common.repository")}`,placeholder:`Blocklet ${h("common.repository")}`,InputProps:{"data-cy":"blocklet-repository",readOnly:o},autoComplete:"off",variant:"outlined",fullWidth:!0,value:l.blockletRepository||"",onChange:P=>{P.target.value&&!/^(git|https|svn)/.test(P.target.value)?u({blockletRepository:h("blocklet.publish.errorTip.invalidUrl")}):u({blockletRepository:""}),a({blockletRepository:P.target.value})},error:!!n.blockletRepository,helperText:n.blockletRepository||"",sx:{mt:3}})]})}),e.jsx(c,{display:"flex",mt:3,className:"section full-width",children:e.jsxs(c,{flex:1,overflow:"hidden",children:[e.jsxs(c,{display:"flex",flexDirection:"row",flexWrap:"wrap",children:[e.jsxs(Se,{direction:"column",spacing:1,sx:{mr:2,width:"160px"},children:[e.jsx(L,{variant:"subtitle1",sx:{fontWeight:"bold"},children:h("common.logo")}),e.jsxs(Se,{direction:"column",alignItems:"flex-start",spacing:1,sx:{opacity:.8,fontSize:"12px"},children:[e.jsx(c,{children:e.jsxs(c,{component:"span",children:[e.jsxs(c,{component:"span",sx:{color:"#555"},children:[h("studio.type"),":"," "]}),e.jsx(c,{component:"span",sx:{color:"#007ec6"},children:"png, jpg, webp, svg"})]})}),e.jsx(c,{children:e.jsxs(c,{component:"span",children:[e.jsxs(c,{component:"span",sx:{color:"#555"},children:[h("studio.ratio"),":"," "]}),e.jsx(c,{component:"span",sx:{color:"#007ec6"},children:"256x256"})]})}),e.jsx(c,{children:e.jsxs(c,{component:"span",children:[e.jsxs(c,{component:"span",sx:{color:"#555"},children:[h("studio.size"),":"," "]}),e.jsx(c,{component:"span",sx:{color:"#007ec6"},children:"<500Kb"})]})})]})]}),e.jsx(c,{sx:{flex:1,cursor:o?"default":"pointer",display:"flex",alignItems:"flex-end"},children:e.jsx(wo,{variant:"square",sx:{width:80,height:80},alt:"Blocklet Logo",src:S||O,onClick:()=>{var P;H()&&((P=I.current)==null||P.open())}})})]}),g&&e.jsx(xt,{errors:W,storeList:G,mt:3}),e.jsxs(c,{display:"flex",mt:3,flexDirection:"row",flexWrap:"wrap",children:[e.jsxs(Se,{direction:"column",spacing:1,sx:{mr:2,width:"160px"},children:[e.jsx(L,{variant:"subtitle1",sx:{fontWeight:"bold"},children:h("common.screenshot")}),e.jsxs(Se,{direction:"column",alignItems:"flex-start",spacing:1,sx:{opacity:.8,fontSize:"12px"},children:[e.jsx(c,{sx:{border:"none"},variant:"outlined",size:"small",children:e.jsxs(c,{component:"span",children:[e.jsxs(c,{component:"span",sx:{color:"#555"},children:[h("studio.ratio"),":"," "]}),e.jsx(c,{component:"span",sx:{color:"#007ec6"},children:"16 / 9"})]})}),e.jsx(c,{children:e.jsxs(c,{component:"span",children:[e.jsxs(c,{component:"span",sx:{color:"#555"},children:[h("studio.count"),":"," "]}),e.jsx(c,{component:"span",sx:{color:"#007ec6"},children:"1~5"})]})}),e.jsx(c,{children:e.jsxs(c,{component:"span",children:[e.jsxs(c,{component:"span",sx:{color:"#555"},children:[h("studio.size"),":"," "]}),e.jsx(c,{component:"span",sx:{color:"#007ec6"},children:"<5MB"})]})}),!o&&e.jsx(c,{children:e.jsxs(c,{component:"span",children:[e.jsxs(c,{component:"span",sx:{color:"#555"},children:[h("studio.order"),":"," "]}),e.jsx(c,{component:"span",sx:{color:"#007ec6"},children:h("studio.orderTip")})]})})]})]}),e.jsx(ao,{onDragEnd:o?void 0:J,children:e.jsx(uo,{droppableId:"screenshots",direction:"horizontal",isDropDisabled:o,children:(P,F)=>e.jsxs(c,{display:"flex",alignItems:"center",sx:{flex:1,flexWrap:"wrap",minHeight:160,background:F.isDraggingOver?"#f5f5f5":"transparent",transition:"background-color 0.2s ease",border:F.isDraggingOver?"2px dashed #999":"none",borderRadius:"4px"},ref:P.innerRef,...P.droppableProps,children:[m.map((X,ee)=>e.jsx(po,{draggableId:X,index:ee,isDragDisabled:o,children:(Z,ie)=>e.jsxs(c,{ref:Z.innerRef,...Z.draggableProps,className:"screenshot",sx:{transform:ie.isDragging?"scale(1.05)":"none",boxShadow:ie.isDragging?"0 5px 10px rgba(0,0,0,0.15)":"none",transition:"transform 0.2s ease, box-shadow 0.2s ease"},children:[e.jsx("img",{alt:"screenshot",src:X}),!o&&e.jsx(ce,{...Z.dragHandleProps,className:"action",style:{right:40,zIndex:10,color:"#fff"},children:e.jsx(bt,{})}),!o&&e.jsx(ce,{className:"action",onClick:()=>{a(K=>{const de=[...K.blockletScreenshots];return de.splice(ee,1),{...K,blockletScreenshots:de}})},children:e.jsx(co,{})})]})},X)),P.placeholder,m.length<5&&e.jsx(c,{sx:{width:240,height:135,background:"#eee",cursor:o?"default":"pointer",color:"#999",mb:2},display:"flex",justifyContent:"center",alignItems:"center",fontSize:40,onClick:()=>{var X;H()&&((X=v.current)==null||X.open())},children:"+"})]})})})]}),N&&e.jsx(xt,{errors:z,storeList:G}),e.jsxs(c,{display:"flex",mt:3,flexDirection:"row",flexWrap:"wrap",children:[e.jsxs(Se,{direction:"column",spacing:1,sx:{mr:2,width:"160px"},children:[e.jsx(L,{variant:"subtitle1",sx:{fontWeight:"bold"},children:h("studio.video")}),e.jsxs(Se,{direction:"column",alignItems:"flex-start",spacing:1,sx:{opacity:.8,fontSize:"12px"},children:[e.jsx(c,{children:e.jsxs(c,{component:"span",children:[e.jsxs(c,{component:"span",sx:{color:"#555"},children:[h("studio.videoType"),":"," "]}),e.jsxs(c,{component:"span",sx:{color:"#007ec6"},children:[e.jsx("a",{href:"https://www.youtube.com/",target:"_blank",rel:"noreferrer",children:"Youtube"}),","," ",e.jsx("a",{href:"https://vimeo.com/",target:"_blank",rel:"noreferrer",children:"Vimeo"})]})]})}),e.jsx(c,{children:e.jsxs(c,{component:"span",children:[e.jsxs(c,{component:"span",sx:{color:"#555"},children:[h("studio.count"),":"," "]}),e.jsx(c,{component:"span",sx:{color:"#007ec6"},children:"1~3"})]})}),!o&&e.jsx(c,{children:e.jsxs(c,{component:"span",children:[e.jsxs(c,{component:"span",sx:{color:"#555"},children:[h("studio.order"),":"," "]}),e.jsx(c,{component:"span",sx:{color:"#007ec6"},children:h("studio.orderTip")})]})})]})]}),e.jsx(ao,{onDragEnd:o?void 0:ze,children:e.jsx(uo,{droppableId:"videos",direction:"horizontal",isDropDisabled:o,children:(P,F)=>e.jsxs(c,{display:"flex",alignItems:"center",sx:{flex:1,flexWrap:"wrap",minHeight:160,background:F.isDraggingOver?"#f5f5f5":"transparent",transition:"background-color 0.2s ease",border:F.isDraggingOver?"2px dashed #999":"none",borderRadius:"4px"},ref:P.innerRef,...P.droppableProps,children:[l.blockletVideos.map((X,ee)=>e.jsx(po,{draggableId:X,index:ee,isDragDisabled:o,children:(Z,ie)=>e.jsxs(c,{ref:Z.innerRef,...Z.draggableProps,className:"screenshot",sx:{transform:ie.isDragging?"scale(1.05)":"none",boxShadow:ie.isDragging?"0 5px 10px rgba(0,0,0,0.15)":"none",transition:"transform 0.2s ease, box-shadow 0.2s ease"},children:[e.jsx(st,{url:X,style:{pointerEvents:ie.isDragging?"none":"auto"}}),!o&&e.jsx(ce,{...Z.dragHandleProps,className:"action",style:{right:40,zIndex:10,color:"#fff"},children:e.jsx(bt,{})}),!o&&e.jsx(ce,{className:"action",onClick:()=>{a(K=>{const de=[...K.blockletVideos];return de.splice(ee,1),{...K,blockletVideos:de}})},children:e.jsx(co,{})})]})},X)),P.placeholder,l.blockletVideos.length<3&&e.jsx(c,{sx:{width:240,height:135,background:"#eee",cursor:o?"default":"pointer",color:"#999",mb:2},display:"flex",justifyContent:"center",alignItems:"center",fontSize:40,onClick:()=>{H()&&E(!0)},children:"+"})]})})})]})]})}),e.jsxs(j.Suspense,{fallback:e.jsx(Fe,{}),children:[e.jsx(jo,{ref:I,locale:R,popup:!0,onUploadFinish:P=>{var F;a({blockletLogo:P.data.filename}),C(""),(F=I.current)==null||F.close()},plugins:["ImageEditor"],installerProps:{disabled:!0},apiPathProps:{uploader:b,disableMediaKitPrefix:!0,disableMediaKitStatus:!0},coreProps:{restrictions:{allowedFileTypes:["image/png","image/jpeg","image/webp","image/svg+xml"],maxFileSize:1024*1024*.5,maxNumberOfFiles:1}},dashboardProps:{autoOpen:"imageEditor"},imageEditorProps:{actions:{revert:!0,rotate:!0,granularRotate:!0,flip:!0,zoomIn:!0,zoomOut:!0,cropSquare:!1,cropWidescreen:!1,cropWidescreenVertical:!1},cropperOptions:{autoCrop:!0,aspectRatio:1,initialAspectRatio:1,autoCropArea:1,croppedCanvasOptions:{minWidth:256,minHeight:256}}}},"uploader-logo"),q&&e.jsx(os,{onClose:()=>E(!1),params:l,setParams:a}),e.jsx(jo,{ref:v,locale:R,popup:!0,onUploadFinish:P=>{var F;a(X=>{var Z;const ee=X.blockletScreenshots||[];return ee.push((Z=P.data)==null?void 0:Z.filename),{...X,blockletScreenshots:ee}}),(F=v.current)==null||F.close()},installerProps:{disabled:!0},plugins:["ImageEditor"],apiPathProps:{uploader:y,disableMediaKitPrefix:!0,disableMediaKitStatus:!0},coreProps:{restrictions:{allowedFileTypes:["image/*","image/svg+xml"],maxFileSize:1024*1024*5,maxNumberOfFiles:5-m.length}},imageEditorProps:{actions:{revert:!0,rotate:!0,granularRotate:!0,flip:!0,zoomIn:!0,zoomOut:!0,cropSquare:!1,cropWidescreen:!1,cropWidescreenVertical:!1},cropperOptions:{autoCrop:!0,autoCropArea:1,aspectRatio:16/9,initialAspectRatio:16/9,croppedCanvasOptions:{minWidth:1280,minHeight:720,maxWidth:1280*2,maxHeight:720*2}}}},"uploader-screenshot")]})]})}ss.propTypes={projectId:i.string.isRequired,readOnly:i.bool.isRequired,params:i.object.isRequired,setParams:i.func.isRequired,paramsErrTip:i.object.isRequired,setParamsErrTip:i.func.isRequired,warning:i.object.isRequired,loading:i.bool.isRequired,blocklet:i.object.isRequired,setLoading:i.func.isRequired,initUrl:i.object.isRequired,componentDid:i.isRequired,initLogoUrl:i.string.isRequired,setInitLogoUrl:i.func.isRequired};const hr=ge.div`
128
+ `;var Mt={},sr=ke;Object.defineProperty(Mt,"__esModule",{value:!0});var bt=Mt.default=void 0,nr=sr(Re()),rr=e;bt=Mt.default=(0,nr.default)((0,rr.jsx)("path",{d:"M11 18c0 1.1-.9 2-2 2s-2-.9-2-2 .9-2 2-2 2 .9 2 2m-2-8c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2m0-6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2m6 4c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2m0 2c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2m0 6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2"}),"DragIndicator");const go="lastWantToConnectStoreId";function lr(t){var u,d;const[o,s]=j.useState(null),{session:r}=Ue(),l=j.useCallback(f=>{s(f),localStorage.setItem(go,f==null?void 0:f.id)},[s]),a=j.useMemo(()=>{var C,p,h,R;const f=localStorage.getItem(go),x=f?(((C=t==null?void 0:t.settings)==null?void 0:C.storeList)||[]).find(w=>w.id===f):null;if(x)return x;let S=(((p=t==null?void 0:t.settings)==null?void 0:p.storeList)||[]).find(w=>{var k;return!(w.id!==Y.BLOCKLET_STORE.id||w.scope&&w.scope!=="studio"&&w.scope!==((k=r==null?void 0:r.user)==null?void 0:k.did))});return S||(S=(R=(h=t==null?void 0:t.settings)==null?void 0:h.storeList)==null?void 0:R[0]),S},[(u=t==null?void 0:t.settings)==null?void 0:u.storeList,(d=r==null?void 0:r.user)==null?void 0:d.did]);return[o||a||{},l]}const pt={};async function es(t,{interval:o=1e3,maxDuration:s=120*1e3,intervalFirst:r=4e3,timerKey:l=""}){pt[l]&&clearTimeout(pt[l]),await new Promise(u=>setTimeout(u,r));const a=Date.now(),n=async(u,d)=>{try{const f=await t();u(f)}catch(f){Date.now()-a>s?d(f):l?pt[l]=setTimeout(()=>n(u,d),o):setTimeout(()=>n(u,d),o)}};return new Promise(n)}function ir(){return Math.random().toString(36).slice(2)+Math.random().toString(36).slice(2)+`${Date.now()}`.slice(-6)}function cr(t,{did:o,projectId:s,messageId:r}){return es(async()=>{var a;const l=await t.getProject({input:{did:o,projectId:s,messageId:r}});if(!((a=l==null?void 0:l.project)!=null&&a.blockletDid))throw new Error("Connected store not found");return l.project.blockletDid},{timerKey:"connect-studio"})}function ar(t,{did:o,projectId:s,storeId:r}){return es(async()=>{var n,u;const l=await t.getProject({input:{did:o,projectId:s,messageId:""}});if(!((u=(n=l==null?void 0:l.project)==null?void 0:n.connectedStores)!=null&&u.length))throw new Error("Connected store not found");if(!l.project.connectedStores.find(d=>d.storeId===r))throw new Error("Connected store not found")},{timerKey:`connect-store-${r}`})}const dr=({fromBlocklet:t,nodeInfo:o,blocklet:s,userDid:r})=>{var n,u;const l=t?(n=s==null?void 0:s.meta)==null?void 0:n.did:o==null?void 0:o.did;let a=t?((u=s==null?void 0:s.settings)==null?void 0:u.storeList)||[]:(o==null?void 0:o.blockletRegistryList)||[];return Array.isArray(a)||(a=[]),a=a.filter(d=>d.protected||!d.scope||d.scope==="studio"||d.scope===r),{teamDid:l,storeList:a}},Vt=dr;function Ut({blocklet:t,store:o={},onChangeStore:s,onClick:r,disabled:l,loading:a,componentDid:n}){var m,b,y;const{t:u}=oe(),{session:d}=Ue(),{api:f,info:x,inService:S}=ye(),C=Ee(),[p,h]=j.useState(!1),R=j.useRef(null),[w,k]=j.useState(!1),[I,v]=j.useState(null),D=W=>{s(W),h(!1)},_=()=>{h(!p)},q=W=>{R.current&&R.current.contains(W.target)||h(!1)},E=()=>{k(!0)},M=()=>{k(!1)},$=async()=>{var W;if(I)try{await f.deleteBlockletStore({input:{teamDid:t.meta.did,url:I.url,projectId:"",scope:I.scope||"studio"}}),await((W=C==null?void 0:C.actions)==null?void 0:W.refreshBlocklet())}catch(z){U.error(`Remove Blocklet Store Error: ${Ne(z)}`)}finally{v(null)}},{storeList:Q}=Vt({fromBlocklet:S,blocklet:t,nodeInfo:x,componentDid:n,userDid:(m=d==null?void 0:d.user)==null?void 0:m.did}),O=(b=t==null?void 0:t.meta)==null?void 0:b.did;return e.jsxs(e.Fragment,{children:[e.jsxs(ht,{disabled:l,ref:R,variant:"contained",color:"primary","aria-label":"Button group with connect store",children:[e.jsxs(ne,{onClick:r,children:[a&&e.jsx(Ye,{size:14,sx:{mr:.5}}),`${u("common.connect")} ${o.name||""}`]}),e.jsx(ne,{size:"small","aria-controls":p?"split-button-menu":void 0,"aria-expanded":p?"true":void 0,"aria-label":"select merge strategy","aria-haspopup":"menu",onClick:_,children:e.jsx(fn,{})})]}),e.jsx(Do,{sx:{zIndex:10},open:p,anchorEl:R.current,placement:"bottom-end",role:void 0,transition:!0,disablePortal:!0,children:({TransitionProps:W})=>e.jsx(To,{...W,style:{transformOrigin:"center top"},children:e.jsx(jt,{children:e.jsx(_o,{onClickAway:q,children:e.jsxs(Po,{id:"split-button-menu",autoFocusItem:!0,sx:{maxHeight:300,overflowY:"auto",zIndex:10},children:[Q==null?void 0:Q.map(z=>{var G;return e.jsxs(fe,{selected:z.id===(o==null?void 0:o.id),sx:{height:56},onClick:()=>D(z),children:[e.jsxs(c,{children:[e.jsx(je,{sx:{fontSize:"16px"},maxLength:24,children:z.name}),e.jsx(je,{sx:{fontSize:"13px",opacity:.6},maxLength:30,children:z.url})]}),rn({store:z,userDid:(G=d==null?void 0:d.user)==null?void 0:G.did})&&e.jsx(ce,{sx:{ml:1},onClick:g=>{g.preventDefault(),g.stopPropagation(),v(z)},children:e.jsx(ae,{icon:"ic:outline-delete"})})]},z.url)}),e.jsx(Ss,{}),e.jsxs(fe,{onClick:E,children:[e.jsx(Rt,{font:!0}),e.jsx(L,{variant:"inherit",children:u("store.blockletRegistry.addRegistry")})]})]})})})})}),w&&e.jsx(Vo,{hiddenChildren:!0,open:!0,onClose:M,teamDid:O,storeList:Q,scope:"studio",onAdd:(y=C==null?void 0:C.actions)==null?void 0:y.refreshBlocklet}),I&&e.jsx(vt,{displayError:!0,title:`${u("common.delete")} ${I.name}`,description:u("blocklet.publish.deleteStoreTip",{name:I.name}),confirm:u("common.confirm"),onConfirm:$,onCancel:()=>v(null)})]})}Ut.propTypes={store:i.object,blocklet:i.object,onChangeStore:i.func.isRequired,onClick:i.func.isRequired,loading:i.bool.isRequired,disabled:i.bool.isRequired,componentDid:i.string.isRequired,projectType:i.string.isRequired,getData:i.func.isRequired};Ut.defaultProps={store:null,blocklet:null};const ur=(t,o,s)=>{const r=`${Y.WELLKNOWN_SERVICE_PATH_PREFIX}/api/project/${o.meta.did}/${s}/logo/upload`,l=`${Y.WELLKNOWN_SERVICE_PATH_PREFIX}/api/project/${o.meta.did}/${s}/screenshot/upload`,a=t!=null&&t.blockletLogo?`${r}/${t.blockletLogo}`:`${Y.WELLKNOWN_SERVICE_PATH_PREFIX}/static/images/logo.png`,n=((t==null?void 0:t.blockletScreenshots)||[]).filter(Boolean).map(u=>`${l}/${u}`);return{logoUrl:a,screenshotUrls:n,uploadLogoPrefix:r,uploadScreenshotPrefix:l}},ts=ur,pr=t=>{const o=t.includes("youtube.com")||t.includes("youtu.be"),s=t.includes("vimeo.com");return o||s};function st({url:t,style:o,controls:s,modestbranding:r}){var u;const{t:l}=oe(),a=t.includes("youtube.com")||t.includes("youtu.be"),n=t.includes("vimeo.com");if(a){const d=((u=t.split("v=")[1])==null?void 0:u.split("&")[0])||t.split("/").pop();return e.jsx("div",{style:{position:"relative",width:"100%",paddingTop:"56.25%",pointerEvents:(o==null?void 0:o.pointerEvents)||"auto"},children:e.jsx("iframe",{src:`https://www.youtube.com/embed/${d}?modestbranding=${r}&controls=${s}&rel=0`,title:"YouTube video player",style:{position:"absolute",top:0,left:0,width:"100%",height:"100%",border:"none",...o},allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0})})}if(n){const d=t.split("/").pop();return e.jsx("div",{style:{position:"relative",width:"100%",paddingTop:"56.25%",pointerEvents:o.pointerEvents||"auto"},children:e.jsx("iframe",{src:`https://player.vimeo.com/video/${d}`,title:"Vimeo video player",style:{position:"absolute",top:0,left:0,width:"100%",height:"100%",border:"none",...o},allow:"autoplay; fullscreen; picture-in-picture",allowFullScreen:!0})})}return e.jsx(c,{style:{position:"relative",width:"100%",paddingTop:"56.25%"},children:e.jsxs(c,{style:{position:"absolute",top:0,left:0,width:"100%",height:"100%",border:"none",backgroundColor:"rgba(0, 0, 0, 0.04)",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",...o},allow:"autoplay; fullscreen; picture-in-picture",allowFullScreen:!0,children:[e.jsx(ae,{icon:"carbon:video-off",style:{fontSize:40,marginBottom:"10px",opacity:.5}}),e.jsx(L,{variant:"body1",sx:{opacity:.5},children:l("studio.videoDialogNoSrc")})]})})}st.propTypes={url:i.string.isRequired,style:i.object,controls:i.number,modestbranding:i.number};st.defaultProps={style:{},controls:1,modestbranding:1};function os({setParams:t,onClose:o,params:s}){const{t:r}=oe(),[l,a]=j.useState(""),n=l&&s.blockletVideos.includes(l),u=pr(l),d=()=>{t(f=>{const x=[...f.blockletVideos];return x.push(l),{...f,blockletVideos:x}}),o()};return e.jsxs(ot,{open:!0,fullWidth:!0,maxWidth:"sm",children:[e.jsx($o,{children:r("studio.videoDialogTitle")}),e.jsxs(qo,{children:[e.jsx(Is,{fullWidth:!0,value:l,onChange:f=>a(f.target.value),placeholder:r("studio.videoInputLabel"),endAdornment:l?e.jsx(Ve,{position:"end",children:e.jsx(ce,{onClick:()=>a(""),children:e.jsx(Hs,{})})}):null,error:n}),n&&e.jsx(L,{variant:"body2",color:"error",children:r("studio.duplicateVideo")}),e.jsx(st,{url:l,style:{marginTop:"20px",borderRadius:"4px"}})]}),e.jsxs(Lo,{children:[e.jsx(ne,{onClick:()=>o(),children:r("studio.cancel")}),e.jsx(ne,{disabled:!u||n,onClick:d,children:r("studio.confirm")})]})]})}os.propTypes={onClose:i.func.isRequired,params:i.object.isRequired,setParams:i.func.isRequired};function xt({errors:t,storeList:o,...s}){const{t:r}=oe();return e.jsxs(c,{...s,color:"warning.main",fontSize:"14px",sx:{border:"1px solid rgba(214, 164, 64, 0.34)",borderRadius:"4px",py:2,px:1.5,position:"relative"},children:[e.jsx(L,{variant:"caption",sx:{fontWeight:"bold",position:"absolute",top:-10,left:12,backgroundColor:"white",px:1,width:"fit-content"},children:r("blocklet.publish.storeRule.warning")}),t&&Object.entries(t).map(([l,a])=>{const n=Object.values(a),u=o.find(d=>d.url===l);return n.length>0&&e.jsxs(c,{children:[e.jsx(me,{title:l,children:e.jsx(c,{component:"span",sx:{cursor:"pointer"},children:u.name})}),n.map(d=>e.jsx(c,{component:"li",ml:2,breakWords:!0,children:d},d))]},l)})]})}xt.propTypes={errors:i.object.isRequired,storeList:i.array.isRequired};const jo=j.lazy(()=>Oo(()=>import("./index-B64a4BbE.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12])).then(t=>({default:t.Uploader})));function ss({projectId:t,readOnly:o,loading:s,blocklet:r,params:l,setParams:a,paramsErrTip:n,setParamsErrTip:u,warning:d,setLoading:f,initUrl:x,initLogoUrl:S,setInitLogoUrl:C,componentDid:p}){const{t:h,locale:R}=oe(),{api:w}=ye(),k=gt(),I=j.useRef(null),v=j.useRef(null),[D,_]=lr(r),[q,E]=j.useState(!1),M=ln({messageType:"connect-store-message",onOpen:()=>f(!0),onClose:()=>f(!1)}),$=async P=>{const F=setTimeout(()=>{f(!1)},2e4),X=await cr(w,P);f(!1),clearTimeout(F),window.parent.postMessage({event:"studioDialog.connected",componentDid:p},"*"),k(window.location.pathname.replace(`${Y.UNOWNED_DID}/create`,`${X}/create`),{replace:!0})},Q=()=>{if(!l.blockletTitle){U.error(h("blocklet.publish.errorTip.noTitle"));return}if(!(D!=null&&D.url)){U.error(h("blocklet.publish.noStoreSelected"));return}const P=ir();M(async(F,X)=>{var ee,Z,ie;try{const K=await w.connectByStudio({input:{did:(ee=r==null?void 0:r.meta)==null?void 0:ee.did,blockletTitle:l==null?void 0:l.blockletTitle,storeUrl:D.url,storeId:D.id,storeName:D.name,type:((Z=l==null?void 0:l.blockletComponents)==null?void 0:Z.length)>0?"pack":"resource",componentDid:p,messageId:P,tenantScope:(x==null?void 0:x.searchParams.get("tenantScope"))||""}});if(!(K!=null&&K.url)){U.error("failed to connect to store");return}X(K.url),$({did:(ie=r==null?void 0:r.meta)==null?void 0:ie.did,projectId:"",messageId:P})}catch(K){const de=Ne(K);U.error(de),f(!1)}})},{logoUrl:O,screenshotUrls:m,uploadLogoPrefix:b,uploadScreenshotPrefix:y}=ts(l,r,t),{logoErrors:W,screenshotErrors:z,storeList:G,hasLogoWarning:g,hasScreenshotWarning:N}=d,H=()=>o?!1:!t||t===Y.UNOWNED_DID?(U.error(h("blocklet.publish.errorTip.noFirstDid")),!1):!0,J=P=>{if(!P.destination)return;const F=Array.from(l.blockletScreenshots),[X]=F.splice(P.source.index,1);F.splice(P.destination.index,0,X),a(ee=>({...ee,blockletScreenshots:F}))},ze=P=>{if(!P.destination)return;const F=Array.from(l.blockletVideos),[X]=F.splice(P.source.index,1);F.splice(P.destination.index,0,X),a(ee=>({...ee,blockletVideos:F}))};return e.jsxs(hr,{children:[e.jsx(c,{display:"flex",className:"section",children:e.jsxs(c,{sx:{flex:1},children:[e.jsx(se,{disabled:s||o,label:`Blocklet ${h("common.title")}`,placeholder:`Blocklet ${h("common.title")}`,InputProps:{"data-cy":"blocklet-title",readOnly:o},autoComplete:"off",variant:"outlined",fullWidth:!0,required:!0,value:l.blockletTitle||"",onChange:P=>{u({blockletTitle:""}),a({blockletTitle:P.target.value})},error:!!n.blockletTitle,helperText:n.blockletTitle||""}),e.jsx(se,{required:!0,label:"Blocklet DID",fullWidth:!0,readonly:!0,disabled:!0,autoComplete:"off",variant:"outlined",InputProps:{"data-cy":"export-blocklet-did",endAdornment:t===Y.UNOWNED_DID&&e.jsx(Ve,{position:"end",children:e.jsx(Ut,{blocklet:r,store:D,componentDid:p,onChangeStore:_,disabled:!l.blockletTitle||o||s,loading:s,onClick:Q})})},error:!!n.projectId,helperText:n.projectId||"",value:t===Y.UNOWNED_DID?"":`did:abt:${t}`,sx:{mt:3}}),e.jsx(se,{disabled:s||o,label:`Blocklet ${h("common.description")}`,placeholder:`Blocklet ${h("common.description")}`,InputProps:{"data-cy":"blocklet-description",readOnly:o},required:!0,autoComplete:"off",variant:"outlined",fullWidth:!0,value:l.blockletDescription||"",onChange:P=>{u({blockletDescription:""}),a({blockletDescription:P.target.value})},error:!!n.blockletDescription,helperText:n.blockletDescription||"",sx:{mt:3}}),e.jsx(se,{disabled:s||o,label:`Blocklet ${h("common.homepageTip")}`,placeholder:`Blocklet ${h("common.homepageTip")}`,InputProps:{"data-cy":"blocklet-homepage",readOnly:o},autoComplete:"off",variant:"outlined",fullWidth:!0,value:l.blockletHomepage||"",onChange:P=>{P.target.value&&!/^(http|https):\/\//.test(P.target.value)?u({blockletHomepage:h("blocklet.publish.errorTip.invalidUrl")}):u({blockletHomepage:""}),a({blockletHomepage:P.target.value})},error:!!n.blockletHomepage,helperText:n.blockletHomepage||"",sx:{mt:3}}),e.jsx(se,{disabled:s||o,label:`Blocklet ${h("common.community")}`,placeholder:`Blocklet ${h("common.community")}`,InputProps:{"data-cy":"blocklet-community",readOnly:o},autoComplete:"off",variant:"outlined",fullWidth:!0,value:l.blockletCommunity||"",onChange:P=>{P.target.value&&!/^(http|https):\/\//.test(P.target.value)?u({blockletCommunity:h("blocklet.publish.errorTip.invalidUrl")}):u({blockletCommunity:""}),a({blockletCommunity:P.target.value})},error:!!n.blockletCommunity,helperText:n.blockletCommunity||"",sx:{mt:3}}),e.jsx(se,{disabled:s||o,label:`Blocklet ${h("common.support")}`,placeholder:`Blocklet ${h("common.support")}`,InputProps:{"data-cy":"blocklet-support",readOnly:o},autoComplete:"off",variant:"outlined",fullWidth:!0,value:l.blockletSupport||"",onChange:P=>{P.target.value&&!/^(http|https):\/\//.test(P.target.value)&&!/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/.test(P.target.value)?u({blockletSupport:h("blocklet.publish.errorTip.invalidUrlOrEmail")}):u({blockletSupport:""}),a({blockletSupport:P.target.value})},error:!!n.blockletSupport,helperText:n.blockletSupport||"",sx:{mt:3}}),e.jsx(se,{disabled:s||o,label:`Blocklet ${h("common.repository")}`,placeholder:`Blocklet ${h("common.repository")}`,InputProps:{"data-cy":"blocklet-repository",readOnly:o},autoComplete:"off",variant:"outlined",fullWidth:!0,value:l.blockletRepository||"",onChange:P=>{P.target.value&&!/^(git|https|svn)/.test(P.target.value)?u({blockletRepository:h("blocklet.publish.errorTip.invalidUrl")}):u({blockletRepository:""}),a({blockletRepository:P.target.value})},error:!!n.blockletRepository,helperText:n.blockletRepository||"",sx:{mt:3}})]})}),e.jsx(c,{display:"flex",mt:3,className:"section full-width",children:e.jsxs(c,{flex:1,overflow:"hidden",children:[e.jsxs(c,{display:"flex",flexDirection:"row",flexWrap:"wrap",children:[e.jsxs(Se,{direction:"column",spacing:1,sx:{mr:2,width:"160px"},children:[e.jsx(L,{variant:"subtitle1",sx:{fontWeight:"bold"},children:h("common.logo")}),e.jsxs(Se,{direction:"column",alignItems:"flex-start",spacing:1,sx:{opacity:.8,fontSize:"12px"},children:[e.jsx(c,{children:e.jsxs(c,{component:"span",children:[e.jsxs(c,{component:"span",sx:{color:"#555"},children:[h("studio.type"),":"," "]}),e.jsx(c,{component:"span",sx:{color:"#007ec6"},children:"png, jpg, webp, svg"})]})}),e.jsx(c,{children:e.jsxs(c,{component:"span",children:[e.jsxs(c,{component:"span",sx:{color:"#555"},children:[h("studio.ratio"),":"," "]}),e.jsx(c,{component:"span",sx:{color:"#007ec6"},children:"256x256"})]})}),e.jsx(c,{children:e.jsxs(c,{component:"span",children:[e.jsxs(c,{component:"span",sx:{color:"#555"},children:[h("studio.size"),":"," "]}),e.jsx(c,{component:"span",sx:{color:"#007ec6"},children:"<500Kb"})]})})]})]}),e.jsx(c,{sx:{flex:1,cursor:o?"default":"pointer",display:"flex",alignItems:"flex-end"},children:e.jsx(wo,{variant:"square",sx:{width:80,height:80},alt:"Blocklet Logo",src:S||O,onClick:()=>{var P;H()&&((P=I.current)==null||P.open())}})})]}),g&&e.jsx(xt,{errors:W,storeList:G,mt:3}),e.jsxs(c,{display:"flex",mt:3,flexDirection:"row",flexWrap:"wrap",children:[e.jsxs(Se,{direction:"column",spacing:1,sx:{mr:2,width:"160px"},children:[e.jsx(L,{variant:"subtitle1",sx:{fontWeight:"bold"},children:h("common.screenshot")}),e.jsxs(Se,{direction:"column",alignItems:"flex-start",spacing:1,sx:{opacity:.8,fontSize:"12px"},children:[e.jsx(c,{sx:{border:"none"},variant:"outlined",size:"small",children:e.jsxs(c,{component:"span",children:[e.jsxs(c,{component:"span",sx:{color:"#555"},children:[h("studio.ratio"),":"," "]}),e.jsx(c,{component:"span",sx:{color:"#007ec6"},children:"16 / 9"})]})}),e.jsx(c,{children:e.jsxs(c,{component:"span",children:[e.jsxs(c,{component:"span",sx:{color:"#555"},children:[h("studio.count"),":"," "]}),e.jsx(c,{component:"span",sx:{color:"#007ec6"},children:"1~5"})]})}),e.jsx(c,{children:e.jsxs(c,{component:"span",children:[e.jsxs(c,{component:"span",sx:{color:"#555"},children:[h("studio.size"),":"," "]}),e.jsx(c,{component:"span",sx:{color:"#007ec6"},children:"<5MB"})]})}),!o&&e.jsx(c,{children:e.jsxs(c,{component:"span",children:[e.jsxs(c,{component:"span",sx:{color:"#555"},children:[h("studio.order"),":"," "]}),e.jsx(c,{component:"span",sx:{color:"#007ec6"},children:h("studio.orderTip")})]})})]})]}),e.jsx(ao,{onDragEnd:o?void 0:J,children:e.jsx(uo,{droppableId:"screenshots",direction:"horizontal",isDropDisabled:o,children:(P,F)=>e.jsxs(c,{display:"flex",alignItems:"center",sx:{flex:1,flexWrap:"wrap",minHeight:160,background:F.isDraggingOver?"#f5f5f5":"transparent",transition:"background-color 0.2s ease",border:F.isDraggingOver?"2px dashed #999":"none",borderRadius:"4px"},ref:P.innerRef,...P.droppableProps,children:[m.map((X,ee)=>e.jsx(po,{draggableId:X,index:ee,isDragDisabled:o,children:(Z,ie)=>e.jsxs(c,{ref:Z.innerRef,...Z.draggableProps,className:"screenshot",sx:{transform:ie.isDragging?"scale(1.05)":"none",boxShadow:ie.isDragging?"0 5px 10px rgba(0,0,0,0.15)":"none",transition:"transform 0.2s ease, box-shadow 0.2s ease"},children:[e.jsx("img",{alt:"screenshot",src:X}),!o&&e.jsx(ce,{...Z.dragHandleProps,className:"action",style:{right:40,zIndex:10,color:"#fff"},children:e.jsx(bt,{})}),!o&&e.jsx(ce,{className:"action",onClick:()=>{a(K=>{const de=[...K.blockletScreenshots];return de.splice(ee,1),{...K,blockletScreenshots:de}})},children:e.jsx(co,{})})]})},X)),P.placeholder,m.length<5&&e.jsx(c,{sx:{width:240,height:135,background:"#eee",cursor:o?"default":"pointer",color:"#999",mb:2},display:"flex",justifyContent:"center",alignItems:"center",fontSize:40,onClick:()=>{var X;H()&&((X=v.current)==null||X.open())},children:"+"})]})})})]}),N&&e.jsx(xt,{errors:z,storeList:G}),e.jsxs(c,{display:"flex",mt:3,flexDirection:"row",flexWrap:"wrap",children:[e.jsxs(Se,{direction:"column",spacing:1,sx:{mr:2,width:"160px"},children:[e.jsx(L,{variant:"subtitle1",sx:{fontWeight:"bold"},children:h("studio.video")}),e.jsxs(Se,{direction:"column",alignItems:"flex-start",spacing:1,sx:{opacity:.8,fontSize:"12px"},children:[e.jsx(c,{children:e.jsxs(c,{component:"span",children:[e.jsxs(c,{component:"span",sx:{color:"#555"},children:[h("studio.videoType"),":"," "]}),e.jsxs(c,{component:"span",sx:{color:"#007ec6"},children:[e.jsx("a",{href:"https://www.youtube.com/",target:"_blank",rel:"noreferrer",children:"Youtube"}),","," ",e.jsx("a",{href:"https://vimeo.com/",target:"_blank",rel:"noreferrer",children:"Vimeo"})]})]})}),e.jsx(c,{children:e.jsxs(c,{component:"span",children:[e.jsxs(c,{component:"span",sx:{color:"#555"},children:[h("studio.count"),":"," "]}),e.jsx(c,{component:"span",sx:{color:"#007ec6"},children:"1~3"})]})}),!o&&e.jsx(c,{children:e.jsxs(c,{component:"span",children:[e.jsxs(c,{component:"span",sx:{color:"#555"},children:[h("studio.order"),":"," "]}),e.jsx(c,{component:"span",sx:{color:"#007ec6"},children:h("studio.orderTip")})]})})]})]}),e.jsx(ao,{onDragEnd:o?void 0:ze,children:e.jsx(uo,{droppableId:"videos",direction:"horizontal",isDropDisabled:o,children:(P,F)=>e.jsxs(c,{display:"flex",alignItems:"center",sx:{flex:1,flexWrap:"wrap",minHeight:160,background:F.isDraggingOver?"#f5f5f5":"transparent",transition:"background-color 0.2s ease",border:F.isDraggingOver?"2px dashed #999":"none",borderRadius:"4px"},ref:P.innerRef,...P.droppableProps,children:[l.blockletVideos.map((X,ee)=>e.jsx(po,{draggableId:X,index:ee,isDragDisabled:o,children:(Z,ie)=>e.jsxs(c,{ref:Z.innerRef,...Z.draggableProps,className:"screenshot",sx:{transform:ie.isDragging?"scale(1.05)":"none",boxShadow:ie.isDragging?"0 5px 10px rgba(0,0,0,0.15)":"none",transition:"transform 0.2s ease, box-shadow 0.2s ease"},children:[e.jsx(st,{url:X,style:{pointerEvents:ie.isDragging?"none":"auto"}}),!o&&e.jsx(ce,{...Z.dragHandleProps,className:"action",style:{right:40,zIndex:10,color:"#fff"},children:e.jsx(bt,{})}),!o&&e.jsx(ce,{className:"action",onClick:()=>{a(K=>{const de=[...K.blockletVideos];return de.splice(ee,1),{...K,blockletVideos:de}})},children:e.jsx(co,{})})]})},X)),P.placeholder,l.blockletVideos.length<3&&e.jsx(c,{sx:{width:240,height:135,background:"#eee",cursor:o?"default":"pointer",color:"#999",mb:2},display:"flex",justifyContent:"center",alignItems:"center",fontSize:40,onClick:()=>{H()&&E(!0)},children:"+"})]})})})]})]})}),e.jsxs(j.Suspense,{fallback:e.jsx(Fe,{}),children:[e.jsx(jo,{ref:I,locale:R,popup:!0,onUploadFinish:P=>{var F;a({blockletLogo:P.data.filename}),C(""),(F=I.current)==null||F.close()},plugins:["ImageEditor"],installerProps:{disabled:!0},apiPathProps:{uploader:b,disableMediaKitPrefix:!0,disableMediaKitStatus:!0},coreProps:{restrictions:{allowedFileTypes:["image/png","image/jpeg","image/webp","image/svg+xml"],maxFileSize:1024*1024*.5,maxNumberOfFiles:1}},dashboardProps:{autoOpen:"imageEditor"},imageEditorProps:{actions:{revert:!0,rotate:!0,granularRotate:!0,flip:!0,zoomIn:!0,zoomOut:!0,cropSquare:!1,cropWidescreen:!1,cropWidescreenVertical:!1},cropperOptions:{autoCrop:!0,aspectRatio:1,initialAspectRatio:1,autoCropArea:1,croppedCanvasOptions:{minWidth:256,minHeight:256}}}},"uploader-logo"),q&&e.jsx(os,{onClose:()=>E(!1),params:l,setParams:a}),e.jsx(jo,{ref:v,locale:R,popup:!0,onUploadFinish:P=>{var F;a(X=>{var Z;const ee=X.blockletScreenshots||[];return ee.push((Z=P.data)==null?void 0:Z.filename),{...X,blockletScreenshots:ee}}),(F=v.current)==null||F.close()},installerProps:{disabled:!0},plugins:["ImageEditor"],apiPathProps:{uploader:y,disableMediaKitPrefix:!0,disableMediaKitStatus:!0},coreProps:{restrictions:{allowedFileTypes:["image/*","image/svg+xml"],maxFileSize:1024*1024*5,maxNumberOfFiles:5-m.length}},imageEditorProps:{actions:{revert:!0,rotate:!0,granularRotate:!0,flip:!0,zoomIn:!0,zoomOut:!0,cropSquare:!1,cropWidescreen:!1,cropWidescreenVertical:!1},cropperOptions:{autoCrop:!0,autoCropArea:1,aspectRatio:16/9,initialAspectRatio:16/9,croppedCanvasOptions:{minWidth:1280,minHeight:720,maxWidth:1280*2,maxHeight:720*2}}}},"uploader-screenshot")]})]})}ss.propTypes={projectId:i.string.isRequired,readOnly:i.bool.isRequired,params:i.object.isRequired,setParams:i.func.isRequired,paramsErrTip:i.object.isRequired,setParamsErrTip:i.func.isRequired,warning:i.object.isRequired,loading:i.bool.isRequired,blocklet:i.object.isRequired,setLoading:i.func.isRequired,initUrl:i.object.isRequired,componentDid:i.isRequired,initLogoUrl:i.string.isRequired,setInitLogoUrl:i.func.isRequired};const hr=ge.div`
129
129
  margin-top: 24px;
130
130
  .screenshot {
131
131
  margin-bottom: 16px;
@@ -173,7 +173,7 @@ import{r as j,k as gt,l as tt,L as xe,g as Rs,u as vs,h as Cs,i as ct}from"./ven
173
173
  padding-bottom: 12px;
174
174
  border-bottom: ${({theme:t})=>`1px solid ${t.palette.divider}`};
175
175
  }
176
- `;function as({text:t}){return t?e.jsx(xn,{wrapperElement:{"data-color-mode":"light"},source:Ys.sanitize(t),rehypePlugins:[[mn,{target:"_blank"}]]}):e.jsx(Ae,{Icon:Dt})}as.propTypes={text:i.string.isRequired};function ds({params:t,setParams:o,paramsErrTip:s,loading:r,setParamsErrTip:l,readOnly:a}){var x;const{t:n}=oe(),[u,d]=j.useState(a?"preview":"write"),f=(S,C)=>{d(C)};return e.jsxs(c,{sx:{border:"1px solid #fff",width:"100%",borderRadius:2},children:[e.jsxs(c,{sx:{display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center"},children:[e.jsx(L,{variant:"h6",fontWeight:"bold",sx:{},children:n("common.introduction")}),e.jsxs(No,{value:u,onChange:f,"aria-label":"wrapped label tabs example",children:[e.jsx(Qe,{value:"write",label:"Write"}),e.jsx(Qe,{value:"preview",label:"Preview"})]})]}),e.jsx(c,{display:u==="write"?"block":"none",sx:{width:"100%",marginTop:3},children:e.jsx(se,{disabled:r||a,sx:{border:"none"},placeholder:`Blocklet ${n("common.introduction")}`,InputProps:{"data-cy":"export-blocklet-introduction",readOnly:a,endAdornment:e.jsxs(Ve,{position:"end",children:[((x=t==null?void 0:t.blockletIntroduction)==null?void 0:x.length)||0," / ",ue.PROJECT.MAX_INTRO_LENGTH]})},autoComplete:"off",variant:"outlined",fullWidth:!0,multiline:!0,minRows:4,value:t.blockletIntroduction||"",onChange:S=>{l({blockletIntroduction:""}),o({blockletIntroduction:S.target.value.slice(0,ue.PROJECT.MAX_INTRO_LENGTH)})},error:!!s.blockletIntroduction,helperText:s.blockletIntroduction||""})}),e.jsx(c,{display:u==="preview"?"block":"none",mt:3,children:e.jsx(as,{text:t.blockletIntroduction||""})})]})}ds.propTypes={params:i.object.isRequired,setParams:i.func.isRequired,paramsErrTip:i.object.isRequired,setParamsErrTip:i.func.isRequired,readOnly:i.bool.isRequired,loading:i.bool.isRequired};var Jt={},vr=ke;Object.defineProperty(Jt,"__esModule",{value:!0});var mt=Jt.default=void 0,Cr=vr(Re()),yo=e;mt=Jt.default=(0,Cr.default)([(0,yo.jsx)("circle",{cx:"12",cy:"19",r:"2"},"0"),(0,yo.jsx)("path",{d:"M10 3h4v12h-4z"},"1")],"PriorityHigh");function Gt({step:t,ok:o,active:s,error:r,warning:l}){let a="grey.500",n=t+1;return o&&(n=e.jsx(gn,{sx:{fontSize:18,margin:0},color:"white"})),r||!o&&s>t?(a="error.main",n=e.jsx(mt,{sx:{fontSize:18,margin:0},color:"white"})):l?(a="warning.main",n=e.jsx(mt,{sx:{fontSize:18,margin:0},color:"white"})):s>=t&&(a="primary.main"),e.jsx(c,{width:24,height:24,bgcolor:a,borderRadius:"100%",color:"white",display:"flex",justifyContent:"center",fontWeight:"bold",fontSize:14,alignItems:"center",children:n})}Gt.propTypes={step:i.number,ok:i.bool,active:i.number,error:i.string,warning:i.bool};Gt.defaultProps={step:0,ok:!1,active:0,error:"",warning:!1};function us({steps:t,activeStep:o,setActiveStep:s,hasSelectedResources:r,params:l,loading:a,paramsErrTip:n,warning:u,viewMode:d,projectId:f}){const{t:x}=oe(),S=()=>{s(R=>R+1)},C=()=>{s(R=>R-1)},p=R=>R===0?(n==null?void 0:n.blockletTitle)||(n==null?void 0:n.projectId)||(n==null?void 0:n.blockletDescription)||(n==null?void 0:n.blockletHomepage)||(n==null?void 0:n.blockletSupport)||(n==null?void 0:n.blockletCommunity)||(n==null?void 0:n.blockletRepository):R===2?(n==null?void 0:n.blockletResource)||(n==null?void 0:n.blockletDocker)||(n==null?void 0:n.dockerImageName):R>=4?(n==null?void 0:n.blockletVersion)||(n==null?void 0:n.note):"",h=d||rs({hasSelectedResources:r,params:l,projectId:f,t:x})===null;return e.jsxs(c,{sx:{width:300,maxWidth:300,minWidth:300,padding:2,border:"1px solid #ccc",borderRadius:2},children:[e.jsx($s,{activeStep:o,orientation:"vertical",children:t.map((R,w)=>{const k={},I=a||!yr({hasSelectedResources:r,params:l,projectId:f,step:w,t:x}),v=a?"":p(w);return v&&(k.optional=e.jsx(L,{variant:"caption",color:"error",children:v}),k.error=!0),e.jsxs(qs,{children:[e.jsx(Ls,{icon:e.jsx(Gt,{error:v,warning:w===0?u.hasWarning:!1,active:h?99:o,step:w,ok:I}),sx:{cursor:"pointer",color:v?"error.main":"inherit"},disabled:!1,onClick:()=>s(w),...k,children:e.jsx(L,{fontSize:"14px",fontWeight:"500",color:v||!I&&o>w?"error.main":"inherit",children:R.label})}),e.jsxs(Ns,{children:[e.jsx(L,{fontSize:12,children:R.description}),!h&&e.jsx(c,{sx:{mb:2},children:e.jsxs("div",{children:[w<t.length-1&&e.jsx(ne,{variant:"contained",onClick:S,sx:{mt:1,mr:1},disabled:v||!I,children:x("common.continue")}),w>0&&e.jsx(ne,{disabled:w===0,onClick:C,sx:{mt:1,mr:1},children:x("common.back")})]})})]})]},R.label)})}),o>=t.length-1&&e.jsx(jt,{square:!0,elevation:0,sx:{p:3},children:e.jsx(L,{fontSize:12,sx:{opacity:.5},children:"Click right top button to release"})})]})}us.propTypes={steps:i.array.isRequired,activeStep:i.number.isRequired,setActiveStep:i.func.isRequired,params:i.object.isRequired,viewMode:i.string.isRequired,loading:i.bool.isRequired,projectId:i.string.isRequired,hasSelectedResources:i.bool.isRequired,warning:i.object.isRequired,paramsErrTip:i.shape({projectId:i.string,blockletVersion:i.string,blockletTitle:i.string,blockletDescription:i.string,note:i.string,blockletResource:i.string,blockletHomepage:i.string,blockletSupport:i.string,blockletCommunity:i.string,blockletRepository:i.string,blockletDocker:i.object,dockerImageName:i.string}).isRequired};const wr=[".zip",".gz"],Sr=1024*1024*100,Ir=j.lazy(()=>Oo(()=>import("./index-D22lazSG.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12])).then(t=>({default:t.Uploader})));function Xt({app:t,projectId:o,readOnly:s,params:r,setParams:l,setParamsErrTip:a,error:n}){const{t:u,locale:d}=oe(),f=j.useRef(null),x=()=>s?!1:!o||o===Y.UNOWNED_DID?(U.error(u("blocklet.publish.errorTip.noFirstDid")),!1):!0,S=`${Y.WELLKNOWN_SERVICE_PATH_PREFIX}/api/project/${t.meta.did}/${o}/resource/upload`;return e.jsxs(c,{sx:{mt:3},children:[e.jsx(L,{gutterBottom:!0,children:u("blocklet.publish.resourceUpload")}),e.jsxs(Se,{direction:"row",alignItems:"center",spacing:1,sx:{flex:1,cursor:s?"default":"pointer"},children:[!!r.uploadedResource&&e.jsx(L,{component:"a",href:`${S}/params.uploadedResource`,children:r.uploadedResource}),!s&&e.jsx(ne,{variant:"outlined",size:"small",onClick:()=>{var C;x()&&((C=f.current)==null||C.open())},children:r.uploadedResource?u("common.change"):u("common.upload")})]}),e.jsx(j.Suspense,{fallback:e.jsx(Fe,{}),children:e.jsx(Ir,{ref:f,locale:d,popup:!0,onUploadFinish:C=>{var p;l({uploadedResource:C.data.filename}),a({blockletResource:""}),(p=f.current)==null||p.close()},plugins:["ImageEditor"],installerProps:{disabled:!0},apiPathProps:{uploader:S,disableMediaKitPrefix:!0,disableMediaKitStatus:!0},coreProps:{restrictions:{allowedFileExts:wr,maxFileSize:Sr,maxNumberOfFiles:1}}},"uploader-resource")}),!!n&&e.jsx(c,{color:"error.main",mt:1,fontSize:14,children:n})]})}Xt.propTypes={app:i.object.isRequired,projectId:i.string.isRequired,readOnly:i.bool.isRequired,params:i.object.isRequired,setParams:i.func.isRequired,error:i.string.isRequired,setParamsErrTip:i.func.isRequired};Xt.defaultProps={};function Ke({readOnly:t,params:o,setParams:s,paramsErrTip:r,setParamsErrTip:l,loading:a}){var u;const{t:n}=oe();return e.jsx(c,{display:"flex",mt:3,className:"section",children:e.jsxs(c,{sx:{flex:1},children:[e.jsx(se,{required:!0,disabled:a||t,label:`Blocklet ${n("common.version")}`,placeholder:`Blocklet ${n("common.version")}`,InputProps:{"data-cy":"blocklet-version",readOnly:t},autoComplete:"off",variant:"outlined",fullWidth:!0,value:o.blockletVersion||"",onChange:d=>{l({blockletVersion:""}),s({blockletVersion:d.target.value})},error:!!r.blockletVersion,helperText:r.blockletVersion||""}),e.jsx(se,{label:n("blocklet.publish.releaseNote"),autoComplete:"off",disabled:a||t,variant:"outlined",InputProps:{"data-cy":"release-note",readOnly:t,endAdornment:e.jsxs(Ve,{position:"end",children:[((u=o==null?void 0:o.note)==null?void 0:u.length)||0," / ",ue.PROJECT.MAX_NOTE_LENGTH]})},fullWidth:!0,multiline:!0,minRows:4,required:!0,value:o.note||"",onChange:d=>{l({note:""}),s({note:d.target.value.slice(0,ue.PROJECT.MAX_NOTE_LENGTH)})},error:!!r.note,helperText:r.note||"",sx:{mt:3}})]})})}Ke.propTypes={readOnly:i.bool.isRequired,params:i.object.isRequired,setParams:i.func.isRequired,paramsErrTip:i.object.isRequired,setParamsErrTip:i.func.isRequired,loading:i.bool.isRequired};Ke.defaultProps={};function ps(t){for(const o in t)typeof t[o]=="string"?t[o]=t[o].replace(/\\\\/g,"\\"):typeof t[o]=="object"&&t[o]!==null&&ps(t[o]);return t}function et({index:t,item:o,dockerParams:s,setDockerParams:r,dataKey:l,t:a,readOnly:n}){const u=(o==null?void 0:o.value)||"",[d,f]=j.useState(!1),x=()=>{var O;(O=s[l])==null||O.splice(t,1),r({...s,[l]:[...s[l]]})},S=(O,m)=>{var b;(b=s[l])!=null&&b[t]&&(m?(s[l][t].custom=s[l][t].value,s[l][t].value=`$${dt(o.key)}`):(s[l][t].value=s[l][t].custom||"",s[l][t].custom="")),r({...s,[l]:[...s[l]]})},C=(O,m)=>{var y;const b=((y=s[l][t])==null?void 0:y.value)||"";s[l][t]={...s[l][t],secure:m,value:m&&b===ue.BLOCKLET_AUTOMATIC_ENV_VALUE?"":b},r({...s,[l]:[...s[l]]})},p=(O,m)=>{s[l][t]={...s[l][t],shared:m},r({...s,[l]:[...s[l]]})},h=(O,m)=>{var y;const b=((y=s[l][t])==null?void 0:y.value)||"";s[l][t]={...s[l][t],required:m,value:m&&b===ue.BLOCKLET_AUTOMATIC_ENV_VALUE?"":b},r({...s,[l]:[...s[l]]})},R=(O,m)=>{s[l][t]={...s[l][t],value:m?ue.BLOCKLET_AUTOMATIC_ENV_VALUE:"",secure:!1,required:!1},r({...s,[l]:[...s[l]]})},w=O=>{s[l][t]={...s[l][t],description:O.target.value},r({...s,[l]:[...s[l]]})},k=O=>{const m=O.target.value==="web"?"web":"docker";m==="web"&&s.dockerArgs.forEach(W=>{W.type="docker"});const y=`/${s.dockerImage.replace(/\W/g,"-")}-${t}`;s.dockerArgs[t]={...s.dockerArgs[t],type:m,path:m==="docker"?y:"/",protocol:"http",prefix:m==="docker"?y:"/",name:"publicUrl",port:"BLOCKLET_PORT"},r({...s,dockerArgs:[...s.dockerArgs]})},I=O=>{s.dockerArgs[t]={...s.dockerArgs[t],proxyBehavior:O.target.value==="direct"?"direct":"service"},r({...s,dockerArgs:[...s.dockerArgs]})},v=O=>{const m=O.target.value;s[l][t]={...s[l][t],prefix:m,path:m==="*"?"/":m},r({...s,[l]:[...s[l]]})},D=O=>{var m;(m=s[l])!=null&&m[t]&&(s[l][t].value=O.target.value),r({...s,[l]:[...s[l]]})},_=u===`$${dt(o.key)}`||o.custom,q=l==="dockerArgs"&&!Uo[o.key],E=dn[o.key],M=l==="dockerEnvs",$=o.key==="--publish";let Q=o.key;return $&&o.type==="web"?Q="--publish (Web)":M&&(Q=`--env ${o.key}`),e.jsxs(c,{sx:{display:"flex",flexDirection:"row",gap:2,alignItems:"center"},children:[e.jsx(c,{sx:{width:250},children:e.jsx(L,{sx:{textOverflow:"ellipsis",width:"100%",overflow:"hidden"},children:Q})}),e.jsxs(c,{sx:{display:"flex",flexDirection:"column",gap:1,flex:1},children:[e.jsx(se,{disabled:n||_||q||o.value===ue.BLOCKLET_AUTOMATIC_ENV_VALUE,placeholder:"",value:_?`$${dt(o.key)}`:u,sx:{flex:1},InputProps:{endAdornment:e.jsxs(Ve,{position:"end",sx:{zoom:.9},children:[(!(E||q)||M||$)&&e.jsx(ce,{onClick:()=>f(!0),children:e.jsx(ae,{icon:"icon-park-outline:setting-config"})}),!n&&e.jsx(ce,{onClick:x,color:q?"error":"default",children:e.jsx(ae,{icon:"ic:round-delete"})})]})},error:q,onChange:D}),q&&e.jsx(L,{variant:"caption",color:"error",children:a("blocklet.publish.docker.noAllowTheArg")}),o.key==="--publish"&&e.jsx(L,{variant:"caption",color:"text.secondary",children:a("blocklet.publish.docker.publishTips")}),o.key==="--volume"&&un[o.key](u)&&e.jsx(L,{variant:"caption",color:"error",children:a("blocklet.publish.docker.volumeTips")})]}),d&&e.jsx(yt,{open:!0,fullWidth:!0,maxWidth:"sm",PaperProps:{style:{minHeight:0}},title:a(M?"blocklet.publish.docker.modifyEnv":"blocklet.publish.docker.modifyParam"),onClose:()=>f(!1),children:e.jsxs(c,{sx:{display:"flex",flexDirection:"column",gap:1,paddingBottom:2},children:[E||q||M?null:e.jsxs(c,{sx:{width:"100%",display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"space-between"},children:[e.jsx(L,{children:a("blocklet.publish.docker.needCustomInput")}),e.jsx(De,{disabled:n,checked:_,onChange:S,sx:{zoom:.9}})]}),M&&e.jsxs(c,{sx:{width:"100%",display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"space-between"},children:[e.jsx(L,{children:a("blocklet.publish.docker.shared")}),e.jsx(De,{disabled:n,checked:o.shared,onChange:p,sx:{zoom:.9}})]}),M&&e.jsxs(c,{sx:{width:"100%",display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"space-between"},children:[e.jsx(L,{children:a("blocklet.publish.docker.required")}),e.jsx(De,{disabled:n,checked:o.required,onChange:h,sx:{zoom:.9}})]}),M&&e.jsxs(c,{sx:{width:"100%",display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"space-between"},children:[e.jsx(L,{children:a("blocklet.publish.docker.secure")}),e.jsx(De,{disabled:n,checked:o.secure,onChange:C,sx:{zoom:.9}})]}),M&&e.jsxs(c,{sx:{width:"100%",display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"space-between"},children:[e.jsx(L,{children:a("blocklet.publish.docker.autoGenerated")}),e.jsx(De,{disabled:n,checked:o.value===ue.BLOCKLET_AUTOMATIC_ENV_VALUE,onChange:R,sx:{zoom:.9}})]}),M&&e.jsxs(c,{sx:{mt:1,width:"100%",display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"space-between"},children:[e.jsx(L,{sx:{flex:1},children:a("blocklet.publish.docker.description")}),e.jsx(se,{disabled:n,value:o.description,onChange:w,sx:{flex:1},label:a("blocklet.publish.docker.description")})]}),$&&e.jsxs(c,{sx:{mt:1,width:"100%",display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"space-between"},children:[e.jsx(L,{sx:{flex:1},children:a("blocklet.publish.docker.portType")}),e.jsxs(ft,{value:o.type||"docker",onChange:k,children:[e.jsx(fe,{value:"docker",children:"Docker"}),e.jsx(fe,{value:"web",children:"Web"})]})]}),$&&o.type==="web"&&e.jsxs(c,{sx:{mt:1,width:"100%",display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"space-between"},children:[e.jsx(L,{sx:{flex:1},children:a("blocklet.publish.docker.proxyBehavior")}),e.jsxs(ft,{value:o.proxyBehavior||"service",onChange:I,children:[e.jsx(fe,{value:"service",children:a("blocklet.publish.docker.serviceProxy")}),e.jsx(fe,{value:"direct",children:a("blocklet.publish.docker.directProxy")})]})]}),$&&o.type==="web"&&e.jsxs(c,{sx:{mt:1,width:"100%",display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"space-between"},children:[e.jsx(L,{sx:{flex:1},children:a("blocklet.publish.docker.prefix")}),e.jsx(se,{disabled:n,value:o.prefix,onChange:v,sx:{flex:1},label:a("blocklet.publish.docker.prefix")})]})]})})]})}et.propTypes={dockerParams:i.object.isRequired,setDockerParams:i.func.isRequired,dataKey:i.string.isRequired,item:i.object.isRequired,t:i.func.isRequired,readOnly:i.bool.isRequired,index:i.number.isRequired};et.defaultProps={};const Dr=`
176
+ `;function as({text:t}){return t?e.jsx(xn,{wrapperElement:{"data-color-mode":"light"},source:Ys.sanitize(t),rehypePlugins:[[mn,{target:"_blank"}]]}):e.jsx(Ae,{Icon:Dt})}as.propTypes={text:i.string.isRequired};function ds({params:t,setParams:o,paramsErrTip:s,loading:r,setParamsErrTip:l,readOnly:a}){var x;const{t:n}=oe(),[u,d]=j.useState(a?"preview":"write"),f=(S,C)=>{d(C)};return e.jsxs(c,{sx:{border:"1px solid #fff",width:"100%",borderRadius:2},children:[e.jsxs(c,{sx:{display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center"},children:[e.jsx(L,{variant:"h6",fontWeight:"bold",sx:{},children:n("common.introduction")}),e.jsxs(No,{value:u,onChange:f,"aria-label":"wrapped label tabs example",children:[e.jsx(Qe,{value:"write",label:"Write"}),e.jsx(Qe,{value:"preview",label:"Preview"})]})]}),e.jsx(c,{display:u==="write"?"block":"none",sx:{width:"100%",marginTop:3},children:e.jsx(se,{disabled:r||a,sx:{border:"none"},placeholder:`Blocklet ${n("common.introduction")}`,InputProps:{"data-cy":"export-blocklet-introduction",readOnly:a,endAdornment:e.jsxs(Ve,{position:"end",children:[((x=t==null?void 0:t.blockletIntroduction)==null?void 0:x.length)||0," / ",ue.PROJECT.MAX_INTRO_LENGTH]})},autoComplete:"off",variant:"outlined",fullWidth:!0,multiline:!0,minRows:4,value:t.blockletIntroduction||"",onChange:S=>{l({blockletIntroduction:""}),o({blockletIntroduction:S.target.value.slice(0,ue.PROJECT.MAX_INTRO_LENGTH)})},error:!!s.blockletIntroduction,helperText:s.blockletIntroduction||""})}),e.jsx(c,{display:u==="preview"?"block":"none",mt:3,children:e.jsx(as,{text:t.blockletIntroduction||""})})]})}ds.propTypes={params:i.object.isRequired,setParams:i.func.isRequired,paramsErrTip:i.object.isRequired,setParamsErrTip:i.func.isRequired,readOnly:i.bool.isRequired,loading:i.bool.isRequired};var Jt={},vr=ke;Object.defineProperty(Jt,"__esModule",{value:!0});var mt=Jt.default=void 0,Cr=vr(Re()),yo=e;mt=Jt.default=(0,Cr.default)([(0,yo.jsx)("circle",{cx:"12",cy:"19",r:"2"},"0"),(0,yo.jsx)("path",{d:"M10 3h4v12h-4z"},"1")],"PriorityHigh");function Gt({step:t,ok:o,active:s,error:r,warning:l}){let a="grey.500",n=t+1;return o&&(n=e.jsx(gn,{sx:{fontSize:18,margin:0},color:"white"})),r||!o&&s>t?(a="error.main",n=e.jsx(mt,{sx:{fontSize:18,margin:0},color:"white"})):l?(a="warning.main",n=e.jsx(mt,{sx:{fontSize:18,margin:0},color:"white"})):s>=t&&(a="primary.main"),e.jsx(c,{width:24,height:24,bgcolor:a,borderRadius:"100%",color:"white",display:"flex",justifyContent:"center",fontWeight:"bold",fontSize:14,alignItems:"center",children:n})}Gt.propTypes={step:i.number,ok:i.bool,active:i.number,error:i.string,warning:i.bool};Gt.defaultProps={step:0,ok:!1,active:0,error:"",warning:!1};function us({steps:t,activeStep:o,setActiveStep:s,hasSelectedResources:r,params:l,loading:a,paramsErrTip:n,warning:u,viewMode:d,projectId:f}){const{t:x}=oe(),S=()=>{s(R=>R+1)},C=()=>{s(R=>R-1)},p=R=>R===0?(n==null?void 0:n.blockletTitle)||(n==null?void 0:n.projectId)||(n==null?void 0:n.blockletDescription)||(n==null?void 0:n.blockletHomepage)||(n==null?void 0:n.blockletSupport)||(n==null?void 0:n.blockletCommunity)||(n==null?void 0:n.blockletRepository):R===2?(n==null?void 0:n.blockletResource)||(n==null?void 0:n.blockletDocker)||(n==null?void 0:n.dockerImageName):R>=4?(n==null?void 0:n.blockletVersion)||(n==null?void 0:n.note):"",h=d||rs({hasSelectedResources:r,params:l,projectId:f,t:x})===null;return e.jsxs(c,{sx:{width:300,maxWidth:300,minWidth:300,padding:2,border:"1px solid #ccc",borderRadius:2},children:[e.jsx($s,{activeStep:o,orientation:"vertical",children:t.map((R,w)=>{const k={},I=a||!yr({hasSelectedResources:r,params:l,projectId:f,step:w,t:x}),v=a?"":p(w);return v&&(k.optional=e.jsx(L,{variant:"caption",color:"error",children:v}),k.error=!0),e.jsxs(qs,{children:[e.jsx(Ls,{icon:e.jsx(Gt,{error:v,warning:w===0?u.hasWarning:!1,active:h?99:o,step:w,ok:I}),sx:{cursor:"pointer",color:v?"error.main":"inherit"},disabled:!1,onClick:()=>s(w),...k,children:e.jsx(L,{fontSize:"14px",fontWeight:"500",color:v||!I&&o>w?"error.main":"inherit",children:R.label})}),e.jsxs(Ns,{children:[e.jsx(L,{fontSize:12,children:R.description}),!h&&e.jsx(c,{sx:{mb:2},children:e.jsxs("div",{children:[w<t.length-1&&e.jsx(ne,{variant:"contained",onClick:S,sx:{mt:1,mr:1},disabled:v||!I,children:x("common.continue")}),w>0&&e.jsx(ne,{disabled:w===0,onClick:C,sx:{mt:1,mr:1},children:x("common.back")})]})})]})]},R.label)})}),o>=t.length-1&&e.jsx(jt,{square:!0,elevation:0,sx:{p:3},children:e.jsx(L,{fontSize:12,sx:{opacity:.5},children:"Click right top button to release"})})]})}us.propTypes={steps:i.array.isRequired,activeStep:i.number.isRequired,setActiveStep:i.func.isRequired,params:i.object.isRequired,viewMode:i.string.isRequired,loading:i.bool.isRequired,projectId:i.string.isRequired,hasSelectedResources:i.bool.isRequired,warning:i.object.isRequired,paramsErrTip:i.shape({projectId:i.string,blockletVersion:i.string,blockletTitle:i.string,blockletDescription:i.string,note:i.string,blockletResource:i.string,blockletHomepage:i.string,blockletSupport:i.string,blockletCommunity:i.string,blockletRepository:i.string,blockletDocker:i.object,dockerImageName:i.string}).isRequired};const wr=[".zip",".gz"],Sr=1024*1024*100,Ir=j.lazy(()=>Oo(()=>import("./index-B64a4BbE.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12])).then(t=>({default:t.Uploader})));function Xt({app:t,projectId:o,readOnly:s,params:r,setParams:l,setParamsErrTip:a,error:n}){const{t:u,locale:d}=oe(),f=j.useRef(null),x=()=>s?!1:!o||o===Y.UNOWNED_DID?(U.error(u("blocklet.publish.errorTip.noFirstDid")),!1):!0,S=`${Y.WELLKNOWN_SERVICE_PATH_PREFIX}/api/project/${t.meta.did}/${o}/resource/upload`;return e.jsxs(c,{sx:{mt:3},children:[e.jsx(L,{gutterBottom:!0,children:u("blocklet.publish.resourceUpload")}),e.jsxs(Se,{direction:"row",alignItems:"center",spacing:1,sx:{flex:1,cursor:s?"default":"pointer"},children:[!!r.uploadedResource&&e.jsx(L,{component:"a",href:`${S}/params.uploadedResource`,children:r.uploadedResource}),!s&&e.jsx(ne,{variant:"outlined",size:"small",onClick:()=>{var C;x()&&((C=f.current)==null||C.open())},children:r.uploadedResource?u("common.change"):u("common.upload")})]}),e.jsx(j.Suspense,{fallback:e.jsx(Fe,{}),children:e.jsx(Ir,{ref:f,locale:d,popup:!0,onUploadFinish:C=>{var p;l({uploadedResource:C.data.filename}),a({blockletResource:""}),(p=f.current)==null||p.close()},plugins:["ImageEditor"],installerProps:{disabled:!0},apiPathProps:{uploader:S,disableMediaKitPrefix:!0,disableMediaKitStatus:!0},coreProps:{restrictions:{allowedFileExts:wr,maxFileSize:Sr,maxNumberOfFiles:1}}},"uploader-resource")}),!!n&&e.jsx(c,{color:"error.main",mt:1,fontSize:14,children:n})]})}Xt.propTypes={app:i.object.isRequired,projectId:i.string.isRequired,readOnly:i.bool.isRequired,params:i.object.isRequired,setParams:i.func.isRequired,error:i.string.isRequired,setParamsErrTip:i.func.isRequired};Xt.defaultProps={};function Ke({readOnly:t,params:o,setParams:s,paramsErrTip:r,setParamsErrTip:l,loading:a}){var u;const{t:n}=oe();return e.jsx(c,{display:"flex",mt:3,className:"section",children:e.jsxs(c,{sx:{flex:1},children:[e.jsx(se,{required:!0,disabled:a||t,label:`Blocklet ${n("common.version")}`,placeholder:`Blocklet ${n("common.version")}`,InputProps:{"data-cy":"blocklet-version",readOnly:t},autoComplete:"off",variant:"outlined",fullWidth:!0,value:o.blockletVersion||"",onChange:d=>{l({blockletVersion:""}),s({blockletVersion:d.target.value})},error:!!r.blockletVersion,helperText:r.blockletVersion||""}),e.jsx(se,{label:n("blocklet.publish.releaseNote"),autoComplete:"off",disabled:a||t,variant:"outlined",InputProps:{"data-cy":"release-note",readOnly:t,endAdornment:e.jsxs(Ve,{position:"end",children:[((u=o==null?void 0:o.note)==null?void 0:u.length)||0," / ",ue.PROJECT.MAX_NOTE_LENGTH]})},fullWidth:!0,multiline:!0,minRows:4,required:!0,value:o.note||"",onChange:d=>{l({note:""}),s({note:d.target.value.slice(0,ue.PROJECT.MAX_NOTE_LENGTH)})},error:!!r.note,helperText:r.note||"",sx:{mt:3}})]})})}Ke.propTypes={readOnly:i.bool.isRequired,params:i.object.isRequired,setParams:i.func.isRequired,paramsErrTip:i.object.isRequired,setParamsErrTip:i.func.isRequired,loading:i.bool.isRequired};Ke.defaultProps={};function ps(t){for(const o in t)typeof t[o]=="string"?t[o]=t[o].replace(/\\\\/g,"\\"):typeof t[o]=="object"&&t[o]!==null&&ps(t[o]);return t}function et({index:t,item:o,dockerParams:s,setDockerParams:r,dataKey:l,t:a,readOnly:n}){const u=(o==null?void 0:o.value)||"",[d,f]=j.useState(!1),x=()=>{var O;(O=s[l])==null||O.splice(t,1),r({...s,[l]:[...s[l]]})},S=(O,m)=>{var b;(b=s[l])!=null&&b[t]&&(m?(s[l][t].custom=s[l][t].value,s[l][t].value=`$${dt(o.key)}`):(s[l][t].value=s[l][t].custom||"",s[l][t].custom="")),r({...s,[l]:[...s[l]]})},C=(O,m)=>{var y;const b=((y=s[l][t])==null?void 0:y.value)||"";s[l][t]={...s[l][t],secure:m,value:m&&b===ue.BLOCKLET_AUTOMATIC_ENV_VALUE?"":b},r({...s,[l]:[...s[l]]})},p=(O,m)=>{s[l][t]={...s[l][t],shared:m},r({...s,[l]:[...s[l]]})},h=(O,m)=>{var y;const b=((y=s[l][t])==null?void 0:y.value)||"";s[l][t]={...s[l][t],required:m,value:m&&b===ue.BLOCKLET_AUTOMATIC_ENV_VALUE?"":b},r({...s,[l]:[...s[l]]})},R=(O,m)=>{s[l][t]={...s[l][t],value:m?ue.BLOCKLET_AUTOMATIC_ENV_VALUE:"",secure:!1,required:!1},r({...s,[l]:[...s[l]]})},w=O=>{s[l][t]={...s[l][t],description:O.target.value},r({...s,[l]:[...s[l]]})},k=O=>{const m=O.target.value==="web"?"web":"docker";m==="web"&&s.dockerArgs.forEach(W=>{W.type="docker"});const y=`/${s.dockerImage.replace(/\W/g,"-")}-${t}`;s.dockerArgs[t]={...s.dockerArgs[t],type:m,path:m==="docker"?y:"/",protocol:"http",prefix:m==="docker"?y:"/",name:"publicUrl",port:"BLOCKLET_PORT"},r({...s,dockerArgs:[...s.dockerArgs]})},I=O=>{s.dockerArgs[t]={...s.dockerArgs[t],proxyBehavior:O.target.value==="direct"?"direct":"service"},r({...s,dockerArgs:[...s.dockerArgs]})},v=O=>{const m=O.target.value;s[l][t]={...s[l][t],prefix:m,path:m==="*"?"/":m},r({...s,[l]:[...s[l]]})},D=O=>{var m;(m=s[l])!=null&&m[t]&&(s[l][t].value=O.target.value),r({...s,[l]:[...s[l]]})},_=u===`$${dt(o.key)}`||o.custom,q=l==="dockerArgs"&&!Uo[o.key],E=dn[o.key],M=l==="dockerEnvs",$=o.key==="--publish";let Q=o.key;return $&&o.type==="web"?Q="--publish (Web)":M&&(Q=`--env ${o.key}`),e.jsxs(c,{sx:{display:"flex",flexDirection:"row",gap:2,alignItems:"center"},children:[e.jsx(c,{sx:{width:250},children:e.jsx(L,{sx:{textOverflow:"ellipsis",width:"100%",overflow:"hidden"},children:Q})}),e.jsxs(c,{sx:{display:"flex",flexDirection:"column",gap:1,flex:1},children:[e.jsx(se,{disabled:n||_||q||o.value===ue.BLOCKLET_AUTOMATIC_ENV_VALUE,placeholder:"",value:_?`$${dt(o.key)}`:u,sx:{flex:1},InputProps:{endAdornment:e.jsxs(Ve,{position:"end",sx:{zoom:.9},children:[(!(E||q)||M||$)&&e.jsx(ce,{onClick:()=>f(!0),children:e.jsx(ae,{icon:"icon-park-outline:setting-config"})}),!n&&e.jsx(ce,{onClick:x,color:q?"error":"default",children:e.jsx(ae,{icon:"ic:round-delete"})})]})},error:q,onChange:D}),q&&e.jsx(L,{variant:"caption",color:"error",children:a("blocklet.publish.docker.noAllowTheArg")}),o.key==="--publish"&&e.jsx(L,{variant:"caption",color:"text.secondary",children:a("blocklet.publish.docker.publishTips")}),o.key==="--volume"&&un[o.key](u)&&e.jsx(L,{variant:"caption",color:"error",children:a("blocklet.publish.docker.volumeTips")})]}),d&&e.jsx(yt,{open:!0,fullWidth:!0,maxWidth:"sm",PaperProps:{style:{minHeight:0}},title:a(M?"blocklet.publish.docker.modifyEnv":"blocklet.publish.docker.modifyParam"),onClose:()=>f(!1),children:e.jsxs(c,{sx:{display:"flex",flexDirection:"column",gap:1,paddingBottom:2},children:[E||q||M?null:e.jsxs(c,{sx:{width:"100%",display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"space-between"},children:[e.jsx(L,{children:a("blocklet.publish.docker.needCustomInput")}),e.jsx(De,{disabled:n,checked:_,onChange:S,sx:{zoom:.9}})]}),M&&e.jsxs(c,{sx:{width:"100%",display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"space-between"},children:[e.jsx(L,{children:a("blocklet.publish.docker.shared")}),e.jsx(De,{disabled:n,checked:o.shared,onChange:p,sx:{zoom:.9}})]}),M&&e.jsxs(c,{sx:{width:"100%",display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"space-between"},children:[e.jsx(L,{children:a("blocklet.publish.docker.required")}),e.jsx(De,{disabled:n,checked:o.required,onChange:h,sx:{zoom:.9}})]}),M&&e.jsxs(c,{sx:{width:"100%",display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"space-between"},children:[e.jsx(L,{children:a("blocklet.publish.docker.secure")}),e.jsx(De,{disabled:n,checked:o.secure,onChange:C,sx:{zoom:.9}})]}),M&&e.jsxs(c,{sx:{width:"100%",display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"space-between"},children:[e.jsx(L,{children:a("blocklet.publish.docker.autoGenerated")}),e.jsx(De,{disabled:n,checked:o.value===ue.BLOCKLET_AUTOMATIC_ENV_VALUE,onChange:R,sx:{zoom:.9}})]}),M&&e.jsxs(c,{sx:{mt:1,width:"100%",display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"space-between"},children:[e.jsx(L,{sx:{flex:1},children:a("blocklet.publish.docker.description")}),e.jsx(se,{disabled:n,value:o.description,onChange:w,sx:{flex:1},label:a("blocklet.publish.docker.description")})]}),$&&e.jsxs(c,{sx:{mt:1,width:"100%",display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"space-between"},children:[e.jsx(L,{sx:{flex:1},children:a("blocklet.publish.docker.portType")}),e.jsxs(ft,{value:o.type||"docker",onChange:k,children:[e.jsx(fe,{value:"docker",children:"Docker"}),e.jsx(fe,{value:"web",children:"Web"})]})]}),$&&o.type==="web"&&e.jsxs(c,{sx:{mt:1,width:"100%",display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"space-between"},children:[e.jsx(L,{sx:{flex:1},children:a("blocklet.publish.docker.proxyBehavior")}),e.jsxs(ft,{value:o.proxyBehavior||"service",onChange:I,children:[e.jsx(fe,{value:"service",children:a("blocklet.publish.docker.serviceProxy")}),e.jsx(fe,{value:"direct",children:a("blocklet.publish.docker.directProxy")})]})]}),$&&o.type==="web"&&e.jsxs(c,{sx:{mt:1,width:"100%",display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"space-between"},children:[e.jsx(L,{sx:{flex:1},children:a("blocklet.publish.docker.prefix")}),e.jsx(se,{disabled:n,value:o.prefix,onChange:v,sx:{flex:1},label:a("blocklet.publish.docker.prefix")})]})]})})]})}et.propTypes={dockerParams:i.object.isRequired,setDockerParams:i.func.isRequired,dataKey:i.string.isRequired,item:i.object.isRequired,t:i.func.isRequired,readOnly:i.bool.isRequired,index:i.number.isRequired};et.defaultProps={};const Dr=`
177
177
  docker run --name postgrest
178
178
  -p 3000:3000
179
179
  -e PGRST_DB_URI="postgres://username:password@host:port/database"
@@ -1,4 +1,4 @@
1
- import{u as $,Y as W,c2 as Y,h as be,_ as fe,a5 as ge,bM as je}from"./vendor-ux-did-connect-DOjsg91L.js";import{x as ye,m as de,j as we}from"./vendor-hooks-BwVH-TAd.js";import{r as C,b as X}from"./vendor-react-DoD83n6N.js";import{d as Z}from"./InfoOutlined-DSoJjRQo.js";import{z as F,C as ce,t as ke}from"./index-BPa_QtWl.js";import{u as N,a as ve,C as K}from"./dashboard-vsk4QHJ1.js";import{H as o,j as e,D as Ee,ai as Ce,t as Te,aa as f,O as ie,T as S,a9 as U,aj as ee,z as Se,y as B,bs as ae,bO as V,ab as O,L as Q,A as G,bl as Re,E as A,I as _,C as Ie,bq as Me,ak as P,c4 as Pe,X as De,bg as J,bp as ze,b4 as We,c5 as Oe,c6 as Ae,b5 as qe,am as $e,bZ as Le,s as pe,v as Be,c7 as He,c8 as Fe,c9 as Ne,ca as Ue,cb as _e}from"./vendor-mui-core-DxD1UA4o.js";import{l as Ye}from"./vendor-arcblock-ACo-BN0q.js";import{d as Ke}from"./ExpandLess-BNGLjxae.js";import{z as ue,x as Ve,y as Je}from"./vendor-utils-CTIzdAFg.js";import{C as Qe}from"./confirm-_RIb3OmR.js";import{A as Ge}from"./actions-CMsM02NP.js";import"./lottie-web-B6s7dDoL.js";import"./useLocalStorage-DKl7XFfI.js";import"./PlayArrow-D38lbyGo.js";import"./get-safe-url-DMordnyN.js";import"./format-error-LAoTjvJe.js";import"./index-xa5W6ExD.js";import"./session-DB9Du-lc.js";import"./useAsyncRetry-BBomZj1z.js";import"./useAsync-DKE0K0bz.js";import"./useSetState-BL3ktMon.js";import"./use-mobile-CHMVa8_W.js";import"./MoreHoriz-Bo_R2nuS.js";const Xe=t=>{var j,y;const[d,c]=C.useState(null),[l,b]=C.useState(!t),[R,p]=C.useState(null),{blocklet:n}=ce(),a=(y=(j=n==null?void 0:n.site)==null?void 0:j.domainAliases[0])==null?void 0:y.value,v=C.useMemo(()=>{const h={};return d&&(d.sources.forEach(r=>{h[r.did]={source:r,events:[],count:0}}),d.events.forEach(r=>{h[r.source]&&(h[r.source].events.push(r),h[r.source].count+=1)})),h},[d]),T=async()=>{try{if(b(!0),!a)return;const r=await(await fetch(`https://${a}/.well-known/service/openevent.json`)).json();c(r),p(null)}catch(h){p(h instanceof Error?h:new Error(String(h)))}finally{b(!1)}};return C.useEffect(()=>{T()},[a]),{openEvent:d,setOpenEvent:c,eventsBySource:v,loading:l,error:R,loadData:T}};function te({eventsBySource:t,selectedEvents:d,setSelectedEvents:c,error:l}){const{t:b}=$(),[R,p]=C.useState({}),n=C.useMemo(()=>{const r={};return Object.entries(t).forEach(([w,{events:g}])=>{const E=g.filter(u=>d[`${u.type}-${u.source}`]).length;r[w]=E}),r},[t,d]),a=C.useMemo(()=>Object.values(n).reduce((r,w)=>r+w,0),[n]),v=C.useMemo(()=>Object.values(t).reduce((r,{events:w})=>r+w.length,0),[t]),T=(r,w)=>{w.stopPropagation(),p({...R,[r]:!R[r]})},j=r=>{const w=`${r.type}-${r.source}`;c(g=>({...g,[w]:!g[w]}))},y=(r,w)=>{const g={};r.forEach(E=>{const u=`${E.type}-${E.source}`;g[u]=!w}),c(E=>({...E,...g}))},h=r=>{const w={};Object.values(t).forEach(({events:g})=>{g.forEach(E=>{const u=`${E.type}-${E.source}`;w[u]=r.target.checked})}),c(w)};return e.jsxs(f,{sx:{width:"100%"},children:[e.jsxs(f,{sx:{display:"flex",alignItems:"center",mb:1,mt:1},children:[e.jsx(ae,{control:e.jsx(V,{onChange:h,checked:a>0&&a===v}),label:e.jsxs(f,{sx:{display:"flex",alignItems:"center",cursor:"pointer"},children:[b("webhookEndpoint.selectAllEvents"),e.jsx(f,{sx:{display:"flex",alignItems:"center"},children:e.jsx(O,{title:b("webhookEndpoint.selectAllEventsTooltip"),placement:"right",children:e.jsx(Z,{fontSize:"small",sx:{ml:.5,cursor:"help"}})})})]}),sx:{m:0}}),a>0&&e.jsx(S,{variant:"body2",color:"primary",sx:{ml:"auto"},children:b("webhookEndpoint.selectedEventsCount",{count:a})})]}),e.jsx(f,{sx:{maxHeight:"50vh",overflow:"auto"},children:e.jsx(Q,{disablePadding:!0,sx:{border:"1px solid #e0e0e0",borderRadius:"4px"},children:Object.entries(t).map(([r,{source:w,events:g,count:E}],u)=>{const M=n[r]>0,i=n[r]===g.length&&g.length>0,x=R[r];return e.jsxs(X.Fragment,{children:[e.jsx(G,{sx:{borderBottom:u<Object.keys(t).length-1?"1px solid #f0f0f0":"none",px:2,py:1.5,"&:hover":{bgcolor:"rgba(0, 0, 0, 0.02)"}},children:e.jsxs(f,{sx:{display:"flex",width:"100%",justifyContent:"space-between",alignItems:"center"},onClick:s=>{s.target.closest(".MuiFormControlLabel-root")||T(r,s)},children:[e.jsx(f,{sx:{display:"flex",alignItems:"center"},children:g.length>0&&e.jsx(ae,{control:e.jsx(V,{checked:i,indeterminate:M&&!i,onChange:s=>{s.stopPropagation(),y(g,i)}}),label:e.jsxs(f,{sx:{display:"flex",alignItems:"center",gap:1},children:[w.logo&&e.jsx(Re,{src:w.logo,sx:{width:24,height:24}}),e.jsx(f,{children:w.title||r}),M&&e.jsx(A,{label:b("webhookEndpoint.selectedCount",{count:n[r]}),size:"small",sx:{mt:"2px",height:"20px",fontSize:"12px",bgcolor:s=>`${s.palette.primary.main}20`,color:"primary.main",fontWeight:500}})]}),sx:{m:0,"& .MuiFormControlLabel-label":{flex:1}}})}),e.jsxs(f,{sx:{display:"flex",alignItems:"center"},children:[e.jsx(S,{variant:"body2",color:"text.secondary",sx:{mr:1},children:b("webhookEndpoint.eventsCount",{count:E})}),g.length>0&&e.jsx(_,{size:"small",edge:"end",children:x?e.jsx(Ke,{}):e.jsx(Ye,{})})]})]})}),g.length>0&&e.jsx(Ie,{in:x,timeout:"auto",unmountOnExit:!0,children:e.jsx(Q,{disablePadding:!0,sx:{pl:2,pr:2,py:1,bgcolor:"rgba(0, 0, 0, 0.01)"},children:g.map(s=>{const m=`${s.type}-${s.source}`,k=!!d[m];return e.jsx(G,{dense:!0,sx:{py:.75},onClick:()=>j(s),children:e.jsxs(f,{sx:{display:"flex",alignItems:"flex-start",width:"100%"},children:[e.jsx(V,{checked:k,sx:{mr:1}}),e.jsxs(f,{children:[e.jsx(S,{variant:"body1",sx:{cursor:"pointer"},children:s.type}),e.jsx(S,{variant:"caption",color:"text.disabled",sx:{display:"block",cursor:"pointer"},children:s.description})]})]})},m)})})})]},r)})})}),l&&e.jsx(Me,{error:!0,sx:{mt:1},children:l})]})}te.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};te.defaultProps={error:null};function oe({id:t,url:d,description:c,enabledEvents:l,onSubmit:b,onClose:R}){var s;const{t:p}=$(),[n,a]=C.useState({}),{teamDid:v}=N(),{api:T}=F(),{loading:j,error:y,eventsBySource:h}=Xe(),{control:r,handleSubmit:w,formState:{errors:g},reset:E,setValue:u,trigger:M}=ve({defaultValues:{url:"",description:""}});C.useEffect(()=>{const m=Object.values(n).some(k=>k);u("selectedEvents",m?"valid":""),M("selectedEvents")},[n,u,M]);const i=()=>{a({}),E(),R()},x=async m=>{const k=Object.keys(n).filter(I=>n[I]),D={url:m.url,description:m.description,enabledEvents:k.map(I=>{const[q,L]=I.split("-");return!q||!L?null:{type:q,source:L}}).filter(Boolean)};try{if(t){const I=await T.updateWebhookEndpoint({input:{teamDid:v,id:t,data:D}});W.success(`${p("webhookEndpoint.updateWebhook")} ${p("webhookEndpoint.success")}`),b(I)}else{const I=await T.createWebhookEndpoint({input:{teamDid:v,input:D}});W.success(`${p("webhookEndpoint.createWebhook")} ${p("webhookEndpoint.success")}`),b(I)}}catch(I){W.error(I==null?void 0:I.message)}i()};return C.useEffect(()=>{E({url:d,description:c}),a(l.reduce((m,k)=>(m[`${k.type}-${k.source}`]=!0,m),{}))},[E,a,d,c,l]),e.jsx(Ee,{open:!0,onClose:i,maxWidth:"lg",fullWidth:!0,sx:{"& .MuiDialog-paper":{minHeight:600}},children:e.jsxs("form",{onSubmit:w(x),children:[e.jsx(Ce,{children:p(t?"webhookEndpoint.editWebhookTitle":"webhookEndpoint.createWebhookTitle")}),e.jsx(Te,{children:e.jsxs(f,{sx:{display:"flex",flexDirection:"column",gap:2,mt:2},children:[e.jsx(K,{name:"url",control:r,rules:{required:p("webhookEndpoint.validation.urlRequired"),pattern:{value:/^(http|https):\/\/[^ "]+$/,message:p("webhookEndpoint.validation.urlInvalid")}},render:({field:m})=>{var k;return e.jsx(ie,{...m,label:p("webhookEndpoint.url.label"),fullWidth:!0,error:!!g.url,helperText:(k=g.url)==null?void 0:k.message})}}),e.jsx(K,{name:"description",control:r,rules:{required:p("webhookEndpoint.validation.descriptionRequired")},render:({field:m})=>{var k;return e.jsx(ie,{...m,label:p("webhookEndpoint.description.label"),fullWidth:!0,multiline:!0,minRows:2,maxRows:4,error:!!g.description,helperText:(k=g.description)==null?void 0:k.message})}}),e.jsx(K,{name:"selectedEvents",control:r,rules:{required:p("webhookEndpoint.validation.eventRequired")},render:({field:m})=>e.jsx("input",{type:"hidden",...m})}),!j&&h&&Object.keys(h).length>0&&e.jsx(te,{eventsBySource:h,selectedEvents:n,setSelectedEvents:a,error:(s=g.selectedEvents)==null?void 0:s.message}),!j&&(!h||Object.keys(h).length===0)&&e.jsx(S,{color:"text.secondary",children:p("webhookEndpoint.noAvailableEvents")}),j&&e.jsx(f,{sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"500px",width:"100%"},children:e.jsx(U,{size:20})}),y&&e.jsx(ee,{severity:"error",children:p("webhookEndpoint.loadingError",{message:y==null?void 0:y.message})})]})}),e.jsxs(Se,{sx:{p:"8px 24px 24px"},children:[e.jsx(B,{onClick:i,children:p("common.cancel")}),e.jsx(B,{type:"submit",variant:"contained",color:"primary",children:p(t?"webhookEndpoint.updateWebhook":"webhookEndpoint.saveWebhook")})]})]})})}oe.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};oe.defaultProps={id:null,url:"",description:"",enabledEvents:[],onClose:()=>{}};function he(t){switch(t){case"enabled":return"success";case"disabled":default:return"default"}}const Ze=(t="en")=>t==="tw"?"zh":t;function H(t,d="YYYY-MM-DD HH:mm:ss",c="en"){return t?ke(t).locale(Ze(c)).format(d):"-"}function et(t){return typeof t=="number"?!1:ue(t)}function tt(t){return t>=200&&t<300}function z(t){const d=et(t.value);return e.jsxs(e.Fragment,{children:[e.jsxs(P,{direction:"column",alignItems:"flex-start",children:[e.jsxs(S,{component:"div",variant:"body1",mb:1,color:"text.primary",sx:{fontWeight:500},children:[t.label,!!t.tip&&e.jsx(O,{title:t.tip,children:e.jsx(Pe,{fontSize:"small"})})]}),e.jsx(S,{component:"div",variant:"body1",color:d?"text.disabled":"text.secondary",sx:{width:"100%",minHeight:"24px"},children:d?"-":t.value})]}),t.divider&&e.jsx(De,{orientation:"vertical",flexItem:!0})]})}z.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};z.defaultProps={tip:"",divider:!1};function ne(t){return e.jsxs(P,{className:"section-header",direction:"row",justifyContent:"space-between",alignItems:"center",flexWrap:"wrap",gap:1,sx:{mb:t.mb,mt:t.mt,pb:1},children:[e.jsx(S,{variant:"h3",sx:{fontSize:{xs:"18px",md:"1.09375rem"}},component:"div",children:t.title}),t.children]})}ne.propTypes={title:o.oneOfType([o.string,o.node]).isRequired,children:o.node,mb:o.number,mt:o.number};ne.defaultProps={children:null,mb:1.5,mt:1.5};const ot={width:24,height:24,body:'<path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 6H6a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2v-6m-7 1l9-9m-5 0h5v5"/>'},nt=t=>{const d={};return t.forEach(c=>{var b;const l=new Date(c.createdAt).toLocaleDateString();d[l]||(d[l]=[]),(b=d[l])==null||b.push(c)}),d};function se({eventId:t,webhookEndpointId:d,event:c}){const{api:l}=F(),{t:b}=$(),{teamDid:R}=N(),{blocklet:p}=ce(),{data:n,loadMore:a,loadingMore:v,loading:T}=ye(u=>{const i=u?Math.ceil(u.list.length/15)+1:1;return l.getWebhookAttempts({input:{teamDid:R,input:{eventId:t,webhookId:d},paging:{page:i,pageSize:15}}})},{reloadDeps:[t,d]}),j=(n==null?void 0:n.list)||[],[y,h]=C.useState(null),r=nt(j);C.useEffect(()=>{!y&&(n!=null&&n.list.length)&&h(n.list[0])},[n==null?void 0:n.list.length,y]);const w=u=>{h(u)};if(T)return e.jsx(U,{});const g=n&&n.list.length<n.paging.total,E=u=>{var M,i,x,s,m;if(u.responseBody&&((M=u.responseBody)!=null&&M.sessionId)&&((i=u.responseBody)!=null&&i.projectId)&&((x=u.responseBody)!=null&&x.agentId)){const k=(m=(s=p==null?void 0:p.site)==null?void 0:s.domainAliases[0])==null?void 0:m.value,D=(p.children||[]).find(q=>{var L;return((L=q==null?void 0:q.meta)==null?void 0:L.name)==="ai-studio"}),I=Ve(Je(`https://${k}`,(D==null?void 0:D.mountPoint)||"","projects",u.responseBody.projectId,"logs/main"),{sessionId:u.responseBody.sessionId,agentId:u.responseBody.agentId});return e.jsx(_,{sx:{fontSize:20},onClick:()=>window.open(I,"_blank"),children:e.jsx(f,{component:be,icon:ot})})}return null};return e.jsxs(J,{container:!0,spacing:{xs:0,md:1},sx:{height:1},children:[e.jsx(J,{item:!0,xs:12,md:4,height:1,children:ue(Object.keys(r))?e.jsx(S,{color:"text.secondary",children:b("webhookEndpoint.waitingForEvents")}):e.jsxs(e.Fragment,{children:[e.jsx(Q,{sx:{maxHeight:"calc(100% - 40px)",py:0,overflowY:"auto"},children:Object.entries(r).map(([u,M])=>e.jsxs(X.Fragment,{children:[e.jsx(ze,{children:u}),M.map(i=>e.jsxs(G,{sx:{cursor:"pointer"},onClick:()=>w(i),selected:y===i,secondaryAction:e.jsx(S,{color:"text.secondary",children:H(i.createdAt,"HH:mm:ss")}),children:[e.jsx(We,{sx:{minWidth:0,mr:1.5},children:tt(i.responseStatus)===!1?e.jsx(Oe,{color:"error"}):e.jsx(Ae,{color:"success"})}),e.jsx(qe,{primary:e.jsx(S,{color:"text.primary",children:i.event.type})})]},i.id))]},u))}),g&&e.jsx(f,{display:"flex",justifyContent:"center",alignItems:"center",width:1,children:e.jsx(B,{variant:"text",type:"button",color:"inherit",onClick:a,disabled:v,sx:{color:u=>u.palette.text.disabled},children:b(v?"webhookEndpoint.loadingMore":"webhookEndpoint.loadMore")})})]})}),e.jsxs(J,{item:!0,xs:12,md:8,height:1,children:[y&&e.jsxs(P,{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(f,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(S,{variant:"h6",children:t?y.endpoint.url:y.event.type}),e.jsx(f,{children:E(y)})]}),e.jsxs(f,{children:[e.jsxs(S,{variant:"h6",children:[b("webhookEndpoint.response")," (",y.responseStatus,")"]}),e.jsx(Y,{language:"json",children:JSON.stringify(y.responseBody,null,2)})]}),e.jsxs(f,{children:[e.jsx(P,{direction:"row",alignItems:"center",spacing:1,children:e.jsx(S,{variant:"h6",children:b("webhookEndpoint.request")})}),e.jsx(Y,{language:"json",sx:{margin:0},children:JSON.stringify(y.event,null,2)})]})]}),(n==null?void 0:n.list.length)===0&&c&&e.jsxs(f,{children:[e.jsx(P,{direction:"row",alignItems:"center",spacing:1,children:e.jsx(S,{variant:"h6",children:b("webhookEndpoint.eventData")})}),e.jsx(Y,{language:"json",sx:{margin:0},children:JSON.stringify(c.data,null,2)})]})]})]})}se.propTypes={eventId:o.string,webhookEndpointId:o.string,event:o.shape({type:o.string,data:o.object,request:o.object,requestInfo:o.object})};se.defaultProps={eventId:"",webhookEndpointId:"",event:null};function xe({id:t,onClose:d}){var v,T,j,y;const{t:c}=$(),{api:l}=F(),{teamDid:b}=N(),{loading:R,error:p,data:n}=de(()=>l.getWebhookEndpoint({input:{teamDid:b,id:t}})),a=n==null?void 0:n.data;return p?e.jsx(ee,{severity:"error",children:p.message}):R||!a?e.jsx(f,{display:"flex",justifyContent:"center",alignItems:"center",height:1,width:1,children:e.jsx(U,{})}):e.jsxs(st,{direction:"column",sx:{height:{xs:"auto",md:1}},children:[e.jsxs(f,{children:[e.jsxs(P,{direction:"row",justifyContent:"space-between",alignItems:"center",children:[e.jsx(P,{flex:1,width:0,children:e.jsxs(f,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(S,{variant:"h5",fontWeight:600,sx:{overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis"},children:a.description}),e.jsx(O,{title:a.url,children:e.jsx(Z,{sx:{fontSize:"16px",marginTop:"2px"}})})]})}),e.jsx(P,{direction:"row",alignItems:"center",children:e.jsx(_,{edge:"end",color:"inherit",onClick:d,children:e.jsx(Le,{})})})]}),e.jsx(f,{mt:2,children:e.jsxs(P,{className:"section-body",direction:{xs:"column",md:"row"},spacing:{xs:1,md:3},justifyContent:"flex-start",flexWrap:"wrap",sx:{pt:2,mt:2,borderTop:"1px solid #eee"},children:[e.jsx(z,{label:c("common.status"),value:e.jsx(A,{size:"small",variant:"filled",label:a.status,color:he(a.status),sx:{borderRadius:"4px",lineHeight:"20px",textTransform:"capitalize"}}),divider:!0}),e.jsx(z,{label:c("webhookEndpoint.listen"),value:e.jsx(O,{arrow:!0,title:e.jsx("ul",{style:{padding:0,margin:0},children:a.enabledEvents.map(h=>e.jsx("li",{style:{fontSize:"0.7875rem"},children:h==null?void 0:h.type},h))}),children:e.jsx(A,{size:"small",variant:"filled",label:c("webhookEndpoint.eventsCount",{count:a.enabledEvents.length}),sx:{borderRadius:"4px",lineHeight:"20px",textTransform:"capitalize"}})}),divider:!0}),e.jsx(z,{label:c("webhookEndpoint.version"),value:a.apiVersion,divider:!0}),e.jsx(z,{label:c("common.createdAt"),value:H(a.createdAt),divider:!0}),e.jsx(z,{label:c("common.updatedAt"),value:H(a.updatedAt),divider:!0}),e.jsx(z,{label:c("common.createdBy"),value:e.jsx(O,{arrow:!0,title:(v=a.createUser)==null?void 0:v.did,children:e.jsx(A,{size:"small",variant:"filled",label:(T=a.createUser)==null?void 0:T.fullName,sx:{borderRadius:"4px",lineHeight:"20px",textTransform:"capitalize"}})}),divider:!0}),e.jsx(z,{label:c("common.updatedBy"),value:e.jsx(O,{arrow:!0,title:(j=a.updateUser)==null?void 0:j.did,children:e.jsx(A,{size:"small",variant:"filled",label:(y=a.updateUser)==null?void 0:y.fullName,sx:{borderRadius:"4px",lineHeight:"20px",textTransform:"capitalize"}})})})]})})]}),e.jsxs(P,{className:"section",flex:1,height:0,overflow:"hidden",children:[e.jsx(ne,{title:c("webhookEndpoint.attempts"),mb:0,mt:4}),e.jsx(P,{height:0,flex:1,overflow:"hidden",children:e.jsx(se,{webhookEndpointId:a.id})})]})]})}xe.propTypes={id:o.string.isRequired,onClose:o.func.isRequired};const st=pe(P)``;function me({open:t,onClose:d,id:c}){return e.jsx($e,{anchor:"right",open:t,onClose:d,PaperProps:{sx:{width:"90vw",maxWidth:"1200px"}},children:e.jsx(f,{sx:{height:"100vh",p:3},children:e.jsx(xe,{id:c,onClose:d})})})}me.propTypes={open:o.bool.isRequired,onClose:o.func.isRequired,id:o.string.isRequired};function le(){return null}const re=X.memo(({options:t,columns:d,toolbar:c=!0,footer:l=!0,hasRowLink:b=!1,emptyNodeText:R="",...p})=>{const{locale:n}=$(),a=Be(j=>j.breakpoints.down("md")),v={print:!1,download:!1,filter:!1,selectableRows:"none",rowsPerPage:a?5:10,rowsPerPageOptions:[5,10,20,50,100],searchDebounceTime:300,tableBodyHeight:"100%",loading:!0},T={};return c||(T.TableToolbar=le),l||(T.TableFooter=le),e.jsx(rt,{locale:n,options:{...v,...t},columns:(d||[]).map(j=>(j.options=j.options||{},j.options.filter=j.options.filter||!1,j.options.sort=j.options.sort||!1,j)),emptyNode:e.jsx(fe,{children:R}),...p,components:T,hasRowLink:b,isMobile:a})});re.propTypes={options:o.object,columns:o.array,toolbar:o.bool,footer:o.bool,hasRowLink:o.bool,emptyNodeText:o.node,durable:o.string,durableKeys:o.array,data:o.array,loading:o.bool,onChange:o.func,title:o.node,components:o.object};re.defaultProps={options:{},columns:[],toolbar:!0,footer:!0,hasRowLink:!1,emptyNodeText:null,durable:"",durableKeys:[],data:[],loading:!1,onChange:()=>{},title:null,components:{}};const rt=pe(ge)`
1
+ import{u as $,Y as W,c2 as Y,h as be,_ as fe,a5 as ge,bM as je}from"./vendor-ux-did-connect-CiLSrCOH.js";import{x as ye,m as de,j as we}from"./vendor-hooks-BwVH-TAd.js";import{r as C,b as X}from"./vendor-react-DoD83n6N.js";import{d as Z}from"./InfoOutlined-DO0_Vjz-.js";import{z as F,C as ce,t as ke}from"./index-tjRN_EVx.js";import{u as N,a as ve,C as K}from"./dashboard-oxsbu66O.js";import{H as o,j as e,D as Ee,ai as Ce,t as Te,aa as f,O as ie,T as S,a9 as U,aj as ee,z as Se,y as B,bs as ae,bO as V,ab as O,L as Q,A as G,bl as Re,E as A,I as _,C as Ie,bq as Me,ak as P,c4 as Pe,X as De,bg as J,bp as ze,b4 as We,c5 as Oe,c6 as Ae,b5 as qe,am as $e,bZ as Le,s as pe,v as Be,c7 as He,c8 as Fe,c9 as Ne,ca as Ue,cb as _e}from"./vendor-mui-core-DxD1UA4o.js";import{l as Ye}from"./vendor-arcblock-BtlDhznp.js";import{d as Ke}from"./ExpandLess-DRlih5VO.js";import{z as ue,x as Ve,y as Je}from"./vendor-utils-CTIzdAFg.js";import{C as Qe}from"./confirm-BX8_-j-l.js";import{A as Ge}from"./actions-BOikuUJD.js";import"./lottie-web-B6s7dDoL.js";import"./useLocalStorage-BXnF_60k.js";import"./PlayArrow-NjIpSDwJ.js";import"./get-safe-url-ZRaKUVld.js";import"./format-error-LAoTjvJe.js";import"./index-DIckhHU5.js";import"./session-DaQ4KCFD.js";import"./useAsyncRetry-k063P8TB.js";import"./useAsync-BmW5cnbx.js";import"./useSetState-BL3ktMon.js";import"./use-mobile-CHMVa8_W.js";import"./MoreHoriz-B8cBSV22.js";const Xe=t=>{var j,y;const[d,c]=C.useState(null),[l,b]=C.useState(!t),[R,p]=C.useState(null),{blocklet:n}=ce(),a=(y=(j=n==null?void 0:n.site)==null?void 0:j.domainAliases[0])==null?void 0:y.value,v=C.useMemo(()=>{const h={};return d&&(d.sources.forEach(r=>{h[r.did]={source:r,events:[],count:0}}),d.events.forEach(r=>{h[r.source]&&(h[r.source].events.push(r),h[r.source].count+=1)})),h},[d]),T=async()=>{try{if(b(!0),!a)return;const r=await(await fetch(`https://${a}/.well-known/service/openevent.json`)).json();c(r),p(null)}catch(h){p(h instanceof Error?h:new Error(String(h)))}finally{b(!1)}};return C.useEffect(()=>{T()},[a]),{openEvent:d,setOpenEvent:c,eventsBySource:v,loading:l,error:R,loadData:T}};function te({eventsBySource:t,selectedEvents:d,setSelectedEvents:c,error:l}){const{t:b}=$(),[R,p]=C.useState({}),n=C.useMemo(()=>{const r={};return Object.entries(t).forEach(([w,{events:g}])=>{const E=g.filter(u=>d[`${u.type}-${u.source}`]).length;r[w]=E}),r},[t,d]),a=C.useMemo(()=>Object.values(n).reduce((r,w)=>r+w,0),[n]),v=C.useMemo(()=>Object.values(t).reduce((r,{events:w})=>r+w.length,0),[t]),T=(r,w)=>{w.stopPropagation(),p({...R,[r]:!R[r]})},j=r=>{const w=`${r.type}-${r.source}`;c(g=>({...g,[w]:!g[w]}))},y=(r,w)=>{const g={};r.forEach(E=>{const u=`${E.type}-${E.source}`;g[u]=!w}),c(E=>({...E,...g}))},h=r=>{const w={};Object.values(t).forEach(({events:g})=>{g.forEach(E=>{const u=`${E.type}-${E.source}`;w[u]=r.target.checked})}),c(w)};return e.jsxs(f,{sx:{width:"100%"},children:[e.jsxs(f,{sx:{display:"flex",alignItems:"center",mb:1,mt:1},children:[e.jsx(ae,{control:e.jsx(V,{onChange:h,checked:a>0&&a===v}),label:e.jsxs(f,{sx:{display:"flex",alignItems:"center",cursor:"pointer"},children:[b("webhookEndpoint.selectAllEvents"),e.jsx(f,{sx:{display:"flex",alignItems:"center"},children:e.jsx(O,{title:b("webhookEndpoint.selectAllEventsTooltip"),placement:"right",children:e.jsx(Z,{fontSize:"small",sx:{ml:.5,cursor:"help"}})})})]}),sx:{m:0}}),a>0&&e.jsx(S,{variant:"body2",color:"primary",sx:{ml:"auto"},children:b("webhookEndpoint.selectedEventsCount",{count:a})})]}),e.jsx(f,{sx:{maxHeight:"50vh",overflow:"auto"},children:e.jsx(Q,{disablePadding:!0,sx:{border:"1px solid #e0e0e0",borderRadius:"4px"},children:Object.entries(t).map(([r,{source:w,events:g,count:E}],u)=>{const M=n[r]>0,i=n[r]===g.length&&g.length>0,x=R[r];return e.jsxs(X.Fragment,{children:[e.jsx(G,{sx:{borderBottom:u<Object.keys(t).length-1?"1px solid #f0f0f0":"none",px:2,py:1.5,"&:hover":{bgcolor:"rgba(0, 0, 0, 0.02)"}},children:e.jsxs(f,{sx:{display:"flex",width:"100%",justifyContent:"space-between",alignItems:"center"},onClick:s=>{s.target.closest(".MuiFormControlLabel-root")||T(r,s)},children:[e.jsx(f,{sx:{display:"flex",alignItems:"center"},children:g.length>0&&e.jsx(ae,{control:e.jsx(V,{checked:i,indeterminate:M&&!i,onChange:s=>{s.stopPropagation(),y(g,i)}}),label:e.jsxs(f,{sx:{display:"flex",alignItems:"center",gap:1},children:[w.logo&&e.jsx(Re,{src:w.logo,sx:{width:24,height:24}}),e.jsx(f,{children:w.title||r}),M&&e.jsx(A,{label:b("webhookEndpoint.selectedCount",{count:n[r]}),size:"small",sx:{mt:"2px",height:"20px",fontSize:"12px",bgcolor:s=>`${s.palette.primary.main}20`,color:"primary.main",fontWeight:500}})]}),sx:{m:0,"& .MuiFormControlLabel-label":{flex:1}}})}),e.jsxs(f,{sx:{display:"flex",alignItems:"center"},children:[e.jsx(S,{variant:"body2",color:"text.secondary",sx:{mr:1},children:b("webhookEndpoint.eventsCount",{count:E})}),g.length>0&&e.jsx(_,{size:"small",edge:"end",children:x?e.jsx(Ke,{}):e.jsx(Ye,{})})]})]})}),g.length>0&&e.jsx(Ie,{in:x,timeout:"auto",unmountOnExit:!0,children:e.jsx(Q,{disablePadding:!0,sx:{pl:2,pr:2,py:1,bgcolor:"rgba(0, 0, 0, 0.01)"},children:g.map(s=>{const m=`${s.type}-${s.source}`,k=!!d[m];return e.jsx(G,{dense:!0,sx:{py:.75},onClick:()=>j(s),children:e.jsxs(f,{sx:{display:"flex",alignItems:"flex-start",width:"100%"},children:[e.jsx(V,{checked:k,sx:{mr:1}}),e.jsxs(f,{children:[e.jsx(S,{variant:"body1",sx:{cursor:"pointer"},children:s.type}),e.jsx(S,{variant:"caption",color:"text.disabled",sx:{display:"block",cursor:"pointer"},children:s.description})]})]})},m)})})})]},r)})})}),l&&e.jsx(Me,{error:!0,sx:{mt:1},children:l})]})}te.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};te.defaultProps={error:null};function oe({id:t,url:d,description:c,enabledEvents:l,onSubmit:b,onClose:R}){var s;const{t:p}=$(),[n,a]=C.useState({}),{teamDid:v}=N(),{api:T}=F(),{loading:j,error:y,eventsBySource:h}=Xe(),{control:r,handleSubmit:w,formState:{errors:g},reset:E,setValue:u,trigger:M}=ve({defaultValues:{url:"",description:""}});C.useEffect(()=>{const m=Object.values(n).some(k=>k);u("selectedEvents",m?"valid":""),M("selectedEvents")},[n,u,M]);const i=()=>{a({}),E(),R()},x=async m=>{const k=Object.keys(n).filter(I=>n[I]),D={url:m.url,description:m.description,enabledEvents:k.map(I=>{const[q,L]=I.split("-");return!q||!L?null:{type:q,source:L}}).filter(Boolean)};try{if(t){const I=await T.updateWebhookEndpoint({input:{teamDid:v,id:t,data:D}});W.success(`${p("webhookEndpoint.updateWebhook")} ${p("webhookEndpoint.success")}`),b(I)}else{const I=await T.createWebhookEndpoint({input:{teamDid:v,input:D}});W.success(`${p("webhookEndpoint.createWebhook")} ${p("webhookEndpoint.success")}`),b(I)}}catch(I){W.error(I==null?void 0:I.message)}i()};return C.useEffect(()=>{E({url:d,description:c}),a(l.reduce((m,k)=>(m[`${k.type}-${k.source}`]=!0,m),{}))},[E,a,d,c,l]),e.jsx(Ee,{open:!0,onClose:i,maxWidth:"lg",fullWidth:!0,sx:{"& .MuiDialog-paper":{minHeight:600}},children:e.jsxs("form",{onSubmit:w(x),children:[e.jsx(Ce,{children:p(t?"webhookEndpoint.editWebhookTitle":"webhookEndpoint.createWebhookTitle")}),e.jsx(Te,{children:e.jsxs(f,{sx:{display:"flex",flexDirection:"column",gap:2,mt:2},children:[e.jsx(K,{name:"url",control:r,rules:{required:p("webhookEndpoint.validation.urlRequired"),pattern:{value:/^(http|https):\/\/[^ "]+$/,message:p("webhookEndpoint.validation.urlInvalid")}},render:({field:m})=>{var k;return e.jsx(ie,{...m,label:p("webhookEndpoint.url.label"),fullWidth:!0,error:!!g.url,helperText:(k=g.url)==null?void 0:k.message})}}),e.jsx(K,{name:"description",control:r,rules:{required:p("webhookEndpoint.validation.descriptionRequired")},render:({field:m})=>{var k;return e.jsx(ie,{...m,label:p("webhookEndpoint.description.label"),fullWidth:!0,multiline:!0,minRows:2,maxRows:4,error:!!g.description,helperText:(k=g.description)==null?void 0:k.message})}}),e.jsx(K,{name:"selectedEvents",control:r,rules:{required:p("webhookEndpoint.validation.eventRequired")},render:({field:m})=>e.jsx("input",{type:"hidden",...m})}),!j&&h&&Object.keys(h).length>0&&e.jsx(te,{eventsBySource:h,selectedEvents:n,setSelectedEvents:a,error:(s=g.selectedEvents)==null?void 0:s.message}),!j&&(!h||Object.keys(h).length===0)&&e.jsx(S,{color:"text.secondary",children:p("webhookEndpoint.noAvailableEvents")}),j&&e.jsx(f,{sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"500px",width:"100%"},children:e.jsx(U,{size:20})}),y&&e.jsx(ee,{severity:"error",children:p("webhookEndpoint.loadingError",{message:y==null?void 0:y.message})})]})}),e.jsxs(Se,{sx:{p:"8px 24px 24px"},children:[e.jsx(B,{onClick:i,children:p("common.cancel")}),e.jsx(B,{type:"submit",variant:"contained",color:"primary",children:p(t?"webhookEndpoint.updateWebhook":"webhookEndpoint.saveWebhook")})]})]})})}oe.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};oe.defaultProps={id:null,url:"",description:"",enabledEvents:[],onClose:()=>{}};function he(t){switch(t){case"enabled":return"success";case"disabled":default:return"default"}}const Ze=(t="en")=>t==="tw"?"zh":t;function H(t,d="YYYY-MM-DD HH:mm:ss",c="en"){return t?ke(t).locale(Ze(c)).format(d):"-"}function et(t){return typeof t=="number"?!1:ue(t)}function tt(t){return t>=200&&t<300}function z(t){const d=et(t.value);return e.jsxs(e.Fragment,{children:[e.jsxs(P,{direction:"column",alignItems:"flex-start",children:[e.jsxs(S,{component:"div",variant:"body1",mb:1,color:"text.primary",sx:{fontWeight:500},children:[t.label,!!t.tip&&e.jsx(O,{title:t.tip,children:e.jsx(Pe,{fontSize:"small"})})]}),e.jsx(S,{component:"div",variant:"body1",color:d?"text.disabled":"text.secondary",sx:{width:"100%",minHeight:"24px"},children:d?"-":t.value})]}),t.divider&&e.jsx(De,{orientation:"vertical",flexItem:!0})]})}z.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};z.defaultProps={tip:"",divider:!1};function ne(t){return e.jsxs(P,{className:"section-header",direction:"row",justifyContent:"space-between",alignItems:"center",flexWrap:"wrap",gap:1,sx:{mb:t.mb,mt:t.mt,pb:1},children:[e.jsx(S,{variant:"h3",sx:{fontSize:{xs:"18px",md:"1.09375rem"}},component:"div",children:t.title}),t.children]})}ne.propTypes={title:o.oneOfType([o.string,o.node]).isRequired,children:o.node,mb:o.number,mt:o.number};ne.defaultProps={children:null,mb:1.5,mt:1.5};const ot={width:24,height:24,body:'<path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 6H6a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2v-6m-7 1l9-9m-5 0h5v5"/>'},nt=t=>{const d={};return t.forEach(c=>{var b;const l=new Date(c.createdAt).toLocaleDateString();d[l]||(d[l]=[]),(b=d[l])==null||b.push(c)}),d};function se({eventId:t,webhookEndpointId:d,event:c}){const{api:l}=F(),{t:b}=$(),{teamDid:R}=N(),{blocklet:p}=ce(),{data:n,loadMore:a,loadingMore:v,loading:T}=ye(u=>{const i=u?Math.ceil(u.list.length/15)+1:1;return l.getWebhookAttempts({input:{teamDid:R,input:{eventId:t,webhookId:d},paging:{page:i,pageSize:15}}})},{reloadDeps:[t,d]}),j=(n==null?void 0:n.list)||[],[y,h]=C.useState(null),r=nt(j);C.useEffect(()=>{!y&&(n!=null&&n.list.length)&&h(n.list[0])},[n==null?void 0:n.list.length,y]);const w=u=>{h(u)};if(T)return e.jsx(U,{});const g=n&&n.list.length<n.paging.total,E=u=>{var M,i,x,s,m;if(u.responseBody&&((M=u.responseBody)!=null&&M.sessionId)&&((i=u.responseBody)!=null&&i.projectId)&&((x=u.responseBody)!=null&&x.agentId)){const k=(m=(s=p==null?void 0:p.site)==null?void 0:s.domainAliases[0])==null?void 0:m.value,D=(p.children||[]).find(q=>{var L;return((L=q==null?void 0:q.meta)==null?void 0:L.name)==="ai-studio"}),I=Ve(Je(`https://${k}`,(D==null?void 0:D.mountPoint)||"","projects",u.responseBody.projectId,"logs/main"),{sessionId:u.responseBody.sessionId,agentId:u.responseBody.agentId});return e.jsx(_,{sx:{fontSize:20},onClick:()=>window.open(I,"_blank"),children:e.jsx(f,{component:be,icon:ot})})}return null};return e.jsxs(J,{container:!0,spacing:{xs:0,md:1},sx:{height:1},children:[e.jsx(J,{item:!0,xs:12,md:4,height:1,children:ue(Object.keys(r))?e.jsx(S,{color:"text.secondary",children:b("webhookEndpoint.waitingForEvents")}):e.jsxs(e.Fragment,{children:[e.jsx(Q,{sx:{maxHeight:"calc(100% - 40px)",py:0,overflowY:"auto"},children:Object.entries(r).map(([u,M])=>e.jsxs(X.Fragment,{children:[e.jsx(ze,{children:u}),M.map(i=>e.jsxs(G,{sx:{cursor:"pointer"},onClick:()=>w(i),selected:y===i,secondaryAction:e.jsx(S,{color:"text.secondary",children:H(i.createdAt,"HH:mm:ss")}),children:[e.jsx(We,{sx:{minWidth:0,mr:1.5},children:tt(i.responseStatus)===!1?e.jsx(Oe,{color:"error"}):e.jsx(Ae,{color:"success"})}),e.jsx(qe,{primary:e.jsx(S,{color:"text.primary",children:i.event.type})})]},i.id))]},u))}),g&&e.jsx(f,{display:"flex",justifyContent:"center",alignItems:"center",width:1,children:e.jsx(B,{variant:"text",type:"button",color:"inherit",onClick:a,disabled:v,sx:{color:u=>u.palette.text.disabled},children:b(v?"webhookEndpoint.loadingMore":"webhookEndpoint.loadMore")})})]})}),e.jsxs(J,{item:!0,xs:12,md:8,height:1,children:[y&&e.jsxs(P,{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(f,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(S,{variant:"h6",children:t?y.endpoint.url:y.event.type}),e.jsx(f,{children:E(y)})]}),e.jsxs(f,{children:[e.jsxs(S,{variant:"h6",children:[b("webhookEndpoint.response")," (",y.responseStatus,")"]}),e.jsx(Y,{language:"json",children:JSON.stringify(y.responseBody,null,2)})]}),e.jsxs(f,{children:[e.jsx(P,{direction:"row",alignItems:"center",spacing:1,children:e.jsx(S,{variant:"h6",children:b("webhookEndpoint.request")})}),e.jsx(Y,{language:"json",sx:{margin:0},children:JSON.stringify(y.event,null,2)})]})]}),(n==null?void 0:n.list.length)===0&&c&&e.jsxs(f,{children:[e.jsx(P,{direction:"row",alignItems:"center",spacing:1,children:e.jsx(S,{variant:"h6",children:b("webhookEndpoint.eventData")})}),e.jsx(Y,{language:"json",sx:{margin:0},children:JSON.stringify(c.data,null,2)})]})]})]})}se.propTypes={eventId:o.string,webhookEndpointId:o.string,event:o.shape({type:o.string,data:o.object,request:o.object,requestInfo:o.object})};se.defaultProps={eventId:"",webhookEndpointId:"",event:null};function xe({id:t,onClose:d}){var v,T,j,y;const{t:c}=$(),{api:l}=F(),{teamDid:b}=N(),{loading:R,error:p,data:n}=de(()=>l.getWebhookEndpoint({input:{teamDid:b,id:t}})),a=n==null?void 0:n.data;return p?e.jsx(ee,{severity:"error",children:p.message}):R||!a?e.jsx(f,{display:"flex",justifyContent:"center",alignItems:"center",height:1,width:1,children:e.jsx(U,{})}):e.jsxs(st,{direction:"column",sx:{height:{xs:"auto",md:1}},children:[e.jsxs(f,{children:[e.jsxs(P,{direction:"row",justifyContent:"space-between",alignItems:"center",children:[e.jsx(P,{flex:1,width:0,children:e.jsxs(f,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(S,{variant:"h5",fontWeight:600,sx:{overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis"},children:a.description}),e.jsx(O,{title:a.url,children:e.jsx(Z,{sx:{fontSize:"16px",marginTop:"2px"}})})]})}),e.jsx(P,{direction:"row",alignItems:"center",children:e.jsx(_,{edge:"end",color:"inherit",onClick:d,children:e.jsx(Le,{})})})]}),e.jsx(f,{mt:2,children:e.jsxs(P,{className:"section-body",direction:{xs:"column",md:"row"},spacing:{xs:1,md:3},justifyContent:"flex-start",flexWrap:"wrap",sx:{pt:2,mt:2,borderTop:"1px solid #eee"},children:[e.jsx(z,{label:c("common.status"),value:e.jsx(A,{size:"small",variant:"filled",label:a.status,color:he(a.status),sx:{borderRadius:"4px",lineHeight:"20px",textTransform:"capitalize"}}),divider:!0}),e.jsx(z,{label:c("webhookEndpoint.listen"),value:e.jsx(O,{arrow:!0,title:e.jsx("ul",{style:{padding:0,margin:0},children:a.enabledEvents.map(h=>e.jsx("li",{style:{fontSize:"0.7875rem"},children:h==null?void 0:h.type},h))}),children:e.jsx(A,{size:"small",variant:"filled",label:c("webhookEndpoint.eventsCount",{count:a.enabledEvents.length}),sx:{borderRadius:"4px",lineHeight:"20px",textTransform:"capitalize"}})}),divider:!0}),e.jsx(z,{label:c("webhookEndpoint.version"),value:a.apiVersion,divider:!0}),e.jsx(z,{label:c("common.createdAt"),value:H(a.createdAt),divider:!0}),e.jsx(z,{label:c("common.updatedAt"),value:H(a.updatedAt),divider:!0}),e.jsx(z,{label:c("common.createdBy"),value:e.jsx(O,{arrow:!0,title:(v=a.createUser)==null?void 0:v.did,children:e.jsx(A,{size:"small",variant:"filled",label:(T=a.createUser)==null?void 0:T.fullName,sx:{borderRadius:"4px",lineHeight:"20px",textTransform:"capitalize"}})}),divider:!0}),e.jsx(z,{label:c("common.updatedBy"),value:e.jsx(O,{arrow:!0,title:(j=a.updateUser)==null?void 0:j.did,children:e.jsx(A,{size:"small",variant:"filled",label:(y=a.updateUser)==null?void 0:y.fullName,sx:{borderRadius:"4px",lineHeight:"20px",textTransform:"capitalize"}})})})]})})]}),e.jsxs(P,{className:"section",flex:1,height:0,overflow:"hidden",children:[e.jsx(ne,{title:c("webhookEndpoint.attempts"),mb:0,mt:4}),e.jsx(P,{height:0,flex:1,overflow:"hidden",children:e.jsx(se,{webhookEndpointId:a.id})})]})]})}xe.propTypes={id:o.string.isRequired,onClose:o.func.isRequired};const st=pe(P)``;function me({open:t,onClose:d,id:c}){return e.jsx($e,{anchor:"right",open:t,onClose:d,PaperProps:{sx:{width:"90vw",maxWidth:"1200px"}},children:e.jsx(f,{sx:{height:"100vh",p:3},children:e.jsx(xe,{id:c,onClose:d})})})}me.propTypes={open:o.bool.isRequired,onClose:o.func.isRequired,id:o.string.isRequired};function le(){return null}const re=X.memo(({options:t,columns:d,toolbar:c=!0,footer:l=!0,hasRowLink:b=!1,emptyNodeText:R="",...p})=>{const{locale:n}=$(),a=Be(j=>j.breakpoints.down("md")),v={print:!1,download:!1,filter:!1,selectableRows:"none",rowsPerPage:a?5:10,rowsPerPageOptions:[5,10,20,50,100],searchDebounceTime:300,tableBodyHeight:"100%",loading:!0},T={};return c||(T.TableToolbar=le),l||(T.TableFooter=le),e.jsx(rt,{locale:n,options:{...v,...t},columns:(d||[]).map(j=>(j.options=j.options||{},j.options.filter=j.options.filter||!1,j.options.sort=j.options.sort||!1,j)),emptyNode:e.jsx(fe,{children:R}),...p,components:T,hasRowLink:b,isMobile:a})});re.propTypes={options:o.object,columns:o.array,toolbar:o.bool,footer:o.bool,hasRowLink:o.bool,emptyNodeText:o.node,durable:o.string,durableKeys:o.array,data:o.array,loading:o.bool,onChange:o.func,title:o.node,components:o.object};re.defaultProps={options:{},columns:[],toolbar:!0,footer:!0,hasRowLink:!1,emptyNodeText:null,durable:"",durableKeys:[],data:[],loading:!1,onChange:()=>{},title:null,components:{}};const rt=pe(ge)`
2
2
  .MuiPaper-root {
3
3
  border-radius: 8px;
4
4
  overflow: hidden;