import{D as E,j as e,ak as l,y as h,bW as A,bX as g,bY as y,at as L,W as N}from"./vendor-mui-core-DnR6WYuU.js";import{r as m}from"./vendor-react-CTtPmzVP.js";import{V as I,Q as j}from"./vendor-ux-DMZIE6wA.js";import{A as b}from"./config-Bjbv_xI5.js";import{a as O}from"./page-header-CHAwrgX-.js";import{y as v,q as R,c as s,r as Y}from"./index-DwyzCfdd.js";import{S as T}from"./layout-tkk_Lr2y.js";import{S as W}from"./step-actions-AHe2MQxo.js";import{S as D}from"./button-BnSiFtNt.js";import"./vendor-utils-D5UG1a5Y.js";import"./vendor-hooks-BZ19vVZ7.js";import"./lottie-web-4koyQiv_.js";import"./vendor-arcblock-DkdOhPyM.js";import"./content-layout-DmSBGGVm.js";import"./use-mobile-D5clNlrm.js";function P({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,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 Y.updateBlockletSecurityRule({input:{did:r.meta.did,data:{id:s.SECURITY_RULE_DEFAULT_ID,accessPolicyId:o}}}),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(y,{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(W,{mt:8,disabled:i,blocklet:r,onStartNow:()=>a("complete"),children:e.jsx(D,{loading:i,variant:"contained",disabled:i,onClick:()=>a(),children:n("setup.continue")})})]})}P.propTypes={onNext:N.func};const k=L(T)`
  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{P as default};
