import{G as E,j as e,al as l,z as h,bJ as A,bK as g,bL as L,aT as N,X as I}from"./vendor-mui-core-D7t4vMS5.js";import{r as m}from"./vendor-react-DX7tU9aY.js";import{W as j,Q as y}from"./vendor-ux-Dl3wVbv_.js";import{A as b}from"./config-Ca5tnO9j.js";import{a as O}from"./page-header-B0HpJClf.js";import{x as v,o as R,c as s,q as T}from"./index-Ca33rdd_.js";import{S as Y}from"./layout-CydCBGqn.js";import{S as P}from"./step-actions-CArEuzNw.js";import{S as W}from"./button-B_Qd9K_t.js";import"./vendor-utils-BzQg432x.js";import"./vendor-hooks-DAZ1H6Va.js";import"./vendor-arcblock-ivFYo5vP.js";import"./content-layout-CanSZTqf.js";import"./use-mobile-TAIHvgoJ.js";function D({onNext:a=()=>{}}){const C=E(),{t:n,locale:p}=j(),[i,c]=m.useState(!1),[S,d]=m.useState(""),{blocklet:r}=v();m.useEffect(()=>{const t=R.findServiceFromMeta(r.meta,s.NODE_SERVICES.AUTH);d(t?.config?.whoCanAccess||s.WHO_CAN_ACCESS.ALL)},[r]);const f=async t=>{let o=s.ACCESS_POLICY_PUBLIC;t===s.WHO_CAN_ACCESS.ALL?o=s.ACCESS_POLICY_PUBLIC:t===s.WHO_CAN_ACCESS.INVITED?o=s.ACCESS_POLICY_INVITED_ONLY:t===s.WHO_CAN_ACCESS.OWNER?o=s.ACCESS_POLICY_OWNER_ONLY:t===s.WHO_CAN_ACCESS.ADMIN&&(o=s.ACCESS_POLICY_ADMIN_ONLY);try{c(!0),await T.updateBlockletSecurityRule({input:{did:r.meta.did,data:{id:s.SECURITY_RULE_DEFAULT_ID,accessPolicyId:o}}}),c(!1)}catch(_){c(!1),y.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(H,{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(P,{mt:8,disabled:i,blocklet:r,onStartNow:()=>a("complete"),children:e.jsx(W,{loading:i,variant:"contained",disabled:i,onClick:()=>a(),children:n("setup.continue")})})]})}D.propTypes={onNext:I.func};const H=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{D as default};
