import{G as E,j as e,al as l,z as y,bJ as L,bK as j,bL as _,aT as b,X as I}from"./vendor-mui-core-CDEc-eG6.js";import{r as m}from"./vendor-react-DX7tU9aY.js";import{W as A,O as N}from"./vendor-ux-bFYdDLNG.js";import{A as v}from"./config-QTWMenj3.js";import{a as O}from"./page-header-CEL5h6do.js";import{v as R,n as T,cu as Y,cv as a,o as D,cw as f,ac as k,cx as P,cy as z,cz as B}from"./index-DGZk149v.js";import{S as U}from"./layout-D7JBXyAe.js";import{S as V}from"./step-actions-DiRyepq4.js";import{S as w}from"./button-DJOGWCMI.js";import"./vendor-utils-_C9URqjS.js";import"./vendor-hooks-BrgYeCrj.js";import"./vendor-arcblock-DY2miJjh.js";import"./content-layout-D49-hpq6.js";import"./use-mobile-DUKvJoqs.js";function F({onNext:o=()=>{}}){const x=E(),{t:n,locale:p}=A(),[i,c]=m.useState(!1),[u,d]=m.useState(""),{blocklet:r}=R();m.useEffect(()=>{const t=T.findServiceFromMeta(r.meta,Y.AUTH);d(t?.config?.whoCanAccess||a.ALL)},[r]);const S=async t=>{let s=f;t===a.ALL?s=f:t===a.INVITED?s=P:t===a.OWNER?s=z:t===a.ADMIN&&(s=B);try{c(!0),await D.updateBlockletSecurityRule({input:{did:r.meta.did,data:{id:k,accessPolicyId:s}}}),c(!1)}catch(g){c(!1),N.error(g.message)}},C=async t=>{i||(d(t.target.value),await S(t.target.value))},h={marginRight:4,fontSize:18,verticalAlign:"text-bottom",color:x.palette.text.secondary};return e.jsxs(W,{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(y,{component:"fieldset",children:e.jsx(L,{name:"inherit",value:u,onChange:C,children:v.map(t=>e.jsxs(l,{sx:{mb:2,"&:last-child":{mb:0}},children:[e.jsx(j,{value:t.value,control:e.jsx(_,{size:"small",color:"primary"}),label:e.jsxs("span",{style:{display:"flex",alignItems:"center",position:"relative"},children:[e.jsx(t.icon,{style:h}),e.jsx("span",{style:{marginTop:2},children:t.title[p]})]})}),e.jsx(l,{className:"tip",children:t.description[p]})]},t.value))})})}),e.jsx(V,{mt:8,disabled:i,blocklet:r,onStartNow:()=>o("complete"),children:e.jsx(w,{loading:i,variant:"contained",disabled:i,onClick:()=>o(),children:n("setup.continue")})})]})}F.propTypes={onNext:I.func};const W=b(U)`
  height: 100%;
  overflow-y: auto;
  .header {
    width: 100%;
    margin-top: 60px;
  }
  .tip {
    margin-left: 30px;
    font-size: 12px;
    margin-top: -8px;
    color: ${o=>o.theme.palette.text.disabled};
  }
`;export{F as default};
