1import{r as p,j as e}from"./react-vendor-CSsSSEML.js";import{M as ye,B as S,bS as Fe,cm as Oe,f as q,X as Te,E as ue,j as F,r as $e,D as _e,F as ze,K as We,P as Y}from"./index-BVsjb7mB.js";import{P as Ge}from"./Pagination-BnDSIG0w.js";import{E as Ue}from"./ErrorState-CE1mnLGb.js";import{I as Ve}from"./InfoTooltip-riKjpznF.js";import{S as Ke}from"./SearchableSelect-BM_5_tjW.js";import{T as He}from"./TableSkeleton-CEkMNKo7.js";import{I as ge}from"./ImportedFromChip-hAc29Ehe.js";import{p as Q}from"./importedName-D6DVdCGk.js";import{S as Ze}from"./SearchInput-DLZe8zNw.js";import{u as qe}from"./useDebouncedValue-x0dK07ix.js";import{b as Ye}from"./hooks-BboSRtlu.js";import{u as Qe,b as Je,c as Xe,d as pe,O as R,p as et,S as tt,R as st,a as nt}from"./useRoleMutations-afvY3QHG.js";import{i as rt}from"./formDirty-KbNXPJ_S.js";import"./tanstack-vendor-D2LStv3_.js";import"./sentry-vendor-DQkRq1-W.js";import"./GroupedTypeDropdown-iViufUrm.js";(function(){try{var s=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{};s.SENTRY_RELEASE={id:"33b2f1a2eb67da61a8a79f4c3c0fca45c630c2e5"};var r=new s.Error().stack;r&&(s._sentryDebugIds=s._sentryDebugIds||{},s._sentryDebugIds[r]="8e062cd1-6194-4010-b30c-59be323f0563",s._sentryDebugIdIdentifier="sentry-dbid-8e062cd1-6194-4010-b30c-59be323f0563")}catch{}})();const at={s3:"S3",iam:"IAM",kms:"KMS",sts:"STS",logs:"CloudWatch Logs",ec2:"EC2",lambda:"Lambda",dynamodb:"DynamoDB",rds:"RDS",sns:"SNS",sqs:"SQS",cloudwatch:"CloudWatch",cloudtrail:"CloudTrail",secretsmanager:"Secrets Manager",cloudformation:"CloudFormation",events:"EventBridge",eks:"EKS",ecs:"ECS",ecr:"ECR",apigateway:"API Gateway",efs:"EFS",elasticloadbalancing:"ELB",route53:"Route 53"},ot={compute:"Compute Engine",storage:"Cloud Storage",iam:"IAM",cloudresourcemanager:"Resource Manager",pubsub:"Pub/Sub",bigquery:"BigQuery",cloudfunctions:"Cloud Functions",run:"Cloud Run",container:"GKE",cloudkms:"Cloud KMS",secretmanager:"Secret Manager",logging:"Cloud Logging",monitoring:"Cloud Monitoring",cloudtasks:"Cloud Tasks"},it={Storage:"Storage",Compute:"Compute",Network:"Network",KeyVault:"Key Vault",Authorization:"Authorization",Resources:"Resources"},lt={s3:"box",storage:"box",efs:"box",iam:"users",authorization:"users",kms:"key",cloudkms:"key",keyvault:"key",secretsmanager:"key",secretmanager:"key",sts:"shield",logs:"list",logging:"list",cloudtrail:"list",ec2:"server",compute:"server",container:"server",eks:"server",ecs:"server",network:"globe",route53:"globe",apigateway:"globe",elasticloadbalancing:"globe",rds:"database",dynamodb:"database",bigquery:"database",lambda:"function",cloudfunctions:"function",run:"function"};function ct(s){const r=s.trim();if(!r)return null;const a=r.indexOf(":");if(a<=0)return{key:"other",label:"Other"};const o=r.slice(0,a).toLowerCase();return{key:o,label:at[o]||o.toUpperCase()}}function dt(s){const r=s.trim();if(!r)return null;const a=r.indexOf(".");if(a<=0)return{key:"other",label:"Other"};const o=r.slice(0,a).toLowerCase(),l=o.charAt(0).toUpperCase()+o.slice(1);return{key:o,label:ot[o]||l}}function mt(s){const r=s.trim();if(!r)return null;const a="Microsoft.";if(!r.startsWith(a))return{key:"other",label:"Other"};const o=r.slice(a.length),l=o.indexOf("/"),x=l>0?o.slice(0,l):o;if(!x)return{key:"other",label:"Other"};const n=x.charAt(0).toUpperCase()+x.slice(1);return{key:n,label:it[n]||n}}function ut(s){return s.trim()?{key:"other",label:"Cloud actions"}:null}const pt={aws:ct,gcp:dt,azure:mt};function O(s=[],r=""){if(!Array.isArray(s)||s.length===0)return{groups:[],total:0};const a=pt[(r||"").toLowerCase()]||ut,o=new Map;let l=0;for(const n of s){if(typeof n!="string")continue;const c=a(n);if(!c)continue;l+=1;const h=o.get(c.key);h?h.actions.push(n):o.set(c.key,{key:c.key,label:c.label,actions:[n]})}return{groups:Array.from(o.values()).map(n=>({...n,count:n.actions.length})).sort((n,c)=>c.count!==n.count?c.count-n.count:n.key<c.key?-1:n.key>c.key?1:0),total:l}}function xt(s){return!s||typeof s!="string"?"cloud":lt[s.toLowerCase()]||"cloud"}function J(s){if(!s)return null;
1if(typeof s!="string")return s;try{return JSON.parse(s)}catch{return null}}const ht={aws:"AWS",gcp:"GCP",azure:"Azure"},xe={"conditional deny":"ZopNight didn't translate this role because a Deny statement uses AWS Conditions that can't be applied safely.","NotAction deny":"ZopNight didn't translate this role because a Deny statement uses AWS NotAction (set-complement).","conditional access":"Some statements in this role use AWS Conditions ZopNight didn't evaluate.","NotAction set-complement semantics":"Some statements in this role use AWS NotAction (set-complement).","Azure NotActions present â set-subtraction cannot be safely translated":"ZopNight didn't translate this role because its permissions block uses NotActions (set-complement) on the management plane.","Azure NotDataActions present â set-subtraction cannot be safely translated":"ZopNight didn't translate this role because its permissions block uses NotDataActions (set-complement) on the data plane."},he="ZopNight didn't translate this role automatically.",ft="bg-surface-tertiary text-text-secondary",fe={box:e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M3 7l9-4 9 4-9 4-9-4z"}),e.jsx("path",{d:"M3 7v10l9 4 9-4V7"})]}),users:e.jsxs(e.Fragment,{children:[e.jsx("circle",{cx:"9",cy:"8",r:"3"}),e.jsx("path",{d:"M3 20c0-3 3-5 6-5s6 2 6 5"}),e.jsx("path",{d:"M16 11a3 3 0 0 0 0-6"}),e.jsx("path",{d:"M21 20c0-2-1.5-4-4-4.5"})]}),key:e.jsxs(e.Fragment,{children:[e.jsx("circle",{cx:"8",cy:"15",r:"4"}),e.jsx("path",{d:"M11 12l9-9"}),e.jsx("path",{d:"M17 6l3 3"})]}),shield:e.jsx("path",{d:"M12 3l8 3v6c0 5-3.5 8-8 9-4.5-1-8-4-8-9V6l8-3z"}),list:e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M8 6h13M8 12h13M8 18h13"}),e.jsx("circle",{cx:"4",cy:"6",r:"1"}),e.jsx("circle",{cx:"4",cy:"12",r:"1"}),e.jsx("circle",{cx:"4",cy:"18",r:"1"})]}),server:e.jsxs(e.Fragment,{children:[e.jsx("rect",{x:"3",y:"4",width:"18",height:"7",rx:"1.5"}),e.jsx("rect",{x:"3",y:"13",width:"18",height:"7",rx:"1.5"}),e.jsx("path",{d:"M7 7.5h.01M7 16.5h.01"})]}),globe:e.jsxs(e.Fragment,{children:[e.jsx("circle",{cx:"12",cy:"12",r:"9"}),e.jsx("path",{d:"M3 12h18"}),e.jsx("path",{d:"M12 3c3 3 3 15 0 18-3-3-3-15 0-18z"})]}),database:e.jsxs(e.Fragment,{children:[e.jsx("ellipse",{cx:"12",cy:"5",rx:"8",ry:"3"}),e.jsx("path",{d:"M4 5v6c0 1.7 3.6 3 8 3s8-1.3 8-3V5"}),e.jsx("path",{d:"M4 11v6c0 1.7 3.6 3 8 3s8-1.3 8-3v-6"})]}),function:e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M16 4h-2a3 3 0 0 0-3 3v2H8"}),e.jsx("path",{d:"M14 9H7"}),e.jsx("path",{d:"M11 9v8a3 3 0 0 1-3 3H6"})]}),cloud:e.jsx("path",{d:"M7 18a4 4 0 0 1-.5-7.97A6 6 0 0 1 18 11a3.5 3.5 0 0 1-.5 7H7z"})};function yt({name:s}){return e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",className:"h-4 w-4","aria-hidden":"true",children:fe[s]||fe.cloud})}function gt({open:s}){return e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",className:`h-4 w-4 text-text-muted transition-transform ${s?"rotate-90":""}`,"aria-hidden":"true",children:e.jsx("path",{d:"m9 6 6 6-6 6"})})}function jt({group:s,open:r,onToggle:a}){const o=xt(s.key),l=ft,x=s.count===1?"1 action":`${s.count} actions`;function n(c){(c.key==="Enter"||c.key===" ")&&(c.preventDefault(),a())}return e.jsxs("div",{children:[e.jsxs("div",{role:"button",tabIndex:0,"aria-expanded":r,onClick:a,onKeyDown:n,className:"px-4 py-3 flex items-center gap-3 hover:bg-surface-secondary/60 cursor-pointer focus:outline-none rounded-md",children:[e.jsx("span",{className:`inline-flex h-8 w-8 items-center justify-center rounded-md ${l}`,"aria-hidden":"true",children:e.jsx(yt,{name:o})}),e.jsx("span",{className:"font-medium text-text-primary text-sm",children:s.label}),e.jsx("span",{className:"text-text-muted text-xs",children:x}),e.jsx("span",{className:"ml-auto",children:e.jsx(gt,{open:r})})]}),r?e.jsx("div",{className:"pl-[3.75rem] pr-5 pb-4 pt-1 flex flex-wrap gap-1.5 transition-all",children:(s.actions??[]).map((c,h)=>e.jsx("span",{className:"font-mono text-[11px] bg-surface-tertiary text-text-secondary rounded-md px-2 py-0.5 break-all",children:c},`${s.key}:${c}:${h}`))}):null]})}function bt({open:s,onClose:r,role:a}){const o=J(a?.metadata),l=o?.importedFrom?.translation,x=(o?.importedFrom?.provider??"").toString().toLowerCase(),n=l?.bailReason??"",{groups:c,total:h,isBailFallback:L}=p.useMemo(()=>{const y=Array.isArray(l?.skippedActions)?l.skippedActions:[];if(y.length>0)return{...O(y,x),isBailFallback:!1};if(n){if(Array.isArray(l?.rawInputAWS)){const j=l.rawInputAWS.filter(d=>d?.effect==="Allow"||d?.Effect==="Allow").flatMap(d=>d?.actions??d?.Actions??[]);return{...O(j,x),isBailFallback:!0}}if(Array.isArray(l?.rawInputGCP))return{...O(l.rawInputGCP,x),isBailFallback:!0};if(Array.isArray(l?.rawInputAzure)){const j=l.rawInputAzure.flatMap(d=>[...d?.actions??d?.Actions??[],...d?.dataActions??d?.DataActions??[]]);return{...O(j,x),isBailFallback:!0}}}return{groups:[],total:0,isBailFallback:!1}},[l,x,n]),g=c[0]?.key??null,[X,E]=p.useState(()=>new Set(g?[g]:[]));if(!s||!a)return null;const I=ht[x]||"cloud";let b;h===0&&n?b=xe[n]??he:h===0?b="Every action in this role mapped to a ZopNight policy. Nothing else to show here.":L?b=`${xe[n]??he} Here are the ${h} ${I} ${h===1?"permission":"permissions"} from the original role:`:b=`This role has ${h} ${I} ${h===1?"permission":"permissions"} that ZopNight doesn't manage.`;function T(y){E(j=>{const d=new Set(j);return d.has(y)?d.delete(y):d.add(y),d})}const $=e.jsxs("span",{className:"inline-flex items-center gap-2 text-sm",children:[e.jsx(ge,{metadata:o}),e.jsx("span",{className:"font-semibold text-text-primary truncate max-w-[18rem]",children:Q(a.name)})]});return e.jsxs(ye,{open:s,onClose:r,title:$,children:[e.jsx("p",{className:"text-text-secondary text-sm leading-relaxed mb-4",children:b}),n?e.jsxs("div",{className:"flex items-start gap-2 text-text-muted text-xs mb-4",children:[e.jsx("span",{className:"mt-1.5 inline-block h-1.5 w-1.5 rounded-full bg-primary-400 shrink-0","aria-hidden":"true"}),e.jsxs("span",{children:[n,". These statements continue to apply in your account."]})]}):null,c.length>0?e.jsx("div",{className:"border border-border-default rounded-lg divide-y divide-border-default bg-surface-secondary/30 max-h-[48vh] overflow-y-auto",children:c.map(y=>e.jsx(jt,{group:y,open:X.has(y.key),onToggle:()=>T(y.key)},y.key))}):null,e.jsx("div",{className:"mt-5 flex justify-end shrink-0",children:e.jsx(S,{variant:"primary",onClick:r,children:"Got it"})})]})}const kt=20,Nt=[{value:"",label:"All types"},{value:"system",label:"System"},{value:"custom",label:"Custom"},{value:"imported",label:"Imported"}];function vt({role:s,onViewMore:r}){return J(s?.metadata)?.importedFrom?.translation?.needsReview?e.jsx(Ve,{text:"A few cloud permissions in this role don't map to a ZopNight policy. Open the role to add anything missing.",placement:"top",width:"w-72",actionLabel:"View details â",onAction:()=>r?.(s)}):null}function zt(){const[s,r]=p.useState(1),[a,o]=p.useState(kt),[l,x]=p.useState(""),[n,c]=p.useState(""),h=qe(l,200),L=Fe(),g=L.data,E=g&&typeof g=="object"&&"items"in g?g.items:Array.isArray(g)?g:[],{isLoading:I,isError:b,error:T,refetch:$}=L,y=t=>!!J(t.metadata)?.importedFrom,j=p.useMemo(()=>{const t=h.trim().toLowerCase();return E.filter(f=>t&&!`${f.name??""} ${Q(f.name)??""}`.toLowerCase().includes(t)?!1:n==="system"?f.isSystem:n==="custom"?!f.isSystem&&!y(f):n==="imported"?y(f):!0)},[E,h,n]),d=j.length,je=Math.max(1,Math.ceil(d/a)),C=Math.min(s,je),be=C*a<d,ee=p.useMemo(()=>j.slice((C-1)*a,C*a),[j,C,a]),ke=!!h||!!n;Oe();const te=Qe(),se=Je(),_=Xe(),ne=q(Y.ROLE_CREATE),Ne=q(Y.ROLE_UPDATE),ve=q(Y.ROLE_DELETE),[we,Se]=p.useState(null),[Ce,k]=p.useState(!1),[N,re]=p.useState(null),[M,z]=p.useState(""),[W,G]=p.useState({}),[P,D]=p.useState(null),U=Te(),{data:ae}=Ye({enabled:U}),Ae=p.useMemo(()=>
1{if(!U)return{};const t=[...new Set((ae??[]).map(f=>f.provider).filter(Boolean))];return t.length?{"virtual-key":t,"ai-model":t}:{}},[U,ae]),[V,oe]=p.useState(null);function ie(){re(null),z(""),G({}),k(!0)}function Ee(t){re(t),z(t.name),G(pe(t.policies)),k(!0)}const le=!!N&&rt({name:N.name,policyMap:pe(N.policies)},{name:M,policyMap:W});function Me(t){if(t.preventDefault(),le){k(!1);return}const f=nt(W);N?se.mutate({id:N.id,name:M,policies:f},{onSuccess:()=>k(!1)}):te.mutate({name:M,policies:f},{onSuccess:()=>k(!1)})}function Re(){P&&_.mutate(P.id,{onSuccess:()=>D(null)})}if(I)return e.jsx(He,{cols:4});if(b)return e.jsx(Ue,{title:"Failed to load roles",error:T,onRetry:$,resource:"roles"});const ce=te.isPending||se.isPending;return e.jsxs("div",{children:[E.length>0?e.jsxs("div",{className:"mb-4 flex flex-wrap items-center gap-x-3 gap-y-2 bg-surface-secondary rounded-lg px-3 py-2.5 border border-border",children:[e.jsx(Ze,{placeholder:"Search roles...",value:l,onChange:t=>{x(t),r(1)},size:"sm",className:"w-full sm:max-w-xs"}),e.jsx("span",{className:"hidden sm:block w-px h-5 bg-border-strong"}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-xs font-medium text-text-muted shrink-0",children:"Type"}),e.jsx(Ke,{value:n,onChange:t=>{c(t.target.value),r(1)},options:Nt,size:"sm",className:"min-w-[150px]"})]}),ne&&e.jsx(S,{onClick:ie,className:"ml-auto",children:"+ Create Role"})]}):ne&&e.jsx("div",{className:"flex justify-end mb-4",children:e.jsx(S,{onClick:ie,children:"+ Create Role"})}),ee.length===0?ke?e.jsx(ue,{title:"No roles match your filters",description:"Try a different search term or type filter."}):e.jsx(ue,{title:"No roles",description:"Create a custom role to fine-tune permissions."}):e.jsx("div",{className:"border border-border rounded-xl bg-surface divide-y divide-border",children:ee.map(t=>{const f=we===t.id;new Set((t.policies??[]).map(i=>i.policyName));const de={};for(const i of t.policies??[])de[i.policyName]=i;return e.jsxs("div",{children:[e.jsxs("button",{type:"button",onClick:()=>Se(f?null:t.id),className:"w-full flex items-center justify-between px-4 py-3 hover:bg-surface-secondary/50 transition-colors text-left",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("svg",{className:`w-4 h-4 text-text-muted transition-transform ${f?"rotate-90":""}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 5l7 7-7 7"})}),e.jsx(F,{content:t.name,placement:"top",children:e.jsx("span",{className:"text-sm font-medium text-text-primary",children:Q(t.name)})}),t.isSystem&&e.jsx($e,{variant:"info",children:"System"}),e.jsx(ge,{metadata:t.metadata}),e.jsx(vt,{role:t,onViewMore:oe})]}),e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsxs("span",{className:"text-xs text-text-muted",children:[t.policies?.length??0," ",t.policies?.length===1?"policy":"policies"]}),(()=>{const i=t.isSystem||!Ne,v=t.isSystem||!ve;return e.jsxs(e.Fragment,{children:[e.jsx(F,{content:"Edit",wrapDisabled:!0,children:e.jsx("span",{role:"button",tabIndex:i?-1:0,"aria-disabled":i,"aria-label":"Edit role",onClick:i?void 0:w=>{w.stopPropagation(),Ee(t)},className:`p-1.5 rounded-md transition-colors ${i?"text-text-muted/40 cursor-not-allowed":"text-text-muted hover:text-primary-600 hover:bg-surface-tertiary cursor-pointer"}`,children:e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.8,stroke:"currentColor",className:"w-4 h-4",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"m16.862 4.487 1.687-1.688a1.875 1.875 0 1 1 2.652 2.652L10.582 16.07a4.5 4.5 0 0 1-1.897 1.13L6 18l.8-2.685a4.5 4.5 0 0 1 1.13-1.897l8.932-8.931Zm0 0L19.5 7.125M18 14v4.75A2.25 2.25 0 0 1 15.75 21H5.25A2.25 2.25 0 0 1 3 18.75V8.25A2.25 2.25 0 0 1 5.25 6H10"})})})}),e.jsx(F,{content:"Delete",wrapDisabled:!0,children:e.jsx("span",{role:"button",tabIndex:v?-1:0,"aria-disabled":v,"aria-label":"Delete role",onClick:v?void 0:w=>{w.stopPropagation(),D(t)},className:`p-1.5 rounded-md transition-colors ${v?"text-text-muted/40 cursor-not-allowed":"text-text-muted hover:text-danger-500 hover:bg-surface-tertiary cursor-pointer"}`,children:e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.8,stroke:"currentColor",className:"w-4 h-4",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"m14.74 9-.346 9m-4.788 0L9.26 9m9.968-3.21c.342.052.682.107 1.022.166m-1.022-.165L18.16 19.673a2.25 2.25 0 0 1-2.244 2.077H8.084a2.25 2.25 0 0 1-2.244-2.077L4.772 5.79m14.456 0a48.108 48.108 0 0 0-3.478-.397m-12 .562c.34-.059.68-.114 1.022-.165m0 0a48.11 48.11 0 0 1 3.478-.397m7.5 0v-.916c0-1.18-.91-2.164-2.09-2.201a51.964 51.964 0 0 0-3.32 0c-1.18.037-2.09 1.022-2.09 2.201v.916m7.5 0a48.667 48.667 0 0 0-7.5 0"})})})})]})})()]})]}),f&&e.jsx("div",{className:"px-4 pb-4",children:e.jsx("div",{className:"border border-border rounded-lg overflow-x-auto",children:e.jsxs("table",{className:"w-full text-xs min-w-[500px]",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-surface-secondary",children:[e.jsx("th",{className:"px-3 py-2 text-left font-medium text-text-muted",children:"Capability"}),R.map(i=>e.jsx("th",{className:"px-3 py-2 text-center font-medium text-text-muted",children:i.label},i.key)),e.jsx("th",{className:"px-3 py-2 text-center font-medium text-text-muted",children:"All Resources"})]})}),e.jsx("tbody",{className:"divide-y divide-border",children:et().flatMap(i=>{const v=(t.policies??[]).filter(m=>m.policyName?.startsWith(i.key+":")),w=v.length>0,me=tt.has(i.key),Le=Array.from(new Set(v.map(m=>{const u=(m.policyName??"").split(":");return u.length>=3?u.slice(2).join(":"):""}
1).filter(Boolean)));R.some(m=>(t.policies??[]).some(u=>u.policyName===`${i.key}:${m.key}`));const B=new Map;for(const m of Le){const u=R.map(A=>(t.policies??[]).some(H=>H.policyName===`${i.key}:${A.key}:${m}`)?A.key:"-").join("|");B.has(u)||B.set(u,[]),B.get(u).push(m)}const Ie=()=>e.jsxs("tr",{children:[e.jsx("td",{className:"px-3 py-2 text-text-primary font-medium",children:i.label}),R.map(m=>{const u=(t.policies??[]).some(A=>A.policyName===`${i.key}:${m.key}`);return e.jsx("td",{className:"px-3 py-2 text-center",children:u?e.jsx("svg",{className:"w-4 h-4 text-primary-600 inline-block",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2.5,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})}):e.jsx("span",{className:"text-text-muted",children:"â"})},m.key)}),e.jsx("td",{className:"px-3 py-2 text-center",children:!me||!w?e.jsx("span",{className:"text-text-muted",children:"â"}):e.jsx("svg",{className:"w-4 h-4 text-primary-600 inline-block",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2.5,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})})]},i.key),K=[],Pe=()=>{const m=[];for(const u of B.values())m.push(...u);return e.jsxs("tr",{children:[e.jsx("td",{className:"px-3 py-2 text-text-primary font-medium",children:i.label}),R.map(u=>{const A=(t.policies??[]).some(Z=>Z.policyName===`${i.key}:${u.key}`),H=m.some(Z=>(t.policies??[]).some(Be=>Be.policyName===`${i.key}:${u.key}:${Z}`)),De=A||H;return e.jsx("td",{className:"px-3 py-2 text-center",children:De?e.jsx("svg",{className:"w-4 h-4 text-primary-600 inline-block",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2.5,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})}):e.jsx("span",{className:"text-text-muted",children:"â"})},u.key)}),e.jsx("td",{className:"px-3 py-2 text-center",children:m.length===0?me&&w?e.jsx("svg",{className:"w-4 h-4 text-primary-600 inline-block",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2.5,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})}):e.jsx("span",{className:"text-text-muted",children:"â"}):e.jsx(F,{content:`Applies to: ${m.join(", ")}`,children:e.jsxs("span",{className:"inline-flex items-center gap-1 text-[11px] font-medium text-primary-600 whitespace-nowrap",children:[e.jsx("span",{children:m.slice(0,2).join(", ")}),m.length>2&&e.jsxs("span",{className:"text-text-muted",children:["+",m.length-2," more"]})]})})})]},`${i.key}:union`)};return w?K.push(Pe()):K.push(Ie()),K})})]})})})]},t.id)})}),(d>a||C>1)&&e.jsx(Ge,{page:C,hasMore:be,label:"roles",onPageChange:t=>r(t),pageSize:a,onPageSizeChange:t=>{o(t),r(1)}}),e.jsx(_e,{open:Ce,onClose:()=>k(!1),title:N?"Edit Role":"Create Role",wide:!0,footer:e.jsxs("div",{className:"flex justify-end gap-2 w-full",children:[e.jsx(S,{variant:"secondary",size:"sm",onClick:()=>k(!1),children:"Cancel"}),e.jsx(S,{type:"submit",form:"role-form",size:"sm",disabled:!M.trim()||ce||le,children:ce?"Saving...":N?"Save Changes":"Create"})]}),children:e.jsxs("form",{id:"role-form",onSubmit:Me,className:"flex flex-col gap-5",children:[e.jsx("p",{className:"text-sm text-text-muted",children:"By creating a custom role, you can control who can view, edit, or manage specific resources with fine-grained permissions."}),e.jsx(ze,{label:"Role Name",required:!0,children:e.jsx(We,{placeholder:"e.g. Admin, Project Viewer, Finance Manager",value:M,onChange:t=>z(t.target.value),required:!0,autoFocus:!0})}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-text-secondary mb-2",children:"Granular Permission Matrix"}),e.jsx(st,{policyMap:W,onChange:G,scopeOptions:Ae})]})]})}),e.jsxs(ye,{open:!!P,onClose:()=>D(null),title:"Delete Role",children:[e.jsxs("p",{className:"text-sm text-text-secondary mb-4",children:["Are you sure you want to delete ",e.jsx("strong",{children:P?.name}),"? This role must not be in use by any assignments or team members."]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(S,{variant:"secondary",onClick:()=>D(null),children:"Cancel"}),e.jsx(S,{variant:"delete",onClick:Re,disabled:_.isPending,children:_.isPending?"Deleting...":"Delete"})]})]}),e.jsx(bt,{open:!!V,onClose:()=>oe(null),role:V},V?.id??"no-role")]})}export{zt as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.