@abtnode/blocklet-services 1.16.53-beta-20251011-095147-8bd212c5 → 1.16.53-beta-20251013-075536-64fcb94b

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 (126) hide show
  1. package/api/index.js +8 -17
  2. package/api/util/federated.js +10 -5
  3. package/dist/assets/{access-control-C2aF8l7f.js → access-control-CUUGBegg.js} +1 -1
  4. package/dist/assets/{add-component-core-DaSlPT-f.js → add-component-core-D8CsaWtE.js} +1 -1
  5. package/dist/assets/{add-resource-BbsAiWlt.js → add-resource-DRYWyzFg.js} +1 -1
  6. package/dist/assets/{addon-FUH-lSq2.js → addon-DhicELT4.js} +1 -1
  7. package/dist/assets/{advanced-C5U4taie.js → advanced-D4kyySFu.js} +1 -1
  8. package/dist/assets/{aigne-eGqt4yLH.js → aigne--ydEFgxM.js} +1 -1
  9. package/dist/assets/{appearance-COFOsk8H.js → appearance-DiUMtWiZ.js} +1 -1
  10. package/dist/assets/{arrow-down.svg-BIpNdtOh.js → arrow-down.svg-DgXRF8DP.js} +1 -1
  11. package/dist/assets/{audit-logs-mrNr9NEV.js → audit-logs-zMqI7X3o.js} +1 -1
  12. package/dist/assets/{authorize-DNMdsHLY.js → authorize-Dr-5dOao.js} +1 -1
  13. package/dist/assets/{bind-account-DHM0aKm4.js → bind-account-DA7_VhlG.js} +1 -1
  14. package/dist/assets/{branding-DCFBnIuE.js → branding-BqZaDEQy.js} +1 -1
  15. package/dist/assets/{branding-C8c4AQBL.js → branding-Bwa2_l30.js} +1 -1
  16. package/dist/assets/{branding-Ds21HJPv.js → branding-CDF8I7CS.js} +1 -1
  17. package/dist/assets/{bundle-avatar-YluGbYkj.js → bundle-avatar-D5n6XSFF.js} +1 -1
  18. package/dist/assets/{complete-ci8dXkdd.js → complete-CJN6MZr9.js} +1 -1
  19. package/dist/assets/{component-CktAV437.js → component-BkgYdhLW.js} +2 -2
  20. package/dist/assets/{config-hlI_P1F8.js → config-BKWRBZkN.js} +1 -1
  21. package/dist/assets/config-C6P5yz_l.js +53 -0
  22. package/dist/assets/{config-BDvrfPci.js → config-NzhCDrRK.js} +1 -1
  23. package/dist/assets/{config-navigation-D8-g7qAt.js → config-navigation-CpkTSVgC.js} +2 -2
  24. package/dist/assets/{config-space-BLuDOEKJ.js → config-space-D742OP6B.js} +1 -1
  25. package/dist/assets/{confirm-Cs-v9Ueu.js → confirm-D1n-RK65.js} +1 -1
  26. package/dist/assets/{connect-Do64lcqi.js → connect-Cp5779ib.js} +1 -1
  27. package/dist/assets/{connect-DZzHQL_N.js → connect-DCldlgle.js} +1 -1
  28. package/dist/assets/{connect-to-D-Tb_fXt.js → connect-to-CzzpDiUC.js} +1 -1
  29. package/dist/assets/{dashboard-DcdBCHRL.js → dashboard-COW8XxoK.js} +2 -2
  30. package/dist/assets/{delete-confirm-D-H3beUW.js → delete-confirm-DDcjKsY2.js} +1 -1
  31. package/dist/assets/{domain-D1iCGb9_.js → domain-DR_J7IrS.js} +1 -1
  32. package/dist/assets/{domain-action-card-dl9BP1dq.js → domain-action-card-CuN-BTun.js} +1 -1
  33. package/dist/assets/{domains-VJkxJvLu.js → domains-BwpVswVc.js} +1 -1
  34. package/dist/assets/{email-CXQwvoco.js → email-Da8K28dJ.js} +1 -1
  35. package/dist/assets/engine-CynZsYEr.js +1 -0
  36. package/dist/assets/{exchange-passport-By4W6XDH.js → exchange-passport-Bic3wuCk.js} +1 -1
  37. package/dist/assets/{form-B_F_xaXO.js → form-BO9zQEEu.js} +1 -1
  38. package/dist/assets/{fuel-CW2Evrsd.js → fuel-QHX754Te.js} +1 -1
  39. package/dist/assets/{gen-access-key-DlPCMbg5.js → gen-access-key-1fCgd-vd.js} +1 -1
  40. package/dist/assets/{gen-simple-access-key-DGvoYxjH.js → gen-simple-access-key-DrYDMNDo.js} +1 -1
  41. package/dist/assets/{get-safe-url-rD2TSrmk.js → get-safe-url-BrBIp6RF.js} +1 -1
  42. package/dist/assets/{home-B4ti5g0W.js → home-CR7v9FTO.js} +1 -1
  43. package/dist/assets/{iframe-BI7fZAER.js → iframe-CKOcsJB-.js} +1 -1
  44. package/dist/assets/{index-DbJX8mTu.js → index--2eh3YdI.js} +1 -1
  45. package/dist/assets/{index-D-SgeZ2f.js → index-6KFpxb0K.js} +1 -1
  46. package/dist/assets/{index-Bxd2Cj9Z.js → index-9WUHnAoz.js} +1 -1
  47. package/dist/assets/{index-CwiCg7Wy.js → index-BAigP45p.js} +1 -1
  48. package/dist/assets/{index-B3Wj0Nic.js → index-BAm_yZT8.js} +1 -1
  49. package/dist/assets/{index-DeRDwip-.js → index-BFBoLr1Z.js} +1 -1
  50. package/dist/assets/{index-DHsKHttK.js → index-BH9BMLP2.js} +1 -1
  51. package/dist/assets/{index-Ha4kS6kt.js → index-BOst2c_c.js} +1 -1
  52. package/dist/assets/{index-OE1287Me.js → index-BSTi6sO4.js} +1 -1
  53. package/dist/assets/{index-4foCOGch.js → index-BZUEA_VO.js} +1 -1
  54. package/dist/assets/{index-B5MKa5ov.js → index-C5sng-9P.js} +2 -2
  55. package/dist/assets/{index-D46_FTfy.js → index-CGC3omja.js} +1 -1
  56. package/dist/assets/{index-Bdipd-mG.js → index-ChdZfn2Z.js} +1 -1
  57. package/dist/assets/{index-DgBkBy0d.js → index-DYxM5dQ0.js} +1 -1
  58. package/dist/assets/{index-B8GEVW-7.js → index-De6RU5uv.js} +1 -1
  59. package/dist/assets/{index-kK-2wGsh.js → index-Difo-vx2.js} +1 -1
  60. package/dist/assets/{index-kYJKn2jR.js → index-Dt8akALo.js} +3 -3
  61. package/dist/assets/{index-CM-I96vs.js → index-DuO31sai.js} +1 -1
  62. package/dist/assets/{index-Ffd9R2jw.js → index-DyNpNTLA.js} +1 -1
  63. package/dist/assets/{index-CWPu1V9G.js → index-F6BB6AaL.js} +1 -1
  64. package/dist/assets/{index-8x51s8zo.js → index-Oj4fYD5K.js} +3 -3
  65. package/dist/assets/{index-CE80LF06.js → index-OuTt2geA.js} +1 -1
  66. package/dist/assets/{index-DeRE90O3.js → index-Y3X8f7Z4.js} +1 -1
  67. package/dist/assets/{index-Dy82BFhx.js → index-dAVnNC1I.js} +1 -1
  68. package/dist/assets/{index-Bm6372dL.js → index-pDY1qDDT.js} +1 -1
  69. package/dist/assets/{index-BmZkZYAT.js → index-rX_gKff6.js} +1 -1
  70. package/dist/assets/{invitation-uW2SRspc.js → invitation-BKbYsXkF.js} +1 -1
  71. package/dist/assets/{invitations-BKP1NV2c.js → invitations-B-nYRbwb.js} +1 -1
  72. package/dist/assets/{invite-Cyj0TX33.js → invite-wTyupZG1.js} +1 -1
  73. package/dist/assets/{isURL-DOKl6zP6.js → isURL-B2kErAOg.js} +1 -1
  74. package/dist/assets/{issue-passport-jS72R6Y9.js → issue-passport-BrDZjXex.js} +1 -1
  75. package/dist/assets/{item-6E9xBb8C.js → item-BFG9doj4.js} +1 -1
  76. package/dist/assets/{landing-page-CfBuAqix.js → landing-page-CQU5LiHu.js} +1 -1
  77. package/dist/assets/{layout-Yt1Ps3ty.js → layout-BByAfem8.js} +1 -1
  78. package/dist/assets/{list-CbJU6aON.js → list-4bMHptVO.js} +1 -1
  79. package/dist/assets/{list-CWTC1dNA.js → list-aRu0R0L1.js} +1 -1
  80. package/dist/assets/{localization-BWvCdRh6.js → localization-J2gA-h7I.js} +1 -1
  81. package/dist/assets/{log-D8J_RKs2.js → log-BgOBDKaO.js} +1 -1
  82. package/dist/assets/{login-DqfZ0aMJ.js → login-DFrvIKm0.js} +1 -1
  83. package/dist/assets/{login-oauth-callback-BHyWL0cZ.js → login-oauth-callback-D81WLOfu.js} +1 -1
  84. package/dist/assets/{logo-uploader-CN181syA.js → logo-uploader-BSLuQUWG.js} +1 -1
  85. package/dist/assets/{lost-passport-BQSFuIDg.js → lost-passport-CN1lCjAR.js} +1 -1
  86. package/dist/assets/{open-window-CVPA9xdu.js → open-window-DFdTfBab.js} +1 -1
  87. package/dist/assets/{over-due-invoice-payment-gqfc7YHA.js → over-due-invoice-payment-BHBjNHAK.js} +1 -1
  88. package/dist/assets/{overview-BfjhNxe0.js → overview-BNptGAD0.js} +1 -1
  89. package/dist/assets/{passport-C9JudxNO.js → passport-Di66zEMV.js} +1 -1
  90. package/dist/assets/{passport-item-VF3cWzrN.js → passport-item-cu1WVC_B.js} +1 -1
  91. package/dist/assets/{permission-B4abezk1.js → permission-ya4qYiIS.js} +1 -1
  92. package/dist/assets/{preferences-C_XdWNfF.js → preferences-BPkyQMDe.js} +1 -1
  93. package/dist/assets/{profile-embed-QqF7FA6v.js → profile-embed-DEkmxYPv.js} +1 -1
  94. package/dist/assets/{publish-resource-H7eMW32y.js → publish-resource-q3_KT0uW.js} +1 -1
  95. package/dist/assets/{runtime-8vm1QUk_.js → runtime-zSSdjk9Q.js} +1 -1
  96. package/dist/assets/sdk-DlI_Utmi.js +1 -0
  97. package/dist/assets/{security-Dw-d-MTv.js → security-BlvbBEUe.js} +1 -1
  98. package/dist/assets/{session-C838MSz1.js → session-Y3RU3I2O.js} +1 -1
  99. package/dist/assets/{setup-DegA44sL.js → setup-BZH_pYLe.js} +1 -1
  100. package/dist/assets/{spaces-M_qE7wW_.js → spaces-BwBxBfty.js} +1 -1
  101. package/dist/assets/{start-BVg7NHO7.js → start-DZ1T1oW8.js} +1 -1
  102. package/dist/assets/{starting-progress-Bc97wy6x.js → starting-progress-HuVVYFsR.js} +1 -1
  103. package/dist/assets/{status-QhfaNvgn.js → status-BR0A9vPy.js} +1 -1
  104. package/dist/assets/{step-actions-DTwta5X_.js → step-actions-D4zI4sWZ.js} +1 -1
  105. package/dist/assets/{studio-BKBKyaGG.js → studio-UxYOr-dB.js} +1 -1
  106. package/dist/assets/{team-BxHvUIQ6.js → team-s6q3vfNx.js} +1 -1
  107. package/dist/assets/{traffic-bm4qFOVU.js → traffic-CwvEJLQW.js} +1 -1
  108. package/dist/assets/{transfer-BrMoTS5Z.js → transfer-DBlISG7m.js} +1 -1
  109. package/dist/assets/{unsubscribe-B27dQ-V0.js → unsubscribe-BW7dIXXb.js} +1 -1
  110. package/dist/assets/{use-app-logo-ezyDWOV9.js → use-app-logo-BjReZUm7.js} +1 -1
  111. package/dist/assets/{user-center-uDx2x7Sm.js → user-center-D18_bCCh.js} +2 -2
  112. package/dist/assets/{user-follower-CxhX_9BD.js → user-follower-McTCB9YD.js} +1 -1
  113. package/dist/assets/{user-sessions-B3zzrErP.js → user-sessions-DYtBKHTy.js} +1 -1
  114. package/dist/assets/{util-B8m2D-S9.js → util-DDkRAi85.js} +1 -1
  115. package/dist/assets/{util-k7U_iSB6.js → util-V3sRgqXp.js} +1 -1
  116. package/dist/assets/{wait-connect-DhEi-ni_.js → wait-connect-C4xkzmAl.js} +1 -1
  117. package/dist/assets/{wizard-obzJ3sCB.js → wizard-5C6_E9yj.js} +1 -1
  118. package/dist/assets/{wizard-components-BZT4jikM.js → wizard-components-Cu-kCEHh.js} +1 -1
  119. package/dist/assets/{wrap-locale-CaI-lUtp.js → wrap-locale-DcfUdcYR.js} +1 -1
  120. package/dist/assets/{zh-dnVpNwG1.js → zh-Ckmy3lEn.js} +1 -1
  121. package/dist/index.html +1 -1
  122. package/dist/service-worker.js +1 -1
  123. package/package.json +23 -23
  124. package/dist/assets/config-BE0FYeHo.js +0 -53
  125. package/dist/assets/engine-OnFdHI4e.js +0 -1
  126. package/dist/assets/sdk-DRBI7AWf.js +0 -1
@@ -1,4 +1,4 @@
1
- import{j as a,D as M,T as _,ce as T,Q as W,cf as X,aV as Z,ak as h,cg as q,aU as Y,av as B,f as C,b$ as J,ch as K}from"./vendor-mui-core-DRxbhqaK.js";import{r as d,k as L,L as z,n as ee,o as ae}from"./vendor-react-Dvs43sk9.js";import{H as E,aU as te}from"./index-kYJKn2jR.js";import{e as ie}from"./vendor-hooks-BlA8TRnZ.js";import{M as re,l as m,X as A,Z as S}from"./vendor-ux-B9VfuZTg.js";import{z as oe}from"./vendor-arcblock-DeeG8u0h.js";const H=d.createContext(null),se=e=>{const i=d.use(H);return d.useLayoutEffect(()=>{},[]),i};function le({children:e=void 0,...i}){const[t,r]=d.useState({inFullPage:!1,showToggleButton:!1,headerVisibleInFullPage:!0,footerVisibleInFullPage:!1,sidebarVisibleInFullPage:!1}),s=()=>{r(o=>({...o,inFullPage:!o.inFullPage}))},l=d.useMemo(()=>({...t,headerVisible:!t.inFullPage||t.headerVisibleInFullPage,footerVisible:!t.inFullPage||t.footerVisibleInFullPage,sidebarVisible:!t.inFullPage||t.sidebarVisibleInFullPage,toggleFullPage:s,configure:o=>r(n=>({...n,...o}))}),[t]);return a.jsx(H,{value:l,...i,children:e})}function ne({name:e,size:i=36,alt:t="",color:r="#000000",prefix:s="/images",showBadge:l=!1,style:o={},...n}){const c=`${s}/${e}-${r.replace(/^#/,"")}.png`;return a.jsxs(de,{style:{width:i,height:i},children:[a.jsx(re,{width:i,height:i,alt:t||e,src:c,style:Object.assign({width:i},o),...n}),l&&a.jsx("i",{className:"badge-point"})]})}const de=m("div")`
1
+ import{j as a,D as M,T as _,ce as T,Q as W,cf as X,aV as Z,ak as h,cg as q,aU as Y,av as B,f as C,b$ as J,ch as K}from"./vendor-mui-core-DRxbhqaK.js";import{r as d,k as L,L as z,n as ee,o as ae}from"./vendor-react-Dvs43sk9.js";import{H as E,aU as te}from"./index-Dt8akALo.js";import{e as ie}from"./vendor-hooks-BlA8TRnZ.js";import{M as re,l as m,X as A,Z as S}from"./vendor-ux-B9VfuZTg.js";import{z as oe}from"./vendor-arcblock-DeeG8u0h.js";const H=d.createContext(null),se=e=>{const i=d.use(H);return d.useLayoutEffect(()=>{},[]),i};function le({children:e=void 0,...i}){const[t,r]=d.useState({inFullPage:!1,showToggleButton:!1,headerVisibleInFullPage:!0,footerVisibleInFullPage:!1,sidebarVisibleInFullPage:!1}),s=()=>{r(o=>({...o,inFullPage:!o.inFullPage}))},l=d.useMemo(()=>({...t,headerVisible:!t.inFullPage||t.headerVisibleInFullPage,footerVisible:!t.inFullPage||t.footerVisibleInFullPage,sidebarVisible:!t.inFullPage||t.sidebarVisibleInFullPage,toggleFullPage:s,configure:o=>r(n=>({...n,...o}))}),[t]);return a.jsx(H,{value:l,...i,children:e})}function ne({name:e,size:i=36,alt:t="",color:r="#000000",prefix:s="/images",showBadge:l=!1,style:o={},...n}){const c=`${s}/${e}-${r.replace(/^#/,"")}.png`;return a.jsxs(de,{style:{width:i,height:i},children:[a.jsx(re,{width:i,height:i,alt:t||e,src:c,style:Object.assign({width:i},o),...n}),l&&a.jsx("i",{className:"badge-point"})]})}const de=m("div")`
2
2
  position: relative;
3
3
  .badge-point {
4
4
  position: absolute;
@@ -1,4 +1,4 @@
1
- import{r as j,g as ge}from"./vendor-react-Dvs43sk9.js";import{j as o,T as H,z as $,x as ye,c3 as ve,c4 as Y,bw as je,F as Ce,bD as Te,aX as Fe,a6 as U,W as C,b6 as be,a5 as we,I as K,at as G,ak as B,J as Se,Q as Be,cb as De,am as Re}from"./vendor-mui-core-DRxbhqaK.js";import{X as L,b7 as ae,B as le,c as Ne}from"./index-kYJKn2jR.js";import{T as M,b as ce,n as E,H as z,E as ee,S as Pe}from"./vendor-ux-B9VfuZTg.js";import{e as ue}from"./edit.svg-DycWG9v3.js";import{C as He}from"./lock.svg-COUP8tyO.js";import{G as Ie,H as Ee}from"./vendor-utils-CUDP56Ff.js";import{f as pe}from"./index-DBs9Ljax.js";import{u as de}from"./team-BxHvUIQ6.js";import{w as me,P as Le}from"./permission-B4abezk1.js";import{C as Me}from"./confirm-Cs-v9Ueu.js";const _e=u=>j.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",...u},j.createElement("path",{d:"M8.4375 4.3125H8.25C8.35313 4.3125 8.4375 4.22812 8.4375 4.125V4.3125H15.5625V4.125C15.5625 4.22812 15.6469 4.3125 15.75 4.3125H15.5625V6H17.25V4.125C17.25 3.29766 16.5773 2.625 15.75 2.625H8.25C7.42266 2.625 6.75 3.29766 6.75 4.125V6H8.4375V4.3125ZM20.25 6H3.75C3.33516 6 3 6.33516 3 6.75V7.5C3 7.60313 3.08437 7.6875 3.1875 7.6875H4.60312L5.18203 19.9453C5.21953 20.7445 5.88047 21.375 6.67969 21.375H17.3203C18.1219 21.375 18.7805 20.7469 18.818 19.9453L19.3969 7.6875H20.8125C20.9156 7.6875 21 7.60313 21 7.5V6.75C21 6.33516 20.6648 6 20.25 6ZM17.1398 19.6875H6.86016L6.29297 7.6875H17.707L17.1398 19.6875Z"}));var A={exports:{}},W={exports:{}},te;function ke(){return te||(te=1,function(){var u="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",m={rotl:function(a,c){return a<<c|a>>>32-c},rotr:function(a,c){return a<<32-c|a>>>c},endian:function(a){if(a.constructor==Number)return m.rotl(a,8)&16711935|m.rotl(a,24)&4278255360;for(var c=0;c<a.length;c++)a[c]=m.endian(a[c]);return a},randomBytes:function(a){for(var c=[];a>0;a--)c.push(Math.floor(Math.random()*256));return c},bytesToWords:function(a){for(var c=[],l=0,p=0;l<a.length;l++,p+=8)c[p>>>5]|=a[l]<<24-p%32;return c},wordsToBytes:function(a){for(var c=[],l=0;l<a.length*32;l+=8)c.push(a[l>>>5]>>>24-l%32&255);return c},bytesToHex:function(a){for(var c=[],l=0;l<a.length;l++)c.push((a[l]>>>4).toString(16)),c.push((a[l]&15).toString(16));return c.join("")},hexToBytes:function(a){for(var c=[],l=0;l<a.length;l+=2)c.push(parseInt(a.substr(l,2),16));return c},bytesToBase64:function(a){for(var c=[],l=0;l<a.length;l+=3)for(var p=a[l]<<16|a[l+1]<<8|a[l+2],d=0;d<4;d++)l*8+d*6<=a.length*8?c.push(u.charAt(p>>>6*(3-d)&63)):c.push("=");return c.join("")},base64ToBytes:function(a){a=a.replace(/[^A-Z0-9+\/]/ig,"");for(var c=[],l=0,p=0;l<a.length;p=++l%4)p!=0&&c.push((u.indexOf(a.charAt(l-1))&Math.pow(2,-2*p+8)-1)<<p*2|u.indexOf(a.charAt(l))>>>6-p*2);return c}};W.exports=m}()),W.exports}var V,re;function ne(){if(re)return V;re=1;var u={utf8:{stringToBytes:function(m){return u.bin.stringToBytes(unescape(encodeURIComponent(m)))},bytesToString:function(m){return decodeURIComponent(escape(u.bin.bytesToString(m)))}},bin:{stringToBytes:function(m){for(var a=[],c=0;c<m.length;c++)a.push(m.charCodeAt(c)&255);return a},bytesToString:function(m){for(var a=[],c=0;c<m.length;c++)a.push(String.fromCharCode(m[c]));return a.join("")}}};return V=u,V}/*!
1
+ import{r as j,g as ge}from"./vendor-react-Dvs43sk9.js";import{j as o,T as H,z as $,x as ye,c3 as ve,c4 as Y,bw as je,F as Ce,bD as Te,aX as Fe,a6 as U,W as C,b6 as be,a5 as we,I as K,at as G,ak as B,J as Se,Q as Be,cb as De,am as Re}from"./vendor-mui-core-DRxbhqaK.js";import{X as L,b7 as ae,B as le,c as Ne}from"./index-Dt8akALo.js";import{T as M,b as ce,n as E,H as z,E as ee,S as Pe}from"./vendor-ux-B9VfuZTg.js";import{e as ue}from"./edit.svg-DycWG9v3.js";import{C as He}from"./lock.svg-COUP8tyO.js";import{G as Ie,H as Ee}from"./vendor-utils-CUDP56Ff.js";import{f as pe}from"./index-DBs9Ljax.js";import{u as de}from"./team-s6q3vfNx.js";import{w as me,P as Le}from"./permission-ya4qYiIS.js";import{C as Me}from"./confirm-D1n-RK65.js";const _e=u=>j.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",...u},j.createElement("path",{d:"M8.4375 4.3125H8.25C8.35313 4.3125 8.4375 4.22812 8.4375 4.125V4.3125H15.5625V4.125C15.5625 4.22812 15.6469 4.3125 15.75 4.3125H15.5625V6H17.25V4.125C17.25 3.29766 16.5773 2.625 15.75 2.625H8.25C7.42266 2.625 6.75 3.29766 6.75 4.125V6H8.4375V4.3125ZM20.25 6H3.75C3.33516 6 3 6.33516 3 6.75V7.5C3 7.60313 3.08437 7.6875 3.1875 7.6875H4.60312L5.18203 19.9453C5.21953 20.7445 5.88047 21.375 6.67969 21.375H17.3203C18.1219 21.375 18.7805 20.7469 18.818 19.9453L19.3969 7.6875H20.8125C20.9156 7.6875 21 7.60313 21 7.5V6.75C21 6.33516 20.6648 6 20.25 6ZM17.1398 19.6875H6.86016L6.29297 7.6875H17.707L17.1398 19.6875Z"}));var A={exports:{}},W={exports:{}},te;function ke(){return te||(te=1,function(){var u="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",m={rotl:function(a,c){return a<<c|a>>>32-c},rotr:function(a,c){return a<<32-c|a>>>c},endian:function(a){if(a.constructor==Number)return m.rotl(a,8)&16711935|m.rotl(a,24)&4278255360;for(var c=0;c<a.length;c++)a[c]=m.endian(a[c]);return a},randomBytes:function(a){for(var c=[];a>0;a--)c.push(Math.floor(Math.random()*256));return c},bytesToWords:function(a){for(var c=[],l=0,p=0;l<a.length;l++,p+=8)c[p>>>5]|=a[l]<<24-p%32;return c},wordsToBytes:function(a){for(var c=[],l=0;l<a.length*32;l+=8)c.push(a[l>>>5]>>>24-l%32&255);return c},bytesToHex:function(a){for(var c=[],l=0;l<a.length;l++)c.push((a[l]>>>4).toString(16)),c.push((a[l]&15).toString(16));return c.join("")},hexToBytes:function(a){for(var c=[],l=0;l<a.length;l+=2)c.push(parseInt(a.substr(l,2),16));return c},bytesToBase64:function(a){for(var c=[],l=0;l<a.length;l+=3)for(var p=a[l]<<16|a[l+1]<<8|a[l+2],d=0;d<4;d++)l*8+d*6<=a.length*8?c.push(u.charAt(p>>>6*(3-d)&63)):c.push("=");return c.join("")},base64ToBytes:function(a){a=a.replace(/[^A-Z0-9+\/]/ig,"");for(var c=[],l=0,p=0;l<a.length;p=++l%4)p!=0&&c.push((u.indexOf(a.charAt(l-1))&Math.pow(2,-2*p+8)-1)<<p*2|u.indexOf(a.charAt(l))>>>6-p*2);return c}};W.exports=m}()),W.exports}var V,re;function ne(){if(re)return V;re=1;var u={utf8:{stringToBytes:function(m){return u.bin.stringToBytes(unescape(encodeURIComponent(m)))},bytesToString:function(m){return decodeURIComponent(escape(u.bin.bytesToString(m)))}},bin:{stringToBytes:function(m){for(var a=[],c=0;c<m.length;c++)a.push(m.charCodeAt(c)&255);return a},bytesToString:function(m){for(var a=[],c=0;c<m.length;c++)a.push(String.fromCharCode(m[c]));return a.join("")}}};return V=u,V}/*!
2
2
  * Determine if an object is a Buffer
3
3
  *
4
4
  * @author Feross Aboukhadijeh <https://feross.org>
@@ -1,4 +1,4 @@
1
- import{j as t,a6 as f,ak as r,at as j,W as n}from"./vendor-mui-core-DRxbhqaK.js";import{r as h}from"./vendor-react-Dvs43sk9.js";import{c as S,n as p}from"./vendor-ux-B9VfuZTg.js";import{a as C}from"./page-header-DvSb4Cmz.js";import{a9 as g}from"./index-kYJKn2jR.js";import{o as b}from"./vendor-arcblock-DeeG8u0h.js";import{u as k}from"./config-space-BLuDOEKJ.js";import{C as y,D as v,a as w}from"./connect-to-D-Tb_fXt.js";import{S as c}from"./step-actions-DTwta5X_.js";import{S as E}from"./layout-Yt1Ps3ty.js";import"./vendor-utils-CUDP56Ff.js";import"./vendor-hooks-BlA8TRnZ.js";import"./lottie-web-4koyQiv_.js";import"./spaces-M_qE7wW_.js";import"./api-rC33aBSs.js";import"./index-Ha4kS6kt.js";import"./index-DRYJ0xIl.js";import"./index-BojVbZw0.js";import"./index-Y8LQew4k.js";import"./index-DBs9Ljax.js";import"./use-mobile-D6YQgajG.js";import"./content-layout-B9tc9LCL.js";function T({onNext:a=()=>{},onPrevious:d=()=>{}}){const{t:e}=h.useContext(S),{blocklet:o}=g(),{spaceGateway:m,settingStorageEndpoint:l,updateSpaceGateway:u,hasStorageEndpoint:x,loading:i,storageEndpoint:s}=k();return i?t.jsx(b,{relative:"parent",children:t.jsx(f,{})}):t.jsxs(B,{children:[t.jsx("div",{className:"header",children:t.jsx(C,{title:e("setup.didSpace.title"),subTitle:e("setup.didSpace.subTitle"),onClickBack:d})}),t.jsxs(r,{className:"form-container",sx:{width:"100%",maxWidth:"720px"},children:[x?t.jsx(y,{spaceGateway:m,settingStorageEndpoint:l}):t.jsx(v,{}),o?.capabilities?.didSpace&&t.jsx(r,{sx:{display:"flex",alignItems:"center",justifyContent:"center",paddingTop:"24px"},children:t.jsx(w,{onConnect:u,storageEndpoint:s})})]}),o?.capabilities?.didSpace==="required"&&t.jsx(c,{mt:8,children:t.jsx(p,{loading:i,variant:"contained",disabled:i||!s,onClick:()=>a(),children:e("setup.continue")})}),o?.capabilities?.didSpace==="optional"&&t.jsx(c,{blocklet:o,onStartNow:()=>a("complete"),children:t.jsx(p,{className:"start-now",loading:i,variant:"contained",disabled:i,onClick:()=>a(),children:e(s?"setup.continue":"setup.skip")})})]})}T.propTypes={onNext:n.func,onPrevious:n.func};const B=j(E)`
1
+ import{j as t,a6 as f,ak as r,at as j,W as n}from"./vendor-mui-core-DRxbhqaK.js";import{r as h}from"./vendor-react-Dvs43sk9.js";import{c as S,n as p}from"./vendor-ux-B9VfuZTg.js";import{a as C}from"./page-header-DvSb4Cmz.js";import{a9 as g}from"./index-Dt8akALo.js";import{o as b}from"./vendor-arcblock-DeeG8u0h.js";import{u as k}from"./config-space-D742OP6B.js";import{C as y,D as v,a as w}from"./connect-to-CzzpDiUC.js";import{S as c}from"./step-actions-D4zI4sWZ.js";import{S as E}from"./layout-BByAfem8.js";import"./vendor-utils-CUDP56Ff.js";import"./vendor-hooks-BlA8TRnZ.js";import"./lottie-web-4koyQiv_.js";import"./spaces-BwBxBfty.js";import"./api-rC33aBSs.js";import"./index-BOst2c_c.js";import"./index-DRYJ0xIl.js";import"./index-BojVbZw0.js";import"./index-Y8LQew4k.js";import"./index-DBs9Ljax.js";import"./use-mobile-D6YQgajG.js";import"./content-layout-B9tc9LCL.js";function T({onNext:a=()=>{},onPrevious:d=()=>{}}){const{t:e}=h.useContext(S),{blocklet:o}=g(),{spaceGateway:m,settingStorageEndpoint:l,updateSpaceGateway:u,hasStorageEndpoint:x,loading:i,storageEndpoint:s}=k();return i?t.jsx(b,{relative:"parent",children:t.jsx(f,{})}):t.jsxs(B,{children:[t.jsx("div",{className:"header",children:t.jsx(C,{title:e("setup.didSpace.title"),subTitle:e("setup.didSpace.subTitle"),onClickBack:d})}),t.jsxs(r,{className:"form-container",sx:{width:"100%",maxWidth:"720px"},children:[x?t.jsx(y,{spaceGateway:m,settingStorageEndpoint:l}):t.jsx(v,{}),o?.capabilities?.didSpace&&t.jsx(r,{sx:{display:"flex",alignItems:"center",justifyContent:"center",paddingTop:"24px"},children:t.jsx(w,{onConnect:u,storageEndpoint:s})})]}),o?.capabilities?.didSpace==="required"&&t.jsx(c,{mt:8,children:t.jsx(p,{loading:i,variant:"contained",disabled:i||!s,onClick:()=>a(),children:e("setup.continue")})}),o?.capabilities?.didSpace==="optional"&&t.jsx(c,{blocklet:o,onStartNow:()=>a("complete"),children:t.jsx(p,{className:"start-now",loading:i,variant:"contained",disabled:i,onClick:()=>a(),children:e(s?"setup.continue":"setup.skip")})})]})}T.propTypes={onNext:n.func,onPrevious:n.func};const B=j(E)`
2
2
  height: 100%;
3
3
  overflow-y: auto;
4
4
  `;export{T as default};
@@ -1,5 +1,5 @@
1
1
  const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=[window.__toCdnUrl("assets/vendor-ux-DYcPPYq2.css"),window.__toCdnUrl("assets/index-DrVXX4fX.css"),window.__toCdnUrl("assets/index-B5LvOF-F.css")])))=>i.map(i=>d[i]);
2
- import{r as k,i as It,j as rt,L as we,g as fo,k as As,l as qs,m as bt}from"./vendor-react-Dvs43sk9.js";import{J as Oe,j as e,ak as a,b4 as Et,W as n,am as ke,I as ce,dx as Ns,dy as _s,bb as xo,cb as nt,dz as Ws,a_ as Os,T as A,s as go,cx as ko,dA as zs,cO as Bs,Y as lt,at as ve,av as Vs,dB as Us,a5 as Ye,aX as it,bd as Pt,c7 as Ms,bh as Fs,b6 as Ze,cW as Hs,bi as et,Q as G,a6 as Se,bE as Js,O as jo,K as yo,P as Lt,ai as wo,o as vo,M as be,a3 as Xs,bC as Co,$ as Ro,bw as Gs,A as He,aJ as Ks,R as So,z as ne,b1 as Re,dC as Xt,bX as tt,dD as To,V as Do,S as $t,aP as Io,bD as Ys,D as Eo,cr as Zs,aQ as Qs,aR as er,cs as tr,ct as or,bF as Po,aq as sr,dE as rr,a1 as Lo,a0 as ot,bj as Gt,bI as nr,bJ as lr,dF as ir,dG as cr,bc as vt,y as ar,F as dr,bq as ur,br as ft}from"./vendor-mui-core-DRxbhqaK.js";import{c as F,X as ge,a9 as De,t as pr,V as me,bP as hr,W as mr,e as Kt,bQ as br,au as Yt,b9 as fr,bu as xr,bR as gr,bS as kr,bT as jr}from"./index-kYJKn2jR.js";import{T as X,a0 as $o,x as yr,n as $e,a3 as Ao,I as qo,O as wr,j as At,H as W,s as qt,aK as Nt,P as ae,_ as No,J as We,b as ct,p as _o}from"./vendor-ux-B9VfuZTg.js";import{C as at}from"./confirm-Cs-v9Ueu.js";import{u as ze}from"./session-C838MSz1.js";import{W as Ct}from"./did-address-DnFNwELW.js";import{E as Je}from"./empty-spinner-LXNYl6_1.js";import{B as _t}from"./bundle-avatar-YluGbYkj.js";import{S as Te}from"./shorten-label-DVy6K5I7.js";import{L as Wt}from"./list-header-DMpz8A8v.js";import{K as vr,C as ue,A as Ot,D as Wo,a0 as Cr}from"./vendor-utils-CUDP56Ff.js";import{C as Oo}from"./click-to-copy-CO6UIqva.js";import{t as Rr}from"./question-mark-circle.svg-B4stD6SS.js";import{l as Sr,b as Tr}from"./vendor-hooks-BlA8TRnZ.js";import{u as Me}from"./useSetState-DFuQZPPV.js";import{e as Dr}from"./engine-OnFdHI4e.js";import"./api-rC33aBSs.js";import{T as Ir,S as Er}from"./vendor-mui-x-Qp6zkx78.js";import{D as Zt,C as Qt,P as eo}from"./react-beautiful-dnd.esm-BeX82uI5.js";import{u as zo,c as Pr,w as Lr,a as $r,b as Ar}from"./wait-connect-DhEi-ni_.js";import{f as xe}from"./index-DBs9Ljax.js";import{c as qr,A as Bo,S as Nr,U as _r,r as Wr}from"./item-6E9xBb8C.js";import{D as Or}from"./delete-confirm-D-H3beUW.js";import{g as Vo}from"./get-safe-url-rD2TSrmk.js";import{u as Le}from"./index-DlrQ2HQP.js";import{M as zr}from"./index-Bx-RW9vi.js";import{r as Br}from"./index-BO080WnZ.js";import"./vendor-arcblock-DeeG8u0h.js";import"./lottie-web-4koyQiv_.js";import"./raf-schd.esm-CHNehTG3.js";function zt({did:t,projectId:o,title:s,logo:r,describe:l}){const i=`${`${F.WELLKNOWN_SERVICE_PATH_PREFIX}/api/project/${t}/${o}/logo/upload`}/${r}`,[d,u]=k.useState(!1),x=Oe(p=>p.breakpoints.down("md"));return e.jsxs(a,{sx:{display:"flex",flexDirection:"row",color:d?"primary.main":"grey.900",gap:1},onPointerEnter:()=>u(!0),onPointerLeave:()=>u(!1),children:[e.jsx(Et,{sx:{borderRadius:1},src:i}),e.jsxs(a,{children:[e.jsx(Te,{hiddenTip:!0,maxLength:"24",sx:{fontSize:"14px",fontWeight:"500",color:x?"primary.main":""},children:s||"/"}),e.jsx(Te,{hiddenTip:!0,maxLength:"58",sx:{fontSize:"12px",color:x||d?"primary.main":"grey.700"},children:l||"/"})]})]})}zt.propTypes={projectId:n.string.isRequired,did:n.string.isRequired,title:n.string.isRequired,logo:n.string.isRequired,describe:n.string.isRequired};function Uo({initUrl:t=null}){const o=It(),s=t?.searchParams.get("tenantScope")||"",{t:r,locale:l}=X(),{api:c}=ge(),{api:i}=ze(),[d,u]=k.useState(!0),{blocklet:x}=De(),[p,m]=k.useState(null),[f,b]=k.useState(!1),h=Oe(E=>E.breakpoints.down("xl")),j=Oe(E=>E.breakpoints.down("md")),{componentDid:v=""}=rt(),[g,C]=k.useState(null),D=`publish-${x.meta.did}`,R=$o(D),[y,T]=k.useState({searchText:R.searchText||"",pageSize:R.rowsPerPage||10,page:1}),O=()=>{c.getProjects({input:{did:x.meta.did,componentDid:v,tenantScope:s}}).then(E=>{const I=E?.projects||[];u(!1),C(I)}).catch(E=>{u(!1),W.error(E.message)})},N=()=>{o(`${F.UNOWNED_DID}/create/none/0.0.0`,{replace:!0})},z=E=>{m(E)},K=()=>{u(!1),b(!0)},P=()=>{b(!1),m(null)},L=E=>{W.error(E.message),b(!1),m(null)},w=E=>{if(!E?.deleted){W.error("Delete project failed");return}O(),b(!1),m(null)};k.useEffect(()=>{O()},[]);const S=k.useMemo(()=>{if(!y.searchText)return g;let E=y.searchText?.trim();return E?(E=yr.toAddress(E).toLocaleLowerCase(),g.filter(I=>I.blockletTitle.toLowerCase().includes(E)||I.blockletDid.toLowerCase().includes(E))):g},[g,y.searchText]);if(!g&&d)return e.jsx(a,{sx:{display:"flex",justifyContent:"center",alignItems:"center",marginTop:"40px"},children:e.jsx(Je,{})});if(!g)return null;if(!g.length)return e.jsxs(a,{sx:{display:"flex",flexDirection:"column",alignItems:"center",pt:10},children:[e.jsx(a,{sx:{fontSize:20,fontWeight:"bold",mb:3},children:r("blocklet.publish.blockletEmptyTip")}),e.jsx(a,{sx:{fontSize:14,color:"text.secondary",mb:3},children:r("blocklet.publish.createBlockletTip")}),e.jsx($e,{onClick:N,variant:"contained",children:r("blocklet.publish.createBlocklet")})]});const Z=[{label:"Blocklet",name:"blockletTitle",minWidth:160,options:{customBodyRenderLite:E=>{const I=g[E];return e.jsx(we,{to:`${I.id}`,children:e.jsx(zt,{did:x.meta.did,projectId:I.id,logo:I.blockletLogo,title:I.blockletTitle,describe:I.blockletDescription})})}}},{label:"Version",name:"blockletVersion",options:{searchable:!1,customBodyRender:E=>E?e.jsx(Ao,{type:"success",children:E}):""}},{label:"DID",name:"blockletDid",options:{customBodyRender:E=>E?e.jsx(Ct,{size:14,compact:!0,responsive:!1,did:E}):null}},h||v?null:{label:r("common.createdBy"),name:"createdBy",options:{customBodyRender:E=>E?e.jsx(Ct,{onClick:()=>{o(`${F.WELLKNOWN_SERVICE_PATH_PREFIX}/admin/members?did=${E}`)},style:{cursor:"pointer"},size:14,compact:!0,copyable:!1,showQrcode:!1,responsive:!1,did:E}):null}},h||v?null:{label:r("common.scope"),name:"componentDid",options:{customBodyRender:E=>{const I=(x.children||[]).find(V=>V.meta.did===E);return I?e.jsxs(a,{sx:{display:"flex",alignItems:"center",justifyContent:"flex-start"},children:[e.jsx(_t,{size:14,blocklet:I,ancestors:[x]}),e.jsx(a,{sx:{ml:.5,color:"text.primary",fontSize:14},children:I.meta.title})]},E):""}}},h||s?null:{label:r("blocklet.publish.tenantScope"),name:"tenantScope",options:{customBodyRender:E=>e.jsx(a,{sx:{ml:.5,color:"text.primary",fontSize:14},children:e.jsx(Te,{children:E})})}},{label:r("common.updatedAt"),name:"updatedAt",options:{searchable:!1,customBodyRender:E=>e.jsx(qo,{value:Number(E),locale:l})}},{label:r("common.actions"),name:"actions",options:{searchable:!1,customBodyRenderLite:E=>{const I=g[E];return e.jsxs(a,{sx:{display:"flex"},children:[e.jsx(we,{to:`${I.id}/new-release/none/${I.lastReleaseId}`,children:e.jsx(ke,{title:r("blocklet.publish.createRelease"),placement:"top",children:e.jsx(ce,{color:"primary","aria-label":"create",children:e.jsx(Ns,{style:{fontSize:18}})})})}),!!I.lastReleaseId&&e.jsx(ke,{title:r("blocklet.publish.viewLastRelease",{name:I.blockletTitle}),placement:"top",children:e.jsx(ce,{color:"secondary","aria-label":"create",children:e.jsx(we,{style:{display:"flex"},to:`${I.id}/view/${I.lastReleaseId}/${I.blockletVersion}`,children:e.jsx(_s,{sx:{fontSize:18}})})})}),e.jsx(ke,{title:r("blocklet.publish.delete",{name:I.blockletTitle}),placement:"top",children:e.jsx(ce,{color:"primary","aria-label":"delete",onClick:()=>z(I),children:e.jsx(xo,{sx:{fontSize:18}})})})]})}}}].filter(Boolean),H=({page:E,rowsPerPage:I,searchText:V})=>{y.pageSize!==I?T(U=>({...U,searchText:"",pageSize:I,page:1})):y.page!==E+1?T(U=>({...U,searchText:"",page:E+1})):y.searchText!==V&&T(U=>({...U,searchText:V,page:1}))},Q=f?e.jsx(pr,{open:!0,popup:!0,onClose:P,action:"check-has-project-id",locale:l,checkFn:i.get,saveConnect:!1,forceConnected:!1,checkTimeout:5*60*1e3,onSuccess:w,onError:L,extraParams:{projectId:p.id,did:x.meta.did,name:p.blockletTitle},messages:{title:r("blocklet.publish.deleteProject.title",{name:p.blockletTitle}),scan:r("blocklet.publish.deleteProject.scan",{name:p.blockletTitle}),confirm:r("blocklet.publish.deleteProject.confirm"),success:r("blocklet.publish.deleteProject.success")}}):null;return e.jsxs(Vr,{children:[e.jsx(Wt,{sx:{mb:2},left:e.jsxs(a,{sx:{display:"flex",flexDirection:"row",alignItems:"center"},children:[e.jsx(a,{sx:{fontSize:"1.2rem",fontWeight:"bold"},children:r("common.blockletStudio")}),e.jsx(ke,{title:r("blocklet.publish.createBlockletTip"),arrow:!0,placement:"right",children:e.jsx(Ws,{sx:{opacity:.6,fontSize:"1.1em",ml:1}})})]}),actions:e.jsxs(e.Fragment,{children:[e.jsx(wr,{options:{searchPlaceholder:r("blocklet.list.searchPlaceholder"),searchDebounceTime:600,searchAlwaysOpen:j},search:y.searchText,searchText:y.searchText,searchTextUpdate:E=>T(I=>({...I,searchText:E})),searchClose:()=>T(E=>({...E,searchText:""})),onSearchOpen:()=>{}}),e.jsxs($e,{onClick:N,variant:"contained",children:[e.jsx(nt,{style:{fontSize:"1.3em",marginRight:4}}),r("blocklet.publish.createBlocklet")]})]})}),e.jsx(At,{className:"main-table",locale:l,data:S,columns:Z,options:{search:!1,sort:!1,download:!1,filter:!1,print:!1,viewColumns:!1,searchAlwaysOpen:!0,rowsPerPageOptions:[10,20,50,100]},durable:D,onChange:H}),p&&e.jsx(at,{title:`${r("common.delete")} ${p.blockletTitle}`,description:r("blocklet.publish.deleteProject.description"),confirm:r("common.confirm"),onConfirm:K,onCancel:()=>m(null),children:e.jsx(a,{sx:{marginTop:2},children:[r("blocklet.publish.deleteProject.tip1"),r("blocklet.publish.deleteProject.tip2"),r("blocklet.publish.deleteProject.tip3")].map(E=>e.jsxs(a,{sx:{display:"flex",marginTop:1,flexDirection:"row",alignItems:"flex-start"},children:[e.jsx(Os,{color:"warning",sx:{marginRight:1,fontSize:20,marginTop:"2px"}}),e.jsx(A,{component:"span",variant:"inherit",sx:{color:"text.secondary"},children:E})]}))})}),Q]})}const Vr=go(a)`
2
+ import{r as k,i as It,j as rt,L as we,g as fo,k as As,l as qs,m as bt}from"./vendor-react-Dvs43sk9.js";import{J as Oe,j as e,ak as a,b4 as Et,W as n,am as ke,I as ce,dx as Ns,dy as _s,bb as xo,cb as nt,dz as Ws,a_ as Os,T as A,s as go,cx as ko,dA as zs,cO as Bs,Y as lt,at as ve,av as Vs,dB as Us,a5 as Ye,aX as it,bd as Pt,c7 as Ms,bh as Fs,b6 as Ze,cW as Hs,bi as et,Q as G,a6 as Se,bE as Js,O as jo,K as yo,P as Lt,ai as wo,o as vo,M as be,a3 as Xs,bC as Co,$ as Ro,bw as Gs,A as He,aJ as Ks,R as So,z as ne,b1 as Re,dC as Xt,bX as tt,dD as To,V as Do,S as $t,aP as Io,bD as Ys,D as Eo,cr as Zs,aQ as Qs,aR as er,cs as tr,ct as or,bF as Po,aq as sr,dE as rr,a1 as Lo,a0 as ot,bj as Gt,bI as nr,bJ as lr,dF as ir,dG as cr,bc as vt,y as ar,F as dr,bq as ur,br as ft}from"./vendor-mui-core-DRxbhqaK.js";import{c as F,X as ge,a9 as De,t as pr,V as me,bP as hr,W as mr,e as Kt,bQ as br,au as Yt,b9 as fr,bu as xr,bR as gr,bS as kr,bT as jr}from"./index-Dt8akALo.js";import{T as X,a0 as $o,x as yr,n as $e,a3 as Ao,I as qo,O as wr,j as At,H as W,s as qt,aK as Nt,P as ae,_ as No,J as We,b as ct,p as _o}from"./vendor-ux-B9VfuZTg.js";import{C as at}from"./confirm-D1n-RK65.js";import{u as ze}from"./session-Y3RU3I2O.js";import{W as Ct}from"./did-address-DnFNwELW.js";import{E as Je}from"./empty-spinner-LXNYl6_1.js";import{B as _t}from"./bundle-avatar-D5n6XSFF.js";import{S as Te}from"./shorten-label-DVy6K5I7.js";import{L as Wt}from"./list-header-DMpz8A8v.js";import{K as vr,C as ue,A as Ot,D as Wo,a0 as Cr}from"./vendor-utils-CUDP56Ff.js";import{C as Oo}from"./click-to-copy-CO6UIqva.js";import{t as Rr}from"./question-mark-circle.svg-B4stD6SS.js";import{l as Sr,b as Tr}from"./vendor-hooks-BlA8TRnZ.js";import{u as Me}from"./useSetState-DFuQZPPV.js";import{e as Dr}from"./engine-CynZsYEr.js";import"./api-rC33aBSs.js";import{T as Ir,S as Er}from"./vendor-mui-x-Qp6zkx78.js";import{D as Zt,C as Qt,P as eo}from"./react-beautiful-dnd.esm-BeX82uI5.js";import{u as zo,c as Pr,w as Lr,a as $r,b as Ar}from"./wait-connect-C4xkzmAl.js";import{f as xe}from"./index-DBs9Ljax.js";import{c as qr,A as Bo,S as Nr,U as _r,r as Wr}from"./item-BFG9doj4.js";import{D as Or}from"./delete-confirm-DDcjKsY2.js";import{g as Vo}from"./get-safe-url-BrBIp6RF.js";import{u as Le}from"./index-DlrQ2HQP.js";import{M as zr}from"./index-Bx-RW9vi.js";import{r as Br}from"./index-BO080WnZ.js";import"./vendor-arcblock-DeeG8u0h.js";import"./lottie-web-4koyQiv_.js";import"./raf-schd.esm-CHNehTG3.js";function zt({did:t,projectId:o,title:s,logo:r,describe:l}){const i=`${`${F.WELLKNOWN_SERVICE_PATH_PREFIX}/api/project/${t}/${o}/logo/upload`}/${r}`,[d,u]=k.useState(!1),x=Oe(p=>p.breakpoints.down("md"));return e.jsxs(a,{sx:{display:"flex",flexDirection:"row",color:d?"primary.main":"grey.900",gap:1},onPointerEnter:()=>u(!0),onPointerLeave:()=>u(!1),children:[e.jsx(Et,{sx:{borderRadius:1},src:i}),e.jsxs(a,{children:[e.jsx(Te,{hiddenTip:!0,maxLength:"24",sx:{fontSize:"14px",fontWeight:"500",color:x?"primary.main":""},children:s||"/"}),e.jsx(Te,{hiddenTip:!0,maxLength:"58",sx:{fontSize:"12px",color:x||d?"primary.main":"grey.700"},children:l||"/"})]})]})}zt.propTypes={projectId:n.string.isRequired,did:n.string.isRequired,title:n.string.isRequired,logo:n.string.isRequired,describe:n.string.isRequired};function Uo({initUrl:t=null}){const o=It(),s=t?.searchParams.get("tenantScope")||"",{t:r,locale:l}=X(),{api:c}=ge(),{api:i}=ze(),[d,u]=k.useState(!0),{blocklet:x}=De(),[p,m]=k.useState(null),[f,b]=k.useState(!1),h=Oe(E=>E.breakpoints.down("xl")),j=Oe(E=>E.breakpoints.down("md")),{componentDid:v=""}=rt(),[g,C]=k.useState(null),D=`publish-${x.meta.did}`,R=$o(D),[y,T]=k.useState({searchText:R.searchText||"",pageSize:R.rowsPerPage||10,page:1}),O=()=>{c.getProjects({input:{did:x.meta.did,componentDid:v,tenantScope:s}}).then(E=>{const I=E?.projects||[];u(!1),C(I)}).catch(E=>{u(!1),W.error(E.message)})},N=()=>{o(`${F.UNOWNED_DID}/create/none/0.0.0`,{replace:!0})},z=E=>{m(E)},K=()=>{u(!1),b(!0)},P=()=>{b(!1),m(null)},L=E=>{W.error(E.message),b(!1),m(null)},w=E=>{if(!E?.deleted){W.error("Delete project failed");return}O(),b(!1),m(null)};k.useEffect(()=>{O()},[]);const S=k.useMemo(()=>{if(!y.searchText)return g;let E=y.searchText?.trim();return E?(E=yr.toAddress(E).toLocaleLowerCase(),g.filter(I=>I.blockletTitle.toLowerCase().includes(E)||I.blockletDid.toLowerCase().includes(E))):g},[g,y.searchText]);if(!g&&d)return e.jsx(a,{sx:{display:"flex",justifyContent:"center",alignItems:"center",marginTop:"40px"},children:e.jsx(Je,{})});if(!g)return null;if(!g.length)return e.jsxs(a,{sx:{display:"flex",flexDirection:"column",alignItems:"center",pt:10},children:[e.jsx(a,{sx:{fontSize:20,fontWeight:"bold",mb:3},children:r("blocklet.publish.blockletEmptyTip")}),e.jsx(a,{sx:{fontSize:14,color:"text.secondary",mb:3},children:r("blocklet.publish.createBlockletTip")}),e.jsx($e,{onClick:N,variant:"contained",children:r("blocklet.publish.createBlocklet")})]});const Z=[{label:"Blocklet",name:"blockletTitle",minWidth:160,options:{customBodyRenderLite:E=>{const I=g[E];return e.jsx(we,{to:`${I.id}`,children:e.jsx(zt,{did:x.meta.did,projectId:I.id,logo:I.blockletLogo,title:I.blockletTitle,describe:I.blockletDescription})})}}},{label:"Version",name:"blockletVersion",options:{searchable:!1,customBodyRender:E=>E?e.jsx(Ao,{type:"success",children:E}):""}},{label:"DID",name:"blockletDid",options:{customBodyRender:E=>E?e.jsx(Ct,{size:14,compact:!0,responsive:!1,did:E}):null}},h||v?null:{label:r("common.createdBy"),name:"createdBy",options:{customBodyRender:E=>E?e.jsx(Ct,{onClick:()=>{o(`${F.WELLKNOWN_SERVICE_PATH_PREFIX}/admin/members?did=${E}`)},style:{cursor:"pointer"},size:14,compact:!0,copyable:!1,showQrcode:!1,responsive:!1,did:E}):null}},h||v?null:{label:r("common.scope"),name:"componentDid",options:{customBodyRender:E=>{const I=(x.children||[]).find(V=>V.meta.did===E);return I?e.jsxs(a,{sx:{display:"flex",alignItems:"center",justifyContent:"flex-start"},children:[e.jsx(_t,{size:14,blocklet:I,ancestors:[x]}),e.jsx(a,{sx:{ml:.5,color:"text.primary",fontSize:14},children:I.meta.title})]},E):""}}},h||s?null:{label:r("blocklet.publish.tenantScope"),name:"tenantScope",options:{customBodyRender:E=>e.jsx(a,{sx:{ml:.5,color:"text.primary",fontSize:14},children:e.jsx(Te,{children:E})})}},{label:r("common.updatedAt"),name:"updatedAt",options:{searchable:!1,customBodyRender:E=>e.jsx(qo,{value:Number(E),locale:l})}},{label:r("common.actions"),name:"actions",options:{searchable:!1,customBodyRenderLite:E=>{const I=g[E];return e.jsxs(a,{sx:{display:"flex"},children:[e.jsx(we,{to:`${I.id}/new-release/none/${I.lastReleaseId}`,children:e.jsx(ke,{title:r("blocklet.publish.createRelease"),placement:"top",children:e.jsx(ce,{color:"primary","aria-label":"create",children:e.jsx(Ns,{style:{fontSize:18}})})})}),!!I.lastReleaseId&&e.jsx(ke,{title:r("blocklet.publish.viewLastRelease",{name:I.blockletTitle}),placement:"top",children:e.jsx(ce,{color:"secondary","aria-label":"create",children:e.jsx(we,{style:{display:"flex"},to:`${I.id}/view/${I.lastReleaseId}/${I.blockletVersion}`,children:e.jsx(_s,{sx:{fontSize:18}})})})}),e.jsx(ke,{title:r("blocklet.publish.delete",{name:I.blockletTitle}),placement:"top",children:e.jsx(ce,{color:"primary","aria-label":"delete",onClick:()=>z(I),children:e.jsx(xo,{sx:{fontSize:18}})})})]})}}}].filter(Boolean),H=({page:E,rowsPerPage:I,searchText:V})=>{y.pageSize!==I?T(U=>({...U,searchText:"",pageSize:I,page:1})):y.page!==E+1?T(U=>({...U,searchText:"",page:E+1})):y.searchText!==V&&T(U=>({...U,searchText:V,page:1}))},Q=f?e.jsx(pr,{open:!0,popup:!0,onClose:P,action:"check-has-project-id",locale:l,checkFn:i.get,saveConnect:!1,forceConnected:!1,checkTimeout:5*60*1e3,onSuccess:w,onError:L,extraParams:{projectId:p.id,did:x.meta.did,name:p.blockletTitle},messages:{title:r("blocklet.publish.deleteProject.title",{name:p.blockletTitle}),scan:r("blocklet.publish.deleteProject.scan",{name:p.blockletTitle}),confirm:r("blocklet.publish.deleteProject.confirm"),success:r("blocklet.publish.deleteProject.success")}}):null;return e.jsxs(Vr,{children:[e.jsx(Wt,{sx:{mb:2},left:e.jsxs(a,{sx:{display:"flex",flexDirection:"row",alignItems:"center"},children:[e.jsx(a,{sx:{fontSize:"1.2rem",fontWeight:"bold"},children:r("common.blockletStudio")}),e.jsx(ke,{title:r("blocklet.publish.createBlockletTip"),arrow:!0,placement:"right",children:e.jsx(Ws,{sx:{opacity:.6,fontSize:"1.1em",ml:1}})})]}),actions:e.jsxs(e.Fragment,{children:[e.jsx(wr,{options:{searchPlaceholder:r("blocklet.list.searchPlaceholder"),searchDebounceTime:600,searchAlwaysOpen:j},search:y.searchText,searchText:y.searchText,searchTextUpdate:E=>T(I=>({...I,searchText:E})),searchClose:()=>T(E=>({...E,searchText:""})),onSearchOpen:()=>{}}),e.jsxs($e,{onClick:N,variant:"contained",children:[e.jsx(nt,{style:{fontSize:"1.3em",marginRight:4}}),r("blocklet.publish.createBlocklet")]})]})}),e.jsx(At,{className:"main-table",locale:l,data:S,columns:Z,options:{search:!1,sort:!1,download:!1,filter:!1,print:!1,viewColumns:!1,searchAlwaysOpen:!0,rowsPerPageOptions:[10,20,50,100]},durable:D,onChange:H}),p&&e.jsx(at,{title:`${r("common.delete")} ${p.blockletTitle}`,description:r("blocklet.publish.deleteProject.description"),confirm:r("common.confirm"),onConfirm:K,onCancel:()=>m(null),children:e.jsx(a,{sx:{marginTop:2},children:[r("blocklet.publish.deleteProject.tip1"),r("blocklet.publish.deleteProject.tip2"),r("blocklet.publish.deleteProject.tip3")].map(E=>e.jsxs(a,{sx:{display:"flex",marginTop:1,flexDirection:"row",alignItems:"flex-start"},children:[e.jsx(Os,{color:"warning",sx:{marginRight:1,fontSize:20,marginTop:"2px"}}),e.jsx(A,{component:"span",variant:"inherit",sx:{color:"text.secondary"},children:E})]}))})}),Q]})}const Vr=go(a)`
3
3
  ${({theme:t})=>t.breakpoints.down("md")} {
4
4
  .MuiTableRow-root {
5
5
  border-color: ${({theme:t})=>t.palette.divider};
@@ -142,7 +142,7 @@ import{r as k,i as It,j as rt,L as we,g as fo,k as As,l as qs,m as bt}from"./ven
142
142
  background: #fff;
143
143
  z-index: 10;
144
144
  }
145
- `,io="lastWantToConnectStoreId";function rn(t){const[o,s]=k.useState(null),{session:r}=ze(),l=k.useCallback(d=>{s(d),localStorage.setItem(io,d?.id)},[s]),c=k.useMemo(()=>{const d=localStorage.getItem(io),u=d?(t?.settings?.storeList||[]).find(p=>p.id===d):null;if(u)return u;let x=(t?.settings?.storeList||[]).find(p=>!(p.id!==F.BLOCKLET_STORE.id||p.scope&&p.scope!=="studio"&&p.scope!==r?.user?.did));return x||(x=t?.settings?.storeList?.[0]),x},[t?.settings?.storeList,r?.user?.did]);return[o||c||{},l]}const Bt=({fromBlocklet:t,nodeInfo:o,blocklet:s,userDid:r})=>{const l=t?s?.meta?.did:o?.did;let c=t?s?.settings?.storeList||[]:o?.blockletRegistryList||[];return Array.isArray(c)||(c=[]),c=c.filter(i=>i.protected||Cr(i.scope)||i.scope==="studio"||i.scope===r),{teamDid:l,storeList:c}};function es({blocklet:t=null,store:o=null,onChangeStore:s,onClick:r,disabled:l,loading:c,componentDid:i}){const{t:d}=X(),{session:u}=ze(),{api:x,info:p,inService:m}=ge(),f=De(),[b,h]=k.useState(!1),j=k.useRef(null),[v,g]=k.useState(!1),[C,D]=k.useState(null),R=L=>{s(L),h(!1)},y=()=>{h(!b)},T=L=>{j.current&&j.current.contains(L.target)||h(!1)},O=()=>{g(!0)},N=()=>{g(!1)},z=async()=>{if(C)try{await x.deleteBlockletStore({input:{teamDid:t.meta.did,url:C.url,projectId:"",scope:C.scope||"studio"}}),await f?.actions?.refreshBlocklet()}catch(L){W.error(`Remove Blocklet Store Error: ${xe(L)}`)}finally{D(null)}},{storeList:K}=Bt({fromBlocklet:m,blocklet:t,nodeInfo:p,userDid:u?.user?.did}),P=t?.meta?.did;return e.jsxs(e.Fragment,{children:[e.jsxs(et,{disabled:l,ref:j,variant:"contained",color:"primary","aria-label":"Button group with connect store",children:[e.jsxs(G,{onClick:r,children:[c&&e.jsx(Se,{size:14,sx:{mr:.5}}),`${d("common.connect")} ${o.name||""}`]}),e.jsx(G,{size:"small","aria-controls":b?"split-button-menu":void 0,"aria-expanded":b?"true":void 0,"aria-label":"select merge strategy","aria-haspopup":"menu",onClick:y,children:e.jsx(Js,{})})]}),e.jsx(jo,{sx:{zIndex:10},open:b,anchorEl:j.current,placement:"bottom-end",role:void 0,transition:!0,disablePortal:!0,children:({TransitionProps:L})=>e.jsx(yo,{...L,style:{transformOrigin:"center top"},children:e.jsx(Lt,{children:e.jsx(wo,{onClickAway:T,children:e.jsxs(vo,{id:"split-button-menu",autoFocusItem:!0,sx:{maxHeight:300,overflowY:"auto",zIndex:10},children:[K?.map(w=>e.jsxs(be,{selected:w.id===o?.id,sx:{height:56},onClick:()=>R(w),children:[e.jsxs(a,{children:[e.jsx(Te,{sx:{fontSize:"16px"},maxLength:24,children:w.name}),e.jsx(Te,{sx:{fontSize:"13px",opacity:.6},maxLength:30,children:w.url})]}),qr({store:w,userDid:u?.user?.did})&&e.jsx(ce,{sx:{ml:1},onClick:S=>{S.preventDefault(),S.stopPropagation(),D(w)},children:e.jsx(ae,{icon:"ic:outline-delete"})})]},w.url)),e.jsx(Xs,{}),e.jsxs(be,{onClick:O,children:[e.jsx(nt,{font:!0}),e.jsx(A,{variant:"inherit",children:d("store.blockletRegistry.addRegistry")})]})]})})})})}),v&&e.jsx(Bo,{hiddenChildren:!0,open:!0,onClose:N,teamDid:P,storeList:K,scope:"studio",onAdd:f?.actions?.refreshBlocklet}),C&&e.jsx(at,{displayError:!0,title:`${d("common.delete")} ${C.name}`,description:d("blocklet.publish.deleteStoreTip",{name:C.name}),confirm:d("common.confirm"),onConfirm:z,onCancel:()=>D(null)})]})}es.propTypes={store:n.object,blocklet:n.object,onChangeStore:n.func.isRequired,onClick:n.func.isRequired,loading:n.bool.isRequired,disabled:n.bool.isRequired,componentDid:n.string.isRequired,projectType:n.string.isRequired,getData:n.func.isRequired};const ts=(t,o,s)=>{const r=`${F.WELLKNOWN_SERVICE_PATH_PREFIX}/api/project/${o.meta.did}/${s}/logo/upload`,l=`${F.WELLKNOWN_SERVICE_PATH_PREFIX}/api/project/${o.meta.did}/${s}/screenshot/upload`,c=t?.blockletLogo?`${r}/${t.blockletLogo}`:`${F.WELLKNOWN_SERVICE_PATH_PREFIX}/static/images/logo.png`,i=(t?.blockletScreenshots||[]).filter(Boolean).map(d=>`${l}/${d}`);return{logoUrl:c,screenshotUrls:i,uploadLogoPrefix:r,uploadScreenshotPrefix:l}},nn=t=>{const o=t.includes("youtube.com")||t.includes("youtu.be"),s=t.includes("vimeo.com");return o||s};function Vt({url:t,style:o={},controls:s=1,modestbranding:r=1}){const{t:l}=X(),c=t.includes("youtube.com")||t.includes("youtu.be"),i=t.includes("vimeo.com");if(c){const d=t.split("v=")[1]?.split("&")[0]||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://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(i){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(a,{style:{position:"relative",width:"100%",paddingTop:"56.25%"},children:e.jsxs(a,{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(A,{variant:"body1",sx:{opacity:.5},children:l("studio.videoDialogNoSrc")})]})})}Vt.propTypes={url:n.string.isRequired,style:n.object,controls:n.number,modestbranding:n.number};function os({setParams:t,onClose:o,params:s}){const{t:r}=X(),[l,c]=k.useState(""),i=l&&s.blockletVideos.includes(l),d=nn(l),u=()=>{t(x=>{const p=[...x.blockletVideos];return p.push(l),{...x,blockletVideos:p}}),o()};return e.jsxs(lt,{open:!0,fullWidth:!0,maxWidth:"sm",children:[e.jsx(Co,{children:r("studio.videoDialogTitle")}),e.jsxs(Ro,{children:[e.jsx(Gs,{fullWidth:!0,value:l,onChange:x=>c(x.target.value),placeholder:r("studio.videoInputLabel"),endAdornment:l?e.jsx(He,{position:"end",children:e.jsx(ce,{onClick:()=>c(""),children:e.jsx(Ks,{})})}):null,error:i}),i&&e.jsx(A,{variant:"body2",color:"error",children:r("studio.duplicateVideo")}),e.jsx(Vt,{url:l,style:{marginTop:"20px",borderRadius:"4px"}})]}),e.jsxs(So,{children:[e.jsx(G,{onClick:()=>o(),children:r("studio.cancel")}),e.jsx(G,{disabled:!d||i,onClick:u,children:r("studio.confirm")})]})]})}os.propTypes={onClose:n.func.isRequired,params:n.object.isRequired,setParams:n.func.isRequired};function Rt({errors:t,storeList:o,...s}){const{t:r}=X();return e.jsxs(a,{...s,sx:[{color:"warning.main",fontSize:"14px",border:"1px solid rgba(214, 164, 64, 0.34)",borderRadius:"4px",py:2,px:1.5,position:"relative"},...Array.isArray(s.sx)?s.sx:[s.sx]],children:[e.jsx(A,{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,c])=>{const i=Object.values(c),d=o.find(u=>u.url===l);return i.length>0&&e.jsxs(a,{children:[e.jsx(ke,{title:l,children:e.jsx(a,{component:"span",sx:{cursor:"pointer"},children:d.name})}),i.map(u=>e.jsx(a,{component:"li",sx:{ml:2,wordBreak:!0},children:u},u))]},l)})]})}Rt.propTypes={errors:n.object.isRequired,storeList:n.array.isRequired};const co=k.lazy(()=>No(()=>import("./index-B5MKa5ov.js"),__vite__mapDeps([0,1,2]),import.meta.url).then(t=>({default:t.Uploader})));function ss({projectId:t,readOnly:o,loading:s,blocklet:r,params:l,setParams:c,paramsErrTip:i,setParamsErrTip:d,warning:u,setLoading:x,initUrl:p=null,initLogoUrl:m,setInitLogoUrl:f,componentDid:b=""}){const{t:h,locale:j}=X(),{api:v}=ge(),g=It(),C=k.useRef(null),D=k.useRef(null),[R,y]=rn(r),[T,O]=k.useState(!1),N=zo({messageType:"connect-store-message",onOpen:()=>x(!0),onClose:()=>x(!1)}),z=async q=>{const Y=setTimeout(()=>{x(!1)},2e4),J=await Lr(v,q);x(!1),clearTimeout(Y),window.parent.postMessage({event:"studioDialog.connected",componentDid:b},"*"),g(window.location.pathname.replace(`${F.UNOWNED_DID}/create`,`${J}/create`),{replace:!0})},K=()=>{if(!l.blockletTitle){W.error(h("blocklet.publish.errorTip.noTitle"));return}if(!R?.url){W.error(h("blocklet.publish.noStoreSelected"));return}const q=Pr();N(async(Y,J)=>{try{const se=await v.connectByStudio({input:{did:r?.meta?.did,blockletTitle:l?.blockletTitle,storeUrl:R.url,storeId:R.id,storeName:R.name,type:l?.blockletComponents?.length>0?"pack":"resource",componentDid:b,messageId:q,tenantScope:p?.searchParams.get("tenantScope")||""}});if(!se?.url){W.error("failed to connect to store");return}J(se.url),z({did:r?.meta?.did,projectId:"",messageId:q})}catch(se){const de=xe(se);W.error(de),x(!1)}})},{logoUrl:P,screenshotUrls:L,uploadLogoPrefix:w,uploadScreenshotPrefix:S}=ts(l,r,t),{logoErrors:Z,screenshotErrors:H,storeList:Q,hasLogoWarning:E,hasScreenshotWarning:I}=u,V=()=>o?!1:!t||t===F.UNOWNED_DID?(W.error(h("blocklet.publish.errorTip.noFirstDid")),!1):!0,U=q=>{if(!q.destination)return;const Y=Array.from(l.blockletScreenshots),[J]=Y.splice(q.source.index,1);Y.splice(q.destination.index,0,J),c(se=>({...se,blockletScreenshots:Y}))},ee=q=>{if(!q.destination)return;const Y=Array.from(l.blockletVideos),[J]=Y.splice(q.source.index,1);Y.splice(q.destination.index,0,J),c(se=>({...se,blockletVideos:Y}))};return e.jsxs(ln,{children:[e.jsx(a,{className:"section",sx:{display:"flex"},children:e.jsxs(a,{sx:{flex:1},children:[e.jsx(ne,{disabled:s||o,label:`Blocklet ${h("common.title")}`,placeholder:`Blocklet ${h("common.title")}`,autoComplete:"off",variant:"outlined",fullWidth:!0,required:!0,value:l.blockletTitle||"",onChange:q=>{d({blockletTitle:""}),c({blockletTitle:q.target.value})},error:!!i.blockletTitle,helperText:i.blockletTitle||"",slotProps:{input:{"data-cy":"blocklet-title",readOnly:o}}}),e.jsx(ne,{required:!0,label:"Blocklet DID",fullWidth:!0,readonly:!0,disabled:!0,autoComplete:"off",variant:"outlined",error:!!i.projectId,helperText:i.projectId||"",value:t===F.UNOWNED_DID?"":`did:abt:${t}`,sx:{mt:3},slotProps:{input:{"data-cy":"export-blocklet-did",endAdornment:t===F.UNOWNED_DID&&e.jsx(He,{position:"end",children:e.jsx(es,{blocklet:r,store:R,componentDid:b,onChangeStore:y,disabled:!l.blockletTitle||o||s,loading:s,onClick:K})})}}}),e.jsx(ne,{disabled:s||o,label:`Blocklet ${h("common.description")}`,placeholder:`Blocklet ${h("common.description")}`,required:!0,autoComplete:"off",variant:"outlined",fullWidth:!0,value:l.blockletDescription||"",onChange:q=>{d({blockletDescription:""}),c({blockletDescription:q.target.value.slice(0,159)})},error:!!i.blockletDescription,helperText:i.blockletDescription||"",sx:{mt:3},slotProps:{input:{"data-cy":"blocklet-description",readOnly:o}}}),e.jsx(ne,{disabled:s||o,label:`Blocklet ${h("common.homepageTip")}`,placeholder:`Blocklet ${h("common.homepageTip")}`,autoComplete:"off",variant:"outlined",fullWidth:!0,value:l.blockletHomepage||"",onChange:q=>{q.target.value&&!/^(http|https):\/\//.test(q.target.value)?d({blockletHomepage:h("blocklet.publish.errorTip.invalidUrl")}):d({blockletHomepage:""}),c({blockletHomepage:q.target.value})},error:!!i.blockletHomepage,helperText:i.blockletHomepage||"",sx:{mt:3},slotProps:{input:{"data-cy":"blocklet-homepage",readOnly:o}}}),e.jsx(ne,{disabled:s||o,label:`Blocklet ${h("common.community")}`,placeholder:`Blocklet ${h("common.community")}`,autoComplete:"off",variant:"outlined",fullWidth:!0,value:l.blockletCommunity||"",onChange:q=>{q.target.value&&!/^(http|https):\/\//.test(q.target.value)?d({blockletCommunity:h("blocklet.publish.errorTip.invalidUrl")}):d({blockletCommunity:""}),c({blockletCommunity:q.target.value})},error:!!i.blockletCommunity,helperText:i.blockletCommunity||"",sx:{mt:3},slotProps:{input:{"data-cy":"blocklet-community",readOnly:o}}}),e.jsx(ne,{disabled:s||o,label:`Blocklet ${h("common.support")}`,placeholder:`Blocklet ${h("common.support")}`,autoComplete:"off",variant:"outlined",fullWidth:!0,value:l.blockletSupport||"",onChange:q=>{q.target.value&&!/^(http|https):\/\//.test(q.target.value)&&!/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/.test(q.target.value)?d({blockletSupport:h("blocklet.publish.errorTip.invalidUrlOrEmail")}):d({blockletSupport:""}),c({blockletSupport:q.target.value})},error:!!i.blockletSupport,helperText:i.blockletSupport||"",sx:{mt:3},slotProps:{input:{"data-cy":"blocklet-support",readOnly:o}}}),e.jsx(ne,{disabled:s||o,label:`Blocklet ${h("common.repository")}`,placeholder:`Blocklet ${h("common.repository")}`,autoComplete:"off",variant:"outlined",fullWidth:!0,value:l.blockletRepository||"",onChange:q=>{q.target.value&&!/^(git|https|svn)/.test(q.target.value)?d({blockletRepository:h("blocklet.publish.errorTip.invalidUrl")}):d({blockletRepository:""}),c({blockletRepository:q.target.value})},error:!!i.blockletRepository,helperText:i.blockletRepository||"",sx:{mt:3},slotProps:{input:{"data-cy":"blocklet-repository",readOnly:o}}})]})}),e.jsx(a,{className:"section full-width",sx:{display:"flex",mt:3},children:e.jsxs(a,{sx:{flex:1,overflow:"hidden"},children:[e.jsxs(a,{sx:{display:"flex",flexDirection:"row",flexWrap:"wrap"},children:[e.jsxs(Re,{direction:"column",spacing:1,sx:{mr:2,width:"160px"},children:[e.jsx(A,{variant:"subtitle1",sx:{fontWeight:"bold"},children:h("common.logo")}),e.jsxs(Re,{direction:"column",spacing:1,sx:{alignItems:"flex-start",opacity:.8,fontSize:"12px"},children:[e.jsx(a,{children:e.jsxs(a,{component:"span",children:[e.jsxs(a,{component:"span",sx:{color:"text.secondary"},children:[h("studio.type"),":"," "]}),e.jsx(a,{component:"span",sx:{color:"secondary.main"},children:"png, jpg, webp, svg"})]})}),e.jsx(a,{children:e.jsxs(a,{component:"span",children:[e.jsxs(a,{component:"span",sx:{color:"text.secondary"},children:[h("studio.ratio"),":"," "]}),e.jsx(a,{component:"span",sx:{color:"secondary.main"},children:"256x256"})]})}),e.jsx(a,{children:e.jsxs(a,{component:"span",children:[e.jsxs(a,{component:"span",sx:{color:"text.secondary"},children:[h("studio.size"),":"," "]}),e.jsx(a,{component:"span",sx:{color:"secondary.main"},children:"<500Kb"})]})})]})]}),e.jsx(a,{sx:{flex:1,cursor:o?"default":"pointer",display:"flex",alignItems:"flex-end"},children:e.jsx(Et,{variant:"square",sx:{width:80,height:80},alt:"Blocklet Logo",src:m||P,onClick:()=>{V()&&C.current?.open()}})})]}),E&&e.jsx(Rt,{errors:Z,storeList:Q,mt:3}),e.jsxs(a,{sx:{display:"flex",mt:3,flexDirection:"row",flexWrap:"wrap"},children:[e.jsxs(Re,{direction:"column",spacing:1,sx:{mr:2,width:"160px"},children:[e.jsx(A,{variant:"subtitle1",sx:{fontWeight:"bold"},children:h("common.screenshot")}),e.jsxs(Re,{direction:"column",spacing:1,sx:{alignItems:"flex-start",opacity:.8,fontSize:"12px"},children:[e.jsx(a,{sx:{border:"none"},variant:"outlined",size:"small",children:e.jsxs(a,{component:"span",children:[e.jsxs(a,{component:"span",sx:{color:"text.secondary"},children:[h("studio.ratio"),":"," "]}),e.jsx(a,{component:"span",sx:{color:"secondary.main"},children:"16 / 9"})]})}),e.jsx(a,{children:e.jsxs(a,{component:"span",children:[e.jsxs(a,{component:"span",sx:{color:"text.secondary"},children:[h("studio.count"),":"," "]}),e.jsx(a,{component:"span",sx:{color:"secondary.main"},children:"1~5"})]})}),e.jsx(a,{children:e.jsxs(a,{component:"span",children:[e.jsxs(a,{component:"span",sx:{color:"text.secondary"},children:[h("studio.size"),":"," "]}),e.jsx(a,{component:"span",sx:{color:"secondary.main"},children:"<5MB"})]})}),!o&&e.jsx(a,{children:e.jsxs(a,{component:"span",children:[e.jsxs(a,{component:"span",sx:{color:"text.secondary"},children:[h("studio.order"),":"," "]}),e.jsx(a,{component:"span",sx:{color:"secondary.main"},children:h("studio.orderTip")})]})})]})]}),e.jsx(Zt,{onDragEnd:o?void 0:U,children:e.jsx(Qt,{droppableId:"screenshots",direction:"horizontal",isDropDisabled:o,children:(q,Y)=>e.jsxs(a,{ref:q.innerRef,...q.droppableProps,sx:{display:"flex",alignItems:"center",flex:1,flexWrap:"wrap",minHeight:160,background:Y.isDraggingOver?"grey.100":"transparent",transition:"background-color 0.2s ease",border:Y.isDraggingOver?"2px dashed #999":"none",borderRadius:"4px"},children:[L.map((J,se)=>e.jsx(eo,{draggableId:J,index:se,isDragDisabled:o,children:(de,le)=>e.jsxs(a,{ref:de.innerRef,...de.draggableProps,className:"screenshot",sx:{transform:le.isDragging?"scale(1.05)":"none",boxShadow:le.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:J}),!o&&e.jsx(ce,{...de.dragHandleProps,className:"action",style:{right:40,zIndex:10,color:"#fff"},children:e.jsx(Xt,{})}),!o&&e.jsx(ce,{className:"action",onClick:()=>{c(pe=>{const he=[...pe.blockletScreenshots];return he.splice(se,1),{...pe,blockletScreenshots:he}})},children:e.jsx(tt,{})})]})},J)),q.placeholder,L.length<5&&e.jsx(a,{onClick:()=>{V()&&D.current?.open()},sx:{display:"flex",justifyContent:"center",alignItems:"center",fontSize:40,width:240,height:135,background:"#eee",cursor:o?"default":"pointer",color:"#999",mb:2},children:"+"})]})})})]}),I&&e.jsx(Rt,{errors:H,storeList:Q}),e.jsxs(a,{sx:{display:"flex",mt:3,flexDirection:"row",flexWrap:"wrap"},children:[e.jsxs(Re,{direction:"column",spacing:1,sx:{mr:2,width:"160px"},children:[e.jsx(A,{variant:"subtitle1",sx:{fontWeight:"bold"},children:h("studio.video")}),e.jsxs(Re,{direction:"column",spacing:1,sx:{alignItems:"flex-start",opacity:.8,fontSize:"12px"},children:[e.jsx(a,{children:e.jsxs(a,{component:"span",children:[e.jsxs(a,{component:"span",sx:{color:"text.secondary"},children:[h("studio.videoType"),":"," "]}),e.jsxs(a,{component:"span",sx:{color:"secondary.main"},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(a,{children:e.jsxs(a,{component:"span",children:[e.jsxs(a,{component:"span",sx:{color:"text.secondary"},children:[h("studio.count"),":"," "]}),e.jsx(a,{component:"span",sx:{color:"secondary.main"},children:"1~3"})]})}),!o&&e.jsx(a,{children:e.jsxs(a,{component:"span",children:[e.jsxs(a,{component:"span",sx:{color:"text.secondary"},children:[h("studio.order"),":"," "]}),e.jsx(a,{component:"span",sx:{color:"secondary.main"},children:h("studio.orderTip")})]})})]})]}),e.jsx(Zt,{onDragEnd:o?void 0:ee,children:e.jsx(Qt,{droppableId:"videos",direction:"horizontal",isDropDisabled:o,children:(q,Y)=>e.jsxs(a,{ref:q.innerRef,...q.droppableProps,sx:{display:"flex",alignItems:"center",flex:1,flexWrap:"wrap",minHeight:160,background:Y.isDraggingOver?"#f5f5f5":"transparent",transition:"background-color 0.2s ease",border:Y.isDraggingOver?"2px dashed #999":"none",borderRadius:"4px"},children:[l.blockletVideos.map((J,se)=>e.jsx(eo,{draggableId:J,index:se,isDragDisabled:o,children:(de,le)=>e.jsxs(a,{ref:de.innerRef,...de.draggableProps,className:"screenshot",sx:{transform:le.isDragging?"scale(1.05)":"none",boxShadow:le.isDragging?"0 5px 10px rgba(0,0,0,0.15)":"none",transition:"transform 0.2s ease, box-shadow 0.2s ease"},children:[e.jsx(Vt,{url:J,style:{pointerEvents:le.isDragging?"none":"auto"}}),!o&&e.jsx(ce,{...de.dragHandleProps,className:"action",style:{right:40,zIndex:10,color:"#fff"},children:e.jsx(Xt,{})}),!o&&e.jsx(ce,{className:"action",onClick:()=>{c(pe=>{const he=[...pe.blockletVideos];return he.splice(se,1),{...pe,blockletVideos:he}})},children:e.jsx(tt,{})})]})},J)),q.placeholder,l.blockletVideos.length<3&&e.jsx(a,{onClick:()=>{V()&&O(!0)},sx:{display:"flex",justifyContent:"center",alignItems:"center",fontSize:40,width:240,height:135,background:"#eee",cursor:o?"default":"pointer",color:"#999",mb:2},children:"+"})]})})})]})]})}),e.jsxs(k.Suspense,{fallback:e.jsx(Je,{}),children:[e.jsx(co,{ref:C,locale:j,popup:!0,onUploadFinish:q=>{c({blockletLogo:q.data.filename}),f(""),C.current?.close()},plugins:["ImageEditor"],installerProps:{disabled:!0},apiPathProps:{uploader:w,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"),T&&e.jsx(os,{onClose:()=>O(!1),params:l,setParams:c}),e.jsx(co,{ref:D,locale:j,popup:!0,onUploadFinish:q=>{c(Y=>{const J=Y.blockletScreenshots||[];return J.push(q.data?.filename),{...Y,blockletScreenshots:J}}),D.current?.close()},installerProps:{disabled:!0},plugins:["ImageEditor"],apiPathProps:{uploader:S,disableMediaKitPrefix:!0,disableMediaKitStatus:!0},coreProps:{restrictions:{allowedFileTypes:["image/*","image/svg+xml"],maxFileSize:1024*1024*5,maxNumberOfFiles:5-L.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:n.string.isRequired,readOnly:n.bool.isRequired,params:n.object.isRequired,setParams:n.func.isRequired,paramsErrTip:n.object.isRequired,setParamsErrTip:n.func.isRequired,warning:n.object.isRequired,loading:n.bool.isRequired,blocklet:n.object.isRequired,setLoading:n.func.isRequired,initUrl:n.object,componentDid:n.string,initLogoUrl:n.string.isRequired,setInitLogoUrl:n.func.isRequired};const ln=ve.div`
145
+ `,io="lastWantToConnectStoreId";function rn(t){const[o,s]=k.useState(null),{session:r}=ze(),l=k.useCallback(d=>{s(d),localStorage.setItem(io,d?.id)},[s]),c=k.useMemo(()=>{const d=localStorage.getItem(io),u=d?(t?.settings?.storeList||[]).find(p=>p.id===d):null;if(u)return u;let x=(t?.settings?.storeList||[]).find(p=>!(p.id!==F.BLOCKLET_STORE.id||p.scope&&p.scope!=="studio"&&p.scope!==r?.user?.did));return x||(x=t?.settings?.storeList?.[0]),x},[t?.settings?.storeList,r?.user?.did]);return[o||c||{},l]}const Bt=({fromBlocklet:t,nodeInfo:o,blocklet:s,userDid:r})=>{const l=t?s?.meta?.did:o?.did;let c=t?s?.settings?.storeList||[]:o?.blockletRegistryList||[];return Array.isArray(c)||(c=[]),c=c.filter(i=>i.protected||Cr(i.scope)||i.scope==="studio"||i.scope===r),{teamDid:l,storeList:c}};function es({blocklet:t=null,store:o=null,onChangeStore:s,onClick:r,disabled:l,loading:c,componentDid:i}){const{t:d}=X(),{session:u}=ze(),{api:x,info:p,inService:m}=ge(),f=De(),[b,h]=k.useState(!1),j=k.useRef(null),[v,g]=k.useState(!1),[C,D]=k.useState(null),R=L=>{s(L),h(!1)},y=()=>{h(!b)},T=L=>{j.current&&j.current.contains(L.target)||h(!1)},O=()=>{g(!0)},N=()=>{g(!1)},z=async()=>{if(C)try{await x.deleteBlockletStore({input:{teamDid:t.meta.did,url:C.url,projectId:"",scope:C.scope||"studio"}}),await f?.actions?.refreshBlocklet()}catch(L){W.error(`Remove Blocklet Store Error: ${xe(L)}`)}finally{D(null)}},{storeList:K}=Bt({fromBlocklet:m,blocklet:t,nodeInfo:p,userDid:u?.user?.did}),P=t?.meta?.did;return e.jsxs(e.Fragment,{children:[e.jsxs(et,{disabled:l,ref:j,variant:"contained",color:"primary","aria-label":"Button group with connect store",children:[e.jsxs(G,{onClick:r,children:[c&&e.jsx(Se,{size:14,sx:{mr:.5}}),`${d("common.connect")} ${o.name||""}`]}),e.jsx(G,{size:"small","aria-controls":b?"split-button-menu":void 0,"aria-expanded":b?"true":void 0,"aria-label":"select merge strategy","aria-haspopup":"menu",onClick:y,children:e.jsx(Js,{})})]}),e.jsx(jo,{sx:{zIndex:10},open:b,anchorEl:j.current,placement:"bottom-end",role:void 0,transition:!0,disablePortal:!0,children:({TransitionProps:L})=>e.jsx(yo,{...L,style:{transformOrigin:"center top"},children:e.jsx(Lt,{children:e.jsx(wo,{onClickAway:T,children:e.jsxs(vo,{id:"split-button-menu",autoFocusItem:!0,sx:{maxHeight:300,overflowY:"auto",zIndex:10},children:[K?.map(w=>e.jsxs(be,{selected:w.id===o?.id,sx:{height:56},onClick:()=>R(w),children:[e.jsxs(a,{children:[e.jsx(Te,{sx:{fontSize:"16px"},maxLength:24,children:w.name}),e.jsx(Te,{sx:{fontSize:"13px",opacity:.6},maxLength:30,children:w.url})]}),qr({store:w,userDid:u?.user?.did})&&e.jsx(ce,{sx:{ml:1},onClick:S=>{S.preventDefault(),S.stopPropagation(),D(w)},children:e.jsx(ae,{icon:"ic:outline-delete"})})]},w.url)),e.jsx(Xs,{}),e.jsxs(be,{onClick:O,children:[e.jsx(nt,{font:!0}),e.jsx(A,{variant:"inherit",children:d("store.blockletRegistry.addRegistry")})]})]})})})})}),v&&e.jsx(Bo,{hiddenChildren:!0,open:!0,onClose:N,teamDid:P,storeList:K,scope:"studio",onAdd:f?.actions?.refreshBlocklet}),C&&e.jsx(at,{displayError:!0,title:`${d("common.delete")} ${C.name}`,description:d("blocklet.publish.deleteStoreTip",{name:C.name}),confirm:d("common.confirm"),onConfirm:z,onCancel:()=>D(null)})]})}es.propTypes={store:n.object,blocklet:n.object,onChangeStore:n.func.isRequired,onClick:n.func.isRequired,loading:n.bool.isRequired,disabled:n.bool.isRequired,componentDid:n.string.isRequired,projectType:n.string.isRequired,getData:n.func.isRequired};const ts=(t,o,s)=>{const r=`${F.WELLKNOWN_SERVICE_PATH_PREFIX}/api/project/${o.meta.did}/${s}/logo/upload`,l=`${F.WELLKNOWN_SERVICE_PATH_PREFIX}/api/project/${o.meta.did}/${s}/screenshot/upload`,c=t?.blockletLogo?`${r}/${t.blockletLogo}`:`${F.WELLKNOWN_SERVICE_PATH_PREFIX}/static/images/logo.png`,i=(t?.blockletScreenshots||[]).filter(Boolean).map(d=>`${l}/${d}`);return{logoUrl:c,screenshotUrls:i,uploadLogoPrefix:r,uploadScreenshotPrefix:l}},nn=t=>{const o=t.includes("youtube.com")||t.includes("youtu.be"),s=t.includes("vimeo.com");return o||s};function Vt({url:t,style:o={},controls:s=1,modestbranding:r=1}){const{t:l}=X(),c=t.includes("youtube.com")||t.includes("youtu.be"),i=t.includes("vimeo.com");if(c){const d=t.split("v=")[1]?.split("&")[0]||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://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(i){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(a,{style:{position:"relative",width:"100%",paddingTop:"56.25%"},children:e.jsxs(a,{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(A,{variant:"body1",sx:{opacity:.5},children:l("studio.videoDialogNoSrc")})]})})}Vt.propTypes={url:n.string.isRequired,style:n.object,controls:n.number,modestbranding:n.number};function os({setParams:t,onClose:o,params:s}){const{t:r}=X(),[l,c]=k.useState(""),i=l&&s.blockletVideos.includes(l),d=nn(l),u=()=>{t(x=>{const p=[...x.blockletVideos];return p.push(l),{...x,blockletVideos:p}}),o()};return e.jsxs(lt,{open:!0,fullWidth:!0,maxWidth:"sm",children:[e.jsx(Co,{children:r("studio.videoDialogTitle")}),e.jsxs(Ro,{children:[e.jsx(Gs,{fullWidth:!0,value:l,onChange:x=>c(x.target.value),placeholder:r("studio.videoInputLabel"),endAdornment:l?e.jsx(He,{position:"end",children:e.jsx(ce,{onClick:()=>c(""),children:e.jsx(Ks,{})})}):null,error:i}),i&&e.jsx(A,{variant:"body2",color:"error",children:r("studio.duplicateVideo")}),e.jsx(Vt,{url:l,style:{marginTop:"20px",borderRadius:"4px"}})]}),e.jsxs(So,{children:[e.jsx(G,{onClick:()=>o(),children:r("studio.cancel")}),e.jsx(G,{disabled:!d||i,onClick:u,children:r("studio.confirm")})]})]})}os.propTypes={onClose:n.func.isRequired,params:n.object.isRequired,setParams:n.func.isRequired};function Rt({errors:t,storeList:o,...s}){const{t:r}=X();return e.jsxs(a,{...s,sx:[{color:"warning.main",fontSize:"14px",border:"1px solid rgba(214, 164, 64, 0.34)",borderRadius:"4px",py:2,px:1.5,position:"relative"},...Array.isArray(s.sx)?s.sx:[s.sx]],children:[e.jsx(A,{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,c])=>{const i=Object.values(c),d=o.find(u=>u.url===l);return i.length>0&&e.jsxs(a,{children:[e.jsx(ke,{title:l,children:e.jsx(a,{component:"span",sx:{cursor:"pointer"},children:d.name})}),i.map(u=>e.jsx(a,{component:"li",sx:{ml:2,wordBreak:!0},children:u},u))]},l)})]})}Rt.propTypes={errors:n.object.isRequired,storeList:n.array.isRequired};const co=k.lazy(()=>No(()=>import("./index-C5sng-9P.js"),__vite__mapDeps([0,1,2]),import.meta.url).then(t=>({default:t.Uploader})));function ss({projectId:t,readOnly:o,loading:s,blocklet:r,params:l,setParams:c,paramsErrTip:i,setParamsErrTip:d,warning:u,setLoading:x,initUrl:p=null,initLogoUrl:m,setInitLogoUrl:f,componentDid:b=""}){const{t:h,locale:j}=X(),{api:v}=ge(),g=It(),C=k.useRef(null),D=k.useRef(null),[R,y]=rn(r),[T,O]=k.useState(!1),N=zo({messageType:"connect-store-message",onOpen:()=>x(!0),onClose:()=>x(!1)}),z=async q=>{const Y=setTimeout(()=>{x(!1)},2e4),J=await Lr(v,q);x(!1),clearTimeout(Y),window.parent.postMessage({event:"studioDialog.connected",componentDid:b},"*"),g(window.location.pathname.replace(`${F.UNOWNED_DID}/create`,`${J}/create`),{replace:!0})},K=()=>{if(!l.blockletTitle){W.error(h("blocklet.publish.errorTip.noTitle"));return}if(!R?.url){W.error(h("blocklet.publish.noStoreSelected"));return}const q=Pr();N(async(Y,J)=>{try{const se=await v.connectByStudio({input:{did:r?.meta?.did,blockletTitle:l?.blockletTitle,storeUrl:R.url,storeId:R.id,storeName:R.name,type:l?.blockletComponents?.length>0?"pack":"resource",componentDid:b,messageId:q,tenantScope:p?.searchParams.get("tenantScope")||""}});if(!se?.url){W.error("failed to connect to store");return}J(se.url),z({did:r?.meta?.did,projectId:"",messageId:q})}catch(se){const de=xe(se);W.error(de),x(!1)}})},{logoUrl:P,screenshotUrls:L,uploadLogoPrefix:w,uploadScreenshotPrefix:S}=ts(l,r,t),{logoErrors:Z,screenshotErrors:H,storeList:Q,hasLogoWarning:E,hasScreenshotWarning:I}=u,V=()=>o?!1:!t||t===F.UNOWNED_DID?(W.error(h("blocklet.publish.errorTip.noFirstDid")),!1):!0,U=q=>{if(!q.destination)return;const Y=Array.from(l.blockletScreenshots),[J]=Y.splice(q.source.index,1);Y.splice(q.destination.index,0,J),c(se=>({...se,blockletScreenshots:Y}))},ee=q=>{if(!q.destination)return;const Y=Array.from(l.blockletVideos),[J]=Y.splice(q.source.index,1);Y.splice(q.destination.index,0,J),c(se=>({...se,blockletVideos:Y}))};return e.jsxs(ln,{children:[e.jsx(a,{className:"section",sx:{display:"flex"},children:e.jsxs(a,{sx:{flex:1},children:[e.jsx(ne,{disabled:s||o,label:`Blocklet ${h("common.title")}`,placeholder:`Blocklet ${h("common.title")}`,autoComplete:"off",variant:"outlined",fullWidth:!0,required:!0,value:l.blockletTitle||"",onChange:q=>{d({blockletTitle:""}),c({blockletTitle:q.target.value})},error:!!i.blockletTitle,helperText:i.blockletTitle||"",slotProps:{input:{"data-cy":"blocklet-title",readOnly:o}}}),e.jsx(ne,{required:!0,label:"Blocklet DID",fullWidth:!0,readonly:!0,disabled:!0,autoComplete:"off",variant:"outlined",error:!!i.projectId,helperText:i.projectId||"",value:t===F.UNOWNED_DID?"":`did:abt:${t}`,sx:{mt:3},slotProps:{input:{"data-cy":"export-blocklet-did",endAdornment:t===F.UNOWNED_DID&&e.jsx(He,{position:"end",children:e.jsx(es,{blocklet:r,store:R,componentDid:b,onChangeStore:y,disabled:!l.blockletTitle||o||s,loading:s,onClick:K})})}}}),e.jsx(ne,{disabled:s||o,label:`Blocklet ${h("common.description")}`,placeholder:`Blocklet ${h("common.description")}`,required:!0,autoComplete:"off",variant:"outlined",fullWidth:!0,value:l.blockletDescription||"",onChange:q=>{d({blockletDescription:""}),c({blockletDescription:q.target.value.slice(0,159)})},error:!!i.blockletDescription,helperText:i.blockletDescription||"",sx:{mt:3},slotProps:{input:{"data-cy":"blocklet-description",readOnly:o}}}),e.jsx(ne,{disabled:s||o,label:`Blocklet ${h("common.homepageTip")}`,placeholder:`Blocklet ${h("common.homepageTip")}`,autoComplete:"off",variant:"outlined",fullWidth:!0,value:l.blockletHomepage||"",onChange:q=>{q.target.value&&!/^(http|https):\/\//.test(q.target.value)?d({blockletHomepage:h("blocklet.publish.errorTip.invalidUrl")}):d({blockletHomepage:""}),c({blockletHomepage:q.target.value})},error:!!i.blockletHomepage,helperText:i.blockletHomepage||"",sx:{mt:3},slotProps:{input:{"data-cy":"blocklet-homepage",readOnly:o}}}),e.jsx(ne,{disabled:s||o,label:`Blocklet ${h("common.community")}`,placeholder:`Blocklet ${h("common.community")}`,autoComplete:"off",variant:"outlined",fullWidth:!0,value:l.blockletCommunity||"",onChange:q=>{q.target.value&&!/^(http|https):\/\//.test(q.target.value)?d({blockletCommunity:h("blocklet.publish.errorTip.invalidUrl")}):d({blockletCommunity:""}),c({blockletCommunity:q.target.value})},error:!!i.blockletCommunity,helperText:i.blockletCommunity||"",sx:{mt:3},slotProps:{input:{"data-cy":"blocklet-community",readOnly:o}}}),e.jsx(ne,{disabled:s||o,label:`Blocklet ${h("common.support")}`,placeholder:`Blocklet ${h("common.support")}`,autoComplete:"off",variant:"outlined",fullWidth:!0,value:l.blockletSupport||"",onChange:q=>{q.target.value&&!/^(http|https):\/\//.test(q.target.value)&&!/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/.test(q.target.value)?d({blockletSupport:h("blocklet.publish.errorTip.invalidUrlOrEmail")}):d({blockletSupport:""}),c({blockletSupport:q.target.value})},error:!!i.blockletSupport,helperText:i.blockletSupport||"",sx:{mt:3},slotProps:{input:{"data-cy":"blocklet-support",readOnly:o}}}),e.jsx(ne,{disabled:s||o,label:`Blocklet ${h("common.repository")}`,placeholder:`Blocklet ${h("common.repository")}`,autoComplete:"off",variant:"outlined",fullWidth:!0,value:l.blockletRepository||"",onChange:q=>{q.target.value&&!/^(git|https|svn)/.test(q.target.value)?d({blockletRepository:h("blocklet.publish.errorTip.invalidUrl")}):d({blockletRepository:""}),c({blockletRepository:q.target.value})},error:!!i.blockletRepository,helperText:i.blockletRepository||"",sx:{mt:3},slotProps:{input:{"data-cy":"blocklet-repository",readOnly:o}}})]})}),e.jsx(a,{className:"section full-width",sx:{display:"flex",mt:3},children:e.jsxs(a,{sx:{flex:1,overflow:"hidden"},children:[e.jsxs(a,{sx:{display:"flex",flexDirection:"row",flexWrap:"wrap"},children:[e.jsxs(Re,{direction:"column",spacing:1,sx:{mr:2,width:"160px"},children:[e.jsx(A,{variant:"subtitle1",sx:{fontWeight:"bold"},children:h("common.logo")}),e.jsxs(Re,{direction:"column",spacing:1,sx:{alignItems:"flex-start",opacity:.8,fontSize:"12px"},children:[e.jsx(a,{children:e.jsxs(a,{component:"span",children:[e.jsxs(a,{component:"span",sx:{color:"text.secondary"},children:[h("studio.type"),":"," "]}),e.jsx(a,{component:"span",sx:{color:"secondary.main"},children:"png, jpg, webp, svg"})]})}),e.jsx(a,{children:e.jsxs(a,{component:"span",children:[e.jsxs(a,{component:"span",sx:{color:"text.secondary"},children:[h("studio.ratio"),":"," "]}),e.jsx(a,{component:"span",sx:{color:"secondary.main"},children:"256x256"})]})}),e.jsx(a,{children:e.jsxs(a,{component:"span",children:[e.jsxs(a,{component:"span",sx:{color:"text.secondary"},children:[h("studio.size"),":"," "]}),e.jsx(a,{component:"span",sx:{color:"secondary.main"},children:"<500Kb"})]})})]})]}),e.jsx(a,{sx:{flex:1,cursor:o?"default":"pointer",display:"flex",alignItems:"flex-end"},children:e.jsx(Et,{variant:"square",sx:{width:80,height:80},alt:"Blocklet Logo",src:m||P,onClick:()=>{V()&&C.current?.open()}})})]}),E&&e.jsx(Rt,{errors:Z,storeList:Q,mt:3}),e.jsxs(a,{sx:{display:"flex",mt:3,flexDirection:"row",flexWrap:"wrap"},children:[e.jsxs(Re,{direction:"column",spacing:1,sx:{mr:2,width:"160px"},children:[e.jsx(A,{variant:"subtitle1",sx:{fontWeight:"bold"},children:h("common.screenshot")}),e.jsxs(Re,{direction:"column",spacing:1,sx:{alignItems:"flex-start",opacity:.8,fontSize:"12px"},children:[e.jsx(a,{sx:{border:"none"},variant:"outlined",size:"small",children:e.jsxs(a,{component:"span",children:[e.jsxs(a,{component:"span",sx:{color:"text.secondary"},children:[h("studio.ratio"),":"," "]}),e.jsx(a,{component:"span",sx:{color:"secondary.main"},children:"16 / 9"})]})}),e.jsx(a,{children:e.jsxs(a,{component:"span",children:[e.jsxs(a,{component:"span",sx:{color:"text.secondary"},children:[h("studio.count"),":"," "]}),e.jsx(a,{component:"span",sx:{color:"secondary.main"},children:"1~5"})]})}),e.jsx(a,{children:e.jsxs(a,{component:"span",children:[e.jsxs(a,{component:"span",sx:{color:"text.secondary"},children:[h("studio.size"),":"," "]}),e.jsx(a,{component:"span",sx:{color:"secondary.main"},children:"<5MB"})]})}),!o&&e.jsx(a,{children:e.jsxs(a,{component:"span",children:[e.jsxs(a,{component:"span",sx:{color:"text.secondary"},children:[h("studio.order"),":"," "]}),e.jsx(a,{component:"span",sx:{color:"secondary.main"},children:h("studio.orderTip")})]})})]})]}),e.jsx(Zt,{onDragEnd:o?void 0:U,children:e.jsx(Qt,{droppableId:"screenshots",direction:"horizontal",isDropDisabled:o,children:(q,Y)=>e.jsxs(a,{ref:q.innerRef,...q.droppableProps,sx:{display:"flex",alignItems:"center",flex:1,flexWrap:"wrap",minHeight:160,background:Y.isDraggingOver?"grey.100":"transparent",transition:"background-color 0.2s ease",border:Y.isDraggingOver?"2px dashed #999":"none",borderRadius:"4px"},children:[L.map((J,se)=>e.jsx(eo,{draggableId:J,index:se,isDragDisabled:o,children:(de,le)=>e.jsxs(a,{ref:de.innerRef,...de.draggableProps,className:"screenshot",sx:{transform:le.isDragging?"scale(1.05)":"none",boxShadow:le.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:J}),!o&&e.jsx(ce,{...de.dragHandleProps,className:"action",style:{right:40,zIndex:10,color:"#fff"},children:e.jsx(Xt,{})}),!o&&e.jsx(ce,{className:"action",onClick:()=>{c(pe=>{const he=[...pe.blockletScreenshots];return he.splice(se,1),{...pe,blockletScreenshots:he}})},children:e.jsx(tt,{})})]})},J)),q.placeholder,L.length<5&&e.jsx(a,{onClick:()=>{V()&&D.current?.open()},sx:{display:"flex",justifyContent:"center",alignItems:"center",fontSize:40,width:240,height:135,background:"#eee",cursor:o?"default":"pointer",color:"#999",mb:2},children:"+"})]})})})]}),I&&e.jsx(Rt,{errors:H,storeList:Q}),e.jsxs(a,{sx:{display:"flex",mt:3,flexDirection:"row",flexWrap:"wrap"},children:[e.jsxs(Re,{direction:"column",spacing:1,sx:{mr:2,width:"160px"},children:[e.jsx(A,{variant:"subtitle1",sx:{fontWeight:"bold"},children:h("studio.video")}),e.jsxs(Re,{direction:"column",spacing:1,sx:{alignItems:"flex-start",opacity:.8,fontSize:"12px"},children:[e.jsx(a,{children:e.jsxs(a,{component:"span",children:[e.jsxs(a,{component:"span",sx:{color:"text.secondary"},children:[h("studio.videoType"),":"," "]}),e.jsxs(a,{component:"span",sx:{color:"secondary.main"},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(a,{children:e.jsxs(a,{component:"span",children:[e.jsxs(a,{component:"span",sx:{color:"text.secondary"},children:[h("studio.count"),":"," "]}),e.jsx(a,{component:"span",sx:{color:"secondary.main"},children:"1~3"})]})}),!o&&e.jsx(a,{children:e.jsxs(a,{component:"span",children:[e.jsxs(a,{component:"span",sx:{color:"text.secondary"},children:[h("studio.order"),":"," "]}),e.jsx(a,{component:"span",sx:{color:"secondary.main"},children:h("studio.orderTip")})]})})]})]}),e.jsx(Zt,{onDragEnd:o?void 0:ee,children:e.jsx(Qt,{droppableId:"videos",direction:"horizontal",isDropDisabled:o,children:(q,Y)=>e.jsxs(a,{ref:q.innerRef,...q.droppableProps,sx:{display:"flex",alignItems:"center",flex:1,flexWrap:"wrap",minHeight:160,background:Y.isDraggingOver?"#f5f5f5":"transparent",transition:"background-color 0.2s ease",border:Y.isDraggingOver?"2px dashed #999":"none",borderRadius:"4px"},children:[l.blockletVideos.map((J,se)=>e.jsx(eo,{draggableId:J,index:se,isDragDisabled:o,children:(de,le)=>e.jsxs(a,{ref:de.innerRef,...de.draggableProps,className:"screenshot",sx:{transform:le.isDragging?"scale(1.05)":"none",boxShadow:le.isDragging?"0 5px 10px rgba(0,0,0,0.15)":"none",transition:"transform 0.2s ease, box-shadow 0.2s ease"},children:[e.jsx(Vt,{url:J,style:{pointerEvents:le.isDragging?"none":"auto"}}),!o&&e.jsx(ce,{...de.dragHandleProps,className:"action",style:{right:40,zIndex:10,color:"#fff"},children:e.jsx(Xt,{})}),!o&&e.jsx(ce,{className:"action",onClick:()=>{c(pe=>{const he=[...pe.blockletVideos];return he.splice(se,1),{...pe,blockletVideos:he}})},children:e.jsx(tt,{})})]})},J)),q.placeholder,l.blockletVideos.length<3&&e.jsx(a,{onClick:()=>{V()&&O(!0)},sx:{display:"flex",justifyContent:"center",alignItems:"center",fontSize:40,width:240,height:135,background:"#eee",cursor:o?"default":"pointer",color:"#999",mb:2},children:"+"})]})})})]})]})}),e.jsxs(k.Suspense,{fallback:e.jsx(Je,{}),children:[e.jsx(co,{ref:C,locale:j,popup:!0,onUploadFinish:q=>{c({blockletLogo:q.data.filename}),f(""),C.current?.close()},plugins:["ImageEditor"],installerProps:{disabled:!0},apiPathProps:{uploader:w,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"),T&&e.jsx(os,{onClose:()=>O(!1),params:l,setParams:c}),e.jsx(co,{ref:D,locale:j,popup:!0,onUploadFinish:q=>{c(Y=>{const J=Y.blockletScreenshots||[];return J.push(q.data?.filename),{...Y,blockletScreenshots:J}}),D.current?.close()},installerProps:{disabled:!0},plugins:["ImageEditor"],apiPathProps:{uploader:S,disableMediaKitPrefix:!0,disableMediaKitStatus:!0},coreProps:{restrictions:{allowedFileTypes:["image/*","image/svg+xml"],maxFileSize:1024*1024*5,maxNumberOfFiles:5-L.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:n.string.isRequired,readOnly:n.bool.isRequired,params:n.object.isRequired,setParams:n.func.isRequired,paramsErrTip:n.object.isRequired,setParamsErrTip:n.func.isRequired,warning:n.object.isRequired,loading:n.bool.isRequired,blocklet:n.object.isRequired,setLoading:n.func.isRequired,initUrl:n.object,componentDid:n.string,initLogoUrl:n.string.isRequired,setInitLogoUrl:n.func.isRequired};const ln=ve.div`
146
146
  margin-top: 24px;
147
147
  .screenshot {
148
148
  margin-bottom: 16px;
@@ -190,7 +190,7 @@ import{r as k,i as It,j as rt,L as we,g as fo,k as As,l as qs,m as bt}from"./ven
190
190
  padding-bottom: 12px;
191
191
  border-bottom: ${({theme:t})=>`1px solid ${t.palette.divider}`};
192
192
  }
193
- `;function bs({text:t}){const{palette:o}=Eo();return t?e.jsx(zr,{style:{backgroundColor:o.background.default,color:o.text.primary},wrapperElement:{"data-color-mode":"light"},source:xr.sanitize(t),rehypePlugins:[[Br,{target:"_blank"}]]}):e.jsx(Fe,{Icon:Nt})}bs.propTypes={text:n.string.isRequired};function fs({params:t,setParams:o,paramsErrTip:s,loading:r,setParamsErrTip:l,readOnly:c}){const{t:i}=X(),[d,u]=k.useState(c?"preview":"write"),x=(p,m)=>{u(m)};return e.jsxs(a,{sx:{border:"1px solid transparent",borderRadius:2},children:[e.jsxs(a,{sx:{display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center"},children:[e.jsx(A,{variant:"h6",sx:{fontWeight:"bold"},children:i("common.introduction")}),e.jsxs(Lo,{value:d,onChange:x,"aria-label":"wrapped label tabs example",children:[e.jsx(ot,{value:"write",label:"Write"}),e.jsx(ot,{value:"preview",label:"Preview"})]})]}),e.jsx(a,{sx:{display:d==="write"?"block":"none",width:"100%",marginTop:3},children:e.jsx(ne,{disabled:r||c,sx:{border:"none"},placeholder:`Blocklet ${i("common.introduction")}`,autoComplete:"off",variant:"outlined",fullWidth:!0,multiline:!0,minRows:4,value:t.blockletIntroduction||"",onChange:p=>{l({blockletIntroduction:""}),o({blockletIntroduction:p.target.value.slice(0,me.PROJECT.MAX_INTRO_LENGTH)})},error:!!s.blockletIntroduction,helperText:s.blockletIntroduction||"",slotProps:{input:{"data-cy":"export-blocklet-introduction",readOnly:c,endAdornment:e.jsxs(He,{position:"end",children:[t?.blockletIntroduction?.length||0," / ",me.PROJECT.MAX_INTRO_LENGTH]})}}})}),e.jsx(a,{sx:{display:d==="preview"?"block":"none",mt:3},children:e.jsx(bs,{text:t.blockletIntroduction||""})})]})}fs.propTypes={params:n.object.isRequired,setParams:n.func.isRequired,paramsErrTip:n.object.isRequired,setParamsErrTip:n.func.isRequired,readOnly:n.bool.isRequired,loading:n.bool.isRequired};function xs({step:t=0,ok:o=!1,active:s=0,error:r="",warning:l=!1}){let c="grey.500",i=t+1;return o&&(i=e.jsx(Po,{sx:{fontSize:18,margin:0},color:"white"})),r||!o&&s>t?(c="error.main",i=e.jsx(Gt,{sx:{fontSize:18,margin:0},color:"white"})):l?(c="warning.main",i=e.jsx(Gt,{sx:{fontSize:18,margin:0},color:"white"})):s>=t&&(c="primary.main"),e.jsx(a,{sx:{width:24,height:24,bgcolor:c,borderRadius:"100%",color:"white",display:"flex",justifyContent:"center",fontWeight:"bold",fontSize:14,alignItems:"center"},children:i})}xs.propTypes={step:n.number,ok:n.bool,active:n.number,error:n.string,warning:n.bool};function gs({steps:t,activeStep:o,setActiveStep:s,hasSelectedResources:r=!1,params:l,loading:c,paramsErrTip:i,warning:d,viewMode:u="",projectId:x}){const{t:p}=X(),m=()=>{s(j=>j+1)},f=()=>{s(j=>j-1)},b=j=>j===0?i?.blockletTitle||i?.projectId||i?.blockletDescription||i?.blockletHomepage||i?.blockletSupport||i?.blockletCommunity||i?.blockletRepository:j===2?i?.blockletResource||i?.blockletDocker||i?.dockerImageName:j>=4?i?.blockletVersion||i?.note:"",h=u||rs({params:l,projectId:x,t:p})===null;return e.jsxs(a,{sx:{width:300,maxWidth:300,minWidth:300,padding:2,border:"1px solid",borderColor:"divider",borderRadius:1},children:[e.jsx(nr,{activeStep:o,orientation:"vertical",children:t.map((j,v)=>{const g={},C=c||!pn({params:l,projectId:x,step:v,t:p}),D=c?"":b(v);return D&&(g.optional=e.jsx(A,{variant:"caption",color:"error",sx:{wordBreak:"break-word"},children:D}),g.error=!0),e.jsxs(lr,{children:[e.jsx(ir,{icon:e.jsx(xs,{error:D,warning:v===0?d.hasWarning:!1,active:h?99:o,step:v,ok:C}),sx:{cursor:"pointer",color:D?"error.main":"inherit"},disabled:!1,onClick:()=>s(v),...g,children:e.jsx(A,{fontSize:"14px",fontWeight:"500",color:D||!C&&o>v?"error.main":"inherit",children:j.label})}),e.jsxs(cr,{children:[e.jsx(A,{fontSize:12,children:j.description}),!h&&e.jsx(a,{sx:{mb:2},children:e.jsxs("div",{children:[v<t.length-1&&e.jsx(G,{variant:"contained",onClick:m,sx:{mt:1,mr:1},disabled:D||!C,children:p("common.continue")}),v>0&&e.jsx(G,{disabled:v===0,onClick:f,sx:{mt:1,mr:1},children:p("common.back")})]})})]})]},j.label)})}),o>=t.length-1&&e.jsx(Lt,{square:!0,elevation:0,sx:{p:3},children:e.jsx(A,{fontSize:12,sx:{opacity:.5},children:"Click right top button to release"})})]})}gs.propTypes={steps:n.array.isRequired,activeStep:n.number.isRequired,setActiveStep:n.func.isRequired,params:n.object.isRequired,viewMode:n.oneOfType([n.string,n.bool]),loading:n.bool.isRequired,projectId:n.string.isRequired,hasSelectedResources:n.oneOfType([n.string,n.bool]),warning:n.object.isRequired,paramsErrTip:n.shape({projectId:n.string,blockletVersion:n.string,blockletTitle:n.string,blockletDescription:n.string,note:n.string,blockletResource:n.string,blockletHomepage:n.string,blockletSupport:n.string,blockletCommunity:n.string,blockletRepository:n.string,blockletDocker:n.object,dockerImageName:n.string}).isRequired};const mn=[".zip",".gz"],bn=1024*1024*100,fn=k.lazy(()=>No(()=>import("./index-B5MKa5ov.js"),__vite__mapDeps([0,1,2]),import.meta.url).then(t=>({default:t.Uploader})));function ks({app:t,projectId:o,readOnly:s,params:r,setParams:l,setParamsErrTip:c,error:i}){const{t:d,locale:u}=X(),x=k.useRef(null),p=()=>s?!1:!o||o===F.UNOWNED_DID?(W.error(d("blocklet.publish.errorTip.noFirstDid")),!1):!0,m=`${F.WELLKNOWN_SERVICE_PATH_PREFIX}/api/project/${t.meta.did}/${o}/resource/upload`;return e.jsxs(a,{sx:{mt:3},children:[e.jsx(A,{gutterBottom:!0,children:d("blocklet.publish.resourceUpload")}),e.jsxs(Re,{direction:"row",spacing:1,sx:{alignItems:"center",flex:1,cursor:s?"default":"pointer"},children:[!!r.uploadedResource&&e.jsx(A,{component:"a",href:`${m}/params.uploadedResource`,children:r.uploadedResource}),!s&&e.jsx(G,{variant:"outlined",size:"small",onClick:()=>{p()&&x.current?.open()},children:r.uploadedResource?d("common.change"):d("common.upload")})]}),e.jsx(k.Suspense,{fallback:e.jsx(Je,{}),children:e.jsx(fn,{ref:x,locale:u,popup:!0,onUploadFinish:f=>{l({uploadedResource:f.data.filename}),c({blockletResource:""}),x.current?.close()},plugins:["ImageEditor"],installerProps:{disabled:!0},apiPathProps:{uploader:m,disableMediaKitPrefix:!0,disableMediaKitStatus:!0},coreProps:{restrictions:{allowedFileExts:mn,maxFileSize:bn,maxNumberOfFiles:1}}},"uploader-resource")}),!!i&&e.jsx(a,{sx:{color:"error.main",mt:1,fontSize:14},children:i})]})}ks.propTypes={app:n.object.isRequired,projectId:n.string.isRequired,readOnly:n.bool.isRequired,params:n.object.isRequired,setParams:n.func.isRequired,error:n.string.isRequired,setParamsErrTip:n.func.isRequired};function Tt({readOnly:t,params:o,setParams:s,paramsErrTip:r,setParamsErrTip:l,loading:c}){const{t:i}=X();return e.jsx(a,{className:"section",sx:{display:"flex",mt:3},children:e.jsxs(a,{sx:{flex:1},children:[e.jsx(ne,{required:!0,disabled:c||t,label:`Blocklet ${i("common.version")}`,placeholder:`Blocklet ${i("common.version")}`,autoComplete:"off",variant:"outlined",fullWidth:!0,value:o.blockletVersion||"",onChange:d=>{l({blockletVersion:""}),s({blockletVersion:d.target.value})},error:!!r.blockletVersion,helperText:r.blockletVersion||"",slotProps:{input:{"data-cy":"blocklet-version",readOnly:t}}}),e.jsx(ne,{label:i("blocklet.publish.releaseNote"),autoComplete:"off",disabled:c||t,variant:"outlined",fullWidth:!0,multiline:!0,minRows:4,required:!0,value:o.note||"",onChange:d=>{l({note:""}),s({note:d.target.value.slice(0,me.PROJECT.MAX_NOTE_LENGTH)})},error:!!r.note,helperText:r.note||"",sx:{mt:3},slotProps:{input:{"data-cy":"release-note",readOnly:t,endAdornment:e.jsxs(He,{position:"end",children:[o?.note?.length||0," / ",me.PROJECT.MAX_NOTE_LENGTH]})}}})]})})}Tt.propTypes={readOnly:n.bool.isRequired,params:n.object.isRequired,setParams:n.func.isRequired,paramsErrTip:n.object.isRequired,setParamsErrTip:n.func.isRequired,loading:n.bool.isRequired};function js(t){for(const o in t)typeof t[o]=="string"?t[o]=t[o].replace(/\\\\/g,"\\"):typeof t[o]=="object"&&t[o]!==null&&js(t[o]);return t}var xn=Wr();const oe=fo(xn),gn={"-a":"--attach","-d":"--detach","-e":"--env","-h":"--hostname","-i":"--interactive","-it":"-it","-rm":"-rm","-m":"--memory","-p":"--publish","-P":"--publish-all","-l":"--label","-n":"--name","-q":"--quiet","-x":"--x-registry","-t":"--tty","-u":"--user","-v":"--volume","-w":"--workdir","-cgroupns":"--cgroupns","-cpus":"--cpus","-g":"--gpus","-ip6":"--ip6","--read-only":"--read-only","--add-host":"--add-host","--attach":"--attach","--blkio-weight":"--blkio-weight","--blkio-weight-device":"--blkio-weight-device","--cap-add":"--cap-add","--cap-drop":"--cap-drop","--cgroup-parent":"--cgroup-parent","--cidfile":"--cidfile","--cpu-period":"--cpu-period","--cpu-quota":"--cpu-quota","--cpu-rt-period":"--cpu-rt-period","--cpu-rt-runtime":"--cpu-rt-runtime","--cpu-shares":"--cpu-shares","--cpus":"--cpus","--cpuset-cpus":"--cpuset-cpus","--cpuset-mems":"--cpuset-mems","--detach":"--detach","--detach-keys":"--detach-keys","--device":"--device","--device-cgroup-rule":"--device-cgroup-rule","--device-read-bps":"--device-read-bps","--device-read-iops":"--device-read-iops","--device-write-bps":"--device-write-bps","--device-write-iops":"--device-write-iops","--disable-content-trust":"--disable-content-trust","--dns":"--dns","--dns-opt":"--dns-opt","--dns-search":"--dns-search","--domainname":"--domainname","--entrypoint":"--entrypoint","--env":"--env","--env-file":"--env-file","--expose":"--expose","--gpus":"--gpus","--group-add":"--group-add","--health-cmd":"--health-cmd","--health-interval":"--health-interval","--health-retries":"--health-retries","--health-start-period":"--health-start-period","--health-timeout":"--health-timeout","--help":"--help","--hostname":"--hostname","--init":"--init","--interactive":"--interactive","--ip":"--ip","--ip6":"--ip6","--ipc":"--ipc","--isolation":"--isolation","--kernel-memory":"--kernel-memory","--label":"--label","--label-file":"--label-file","--link":"--link","--link-local-ip":"--link-local-ip","--log-driver":"--log-driver","--log-opt":"--log-opt","--mac-address":"--mac-address","--memory":"--memory","--memory-reservation":"--memory-reservation","--memory-swap":"--memory-swap","--memory-swappiness":"--memory-swappiness","--mount":"--mount","--name":"--name","--network":"--network","--network-alias":"--network-alias","--no-healthcheck":"--no-healthcheck","--oom-kill-disable":"--oom-kill-disable","--oom-score-adj":"--oom-score-adj","--pid":"--pid","--pids-limit":"--pids-limit","--platform":"--platform","--privileged":"--privileged","--publish":"--publish","--publish-all":"--publish-all","--pull":"--pull","--restart":"--restart","--rm":"--rm","--runtime":"--runtime","--security-opt":"--security-opt","--shm-size":"--shm-size","--stop-signal":"--stop-signal","--stop-timeout":"--stop-timeout","--storage-opt":"--storage-opt","--sysctl":"--sysctl","--tmpfs":"--tmpfs","--tty":"--tty","--ulimit":"--ulimit","--user":"--user","--userns":"--userns","--uts":"--uts","--volume":"--volume","--volume-driver":"--volume-driver","--volumes-from":"--volumes-from","--workdir":"--workdir"},Ut={"--env":!0,"--publish":!0,"--volume":!0,"--attach":!0,"--quiet":!0,"--entrypoint":!0,"--workdir":!0,"--cidfile":!0,"--detach-keys":!0,"--disable-content-trust":!0,"--domainname":!0,"--expose":!0,"--ip":!0,"--link-local-ip":!0,"--platform":!0},kn={"--volume":!0,"--publish":!0},jn=new Set(["--publish","--volume"]),ys=t=>{const[o]=t.split(":");return o?.startsWith("/")||o?.startsWith("./")||o?.startsWith("../")||o?.startsWith("~")||o?.startsWith("$BLOCKLET")};function yn(t){return t.map(o=>{if(o.key!=="--volume"||o.value.startsWith("$BLOCKLET_APP_DIR/")||o.value.startsWith("$BLOCKLET_DATA_DIR/"))return o;const[s,...r]=o.value.split(":");if(!s||!ys(o.value))return o;const l=s.startsWith("/")?`$BLOCKLET_DATA_DIR${s}`:`$BLOCKLET_DATA_DIR/${s}`;return{...o,value:[l,...r].join(":")}})}function wn(t){let o=!0;return t.find(r=>r.key==="--publish"&&r.type==="web")?t.map(r=>{if(r.key==="--publish"){const l={...r,type:o?"docker":r.type};return o=r.type==="web",l}return r}):t.map(r=>{if(r.key==="--publish"){const l={...r,type:o?"web":"docker"};return o=!1,l}return r})}function po(t){if(!t)return{dockerArgs:[],dockerEnvs:[],dockerImage:"",dockerCommand:""};if(t=t.trim(),t.startsWith("$ docker run")&&(t=t.replace("$ docker run","docker run")),!t.startsWith("docker run"))return{dockerArgs:[],dockerEnvs:[],dockerImage:"",dockerCommand:""};const s=t.replace(/\\\n/g,"").replace(/\n/g," ").trim().match(/(?:[^\s"']+|'[^']*'|"[^"]*")+/g);if(!s)return{dockerArgs:[],dockerEnvs:[],dockerImage:"",dockerCommand:""};const r=[],l=[];let c=0,i="",d="";const u=[];for(;c<s.length;){const p=s[c];if(!p){c++;continue}if(p==="docker"||p==="run"){c++;continue}if((p==="-e"||p==="--env")&&c+1<s.length){const m=s[c+1]||"",[f,...b]=m.split("=");if(f){const h=b.join("=").replace(/^['"]|['"]$/g,"");l.push({key:f,value:h})}c+=2;continue}if(p.startsWith("-")&&u.length===0){const m=p.indexOf("=");let f=p,b=null;m!==-1&&(f=p.substring(0,m),b=p.substring(m+1).replace(/^['"]|['"]$/g,""));const h=gn[f];if(!h){c+=2;continue}if(h==="--publish"){let j="";if(b)j=b,r.push({key:h,value:j});else if(c+1<s.length&&!(s[c+1]||"").startsWith("-")){j=(s[c+1]||"").replace(/^['"]|['"]$/g,""),r.push({key:h,value:j}),c+=2;continue}else{r.push({key:h,value:"true"}),c++;continue}c++;continue}if(b!==null){r.push({key:h,value:b}),c++;continue}else if(c+1<s.length&&!(s[c+1]||"").startsWith("-")){const j=(s[c+1]||"").replace(/^['"]|['"]$/g,"");r.push({key:h,value:j}),c+=2;continue}else{r.push({key:h,value:"true"}),c++;continue}}u.push(p),c++}i=u[0]||"",d=u.slice(1).join(" ");const x=[];for(const p of r)p.name="",p.path="",p.prefix="",p.protocol="",p.proxyBehavior="service",p.type="docker",!(jn.has(p.key)&&p.value==="true")&&x.push(p);for(const p of l)p.custom="",p.description="",p.secure=!1,p.shared=!1,p.required=!1;return{dockerArgs:wn(yn(x)),dockerEnvs:l,dockerImage:i,dockerCommand:d}}function vn({dockerArgs:t,dockerEnvs:o,dockerImage:s,dockerCommand:r}){if(t.length===0&&o.length===0&&!s)return"";const l=["docker run \\"],c=new Set(["--publish","--volume","--expose","--device","--mount","--label","--cap-add","--cap-drop","--add-host","--dns","--network-alias","--sysctl","--ulimit","--network"]);for(const i of t){const{key:d,value:u}=i;if(c.has(d))if(u==="true")l.push(` ${d} \\`);else{const x=/[\s"']/g.test(u)?`"${u}"`:u;l.push(` ${d} ${x} \\`)}else if(!l.some(x=>x.startsWith(` ${d}`)))if(u==="true")l.push(` ${d} \\`);else{const x=/[\s"']/g.test(u)?`"${u}"`:u;l.push(` ${d} ${x} \\`)}}for(const i of o){const{key:d,value:u}=i,x=/["']/g.test(u)?u:`"${u}"`;l.push(` -e ${d}=${x} \\`)}return s&&l.push(` ${s} \\`),r&&l.push(` ${r} \\`),l[l.length-1]?.endsWith(" \\")&&(l[l.length-1]=(l[l.length-1]||"").slice(0,-2)),l.join(`
193
+ `;function bs({text:t}){const{palette:o}=Eo();return t?e.jsx(zr,{style:{backgroundColor:o.background.default,color:o.text.primary},wrapperElement:{"data-color-mode":"light"},source:xr.sanitize(t),rehypePlugins:[[Br,{target:"_blank"}]]}):e.jsx(Fe,{Icon:Nt})}bs.propTypes={text:n.string.isRequired};function fs({params:t,setParams:o,paramsErrTip:s,loading:r,setParamsErrTip:l,readOnly:c}){const{t:i}=X(),[d,u]=k.useState(c?"preview":"write"),x=(p,m)=>{u(m)};return e.jsxs(a,{sx:{border:"1px solid transparent",borderRadius:2},children:[e.jsxs(a,{sx:{display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center"},children:[e.jsx(A,{variant:"h6",sx:{fontWeight:"bold"},children:i("common.introduction")}),e.jsxs(Lo,{value:d,onChange:x,"aria-label":"wrapped label tabs example",children:[e.jsx(ot,{value:"write",label:"Write"}),e.jsx(ot,{value:"preview",label:"Preview"})]})]}),e.jsx(a,{sx:{display:d==="write"?"block":"none",width:"100%",marginTop:3},children:e.jsx(ne,{disabled:r||c,sx:{border:"none"},placeholder:`Blocklet ${i("common.introduction")}`,autoComplete:"off",variant:"outlined",fullWidth:!0,multiline:!0,minRows:4,value:t.blockletIntroduction||"",onChange:p=>{l({blockletIntroduction:""}),o({blockletIntroduction:p.target.value.slice(0,me.PROJECT.MAX_INTRO_LENGTH)})},error:!!s.blockletIntroduction,helperText:s.blockletIntroduction||"",slotProps:{input:{"data-cy":"export-blocklet-introduction",readOnly:c,endAdornment:e.jsxs(He,{position:"end",children:[t?.blockletIntroduction?.length||0," / ",me.PROJECT.MAX_INTRO_LENGTH]})}}})}),e.jsx(a,{sx:{display:d==="preview"?"block":"none",mt:3},children:e.jsx(bs,{text:t.blockletIntroduction||""})})]})}fs.propTypes={params:n.object.isRequired,setParams:n.func.isRequired,paramsErrTip:n.object.isRequired,setParamsErrTip:n.func.isRequired,readOnly:n.bool.isRequired,loading:n.bool.isRequired};function xs({step:t=0,ok:o=!1,active:s=0,error:r="",warning:l=!1}){let c="grey.500",i=t+1;return o&&(i=e.jsx(Po,{sx:{fontSize:18,margin:0},color:"white"})),r||!o&&s>t?(c="error.main",i=e.jsx(Gt,{sx:{fontSize:18,margin:0},color:"white"})):l?(c="warning.main",i=e.jsx(Gt,{sx:{fontSize:18,margin:0},color:"white"})):s>=t&&(c="primary.main"),e.jsx(a,{sx:{width:24,height:24,bgcolor:c,borderRadius:"100%",color:"white",display:"flex",justifyContent:"center",fontWeight:"bold",fontSize:14,alignItems:"center"},children:i})}xs.propTypes={step:n.number,ok:n.bool,active:n.number,error:n.string,warning:n.bool};function gs({steps:t,activeStep:o,setActiveStep:s,hasSelectedResources:r=!1,params:l,loading:c,paramsErrTip:i,warning:d,viewMode:u="",projectId:x}){const{t:p}=X(),m=()=>{s(j=>j+1)},f=()=>{s(j=>j-1)},b=j=>j===0?i?.blockletTitle||i?.projectId||i?.blockletDescription||i?.blockletHomepage||i?.blockletSupport||i?.blockletCommunity||i?.blockletRepository:j===2?i?.blockletResource||i?.blockletDocker||i?.dockerImageName:j>=4?i?.blockletVersion||i?.note:"",h=u||rs({params:l,projectId:x,t:p})===null;return e.jsxs(a,{sx:{width:300,maxWidth:300,minWidth:300,padding:2,border:"1px solid",borderColor:"divider",borderRadius:1},children:[e.jsx(nr,{activeStep:o,orientation:"vertical",children:t.map((j,v)=>{const g={},C=c||!pn({params:l,projectId:x,step:v,t:p}),D=c?"":b(v);return D&&(g.optional=e.jsx(A,{variant:"caption",color:"error",sx:{wordBreak:"break-word"},children:D}),g.error=!0),e.jsxs(lr,{children:[e.jsx(ir,{icon:e.jsx(xs,{error:D,warning:v===0?d.hasWarning:!1,active:h?99:o,step:v,ok:C}),sx:{cursor:"pointer",color:D?"error.main":"inherit"},disabled:!1,onClick:()=>s(v),...g,children:e.jsx(A,{fontSize:"14px",fontWeight:"500",color:D||!C&&o>v?"error.main":"inherit",children:j.label})}),e.jsxs(cr,{children:[e.jsx(A,{fontSize:12,children:j.description}),!h&&e.jsx(a,{sx:{mb:2},children:e.jsxs("div",{children:[v<t.length-1&&e.jsx(G,{variant:"contained",onClick:m,sx:{mt:1,mr:1},disabled:D||!C,children:p("common.continue")}),v>0&&e.jsx(G,{disabled:v===0,onClick:f,sx:{mt:1,mr:1},children:p("common.back")})]})})]})]},j.label)})}),o>=t.length-1&&e.jsx(Lt,{square:!0,elevation:0,sx:{p:3},children:e.jsx(A,{fontSize:12,sx:{opacity:.5},children:"Click right top button to release"})})]})}gs.propTypes={steps:n.array.isRequired,activeStep:n.number.isRequired,setActiveStep:n.func.isRequired,params:n.object.isRequired,viewMode:n.oneOfType([n.string,n.bool]),loading:n.bool.isRequired,projectId:n.string.isRequired,hasSelectedResources:n.oneOfType([n.string,n.bool]),warning:n.object.isRequired,paramsErrTip:n.shape({projectId:n.string,blockletVersion:n.string,blockletTitle:n.string,blockletDescription:n.string,note:n.string,blockletResource:n.string,blockletHomepage:n.string,blockletSupport:n.string,blockletCommunity:n.string,blockletRepository:n.string,blockletDocker:n.object,dockerImageName:n.string}).isRequired};const mn=[".zip",".gz"],bn=1024*1024*100,fn=k.lazy(()=>No(()=>import("./index-C5sng-9P.js"),__vite__mapDeps([0,1,2]),import.meta.url).then(t=>({default:t.Uploader})));function ks({app:t,projectId:o,readOnly:s,params:r,setParams:l,setParamsErrTip:c,error:i}){const{t:d,locale:u}=X(),x=k.useRef(null),p=()=>s?!1:!o||o===F.UNOWNED_DID?(W.error(d("blocklet.publish.errorTip.noFirstDid")),!1):!0,m=`${F.WELLKNOWN_SERVICE_PATH_PREFIX}/api/project/${t.meta.did}/${o}/resource/upload`;return e.jsxs(a,{sx:{mt:3},children:[e.jsx(A,{gutterBottom:!0,children:d("blocklet.publish.resourceUpload")}),e.jsxs(Re,{direction:"row",spacing:1,sx:{alignItems:"center",flex:1,cursor:s?"default":"pointer"},children:[!!r.uploadedResource&&e.jsx(A,{component:"a",href:`${m}/params.uploadedResource`,children:r.uploadedResource}),!s&&e.jsx(G,{variant:"outlined",size:"small",onClick:()=>{p()&&x.current?.open()},children:r.uploadedResource?d("common.change"):d("common.upload")})]}),e.jsx(k.Suspense,{fallback:e.jsx(Je,{}),children:e.jsx(fn,{ref:x,locale:u,popup:!0,onUploadFinish:f=>{l({uploadedResource:f.data.filename}),c({blockletResource:""}),x.current?.close()},plugins:["ImageEditor"],installerProps:{disabled:!0},apiPathProps:{uploader:m,disableMediaKitPrefix:!0,disableMediaKitStatus:!0},coreProps:{restrictions:{allowedFileExts:mn,maxFileSize:bn,maxNumberOfFiles:1}}},"uploader-resource")}),!!i&&e.jsx(a,{sx:{color:"error.main",mt:1,fontSize:14},children:i})]})}ks.propTypes={app:n.object.isRequired,projectId:n.string.isRequired,readOnly:n.bool.isRequired,params:n.object.isRequired,setParams:n.func.isRequired,error:n.string.isRequired,setParamsErrTip:n.func.isRequired};function Tt({readOnly:t,params:o,setParams:s,paramsErrTip:r,setParamsErrTip:l,loading:c}){const{t:i}=X();return e.jsx(a,{className:"section",sx:{display:"flex",mt:3},children:e.jsxs(a,{sx:{flex:1},children:[e.jsx(ne,{required:!0,disabled:c||t,label:`Blocklet ${i("common.version")}`,placeholder:`Blocklet ${i("common.version")}`,autoComplete:"off",variant:"outlined",fullWidth:!0,value:o.blockletVersion||"",onChange:d=>{l({blockletVersion:""}),s({blockletVersion:d.target.value})},error:!!r.blockletVersion,helperText:r.blockletVersion||"",slotProps:{input:{"data-cy":"blocklet-version",readOnly:t}}}),e.jsx(ne,{label:i("blocklet.publish.releaseNote"),autoComplete:"off",disabled:c||t,variant:"outlined",fullWidth:!0,multiline:!0,minRows:4,required:!0,value:o.note||"",onChange:d=>{l({note:""}),s({note:d.target.value.slice(0,me.PROJECT.MAX_NOTE_LENGTH)})},error:!!r.note,helperText:r.note||"",sx:{mt:3},slotProps:{input:{"data-cy":"release-note",readOnly:t,endAdornment:e.jsxs(He,{position:"end",children:[o?.note?.length||0," / ",me.PROJECT.MAX_NOTE_LENGTH]})}}})]})})}Tt.propTypes={readOnly:n.bool.isRequired,params:n.object.isRequired,setParams:n.func.isRequired,paramsErrTip:n.object.isRequired,setParamsErrTip:n.func.isRequired,loading:n.bool.isRequired};function js(t){for(const o in t)typeof t[o]=="string"?t[o]=t[o].replace(/\\\\/g,"\\"):typeof t[o]=="object"&&t[o]!==null&&js(t[o]);return t}var xn=Wr();const oe=fo(xn),gn={"-a":"--attach","-d":"--detach","-e":"--env","-h":"--hostname","-i":"--interactive","-it":"-it","-rm":"-rm","-m":"--memory","-p":"--publish","-P":"--publish-all","-l":"--label","-n":"--name","-q":"--quiet","-x":"--x-registry","-t":"--tty","-u":"--user","-v":"--volume","-w":"--workdir","-cgroupns":"--cgroupns","-cpus":"--cpus","-g":"--gpus","-ip6":"--ip6","--read-only":"--read-only","--add-host":"--add-host","--attach":"--attach","--blkio-weight":"--blkio-weight","--blkio-weight-device":"--blkio-weight-device","--cap-add":"--cap-add","--cap-drop":"--cap-drop","--cgroup-parent":"--cgroup-parent","--cidfile":"--cidfile","--cpu-period":"--cpu-period","--cpu-quota":"--cpu-quota","--cpu-rt-period":"--cpu-rt-period","--cpu-rt-runtime":"--cpu-rt-runtime","--cpu-shares":"--cpu-shares","--cpus":"--cpus","--cpuset-cpus":"--cpuset-cpus","--cpuset-mems":"--cpuset-mems","--detach":"--detach","--detach-keys":"--detach-keys","--device":"--device","--device-cgroup-rule":"--device-cgroup-rule","--device-read-bps":"--device-read-bps","--device-read-iops":"--device-read-iops","--device-write-bps":"--device-write-bps","--device-write-iops":"--device-write-iops","--disable-content-trust":"--disable-content-trust","--dns":"--dns","--dns-opt":"--dns-opt","--dns-search":"--dns-search","--domainname":"--domainname","--entrypoint":"--entrypoint","--env":"--env","--env-file":"--env-file","--expose":"--expose","--gpus":"--gpus","--group-add":"--group-add","--health-cmd":"--health-cmd","--health-interval":"--health-interval","--health-retries":"--health-retries","--health-start-period":"--health-start-period","--health-timeout":"--health-timeout","--help":"--help","--hostname":"--hostname","--init":"--init","--interactive":"--interactive","--ip":"--ip","--ip6":"--ip6","--ipc":"--ipc","--isolation":"--isolation","--kernel-memory":"--kernel-memory","--label":"--label","--label-file":"--label-file","--link":"--link","--link-local-ip":"--link-local-ip","--log-driver":"--log-driver","--log-opt":"--log-opt","--mac-address":"--mac-address","--memory":"--memory","--memory-reservation":"--memory-reservation","--memory-swap":"--memory-swap","--memory-swappiness":"--memory-swappiness","--mount":"--mount","--name":"--name","--network":"--network","--network-alias":"--network-alias","--no-healthcheck":"--no-healthcheck","--oom-kill-disable":"--oom-kill-disable","--oom-score-adj":"--oom-score-adj","--pid":"--pid","--pids-limit":"--pids-limit","--platform":"--platform","--privileged":"--privileged","--publish":"--publish","--publish-all":"--publish-all","--pull":"--pull","--restart":"--restart","--rm":"--rm","--runtime":"--runtime","--security-opt":"--security-opt","--shm-size":"--shm-size","--stop-signal":"--stop-signal","--stop-timeout":"--stop-timeout","--storage-opt":"--storage-opt","--sysctl":"--sysctl","--tmpfs":"--tmpfs","--tty":"--tty","--ulimit":"--ulimit","--user":"--user","--userns":"--userns","--uts":"--uts","--volume":"--volume","--volume-driver":"--volume-driver","--volumes-from":"--volumes-from","--workdir":"--workdir"},Ut={"--env":!0,"--publish":!0,"--volume":!0,"--attach":!0,"--quiet":!0,"--entrypoint":!0,"--workdir":!0,"--cidfile":!0,"--detach-keys":!0,"--disable-content-trust":!0,"--domainname":!0,"--expose":!0,"--ip":!0,"--link-local-ip":!0,"--platform":!0},kn={"--volume":!0,"--publish":!0},jn=new Set(["--publish","--volume"]),ys=t=>{const[o]=t.split(":");return o?.startsWith("/")||o?.startsWith("./")||o?.startsWith("../")||o?.startsWith("~")||o?.startsWith("$BLOCKLET")};function yn(t){return t.map(o=>{if(o.key!=="--volume"||o.value.startsWith("$BLOCKLET_APP_DIR/")||o.value.startsWith("$BLOCKLET_DATA_DIR/"))return o;const[s,...r]=o.value.split(":");if(!s||!ys(o.value))return o;const l=s.startsWith("/")?`$BLOCKLET_DATA_DIR${s}`:`$BLOCKLET_DATA_DIR/${s}`;return{...o,value:[l,...r].join(":")}})}function wn(t){let o=!0;return t.find(r=>r.key==="--publish"&&r.type==="web")?t.map(r=>{if(r.key==="--publish"){const l={...r,type:o?"docker":r.type};return o=r.type==="web",l}return r}):t.map(r=>{if(r.key==="--publish"){const l={...r,type:o?"web":"docker"};return o=!1,l}return r})}function po(t){if(!t)return{dockerArgs:[],dockerEnvs:[],dockerImage:"",dockerCommand:""};if(t=t.trim(),t.startsWith("$ docker run")&&(t=t.replace("$ docker run","docker run")),!t.startsWith("docker run"))return{dockerArgs:[],dockerEnvs:[],dockerImage:"",dockerCommand:""};const s=t.replace(/\\\n/g,"").replace(/\n/g," ").trim().match(/(?:[^\s"']+|'[^']*'|"[^"]*")+/g);if(!s)return{dockerArgs:[],dockerEnvs:[],dockerImage:"",dockerCommand:""};const r=[],l=[];let c=0,i="",d="";const u=[];for(;c<s.length;){const p=s[c];if(!p){c++;continue}if(p==="docker"||p==="run"){c++;continue}if((p==="-e"||p==="--env")&&c+1<s.length){const m=s[c+1]||"",[f,...b]=m.split("=");if(f){const h=b.join("=").replace(/^['"]|['"]$/g,"");l.push({key:f,value:h})}c+=2;continue}if(p.startsWith("-")&&u.length===0){const m=p.indexOf("=");let f=p,b=null;m!==-1&&(f=p.substring(0,m),b=p.substring(m+1).replace(/^['"]|['"]$/g,""));const h=gn[f];if(!h){c+=2;continue}if(h==="--publish"){let j="";if(b)j=b,r.push({key:h,value:j});else if(c+1<s.length&&!(s[c+1]||"").startsWith("-")){j=(s[c+1]||"").replace(/^['"]|['"]$/g,""),r.push({key:h,value:j}),c+=2;continue}else{r.push({key:h,value:"true"}),c++;continue}c++;continue}if(b!==null){r.push({key:h,value:b}),c++;continue}else if(c+1<s.length&&!(s[c+1]||"").startsWith("-")){const j=(s[c+1]||"").replace(/^['"]|['"]$/g,"");r.push({key:h,value:j}),c+=2;continue}else{r.push({key:h,value:"true"}),c++;continue}}u.push(p),c++}i=u[0]||"",d=u.slice(1).join(" ");const x=[];for(const p of r)p.name="",p.path="",p.prefix="",p.protocol="",p.proxyBehavior="service",p.type="docker",!(jn.has(p.key)&&p.value==="true")&&x.push(p);for(const p of l)p.custom="",p.description="",p.secure=!1,p.shared=!1,p.required=!1;return{dockerArgs:wn(yn(x)),dockerEnvs:l,dockerImage:i,dockerCommand:d}}function vn({dockerArgs:t,dockerEnvs:o,dockerImage:s,dockerCommand:r}){if(t.length===0&&o.length===0&&!s)return"";const l=["docker run \\"],c=new Set(["--publish","--volume","--expose","--device","--mount","--label","--cap-add","--cap-drop","--add-host","--dns","--network-alias","--sysctl","--ulimit","--network"]);for(const i of t){const{key:d,value:u}=i;if(c.has(d))if(u==="true")l.push(` ${d} \\`);else{const x=/[\s"']/g.test(u)?`"${u}"`:u;l.push(` ${d} ${x} \\`)}else if(!l.some(x=>x.startsWith(` ${d}`)))if(u==="true")l.push(` ${d} \\`);else{const x=/[\s"']/g.test(u)?`"${u}"`:u;l.push(` ${d} ${x} \\`)}}for(const i of o){const{key:d,value:u}=i,x=/["']/g.test(u)?u:`"${u}"`;l.push(` -e ${d}=${x} \\`)}return s&&l.push(` ${s} \\`),r&&l.push(` ${r} \\`),l[l.length-1]?.endsWith(" \\")&&(l[l.length-1]=(l[l.length-1]||"").slice(0,-2)),l.join(`
194
194
  `)}const ws={"--volume":t=>{const[o]=t.split(":");return o?ys(t)&&!t.startsWith("$BLOCKLET_APP_DIR/")&&!t.startsWith("$BLOCKLET_DATA_DIR/")?"Volume must start with $BLOCKLET_APP_DIR or $BLOCKLET_DATA_DIR":t.indexOf("..")>-1?'Volume cannot contain ".."':"":"Volume must start with key:value"}},Qe=t=>t.replace(/^[-]+/,"").replace(/-([a-z])/g,(r,l)=>l.toUpperCase()),Cn=t=>`--${t.replace(/([A-Z])/g,"-$1").toLowerCase()}`,Rn=[" -- ","~","&","|",">","<","{","}","[","]",";","$","!","*","%","&&","||",","],Sn=["rm ","sudo "];function vs(t){if(t==="")return;if(/(\n|\\n|\\\n|\t|\\t|\\\t)/.test(t))throw new Error("Docker CMD is invalid");const s=t.toLocaleLowerCase();if(Sn.some(l=>s.indexOf(l)!==-1))throw new Error("Docker CMD is invalid");if(Rn.some(l=>t.indexOf(l)!==-1))throw new Error("Docker CMD is invalid");if(!/^(?:(?:[a-zA-Z0-9\-_.\/:=\s]+)|(?:\@{1,2}[a-zA-Z_][a-zA-Z0-9_]*))+$/.test(t))throw new Error("Docker CMD is invalid")}const Tn=Array.from(new Set(Object.keys(Ut).map(Qe))),Dn=["publish","volume"];oe.object({workdir:oe.string().trim().optional(),image:oe.string().trim().regex(/^[^\s]+$/).optional(),shell:oe.string().trim().optional(),volumes:oe.array().items(oe.string().trim()).optional(),script:oe.string().trim().optional(),installNodeModules:oe.boolean().optional(),skipWrapDockerfile:oe.boolean().optional(),command:oe.string().allow("").default("").optional().custom((t,o)=>{try{return vs(t),t}catch(s){return o.error("any.invalid",{message:s.message})}},"Docker CMD validation"),runBaseScript:oe.boolean().optional(),...Tn.reduce((t,o)=>{const s=ws[Cn(o)];return Dn.includes(o)?(t[o]=oe.array().items(oe.string().trim()).optional(),s?t[o]=oe.array().items(oe.string().trim().custom((r,l)=>{const c=s(r);return c?l.message(c):r})).optional():t[o]=oe.array().items(oe.string().trim()).optional(),t):(s?t[o]=oe.string().trim().custom((r,l)=>{const c=s(r);return c?l.message(c):r}).optional():t[o]=oe.string().trim().optional(),t)},{})}).optional();function Dt({index:t,item:o,dockerParams:s,setDockerParams:r,dataKey:l,t:c,readOnly:i}){const d=o?.value||"",[u,x]=k.useState(!1),p=()=>{s[l]?.splice(t,1),r({...s,[l]:[...s[l]]})},m=(P,L)=>{s[l]?.[t]&&(L?(s[l][t].custom=s[l][t].value,s[l][t].value=`$${Qe(o.key)}`):(s[l][t].value=s[l][t].custom||"",s[l][t].custom="")),r({...s,[l]:[...s[l]]})},f=(P,L)=>{const w=s[l][t]?.value||"";s[l][t]={...s[l][t],secure:L,value:L&&w===me.BLOCKLET_AUTOMATIC_ENV_VALUE?"":w},r({...s,[l]:[...s[l]]})},b=(P,L)=>{s[l][t]={...s[l][t],shared:L},r({...s,[l]:[...s[l]]})},h=(P,L)=>{const w=s[l][t]?.value||"";s[l][t]={...s[l][t],required:L,value:L&&w===me.BLOCKLET_AUTOMATIC_ENV_VALUE?"":w},r({...s,[l]:[...s[l]]})},j=(P,L)=>{s[l][t]={...s[l][t],value:L?me.BLOCKLET_AUTOMATIC_ENV_VALUE:"",secure:!1,required:!1},r({...s,[l]:[...s[l]]})},v=P=>{s[l][t]={...s[l][t],description:P.target.value},r({...s,[l]:[...s[l]]})},g=P=>{const L=P.target.value==="web"?"web":"docker";L==="web"&&s.dockerArgs.forEach(Z=>{Z.type="docker"});const S=`/${s.dockerImage.replace(/\W/g,"-")}-${t}`;s.dockerArgs[t]={...s.dockerArgs[t],type:L,path:L==="docker"?S:"/",protocol:"http",prefix:L==="docker"?S:"/",name:"publicUrl",port:"BLOCKLET_PORT"},r({...s,dockerArgs:[...s.dockerArgs]})},C=P=>{s.dockerArgs[t]={...s.dockerArgs[t],proxyBehavior:P.target.value==="direct"?"direct":"service"},r({...s,dockerArgs:[...s.dockerArgs]})},D=P=>{const L=P.target.value;s[l][t]={...s[l][t],prefix:L,path:L==="*"?"/":L},r({...s,[l]:[...s[l]]})},R=P=>{s[l]?.[t]&&(s[l][t].value=P.target.value),r({...s,[l]:[...s[l]]})},y=d===`$${Qe(o.key)}`||o.custom,T=l==="dockerArgs"&&!Ut[o.key],O=kn[o.key],N=l==="dockerEnvs",z=o.key==="--publish";let K=o.key;return z&&o.type==="web"?K="--publish (Web)":N&&(K=`--env ${o.key}`),e.jsxs(a,{sx:{display:"flex",flexDirection:"row",gap:2,alignItems:"center"},children:[e.jsx(a,{sx:{width:250},children:e.jsx(A,{sx:{textOverflow:"ellipsis",width:"100%",overflow:"hidden"},children:K})}),e.jsxs(a,{sx:{display:"flex",flexDirection:"column",gap:1,flex:1},children:[e.jsx(ne,{disabled:i||y||T||o.value===me.BLOCKLET_AUTOMATIC_ENV_VALUE,placeholder:"",value:y?`$${Qe(o.key)}`:d,sx:{flex:1},error:T,onChange:R,slotProps:{input:{endAdornment:e.jsxs(He,{position:"end",sx:{zoom:.9},children:[(!(O||T)||N||z)&&e.jsx(ce,{onClick:()=>x(!0),children:e.jsx(ae,{icon:"icon-park-outline:setting-config"})}),!i&&e.jsx(ce,{onClick:p,color:T?"error":"default",children:e.jsx(ae,{icon:"ic:round-delete"})})]})}}}),T&&e.jsx(A,{variant:"caption",color:"error",children:c("blocklet.publish.docker.noAllowTheArg")}),o.key==="--publish"&&e.jsx(A,{variant:"caption",sx:{color:"text.secondary"},children:c("blocklet.publish.docker.publishTips")}),o.key==="--volume"&&ws[o.key](d)&&e.jsx(A,{variant:"caption",color:"error",children:c("blocklet.publish.docker.volumeTips")})]}),u&&e.jsx(ct,{open:!0,fullWidth:!0,maxWidth:"sm",PaperProps:{style:{minHeight:0}},title:c(N?"blocklet.publish.docker.modifyEnv":"blocklet.publish.docker.modifyParam"),onClose:()=>x(!1),children:e.jsxs(a,{sx:{display:"flex",flexDirection:"column",gap:1,paddingBottom:2},children:[O||T||N?null:e.jsxs(a,{sx:{width:"100%",display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"space-between"},children:[e.jsx(A,{children:c("blocklet.publish.docker.needCustomInput")}),e.jsx(Le,{disabled:i,checked:y,onChange:m,sx:{zoom:.9}})]}),N&&e.jsxs(a,{sx:{width:"100%",display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"space-between"},children:[e.jsx(A,{children:c("blocklet.publish.docker.shared")}),e.jsx(Le,{disabled:i,checked:o.shared,onChange:b,sx:{zoom:.9}})]}),N&&e.jsxs(a,{sx:{width:"100%",display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"space-between"},children:[e.jsx(A,{children:c("blocklet.publish.docker.required")}),e.jsx(Le,{disabled:i,checked:o.required,onChange:h,sx:{zoom:.9}})]}),N&&e.jsxs(a,{sx:{width:"100%",display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"space-between"},children:[e.jsx(A,{children:c("blocklet.publish.docker.secure")}),e.jsx(Le,{disabled:i,checked:o.secure,onChange:f,sx:{zoom:.9}})]}),N&&e.jsxs(a,{sx:{width:"100%",display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"space-between"},children:[e.jsx(A,{children:c("blocklet.publish.docker.autoGenerated")}),e.jsx(Le,{disabled:i,checked:o.value===me.BLOCKLET_AUTOMATIC_ENV_VALUE,onChange:j,sx:{zoom:.9}})]}),N&&e.jsxs(a,{sx:{mt:1,width:"100%",display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"space-between"},children:[e.jsx(A,{sx:{flex:1},children:c("blocklet.publish.docker.description")}),e.jsx(ne,{disabled:i,value:o.description,onChange:v,sx:{flex:1},label:c("blocklet.publish.docker.description")})]}),z&&e.jsxs(a,{sx:{mt:1,width:"100%",display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"space-between"},children:[e.jsx(A,{sx:{flex:1},children:c("blocklet.publish.docker.portType")}),e.jsxs(vt,{value:o.type||"docker",onChange:g,children:[e.jsx(be,{value:"docker",children:"Docker"}),e.jsx(be,{value:"web",children:"Web"})]})]}),z&&o.type==="web"&&e.jsxs(a,{sx:{mt:1,width:"100%",display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"space-between"},children:[e.jsx(A,{sx:{flex:1},children:c("blocklet.publish.docker.proxyBehavior")}),e.jsxs(vt,{value:o.proxyBehavior||"service",onChange:C,children:[e.jsx(be,{value:"service",children:c("blocklet.publish.docker.serviceProxy")}),e.jsx(be,{value:"direct",children:c("blocklet.publish.docker.directProxy")})]})]}),z&&o.type==="web"&&e.jsxs(a,{sx:{mt:1,width:"100%",display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"space-between"},children:[e.jsx(A,{sx:{flex:1},children:c("blocklet.publish.docker.prefix")}),e.jsx(ne,{disabled:i,value:o.prefix,onChange:D,sx:{flex:1},label:c("blocklet.publish.docker.prefix")})]})]})})]})}Dt.propTypes={dockerParams:n.object.isRequired,setDockerParams:n.func.isRequired,dataKey:n.string.isRequired,item:n.object.isRequired,t:n.func.isRequired,readOnly:n.bool.isRequired,index:n.number.isRequired};const In=`
195
195
  docker run --name postgrest
196
196
  -p 3000:3000
@@ -1 +1 @@
1
- import{r as p}from"./vendor-react-Dvs43sk9.js";import{j as a,y as b,W as t,z as y,M as E,ak as I}from"./vendor-mui-core-DRxbhqaK.js";import{a as j}from"./vendor-hooks-BlA8TRnZ.js";import{_ as r}from"./index-kYJKn2jR.js";import{T as A}from"./vendor-ux-B9VfuZTg.js";import{l as C}from"./arrow-down.svg-BIpNdtOh.js";import{L as O,D as H}from"./vendor-mui-x-Qp6zkx78.js";import{A as R}from"./AdapterDayjs-Bp0ir26R.js";function v({value:s=null,onChange:i,error:l=!1,helperText:c="",label:T="",timezone:e="",minDateTime:f=null}){const d=j(()=>{let n=r();return s&&(n=e?r(s).tz(e):r(s)),n},[s,e]),m=n=>{const h=e?r(n).tz(e):r(n);i(new Date(h.format("YYYY-MM-DD HH:mm:00")))};return a.jsx(O,{dateAdapter:R,children:a.jsx(b,{fullWidth:!0,error:l,children:a.jsx(H,{label:T,minDateTime:f,value:d,onChange:m,slotProps:{textField:{error:l,helperText:l?c:""}},format:"YYYY-MM-DD HH:mm"})})})}v.propTypes={value:t.oneOfType([t.string,t.instanceOf(Date)]),onChange:t.func.isRequired,error:t.bool,helperText:t.string,label:t.string,timezone:t.string,minDateTime:t.instanceOf(Date)};function U(s){return a.jsx(C,{...s,width:20,height:20})}const u={MINUTES_30:30*60*1e3,HOUR_1:60*60*1e3,HOURS_3:3*60*60*1e3,DAY_1:24*60*60*1e3,DAYS_7:7*24*60*60*1e3,DAYS_30:30*24*60*60*1e3};function $({placeholder:s="",value:i="",onChange:l,timezone:c="",showError:T=!0}){const{t:e}=A(),[f,d]=p.useState(i||""),[m,n]=p.useState(null),[h,Y]=p.useState(null),x=p.useMemo(()=>[{value:u.MINUTES_30,label:`30 ${e("common.minutes")}`},{value:u.HOUR_1,label:`1 ${e("common.hour")}`},{value:u.HOURS_3,label:`3 ${e("common.hours")}`},{value:u.DAY_1,label:`1 ${e("common.day")}`},{value:u.DAYS_7,label:`7 ${e("common.days")}`},{value:u.DAYS_30,label:`30 ${e("common.days")}`},{value:"custom",label:e("common.custom")}],[e]),_=o=>{if(d(o),o==="custom"){const D=c?r().tz(c):r(),S=D.add(1,"day").toDate();Y(D),n(S),l(S)}else l(new Date(Date.now()+o))},M=o=>{n(o),l(o)};p.useEffect(()=>{i&&(x.find(D=>r(D.value).isSame(i))||(d("custom"),n(i)))},[]);const g=j(()=>T?!!(!m||r(m).isBefore(r())):!1,[m,e]);return a.jsxs(a.Fragment,{children:[a.jsx(b,{fullWidth:!0,children:a.jsx(y,{select:!0,value:f,label:s||e("team.passport.passportExpireTime"),onChange:o=>_(o.target.value),variant:"outlined",slotProps:{select:{IconComponent:U}},sx:{"& .MuiInputLabel-root":{width:"calc(100% - 46px)"}},children:x.map(o=>a.jsx(E,{value:o.value,children:o.label},o.value))})}),f==="custom"&&a.jsx(I,{children:a.jsx(v,{value:m,onChange:M,label:e("team.passport.customExpireTime"),timezone:c,error:!!g,helperText:g?e("team.passport.customExpireTimeIsInvalid"):void 0,minDateTime:h})})]})}$.propTypes={value:t.oneOfType([t.string,t.instanceOf(Date)]),onChange:t.func.isRequired,timezone:t.string,placeholder:t.string,showError:t.bool};export{$ as T};
1
+ import{r as p}from"./vendor-react-Dvs43sk9.js";import{j as a,y as b,W as t,z as y,M as E,ak as I}from"./vendor-mui-core-DRxbhqaK.js";import{a as j}from"./vendor-hooks-BlA8TRnZ.js";import{_ as r}from"./index-Dt8akALo.js";import{T as A}from"./vendor-ux-B9VfuZTg.js";import{l as C}from"./arrow-down.svg-DgXRF8DP.js";import{L as O,D as H}from"./vendor-mui-x-Qp6zkx78.js";import{A as R}from"./AdapterDayjs-Bp0ir26R.js";function v({value:s=null,onChange:i,error:l=!1,helperText:c="",label:T="",timezone:e="",minDateTime:f=null}){const d=j(()=>{let n=r();return s&&(n=e?r(s).tz(e):r(s)),n},[s,e]),m=n=>{const h=e?r(n).tz(e):r(n);i(new Date(h.format("YYYY-MM-DD HH:mm:00")))};return a.jsx(O,{dateAdapter:R,children:a.jsx(b,{fullWidth:!0,error:l,children:a.jsx(H,{label:T,minDateTime:f,value:d,onChange:m,slotProps:{textField:{error:l,helperText:l?c:""}},format:"YYYY-MM-DD HH:mm"})})})}v.propTypes={value:t.oneOfType([t.string,t.instanceOf(Date)]),onChange:t.func.isRequired,error:t.bool,helperText:t.string,label:t.string,timezone:t.string,minDateTime:t.instanceOf(Date)};function U(s){return a.jsx(C,{...s,width:20,height:20})}const u={MINUTES_30:30*60*1e3,HOUR_1:60*60*1e3,HOURS_3:3*60*60*1e3,DAY_1:24*60*60*1e3,DAYS_7:7*24*60*60*1e3,DAYS_30:30*24*60*60*1e3};function $({placeholder:s="",value:i="",onChange:l,timezone:c="",showError:T=!0}){const{t:e}=A(),[f,d]=p.useState(i||""),[m,n]=p.useState(null),[h,Y]=p.useState(null),x=p.useMemo(()=>[{value:u.MINUTES_30,label:`30 ${e("common.minutes")}`},{value:u.HOUR_1,label:`1 ${e("common.hour")}`},{value:u.HOURS_3,label:`3 ${e("common.hours")}`},{value:u.DAY_1,label:`1 ${e("common.day")}`},{value:u.DAYS_7,label:`7 ${e("common.days")}`},{value:u.DAYS_30,label:`30 ${e("common.days")}`},{value:"custom",label:e("common.custom")}],[e]),_=o=>{if(d(o),o==="custom"){const D=c?r().tz(c):r(),S=D.add(1,"day").toDate();Y(D),n(S),l(S)}else l(new Date(Date.now()+o))},M=o=>{n(o),l(o)};p.useEffect(()=>{i&&(x.find(D=>r(D.value).isSame(i))||(d("custom"),n(i)))},[]);const g=j(()=>T?!!(!m||r(m).isBefore(r())):!1,[m,e]);return a.jsxs(a.Fragment,{children:[a.jsx(b,{fullWidth:!0,children:a.jsx(y,{select:!0,value:f,label:s||e("team.passport.passportExpireTime"),onChange:o=>_(o.target.value),variant:"outlined",slotProps:{select:{IconComponent:U}},sx:{"& .MuiInputLabel-root":{width:"calc(100% - 46px)"}},children:x.map(o=>a.jsx(E,{value:o.value,children:o.label},o.value))})}),f==="custom"&&a.jsx(I,{children:a.jsx(v,{value:m,onChange:M,label:e("team.passport.customExpireTime"),timezone:c,error:!!g,helperText:g?e("team.passport.customExpireTimeIsInvalid"):void 0,minDateTime:h})})]})}$.propTypes={value:t.oneOfType([t.string,t.instanceOf(Date)]),onChange:t.func.isRequired,timezone:t.string,placeholder:t.string,showError:t.bool};export{$ as T};
@@ -1,4 +1,4 @@
1
- import{g as Wt,r as v}from"./vendor-react-Dvs43sk9.js";import{j as e,ak as y,z as Q,b6 as me,bg as qe,y as V,am as ut,d2 as Bt,bn as qt,at as ae,b1 as mt,W as h,T as ee,U as Je,d3 as pt,b5 as Ke,a5 as Me,Q as Fe,d4 as Ge,aN as Ue,a6 as ft,D as ht,d5 as Kt,ad as xt,d6 as Mt,d7 as Ut,c2 as st,n as Ht,x as $t,bc as Vt,M as it,cw as Jt,I as Gt,d8 as Yt}from"./vendor-mui-core-DRxbhqaK.js";import{A as gt,J as Xt,C as Qt,e as le,F as Zt,a3 as je}from"./vendor-utils-CUDP56Ff.js";import{T as te,H as M,n as ce,c as en,p as bt,a3 as tn,au as nn,m as jt,$ as vt,j as yt,av as Ae,b as St,I as sn,a0 as an}from"./vendor-ux-B9VfuZTg.js";import{aD as rn,X as Ye,a9 as Ct,aW as wt,J as _e,c as _,_ as Z,o as on,aL as at}from"./index-kYJKn2jR.js";import{g as ye,b as $,a as se}from"./vendor-hooks-BlA8TRnZ.js";import{u as Rt,C as Y}from"./index.esm-JPZAjt0x.js";import{i as He}from"./isURL-DOKl6zP6.js";import{S as X}from"./section-ZPKr6_ii.js";import{A as ln,a as cn,b as dn}from"./collapse-DJGzUM1Q.js";import{S as Se}from"./shorten-label-DVy6K5I7.js";import{v as Tt}from"./index-Ba9-ArMT.js";import{R as Nt,A as un,S as mn,a as pn,B as fn}from"./list-CWTC1dNA.js";import{j as hn,c as xn,N as gn}from"./team-BxHvUIQ6.js";import{W as bn}from"./did-address-DnFNwELW.js";import{p as It}from"./util-B8m2D-S9.js";import{D as jn,g as vn}from"./traffic-bm4qFOVU.js";import{B as Et}from"./bundle-avatar-YluGbYkj.js";import{u as yn}from"./use-mobile-BQQpAf3i.js";import"./lottie-web-4koyQiv_.js";import"./vendor-arcblock-DeeG8u0h.js";import"./required-BT8zXV8U.js";import"./server-logo-notext.svg-CKQB0tIp.js";import"./index-DeRDwip-.js";import"./session-C838MSz1.js";import"./use-app-logo-ezyDWOV9.js";import"./base32-BK7MXAD4.js";import"./useAsyncRetry-EEjDgDMR.js";import"./useAsync-DVtDVEv6.js";import"./iframe-BI7fZAER.js";import"./index-B6gW9Yjq.js";import"./index-DBs9Ljax.js";import"./base-chart-UFWO9a3P.js";import"./index-3ePiAFIp.js";import"./vendor-mui-x-Qp6zkx78.js";import"./AdapterDayjs-Bp0ir26R.js";var Te={exports:{}},Ne={exports:{}},Ie={exports:{}},rt;function Sn(){return rt||(rt=1,function(n,s){Object.defineProperty(s,"__esModule",{value:!0}),s.default=t;function t(r){return r==null}n.exports=s.default,n.exports.default=s.default}(Ie,Ie.exports)),Ie.exports}var ot;function Cn(){return ot||(ot=1,function(n,s){Object.defineProperty(s,"__esModule",{value:!0}),s.default=u;var t=o(rn()),r=o(Sn());function o(p){return p&&p.__esModule?p:{default:p}}var l=/^(?:[-+]?(?:0|[1-9][0-9]*))$/,b=/^[-+]?[0-9]+$/;function u(p,i){(0,t.default)(p),i=i||{};var N=i.allow_leading_zeroes===!1?l:b,I=!i.hasOwnProperty("min")||(0,r.default)(i.min)||p>=i.min,S=!i.hasOwnProperty("max")||(0,r.default)(i.max)||p<=i.max,j=!i.hasOwnProperty("lt")||(0,r.default)(i.lt)||p<i.lt,E=!i.hasOwnProperty("gt")||(0,r.default)(i.gt)||p>i.gt;return N.test(p)&&I&&S&&j&&E}n.exports=s.default,n.exports.default=s.default}(Ne,Ne.exports)),Ne.exports}var lt;function wn(){return lt||(lt=1,function(n,s){Object.defineProperty(s,"__esModule",{value:!0}),s.default=o;var t=r(Cn());function r(l){return l&&l.__esModule?l:{default:l}}function o(l){return(0,t.default)(l,{allow_leading_zeroes:!1,min:0,max:65535})}n.exports=s.default,n.exports.default=s.default}(Te,Te.exports)),Te.exports}var Rn=wn();const Tn=Wt(Rn),ze={enabled:!1,secure:!1,from:"",host:"",port:"",user:"",password:"",companyName:"",companyLink:"",companyAddress:"",supportEmail:""};function Nn(){const{api:n}=Ye(),{blocklet:s}=Ct(),{t}=te(),{confirmApi:r,confirmHolder:o}=wt(),l=s?.meta?.did,b=Object.assign({...ze},s?.settings?.notification?.email||{}),{handleSubmit:u,control:p,formState:i,watch:N,reset:I}=Rt({defaultValues:gt(b,Object.keys(ze))}),S=ye({testReceiver:"",testReceiverError:""}),j=N("enabled"),E=$(async(a,T,O=!0)=>{try{const{blocklet:D}=await n.configNotification({input:{did:l,notification:JSON.stringify({email:a})}}),re=Object.assign({...ze},D?.settings?.notification?.email||{});I(re),O&&M.success(t("oauth.saveSuccess"))}catch(D){if(O)M.error(D.message||t("oauth.saveFailed"));else throw D}}),J=$(async(a,T,O)=>{try{i.isDirty&&await E(a,T,!1),await n.sendEmail({input:{did:l,receiver:O,email:JSON.stringify({body:"Your SMTP configuration is correct!",title:"Test email",type:"notification",attachments:[{type:"link",data:{url:"https://community.arcblock.io",title:"Community",image:"https://community.arcblock.io/.well-known/service/blocklet/logo-rect-dark",utm:{campaign:"test-campaign"}}}],utm:{content:"test-email-button"}})}}),M.success(t("notification.email.testSuccess"))}catch(D){M.error(D.message||t("notification.email.testfailed"))}}),z=$((a,T)=>{S.testReceiver=localStorage.getItem("test-receiver")||"",S.testReceiverError="",r.open({title:t("notification.email.testSendEmail"),content:()=>e.jsx(y,{sx:{width:"300px"},children:e.jsx(Q,{sx:{mt:1},fullWidth:!0,name:"testReceiver",label:t("notification.email.inputTestReceiver"),value:S.testReceiver,onChange:O=>{S.testReceiver=O.target.value},error:!!S.testReceiverError,helperText:S.testReceiverError||" "})}),confirmButtonText:t("common.confirm"),cancelButtonText:t("common.cancel"),async onConfirm(O){const D=S.testReceiver?.trim();if(!D){S.testReceiverError=t("notification.email.receiverRequired");return}if(!_e(D)){S.testReceiverError=t("notification.email.receiverInvalid");return}S.testReceiverError="",await J(a,T,D),O()}})}),F=$(a=>{const T=a?.trim();return T?_e(T)?!0:t("notification.email.fromInvalid"):t("notification.email.fromRequired")}),B=$(a=>{const T=a?.trim();return T?He(T,{require_host:!1,protocols:[]})?!0:t("notification.email.hostInvalid"):t("notification.email.hostRequired")}),w=$(a=>a?Tn(a)?!0:t("notification.email.portInvalid"):t("notification.email.portRequired")),q=$(a=>a?.trim()?!0:t("notification.email.userRequired")),K=$(a=>a?.trim()?!0:t("notification.email.passwordRequired")),f=$(a=>a?.trim()&&!He(a,{protocols:["http","https"],require_protocol:!0})?t("notification.email.linkInvalid"):!0),R=$(a=>a?.trim()&&!_e(a)?t("notification.email.emailInvalid"):!0),C=$(()=>!0);return e.jsxs(y,{children:[e.jsxs(In,{component:"form",onSubmit:u(E),disabled:!0,sx:{".section-left":{width:"160px"}},children:[e.jsx(X,{title:t("notification.email.enable"),my:2.5,children:e.jsx(Y,{name:"enabled",control:p,render:({field:a})=>e.jsx(me,{control:e.jsx(qe,{checked:a.value,...a})})})}),e.jsx(X,{title:t("notification.email.from"),children:e.jsx(Y,{name:"from",control:p,rules:{validate:j?F:C},render:({field:a})=>e.jsx(V,{fullWidth:!0,children:e.jsx(Q,{...a,size:"small",required:!0,label:t("notification.email.from"),error:!!i.errors[a.name],helperText:i.errors[a.name]?.message||" ",disabled:!j})})})}),e.jsx(X,{title:t("notification.email.host"),children:e.jsx(Y,{name:"host",control:p,rules:{validate:j?B:C},render:({field:a})=>e.jsx(V,{fullWidth:!0,children:e.jsx(Q,{...a,size:"small",required:!0,error:!!i.errors[a.name],label:t("notification.email.host"),helperText:i.errors[a.name]?.message||" ",disabled:!j})})})}),e.jsx(X,{title:t("notification.email.port"),children:e.jsx(Y,{name:"port",control:p,rules:{validate:j?w:C},render:({field:a})=>e.jsx(V,{fullWidth:!0,children:e.jsx(Q,{...a,size:"small",required:!0,type:"number",error:!!i.errors[a.name],label:t("notification.email.port"),helperText:i.errors[a.name]?.message||" ",disabled:!j})})})}),e.jsx(X,{title:t("notification.email.user"),children:e.jsx(Y,{name:"user",control:p,rules:{validate:j?q:C},render:({field:a})=>e.jsx(V,{fullWidth:!0,children:e.jsx(Q,{...a,size:"small",required:!0,error:!!i.errors[a.name],label:t("notification.email.user"),helperText:i.errors[a.name]?.message||" ",disabled:!j})})})}),e.jsx(X,{title:t("notification.email.password"),children:e.jsx(Y,{name:"password",control:p,rules:{validate:j?K:C},render:({field:a})=>e.jsx(V,{fullWidth:!0,children:e.jsx(Q,{...a,size:"small",required:!0,type:"password",error:!!i.errors[a.name],label:t("notification.email.password"),helperText:i.errors[a.name]?.message||" ",disabled:!j})})})}),e.jsx(X,{title:t("notification.email.secure"),children:e.jsx(Y,{name:"secure",control:p,rules:{validate:C},render:({field:a})=>e.jsx(V,{fullWidth:!0,children:e.jsx(me,{control:e.jsx(qe,{checked:a.value,...a,disabled:!j})})})})}),e.jsxs(ln,{children:[e.jsxs(cn,{expandIcon:e.jsx(qt,{fontSize:"small"}),"aria-controls":"panel1-content",id:"panel1-header",children:[t("notification.email.signature"),e.jsx(ut,{title:t("notification.email.signatureTooltip"),children:e.jsx(Bt,{fontSize:"small",sx:{ml:1,cursor:"help"}})})]}),e.jsxs(dn,{children:[e.jsx(X,{title:t("notification.email.companyName"),children:e.jsx(Y,{name:"companyName",control:p,rules:{validate:C},render:({field:a})=>e.jsx(V,{fullWidth:!0,children:e.jsx(Q,{...a,size:"small",error:!!i.errors[a.name],label:t("notification.email.companyName"),helperText:i.errors[a.name]?.message||" ",disabled:!j})})})}),e.jsx(X,{title:t("notification.email.companyLink"),children:e.jsx(Y,{name:"companyLink",control:p,rules:{validate:j?f:C},render:({field:a})=>e.jsx(V,{fullWidth:!0,children:e.jsx(Q,{...a,size:"small",error:!!i.errors[a.name],label:t("notification.email.companyLink"),helperText:i.errors[a.name]?.message||" ",disabled:!j})})})}),e.jsx(X,{title:t("notification.email.companyAddress"),children:e.jsx(Y,{name:"companyAddress",control:p,rules:{validate:C},render:({field:a})=>e.jsx(V,{fullWidth:!0,children:e.jsx(Q,{...a,size:"small",error:!!i.errors[a.name],label:t("notification.email.companyAddress"),helperText:i.errors[a.name]?.message||" ",disabled:!j})})})}),e.jsx(X,{title:t("notification.email.supportEmail"),children:e.jsx(Y,{name:"supportEmail",control:p,rules:{validate:j?R:C},render:({field:a})=>e.jsx(V,{fullWidth:!0,children:e.jsx(Q,{...a,size:"small",type:"email",error:!!i.errors[a.name],label:t("notification.email.supportEmail"),helperText:i.errors[a.name]?.message||" ",disabled:!j})})})})]})]}),e.jsxs(y,{sx:{display:"flex",justifyContent:"flex-end",gap:2,mt:3},children:[e.jsx(ce,{variant:"outlined",color:"warning",onClick:u(z),disabled:!j,children:t("oauth.runTest")}),e.jsx(ce,{type:"submit",variant:"contained",disabled:!i.isDirty,children:t("oauth.save")})]})]}),o]})}const In=ae(mt)``,We={enabled:!1,endpoint:"",did:void 0,pushPath:void 0};function En(){const{api:n}=Ye(),{blocklet:s}=Ct(),{t}=te(),{confirmApi:r,confirmHolder:o}=wt(),l=s?.meta?.did,b=Object.assign({...We},s?.settings?.notification?.pushKit||{}),{handleSubmit:u,control:p,formState:i,watch:N,reset:I}=Rt({defaultValues:gt(b,Object.keys(We))}),S=ye({testReceiver:"",testReceiverError:""}),j=N("enabled"),E=$(async(w,q,K=!0)=>{try{const{blocklet:f}=await n.configNotification({input:{did:l,notification:JSON.stringify({pushKit:w})}}),R=Object.assign({...We},f?.settings?.notification?.pushKit||{});I(R),K&&M.success(t("oauth.saveSuccess"))}catch(f){if(K)M.error(f.message||t("oauth.saveFailed"));else throw f}}),J=$(async(w,q)=>{try{i.isDirty&&await E(w,q,!1);const K=(s?.configs||[]).find(C=>C.key==="BLOCKLET_APP_URL")?.value,f=Xt(Qt(K,_.WELLKNOWN_SERVICE_PATH_PREFIX,"/blocklet/logo"),{v:s?.meta?.version,t:new Date(s?.updatedAt||0).getTime()}),R={type:"passthrough",passthroughType:"messageStatus",data:{message:{title:"Test push-kit notification",body:"This is message from push-kit config test",sender:{did:s?.appDid,fullName:s?.meta?.title,avatar:f}}}};await n.sendPush({input:{did:l,receiver:S.testReceiver,notification:JSON.stringify(R)}}),M.success(t("notification.pushKit.testSuccess"))}catch(K){M.error(K.message||t("notification.pushKit.testfailed"))}}),z=$((w,q)=>{S.testReceiverError="",r.open({title:t("notification.pushKit.testSend"),content:()=>e.jsx(y,{sx:{width:"450px",maxWidth:"100%"},children:e.jsx(Q,{sx:{mt:1},fullWidth:!0,name:"testReceiver",label:t("notification.pushKit.inputTestReceiver"),value:S.testReceiver,onChange:K=>{S.testReceiver=K.target.value},error:!!S.testReceiverError,helperText:S.testReceiverError||" "})}),confirmButtonText:t("common.confirm"),cancelButtonText:t("common.cancel"),async onConfirm(K){if(!S.testReceiver?.trim()){S.testReceiverError=t("notification.pushKit.receiverRequired");return}S.testReceiverError="",await J(w,q),K()}})}),F=$(w=>{const q=w?.trim();return q?He(q)?!0:t("notification.pushKit.endpointInvalid"):t("notification.pushKit.endpointRequired")}),B=$(()=>!0);return e.jsxs(y,{children:[e.jsxs(kn,{component:"form",onSubmit:u(E),disabled:!0,sx:{".section-left":{width:"160px"}},children:[e.jsx(X,{title:t("notification.pushKit.enable"),my:2.5,children:e.jsx(Y,{name:"enabled",control:p,render:({field:w})=>e.jsx(me,{control:e.jsx(qe,{checked:w.value,...w})})})}),e.jsx(X,{title:t("notification.pushKit.endpoint"),children:e.jsx(Y,{name:"endpoint",control:p,rules:{validate:j?F:B},render:({field:w})=>e.jsx(V,{fullWidth:!0,children:e.jsx(Q,{...w,size:"small",required:!0,label:t("notification.pushKit.endpoint"),error:!!i.errors[w.name],helperText:i.errors[w.name]?.message||" ",disabled:!j})})})}),e.jsxs(X,{title:t("notification.pushKit.customOptions"),children:[e.jsx(Y,{name:"did",control:p,render:({field:w})=>e.jsx(V,{fullWidth:!0,children:e.jsx(Q,{...w,size:"small",label:t("notification.pushKit.did"),error:!!i.errors[w.name],helperText:i.errors[w.name]?.message||" ",disabled:!j})})}),e.jsx(Y,{name:"pushPath",control:p,render:({field:w})=>e.jsx(V,{fullWidth:!0,children:e.jsx(Q,{...w,size:"small",label:t("notification.pushKit.pushPath"),error:!!i.errors[w.name],helperText:i.errors[w.name]?.message||" ",disabled:!j})})})]}),e.jsxs(y,{sx:{display:"flex",justifyContent:"flex-end",gap:2,mt:3},children:[e.jsx(ce,{variant:"outlined",color:"warning",onClick:u(z),disabled:!j,children:t("oauth.runTest")}),e.jsx(ce,{type:"submit",variant:"contained",disabled:!i.isDirty,children:t("oauth.save")})]})]}),o]})}const kn=ae(mt)``,ct=[{label:e.jsx(y,{sx:{textAlign:"center",width:"100%"},children:"Email"}),value:"email"},{label:e.jsx(y,{sx:{textAlign:"center",width:"100%"},children:"Push Kit"}),value:"pushKit"}];function An(){const[n,s]=v.useState(ct[0].value),{locale:t}=v.useContext(en),r=se(()=>({email:e.jsx(Nn,{}),pushKit:e.jsx(En,{})}),[t]),o=v.useMemo(()=>({padding:"10px 0"}),[]);return e.jsxs(y,{children:[e.jsx(bt,{tabs:ct,current:n,onChange:s}),e.jsx(y,{style:o,children:r[n]})]})}const kt=v.createContext({}),{Provider:On,Consumer:Ws}=kt;function Dn({children:n,blocklet:s=""}){const{api:t,inService:r,ws:{useSubscription:o}}=Ye(),[l,b]=v.useState([]),[u,p]=v.useState({total:0,pageSize:20,pageCount:0,page:1}),i=se(()=>s.meta?.did,[s]),[N,I]=v.useState([]),[S,j]=v.useState({}),E=se(()=>l.length?new Set(l.map(f=>f.id)):new Set,[l]),J=async({page:f=1,pageSize:R=20,...C}={})=>{if(!i)return[];try{const a={paging:{page:f,pageSize:R},...C,teamDid:i,dateRange:C.dateRange?[Z(C.dateRange[0]).toISOString(),Z(C.dateRange[1]).toISOString()]:void 0},{dids:T,...O}=a;let D="";T&&T.includes("system")&&(D="system");const re=T?T.filter(pe=>pe!=="system"):[],ue={...O,source:D,componentDids:re},oe=await t.getNotificationSendLog({input:ue});return j(ue),b(oe.list),p(oe.paging),oe.list}catch(a){return M.error(a.message),[]}},z=async()=>{const f=await t.getNotificationComponents({input:{teamDid:i}});I(f.componentDids)},F=v.useCallback(f=>{const R=s.children.find(C=>C.meta?.did===f);if(R)return R.ancestors=[s],R},[s]),B=async({notificationId:f,receivers:R,channels:C,...a})=>{await t.resendNotification({input:{teamDid:i,notificationId:f,receivers:R,channels:C.map(T=>T==="wallet"?_.NOTIFICATION_SEND_CHANNEL.WALLET:T==="pushKit"?_.NOTIFICATION_SEND_CHANNEL.PUSH:T),...a}})},w=v.useCallback(async f=>(await t.getUser({input:{teamDid:i,user:{did:f},options:{enableConnectedAccount:!0}}})).user,[t,i]),q=v.useCallback(async({page:f=1,pageSize:R=20,...C}={})=>{try{const a={paging:{page:f,pageSize:R},...C,userName:C.searchText||"",teamDid:i,dateRange:C.dateRange?[Z(C.dateRange[0]).toISOString(),Z(C.dateRange[1]).toISOString()]:void 0};return await t.getReceivers({input:a})}catch(a){throw M.error(a.message),a}},[t,i]);v.useEffect(()=>{i&&z()},[i]),o(_.EVENTS.NOTIFICATION_BLOCKLET_UPDATE,f=>{E.has(f.notificationId)&&J(S)},[E,S]),o(_.EVENTS.NOTIFICATION_BLOCKLET_CREATE,f=>{E.has(f.id)||J(S)},[E,S]);const K={fetch:J,data:l,paging:u,blocklet:s,getComponent:F,resendNotification:B,getUser:w,componentDids:N,getReceivers:q,inService:r,teamDid:i};return e.jsx(On,{value:{notificationRecords:K},children:n})}function Xe(){const{notificationRecords:n}=v.useContext(kt);return n}Ce.propTypes={severity:h.oneOf(Object.values(["info","success","error","warning"])).isRequired};const Ln={info:"primary",success:"success",error:"error",warning:"warning"};function Ce({severity:n="info"}){return e.jsx(tn,{type:Ln[n],children:n})}const Pn=(n,s,t="")=>{if(!t||!s)return"";switch(t){case _.NOTIFICATION_SEND_FAILED_REASON.USER_DISABLED:return n("notification.sendStatus.reason.disabled",{channel:s});case _.NOTIFICATION_SEND_FAILED_REASON.CHANNEL_UNAVAILABLE:return n("notification.sendStatus.reason.unavailable",{channel:s});case _.NOTIFICATION_SEND_FAILED_REASON.CHANNEL_DISABLED:return n("notification.sendStatus.reason.notSent",{channel:s});case _.NOTIFICATION_SEND_FAILED_REASON.NOT_ONLINE:return n("notification.sendStatus.reason.offline");default:return t}};function At(n,s,t={}){const{status:r,updatedAt:o,reason:l="",channel:b="wallet"}=t,u=o?n("notification.sendStatus.sentTime",{date:on(o,s)}):"",p=Pn(n,b,l);return r===_.NOTIFICATION_SEND_STATUS.FAILED?{status:"failed",title:n("notification.sendStatus.failed"),sentTime:u,reason:p}:r===_.NOTIFICATION_SEND_STATUS.SENT?{status:"success",title:n("notification.sendStatus.success"),sentTime:u}:{status:"pending",title:n("notification.sendStatus.pending"),reason:p,sentTime:u}}const $e={pending:"#aaaaaa",success:"#34BE74",failed:"#D0021B"},Ve=["wallet","pushKit","email"],dt=["info","success","error","warning"],Ot=n=>{const{settings:s}=n;return s?.notification?.email?.enabled},Dt=n=>{const{settings:s}=n;return s?.notification?.pushKit?.enabled},Fn=(n,s)=>{const t=le(s,"extra.notifications.email",!0);return{available:Ot(n),enabled:t}},_n=(n,s)=>{const t=le(s,"extra.notifications.push",!0);return{available:Dt(n),enabled:t}},zn=n=>({enabled:le(n,"extra.notifications.wallet",!0)}),Wn=n=>({enabled:le(n,"extra.webhooks",[]).length>0}),Ee=(n=3)=>new Promise(s=>{setTimeout(()=>{s()},n*1e3)}),Bn=(n,s)=>s==="wallet"||s==="webhook"?[{channel:s,type:"enabled",pass:n("notification.sendStatus.reason.enabled",{channel:s}),fail:n("notification.sendStatus.reason.disabled",{channel:s})}]:s==="pushKit"||s==="email"?[{channel:s,type:"available",pass:n("notification.sendStatus.reason.available",{channel:s}),fail:n("notification.sendStatus.reason.unavailable",{channel:s})},{channel:s,type:"enabled",pass:n("notification.sendStatus.reason.enabled",{channel:s}),fail:n("notification.sendStatus.reason.disabled",{channel:s})}]:[],ke=(n=[])=>{const s=Z().startOf("day");return n.filter(t=>Z(t.sendAt).isSame(s,"day")).length},qn=(n,s="")=>{if(s&&Ve.includes(s)){const l=`${s}SendRecord`,b=le(n,l,[]);return ke(b)}const t=le(n,"webhook",{}),r=Object.keys(t??{})??[];if(s&&r.includes(s)){const l=t[s]??[];return ke(l)}const o={};return Ve.forEach(l=>{const b=`${l}SendRecord`,u=le(n,b,[]),p=ke(u);o[l]=p}),r.length>0&&r.forEach(l=>{const b=t[l]??[],u=ke(b);o[l]=u}),o},Oe=(n,s,t)=>{if(!Array.isArray(n))throw new Error("Invalid filterList or index");return n[t].splice(s,1),n},De=(n,s)=>{if(!Array.isArray(s))throw new Error("filters must be an array");return s.length?!s.includes(n):!1},Kn=n=>{switch(n){case _.NOTIFICATION_SEND_CHANNEL.WALLET:return"Wallet";case _.NOTIFICATION_SEND_CHANNEL.PUSH:return"Push Kit";case _.NOTIFICATION_SEND_CHANNEL.EMAIL:return"Email";case _.NOTIFICATION_SEND_CHANNEL.WEBHOOK:return"Webhook";default:return""}},Lt=()=>({components:{MUIDataTableFilter:{styleOverrides:{header:{marginBottom:0,p:{margin:0}},root:{"& .MuiGrid-container":{marginTop:0,"& .MuiGrid-item":{paddingTop:0}}}}},MuiPopover:{styleOverrides:{root:{"&.MuiPopover-root":{"& .MuiPaper-root:has(.filter-container)":{width:"420px"}}}}}}});function de({config:n,enableTooltip:s=!0,showTitle:t=!1,children:r=null}){const{status:o,title:l="",sentTime:b="",reason:u=""}=n,p=[l,u].filter(Boolean).join(", ");return e.jsx(ut,{title:s?e.jsxs(e.Fragment,{children:[e.jsx(ee,{color:"inherit",sx:{fontSize:12},children:p}),e.jsx("span",{children:b})]}):null,arrow:!0,placement:"top",children:e.jsxs(y,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"4px"},children:[e.jsxs(y,{sx:{position:"relative",minHeight:14,minWidth:14,display:"flex",alignItems:"center",justifyContent:"center"},children:[e.jsx(y,{style:{opacity:.15},sx:{position:"absolute",width:"100%",height:"100%",borderRadius:"50%",bgcolor:$e[o]}}),e.jsx(y,{sx:{position:"absolute",width:"55%",height:"55%",borderRadius:"50%",bgcolor:$e[o]}})]}),e.jsx(ee,{color:"inherit",sx:{fontSize:12},children:t?l:r})]})})}de.propTypes={config:h.object.isRequired,enableTooltip:h.bool,showTitle:h.bool,children:h.node};Le.propTypes={list:h.array.isRequired,label:h.string.isRequired,onDelete:h.func};function Le({list:n,label:s,onDelete:t=()=>{}}){const{t:r,locale:o}=te();return e.jsxs(y,{sx:{display:"flex",gap:1,alignItems:"center"},children:[e.jsxs(ee,{children:[s,": "]}),n.map(l=>{const b=At(r,o,{status:l});return e.jsx(Je,{size:"small",label:e.jsx(y,{sx:{display:"flex",alignItems:"center",gap:"4px"},children:e.jsx(de,{config:b,enableTooltip:!1,children:b.title})}),onDelete:u=>t(u,l)},l)})]})}Qe.propTypes={filterList:h.array.isRequired,onChange:h.func.isRequired,index:h.number.isRequired,column:h.object.isRequired,filterValues:h.array.isRequired,label:h.string.isRequired,renderLabel:h.func.isRequired};function Qe({filterList:n,onChange:s,index:t,column:r,filterValues:o,label:l,renderLabel:b}){return e.jsxs(V,{className:"filter-container",children:[e.jsx(pt,{component:"legend",children:l}),e.jsx(Ke,{row:!0,children:o.map(u=>e.jsx(me,{control:e.jsx(Me,{checked:n[t].indexOf(u.value??u)>-1,onChange:p=>{const i=[...n];p.target.checked?i[t]=[...i[t],u.value??u]:i[t]=i[t].filter(N=>N!==(u.value??u)),s(i[t],t,r)},name:u.value??u}),label:e.jsx("span",{style:{display:"flex",alignItems:"center"},children:b(u)})},u.value??u))})]})}function Be(n){return e.jsx(Qe,{...n,renderLabel:s=>e.jsx(de,{enableTooltip:!1,config:{status:s.status},children:s.label})})}xe.propTypes={status:h.number.isRequired,updatedAt:h.string.isRequired,reason:h.string,channel:h.string,onResend:h.func};function xe({status:n,updatedAt:s,reason:t="",channel:r="wallet",onResend:o}){const{t:l,locale:b}=te(),u=At(l,b,{status:n,updatedAt:s,reason:t,channel:r});return e.jsxs(y,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(de,{config:u,showTitle:!0}),u.status!=="success"&&e.jsx(Fe,{className:"resend-btn",size:"small",startIcon:e.jsx(Ge,{}),sx:{fontSize:12,color:"rgba(0, 0, 0, 0.87)",fontWeight:400,".MuiButton-startIcon":{mr:"2px"}},onClick:o,children:l("notification.resend")})]})}Ze.propTypes={value:h.array.isRequired,onChange:h.func};function Ze({value:n,onChange:s}){const{locale:t}=te(),r=Z().toDate(),[o,l]=v.useState(null),b=v.useCallback(i=>{l(o?null:i.currentTarget)},[o]),u=!!o,p=v.useCallback(i=>{if(!i.startDate||!i.endDate){M.error("Please select a date range");return}if(Z(i.startDate).isAfter(i.endDate)||!Z(i.startDate).isValid()||!Z(i.endDate).isValid()){M.error("Invalid date range");return}s([i.startDate,i.endDate]),l(null)},[s]);return e.jsxs("div",{children:[e.jsx(ee,{component:"div",variant:"h5",color:"textPrimary",style:{fontSize:18,fontWeight:"bold"},sx:{mb:0},children:e.jsxs(Fe,{onClick:b,variant:"outlined",size:"small",color:"inherit",children:[at(n[0],t)," - ",at(n[1],t)]})}),e.jsx(Ue,{open:u,anchorEl:o,onClose:()=>{l(null)},anchorOrigin:{vertical:"bottom",horizontal:"left"},children:e.jsx(jn,{open:!0,maxDate:r,initialDateRange:{startDate:n[0],endDate:n[1]},toggle:b,definedRanges:vn(r),onChange:p})})]})}et.propTypes={itemComponent:h.elementType.isRequired};function et({itemComponent:n,...s}){const{t}=te();return!s?.filterList?.filter(o=>o.length).length?null:e.jsxs(y,{sx:{display:"flex",gap:1,alignItems:"center"},children:[e.jsx("div",{className:"toolbar-filter-title",children:t("notification.filter")}),e.jsx("div",{className:"toolbar-filter-content",children:e.jsx(nn.TableFilterList,{...s,ItemComponent:n})})]})}function tt({label:n,onDelete:s,canDelete:t=()=>!0,...r}){const o=s&&typeof s=="function"?s:void 0;let l=!0;return t&&typeof t=="function"&&(l=t({label:n,...r})),e.jsx(Je,{label:n,variant:"outlined",...o&&l?{onDelete:o}:{}})}tt.propTypes={label:h.string.isRequired,onDelete:h.func,canDelete:h.func};const Mn=[{label:"Wallet",value:"app",checked:!0},{label:"Email",value:"email",checked:!0},{label:"Push Kit",value:"push",checked:!0},{label:"Webhook",value:"webhook",checked:!0}];Pt.propTypes={loading:h.bool,onCancel:h.func,onConfirm:h.func};function Pt({loading:n=!1,onCancel:s=()=>{},onConfirm:t=()=>{}}){const{t:r}=te(),[o,l]=v.useState(Mn),[b,u]=v.useState(!0),p=(N,I)=>{I.checked=N.target.checked;const S=o.map(j=>({...j,checked:j.value===I.value?I.checked:j.checked}));l(S)},i=N=>{N.stopPropagation(),t({channels:o.filter(I=>I.checked).map(I=>I.value),isResendFailedOnly:b})};return e.jsxs(y,{className:"resend-config",sx:{padding:"16px 24px"},children:[e.jsx(ee,{variant:"body1",component:"div",className:"check-title",sx:{fontWeight:700,mb:1},children:r("notification.config")}),e.jsx(y,{className:"choose-channel",children:e.jsxs(V,{component:"fieldset",variant:"standard",children:[e.jsx(pt,{component:"legend",children:r("notification.selectChannels")}),e.jsx(Ke,{sx:{display:"flex",flexDirection:"row",flexWrap:"wrap",gap:1},children:o.map(N=>e.jsx(me,{control:e.jsx(Me,{checked:N.checked,onChange:I=>p(I,N),name:N.value}),label:N.label},N.value))})]})}),e.jsx(y,{className:"resend-config-footer",children:e.jsx(Ke,{children:e.jsx(me,{control:e.jsx(Me,{checked:b,onChange:N=>u(N.target.checked)}),label:r("notification.resendFailedOnly")})})}),e.jsxs(y,{className:"resend-config-footer-tip",sx:{display:"flex",justifyContent:"flex-end",gap:1},children:[e.jsx(Fe,{onClick:N=>{N.stopPropagation(),s()},color:"inherit",children:r("common.cancel")}),e.jsxs(Fe,{onClick:i,color:"primary",disabled:n,variant:"contained",autoFocus:!0,style:{marginLeft:8},children:[n&&e.jsx(ft,{size:16}),r("common.confirm")]})]})]})}Ft.propTypes={notificationId:h.string.isRequired,handleResend:h.func,resending:h.bool};function Ft({notificationId:n,handleResend:s,resending:t=!1}){const{t:r,locale:o}=te(),l=ht(),b=v.useMemo(()=>jt(l,Lt()),[l]),{getReceivers:u,inService:p,teamDid:i,getUser:N,blocklet:I}=Xe(),[S,j]=v.useState(!1),[E,J]=v.useState([]),z=ye({anchorEl:null,position:null}),F=ye({anchorEl:null,position:null}),[B,w]=v.useState(null),[q,K]=v.useState({total:0,pageSize:10,pageCount:0,page:1}),[f,R]=v.useState({searchText:"",page:1,pageSize:10,walletSendStatus:[],pushKitSendStatus:[],emailSendStatus:[],dateRange:[Z().subtract(1,"month").startOf("day").toDate(),Z().endOf("day").toDate()]}),[C,a]=v.useState([]),T=[{label:r("notification.sendStatus.pending"),value:0,status:"pending"},{label:r("notification.sendStatus.success"),value:1,status:"success"},{label:r("notification.sendStatus.failed"),value:2,status:"failed"}],O=async()=>{if(!S&&n)try{j(!0);const c=await u({notificationId:n,...f}),d=c.list.map(m=>({...m,receiverUser:{...m.receiverUser,avatar:It(m.receiverUser.avatar,i,p)}}));J(d),K(c.paging),j(!1)}catch(c){M.error(c.message),j(!1)}};v.useEffect(()=>{O()},[f]);const D=c=>{c.stopPropagation();const d=c.currentTarget;F.anchorEl=d;const m=d.getBoundingClientRect();F.position={top:m.top+window.scrollY,left:m.left+window.scrollX}},re=c=>c.data.length?e.jsx("div",{style:{display:"flex",alignItems:"center",padding:"10px"},children:e.jsx(ce,{className:"resend-btn",size:"small",color:"primary",variant:"contained",startIcon:e.jsx(Ge,{}),sx:{".MuiButton-startIcon":{mr:"2px"}},onClick:D,children:r("notification.resend")})}):null,ue={sort:!1,download:!1,print:!1,selectableRows:"multiple",searchPlaceholder:r("common.search"),searchAlwaysOpen:!1,filterType:"checkbox",searchDebounceTime:300,page:q.page-1,rowsPerPage:q.pageSize,count:q.total,searchText:f.searchText,tableBodyMaxHeight:"calc(80vh - 260px)",rowsSelected:C,onRowSelectionChange:(c,d)=>{a(d.map(m=>m.dataIndex))},customToolbarSelect:re},oe=({page:c,rowsPerPage:d,searchText:m,filterList:A})=>{const[,U=[],ne=[],G=[]]=A;f.pageSize!==d?R(H=>({...H,pageSize:d,page:1})):f.page!==c+1?R(H=>({...H,page:c+1})):f.searchText!==m?R(H=>({...H,searchText:m,page:1})):je(U,f.walletSendStatus)?je(ne,f.pushKitSendStatus)?je(G,f.emailSendStatus)||R(H=>({...H,emailSendStatus:G,page:1})):R(H=>({...H,pushKitSendStatus:ne,page:1})):R(H=>({...H,walletSendStatus:U,page:1}))},pe=v.useCallback(async(c,d)=>{if(!d)return!1;const m=await N(d);return m?c==="wallet"?zn(m):c==="email"?Fn(I,m):c==="pushKit"?_n(I,m):c==="webhook"?Wn(m):!0:!1},[N,I]),we=v.useCallback(c=>Bn(r,c),[r]),fe=()=>{z.anchorEl=null,z.position=null,w(null)},he=()=>{F.anchorEl=null,F.position=null},g=async(c,d,m=!0,A="")=>{if(!(!d.length||!c.length))try{s(c,d,m,A),F.anchorEl||(await Ee(.5),fe())}catch(U){console.error("handleResend error",{error:U})}},x=async({channels:c,isResendFailedOnly:d})=>{const m=C.map(A=>E[A].receiver);await g(c,m,d),await Ee(.5),he(),a([])},k=async(c,d=[],m=!0)=>{try{await g(["webhook"],[c.receiver],m,d)}catch(A){M.error(A.response?A.response.statusText:A.message)}},L=async(c,d,m,A=[],U=!0)=>{if(c.stopPropagation(),qn(d,m)>=4){M.warning(r("notification.resendLimit"));return}if(!Ve.includes(m)){await k(d,A,U);return}if(c){const G=c.currentTarget,H=G.getBoundingClientRect();z.anchorEl=G,z.position={top:H.top+window.scrollY,left:H.left+window.scrollX}}w({channel:m});try{const G=await pe(m,d.receiver);await Ee(1),w({channel:m,result:G}),(typeof G=="boolean"&&G||Zt(G)&&Object.values(G).every(H=>!!H))&&(await s([m],[d.receiver],U),F.anchorEl||(await Ee(.5),fe()))}catch(G){M.error(G.message)}},W=c=>{R(d=>({...d,dateRange:c,page:1}))},P=(c,d,m,A)=>{c.stopPropagation();const U=m.filter(ne=>ne!==d);R(ne=>({...ne,[A]:U,page:1}))},ie=se(()=>[{label:r("notification.receiver"),name:"receiver",width:200,options:{filter:!1,customBodyRenderLite:c=>{const{receiverUser:d,receiver:m}=E[c];return d?e.jsxs(y,{"data-cy":`member-name-${d.fullName}`,sx:{display:"flex",alignItems:"center",gap:1,justifyContent:"flex-start"},children:[e.jsx(vt,{src:`${d.avatar}?imageFilter=resize&w=48&h=48`,size:32,did:m,shape:"circle",style:{borderRadius:"100%",overflow:"hidden"}}),e.jsx(Se,{children:d.fullName})]},m):e.jsx(bn,{size:14,responsive:!1,compact:!0,copyable:!1,did:m})}}},{label:"Wallet",name:"walletSendStatus",width:200,options:{setCellProps:()=>({className:"sent-status-cell"}),filter:!0,filterType:"custom",filterList:f.walletSendStatus??[],customFilterListOptions:{render:c=>e.jsx(Le,{list:c,label:"Wallet",onDelete:(d,m)=>{d.stopPropagation(),P(d,m,ie[1].options.filterList,"walletSendStatus")}}),update:Oe},filterOptions:{names:T,fullWidth:!0,logic:De,display:(c,d,m,A)=>e.jsx(Be,{label:"Wallet",filterList:c,onChange:d,index:m,column:A,filterValues:T})},customBodyRenderLite:c=>{const{walletSendStatus:d,walletSendAt:m,walletSendFailedReason:A}=E[c];return e.jsx(xe,{status:d,updatedAt:m,reason:A,channel:"wallet",onResend:U=>L(U,E[c],"wallet",[],!1)})}}},{label:"Push Kit",name:"pushKitSendStatus",width:200,options:{setCellProps:()=>({className:"sent-status-cell"}),customBodyRenderLite:c=>{const{pushKitSendStatus:d,pushKitSendAt:m,pushKitSendFailedReason:A}=E[c];return e.jsx(xe,{status:d,updatedAt:m,reason:A,channel:"pushkit",onResend:U=>L(U,E[c],"pushKit",[],!1)})},filter:!0,filterType:"custom",filterList:f.pushKitSendStatus??[],customFilterListOptions:{render:c=>e.jsx(Le,{list:c,label:"Push Kit",onDelete:(d,m)=>{d.stopPropagation(),P(d,m,ie[2].options.filterList,"pushKitSendStatus")}}),update:Oe},filterOptions:{names:T,fullWidth:!0,logic:De,display:(c,d,m,A)=>e.jsx(Be,{label:"Push Kit",filterList:c,onChange:d,index:m,column:A,filterValues:T})}}},{label:"Email",name:"emailSendStatus",width:200,options:{setCellProps:()=>({className:"sent-status-cell"}),customBodyRenderLite:c=>{const{emailSendStatus:d,emailSendAt:m,emailSendFailedReason:A}=E[c];return e.jsx(xe,{status:d,updatedAt:m,reason:A,channel:"email",onResend:U=>L(U,E[c],"email",[],!1)})},filter:!0,filterType:"custom",filterList:f.emailSendStatus??[],customFilterListOptions:{render:c=>e.jsx(Le,{list:c,label:"Email",onDelete:(d,m)=>{d.stopPropagation(),P(d,m,ie[3].options.filterList,"emailSendStatus")}}),update:Oe},filterOptions:{names:T,fullWidth:!0,logic:De,display:(c,d,m,A)=>e.jsx(Be,{label:"Email",filterList:c,onChange:d,index:m,column:A,filterValues:T})}}},{label:"Webhook",name:"webhook",width:200,options:{filter:!1,setCellProps:()=>({className:"sent-status-cell"}),customBodyRenderLite:c=>{const{webhook:d}=E[c];if(!d)return null;const m=Object.entries(d)[0];if(!m)return null;const[A,U]=m,ne=U[0];return e.jsx(y,{sx:{display:"flex",flexDirection:"column",gap:1},children:e.jsxs(y,{className:"webhook-item",sx:{fontSize:12},children:[e.jsx(Se,{maxLength:30,children:A},A),e.jsx(xe,{status:ne.status,updatedAt:ne.sendAt,reason:ne.failedReason,channel:"webhook",onResend:G=>L(G,E[c],"webhook",[A],!1)})]},A)})}}},{label:r("common.createdAt"),name:"createdAt",width:100,options:{filter:!1,customBodyRenderLite:c=>{const{createdAt:d}=E[c];return e.jsx(Nt,{value:d,locale:o,shouldUpdate:!0})}}}],[E,o,f,r]),Re=[e.jsx(Ze,{value:f.dateRange,onChange:W},"date-picker"),e.jsx(ce,{variant:"contained",size:"small",color:"primary",loading:S,startIcon:e.jsx(Kt,{}),onClick:()=>O(),sx:{".MuiButton-startIcon":{mr:"2px"}},style:{marginLeft:8},children:r("common.refresh")},"refresh")];return e.jsx(y,{sx:{overflow:"auto",".MuiTableCell-head":{whiteSpace:"nowrap",fontWeight:"bold"},".MuiTableCell-root":{paddingRight:"8px",whiteSpace:"nowrap"}},children:e.jsx(Hn,{children:e.jsxs(xt,{theme:b,children:[e.jsx(yt,{className:"receivers-table",locale:o,loading:S,columns:ie,data:E,onChange:oe,options:ue,customButtons:Re,components:{TableFilterList:c=>e.jsx(et,{...c,itemComponent:d=>e.jsx(tt,{...d,canDelete:()=>!1})})}}),z.anchorEl&&e.jsx(Ue,{open:!!z.anchorEl,anchorReference:"anchorPosition",anchorPosition:z.position,onClose:fe,anchorOrigin:{vertical:"center",horizontal:"right"},transformOrigin:{vertical:"center",horizontal:"left"},children:e.jsxs($n,{children:[e.jsxs(ee,{variant:"body1",component:"div",className:"check-title",children:[B?.channel," Checking"]}),e.jsx(y,{sx:{display:"flex",flexDirection:"column",gap:"4px"},children:we(B?.channel).map(c=>{const{type:d,pass:m,fail:A}=c;return!B?.result||B?.result?.[d]?e.jsxs(ee,{variant:"body1",component:"div",className:"check-item",sx:{display:"flex",alignItems:"center",gap:"4px",color:B?.result?.[d]?Ae.success.main:"inherit"},children:[B?.result?e.jsx(Mt,{}):e.jsx(ft,{size:12,sx:{color:Ae.primary.main}}),e.jsx("span",{children:m})]},d):e.jsxs(ee,{variant:"body1",component:"div",className:"check-item",sx:{display:"flex",alignItems:"center",gap:"4px",color:Ae.error.main},children:[e.jsx(Ut,{}),e.jsx("span",{children:A})]},d)})})]})}),F.anchorEl&&e.jsx(Ue,{open:!!F.anchorEl,anchorReference:"anchorPosition",anchorPosition:F.position,onClose:he,anchorOrigin:{vertical:"center",horizontal:"right"},transformOrigin:{vertical:"center",horizontal:"left"},children:e.jsx(Pt,{loading:t,onCancel:he,onConfirm:x})})]})})})}const Un=v.memo(Ft),Hn=ae.div`
1
+ import{g as Wt,r as v}from"./vendor-react-Dvs43sk9.js";import{j as e,ak as y,z as Q,b6 as me,bg as qe,y as V,am as ut,d2 as Bt,bn as qt,at as ae,b1 as mt,W as h,T as ee,U as Je,d3 as pt,b5 as Ke,a5 as Me,Q as Fe,d4 as Ge,aN as Ue,a6 as ft,D as ht,d5 as Kt,ad as xt,d6 as Mt,d7 as Ut,c2 as st,n as Ht,x as $t,bc as Vt,M as it,cw as Jt,I as Gt,d8 as Yt}from"./vendor-mui-core-DRxbhqaK.js";import{A as gt,J as Xt,C as Qt,e as le,F as Zt,a3 as je}from"./vendor-utils-CUDP56Ff.js";import{T as te,H as M,n as ce,c as en,p as bt,a3 as tn,au as nn,m as jt,$ as vt,j as yt,av as Ae,b as St,I as sn,a0 as an}from"./vendor-ux-B9VfuZTg.js";import{aD as rn,X as Ye,a9 as Ct,aW as wt,J as _e,c as _,_ as Z,o as on,aL as at}from"./index-Dt8akALo.js";import{g as ye,b as $,a as se}from"./vendor-hooks-BlA8TRnZ.js";import{u as Rt,C as Y}from"./index.esm-JPZAjt0x.js";import{i as He}from"./isURL-B2kErAOg.js";import{S as X}from"./section-ZPKr6_ii.js";import{A as ln,a as cn,b as dn}from"./collapse-DJGzUM1Q.js";import{S as Se}from"./shorten-label-DVy6K5I7.js";import{v as Tt}from"./index-Ba9-ArMT.js";import{R as Nt,A as un,S as mn,a as pn,B as fn}from"./list-aRu0R0L1.js";import{j as hn,c as xn,N as gn}from"./team-s6q3vfNx.js";import{W as bn}from"./did-address-DnFNwELW.js";import{p as It}from"./util-DDkRAi85.js";import{D as jn,g as vn}from"./traffic-CwvEJLQW.js";import{B as Et}from"./bundle-avatar-D5n6XSFF.js";import{u as yn}from"./use-mobile-BQQpAf3i.js";import"./lottie-web-4koyQiv_.js";import"./vendor-arcblock-DeeG8u0h.js";import"./required-BT8zXV8U.js";import"./server-logo-notext.svg-CKQB0tIp.js";import"./index-BFBoLr1Z.js";import"./session-Y3RU3I2O.js";import"./use-app-logo-BjReZUm7.js";import"./base32-BK7MXAD4.js";import"./useAsyncRetry-EEjDgDMR.js";import"./useAsync-DVtDVEv6.js";import"./iframe-CKOcsJB-.js";import"./index-B6gW9Yjq.js";import"./index-DBs9Ljax.js";import"./base-chart-UFWO9a3P.js";import"./index-3ePiAFIp.js";import"./vendor-mui-x-Qp6zkx78.js";import"./AdapterDayjs-Bp0ir26R.js";var Te={exports:{}},Ne={exports:{}},Ie={exports:{}},rt;function Sn(){return rt||(rt=1,function(n,s){Object.defineProperty(s,"__esModule",{value:!0}),s.default=t;function t(r){return r==null}n.exports=s.default,n.exports.default=s.default}(Ie,Ie.exports)),Ie.exports}var ot;function Cn(){return ot||(ot=1,function(n,s){Object.defineProperty(s,"__esModule",{value:!0}),s.default=u;var t=o(rn()),r=o(Sn());function o(p){return p&&p.__esModule?p:{default:p}}var l=/^(?:[-+]?(?:0|[1-9][0-9]*))$/,b=/^[-+]?[0-9]+$/;function u(p,i){(0,t.default)(p),i=i||{};var N=i.allow_leading_zeroes===!1?l:b,I=!i.hasOwnProperty("min")||(0,r.default)(i.min)||p>=i.min,S=!i.hasOwnProperty("max")||(0,r.default)(i.max)||p<=i.max,j=!i.hasOwnProperty("lt")||(0,r.default)(i.lt)||p<i.lt,E=!i.hasOwnProperty("gt")||(0,r.default)(i.gt)||p>i.gt;return N.test(p)&&I&&S&&j&&E}n.exports=s.default,n.exports.default=s.default}(Ne,Ne.exports)),Ne.exports}var lt;function wn(){return lt||(lt=1,function(n,s){Object.defineProperty(s,"__esModule",{value:!0}),s.default=o;var t=r(Cn());function r(l){return l&&l.__esModule?l:{default:l}}function o(l){return(0,t.default)(l,{allow_leading_zeroes:!1,min:0,max:65535})}n.exports=s.default,n.exports.default=s.default}(Te,Te.exports)),Te.exports}var Rn=wn();const Tn=Wt(Rn),ze={enabled:!1,secure:!1,from:"",host:"",port:"",user:"",password:"",companyName:"",companyLink:"",companyAddress:"",supportEmail:""};function Nn(){const{api:n}=Ye(),{blocklet:s}=Ct(),{t}=te(),{confirmApi:r,confirmHolder:o}=wt(),l=s?.meta?.did,b=Object.assign({...ze},s?.settings?.notification?.email||{}),{handleSubmit:u,control:p,formState:i,watch:N,reset:I}=Rt({defaultValues:gt(b,Object.keys(ze))}),S=ye({testReceiver:"",testReceiverError:""}),j=N("enabled"),E=$(async(a,T,O=!0)=>{try{const{blocklet:D}=await n.configNotification({input:{did:l,notification:JSON.stringify({email:a})}}),re=Object.assign({...ze},D?.settings?.notification?.email||{});I(re),O&&M.success(t("oauth.saveSuccess"))}catch(D){if(O)M.error(D.message||t("oauth.saveFailed"));else throw D}}),J=$(async(a,T,O)=>{try{i.isDirty&&await E(a,T,!1),await n.sendEmail({input:{did:l,receiver:O,email:JSON.stringify({body:"Your SMTP configuration is correct!",title:"Test email",type:"notification",attachments:[{type:"link",data:{url:"https://community.arcblock.io",title:"Community",image:"https://community.arcblock.io/.well-known/service/blocklet/logo-rect-dark",utm:{campaign:"test-campaign"}}}],utm:{content:"test-email-button"}})}}),M.success(t("notification.email.testSuccess"))}catch(D){M.error(D.message||t("notification.email.testfailed"))}}),z=$((a,T)=>{S.testReceiver=localStorage.getItem("test-receiver")||"",S.testReceiverError="",r.open({title:t("notification.email.testSendEmail"),content:()=>e.jsx(y,{sx:{width:"300px"},children:e.jsx(Q,{sx:{mt:1},fullWidth:!0,name:"testReceiver",label:t("notification.email.inputTestReceiver"),value:S.testReceiver,onChange:O=>{S.testReceiver=O.target.value},error:!!S.testReceiverError,helperText:S.testReceiverError||" "})}),confirmButtonText:t("common.confirm"),cancelButtonText:t("common.cancel"),async onConfirm(O){const D=S.testReceiver?.trim();if(!D){S.testReceiverError=t("notification.email.receiverRequired");return}if(!_e(D)){S.testReceiverError=t("notification.email.receiverInvalid");return}S.testReceiverError="",await J(a,T,D),O()}})}),F=$(a=>{const T=a?.trim();return T?_e(T)?!0:t("notification.email.fromInvalid"):t("notification.email.fromRequired")}),B=$(a=>{const T=a?.trim();return T?He(T,{require_host:!1,protocols:[]})?!0:t("notification.email.hostInvalid"):t("notification.email.hostRequired")}),w=$(a=>a?Tn(a)?!0:t("notification.email.portInvalid"):t("notification.email.portRequired")),q=$(a=>a?.trim()?!0:t("notification.email.userRequired")),K=$(a=>a?.trim()?!0:t("notification.email.passwordRequired")),f=$(a=>a?.trim()&&!He(a,{protocols:["http","https"],require_protocol:!0})?t("notification.email.linkInvalid"):!0),R=$(a=>a?.trim()&&!_e(a)?t("notification.email.emailInvalid"):!0),C=$(()=>!0);return e.jsxs(y,{children:[e.jsxs(In,{component:"form",onSubmit:u(E),disabled:!0,sx:{".section-left":{width:"160px"}},children:[e.jsx(X,{title:t("notification.email.enable"),my:2.5,children:e.jsx(Y,{name:"enabled",control:p,render:({field:a})=>e.jsx(me,{control:e.jsx(qe,{checked:a.value,...a})})})}),e.jsx(X,{title:t("notification.email.from"),children:e.jsx(Y,{name:"from",control:p,rules:{validate:j?F:C},render:({field:a})=>e.jsx(V,{fullWidth:!0,children:e.jsx(Q,{...a,size:"small",required:!0,label:t("notification.email.from"),error:!!i.errors[a.name],helperText:i.errors[a.name]?.message||" ",disabled:!j})})})}),e.jsx(X,{title:t("notification.email.host"),children:e.jsx(Y,{name:"host",control:p,rules:{validate:j?B:C},render:({field:a})=>e.jsx(V,{fullWidth:!0,children:e.jsx(Q,{...a,size:"small",required:!0,error:!!i.errors[a.name],label:t("notification.email.host"),helperText:i.errors[a.name]?.message||" ",disabled:!j})})})}),e.jsx(X,{title:t("notification.email.port"),children:e.jsx(Y,{name:"port",control:p,rules:{validate:j?w:C},render:({field:a})=>e.jsx(V,{fullWidth:!0,children:e.jsx(Q,{...a,size:"small",required:!0,type:"number",error:!!i.errors[a.name],label:t("notification.email.port"),helperText:i.errors[a.name]?.message||" ",disabled:!j})})})}),e.jsx(X,{title:t("notification.email.user"),children:e.jsx(Y,{name:"user",control:p,rules:{validate:j?q:C},render:({field:a})=>e.jsx(V,{fullWidth:!0,children:e.jsx(Q,{...a,size:"small",required:!0,error:!!i.errors[a.name],label:t("notification.email.user"),helperText:i.errors[a.name]?.message||" ",disabled:!j})})})}),e.jsx(X,{title:t("notification.email.password"),children:e.jsx(Y,{name:"password",control:p,rules:{validate:j?K:C},render:({field:a})=>e.jsx(V,{fullWidth:!0,children:e.jsx(Q,{...a,size:"small",required:!0,type:"password",error:!!i.errors[a.name],label:t("notification.email.password"),helperText:i.errors[a.name]?.message||" ",disabled:!j})})})}),e.jsx(X,{title:t("notification.email.secure"),children:e.jsx(Y,{name:"secure",control:p,rules:{validate:C},render:({field:a})=>e.jsx(V,{fullWidth:!0,children:e.jsx(me,{control:e.jsx(qe,{checked:a.value,...a,disabled:!j})})})})}),e.jsxs(ln,{children:[e.jsxs(cn,{expandIcon:e.jsx(qt,{fontSize:"small"}),"aria-controls":"panel1-content",id:"panel1-header",children:[t("notification.email.signature"),e.jsx(ut,{title:t("notification.email.signatureTooltip"),children:e.jsx(Bt,{fontSize:"small",sx:{ml:1,cursor:"help"}})})]}),e.jsxs(dn,{children:[e.jsx(X,{title:t("notification.email.companyName"),children:e.jsx(Y,{name:"companyName",control:p,rules:{validate:C},render:({field:a})=>e.jsx(V,{fullWidth:!0,children:e.jsx(Q,{...a,size:"small",error:!!i.errors[a.name],label:t("notification.email.companyName"),helperText:i.errors[a.name]?.message||" ",disabled:!j})})})}),e.jsx(X,{title:t("notification.email.companyLink"),children:e.jsx(Y,{name:"companyLink",control:p,rules:{validate:j?f:C},render:({field:a})=>e.jsx(V,{fullWidth:!0,children:e.jsx(Q,{...a,size:"small",error:!!i.errors[a.name],label:t("notification.email.companyLink"),helperText:i.errors[a.name]?.message||" ",disabled:!j})})})}),e.jsx(X,{title:t("notification.email.companyAddress"),children:e.jsx(Y,{name:"companyAddress",control:p,rules:{validate:C},render:({field:a})=>e.jsx(V,{fullWidth:!0,children:e.jsx(Q,{...a,size:"small",error:!!i.errors[a.name],label:t("notification.email.companyAddress"),helperText:i.errors[a.name]?.message||" ",disabled:!j})})})}),e.jsx(X,{title:t("notification.email.supportEmail"),children:e.jsx(Y,{name:"supportEmail",control:p,rules:{validate:j?R:C},render:({field:a})=>e.jsx(V,{fullWidth:!0,children:e.jsx(Q,{...a,size:"small",type:"email",error:!!i.errors[a.name],label:t("notification.email.supportEmail"),helperText:i.errors[a.name]?.message||" ",disabled:!j})})})})]})]}),e.jsxs(y,{sx:{display:"flex",justifyContent:"flex-end",gap:2,mt:3},children:[e.jsx(ce,{variant:"outlined",color:"warning",onClick:u(z),disabled:!j,children:t("oauth.runTest")}),e.jsx(ce,{type:"submit",variant:"contained",disabled:!i.isDirty,children:t("oauth.save")})]})]}),o]})}const In=ae(mt)``,We={enabled:!1,endpoint:"",did:void 0,pushPath:void 0};function En(){const{api:n}=Ye(),{blocklet:s}=Ct(),{t}=te(),{confirmApi:r,confirmHolder:o}=wt(),l=s?.meta?.did,b=Object.assign({...We},s?.settings?.notification?.pushKit||{}),{handleSubmit:u,control:p,formState:i,watch:N,reset:I}=Rt({defaultValues:gt(b,Object.keys(We))}),S=ye({testReceiver:"",testReceiverError:""}),j=N("enabled"),E=$(async(w,q,K=!0)=>{try{const{blocklet:f}=await n.configNotification({input:{did:l,notification:JSON.stringify({pushKit:w})}}),R=Object.assign({...We},f?.settings?.notification?.pushKit||{});I(R),K&&M.success(t("oauth.saveSuccess"))}catch(f){if(K)M.error(f.message||t("oauth.saveFailed"));else throw f}}),J=$(async(w,q)=>{try{i.isDirty&&await E(w,q,!1);const K=(s?.configs||[]).find(C=>C.key==="BLOCKLET_APP_URL")?.value,f=Xt(Qt(K,_.WELLKNOWN_SERVICE_PATH_PREFIX,"/blocklet/logo"),{v:s?.meta?.version,t:new Date(s?.updatedAt||0).getTime()}),R={type:"passthrough",passthroughType:"messageStatus",data:{message:{title:"Test push-kit notification",body:"This is message from push-kit config test",sender:{did:s?.appDid,fullName:s?.meta?.title,avatar:f}}}};await n.sendPush({input:{did:l,receiver:S.testReceiver,notification:JSON.stringify(R)}}),M.success(t("notification.pushKit.testSuccess"))}catch(K){M.error(K.message||t("notification.pushKit.testfailed"))}}),z=$((w,q)=>{S.testReceiverError="",r.open({title:t("notification.pushKit.testSend"),content:()=>e.jsx(y,{sx:{width:"450px",maxWidth:"100%"},children:e.jsx(Q,{sx:{mt:1},fullWidth:!0,name:"testReceiver",label:t("notification.pushKit.inputTestReceiver"),value:S.testReceiver,onChange:K=>{S.testReceiver=K.target.value},error:!!S.testReceiverError,helperText:S.testReceiverError||" "})}),confirmButtonText:t("common.confirm"),cancelButtonText:t("common.cancel"),async onConfirm(K){if(!S.testReceiver?.trim()){S.testReceiverError=t("notification.pushKit.receiverRequired");return}S.testReceiverError="",await J(w,q),K()}})}),F=$(w=>{const q=w?.trim();return q?He(q)?!0:t("notification.pushKit.endpointInvalid"):t("notification.pushKit.endpointRequired")}),B=$(()=>!0);return e.jsxs(y,{children:[e.jsxs(kn,{component:"form",onSubmit:u(E),disabled:!0,sx:{".section-left":{width:"160px"}},children:[e.jsx(X,{title:t("notification.pushKit.enable"),my:2.5,children:e.jsx(Y,{name:"enabled",control:p,render:({field:w})=>e.jsx(me,{control:e.jsx(qe,{checked:w.value,...w})})})}),e.jsx(X,{title:t("notification.pushKit.endpoint"),children:e.jsx(Y,{name:"endpoint",control:p,rules:{validate:j?F:B},render:({field:w})=>e.jsx(V,{fullWidth:!0,children:e.jsx(Q,{...w,size:"small",required:!0,label:t("notification.pushKit.endpoint"),error:!!i.errors[w.name],helperText:i.errors[w.name]?.message||" ",disabled:!j})})})}),e.jsxs(X,{title:t("notification.pushKit.customOptions"),children:[e.jsx(Y,{name:"did",control:p,render:({field:w})=>e.jsx(V,{fullWidth:!0,children:e.jsx(Q,{...w,size:"small",label:t("notification.pushKit.did"),error:!!i.errors[w.name],helperText:i.errors[w.name]?.message||" ",disabled:!j})})}),e.jsx(Y,{name:"pushPath",control:p,render:({field:w})=>e.jsx(V,{fullWidth:!0,children:e.jsx(Q,{...w,size:"small",label:t("notification.pushKit.pushPath"),error:!!i.errors[w.name],helperText:i.errors[w.name]?.message||" ",disabled:!j})})})]}),e.jsxs(y,{sx:{display:"flex",justifyContent:"flex-end",gap:2,mt:3},children:[e.jsx(ce,{variant:"outlined",color:"warning",onClick:u(z),disabled:!j,children:t("oauth.runTest")}),e.jsx(ce,{type:"submit",variant:"contained",disabled:!i.isDirty,children:t("oauth.save")})]})]}),o]})}const kn=ae(mt)``,ct=[{label:e.jsx(y,{sx:{textAlign:"center",width:"100%"},children:"Email"}),value:"email"},{label:e.jsx(y,{sx:{textAlign:"center",width:"100%"},children:"Push Kit"}),value:"pushKit"}];function An(){const[n,s]=v.useState(ct[0].value),{locale:t}=v.useContext(en),r=se(()=>({email:e.jsx(Nn,{}),pushKit:e.jsx(En,{})}),[t]),o=v.useMemo(()=>({padding:"10px 0"}),[]);return e.jsxs(y,{children:[e.jsx(bt,{tabs:ct,current:n,onChange:s}),e.jsx(y,{style:o,children:r[n]})]})}const kt=v.createContext({}),{Provider:On,Consumer:Ws}=kt;function Dn({children:n,blocklet:s=""}){const{api:t,inService:r,ws:{useSubscription:o}}=Ye(),[l,b]=v.useState([]),[u,p]=v.useState({total:0,pageSize:20,pageCount:0,page:1}),i=se(()=>s.meta?.did,[s]),[N,I]=v.useState([]),[S,j]=v.useState({}),E=se(()=>l.length?new Set(l.map(f=>f.id)):new Set,[l]),J=async({page:f=1,pageSize:R=20,...C}={})=>{if(!i)return[];try{const a={paging:{page:f,pageSize:R},...C,teamDid:i,dateRange:C.dateRange?[Z(C.dateRange[0]).toISOString(),Z(C.dateRange[1]).toISOString()]:void 0},{dids:T,...O}=a;let D="";T&&T.includes("system")&&(D="system");const re=T?T.filter(pe=>pe!=="system"):[],ue={...O,source:D,componentDids:re},oe=await t.getNotificationSendLog({input:ue});return j(ue),b(oe.list),p(oe.paging),oe.list}catch(a){return M.error(a.message),[]}},z=async()=>{const f=await t.getNotificationComponents({input:{teamDid:i}});I(f.componentDids)},F=v.useCallback(f=>{const R=s.children.find(C=>C.meta?.did===f);if(R)return R.ancestors=[s],R},[s]),B=async({notificationId:f,receivers:R,channels:C,...a})=>{await t.resendNotification({input:{teamDid:i,notificationId:f,receivers:R,channels:C.map(T=>T==="wallet"?_.NOTIFICATION_SEND_CHANNEL.WALLET:T==="pushKit"?_.NOTIFICATION_SEND_CHANNEL.PUSH:T),...a}})},w=v.useCallback(async f=>(await t.getUser({input:{teamDid:i,user:{did:f},options:{enableConnectedAccount:!0}}})).user,[t,i]),q=v.useCallback(async({page:f=1,pageSize:R=20,...C}={})=>{try{const a={paging:{page:f,pageSize:R},...C,userName:C.searchText||"",teamDid:i,dateRange:C.dateRange?[Z(C.dateRange[0]).toISOString(),Z(C.dateRange[1]).toISOString()]:void 0};return await t.getReceivers({input:a})}catch(a){throw M.error(a.message),a}},[t,i]);v.useEffect(()=>{i&&z()},[i]),o(_.EVENTS.NOTIFICATION_BLOCKLET_UPDATE,f=>{E.has(f.notificationId)&&J(S)},[E,S]),o(_.EVENTS.NOTIFICATION_BLOCKLET_CREATE,f=>{E.has(f.id)||J(S)},[E,S]);const K={fetch:J,data:l,paging:u,blocklet:s,getComponent:F,resendNotification:B,getUser:w,componentDids:N,getReceivers:q,inService:r,teamDid:i};return e.jsx(On,{value:{notificationRecords:K},children:n})}function Xe(){const{notificationRecords:n}=v.useContext(kt);return n}Ce.propTypes={severity:h.oneOf(Object.values(["info","success","error","warning"])).isRequired};const Ln={info:"primary",success:"success",error:"error",warning:"warning"};function Ce({severity:n="info"}){return e.jsx(tn,{type:Ln[n],children:n})}const Pn=(n,s,t="")=>{if(!t||!s)return"";switch(t){case _.NOTIFICATION_SEND_FAILED_REASON.USER_DISABLED:return n("notification.sendStatus.reason.disabled",{channel:s});case _.NOTIFICATION_SEND_FAILED_REASON.CHANNEL_UNAVAILABLE:return n("notification.sendStatus.reason.unavailable",{channel:s});case _.NOTIFICATION_SEND_FAILED_REASON.CHANNEL_DISABLED:return n("notification.sendStatus.reason.notSent",{channel:s});case _.NOTIFICATION_SEND_FAILED_REASON.NOT_ONLINE:return n("notification.sendStatus.reason.offline");default:return t}};function At(n,s,t={}){const{status:r,updatedAt:o,reason:l="",channel:b="wallet"}=t,u=o?n("notification.sendStatus.sentTime",{date:on(o,s)}):"",p=Pn(n,b,l);return r===_.NOTIFICATION_SEND_STATUS.FAILED?{status:"failed",title:n("notification.sendStatus.failed"),sentTime:u,reason:p}:r===_.NOTIFICATION_SEND_STATUS.SENT?{status:"success",title:n("notification.sendStatus.success"),sentTime:u}:{status:"pending",title:n("notification.sendStatus.pending"),reason:p,sentTime:u}}const $e={pending:"#aaaaaa",success:"#34BE74",failed:"#D0021B"},Ve=["wallet","pushKit","email"],dt=["info","success","error","warning"],Ot=n=>{const{settings:s}=n;return s?.notification?.email?.enabled},Dt=n=>{const{settings:s}=n;return s?.notification?.pushKit?.enabled},Fn=(n,s)=>{const t=le(s,"extra.notifications.email",!0);return{available:Ot(n),enabled:t}},_n=(n,s)=>{const t=le(s,"extra.notifications.push",!0);return{available:Dt(n),enabled:t}},zn=n=>({enabled:le(n,"extra.notifications.wallet",!0)}),Wn=n=>({enabled:le(n,"extra.webhooks",[]).length>0}),Ee=(n=3)=>new Promise(s=>{setTimeout(()=>{s()},n*1e3)}),Bn=(n,s)=>s==="wallet"||s==="webhook"?[{channel:s,type:"enabled",pass:n("notification.sendStatus.reason.enabled",{channel:s}),fail:n("notification.sendStatus.reason.disabled",{channel:s})}]:s==="pushKit"||s==="email"?[{channel:s,type:"available",pass:n("notification.sendStatus.reason.available",{channel:s}),fail:n("notification.sendStatus.reason.unavailable",{channel:s})},{channel:s,type:"enabled",pass:n("notification.sendStatus.reason.enabled",{channel:s}),fail:n("notification.sendStatus.reason.disabled",{channel:s})}]:[],ke=(n=[])=>{const s=Z().startOf("day");return n.filter(t=>Z(t.sendAt).isSame(s,"day")).length},qn=(n,s="")=>{if(s&&Ve.includes(s)){const l=`${s}SendRecord`,b=le(n,l,[]);return ke(b)}const t=le(n,"webhook",{}),r=Object.keys(t??{})??[];if(s&&r.includes(s)){const l=t[s]??[];return ke(l)}const o={};return Ve.forEach(l=>{const b=`${l}SendRecord`,u=le(n,b,[]),p=ke(u);o[l]=p}),r.length>0&&r.forEach(l=>{const b=t[l]??[],u=ke(b);o[l]=u}),o},Oe=(n,s,t)=>{if(!Array.isArray(n))throw new Error("Invalid filterList or index");return n[t].splice(s,1),n},De=(n,s)=>{if(!Array.isArray(s))throw new Error("filters must be an array");return s.length?!s.includes(n):!1},Kn=n=>{switch(n){case _.NOTIFICATION_SEND_CHANNEL.WALLET:return"Wallet";case _.NOTIFICATION_SEND_CHANNEL.PUSH:return"Push Kit";case _.NOTIFICATION_SEND_CHANNEL.EMAIL:return"Email";case _.NOTIFICATION_SEND_CHANNEL.WEBHOOK:return"Webhook";default:return""}},Lt=()=>({components:{MUIDataTableFilter:{styleOverrides:{header:{marginBottom:0,p:{margin:0}},root:{"& .MuiGrid-container":{marginTop:0,"& .MuiGrid-item":{paddingTop:0}}}}},MuiPopover:{styleOverrides:{root:{"&.MuiPopover-root":{"& .MuiPaper-root:has(.filter-container)":{width:"420px"}}}}}}});function de({config:n,enableTooltip:s=!0,showTitle:t=!1,children:r=null}){const{status:o,title:l="",sentTime:b="",reason:u=""}=n,p=[l,u].filter(Boolean).join(", ");return e.jsx(ut,{title:s?e.jsxs(e.Fragment,{children:[e.jsx(ee,{color:"inherit",sx:{fontSize:12},children:p}),e.jsx("span",{children:b})]}):null,arrow:!0,placement:"top",children:e.jsxs(y,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"4px"},children:[e.jsxs(y,{sx:{position:"relative",minHeight:14,minWidth:14,display:"flex",alignItems:"center",justifyContent:"center"},children:[e.jsx(y,{style:{opacity:.15},sx:{position:"absolute",width:"100%",height:"100%",borderRadius:"50%",bgcolor:$e[o]}}),e.jsx(y,{sx:{position:"absolute",width:"55%",height:"55%",borderRadius:"50%",bgcolor:$e[o]}})]}),e.jsx(ee,{color:"inherit",sx:{fontSize:12},children:t?l:r})]})})}de.propTypes={config:h.object.isRequired,enableTooltip:h.bool,showTitle:h.bool,children:h.node};Le.propTypes={list:h.array.isRequired,label:h.string.isRequired,onDelete:h.func};function Le({list:n,label:s,onDelete:t=()=>{}}){const{t:r,locale:o}=te();return e.jsxs(y,{sx:{display:"flex",gap:1,alignItems:"center"},children:[e.jsxs(ee,{children:[s,": "]}),n.map(l=>{const b=At(r,o,{status:l});return e.jsx(Je,{size:"small",label:e.jsx(y,{sx:{display:"flex",alignItems:"center",gap:"4px"},children:e.jsx(de,{config:b,enableTooltip:!1,children:b.title})}),onDelete:u=>t(u,l)},l)})]})}Qe.propTypes={filterList:h.array.isRequired,onChange:h.func.isRequired,index:h.number.isRequired,column:h.object.isRequired,filterValues:h.array.isRequired,label:h.string.isRequired,renderLabel:h.func.isRequired};function Qe({filterList:n,onChange:s,index:t,column:r,filterValues:o,label:l,renderLabel:b}){return e.jsxs(V,{className:"filter-container",children:[e.jsx(pt,{component:"legend",children:l}),e.jsx(Ke,{row:!0,children:o.map(u=>e.jsx(me,{control:e.jsx(Me,{checked:n[t].indexOf(u.value??u)>-1,onChange:p=>{const i=[...n];p.target.checked?i[t]=[...i[t],u.value??u]:i[t]=i[t].filter(N=>N!==(u.value??u)),s(i[t],t,r)},name:u.value??u}),label:e.jsx("span",{style:{display:"flex",alignItems:"center"},children:b(u)})},u.value??u))})]})}function Be(n){return e.jsx(Qe,{...n,renderLabel:s=>e.jsx(de,{enableTooltip:!1,config:{status:s.status},children:s.label})})}xe.propTypes={status:h.number.isRequired,updatedAt:h.string.isRequired,reason:h.string,channel:h.string,onResend:h.func};function xe({status:n,updatedAt:s,reason:t="",channel:r="wallet",onResend:o}){const{t:l,locale:b}=te(),u=At(l,b,{status:n,updatedAt:s,reason:t,channel:r});return e.jsxs(y,{sx:{display:"flex",alignItems:"center",gap:1},children:[e.jsx(de,{config:u,showTitle:!0}),u.status!=="success"&&e.jsx(Fe,{className:"resend-btn",size:"small",startIcon:e.jsx(Ge,{}),sx:{fontSize:12,color:"rgba(0, 0, 0, 0.87)",fontWeight:400,".MuiButton-startIcon":{mr:"2px"}},onClick:o,children:l("notification.resend")})]})}Ze.propTypes={value:h.array.isRequired,onChange:h.func};function Ze({value:n,onChange:s}){const{locale:t}=te(),r=Z().toDate(),[o,l]=v.useState(null),b=v.useCallback(i=>{l(o?null:i.currentTarget)},[o]),u=!!o,p=v.useCallback(i=>{if(!i.startDate||!i.endDate){M.error("Please select a date range");return}if(Z(i.startDate).isAfter(i.endDate)||!Z(i.startDate).isValid()||!Z(i.endDate).isValid()){M.error("Invalid date range");return}s([i.startDate,i.endDate]),l(null)},[s]);return e.jsxs("div",{children:[e.jsx(ee,{component:"div",variant:"h5",color:"textPrimary",style:{fontSize:18,fontWeight:"bold"},sx:{mb:0},children:e.jsxs(Fe,{onClick:b,variant:"outlined",size:"small",color:"inherit",children:[at(n[0],t)," - ",at(n[1],t)]})}),e.jsx(Ue,{open:u,anchorEl:o,onClose:()=>{l(null)},anchorOrigin:{vertical:"bottom",horizontal:"left"},children:e.jsx(jn,{open:!0,maxDate:r,initialDateRange:{startDate:n[0],endDate:n[1]},toggle:b,definedRanges:vn(r),onChange:p})})]})}et.propTypes={itemComponent:h.elementType.isRequired};function et({itemComponent:n,...s}){const{t}=te();return!s?.filterList?.filter(o=>o.length).length?null:e.jsxs(y,{sx:{display:"flex",gap:1,alignItems:"center"},children:[e.jsx("div",{className:"toolbar-filter-title",children:t("notification.filter")}),e.jsx("div",{className:"toolbar-filter-content",children:e.jsx(nn.TableFilterList,{...s,ItemComponent:n})})]})}function tt({label:n,onDelete:s,canDelete:t=()=>!0,...r}){const o=s&&typeof s=="function"?s:void 0;let l=!0;return t&&typeof t=="function"&&(l=t({label:n,...r})),e.jsx(Je,{label:n,variant:"outlined",...o&&l?{onDelete:o}:{}})}tt.propTypes={label:h.string.isRequired,onDelete:h.func,canDelete:h.func};const Mn=[{label:"Wallet",value:"app",checked:!0},{label:"Email",value:"email",checked:!0},{label:"Push Kit",value:"push",checked:!0},{label:"Webhook",value:"webhook",checked:!0}];Pt.propTypes={loading:h.bool,onCancel:h.func,onConfirm:h.func};function Pt({loading:n=!1,onCancel:s=()=>{},onConfirm:t=()=>{}}){const{t:r}=te(),[o,l]=v.useState(Mn),[b,u]=v.useState(!0),p=(N,I)=>{I.checked=N.target.checked;const S=o.map(j=>({...j,checked:j.value===I.value?I.checked:j.checked}));l(S)},i=N=>{N.stopPropagation(),t({channels:o.filter(I=>I.checked).map(I=>I.value),isResendFailedOnly:b})};return e.jsxs(y,{className:"resend-config",sx:{padding:"16px 24px"},children:[e.jsx(ee,{variant:"body1",component:"div",className:"check-title",sx:{fontWeight:700,mb:1},children:r("notification.config")}),e.jsx(y,{className:"choose-channel",children:e.jsxs(V,{component:"fieldset",variant:"standard",children:[e.jsx(pt,{component:"legend",children:r("notification.selectChannels")}),e.jsx(Ke,{sx:{display:"flex",flexDirection:"row",flexWrap:"wrap",gap:1},children:o.map(N=>e.jsx(me,{control:e.jsx(Me,{checked:N.checked,onChange:I=>p(I,N),name:N.value}),label:N.label},N.value))})]})}),e.jsx(y,{className:"resend-config-footer",children:e.jsx(Ke,{children:e.jsx(me,{control:e.jsx(Me,{checked:b,onChange:N=>u(N.target.checked)}),label:r("notification.resendFailedOnly")})})}),e.jsxs(y,{className:"resend-config-footer-tip",sx:{display:"flex",justifyContent:"flex-end",gap:1},children:[e.jsx(Fe,{onClick:N=>{N.stopPropagation(),s()},color:"inherit",children:r("common.cancel")}),e.jsxs(Fe,{onClick:i,color:"primary",disabled:n,variant:"contained",autoFocus:!0,style:{marginLeft:8},children:[n&&e.jsx(ft,{size:16}),r("common.confirm")]})]})]})}Ft.propTypes={notificationId:h.string.isRequired,handleResend:h.func,resending:h.bool};function Ft({notificationId:n,handleResend:s,resending:t=!1}){const{t:r,locale:o}=te(),l=ht(),b=v.useMemo(()=>jt(l,Lt()),[l]),{getReceivers:u,inService:p,teamDid:i,getUser:N,blocklet:I}=Xe(),[S,j]=v.useState(!1),[E,J]=v.useState([]),z=ye({anchorEl:null,position:null}),F=ye({anchorEl:null,position:null}),[B,w]=v.useState(null),[q,K]=v.useState({total:0,pageSize:10,pageCount:0,page:1}),[f,R]=v.useState({searchText:"",page:1,pageSize:10,walletSendStatus:[],pushKitSendStatus:[],emailSendStatus:[],dateRange:[Z().subtract(1,"month").startOf("day").toDate(),Z().endOf("day").toDate()]}),[C,a]=v.useState([]),T=[{label:r("notification.sendStatus.pending"),value:0,status:"pending"},{label:r("notification.sendStatus.success"),value:1,status:"success"},{label:r("notification.sendStatus.failed"),value:2,status:"failed"}],O=async()=>{if(!S&&n)try{j(!0);const c=await u({notificationId:n,...f}),d=c.list.map(m=>({...m,receiverUser:{...m.receiverUser,avatar:It(m.receiverUser.avatar,i,p)}}));J(d),K(c.paging),j(!1)}catch(c){M.error(c.message),j(!1)}};v.useEffect(()=>{O()},[f]);const D=c=>{c.stopPropagation();const d=c.currentTarget;F.anchorEl=d;const m=d.getBoundingClientRect();F.position={top:m.top+window.scrollY,left:m.left+window.scrollX}},re=c=>c.data.length?e.jsx("div",{style:{display:"flex",alignItems:"center",padding:"10px"},children:e.jsx(ce,{className:"resend-btn",size:"small",color:"primary",variant:"contained",startIcon:e.jsx(Ge,{}),sx:{".MuiButton-startIcon":{mr:"2px"}},onClick:D,children:r("notification.resend")})}):null,ue={sort:!1,download:!1,print:!1,selectableRows:"multiple",searchPlaceholder:r("common.search"),searchAlwaysOpen:!1,filterType:"checkbox",searchDebounceTime:300,page:q.page-1,rowsPerPage:q.pageSize,count:q.total,searchText:f.searchText,tableBodyMaxHeight:"calc(80vh - 260px)",rowsSelected:C,onRowSelectionChange:(c,d)=>{a(d.map(m=>m.dataIndex))},customToolbarSelect:re},oe=({page:c,rowsPerPage:d,searchText:m,filterList:A})=>{const[,U=[],ne=[],G=[]]=A;f.pageSize!==d?R(H=>({...H,pageSize:d,page:1})):f.page!==c+1?R(H=>({...H,page:c+1})):f.searchText!==m?R(H=>({...H,searchText:m,page:1})):je(U,f.walletSendStatus)?je(ne,f.pushKitSendStatus)?je(G,f.emailSendStatus)||R(H=>({...H,emailSendStatus:G,page:1})):R(H=>({...H,pushKitSendStatus:ne,page:1})):R(H=>({...H,walletSendStatus:U,page:1}))},pe=v.useCallback(async(c,d)=>{if(!d)return!1;const m=await N(d);return m?c==="wallet"?zn(m):c==="email"?Fn(I,m):c==="pushKit"?_n(I,m):c==="webhook"?Wn(m):!0:!1},[N,I]),we=v.useCallback(c=>Bn(r,c),[r]),fe=()=>{z.anchorEl=null,z.position=null,w(null)},he=()=>{F.anchorEl=null,F.position=null},g=async(c,d,m=!0,A="")=>{if(!(!d.length||!c.length))try{s(c,d,m,A),F.anchorEl||(await Ee(.5),fe())}catch(U){console.error("handleResend error",{error:U})}},x=async({channels:c,isResendFailedOnly:d})=>{const m=C.map(A=>E[A].receiver);await g(c,m,d),await Ee(.5),he(),a([])},k=async(c,d=[],m=!0)=>{try{await g(["webhook"],[c.receiver],m,d)}catch(A){M.error(A.response?A.response.statusText:A.message)}},L=async(c,d,m,A=[],U=!0)=>{if(c.stopPropagation(),qn(d,m)>=4){M.warning(r("notification.resendLimit"));return}if(!Ve.includes(m)){await k(d,A,U);return}if(c){const G=c.currentTarget,H=G.getBoundingClientRect();z.anchorEl=G,z.position={top:H.top+window.scrollY,left:H.left+window.scrollX}}w({channel:m});try{const G=await pe(m,d.receiver);await Ee(1),w({channel:m,result:G}),(typeof G=="boolean"&&G||Zt(G)&&Object.values(G).every(H=>!!H))&&(await s([m],[d.receiver],U),F.anchorEl||(await Ee(.5),fe()))}catch(G){M.error(G.message)}},W=c=>{R(d=>({...d,dateRange:c,page:1}))},P=(c,d,m,A)=>{c.stopPropagation();const U=m.filter(ne=>ne!==d);R(ne=>({...ne,[A]:U,page:1}))},ie=se(()=>[{label:r("notification.receiver"),name:"receiver",width:200,options:{filter:!1,customBodyRenderLite:c=>{const{receiverUser:d,receiver:m}=E[c];return d?e.jsxs(y,{"data-cy":`member-name-${d.fullName}`,sx:{display:"flex",alignItems:"center",gap:1,justifyContent:"flex-start"},children:[e.jsx(vt,{src:`${d.avatar}?imageFilter=resize&w=48&h=48`,size:32,did:m,shape:"circle",style:{borderRadius:"100%",overflow:"hidden"}}),e.jsx(Se,{children:d.fullName})]},m):e.jsx(bn,{size:14,responsive:!1,compact:!0,copyable:!1,did:m})}}},{label:"Wallet",name:"walletSendStatus",width:200,options:{setCellProps:()=>({className:"sent-status-cell"}),filter:!0,filterType:"custom",filterList:f.walletSendStatus??[],customFilterListOptions:{render:c=>e.jsx(Le,{list:c,label:"Wallet",onDelete:(d,m)=>{d.stopPropagation(),P(d,m,ie[1].options.filterList,"walletSendStatus")}}),update:Oe},filterOptions:{names:T,fullWidth:!0,logic:De,display:(c,d,m,A)=>e.jsx(Be,{label:"Wallet",filterList:c,onChange:d,index:m,column:A,filterValues:T})},customBodyRenderLite:c=>{const{walletSendStatus:d,walletSendAt:m,walletSendFailedReason:A}=E[c];return e.jsx(xe,{status:d,updatedAt:m,reason:A,channel:"wallet",onResend:U=>L(U,E[c],"wallet",[],!1)})}}},{label:"Push Kit",name:"pushKitSendStatus",width:200,options:{setCellProps:()=>({className:"sent-status-cell"}),customBodyRenderLite:c=>{const{pushKitSendStatus:d,pushKitSendAt:m,pushKitSendFailedReason:A}=E[c];return e.jsx(xe,{status:d,updatedAt:m,reason:A,channel:"pushkit",onResend:U=>L(U,E[c],"pushKit",[],!1)})},filter:!0,filterType:"custom",filterList:f.pushKitSendStatus??[],customFilterListOptions:{render:c=>e.jsx(Le,{list:c,label:"Push Kit",onDelete:(d,m)=>{d.stopPropagation(),P(d,m,ie[2].options.filterList,"pushKitSendStatus")}}),update:Oe},filterOptions:{names:T,fullWidth:!0,logic:De,display:(c,d,m,A)=>e.jsx(Be,{label:"Push Kit",filterList:c,onChange:d,index:m,column:A,filterValues:T})}}},{label:"Email",name:"emailSendStatus",width:200,options:{setCellProps:()=>({className:"sent-status-cell"}),customBodyRenderLite:c=>{const{emailSendStatus:d,emailSendAt:m,emailSendFailedReason:A}=E[c];return e.jsx(xe,{status:d,updatedAt:m,reason:A,channel:"email",onResend:U=>L(U,E[c],"email",[],!1)})},filter:!0,filterType:"custom",filterList:f.emailSendStatus??[],customFilterListOptions:{render:c=>e.jsx(Le,{list:c,label:"Email",onDelete:(d,m)=>{d.stopPropagation(),P(d,m,ie[3].options.filterList,"emailSendStatus")}}),update:Oe},filterOptions:{names:T,fullWidth:!0,logic:De,display:(c,d,m,A)=>e.jsx(Be,{label:"Email",filterList:c,onChange:d,index:m,column:A,filterValues:T})}}},{label:"Webhook",name:"webhook",width:200,options:{filter:!1,setCellProps:()=>({className:"sent-status-cell"}),customBodyRenderLite:c=>{const{webhook:d}=E[c];if(!d)return null;const m=Object.entries(d)[0];if(!m)return null;const[A,U]=m,ne=U[0];return e.jsx(y,{sx:{display:"flex",flexDirection:"column",gap:1},children:e.jsxs(y,{className:"webhook-item",sx:{fontSize:12},children:[e.jsx(Se,{maxLength:30,children:A},A),e.jsx(xe,{status:ne.status,updatedAt:ne.sendAt,reason:ne.failedReason,channel:"webhook",onResend:G=>L(G,E[c],"webhook",[A],!1)})]},A)})}}},{label:r("common.createdAt"),name:"createdAt",width:100,options:{filter:!1,customBodyRenderLite:c=>{const{createdAt:d}=E[c];return e.jsx(Nt,{value:d,locale:o,shouldUpdate:!0})}}}],[E,o,f,r]),Re=[e.jsx(Ze,{value:f.dateRange,onChange:W},"date-picker"),e.jsx(ce,{variant:"contained",size:"small",color:"primary",loading:S,startIcon:e.jsx(Kt,{}),onClick:()=>O(),sx:{".MuiButton-startIcon":{mr:"2px"}},style:{marginLeft:8},children:r("common.refresh")},"refresh")];return e.jsx(y,{sx:{overflow:"auto",".MuiTableCell-head":{whiteSpace:"nowrap",fontWeight:"bold"},".MuiTableCell-root":{paddingRight:"8px",whiteSpace:"nowrap"}},children:e.jsx(Hn,{children:e.jsxs(xt,{theme:b,children:[e.jsx(yt,{className:"receivers-table",locale:o,loading:S,columns:ie,data:E,onChange:oe,options:ue,customButtons:Re,components:{TableFilterList:c=>e.jsx(et,{...c,itemComponent:d=>e.jsx(tt,{...d,canDelete:()=>!1})})}}),z.anchorEl&&e.jsx(Ue,{open:!!z.anchorEl,anchorReference:"anchorPosition",anchorPosition:z.position,onClose:fe,anchorOrigin:{vertical:"center",horizontal:"right"},transformOrigin:{vertical:"center",horizontal:"left"},children:e.jsxs($n,{children:[e.jsxs(ee,{variant:"body1",component:"div",className:"check-title",children:[B?.channel," Checking"]}),e.jsx(y,{sx:{display:"flex",flexDirection:"column",gap:"4px"},children:we(B?.channel).map(c=>{const{type:d,pass:m,fail:A}=c;return!B?.result||B?.result?.[d]?e.jsxs(ee,{variant:"body1",component:"div",className:"check-item",sx:{display:"flex",alignItems:"center",gap:"4px",color:B?.result?.[d]?Ae.success.main:"inherit"},children:[B?.result?e.jsx(Mt,{}):e.jsx(ft,{size:12,sx:{color:Ae.primary.main}}),e.jsx("span",{children:m})]},d):e.jsxs(ee,{variant:"body1",component:"div",className:"check-item",sx:{display:"flex",alignItems:"center",gap:"4px",color:Ae.error.main},children:[e.jsx(Ut,{}),e.jsx("span",{children:A})]},d)})})]})}),F.anchorEl&&e.jsx(Ue,{open:!!F.anchorEl,anchorReference:"anchorPosition",anchorPosition:F.position,onClose:he,anchorOrigin:{vertical:"center",horizontal:"right"},transformOrigin:{vertical:"center",horizontal:"left"},children:e.jsx(Pt,{loading:t,onCancel:he,onConfirm:x})})]})})})}const Un=v.memo(Ft),Hn=ae.div`
2
2
  td.MuiTableCell-footer {
3
3
  border: none !important;
4
4
  }