import{D as E,j as e,ak as l,y as h,bq as A,b6 as g,br as L,at as N,W as y}from"./vendor-mui-core-CnXrAOs3.js";import{r as m}from"./vendor-react-Dvs43sk9.js";import{V as I,H as j}from"./vendor-ux-IiQnod3w.js";import{A as b}from"./config-BLLq9bPE.js";import{a as O}from"./page-header-DCvzRay5.js";import{l as v,e as R,c as o,f as T}from"./index-sNHCLgAE.js";import{S as Y}from"./layout-Ccrs-yyw.js";import{S as D}from"./step-actions-thgNsMmu.js";import{S as P}from"./button-vwR-NYG5.js";import"./vendor-utils-cJEl_UEd.js";import"./vendor-hooks-CjESGRlR.js";import"./lottie-web-4koyQiv_.js";import"./vendor-arcblock-CuFtPveO.js";import"./content-layout-oyz1EqNZ.js";import"./use-mobile-DCNBsOlH.js";function W({onNext:a=()=>{}}){const C=E(),{t:n,locale:p}=I(),[i,c]=m.useState(!1),[S,d]=m.useState(""),{blocklet:r}=v();m.useEffect(()=>{const t=R.findServiceFromMeta(r.meta,o.NODE_SERVICES.AUTH);d(t?.config?.whoCanAccess||o.WHO_CAN_ACCESS.ALL)},[r]);const f=async t=>{let s=o.ACCESS_POLICY_PUBLIC;t===o.WHO_CAN_ACCESS.ALL?s=o.ACCESS_POLICY_PUBLIC:t===o.WHO_CAN_ACCESS.INVITED?s=o.ACCESS_POLICY_INVITED_ONLY:t===o.WHO_CAN_ACCESS.OWNER?s=o.ACCESS_POLICY_OWNER_ONLY:t===o.WHO_CAN_ACCESS.ADMIN&&(s=o.ACCESS_POLICY_ADMIN_ONLY);try{c(!0),await T.updateBlockletSecurityRule({input:{did:r.meta.did,data:{id:o.SECURITY_RULE_DEFAULT_ID,accessPolicyId:s}}}),c(!1)}catch(_){c(!1),j.error(_.message)}},x=async t=>{i||(d(t.target.value),await f(t.target.value))},u={marginRight:4,fontSize:18,verticalAlign:"text-bottom",color:C.palette.text.secondary};return e.jsxs(k,{children:[e.jsx(l,{className:"header",children:e.jsx(O,{title:n("blocklet.config.access.title"),subTitle:n("blocklet.config.access.description")})}),e.jsx(l,{className:"form-container",children:e.jsx(h,{component:"fieldset",children:e.jsx(A,{name:"inherit",value:S,onChange:x,children:b.map(t=>e.jsxs(l,{sx:{mb:2,"&:last-child":{mb:0}},children:[e.jsx(g,{value:t.value,control:e.jsx(L,{size:"small",color:"primary"}),label:e.jsxs("span",{style:{display:"flex",alignItems:"center",position:"relative"},children:[e.jsx(t.icon,{style:u}),e.jsx("span",{style:{marginTop:2},children:t.title[p]})]})}),e.jsx(l,{className:"tip",children:t.description[p]})]},t.value))})})}),e.jsx(D,{mt:8,disabled:i,blocklet:r,onStartNow:()=>a("complete"),children:e.jsx(P,{loading:i,variant:"contained",disabled:i,onClick:()=>a(),children:n("setup.continue")})})]})}W.propTypes={onNext:y.func};const k=N(Y)`
  height: 100%;
  overflow-y: auto;
  .header {
    width: 100%;
    margin-top: 60px;
  }
  .tip {
    margin-left: 30px;
    font-size: 12px;
    margin-top: -8px;
    color: ${a=>a.theme.palette.text.disabled};
  }
`;export{W as default};
