"use strict";var _a;Object.defineProperty(exports,"__esModule",{value:!0}),exports.Group=void 0;var jsiiDeprecationWarnings=()=>{var tmp=require("../../.warnings.jsii.js");return jsiiDeprecationWarnings=()=>tmp,tmp};const JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti");var iam_generated_1=()=>{var tmp=require("./iam.generated");return iam_generated_1=()=>tmp,tmp},policy_1=()=>{var tmp=require("./policy");return policy_1=()=>tmp,tmp},principals_1=()=>{var tmp=require("./principals");return principals_1=()=>tmp,tmp},util_1=()=>{var tmp=require("./private/util");return util_1=()=>tmp,tmp},core_1=()=>{var tmp=require("../../core");return core_1=()=>tmp,tmp};class GroupBase extends core_1().Resource{constructor(){super(...arguments),this.grantPrincipal=this,this.principalAccount=this.env.account,this.assumeRoleAction="sts:AssumeRole",this.attachedPolicies=new(util_1()).AttachedPolicies}get policyFragment(){return new(principals_1()).ArnPrincipal(this.groupArn).policyFragment}attachInlinePolicy(policy){this.attachedPolicies.attach(policy),policy.attachToGroup(this)}addManagedPolicy(_policy){}addUser(user){user.addToGroup(this)}addToPrincipalPolicy(statement){return this.defaultPolicy||(this.defaultPolicy=new(policy_1()).Policy(this,"DefaultPolicy"),this.defaultPolicy.attachToGroup(this)),this.defaultPolicy.addStatements(statement),{statementAdded:!0,policyDependable:this.defaultPolicy}}addToPolicy(statement){return this.addToPrincipalPolicy(statement).statementAdded}}class Group extends GroupBase{static fromGroupArn(scope,id,groupArn){const arnComponents=core_1().Stack.of(scope).splitArn(groupArn,core_1().ArnFormat.SLASH_RESOURCE_NAME),groupName=arnComponents.resourceName;class Import extends GroupBase{constructor(){super(...arguments),this.groupName=groupName,this.groupArn=groupArn,this.principalAccount=arnComponents.account}}return new Import(scope,id)}static fromGroupName(scope,id,groupName){const groupArn=core_1().Stack.of(scope).formatArn({service:"iam",region:"",resource:"group",resourceName:groupName});return Group.fromGroupArn(scope,id,groupArn)}constructor(scope,id,props={}){super(scope,id,{physicalName:props.groupName}),this.managedPolicies=[];try{jsiiDeprecationWarnings().aws_cdk_lib_aws_iam_GroupProps(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,Group),error}this.managedPolicies.push(...props.managedPolicies||[]);const group=new(iam_generated_1()).CfnGroup(this,"Resource",{groupName:this.physicalName,managedPolicyArns:core_1().Lazy.list({produce:()=>this.managedPolicies.map(p=>p.managedPolicyArn)},{omitEmpty:!0}),path:props.path});this.groupName=this.getResourceNameAttribute(group.ref),this.groupArn=this.getResourceArnAttribute(group.attrArn,{region:"",service:"iam",resource:"group",resourceName:`${props.path?props.path.substr(props.path.charAt(0)==="/"?1:0):""}${this.physicalName}`}),this.managedPoliciesExceededWarning()}addManagedPolicy(policy){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_iam_IManagedPolicy(policy)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.addManagedPolicy),error}this.managedPolicies.find(mp=>mp===policy)||(this.managedPolicies.push(policy),this.managedPoliciesExceededWarning())}managedPoliciesExceededWarning(){this.managedPolicies.length>10&&core_1().Annotations.of(this).addWarningV2("@aws-cdk/aws-iam:groupMaxPoliciesExceeded",`You added ${this.managedPolicies.length} to IAM Group ${this.physicalName}. The maximum number of managed policies attached to an IAM group is 10.`)}}exports.Group=Group,_a=JSII_RTTI_SYMBOL_1,Group[_a]={fqn:"aws-cdk-lib.aws_iam.Group",version:"2.148.1"};
