@awsless/cli 0.0.32 → 0.0.34

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -25,7 +25,7 @@ ${(0,t.toHex)(s)}`}getCanonicalPath({path:e}){if(this.uriEscapePath){let t=[];fo
25
25
  `);let i=t.parse(e),a=`#text`,o=Object.keys(i)[0],s=i[o];return s[a]&&(s[o]=s[a],delete s[a]),(0,n.getValueFromTextNode)(s)}return{}}),je=async(e,t)=>{let n=await Ae(e,t);return n.Error&&(n.Error.message=n.Error.message??n.Error.Message),n},Me=e=>Object.entries(e).map(([e,t])=>(0,n.extendedEncodeURIComponent)(e)+`=`+(0,n.extendedEncodeURIComponent)(t)).join(`&`),Ne=(e,t)=>{if(t.Error?.Code!==void 0)return t.Error.Code;if(e.statusCode==404)return`NotFound`}})),as=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.AssumeRoleCommand=void 0;let t=L(),n=F(),r=xa(),i=P(),a=is();e.AssumeRoleCommand=class e extends i.Command{static getEndpointParameterInstructions(){return{UseGlobalEndpoint:{type:`builtInParams`,name:`useGlobalEndpoint`},UseFIPS:{type:`builtInParams`,name:`useFipsEndpoint`},Endpoint:{type:`builtInParams`,name:`endpoint`},Region:{type:`builtInParams`,name:`region`},UseDualStack:{type:`builtInParams`,name:`useDualstackEndpoint`}}}constructor(e){super(),this.input=e}resolveMiddleware(i,a,o){this.middlewareStack.use((0,n.getSerdePlugin)(a,this.serialize,this.deserialize)),this.middlewareStack.use((0,t.getEndpointPlugin)(a,e.getEndpointParameterInstructions())),this.middlewareStack.use((0,r.getAwsAuthPlugin)(a));let s=i.concat(this.middlewareStack),{logger:c}=a,l={logger:c,clientName:`STSClient`,commandName:`AssumeRoleCommand`,inputFilterSensitiveLog:e=>e,outputFilterSensitiveLog:e=>e},{requestHandler:u}=a;return s.resolve(e=>u.handle(e.request,o||{}),l)}serialize(e,t){return(0,a.se_AssumeRoleCommand)(e,t)}deserialize(e,t){return(0,a.de_AssumeRoleCommand)(e,t)}}})),os=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.AssumeRoleWithSAMLCommand=void 0;let t=L(),n=F(),r=P(),i=is();e.AssumeRoleWithSAMLCommand=class e extends r.Command{static getEndpointParameterInstructions(){return{UseGlobalEndpoint:{type:`builtInParams`,name:`useGlobalEndpoint`},UseFIPS:{type:`builtInParams`,name:`useFipsEndpoint`},Endpoint:{type:`builtInParams`,name:`endpoint`},Region:{type:`builtInParams`,name:`region`},UseDualStack:{type:`builtInParams`,name:`useDualstackEndpoint`}}}constructor(e){super(),this.input=e}resolveMiddleware(r,i,a){this.middlewareStack.use((0,n.getSerdePlugin)(i,this.serialize,this.deserialize)),this.middlewareStack.use((0,t.getEndpointPlugin)(i,e.getEndpointParameterInstructions()));let o=r.concat(this.middlewareStack),{logger:s}=i,c={logger:s,clientName:`STSClient`,commandName:`AssumeRoleWithSAMLCommand`,inputFilterSensitiveLog:e=>e,outputFilterSensitiveLog:e=>e},{requestHandler:l}=i;return o.resolve(e=>l.handle(e.request,a||{}),c)}serialize(e,t){return(0,i.se_AssumeRoleWithSAMLCommand)(e,t)}deserialize(e,t){return(0,i.de_AssumeRoleWithSAMLCommand)(e,t)}}})),ss=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.AssumeRoleWithWebIdentityCommand=void 0;let t=L(),n=F(),r=P(),i=is();e.AssumeRoleWithWebIdentityCommand=class e extends r.Command{static getEndpointParameterInstructions(){return{UseGlobalEndpoint:{type:`builtInParams`,name:`useGlobalEndpoint`},UseFIPS:{type:`builtInParams`,name:`useFipsEndpoint`},Endpoint:{type:`builtInParams`,name:`endpoint`},Region:{type:`builtInParams`,name:`region`},UseDualStack:{type:`builtInParams`,name:`useDualstackEndpoint`}}}constructor(e){super(),this.input=e}resolveMiddleware(r,i,a){this.middlewareStack.use((0,n.getSerdePlugin)(i,this.serialize,this.deserialize)),this.middlewareStack.use((0,t.getEndpointPlugin)(i,e.getEndpointParameterInstructions()));let o=r.concat(this.middlewareStack),{logger:s}=i,c={logger:s,clientName:`STSClient`,commandName:`AssumeRoleWithWebIdentityCommand`,inputFilterSensitiveLog:e=>e,outputFilterSensitiveLog:e=>e},{requestHandler:l}=i;return o.resolve(e=>l.handle(e.request,a||{}),c)}serialize(e,t){return(0,i.se_AssumeRoleWithWebIdentityCommand)(e,t)}deserialize(e,t){return(0,i.de_AssumeRoleWithWebIdentityCommand)(e,t)}}})),cs=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.DecodeAuthorizationMessageCommand=void 0;let t=L(),n=F(),r=xa(),i=P(),a=is();e.DecodeAuthorizationMessageCommand=class e extends i.Command{static getEndpointParameterInstructions(){return{UseGlobalEndpoint:{type:`builtInParams`,name:`useGlobalEndpoint`},UseFIPS:{type:`builtInParams`,name:`useFipsEndpoint`},Endpoint:{type:`builtInParams`,name:`endpoint`},Region:{type:`builtInParams`,name:`region`},UseDualStack:{type:`builtInParams`,name:`useDualstackEndpoint`}}}constructor(e){super(),this.input=e}resolveMiddleware(i,a,o){this.middlewareStack.use((0,n.getSerdePlugin)(a,this.serialize,this.deserialize)),this.middlewareStack.use((0,t.getEndpointPlugin)(a,e.getEndpointParameterInstructions())),this.middlewareStack.use((0,r.getAwsAuthPlugin)(a));let s=i.concat(this.middlewareStack),{logger:c}=a,l={logger:c,clientName:`STSClient`,commandName:`DecodeAuthorizationMessageCommand`,inputFilterSensitiveLog:e=>e,outputFilterSensitiveLog:e=>e},{requestHandler:u}=a;return s.resolve(e=>u.handle(e.request,o||{}),l)}serialize(e,t){return(0,a.se_DecodeAuthorizationMessageCommand)(e,t)}deserialize(e,t){return(0,a.de_DecodeAuthorizationMessageCommand)(e,t)}}})),ls=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.GetAccessKeyInfoCommand=void 0;let t=L(),n=F(),r=xa(),i=P(),a=is();e.GetAccessKeyInfoCommand=class e extends i.Command{static getEndpointParameterInstructions(){return{UseGlobalEndpoint:{type:`builtInParams`,name:`useGlobalEndpoint`},UseFIPS:{type:`builtInParams`,name:`useFipsEndpoint`},Endpoint:{type:`builtInParams`,name:`endpoint`},Region:{type:`builtInParams`,name:`region`},UseDualStack:{type:`builtInParams`,name:`useDualstackEndpoint`}}}constructor(e){super(),this.input=e}resolveMiddleware(i,a,o){this.middlewareStack.use((0,n.getSerdePlugin)(a,this.serialize,this.deserialize)),this.middlewareStack.use((0,t.getEndpointPlugin)(a,e.getEndpointParameterInstructions())),this.middlewareStack.use((0,r.getAwsAuthPlugin)(a));let s=i.concat(this.middlewareStack),{logger:c}=a,l={logger:c,clientName:`STSClient`,commandName:`GetAccessKeyInfoCommand`,inputFilterSensitiveLog:e=>e,outputFilterSensitiveLog:e=>e},{requestHandler:u}=a;return s.resolve(e=>u.handle(e.request,o||{}),l)}serialize(e,t){return(0,a.se_GetAccessKeyInfoCommand)(e,t)}deserialize(e,t){return(0,a.de_GetAccessKeyInfoCommand)(e,t)}}})),us=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.GetCallerIdentityCommand=void 0;let t=L(),n=F(),r=xa(),i=P(),a=is();e.GetCallerIdentityCommand=class e extends i.Command{static getEndpointParameterInstructions(){return{UseGlobalEndpoint:{type:`builtInParams`,name:`useGlobalEndpoint`},UseFIPS:{type:`builtInParams`,name:`useFipsEndpoint`},Endpoint:{type:`builtInParams`,name:`endpoint`},Region:{type:`builtInParams`,name:`region`},UseDualStack:{type:`builtInParams`,name:`useDualstackEndpoint`}}}constructor(e){super(),this.input=e}resolveMiddleware(i,a,o){this.middlewareStack.use((0,n.getSerdePlugin)(a,this.serialize,this.deserialize)),this.middlewareStack.use((0,t.getEndpointPlugin)(a,e.getEndpointParameterInstructions())),this.middlewareStack.use((0,r.getAwsAuthPlugin)(a));let s=i.concat(this.middlewareStack),{logger:c}=a,l={logger:c,clientName:`STSClient`,commandName:`GetCallerIdentityCommand`,inputFilterSensitiveLog:e=>e,outputFilterSensitiveLog:e=>e},{requestHandler:u}=a;return s.resolve(e=>u.handle(e.request,o||{}),l)}serialize(e,t){return(0,a.se_GetCallerIdentityCommand)(e,t)}deserialize(e,t){return(0,a.de_GetCallerIdentityCommand)(e,t)}}})),ds=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.GetFederationTokenCommand=void 0;let t=L(),n=F(),r=xa(),i=P(),a=is();e.GetFederationTokenCommand=class e extends i.Command{static getEndpointParameterInstructions(){return{UseGlobalEndpoint:{type:`builtInParams`,name:`useGlobalEndpoint`},UseFIPS:{type:`builtInParams`,name:`useFipsEndpoint`},Endpoint:{type:`builtInParams`,name:`endpoint`},Region:{type:`builtInParams`,name:`region`},UseDualStack:{type:`builtInParams`,name:`useDualstackEndpoint`}}}constructor(e){super(),this.input=e}resolveMiddleware(i,a,o){this.middlewareStack.use((0,n.getSerdePlugin)(a,this.serialize,this.deserialize)),this.middlewareStack.use((0,t.getEndpointPlugin)(a,e.getEndpointParameterInstructions())),this.middlewareStack.use((0,r.getAwsAuthPlugin)(a));let s=i.concat(this.middlewareStack),{logger:c}=a,l={logger:c,clientName:`STSClient`,commandName:`GetFederationTokenCommand`,inputFilterSensitiveLog:e=>e,outputFilterSensitiveLog:e=>e},{requestHandler:u}=a;return s.resolve(e=>u.handle(e.request,o||{}),l)}serialize(e,t){return(0,a.se_GetFederationTokenCommand)(e,t)}deserialize(e,t){return(0,a.de_GetFederationTokenCommand)(e,t)}}})),fs=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.GetSessionTokenCommand=void 0;let t=L(),n=F(),r=xa(),i=P(),a=is();e.GetSessionTokenCommand=class e extends i.Command{static getEndpointParameterInstructions(){return{UseGlobalEndpoint:{type:`builtInParams`,name:`useGlobalEndpoint`},UseFIPS:{type:`builtInParams`,name:`useFipsEndpoint`},Endpoint:{type:`builtInParams`,name:`endpoint`},Region:{type:`builtInParams`,name:`region`},UseDualStack:{type:`builtInParams`,name:`useDualstackEndpoint`}}}constructor(e){super(),this.input=e}resolveMiddleware(i,a,o){this.middlewareStack.use((0,n.getSerdePlugin)(a,this.serialize,this.deserialize)),this.middlewareStack.use((0,t.getEndpointPlugin)(a,e.getEndpointParameterInstructions())),this.middlewareStack.use((0,r.getAwsAuthPlugin)(a));let s=i.concat(this.middlewareStack),{logger:c}=a,l={logger:c,clientName:`STSClient`,commandName:`GetSessionTokenCommand`,inputFilterSensitiveLog:e=>e,outputFilterSensitiveLog:e=>e},{requestHandler:u}=a;return s.resolve(e=>u.handle(e.request,o||{}),l)}serialize(e,t){return(0,a.se_GetSessionTokenCommand)(e,t)}deserialize(e,t){return(0,a.de_GetSessionTokenCommand)(e,t)}}})),ps=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.resolveStsAuthConfig=void 0;let t=xa();e.resolveStsAuthConfig=(e,{stsClientCtor:n})=>(0,t.resolveAwsAuthConfig)({...e,stsClientCtor:n})})),ms=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.resolveClientEndpointParameters=void 0,e.resolveClientEndpointParameters=e=>({...e,useDualstackEndpoint:e.useDualstackEndpoint??!1,useFipsEndpoint:e.useFipsEndpoint??!1,useGlobalEndpoint:e.useGlobalEndpoint??!1,defaultSigningName:`sts`})})),hs=u(((e,t)=>{t.exports={name:`@aws-sdk/client-sts`,description:`AWS SDK for JavaScript Sts Client for Node.js, Browser and React Native`,version:`3.329.0`,scripts:{build:`concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types'`,"build:cjs":`tsc -p tsconfig.cjs.json`,"build:docs":`typedoc`,"build:es":`tsc -p tsconfig.es.json`,"build:include:deps":`lerna run --scope $npm_package_name --include-dependencies build`,"build:types":`tsc -p tsconfig.types.json`,"build:types:downlevel":`downlevel-dts dist-types dist-types/ts3.4`,clean:`rimraf ./dist-* && rimraf *.tsbuildinfo`,"extract:docs":`api-extractor run --local`,"generate:client":`node ../../scripts/generate-clients/single-service --solo sts`,test:`yarn test:unit`,"test:unit":`jest`},main:`./dist-cjs/index.js`,types:`./dist-types/index.d.ts`,module:`./dist-es/index.js`,sideEffects:!1,dependencies:{"@aws-crypto/sha256-browser":`3.0.0`,"@aws-crypto/sha256-js":`3.0.0`,"@aws-sdk/config-resolver":`3.329.0`,"@aws-sdk/credential-provider-node":`3.329.0`,"@aws-sdk/fetch-http-handler":`3.329.0`,"@aws-sdk/hash-node":`3.329.0`,"@aws-sdk/invalid-dependency":`3.329.0`,"@aws-sdk/middleware-content-length":`3.329.0`,"@aws-sdk/middleware-endpoint":`3.329.0`,"@aws-sdk/middleware-host-header":`3.329.0`,"@aws-sdk/middleware-logger":`3.329.0`,"@aws-sdk/middleware-recursion-detection":`3.329.0`,"@aws-sdk/middleware-retry":`3.329.0`,"@aws-sdk/middleware-sdk-sts":`3.329.0`,"@aws-sdk/middleware-serde":`3.329.0`,"@aws-sdk/middleware-signing":`3.329.0`,"@aws-sdk/middleware-stack":`3.329.0`,"@aws-sdk/middleware-user-agent":`3.329.0`,"@aws-sdk/node-config-provider":`3.329.0`,"@aws-sdk/node-http-handler":`3.329.0`,"@aws-sdk/protocol-http":`3.329.0`,"@aws-sdk/smithy-client":`3.329.0`,"@aws-sdk/types":`3.329.0`,"@aws-sdk/url-parser":`3.329.0`,"@aws-sdk/util-base64":`3.310.0`,"@aws-sdk/util-body-length-browser":`3.310.0`,"@aws-sdk/util-body-length-node":`3.310.0`,"@aws-sdk/util-defaults-mode-browser":`3.329.0`,"@aws-sdk/util-defaults-mode-node":`3.329.0`,"@aws-sdk/util-endpoints":`3.329.0`,"@aws-sdk/util-retry":`3.329.0`,"@aws-sdk/util-user-agent-browser":`3.329.0`,"@aws-sdk/util-user-agent-node":`3.329.0`,"@aws-sdk/util-utf8":`3.310.0`,"fast-xml-parser":`4.1.2`,tslib:`^2.5.0`},devDependencies:{"@aws-sdk/service-client-documentation-generator":`3.310.0`,"@tsconfig/node14":`1.0.3`,"@types/node":`^14.14.31`,concurrently:`7.0.0`,"downlevel-dts":`0.10.1`,rimraf:`3.0.2`,typedoc:`0.23.23`,typescript:`~4.9.5`},engines:{node:`>=14.0.0`},typesVersions:{"<4.0":{"dist-types/*":[`dist-types/ts3.4/*`]}},files:[`dist-*/**`],author:{name:`AWS SDK for JavaScript Team`,url:`https://aws.amazon.com/javascript/`},license:`Apache-2.0`,browser:{"./dist-es/runtimeConfig":`./dist-es/runtimeConfig.browser`},"react-native":{"./dist-es/runtimeConfig":`./dist-es/runtimeConfig.native`},homepage:`https://github.com/aws/aws-sdk-js-v3/tree/main/clients/client-sts`,repository:{type:`git`,url:`https://github.com/aws/aws-sdk-js-v3.git`,directory:`clients/client-sts`}}})),gs=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.decorateDefaultCredentialProvider=e.getDefaultRoleAssumerWithWebIdentity=e.getDefaultRoleAssumer=void 0;let t=as(),n=ss(),r=`us-east-1`,i=e=>typeof e==`function`?async()=>{try{return await e()}catch{return r}}:e===void 0?r:e;e.getDefaultRoleAssumer=(e,n)=>{let r,a;return async(o,s)=>{if(a=o,!r){let{logger:t,region:o,requestHandler:s}=e;r=new n({logger:t,credentialDefaultProvider:()=>async()=>a,region:i(o||e.region),...s?{requestHandler:s}:{}})}let{Credentials:c}=await r.send(new t.AssumeRoleCommand(s));if(!c||!c.AccessKeyId||!c.SecretAccessKey)throw Error(`Invalid response from STS.assumeRole call with role ${s.RoleArn}`);return{accessKeyId:c.AccessKeyId,secretAccessKey:c.SecretAccessKey,sessionToken:c.SessionToken,expiration:c.Expiration}}},e.getDefaultRoleAssumerWithWebIdentity=(e,t)=>{let r;return async a=>{if(!r){let{logger:n,region:a,requestHandler:o}=e;r=new t({logger:n,region:i(a||e.region),...o?{requestHandler:o}:{}})}let{Credentials:o}=await r.send(new n.AssumeRoleWithWebIdentityCommand(a));if(!o||!o.AccessKeyId||!o.SecretAccessKey)throw Error(`Invalid response from STS.assumeRoleWithWebIdentity call with role ${a.RoleArn}`);return{accessKeyId:o.AccessKeyId,secretAccessKey:o.SecretAccessKey,sessionToken:o.SessionToken,expiration:o.Expiration}}},e.decorateDefaultCredentialProvider=t=>n=>t({roleAssumer:(0,e.getDefaultRoleAssumer)(n,n.stsClientCtor),roleAssumerWithWebIdentity:(0,e.getDefaultRoleAssumerWithWebIdentity)(n,n.stsClientCtor),...n})})),_s=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.fromEnv=e.ENV_EXPIRATION=e.ENV_SESSION=e.ENV_SECRET=e.ENV_KEY=void 0;let t=qi();e.ENV_KEY=`AWS_ACCESS_KEY_ID`,e.ENV_SECRET=`AWS_SECRET_ACCESS_KEY`,e.ENV_SESSION=`AWS_SESSION_TOKEN`,e.ENV_EXPIRATION=`AWS_CREDENTIAL_EXPIRATION`,e.fromEnv=()=>async()=>{let n=process.env[e.ENV_KEY],r=process.env[e.ENV_SECRET],i=process.env[e.ENV_SESSION],a=process.env[e.ENV_EXPIRATION];if(n&&r)return{accessKeyId:n,secretAccessKey:r,...i&&{sessionToken:i},...a&&{expiration:new Date(a)}};throw new t.CredentialsProviderError(`Unable to find environment variable credentials.`)}})),vs=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),(N(),m(j)).__exportStar(_s(),e)})),ys=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.getHomeDir=void 0;let t=h(`os`),n=h(`path`);e.getHomeDir=()=>{let{HOME:e,USERPROFILE:r,HOMEPATH:i,HOMEDRIVE:a=`C:${n.sep}`}=process.env;return e||r||(i?`${a}${i}`:(0,t.homedir)())}})),bs=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.getProfileName=e.DEFAULT_PROFILE=e.ENV_PROFILE=void 0,e.ENV_PROFILE=`AWS_PROFILE`,e.DEFAULT_PROFILE=`default`,e.getProfileName=t=>t.profile||process.env[e.ENV_PROFILE]||e.DEFAULT_PROFILE})),xs=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.getSSOTokenFilepath=void 0;let t=h(`crypto`),n=h(`path`),r=ys();e.getSSOTokenFilepath=e=>{let i=(0,t.createHash)(`sha1`).update(e).digest(`hex`);return(0,n.join)((0,r.getHomeDir)(),`.aws`,`sso`,`cache`,`${i}.json`)}})),Ss=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.getSSOTokenFromFile=void 0;let t=h(`fs`),n=xs(),{readFile:r}=t.promises;e.getSSOTokenFromFile=async e=>{let t=await r((0,n.getSSOTokenFilepath)(e),`utf8`);return JSON.parse(t)}})),Cs=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.getConfigFilepath=e.ENV_CONFIG_PATH=void 0;let t=h(`path`),n=ys();e.ENV_CONFIG_PATH=`AWS_CONFIG_FILE`,e.getConfigFilepath=()=>process.env[e.ENV_CONFIG_PATH]||(0,t.join)((0,n.getHomeDir)(),`.aws`,`config`)})),ws=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.getCredentialsFilepath=e.ENV_CREDENTIALS_PATH=void 0;let t=h(`path`),n=ys();e.ENV_CREDENTIALS_PATH=`AWS_SHARED_CREDENTIALS_FILE`,e.getCredentialsFilepath=()=>process.env[e.ENV_CREDENTIALS_PATH]||(0,t.join)((0,n.getHomeDir)(),`.aws`,`credentials`)})),Ts=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.getProfileData=void 0;let t=/^profile\s(["'])?([^\1]+)\1$/;e.getProfileData=e=>Object.entries(e).filter(([e])=>t.test(e)).reduce((e,[n,r])=>({...e,[t.exec(n)[2]]:r}),{...e.default&&{default:e.default}})})),Es=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.parseIni=void 0;let t=[`__proto__`,`profile __proto__`];e.parseIni=e=>{let n={},r;for(let i of e.split(/\r?\n/))if(i=i.split(/(^|\s)[;#]/)[0].trim(),i[0]===`[`&&i[i.length-1]===`]`){if(r=i.substring(1,i.length-1),t.includes(r))throw Error(`Found invalid profile name "${r}"`)}else if(r){let e=i.indexOf(`=`),t=i.length-1;if(e!==-1&&e!==0&&e!==t){let[t,a]=[i.substring(0,e).trim(),i.substring(e+1).trim()];n[r]=n[r]||{},n[r][t]=a}}return n}})),Ds=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.slurpFile=void 0;let{readFile:t}=h(`fs`).promises,n={};e.slurpFile=(e,r)=>((!n[e]||r?.ignoreCache)&&(n[e]=t(e,`utf8`)),n[e])})),Os=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.loadSharedConfigFiles=void 0;let t=Cs(),n=ws(),r=Ts(),i=Es(),a=Ds(),o=()=>({});e.loadSharedConfigFiles=async(e={})=>{let{filepath:s=(0,n.getCredentialsFilepath)(),configFilepath:c=(0,t.getConfigFilepath)()}=e,l=await Promise.all([(0,a.slurpFile)(c,{ignoreCache:e.ignoreCache}).then(i.parseIni).then(r.getProfileData).catch(o),(0,a.slurpFile)(s,{ignoreCache:e.ignoreCache}).then(i.parseIni).catch(o)]);return{configFile:l[0],credentialsFile:l[1]}}})),ks=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.getSsoSessionData=void 0;let t=/^sso-session\s(["'])?([^\1]+)\1$/;e.getSsoSessionData=e=>Object.entries(e).filter(([e])=>t.test(e)).reduce((e,[n,r])=>({...e,[t.exec(n)[2]]:r}),{})})),As=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.loadSsoSessionData=void 0;let t=Cs(),n=ks(),r=Es(),i=Ds(),a=()=>({});e.loadSsoSessionData=async(e={})=>(0,i.slurpFile)(e.configFilepath??(0,t.getConfigFilepath)()).then(r.parseIni).then(n.getSsoSessionData).catch(a)})),js=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.mergeConfigFiles=void 0,e.mergeConfigFiles=(...e)=>{let t={};for(let n of e)for(let[e,r]of Object.entries(n))t[e]===void 0?t[e]=r:Object.assign(t[e],r);return t}})),Ms=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.parseKnownFiles=void 0;let t=Os(),n=js();e.parseKnownFiles=async e=>{let r=await(0,t.loadSharedConfigFiles)(e);return(0,n.mergeConfigFiles)(r.configFile,r.credentialsFile)}})),Ns=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0})})),Ps=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=(N(),m(j));t.__exportStar(ys(),e),t.__exportStar(bs(),e),t.__exportStar(xs(),e),t.__exportStar(Ss(),e),t.__exportStar(Os(),e),t.__exportStar(As(),e),t.__exportStar(Ms(),e),t.__exportStar(Ns(),e)})),Fs=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.httpRequest=void 0;let t=qi(),n=h(`buffer`),r=h(`http`);function i(e){return new Promise((i,a)=>{let o=(0,r.request)({method:`GET`,...e,hostname:e.hostname?.replace(/^\[(.+)\]$/,`$1`)});o.on(`error`,e=>{a(Object.assign(new t.ProviderError(`Unable to connect to instance metadata service`),e)),o.destroy()}),o.on(`timeout`,()=>{a(new t.ProviderError(`TimeoutError from instance metadata service`)),o.destroy()}),o.on(`response`,e=>{let{statusCode:r=400}=e;(r<200||300<=r)&&(a(Object.assign(new t.ProviderError(`Error response received from instance metadata service`),{statusCode:r})),o.destroy());let s=[];e.on(`data`,e=>{s.push(e)}),e.on(`end`,()=>{i(n.Buffer.concat(s)),o.destroy()})}),o.end()})}e.httpRequest=i})),Is=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.fromImdsCredentials=e.isImdsCredentials=void 0,e.isImdsCredentials=e=>!!e&&typeof e==`object`&&typeof e.AccessKeyId==`string`&&typeof e.SecretAccessKey==`string`&&typeof e.Token==`string`&&typeof e.Expiration==`string`,e.fromImdsCredentials=e=>({accessKeyId:e.AccessKeyId,secretAccessKey:e.SecretAccessKey,sessionToken:e.Token,expiration:new Date(e.Expiration)})})),Ls=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.providerConfigFromInit=e.DEFAULT_MAX_RETRIES=e.DEFAULT_TIMEOUT=void 0,e.DEFAULT_TIMEOUT=1e3,e.DEFAULT_MAX_RETRIES=0,e.providerConfigFromInit=({maxRetries:t=e.DEFAULT_MAX_RETRIES,timeout:n=e.DEFAULT_TIMEOUT})=>({maxRetries:t,timeout:n})})),Rs=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.retry=void 0,e.retry=(e,t)=>{let n=e();for(let r=0;r<t;r++)n=n.catch(e);return n}})),zs=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.fromContainerMetadata=e.ENV_CMDS_AUTH_TOKEN=e.ENV_CMDS_RELATIVE_URI=e.ENV_CMDS_FULL_URI=void 0;let t=qi(),n=h(`url`),r=Fs(),i=Is(),a=Ls(),o=Rs();e.ENV_CMDS_FULL_URI=`AWS_CONTAINER_CREDENTIALS_FULL_URI`,e.ENV_CMDS_RELATIVE_URI=`AWS_CONTAINER_CREDENTIALS_RELATIVE_URI`,e.ENV_CMDS_AUTH_TOKEN=`AWS_CONTAINER_AUTHORIZATION_TOKEN`,e.fromContainerMetadata=(e={})=>{let{timeout:n,maxRetries:r}=(0,a.providerConfigFromInit)(e);return()=>(0,o.retry)(async()=>{let e=await u(),r=JSON.parse(await s(n,e));if(!(0,i.isImdsCredentials)(r))throw new t.CredentialsProviderError(`Invalid response received from instance metadata service.`);return(0,i.fromImdsCredentials)(r)},r)};let s=async(t,n)=>(process.env[e.ENV_CMDS_AUTH_TOKEN]&&(n.headers={...n.headers,Authorization:process.env[e.ENV_CMDS_AUTH_TOKEN]}),(await(0,r.httpRequest)({...n,timeout:t})).toString()),c={localhost:!0,"127.0.0.1":!0},l={"http:":!0,"https:":!0},u=async()=>{if(process.env[e.ENV_CMDS_RELATIVE_URI])return{hostname:`169.254.170.2`,path:process.env[e.ENV_CMDS_RELATIVE_URI]};if(process.env[e.ENV_CMDS_FULL_URI]){let r=(0,n.parse)(process.env[e.ENV_CMDS_FULL_URI]);if(!r.hostname||!(r.hostname in c))throw new t.CredentialsProviderError(`${r.hostname} is not a valid container metadata service hostname`,!1);if(!r.protocol||!(r.protocol in l))throw new t.CredentialsProviderError(`${r.protocol} is not a valid container metadata service protocol`,!1);return{...r,port:r.port?parseInt(r.port,10):void 0}}throw new t.CredentialsProviderError(`The container metadata credential provider cannot be used unless the ${e.ENV_CMDS_RELATIVE_URI} or ${e.ENV_CMDS_FULL_URI} environment variable is set`,!1)}})),Bs=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.fromEnv=void 0;let t=qi();e.fromEnv=e=>async()=>{try{let t=e(process.env);if(t===void 0)throw Error();return t}catch(n){throw new t.CredentialsProviderError(n.message||`Cannot load config from environment variables with getter: ${e}`)}}})),Vs=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.fromSharedConfigFiles=void 0;let t=qi(),n=Ps();e.fromSharedConfigFiles=(e,{preferredFile:r=`config`,...i}={})=>async()=>{let a=(0,n.getProfileName)(i),{configFile:o,credentialsFile:s}=await(0,n.loadSharedConfigFiles)(i),c=s[a]||{},l=o[a]||{},u=r===`config`?{...c,...l}:{...l,...c};try{let t=e(u);if(t===void 0)throw Error();return t}catch(n){throw new t.CredentialsProviderError(n.message||`Cannot load config for profile ${a} in SDK configuration files with getter: ${e}`)}}})),Hs=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.fromStatic=void 0;let t=qi(),n=e=>typeof e==`function`;e.fromStatic=e=>n(e)?async()=>await e():(0,t.fromStatic)(e)})),Us=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.loadConfig=void 0;let t=qi(),n=Bs(),r=Vs(),i=Hs();e.loadConfig=({environmentVariableSelector:e,configFileSelector:a,default:o},s={})=>(0,t.memoize)((0,t.chain)((0,n.fromEnv)(e),(0,r.fromSharedConfigFiles)(a,s),(0,i.fromStatic)(o)))})),Ws=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),(N(),m(j)).__exportStar(Us(),e)})),Gs=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.Endpoint=void 0,(function(e){e.IPv4=`http://169.254.169.254`,e.IPv6=`http://[fd00:ec2::254]`})(e.Endpoint||={})})),Ks=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.ENDPOINT_CONFIG_OPTIONS=e.CONFIG_ENDPOINT_NAME=e.ENV_ENDPOINT_NAME=void 0,e.ENV_ENDPOINT_NAME=`AWS_EC2_METADATA_SERVICE_ENDPOINT`,e.CONFIG_ENDPOINT_NAME=`ec2_metadata_service_endpoint`,e.ENDPOINT_CONFIG_OPTIONS={environmentVariableSelector:t=>t[e.ENV_ENDPOINT_NAME],configFileSelector:t=>t[e.CONFIG_ENDPOINT_NAME],default:void 0}})),qs=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.EndpointMode=void 0,(function(e){e.IPv4=`IPv4`,e.IPv6=`IPv6`})(e.EndpointMode||={})})),Js=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.ENDPOINT_MODE_CONFIG_OPTIONS=e.CONFIG_ENDPOINT_MODE_NAME=e.ENV_ENDPOINT_MODE_NAME=void 0;let t=qs();e.ENV_ENDPOINT_MODE_NAME=`AWS_EC2_METADATA_SERVICE_ENDPOINT_MODE`,e.CONFIG_ENDPOINT_MODE_NAME=`ec2_metadata_service_endpoint_mode`,e.ENDPOINT_MODE_CONFIG_OPTIONS={environmentVariableSelector:t=>t[e.ENV_ENDPOINT_MODE_NAME],configFileSelector:t=>t[e.CONFIG_ENDPOINT_MODE_NAME],default:t.EndpointMode.IPv4}})),Ys=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.getInstanceMetadataEndpoint=void 0;let t=Ws(),n=Zt(),r=Gs(),i=Ks(),a=qs(),o=Js();e.getInstanceMetadataEndpoint=async()=>(0,n.parseUrl)(await s()||await c());let s=async()=>(0,t.loadConfig)(i.ENDPOINT_CONFIG_OPTIONS)(),c=async()=>{let e=await(0,t.loadConfig)(o.ENDPOINT_MODE_CONFIG_OPTIONS)();switch(e){case a.EndpointMode.IPv4:return r.Endpoint.IPv4;case a.EndpointMode.IPv6:return r.Endpoint.IPv6;default:throw Error(`Unsupported endpoint mode: ${e}. Select from ${Object.values(a.EndpointMode)}`)}}})),Xs=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.getExtendedInstanceMetadataCredentials=void 0,e.getExtendedInstanceMetadataCredentials=(e,t)=>{let n=300+Math.floor(Math.random()*300),r=new Date(Date.now()+n*1e3);t.warn(`Attempting credential expiration extension due to a credential service availability issue. A refresh of these credentials will be attempted after \${new Date(newExpiration)}.
26
26
  For more information, please visit: https://docs.aws.amazon.com/sdkref/latest/guide/feature-static-credentials.html`);let i=e.originalExpiration??e.expiration;return{...e,...i?{originalExpiration:i}:{},expiration:r}}})),Zs=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.staticStabilityProvider=void 0;let t=Xs();e.staticStabilityProvider=(e,n={})=>{let r=n?.logger||console,i;return async()=>{let n;try{n=await e(),n.expiration&&n.expiration.getTime()<Date.now()&&(n=(0,t.getExtendedInstanceMetadataCredentials)(n,r))}catch(e){if(i)r.warn(`Credential renew failed: `,e),n=(0,t.getExtendedInstanceMetadataCredentials)(i,r);else throw e}return i=n,n}}})),Qs=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.fromInstanceMetadata=void 0;let t=qi(),n=Fs(),r=Is(),i=Ls(),a=Rs(),o=Ys(),s=Zs(),c=`/latest/meta-data/iam/security-credentials/`;e.fromInstanceMetadata=(e={})=>(0,s.staticStabilityProvider)(l(e),{logger:e.logger});let l=e=>{let t=!1,{timeout:n,maxRetries:r}=(0,i.providerConfigFromInit)(e),s=async(e,n)=>{let r=(await(0,a.retry)(async()=>{let e;try{e=await d(n)}catch(e){throw e.statusCode===401&&(t=!1),e}return e},e)).trim();return(0,a.retry)(async()=>{let e;try{e=await f(r,n)}catch(e){throw e.statusCode===401&&(t=!1),e}return e},e)};return async()=>{let e=await(0,o.getInstanceMetadataEndpoint)();if(t)return s(r,{...e,timeout:n});{let i;try{i=(await u({...e,timeout:n})).toString()}catch(i){if(i?.statusCode===400)throw Object.assign(i,{message:`EC2 Metadata token request returned error`});return(i.message===`TimeoutError`||[403,404,405].includes(i.statusCode))&&(t=!0),s(r,{...e,timeout:n})}return s(r,{...e,headers:{"x-aws-ec2-metadata-token":i},timeout:n})}}},u=async e=>(0,n.httpRequest)({...e,path:`/latest/api/token`,method:`PUT`,headers:{"x-aws-ec2-metadata-token-ttl-seconds":`21600`}}),d=async e=>(await(0,n.httpRequest)({...e,path:c})).toString(),f=async(e,i)=>{let a=JSON.parse((await(0,n.httpRequest)({...i,path:c+e})).toString());if(!(0,r.isImdsCredentials)(a))throw new t.CredentialsProviderError(`Invalid response received from instance metadata service.`);return(0,r.fromImdsCredentials)(a)}})),$s=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0})})),ec=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.getInstanceMetadataEndpoint=e.httpRequest=void 0;let t=(N(),m(j));t.__exportStar(zs(),e),t.__exportStar(Qs(),e),t.__exportStar(Ls(),e),t.__exportStar($s(),e);var n=Fs();Object.defineProperty(e,`httpRequest`,{enumerable:!0,get:function(){return n.httpRequest}});var r=Ys();Object.defineProperty(e,`getInstanceMetadataEndpoint`,{enumerable:!0,get:function(){return r.getInstanceMetadataEndpoint}})})),tc=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.resolveCredentialSource=void 0;let t=vs(),n=ec(),r=qi();e.resolveCredentialSource=(e,i)=>{let a={EcsContainer:n.fromContainerMetadata,Ec2InstanceMetadata:n.fromInstanceMetadata,Environment:t.fromEnv};if(e in a)return a[e]();throw new r.CredentialsProviderError(`Unsupported credential source in profile ${i}. Got ${e}, expected EcsContainer or Ec2InstanceMetadata or Environment.`)}})),nc=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.resolveAssumeRoleCredentials=e.isAssumeRoleProfile=void 0;let t=qi(),n=Ps(),r=tc(),i=xu();e.isAssumeRoleProfile=e=>!!e&&typeof e==`object`&&typeof e.role_arn==`string`&&[`undefined`,`string`].indexOf(typeof e.role_session_name)>-1&&[`undefined`,`string`].indexOf(typeof e.external_id)>-1&&[`undefined`,`string`].indexOf(typeof e.mfa_serial)>-1&&(a(e)||o(e));let a=e=>typeof e.source_profile==`string`&&e.credential_source===void 0,o=e=>typeof e.credential_source==`string`&&e.source_profile===void 0;e.resolveAssumeRoleCredentials=async(e,a,o,s={})=>{let c=a[e];if(!o.roleAssumer)throw new t.CredentialsProviderError(`Profile ${e} requires a role to be assumed, but no role assumption callback was provided.`,!1);let{source_profile:l}=c;if(l&&l in s)throw new t.CredentialsProviderError(`Detected a cycle attempting to resolve credentials for profile ${(0,n.getProfileName)(o)}. Profiles visited: `+Object.keys(s).join(`, `),!1);let u=l?(0,i.resolveProfileData)(l,a,o,{...s,[l]:!0}):(0,r.resolveCredentialSource)(c.credential_source,e)(),d={RoleArn:c.role_arn,RoleSessionName:c.role_session_name||`aws-sdk-js-${Date.now()}`,ExternalId:c.external_id},{mfa_serial:f}=c;if(f){if(!o.mfaCodeProvider)throw new t.CredentialsProviderError(`Profile ${e} requires multi-factor authentication, but no MFA code callback was provided.`,!1);d.SerialNumber=f,d.TokenCode=await o.mfaCodeProvider(f)}let p=await u;return o.roleAssumer(p,d)}})),rc=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.getValidatedProcessCredentials=void 0,e.getValidatedProcessCredentials=(e,t)=>{if(t.Version!==1)throw Error(`Profile ${e} credential_process did not return Version 1.`);if(t.AccessKeyId===void 0||t.SecretAccessKey===void 0)throw Error(`Profile ${e} credential_process returned invalid credentials.`);if(t.Expiration){let n=new Date;if(new Date(t.Expiration)<n)throw Error(`Profile ${e} credential_process returned expired credentials.`)}return{accessKeyId:t.AccessKeyId,secretAccessKey:t.SecretAccessKey,...t.SessionToken&&{sessionToken:t.SessionToken},...t.Expiration&&{expiration:new Date(t.Expiration)}}}})),ic=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.resolveProcessCredentials=void 0;let t=qi(),n=h(`child_process`),r=h(`util`),i=rc();e.resolveProcessCredentials=async(e,a)=>{let o=a[e];if(a[e]){let a=o.credential_process;if(a!==void 0){let o=(0,r.promisify)(n.exec);try{let{stdout:t}=await o(a),n;try{n=JSON.parse(t.trim())}catch{throw Error(`Profile ${e} credential_process returned invalid JSON.`)}return(0,i.getValidatedProcessCredentials)(e,n)}catch(e){throw new t.CredentialsProviderError(e.message)}}else throw new t.CredentialsProviderError(`Profile ${e} did not contain credential_process.`)}else throw new t.CredentialsProviderError(`Profile ${e} could not be found in shared credentials file.`)}})),ac=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.fromProcess=void 0;let t=Ps(),n=ic();e.fromProcess=(e={})=>async()=>{let r=await(0,t.parseKnownFiles)(e);return(0,n.resolveProcessCredentials)((0,t.getProfileName)(e),r)}})),oc=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),(N(),m(j)).__exportStar(ac(),e)})),sc=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.resolveProcessCredentials=e.isProcessProfile=void 0;let t=oc();e.isProcessProfile=e=>!!e&&typeof e==`object`&&typeof e.credential_process==`string`,e.resolveProcessCredentials=async(e,n)=>(0,t.fromProcess)({...e,profile:n})()})),cc=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.isSsoProfile=void 0,e.isSsoProfile=e=>e&&(typeof e.sso_start_url==`string`||typeof e.sso_account_id==`string`||typeof e.sso_session==`string`||typeof e.sso_region==`string`||typeof e.sso_role_name==`string`)})),lc=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.SSOServiceException=void 0;let t=P();e.SSOServiceException=class e extends t.ServiceException{constructor(t){super(t),Object.setPrototypeOf(this,e.prototype)}}})),uc=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.LogoutRequestFilterSensitiveLog=e.ListAccountsRequestFilterSensitiveLog=e.ListAccountRolesRequestFilterSensitiveLog=e.GetRoleCredentialsResponseFilterSensitiveLog=e.RoleCredentialsFilterSensitiveLog=e.GetRoleCredentialsRequestFilterSensitiveLog=e.UnauthorizedException=e.TooManyRequestsException=e.ResourceNotFoundException=e.InvalidRequestException=void 0;let t=P(),n=lc();e.InvalidRequestException=class e extends n.SSOServiceException{constructor(t){super({name:`InvalidRequestException`,$fault:`client`,...t}),this.name=`InvalidRequestException`,this.$fault=`client`,Object.setPrototypeOf(this,e.prototype)}},e.ResourceNotFoundException=class e extends n.SSOServiceException{constructor(t){super({name:`ResourceNotFoundException`,$fault:`client`,...t}),this.name=`ResourceNotFoundException`,this.$fault=`client`,Object.setPrototypeOf(this,e.prototype)}},e.TooManyRequestsException=class e extends n.SSOServiceException{constructor(t){super({name:`TooManyRequestsException`,$fault:`client`,...t}),this.name=`TooManyRequestsException`,this.$fault=`client`,Object.setPrototypeOf(this,e.prototype)}},e.UnauthorizedException=class e extends n.SSOServiceException{constructor(t){super({name:`UnauthorizedException`,$fault:`client`,...t}),this.name=`UnauthorizedException`,this.$fault=`client`,Object.setPrototypeOf(this,e.prototype)}},e.GetRoleCredentialsRequestFilterSensitiveLog=e=>({...e,...e.accessToken&&{accessToken:t.SENSITIVE_STRING}}),e.RoleCredentialsFilterSensitiveLog=e=>({...e,...e.secretAccessKey&&{secretAccessKey:t.SENSITIVE_STRING},...e.sessionToken&&{sessionToken:t.SENSITIVE_STRING}}),e.GetRoleCredentialsResponseFilterSensitiveLog=t=>({...t,...t.roleCredentials&&{roleCredentials:(0,e.RoleCredentialsFilterSensitiveLog)(t.roleCredentials)}}),e.ListAccountRolesRequestFilterSensitiveLog=e=>({...e,...e.accessToken&&{accessToken:t.SENSITIVE_STRING}}),e.ListAccountsRequestFilterSensitiveLog=e=>({...e,...e.accessToken&&{accessToken:t.SENSITIVE_STRING}}),e.LogoutRequestFilterSensitiveLog=e=>({...e,...e.accessToken&&{accessToken:t.SENSITIVE_STRING}})})),dc=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.de_LogoutCommand=e.de_ListAccountsCommand=e.de_ListAccountRolesCommand=e.de_GetRoleCredentialsCommand=e.se_LogoutCommand=e.se_ListAccountsCommand=e.se_ListAccountRolesCommand=e.se_GetRoleCredentialsCommand=void 0;let t=gn(),n=P(),r=uc(),i=lc();e.se_GetRoleCredentialsCommand=async(e,r)=>{let{hostname:i,protocol:a=`https`,port:o,path:s}=await r.endpoint(),c=(0,n.map)({},_,{"x-amz-sso_bearer_token":e.accessToken}),l=`${s?.endsWith(`/`)?s.slice(0,-1):s||``}/federation/credentials`,u=(0,n.map)({role_name:[,(0,n.expectNonNull)(e.roleName,`roleName`)],account_id:[,(0,n.expectNonNull)(e.accountId,`accountId`)]});return new t.HttpRequest({protocol:a,hostname:i,port:o,method:`GET`,headers:c,path:l,query:u,body:void 0})},e.se_ListAccountRolesCommand=async(e,r)=>{let{hostname:i,protocol:a=`https`,port:o,path:s}=await r.endpoint(),c=(0,n.map)({},_,{"x-amz-sso_bearer_token":e.accessToken}),l=`${s?.endsWith(`/`)?s.slice(0,-1):s||``}/assignment/roles`,u=(0,n.map)({next_token:[,e.nextToken],max_result:[()=>e.maxResults!==void 0,()=>e.maxResults.toString()],account_id:[,(0,n.expectNonNull)(e.accountId,`accountId`)]});return new t.HttpRequest({protocol:a,hostname:i,port:o,method:`GET`,headers:c,path:l,query:u,body:void 0})},e.se_ListAccountsCommand=async(e,r)=>{let{hostname:i,protocol:a=`https`,port:o,path:s}=await r.endpoint(),c=(0,n.map)({},_,{"x-amz-sso_bearer_token":e.accessToken}),l=`${s?.endsWith(`/`)?s.slice(0,-1):s||``}/assignment/accounts`,u=(0,n.map)({next_token:[,e.nextToken],max_result:[()=>e.maxResults!==void 0,()=>e.maxResults.toString()]});return new t.HttpRequest({protocol:a,hostname:i,port:o,method:`GET`,headers:c,path:l,query:u,body:void 0})},e.se_LogoutCommand=async(e,r)=>{let{hostname:i,protocol:a=`https`,port:o,path:s}=await r.endpoint(),c=(0,n.map)({},_,{"x-amz-sso_bearer_token":e.accessToken}),l=`${s?.endsWith(`/`)?s.slice(0,-1):s||``}/logout`;return new t.HttpRequest({protocol:a,hostname:i,port:o,method:`POST`,headers:c,path:l,body:void 0})},e.de_GetRoleCredentialsCommand=async(e,t)=>{if(e.statusCode!==200&&e.statusCode>=300)return a(e,t);let r=(0,n.map)({$metadata:m(e)}),i=(0,n.expectNonNull)((0,n.expectObject)(await v(e.body,t)),`body`),o=(0,n.take)(i,{roleCredentials:n._json});return Object.assign(r,o),r};let a=async(e,t)=>{let n={...e,body:await y(e.body,t)},r=b(e,n.body);switch(r){case`InvalidRequestException`:case`com.amazonaws.sso#InvalidRequestException`:throw await u(n,t);case`ResourceNotFoundException`:case`com.amazonaws.sso#ResourceNotFoundException`:throw await d(n,t);case`TooManyRequestsException`:case`com.amazonaws.sso#TooManyRequestsException`:throw await f(n,t);case`UnauthorizedException`:case`com.amazonaws.sso#UnauthorizedException`:throw await p(n,t);default:let i=n.body;return l({output:e,parsedBody:i,errorCode:r})}};e.de_ListAccountRolesCommand=async(e,t)=>{if(e.statusCode!==200&&e.statusCode>=300)return o(e,t);let r=(0,n.map)({$metadata:m(e)}),i=(0,n.expectNonNull)((0,n.expectObject)(await v(e.body,t)),`body`),a=(0,n.take)(i,{nextToken:n.expectString,roleList:n._json});return Object.assign(r,a),r};let o=async(e,t)=>{let n={...e,body:await y(e.body,t)},r=b(e,n.body);switch(r){case`InvalidRequestException`:case`com.amazonaws.sso#InvalidRequestException`:throw await u(n,t);case`ResourceNotFoundException`:case`com.amazonaws.sso#ResourceNotFoundException`:throw await d(n,t);case`TooManyRequestsException`:case`com.amazonaws.sso#TooManyRequestsException`:throw await f(n,t);case`UnauthorizedException`:case`com.amazonaws.sso#UnauthorizedException`:throw await p(n,t);default:let i=n.body;return l({output:e,parsedBody:i,errorCode:r})}};e.de_ListAccountsCommand=async(e,t)=>{if(e.statusCode!==200&&e.statusCode>=300)return s(e,t);let r=(0,n.map)({$metadata:m(e)}),i=(0,n.expectNonNull)((0,n.expectObject)(await v(e.body,t)),`body`),a=(0,n.take)(i,{accountList:n._json,nextToken:n.expectString});return Object.assign(r,a),r};let s=async(e,t)=>{let n={...e,body:await y(e.body,t)},r=b(e,n.body);switch(r){case`InvalidRequestException`:case`com.amazonaws.sso#InvalidRequestException`:throw await u(n,t);case`ResourceNotFoundException`:case`com.amazonaws.sso#ResourceNotFoundException`:throw await d(n,t);case`TooManyRequestsException`:case`com.amazonaws.sso#TooManyRequestsException`:throw await f(n,t);case`UnauthorizedException`:case`com.amazonaws.sso#UnauthorizedException`:throw await p(n,t);default:let i=n.body;return l({output:e,parsedBody:i,errorCode:r})}};e.de_LogoutCommand=async(e,t)=>{if(e.statusCode!==200&&e.statusCode>=300)return c(e,t);let r=(0,n.map)({$metadata:m(e)});return await h(e.body,t),r};let c=async(e,t)=>{let n={...e,body:await y(e.body,t)},r=b(e,n.body);switch(r){case`InvalidRequestException`:case`com.amazonaws.sso#InvalidRequestException`:throw await u(n,t);case`TooManyRequestsException`:case`com.amazonaws.sso#TooManyRequestsException`:throw await f(n,t);case`UnauthorizedException`:case`com.amazonaws.sso#UnauthorizedException`:throw await p(n,t);default:let i=n.body;return l({output:e,parsedBody:i,errorCode:r})}},l=(0,n.withBaseException)(i.SSOServiceException),u=async(e,t)=>{let i=(0,n.map)({}),a=e.body,o=(0,n.take)(a,{message:n.expectString});Object.assign(i,o);let s=new r.InvalidRequestException({$metadata:m(e),...i});return(0,n.decorateServiceException)(s,e.body)},d=async(e,t)=>{let i=(0,n.map)({}),a=e.body,o=(0,n.take)(a,{message:n.expectString});Object.assign(i,o);let s=new r.ResourceNotFoundException({$metadata:m(e),...i});return(0,n.decorateServiceException)(s,e.body)},f=async(e,t)=>{let i=(0,n.map)({}),a=e.body,o=(0,n.take)(a,{message:n.expectString});Object.assign(i,o);let s=new r.TooManyRequestsException({$metadata:m(e),...i});return(0,n.decorateServiceException)(s,e.body)},p=async(e,t)=>{let i=(0,n.map)({}),a=e.body,o=(0,n.take)(a,{message:n.expectString});Object.assign(i,o);let s=new r.UnauthorizedException({$metadata:m(e),...i});return(0,n.decorateServiceException)(s,e.body)},m=e=>({httpStatusCode:e.statusCode,requestId:e.headers[`x-amzn-requestid`]??e.headers[`x-amzn-request-id`]??e.headers[`x-amz-request-id`],extendedRequestId:e.headers[`x-amz-id-2`],cfId:e.headers[`x-amz-cf-id`]}),h=(e=new Uint8Array,t)=>e instanceof Uint8Array?Promise.resolve(e):t.streamCollector(e)||Promise.resolve(new Uint8Array),g=(e,t)=>h(e,t).then(e=>t.utf8Encoder(e)),_=e=>e!=null&&e!==``&&(!Object.getOwnPropertyNames(e).includes(`length`)||e.length!=0)&&(!Object.getOwnPropertyNames(e).includes(`size`)||e.size!=0),v=(e,t)=>g(e,t).then(e=>e.length?JSON.parse(e):{}),y=async(e,t)=>{let n=await v(e,t);return n.message=n.message??n.Message,n},b=(e,t)=>{let n=(e,t)=>Object.keys(e).find(e=>e.toLowerCase()===t.toLowerCase()),r=e=>{let t=e;return typeof t==`number`&&(t=t.toString()),t.indexOf(`,`)>=0&&(t=t.split(`,`)[0]),t.indexOf(`:`)>=0&&(t=t.split(`:`)[0]),t.indexOf(`#`)>=0&&(t=t.split(`#`)[1]),t},i=n(e.headers,`x-amzn-errortype`);if(i!==void 0)return r(e.headers[i]);if(t.code!==void 0)return r(t.code);if(t.__type!==void 0)return r(t.__type)}})),fc=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.GetRoleCredentialsCommand=void 0;let t=L(),n=F(),r=P(),i=uc(),a=dc();e.GetRoleCredentialsCommand=class e extends r.Command{static getEndpointParameterInstructions(){return{UseFIPS:{type:`builtInParams`,name:`useFipsEndpoint`},Endpoint:{type:`builtInParams`,name:`endpoint`},Region:{type:`builtInParams`,name:`region`},UseDualStack:{type:`builtInParams`,name:`useDualstackEndpoint`}}}constructor(e){super(),this.input=e}resolveMiddleware(r,a,o){this.middlewareStack.use((0,n.getSerdePlugin)(a,this.serialize,this.deserialize)),this.middlewareStack.use((0,t.getEndpointPlugin)(a,e.getEndpointParameterInstructions()));let s=r.concat(this.middlewareStack),{logger:c}=a,l={logger:c,clientName:`SSOClient`,commandName:`GetRoleCredentialsCommand`,inputFilterSensitiveLog:i.GetRoleCredentialsRequestFilterSensitiveLog,outputFilterSensitiveLog:i.GetRoleCredentialsResponseFilterSensitiveLog},{requestHandler:u}=a;return s.resolve(e=>u.handle(e.request,o||{}),l)}serialize(e,t){return(0,a.se_GetRoleCredentialsCommand)(e,t)}deserialize(e,t){return(0,a.de_GetRoleCredentialsCommand)(e,t)}}})),pc=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.ListAccountRolesCommand=void 0;let t=L(),n=F(),r=P(),i=uc(),a=dc();e.ListAccountRolesCommand=class e extends r.Command{static getEndpointParameterInstructions(){return{UseFIPS:{type:`builtInParams`,name:`useFipsEndpoint`},Endpoint:{type:`builtInParams`,name:`endpoint`},Region:{type:`builtInParams`,name:`region`},UseDualStack:{type:`builtInParams`,name:`useDualstackEndpoint`}}}constructor(e){super(),this.input=e}resolveMiddleware(r,a,o){this.middlewareStack.use((0,n.getSerdePlugin)(a,this.serialize,this.deserialize)),this.middlewareStack.use((0,t.getEndpointPlugin)(a,e.getEndpointParameterInstructions()));let s=r.concat(this.middlewareStack),{logger:c}=a,l={logger:c,clientName:`SSOClient`,commandName:`ListAccountRolesCommand`,inputFilterSensitiveLog:i.ListAccountRolesRequestFilterSensitiveLog,outputFilterSensitiveLog:e=>e},{requestHandler:u}=a;return s.resolve(e=>u.handle(e.request,o||{}),l)}serialize(e,t){return(0,a.se_ListAccountRolesCommand)(e,t)}deserialize(e,t){return(0,a.de_ListAccountRolesCommand)(e,t)}}})),mc=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.ListAccountsCommand=void 0;let t=L(),n=F(),r=P(),i=uc(),a=dc();e.ListAccountsCommand=class e extends r.Command{static getEndpointParameterInstructions(){return{UseFIPS:{type:`builtInParams`,name:`useFipsEndpoint`},Endpoint:{type:`builtInParams`,name:`endpoint`},Region:{type:`builtInParams`,name:`region`},UseDualStack:{type:`builtInParams`,name:`useDualstackEndpoint`}}}constructor(e){super(),this.input=e}resolveMiddleware(r,a,o){this.middlewareStack.use((0,n.getSerdePlugin)(a,this.serialize,this.deserialize)),this.middlewareStack.use((0,t.getEndpointPlugin)(a,e.getEndpointParameterInstructions()));let s=r.concat(this.middlewareStack),{logger:c}=a,l={logger:c,clientName:`SSOClient`,commandName:`ListAccountsCommand`,inputFilterSensitiveLog:i.ListAccountsRequestFilterSensitiveLog,outputFilterSensitiveLog:e=>e},{requestHandler:u}=a;return s.resolve(e=>u.handle(e.request,o||{}),l)}serialize(e,t){return(0,a.se_ListAccountsCommand)(e,t)}deserialize(e,t){return(0,a.de_ListAccountsCommand)(e,t)}}})),hc=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.LogoutCommand=void 0;let t=L(),n=F(),r=P(),i=uc(),a=dc();e.LogoutCommand=class e extends r.Command{static getEndpointParameterInstructions(){return{UseFIPS:{type:`builtInParams`,name:`useFipsEndpoint`},Endpoint:{type:`builtInParams`,name:`endpoint`},Region:{type:`builtInParams`,name:`region`},UseDualStack:{type:`builtInParams`,name:`useDualstackEndpoint`}}}constructor(e){super(),this.input=e}resolveMiddleware(r,a,o){this.middlewareStack.use((0,n.getSerdePlugin)(a,this.serialize,this.deserialize)),this.middlewareStack.use((0,t.getEndpointPlugin)(a,e.getEndpointParameterInstructions()));let s=r.concat(this.middlewareStack),{logger:c}=a,l={logger:c,clientName:`SSOClient`,commandName:`LogoutCommand`,inputFilterSensitiveLog:i.LogoutRequestFilterSensitiveLog,outputFilterSensitiveLog:e=>e},{requestHandler:u}=a;return s.resolve(e=>u.handle(e.request,o||{}),l)}serialize(e,t){return(0,a.se_LogoutCommand)(e,t)}deserialize(e,t){return(0,a.de_LogoutCommand)(e,t)}}})),gc=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.resolveClientEndpointParameters=void 0,e.resolveClientEndpointParameters=e=>({...e,useDualstackEndpoint:e.useDualstackEndpoint??!1,useFipsEndpoint:e.useFipsEndpoint??!1,defaultSigningName:`awsssoportal`})})),_c=u(((e,t)=>{t.exports={name:`@aws-sdk/client-sso`,description:`AWS SDK for JavaScript Sso Client for Node.js, Browser and React Native`,version:`3.329.0`,scripts:{build:`concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types'`,"build:cjs":`tsc -p tsconfig.cjs.json`,"build:docs":`typedoc`,"build:es":`tsc -p tsconfig.es.json`,"build:include:deps":`lerna run --scope $npm_package_name --include-dependencies build`,"build:types":`tsc -p tsconfig.types.json`,"build:types:downlevel":`downlevel-dts dist-types dist-types/ts3.4`,clean:`rimraf ./dist-* && rimraf *.tsbuildinfo`,"extract:docs":`api-extractor run --local`,"generate:client":`node ../../scripts/generate-clients/single-service --solo sso`},main:`./dist-cjs/index.js`,types:`./dist-types/index.d.ts`,module:`./dist-es/index.js`,sideEffects:!1,dependencies:{"@aws-crypto/sha256-browser":`3.0.0`,"@aws-crypto/sha256-js":`3.0.0`,"@aws-sdk/config-resolver":`3.329.0`,"@aws-sdk/fetch-http-handler":`3.329.0`,"@aws-sdk/hash-node":`3.329.0`,"@aws-sdk/invalid-dependency":`3.329.0`,"@aws-sdk/middleware-content-length":`3.329.0`,"@aws-sdk/middleware-endpoint":`3.329.0`,"@aws-sdk/middleware-host-header":`3.329.0`,"@aws-sdk/middleware-logger":`3.329.0`,"@aws-sdk/middleware-recursion-detection":`3.329.0`,"@aws-sdk/middleware-retry":`3.329.0`,"@aws-sdk/middleware-serde":`3.329.0`,"@aws-sdk/middleware-stack":`3.329.0`,"@aws-sdk/middleware-user-agent":`3.329.0`,"@aws-sdk/node-config-provider":`3.329.0`,"@aws-sdk/node-http-handler":`3.329.0`,"@aws-sdk/protocol-http":`3.329.0`,"@aws-sdk/smithy-client":`3.329.0`,"@aws-sdk/types":`3.329.0`,"@aws-sdk/url-parser":`3.329.0`,"@aws-sdk/util-base64":`3.310.0`,"@aws-sdk/util-body-length-browser":`3.310.0`,"@aws-sdk/util-body-length-node":`3.310.0`,"@aws-sdk/util-defaults-mode-browser":`3.329.0`,"@aws-sdk/util-defaults-mode-node":`3.329.0`,"@aws-sdk/util-endpoints":`3.329.0`,"@aws-sdk/util-retry":`3.329.0`,"@aws-sdk/util-user-agent-browser":`3.329.0`,"@aws-sdk/util-user-agent-node":`3.329.0`,"@aws-sdk/util-utf8":`3.310.0`,tslib:`^2.5.0`},devDependencies:{"@aws-sdk/service-client-documentation-generator":`3.310.0`,"@tsconfig/node14":`1.0.3`,"@types/node":`^14.14.31`,concurrently:`7.0.0`,"downlevel-dts":`0.10.1`,rimraf:`3.0.2`,typedoc:`0.23.23`,typescript:`~4.9.5`},engines:{node:`>=14.0.0`},typesVersions:{"<4.0":{"dist-types/*":[`dist-types/ts3.4/*`]}},files:[`dist-*/**`],author:{name:`AWS SDK for JavaScript Team`,url:`https://aws.amazon.com/javascript/`},license:`Apache-2.0`,browser:{"./dist-es/runtimeConfig":`./dist-es/runtimeConfig.browser`},"react-native":{"./dist-es/runtimeConfig":`./dist-es/runtimeConfig.native`},homepage:`https://github.com/aws/aws-sdk-js-v3/tree/main/clients/client-sso`,repository:{type:`git`,url:`https://github.com/aws/aws-sdk-js-v3.git`,directory:`clients/client-sso`}}})),vc=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.Hash=void 0;let t=Xi(),n=ea(),r=h(`buffer`),i=h(`crypto`);e.Hash=class{constructor(e,t){this.algorithmIdentifier=e,this.secret=t,this.reset()}update(e,t){this.hash.update((0,n.toUint8Array)(a(e,t)))}digest(){return Promise.resolve(this.hash.digest())}reset(){this.hash=this.secret?(0,i.createHmac)(this.algorithmIdentifier,a(this.secret)):(0,i.createHash)(this.algorithmIdentifier)}};function a(e,n){return r.Buffer.isBuffer(e)?e:typeof e==`string`?(0,t.fromString)(e,n):ArrayBuffer.isView(e)?(0,t.fromArrayBuffer)(e.buffer,e.byteOffset,e.byteLength):(0,t.fromArrayBuffer)(e)}})),yc=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.buildQueryString=void 0;let t=oa();function n(e){let n=[];for(let r of Object.keys(e).sort()){let i=e[r];if(r=(0,t.escapeUri)(r),Array.isArray(i))for(let e=0,a=i.length;e<a;e++)n.push(`${r}=${(0,t.escapeUri)(i[e])}`);else{let e=r;(i||typeof i==`string`)&&(e+=`=${(0,t.escapeUri)(i)}`),n.push(e)}}return n.join(`&`)}e.buildQueryString=n})),bc=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.NODEJS_TIMEOUT_ERROR_CODES=void 0,e.NODEJS_TIMEOUT_ERROR_CODES=[`ECONNRESET`,`EPIPE`,`ETIMEDOUT`]})),xc=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.getTransformedHeaders=void 0,e.getTransformedHeaders=e=>{let t={};for(let n of Object.keys(e)){let r=e[n];t[n]=Array.isArray(r)?r.join(`,`):r}return t}})),Sc=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.setConnectionTimeout=void 0,e.setConnectionTimeout=(e,t,n=0)=>{n&&e.on(`socket`,r=>{if(r.connecting){let i=setTimeout(()=>{e.destroy(),t(Object.assign(Error(`Socket timed out without establishing a connection within ${n} ms`),{name:`TimeoutError`}))},n);r.on(`connect`,()=>{clearTimeout(i)})}})}})),Cc=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.setSocketTimeout=void 0,e.setSocketTimeout=(e,t,n=0)=>{e.setTimeout(n,()=>{e.destroy(),t(Object.assign(Error(`Connection timed out after ${n} ms`),{name:`TimeoutError`}))})}})),wc=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.writeRequestBody=void 0;let t=h(`stream`);function n(e,t){(t.headers.Expect||t.headers.expect)===`100-continue`?e.on(`continue`,()=>{r(e,t.body)}):r(e,t.body)}e.writeRequestBody=n;function r(e,n){n instanceof t.Readable?n.pipe(e):n?e.end(Buffer.from(n)):e.end()}})),Tc=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.setSocketKeepAlive=void 0,e.setSocketKeepAlive=(e,{keepAlive:t,keepAliveMsecs:n})=>{t===!0&&e.on(`socket`,e=>{e.setKeepAlive(t,n||0)})}})),Ec=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.NodeHttpHandler=e.DEFAULT_REQUEST_TIMEOUT=void 0;let t=gn(),n=yc(),r=h(`http`),i=h(`https`),a=bc(),o=xc(),s=Sc(),c=Cc(),l=wc(),u=Tc();e.DEFAULT_REQUEST_TIMEOUT=0,e.NodeHttpHandler=class{constructor(e){this.metadata={handlerProtocol:`http/1.1`},this.configProvider=new Promise((t,n)=>{typeof e==`function`?e().then(e=>{t(this.resolveDefaultConfig(e))}).catch(n):t(this.resolveDefaultConfig(e))})}resolveDefaultConfig(e){let{requestTimeout:t,connectionTimeout:n,socketTimeout:a,httpAgent:o,httpsAgent:s}=e||{};return{connectionTimeout:n,requestTimeout:t??a,httpAgent:o||new r.Agent({keepAlive:!0,maxSockets:50}),httpsAgent:s||new i.Agent({keepAlive:!0,maxSockets:50})}}destroy(){var e,t;(e=this.config?.httpAgent)==null||e.destroy(),(t=this.config?.httpsAgent)==null||t.destroy()}async handle(e,{abortSignal:d}={}){return this.config||=await this.configProvider,new Promise((f,p)=>{if(!this.config)throw Error(`Node HTTP request handler config is not resolved`);if(d?.aborted){let e=Error(`Request aborted`);e.name=`AbortError`,p(e);return}let m=e.protocol===`https:`,h=(0,n.buildQueryString)(e.query||{}),g={headers:e.headers,host:e.hostname,method:e.method,path:h?`${e.path}?${h}`:e.path,port:e.port,agent:m?this.config.httpsAgent:this.config.httpAgent},_=(m?i.request:r.request)(g,e=>{f({response:new t.HttpResponse({statusCode:e.statusCode||-1,headers:(0,o.getTransformedHeaders)(e.headers),body:e})})});_.on(`error`,e=>{a.NODEJS_TIMEOUT_ERROR_CODES.includes(e.code)?p(Object.assign(e,{name:`TimeoutError`})):p(e)}),(0,s.setConnectionTimeout)(_,p,this.config.connectionTimeout),(0,c.setSocketTimeout)(_,p,this.config.requestTimeout),d&&(d.onabort=()=>{_.abort();let e=Error(`Request aborted`);e.name=`AbortError`,p(e)});let v=g.agent;typeof v==`object`&&`keepAlive`in v&&(0,u.setSocketKeepAlive)(_,{keepAlive:v.keepAlive,keepAliveMsecs:v.keepAliveMsecs}),(0,l.writeRequestBody)(_,e)})}}})),Dc=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.NodeHttp2ConnectionPool=void 0,e.NodeHttp2ConnectionPool=class{constructor(e){this.sessions=[],this.sessions=e??[]}poll(){if(this.sessions.length>0)return this.sessions.shift()}offerLast(e){this.sessions.push(e)}contains(e){return this.sessions.includes(e)}remove(e){this.sessions=this.sessions.filter(t=>t!==e)}[Symbol.iterator](){return this.sessions[Symbol.iterator]()}destroy(e){for(let t of this.sessions)t===e&&(t.destroyed||t.destroy())}}})),Oc=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.NodeHttp2ConnectionManager=void 0;let t=(N(),m(j)).__importDefault(h(`http2`)),n=Dc();e.NodeHttp2ConnectionManager=class{constructor(e){if(this.sessionCache=new Map,this.config=e,this.config.maxConcurrency&&this.config.maxConcurrency<=0)throw RangeError(`maxConcurrency must be greater than zero.`)}lease(e,r){let i=this.getUrlString(e),a=this.sessionCache.get(i);if(a){let e=a.poll();if(e&&!this.config.disableConcurrency)return e}let o=t.default.connect(i);this.config.maxConcurrency&&o.settings({maxConcurrentStreams:this.config.maxConcurrency},t=>{if(t)throw Error(`Fail to set maxConcurrentStreams to `+this.config.maxConcurrency+`when creating new session for `+e.destination.toString())}),o.unref();let s=()=>{o.destroy(),this.deleteSession(i,o)};o.on(`goaway`,s),o.on(`error`,s),o.on(`frameError`,s),o.on(`close`,()=>this.deleteSession(i,o)),r.requestTimeout&&o.setTimeout(r.requestTimeout,s);let c=this.sessionCache.get(i)||new n.NodeHttp2ConnectionPool;return c.offerLast(o),this.sessionCache.set(i,c),o}deleteSession(e,t){let n=this.sessionCache.get(e);n&&n.contains(t)&&(n.remove(t),this.sessionCache.set(e,n))}release(e,t){var n;let r=this.getUrlString(e);(n=this.sessionCache.get(r))==null||n.offerLast(t)}destroy(){for(let[e,t]of this.sessionCache){for(let e of t)e.destroyed||e.destroy(),t.remove(e);this.sessionCache.delete(e)}}setMaxConcurrentStreams(e){if(this.config.maxConcurrency&&this.config.maxConcurrency<=0)throw RangeError(`maxConcurrentStreams must be greater than zero.`);this.config.maxConcurrency=e}setDisableConcurrentStreams(e){this.config.disableConcurrency=e}getUrlString(e){return e.destination.toString()}}})),kc=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.NodeHttp2Handler=void 0;let t=gn(),n=yc(),r=h(`http2`),i=xc(),a=Oc(),o=wc();e.NodeHttp2Handler=class{constructor(e){this.metadata={handlerProtocol:`h2`},this.connectionManager=new a.NodeHttp2ConnectionManager({}),this.configProvider=new Promise((t,n)=>{typeof e==`function`?e().then(e=>{t(e||{})}).catch(n):t(e||{})})}destroy(){this.connectionManager.destroy()}async handle(e,{abortSignal:a}={}){this.config||(this.config=await this.configProvider,this.connectionManager.setDisableConcurrentStreams(this.config.disableConcurrentStreams||!1),this.config.maxConcurrentStreams&&this.connectionManager.setMaxConcurrentStreams(this.config.maxConcurrentStreams));let{requestTimeout:s,disableConcurrentStreams:c}=this.config;return new Promise((l,u)=>{let d=!1;if(a?.aborted){d=!0;let e=Error(`Request aborted`);e.name=`AbortError`,u(e);return}let{hostname:f,method:p,port:m,protocol:h,path:g,query:_}=e,v=`${h}//${f}${m?`:${m}`:``}`,y={destination:new URL(v)},b=this.connectionManager.lease(y,{requestTimeout:this.config?.sessionTimeout,disableConcurrentStreams:c||!1}),x=e=>{c&&this.destroySession(b),d=!0,u(e)},S=(0,n.buildQueryString)(_||{}),C=b.request({...e.headers,[r.constants.HTTP2_HEADER_PATH]:S?`${g}?${S}`:g,[r.constants.HTTP2_HEADER_METHOD]:p});b.ref(),C.on(`response`,e=>{let n=new t.HttpResponse({statusCode:e[`:status`]||-1,headers:(0,i.getTransformedHeaders)(e),body:C});d=!0,l({response:n}),c&&(b.close(),this.connectionManager.deleteSession(v,b))}),s&&C.setTimeout(s,()=>{C.close();let e=Error(`Stream timed out because of no activity for ${s} ms`);e.name=`TimeoutError`,x(e)}),a&&(a.onabort=()=>{C.close();let e=Error(`Request aborted`);e.name=`AbortError`,x(e)}),C.on(`frameError`,(e,t,n)=>{x(Error(`Frame type id ${e} in stream id ${n} has failed with code ${t}.`))}),C.on(`error`,x),C.on(`aborted`,()=>{x(Error(`HTTP/2 stream is abnormally aborted in mid-communication with result code ${C.rstCode}.`))}),C.on(`close`,()=>{b.unref(),c&&b.destroy(),d||x(Error(`Unexpected error: http2 request did not get a response`))}),(0,o.writeRequestBody)(C,e)})}destroySession(e){e.destroyed||e.destroy()}}})),Ac=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.Collector=void 0;let t=h(`stream`);e.Collector=class extends t.Writable{constructor(){super(...arguments),this.bufferedBytes=[]}_write(e,t,n){this.bufferedBytes.push(e),n()}}})),jc=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.streamCollector=void 0;let t=Ac();e.streamCollector=e=>new Promise((n,r)=>{let i=new t.Collector;e.pipe(i),e.on(`error`,e=>{i.end(),r(e)}),i.on(`error`,r),i.on(`finish`,function(){n(new Uint8Array(Buffer.concat(this.bufferedBytes)))})})})),Mc=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=(N(),m(j));t.__exportStar(Ec(),e),t.__exportStar(kc(),e),t.__exportStar(jc(),e)})),Nc=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.calculateBodyLength=void 0;let t=h(`fs`);e.calculateBodyLength=e=>{if(!e)return 0;if(typeof e==`string`)return Buffer.from(e).length;if(typeof e.byteLength==`number`)return e.byteLength;if(typeof e.size==`number`)return e.size;if(typeof e.path==`string`||Buffer.isBuffer(e.path))return(0,t.lstatSync)(e.path).size;if(typeof e.fd==`number`)return(0,t.fstatSync)(e.fd).size;throw Error(`Body Length computation failed for ${e}`)}})),Pc=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),(N(),m(j)).__exportStar(Nc(),e)})),Fc=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.newLiftedPromise=e.makeSelfCleaningPromise=void 0;function t(e,t){return t?e.finally(()=>{t()}):e}e.makeSelfCleaningPromise=t;function n(e){let t,n,r=new Promise((e,r)=>{t=e,n=r});if(!t||!n)throw Error(`Failed to bind resolve and reject when making lifted promise`);return e&&e(t,n),{promise:r,resolve:t,reject:n}}e.newLiftedPromise=n})),Ic=u((e=>{var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__setModuleDefault||(Object.create?(function(e,t){Object.defineProperty(e,`default`,{enumerable:!0,value:t})}):function(e,t){e.default=t}),r=e&&e.__importStar||function(e){if(e&&e.__esModule)return e;var r={};if(e!=null)for(var i in e)i!==`default`&&Object.prototype.hasOwnProperty.call(e,i)&&t(r,e,i);return n(r,e),r};Object.defineProperty(e,`__esModule`,{value:!0}),e.newCancellablePromiseFromNextEvent=e.CancelController=e.EVENT_NAME=void 0;let i=h(`events`),a=r(Fc());e.EVENT_NAME=`cancelled`,e.CancelController=class{constructor(e){this.cancelled=!1,e&&e.emitterFactory?this.emitter=e.emitterFactory():this.emitter=new i.EventEmitter}cancel(){this.cancelled||(this.cancelled=!0,this.emitter.emit(e.EVENT_NAME),this.emitter.removeAllListeners(e.EVENT_NAME))}hasBeenCancelled(){return this.cancelled}addListener(t){if(this.cancelled){t();return}return this.emitter.on(e.EVENT_NAME,t),()=>{this.emitter.removeListener(e.EVENT_NAME,t)}}};function o(e){let t,n,r=a.newLiftedPromise();return t=t=>{try{e.eventDataTransformer?r.resolve(e.eventDataTransformer(t)):r.resolve(t)}catch(e){r.reject(e)}},e.emitter.addListener(e.eventName,t),e.cancelController&&(n=e.cancelController.addListener(()=>{r.reject(e.cancelMessage)})),a.makeSelfCleaningPromise(r.promise,()=>{t&&e.emitter.removeListener(e.eventName,t),n&&n()})}e.newCancellablePromiseFromNextEvent=o})),Lc=u(((e,t)=>{t.exports={name:`aws-crt`,version:`1.30.0`,description:`NodeJS/browser bindings to the aws-c-* libraries`,homepage:`https://github.com/awslabs/aws-crt-nodejs`,repository:{type:`git`,url:`git+https://github.com/awslabs/aws-crt-nodejs.git`},contributors:[`AWS Common Runtime Team <aws-sdk-common-runtime@amazon.com>`],license:`Apache-2.0`,main:`./dist/index.js`,browser:`./dist.browser/browser.js`,types:`./dist/index.d.ts`,scripts:{tsc:`node ./scripts/tsc.js`,test:`npm run test:native`,"test:node":`npm run test:native`,"test:native":`npx jest --runInBand --verbose --config test/native/jest.config.js --forceExit`,"test:browser":`npx jest --runInBand --verbose --config test/browser/jest.config.js --forceExit`,"test:browser:ci":`npm run install:puppeteer && npm run test:browser`,"install:puppeteer":`npm install --save-dev jest-puppeteer puppeteer @types/puppeteer`,prepare:`node ./scripts/tsc.js && node ./scripts/install.js`,install:`node ./scripts/install.js`},overrides:{axios:`^1.12.2`},devDependencies:{"@types/crypto-js":`^3.1.43`,"@types/jest":`^27.0.1`,"@types/node":`^14.18.63`,"@types/prettier":`2.6.0`,"@types/puppeteer":`^5.4.7`,"@types/uuid":`^10.0.0`,"@types/ws":`^7.4.7`,"aws-sdk":`^2.1537.0`,"cmake-js":`^7.3.0`,"https-proxy-agent":`^5.0.1`,jest:`^27.2.1`,"jest-puppeteer":`^5.0.4`,"jest-runtime":`^27.2.1`,puppeteer:`^3.3.0`,tar:`^7.5.4`,"ts-jest":`^27.0.5`,typedoc:`^0.24.8`,"typedoc-plugin-merge-modules":`^5.1.0`,typescript:`^4.9.5`,uuid:`^10.0.0`,yargs:`^17.2.1`},dependencies:{"@aws-sdk/util-utf8-browser":`^3.259.0`,"@httptoolkit/websocket-stream":`^6.0.1`,axios:`^1.12.2`,buffer:`^6.0.3`,"crypto-js":`^4.2.0`,mqtt:`^4.3.8`,process:`^0.11.10`}}})),Rc=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.crt_version=e.package_info=e.is_browser=e.is_nodejs=void 0;function t(){return typeof process==`object`&&typeof process.versions==`object`&&process.versions.node!==void 0}e.is_nodejs=t;function n(){return!t()}e.is_browser=n;function r(){try{return Lc()}catch{return{name:`aws-crt-nodejs`,version:`UNKNOWN`}}}e.package_info=r;function i(){return r().version}e.crt_version=i})),zc=u((e=>{var t=e&&e.__awaiter||function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})};Object.defineProperty(e,`__esModule`,{value:!0}),e.using=void 0;function n(e,n){return t(this,void 0,void 0,function*(){try{yield n(e)}finally{e.close()}})}e.using=n})),Bc=u((e=>{var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__setModuleDefault||(Object.create?(function(e,t){Object.defineProperty(e,`default`,{enumerable:!0,value:t})}):function(e,t){e.default=t}),r=e&&e.__importStar||function(e){if(e&&e.__esModule)return e;var r={};if(e!=null)for(var i in e)i!==`default`&&Object.prototype.hasOwnProperty.call(e,i)&&t(r,e,i);return n(r,e),r},i=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,`__esModule`,{value:!0}),e.cRuntime=e.CRuntimeType=void 0;let a=r(h(`path`)),o=h(`os`),s=h(`fs`),c=h(`process`),l=i(h(`child_process`)),u=Object.freeze({NON_LINUX:`cruntime`,MUSL:`musl`,GLIBC:`glibc`});e.CRuntimeType=u;function d(){if((0,o.platform)()!==`linux`)return u.NON_LINUX;try{let e=l.default.spawnSync(`ldd`,[`--version`],{encoding:`utf8`});return(e.stdout+e.stderr).includes(u.MUSL)?u.MUSL:u.GLIBC}catch{return u.GLIBC}}let f=`Please upgrade to node >=10.16.0, or use the provided browser implementation.`;if(`napi`in c.versions){if(parseInt(c.versions.napi)<4)throw Error(`The AWS CRT native implementation requires that NAPI version 4 be present. `+f)}else throw Error(`The current runtime is not reporting an NAPI version. `+f);let p=d();e.cRuntime=p;let m=`${o.platform}-${o.arch}-${p}`,g=a.resolve(__dirname,`..`,`..`),_=a.join(g,`dist`);(0,s.existsSync)(_)&&(g=_);let v=a.resolve(g,`bin`),y=[a.join(v,m,`aws-crt-nodejs`)+`.node`],b=process.env.AWS_CRT_NODEJS_BINARY_RELATIVE_PATH;if(b){let e=a.resolve(__dirname,...b.split(a.sep));y.push(e)}process.env.AWS_CRT_NODEJS_BINARY_ABSOLUTE_PATH&&y.push(process.env.AWS_CRT_NODEJS_BINARY_ABSOLUTE_PATH);let x;for(let e of y)if((0,s.existsSync)(e)){x=h(e);break}if(x==null)throw Error(`AWS CRT binary not present in any of the following locations:
27
27
  `+y.join(`
28
- `));let S=i(Bc());process.versions.hasOwnProperty(`electron`)&&process.on(`exit`,function(){S.default.disable_threadsafe_function()}),e.default=x})),Vc=u((e=>{var t=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,`__esModule`,{value:!0}),e.CrtError=void 0;let n=t(Bc());var r=class extends Error{constructor(e){super(i(e)),this.error=e,this.error_code=a(e),this.error_name=o(e)}};e.CrtError=r;function i(e){return typeof e==`number`?n.default.error_code_to_string(e):e instanceof r?e.message:e.toString()}function a(e){if(typeof e==`number`)return e;if(e instanceof r)return e.error_code}function o(e){if(typeof e==`number`)return n.default.error_code_to_name(e);if(e instanceof r)return e.error_name}})),Hc=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.NativeResourceMixin=e.NativeResource=void 0,e.NativeResource=class{constructor(e){this.handle=e}native_handle(){return this.handle}};function t(e){return class extends e{constructor(...e){let t=e.shift();super(...e),this._handle=t}_super(e){this._handle=e}native_handle(){return this._handle}}}e.NativeResourceMixin=t})),Uc=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.logTrace=e.logDebug=e.logInfo=e.logWarn=e.logError=e.logFatal=e.setLogLevel=e.LogLevel=e.SocketDomain=e.SocketType=e.TlsVersion=void 0,(function(e){e[e.SSLv3=0]=`SSLv3`,e[e.TLSv1=1]=`TLSv1`,e[e.TLSv1_1=2]=`TLSv1_1`,e[e.TLSv1_2=3]=`TLSv1_2`,e[e.TLSv1_3=4]=`TLSv1_3`,e[e.Default=128]=`Default`})(e.TlsVersion||={}),(function(e){e[e.STREAM=0]=`STREAM`,e[e.DGRAM=1]=`DGRAM`})(e.SocketType||={}),(function(e){e[e.IPV4=0]=`IPV4`,e[e.IPV6=1]=`IPV6`,e[e.LOCAL=2]=`LOCAL`})(e.SocketDomain||={});var t;(function(e){e[e.NONE=0]=`NONE`,e[e.FATAL=1]=`FATAL`,e[e.ERROR=2]=`ERROR`,e[e.WARN=3]=`WARN`,e[e.INFO=4]=`INFO`,e[e.DEBUG=5]=`DEBUG`,e[e.TRACE=6]=`TRACE`})(t=e.LogLevel||={});let n=t.NONE;function r(e){n=e}e.setLogLevel=r;function i(e,r){if(n<t.FATAL)return;let i=new Date().toISOString();console.log(`[FATAL] [${i}] [${e}] - ${r}`)}e.logFatal=i;function a(e,r){if(n<t.ERROR)return;let i=new Date().toISOString();console.log(`[ERROR] [${i}] [${e}] - ${r}`)}e.logError=a;function o(e,r){if(n<t.WARN)return;let i=new Date().toISOString();console.log(`[WARN] [${i}] [${e}] - ${r}`)}e.logWarn=o;function s(e,r){if(n<t.INFO)return;let i=new Date().toISOString();console.log(`[INFO] [${i}] [${e}] - ${r}`)}e.logInfo=s;function c(e,r){if(n<t.DEBUG)return;let i=new Date().toISOString();console.log(`[DEBUG] [${i}] [${e}] - ${r}`)}e.logDebug=c;function l(e,r){if(n<t.TRACE)return;let i=new Date().toISOString();console.log(`[TRACE] [${i}] [${e}] - ${r}`)}e.logTrace=l})),Wc=u((e=>{var t=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,`__esModule`,{value:!0}),e.Pkcs11Lib=e.TlsConnectionOptions=e.ServerTlsContext=e.ClientTlsContext=e.TlsContext=e.TlsContextOptions=e.tls_cipher_preference_is_supported=e.TlsCipherPreference=e.SocketOptions=e.ClientBootstrap=e.InputStream=e.is_alpn_available=e.enable_logging=e.error_code_to_name=e.error_code_to_string=e.SocketDomain=e.SocketType=e.TlsVersion=e.LogLevel=e.setLogLevel=void 0;let n=t(Bc()),r=Hc(),i=Uc();var a=Uc();Object.defineProperty(e,`setLogLevel`,{enumerable:!0,get:function(){return a.setLogLevel}}),Object.defineProperty(e,`LogLevel`,{enumerable:!0,get:function(){return a.LogLevel}}),Object.defineProperty(e,`TlsVersion`,{enumerable:!0,get:function(){return a.TlsVersion}}),Object.defineProperty(e,`SocketType`,{enumerable:!0,get:function(){return a.SocketType}}),Object.defineProperty(e,`SocketDomain`,{enumerable:!0,get:function(){return a.SocketDomain}});let o=Vc();function s(e){return n.default.error_code_to_string(e)}e.error_code_to_string=s;function c(e){return n.default.error_code_to_name(e)}e.error_code_to_name=c;function l(e){n.default.io_logging_enable(e),(0,i.setLogLevel)(e)}e.enable_logging=l;function u(){return n.default.is_alpn_available()}e.is_alpn_available=u,e.InputStream=class extends r.NativeResource{constructor(e){super(n.default.io_input_stream_new(16*1024)),this.source=e,this.source.on(`data`,e=>{e=Buffer.isBuffer(e)?e:Buffer.from(e.toString()),n.default.io_input_stream_append(this.native_handle(),e)}),this.source.on(`end`,()=>{n.default.io_input_stream_append(this.native_handle(),void 0)})}},e.ClientBootstrap=class extends r.NativeResource{constructor(){super(n.default.io_client_bootstrap_new())}},e.SocketOptions=class extends r.NativeResource{constructor(e=i.SocketType.STREAM,t=i.SocketDomain.IPV6,r=5e3,a=!1,o=0,s=0,c=0){super(n.default.io_socket_options_new(e,t,r,o,s,c,a))}},(function(e){e[e.Default=0]=`Default`,e[e.PQ_TLSv1_0_2021_05=6]=`PQ_TLSv1_0_2021_05`,e[e.PQ_Default=8]=`PQ_Default`,e[e.TLSv1_2_2025_07=9]=`TLSv1_2_2025_07`})(e.TlsCipherPreference||={});function d(e){return n.default.io_tls_cipher_preference_is_supported(e)}e.tls_cipher_preference_is_supported=d;var f=class e{constructor(){this.min_tls_version=i.TlsVersion.Default,this.alpn_list=[],this.verify_peer=!0}override_default_trust_store_from_path(e,t){this.ca_dirpath=e,this.ca_filepath=t}override_default_trust_store(e){this.certificate_authority=e}static create_client_with_mtls(t,n){let r=new e;return r.certificate=t,r.private_key=n,r.verify_peer=!0,r}static create_client_with_mtls_from_path(t,n){let r=new e;return r.certificate_filepath=t,r.private_key_filepath=n,r.verify_peer=!0,r}static create_client_with_mtls_pkcs12_from_path(t,n){let r=new e;return r.pkcs12_filepath=t,r.pkcs12_password=n,r.verify_peer=!0,r}static create_client_with_mtls_pkcs_from_path(e,t){return this.create_client_with_mtls_pkcs12_from_path(e,t)}static create_client_with_mtls_pkcs11(t){let n=new e;return n.pkcs11_options=t,n.verify_peer=!0,n}static create_client_with_mtls_windows_cert_store_path(t){let n=new e;return n.windows_cert_store_path=t,n.verify_peer=!0,n}static create_server_with_mtls_from_path(t,n){let r=new e;return r.certificate_filepath=t,r.private_key_filepath=n,r.verify_peer=!1,r}static create_server_with_mtls_pkcs_from_path(t,n){let r=new e;return r.pkcs12_filepath=t,r.pkcs12_password=n,r.verify_peer=!1,r}};e.TlsContextOptions=f;var p=class extends r.NativeResource{constructor(e){if(e==null||e==null)throw new o.CrtError(`TlsContext constructor: ctx_opt not defined`);super(n.default.io_tls_ctx_new(e.min_tls_version,e.ca_filepath,e.ca_dirpath,e.certificate_authority,e.alpn_list&&e.alpn_list.length>0?e.alpn_list.join(`;`):void 0,e.certificate_filepath,e.certificate,e.private_key_filepath,e.private_key,e.pkcs12_filepath,e.pkcs12_password,e.pkcs11_options,e.windows_cert_store_path,e.tls_cipher_preference,e.verify_peer))}};e.TlsContext=p,e.ClientTlsContext=class extends p{constructor(e){e||(e=new f,e.verify_peer=!0),super(e)}},e.ServerTlsContext=class extends p{constructor(e){e||(e=new f,e.verify_peer=!1),super(e)}},e.TlsConnectionOptions=class extends r.NativeResource{constructor(e,t,r=[]){if(e==null||e==null)throw new o.CrtError(`TlsConnectionOptions constructor: tls_ctx not defined`);super(n.default.io_tls_connection_options_new(e.native_handle(),t,r&&r.length>0?r.join(`;`):void 0)),this.tls_ctx=e,this.server_name=t,this.alpn_list=r}};var m=class e extends r.NativeResource{constructor(t,r=e.InitializeFinalizeBehavior.DEFAULT){super(n.default.io_pkcs11_lib_new(t,r))}close(){n.default.io_pkcs11_lib_close(this.native_handle())}};e.Pkcs11Lib=m,(function(e){(function(e){e[e.DEFAULT=0]=`DEFAULT`,e[e.OMIT=1]=`OMIT`,e[e.STRICT=2]=`STRICT`})(e.InitializeFinalizeBehavior||={})})(m=e.Pkcs11Lib||={})})),Gc=u((e=>{var t=e&&e.__awaiter||function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})},n=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,`__esModule`,{value:!0}),e.aws_verify_sigv4a_signing=e.aws_sign_request=e.AwsSignedBodyHeaderType=e.AwsSignedBodyValue=e.AwsSignatureType=e.AwsSigningAlgorithm=e.AwsCredentialsProvider=void 0;let r=n(Bc()),i=Vc(),a=Wc();e.AwsCredentialsProvider=class extends r.default.AwsCredentialsProvider{static newDefault(e=void 0){return super.newDefault(e==null?null:e.native_handle())}static newStatic(e,t,n){return super.newStatic(e,t,n)}static newCognito(e){if(e==null||e==null)throw new i.CrtError(`AwsCredentialsProvider newCognito: Cognito config not defined`);return super.newCognito(e,e.tlsContext==null?new a.ClientTlsContext().native_handle():e.tlsContext.native_handle(),e.bootstrap==null?null:e.bootstrap.native_handle(),e.httpProxyOptions?e.httpProxyOptions.create_native_handle():null)}static newX509(e){if(e==null||e==null)throw new i.CrtError(`AwsCredentialsProvider newX509: X509 config not defined`);return super.newX509(e,e.tlsContext.native_handle(),e.httpProxyOptions?e.httpProxyOptions.create_native_handle():null)}},(function(e){e[e.SigV4=0]=`SigV4`,e[e.SigV4Asymmetric=1]=`SigV4Asymmetric`})(e.AwsSigningAlgorithm||={}),(function(e){e[e.HttpRequestViaHeaders=0]=`HttpRequestViaHeaders`,e[e.HttpRequestViaQueryParams=1]=`HttpRequestViaQueryParams`,e[e.HttpRequestChunk=2]=`HttpRequestChunk`,e[e.HttpRequestEvent=3]=`HttpRequestEvent`})(e.AwsSignatureType||={}),(function(e){e.EmptySha256=`e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855`,e.UnsignedPayload=`UNSIGNED-PAYLOAD`,e.StreamingAws4HmacSha256Payload=`STREAMING-AWS4-HMAC-SHA256-PAYLOAD`,e.StreamingAws4HmacSha256Events=`STREAMING-AWS4-HMAC-SHA256-EVENTS`})(e.AwsSignedBodyValue||={}),(function(e){e[e.None=0]=`None`,e[e.XAmzContentSha256=1]=`XAmzContentSha256`})(e.AwsSignedBodyHeaderType||={});function o(e,n){return t(this,void 0,void 0,function*(){return new Promise((t,a)=>{try{r.default.aws_sign_request(e,n,n=>{n==0?t(e):a(new i.CrtError(n))})}catch(e){a(e)}})})}e.aws_sign_request=o;function s(e,t,n,i,a,o){return r.default.aws_verify_sigv4a_signing(e,t,n,i,a,o)}e.aws_verify_sigv4a_signing=s})),Kc=u((e=>{var t=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,`__esModule`,{value:!0}),e.crc64nvme=e.crc32c=e.crc32=void 0;let n=t(Bc());function r(e,t){return n.default.checksums_crc32(e,t)}e.crc32=r;function i(e,t){return n.default.checksums_crc32c(e,t)}e.crc32c=i;function a(e,t){return n.default.checksums_crc64nvme(e,t)}e.crc64nvme=a})),qc=u((e=>{var t=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,`__esModule`,{value:!0}),e.native_memory_dump=e.native_memory=void 0;let n=t(Bc());function r(){return n.default.native_memory()}e.native_memory=r;function i(){return n.default.native_memory_dump()}e.native_memory_dump=i})),Jc=u((e=>{var t=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,`__esModule`,{value:!0}),e.hmac_sha256=e.Sha256Hmac=e.hash_sha1=e.Sha1Hash=e.hash_sha256=e.Sha256Hash=e.hash_md5=e.Md5Hash=void 0;let n=t(Bc()),r=Hc();var i=class extends r.NativeResource{update(e){n.default.hash_update(this.native_handle(),e)}finalize(e){return n.default.hash_digest(this.native_handle(),e)}constructor(e){super(e)}};e.Md5Hash=class extends i{constructor(){super(n.default.hash_md5_new())}};function a(e,t){return n.default.hash_md5_compute(e,t)}e.hash_md5=a,e.Sha256Hash=class extends i{constructor(){super(n.default.hash_sha256_new())}};function o(e,t){return n.default.hash_sha256_compute(e,t)}e.hash_sha256=o,e.Sha1Hash=class extends i{constructor(){super(n.default.hash_sha1_new())}};function s(e,t){return n.default.hash_sha1_compute(e,t)}e.hash_sha1=s;var c=class extends r.NativeResource{update(e){n.default.hmac_update(this.native_handle(),e)}finalize(e){return n.default.hmac_digest(this.native_handle(),e)}constructor(e){super(e)}};e.Sha256Hmac=class extends c{constructor(e){super(n.default.hmac_sha256_new(e))}};function l(e,t,r){return n.default.hmac_sha256_compute(e,t,r)}e.hmac_sha256=l})),Yc=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.BufferedEventEmitter=void 0;let t=h(`events`);var n=class{constructor(e,t){this.event=e,this.args=t}};e.BufferedEventEmitter=class extends t.EventEmitter{constructor(){super(),this.corked=!1}cork(){this.corked=!0}uncork(){for(this.corked=!1;this.eventQueue;){let e=this.eventQueue;super.emit(e.event,...e.args),this.eventQueue=this.eventQueue.next}}emit(e,...t){if(this.corked){let r=this.lastQueuedEvent;return this.lastQueuedEvent=new n(e,t),r?r.next=this.lastQueuedEvent:this.eventQueue=this.lastQueuedEvent,this.listeners(e).length>0}return super.emit(e,...t)}}})),Xc=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.unmarshalInt64BigintFromBuffer=e.marshalInt64BigintAsBuffer=e.MIN_INT64=e.MAX_INT64=e.MIN_INT32=e.MAX_INT32=e.MIN_INT16=e.MAX_INT16=e.MIN_INT8=e.MAX_INT8=void 0;let t=Vc();e.MAX_INT8=127,e.MIN_INT8=-128,e.MAX_INT16=32767,e.MIN_INT16=-32768,e.MAX_INT32=2147483647,e.MIN_INT32=-2147483648,e.MAX_INT64=BigInt(`9223372036854775807`),e.MIN_INT64=BigInt(`-9223372036854775808`);let n=BigInt(`256`);function r(r){if(r<e.MIN_INT64||r>e.MAX_INT64)throw new t.CrtError(`marshalInt64BigintAsBuffer expects a value that can fit in 8 bytes`);let i=new Uint8Array(8);if(r<0){r=-r-BigInt(1);for(let e=0;e<8;++e)i[e]=255-Number(r%n),r/=n}else for(let e=0;e<8;++e)i[e]=Number(r%n),r/=n;return i}e.marshalInt64BigintAsBuffer=r;function i(e){let r=BigInt(0),i=new Uint8Array(e);if(i.length!=8)throw new t.CrtError(`unmarshalInt64BigintFromBuffer expects a byte buffer of length 8`);let a=BigInt(1);if(i[7]&128){for(let e=0;e<i.length;++e){let t=BigInt(255-i[e]);r+=t*a,a*=n}r+=BigInt(1),r=-r}else for(let e=0;e<i.length;++e){let t=BigInt(i[e]);r+=t*a,a*=n}return r}e.unmarshalInt64BigintFromBuffer=i})),Zc=u((e=>{var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__setModuleDefault||(Object.create?(function(e,t){Object.defineProperty(e,`default`,{enumerable:!0,value:t})}):function(e,t){e.default=t}),r=e&&e.__importStar||function(e){if(e&&e.__esModule)return e;var r={};if(e!=null)for(var i in e)i!==`default`&&Object.prototype.hasOwnProperty.call(e,i)&&t(r,e,i);return n(r,e),r},i=e&&e.__awaiter||function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})},a=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,`__esModule`,{value:!0}),e.ClientStream=e.ClientConnection=e.MessageType=e.MessageFlags=e.Header=e.HeaderType=void 0;let o=Hc(),s=Yc(),c=Vc(),l=r(Wc()),u=r(Xc()),d=r(Fc()),f=a(Bc());var p;(function(e){e[e.BooleanTrue=0]=`BooleanTrue`,e[e.BooleanFalse=1]=`BooleanFalse`,e[e.Byte=2]=`Byte`,e[e.Int16=3]=`Int16`,e[e.Int32=4]=`Int32`,e[e.Int64=5]=`Int64`,e[e.ByteBuffer=6]=`ByteBuffer`,e[e.String=7]=`String`,e[e.Timestamp=8]=`Timestamp`,e[e.UUID=9]=`UUID`})(p=e.HeaderType||={});var m=class e{constructor(e,t,n){this.name=e,this.type=t,this.value=n}static validateHeaderName(e){if(e.length==0||e.length>127)throw new c.CrtError(`Event stream header name (${e}) is not valid`)}static newBoolean(t,n){return e.validateHeaderName(t),n?new e(t,p.BooleanTrue):new e(t,p.BooleanFalse)}static newByte(t,n){if(e.validateHeaderName(t),n>=u.MIN_INT8&&n<=u.MAX_INT8&&Number.isSafeInteger(n))return new e(t,p.Byte,n);throw new c.CrtError(`Illegal value for eventstream byte-valued header: ${n}`)}static newInt16(t,n){if(e.validateHeaderName(t),n>=u.MIN_INT16&&n<=u.MAX_INT16&&Number.isSafeInteger(n))return new e(t,p.Int16,n);throw new c.CrtError(`Illegal value for eventstream int16-valued header: ${n}`)}static newInt32(t,n){if(e.validateHeaderName(t),n>=u.MIN_INT32&&n<=u.MAX_INT32&&Number.isSafeInteger(n))return new e(t,p.Int32,n);throw new c.CrtError(`Illegal value for eventstream int32-valued header: ${n}`)}static newInt64FromNumber(t,n){if(e.validateHeaderName(t),Number.isSafeInteger(n))return new e(t,p.Int64,u.marshalInt64BigintAsBuffer(BigInt(n)));throw new c.CrtError(`Illegal value for eventstream int64-valued header: ${n}`)}static newInt64FromBigint(t,n){if(e.validateHeaderName(t),n>=u.MIN_INT64&&n<=u.MAX_INT64)return new e(t,p.Int64,u.marshalInt64BigintAsBuffer(n));throw new c.CrtError(`Illegal value for eventstream int64-valued header: ${n}`)}static newByteBuffer(t,n){return e.validateHeaderName(t),new e(t,p.ByteBuffer,n)}static newString(t,n){return e.validateHeaderName(t),new e(t,p.String,n)}static newTimeStampFromSecondsSinceEpoch(t,n){if(e.validateHeaderName(t),Number.isSafeInteger(n)&&n>=0)return new e(t,p.Timestamp,n);throw new c.CrtError(`Illegal value for eventstream timestamp-valued header: ${n}`)}static newTimeStampFromDate(t,n){e.validateHeaderName(t);let r=n.getTime();if(Number.isSafeInteger(r))return new e(t,p.Timestamp,r);throw new c.CrtError(`Illegal value for eventstream timestamp-valued header: ${n}`)}static newUUID(t,n){if(e.validateHeaderName(t),n.byteLength==16)return new e(t,p.UUID,n);throw new c.CrtError(`Illegal value for eventstream uuid-valued header: ${n}`)}toValue(e){if(e!=this.type)throw new c.CrtError(`Header of type (${this.type}) cannot be converted to type (${e})`);return this.value}asBoolean(){switch(this.type){case p.BooleanFalse:return!1;case p.BooleanTrue:return!0;default:throw new c.CrtError(`Header of type (${this.type}) cannot be converted to type (boolean)`)}}asByte(){return this.toValue(p.Byte)}asInt16(){return this.toValue(p.Int16)}asInt32(){return this.toValue(p.Int32)}asInt64(){return u.unmarshalInt64BigintFromBuffer(this.toValue(p.Int64))}asByteBuffer(){return this.toValue(p.ByteBuffer)}asString(){return this.toValue(p.String)}asTimestamp(){return this.toValue(p.Timestamp)}asUUID(){return this.toValue(p.UUID)}};e.Header=m,(function(e){e[e.None=0]=`None`,e[e.ConnectionAccepted=1]=`ConnectionAccepted`,e[e.TerminateStream=2]=`TerminateStream`})(e.MessageFlags||={}),(function(e){e[e.ApplicationMessage=0]=`ApplicationMessage`,e[e.ApplicationError=1]=`ApplicationError`,e[e.Ping=2]=`Ping`,e[e.PingResponse=3]=`PingResponse`,e[e.Connect=4]=`Connect`,e[e.ConnectAck=5]=`ConnectAck`,e[e.ProtocolError=6]=`ProtocolError`,e[e.InternalError=7]=`InternalError`})(e.MessageType||={});function h(e){return Array.from(e,e=>new m(e.name,e.type,e.value))}function g(e){let t={type:e.type,flags:e.flags,payload:e.payload};return e.headers&&(t.headers=h(e.headers)),t}var _;(function(e){e[e.None=0]=`None`,e[e.Connecting=1]=`Connecting`,e[e.Connected=2]=`Connected`,e[e.Disconnected=3]=`Disconnected`,e[e.Closed=4]=`Closed`})(_||={});var v=class e extends (0,o.NativeResourceMixin)(s.BufferedEventEmitter){constructor(t){if(t===void 0)throw new c.CrtError(`Invalid configuration passed to eventstream ClientConnection constructor`);super(),this.state=_.None,this._super(f.default.event_stream_client_connection_new(this,t,(t,n)=>{e._s_on_disconnect(t,n)},(t,n)=>{e._s_on_protocol_message(t,n)},t.socketOptions?t.socketOptions.native_handle():null,t.tlsCtx?t.tlsCtx.native_handle():null))}close(){this.state!=_.Closed&&(this.state=_.Closed,f.default.event_stream_client_connection_close(this.native_handle()))}connect(t){return i(this,void 0,void 0,function*(){let n,r=new Promise((r,i)=>{if(!t){i(new c.CrtError(`Invalid options passed to event stream ClientConnection.connect`));return}if(this.state!=_.None){i(new c.CrtError(`Event stream connection in a state (${this.state}) where connect() is not allowed.`));return}if(this.state=_.Connecting,t.cancelController&&(n=t.cancelController.addListener(()=>{i(new c.CrtError(`Event stream connection connect() cancelled by external request.`)),setImmediate(()=>{this.close()})}),!n))return;function a(t,n){return e._s_on_connection_setup(r,i,t,n)}try{f.default.event_stream_client_connection_connect(this.native_handle(),a)}catch(e){this.state=_.Disconnected,i(e)}});return d.makeSelfCleaningPromise(r,n)})}sendProtocolMessage(t){return i(this,void 0,void 0,function*(){let n,r=new Promise((r,i)=>{try{if(!t){i(new c.CrtError(`Invalid options passed to event stream ClientConnection.sendProtocolMessage`));return}if(!this.isConnected()){i(new c.CrtError(`Event stream connection in a state (${this.state}) where sending protocol messages is not allowed.`));return}if(t.cancelController&&(n=t.cancelController.addListener(()=>{i(new c.CrtError(`Event stream connection sendProtocolMessage() cancelled by external request.`)),setImmediate(()=>{this.close()})}),!n))return;function a(t){return e._s_on_connection_send_protocol_message_completion(r,i,t)}f.default.event_stream_client_connection_send_protocol_message(this.native_handle(),t,a)}catch(e){i(e)}});return d.makeSelfCleaningPromise(r,n)})}isConnected(){return this.state==_.Connected}newStream(){if(!this.isConnected())throw new c.CrtError(`Event stream connection in a state (${this.state}) where creating new streams is forbidden.`);return new b(this)}on(e,t){return super.on(e,t),this}static _s_on_connection_setup(e,t,n,r){r==0&&n.state==_.Connecting?(n.state=_.Connected,e()):(n.state!=_.Closed&&(n.state=_.Disconnected),t(l.error_code_to_string(r)))}static _s_on_disconnect(e,t){e.state!=_.Closed&&(e.state=_.Disconnected),process.nextTick(()=>{e.emit(`disconnection`,{errorCode:t})})}static _s_on_protocol_message(e,t){process.nextTick(()=>{e.emit(`protocolMessage`,{message:g(t)})})}static _s_on_connection_send_protocol_message_completion(e,t,n){n==0?e():t(l.error_code_to_string(n))}};e.ClientConnection=v,v.DISCONNECTION=`disconnection`,v.PROTOCOL_MESSAGE=`protocolMessage`;var y;(function(e){e[e.None=0]=`None`,e[e.Activating=1]=`Activating`,e[e.Activated=2]=`Activated`,e[e.Ended=3]=`Ended`,e[e.Closed=4]=`Closed`})(y||={});var b=class e extends (0,o.NativeResourceMixin)(s.BufferedEventEmitter){constructor(t){super(),this._super(f.default.event_stream_client_stream_new(this,t.native_handle(),t=>{e._s_on_stream_ended(t)},(t,n)=>{e._s_on_stream_message(t,n)})),this.state=y.None}close(){this.state!=y.Closed&&(this.state=y.Closed,f.default.event_stream_client_stream_close(this.native_handle()))}activate(t){return i(this,void 0,void 0,function*(){let n,r=new Promise((r,i)=>{try{if(this.state!=y.None){i(new c.CrtError(`Event stream in a state (${this.state}) where activation is not allowed.`));return}if(t===void 0){this.state=y.Ended,i(new c.CrtError(`Invalid options passed to ClientStream.activate`));return}if(this.state=y.Activating,t.cancelController&&(n=t.cancelController.addListener(()=>{i(new c.CrtError(`Event stream activate() cancelled by external request.`)),setImmediate(()=>{this.close()})}),!n))return;function a(t,n){return e._s_on_stream_activated(r,i,t,n)}f.default.event_stream_client_stream_activate(this.native_handle(),t,a)}catch(e){this.state=y.Ended,i(e)}});return d.makeSelfCleaningPromise(r,n)})}sendMessage(t){return i(this,void 0,void 0,function*(){let n,r=new Promise((r,i)=>{try{if(!t){i(new c.CrtError(`Invalid options passed to ClientStream.sendMessage`));return}if(this.state!=y.Activated){i(new c.CrtError(`Event stream in a state (${this.state}) where sending messages is not allowed.`));return}if(t.cancelController&&(n=t.cancelController.addListener(()=>{i(new c.CrtError(`Event stream sendMessage() cancelled by external request.`)),setImmediate(()=>{this.close()})}),!n))return;function a(t){return e._s_on_stream_send_message_completion(r,i,t)}f.default.event_stream_client_stream_send_message(this.native_handle(),t,a)}catch(e){i(e)}});return d.makeSelfCleaningPromise(r,n)})}isActive(){return this.state==y.Activated}on(e,t){return super.on(e,t),this}static _s_on_stream_activated(e,t,n,r){r==0&&n.state==y.Activating?(n.state=y.Activated,e()):(n.state!=y.Closed&&(n.state=y.Ended),t(l.error_code_to_string(r)))}static _s_on_stream_send_message_completion(e,t,n){n==0?e():t(l.error_code_to_string(n))}static _s_on_stream_ended(t){process.nextTick(()=>{t.emit(e.ENDED,{})})}static _s_on_stream_message(t,n){process.nextTick(()=>{t.emit(e.MESSAGE,{message:g(n)})})}};e.ClientStream=b,b.ENDED=`ended`,b.MESSAGE=`message`})),Qc=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.CommonHttpProxyOptions=e.HttpProxyAuthenticationType=e.HttpVersion=void 0,(function(e){e[e.Unknown=0]=`Unknown`,e[e.Http1_0=1]=`Http1_0`,e[e.Http1_1=2]=`Http1_1`,e[e.Http2=3]=`Http2`})(e.HttpVersion||={});var t;(function(e){e[e.None=0]=`None`,e[e.Basic=1]=`Basic`})(t=e.HttpProxyAuthenticationType||={}),e.CommonHttpProxyOptions=class{constructor(e,n,r=t.None,i,a){this.host_name=e,this.port=n,this.auth_method=r,this.auth_username=i,this.auth_password=a}}})),$c=u((e=>{var t=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,`__esModule`,{value:!0}),e.HttpClientConnectionManager=e.HttpClientStream=e.HttpStream=e.HttpClientConnection=e.HttpProxyOptions=e.HttpProxyConnectionType=e.HttpConnection=e.HttpRequest=e.HttpHeaders=e.HttpProxyAuthenticationType=void 0;let n=t(Bc()),r=Hc(),i=Vc(),a=Qc();var o=Qc();Object.defineProperty(e,`HttpProxyAuthenticationType`,{enumerable:!0,get:function(){return o.HttpProxyAuthenticationType}});let s=Yc();e.HttpHeaders=n.default.HttpHeaders;let c=n.default.HttpRequest;e.HttpRequest=class extends c{constructor(e,t,n,r){super(e,t,n,r?.native_handle())}};var l=class extends (0,r.NativeResourceMixin)(s.BufferedEventEmitter){constructor(e){super(),this._super(e)}close(){n.default.http_connection_close(this.native_handle())}on(e,t){return super.on(e,t),e==`connect`&&process.nextTick(()=>{this.uncork()}),this}};e.HttpConnection=l,l.CONNECT=`connect`,l.ERROR=`error`,l.CLOSE=`close`;var u;(function(e){e[e.Legacy=0]=`Legacy`,e[e.Forwarding=1]=`Forwarding`,e[e.Tunneling=2]=`Tunneling`})(u=e.HttpProxyConnectionType||={}),e.HttpProxyOptions=class extends a.CommonHttpProxyOptions{constructor(e,t,n=a.HttpProxyAuthenticationType.None,r,i,o,s){super(e,t,n,r,i),this.tls_opts=o,this.connection_type=s}create_native_handle(){return n.default.http_proxy_options_new(this.host_name,this.port,this.auth_method,this.auth_username,this.auth_password,this.tls_opts?this.tls_opts.native_handle():void 0,this.connection_type?this.connection_type:u.Legacy)}};var d=class extends l{_on_setup(e,t){if(t){this.emit(`error`,new i.CrtError(t));return}this.emit(`connect`)}_on_shutdown(e,t){if(t){this.emit(`error`,new i.CrtError(t));return}this.emit(`close`)}constructor(e,t,r,a,o,s,c){if(a==null||a==null)throw new i.CrtError(`HttpClientConnection constructor: socket_options not defined`);super(c||n.default.http_connection_new(e==null?null:e.native_handle(),(e,t)=>{this._on_setup(e,t)},(e,t)=>{this._on_shutdown(e,t)},t,r,a.native_handle(),o?o.native_handle():void 0,s?s.create_native_handle():void 0)),this.bootstrap=e,this.socket_options=a,this.tls_opts=o}request(e){let t;return t=new p(n.default.http_stream_new(this.native_handle(),e,e=>{t._on_complete(e)},(e,n)=>{t._on_response(e,n)},e=>{t._on_body(e)}),this,e)}};e.HttpClientConnection=d;var f=class extends (0,r.NativeResourceMixin)(s.BufferedEventEmitter){constructor(e,t){super(),this.connection=t,this._super(e),this.cork()}activate(){n.default.http_stream_activate(this.native_handle())}close(){n.default.http_stream_close(this.native_handle())}_on_body(e){this.emit(`data`,e)}_on_complete(e){if(e){this.emit(`error`,new i.CrtError(e)),this.close();return}this.on(`end`,()=>{this.close()}),this.emit(`end`)}};e.HttpStream=f;var p=class extends f{constructor(e,t,n){super(e,t),this.request=n}status_code(){return this.response_status_code}on(e,t){return super.on(e,t),e==`response`&&process.nextTick(()=>{this.uncork()}),this}_on_response(t,n){this.response_status_code=t;let r=new e.HttpHeaders(n);this.emit(`response`,t,r)}};e.HttpClientStream=p,p.RESPONSE=`response`,p.DATA=`data`,p.ERROR=`error`,p.END=`end`,p.HEADERS=`headers`,e.HttpClientConnectionManager=class extends r.NativeResource{constructor(e,t,r,a,o,s,c,l){if(s==null||s==null)throw new i.CrtError(`HttpClientConnectionManager constructor: socket_options not defined`);super(n.default.http_connection_manager_new(e==null?null:e.native_handle(),t,r,a,o,s.native_handle(),c?c.native_handle():void 0,l?l.create_native_handle():void 0,void 0)),this.bootstrap=e,this.host=t,this.port=r,this.max_connections=a,this.initial_window_size=o,this.socket_options=s,this.tls_opts=c,this.proxy_options=l,this.connections=new Map}acquire(){return new Promise((e,t)=>{n.default.http_connection_manager_acquire(this.native_handle(),(n,r)=>{if(r){t(new i.CrtError(r));return}let a=this.connections.get(n);a||(a=new d(this.bootstrap,this.host,this.port,this.socket_options,this.tls_opts,this.proxy_options,n),this.connections.set(n,a),a.on(`close`,()=>{this.connections.delete(n)})),e(a)})})}release(e){if(e==null||e==null)throw new i.CrtError(`HttpClientConnectionManager release: connection not defined`);n.default.http_connection_manager_release(this.native_handle(),e.native_handle())}close(){n.default.http_connection_manager_close(this.native_handle())}}})),el=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.DEFAULT_RECONNECT_MIN_SEC=e.DEFAULT_RECONNECT_MAX_SEC=e.MqttWill=e.QoS=void 0,(function(e){e[e.AtMostOnce=0]=`AtMostOnce`,e[e.AtLeastOnce=1]=`AtLeastOnce`,e[e.ExactlyOnce=2]=`ExactlyOnce`})(e.QoS||={}),e.MqttWill=class{constructor(e,t,n,r=!1){this.topic=e,this.qos=t,this.payload=n,this.retain=r}},e.DEFAULT_RECONNECT_MAX_SEC=128,e.DEFAULT_RECONNECT_MIN_SEC=1})),tl=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.set_defined_property=void 0;function t(e,t,n){return n===void 0||n==null?!1:(e[t]=n,!0)}e.set_defined_property=t})),nl=u((e=>{var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__setModuleDefault||(Object.create?(function(e,t){Object.defineProperty(e,`default`,{enumerable:!0,value:t})}):function(e,t){e.default=t}),r=e&&e.__importStar||function(e){if(e&&e.__esModule)return e;var r={};if(e!=null)for(var i in e)i!==`default`&&Object.prototype.hasOwnProperty.call(e,i)&&t(r,e,i);return n(r,e),r};Object.defineProperty(e,`__esModule`,{value:!0}),e.extractRegionFromEndpoint=e.buildMqtt5FinalUsername=e.canonicalizeCustomAuthConfig=e.canonicalizeCustomAuthTokenSignature=e.populate_username_string_with_custom_authorizer=e.is_string_and_not_empty=e.add_to_username_parameter=void 0;let i=r(Rc()),a=r(tl());function o(e,t,n){let r=e;return r.indexOf(`?`)==-1?r+=`?`:r+=`&`,t.indexOf(n)==-1?r+n+t:r+t}e.add_to_username_parameter=o;function s(e){return e!=null&&typeof e==`string`&&e!=``}e.is_string_and_not_empty=s;function c(e,t,n,r,i,a,c){let l=``;if(e&&(l+=e),s(t)==0?s(i)&&i&&(l+=i):l+=t,s(n)&&n&&(l=o(l,n,`x-amz-customauthorizer-name=`)),(s(r)||s(c)||s(a))&&(!c||!a||!r))throw Error(`Signing-based custom authentication requires all token-related properties to be set`);return s(r)&&r&&(l=o(l,r,`x-amz-customauthorizer-signature=`)),s(c)&&s(a)&&(l=o(l,c,a+`=`)),l}e.populate_username_string_with_custom_authorizer=c;function l(e){if(!(e===void 0||e==null))return e.indexOf(`%`)==-1?encodeURIComponent(e):e}e.canonicalizeCustomAuthTokenSignature=l;function u(e){let t={};return a.set_defined_property(t,`authorizerName`,e.authorizerName),a.set_defined_property(t,`username`,e.username),a.set_defined_property(t,`password`,e.password),a.set_defined_property(t,`tokenKeyName`,e.tokenKeyName),a.set_defined_property(t,`tokenValue`,e.tokenValue),a.set_defined_property(t,`tokenSignature`,l(e.tokenSignature)),t}e.canonicalizeCustomAuthConfig=u;function d(e,t,n){t&&n.push([e,t])}function f(e){let t=``,n=[];if(e){let r=!1;if((e.tokenValue||e.tokenKeyName||e.tokenSignature)&&(r=!0,!e.tokenValue||!e.tokenKeyName||!e.tokenSignature))throw Error(`Token-based custom authentication requires all token-related properties to be set`);let i=(e.username??``).split(`?`),a=i.slice(1);if(t=i[0],a.length>1)throw Error(`Custom auth username property value is invalid`);a.length==1&&a[0].split(`&`).forEach((e,t,r)=>{let i=e.split(`=`);n.push([i[0],i[1]??``])}),d(`x-amz-customauthorizer-name`,e.authorizerName,n),r&&(d(e.tokenKeyName,e.tokenValue,n),d(`x-amz-customauthorizer-signature`,e.tokenSignature,n))}return n.push([`SDK`,`NodeJSv2`]),n.push([`Version`,i.crt_version()]),(t??``)+`?`+n.map(e=>`${e[0]}=${e[1]}`).join(`&`)}e.buildMqtt5FinalUsername=f;function p(e){let t=e.match(/^[\w\-]+\.[\w\-]+\.([\w+\-]+)\./);if(t)return t[1];throw Error(`AWS region could not be extracted from endpoint. Use 'region' property on WebsocketConfig to set manually.`)}e.extractRegionFromEndpoint=p})),rl=u((e=>{var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__setModuleDefault||(Object.create?(function(e,t){Object.defineProperty(e,`default`,{enumerable:!0,value:t})}):function(e,t){e.default=t}),r=e&&e.__importStar||function(e){if(e&&e.__esModule)return e;var r={};if(e!=null)for(var i in e)i!==`default`&&Object.prototype.hasOwnProperty.call(e,i)&&t(r,e,i);return n(r,e),r},i=e&&e.__awaiter||function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})};Object.defineProperty(e,`__esModule`,{value:!0}),e.AwsIotMqttConnectionConfigBuilder=void 0;let a=el(),o=r(Wc()),s=Wc(),c=r(Rc()),l=Vc(),u=Gc(),d=r(nl());e.AwsIotMqttConnectionConfigBuilder=class e{constructor(e){this.tls_ctx_options=e,this.params={client_id:``,host_name:``,socket_options:new o.SocketOptions,port:8883,use_websocket:!1,clean_session:!1,keep_alive:void 0,will:void 0,username:``,password:void 0,tls_ctx:void 0,reconnect_min_sec:a.DEFAULT_RECONNECT_MIN_SEC,reconnect_max_sec:a.DEFAULT_RECONNECT_MAX_SEC},this.is_using_custom_authorizer=!1}static new_mtls_builder_from_path(t,n){let r=new e(s.TlsContextOptions.create_client_with_mtls_from_path(t,n));return r.params.port=8883,o.is_alpn_available()&&r.tls_ctx_options.alpn_list.unshift(`x-amzn-mqtt-ca`),r}static new_mtls_builder(t,n){let r=new e(s.TlsContextOptions.create_client_with_mtls(t,n));return r.params.port=8883,o.is_alpn_available()&&r.tls_ctx_options.alpn_list.unshift(`x-amzn-mqtt-ca`),r}static new_mtls_pkcs11_builder(t){let n=new e(s.TlsContextOptions.create_client_with_mtls_pkcs11(t));return n.params.port=8883,o.is_alpn_available()&&n.tls_ctx_options.alpn_list.unshift(`x-amzn-mqtt-ca`),n}static new_mtls_pkcs12_builder(t){let n=new e(s.TlsContextOptions.create_client_with_mtls_pkcs12_from_path(t.pkcs12_file,t.pkcs12_password));return n.params.port=8883,o.is_alpn_available()&&n.tls_ctx_options.alpn_list.unshift(`x-amzn-mqtt-ca`),n}static new_mtls_windows_cert_store_path_builder(t){let n=new e(s.TlsContextOptions.create_client_with_mtls_windows_cert_store_path(t));return n.params.port=8883,o.is_alpn_available()&&n.tls_ctx_options.alpn_list.unshift(`x-amzn-mqtt-ca`),n}static new_default_builder(){return new e(new o.TlsContextOptions)}static new_websocket_builder(...e){return this.new_with_websockets(...e)}static configure_websocket_handshake(e,t){if(t){if(e==null||e==null)throw new l.CrtError(`AwsIotMqttConnectionConfigBuilder configure_websocket_handshake: builder not defined`);e.params.websocket_handshake_transform=(e,n)=>i(this,void 0,void 0,function*(){let r=t.create_signing_config?.call(t)??{algorithm:u.AwsSigningAlgorithm.SigV4,signature_type:u.AwsSignatureType.HttpRequestViaQueryParams,provider:t.credentials_provider,region:t.region,service:t.service??`iotdevicegateway`,signed_body_value:u.AwsSignedBodyValue.EmptySha256,omit_session_token:!0};try{yield(0,u.aws_sign_request)(e,r),n()}catch(e){e instanceof l.CrtError?n(e.error_code):n(3)}})}return e}static new_with_websockets(t){let n=t?.tls_ctx_options;n||(n=new s.TlsContextOptions,n.alpn_list=[]);let r=new e(n);return r.params.use_websocket=!0,r.params.proxy_options=t?.proxy_options,r.tls_ctx_options&&(r.params.port=443),this.configure_websocket_handshake(r,t),r}static new_builder_for_websocket(){return this.new_with_websockets()}with_certificate_authority_from_path(e,t){return this.tls_ctx_options.override_default_trust_store_from_path(e,t),this}with_certificate_authority(e){return this.tls_ctx_options.override_default_trust_store(e),this}with_tls_cipher_preference(e){return this.tls_ctx_options.tls_cipher_preference=e,this}with_endpoint(e){return this.params.host_name=e,this}with_port(e){return this.params.port=e,this}with_client_id(e){return this.params.client_id=e,this}with_clean_session(e){return this.params.clean_session=e,this}with_keep_alive_seconds(e){return this.params.keep_alive=e,this}with_timeout_ms(e){return this.with_ping_timeout_ms(e),this}with_ping_timeout_ms(e){return this.params.ping_timeout=e,this}with_protocol_operation_timeout_ms(e){return this.params.protocol_operation_timeout=e,this}with_will(e){return this.params.will=e,this}with_socket_options(e){return this.params.socket_options=e,this}with_credentials(t,n,r,i){return e.configure_websocket_handshake(this,{credentials_provider:u.AwsCredentialsProvider.newStatic(n,r,i),region:t,service:`iotdevicegateway`})}with_http_proxy_options(e){return this.params.proxy_options=e,this}with_custom_authorizer(e,t,n,r,i,a){this.is_using_custom_authorizer=!0;let o=d.canonicalizeCustomAuthTokenSignature(n),s=d.populate_username_string_with_custom_authorizer(``,e,t,o,this.params.username,i,a);return this.params.username=s,this.params.password=r,this.params.use_websocket||(this.tls_ctx_options.alpn_list=[`mqtt`]),this.params.port=443,this}with_username(e){return this.params.username=e,this}with_password(e){return this.params.password=e,this}with_reconnect_max_sec(e){return this.params.reconnect_max_sec=e,this}with_reconnect_min_sec(e){return this.params.reconnect_min_sec=e,this}build(){if(this.params.client_id===void 0||this.params.host_name===void 0)throw`client_id and endpoint are required`;return this.is_using_custom_authorizer==0&&d.is_string_and_not_empty(this.params.username)&&(this.params.username?.indexOf(`x-amz-customauthorizer-name=`)!=-1||this.params.username?.indexOf(`x-amz-customauthorizer-signature=`)!=-1)&&(this.is_using_custom_authorizer=!0),this.is_using_custom_authorizer==1&&this.params.port!=443&&console.log(`Warning: Attempting to connect to authorizer with unsupported port. Port is not 443...`),this.params.tls_ctx===void 0&&(this.params.tls_ctx=new o.ClientTlsContext(this.tls_ctx_options)),d.is_string_and_not_empty(this.params.username)==0?this.params.username=`?SDK=NodeJSv2&Version=`:this.params.username?.indexOf(`?`)==-1?this.params.username+=`?SDK=NodeJSv2&Version=`:this.params.username+=`&SDK=NodeJSv2&Version=`,this.params.username+=c.crt_version(),this.params}}})),il=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.isValidTopic=e.isValidTopicFilter=e.DEFAULT_KEEP_ALIVE=e.normalize_payload_to_buffer=e.normalize_payload=void 0;function t(e){if(e instanceof Buffer||typeof e==`string`)return e;if(ArrayBuffer.isView(e)){let t=e;return Buffer.from(t.buffer,t.byteOffset,t.byteLength)}if(e instanceof ArrayBuffer)return Buffer.from(e);if(typeof e==`object`)return JSON.stringify(e);if(!e)return``;throw TypeError(`payload parameter must be a string, object, or DataView.`)}e.normalize_payload=t;function n(e){let n=t(e);return typeof n==`string`?Buffer.from(n):n}e.normalize_payload_to_buffer=n,e.DEFAULT_KEEP_ALIVE=1200;function r(e,t){if(e.length===0||e.length>65535)return!1;let n=!1;for(let r of e.split(`/`)){if(n)return!1;if(r.length!==0){if(r.includes(`+`)&&(!t||r.length>1))return!1;if(r.includes(`#`)){if(!t||r.length>1)return!1;n=!0}}}return!0}function i(e){return typeof e==`string`?r(e,!0):!1}e.isValidTopicFilter=i;function a(e){return typeof e==`string`?r(e,!1):!1}e.isValidTopic=a})),al=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.InboundTopicAliasBehaviorType=e.OutboundTopicAliasBehaviorType=e.RetryJitterType=e.ClientSessionBehavior=void 0,(function(e){e[e.Default=0]=`Default`,e[e.Clean=1]=`Clean`,e[e.RejoinPostSuccess=2]=`RejoinPostSuccess`,e[e.RejoinAlways=3]=`RejoinAlways`})(e.ClientSessionBehavior||={}),(function(e){e[e.Default=0]=`Default`,e[e.None=1]=`None`,e[e.Full=2]=`Full`,e[e.Decorrelated=3]=`Decorrelated`})(e.RetryJitterType||={}),(function(e){e[e.Default=0]=`Default`,e[e.Manual=1]=`Manual`,e[e.LRU=2]=`LRU`,e[e.Disabled=3]=`Disabled`})(e.OutboundTopicAliasBehaviorType||={}),(function(e){e[e.Default=0]=`Default`,e[e.Enabled=1]=`Enabled`,e[e.Disabled=2]=`Disabled`})(e.InboundTopicAliasBehaviorType||={})})),ol=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.PacketType=e.RetainHandlingType=e.QoS=e.PayloadFormatIndicator=e.isSuccessfulPubackReasonCode=e.PubackReasonCode=e.isSuccessfulUnsubackReasonCode=e.UnsubackReasonCode=e.isSuccessfulSubackReasonCode=e.SubackReasonCode=e.isSuccessfulDisconnectReasonCode=e.DisconnectReasonCode=e.isSuccessfulConnectReasonCode=e.ConnectReasonCode=void 0,(function(e){e[e.Success=0]=`Success`,e[e.UnspecifiedError=128]=`UnspecifiedError`,e[e.MalformedPacket=129]=`MalformedPacket`,e[e.ProtocolError=130]=`ProtocolError`,e[e.ImplementationSpecificError=131]=`ImplementationSpecificError`,e[e.UnsupportedProtocolVersion=132]=`UnsupportedProtocolVersion`,e[e.ClientIdentifierNotValid=133]=`ClientIdentifierNotValid`,e[e.BadUsernameOrPassword=134]=`BadUsernameOrPassword`,e[e.NotAuthorized=135]=`NotAuthorized`,e[e.ServerUnavailable=136]=`ServerUnavailable`,e[e.ServerBusy=137]=`ServerBusy`,e[e.Banned=138]=`Banned`,e[e.BadAuthenticationMethod=140]=`BadAuthenticationMethod`,e[e.TopicNameInvalid=144]=`TopicNameInvalid`,e[e.PacketTooLarge=149]=`PacketTooLarge`,e[e.QuotaExceeded=151]=`QuotaExceeded`,e[e.PayloadFormatInvalid=153]=`PayloadFormatInvalid`,e[e.RetainNotSupported=154]=`RetainNotSupported`,e[e.QosNotSupported=155]=`QosNotSupported`,e[e.UseAnotherServer=156]=`UseAnotherServer`,e[e.ServerMoved=157]=`ServerMoved`,e[e.ConnectionRateExceeded=159]=`ConnectionRateExceeded`})(e.ConnectReasonCode||={});function t(e){return e<128}e.isSuccessfulConnectReasonCode=t,(function(e){e[e.NormalDisconnection=0]=`NormalDisconnection`,e[e.DisconnectWithWillMessage=4]=`DisconnectWithWillMessage`,e[e.UnspecifiedError=128]=`UnspecifiedError`,e[e.MalformedPacket=129]=`MalformedPacket`,e[e.ProtocolError=130]=`ProtocolError`,e[e.ImplementationSpecificError=131]=`ImplementationSpecificError`,e[e.NotAuthorized=135]=`NotAuthorized`,e[e.ServerBusy=137]=`ServerBusy`,e[e.ServerShuttingDown=139]=`ServerShuttingDown`,e[e.KeepAliveTimeout=141]=`KeepAliveTimeout`,e[e.SessionTakenOver=142]=`SessionTakenOver`,e[e.TopicFilterInvalid=143]=`TopicFilterInvalid`,e[e.TopicNameInvalid=144]=`TopicNameInvalid`,e[e.ReceiveMaximumExceeded=147]=`ReceiveMaximumExceeded`,e[e.TopicAliasInvalid=148]=`TopicAliasInvalid`,e[e.PacketTooLarge=149]=`PacketTooLarge`,e[e.MessageRateTooHigh=150]=`MessageRateTooHigh`,e[e.QuotaExceeded=151]=`QuotaExceeded`,e[e.AdministrativeAction=152]=`AdministrativeAction`,e[e.PayloadFormatInvalid=153]=`PayloadFormatInvalid`,e[e.RetainNotSupported=154]=`RetainNotSupported`,e[e.QosNotSupported=155]=`QosNotSupported`,e[e.UseAnotherServer=156]=`UseAnotherServer`,e[e.ServerMoved=157]=`ServerMoved`,e[e.SharedSubscriptionsNotSupported=158]=`SharedSubscriptionsNotSupported`,e[e.ConnectionRateExceeded=159]=`ConnectionRateExceeded`,e[e.MaximumConnectTime=160]=`MaximumConnectTime`,e[e.SubscriptionIdentifiersNotSupported=161]=`SubscriptionIdentifiersNotSupported`,e[e.WildcardSubscriptionsNotSupported=162]=`WildcardSubscriptionsNotSupported`})(e.DisconnectReasonCode||={});function n(e){return e<128}e.isSuccessfulDisconnectReasonCode=n,(function(e){e[e.GrantedQoS0=0]=`GrantedQoS0`,e[e.GrantedQoS1=1]=`GrantedQoS1`,e[e.GrantedQoS2=2]=`GrantedQoS2`,e[e.UnspecifiedError=128]=`UnspecifiedError`,e[e.ImplementationSpecificError=131]=`ImplementationSpecificError`,e[e.NotAuthorized=135]=`NotAuthorized`,e[e.TopicFilterInvalid=143]=`TopicFilterInvalid`,e[e.PacketIdentifierInUse=145]=`PacketIdentifierInUse`,e[e.QuotaExceeded=151]=`QuotaExceeded`,e[e.SharedSubscriptionsNotSupported=158]=`SharedSubscriptionsNotSupported`,e[e.SubscriptionIdentifiersNotSupported=161]=`SubscriptionIdentifiersNotSupported`,e[e.WildcardSubscriptionsNotSupported=162]=`WildcardSubscriptionsNotSupported`})(e.SubackReasonCode||={});function r(e){return e<128}e.isSuccessfulSubackReasonCode=r,(function(e){e[e.Success=0]=`Success`,e[e.NoSubscriptionExisted=17]=`NoSubscriptionExisted`,e[e.UnspecifiedError=128]=`UnspecifiedError`,e[e.ImplementationSpecificError=131]=`ImplementationSpecificError`,e[e.NotAuthorized=135]=`NotAuthorized`,e[e.TopicFilterInvalid=143]=`TopicFilterInvalid`,e[e.PacketIdentifierInUse=145]=`PacketIdentifierInUse`})(e.UnsubackReasonCode||={});function i(e){return e<128}e.isSuccessfulUnsubackReasonCode=i,(function(e){e[e.Success=0]=`Success`,e[e.NoMatchingSubscribers=16]=`NoMatchingSubscribers`,e[e.UnspecifiedError=128]=`UnspecifiedError`,e[e.ImplementationSpecificError=131]=`ImplementationSpecificError`,e[e.NotAuthorized=135]=`NotAuthorized`,e[e.TopicNameInvalid=144]=`TopicNameInvalid`,e[e.PacketIdentifierInUse=145]=`PacketIdentifierInUse`,e[e.QuotaExceeded=151]=`QuotaExceeded`,e[e.PayloadFormatInvalid=153]=`PayloadFormatInvalid`})(e.PubackReasonCode||={});function a(e){return e<128}e.isSuccessfulPubackReasonCode=a,(function(e){e[e.Bytes=0]=`Bytes`,e[e.Utf8=1]=`Utf8`})(e.PayloadFormatIndicator||={}),(function(e){e[e.AtMostOnce=0]=`AtMostOnce`,e[e.AtLeastOnce=1]=`AtLeastOnce`,e[e.ExactlyOnce=2]=`ExactlyOnce`})(e.QoS||={}),(function(e){e[e.SendOnSubscribe=0]=`SendOnSubscribe`,e[e.SendOnSubscribeIfNew=1]=`SendOnSubscribeIfNew`,e[e.DontSend=2]=`DontSend`})(e.RetainHandlingType||={}),(function(e){e[e.Connect=1]=`Connect`,e[e.Connack=2]=`Connack`,e[e.Publish=3]=`Publish`,e[e.Puback=4]=`Puback`,e[e.Pubrec=5]=`Pubrec`,e[e.Pubrel=6]=`Pubrel`,e[e.Pubcomp=7]=`Pubcomp`,e[e.Subscribe=8]=`Subscribe`,e[e.Suback=9]=`Suback`,e[e.Unsubscribe=10]=`Unsubscribe`,e[e.Unsuback=11]=`Unsuback`,e[e.Pingreq=12]=`Pingreq`,e[e.Pingresp=13]=`Pingresp`,e[e.Disconnect=14]=`Disconnect`,e[e.Auth=15]=`Auth`})(e.PacketType||={})})),sl=u((e=>{var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__setModuleDefault||(Object.create?(function(e,t){Object.defineProperty(e,`default`,{enumerable:!0,value:t})}):function(e,t){e.default=t}),r=e&&e.__importStar||function(e){if(e&&e.__esModule)return e;var r={};if(e!=null)for(var i in e)i!==`default`&&Object.prototype.hasOwnProperty.call(e,i)&&t(r,e,i);return n(r,e),r},i=e&&e.__exportStar||function(e,n){for(var r in e)r!==`default`&&!Object.prototype.hasOwnProperty.call(n,r)&&t(n,e,r)},a=e&&e.__awaiter||function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})},o=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,`__esModule`,{value:!0}),e.Mqtt5Client=e.ClientExtendedValidationAndFlowControl=e.ClientOperationQueueBehavior=e.HttpProxyOptions=void 0;let s=o(Bc()),c=Hc(),l=Yc(),u=r(Wc()),d=r(il()),f=Vc();var p=$c();Object.defineProperty(e,`HttpProxyOptions`,{enumerable:!0,get:function(){return p.HttpProxyOptions}}),i(al(),e),i(ol(),e),(function(e){e[e.Default=0]=`Default`,e[e.FailNonQos1PublishOnDisconnect=1]=`FailNonQos1PublishOnDisconnect`,e[e.FailQos0PublishOnDisconnect=2]=`FailQos0PublishOnDisconnect`,e[e.FailAllOnDisconnect=3]=`FailAllOnDisconnect`})(e.ClientOperationQueueBehavior||={}),(function(e){e[e.None=0]=`None`,e[e.AwsIotCoreDefaults=1]=`AwsIotCoreDefaults`})(e.ClientExtendedValidationAndFlowControl||={});var m=class e extends (0,c.NativeResourceMixin)(l.BufferedEventEmitter){constructor(t){super(),this._super(s.default.mqtt5_client_new(this,t,t=>{e._s_on_stopped(t)},t=>{e._s_on_attempting_connect(t)},(t,n,r)=>{e._s_on_connection_success(t,n,r)},(t,n,r)=>{e._s_on_connection_failure(t,new f.CrtError(n),r)},(t,n,r)=>{e._s_on_disconnection(t,new f.CrtError(n),r)},(t,n)=>{e._s_on_message_received(t,n)},t.clientBootstrap?t.clientBootstrap.native_handle():null,t.socketOptions?t.socketOptions.native_handle():null,t.tlsCtx?t.tlsCtx.native_handle():null,t.httpProxyOptions?t.httpProxyOptions.create_native_handle():null))}close(){s.default.mqtt5_client_close(this.native_handle())}start(){s.default.mqtt5_client_start(this.native_handle())}stop(e){s.default.mqtt5_client_stop(this.native_handle(),e)}subscribe(t){return a(this,void 0,void 0,function*(){return new Promise((n,r)=>{function i(t,i,a){return e._s_on_suback_callback(n,r,t,i,a)}try{s.default.mqtt5_client_subscribe(this.native_handle(),t,i)}catch(e){r(e)}})})}unsubscribe(t){return a(this,void 0,void 0,function*(){return new Promise((n,r)=>{function i(t,i,a){return e._s_on_unsuback_callback(n,r,t,i,a)}try{s.default.mqtt5_client_unsubscribe(this.native_handle(),t,i)}catch(e){r(e)}})})}publish(t){return a(this,void 0,void 0,function*(){return new Promise((n,r)=>{t&&t.payload&&(t.payload=d.normalize_payload(t.payload));function i(t,i,a){return e._s_on_puback_callback(n,r,t,i,a)}try{s.default.mqtt5_client_publish(this.native_handle(),t,i)}catch(e){r(e)}})})}getOperationalStatistics(){return s.default.mqtt5_client_get_queue_statistics(this.native_handle())}getQueueStatistics(){return this.getOperationalStatistics()}on(e,t){return super.on(e,t),this}static _s_on_stopped(t){process.nextTick(()=>{t.emit(e.STOPPED,{})})}static _s_on_attempting_connect(t){process.nextTick(()=>{t.emit(e.ATTEMPTING_CONNECT,{})})}static _s_on_connection_success(t,n,r){let i={connack:n,settings:r};process.nextTick(()=>{t.emit(e.CONNECTION_SUCCESS,i)})}static _s_on_connection_failure(t,n,r){let i={error:n};r!=null&&(i.connack=r),process.nextTick(()=>{t.emit(e.CONNECTION_FAILURE,i)})}static _s_on_disconnection(t,n,r){let i={error:n};r!=null&&(i.disconnect=r),process.nextTick(()=>{t.emit(e.DISCONNECTION,i)})}static _s_on_suback_callback(e,t,n,r,i){r==0&&i!==void 0?e(i):t(u.error_code_to_string(r))}static _s_on_unsuback_callback(e,t,n,r,i){r==0&&i!==void 0?e(i):t(u.error_code_to_string(r))}static _s_on_puback_callback(e,t,n,r,i){r==0?e(i):t(u.error_code_to_string(r))}static _s_on_message_received(t,n){let r={message:n};process.nextTick(()=>{t.emit(e.MESSAGE_RECEIVED,r)})}};e.Mqtt5Client=m,m.ERROR=`error`,m.MESSAGE_RECEIVED=`messageReceived`,m.ATTEMPTING_CONNECT=`attemptingConnect`,m.CONNECTION_SUCCESS=`connectionSuccess`,m.CONNECTION_FAILURE=`connectionFailure`,m.DISCONNECTION=`disconnection`,m.STOPPED=`stopped`})),cl=u((e=>{var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__setModuleDefault||(Object.create?(function(e,t){Object.defineProperty(e,`default`,{enumerable:!0,value:t})}):function(e,t){e.default=t}),r=e&&e.__importStar||function(e){if(e&&e.__esModule)return e;var r={};if(e!=null)for(var i in e)i!==`default`&&Object.prototype.hasOwnProperty.call(e,i)&&t(r,e,i);return n(r,e),r},i=e&&e.__awaiter||function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})};Object.defineProperty(e,`__esModule`,{value:!0}),e.AwsIotMqtt5ClientConfigBuilder=void 0;let a=r(sl()),o=r(Wc()),s=r(Gc()),c=Vc(),l=r(nl()),u=r(il());var d=class e{constructor(e,t,n){this.tlsContextOptions=n,this.config={hostName:e,port:t,connectProperties:{keepAliveIntervalSeconds:u.DEFAULT_KEEP_ALIVE},extendedValidationAndFlowControlOptions:a.ClientExtendedValidationAndFlowControl.AwsIotCoreDefaults}}static newDirectMqttBuilderWithMtlsFromPath(t,n,r){let i=new e(t,e.DEFAULT_DIRECT_MQTT_PORT,o.TlsContextOptions.create_client_with_mtls_from_path(n,r));return o.is_alpn_available()&&i.tlsContextOptions.alpn_list.unshift(`x-amzn-mqtt-ca`),i}static newDirectMqttBuilderWithMtlsFromMemory(t,n,r){let i=new e(t,e.DEFAULT_DIRECT_MQTT_PORT,o.TlsContextOptions.create_client_with_mtls(n,r));return o.is_alpn_available()&&i.tlsContextOptions.alpn_list.unshift(`x-amzn-mqtt-ca`),i}static newDirectMqttBuilderWithMtlsFromPkcs11(t,n){let r=new e(t,e.DEFAULT_DIRECT_MQTT_PORT,o.TlsContextOptions.create_client_with_mtls_pkcs11(n));return o.is_alpn_available()&&r.tlsContextOptions.alpn_list.unshift(`x-amzn-mqtt-ca`),r}static newDirectMqttBuilderWithMtlsFromPkcs12(t,n){let r=new e(t,e.DEFAULT_DIRECT_MQTT_PORT,o.TlsContextOptions.create_client_with_mtls_pkcs12_from_path(n.pkcs12_file,n.pkcs12_password));return o.is_alpn_available()&&r.tlsContextOptions.alpn_list.unshift(`x-amzn-mqtt-ca`),r}static newDirectMqttBuilderWithMtlsFromWindowsCertStorePath(t,n){let r=new e(t,e.DEFAULT_DIRECT_MQTT_PORT,o.TlsContextOptions.create_client_with_mtls_windows_cert_store_path(n));return o.is_alpn_available()&&r.tlsContextOptions.alpn_list.unshift(`x-amzn-mqtt-ca`),r}static newDirectMqttBuilderWithCustomAuth(t,n){let r=new e(t,e.DEFAULT_WEBSOCKET_MQTT_PORT,new o.TlsContextOptions);return r.customAuthConfig=l.canonicalizeCustomAuthConfig(n),r.tlsContextOptions.alpn_list=[`mqtt`],r}static newWebsocketMqttBuilderWithSigv4Auth(t,n){let r=new o.TlsContextOptions;r.alpn_list=[];let a=new e(t,e.DEFAULT_WEBSOCKET_MQTT_PORT,r),u=n?.credentialsProvider;return u||=s.AwsCredentialsProvider.newDefault(),a.config.websocketHandshakeTransform=(e,r)=>i(this,void 0,void 0,function*(){try{let i={algorithm:s.AwsSigningAlgorithm.SigV4,signature_type:s.AwsSignatureType.HttpRequestViaQueryParams,provider:u,region:n?.region??l.extractRegionFromEndpoint(t),service:`iotdevicegateway`,signed_body_value:s.AwsSignedBodyValue.EmptySha256,omit_session_token:!0};yield s.aws_sign_request(e,i),r()}catch(e){e instanceof c.CrtError?r(e.error_code):r(3)}}),a}static newWebsocketMqttBuilderWithCustomAuth(t,n){let r=new e(t,e.DEFAULT_WEBSOCKET_MQTT_PORT,new o.TlsContextOptions);return r.customAuthConfig=n,r.config.websocketHandshakeTransform=(e,t)=>i(this,void 0,void 0,function*(){t(0)}),r}withCertificateAuthorityFromPath(e,t){return this.tlsContextOptions.override_default_trust_store_from_path(e,t),this}withCertificateAuthority(e){return this.tlsContextOptions.override_default_trust_store(e),this}withTlsCipherPreference(e){return this.tlsContextOptions.tls_cipher_preference=e,this}withPort(e){return this.config.port=e,this}withConnectProperties(e){return this.config.connectProperties=e,this}withSessionBehavior(e){return this.config.sessionBehavior=e,this}withRetryJitterMode(e){return this.config.retryJitterMode=e,this}withMinReconnectDelayMs(e){return this.config.minReconnectDelayMs=e,this}withMaxReconnectDelayMs(e){return this.config.maxReconnectDelayMs=e,this}withMinConnectedTimeToResetReconnectDelayMs(e){return this.config.minConnectedTimeToResetReconnectDelayMs=e,this}withConnackTimeoutMs(e){return this.config.connackTimeoutMs=e,this}withOfflineQueueBehavior(e){return this.config.offlineQueueBehavior=e,this}withPingTimeoutMs(e){return this.config.pingTimeoutMs=e,this}withAckTimeoutSeconds(e){return this.config.ackTimeoutSeconds=e,this}withSocketOptions(e){return this.config.socketOptions=e,this}withHttpProxyOptions(e){return this.config.httpProxyOptions=e,this}withExtendedValidationAndFlowControlOptions(e){return this.config.extendedValidationAndFlowControlOptions=e,this}withTopicAliasingOptions(e){return this.config.topicAliasingOptions=e,this}build(){return this.config.tlsCtx===void 0&&(this.config.tlsCtx=new o.ClientTlsContext(this.tlsContextOptions)),this.config.connectProperties&&(this.config.connectProperties.username=l.buildMqtt5FinalUsername(this.customAuthConfig),this.customAuthConfig?.password&&(this.config.connectProperties.password=this.customAuthConfig?.password)),this.config}};e.AwsIotMqtt5ClientConfigBuilder=d,d.DEFAULT_WEBSOCKET_MQTT_PORT=443,d.DEFAULT_DIRECT_MQTT_PORT=8883})),ll=u((e=>{var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__exportStar||function(e,n){for(var r in e)r!==`default`&&!Object.prototype.hasOwnProperty.call(n,r)&&t(n,e,r)};Object.defineProperty(e,`__esModule`,{value:!0}),n(rl(),e),n(cl(),e)})),ul=u((e=>{var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__setModuleDefault||(Object.create?(function(e,t){Object.defineProperty(e,`default`,{enumerable:!0,value:t})}):function(e,t){e.default=t}),r=e&&e.__importStar||function(e){if(e&&e.__esModule)return e;var r={};if(e!=null)for(var i in e)i!==`default`&&Object.prototype.hasOwnProperty.call(e,i)&&t(r,e,i);return n(r,e),r},i=e&&e.__awaiter||function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})},a=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,`__esModule`,{value:!0}),e.MqttClientConnection=e.MqttClient=e.MqttWill=e.QoS=e.HttpProxyOptions=void 0;let o=a(Bc()),s=Hc(),c=Yc(),l=r(il()),u=Vc(),d=r(Wc());var f=$c();Object.defineProperty(e,`HttpProxyOptions`,{enumerable:!0,get:function(){return f.HttpProxyOptions}});let p=el();var m=el();Object.defineProperty(e,`QoS`,{enumerable:!0,get:function(){return m.QoS}}),Object.defineProperty(e,`MqttWill`,{enumerable:!0,get:function(){return m.MqttWill}}),e.MqttClient=class extends s.NativeResource{constructor(e=void 0){super(o.default.mqtt_client_new(e==null?null:e.native_handle())),this.bootstrap=e}new_connection(e){return new h(this,e)}};var h=class extends (0,s.NativeResourceMixin)(c.BufferedEventEmitter){constructor(e,t){if(super(),this.client=e,this.config=t,t==null||t==null)throw new u.CrtError(`MqttClientConnection constructor: config not defined`);let n=t.will?{topic:t.will.topic,qos:t.will.qos,payload:l.normalize_payload(t.will.payload),retain:t.will.retain}:void 0;var r=p.DEFAULT_RECONNECT_MIN_SEC,i=p.DEFAULT_RECONNECT_MAX_SEC;if(t.reconnect_min_sec&&(r=t.reconnect_min_sec,i=Math.max(r,i)),t.reconnect_max_sec&&(i=t.reconnect_max_sec,r=Math.min(r,i)),e==null||e==null)throw new u.CrtError(`MqttClientConnection constructor: client not defined`);if(t.socket_options==null||t.socket_options==null)throw new u.CrtError(`MqttClientConnection constructor: socket_options in configuration not defined`);this._super(o.default.mqtt_client_connection_new(e.native_handle(),e=>{this._on_connection_interrupted(e)},(e,t)=>{this._on_connection_resumed(e,t)},(e,t)=>{this._on_connection_success(e,t)},e=>{this._on_connection_failure(e)},t.tls_ctx?t.tls_ctx.native_handle():null,n,t.username,t.password,t.use_websocket,t.proxy_options?t.proxy_options.create_native_handle():void 0,t.websocket_handshake_transform,r,i)),this.tls_ctx=t.tls_ctx,o.default.mqtt_client_connection_on_message(this.native_handle(),this._on_any_publish.bind(this)),o.default.mqtt_client_connection_on_closed(this.native_handle(),this._on_connection_closed.bind(this)),this.on(`error`,e=>{})}close(){o.default.mqtt_client_connection_close(this.native_handle())}on(e,t){return super.on(e,t),e==`connect`&&process.nextTick(()=>{this.uncork()}),this}connect(){return i(this,void 0,void 0,function*(){return new Promise((e,t)=>{if(t=this._reject(t),this.config.socket_options==null||this.config.socket_options==null)throw new u.CrtError(`MqttClientConnection connect: socket_options in configuration not defined`);try{o.default.mqtt_client_connection_connect(this.native_handle(),this.config.client_id,this.config.host_name,this.config.port,this.config.socket_options.native_handle(),this.config.keep_alive,this.config.ping_timeout,this.config.protocol_operation_timeout,this.config.clean_session,this._on_connect_callback.bind(this,e,t))}catch(e){t(e)}})})}reconnect(){return i(this,void 0,void 0,function*(){return new Promise((e,t)=>{t=this._reject(t);try{o.default.mqtt_client_connection_reconnect(this.native_handle(),this._on_connect_callback.bind(this,e,t))}catch(e){t(e)}})})}publish(e,t,n,r=!1){return i(this,void 0,void 0,function*(){return typeof e==`string`?typeof n==`number`?typeof r==`boolean`?new Promise((i,a)=>{a=this._reject(a);try{o.default.mqtt_client_connection_publish(this.native_handle(),e,l.normalize_payload(t),n,r,this._on_puback_callback.bind(this,i,a))}catch(e){a(e)}}):Promise.reject(`retain is not a boolean`):Promise.reject(`qos is not a number`):Promise.reject(`topic is not a string`)})}subscribe(e,t,n){return i(this,void 0,void 0,function*(){return typeof e==`string`?typeof t==`number`?new Promise((r,i)=>{i=this._reject(i);try{o.default.mqtt_client_connection_subscribe(this.native_handle(),e,t,n,this._on_suback_callback.bind(this,r,i))}catch(e){i(e)}}):Promise.reject(`qos is not a number`):Promise.reject(`topic is not a string`)})}unsubscribe(e){return i(this,void 0,void 0,function*(){return typeof e==`string`?new Promise((t,n)=>{n=this._reject(n);try{o.default.mqtt_client_connection_unsubscribe(this.native_handle(),e,this._on_unsuback_callback.bind(this,t,n))}catch(e){n(e)}}):Promise.reject(`topic is not a string`)})}disconnect(){return i(this,void 0,void 0,function*(){return new Promise((e,t)=>{t=this._reject(t);try{o.default.mqtt_client_connection_disconnect(this.native_handle(),this._on_disconnect_callback.bind(this,e))}catch(e){t(e)}})})}getOperationalStatistics(){return o.default.mqtt_client_connection_get_queue_statistics(this.native_handle())}getQueueStatistics(){return this.getOperationalStatistics()}_reject(e){return t=>{e(t),process.nextTick(()=>{this.emit(`error`,new u.CrtError(t))})}}_on_connection_failure(e){let t={error:new u.CrtError(e)};this.emit(`connection_failure`,t)}_on_connection_success(e,t){let n={session_present:t,reason_code:e};this.emit(`connection_success`,n)}_on_connection_interrupted(e){this.emit(`interrupt`,new u.CrtError(e))}_on_connection_resumed(e,t){this.emit(`resume`,e,t)}_on_any_publish(e,t,n,r,i){this.emit(`message`,e,t,n,r,i)}_on_connection_closed(){this.emit(`closed`,{}),this.close()}_on_connect_callback(e,t,n,r,i){n==0&&r==0?(e(i),this.emit(`connect`,i)):t(n==0?`Server rejected connection.`:`Failed to connect: `+d.error_code_to_string(n))}_on_puback_callback(e,t,n,r){r==0?e({packet_id:n}):t(`Failed to publish: `+d.error_code_to_string(r))}_on_suback_callback(e,t,n,r,i,a){a==0?e({packet_id:n,topic:r,qos:i,error_code:a}):t(`Failed to subscribe: `+d.error_code_to_string(a))}_on_unsuback_callback(e,t,n,r){r==0?e({packet_id:n}):t(`Failed to unsubscribe: `+d.error_code_to_string(r))}_on_disconnect_callback(e){e(),this.emit(`disconnect`)}};e.MqttClientConnection=h,h.CONNECT=`connect`,h.DISCONNECT=`disconnect`,h.ERROR=`error`,h.INTERRUPT=`interrupt`,h.RESUME=`resume`,h.MESSAGE=`message`,h.CONNECTION_SUCCESS=`connection_success`,h.CONNECTION_FAILURE=`connection_failure`,h.CLOSED=`closed`})),dl=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.RequestResponseClientState=e.StreamingOperationState=void 0,(function(e){e[e.None=0]=`None`,e[e.Open=1]=`Open`,e[e.Closed=2]=`Closed`})(e.StreamingOperationState||={}),(function(e){e[e.Ready=0]=`Ready`,e[e.Closed=1]=`Closed`})(e.RequestResponseClientState||={})})),fl=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.SubscriptionStatusEventType=void 0,(function(e){e[e.SubscriptionEstablished=0]=`SubscriptionEstablished`,e[e.SubscriptionLost=1]=`SubscriptionLost`,e[e.SubscriptionHalted=2]=`SubscriptionHalted`})(e.SubscriptionStatusEventType||={})})),pl=u((e=>{var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__setModuleDefault||(Object.create?(function(e,t){Object.defineProperty(e,`default`,{enumerable:!0,value:t})}):function(e,t){e.default=t}),r=e&&e.__importStar||function(e){if(e&&e.__esModule)return e;var r={};if(e!=null)for(var i in e)i!==`default`&&Object.prototype.hasOwnProperty.call(e,i)&&t(r,e,i);return n(r,e),r},i=e&&e.__exportStar||function(e,n){for(var r in e)r!==`default`&&!Object.prototype.hasOwnProperty.call(n,r)&&t(n,e,r)},a=e&&e.__awaiter||function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})},o=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,`__esModule`,{value:!0}),e.RequestResponseClient=e.StreamingOperationBase=void 0;let s=Vc(),c=r(dl()),l=Hc(),u=Yc(),d=o(Bc()),f=Wc();i(fl(),e);var p=class e extends (0,l.NativeResourceMixin)(u.BufferedEventEmitter){static new(t,n){if(!t)throw new s.CrtError(`invalid configuration for streaming operation`);let r=new e(n);return r._super(d.default.mqtt_streaming_operation_new(r,n.native_handle(),t,(t,n,i)=>{e._s_on_subscription_status_update(r,n,i)},(t,n)=>{e._s_on_incoming_publish(r,n)})),n.registerUnclosedStreamingOperation(r),r}constructor(e){super(),this.state=c.StreamingOperationState.None,this.client=e}open(){if(this.state==c.StreamingOperationState.None)this.state=c.StreamingOperationState.Open,d.default.mqtt_streaming_operation_open(this.native_handle());else if(this.state==c.StreamingOperationState.Closed)throw new s.CrtError(`MQTT streaming operation already closed`)}close(){this.state!=c.StreamingOperationState.Closed&&(this.client.unregisterUnclosedStreamingOperation(this),this.state=c.StreamingOperationState.Closed,d.default.mqtt_streaming_operation_close(this.native_handle()))}on(e,t){return super.on(e,t),this}static _s_on_subscription_status_update(t,n,r){let i={type:n};r!=0&&(i.error=new s.CrtError(r)),process.nextTick(()=>{t.emit(e.SUBSCRIPTION_STATUS,i)})}static _s_on_incoming_publish(t,n){process.nextTick(()=>{t.emit(e.INCOMING_PUBLISH,n)})}};e.StreamingOperationBase=p,p.SUBSCRIPTION_STATUS=`subscriptionStatus`,p.INCOMING_PUBLISH=`incomingPublish`,e.RequestResponseClient=class e extends (0,l.NativeResourceMixin)(u.BufferedEventEmitter){constructor(){super(),this.state=c.RequestResponseClientState.Ready,this.unclosedOperations=new Set}static newFromMqtt5(t,n){if(!t)throw new s.CrtError(`protocol client is null`);let r=new e;return r._super(d.default.mqtt_request_response_client_new_from_5(r,t.native_handle(),n)),r}static newFromMqtt311(t,n){if(!t)throw new s.CrtError(`protocol client is null`);let r=new e;return r._super(d.default.mqtt_request_response_client_new_from_311(r,t.native_handle(),n)),r}close(){this.state!=c.RequestResponseClientState.Closed&&(this.state=c.RequestResponseClientState.Closed,this.closeStreamingOperations(),d.default.mqtt_request_response_client_close(this.native_handle()))}createStream(e){if(this.state==c.RequestResponseClientState.Closed)throw new s.CrtError(`MQTT request-response client has already been closed`);return p.new(e,this)}submitRequest(t){return a(this,void 0,void 0,function*(){return new Promise((n,r)=>{if(this.state==c.RequestResponseClientState.Closed){r(new s.CrtError(`MQTT request-response client has already been closed`));return}if(!t){r(new s.CrtError(`null request options`));return}function i(t,i,a){return e._s_on_request_completion(n,r,t,i,a)}try{d.default.mqtt_request_response_client_submit_request(this.native_handle(),t,i)}catch(e){r(e)}})})}registerUnclosedStreamingOperation(e){this.unclosedOperations&&this.unclosedOperations.add(e)}unregisterUnclosedStreamingOperation(e){this.unclosedOperations&&this.unclosedOperations.delete(e)}closeStreamingOperations(){if(this.unclosedOperations){let e=this.unclosedOperations;this.unclosedOperations=void 0;for(let t of e)t.close()}}static _s_on_request_completion(e,t,n,r,i){n==0&&r!==void 0&&i!==void 0?e({payload:i,topic:r}):t(new s.CrtError((0,f.error_code_to_string)(n)))}}})),ml=u((e=>{var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__setModuleDefault||(Object.create?(function(e,t){Object.defineProperty(e,`default`,{enumerable:!0,value:t})}):function(e,t){e.default=t}),r=e&&e.__importStar||function(e){if(e&&e.__esModule)return e;var r={};if(e!=null)for(var i in e)i!==`default`&&Object.prototype.hasOwnProperty.call(e,i)&&t(r,e,i);return n(r,e),r};Object.defineProperty(e,`__esModule`,{value:!0}),e.CrtError=e.resource_safety=e.promise=e.platform=e.mqtt_request_response=e.mqtt5=e.mqtt=e.iot=e.io=e.http=e.eventstream=e.crt=e.crypto=e.checksums=e.cancel=e.auth=void 0,e.cancel=r(Ic()),e.platform=r(Rc()),e.promise=r(Fc()),e.resource_safety=r(zc()),e.auth=r(Gc()),e.checksums=r(Kc()),e.crt=r(qc()),e.crypto=r(Jc()),e.eventstream=r(Zc()),e.http=r($c()),e.io=r(Wc()),e.iot=r(ll()),e.mqtt=r(ul()),e.mqtt5=r(sl()),e.mqtt_request_response=r(pl());let i=Vc();Object.defineProperty(e,`CrtError`,{enumerable:!0,get:function(){return i.CrtError}})})),hl=u(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.isCrtAvailable=void 0,e.isCrtAvailable=()=>{try{return typeof h==`function`&&t!==void 0&&ml()?[`md/crt-avail`]:null}catch{return null}}})),gl=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.defaultUserAgent=e.UA_APP_ID_INI_NAME=e.UA_APP_ID_ENV_NAME=void 0;let t=Ws(),n=h(`os`),r=h(`process`),i=hl();e.UA_APP_ID_ENV_NAME=`AWS_SDK_UA_APP_ID`,e.UA_APP_ID_INI_NAME=`sdk-ua-app-id`,e.defaultUserAgent=({serviceId:a,clientVersion:o})=>{let s=[[`aws-sdk-js`,o],[`os/${(0,n.platform)()}`,(0,n.release)()],[`lang/js`],[`md/nodejs`,`${r.versions.node}`]],c=(0,i.isCrtAvailable)();c&&s.push(c),a&&s.push([`api/${a}`,o]),r.env.AWS_EXECUTION_ENV&&s.push([`exec-env/${r.env.AWS_EXECUTION_ENV}`]);let l=(0,t.loadConfig)({environmentVariableSelector:t=>t[e.UA_APP_ID_ENV_NAME],configFileSelector:t=>t[e.UA_APP_ID_INI_NAME],default:void 0})(),u;return async()=>{if(!u){let e=await l;u=e?[...s,[`app/${e}`]]:[...s]}return u}}})),_l=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.fromBase64=void 0;let t=Xi(),n=/^[A-Za-z0-9+/]*={0,2}$/;e.fromBase64=e=>{if(e.length*3%4!=0)throw TypeError(`Incorrect padding on base64 string.`);if(!n.exec(e))throw TypeError(`Invalid base64 string.`);let r=(0,t.fromString)(e,`base64`);return new Uint8Array(r.buffer,r.byteOffset,r.byteLength)}})),vl=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.toBase64=void 0;let t=Xi();e.toBase64=e=>(0,t.fromArrayBuffer)(e.buffer,e.byteOffset,e.byteLength).toString(`base64`)})),yl=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=(N(),m(j));t.__exportStar(_l(),e),t.__exportStar(vl(),e)})),bl=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.ruleSet=void 0;let t=`required`,n=`argv`,r=`PartitionResult`,i=`tree`,a=`error`,o=`endpoint`,s={[t]:!1,type:`String`},c={[t]:!0,default:!1,type:`Boolean`},l={ref:`Endpoint`},u={fn:`booleanEquals`,[n]:[{ref:`UseFIPS`},!0]},d={fn:`booleanEquals`,[n]:[{ref:`UseDualStack`},!0]},f={},p={fn:`booleanEquals`,[n]:[!0,{fn:`getAttr`,[n]:[{ref:r},`supportsFIPS`]}]},m={fn:`booleanEquals`,[n]:[!0,{fn:`getAttr`,[n]:[{ref:r},`supportsDualStack`]}]},h=[l],g=[u],_=[d];e.ruleSet={version:`1.0`,parameters:{Region:s,UseDualStack:c,UseFIPS:c,Endpoint:s},rules:[{conditions:[{fn:`aws.partition`,[n]:[{ref:`Region`}],assign:r}],type:i,rules:[{conditions:[{fn:`isSet`,[n]:h},{fn:`parseURL`,[n]:h,assign:`url`}],type:i,rules:[{conditions:g,error:`Invalid Configuration: FIPS and custom endpoint are not supported`,type:a},{type:i,rules:[{conditions:_,error:`Invalid Configuration: Dualstack and custom endpoint are not supported`,type:a},{endpoint:{url:l,properties:f,headers:f},type:o}]}]},{conditions:[u,d],type:i,rules:[{conditions:[p,m],type:i,rules:[{endpoint:{url:`https://portal.sso-fips.{Region}.{PartitionResult#dualStackDnsSuffix}`,properties:f,headers:f},type:o}]},{error:`FIPS and DualStack are enabled, but this partition does not support one or both`,type:a}]},{conditions:g,type:i,rules:[{conditions:[p],type:i,rules:[{type:i,rules:[{endpoint:{url:`https://portal.sso-fips.{Region}.{PartitionResult#dnsSuffix}`,properties:f,headers:f},type:o}]}]},{error:`FIPS is enabled but this partition does not support FIPS`,type:a}]},{conditions:_,type:i,rules:[{conditions:[m],type:i,rules:[{endpoint:{url:`https://portal.sso.{Region}.{PartitionResult#dualStackDnsSuffix}`,properties:f,headers:f},type:o}]},{error:`DualStack is enabled but this partition does not support DualStack`,type:a}]},{endpoint:{url:`https://portal.sso.{Region}.{PartitionResult#dnsSuffix}`,properties:f,headers:f},type:o}]}]}})),xl=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.defaultEndpointResolver=void 0;let t=Xo(),n=bl();e.defaultEndpointResolver=(e,r={})=>(0,t.resolveEndpoint)(n.ruleSet,{endpointParams:e,logger:r.logger})})),Sl=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.getRuntimeConfig=void 0;let t=P(),n=Zt(),r=yl(),i=ea(),a=xl();e.getRuntimeConfig=e=>({apiVersion:`2019-06-10`,base64Decoder:e?.base64Decoder??r.fromBase64,base64Encoder:e?.base64Encoder??r.toBase64,disableHostPrefix:e?.disableHostPrefix??!1,endpointProvider:e?.endpointProvider??a.defaultEndpointResolver,logger:e?.logger??new t.NoOpLogger,serviceId:e?.serviceId??`SSO`,urlParser:e?.urlParser??n.parseUrl,utf8Decoder:e?.utf8Decoder??i.fromUtf8,utf8Encoder:e?.utf8Encoder??i.toUtf8})})),Cl=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.IMDS_REGION_PATH=e.DEFAULTS_MODE_OPTIONS=e.ENV_IMDS_DISABLED=e.AWS_DEFAULT_REGION_ENV=e.AWS_REGION_ENV=e.AWS_EXECUTION_ENV=void 0,e.AWS_EXECUTION_ENV=`AWS_EXECUTION_ENV`,e.AWS_REGION_ENV=`AWS_REGION`,e.AWS_DEFAULT_REGION_ENV=`AWS_DEFAULT_REGION`,e.ENV_IMDS_DISABLED=`AWS_EC2_METADATA_DISABLED`,e.DEFAULTS_MODE_OPTIONS=[`in-region`,`cross-region`,`mobile`,`standard`,`legacy`],e.IMDS_REGION_PATH=`/latest/meta-data/placement/region`})),wl=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.NODE_DEFAULTS_MODE_CONFIG_OPTIONS=void 0,e.NODE_DEFAULTS_MODE_CONFIG_OPTIONS={environmentVariableSelector:e=>e.AWS_DEFAULTS_MODE,configFileSelector:e=>e.defaults_mode,default:`legacy`}})),Tl=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.resolveDefaultsModeConfig=void 0;let t=Or(),n=ec(),r=Ws(),i=qi(),a=Cl(),o=wl();e.resolveDefaultsModeConfig=({region:e=(0,r.loadConfig)(t.NODE_REGION_CONFIG_OPTIONS),defaultsMode:n=(0,r.loadConfig)(o.NODE_DEFAULTS_MODE_CONFIG_OPTIONS)}={})=>(0,i.memoize)(async()=>{let t=typeof n==`function`?await n():n;switch(t?.toLowerCase()){case`auto`:return s(e);case`in-region`:case`cross-region`:case`mobile`:case`standard`:case`legacy`:return Promise.resolve(t?.toLocaleLowerCase());case void 0:return Promise.resolve(`legacy`);default:throw Error(`Invalid parameter for "defaultsMode", expect ${a.DEFAULTS_MODE_OPTIONS.join(`, `)}, got ${t}`)}});let s=async e=>{if(e){let t=typeof e==`function`?await e():e,n=await c();return n?t===n?`in-region`:`cross-region`:`standard`}return`standard`},c=async()=>{if(process.env[a.AWS_EXECUTION_ENV]&&(process.env[a.AWS_REGION_ENV]||process.env[a.AWS_DEFAULT_REGION_ENV]))return process.env[a.AWS_REGION_ENV]??process.env[a.AWS_DEFAULT_REGION_ENV];if(!process.env[a.ENV_IMDS_DISABLED])try{let e=await(0,n.getInstanceMetadataEndpoint)();return(await(0,n.httpRequest)({...e,path:a.IMDS_REGION_PATH})).toString()}catch{}}})),El=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),(N(),m(j)).__exportStar(Tl(),e)})),Dl=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.getRuntimeConfig=void 0;let t=(N(),m(j)).__importDefault(_c()),n=Or(),r=vc(),i=Bi(),a=Ws(),o=Mc(),s=Pc(),c=Wr(),l=gl(),u=Sl(),d=P(),f=El(),p=P();e.getRuntimeConfig=e=>{(0,p.emitWarningIfUnsupportedVersion)(process.version);let m=(0,f.resolveDefaultsModeConfig)(e),h=()=>m().then(d.loadConfigsForDefaultMode),g=(0,u.getRuntimeConfig)(e);return{...g,...e,runtime:`node`,defaultsMode:m,bodyLengthChecker:e?.bodyLengthChecker??s.calculateBodyLength,defaultUserAgentProvider:e?.defaultUserAgentProvider??(0,l.defaultUserAgent)({serviceId:g.serviceId,clientVersion:t.default.version}),maxAttempts:e?.maxAttempts??(0,a.loadConfig)(i.NODE_MAX_ATTEMPT_CONFIG_OPTIONS),region:e?.region??(0,a.loadConfig)(n.NODE_REGION_CONFIG_OPTIONS,n.NODE_REGION_CONFIG_FILE_OPTIONS),requestHandler:e?.requestHandler??new o.NodeHttpHandler(h),retryMode:e?.retryMode??(0,a.loadConfig)({...i.NODE_RETRY_MODE_CONFIG_OPTIONS,default:async()=>(await h()).retryMode||c.DEFAULT_RETRY_MODE}),sha256:e?.sha256??r.Hash.bind(null,`sha256`),streamCollector:e?.streamCollector??o.streamCollector,useDualstackEndpoint:e?.useDualstackEndpoint??(0,a.loadConfig)(n.NODE_USE_DUALSTACK_ENDPOINT_CONFIG_OPTIONS),useFipsEndpoint:e?.useFipsEndpoint??(0,a.loadConfig)(n.NODE_USE_FIPS_ENDPOINT_CONFIG_OPTIONS)}}})),Ol=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.SSOClient=void 0;let t=Or(),n=kr(),r=L(),i=Z(),a=jr(),o=Mr(),s=Bi(),c=$o(),l=P(),u=gc(),d=Dl();e.SSOClient=class extends l.Client{constructor(e){let l=(0,d.getRuntimeConfig)(e),f=(0,u.resolveClientEndpointParameters)(l),p=(0,t.resolveRegionConfig)(f),m=(0,r.resolveEndpointConfig)(p),h=(0,s.resolveRetryConfig)(m),g=(0,i.resolveHostHeaderConfig)(h),_=(0,c.resolveUserAgentConfig)(g);super(_),this.config=_,this.middlewareStack.use((0,s.getRetryPlugin)(this.config)),this.middlewareStack.use((0,n.getContentLengthPlugin)(this.config)),this.middlewareStack.use((0,i.getHostHeaderPlugin)(this.config)),this.middlewareStack.use((0,a.getLoggerPlugin)(this.config)),this.middlewareStack.use((0,o.getRecursionDetectionPlugin)(this.config)),this.middlewareStack.use((0,c.getUserAgentPlugin)(this.config))}destroy(){super.destroy()}}})),kl=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.SSO=void 0;let t=P(),n=fc(),r=pc(),i=mc(),a=hc(),o=Ol(),s={GetRoleCredentialsCommand:n.GetRoleCredentialsCommand,ListAccountRolesCommand:r.ListAccountRolesCommand,ListAccountsCommand:i.ListAccountsCommand,LogoutCommand:a.LogoutCommand};var c=class extends o.SSOClient{};e.SSO=c,(0,t.createAggregatedClient)(s,c)})),Al=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=(N(),m(j));t.__exportStar(fc(),e),t.__exportStar(pc(),e),t.__exportStar(mc(),e),t.__exportStar(hc(),e)})),jl=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),(N(),m(j)).__exportStar(uc(),e)})),Ml=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0})})),Nl=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.paginateListAccountRoles=void 0;let t=pc(),n=Ol(),r=async(e,n,...r)=>await e.send(new t.ListAccountRolesCommand(n),...r);async function*i(e,t,...i){let a=e.startingToken||void 0,o=!0,s;for(;o;){if(t.nextToken=a,t.maxResults=e.pageSize,e.client instanceof n.SSOClient)s=await r(e.client,t,...i);else throw Error(`Invalid client, expected SSO | SSOClient`);yield s;let c=a;a=s.nextToken,o=!!(a&&(!e.stopOnSameToken||a!==c))}return void 0}e.paginateListAccountRoles=i})),Pl=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.paginateListAccounts=void 0;let t=mc(),n=Ol(),r=async(e,n,...r)=>await e.send(new t.ListAccountsCommand(n),...r);async function*i(e,t,...i){let a=e.startingToken||void 0,o=!0,s;for(;o;){if(t.nextToken=a,t.maxResults=e.pageSize,e.client instanceof n.SSOClient)s=await r(e.client,t,...i);else throw Error(`Invalid client, expected SSO | SSOClient`);yield s;let c=a;a=s.nextToken,o=!!(a&&(!e.stopOnSameToken||a!==c))}return void 0}e.paginateListAccounts=i})),Fl=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=(N(),m(j));t.__exportStar(Ml(),e),t.__exportStar(Nl(),e),t.__exportStar(Pl(),e)})),Il=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.SSOServiceException=void 0;let t=(N(),m(j));t.__exportStar(kl(),e),t.__exportStar(Ol(),e),t.__exportStar(Al(),e),t.__exportStar(jl(),e),t.__exportStar(Fl(),e);var n=lc();Object.defineProperty(e,`SSOServiceException`,{enumerable:!0,get:function(){return n.SSOServiceException}})})),Ll=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.REFRESH_MESSAGE=e.EXPIRE_WINDOW_MS=void 0,e.EXPIRE_WINDOW_MS=300*1e3,e.REFRESH_MESSAGE=`To refresh this SSO session run 'aws sso login' with the corresponding profile.`})),Rl=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.SSOOIDCServiceException=void 0;let t=P();e.SSOOIDCServiceException=class e extends t.ServiceException{constructor(t){super(t),Object.setPrototypeOf(this,e.prototype)}}})),zl=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.InvalidClientMetadataException=e.UnsupportedGrantTypeException=e.UnauthorizedClientException=e.SlowDownException=e.InvalidScopeException=e.InvalidRequestException=e.InvalidGrantException=e.InvalidClientException=e.InternalServerException=e.ExpiredTokenException=e.AuthorizationPendingException=e.AccessDeniedException=void 0;let t=Rl();e.AccessDeniedException=class e extends t.SSOOIDCServiceException{constructor(t){super({name:`AccessDeniedException`,$fault:`client`,...t}),this.name=`AccessDeniedException`,this.$fault=`client`,Object.setPrototypeOf(this,e.prototype),this.error=t.error,this.error_description=t.error_description}},e.AuthorizationPendingException=class e extends t.SSOOIDCServiceException{constructor(t){super({name:`AuthorizationPendingException`,$fault:`client`,...t}),this.name=`AuthorizationPendingException`,this.$fault=`client`,Object.setPrototypeOf(this,e.prototype),this.error=t.error,this.error_description=t.error_description}},e.ExpiredTokenException=class e extends t.SSOOIDCServiceException{constructor(t){super({name:`ExpiredTokenException`,$fault:`client`,...t}),this.name=`ExpiredTokenException`,this.$fault=`client`,Object.setPrototypeOf(this,e.prototype),this.error=t.error,this.error_description=t.error_description}},e.InternalServerException=class e extends t.SSOOIDCServiceException{constructor(t){super({name:`InternalServerException`,$fault:`server`,...t}),this.name=`InternalServerException`,this.$fault=`server`,Object.setPrototypeOf(this,e.prototype),this.error=t.error,this.error_description=t.error_description}},e.InvalidClientException=class e extends t.SSOOIDCServiceException{constructor(t){super({name:`InvalidClientException`,$fault:`client`,...t}),this.name=`InvalidClientException`,this.$fault=`client`,Object.setPrototypeOf(this,e.prototype),this.error=t.error,this.error_description=t.error_description}},e.InvalidGrantException=class e extends t.SSOOIDCServiceException{constructor(t){super({name:`InvalidGrantException`,$fault:`client`,...t}),this.name=`InvalidGrantException`,this.$fault=`client`,Object.setPrototypeOf(this,e.prototype),this.error=t.error,this.error_description=t.error_description}},e.InvalidRequestException=class e extends t.SSOOIDCServiceException{constructor(t){super({name:`InvalidRequestException`,$fault:`client`,...t}),this.name=`InvalidRequestException`,this.$fault=`client`,Object.setPrototypeOf(this,e.prototype),this.error=t.error,this.error_description=t.error_description}},e.InvalidScopeException=class e extends t.SSOOIDCServiceException{constructor(t){super({name:`InvalidScopeException`,$fault:`client`,...t}),this.name=`InvalidScopeException`,this.$fault=`client`,Object.setPrototypeOf(this,e.prototype),this.error=t.error,this.error_description=t.error_description}},e.SlowDownException=class e extends t.SSOOIDCServiceException{constructor(t){super({name:`SlowDownException`,$fault:`client`,...t}),this.name=`SlowDownException`,this.$fault=`client`,Object.setPrototypeOf(this,e.prototype),this.error=t.error,this.error_description=t.error_description}},e.UnauthorizedClientException=class e extends t.SSOOIDCServiceException{constructor(t){super({name:`UnauthorizedClientException`,$fault:`client`,...t}),this.name=`UnauthorizedClientException`,this.$fault=`client`,Object.setPrototypeOf(this,e.prototype),this.error=t.error,this.error_description=t.error_description}},e.UnsupportedGrantTypeException=class e extends t.SSOOIDCServiceException{constructor(t){super({name:`UnsupportedGrantTypeException`,$fault:`client`,...t}),this.name=`UnsupportedGrantTypeException`,this.$fault=`client`,Object.setPrototypeOf(this,e.prototype),this.error=t.error,this.error_description=t.error_description}},e.InvalidClientMetadataException=class e extends t.SSOOIDCServiceException{constructor(t){super({name:`InvalidClientMetadataException`,$fault:`client`,...t}),this.name=`InvalidClientMetadataException`,this.$fault=`client`,Object.setPrototypeOf(this,e.prototype),this.error=t.error,this.error_description=t.error_description}}})),Bl=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.de_StartDeviceAuthorizationCommand=e.de_RegisterClientCommand=e.de_CreateTokenCommand=e.se_StartDeviceAuthorizationCommand=e.se_RegisterClientCommand=e.se_CreateTokenCommand=void 0;let t=gn(),n=P(),r=zl(),i=Rl();e.se_CreateTokenCommand=async(e,r)=>{let{hostname:i,protocol:a=`https`,port:o,path:s}=await r.endpoint(),c={"content-type":`application/json`},l=`${s?.endsWith(`/`)?s.slice(0,-1):s||``}/token`,u;return u=JSON.stringify((0,n.take)(e,{clientId:[],clientSecret:[],code:[],deviceCode:[],grantType:[],redirectUri:[],refreshToken:[],scope:e=>(0,n._json)(e)})),new t.HttpRequest({protocol:a,hostname:i,port:o,method:`POST`,headers:c,path:l,body:u})},e.se_RegisterClientCommand=async(e,r)=>{let{hostname:i,protocol:a=`https`,port:o,path:s}=await r.endpoint(),c={"content-type":`application/json`},l=`${s?.endsWith(`/`)?s.slice(0,-1):s||``}/client/register`,u;return u=JSON.stringify((0,n.take)(e,{clientName:[],clientType:[],scopes:e=>(0,n._json)(e)})),new t.HttpRequest({protocol:a,hostname:i,port:o,method:`POST`,headers:c,path:l,body:u})},e.se_StartDeviceAuthorizationCommand=async(e,r)=>{let{hostname:i,protocol:a=`https`,port:o,path:s}=await r.endpoint(),c={"content-type":`application/json`},l=`${s?.endsWith(`/`)?s.slice(0,-1):s||``}/device_authorization`,u;return u=JSON.stringify((0,n.take)(e,{clientId:[],clientSecret:[],startUrl:[]})),new t.HttpRequest({protocol:a,hostname:i,port:o,method:`POST`,headers:c,path:l,body:u})},e.de_CreateTokenCommand=async(e,t)=>{if(e.statusCode!==200&&e.statusCode>=300)return a(e,t);let r=(0,n.map)({$metadata:x(e)}),i=(0,n.expectNonNull)((0,n.expectObject)(await w(e.body,t)),`body`),o=(0,n.take)(i,{accessToken:n.expectString,expiresIn:n.expectInt32,idToken:n.expectString,refreshToken:n.expectString,tokenType:n.expectString});return Object.assign(r,o),r};let a=async(e,t)=>{let n={...e,body:await ee(e.body,t)},r=te(e,n.body);switch(r){case`AccessDeniedException`:case`com.amazonaws.ssooidc#AccessDeniedException`:throw await l(n,t);case`AuthorizationPendingException`:case`com.amazonaws.ssooidc#AuthorizationPendingException`:throw await u(n,t);case`ExpiredTokenException`:case`com.amazonaws.ssooidc#ExpiredTokenException`:throw await d(n,t);case`InternalServerException`:case`com.amazonaws.ssooidc#InternalServerException`:throw await f(n,t);case`InvalidClientException`:case`com.amazonaws.ssooidc#InvalidClientException`:throw await p(n,t);case`InvalidGrantException`:case`com.amazonaws.ssooidc#InvalidGrantException`:throw await h(n,t);case`InvalidRequestException`:case`com.amazonaws.ssooidc#InvalidRequestException`:throw await g(n,t);case`InvalidScopeException`:case`com.amazonaws.ssooidc#InvalidScopeException`:throw await _(n,t);case`SlowDownException`:case`com.amazonaws.ssooidc#SlowDownException`:throw await v(n,t);case`UnauthorizedClientException`:case`com.amazonaws.ssooidc#UnauthorizedClientException`:throw await y(n,t);case`UnsupportedGrantTypeException`:case`com.amazonaws.ssooidc#UnsupportedGrantTypeException`:throw await b(n,t);default:let i=n.body;return c({output:e,parsedBody:i,errorCode:r})}};e.de_RegisterClientCommand=async(e,t)=>{if(e.statusCode!==200&&e.statusCode>=300)return o(e,t);let r=(0,n.map)({$metadata:x(e)}),i=(0,n.expectNonNull)((0,n.expectObject)(await w(e.body,t)),`body`),a=(0,n.take)(i,{authorizationEndpoint:n.expectString,clientId:n.expectString,clientIdIssuedAt:n.expectLong,clientSecret:n.expectString,clientSecretExpiresAt:n.expectLong,tokenEndpoint:n.expectString});return Object.assign(r,a),r};let o=async(e,t)=>{let n={...e,body:await ee(e.body,t)},r=te(e,n.body);switch(r){case`InternalServerException`:case`com.amazonaws.ssooidc#InternalServerException`:throw await f(n,t);case`InvalidClientMetadataException`:case`com.amazonaws.ssooidc#InvalidClientMetadataException`:throw await m(n,t);case`InvalidRequestException`:case`com.amazonaws.ssooidc#InvalidRequestException`:throw await g(n,t);case`InvalidScopeException`:case`com.amazonaws.ssooidc#InvalidScopeException`:throw await _(n,t);default:let i=n.body;return c({output:e,parsedBody:i,errorCode:r})}};e.de_StartDeviceAuthorizationCommand=async(e,t)=>{if(e.statusCode!==200&&e.statusCode>=300)return s(e,t);let r=(0,n.map)({$metadata:x(e)}),i=(0,n.expectNonNull)((0,n.expectObject)(await w(e.body,t)),`body`),a=(0,n.take)(i,{deviceCode:n.expectString,expiresIn:n.expectInt32,interval:n.expectInt32,userCode:n.expectString,verificationUri:n.expectString,verificationUriComplete:n.expectString});return Object.assign(r,a),r};let s=async(e,t)=>{let n={...e,body:await ee(e.body,t)},r=te(e,n.body);switch(r){case`InternalServerException`:case`com.amazonaws.ssooidc#InternalServerException`:throw await f(n,t);case`InvalidClientException`:case`com.amazonaws.ssooidc#InvalidClientException`:throw await p(n,t);case`InvalidRequestException`:case`com.amazonaws.ssooidc#InvalidRequestException`:throw await g(n,t);case`SlowDownException`:case`com.amazonaws.ssooidc#SlowDownException`:throw await v(n,t);case`UnauthorizedClientException`:case`com.amazonaws.ssooidc#UnauthorizedClientException`:throw await y(n,t);default:let i=n.body;return c({output:e,parsedBody:i,errorCode:r})}},c=(0,n.withBaseException)(i.SSOOIDCServiceException),l=async(e,t)=>{let i=(0,n.map)({}),a=e.body,o=(0,n.take)(a,{error:n.expectString,error_description:n.expectString});Object.assign(i,o);let s=new r.AccessDeniedException({$metadata:x(e),...i});return(0,n.decorateServiceException)(s,e.body)},u=async(e,t)=>{let i=(0,n.map)({}),a=e.body,o=(0,n.take)(a,{error:n.expectString,error_description:n.expectString});Object.assign(i,o);let s=new r.AuthorizationPendingException({$metadata:x(e),...i});return(0,n.decorateServiceException)(s,e.body)},d=async(e,t)=>{let i=(0,n.map)({}),a=e.body,o=(0,n.take)(a,{error:n.expectString,error_description:n.expectString});Object.assign(i,o);let s=new r.ExpiredTokenException({$metadata:x(e),...i});return(0,n.decorateServiceException)(s,e.body)},f=async(e,t)=>{let i=(0,n.map)({}),a=e.body,o=(0,n.take)(a,{error:n.expectString,error_description:n.expectString});Object.assign(i,o);let s=new r.InternalServerException({$metadata:x(e),...i});return(0,n.decorateServiceException)(s,e.body)},p=async(e,t)=>{let i=(0,n.map)({}),a=e.body,o=(0,n.take)(a,{error:n.expectString,error_description:n.expectString});Object.assign(i,o);let s=new r.InvalidClientException({$metadata:x(e),...i});return(0,n.decorateServiceException)(s,e.body)},m=async(e,t)=>{let i=(0,n.map)({}),a=e.body,o=(0,n.take)(a,{error:n.expectString,error_description:n.expectString});Object.assign(i,o);let s=new r.InvalidClientMetadataException({$metadata:x(e),...i});return(0,n.decorateServiceException)(s,e.body)},h=async(e,t)=>{let i=(0,n.map)({}),a=e.body,o=(0,n.take)(a,{error:n.expectString,error_description:n.expectString});Object.assign(i,o);let s=new r.InvalidGrantException({$metadata:x(e),...i});return(0,n.decorateServiceException)(s,e.body)},g=async(e,t)=>{let i=(0,n.map)({}),a=e.body,o=(0,n.take)(a,{error:n.expectString,error_description:n.expectString});Object.assign(i,o);let s=new r.InvalidRequestException({$metadata:x(e),...i});return(0,n.decorateServiceException)(s,e.body)},_=async(e,t)=>{let i=(0,n.map)({}),a=e.body,o=(0,n.take)(a,{error:n.expectString,error_description:n.expectString});Object.assign(i,o);let s=new r.InvalidScopeException({$metadata:x(e),...i});return(0,n.decorateServiceException)(s,e.body)},v=async(e,t)=>{let i=(0,n.map)({}),a=e.body,o=(0,n.take)(a,{error:n.expectString,error_description:n.expectString});Object.assign(i,o);let s=new r.SlowDownException({$metadata:x(e),...i});return(0,n.decorateServiceException)(s,e.body)},y=async(e,t)=>{let i=(0,n.map)({}),a=e.body,o=(0,n.take)(a,{error:n.expectString,error_description:n.expectString});Object.assign(i,o);let s=new r.UnauthorizedClientException({$metadata:x(e),...i});return(0,n.decorateServiceException)(s,e.body)},b=async(e,t)=>{let i=(0,n.map)({}),a=e.body,o=(0,n.take)(a,{error:n.expectString,error_description:n.expectString});Object.assign(i,o);let s=new r.UnsupportedGrantTypeException({$metadata:x(e),...i});return(0,n.decorateServiceException)(s,e.body)},x=e=>({httpStatusCode:e.statusCode,requestId:e.headers[`x-amzn-requestid`]??e.headers[`x-amzn-request-id`]??e.headers[`x-amz-request-id`],extendedRequestId:e.headers[`x-amz-id-2`],cfId:e.headers[`x-amz-cf-id`]}),S=(e=new Uint8Array,t)=>e instanceof Uint8Array?Promise.resolve(e):t.streamCollector(e)||Promise.resolve(new Uint8Array),C=(e,t)=>S(e,t).then(e=>t.utf8Encoder(e)),w=(e,t)=>C(e,t).then(e=>e.length?JSON.parse(e):{}),ee=async(e,t)=>{let n=await w(e,t);return n.message=n.message??n.Message,n},te=(e,t)=>{let n=(e,t)=>Object.keys(e).find(e=>e.toLowerCase()===t.toLowerCase()),r=e=>{let t=e;return typeof t==`number`&&(t=t.toString()),t.indexOf(`,`)>=0&&(t=t.split(`,`)[0]),t.indexOf(`:`)>=0&&(t=t.split(`:`)[0]),t.indexOf(`#`)>=0&&(t=t.split(`#`)[1]),t},i=n(e.headers,`x-amzn-errortype`);if(i!==void 0)return r(e.headers[i]);if(t.code!==void 0)return r(t.code);if(t.__type!==void 0)return r(t.__type)}})),Vl=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.CreateTokenCommand=void 0;let t=L(),n=F(),r=P(),i=Bl();e.CreateTokenCommand=class e extends r.Command{static getEndpointParameterInstructions(){return{UseFIPS:{type:`builtInParams`,name:`useFipsEndpoint`},Endpoint:{type:`builtInParams`,name:`endpoint`},Region:{type:`builtInParams`,name:`region`},UseDualStack:{type:`builtInParams`,name:`useDualstackEndpoint`}}}constructor(e){super(),this.input=e}resolveMiddleware(r,i,a){this.middlewareStack.use((0,n.getSerdePlugin)(i,this.serialize,this.deserialize)),this.middlewareStack.use((0,t.getEndpointPlugin)(i,e.getEndpointParameterInstructions()));let o=r.concat(this.middlewareStack),{logger:s}=i,c={logger:s,clientName:`SSOOIDCClient`,commandName:`CreateTokenCommand`,inputFilterSensitiveLog:e=>e,outputFilterSensitiveLog:e=>e},{requestHandler:l}=i;return o.resolve(e=>l.handle(e.request,a||{}),c)}serialize(e,t){return(0,i.se_CreateTokenCommand)(e,t)}deserialize(e,t){return(0,i.de_CreateTokenCommand)(e,t)}}})),Hl=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.RegisterClientCommand=void 0;let t=L(),n=F(),r=P(),i=Bl();e.RegisterClientCommand=class e extends r.Command{static getEndpointParameterInstructions(){return{UseFIPS:{type:`builtInParams`,name:`useFipsEndpoint`},Endpoint:{type:`builtInParams`,name:`endpoint`},Region:{type:`builtInParams`,name:`region`},UseDualStack:{type:`builtInParams`,name:`useDualstackEndpoint`}}}constructor(e){super(),this.input=e}resolveMiddleware(r,i,a){this.middlewareStack.use((0,n.getSerdePlugin)(i,this.serialize,this.deserialize)),this.middlewareStack.use((0,t.getEndpointPlugin)(i,e.getEndpointParameterInstructions()));let o=r.concat(this.middlewareStack),{logger:s}=i,c={logger:s,clientName:`SSOOIDCClient`,commandName:`RegisterClientCommand`,inputFilterSensitiveLog:e=>e,outputFilterSensitiveLog:e=>e},{requestHandler:l}=i;return o.resolve(e=>l.handle(e.request,a||{}),c)}serialize(e,t){return(0,i.se_RegisterClientCommand)(e,t)}deserialize(e,t){return(0,i.de_RegisterClientCommand)(e,t)}}})),Ul=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.StartDeviceAuthorizationCommand=void 0;let t=L(),n=F(),r=P(),i=Bl();e.StartDeviceAuthorizationCommand=class e extends r.Command{static getEndpointParameterInstructions(){return{UseFIPS:{type:`builtInParams`,name:`useFipsEndpoint`},Endpoint:{type:`builtInParams`,name:`endpoint`},Region:{type:`builtInParams`,name:`region`},UseDualStack:{type:`builtInParams`,name:`useDualstackEndpoint`}}}constructor(e){super(),this.input=e}resolveMiddleware(r,i,a){this.middlewareStack.use((0,n.getSerdePlugin)(i,this.serialize,this.deserialize)),this.middlewareStack.use((0,t.getEndpointPlugin)(i,e.getEndpointParameterInstructions()));let o=r.concat(this.middlewareStack),{logger:s}=i,c={logger:s,clientName:`SSOOIDCClient`,commandName:`StartDeviceAuthorizationCommand`,inputFilterSensitiveLog:e=>e,outputFilterSensitiveLog:e=>e},{requestHandler:l}=i;return o.resolve(e=>l.handle(e.request,a||{}),c)}serialize(e,t){return(0,i.se_StartDeviceAuthorizationCommand)(e,t)}deserialize(e,t){return(0,i.de_StartDeviceAuthorizationCommand)(e,t)}}})),Wl=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.resolveClientEndpointParameters=void 0,e.resolveClientEndpointParameters=e=>({...e,useDualstackEndpoint:e.useDualstackEndpoint??!1,useFipsEndpoint:e.useFipsEndpoint??!1,defaultSigningName:`awsssooidc`})})),Gl=u(((e,t)=>{t.exports={name:`@aws-sdk/client-sso-oidc`,description:`AWS SDK for JavaScript Sso Oidc Client for Node.js, Browser and React Native`,version:`3.329.0`,scripts:{build:`concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types'`,"build:cjs":`tsc -p tsconfig.cjs.json`,"build:docs":`typedoc`,"build:es":`tsc -p tsconfig.es.json`,"build:include:deps":`lerna run --scope $npm_package_name --include-dependencies build`,"build:types":`tsc -p tsconfig.types.json`,"build:types:downlevel":`downlevel-dts dist-types dist-types/ts3.4`,clean:`rimraf ./dist-* && rimraf *.tsbuildinfo`,"extract:docs":`api-extractor run --local`,"generate:client":`node ../../scripts/generate-clients/single-service --solo sso-oidc`},main:`./dist-cjs/index.js`,types:`./dist-types/index.d.ts`,module:`./dist-es/index.js`,sideEffects:!1,dependencies:{"@aws-crypto/sha256-browser":`3.0.0`,"@aws-crypto/sha256-js":`3.0.0`,"@aws-sdk/config-resolver":`3.329.0`,"@aws-sdk/fetch-http-handler":`3.329.0`,"@aws-sdk/hash-node":`3.329.0`,"@aws-sdk/invalid-dependency":`3.329.0`,"@aws-sdk/middleware-content-length":`3.329.0`,"@aws-sdk/middleware-endpoint":`3.329.0`,"@aws-sdk/middleware-host-header":`3.329.0`,"@aws-sdk/middleware-logger":`3.329.0`,"@aws-sdk/middleware-recursion-detection":`3.329.0`,"@aws-sdk/middleware-retry":`3.329.0`,"@aws-sdk/middleware-serde":`3.329.0`,"@aws-sdk/middleware-stack":`3.329.0`,"@aws-sdk/middleware-user-agent":`3.329.0`,"@aws-sdk/node-config-provider":`3.329.0`,"@aws-sdk/node-http-handler":`3.329.0`,"@aws-sdk/protocol-http":`3.329.0`,"@aws-sdk/smithy-client":`3.329.0`,"@aws-sdk/types":`3.329.0`,"@aws-sdk/url-parser":`3.329.0`,"@aws-sdk/util-base64":`3.310.0`,"@aws-sdk/util-body-length-browser":`3.310.0`,"@aws-sdk/util-body-length-node":`3.310.0`,"@aws-sdk/util-defaults-mode-browser":`3.329.0`,"@aws-sdk/util-defaults-mode-node":`3.329.0`,"@aws-sdk/util-endpoints":`3.329.0`,"@aws-sdk/util-retry":`3.329.0`,"@aws-sdk/util-user-agent-browser":`3.329.0`,"@aws-sdk/util-user-agent-node":`3.329.0`,"@aws-sdk/util-utf8":`3.310.0`,tslib:`^2.5.0`},devDependencies:{"@aws-sdk/service-client-documentation-generator":`3.310.0`,"@tsconfig/node14":`1.0.3`,"@types/node":`^14.14.31`,concurrently:`7.0.0`,"downlevel-dts":`0.10.1`,rimraf:`3.0.2`,typedoc:`0.23.23`,typescript:`~4.9.5`},engines:{node:`>=14.0.0`},typesVersions:{"<4.0":{"dist-types/*":[`dist-types/ts3.4/*`]}},files:[`dist-*/**`],author:{name:`AWS SDK for JavaScript Team`,url:`https://aws.amazon.com/javascript/`},license:`Apache-2.0`,browser:{"./dist-es/runtimeConfig":`./dist-es/runtimeConfig.browser`},"react-native":{"./dist-es/runtimeConfig":`./dist-es/runtimeConfig.native`},homepage:`https://github.com/aws/aws-sdk-js-v3/tree/main/clients/client-sso-oidc`,repository:{type:`git`,url:`https://github.com/aws/aws-sdk-js-v3.git`,directory:`clients/client-sso-oidc`}}})),Kl=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.ruleSet=void 0;let t=`required`,n=`argv`,r=`PartitionResult`,i=`tree`,a=`error`,o=`endpoint`,s={[t]:!1,type:`String`},c={[t]:!0,default:!1,type:`Boolean`},l={ref:`Endpoint`},u={fn:`booleanEquals`,[n]:[{ref:`UseFIPS`},!0]},d={fn:`booleanEquals`,[n]:[{ref:`UseDualStack`},!0]},f={},p={fn:`booleanEquals`,[n]:[!0,{fn:`getAttr`,[n]:[{ref:r},`supportsFIPS`]}]},m={fn:`booleanEquals`,[n]:[!0,{fn:`getAttr`,[n]:[{ref:r},`supportsDualStack`]}]},h=[l],g=[u],_=[d];e.ruleSet={version:`1.0`,parameters:{Region:s,UseDualStack:c,UseFIPS:c,Endpoint:s},rules:[{conditions:[{fn:`aws.partition`,[n]:[{ref:`Region`}],assign:r}],type:i,rules:[{conditions:[{fn:`isSet`,[n]:h},{fn:`parseURL`,[n]:h,assign:`url`}],type:i,rules:[{conditions:g,error:`Invalid Configuration: FIPS and custom endpoint are not supported`,type:a},{type:i,rules:[{conditions:_,error:`Invalid Configuration: Dualstack and custom endpoint are not supported`,type:a},{endpoint:{url:l,properties:f,headers:f},type:o}]}]},{conditions:[u,d],type:i,rules:[{conditions:[p,m],type:i,rules:[{endpoint:{url:`https://oidc-fips.{Region}.{PartitionResult#dualStackDnsSuffix}`,properties:f,headers:f},type:o}]},{error:`FIPS and DualStack are enabled, but this partition does not support one or both`,type:a}]},{conditions:g,type:i,rules:[{conditions:[p],type:i,rules:[{type:i,rules:[{endpoint:{url:`https://oidc-fips.{Region}.{PartitionResult#dnsSuffix}`,properties:f,headers:f},type:o}]}]},{error:`FIPS is enabled but this partition does not support FIPS`,type:a}]},{conditions:_,type:i,rules:[{conditions:[m],type:i,rules:[{endpoint:{url:`https://oidc.{Region}.{PartitionResult#dualStackDnsSuffix}`,properties:f,headers:f},type:o}]},{error:`DualStack is enabled but this partition does not support DualStack`,type:a}]},{endpoint:{url:`https://oidc.{Region}.{PartitionResult#dnsSuffix}`,properties:f,headers:f},type:o}]}]}})),ql=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.defaultEndpointResolver=void 0;let t=Xo(),n=Kl();e.defaultEndpointResolver=(e,r={})=>(0,t.resolveEndpoint)(n.ruleSet,{endpointParams:e,logger:r.logger})})),Jl=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.getRuntimeConfig=void 0;let t=P(),n=Zt(),r=yl(),i=ea(),a=ql();e.getRuntimeConfig=e=>({apiVersion:`2019-06-10`,base64Decoder:e?.base64Decoder??r.fromBase64,base64Encoder:e?.base64Encoder??r.toBase64,disableHostPrefix:e?.disableHostPrefix??!1,endpointProvider:e?.endpointProvider??a.defaultEndpointResolver,logger:e?.logger??new t.NoOpLogger,serviceId:e?.serviceId??`SSO OIDC`,urlParser:e?.urlParser??n.parseUrl,utf8Decoder:e?.utf8Decoder??i.fromUtf8,utf8Encoder:e?.utf8Encoder??i.toUtf8})})),Yl=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.getRuntimeConfig=void 0;let t=(N(),m(j)).__importDefault(Gl()),n=Or(),r=vc(),i=Bi(),a=Ws(),o=Mc(),s=Pc(),c=Wr(),l=gl(),u=Jl(),d=P(),f=El(),p=P();e.getRuntimeConfig=e=>{(0,p.emitWarningIfUnsupportedVersion)(process.version);let m=(0,f.resolveDefaultsModeConfig)(e),h=()=>m().then(d.loadConfigsForDefaultMode),g=(0,u.getRuntimeConfig)(e);return{...g,...e,runtime:`node`,defaultsMode:m,bodyLengthChecker:e?.bodyLengthChecker??s.calculateBodyLength,defaultUserAgentProvider:e?.defaultUserAgentProvider??(0,l.defaultUserAgent)({serviceId:g.serviceId,clientVersion:t.default.version}),maxAttempts:e?.maxAttempts??(0,a.loadConfig)(i.NODE_MAX_ATTEMPT_CONFIG_OPTIONS),region:e?.region??(0,a.loadConfig)(n.NODE_REGION_CONFIG_OPTIONS,n.NODE_REGION_CONFIG_FILE_OPTIONS),requestHandler:e?.requestHandler??new o.NodeHttpHandler(h),retryMode:e?.retryMode??(0,a.loadConfig)({...i.NODE_RETRY_MODE_CONFIG_OPTIONS,default:async()=>(await h()).retryMode||c.DEFAULT_RETRY_MODE}),sha256:e?.sha256??r.Hash.bind(null,`sha256`),streamCollector:e?.streamCollector??o.streamCollector,useDualstackEndpoint:e?.useDualstackEndpoint??(0,a.loadConfig)(n.NODE_USE_DUALSTACK_ENDPOINT_CONFIG_OPTIONS),useFipsEndpoint:e?.useFipsEndpoint??(0,a.loadConfig)(n.NODE_USE_FIPS_ENDPOINT_CONFIG_OPTIONS)}}})),Xl=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.SSOOIDCClient=void 0;let t=Or(),n=kr(),r=L(),i=Z(),a=jr(),o=Mr(),s=Bi(),c=$o(),l=P(),u=Wl(),d=Yl();e.SSOOIDCClient=class extends l.Client{constructor(e){let l=(0,d.getRuntimeConfig)(e),f=(0,u.resolveClientEndpointParameters)(l),p=(0,t.resolveRegionConfig)(f),m=(0,r.resolveEndpointConfig)(p),h=(0,s.resolveRetryConfig)(m),g=(0,i.resolveHostHeaderConfig)(h),_=(0,c.resolveUserAgentConfig)(g);super(_),this.config=_,this.middlewareStack.use((0,s.getRetryPlugin)(this.config)),this.middlewareStack.use((0,n.getContentLengthPlugin)(this.config)),this.middlewareStack.use((0,i.getHostHeaderPlugin)(this.config)),this.middlewareStack.use((0,a.getLoggerPlugin)(this.config)),this.middlewareStack.use((0,o.getRecursionDetectionPlugin)(this.config)),this.middlewareStack.use((0,c.getUserAgentPlugin)(this.config))}destroy(){super.destroy()}}})),Zl=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.SSOOIDC=void 0;let t=P(),n=Vl(),r=Hl(),i=Ul(),a=Xl(),o={CreateTokenCommand:n.CreateTokenCommand,RegisterClientCommand:r.RegisterClientCommand,StartDeviceAuthorizationCommand:i.StartDeviceAuthorizationCommand};var s=class extends a.SSOOIDCClient{};e.SSOOIDC=s,(0,t.createAggregatedClient)(o,s)})),Ql=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=(N(),m(j));t.__exportStar(Vl(),e),t.__exportStar(Hl(),e),t.__exportStar(Ul(),e)})),$l=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),(N(),m(j)).__exportStar(zl(),e)})),eu=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.SSOOIDCServiceException=void 0;let t=(N(),m(j));t.__exportStar(Zl(),e),t.__exportStar(Xl(),e),t.__exportStar(Ql(),e),t.__exportStar($l(),e);var n=Rl();Object.defineProperty(e,`SSOOIDCServiceException`,{enumerable:!0,get:function(){return n.SSOOIDCServiceException}})})),tu=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.getSsoOidcClient=void 0;let t=eu(),n={};e.getSsoOidcClient=e=>{if(n[e])return n[e];let r=new t.SSOOIDCClient({region:e});return n[e]=r,r}})),nu=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.getNewSsoOidcToken=void 0;let t=eu(),n=tu();e.getNewSsoOidcToken=(e,r)=>(0,n.getSsoOidcClient)(r).send(new t.CreateTokenCommand({clientId:e.clientId,clientSecret:e.clientSecret,refreshToken:e.refreshToken,grantType:`refresh_token`}))})),ru=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.validateTokenExpiry=void 0;let t=qi(),n=Ll();e.validateTokenExpiry=e=>{if(e.expiration&&e.expiration.getTime()<Date.now())throw new t.TokenProviderError(`Token is expired. ${n.REFRESH_MESSAGE}`,!1)}})),iu=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.validateTokenKey=void 0;let t=qi(),n=Ll();e.validateTokenKey=(e,r,i=!1)=>{if(r===void 0)throw new t.TokenProviderError(`Value not present for '${e}' in SSO Token${i?`. Cannot refresh`:``}. ${n.REFRESH_MESSAGE}`,!1)}})),au=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.writeSSOTokenToFile=void 0;let t=Ps(),{writeFile:n}=h(`fs`).promises;e.writeSSOTokenToFile=(e,r)=>n((0,t.getSSOTokenFilepath)(e),JSON.stringify(r,null,2))})),ou=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.fromSso=void 0;let t=qi(),n=Ps(),r=Ll(),i=nu(),a=ru(),o=iu(),s=au(),c=new Date(0);e.fromSso=(e={})=>async()=>{let l=await(0,n.parseKnownFiles)(e),u=(0,n.getProfileName)(e),d=l[u];if(!d)throw new t.TokenProviderError(`Profile '${u}' could not be found in shared credentials file.`,!1);if(!d.sso_session)throw new t.TokenProviderError(`Profile '${u}' is missing required property 'sso_session'.`);let f=d.sso_session,p=(await(0,n.loadSsoSessionData)(e))[f];if(!p)throw new t.TokenProviderError(`Sso session '${f}' could not be found in shared credentials file.`,!1);for(let e of[`sso_start_url`,`sso_region`])if(!p[e])throw new t.TokenProviderError(`Sso session '${f}' is missing required property '${e}'.`,!1);p.sso_start_url;let m=p.sso_region,h;try{h=await(0,n.getSSOTokenFromFile)(f)}catch{throw new t.TokenProviderError(`The SSO session token associated with profile=${u} was not found or is invalid. ${r.REFRESH_MESSAGE}`,!1)}(0,o.validateTokenKey)(`accessToken`,h.accessToken),(0,o.validateTokenKey)(`expiresAt`,h.expiresAt);let{accessToken:g,expiresAt:_}=h,v={token:g,expiration:new Date(_)};if(v.expiration.getTime()-Date.now()>r.EXPIRE_WINDOW_MS)return v;if(Date.now()-c.getTime()<30*1e3)return(0,a.validateTokenExpiry)(v),v;(0,o.validateTokenKey)(`clientId`,h.clientId,!0),(0,o.validateTokenKey)(`clientSecret`,h.clientSecret,!0),(0,o.validateTokenKey)(`refreshToken`,h.refreshToken,!0);try{c.setTime(Date.now());let e=await(0,i.getNewSsoOidcToken)(h,m);(0,o.validateTokenKey)(`accessToken`,e.accessToken),(0,o.validateTokenKey)(`expiresIn`,e.expiresIn);let t=new Date(Date.now()+e.expiresIn*1e3);try{await(0,s.writeSSOTokenToFile)(f,{...h,accessToken:e.accessToken,expiresAt:t.toISOString(),refreshToken:e.refreshToken})}catch{}return{token:e.accessToken,expiration:t}}catch{return(0,a.validateTokenExpiry)(v),v}}})),su=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.fromStatic=void 0;let t=qi();e.fromStatic=({token:e})=>async()=>{if(!e||!e.token)throw new t.TokenProviderError(`Please pass a valid token to fromStatic`,!1);return e}})),cu=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.nodeProvider=void 0;let t=qi(),n=ou();e.nodeProvider=(e={})=>(0,t.memoize)((0,t.chain)((0,n.fromSso)(e),async()=>{throw new t.TokenProviderError(`Could not load token from any providers`,!1)}),e=>e.expiration!==void 0&&e.expiration.getTime()-Date.now()<3e5,e=>e.expiration!==void 0)})),lu=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=(N(),m(j));t.__exportStar(ou(),e),t.__exportStar(su(),e),t.__exportStar(cu(),e)})),uu=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.resolveSSOCredentials=void 0;let t=Il(),n=qi(),r=Ps(),i=lu();e.resolveSSOCredentials=async({ssoStartUrl:e,ssoSession:a,ssoAccountId:o,ssoRegion:s,ssoRoleName:c,ssoClient:l,profile:u})=>{let d,f=`To refresh this SSO session run aws sso login with the corresponding profile.`;if(a)try{let e=await(0,i.fromSso)({profile:u})();d={accessToken:e.token,expiresAt:new Date(e.expiration).toISOString()}}catch(e){throw new n.CredentialsProviderError(e.message,!1)}else try{d=await(0,r.getSSOTokenFromFile)(e)}catch{throw new n.CredentialsProviderError(`The SSO session associated with this profile is invalid. ${f}`,!1)}if(new Date(d.expiresAt).getTime()-Date.now()<=9e5)throw new n.CredentialsProviderError(`The SSO session associated with this profile has expired. ${f}`,!1);let{accessToken:p}=d,m=l||new t.SSOClient({region:s}),h;try{h=await m.send(new t.GetRoleCredentialsCommand({accountId:o,roleName:c,accessToken:p}))}catch(e){throw n.CredentialsProviderError.from(e,!1)}let{roleCredentials:{accessKeyId:g,secretAccessKey:_,sessionToken:v,expiration:y}={}}=h;if(!g||!_||!v||!y)throw new n.CredentialsProviderError(`SSO returns an invalid temporary credential.`,!1);return{accessKeyId:g,secretAccessKey:_,sessionToken:v,expiration:new Date(y)}}})),du=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.validateSsoProfile=void 0;let t=qi();e.validateSsoProfile=e=>{let{sso_start_url:n,sso_account_id:r,sso_region:i,sso_role_name:a}=e;if(!n||!r||!i||!a)throw new t.CredentialsProviderError(`Profile is configured with invalid SSO credentials. Required parameters "sso_account_id", "sso_region", "sso_role_name", "sso_start_url". Got ${Object.keys(e).join(`, `)}\nReference: https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-sso.html`,!1);return e}})),fu=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.fromSSO=void 0;let t=qi(),n=Ps(),r=cc(),i=uu(),a=du();e.fromSSO=(e={})=>async()=>{let{ssoStartUrl:o,ssoAccountId:s,ssoRegion:c,ssoRoleName:l,ssoClient:u,ssoSession:d}=e,f=(0,n.getProfileName)(e);if(!o&&!s&&!c&&!l&&!d){let s=(await(0,n.parseKnownFiles)(e))[f];if(!s)throw new t.CredentialsProviderError(`Profile ${f} was not found.`);if(!(0,r.isSsoProfile)(s))throw new t.CredentialsProviderError(`Profile ${f} is not configured with SSO credentials.`);if(s?.sso_session){let r=(await(0,n.loadSsoSessionData)(e))[s.sso_session],i=` configurations in profile ${f} and sso-session ${s.sso_session}`;if(c&&c!==r.sso_region)throw new t.CredentialsProviderError(`Conflicting SSO region`+i,!1);if(o&&o!==r.sso_start_url)throw new t.CredentialsProviderError(`Conflicting SSO start_url`+i,!1);s.sso_region=r.sso_region,s.sso_start_url=r.sso_start_url}let{sso_start_url:l,sso_account_id:d,sso_region:p,sso_role_name:m,sso_session:h}=(0,a.validateSsoProfile)(s);return(0,i.resolveSSOCredentials)({ssoStartUrl:l,ssoSession:h,ssoAccountId:d,ssoRegion:p,ssoRoleName:m,ssoClient:u,profile:f})}else if(!o||!s||!c||!l)throw new t.CredentialsProviderError(`Incomplete configuration. The fromSSO() argument hash must include "ssoStartUrl", "ssoAccountId", "ssoRegion", "ssoRoleName"`);else return(0,i.resolveSSOCredentials)({ssoStartUrl:o,ssoSession:d,ssoAccountId:s,ssoRegion:c,ssoRoleName:l,ssoClient:u,profile:f})}})),pu=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0})})),mu=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=(N(),m(j));t.__exportStar(fu(),e),t.__exportStar(cc(),e),t.__exportStar(pu(),e),t.__exportStar(du(),e)})),hu=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.resolveSsoCredentials=e.isSsoProfile=void 0;let t=mu();var n=mu();Object.defineProperty(e,`isSsoProfile`,{enumerable:!0,get:function(){return n.isSsoProfile}}),e.resolveSsoCredentials=e=>{let{sso_start_url:n,sso_account_id:r,sso_session:i,sso_region:a,sso_role_name:o}=(0,t.validateSsoProfile)(e);return(0,t.fromSSO)({ssoStartUrl:n,ssoAccountId:r,ssoSession:i,ssoRegion:a,ssoRoleName:o})()}})),gu=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.resolveStaticCredentials=e.isStaticCredsProfile=void 0,e.isStaticCredsProfile=e=>!!e&&typeof e==`object`&&typeof e.aws_access_key_id==`string`&&typeof e.aws_secret_access_key==`string`&&[`undefined`,`string`].indexOf(typeof e.aws_session_token)>-1,e.resolveStaticCredentials=e=>Promise.resolve({accessKeyId:e.aws_access_key_id,secretAccessKey:e.aws_secret_access_key,sessionToken:e.aws_session_token})})),_u=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.fromWebToken=void 0;let t=qi();e.fromWebToken=e=>()=>{let{roleArn:n,roleSessionName:r,webIdentityToken:i,providerId:a,policyArns:o,policy:s,durationSeconds:c,roleAssumerWithWebIdentity:l}=e;if(!l)throw new t.CredentialsProviderError(`Role Arn '${n}' needs to be assumed with web identity, but no role assumption callback was provided.`,!1);return l({RoleArn:n,RoleSessionName:r??`aws-sdk-js-session-${Date.now()}`,WebIdentityToken:i,ProviderId:a,PolicyArns:o,Policy:s,DurationSeconds:c})}})),vu=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.fromTokenFile=void 0;let t=qi(),n=h(`fs`),r=_u();e.fromTokenFile=(e={})=>async()=>i(e);let i=e=>{let i=e?.webIdentityTokenFile??process.env.AWS_WEB_IDENTITY_TOKEN_FILE,a=e?.roleArn??process.env.AWS_ROLE_ARN,o=e?.roleSessionName??process.env.AWS_ROLE_SESSION_NAME;if(!i||!a)throw new t.CredentialsProviderError(`Web identity configuration not specified`);return(0,r.fromWebToken)({...e,webIdentityToken:(0,n.readFileSync)(i,{encoding:`ascii`}),roleArn:a,roleSessionName:o})()}})),yu=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=(N(),m(j));t.__exportStar(vu(),e),t.__exportStar(_u(),e)})),bu=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.resolveWebIdentityCredentials=e.isWebIdentityProfile=void 0;let t=yu();e.isWebIdentityProfile=e=>!!e&&typeof e==`object`&&typeof e.web_identity_token_file==`string`&&typeof e.role_arn==`string`&&[`undefined`,`string`].indexOf(typeof e.role_session_name)>-1,e.resolveWebIdentityCredentials=async(e,n)=>(0,t.fromTokenFile)({webIdentityTokenFile:e.web_identity_token_file,roleArn:e.role_arn,roleSessionName:e.role_session_name,roleAssumerWithWebIdentity:n.roleAssumerWithWebIdentity})()})),xu=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.resolveProfileData=void 0;let t=qi(),n=nc(),r=sc(),i=hu(),a=gu(),o=bu();e.resolveProfileData=async(e,s,c,l={})=>{let u=s[e];if(Object.keys(l).length>0&&(0,a.isStaticCredsProfile)(u))return(0,a.resolveStaticCredentials)(u);if((0,n.isAssumeRoleProfile)(u))return(0,n.resolveAssumeRoleCredentials)(e,s,c,l);if((0,a.isStaticCredsProfile)(u))return(0,a.resolveStaticCredentials)(u);if((0,o.isWebIdentityProfile)(u))return(0,o.resolveWebIdentityCredentials)(u,c);if((0,r.isProcessProfile)(u))return(0,r.resolveProcessCredentials)(c,e);if((0,i.isSsoProfile)(u))return(0,i.resolveSsoCredentials)(u);throw new t.CredentialsProviderError(`Profile ${e} could not be found or parsed in shared credentials file.`)}})),Su=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.fromIni=void 0;let t=Ps(),n=xu();e.fromIni=(e={})=>async()=>{let r=await(0,t.parseKnownFiles)(e);return(0,n.resolveProfileData)((0,t.getProfileName)(e),r,e)}})),Cu=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),(N(),m(j)).__exportStar(Su(),e)})),wu=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.remoteProvider=e.ENV_IMDS_DISABLED=void 0;let t=ec(),n=qi();e.ENV_IMDS_DISABLED=`AWS_EC2_METADATA_DISABLED`,e.remoteProvider=r=>process.env[t.ENV_CMDS_RELATIVE_URI]||process.env[t.ENV_CMDS_FULL_URI]?(0,t.fromContainerMetadata)(r):process.env[e.ENV_IMDS_DISABLED]?async()=>{throw new n.CredentialsProviderError(`EC2 Instance Metadata Service access disabled`)}:(0,t.fromInstanceMetadata)(r)})),Tu=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.defaultProvider=void 0;let t=vs(),n=Cu(),r=oc(),i=mu(),a=yu(),o=qi(),s=Ps(),c=wu();e.defaultProvider=(e={})=>(0,o.memoize)((0,o.chain)(...e.profile||process.env[s.ENV_PROFILE]?[]:[(0,t.fromEnv)()],(0,i.fromSSO)(e),(0,n.fromIni)(e),(0,r.fromProcess)(e),(0,a.fromTokenFile)(e),(0,c.remoteProvider)(e),async()=>{throw new o.CredentialsProviderError(`Could not load credentials from any providers`,!1)}),e=>e.expiration!==void 0&&e.expiration.getTime()-Date.now()<3e5,e=>e.expiration!==void 0)})),Eu=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),(N(),m(j)).__exportStar(Tu(),e)})),Du=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.ruleSet=void 0;let t=`required`,n=`type`,r=`argv`,i=`booleanEquals`,a=`tree`,o=`stringEquals`,s=`sigv4`,c=`us-east-1`,l=`endpoint`,u=`https://sts.{Region}.{PartitionResult#dnsSuffix}`,d=`error`,f=`getAttr`,p={[t]:!1,[n]:`String`},m={[t]:!0,default:!1,[n]:`Boolean`},h={ref:`Endpoint`},g={fn:`isSet`,[r]:[{ref:`Region`}]},_={ref:`Region`},v={fn:`aws.partition`,[r]:[_],assign:`PartitionResult`},y={ref:`UseFIPS`},b={ref:`UseDualStack`},x={url:`https://sts.amazonaws.com`,properties:{authSchemes:[{name:s,signingName:`sts`,signingRegion:c}]},headers:{}},S={},C={conditions:[{fn:o,[r]:[_,`aws-global`]}],[l]:x,[n]:l},w={fn:i,[r]:[y,!0]},ee={fn:i,[r]:[b,!0]},te={fn:i,[r]:[!0,{fn:f,[r]:[{ref:`PartitionResult`},`supportsFIPS`]}]},T={ref:`PartitionResult`},E={fn:i,[r]:[!0,{fn:f,[r]:[T,`supportsDualStack`]}]},ne=[{fn:`isSet`,[r]:[h]}],re=[w],ie=[ee];e.ruleSet={version:`1.0`,parameters:{Region:p,UseDualStack:m,UseFIPS:m,Endpoint:p,UseGlobalEndpoint:m},rules:[{conditions:[{fn:i,[r]:[{ref:`UseGlobalEndpoint`},!0]},{fn:`not`,[r]:ne},g,v,{fn:i,[r]:[y,!1]},{fn:i,[r]:[b,!1]}],[n]:a,rules:[{conditions:[{fn:o,[r]:[_,`ap-northeast-1`]}],endpoint:x,[n]:l},{conditions:[{fn:o,[r]:[_,`ap-south-1`]}],endpoint:x,[n]:l},{conditions:[{fn:o,[r]:[_,`ap-southeast-1`]}],endpoint:x,[n]:l},{conditions:[{fn:o,[r]:[_,`ap-southeast-2`]}],endpoint:x,[n]:l},C,{conditions:[{fn:o,[r]:[_,`ca-central-1`]}],endpoint:x,[n]:l},{conditions:[{fn:o,[r]:[_,`eu-central-1`]}],endpoint:x,[n]:l},{conditions:[{fn:o,[r]:[_,`eu-north-1`]}],endpoint:x,[n]:l},{conditions:[{fn:o,[r]:[_,`eu-west-1`]}],endpoint:x,[n]:l},{conditions:[{fn:o,[r]:[_,`eu-west-2`]}],endpoint:x,[n]:l},{conditions:[{fn:o,[r]:[_,`eu-west-3`]}],endpoint:x,[n]:l},{conditions:[{fn:o,[r]:[_,`sa-east-1`]}],endpoint:x,[n]:l},{conditions:[{fn:o,[r]:[_,c]}],endpoint:x,[n]:l},{conditions:[{fn:o,[r]:[_,`us-east-2`]}],endpoint:x,[n]:l},{conditions:[{fn:o,[r]:[_,`us-west-1`]}],endpoint:x,[n]:l},{conditions:[{fn:o,[r]:[_,`us-west-2`]}],endpoint:x,[n]:l},{endpoint:{url:u,properties:{authSchemes:[{name:s,signingName:`sts`,signingRegion:`{Region}`}]},headers:S},[n]:l}]},{conditions:ne,[n]:a,rules:[{conditions:re,error:`Invalid Configuration: FIPS and custom endpoint are not supported`,[n]:d},{[n]:a,rules:[{conditions:ie,error:`Invalid Configuration: Dualstack and custom endpoint are not supported`,[n]:d},{endpoint:{url:h,properties:S,headers:S},[n]:l}]}]},{[n]:a,rules:[{conditions:[g],[n]:a,rules:[{conditions:[v],[n]:a,rules:[{conditions:[w,ee],[n]:a,rules:[{conditions:[te,E],[n]:a,rules:[{[n]:a,rules:[{endpoint:{url:`https://sts-fips.{Region}.{PartitionResult#dualStackDnsSuffix}`,properties:S,headers:S},[n]:l}]}]},{error:`FIPS and DualStack are enabled, but this partition does not support one or both`,[n]:d}]},{conditions:re,[n]:a,rules:[{conditions:[te],[n]:a,rules:[{[n]:a,rules:[{conditions:[{fn:o,[r]:[`aws-us-gov`,{fn:f,[r]:[T,`name`]}]}],endpoint:{url:`https://sts.{Region}.amazonaws.com`,properties:S,headers:S},[n]:l},{endpoint:{url:`https://sts-fips.{Region}.{PartitionResult#dnsSuffix}`,properties:S,headers:S},[n]:l}]}]},{error:`FIPS is enabled but this partition does not support FIPS`,[n]:d}]},{conditions:ie,[n]:a,rules:[{conditions:[E],[n]:a,rules:[{[n]:a,rules:[{endpoint:{url:`https://sts.{Region}.{PartitionResult#dualStackDnsSuffix}`,properties:S,headers:S},[n]:l}]}]},{error:`DualStack is enabled but this partition does not support DualStack`,[n]:d}]},{[n]:a,rules:[C,{endpoint:{url:u,properties:S,headers:S},[n]:l}]}]}]},{error:`Invalid Configuration: Missing Region`,[n]:d}]}]}})),Ou=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.defaultEndpointResolver=void 0;let t=Xo(),n=Du();e.defaultEndpointResolver=(e,r={})=>(0,t.resolveEndpoint)(n.ruleSet,{endpointParams:e,logger:r.logger})})),ku=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.getRuntimeConfig=void 0;let t=P(),n=Zt(),r=yl(),i=ea(),a=Ou();e.getRuntimeConfig=e=>({apiVersion:`2011-06-15`,base64Decoder:e?.base64Decoder??r.fromBase64,base64Encoder:e?.base64Encoder??r.toBase64,disableHostPrefix:e?.disableHostPrefix??!1,endpointProvider:e?.endpointProvider??a.defaultEndpointResolver,logger:e?.logger??new t.NoOpLogger,serviceId:e?.serviceId??`STS`,urlParser:e?.urlParser??n.parseUrl,utf8Decoder:e?.utf8Decoder??i.fromUtf8,utf8Encoder:e?.utf8Encoder??i.toUtf8})})),Au=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.getRuntimeConfig=void 0;let t=(N(),m(j)).__importDefault(hs()),n=gs(),r=Or(),i=Eu(),a=vc(),o=Bi(),s=Ws(),c=Mc(),l=Pc(),u=Wr(),d=gl(),f=ku(),p=P(),h=El(),g=P();e.getRuntimeConfig=e=>{(0,g.emitWarningIfUnsupportedVersion)(process.version);let m=(0,h.resolveDefaultsModeConfig)(e),_=()=>m().then(p.loadConfigsForDefaultMode),v=(0,f.getRuntimeConfig)(e);return{...v,...e,runtime:`node`,defaultsMode:m,bodyLengthChecker:e?.bodyLengthChecker??l.calculateBodyLength,credentialDefaultProvider:e?.credentialDefaultProvider??(0,n.decorateDefaultCredentialProvider)(i.defaultProvider),defaultUserAgentProvider:e?.defaultUserAgentProvider??(0,d.defaultUserAgent)({serviceId:v.serviceId,clientVersion:t.default.version}),maxAttempts:e?.maxAttempts??(0,s.loadConfig)(o.NODE_MAX_ATTEMPT_CONFIG_OPTIONS),region:e?.region??(0,s.loadConfig)(r.NODE_REGION_CONFIG_OPTIONS,r.NODE_REGION_CONFIG_FILE_OPTIONS),requestHandler:e?.requestHandler??new c.NodeHttpHandler(_),retryMode:e?.retryMode??(0,s.loadConfig)({...o.NODE_RETRY_MODE_CONFIG_OPTIONS,default:async()=>(await _()).retryMode||u.DEFAULT_RETRY_MODE}),sha256:e?.sha256??a.Hash.bind(null,`sha256`),streamCollector:e?.streamCollector??c.streamCollector,useDualstackEndpoint:e?.useDualstackEndpoint??(0,s.loadConfig)(r.NODE_USE_DUALSTACK_ENDPOINT_CONFIG_OPTIONS),useFipsEndpoint:e?.useFipsEndpoint??(0,s.loadConfig)(r.NODE_USE_FIPS_ENDPOINT_CONFIG_OPTIONS)}}})),ju=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.STSClient=void 0;let t=Or(),n=kr(),r=L(),i=Z(),a=jr(),o=Mr(),s=Bi(),c=ps(),l=$o(),u=P(),d=ms(),f=Au();e.STSClient=class e extends u.Client{constructor(u){let p=(0,f.getRuntimeConfig)(u),m=(0,d.resolveClientEndpointParameters)(p),h=(0,t.resolveRegionConfig)(m),g=(0,r.resolveEndpointConfig)(h),_=(0,s.resolveRetryConfig)(g),v=(0,i.resolveHostHeaderConfig)(_),y=(0,c.resolveStsAuthConfig)(v,{stsClientCtor:e}),b=(0,l.resolveUserAgentConfig)(y);super(b),this.config=b,this.middlewareStack.use((0,s.getRetryPlugin)(this.config)),this.middlewareStack.use((0,n.getContentLengthPlugin)(this.config)),this.middlewareStack.use((0,i.getHostHeaderPlugin)(this.config)),this.middlewareStack.use((0,a.getLoggerPlugin)(this.config)),this.middlewareStack.use((0,o.getRecursionDetectionPlugin)(this.config)),this.middlewareStack.use((0,l.getUserAgentPlugin)(this.config))}destroy(){super.destroy()}}})),Mu=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.STS=void 0;let t=P(),n=as(),r=os(),i=ss(),a=cs(),o=ls(),s=us(),c=ds(),l=fs(),u=ju(),d={AssumeRoleCommand:n.AssumeRoleCommand,AssumeRoleWithSAMLCommand:r.AssumeRoleWithSAMLCommand,AssumeRoleWithWebIdentityCommand:i.AssumeRoleWithWebIdentityCommand,DecodeAuthorizationMessageCommand:a.DecodeAuthorizationMessageCommand,GetAccessKeyInfoCommand:o.GetAccessKeyInfoCommand,GetCallerIdentityCommand:s.GetCallerIdentityCommand,GetFederationTokenCommand:c.GetFederationTokenCommand,GetSessionTokenCommand:l.GetSessionTokenCommand};var f=class extends u.STSClient{};e.STS=f,(0,t.createAggregatedClient)(d,f)})),Nu=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=(N(),m(j));t.__exportStar(as(),e),t.__exportStar(os(),e),t.__exportStar(ss(),e),t.__exportStar(cs(),e),t.__exportStar(ls(),e),t.__exportStar(us(),e),t.__exportStar(ds(),e),t.__exportStar(fs(),e)})),Pu=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.decorateDefaultCredentialProvider=e.getDefaultRoleAssumerWithWebIdentity=e.getDefaultRoleAssumer=void 0;let t=gs(),n=ju(),r=(e,t)=>t?class extends e{constructor(e){super(e);for(let e of t)this.middlewareStack.use(e)}}:e;e.getDefaultRoleAssumer=(e={},i)=>(0,t.getDefaultRoleAssumer)(e,r(n.STSClient,i)),e.getDefaultRoleAssumerWithWebIdentity=(e={},i)=>(0,t.getDefaultRoleAssumerWithWebIdentity)(e,r(n.STSClient,i)),e.decorateDefaultCredentialProvider=t=>n=>t({roleAssumer:(0,e.getDefaultRoleAssumer)(n),roleAssumerWithWebIdentity:(0,e.getDefaultRoleAssumerWithWebIdentity)(n),...n})})),Fu=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),(N(),m(j)).__exportStar(rs(),e)})),Iu=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.STSServiceException=void 0;let t=(N(),m(j));t.__exportStar(Mu(),e),t.__exportStar(ju(),e),t.__exportStar(Nu(),e),t.__exportStar(Pu(),e),t.__exportStar(Fu(),e);var n=ns();Object.defineProperty(e,`STSServiceException`,{enumerable:!0,get:function(){return n.STSServiceException}})})),Lu=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.ruleSet=void 0;let t=`required`,n=`argv`,r=`isSet`,i=`tree`,a=`error`,o=`endpoint`,s=`PartitionResult`,c=`stringEquals`,l={[t]:!1,type:`String`},u={[t]:!0,default:!1,type:`Boolean`},d={ref:`Endpoint`},f={fn:`booleanEquals`,[n]:[{ref:`UseFIPS`},!0]},p={fn:`booleanEquals`,[n]:[{ref:`UseDualStack`},!0]},m={},h={ref:`Region`},g={fn:`booleanEquals`,[n]:[!0,{fn:`getAttr`,[n]:[{ref:s},`supportsFIPS`]}]},_={fn:`booleanEquals`,[n]:[!0,{fn:`getAttr`,[n]:[{ref:s},`supportsDualStack`]}]},v=[f],y=[p],b=[h];e.ruleSet={version:`1.0`,parameters:{Region:l,UseDualStack:u,UseFIPS:u,Endpoint:l},rules:[{conditions:[{fn:r,[n]:[d]}],type:i,rules:[{conditions:v,error:`Invalid Configuration: FIPS and custom endpoint are not supported`,type:a},{type:i,rules:[{conditions:y,error:`Invalid Configuration: Dualstack and custom endpoint are not supported`,type:a},{endpoint:{url:d,properties:m,headers:m},type:o}]}]},{type:i,rules:[{conditions:[{fn:r,[n]:b}],type:i,rules:[{conditions:[{fn:`aws.partition`,[n]:b,assign:s}],type:i,rules:[{conditions:[f,p],type:i,rules:[{conditions:[g,_],type:i,rules:[{type:i,rules:[{endpoint:{url:`https://sns-fips.{Region}.{PartitionResult#dualStackDnsSuffix}`,properties:m,headers:m},type:o}]}]},{error:`FIPS and DualStack are enabled, but this partition does not support one or both`,type:a}]},{conditions:v,type:i,rules:[{conditions:[g],type:i,rules:[{type:i,rules:[{conditions:[{fn:c,[n]:[h,`us-gov-east-1`]}],endpoint:{url:`https://sns.us-gov-east-1.amazonaws.com`,properties:m,headers:m},type:o},{conditions:[{fn:c,[n]:[h,`us-gov-west-1`]}],endpoint:{url:`https://sns.us-gov-west-1.amazonaws.com`,properties:m,headers:m},type:o},{endpoint:{url:`https://sns-fips.{Region}.{PartitionResult#dnsSuffix}`,properties:m,headers:m},type:o}]}]},{error:`FIPS is enabled but this partition does not support FIPS`,type:a}]},{conditions:y,type:i,rules:[{conditions:[_],type:i,rules:[{type:i,rules:[{endpoint:{url:`https://sns.{Region}.{PartitionResult#dualStackDnsSuffix}`,properties:m,headers:m},type:o}]}]},{error:`DualStack is enabled but this partition does not support DualStack`,type:a}]},{type:i,rules:[{endpoint:{url:`https://sns.{Region}.{PartitionResult#dnsSuffix}`,properties:m,headers:m},type:o}]}]}]},{error:`Invalid Configuration: Missing Region`,type:a}]}]}})),Ru=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.defaultEndpointResolver=void 0;let t=Xo(),n=Lu();e.defaultEndpointResolver=(e,r={})=>(0,t.resolveEndpoint)(n.ruleSet,{endpointParams:e,logger:r.logger})})),zu=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.getRuntimeConfig=void 0;let t=P(),n=Zt(),r=yl(),i=ea(),a=Ru();e.getRuntimeConfig=e=>({apiVersion:`2010-03-31`,base64Decoder:e?.base64Decoder??r.fromBase64,base64Encoder:e?.base64Encoder??r.toBase64,disableHostPrefix:e?.disableHostPrefix??!1,endpointProvider:e?.endpointProvider??a.defaultEndpointResolver,logger:e?.logger??new t.NoOpLogger,serviceId:e?.serviceId??`SNS`,urlParser:e?.urlParser??n.parseUrl,utf8Decoder:e?.utf8Decoder??i.fromUtf8,utf8Encoder:e?.utf8Encoder??i.toUtf8})})),Bu=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.getRuntimeConfig=void 0;let t=(N(),m(j)).__importDefault(ts()),n=Iu(),r=Or(),i=Eu(),a=vc(),o=Bi(),s=Ws(),c=Mc(),l=Pc(),u=Wr(),d=gl(),f=zu(),p=P(),h=El(),g=P();e.getRuntimeConfig=e=>{(0,g.emitWarningIfUnsupportedVersion)(process.version);let m=(0,h.resolveDefaultsModeConfig)(e),_=()=>m().then(p.loadConfigsForDefaultMode),v=(0,f.getRuntimeConfig)(e);return{...v,...e,runtime:`node`,defaultsMode:m,bodyLengthChecker:e?.bodyLengthChecker??l.calculateBodyLength,credentialDefaultProvider:e?.credentialDefaultProvider??(0,n.decorateDefaultCredentialProvider)(i.defaultProvider),defaultUserAgentProvider:e?.defaultUserAgentProvider??(0,d.defaultUserAgent)({serviceId:v.serviceId,clientVersion:t.default.version}),maxAttempts:e?.maxAttempts??(0,s.loadConfig)(o.NODE_MAX_ATTEMPT_CONFIG_OPTIONS),region:e?.region??(0,s.loadConfig)(r.NODE_REGION_CONFIG_OPTIONS,r.NODE_REGION_CONFIG_FILE_OPTIONS),requestHandler:e?.requestHandler??new c.NodeHttpHandler(_),retryMode:e?.retryMode??(0,s.loadConfig)({...o.NODE_RETRY_MODE_CONFIG_OPTIONS,default:async()=>(await _()).retryMode||u.DEFAULT_RETRY_MODE}),sha256:e?.sha256??a.Hash.bind(null,`sha256`),streamCollector:e?.streamCollector??c.streamCollector,useDualstackEndpoint:e?.useDualstackEndpoint??(0,s.loadConfig)(r.NODE_USE_DUALSTACK_ENDPOINT_CONFIG_OPTIONS),useFipsEndpoint:e?.useFipsEndpoint??(0,s.loadConfig)(r.NODE_USE_FIPS_ENDPOINT_CONFIG_OPTIONS)}}})),Vu=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.SNSClient=void 0;let t=Or(),n=kr(),r=L(),i=Z(),a=jr(),o=Mr(),s=Bi(),c=xa(),l=$o(),u=P(),d=es(),f=Bu();e.SNSClient=class extends u.Client{constructor(e){let u=(0,f.getRuntimeConfig)(e),p=(0,d.resolveClientEndpointParameters)(u),m=(0,t.resolveRegionConfig)(p),h=(0,r.resolveEndpointConfig)(m),g=(0,s.resolveRetryConfig)(h),_=(0,i.resolveHostHeaderConfig)(g),v=(0,c.resolveAwsAuthConfig)(_),y=(0,l.resolveUserAgentConfig)(v);super(y),this.config=y,this.middlewareStack.use((0,s.getRetryPlugin)(this.config)),this.middlewareStack.use((0,n.getContentLengthPlugin)(this.config)),this.middlewareStack.use((0,i.getHostHeaderPlugin)(this.config)),this.middlewareStack.use((0,a.getLoggerPlugin)(this.config)),this.middlewareStack.use((0,o.getRecursionDetectionPlugin)(this.config)),this.middlewareStack.use((0,c.getAwsAuthPlugin)(this.config)),this.middlewareStack.use((0,l.getUserAgentPlugin)(this.config))}destroy(){super.destroy()}}})),Hu=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.SNS=void 0;let t=P(),n=jn(),r=Mn(),i=Nn(),a=Pn(),o=Fn(),s=In(),c=Ln(),l=Rn(),u=zn(),d=Bn(),f=Vn(),p=Hn(),m=Un(),h=Wn(),g=Gn(),_=Kn(),v=qn(),y=Jn(),b=Yn(),x=Xn(),S=Zn(),C=z(),w=Qn(),ee=$n(),te=er(),T=tr(),E=nr(),ne=rr(),re=ir(),ie=ar(),ae=or(),oe=sr(),se=cr(),ce=lr(),le=ur(),ue=dr(),de=fr(),fe=pr(),pe=mr(),me=hr(),he=gr(),ge=_r(),_e=Vu(),ve={AddPermissionCommand:n.AddPermissionCommand,CheckIfPhoneNumberIsOptedOutCommand:r.CheckIfPhoneNumberIsOptedOutCommand,ConfirmSubscriptionCommand:i.ConfirmSubscriptionCommand,CreatePlatformApplicationCommand:a.CreatePlatformApplicationCommand,CreatePlatformEndpointCommand:o.CreatePlatformEndpointCommand,CreateSMSSandboxPhoneNumberCommand:s.CreateSMSSandboxPhoneNumberCommand,CreateTopicCommand:c.CreateTopicCommand,DeleteEndpointCommand:l.DeleteEndpointCommand,DeletePlatformApplicationCommand:u.DeletePlatformApplicationCommand,DeleteSMSSandboxPhoneNumberCommand:d.DeleteSMSSandboxPhoneNumberCommand,DeleteTopicCommand:f.DeleteTopicCommand,GetDataProtectionPolicyCommand:p.GetDataProtectionPolicyCommand,GetEndpointAttributesCommand:m.GetEndpointAttributesCommand,GetPlatformApplicationAttributesCommand:h.GetPlatformApplicationAttributesCommand,GetSMSAttributesCommand:g.GetSMSAttributesCommand,GetSMSSandboxAccountStatusCommand:_.GetSMSSandboxAccountStatusCommand,GetSubscriptionAttributesCommand:v.GetSubscriptionAttributesCommand,GetTopicAttributesCommand:y.GetTopicAttributesCommand,ListEndpointsByPlatformApplicationCommand:b.ListEndpointsByPlatformApplicationCommand,ListOriginationNumbersCommand:x.ListOriginationNumbersCommand,ListPhoneNumbersOptedOutCommand:S.ListPhoneNumbersOptedOutCommand,ListPlatformApplicationsCommand:C.ListPlatformApplicationsCommand,ListSMSSandboxPhoneNumbersCommand:w.ListSMSSandboxPhoneNumbersCommand,ListSubscriptionsCommand:te.ListSubscriptionsCommand,ListSubscriptionsByTopicCommand:ee.ListSubscriptionsByTopicCommand,ListTagsForResourceCommand:T.ListTagsForResourceCommand,ListTopicsCommand:E.ListTopicsCommand,OptInPhoneNumberCommand:ne.OptInPhoneNumberCommand,PublishCommand:ie.PublishCommand,PublishBatchCommand:re.PublishBatchCommand,PutDataProtectionPolicyCommand:ae.PutDataProtectionPolicyCommand,RemovePermissionCommand:oe.RemovePermissionCommand,SetEndpointAttributesCommand:se.SetEndpointAttributesCommand,SetPlatformApplicationAttributesCommand:ce.SetPlatformApplicationAttributesCommand,SetSMSAttributesCommand:le.SetSMSAttributesCommand,SetSubscriptionAttributesCommand:ue.SetSubscriptionAttributesCommand,SetTopicAttributesCommand:de.SetTopicAttributesCommand,SubscribeCommand:fe.SubscribeCommand,TagResourceCommand:pe.TagResourceCommand,UnsubscribeCommand:me.UnsubscribeCommand,UntagResourceCommand:he.UntagResourceCommand,VerifySMSSandboxPhoneNumberCommand:ge.VerifySMSSandboxPhoneNumberCommand};var ye=class extends _e.SNSClient{};e.SNS=ye,(0,t.createAggregatedClient)(ve,ye)})),Uu=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=(N(),m(j));t.__exportStar(jn(),e),t.__exportStar(Mn(),e),t.__exportStar(Nn(),e),t.__exportStar(Pn(),e),t.__exportStar(Fn(),e),t.__exportStar(In(),e),t.__exportStar(Ln(),e),t.__exportStar(Rn(),e),t.__exportStar(zn(),e),t.__exportStar(Bn(),e),t.__exportStar(Vn(),e),t.__exportStar(Hn(),e),t.__exportStar(Un(),e),t.__exportStar(Wn(),e),t.__exportStar(Gn(),e),t.__exportStar(Kn(),e),t.__exportStar(qn(),e),t.__exportStar(Jn(),e),t.__exportStar(Yn(),e),t.__exportStar(Xn(),e),t.__exportStar(Zn(),e),t.__exportStar(z(),e),t.__exportStar(Qn(),e),t.__exportStar($n(),e),t.__exportStar(er(),e),t.__exportStar(tr(),e),t.__exportStar(nr(),e),t.__exportStar(rr(),e),t.__exportStar(ir(),e),t.__exportStar(ar(),e),t.__exportStar(or(),e),t.__exportStar(sr(),e),t.__exportStar(cr(),e),t.__exportStar(lr(),e),t.__exportStar(ur(),e),t.__exportStar(dr(),e),t.__exportStar(fr(),e),t.__exportStar(pr(),e),t.__exportStar(mr(),e),t.__exportStar(hr(),e),t.__exportStar(gr(),e),t.__exportStar(_r(),e)})),Wu=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),(N(),m(j)).__exportStar(An(),e)})),Gu=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0})})),Ku=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.paginateListEndpointsByPlatformApplication=void 0;let t=Yn(),n=Vu(),r=async(e,n,...r)=>await e.send(new t.ListEndpointsByPlatformApplicationCommand(n),...r);async function*i(e,t,...i){let a=e.startingToken||void 0,o=!0,s;for(;o;){if(t.NextToken=a,e.client instanceof n.SNSClient)s=await r(e.client,t,...i);else throw Error(`Invalid client, expected SNS | SNSClient`);yield s;let c=a;a=s.NextToken,o=!!(a&&(!e.stopOnSameToken||a!==c))}return void 0}e.paginateListEndpointsByPlatformApplication=i})),qu=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.paginateListOriginationNumbers=void 0;let t=Xn(),n=Vu(),r=async(e,n,...r)=>await e.send(new t.ListOriginationNumbersCommand(n),...r);async function*i(e,t,...i){let a=e.startingToken||void 0,o=!0,s;for(;o;){if(t.NextToken=a,t.MaxResults=e.pageSize,e.client instanceof n.SNSClient)s=await r(e.client,t,...i);else throw Error(`Invalid client, expected SNS | SNSClient`);yield s;let c=a;a=s.NextToken,o=!!(a&&(!e.stopOnSameToken||a!==c))}return void 0}e.paginateListOriginationNumbers=i})),Ju=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.paginateListPhoneNumbersOptedOut=void 0;let t=Zn(),n=Vu(),r=async(e,n,...r)=>await e.send(new t.ListPhoneNumbersOptedOutCommand(n),...r);async function*i(e,t,...i){let a=e.startingToken||void 0,o=!0,s;for(;o;){if(t.nextToken=a,e.client instanceof n.SNSClient)s=await r(e.client,t,...i);else throw Error(`Invalid client, expected SNS | SNSClient`);yield s;let c=a;a=s.nextToken,o=!!(a&&(!e.stopOnSameToken||a!==c))}return void 0}e.paginateListPhoneNumbersOptedOut=i})),Yu=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.paginateListPlatformApplications=void 0;let t=z(),n=Vu(),r=async(e,n,...r)=>await e.send(new t.ListPlatformApplicationsCommand(n),...r);async function*i(e,t,...i){let a=e.startingToken||void 0,o=!0,s;for(;o;){if(t.NextToken=a,e.client instanceof n.SNSClient)s=await r(e.client,t,...i);else throw Error(`Invalid client, expected SNS | SNSClient`);yield s;let c=a;a=s.NextToken,o=!!(a&&(!e.stopOnSameToken||a!==c))}return void 0}e.paginateListPlatformApplications=i})),Xu=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.paginateListSMSSandboxPhoneNumbers=void 0;let t=Qn(),n=Vu(),r=async(e,n,...r)=>await e.send(new t.ListSMSSandboxPhoneNumbersCommand(n),...r);async function*i(e,t,...i){let a=e.startingToken||void 0,o=!0,s;for(;o;){if(t.NextToken=a,t.MaxResults=e.pageSize,e.client instanceof n.SNSClient)s=await r(e.client,t,...i);else throw Error(`Invalid client, expected SNS | SNSClient`);yield s;let c=a;a=s.NextToken,o=!!(a&&(!e.stopOnSameToken||a!==c))}return void 0}e.paginateListSMSSandboxPhoneNumbers=i})),Zu=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.paginateListSubscriptionsByTopic=void 0;let t=$n(),n=Vu(),r=async(e,n,...r)=>await e.send(new t.ListSubscriptionsByTopicCommand(n),...r);async function*i(e,t,...i){let a=e.startingToken||void 0,o=!0,s;for(;o;){if(t.NextToken=a,e.client instanceof n.SNSClient)s=await r(e.client,t,...i);else throw Error(`Invalid client, expected SNS | SNSClient`);yield s;let c=a;a=s.NextToken,o=!!(a&&(!e.stopOnSameToken||a!==c))}return void 0}e.paginateListSubscriptionsByTopic=i})),Qu=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.paginateListSubscriptions=void 0;let t=er(),n=Vu(),r=async(e,n,...r)=>await e.send(new t.ListSubscriptionsCommand(n),...r);async function*i(e,t,...i){let a=e.startingToken||void 0,o=!0,s;for(;o;){if(t.NextToken=a,e.client instanceof n.SNSClient)s=await r(e.client,t,...i);else throw Error(`Invalid client, expected SNS | SNSClient`);yield s;let c=a;a=s.NextToken,o=!!(a&&(!e.stopOnSameToken||a!==c))}return void 0}e.paginateListSubscriptions=i})),$u=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.paginateListTopics=void 0;let t=nr(),n=Vu(),r=async(e,n,...r)=>await e.send(new t.ListTopicsCommand(n),...r);async function*i(e,t,...i){let a=e.startingToken||void 0,o=!0,s;for(;o;){if(t.NextToken=a,e.client instanceof n.SNSClient)s=await r(e.client,t,...i);else throw Error(`Invalid client, expected SNS | SNSClient`);yield s;let c=a;a=s.NextToken,o=!!(a&&(!e.stopOnSameToken||a!==c))}return void 0}e.paginateListTopics=i})),ed=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=(N(),m(j));t.__exportStar(Gu(),e),t.__exportStar(Ku(),e),t.__exportStar(qu(),e),t.__exportStar(Ju(),e),t.__exportStar(Yu(),e),t.__exportStar(Xu(),e),t.__exportStar(Zu(),e),t.__exportStar(Qu(),e),t.__exportStar($u(),e)})),td=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.SNSServiceException=void 0;let t=(N(),m(j));t.__exportStar(Hu(),e),t.__exportStar(Vu(),e),t.__exportStar(Uu(),e),t.__exportStar(Wu(),e),t.__exportStar(ed(),e);var n=kn();Object.defineProperty(e,`SNSServiceException`,{enumerable:!0,get:function(){return n.SNSServiceException}})})),nd=e=>{let t,n=()=>(t||=e(),t);return n.set=e=>{t=e},n},rd=u(((e,t)=>{t.exports=(e,t=process.argv)=>{let n=e.startsWith(`-`)?``:e.length===1?`-`:`--`,r=t.indexOf(n+e),i=t.indexOf(`--`);return r!==-1&&(i===-1||r<i)}})),id=u(((e,t)=>{let n=h(`os`),r=h(`tty`),i=rd(),{env:a}=process,o;i(`no-color`)||i(`no-colors`)||i(`color=false`)||i(`color=never`)?o=0:(i(`color`)||i(`colors`)||i(`color=true`)||i(`color=always`))&&(o=1),`FORCE_COLOR`in a&&(o=a.FORCE_COLOR===`true`?1:a.FORCE_COLOR===`false`?0:a.FORCE_COLOR.length===0?1:Math.min(parseInt(a.FORCE_COLOR,10),3));function s(e){return e===0?!1:{level:e,hasBasic:!0,has256:e>=2,has16m:e>=3}}function c(e,t){if(o===0)return 0;if(i(`color=16m`)||i(`color=full`)||i(`color=truecolor`))return 3;if(i(`color=256`))return 2;if(e&&!t&&o===void 0)return 0;let r=o||0;if(a.TERM===`dumb`)return r;if(process.platform===`win32`){let e=n.release().split(`.`);return Number(e[0])>=10&&Number(e[2])>=10586?Number(e[2])>=14931?3:2:1}if(`CI`in a)return[`TRAVIS`,`CIRCLECI`,`APPVEYOR`,`GITLAB_CI`,`GITHUB_ACTIONS`,`BUILDKITE`].some(e=>e in a)||a.CI_NAME===`codeship`?1:r;if(`TEAMCITY_VERSION`in a)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(a.TEAMCITY_VERSION)?1:0;if(a.COLORTERM===`truecolor`)return 3;if(`TERM_PROGRAM`in a){let e=parseInt((a.TERM_PROGRAM_VERSION||``).split(`.`)[0],10);switch(a.TERM_PROGRAM){case`iTerm.app`:return e>=3?3:2;case`Apple_Terminal`:return 2}}return/-256(color)?$/i.test(a.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(a.TERM)||`COLORTERM`in a?1:r}function l(e){return s(c(e,e&&e.isTTY))}t.exports={supportsColor:l,stdout:s(c(!0,r.isatty(1))),stderr:s(c(!0,r.isatty(2)))}})),ad=td(),od=nd(()=>new ad.SNSClient({})),sd=e=>{let t={};for(let n in e)t[n]={DataType:`String`,StringValue:e[n]};return t},cd=async({client:e=od(),topic:t,subject:n,payload:r,attributes:i={},region:a=process.env.AWS_REGION,accountId:o=process.env.AWS_ACCOUNT_ID})=>{let s=new ad.PublishCommand({TopicArn:`arn:aws:sns:${a}:${o}:${t}`,Subject:n,Message:r,MessageAttributes:sd({topic:t,...i})});await e.send(s)};const ld=(e,t)=>{let n=process.env.EVENTS_TOPIC;n&&cd({topic:n,payload:ze({event:e,date:new Date,...t}),attributes:{event:e}}).catch(e=>{console.error(`Failed to publish socket event`,e)})},ud=(e,t)=>{let n=me(pe(ne(pe(le(),ee(25),re(e=>typeof e==`string`&&t.includes(e)))),te(1),ee(25)),e);return n.success?{valid:!0,topics:n.output}:{valid:!1,reason:n.issues[0].message}},dd=e=>{ld(`connected`,{socketId:e.data.id,context:e.data.context})},fd=e=>{hd(e),e.close(),e.data.authenticated&&ld(`disconnected`,{socketId:e.data.id,context:e.data.context})},pd=(e,t)=>{let n=ud(t,e.data.allowed);if(!n.valid){hd(e),e.close(4e3,`Invalid topic payload`);return}for(let t of n.topics)e.subscribe(t);n.topics.length>0&&ld(`subscribed`,{socketId:e.data.id,context:e.data.context,topics:n.topics}),e.sendText(`ACK`)},md=(e,t)=>{let n=ud(t,e.data.allowed);if(!n.valid){hd(e),e.close(4e3,`Invalid topic payload`);return}let r=n.topics.filter(t=>e.isSubscribed(t));for(let t of r)e.unsubscribe(t);r.length>0&&ld(`unsubscribed`,{socketId:e.data.id,context:e.data.context,topics:r}),e.sendText(`ACK`)},hd=e=>{let t=e.subscriptions;for(let n of t)e.unsubscribe(n);t.length>0&&ld(`unsubscribed`,{socketId:e.data.id,context:e.data.context,topics:t})};var gd=u((e=>{e.HttpAuthLocation=void 0,(function(e){e.HEADER=`header`,e.QUERY=`query`})(e.HttpAuthLocation||={}),e.HttpApiKeyAuthLocation=void 0,(function(e){e.HEADER=`header`,e.QUERY=`query`})(e.HttpApiKeyAuthLocation||={}),e.EndpointURLScheme=void 0,(function(e){e.HTTP=`http`,e.HTTPS=`https`})(e.EndpointURLScheme||={}),e.AlgorithmId=void 0,(function(e){e.MD5=`md5`,e.CRC32=`crc32`,e.CRC32C=`crc32c`,e.SHA1=`sha1`,e.SHA256=`sha256`})(e.AlgorithmId||={});let t=t=>{let n=[];return t.sha256!==void 0&&n.push({algorithmId:()=>e.AlgorithmId.SHA256,checksumConstructor:()=>t.sha256}),t.md5!=null&&n.push({algorithmId:()=>e.AlgorithmId.MD5,checksumConstructor:()=>t.md5}),{addChecksumAlgorithm(e){n.push(e)},checksumAlgorithms(){return n}}},n=e=>{let t={};return e.checksumAlgorithms().forEach(e=>{t[e.algorithmId()]=e.checksumConstructor()}),t};e.FieldPosition=void 0,(function(e){e[e.HEADER=0]=`HEADER`,e[e.TRAILER=1]=`TRAILER`})(e.FieldPosition||={}),e.IniSectionType=void 0,(function(e){e.PROFILE=`profile`,e.SSO_SESSION=`sso-session`,e.SERVICES=`services`})(e.IniSectionType||={}),e.RequestHandlerProtocol=void 0,(function(e){e.HTTP_0_9=`http/0.9`,e.HTTP_1_0=`http/1.0`,e.TDS_8_0=`tds/8.0`})(e.RequestHandlerProtocol||={}),e.SMITHY_CONTEXT_KEY=`__smithy_context`,e.getDefaultClientConfiguration=e=>t(e),e.resolveDefaultRuntimeConfig=e=>n(e)})),_d=u((e=>{var t=gd();let n=e=>({setHttpHandler(t){e.httpHandler=t},httpHandler(){return e.httpHandler},updateHttpClientConfig(t,n){e.httpHandler?.updateHttpClientConfig(t,n)},httpHandlerConfigs(){return e.httpHandler.httpHandlerConfigs()}}),r=e=>({httpHandler:e.httpHandler()});var i=class{name;kind;values;constructor({name:e,kind:n=t.FieldPosition.HEADER,values:r=[]}){this.name=e,this.kind=n,this.values=r}add(e){this.values.push(e)}set(e){this.values=e}remove(e){this.values=this.values.filter(t=>t!==e)}toString(){return this.values.map(e=>e.includes(`,`)||e.includes(` `)?`"${e}"`:e).join(`, `)}get(){return this.values}},a=class{entries={};encoding;constructor({fields:e=[],encoding:t=`utf-8`}){e.forEach(this.setField.bind(this)),this.encoding=t}setField(e){this.entries[e.name.toLowerCase()]=e}getField(e){return this.entries[e.toLowerCase()]}removeField(e){delete this.entries[e.toLowerCase()]}getByType(e){return Object.values(this.entries).filter(t=>t.kind===e)}},o=class e{method;protocol;hostname;port;path;query;headers;username;password;fragment;body;constructor(e){this.method=e.method||`GET`,this.hostname=e.hostname||`localhost`,this.port=e.port,this.query=e.query||{},this.headers=e.headers||{},this.body=e.body,this.protocol=e.protocol?e.protocol.slice(-1)===`:`?e.protocol:`${e.protocol}:`:`https:`,this.path=e.path?e.path.charAt(0)===`/`?e.path:`/${e.path}`:`/`,this.username=e.username,this.password=e.password,this.fragment=e.fragment}static clone(t){let n=new e({...t,headers:{...t.headers}});return n.query&&=s(n.query),n}static isInstance(e){if(!e)return!1;let t=e;return`method`in t&&`protocol`in t&&`hostname`in t&&`path`in t&&typeof t.query==`object`&&typeof t.headers==`object`}clone(){return e.clone(this)}};function s(e){return Object.keys(e).reduce((t,n)=>{let r=e[n];return{...t,[n]:Array.isArray(r)?[...r]:r}},{})}var c=class{statusCode;reason;headers;body;constructor(e){this.statusCode=e.statusCode,this.reason=e.reason,this.headers=e.headers||{},this.body=e.body}static isInstance(e){if(!e)return!1;let t=e;return typeof t.statusCode==`number`&&typeof t.headers==`object`}};function l(e){return/^[a-z0-9][a-z0-9\.\-]*[a-z0-9]$/.test(e)}e.Field=i,e.Fields=a,e.HttpRequest=o,e.HttpResponse=c,e.getHttpHandlerExtensionConfiguration=n,e.isValidHostname=l,e.resolveHttpHandlerRuntimeConfig=r})),vd=u((e=>{var t=_d();function n(e){return e}let r=e=>n=>async r=>{if(!t.HttpRequest.isInstance(r.request))return n(r);let{request:i}=r,{handlerProtocol:a=``}=e.requestHandler.metadata||{};if(a.indexOf(`h2`)>=0&&!i.headers[`:authority`])delete i.headers.host,i.headers[`:authority`]=i.hostname+(i.port?`:`+i.port:``);else if(!i.headers.host){let e=i.hostname;i.port!=null&&(e+=`:${i.port}`),i.headers.host=e}return n(r)},i={name:`hostHeaderMiddleware`,step:`build`,priority:`low`,tags:[`HOST`],override:!0};e.getHostHeaderPlugin=e=>({applyToStack:t=>{t.add(r(e),i)}}),e.hostHeaderMiddleware=r,e.hostHeaderMiddlewareOptions=i,e.resolveHostHeaderConfig=n})),yd=u((e=>{let t=()=>(e,t)=>async n=>{try{let r=await e(n),{clientName:i,commandName:a,logger:o,dynamoDbDocumentClientOptions:s={}}=t,{overrideInputFilterSensitiveLog:c,overrideOutputFilterSensitiveLog:l}=s,u=c??t.inputFilterSensitiveLog,d=l??t.outputFilterSensitiveLog,{$metadata:f,...p}=r.output;return o?.info?.({clientName:i,commandName:a,input:u(n.input),output:d(p),metadata:f}),r}catch(e){let{clientName:r,commandName:i,logger:a,dynamoDbDocumentClientOptions:o={}}=t,{overrideInputFilterSensitiveLog:s}=o,c=s??t.inputFilterSensitiveLog;throw a?.error?.({clientName:r,commandName:i,input:c(n.input),error:e,metadata:e.$metadata}),e}},n={name:`loggerMiddleware`,tags:[`LOGGER`],step:`initialize`,override:!0};e.getLoggerPlugin=e=>({applyToStack:e=>{e.add(t(),n)}}),e.loggerMiddleware=t,e.loggerMiddlewareOptions=n})),bd=d({InvokeStore:()=>Ed,InvokeStoreBase:()=>Cd}),xd,Sd,Cd,wd,Td,Ed,Dd=l((()=>{xd={REQUEST_ID:Symbol.for(`_AWS_LAMBDA_REQUEST_ID`),X_RAY_TRACE_ID:Symbol.for(`_AWS_LAMBDA_X_RAY_TRACE_ID`),TENANT_ID:Symbol.for(`_AWS_LAMBDA_TENANT_ID`)},Sd=[`true`,`1`].includes(process.env?.AWS_LAMBDA_NODEJS_NO_GLOBAL_AWSLAMBDA??``),Sd||(globalThis.awslambda=globalThis.awslambda||{}),Cd=class{static PROTECTED_KEYS=xd;isProtectedKey(e){return Object.values(xd).includes(e)}getRequestId(){return this.get(xd.REQUEST_ID)??`-`}getXRayTraceId(){return this.get(xd.X_RAY_TRACE_ID)}getTenantId(){return this.get(xd.TENANT_ID)}},wd=class extends Cd{currentContext;getContext(){return this.currentContext}hasContext(){return this.currentContext!==void 0}get(e){return this.currentContext?.[e]}set(e,t){if(this.isProtectedKey(e))throw Error(`Cannot modify protected Lambda context field: ${String(e)}`);this.currentContext=this.currentContext||{},this.currentContext[e]=t}run(e,t){return this.currentContext=e,t()}},Td=class e extends Cd{als;static async create(){let t=new e;return t.als=new(await(import(`node:async_hooks`))).AsyncLocalStorage,t}getContext(){return this.als.getStore()}hasContext(){return this.als.getStore()!==void 0}get(e){return this.als.getStore()?.[e]}set(e,t){if(this.isProtectedKey(e))throw Error(`Cannot modify protected Lambda context field: ${String(e)}`);let n=this.als.getStore();if(!n)throw Error(`No context available`);n[e]=t}run(e,t){return this.als.run(e,t)}},(function(e){let t=null;async function n(e){return t||=(async()=>{let t=e===!0||`AWS_LAMBDA_MAX_CONCURRENCY`in process.env?await Td.create():new wd;return!Sd&&globalThis.awslambda?.InvokeStore?globalThis.awslambda.InvokeStore:(!Sd&&globalThis.awslambda&&(globalThis.awslambda.InvokeStore=t),t)})(),t}e.getInstanceAsync=n,e._testing=process.env.AWS_LAMBDA_BENCHMARK_MODE===`1`?{reset:()=>{t=null,globalThis.awslambda?.InvokeStore&&delete globalThis.awslambda.InvokeStore,globalThis.awslambda={InvokeStore:void 0}}}:void 0})(Ed||={})})),Od=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.recursionDetectionMiddleware=void 0;let t=(Dd(),m(bd)),n=_d(),r=`X-Amzn-Trace-Id`;e.recursionDetectionMiddleware=()=>e=>async i=>{let{request:a}=i;if(!n.HttpRequest.isInstance(a))return e(i);let o=Object.keys(a.headers??{}).find(e=>e.toLowerCase()===`x-amzn-trace-id`)??r;if(a.headers.hasOwnProperty(o))return e(i);let s=process.env.AWS_LAMBDA_FUNCTION_NAME,c=process.env._X_AMZN_TRACE_ID,l=(await t.InvokeStore.getInstanceAsync())?.getXRayTraceId()??c,u=e=>typeof e==`string`&&e.length>0;return u(s)&&u(l)&&(a.headers[r]=l),e({...i,request:a})}})),kd=u((e=>{var t=Od();let n={step:`build`,tags:[`RECURSION_DETECTION`],name:`recursionDetectionMiddleware`,override:!0,priority:`low`};e.getRecursionDetectionPlugin=e=>({applyToStack:e=>{e.add(t.recursionDetectionMiddleware(),n)}}),Object.prototype.hasOwnProperty.call(t,`__proto__`)&&!Object.prototype.hasOwnProperty.call(e,`__proto__`)&&Object.defineProperty(e,`__proto__`,{enumerable:!0,value:t.__proto__}),Object.keys(t).forEach(function(n){n!==`default`&&!Object.prototype.hasOwnProperty.call(e,n)&&(e[n]=t[n])})})),Ad,jd,Md=l((()=>{Ad=gd(),jd=e=>e[Ad.SMITHY_CONTEXT_KEY]||(e[Ad.SMITHY_CONTEXT_KEY]={})})),Nd=u((e=>{var t=gd();e.getSmithyContext=e=>e[t.SMITHY_CONTEXT_KEY]||(e[t.SMITHY_CONTEXT_KEY]={}),e.normalizeProvider=e=>{if(typeof e==`function`)return e;let t=Promise.resolve(e);return()=>t}})),Pd,Fd=l((()=>{Pd=(e,t)=>{if(!t||t.length===0)return e;let n=[];for(let r of t)for(let t of e)t.schemeId.split(`#`)[1]===r&&n.push(t);for(let t of e)n.find(({schemeId:e})=>e===t.schemeId)||n.push(t);return n}}));function Id(e){let t=new Map;for(let n of e)t.set(n.schemeId,n);return t}var Ld,Rd,zd=l((()=>{Ld=Nd(),Fd(),Rd=(e,t)=>(n,r)=>async i=>{let a=Pd(e.httpAuthSchemeProvider(await t.httpAuthSchemeParametersProvider(e,r,i.input)),e.authSchemePreference?await e.authSchemePreference():[]),o=Id(e.httpAuthSchemes),s=(0,Ld.getSmithyContext)(r),c=[];for(let n of a){let i=o.get(n.schemeId);if(!i){c.push(`HttpAuthScheme \`${n.schemeId}\` was not enabled for this service.`);continue}let a=i.identityProvider(await t.identityProviderConfigProvider(e));if(!a){c.push(`HttpAuthScheme \`${n.schemeId}\` did not have an IdentityProvider configured.`);continue}let{identityProperties:l={},signingProperties:u={}}=n.propertiesExtractor?.(e,r)||{};n.identityProperties=Object.assign(n.identityProperties||{},l),n.signingProperties=Object.assign(n.signingProperties||{},u),s.selectedHttpAuthScheme={httpAuthOption:n,identity:await a(n.identityProperties),signer:i.signer};break}if(!s.selectedHttpAuthScheme)throw Error(c.join(`
28
+ `));let S=i(Bc());process.versions.hasOwnProperty(`electron`)&&process.on(`exit`,function(){S.default.disable_threadsafe_function()}),e.default=x})),Vc=u((e=>{var t=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,`__esModule`,{value:!0}),e.CrtError=void 0;let n=t(Bc());var r=class extends Error{constructor(e){super(i(e)),this.error=e,this.error_code=a(e),this.error_name=o(e)}};e.CrtError=r;function i(e){return typeof e==`number`?n.default.error_code_to_string(e):e instanceof r?e.message:e.toString()}function a(e){if(typeof e==`number`)return e;if(e instanceof r)return e.error_code}function o(e){if(typeof e==`number`)return n.default.error_code_to_name(e);if(e instanceof r)return e.error_name}})),Hc=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.NativeResourceMixin=e.NativeResource=void 0,e.NativeResource=class{constructor(e){this.handle=e}native_handle(){return this.handle}};function t(e){return class extends e{constructor(...e){let t=e.shift();super(...e),this._handle=t}_super(e){this._handle=e}native_handle(){return this._handle}}}e.NativeResourceMixin=t})),Uc=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.logTrace=e.logDebug=e.logInfo=e.logWarn=e.logError=e.logFatal=e.setLogLevel=e.LogLevel=e.SocketDomain=e.SocketType=e.TlsVersion=void 0,(function(e){e[e.SSLv3=0]=`SSLv3`,e[e.TLSv1=1]=`TLSv1`,e[e.TLSv1_1=2]=`TLSv1_1`,e[e.TLSv1_2=3]=`TLSv1_2`,e[e.TLSv1_3=4]=`TLSv1_3`,e[e.Default=128]=`Default`})(e.TlsVersion||={}),(function(e){e[e.STREAM=0]=`STREAM`,e[e.DGRAM=1]=`DGRAM`})(e.SocketType||={}),(function(e){e[e.IPV4=0]=`IPV4`,e[e.IPV6=1]=`IPV6`,e[e.LOCAL=2]=`LOCAL`})(e.SocketDomain||={});var t;(function(e){e[e.NONE=0]=`NONE`,e[e.FATAL=1]=`FATAL`,e[e.ERROR=2]=`ERROR`,e[e.WARN=3]=`WARN`,e[e.INFO=4]=`INFO`,e[e.DEBUG=5]=`DEBUG`,e[e.TRACE=6]=`TRACE`})(t=e.LogLevel||={});let n=t.NONE;function r(e){n=e}e.setLogLevel=r;function i(e,r){if(n<t.FATAL)return;let i=new Date().toISOString();console.log(`[FATAL] [${i}] [${e}] - ${r}`)}e.logFatal=i;function a(e,r){if(n<t.ERROR)return;let i=new Date().toISOString();console.log(`[ERROR] [${i}] [${e}] - ${r}`)}e.logError=a;function o(e,r){if(n<t.WARN)return;let i=new Date().toISOString();console.log(`[WARN] [${i}] [${e}] - ${r}`)}e.logWarn=o;function s(e,r){if(n<t.INFO)return;let i=new Date().toISOString();console.log(`[INFO] [${i}] [${e}] - ${r}`)}e.logInfo=s;function c(e,r){if(n<t.DEBUG)return;let i=new Date().toISOString();console.log(`[DEBUG] [${i}] [${e}] - ${r}`)}e.logDebug=c;function l(e,r){if(n<t.TRACE)return;let i=new Date().toISOString();console.log(`[TRACE] [${i}] [${e}] - ${r}`)}e.logTrace=l})),Wc=u((e=>{var t=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,`__esModule`,{value:!0}),e.Pkcs11Lib=e.TlsConnectionOptions=e.ServerTlsContext=e.ClientTlsContext=e.TlsContext=e.TlsContextOptions=e.tls_cipher_preference_is_supported=e.TlsCipherPreference=e.SocketOptions=e.ClientBootstrap=e.InputStream=e.is_alpn_available=e.enable_logging=e.error_code_to_name=e.error_code_to_string=e.SocketDomain=e.SocketType=e.TlsVersion=e.LogLevel=e.setLogLevel=void 0;let n=t(Bc()),r=Hc(),i=Uc();var a=Uc();Object.defineProperty(e,`setLogLevel`,{enumerable:!0,get:function(){return a.setLogLevel}}),Object.defineProperty(e,`LogLevel`,{enumerable:!0,get:function(){return a.LogLevel}}),Object.defineProperty(e,`TlsVersion`,{enumerable:!0,get:function(){return a.TlsVersion}}),Object.defineProperty(e,`SocketType`,{enumerable:!0,get:function(){return a.SocketType}}),Object.defineProperty(e,`SocketDomain`,{enumerable:!0,get:function(){return a.SocketDomain}});let o=Vc();function s(e){return n.default.error_code_to_string(e)}e.error_code_to_string=s;function c(e){return n.default.error_code_to_name(e)}e.error_code_to_name=c;function l(e){n.default.io_logging_enable(e),(0,i.setLogLevel)(e)}e.enable_logging=l;function u(){return n.default.is_alpn_available()}e.is_alpn_available=u,e.InputStream=class extends r.NativeResource{constructor(e){super(n.default.io_input_stream_new(16*1024)),this.source=e,this.source.on(`data`,e=>{e=Buffer.isBuffer(e)?e:Buffer.from(e.toString()),n.default.io_input_stream_append(this.native_handle(),e)}),this.source.on(`end`,()=>{n.default.io_input_stream_append(this.native_handle(),void 0)})}},e.ClientBootstrap=class extends r.NativeResource{constructor(){super(n.default.io_client_bootstrap_new())}},e.SocketOptions=class extends r.NativeResource{constructor(e=i.SocketType.STREAM,t=i.SocketDomain.IPV6,r=5e3,a=!1,o=0,s=0,c=0){super(n.default.io_socket_options_new(e,t,r,o,s,c,a))}},(function(e){e[e.Default=0]=`Default`,e[e.PQ_TLSv1_0_2021_05=6]=`PQ_TLSv1_0_2021_05`,e[e.PQ_Default=8]=`PQ_Default`,e[e.TLSv1_2_2025_07=9]=`TLSv1_2_2025_07`})(e.TlsCipherPreference||={});function d(e){return n.default.io_tls_cipher_preference_is_supported(e)}e.tls_cipher_preference_is_supported=d;var f=class e{constructor(){this.min_tls_version=i.TlsVersion.Default,this.alpn_list=[],this.verify_peer=!0}override_default_trust_store_from_path(e,t){this.ca_dirpath=e,this.ca_filepath=t}override_default_trust_store(e){this.certificate_authority=e}static create_client_with_mtls(t,n){let r=new e;return r.certificate=t,r.private_key=n,r.verify_peer=!0,r}static create_client_with_mtls_from_path(t,n){let r=new e;return r.certificate_filepath=t,r.private_key_filepath=n,r.verify_peer=!0,r}static create_client_with_mtls_pkcs12_from_path(t,n){let r=new e;return r.pkcs12_filepath=t,r.pkcs12_password=n,r.verify_peer=!0,r}static create_client_with_mtls_pkcs_from_path(e,t){return this.create_client_with_mtls_pkcs12_from_path(e,t)}static create_client_with_mtls_pkcs11(t){let n=new e;return n.pkcs11_options=t,n.verify_peer=!0,n}static create_client_with_mtls_windows_cert_store_path(t){let n=new e;return n.windows_cert_store_path=t,n.verify_peer=!0,n}static create_server_with_mtls_from_path(t,n){let r=new e;return r.certificate_filepath=t,r.private_key_filepath=n,r.verify_peer=!1,r}static create_server_with_mtls_pkcs_from_path(t,n){let r=new e;return r.pkcs12_filepath=t,r.pkcs12_password=n,r.verify_peer=!1,r}};e.TlsContextOptions=f;var p=class extends r.NativeResource{constructor(e){if(e==null||e==null)throw new o.CrtError(`TlsContext constructor: ctx_opt not defined`);super(n.default.io_tls_ctx_new(e.min_tls_version,e.ca_filepath,e.ca_dirpath,e.certificate_authority,e.alpn_list&&e.alpn_list.length>0?e.alpn_list.join(`;`):void 0,e.certificate_filepath,e.certificate,e.private_key_filepath,e.private_key,e.pkcs12_filepath,e.pkcs12_password,e.pkcs11_options,e.windows_cert_store_path,e.tls_cipher_preference,e.verify_peer))}};e.TlsContext=p,e.ClientTlsContext=class extends p{constructor(e){e||(e=new f,e.verify_peer=!0),super(e)}},e.ServerTlsContext=class extends p{constructor(e){e||(e=new f,e.verify_peer=!1),super(e)}},e.TlsConnectionOptions=class extends r.NativeResource{constructor(e,t,r=[]){if(e==null||e==null)throw new o.CrtError(`TlsConnectionOptions constructor: tls_ctx not defined`);super(n.default.io_tls_connection_options_new(e.native_handle(),t,r&&r.length>0?r.join(`;`):void 0)),this.tls_ctx=e,this.server_name=t,this.alpn_list=r}};var m=class e extends r.NativeResource{constructor(t,r=e.InitializeFinalizeBehavior.DEFAULT){super(n.default.io_pkcs11_lib_new(t,r))}close(){n.default.io_pkcs11_lib_close(this.native_handle())}};e.Pkcs11Lib=m,(function(e){(function(e){e[e.DEFAULT=0]=`DEFAULT`,e[e.OMIT=1]=`OMIT`,e[e.STRICT=2]=`STRICT`})(e.InitializeFinalizeBehavior||={})})(m=e.Pkcs11Lib||={})})),Gc=u((e=>{var t=e&&e.__awaiter||function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})},n=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,`__esModule`,{value:!0}),e.aws_verify_sigv4a_signing=e.aws_sign_request=e.AwsSignedBodyHeaderType=e.AwsSignedBodyValue=e.AwsSignatureType=e.AwsSigningAlgorithm=e.AwsCredentialsProvider=void 0;let r=n(Bc()),i=Vc(),a=Wc();e.AwsCredentialsProvider=class extends r.default.AwsCredentialsProvider{static newDefault(e=void 0){return super.newDefault(e==null?null:e.native_handle())}static newStatic(e,t,n){return super.newStatic(e,t,n)}static newCognito(e){if(e==null||e==null)throw new i.CrtError(`AwsCredentialsProvider newCognito: Cognito config not defined`);return super.newCognito(e,e.tlsContext==null?new a.ClientTlsContext().native_handle():e.tlsContext.native_handle(),e.bootstrap==null?null:e.bootstrap.native_handle(),e.httpProxyOptions?e.httpProxyOptions.create_native_handle():null)}static newX509(e){if(e==null||e==null)throw new i.CrtError(`AwsCredentialsProvider newX509: X509 config not defined`);return super.newX509(e,e.tlsContext.native_handle(),e.httpProxyOptions?e.httpProxyOptions.create_native_handle():null)}},(function(e){e[e.SigV4=0]=`SigV4`,e[e.SigV4Asymmetric=1]=`SigV4Asymmetric`})(e.AwsSigningAlgorithm||={}),(function(e){e[e.HttpRequestViaHeaders=0]=`HttpRequestViaHeaders`,e[e.HttpRequestViaQueryParams=1]=`HttpRequestViaQueryParams`,e[e.HttpRequestChunk=2]=`HttpRequestChunk`,e[e.HttpRequestEvent=3]=`HttpRequestEvent`})(e.AwsSignatureType||={}),(function(e){e.EmptySha256=`e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855`,e.UnsignedPayload=`UNSIGNED-PAYLOAD`,e.StreamingAws4HmacSha256Payload=`STREAMING-AWS4-HMAC-SHA256-PAYLOAD`,e.StreamingAws4HmacSha256Events=`STREAMING-AWS4-HMAC-SHA256-EVENTS`})(e.AwsSignedBodyValue||={}),(function(e){e[e.None=0]=`None`,e[e.XAmzContentSha256=1]=`XAmzContentSha256`})(e.AwsSignedBodyHeaderType||={});function o(e,n){return t(this,void 0,void 0,function*(){return new Promise((t,a)=>{try{r.default.aws_sign_request(e,n,n=>{n==0?t(e):a(new i.CrtError(n))})}catch(e){a(e)}})})}e.aws_sign_request=o;function s(e,t,n,i,a,o){return r.default.aws_verify_sigv4a_signing(e,t,n,i,a,o)}e.aws_verify_sigv4a_signing=s})),Kc=u((e=>{var t=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,`__esModule`,{value:!0}),e.crc64nvme=e.crc32c=e.crc32=void 0;let n=t(Bc());function r(e,t){return n.default.checksums_crc32(e,t)}e.crc32=r;function i(e,t){return n.default.checksums_crc32c(e,t)}e.crc32c=i;function a(e,t){return n.default.checksums_crc64nvme(e,t)}e.crc64nvme=a})),qc=u((e=>{var t=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,`__esModule`,{value:!0}),e.native_memory_dump=e.native_memory=void 0;let n=t(Bc());function r(){return n.default.native_memory()}e.native_memory=r;function i(){return n.default.native_memory_dump()}e.native_memory_dump=i})),Jc=u((e=>{var t=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,`__esModule`,{value:!0}),e.hmac_sha256=e.Sha256Hmac=e.hash_sha1=e.Sha1Hash=e.hash_sha256=e.Sha256Hash=e.hash_md5=e.Md5Hash=void 0;let n=t(Bc()),r=Hc();var i=class extends r.NativeResource{update(e){n.default.hash_update(this.native_handle(),e)}finalize(e){return n.default.hash_digest(this.native_handle(),e)}constructor(e){super(e)}};e.Md5Hash=class extends i{constructor(){super(n.default.hash_md5_new())}};function a(e,t){return n.default.hash_md5_compute(e,t)}e.hash_md5=a,e.Sha256Hash=class extends i{constructor(){super(n.default.hash_sha256_new())}};function o(e,t){return n.default.hash_sha256_compute(e,t)}e.hash_sha256=o,e.Sha1Hash=class extends i{constructor(){super(n.default.hash_sha1_new())}};function s(e,t){return n.default.hash_sha1_compute(e,t)}e.hash_sha1=s;var c=class extends r.NativeResource{update(e){n.default.hmac_update(this.native_handle(),e)}finalize(e){return n.default.hmac_digest(this.native_handle(),e)}constructor(e){super(e)}};e.Sha256Hmac=class extends c{constructor(e){super(n.default.hmac_sha256_new(e))}};function l(e,t,r){return n.default.hmac_sha256_compute(e,t,r)}e.hmac_sha256=l})),Yc=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.BufferedEventEmitter=void 0;let t=h(`events`);var n=class{constructor(e,t){this.event=e,this.args=t}};e.BufferedEventEmitter=class extends t.EventEmitter{constructor(){super(),this.corked=!1}cork(){this.corked=!0}uncork(){for(this.corked=!1;this.eventQueue;){let e=this.eventQueue;super.emit(e.event,...e.args),this.eventQueue=this.eventQueue.next}}emit(e,...t){if(this.corked){let r=this.lastQueuedEvent;return this.lastQueuedEvent=new n(e,t),r?r.next=this.lastQueuedEvent:this.eventQueue=this.lastQueuedEvent,this.listeners(e).length>0}return super.emit(e,...t)}}})),Xc=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.unmarshalInt64BigintFromBuffer=e.marshalInt64BigintAsBuffer=e.MIN_INT64=e.MAX_INT64=e.MIN_INT32=e.MAX_INT32=e.MIN_INT16=e.MAX_INT16=e.MIN_INT8=e.MAX_INT8=void 0;let t=Vc();e.MAX_INT8=127,e.MIN_INT8=-128,e.MAX_INT16=32767,e.MIN_INT16=-32768,e.MAX_INT32=2147483647,e.MIN_INT32=-2147483648,e.MAX_INT64=BigInt(`9223372036854775807`),e.MIN_INT64=BigInt(`-9223372036854775808`);let n=BigInt(`256`);function r(r){if(r<e.MIN_INT64||r>e.MAX_INT64)throw new t.CrtError(`marshalInt64BigintAsBuffer expects a value that can fit in 8 bytes`);let i=new Uint8Array(8);if(r<0){r=-r-BigInt(1);for(let e=0;e<8;++e)i[e]=255-Number(r%n),r/=n}else for(let e=0;e<8;++e)i[e]=Number(r%n),r/=n;return i}e.marshalInt64BigintAsBuffer=r;function i(e){let r=BigInt(0),i=new Uint8Array(e);if(i.length!=8)throw new t.CrtError(`unmarshalInt64BigintFromBuffer expects a byte buffer of length 8`);let a=BigInt(1);if(i[7]&128){for(let e=0;e<i.length;++e){let t=BigInt(255-i[e]);r+=t*a,a*=n}r+=BigInt(1),r=-r}else for(let e=0;e<i.length;++e){let t=BigInt(i[e]);r+=t*a,a*=n}return r}e.unmarshalInt64BigintFromBuffer=i})),Zc=u((e=>{var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__setModuleDefault||(Object.create?(function(e,t){Object.defineProperty(e,`default`,{enumerable:!0,value:t})}):function(e,t){e.default=t}),r=e&&e.__importStar||function(e){if(e&&e.__esModule)return e;var r={};if(e!=null)for(var i in e)i!==`default`&&Object.prototype.hasOwnProperty.call(e,i)&&t(r,e,i);return n(r,e),r},i=e&&e.__awaiter||function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})},a=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,`__esModule`,{value:!0}),e.ClientStream=e.ClientConnection=e.MessageType=e.MessageFlags=e.Header=e.HeaderType=void 0;let o=Hc(),s=Yc(),c=Vc(),l=r(Wc()),u=r(Xc()),d=r(Fc()),f=a(Bc());var p;(function(e){e[e.BooleanTrue=0]=`BooleanTrue`,e[e.BooleanFalse=1]=`BooleanFalse`,e[e.Byte=2]=`Byte`,e[e.Int16=3]=`Int16`,e[e.Int32=4]=`Int32`,e[e.Int64=5]=`Int64`,e[e.ByteBuffer=6]=`ByteBuffer`,e[e.String=7]=`String`,e[e.Timestamp=8]=`Timestamp`,e[e.UUID=9]=`UUID`})(p=e.HeaderType||={});var m=class e{constructor(e,t,n){this.name=e,this.type=t,this.value=n}static validateHeaderName(e){if(e.length==0||e.length>127)throw new c.CrtError(`Event stream header name (${e}) is not valid`)}static newBoolean(t,n){return e.validateHeaderName(t),n?new e(t,p.BooleanTrue):new e(t,p.BooleanFalse)}static newByte(t,n){if(e.validateHeaderName(t),n>=u.MIN_INT8&&n<=u.MAX_INT8&&Number.isSafeInteger(n))return new e(t,p.Byte,n);throw new c.CrtError(`Illegal value for eventstream byte-valued header: ${n}`)}static newInt16(t,n){if(e.validateHeaderName(t),n>=u.MIN_INT16&&n<=u.MAX_INT16&&Number.isSafeInteger(n))return new e(t,p.Int16,n);throw new c.CrtError(`Illegal value for eventstream int16-valued header: ${n}`)}static newInt32(t,n){if(e.validateHeaderName(t),n>=u.MIN_INT32&&n<=u.MAX_INT32&&Number.isSafeInteger(n))return new e(t,p.Int32,n);throw new c.CrtError(`Illegal value for eventstream int32-valued header: ${n}`)}static newInt64FromNumber(t,n){if(e.validateHeaderName(t),Number.isSafeInteger(n))return new e(t,p.Int64,u.marshalInt64BigintAsBuffer(BigInt(n)));throw new c.CrtError(`Illegal value for eventstream int64-valued header: ${n}`)}static newInt64FromBigint(t,n){if(e.validateHeaderName(t),n>=u.MIN_INT64&&n<=u.MAX_INT64)return new e(t,p.Int64,u.marshalInt64BigintAsBuffer(n));throw new c.CrtError(`Illegal value for eventstream int64-valued header: ${n}`)}static newByteBuffer(t,n){return e.validateHeaderName(t),new e(t,p.ByteBuffer,n)}static newString(t,n){return e.validateHeaderName(t),new e(t,p.String,n)}static newTimeStampFromSecondsSinceEpoch(t,n){if(e.validateHeaderName(t),Number.isSafeInteger(n)&&n>=0)return new e(t,p.Timestamp,n);throw new c.CrtError(`Illegal value for eventstream timestamp-valued header: ${n}`)}static newTimeStampFromDate(t,n){e.validateHeaderName(t);let r=n.getTime();if(Number.isSafeInteger(r))return new e(t,p.Timestamp,r);throw new c.CrtError(`Illegal value for eventstream timestamp-valued header: ${n}`)}static newUUID(t,n){if(e.validateHeaderName(t),n.byteLength==16)return new e(t,p.UUID,n);throw new c.CrtError(`Illegal value for eventstream uuid-valued header: ${n}`)}toValue(e){if(e!=this.type)throw new c.CrtError(`Header of type (${this.type}) cannot be converted to type (${e})`);return this.value}asBoolean(){switch(this.type){case p.BooleanFalse:return!1;case p.BooleanTrue:return!0;default:throw new c.CrtError(`Header of type (${this.type}) cannot be converted to type (boolean)`)}}asByte(){return this.toValue(p.Byte)}asInt16(){return this.toValue(p.Int16)}asInt32(){return this.toValue(p.Int32)}asInt64(){return u.unmarshalInt64BigintFromBuffer(this.toValue(p.Int64))}asByteBuffer(){return this.toValue(p.ByteBuffer)}asString(){return this.toValue(p.String)}asTimestamp(){return this.toValue(p.Timestamp)}asUUID(){return this.toValue(p.UUID)}};e.Header=m,(function(e){e[e.None=0]=`None`,e[e.ConnectionAccepted=1]=`ConnectionAccepted`,e[e.TerminateStream=2]=`TerminateStream`})(e.MessageFlags||={}),(function(e){e[e.ApplicationMessage=0]=`ApplicationMessage`,e[e.ApplicationError=1]=`ApplicationError`,e[e.Ping=2]=`Ping`,e[e.PingResponse=3]=`PingResponse`,e[e.Connect=4]=`Connect`,e[e.ConnectAck=5]=`ConnectAck`,e[e.ProtocolError=6]=`ProtocolError`,e[e.InternalError=7]=`InternalError`})(e.MessageType||={});function h(e){return Array.from(e,e=>new m(e.name,e.type,e.value))}function g(e){let t={type:e.type,flags:e.flags,payload:e.payload};return e.headers&&(t.headers=h(e.headers)),t}var _;(function(e){e[e.None=0]=`None`,e[e.Connecting=1]=`Connecting`,e[e.Connected=2]=`Connected`,e[e.Disconnected=3]=`Disconnected`,e[e.Closed=4]=`Closed`})(_||={});var v=class e extends (0,o.NativeResourceMixin)(s.BufferedEventEmitter){constructor(t){if(t===void 0)throw new c.CrtError(`Invalid configuration passed to eventstream ClientConnection constructor`);super(),this.state=_.None,this._super(f.default.event_stream_client_connection_new(this,t,(t,n)=>{e._s_on_disconnect(t,n)},(t,n)=>{e._s_on_protocol_message(t,n)},t.socketOptions?t.socketOptions.native_handle():null,t.tlsCtx?t.tlsCtx.native_handle():null))}close(){this.state!=_.Closed&&(this.state=_.Closed,f.default.event_stream_client_connection_close(this.native_handle()))}connect(t){return i(this,void 0,void 0,function*(){let n,r=new Promise((r,i)=>{if(!t){i(new c.CrtError(`Invalid options passed to event stream ClientConnection.connect`));return}if(this.state!=_.None){i(new c.CrtError(`Event stream connection in a state (${this.state}) where connect() is not allowed.`));return}if(this.state=_.Connecting,t.cancelController&&(n=t.cancelController.addListener(()=>{i(new c.CrtError(`Event stream connection connect() cancelled by external request.`)),setImmediate(()=>{this.close()})}),!n))return;function a(t,n){return e._s_on_connection_setup(r,i,t,n)}try{f.default.event_stream_client_connection_connect(this.native_handle(),a)}catch(e){this.state=_.Disconnected,i(e)}});return d.makeSelfCleaningPromise(r,n)})}sendProtocolMessage(t){return i(this,void 0,void 0,function*(){let n,r=new Promise((r,i)=>{try{if(!t){i(new c.CrtError(`Invalid options passed to event stream ClientConnection.sendProtocolMessage`));return}if(!this.isConnected()){i(new c.CrtError(`Event stream connection in a state (${this.state}) where sending protocol messages is not allowed.`));return}if(t.cancelController&&(n=t.cancelController.addListener(()=>{i(new c.CrtError(`Event stream connection sendProtocolMessage() cancelled by external request.`)),setImmediate(()=>{this.close()})}),!n))return;function a(t){return e._s_on_connection_send_protocol_message_completion(r,i,t)}f.default.event_stream_client_connection_send_protocol_message(this.native_handle(),t,a)}catch(e){i(e)}});return d.makeSelfCleaningPromise(r,n)})}isConnected(){return this.state==_.Connected}newStream(){if(!this.isConnected())throw new c.CrtError(`Event stream connection in a state (${this.state}) where creating new streams is forbidden.`);return new b(this)}on(e,t){return super.on(e,t),this}static _s_on_connection_setup(e,t,n,r){r==0&&n.state==_.Connecting?(n.state=_.Connected,e()):(n.state!=_.Closed&&(n.state=_.Disconnected),t(l.error_code_to_string(r)))}static _s_on_disconnect(e,t){e.state!=_.Closed&&(e.state=_.Disconnected),process.nextTick(()=>{e.emit(`disconnection`,{errorCode:t})})}static _s_on_protocol_message(e,t){process.nextTick(()=>{e.emit(`protocolMessage`,{message:g(t)})})}static _s_on_connection_send_protocol_message_completion(e,t,n){n==0?e():t(l.error_code_to_string(n))}};e.ClientConnection=v,v.DISCONNECTION=`disconnection`,v.PROTOCOL_MESSAGE=`protocolMessage`;var y;(function(e){e[e.None=0]=`None`,e[e.Activating=1]=`Activating`,e[e.Activated=2]=`Activated`,e[e.Ended=3]=`Ended`,e[e.Closed=4]=`Closed`})(y||={});var b=class e extends (0,o.NativeResourceMixin)(s.BufferedEventEmitter){constructor(t){super(),this._super(f.default.event_stream_client_stream_new(this,t.native_handle(),t=>{e._s_on_stream_ended(t)},(t,n)=>{e._s_on_stream_message(t,n)})),this.state=y.None}close(){this.state!=y.Closed&&(this.state=y.Closed,f.default.event_stream_client_stream_close(this.native_handle()))}activate(t){return i(this,void 0,void 0,function*(){let n,r=new Promise((r,i)=>{try{if(this.state!=y.None){i(new c.CrtError(`Event stream in a state (${this.state}) where activation is not allowed.`));return}if(t===void 0){this.state=y.Ended,i(new c.CrtError(`Invalid options passed to ClientStream.activate`));return}if(this.state=y.Activating,t.cancelController&&(n=t.cancelController.addListener(()=>{i(new c.CrtError(`Event stream activate() cancelled by external request.`)),setImmediate(()=>{this.close()})}),!n))return;function a(t,n){return e._s_on_stream_activated(r,i,t,n)}f.default.event_stream_client_stream_activate(this.native_handle(),t,a)}catch(e){this.state=y.Ended,i(e)}});return d.makeSelfCleaningPromise(r,n)})}sendMessage(t){return i(this,void 0,void 0,function*(){let n,r=new Promise((r,i)=>{try{if(!t){i(new c.CrtError(`Invalid options passed to ClientStream.sendMessage`));return}if(this.state!=y.Activated){i(new c.CrtError(`Event stream in a state (${this.state}) where sending messages is not allowed.`));return}if(t.cancelController&&(n=t.cancelController.addListener(()=>{i(new c.CrtError(`Event stream sendMessage() cancelled by external request.`)),setImmediate(()=>{this.close()})}),!n))return;function a(t){return e._s_on_stream_send_message_completion(r,i,t)}f.default.event_stream_client_stream_send_message(this.native_handle(),t,a)}catch(e){i(e)}});return d.makeSelfCleaningPromise(r,n)})}isActive(){return this.state==y.Activated}on(e,t){return super.on(e,t),this}static _s_on_stream_activated(e,t,n,r){r==0&&n.state==y.Activating?(n.state=y.Activated,e()):(n.state!=y.Closed&&(n.state=y.Ended),t(l.error_code_to_string(r)))}static _s_on_stream_send_message_completion(e,t,n){n==0?e():t(l.error_code_to_string(n))}static _s_on_stream_ended(t){process.nextTick(()=>{t.emit(e.ENDED,{})})}static _s_on_stream_message(t,n){process.nextTick(()=>{t.emit(e.MESSAGE,{message:g(n)})})}};e.ClientStream=b,b.ENDED=`ended`,b.MESSAGE=`message`})),Qc=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.CommonHttpProxyOptions=e.HttpProxyAuthenticationType=e.HttpVersion=void 0,(function(e){e[e.Unknown=0]=`Unknown`,e[e.Http1_0=1]=`Http1_0`,e[e.Http1_1=2]=`Http1_1`,e[e.Http2=3]=`Http2`})(e.HttpVersion||={});var t;(function(e){e[e.None=0]=`None`,e[e.Basic=1]=`Basic`})(t=e.HttpProxyAuthenticationType||={}),e.CommonHttpProxyOptions=class{constructor(e,n,r=t.None,i,a){this.host_name=e,this.port=n,this.auth_method=r,this.auth_username=i,this.auth_password=a}}})),$c=u((e=>{var t=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,`__esModule`,{value:!0}),e.HttpClientConnectionManager=e.HttpClientStream=e.HttpStream=e.HttpClientConnection=e.HttpProxyOptions=e.HttpProxyConnectionType=e.HttpConnection=e.HttpRequest=e.HttpHeaders=e.HttpProxyAuthenticationType=void 0;let n=t(Bc()),r=Hc(),i=Vc(),a=Qc();var o=Qc();Object.defineProperty(e,`HttpProxyAuthenticationType`,{enumerable:!0,get:function(){return o.HttpProxyAuthenticationType}});let s=Yc();e.HttpHeaders=n.default.HttpHeaders;let c=n.default.HttpRequest;e.HttpRequest=class extends c{constructor(e,t,n,r){super(e,t,n,r?.native_handle())}};var l=class extends (0,r.NativeResourceMixin)(s.BufferedEventEmitter){constructor(e){super(),this._super(e)}close(){n.default.http_connection_close(this.native_handle())}on(e,t){return super.on(e,t),e==`connect`&&process.nextTick(()=>{this.uncork()}),this}};e.HttpConnection=l,l.CONNECT=`connect`,l.ERROR=`error`,l.CLOSE=`close`;var u;(function(e){e[e.Legacy=0]=`Legacy`,e[e.Forwarding=1]=`Forwarding`,e[e.Tunneling=2]=`Tunneling`})(u=e.HttpProxyConnectionType||={}),e.HttpProxyOptions=class extends a.CommonHttpProxyOptions{constructor(e,t,n=a.HttpProxyAuthenticationType.None,r,i,o,s){super(e,t,n,r,i),this.tls_opts=o,this.connection_type=s}create_native_handle(){return n.default.http_proxy_options_new(this.host_name,this.port,this.auth_method,this.auth_username,this.auth_password,this.tls_opts?this.tls_opts.native_handle():void 0,this.connection_type?this.connection_type:u.Legacy)}};var d=class extends l{_on_setup(e,t){if(t){this.emit(`error`,new i.CrtError(t));return}this.emit(`connect`)}_on_shutdown(e,t){if(t){this.emit(`error`,new i.CrtError(t));return}this.emit(`close`)}constructor(e,t,r,a,o,s,c){if(a==null||a==null)throw new i.CrtError(`HttpClientConnection constructor: socket_options not defined`);super(c||n.default.http_connection_new(e==null?null:e.native_handle(),(e,t)=>{this._on_setup(e,t)},(e,t)=>{this._on_shutdown(e,t)},t,r,a.native_handle(),o?o.native_handle():void 0,s?s.create_native_handle():void 0)),this.bootstrap=e,this.socket_options=a,this.tls_opts=o}request(e){let t;return t=new p(n.default.http_stream_new(this.native_handle(),e,e=>{t._on_complete(e)},(e,n)=>{t._on_response(e,n)},e=>{t._on_body(e)}),this,e)}};e.HttpClientConnection=d;var f=class extends (0,r.NativeResourceMixin)(s.BufferedEventEmitter){constructor(e,t){super(),this.connection=t,this._super(e),this.cork()}activate(){n.default.http_stream_activate(this.native_handle())}close(){n.default.http_stream_close(this.native_handle())}_on_body(e){this.emit(`data`,e)}_on_complete(e){if(e){this.emit(`error`,new i.CrtError(e)),this.close();return}this.on(`end`,()=>{this.close()}),this.emit(`end`)}};e.HttpStream=f;var p=class extends f{constructor(e,t,n){super(e,t),this.request=n}status_code(){return this.response_status_code}on(e,t){return super.on(e,t),e==`response`&&process.nextTick(()=>{this.uncork()}),this}_on_response(t,n){this.response_status_code=t;let r=new e.HttpHeaders(n);this.emit(`response`,t,r)}};e.HttpClientStream=p,p.RESPONSE=`response`,p.DATA=`data`,p.ERROR=`error`,p.END=`end`,p.HEADERS=`headers`,e.HttpClientConnectionManager=class extends r.NativeResource{constructor(e,t,r,a,o,s,c,l){if(s==null||s==null)throw new i.CrtError(`HttpClientConnectionManager constructor: socket_options not defined`);super(n.default.http_connection_manager_new(e==null?null:e.native_handle(),t,r,a,o,s.native_handle(),c?c.native_handle():void 0,l?l.create_native_handle():void 0,void 0)),this.bootstrap=e,this.host=t,this.port=r,this.max_connections=a,this.initial_window_size=o,this.socket_options=s,this.tls_opts=c,this.proxy_options=l,this.connections=new Map}acquire(){return new Promise((e,t)=>{n.default.http_connection_manager_acquire(this.native_handle(),(n,r)=>{if(r){t(new i.CrtError(r));return}let a=this.connections.get(n);a||(a=new d(this.bootstrap,this.host,this.port,this.socket_options,this.tls_opts,this.proxy_options,n),this.connections.set(n,a),a.on(`close`,()=>{this.connections.delete(n)})),e(a)})})}release(e){if(e==null||e==null)throw new i.CrtError(`HttpClientConnectionManager release: connection not defined`);n.default.http_connection_manager_release(this.native_handle(),e.native_handle())}close(){n.default.http_connection_manager_close(this.native_handle())}}})),el=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.DEFAULT_RECONNECT_MIN_SEC=e.DEFAULT_RECONNECT_MAX_SEC=e.MqttWill=e.QoS=void 0,(function(e){e[e.AtMostOnce=0]=`AtMostOnce`,e[e.AtLeastOnce=1]=`AtLeastOnce`,e[e.ExactlyOnce=2]=`ExactlyOnce`})(e.QoS||={}),e.MqttWill=class{constructor(e,t,n,r=!1){this.topic=e,this.qos=t,this.payload=n,this.retain=r}},e.DEFAULT_RECONNECT_MAX_SEC=128,e.DEFAULT_RECONNECT_MIN_SEC=1})),tl=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.set_defined_property=void 0;function t(e,t,n){return n===void 0||n==null?!1:(e[t]=n,!0)}e.set_defined_property=t})),nl=u((e=>{var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__setModuleDefault||(Object.create?(function(e,t){Object.defineProperty(e,`default`,{enumerable:!0,value:t})}):function(e,t){e.default=t}),r=e&&e.__importStar||function(e){if(e&&e.__esModule)return e;var r={};if(e!=null)for(var i in e)i!==`default`&&Object.prototype.hasOwnProperty.call(e,i)&&t(r,e,i);return n(r,e),r};Object.defineProperty(e,`__esModule`,{value:!0}),e.extractRegionFromEndpoint=e.buildMqtt5FinalUsername=e.canonicalizeCustomAuthConfig=e.canonicalizeCustomAuthTokenSignature=e.populate_username_string_with_custom_authorizer=e.is_string_and_not_empty=e.add_to_username_parameter=void 0;let i=r(Rc()),a=r(tl());function o(e,t,n){let r=e;return r.indexOf(`?`)==-1?r+=`?`:r+=`&`,t.indexOf(n)==-1?r+n+t:r+t}e.add_to_username_parameter=o;function s(e){return e!=null&&typeof e==`string`&&e!=``}e.is_string_and_not_empty=s;function c(e,t,n,r,i,a,c){let l=``;if(e&&(l+=e),s(t)==0?s(i)&&i&&(l+=i):l+=t,s(n)&&n&&(l=o(l,n,`x-amz-customauthorizer-name=`)),(s(r)||s(c)||s(a))&&(!c||!a||!r))throw Error(`Signing-based custom authentication requires all token-related properties to be set`);return s(r)&&r&&(l=o(l,r,`x-amz-customauthorizer-signature=`)),s(c)&&s(a)&&(l=o(l,c,a+`=`)),l}e.populate_username_string_with_custom_authorizer=c;function l(e){if(!(e===void 0||e==null))return e.indexOf(`%`)==-1?encodeURIComponent(e):e}e.canonicalizeCustomAuthTokenSignature=l;function u(e){let t={};return a.set_defined_property(t,`authorizerName`,e.authorizerName),a.set_defined_property(t,`username`,e.username),a.set_defined_property(t,`password`,e.password),a.set_defined_property(t,`tokenKeyName`,e.tokenKeyName),a.set_defined_property(t,`tokenValue`,e.tokenValue),a.set_defined_property(t,`tokenSignature`,l(e.tokenSignature)),t}e.canonicalizeCustomAuthConfig=u;function d(e,t,n){t&&n.push([e,t])}function f(e){let t=``,n=[];if(e){let r=!1;if((e.tokenValue||e.tokenKeyName||e.tokenSignature)&&(r=!0,!e.tokenValue||!e.tokenKeyName||!e.tokenSignature))throw Error(`Token-based custom authentication requires all token-related properties to be set`);let i=(e.username??``).split(`?`),a=i.slice(1);if(t=i[0],a.length>1)throw Error(`Custom auth username property value is invalid`);a.length==1&&a[0].split(`&`).forEach((e,t,r)=>{let i=e.split(`=`);n.push([i[0],i[1]??``])}),d(`x-amz-customauthorizer-name`,e.authorizerName,n),r&&(d(e.tokenKeyName,e.tokenValue,n),d(`x-amz-customauthorizer-signature`,e.tokenSignature,n))}return n.push([`SDK`,`NodeJSv2`]),n.push([`Version`,i.crt_version()]),(t??``)+`?`+n.map(e=>`${e[0]}=${e[1]}`).join(`&`)}e.buildMqtt5FinalUsername=f;function p(e){let t=e.match(/^[\w\-]+\.[\w\-]+\.([\w+\-]+)\./);if(t)return t[1];throw Error(`AWS region could not be extracted from endpoint. Use 'region' property on WebsocketConfig to set manually.`)}e.extractRegionFromEndpoint=p})),rl=u((e=>{var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__setModuleDefault||(Object.create?(function(e,t){Object.defineProperty(e,`default`,{enumerable:!0,value:t})}):function(e,t){e.default=t}),r=e&&e.__importStar||function(e){if(e&&e.__esModule)return e;var r={};if(e!=null)for(var i in e)i!==`default`&&Object.prototype.hasOwnProperty.call(e,i)&&t(r,e,i);return n(r,e),r},i=e&&e.__awaiter||function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})};Object.defineProperty(e,`__esModule`,{value:!0}),e.AwsIotMqttConnectionConfigBuilder=void 0;let a=el(),o=r(Wc()),s=Wc(),c=r(Rc()),l=Vc(),u=Gc(),d=r(nl());e.AwsIotMqttConnectionConfigBuilder=class e{constructor(e){this.tls_ctx_options=e,this.params={client_id:``,host_name:``,socket_options:new o.SocketOptions,port:8883,use_websocket:!1,clean_session:!1,keep_alive:void 0,will:void 0,username:``,password:void 0,tls_ctx:void 0,reconnect_min_sec:a.DEFAULT_RECONNECT_MIN_SEC,reconnect_max_sec:a.DEFAULT_RECONNECT_MAX_SEC},this.is_using_custom_authorizer=!1}static new_mtls_builder_from_path(t,n){let r=new e(s.TlsContextOptions.create_client_with_mtls_from_path(t,n));return r.params.port=8883,o.is_alpn_available()&&r.tls_ctx_options.alpn_list.unshift(`x-amzn-mqtt-ca`),r}static new_mtls_builder(t,n){let r=new e(s.TlsContextOptions.create_client_with_mtls(t,n));return r.params.port=8883,o.is_alpn_available()&&r.tls_ctx_options.alpn_list.unshift(`x-amzn-mqtt-ca`),r}static new_mtls_pkcs11_builder(t){let n=new e(s.TlsContextOptions.create_client_with_mtls_pkcs11(t));return n.params.port=8883,o.is_alpn_available()&&n.tls_ctx_options.alpn_list.unshift(`x-amzn-mqtt-ca`),n}static new_mtls_pkcs12_builder(t){let n=new e(s.TlsContextOptions.create_client_with_mtls_pkcs12_from_path(t.pkcs12_file,t.pkcs12_password));return n.params.port=8883,o.is_alpn_available()&&n.tls_ctx_options.alpn_list.unshift(`x-amzn-mqtt-ca`),n}static new_mtls_windows_cert_store_path_builder(t){let n=new e(s.TlsContextOptions.create_client_with_mtls_windows_cert_store_path(t));return n.params.port=8883,o.is_alpn_available()&&n.tls_ctx_options.alpn_list.unshift(`x-amzn-mqtt-ca`),n}static new_default_builder(){return new e(new o.TlsContextOptions)}static new_websocket_builder(...e){return this.new_with_websockets(...e)}static configure_websocket_handshake(e,t){if(t){if(e==null||e==null)throw new l.CrtError(`AwsIotMqttConnectionConfigBuilder configure_websocket_handshake: builder not defined`);e.params.websocket_handshake_transform=(e,n)=>i(this,void 0,void 0,function*(){let r=t.create_signing_config?.call(t)??{algorithm:u.AwsSigningAlgorithm.SigV4,signature_type:u.AwsSignatureType.HttpRequestViaQueryParams,provider:t.credentials_provider,region:t.region,service:t.service??`iotdevicegateway`,signed_body_value:u.AwsSignedBodyValue.EmptySha256,omit_session_token:!0};try{yield(0,u.aws_sign_request)(e,r),n()}catch(e){e instanceof l.CrtError?n(e.error_code):n(3)}})}return e}static new_with_websockets(t){let n=t?.tls_ctx_options;n||(n=new s.TlsContextOptions,n.alpn_list=[]);let r=new e(n);return r.params.use_websocket=!0,r.params.proxy_options=t?.proxy_options,r.tls_ctx_options&&(r.params.port=443),this.configure_websocket_handshake(r,t),r}static new_builder_for_websocket(){return this.new_with_websockets()}with_certificate_authority_from_path(e,t){return this.tls_ctx_options.override_default_trust_store_from_path(e,t),this}with_certificate_authority(e){return this.tls_ctx_options.override_default_trust_store(e),this}with_tls_cipher_preference(e){return this.tls_ctx_options.tls_cipher_preference=e,this}with_endpoint(e){return this.params.host_name=e,this}with_port(e){return this.params.port=e,this}with_client_id(e){return this.params.client_id=e,this}with_clean_session(e){return this.params.clean_session=e,this}with_keep_alive_seconds(e){return this.params.keep_alive=e,this}with_timeout_ms(e){return this.with_ping_timeout_ms(e),this}with_ping_timeout_ms(e){return this.params.ping_timeout=e,this}with_protocol_operation_timeout_ms(e){return this.params.protocol_operation_timeout=e,this}with_will(e){return this.params.will=e,this}with_socket_options(e){return this.params.socket_options=e,this}with_credentials(t,n,r,i){return e.configure_websocket_handshake(this,{credentials_provider:u.AwsCredentialsProvider.newStatic(n,r,i),region:t,service:`iotdevicegateway`})}with_http_proxy_options(e){return this.params.proxy_options=e,this}with_custom_authorizer(e,t,n,r,i,a){this.is_using_custom_authorizer=!0;let o=d.canonicalizeCustomAuthTokenSignature(n),s=d.populate_username_string_with_custom_authorizer(``,e,t,o,this.params.username,i,a);return this.params.username=s,this.params.password=r,this.params.use_websocket||(this.tls_ctx_options.alpn_list=[`mqtt`]),this.params.port=443,this}with_username(e){return this.params.username=e,this}with_password(e){return this.params.password=e,this}with_reconnect_max_sec(e){return this.params.reconnect_max_sec=e,this}with_reconnect_min_sec(e){return this.params.reconnect_min_sec=e,this}build(){if(this.params.client_id===void 0||this.params.host_name===void 0)throw`client_id and endpoint are required`;return this.is_using_custom_authorizer==0&&d.is_string_and_not_empty(this.params.username)&&(this.params.username?.indexOf(`x-amz-customauthorizer-name=`)!=-1||this.params.username?.indexOf(`x-amz-customauthorizer-signature=`)!=-1)&&(this.is_using_custom_authorizer=!0),this.is_using_custom_authorizer==1&&this.params.port!=443&&console.log(`Warning: Attempting to connect to authorizer with unsupported port. Port is not 443...`),this.params.tls_ctx===void 0&&(this.params.tls_ctx=new o.ClientTlsContext(this.tls_ctx_options)),d.is_string_and_not_empty(this.params.username)==0?this.params.username=`?SDK=NodeJSv2&Version=`:this.params.username?.indexOf(`?`)==-1?this.params.username+=`?SDK=NodeJSv2&Version=`:this.params.username+=`&SDK=NodeJSv2&Version=`,this.params.username+=c.crt_version(),this.params}}})),il=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.isValidTopic=e.isValidTopicFilter=e.DEFAULT_KEEP_ALIVE=e.normalize_payload_to_buffer=e.normalize_payload=void 0;function t(e){if(e instanceof Buffer||typeof e==`string`)return e;if(ArrayBuffer.isView(e)){let t=e;return Buffer.from(t.buffer,t.byteOffset,t.byteLength)}if(e instanceof ArrayBuffer)return Buffer.from(e);if(typeof e==`object`)return JSON.stringify(e);if(!e)return``;throw TypeError(`payload parameter must be a string, object, or DataView.`)}e.normalize_payload=t;function n(e){let n=t(e);return typeof n==`string`?Buffer.from(n):n}e.normalize_payload_to_buffer=n,e.DEFAULT_KEEP_ALIVE=1200;function r(e,t){if(e.length===0||e.length>65535)return!1;let n=!1;for(let r of e.split(`/`)){if(n)return!1;if(r.length!==0){if(r.includes(`+`)&&(!t||r.length>1))return!1;if(r.includes(`#`)){if(!t||r.length>1)return!1;n=!0}}}return!0}function i(e){return typeof e==`string`?r(e,!0):!1}e.isValidTopicFilter=i;function a(e){return typeof e==`string`?r(e,!1):!1}e.isValidTopic=a})),al=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.InboundTopicAliasBehaviorType=e.OutboundTopicAliasBehaviorType=e.RetryJitterType=e.ClientSessionBehavior=void 0,(function(e){e[e.Default=0]=`Default`,e[e.Clean=1]=`Clean`,e[e.RejoinPostSuccess=2]=`RejoinPostSuccess`,e[e.RejoinAlways=3]=`RejoinAlways`})(e.ClientSessionBehavior||={}),(function(e){e[e.Default=0]=`Default`,e[e.None=1]=`None`,e[e.Full=2]=`Full`,e[e.Decorrelated=3]=`Decorrelated`})(e.RetryJitterType||={}),(function(e){e[e.Default=0]=`Default`,e[e.Manual=1]=`Manual`,e[e.LRU=2]=`LRU`,e[e.Disabled=3]=`Disabled`})(e.OutboundTopicAliasBehaviorType||={}),(function(e){e[e.Default=0]=`Default`,e[e.Enabled=1]=`Enabled`,e[e.Disabled=2]=`Disabled`})(e.InboundTopicAliasBehaviorType||={})})),ol=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.PacketType=e.RetainHandlingType=e.QoS=e.PayloadFormatIndicator=e.isSuccessfulPubackReasonCode=e.PubackReasonCode=e.isSuccessfulUnsubackReasonCode=e.UnsubackReasonCode=e.isSuccessfulSubackReasonCode=e.SubackReasonCode=e.isSuccessfulDisconnectReasonCode=e.DisconnectReasonCode=e.isSuccessfulConnectReasonCode=e.ConnectReasonCode=void 0,(function(e){e[e.Success=0]=`Success`,e[e.UnspecifiedError=128]=`UnspecifiedError`,e[e.MalformedPacket=129]=`MalformedPacket`,e[e.ProtocolError=130]=`ProtocolError`,e[e.ImplementationSpecificError=131]=`ImplementationSpecificError`,e[e.UnsupportedProtocolVersion=132]=`UnsupportedProtocolVersion`,e[e.ClientIdentifierNotValid=133]=`ClientIdentifierNotValid`,e[e.BadUsernameOrPassword=134]=`BadUsernameOrPassword`,e[e.NotAuthorized=135]=`NotAuthorized`,e[e.ServerUnavailable=136]=`ServerUnavailable`,e[e.ServerBusy=137]=`ServerBusy`,e[e.Banned=138]=`Banned`,e[e.BadAuthenticationMethod=140]=`BadAuthenticationMethod`,e[e.TopicNameInvalid=144]=`TopicNameInvalid`,e[e.PacketTooLarge=149]=`PacketTooLarge`,e[e.QuotaExceeded=151]=`QuotaExceeded`,e[e.PayloadFormatInvalid=153]=`PayloadFormatInvalid`,e[e.RetainNotSupported=154]=`RetainNotSupported`,e[e.QosNotSupported=155]=`QosNotSupported`,e[e.UseAnotherServer=156]=`UseAnotherServer`,e[e.ServerMoved=157]=`ServerMoved`,e[e.ConnectionRateExceeded=159]=`ConnectionRateExceeded`})(e.ConnectReasonCode||={});function t(e){return e<128}e.isSuccessfulConnectReasonCode=t,(function(e){e[e.NormalDisconnection=0]=`NormalDisconnection`,e[e.DisconnectWithWillMessage=4]=`DisconnectWithWillMessage`,e[e.UnspecifiedError=128]=`UnspecifiedError`,e[e.MalformedPacket=129]=`MalformedPacket`,e[e.ProtocolError=130]=`ProtocolError`,e[e.ImplementationSpecificError=131]=`ImplementationSpecificError`,e[e.NotAuthorized=135]=`NotAuthorized`,e[e.ServerBusy=137]=`ServerBusy`,e[e.ServerShuttingDown=139]=`ServerShuttingDown`,e[e.KeepAliveTimeout=141]=`KeepAliveTimeout`,e[e.SessionTakenOver=142]=`SessionTakenOver`,e[e.TopicFilterInvalid=143]=`TopicFilterInvalid`,e[e.TopicNameInvalid=144]=`TopicNameInvalid`,e[e.ReceiveMaximumExceeded=147]=`ReceiveMaximumExceeded`,e[e.TopicAliasInvalid=148]=`TopicAliasInvalid`,e[e.PacketTooLarge=149]=`PacketTooLarge`,e[e.MessageRateTooHigh=150]=`MessageRateTooHigh`,e[e.QuotaExceeded=151]=`QuotaExceeded`,e[e.AdministrativeAction=152]=`AdministrativeAction`,e[e.PayloadFormatInvalid=153]=`PayloadFormatInvalid`,e[e.RetainNotSupported=154]=`RetainNotSupported`,e[e.QosNotSupported=155]=`QosNotSupported`,e[e.UseAnotherServer=156]=`UseAnotherServer`,e[e.ServerMoved=157]=`ServerMoved`,e[e.SharedSubscriptionsNotSupported=158]=`SharedSubscriptionsNotSupported`,e[e.ConnectionRateExceeded=159]=`ConnectionRateExceeded`,e[e.MaximumConnectTime=160]=`MaximumConnectTime`,e[e.SubscriptionIdentifiersNotSupported=161]=`SubscriptionIdentifiersNotSupported`,e[e.WildcardSubscriptionsNotSupported=162]=`WildcardSubscriptionsNotSupported`})(e.DisconnectReasonCode||={});function n(e){return e<128}e.isSuccessfulDisconnectReasonCode=n,(function(e){e[e.GrantedQoS0=0]=`GrantedQoS0`,e[e.GrantedQoS1=1]=`GrantedQoS1`,e[e.GrantedQoS2=2]=`GrantedQoS2`,e[e.UnspecifiedError=128]=`UnspecifiedError`,e[e.ImplementationSpecificError=131]=`ImplementationSpecificError`,e[e.NotAuthorized=135]=`NotAuthorized`,e[e.TopicFilterInvalid=143]=`TopicFilterInvalid`,e[e.PacketIdentifierInUse=145]=`PacketIdentifierInUse`,e[e.QuotaExceeded=151]=`QuotaExceeded`,e[e.SharedSubscriptionsNotSupported=158]=`SharedSubscriptionsNotSupported`,e[e.SubscriptionIdentifiersNotSupported=161]=`SubscriptionIdentifiersNotSupported`,e[e.WildcardSubscriptionsNotSupported=162]=`WildcardSubscriptionsNotSupported`})(e.SubackReasonCode||={});function r(e){return e<128}e.isSuccessfulSubackReasonCode=r,(function(e){e[e.Success=0]=`Success`,e[e.NoSubscriptionExisted=17]=`NoSubscriptionExisted`,e[e.UnspecifiedError=128]=`UnspecifiedError`,e[e.ImplementationSpecificError=131]=`ImplementationSpecificError`,e[e.NotAuthorized=135]=`NotAuthorized`,e[e.TopicFilterInvalid=143]=`TopicFilterInvalid`,e[e.PacketIdentifierInUse=145]=`PacketIdentifierInUse`})(e.UnsubackReasonCode||={});function i(e){return e<128}e.isSuccessfulUnsubackReasonCode=i,(function(e){e[e.Success=0]=`Success`,e[e.NoMatchingSubscribers=16]=`NoMatchingSubscribers`,e[e.UnspecifiedError=128]=`UnspecifiedError`,e[e.ImplementationSpecificError=131]=`ImplementationSpecificError`,e[e.NotAuthorized=135]=`NotAuthorized`,e[e.TopicNameInvalid=144]=`TopicNameInvalid`,e[e.PacketIdentifierInUse=145]=`PacketIdentifierInUse`,e[e.QuotaExceeded=151]=`QuotaExceeded`,e[e.PayloadFormatInvalid=153]=`PayloadFormatInvalid`})(e.PubackReasonCode||={});function a(e){return e<128}e.isSuccessfulPubackReasonCode=a,(function(e){e[e.Bytes=0]=`Bytes`,e[e.Utf8=1]=`Utf8`})(e.PayloadFormatIndicator||={}),(function(e){e[e.AtMostOnce=0]=`AtMostOnce`,e[e.AtLeastOnce=1]=`AtLeastOnce`,e[e.ExactlyOnce=2]=`ExactlyOnce`})(e.QoS||={}),(function(e){e[e.SendOnSubscribe=0]=`SendOnSubscribe`,e[e.SendOnSubscribeIfNew=1]=`SendOnSubscribeIfNew`,e[e.DontSend=2]=`DontSend`})(e.RetainHandlingType||={}),(function(e){e[e.Connect=1]=`Connect`,e[e.Connack=2]=`Connack`,e[e.Publish=3]=`Publish`,e[e.Puback=4]=`Puback`,e[e.Pubrec=5]=`Pubrec`,e[e.Pubrel=6]=`Pubrel`,e[e.Pubcomp=7]=`Pubcomp`,e[e.Subscribe=8]=`Subscribe`,e[e.Suback=9]=`Suback`,e[e.Unsubscribe=10]=`Unsubscribe`,e[e.Unsuback=11]=`Unsuback`,e[e.Pingreq=12]=`Pingreq`,e[e.Pingresp=13]=`Pingresp`,e[e.Disconnect=14]=`Disconnect`,e[e.Auth=15]=`Auth`})(e.PacketType||={})})),sl=u((e=>{var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__setModuleDefault||(Object.create?(function(e,t){Object.defineProperty(e,`default`,{enumerable:!0,value:t})}):function(e,t){e.default=t}),r=e&&e.__importStar||function(e){if(e&&e.__esModule)return e;var r={};if(e!=null)for(var i in e)i!==`default`&&Object.prototype.hasOwnProperty.call(e,i)&&t(r,e,i);return n(r,e),r},i=e&&e.__exportStar||function(e,n){for(var r in e)r!==`default`&&!Object.prototype.hasOwnProperty.call(n,r)&&t(n,e,r)},a=e&&e.__awaiter||function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})},o=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,`__esModule`,{value:!0}),e.Mqtt5Client=e.ClientExtendedValidationAndFlowControl=e.ClientOperationQueueBehavior=e.HttpProxyOptions=void 0;let s=o(Bc()),c=Hc(),l=Yc(),u=r(Wc()),d=r(il()),f=Vc();var p=$c();Object.defineProperty(e,`HttpProxyOptions`,{enumerable:!0,get:function(){return p.HttpProxyOptions}}),i(al(),e),i(ol(),e),(function(e){e[e.Default=0]=`Default`,e[e.FailNonQos1PublishOnDisconnect=1]=`FailNonQos1PublishOnDisconnect`,e[e.FailQos0PublishOnDisconnect=2]=`FailQos0PublishOnDisconnect`,e[e.FailAllOnDisconnect=3]=`FailAllOnDisconnect`})(e.ClientOperationQueueBehavior||={}),(function(e){e[e.None=0]=`None`,e[e.AwsIotCoreDefaults=1]=`AwsIotCoreDefaults`})(e.ClientExtendedValidationAndFlowControl||={});var m=class e extends (0,c.NativeResourceMixin)(l.BufferedEventEmitter){constructor(t){super(),this._super(s.default.mqtt5_client_new(this,t,t=>{e._s_on_stopped(t)},t=>{e._s_on_attempting_connect(t)},(t,n,r)=>{e._s_on_connection_success(t,n,r)},(t,n,r)=>{e._s_on_connection_failure(t,new f.CrtError(n),r)},(t,n,r)=>{e._s_on_disconnection(t,new f.CrtError(n),r)},(t,n)=>{e._s_on_message_received(t,n)},t.clientBootstrap?t.clientBootstrap.native_handle():null,t.socketOptions?t.socketOptions.native_handle():null,t.tlsCtx?t.tlsCtx.native_handle():null,t.httpProxyOptions?t.httpProxyOptions.create_native_handle():null))}close(){s.default.mqtt5_client_close(this.native_handle())}start(){s.default.mqtt5_client_start(this.native_handle())}stop(e){s.default.mqtt5_client_stop(this.native_handle(),e)}subscribe(t){return a(this,void 0,void 0,function*(){return new Promise((n,r)=>{function i(t,i,a){return e._s_on_suback_callback(n,r,t,i,a)}try{s.default.mqtt5_client_subscribe(this.native_handle(),t,i)}catch(e){r(e)}})})}unsubscribe(t){return a(this,void 0,void 0,function*(){return new Promise((n,r)=>{function i(t,i,a){return e._s_on_unsuback_callback(n,r,t,i,a)}try{s.default.mqtt5_client_unsubscribe(this.native_handle(),t,i)}catch(e){r(e)}})})}publish(t){return a(this,void 0,void 0,function*(){return new Promise((n,r)=>{t&&t.payload&&(t.payload=d.normalize_payload(t.payload));function i(t,i,a){return e._s_on_puback_callback(n,r,t,i,a)}try{s.default.mqtt5_client_publish(this.native_handle(),t,i)}catch(e){r(e)}})})}getOperationalStatistics(){return s.default.mqtt5_client_get_queue_statistics(this.native_handle())}getQueueStatistics(){return this.getOperationalStatistics()}on(e,t){return super.on(e,t),this}static _s_on_stopped(t){process.nextTick(()=>{t.emit(e.STOPPED,{})})}static _s_on_attempting_connect(t){process.nextTick(()=>{t.emit(e.ATTEMPTING_CONNECT,{})})}static _s_on_connection_success(t,n,r){let i={connack:n,settings:r};process.nextTick(()=>{t.emit(e.CONNECTION_SUCCESS,i)})}static _s_on_connection_failure(t,n,r){let i={error:n};r!=null&&(i.connack=r),process.nextTick(()=>{t.emit(e.CONNECTION_FAILURE,i)})}static _s_on_disconnection(t,n,r){let i={error:n};r!=null&&(i.disconnect=r),process.nextTick(()=>{t.emit(e.DISCONNECTION,i)})}static _s_on_suback_callback(e,t,n,r,i){r==0&&i!==void 0?e(i):t(u.error_code_to_string(r))}static _s_on_unsuback_callback(e,t,n,r,i){r==0&&i!==void 0?e(i):t(u.error_code_to_string(r))}static _s_on_puback_callback(e,t,n,r,i){r==0?e(i):t(u.error_code_to_string(r))}static _s_on_message_received(t,n){let r={message:n};process.nextTick(()=>{t.emit(e.MESSAGE_RECEIVED,r)})}};e.Mqtt5Client=m,m.ERROR=`error`,m.MESSAGE_RECEIVED=`messageReceived`,m.ATTEMPTING_CONNECT=`attemptingConnect`,m.CONNECTION_SUCCESS=`connectionSuccess`,m.CONNECTION_FAILURE=`connectionFailure`,m.DISCONNECTION=`disconnection`,m.STOPPED=`stopped`})),cl=u((e=>{var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__setModuleDefault||(Object.create?(function(e,t){Object.defineProperty(e,`default`,{enumerable:!0,value:t})}):function(e,t){e.default=t}),r=e&&e.__importStar||function(e){if(e&&e.__esModule)return e;var r={};if(e!=null)for(var i in e)i!==`default`&&Object.prototype.hasOwnProperty.call(e,i)&&t(r,e,i);return n(r,e),r},i=e&&e.__awaiter||function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})};Object.defineProperty(e,`__esModule`,{value:!0}),e.AwsIotMqtt5ClientConfigBuilder=void 0;let a=r(sl()),o=r(Wc()),s=r(Gc()),c=Vc(),l=r(nl()),u=r(il());var d=class e{constructor(e,t,n){this.tlsContextOptions=n,this.config={hostName:e,port:t,connectProperties:{keepAliveIntervalSeconds:u.DEFAULT_KEEP_ALIVE},extendedValidationAndFlowControlOptions:a.ClientExtendedValidationAndFlowControl.AwsIotCoreDefaults}}static newDirectMqttBuilderWithMtlsFromPath(t,n,r){let i=new e(t,e.DEFAULT_DIRECT_MQTT_PORT,o.TlsContextOptions.create_client_with_mtls_from_path(n,r));return o.is_alpn_available()&&i.tlsContextOptions.alpn_list.unshift(`x-amzn-mqtt-ca`),i}static newDirectMqttBuilderWithMtlsFromMemory(t,n,r){let i=new e(t,e.DEFAULT_DIRECT_MQTT_PORT,o.TlsContextOptions.create_client_with_mtls(n,r));return o.is_alpn_available()&&i.tlsContextOptions.alpn_list.unshift(`x-amzn-mqtt-ca`),i}static newDirectMqttBuilderWithMtlsFromPkcs11(t,n){let r=new e(t,e.DEFAULT_DIRECT_MQTT_PORT,o.TlsContextOptions.create_client_with_mtls_pkcs11(n));return o.is_alpn_available()&&r.tlsContextOptions.alpn_list.unshift(`x-amzn-mqtt-ca`),r}static newDirectMqttBuilderWithMtlsFromPkcs12(t,n){let r=new e(t,e.DEFAULT_DIRECT_MQTT_PORT,o.TlsContextOptions.create_client_with_mtls_pkcs12_from_path(n.pkcs12_file,n.pkcs12_password));return o.is_alpn_available()&&r.tlsContextOptions.alpn_list.unshift(`x-amzn-mqtt-ca`),r}static newDirectMqttBuilderWithMtlsFromWindowsCertStorePath(t,n){let r=new e(t,e.DEFAULT_DIRECT_MQTT_PORT,o.TlsContextOptions.create_client_with_mtls_windows_cert_store_path(n));return o.is_alpn_available()&&r.tlsContextOptions.alpn_list.unshift(`x-amzn-mqtt-ca`),r}static newDirectMqttBuilderWithCustomAuth(t,n){let r=new e(t,e.DEFAULT_WEBSOCKET_MQTT_PORT,new o.TlsContextOptions);return r.customAuthConfig=l.canonicalizeCustomAuthConfig(n),r.tlsContextOptions.alpn_list=[`mqtt`],r}static newWebsocketMqttBuilderWithSigv4Auth(t,n){let r=new o.TlsContextOptions;r.alpn_list=[];let a=new e(t,e.DEFAULT_WEBSOCKET_MQTT_PORT,r),u=n?.credentialsProvider;return u||=s.AwsCredentialsProvider.newDefault(),a.config.websocketHandshakeTransform=(e,r)=>i(this,void 0,void 0,function*(){try{let i={algorithm:s.AwsSigningAlgorithm.SigV4,signature_type:s.AwsSignatureType.HttpRequestViaQueryParams,provider:u,region:n?.region??l.extractRegionFromEndpoint(t),service:`iotdevicegateway`,signed_body_value:s.AwsSignedBodyValue.EmptySha256,omit_session_token:!0};yield s.aws_sign_request(e,i),r()}catch(e){e instanceof c.CrtError?r(e.error_code):r(3)}}),a}static newWebsocketMqttBuilderWithCustomAuth(t,n){let r=new e(t,e.DEFAULT_WEBSOCKET_MQTT_PORT,new o.TlsContextOptions);return r.customAuthConfig=n,r.config.websocketHandshakeTransform=(e,t)=>i(this,void 0,void 0,function*(){t(0)}),r}withCertificateAuthorityFromPath(e,t){return this.tlsContextOptions.override_default_trust_store_from_path(e,t),this}withCertificateAuthority(e){return this.tlsContextOptions.override_default_trust_store(e),this}withTlsCipherPreference(e){return this.tlsContextOptions.tls_cipher_preference=e,this}withPort(e){return this.config.port=e,this}withConnectProperties(e){return this.config.connectProperties=e,this}withSessionBehavior(e){return this.config.sessionBehavior=e,this}withRetryJitterMode(e){return this.config.retryJitterMode=e,this}withMinReconnectDelayMs(e){return this.config.minReconnectDelayMs=e,this}withMaxReconnectDelayMs(e){return this.config.maxReconnectDelayMs=e,this}withMinConnectedTimeToResetReconnectDelayMs(e){return this.config.minConnectedTimeToResetReconnectDelayMs=e,this}withConnackTimeoutMs(e){return this.config.connackTimeoutMs=e,this}withOfflineQueueBehavior(e){return this.config.offlineQueueBehavior=e,this}withPingTimeoutMs(e){return this.config.pingTimeoutMs=e,this}withAckTimeoutSeconds(e){return this.config.ackTimeoutSeconds=e,this}withSocketOptions(e){return this.config.socketOptions=e,this}withHttpProxyOptions(e){return this.config.httpProxyOptions=e,this}withExtendedValidationAndFlowControlOptions(e){return this.config.extendedValidationAndFlowControlOptions=e,this}withTopicAliasingOptions(e){return this.config.topicAliasingOptions=e,this}build(){return this.config.tlsCtx===void 0&&(this.config.tlsCtx=new o.ClientTlsContext(this.tlsContextOptions)),this.config.connectProperties&&(this.config.connectProperties.username=l.buildMqtt5FinalUsername(this.customAuthConfig),this.customAuthConfig?.password&&(this.config.connectProperties.password=this.customAuthConfig?.password)),this.config}};e.AwsIotMqtt5ClientConfigBuilder=d,d.DEFAULT_WEBSOCKET_MQTT_PORT=443,d.DEFAULT_DIRECT_MQTT_PORT=8883})),ll=u((e=>{var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__exportStar||function(e,n){for(var r in e)r!==`default`&&!Object.prototype.hasOwnProperty.call(n,r)&&t(n,e,r)};Object.defineProperty(e,`__esModule`,{value:!0}),n(rl(),e),n(cl(),e)})),ul=u((e=>{var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__setModuleDefault||(Object.create?(function(e,t){Object.defineProperty(e,`default`,{enumerable:!0,value:t})}):function(e,t){e.default=t}),r=e&&e.__importStar||function(e){if(e&&e.__esModule)return e;var r={};if(e!=null)for(var i in e)i!==`default`&&Object.prototype.hasOwnProperty.call(e,i)&&t(r,e,i);return n(r,e),r},i=e&&e.__awaiter||function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})},a=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,`__esModule`,{value:!0}),e.MqttClientConnection=e.MqttClient=e.MqttWill=e.QoS=e.HttpProxyOptions=void 0;let o=a(Bc()),s=Hc(),c=Yc(),l=r(il()),u=Vc(),d=r(Wc());var f=$c();Object.defineProperty(e,`HttpProxyOptions`,{enumerable:!0,get:function(){return f.HttpProxyOptions}});let p=el();var m=el();Object.defineProperty(e,`QoS`,{enumerable:!0,get:function(){return m.QoS}}),Object.defineProperty(e,`MqttWill`,{enumerable:!0,get:function(){return m.MqttWill}}),e.MqttClient=class extends s.NativeResource{constructor(e=void 0){super(o.default.mqtt_client_new(e==null?null:e.native_handle())),this.bootstrap=e}new_connection(e){return new h(this,e)}};var h=class extends (0,s.NativeResourceMixin)(c.BufferedEventEmitter){constructor(e,t){if(super(),this.client=e,this.config=t,t==null||t==null)throw new u.CrtError(`MqttClientConnection constructor: config not defined`);let n=t.will?{topic:t.will.topic,qos:t.will.qos,payload:l.normalize_payload(t.will.payload),retain:t.will.retain}:void 0;var r=p.DEFAULT_RECONNECT_MIN_SEC,i=p.DEFAULT_RECONNECT_MAX_SEC;if(t.reconnect_min_sec&&(r=t.reconnect_min_sec,i=Math.max(r,i)),t.reconnect_max_sec&&(i=t.reconnect_max_sec,r=Math.min(r,i)),e==null||e==null)throw new u.CrtError(`MqttClientConnection constructor: client not defined`);if(t.socket_options==null||t.socket_options==null)throw new u.CrtError(`MqttClientConnection constructor: socket_options in configuration not defined`);this._super(o.default.mqtt_client_connection_new(e.native_handle(),e=>{this._on_connection_interrupted(e)},(e,t)=>{this._on_connection_resumed(e,t)},(e,t)=>{this._on_connection_success(e,t)},e=>{this._on_connection_failure(e)},t.tls_ctx?t.tls_ctx.native_handle():null,n,t.username,t.password,t.use_websocket,t.proxy_options?t.proxy_options.create_native_handle():void 0,t.websocket_handshake_transform,r,i)),this.tls_ctx=t.tls_ctx,o.default.mqtt_client_connection_on_message(this.native_handle(),this._on_any_publish.bind(this)),o.default.mqtt_client_connection_on_closed(this.native_handle(),this._on_connection_closed.bind(this)),this.on(`error`,e=>{})}close(){o.default.mqtt_client_connection_close(this.native_handle())}on(e,t){return super.on(e,t),e==`connect`&&process.nextTick(()=>{this.uncork()}),this}connect(){return i(this,void 0,void 0,function*(){return new Promise((e,t)=>{if(t=this._reject(t),this.config.socket_options==null||this.config.socket_options==null)throw new u.CrtError(`MqttClientConnection connect: socket_options in configuration not defined`);try{o.default.mqtt_client_connection_connect(this.native_handle(),this.config.client_id,this.config.host_name,this.config.port,this.config.socket_options.native_handle(),this.config.keep_alive,this.config.ping_timeout,this.config.protocol_operation_timeout,this.config.clean_session,this._on_connect_callback.bind(this,e,t))}catch(e){t(e)}})})}reconnect(){return i(this,void 0,void 0,function*(){return new Promise((e,t)=>{t=this._reject(t);try{o.default.mqtt_client_connection_reconnect(this.native_handle(),this._on_connect_callback.bind(this,e,t))}catch(e){t(e)}})})}publish(e,t,n,r=!1){return i(this,void 0,void 0,function*(){return typeof e==`string`?typeof n==`number`?typeof r==`boolean`?new Promise((i,a)=>{a=this._reject(a);try{o.default.mqtt_client_connection_publish(this.native_handle(),e,l.normalize_payload(t),n,r,this._on_puback_callback.bind(this,i,a))}catch(e){a(e)}}):Promise.reject(`retain is not a boolean`):Promise.reject(`qos is not a number`):Promise.reject(`topic is not a string`)})}subscribe(e,t,n){return i(this,void 0,void 0,function*(){return typeof e==`string`?typeof t==`number`?new Promise((r,i)=>{i=this._reject(i);try{o.default.mqtt_client_connection_subscribe(this.native_handle(),e,t,n,this._on_suback_callback.bind(this,r,i))}catch(e){i(e)}}):Promise.reject(`qos is not a number`):Promise.reject(`topic is not a string`)})}unsubscribe(e){return i(this,void 0,void 0,function*(){return typeof e==`string`?new Promise((t,n)=>{n=this._reject(n);try{o.default.mqtt_client_connection_unsubscribe(this.native_handle(),e,this._on_unsuback_callback.bind(this,t,n))}catch(e){n(e)}}):Promise.reject(`topic is not a string`)})}disconnect(){return i(this,void 0,void 0,function*(){return new Promise((e,t)=>{t=this._reject(t);try{o.default.mqtt_client_connection_disconnect(this.native_handle(),this._on_disconnect_callback.bind(this,e))}catch(e){t(e)}})})}getOperationalStatistics(){return o.default.mqtt_client_connection_get_queue_statistics(this.native_handle())}getQueueStatistics(){return this.getOperationalStatistics()}_reject(e){return t=>{e(t),process.nextTick(()=>{this.emit(`error`,new u.CrtError(t))})}}_on_connection_failure(e){let t={error:new u.CrtError(e)};this.emit(`connection_failure`,t)}_on_connection_success(e,t){let n={session_present:t,reason_code:e};this.emit(`connection_success`,n)}_on_connection_interrupted(e){this.emit(`interrupt`,new u.CrtError(e))}_on_connection_resumed(e,t){this.emit(`resume`,e,t)}_on_any_publish(e,t,n,r,i){this.emit(`message`,e,t,n,r,i)}_on_connection_closed(){this.emit(`closed`,{}),this.close()}_on_connect_callback(e,t,n,r,i){n==0&&r==0?(e(i),this.emit(`connect`,i)):t(n==0?`Server rejected connection.`:`Failed to connect: `+d.error_code_to_string(n))}_on_puback_callback(e,t,n,r){r==0?e({packet_id:n}):t(`Failed to publish: `+d.error_code_to_string(r))}_on_suback_callback(e,t,n,r,i,a){a==0?e({packet_id:n,topic:r,qos:i,error_code:a}):t(`Failed to subscribe: `+d.error_code_to_string(a))}_on_unsuback_callback(e,t,n,r){r==0?e({packet_id:n}):t(`Failed to unsubscribe: `+d.error_code_to_string(r))}_on_disconnect_callback(e){e(),this.emit(`disconnect`)}};e.MqttClientConnection=h,h.CONNECT=`connect`,h.DISCONNECT=`disconnect`,h.ERROR=`error`,h.INTERRUPT=`interrupt`,h.RESUME=`resume`,h.MESSAGE=`message`,h.CONNECTION_SUCCESS=`connection_success`,h.CONNECTION_FAILURE=`connection_failure`,h.CLOSED=`closed`})),dl=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.RequestResponseClientState=e.StreamingOperationState=void 0,(function(e){e[e.None=0]=`None`,e[e.Open=1]=`Open`,e[e.Closed=2]=`Closed`})(e.StreamingOperationState||={}),(function(e){e[e.Ready=0]=`Ready`,e[e.Closed=1]=`Closed`})(e.RequestResponseClientState||={})})),fl=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.SubscriptionStatusEventType=void 0,(function(e){e[e.SubscriptionEstablished=0]=`SubscriptionEstablished`,e[e.SubscriptionLost=1]=`SubscriptionLost`,e[e.SubscriptionHalted=2]=`SubscriptionHalted`})(e.SubscriptionStatusEventType||={})})),pl=u((e=>{var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__setModuleDefault||(Object.create?(function(e,t){Object.defineProperty(e,`default`,{enumerable:!0,value:t})}):function(e,t){e.default=t}),r=e&&e.__importStar||function(e){if(e&&e.__esModule)return e;var r={};if(e!=null)for(var i in e)i!==`default`&&Object.prototype.hasOwnProperty.call(e,i)&&t(r,e,i);return n(r,e),r},i=e&&e.__exportStar||function(e,n){for(var r in e)r!==`default`&&!Object.prototype.hasOwnProperty.call(n,r)&&t(n,e,r)},a=e&&e.__awaiter||function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})},o=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,`__esModule`,{value:!0}),e.RequestResponseClient=e.StreamingOperationBase=void 0;let s=Vc(),c=r(dl()),l=Hc(),u=Yc(),d=o(Bc()),f=Wc();i(fl(),e);var p=class e extends (0,l.NativeResourceMixin)(u.BufferedEventEmitter){static new(t,n){if(!t)throw new s.CrtError(`invalid configuration for streaming operation`);let r=new e(n);return r._super(d.default.mqtt_streaming_operation_new(r,n.native_handle(),t,(t,n,i)=>{e._s_on_subscription_status_update(r,n,i)},(t,n)=>{e._s_on_incoming_publish(r,n)})),n.registerUnclosedStreamingOperation(r),r}constructor(e){super(),this.state=c.StreamingOperationState.None,this.client=e}open(){if(this.state==c.StreamingOperationState.None)this.state=c.StreamingOperationState.Open,d.default.mqtt_streaming_operation_open(this.native_handle());else if(this.state==c.StreamingOperationState.Closed)throw new s.CrtError(`MQTT streaming operation already closed`)}close(){this.state!=c.StreamingOperationState.Closed&&(this.client.unregisterUnclosedStreamingOperation(this),this.state=c.StreamingOperationState.Closed,d.default.mqtt_streaming_operation_close(this.native_handle()))}on(e,t){return super.on(e,t),this}static _s_on_subscription_status_update(t,n,r){let i={type:n};r!=0&&(i.error=new s.CrtError(r)),process.nextTick(()=>{t.emit(e.SUBSCRIPTION_STATUS,i)})}static _s_on_incoming_publish(t,n){process.nextTick(()=>{t.emit(e.INCOMING_PUBLISH,n)})}};e.StreamingOperationBase=p,p.SUBSCRIPTION_STATUS=`subscriptionStatus`,p.INCOMING_PUBLISH=`incomingPublish`,e.RequestResponseClient=class e extends (0,l.NativeResourceMixin)(u.BufferedEventEmitter){constructor(){super(),this.state=c.RequestResponseClientState.Ready,this.unclosedOperations=new Set}static newFromMqtt5(t,n){if(!t)throw new s.CrtError(`protocol client is null`);let r=new e;return r._super(d.default.mqtt_request_response_client_new_from_5(r,t.native_handle(),n)),r}static newFromMqtt311(t,n){if(!t)throw new s.CrtError(`protocol client is null`);let r=new e;return r._super(d.default.mqtt_request_response_client_new_from_311(r,t.native_handle(),n)),r}close(){this.state!=c.RequestResponseClientState.Closed&&(this.state=c.RequestResponseClientState.Closed,this.closeStreamingOperations(),d.default.mqtt_request_response_client_close(this.native_handle()))}createStream(e){if(this.state==c.RequestResponseClientState.Closed)throw new s.CrtError(`MQTT request-response client has already been closed`);return p.new(e,this)}submitRequest(t){return a(this,void 0,void 0,function*(){return new Promise((n,r)=>{if(this.state==c.RequestResponseClientState.Closed){r(new s.CrtError(`MQTT request-response client has already been closed`));return}if(!t){r(new s.CrtError(`null request options`));return}function i(t,i,a){return e._s_on_request_completion(n,r,t,i,a)}try{d.default.mqtt_request_response_client_submit_request(this.native_handle(),t,i)}catch(e){r(e)}})})}registerUnclosedStreamingOperation(e){this.unclosedOperations&&this.unclosedOperations.add(e)}unregisterUnclosedStreamingOperation(e){this.unclosedOperations&&this.unclosedOperations.delete(e)}closeStreamingOperations(){if(this.unclosedOperations){let e=this.unclosedOperations;this.unclosedOperations=void 0;for(let t of e)t.close()}}static _s_on_request_completion(e,t,n,r,i){n==0&&r!==void 0&&i!==void 0?e({payload:i,topic:r}):t(new s.CrtError((0,f.error_code_to_string)(n)))}}})),ml=u((e=>{var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__setModuleDefault||(Object.create?(function(e,t){Object.defineProperty(e,`default`,{enumerable:!0,value:t})}):function(e,t){e.default=t}),r=e&&e.__importStar||function(e){if(e&&e.__esModule)return e;var r={};if(e!=null)for(var i in e)i!==`default`&&Object.prototype.hasOwnProperty.call(e,i)&&t(r,e,i);return n(r,e),r};Object.defineProperty(e,`__esModule`,{value:!0}),e.CrtError=e.resource_safety=e.promise=e.platform=e.mqtt_request_response=e.mqtt5=e.mqtt=e.iot=e.io=e.http=e.eventstream=e.crt=e.crypto=e.checksums=e.cancel=e.auth=void 0,e.cancel=r(Ic()),e.platform=r(Rc()),e.promise=r(Fc()),e.resource_safety=r(zc()),e.auth=r(Gc()),e.checksums=r(Kc()),e.crt=r(qc()),e.crypto=r(Jc()),e.eventstream=r(Zc()),e.http=r($c()),e.io=r(Wc()),e.iot=r(ll()),e.mqtt=r(ul()),e.mqtt5=r(sl()),e.mqtt_request_response=r(pl());let i=Vc();Object.defineProperty(e,`CrtError`,{enumerable:!0,get:function(){return i.CrtError}})})),hl=u(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.isCrtAvailable=void 0,e.isCrtAvailable=()=>{try{return typeof h==`function`&&t!==void 0&&ml()?[`md/crt-avail`]:null}catch{return null}}})),gl=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.defaultUserAgent=e.UA_APP_ID_INI_NAME=e.UA_APP_ID_ENV_NAME=void 0;let t=Ws(),n=h(`os`),r=h(`process`),i=hl();e.UA_APP_ID_ENV_NAME=`AWS_SDK_UA_APP_ID`,e.UA_APP_ID_INI_NAME=`sdk-ua-app-id`,e.defaultUserAgent=({serviceId:a,clientVersion:o})=>{let s=[[`aws-sdk-js`,o],[`os/${(0,n.platform)()}`,(0,n.release)()],[`lang/js`],[`md/nodejs`,`${r.versions.node}`]],c=(0,i.isCrtAvailable)();c&&s.push(c),a&&s.push([`api/${a}`,o]),r.env.AWS_EXECUTION_ENV&&s.push([`exec-env/${r.env.AWS_EXECUTION_ENV}`]);let l=(0,t.loadConfig)({environmentVariableSelector:t=>t[e.UA_APP_ID_ENV_NAME],configFileSelector:t=>t[e.UA_APP_ID_INI_NAME],default:void 0})(),u;return async()=>{if(!u){let e=await l;u=e?[...s,[`app/${e}`]]:[...s]}return u}}})),_l=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.fromBase64=void 0;let t=Xi(),n=/^[A-Za-z0-9+/]*={0,2}$/;e.fromBase64=e=>{if(e.length*3%4!=0)throw TypeError(`Incorrect padding on base64 string.`);if(!n.exec(e))throw TypeError(`Invalid base64 string.`);let r=(0,t.fromString)(e,`base64`);return new Uint8Array(r.buffer,r.byteOffset,r.byteLength)}})),vl=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.toBase64=void 0;let t=Xi();e.toBase64=e=>(0,t.fromArrayBuffer)(e.buffer,e.byteOffset,e.byteLength).toString(`base64`)})),yl=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=(N(),m(j));t.__exportStar(_l(),e),t.__exportStar(vl(),e)})),bl=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.ruleSet=void 0;let t=`required`,n=`argv`,r=`PartitionResult`,i=`tree`,a=`error`,o=`endpoint`,s={[t]:!1,type:`String`},c={[t]:!0,default:!1,type:`Boolean`},l={ref:`Endpoint`},u={fn:`booleanEquals`,[n]:[{ref:`UseFIPS`},!0]},d={fn:`booleanEquals`,[n]:[{ref:`UseDualStack`},!0]},f={},p={fn:`booleanEquals`,[n]:[!0,{fn:`getAttr`,[n]:[{ref:r},`supportsFIPS`]}]},m={fn:`booleanEquals`,[n]:[!0,{fn:`getAttr`,[n]:[{ref:r},`supportsDualStack`]}]},h=[l],g=[u],_=[d];e.ruleSet={version:`1.0`,parameters:{Region:s,UseDualStack:c,UseFIPS:c,Endpoint:s},rules:[{conditions:[{fn:`aws.partition`,[n]:[{ref:`Region`}],assign:r}],type:i,rules:[{conditions:[{fn:`isSet`,[n]:h},{fn:`parseURL`,[n]:h,assign:`url`}],type:i,rules:[{conditions:g,error:`Invalid Configuration: FIPS and custom endpoint are not supported`,type:a},{type:i,rules:[{conditions:_,error:`Invalid Configuration: Dualstack and custom endpoint are not supported`,type:a},{endpoint:{url:l,properties:f,headers:f},type:o}]}]},{conditions:[u,d],type:i,rules:[{conditions:[p,m],type:i,rules:[{endpoint:{url:`https://portal.sso-fips.{Region}.{PartitionResult#dualStackDnsSuffix}`,properties:f,headers:f},type:o}]},{error:`FIPS and DualStack are enabled, but this partition does not support one or both`,type:a}]},{conditions:g,type:i,rules:[{conditions:[p],type:i,rules:[{type:i,rules:[{endpoint:{url:`https://portal.sso-fips.{Region}.{PartitionResult#dnsSuffix}`,properties:f,headers:f},type:o}]}]},{error:`FIPS is enabled but this partition does not support FIPS`,type:a}]},{conditions:_,type:i,rules:[{conditions:[m],type:i,rules:[{endpoint:{url:`https://portal.sso.{Region}.{PartitionResult#dualStackDnsSuffix}`,properties:f,headers:f},type:o}]},{error:`DualStack is enabled but this partition does not support DualStack`,type:a}]},{endpoint:{url:`https://portal.sso.{Region}.{PartitionResult#dnsSuffix}`,properties:f,headers:f},type:o}]}]}})),xl=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.defaultEndpointResolver=void 0;let t=Xo(),n=bl();e.defaultEndpointResolver=(e,r={})=>(0,t.resolveEndpoint)(n.ruleSet,{endpointParams:e,logger:r.logger})})),Sl=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.getRuntimeConfig=void 0;let t=P(),n=Zt(),r=yl(),i=ea(),a=xl();e.getRuntimeConfig=e=>({apiVersion:`2019-06-10`,base64Decoder:e?.base64Decoder??r.fromBase64,base64Encoder:e?.base64Encoder??r.toBase64,disableHostPrefix:e?.disableHostPrefix??!1,endpointProvider:e?.endpointProvider??a.defaultEndpointResolver,logger:e?.logger??new t.NoOpLogger,serviceId:e?.serviceId??`SSO`,urlParser:e?.urlParser??n.parseUrl,utf8Decoder:e?.utf8Decoder??i.fromUtf8,utf8Encoder:e?.utf8Encoder??i.toUtf8})})),Cl=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.IMDS_REGION_PATH=e.DEFAULTS_MODE_OPTIONS=e.ENV_IMDS_DISABLED=e.AWS_DEFAULT_REGION_ENV=e.AWS_REGION_ENV=e.AWS_EXECUTION_ENV=void 0,e.AWS_EXECUTION_ENV=`AWS_EXECUTION_ENV`,e.AWS_REGION_ENV=`AWS_REGION`,e.AWS_DEFAULT_REGION_ENV=`AWS_DEFAULT_REGION`,e.ENV_IMDS_DISABLED=`AWS_EC2_METADATA_DISABLED`,e.DEFAULTS_MODE_OPTIONS=[`in-region`,`cross-region`,`mobile`,`standard`,`legacy`],e.IMDS_REGION_PATH=`/latest/meta-data/placement/region`})),wl=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.NODE_DEFAULTS_MODE_CONFIG_OPTIONS=void 0,e.NODE_DEFAULTS_MODE_CONFIG_OPTIONS={environmentVariableSelector:e=>e.AWS_DEFAULTS_MODE,configFileSelector:e=>e.defaults_mode,default:`legacy`}})),Tl=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.resolveDefaultsModeConfig=void 0;let t=Or(),n=ec(),r=Ws(),i=qi(),a=Cl(),o=wl();e.resolveDefaultsModeConfig=({region:e=(0,r.loadConfig)(t.NODE_REGION_CONFIG_OPTIONS),defaultsMode:n=(0,r.loadConfig)(o.NODE_DEFAULTS_MODE_CONFIG_OPTIONS)}={})=>(0,i.memoize)(async()=>{let t=typeof n==`function`?await n():n;switch(t?.toLowerCase()){case`auto`:return s(e);case`in-region`:case`cross-region`:case`mobile`:case`standard`:case`legacy`:return Promise.resolve(t?.toLocaleLowerCase());case void 0:return Promise.resolve(`legacy`);default:throw Error(`Invalid parameter for "defaultsMode", expect ${a.DEFAULTS_MODE_OPTIONS.join(`, `)}, got ${t}`)}});let s=async e=>{if(e){let t=typeof e==`function`?await e():e,n=await c();return n?t===n?`in-region`:`cross-region`:`standard`}return`standard`},c=async()=>{if(process.env[a.AWS_EXECUTION_ENV]&&(process.env[a.AWS_REGION_ENV]||process.env[a.AWS_DEFAULT_REGION_ENV]))return process.env[a.AWS_REGION_ENV]??process.env[a.AWS_DEFAULT_REGION_ENV];if(!process.env[a.ENV_IMDS_DISABLED])try{let e=await(0,n.getInstanceMetadataEndpoint)();return(await(0,n.httpRequest)({...e,path:a.IMDS_REGION_PATH})).toString()}catch{}}})),El=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),(N(),m(j)).__exportStar(Tl(),e)})),Dl=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.getRuntimeConfig=void 0;let t=(N(),m(j)).__importDefault(_c()),n=Or(),r=vc(),i=Bi(),a=Ws(),o=Mc(),s=Pc(),c=Wr(),l=gl(),u=Sl(),d=P(),f=El(),p=P();e.getRuntimeConfig=e=>{(0,p.emitWarningIfUnsupportedVersion)(process.version);let m=(0,f.resolveDefaultsModeConfig)(e),h=()=>m().then(d.loadConfigsForDefaultMode),g=(0,u.getRuntimeConfig)(e);return{...g,...e,runtime:`node`,defaultsMode:m,bodyLengthChecker:e?.bodyLengthChecker??s.calculateBodyLength,defaultUserAgentProvider:e?.defaultUserAgentProvider??(0,l.defaultUserAgent)({serviceId:g.serviceId,clientVersion:t.default.version}),maxAttempts:e?.maxAttempts??(0,a.loadConfig)(i.NODE_MAX_ATTEMPT_CONFIG_OPTIONS),region:e?.region??(0,a.loadConfig)(n.NODE_REGION_CONFIG_OPTIONS,n.NODE_REGION_CONFIG_FILE_OPTIONS),requestHandler:e?.requestHandler??new o.NodeHttpHandler(h),retryMode:e?.retryMode??(0,a.loadConfig)({...i.NODE_RETRY_MODE_CONFIG_OPTIONS,default:async()=>(await h()).retryMode||c.DEFAULT_RETRY_MODE}),sha256:e?.sha256??r.Hash.bind(null,`sha256`),streamCollector:e?.streamCollector??o.streamCollector,useDualstackEndpoint:e?.useDualstackEndpoint??(0,a.loadConfig)(n.NODE_USE_DUALSTACK_ENDPOINT_CONFIG_OPTIONS),useFipsEndpoint:e?.useFipsEndpoint??(0,a.loadConfig)(n.NODE_USE_FIPS_ENDPOINT_CONFIG_OPTIONS)}}})),Ol=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.SSOClient=void 0;let t=Or(),n=kr(),r=L(),i=Z(),a=jr(),o=Mr(),s=Bi(),c=$o(),l=P(),u=gc(),d=Dl();e.SSOClient=class extends l.Client{constructor(e){let l=(0,d.getRuntimeConfig)(e),f=(0,u.resolveClientEndpointParameters)(l),p=(0,t.resolveRegionConfig)(f),m=(0,r.resolveEndpointConfig)(p),h=(0,s.resolveRetryConfig)(m),g=(0,i.resolveHostHeaderConfig)(h),_=(0,c.resolveUserAgentConfig)(g);super(_),this.config=_,this.middlewareStack.use((0,s.getRetryPlugin)(this.config)),this.middlewareStack.use((0,n.getContentLengthPlugin)(this.config)),this.middlewareStack.use((0,i.getHostHeaderPlugin)(this.config)),this.middlewareStack.use((0,a.getLoggerPlugin)(this.config)),this.middlewareStack.use((0,o.getRecursionDetectionPlugin)(this.config)),this.middlewareStack.use((0,c.getUserAgentPlugin)(this.config))}destroy(){super.destroy()}}})),kl=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.SSO=void 0;let t=P(),n=fc(),r=pc(),i=mc(),a=hc(),o=Ol(),s={GetRoleCredentialsCommand:n.GetRoleCredentialsCommand,ListAccountRolesCommand:r.ListAccountRolesCommand,ListAccountsCommand:i.ListAccountsCommand,LogoutCommand:a.LogoutCommand};var c=class extends o.SSOClient{};e.SSO=c,(0,t.createAggregatedClient)(s,c)})),Al=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=(N(),m(j));t.__exportStar(fc(),e),t.__exportStar(pc(),e),t.__exportStar(mc(),e),t.__exportStar(hc(),e)})),jl=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),(N(),m(j)).__exportStar(uc(),e)})),Ml=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0})})),Nl=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.paginateListAccountRoles=void 0;let t=pc(),n=Ol(),r=async(e,n,...r)=>await e.send(new t.ListAccountRolesCommand(n),...r);async function*i(e,t,...i){let a=e.startingToken||void 0,o=!0,s;for(;o;){if(t.nextToken=a,t.maxResults=e.pageSize,e.client instanceof n.SSOClient)s=await r(e.client,t,...i);else throw Error(`Invalid client, expected SSO | SSOClient`);yield s;let c=a;a=s.nextToken,o=!!(a&&(!e.stopOnSameToken||a!==c))}return void 0}e.paginateListAccountRoles=i})),Pl=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.paginateListAccounts=void 0;let t=mc(),n=Ol(),r=async(e,n,...r)=>await e.send(new t.ListAccountsCommand(n),...r);async function*i(e,t,...i){let a=e.startingToken||void 0,o=!0,s;for(;o;){if(t.nextToken=a,t.maxResults=e.pageSize,e.client instanceof n.SSOClient)s=await r(e.client,t,...i);else throw Error(`Invalid client, expected SSO | SSOClient`);yield s;let c=a;a=s.nextToken,o=!!(a&&(!e.stopOnSameToken||a!==c))}return void 0}e.paginateListAccounts=i})),Fl=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=(N(),m(j));t.__exportStar(Ml(),e),t.__exportStar(Nl(),e),t.__exportStar(Pl(),e)})),Il=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.SSOServiceException=void 0;let t=(N(),m(j));t.__exportStar(kl(),e),t.__exportStar(Ol(),e),t.__exportStar(Al(),e),t.__exportStar(jl(),e),t.__exportStar(Fl(),e);var n=lc();Object.defineProperty(e,`SSOServiceException`,{enumerable:!0,get:function(){return n.SSOServiceException}})})),Ll=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.REFRESH_MESSAGE=e.EXPIRE_WINDOW_MS=void 0,e.EXPIRE_WINDOW_MS=300*1e3,e.REFRESH_MESSAGE=`To refresh this SSO session run 'aws sso login' with the corresponding profile.`})),Rl=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.SSOOIDCServiceException=void 0;let t=P();e.SSOOIDCServiceException=class e extends t.ServiceException{constructor(t){super(t),Object.setPrototypeOf(this,e.prototype)}}})),zl=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.InvalidClientMetadataException=e.UnsupportedGrantTypeException=e.UnauthorizedClientException=e.SlowDownException=e.InvalidScopeException=e.InvalidRequestException=e.InvalidGrantException=e.InvalidClientException=e.InternalServerException=e.ExpiredTokenException=e.AuthorizationPendingException=e.AccessDeniedException=void 0;let t=Rl();e.AccessDeniedException=class e extends t.SSOOIDCServiceException{constructor(t){super({name:`AccessDeniedException`,$fault:`client`,...t}),this.name=`AccessDeniedException`,this.$fault=`client`,Object.setPrototypeOf(this,e.prototype),this.error=t.error,this.error_description=t.error_description}},e.AuthorizationPendingException=class e extends t.SSOOIDCServiceException{constructor(t){super({name:`AuthorizationPendingException`,$fault:`client`,...t}),this.name=`AuthorizationPendingException`,this.$fault=`client`,Object.setPrototypeOf(this,e.prototype),this.error=t.error,this.error_description=t.error_description}},e.ExpiredTokenException=class e extends t.SSOOIDCServiceException{constructor(t){super({name:`ExpiredTokenException`,$fault:`client`,...t}),this.name=`ExpiredTokenException`,this.$fault=`client`,Object.setPrototypeOf(this,e.prototype),this.error=t.error,this.error_description=t.error_description}},e.InternalServerException=class e extends t.SSOOIDCServiceException{constructor(t){super({name:`InternalServerException`,$fault:`server`,...t}),this.name=`InternalServerException`,this.$fault=`server`,Object.setPrototypeOf(this,e.prototype),this.error=t.error,this.error_description=t.error_description}},e.InvalidClientException=class e extends t.SSOOIDCServiceException{constructor(t){super({name:`InvalidClientException`,$fault:`client`,...t}),this.name=`InvalidClientException`,this.$fault=`client`,Object.setPrototypeOf(this,e.prototype),this.error=t.error,this.error_description=t.error_description}},e.InvalidGrantException=class e extends t.SSOOIDCServiceException{constructor(t){super({name:`InvalidGrantException`,$fault:`client`,...t}),this.name=`InvalidGrantException`,this.$fault=`client`,Object.setPrototypeOf(this,e.prototype),this.error=t.error,this.error_description=t.error_description}},e.InvalidRequestException=class e extends t.SSOOIDCServiceException{constructor(t){super({name:`InvalidRequestException`,$fault:`client`,...t}),this.name=`InvalidRequestException`,this.$fault=`client`,Object.setPrototypeOf(this,e.prototype),this.error=t.error,this.error_description=t.error_description}},e.InvalidScopeException=class e extends t.SSOOIDCServiceException{constructor(t){super({name:`InvalidScopeException`,$fault:`client`,...t}),this.name=`InvalidScopeException`,this.$fault=`client`,Object.setPrototypeOf(this,e.prototype),this.error=t.error,this.error_description=t.error_description}},e.SlowDownException=class e extends t.SSOOIDCServiceException{constructor(t){super({name:`SlowDownException`,$fault:`client`,...t}),this.name=`SlowDownException`,this.$fault=`client`,Object.setPrototypeOf(this,e.prototype),this.error=t.error,this.error_description=t.error_description}},e.UnauthorizedClientException=class e extends t.SSOOIDCServiceException{constructor(t){super({name:`UnauthorizedClientException`,$fault:`client`,...t}),this.name=`UnauthorizedClientException`,this.$fault=`client`,Object.setPrototypeOf(this,e.prototype),this.error=t.error,this.error_description=t.error_description}},e.UnsupportedGrantTypeException=class e extends t.SSOOIDCServiceException{constructor(t){super({name:`UnsupportedGrantTypeException`,$fault:`client`,...t}),this.name=`UnsupportedGrantTypeException`,this.$fault=`client`,Object.setPrototypeOf(this,e.prototype),this.error=t.error,this.error_description=t.error_description}},e.InvalidClientMetadataException=class e extends t.SSOOIDCServiceException{constructor(t){super({name:`InvalidClientMetadataException`,$fault:`client`,...t}),this.name=`InvalidClientMetadataException`,this.$fault=`client`,Object.setPrototypeOf(this,e.prototype),this.error=t.error,this.error_description=t.error_description}}})),Bl=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.de_StartDeviceAuthorizationCommand=e.de_RegisterClientCommand=e.de_CreateTokenCommand=e.se_StartDeviceAuthorizationCommand=e.se_RegisterClientCommand=e.se_CreateTokenCommand=void 0;let t=gn(),n=P(),r=zl(),i=Rl();e.se_CreateTokenCommand=async(e,r)=>{let{hostname:i,protocol:a=`https`,port:o,path:s}=await r.endpoint(),c={"content-type":`application/json`},l=`${s?.endsWith(`/`)?s.slice(0,-1):s||``}/token`,u;return u=JSON.stringify((0,n.take)(e,{clientId:[],clientSecret:[],code:[],deviceCode:[],grantType:[],redirectUri:[],refreshToken:[],scope:e=>(0,n._json)(e)})),new t.HttpRequest({protocol:a,hostname:i,port:o,method:`POST`,headers:c,path:l,body:u})},e.se_RegisterClientCommand=async(e,r)=>{let{hostname:i,protocol:a=`https`,port:o,path:s}=await r.endpoint(),c={"content-type":`application/json`},l=`${s?.endsWith(`/`)?s.slice(0,-1):s||``}/client/register`,u;return u=JSON.stringify((0,n.take)(e,{clientName:[],clientType:[],scopes:e=>(0,n._json)(e)})),new t.HttpRequest({protocol:a,hostname:i,port:o,method:`POST`,headers:c,path:l,body:u})},e.se_StartDeviceAuthorizationCommand=async(e,r)=>{let{hostname:i,protocol:a=`https`,port:o,path:s}=await r.endpoint(),c={"content-type":`application/json`},l=`${s?.endsWith(`/`)?s.slice(0,-1):s||``}/device_authorization`,u;return u=JSON.stringify((0,n.take)(e,{clientId:[],clientSecret:[],startUrl:[]})),new t.HttpRequest({protocol:a,hostname:i,port:o,method:`POST`,headers:c,path:l,body:u})},e.de_CreateTokenCommand=async(e,t)=>{if(e.statusCode!==200&&e.statusCode>=300)return a(e,t);let r=(0,n.map)({$metadata:x(e)}),i=(0,n.expectNonNull)((0,n.expectObject)(await w(e.body,t)),`body`),o=(0,n.take)(i,{accessToken:n.expectString,expiresIn:n.expectInt32,idToken:n.expectString,refreshToken:n.expectString,tokenType:n.expectString});return Object.assign(r,o),r};let a=async(e,t)=>{let n={...e,body:await ee(e.body,t)},r=te(e,n.body);switch(r){case`AccessDeniedException`:case`com.amazonaws.ssooidc#AccessDeniedException`:throw await l(n,t);case`AuthorizationPendingException`:case`com.amazonaws.ssooidc#AuthorizationPendingException`:throw await u(n,t);case`ExpiredTokenException`:case`com.amazonaws.ssooidc#ExpiredTokenException`:throw await d(n,t);case`InternalServerException`:case`com.amazonaws.ssooidc#InternalServerException`:throw await f(n,t);case`InvalidClientException`:case`com.amazonaws.ssooidc#InvalidClientException`:throw await p(n,t);case`InvalidGrantException`:case`com.amazonaws.ssooidc#InvalidGrantException`:throw await h(n,t);case`InvalidRequestException`:case`com.amazonaws.ssooidc#InvalidRequestException`:throw await g(n,t);case`InvalidScopeException`:case`com.amazonaws.ssooidc#InvalidScopeException`:throw await _(n,t);case`SlowDownException`:case`com.amazonaws.ssooidc#SlowDownException`:throw await v(n,t);case`UnauthorizedClientException`:case`com.amazonaws.ssooidc#UnauthorizedClientException`:throw await y(n,t);case`UnsupportedGrantTypeException`:case`com.amazonaws.ssooidc#UnsupportedGrantTypeException`:throw await b(n,t);default:let i=n.body;return c({output:e,parsedBody:i,errorCode:r})}};e.de_RegisterClientCommand=async(e,t)=>{if(e.statusCode!==200&&e.statusCode>=300)return o(e,t);let r=(0,n.map)({$metadata:x(e)}),i=(0,n.expectNonNull)((0,n.expectObject)(await w(e.body,t)),`body`),a=(0,n.take)(i,{authorizationEndpoint:n.expectString,clientId:n.expectString,clientIdIssuedAt:n.expectLong,clientSecret:n.expectString,clientSecretExpiresAt:n.expectLong,tokenEndpoint:n.expectString});return Object.assign(r,a),r};let o=async(e,t)=>{let n={...e,body:await ee(e.body,t)},r=te(e,n.body);switch(r){case`InternalServerException`:case`com.amazonaws.ssooidc#InternalServerException`:throw await f(n,t);case`InvalidClientMetadataException`:case`com.amazonaws.ssooidc#InvalidClientMetadataException`:throw await m(n,t);case`InvalidRequestException`:case`com.amazonaws.ssooidc#InvalidRequestException`:throw await g(n,t);case`InvalidScopeException`:case`com.amazonaws.ssooidc#InvalidScopeException`:throw await _(n,t);default:let i=n.body;return c({output:e,parsedBody:i,errorCode:r})}};e.de_StartDeviceAuthorizationCommand=async(e,t)=>{if(e.statusCode!==200&&e.statusCode>=300)return s(e,t);let r=(0,n.map)({$metadata:x(e)}),i=(0,n.expectNonNull)((0,n.expectObject)(await w(e.body,t)),`body`),a=(0,n.take)(i,{deviceCode:n.expectString,expiresIn:n.expectInt32,interval:n.expectInt32,userCode:n.expectString,verificationUri:n.expectString,verificationUriComplete:n.expectString});return Object.assign(r,a),r};let s=async(e,t)=>{let n={...e,body:await ee(e.body,t)},r=te(e,n.body);switch(r){case`InternalServerException`:case`com.amazonaws.ssooidc#InternalServerException`:throw await f(n,t);case`InvalidClientException`:case`com.amazonaws.ssooidc#InvalidClientException`:throw await p(n,t);case`InvalidRequestException`:case`com.amazonaws.ssooidc#InvalidRequestException`:throw await g(n,t);case`SlowDownException`:case`com.amazonaws.ssooidc#SlowDownException`:throw await v(n,t);case`UnauthorizedClientException`:case`com.amazonaws.ssooidc#UnauthorizedClientException`:throw await y(n,t);default:let i=n.body;return c({output:e,parsedBody:i,errorCode:r})}},c=(0,n.withBaseException)(i.SSOOIDCServiceException),l=async(e,t)=>{let i=(0,n.map)({}),a=e.body,o=(0,n.take)(a,{error:n.expectString,error_description:n.expectString});Object.assign(i,o);let s=new r.AccessDeniedException({$metadata:x(e),...i});return(0,n.decorateServiceException)(s,e.body)},u=async(e,t)=>{let i=(0,n.map)({}),a=e.body,o=(0,n.take)(a,{error:n.expectString,error_description:n.expectString});Object.assign(i,o);let s=new r.AuthorizationPendingException({$metadata:x(e),...i});return(0,n.decorateServiceException)(s,e.body)},d=async(e,t)=>{let i=(0,n.map)({}),a=e.body,o=(0,n.take)(a,{error:n.expectString,error_description:n.expectString});Object.assign(i,o);let s=new r.ExpiredTokenException({$metadata:x(e),...i});return(0,n.decorateServiceException)(s,e.body)},f=async(e,t)=>{let i=(0,n.map)({}),a=e.body,o=(0,n.take)(a,{error:n.expectString,error_description:n.expectString});Object.assign(i,o);let s=new r.InternalServerException({$metadata:x(e),...i});return(0,n.decorateServiceException)(s,e.body)},p=async(e,t)=>{let i=(0,n.map)({}),a=e.body,o=(0,n.take)(a,{error:n.expectString,error_description:n.expectString});Object.assign(i,o);let s=new r.InvalidClientException({$metadata:x(e),...i});return(0,n.decorateServiceException)(s,e.body)},m=async(e,t)=>{let i=(0,n.map)({}),a=e.body,o=(0,n.take)(a,{error:n.expectString,error_description:n.expectString});Object.assign(i,o);let s=new r.InvalidClientMetadataException({$metadata:x(e),...i});return(0,n.decorateServiceException)(s,e.body)},h=async(e,t)=>{let i=(0,n.map)({}),a=e.body,o=(0,n.take)(a,{error:n.expectString,error_description:n.expectString});Object.assign(i,o);let s=new r.InvalidGrantException({$metadata:x(e),...i});return(0,n.decorateServiceException)(s,e.body)},g=async(e,t)=>{let i=(0,n.map)({}),a=e.body,o=(0,n.take)(a,{error:n.expectString,error_description:n.expectString});Object.assign(i,o);let s=new r.InvalidRequestException({$metadata:x(e),...i});return(0,n.decorateServiceException)(s,e.body)},_=async(e,t)=>{let i=(0,n.map)({}),a=e.body,o=(0,n.take)(a,{error:n.expectString,error_description:n.expectString});Object.assign(i,o);let s=new r.InvalidScopeException({$metadata:x(e),...i});return(0,n.decorateServiceException)(s,e.body)},v=async(e,t)=>{let i=(0,n.map)({}),a=e.body,o=(0,n.take)(a,{error:n.expectString,error_description:n.expectString});Object.assign(i,o);let s=new r.SlowDownException({$metadata:x(e),...i});return(0,n.decorateServiceException)(s,e.body)},y=async(e,t)=>{let i=(0,n.map)({}),a=e.body,o=(0,n.take)(a,{error:n.expectString,error_description:n.expectString});Object.assign(i,o);let s=new r.UnauthorizedClientException({$metadata:x(e),...i});return(0,n.decorateServiceException)(s,e.body)},b=async(e,t)=>{let i=(0,n.map)({}),a=e.body,o=(0,n.take)(a,{error:n.expectString,error_description:n.expectString});Object.assign(i,o);let s=new r.UnsupportedGrantTypeException({$metadata:x(e),...i});return(0,n.decorateServiceException)(s,e.body)},x=e=>({httpStatusCode:e.statusCode,requestId:e.headers[`x-amzn-requestid`]??e.headers[`x-amzn-request-id`]??e.headers[`x-amz-request-id`],extendedRequestId:e.headers[`x-amz-id-2`],cfId:e.headers[`x-amz-cf-id`]}),S=(e=new Uint8Array,t)=>e instanceof Uint8Array?Promise.resolve(e):t.streamCollector(e)||Promise.resolve(new Uint8Array),C=(e,t)=>S(e,t).then(e=>t.utf8Encoder(e)),w=(e,t)=>C(e,t).then(e=>e.length?JSON.parse(e):{}),ee=async(e,t)=>{let n=await w(e,t);return n.message=n.message??n.Message,n},te=(e,t)=>{let n=(e,t)=>Object.keys(e).find(e=>e.toLowerCase()===t.toLowerCase()),r=e=>{let t=e;return typeof t==`number`&&(t=t.toString()),t.indexOf(`,`)>=0&&(t=t.split(`,`)[0]),t.indexOf(`:`)>=0&&(t=t.split(`:`)[0]),t.indexOf(`#`)>=0&&(t=t.split(`#`)[1]),t},i=n(e.headers,`x-amzn-errortype`);if(i!==void 0)return r(e.headers[i]);if(t.code!==void 0)return r(t.code);if(t.__type!==void 0)return r(t.__type)}})),Vl=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.CreateTokenCommand=void 0;let t=L(),n=F(),r=P(),i=Bl();e.CreateTokenCommand=class e extends r.Command{static getEndpointParameterInstructions(){return{UseFIPS:{type:`builtInParams`,name:`useFipsEndpoint`},Endpoint:{type:`builtInParams`,name:`endpoint`},Region:{type:`builtInParams`,name:`region`},UseDualStack:{type:`builtInParams`,name:`useDualstackEndpoint`}}}constructor(e){super(),this.input=e}resolveMiddleware(r,i,a){this.middlewareStack.use((0,n.getSerdePlugin)(i,this.serialize,this.deserialize)),this.middlewareStack.use((0,t.getEndpointPlugin)(i,e.getEndpointParameterInstructions()));let o=r.concat(this.middlewareStack),{logger:s}=i,c={logger:s,clientName:`SSOOIDCClient`,commandName:`CreateTokenCommand`,inputFilterSensitiveLog:e=>e,outputFilterSensitiveLog:e=>e},{requestHandler:l}=i;return o.resolve(e=>l.handle(e.request,a||{}),c)}serialize(e,t){return(0,i.se_CreateTokenCommand)(e,t)}deserialize(e,t){return(0,i.de_CreateTokenCommand)(e,t)}}})),Hl=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.RegisterClientCommand=void 0;let t=L(),n=F(),r=P(),i=Bl();e.RegisterClientCommand=class e extends r.Command{static getEndpointParameterInstructions(){return{UseFIPS:{type:`builtInParams`,name:`useFipsEndpoint`},Endpoint:{type:`builtInParams`,name:`endpoint`},Region:{type:`builtInParams`,name:`region`},UseDualStack:{type:`builtInParams`,name:`useDualstackEndpoint`}}}constructor(e){super(),this.input=e}resolveMiddleware(r,i,a){this.middlewareStack.use((0,n.getSerdePlugin)(i,this.serialize,this.deserialize)),this.middlewareStack.use((0,t.getEndpointPlugin)(i,e.getEndpointParameterInstructions()));let o=r.concat(this.middlewareStack),{logger:s}=i,c={logger:s,clientName:`SSOOIDCClient`,commandName:`RegisterClientCommand`,inputFilterSensitiveLog:e=>e,outputFilterSensitiveLog:e=>e},{requestHandler:l}=i;return o.resolve(e=>l.handle(e.request,a||{}),c)}serialize(e,t){return(0,i.se_RegisterClientCommand)(e,t)}deserialize(e,t){return(0,i.de_RegisterClientCommand)(e,t)}}})),Ul=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.StartDeviceAuthorizationCommand=void 0;let t=L(),n=F(),r=P(),i=Bl();e.StartDeviceAuthorizationCommand=class e extends r.Command{static getEndpointParameterInstructions(){return{UseFIPS:{type:`builtInParams`,name:`useFipsEndpoint`},Endpoint:{type:`builtInParams`,name:`endpoint`},Region:{type:`builtInParams`,name:`region`},UseDualStack:{type:`builtInParams`,name:`useDualstackEndpoint`}}}constructor(e){super(),this.input=e}resolveMiddleware(r,i,a){this.middlewareStack.use((0,n.getSerdePlugin)(i,this.serialize,this.deserialize)),this.middlewareStack.use((0,t.getEndpointPlugin)(i,e.getEndpointParameterInstructions()));let o=r.concat(this.middlewareStack),{logger:s}=i,c={logger:s,clientName:`SSOOIDCClient`,commandName:`StartDeviceAuthorizationCommand`,inputFilterSensitiveLog:e=>e,outputFilterSensitiveLog:e=>e},{requestHandler:l}=i;return o.resolve(e=>l.handle(e.request,a||{}),c)}serialize(e,t){return(0,i.se_StartDeviceAuthorizationCommand)(e,t)}deserialize(e,t){return(0,i.de_StartDeviceAuthorizationCommand)(e,t)}}})),Wl=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.resolveClientEndpointParameters=void 0,e.resolveClientEndpointParameters=e=>({...e,useDualstackEndpoint:e.useDualstackEndpoint??!1,useFipsEndpoint:e.useFipsEndpoint??!1,defaultSigningName:`awsssooidc`})})),Gl=u(((e,t)=>{t.exports={name:`@aws-sdk/client-sso-oidc`,description:`AWS SDK for JavaScript Sso Oidc Client for Node.js, Browser and React Native`,version:`3.329.0`,scripts:{build:`concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types'`,"build:cjs":`tsc -p tsconfig.cjs.json`,"build:docs":`typedoc`,"build:es":`tsc -p tsconfig.es.json`,"build:include:deps":`lerna run --scope $npm_package_name --include-dependencies build`,"build:types":`tsc -p tsconfig.types.json`,"build:types:downlevel":`downlevel-dts dist-types dist-types/ts3.4`,clean:`rimraf ./dist-* && rimraf *.tsbuildinfo`,"extract:docs":`api-extractor run --local`,"generate:client":`node ../../scripts/generate-clients/single-service --solo sso-oidc`},main:`./dist-cjs/index.js`,types:`./dist-types/index.d.ts`,module:`./dist-es/index.js`,sideEffects:!1,dependencies:{"@aws-crypto/sha256-browser":`3.0.0`,"@aws-crypto/sha256-js":`3.0.0`,"@aws-sdk/config-resolver":`3.329.0`,"@aws-sdk/fetch-http-handler":`3.329.0`,"@aws-sdk/hash-node":`3.329.0`,"@aws-sdk/invalid-dependency":`3.329.0`,"@aws-sdk/middleware-content-length":`3.329.0`,"@aws-sdk/middleware-endpoint":`3.329.0`,"@aws-sdk/middleware-host-header":`3.329.0`,"@aws-sdk/middleware-logger":`3.329.0`,"@aws-sdk/middleware-recursion-detection":`3.329.0`,"@aws-sdk/middleware-retry":`3.329.0`,"@aws-sdk/middleware-serde":`3.329.0`,"@aws-sdk/middleware-stack":`3.329.0`,"@aws-sdk/middleware-user-agent":`3.329.0`,"@aws-sdk/node-config-provider":`3.329.0`,"@aws-sdk/node-http-handler":`3.329.0`,"@aws-sdk/protocol-http":`3.329.0`,"@aws-sdk/smithy-client":`3.329.0`,"@aws-sdk/types":`3.329.0`,"@aws-sdk/url-parser":`3.329.0`,"@aws-sdk/util-base64":`3.310.0`,"@aws-sdk/util-body-length-browser":`3.310.0`,"@aws-sdk/util-body-length-node":`3.310.0`,"@aws-sdk/util-defaults-mode-browser":`3.329.0`,"@aws-sdk/util-defaults-mode-node":`3.329.0`,"@aws-sdk/util-endpoints":`3.329.0`,"@aws-sdk/util-retry":`3.329.0`,"@aws-sdk/util-user-agent-browser":`3.329.0`,"@aws-sdk/util-user-agent-node":`3.329.0`,"@aws-sdk/util-utf8":`3.310.0`,tslib:`^2.5.0`},devDependencies:{"@aws-sdk/service-client-documentation-generator":`3.310.0`,"@tsconfig/node14":`1.0.3`,"@types/node":`^14.14.31`,concurrently:`7.0.0`,"downlevel-dts":`0.10.1`,rimraf:`3.0.2`,typedoc:`0.23.23`,typescript:`~4.9.5`},engines:{node:`>=14.0.0`},typesVersions:{"<4.0":{"dist-types/*":[`dist-types/ts3.4/*`]}},files:[`dist-*/**`],author:{name:`AWS SDK for JavaScript Team`,url:`https://aws.amazon.com/javascript/`},license:`Apache-2.0`,browser:{"./dist-es/runtimeConfig":`./dist-es/runtimeConfig.browser`},"react-native":{"./dist-es/runtimeConfig":`./dist-es/runtimeConfig.native`},homepage:`https://github.com/aws/aws-sdk-js-v3/tree/main/clients/client-sso-oidc`,repository:{type:`git`,url:`https://github.com/aws/aws-sdk-js-v3.git`,directory:`clients/client-sso-oidc`}}})),Kl=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.ruleSet=void 0;let t=`required`,n=`argv`,r=`PartitionResult`,i=`tree`,a=`error`,o=`endpoint`,s={[t]:!1,type:`String`},c={[t]:!0,default:!1,type:`Boolean`},l={ref:`Endpoint`},u={fn:`booleanEquals`,[n]:[{ref:`UseFIPS`},!0]},d={fn:`booleanEquals`,[n]:[{ref:`UseDualStack`},!0]},f={},p={fn:`booleanEquals`,[n]:[!0,{fn:`getAttr`,[n]:[{ref:r},`supportsFIPS`]}]},m={fn:`booleanEquals`,[n]:[!0,{fn:`getAttr`,[n]:[{ref:r},`supportsDualStack`]}]},h=[l],g=[u],_=[d];e.ruleSet={version:`1.0`,parameters:{Region:s,UseDualStack:c,UseFIPS:c,Endpoint:s},rules:[{conditions:[{fn:`aws.partition`,[n]:[{ref:`Region`}],assign:r}],type:i,rules:[{conditions:[{fn:`isSet`,[n]:h},{fn:`parseURL`,[n]:h,assign:`url`}],type:i,rules:[{conditions:g,error:`Invalid Configuration: FIPS and custom endpoint are not supported`,type:a},{type:i,rules:[{conditions:_,error:`Invalid Configuration: Dualstack and custom endpoint are not supported`,type:a},{endpoint:{url:l,properties:f,headers:f},type:o}]}]},{conditions:[u,d],type:i,rules:[{conditions:[p,m],type:i,rules:[{endpoint:{url:`https://oidc-fips.{Region}.{PartitionResult#dualStackDnsSuffix}`,properties:f,headers:f},type:o}]},{error:`FIPS and DualStack are enabled, but this partition does not support one or both`,type:a}]},{conditions:g,type:i,rules:[{conditions:[p],type:i,rules:[{type:i,rules:[{endpoint:{url:`https://oidc-fips.{Region}.{PartitionResult#dnsSuffix}`,properties:f,headers:f},type:o}]}]},{error:`FIPS is enabled but this partition does not support FIPS`,type:a}]},{conditions:_,type:i,rules:[{conditions:[m],type:i,rules:[{endpoint:{url:`https://oidc.{Region}.{PartitionResult#dualStackDnsSuffix}`,properties:f,headers:f},type:o}]},{error:`DualStack is enabled but this partition does not support DualStack`,type:a}]},{endpoint:{url:`https://oidc.{Region}.{PartitionResult#dnsSuffix}`,properties:f,headers:f},type:o}]}]}})),ql=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.defaultEndpointResolver=void 0;let t=Xo(),n=Kl();e.defaultEndpointResolver=(e,r={})=>(0,t.resolveEndpoint)(n.ruleSet,{endpointParams:e,logger:r.logger})})),Jl=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.getRuntimeConfig=void 0;let t=P(),n=Zt(),r=yl(),i=ea(),a=ql();e.getRuntimeConfig=e=>({apiVersion:`2019-06-10`,base64Decoder:e?.base64Decoder??r.fromBase64,base64Encoder:e?.base64Encoder??r.toBase64,disableHostPrefix:e?.disableHostPrefix??!1,endpointProvider:e?.endpointProvider??a.defaultEndpointResolver,logger:e?.logger??new t.NoOpLogger,serviceId:e?.serviceId??`SSO OIDC`,urlParser:e?.urlParser??n.parseUrl,utf8Decoder:e?.utf8Decoder??i.fromUtf8,utf8Encoder:e?.utf8Encoder??i.toUtf8})})),Yl=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.getRuntimeConfig=void 0;let t=(N(),m(j)).__importDefault(Gl()),n=Or(),r=vc(),i=Bi(),a=Ws(),o=Mc(),s=Pc(),c=Wr(),l=gl(),u=Jl(),d=P(),f=El(),p=P();e.getRuntimeConfig=e=>{(0,p.emitWarningIfUnsupportedVersion)(process.version);let m=(0,f.resolveDefaultsModeConfig)(e),h=()=>m().then(d.loadConfigsForDefaultMode),g=(0,u.getRuntimeConfig)(e);return{...g,...e,runtime:`node`,defaultsMode:m,bodyLengthChecker:e?.bodyLengthChecker??s.calculateBodyLength,defaultUserAgentProvider:e?.defaultUserAgentProvider??(0,l.defaultUserAgent)({serviceId:g.serviceId,clientVersion:t.default.version}),maxAttempts:e?.maxAttempts??(0,a.loadConfig)(i.NODE_MAX_ATTEMPT_CONFIG_OPTIONS),region:e?.region??(0,a.loadConfig)(n.NODE_REGION_CONFIG_OPTIONS,n.NODE_REGION_CONFIG_FILE_OPTIONS),requestHandler:e?.requestHandler??new o.NodeHttpHandler(h),retryMode:e?.retryMode??(0,a.loadConfig)({...i.NODE_RETRY_MODE_CONFIG_OPTIONS,default:async()=>(await h()).retryMode||c.DEFAULT_RETRY_MODE}),sha256:e?.sha256??r.Hash.bind(null,`sha256`),streamCollector:e?.streamCollector??o.streamCollector,useDualstackEndpoint:e?.useDualstackEndpoint??(0,a.loadConfig)(n.NODE_USE_DUALSTACK_ENDPOINT_CONFIG_OPTIONS),useFipsEndpoint:e?.useFipsEndpoint??(0,a.loadConfig)(n.NODE_USE_FIPS_ENDPOINT_CONFIG_OPTIONS)}}})),Xl=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.SSOOIDCClient=void 0;let t=Or(),n=kr(),r=L(),i=Z(),a=jr(),o=Mr(),s=Bi(),c=$o(),l=P(),u=Wl(),d=Yl();e.SSOOIDCClient=class extends l.Client{constructor(e){let l=(0,d.getRuntimeConfig)(e),f=(0,u.resolveClientEndpointParameters)(l),p=(0,t.resolveRegionConfig)(f),m=(0,r.resolveEndpointConfig)(p),h=(0,s.resolveRetryConfig)(m),g=(0,i.resolveHostHeaderConfig)(h),_=(0,c.resolveUserAgentConfig)(g);super(_),this.config=_,this.middlewareStack.use((0,s.getRetryPlugin)(this.config)),this.middlewareStack.use((0,n.getContentLengthPlugin)(this.config)),this.middlewareStack.use((0,i.getHostHeaderPlugin)(this.config)),this.middlewareStack.use((0,a.getLoggerPlugin)(this.config)),this.middlewareStack.use((0,o.getRecursionDetectionPlugin)(this.config)),this.middlewareStack.use((0,c.getUserAgentPlugin)(this.config))}destroy(){super.destroy()}}})),Zl=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.SSOOIDC=void 0;let t=P(),n=Vl(),r=Hl(),i=Ul(),a=Xl(),o={CreateTokenCommand:n.CreateTokenCommand,RegisterClientCommand:r.RegisterClientCommand,StartDeviceAuthorizationCommand:i.StartDeviceAuthorizationCommand};var s=class extends a.SSOOIDCClient{};e.SSOOIDC=s,(0,t.createAggregatedClient)(o,s)})),Ql=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=(N(),m(j));t.__exportStar(Vl(),e),t.__exportStar(Hl(),e),t.__exportStar(Ul(),e)})),$l=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),(N(),m(j)).__exportStar(zl(),e)})),eu=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.SSOOIDCServiceException=void 0;let t=(N(),m(j));t.__exportStar(Zl(),e),t.__exportStar(Xl(),e),t.__exportStar(Ql(),e),t.__exportStar($l(),e);var n=Rl();Object.defineProperty(e,`SSOOIDCServiceException`,{enumerable:!0,get:function(){return n.SSOOIDCServiceException}})})),tu=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.getSsoOidcClient=void 0;let t=eu(),n={};e.getSsoOidcClient=e=>{if(n[e])return n[e];let r=new t.SSOOIDCClient({region:e});return n[e]=r,r}})),nu=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.getNewSsoOidcToken=void 0;let t=eu(),n=tu();e.getNewSsoOidcToken=(e,r)=>(0,n.getSsoOidcClient)(r).send(new t.CreateTokenCommand({clientId:e.clientId,clientSecret:e.clientSecret,refreshToken:e.refreshToken,grantType:`refresh_token`}))})),ru=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.validateTokenExpiry=void 0;let t=qi(),n=Ll();e.validateTokenExpiry=e=>{if(e.expiration&&e.expiration.getTime()<Date.now())throw new t.TokenProviderError(`Token is expired. ${n.REFRESH_MESSAGE}`,!1)}})),iu=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.validateTokenKey=void 0;let t=qi(),n=Ll();e.validateTokenKey=(e,r,i=!1)=>{if(r===void 0)throw new t.TokenProviderError(`Value not present for '${e}' in SSO Token${i?`. Cannot refresh`:``}. ${n.REFRESH_MESSAGE}`,!1)}})),au=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.writeSSOTokenToFile=void 0;let t=Ps(),{writeFile:n}=h(`fs`).promises;e.writeSSOTokenToFile=(e,r)=>n((0,t.getSSOTokenFilepath)(e),JSON.stringify(r,null,2))})),ou=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.fromSso=void 0;let t=qi(),n=Ps(),r=Ll(),i=nu(),a=ru(),o=iu(),s=au(),c=new Date(0);e.fromSso=(e={})=>async()=>{let l=await(0,n.parseKnownFiles)(e),u=(0,n.getProfileName)(e),d=l[u];if(!d)throw new t.TokenProviderError(`Profile '${u}' could not be found in shared credentials file.`,!1);if(!d.sso_session)throw new t.TokenProviderError(`Profile '${u}' is missing required property 'sso_session'.`);let f=d.sso_session,p=(await(0,n.loadSsoSessionData)(e))[f];if(!p)throw new t.TokenProviderError(`Sso session '${f}' could not be found in shared credentials file.`,!1);for(let e of[`sso_start_url`,`sso_region`])if(!p[e])throw new t.TokenProviderError(`Sso session '${f}' is missing required property '${e}'.`,!1);p.sso_start_url;let m=p.sso_region,h;try{h=await(0,n.getSSOTokenFromFile)(f)}catch{throw new t.TokenProviderError(`The SSO session token associated with profile=${u} was not found or is invalid. ${r.REFRESH_MESSAGE}`,!1)}(0,o.validateTokenKey)(`accessToken`,h.accessToken),(0,o.validateTokenKey)(`expiresAt`,h.expiresAt);let{accessToken:g,expiresAt:_}=h,v={token:g,expiration:new Date(_)};if(v.expiration.getTime()-Date.now()>r.EXPIRE_WINDOW_MS)return v;if(Date.now()-c.getTime()<30*1e3)return(0,a.validateTokenExpiry)(v),v;(0,o.validateTokenKey)(`clientId`,h.clientId,!0),(0,o.validateTokenKey)(`clientSecret`,h.clientSecret,!0),(0,o.validateTokenKey)(`refreshToken`,h.refreshToken,!0);try{c.setTime(Date.now());let e=await(0,i.getNewSsoOidcToken)(h,m);(0,o.validateTokenKey)(`accessToken`,e.accessToken),(0,o.validateTokenKey)(`expiresIn`,e.expiresIn);let t=new Date(Date.now()+e.expiresIn*1e3);try{await(0,s.writeSSOTokenToFile)(f,{...h,accessToken:e.accessToken,expiresAt:t.toISOString(),refreshToken:e.refreshToken})}catch{}return{token:e.accessToken,expiration:t}}catch{return(0,a.validateTokenExpiry)(v),v}}})),su=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.fromStatic=void 0;let t=qi();e.fromStatic=({token:e})=>async()=>{if(!e||!e.token)throw new t.TokenProviderError(`Please pass a valid token to fromStatic`,!1);return e}})),cu=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.nodeProvider=void 0;let t=qi(),n=ou();e.nodeProvider=(e={})=>(0,t.memoize)((0,t.chain)((0,n.fromSso)(e),async()=>{throw new t.TokenProviderError(`Could not load token from any providers`,!1)}),e=>e.expiration!==void 0&&e.expiration.getTime()-Date.now()<3e5,e=>e.expiration!==void 0)})),lu=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=(N(),m(j));t.__exportStar(ou(),e),t.__exportStar(su(),e),t.__exportStar(cu(),e)})),uu=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.resolveSSOCredentials=void 0;let t=Il(),n=qi(),r=Ps(),i=lu();e.resolveSSOCredentials=async({ssoStartUrl:e,ssoSession:a,ssoAccountId:o,ssoRegion:s,ssoRoleName:c,ssoClient:l,profile:u})=>{let d,f=`To refresh this SSO session run aws sso login with the corresponding profile.`;if(a)try{let e=await(0,i.fromSso)({profile:u})();d={accessToken:e.token,expiresAt:new Date(e.expiration).toISOString()}}catch(e){throw new n.CredentialsProviderError(e.message,!1)}else try{d=await(0,r.getSSOTokenFromFile)(e)}catch{throw new n.CredentialsProviderError(`The SSO session associated with this profile is invalid. ${f}`,!1)}if(new Date(d.expiresAt).getTime()-Date.now()<=9e5)throw new n.CredentialsProviderError(`The SSO session associated with this profile has expired. ${f}`,!1);let{accessToken:p}=d,m=l||new t.SSOClient({region:s}),h;try{h=await m.send(new t.GetRoleCredentialsCommand({accountId:o,roleName:c,accessToken:p}))}catch(e){throw n.CredentialsProviderError.from(e,!1)}let{roleCredentials:{accessKeyId:g,secretAccessKey:_,sessionToken:v,expiration:y}={}}=h;if(!g||!_||!v||!y)throw new n.CredentialsProviderError(`SSO returns an invalid temporary credential.`,!1);return{accessKeyId:g,secretAccessKey:_,sessionToken:v,expiration:new Date(y)}}})),du=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.validateSsoProfile=void 0;let t=qi();e.validateSsoProfile=e=>{let{sso_start_url:n,sso_account_id:r,sso_region:i,sso_role_name:a}=e;if(!n||!r||!i||!a)throw new t.CredentialsProviderError(`Profile is configured with invalid SSO credentials. Required parameters "sso_account_id", "sso_region", "sso_role_name", "sso_start_url". Got ${Object.keys(e).join(`, `)}\nReference: https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-sso.html`,!1);return e}})),fu=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.fromSSO=void 0;let t=qi(),n=Ps(),r=cc(),i=uu(),a=du();e.fromSSO=(e={})=>async()=>{let{ssoStartUrl:o,ssoAccountId:s,ssoRegion:c,ssoRoleName:l,ssoClient:u,ssoSession:d}=e,f=(0,n.getProfileName)(e);if(!o&&!s&&!c&&!l&&!d){let s=(await(0,n.parseKnownFiles)(e))[f];if(!s)throw new t.CredentialsProviderError(`Profile ${f} was not found.`);if(!(0,r.isSsoProfile)(s))throw new t.CredentialsProviderError(`Profile ${f} is not configured with SSO credentials.`);if(s?.sso_session){let r=(await(0,n.loadSsoSessionData)(e))[s.sso_session],i=` configurations in profile ${f} and sso-session ${s.sso_session}`;if(c&&c!==r.sso_region)throw new t.CredentialsProviderError(`Conflicting SSO region`+i,!1);if(o&&o!==r.sso_start_url)throw new t.CredentialsProviderError(`Conflicting SSO start_url`+i,!1);s.sso_region=r.sso_region,s.sso_start_url=r.sso_start_url}let{sso_start_url:l,sso_account_id:d,sso_region:p,sso_role_name:m,sso_session:h}=(0,a.validateSsoProfile)(s);return(0,i.resolveSSOCredentials)({ssoStartUrl:l,ssoSession:h,ssoAccountId:d,ssoRegion:p,ssoRoleName:m,ssoClient:u,profile:f})}else if(!o||!s||!c||!l)throw new t.CredentialsProviderError(`Incomplete configuration. The fromSSO() argument hash must include "ssoStartUrl", "ssoAccountId", "ssoRegion", "ssoRoleName"`);else return(0,i.resolveSSOCredentials)({ssoStartUrl:o,ssoSession:d,ssoAccountId:s,ssoRegion:c,ssoRoleName:l,ssoClient:u,profile:f})}})),pu=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0})})),mu=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=(N(),m(j));t.__exportStar(fu(),e),t.__exportStar(cc(),e),t.__exportStar(pu(),e),t.__exportStar(du(),e)})),hu=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.resolveSsoCredentials=e.isSsoProfile=void 0;let t=mu();var n=mu();Object.defineProperty(e,`isSsoProfile`,{enumerable:!0,get:function(){return n.isSsoProfile}}),e.resolveSsoCredentials=e=>{let{sso_start_url:n,sso_account_id:r,sso_session:i,sso_region:a,sso_role_name:o}=(0,t.validateSsoProfile)(e);return(0,t.fromSSO)({ssoStartUrl:n,ssoAccountId:r,ssoSession:i,ssoRegion:a,ssoRoleName:o})()}})),gu=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.resolveStaticCredentials=e.isStaticCredsProfile=void 0,e.isStaticCredsProfile=e=>!!e&&typeof e==`object`&&typeof e.aws_access_key_id==`string`&&typeof e.aws_secret_access_key==`string`&&[`undefined`,`string`].indexOf(typeof e.aws_session_token)>-1,e.resolveStaticCredentials=e=>Promise.resolve({accessKeyId:e.aws_access_key_id,secretAccessKey:e.aws_secret_access_key,sessionToken:e.aws_session_token})})),_u=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.fromWebToken=void 0;let t=qi();e.fromWebToken=e=>()=>{let{roleArn:n,roleSessionName:r,webIdentityToken:i,providerId:a,policyArns:o,policy:s,durationSeconds:c,roleAssumerWithWebIdentity:l}=e;if(!l)throw new t.CredentialsProviderError(`Role Arn '${n}' needs to be assumed with web identity, but no role assumption callback was provided.`,!1);return l({RoleArn:n,RoleSessionName:r??`aws-sdk-js-session-${Date.now()}`,WebIdentityToken:i,ProviderId:a,PolicyArns:o,Policy:s,DurationSeconds:c})}})),vu=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.fromTokenFile=void 0;let t=qi(),n=h(`fs`),r=_u();e.fromTokenFile=(e={})=>async()=>i(e);let i=e=>{let i=e?.webIdentityTokenFile??process.env.AWS_WEB_IDENTITY_TOKEN_FILE,a=e?.roleArn??process.env.AWS_ROLE_ARN,o=e?.roleSessionName??process.env.AWS_ROLE_SESSION_NAME;if(!i||!a)throw new t.CredentialsProviderError(`Web identity configuration not specified`);return(0,r.fromWebToken)({...e,webIdentityToken:(0,n.readFileSync)(i,{encoding:`ascii`}),roleArn:a,roleSessionName:o})()}})),yu=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=(N(),m(j));t.__exportStar(vu(),e),t.__exportStar(_u(),e)})),bu=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.resolveWebIdentityCredentials=e.isWebIdentityProfile=void 0;let t=yu();e.isWebIdentityProfile=e=>!!e&&typeof e==`object`&&typeof e.web_identity_token_file==`string`&&typeof e.role_arn==`string`&&[`undefined`,`string`].indexOf(typeof e.role_session_name)>-1,e.resolveWebIdentityCredentials=async(e,n)=>(0,t.fromTokenFile)({webIdentityTokenFile:e.web_identity_token_file,roleArn:e.role_arn,roleSessionName:e.role_session_name,roleAssumerWithWebIdentity:n.roleAssumerWithWebIdentity})()})),xu=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.resolveProfileData=void 0;let t=qi(),n=nc(),r=sc(),i=hu(),a=gu(),o=bu();e.resolveProfileData=async(e,s,c,l={})=>{let u=s[e];if(Object.keys(l).length>0&&(0,a.isStaticCredsProfile)(u))return(0,a.resolveStaticCredentials)(u);if((0,n.isAssumeRoleProfile)(u))return(0,n.resolveAssumeRoleCredentials)(e,s,c,l);if((0,a.isStaticCredsProfile)(u))return(0,a.resolveStaticCredentials)(u);if((0,o.isWebIdentityProfile)(u))return(0,o.resolveWebIdentityCredentials)(u,c);if((0,r.isProcessProfile)(u))return(0,r.resolveProcessCredentials)(c,e);if((0,i.isSsoProfile)(u))return(0,i.resolveSsoCredentials)(u);throw new t.CredentialsProviderError(`Profile ${e} could not be found or parsed in shared credentials file.`)}})),Su=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.fromIni=void 0;let t=Ps(),n=xu();e.fromIni=(e={})=>async()=>{let r=await(0,t.parseKnownFiles)(e);return(0,n.resolveProfileData)((0,t.getProfileName)(e),r,e)}})),Cu=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),(N(),m(j)).__exportStar(Su(),e)})),wu=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.remoteProvider=e.ENV_IMDS_DISABLED=void 0;let t=ec(),n=qi();e.ENV_IMDS_DISABLED=`AWS_EC2_METADATA_DISABLED`,e.remoteProvider=r=>process.env[t.ENV_CMDS_RELATIVE_URI]||process.env[t.ENV_CMDS_FULL_URI]?(0,t.fromContainerMetadata)(r):process.env[e.ENV_IMDS_DISABLED]?async()=>{throw new n.CredentialsProviderError(`EC2 Instance Metadata Service access disabled`)}:(0,t.fromInstanceMetadata)(r)})),Tu=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.defaultProvider=void 0;let t=vs(),n=Cu(),r=oc(),i=mu(),a=yu(),o=qi(),s=Ps(),c=wu();e.defaultProvider=(e={})=>(0,o.memoize)((0,o.chain)(...e.profile||process.env[s.ENV_PROFILE]?[]:[(0,t.fromEnv)()],(0,i.fromSSO)(e),(0,n.fromIni)(e),(0,r.fromProcess)(e),(0,a.fromTokenFile)(e),(0,c.remoteProvider)(e),async()=>{throw new o.CredentialsProviderError(`Could not load credentials from any providers`,!1)}),e=>e.expiration!==void 0&&e.expiration.getTime()-Date.now()<3e5,e=>e.expiration!==void 0)})),Eu=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),(N(),m(j)).__exportStar(Tu(),e)})),Du=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.ruleSet=void 0;let t=`required`,n=`type`,r=`argv`,i=`booleanEquals`,a=`tree`,o=`stringEquals`,s=`sigv4`,c=`us-east-1`,l=`endpoint`,u=`https://sts.{Region}.{PartitionResult#dnsSuffix}`,d=`error`,f=`getAttr`,p={[t]:!1,[n]:`String`},m={[t]:!0,default:!1,[n]:`Boolean`},h={ref:`Endpoint`},g={fn:`isSet`,[r]:[{ref:`Region`}]},_={ref:`Region`},v={fn:`aws.partition`,[r]:[_],assign:`PartitionResult`},y={ref:`UseFIPS`},b={ref:`UseDualStack`},x={url:`https://sts.amazonaws.com`,properties:{authSchemes:[{name:s,signingName:`sts`,signingRegion:c}]},headers:{}},S={},C={conditions:[{fn:o,[r]:[_,`aws-global`]}],[l]:x,[n]:l},w={fn:i,[r]:[y,!0]},ee={fn:i,[r]:[b,!0]},te={fn:i,[r]:[!0,{fn:f,[r]:[{ref:`PartitionResult`},`supportsFIPS`]}]},T={ref:`PartitionResult`},E={fn:i,[r]:[!0,{fn:f,[r]:[T,`supportsDualStack`]}]},ne=[{fn:`isSet`,[r]:[h]}],re=[w],ie=[ee];e.ruleSet={version:`1.0`,parameters:{Region:p,UseDualStack:m,UseFIPS:m,Endpoint:p,UseGlobalEndpoint:m},rules:[{conditions:[{fn:i,[r]:[{ref:`UseGlobalEndpoint`},!0]},{fn:`not`,[r]:ne},g,v,{fn:i,[r]:[y,!1]},{fn:i,[r]:[b,!1]}],[n]:a,rules:[{conditions:[{fn:o,[r]:[_,`ap-northeast-1`]}],endpoint:x,[n]:l},{conditions:[{fn:o,[r]:[_,`ap-south-1`]}],endpoint:x,[n]:l},{conditions:[{fn:o,[r]:[_,`ap-southeast-1`]}],endpoint:x,[n]:l},{conditions:[{fn:o,[r]:[_,`ap-southeast-2`]}],endpoint:x,[n]:l},C,{conditions:[{fn:o,[r]:[_,`ca-central-1`]}],endpoint:x,[n]:l},{conditions:[{fn:o,[r]:[_,`eu-central-1`]}],endpoint:x,[n]:l},{conditions:[{fn:o,[r]:[_,`eu-north-1`]}],endpoint:x,[n]:l},{conditions:[{fn:o,[r]:[_,`eu-west-1`]}],endpoint:x,[n]:l},{conditions:[{fn:o,[r]:[_,`eu-west-2`]}],endpoint:x,[n]:l},{conditions:[{fn:o,[r]:[_,`eu-west-3`]}],endpoint:x,[n]:l},{conditions:[{fn:o,[r]:[_,`sa-east-1`]}],endpoint:x,[n]:l},{conditions:[{fn:o,[r]:[_,c]}],endpoint:x,[n]:l},{conditions:[{fn:o,[r]:[_,`us-east-2`]}],endpoint:x,[n]:l},{conditions:[{fn:o,[r]:[_,`us-west-1`]}],endpoint:x,[n]:l},{conditions:[{fn:o,[r]:[_,`us-west-2`]}],endpoint:x,[n]:l},{endpoint:{url:u,properties:{authSchemes:[{name:s,signingName:`sts`,signingRegion:`{Region}`}]},headers:S},[n]:l}]},{conditions:ne,[n]:a,rules:[{conditions:re,error:`Invalid Configuration: FIPS and custom endpoint are not supported`,[n]:d},{[n]:a,rules:[{conditions:ie,error:`Invalid Configuration: Dualstack and custom endpoint are not supported`,[n]:d},{endpoint:{url:h,properties:S,headers:S},[n]:l}]}]},{[n]:a,rules:[{conditions:[g],[n]:a,rules:[{conditions:[v],[n]:a,rules:[{conditions:[w,ee],[n]:a,rules:[{conditions:[te,E],[n]:a,rules:[{[n]:a,rules:[{endpoint:{url:`https://sts-fips.{Region}.{PartitionResult#dualStackDnsSuffix}`,properties:S,headers:S},[n]:l}]}]},{error:`FIPS and DualStack are enabled, but this partition does not support one or both`,[n]:d}]},{conditions:re,[n]:a,rules:[{conditions:[te],[n]:a,rules:[{[n]:a,rules:[{conditions:[{fn:o,[r]:[`aws-us-gov`,{fn:f,[r]:[T,`name`]}]}],endpoint:{url:`https://sts.{Region}.amazonaws.com`,properties:S,headers:S},[n]:l},{endpoint:{url:`https://sts-fips.{Region}.{PartitionResult#dnsSuffix}`,properties:S,headers:S},[n]:l}]}]},{error:`FIPS is enabled but this partition does not support FIPS`,[n]:d}]},{conditions:ie,[n]:a,rules:[{conditions:[E],[n]:a,rules:[{[n]:a,rules:[{endpoint:{url:`https://sts.{Region}.{PartitionResult#dualStackDnsSuffix}`,properties:S,headers:S},[n]:l}]}]},{error:`DualStack is enabled but this partition does not support DualStack`,[n]:d}]},{[n]:a,rules:[C,{endpoint:{url:u,properties:S,headers:S},[n]:l}]}]}]},{error:`Invalid Configuration: Missing Region`,[n]:d}]}]}})),Ou=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.defaultEndpointResolver=void 0;let t=Xo(),n=Du();e.defaultEndpointResolver=(e,r={})=>(0,t.resolveEndpoint)(n.ruleSet,{endpointParams:e,logger:r.logger})})),ku=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.getRuntimeConfig=void 0;let t=P(),n=Zt(),r=yl(),i=ea(),a=Ou();e.getRuntimeConfig=e=>({apiVersion:`2011-06-15`,base64Decoder:e?.base64Decoder??r.fromBase64,base64Encoder:e?.base64Encoder??r.toBase64,disableHostPrefix:e?.disableHostPrefix??!1,endpointProvider:e?.endpointProvider??a.defaultEndpointResolver,logger:e?.logger??new t.NoOpLogger,serviceId:e?.serviceId??`STS`,urlParser:e?.urlParser??n.parseUrl,utf8Decoder:e?.utf8Decoder??i.fromUtf8,utf8Encoder:e?.utf8Encoder??i.toUtf8})})),Au=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.getRuntimeConfig=void 0;let t=(N(),m(j)).__importDefault(hs()),n=gs(),r=Or(),i=Eu(),a=vc(),o=Bi(),s=Ws(),c=Mc(),l=Pc(),u=Wr(),d=gl(),f=ku(),p=P(),h=El(),g=P();e.getRuntimeConfig=e=>{(0,g.emitWarningIfUnsupportedVersion)(process.version);let m=(0,h.resolveDefaultsModeConfig)(e),_=()=>m().then(p.loadConfigsForDefaultMode),v=(0,f.getRuntimeConfig)(e);return{...v,...e,runtime:`node`,defaultsMode:m,bodyLengthChecker:e?.bodyLengthChecker??l.calculateBodyLength,credentialDefaultProvider:e?.credentialDefaultProvider??(0,n.decorateDefaultCredentialProvider)(i.defaultProvider),defaultUserAgentProvider:e?.defaultUserAgentProvider??(0,d.defaultUserAgent)({serviceId:v.serviceId,clientVersion:t.default.version}),maxAttempts:e?.maxAttempts??(0,s.loadConfig)(o.NODE_MAX_ATTEMPT_CONFIG_OPTIONS),region:e?.region??(0,s.loadConfig)(r.NODE_REGION_CONFIG_OPTIONS,r.NODE_REGION_CONFIG_FILE_OPTIONS),requestHandler:e?.requestHandler??new c.NodeHttpHandler(_),retryMode:e?.retryMode??(0,s.loadConfig)({...o.NODE_RETRY_MODE_CONFIG_OPTIONS,default:async()=>(await _()).retryMode||u.DEFAULT_RETRY_MODE}),sha256:e?.sha256??a.Hash.bind(null,`sha256`),streamCollector:e?.streamCollector??c.streamCollector,useDualstackEndpoint:e?.useDualstackEndpoint??(0,s.loadConfig)(r.NODE_USE_DUALSTACK_ENDPOINT_CONFIG_OPTIONS),useFipsEndpoint:e?.useFipsEndpoint??(0,s.loadConfig)(r.NODE_USE_FIPS_ENDPOINT_CONFIG_OPTIONS)}}})),ju=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.STSClient=void 0;let t=Or(),n=kr(),r=L(),i=Z(),a=jr(),o=Mr(),s=Bi(),c=ps(),l=$o(),u=P(),d=ms(),f=Au();e.STSClient=class e extends u.Client{constructor(u){let p=(0,f.getRuntimeConfig)(u),m=(0,d.resolveClientEndpointParameters)(p),h=(0,t.resolveRegionConfig)(m),g=(0,r.resolveEndpointConfig)(h),_=(0,s.resolveRetryConfig)(g),v=(0,i.resolveHostHeaderConfig)(_),y=(0,c.resolveStsAuthConfig)(v,{stsClientCtor:e}),b=(0,l.resolveUserAgentConfig)(y);super(b),this.config=b,this.middlewareStack.use((0,s.getRetryPlugin)(this.config)),this.middlewareStack.use((0,n.getContentLengthPlugin)(this.config)),this.middlewareStack.use((0,i.getHostHeaderPlugin)(this.config)),this.middlewareStack.use((0,a.getLoggerPlugin)(this.config)),this.middlewareStack.use((0,o.getRecursionDetectionPlugin)(this.config)),this.middlewareStack.use((0,l.getUserAgentPlugin)(this.config))}destroy(){super.destroy()}}})),Mu=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.STS=void 0;let t=P(),n=as(),r=os(),i=ss(),a=cs(),o=ls(),s=us(),c=ds(),l=fs(),u=ju(),d={AssumeRoleCommand:n.AssumeRoleCommand,AssumeRoleWithSAMLCommand:r.AssumeRoleWithSAMLCommand,AssumeRoleWithWebIdentityCommand:i.AssumeRoleWithWebIdentityCommand,DecodeAuthorizationMessageCommand:a.DecodeAuthorizationMessageCommand,GetAccessKeyInfoCommand:o.GetAccessKeyInfoCommand,GetCallerIdentityCommand:s.GetCallerIdentityCommand,GetFederationTokenCommand:c.GetFederationTokenCommand,GetSessionTokenCommand:l.GetSessionTokenCommand};var f=class extends u.STSClient{};e.STS=f,(0,t.createAggregatedClient)(d,f)})),Nu=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=(N(),m(j));t.__exportStar(as(),e),t.__exportStar(os(),e),t.__exportStar(ss(),e),t.__exportStar(cs(),e),t.__exportStar(ls(),e),t.__exportStar(us(),e),t.__exportStar(ds(),e),t.__exportStar(fs(),e)})),Pu=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.decorateDefaultCredentialProvider=e.getDefaultRoleAssumerWithWebIdentity=e.getDefaultRoleAssumer=void 0;let t=gs(),n=ju(),r=(e,t)=>t?class extends e{constructor(e){super(e);for(let e of t)this.middlewareStack.use(e)}}:e;e.getDefaultRoleAssumer=(e={},i)=>(0,t.getDefaultRoleAssumer)(e,r(n.STSClient,i)),e.getDefaultRoleAssumerWithWebIdentity=(e={},i)=>(0,t.getDefaultRoleAssumerWithWebIdentity)(e,r(n.STSClient,i)),e.decorateDefaultCredentialProvider=t=>n=>t({roleAssumer:(0,e.getDefaultRoleAssumer)(n),roleAssumerWithWebIdentity:(0,e.getDefaultRoleAssumerWithWebIdentity)(n),...n})})),Fu=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),(N(),m(j)).__exportStar(rs(),e)})),Iu=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.STSServiceException=void 0;let t=(N(),m(j));t.__exportStar(Mu(),e),t.__exportStar(ju(),e),t.__exportStar(Nu(),e),t.__exportStar(Pu(),e),t.__exportStar(Fu(),e);var n=ns();Object.defineProperty(e,`STSServiceException`,{enumerable:!0,get:function(){return n.STSServiceException}})})),Lu=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.ruleSet=void 0;let t=`required`,n=`argv`,r=`isSet`,i=`tree`,a=`error`,o=`endpoint`,s=`PartitionResult`,c=`stringEquals`,l={[t]:!1,type:`String`},u={[t]:!0,default:!1,type:`Boolean`},d={ref:`Endpoint`},f={fn:`booleanEquals`,[n]:[{ref:`UseFIPS`},!0]},p={fn:`booleanEquals`,[n]:[{ref:`UseDualStack`},!0]},m={},h={ref:`Region`},g={fn:`booleanEquals`,[n]:[!0,{fn:`getAttr`,[n]:[{ref:s},`supportsFIPS`]}]},_={fn:`booleanEquals`,[n]:[!0,{fn:`getAttr`,[n]:[{ref:s},`supportsDualStack`]}]},v=[f],y=[p],b=[h];e.ruleSet={version:`1.0`,parameters:{Region:l,UseDualStack:u,UseFIPS:u,Endpoint:l},rules:[{conditions:[{fn:r,[n]:[d]}],type:i,rules:[{conditions:v,error:`Invalid Configuration: FIPS and custom endpoint are not supported`,type:a},{type:i,rules:[{conditions:y,error:`Invalid Configuration: Dualstack and custom endpoint are not supported`,type:a},{endpoint:{url:d,properties:m,headers:m},type:o}]}]},{type:i,rules:[{conditions:[{fn:r,[n]:b}],type:i,rules:[{conditions:[{fn:`aws.partition`,[n]:b,assign:s}],type:i,rules:[{conditions:[f,p],type:i,rules:[{conditions:[g,_],type:i,rules:[{type:i,rules:[{endpoint:{url:`https://sns-fips.{Region}.{PartitionResult#dualStackDnsSuffix}`,properties:m,headers:m},type:o}]}]},{error:`FIPS and DualStack are enabled, but this partition does not support one or both`,type:a}]},{conditions:v,type:i,rules:[{conditions:[g],type:i,rules:[{type:i,rules:[{conditions:[{fn:c,[n]:[h,`us-gov-east-1`]}],endpoint:{url:`https://sns.us-gov-east-1.amazonaws.com`,properties:m,headers:m},type:o},{conditions:[{fn:c,[n]:[h,`us-gov-west-1`]}],endpoint:{url:`https://sns.us-gov-west-1.amazonaws.com`,properties:m,headers:m},type:o},{endpoint:{url:`https://sns-fips.{Region}.{PartitionResult#dnsSuffix}`,properties:m,headers:m},type:o}]}]},{error:`FIPS is enabled but this partition does not support FIPS`,type:a}]},{conditions:y,type:i,rules:[{conditions:[_],type:i,rules:[{type:i,rules:[{endpoint:{url:`https://sns.{Region}.{PartitionResult#dualStackDnsSuffix}`,properties:m,headers:m},type:o}]}]},{error:`DualStack is enabled but this partition does not support DualStack`,type:a}]},{type:i,rules:[{endpoint:{url:`https://sns.{Region}.{PartitionResult#dnsSuffix}`,properties:m,headers:m},type:o}]}]}]},{error:`Invalid Configuration: Missing Region`,type:a}]}]}})),Ru=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.defaultEndpointResolver=void 0;let t=Xo(),n=Lu();e.defaultEndpointResolver=(e,r={})=>(0,t.resolveEndpoint)(n.ruleSet,{endpointParams:e,logger:r.logger})})),zu=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.getRuntimeConfig=void 0;let t=P(),n=Zt(),r=yl(),i=ea(),a=Ru();e.getRuntimeConfig=e=>({apiVersion:`2010-03-31`,base64Decoder:e?.base64Decoder??r.fromBase64,base64Encoder:e?.base64Encoder??r.toBase64,disableHostPrefix:e?.disableHostPrefix??!1,endpointProvider:e?.endpointProvider??a.defaultEndpointResolver,logger:e?.logger??new t.NoOpLogger,serviceId:e?.serviceId??`SNS`,urlParser:e?.urlParser??n.parseUrl,utf8Decoder:e?.utf8Decoder??i.fromUtf8,utf8Encoder:e?.utf8Encoder??i.toUtf8})})),Bu=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.getRuntimeConfig=void 0;let t=(N(),m(j)).__importDefault(ts()),n=Iu(),r=Or(),i=Eu(),a=vc(),o=Bi(),s=Ws(),c=Mc(),l=Pc(),u=Wr(),d=gl(),f=zu(),p=P(),h=El(),g=P();e.getRuntimeConfig=e=>{(0,g.emitWarningIfUnsupportedVersion)(process.version);let m=(0,h.resolveDefaultsModeConfig)(e),_=()=>m().then(p.loadConfigsForDefaultMode),v=(0,f.getRuntimeConfig)(e);return{...v,...e,runtime:`node`,defaultsMode:m,bodyLengthChecker:e?.bodyLengthChecker??l.calculateBodyLength,credentialDefaultProvider:e?.credentialDefaultProvider??(0,n.decorateDefaultCredentialProvider)(i.defaultProvider),defaultUserAgentProvider:e?.defaultUserAgentProvider??(0,d.defaultUserAgent)({serviceId:v.serviceId,clientVersion:t.default.version}),maxAttempts:e?.maxAttempts??(0,s.loadConfig)(o.NODE_MAX_ATTEMPT_CONFIG_OPTIONS),region:e?.region??(0,s.loadConfig)(r.NODE_REGION_CONFIG_OPTIONS,r.NODE_REGION_CONFIG_FILE_OPTIONS),requestHandler:e?.requestHandler??new c.NodeHttpHandler(_),retryMode:e?.retryMode??(0,s.loadConfig)({...o.NODE_RETRY_MODE_CONFIG_OPTIONS,default:async()=>(await _()).retryMode||u.DEFAULT_RETRY_MODE}),sha256:e?.sha256??a.Hash.bind(null,`sha256`),streamCollector:e?.streamCollector??c.streamCollector,useDualstackEndpoint:e?.useDualstackEndpoint??(0,s.loadConfig)(r.NODE_USE_DUALSTACK_ENDPOINT_CONFIG_OPTIONS),useFipsEndpoint:e?.useFipsEndpoint??(0,s.loadConfig)(r.NODE_USE_FIPS_ENDPOINT_CONFIG_OPTIONS)}}})),Vu=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.SNSClient=void 0;let t=Or(),n=kr(),r=L(),i=Z(),a=jr(),o=Mr(),s=Bi(),c=xa(),l=$o(),u=P(),d=es(),f=Bu();e.SNSClient=class extends u.Client{constructor(e){let u=(0,f.getRuntimeConfig)(e),p=(0,d.resolveClientEndpointParameters)(u),m=(0,t.resolveRegionConfig)(p),h=(0,r.resolveEndpointConfig)(m),g=(0,s.resolveRetryConfig)(h),_=(0,i.resolveHostHeaderConfig)(g),v=(0,c.resolveAwsAuthConfig)(_),y=(0,l.resolveUserAgentConfig)(v);super(y),this.config=y,this.middlewareStack.use((0,s.getRetryPlugin)(this.config)),this.middlewareStack.use((0,n.getContentLengthPlugin)(this.config)),this.middlewareStack.use((0,i.getHostHeaderPlugin)(this.config)),this.middlewareStack.use((0,a.getLoggerPlugin)(this.config)),this.middlewareStack.use((0,o.getRecursionDetectionPlugin)(this.config)),this.middlewareStack.use((0,c.getAwsAuthPlugin)(this.config)),this.middlewareStack.use((0,l.getUserAgentPlugin)(this.config))}destroy(){super.destroy()}}})),Hu=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.SNS=void 0;let t=P(),n=jn(),r=Mn(),i=Nn(),a=Pn(),o=Fn(),s=In(),c=Ln(),l=Rn(),u=zn(),d=Bn(),f=Vn(),p=Hn(),m=Un(),h=Wn(),g=Gn(),_=Kn(),v=qn(),y=Jn(),b=Yn(),x=Xn(),S=Zn(),C=z(),w=Qn(),ee=$n(),te=er(),T=tr(),E=nr(),ne=rr(),re=ir(),ie=ar(),ae=or(),oe=sr(),se=cr(),ce=lr(),le=ur(),ue=dr(),de=fr(),fe=pr(),pe=mr(),me=hr(),he=gr(),ge=_r(),_e=Vu(),ve={AddPermissionCommand:n.AddPermissionCommand,CheckIfPhoneNumberIsOptedOutCommand:r.CheckIfPhoneNumberIsOptedOutCommand,ConfirmSubscriptionCommand:i.ConfirmSubscriptionCommand,CreatePlatformApplicationCommand:a.CreatePlatformApplicationCommand,CreatePlatformEndpointCommand:o.CreatePlatformEndpointCommand,CreateSMSSandboxPhoneNumberCommand:s.CreateSMSSandboxPhoneNumberCommand,CreateTopicCommand:c.CreateTopicCommand,DeleteEndpointCommand:l.DeleteEndpointCommand,DeletePlatformApplicationCommand:u.DeletePlatformApplicationCommand,DeleteSMSSandboxPhoneNumberCommand:d.DeleteSMSSandboxPhoneNumberCommand,DeleteTopicCommand:f.DeleteTopicCommand,GetDataProtectionPolicyCommand:p.GetDataProtectionPolicyCommand,GetEndpointAttributesCommand:m.GetEndpointAttributesCommand,GetPlatformApplicationAttributesCommand:h.GetPlatformApplicationAttributesCommand,GetSMSAttributesCommand:g.GetSMSAttributesCommand,GetSMSSandboxAccountStatusCommand:_.GetSMSSandboxAccountStatusCommand,GetSubscriptionAttributesCommand:v.GetSubscriptionAttributesCommand,GetTopicAttributesCommand:y.GetTopicAttributesCommand,ListEndpointsByPlatformApplicationCommand:b.ListEndpointsByPlatformApplicationCommand,ListOriginationNumbersCommand:x.ListOriginationNumbersCommand,ListPhoneNumbersOptedOutCommand:S.ListPhoneNumbersOptedOutCommand,ListPlatformApplicationsCommand:C.ListPlatformApplicationsCommand,ListSMSSandboxPhoneNumbersCommand:w.ListSMSSandboxPhoneNumbersCommand,ListSubscriptionsCommand:te.ListSubscriptionsCommand,ListSubscriptionsByTopicCommand:ee.ListSubscriptionsByTopicCommand,ListTagsForResourceCommand:T.ListTagsForResourceCommand,ListTopicsCommand:E.ListTopicsCommand,OptInPhoneNumberCommand:ne.OptInPhoneNumberCommand,PublishCommand:ie.PublishCommand,PublishBatchCommand:re.PublishBatchCommand,PutDataProtectionPolicyCommand:ae.PutDataProtectionPolicyCommand,RemovePermissionCommand:oe.RemovePermissionCommand,SetEndpointAttributesCommand:se.SetEndpointAttributesCommand,SetPlatformApplicationAttributesCommand:ce.SetPlatformApplicationAttributesCommand,SetSMSAttributesCommand:le.SetSMSAttributesCommand,SetSubscriptionAttributesCommand:ue.SetSubscriptionAttributesCommand,SetTopicAttributesCommand:de.SetTopicAttributesCommand,SubscribeCommand:fe.SubscribeCommand,TagResourceCommand:pe.TagResourceCommand,UnsubscribeCommand:me.UnsubscribeCommand,UntagResourceCommand:he.UntagResourceCommand,VerifySMSSandboxPhoneNumberCommand:ge.VerifySMSSandboxPhoneNumberCommand};var ye=class extends _e.SNSClient{};e.SNS=ye,(0,t.createAggregatedClient)(ve,ye)})),Uu=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=(N(),m(j));t.__exportStar(jn(),e),t.__exportStar(Mn(),e),t.__exportStar(Nn(),e),t.__exportStar(Pn(),e),t.__exportStar(Fn(),e),t.__exportStar(In(),e),t.__exportStar(Ln(),e),t.__exportStar(Rn(),e),t.__exportStar(zn(),e),t.__exportStar(Bn(),e),t.__exportStar(Vn(),e),t.__exportStar(Hn(),e),t.__exportStar(Un(),e),t.__exportStar(Wn(),e),t.__exportStar(Gn(),e),t.__exportStar(Kn(),e),t.__exportStar(qn(),e),t.__exportStar(Jn(),e),t.__exportStar(Yn(),e),t.__exportStar(Xn(),e),t.__exportStar(Zn(),e),t.__exportStar(z(),e),t.__exportStar(Qn(),e),t.__exportStar($n(),e),t.__exportStar(er(),e),t.__exportStar(tr(),e),t.__exportStar(nr(),e),t.__exportStar(rr(),e),t.__exportStar(ir(),e),t.__exportStar(ar(),e),t.__exportStar(or(),e),t.__exportStar(sr(),e),t.__exportStar(cr(),e),t.__exportStar(lr(),e),t.__exportStar(ur(),e),t.__exportStar(dr(),e),t.__exportStar(fr(),e),t.__exportStar(pr(),e),t.__exportStar(mr(),e),t.__exportStar(hr(),e),t.__exportStar(gr(),e),t.__exportStar(_r(),e)})),Wu=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),(N(),m(j)).__exportStar(An(),e)})),Gu=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0})})),Ku=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.paginateListEndpointsByPlatformApplication=void 0;let t=Yn(),n=Vu(),r=async(e,n,...r)=>await e.send(new t.ListEndpointsByPlatformApplicationCommand(n),...r);async function*i(e,t,...i){let a=e.startingToken||void 0,o=!0,s;for(;o;){if(t.NextToken=a,e.client instanceof n.SNSClient)s=await r(e.client,t,...i);else throw Error(`Invalid client, expected SNS | SNSClient`);yield s;let c=a;a=s.NextToken,o=!!(a&&(!e.stopOnSameToken||a!==c))}return void 0}e.paginateListEndpointsByPlatformApplication=i})),qu=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.paginateListOriginationNumbers=void 0;let t=Xn(),n=Vu(),r=async(e,n,...r)=>await e.send(new t.ListOriginationNumbersCommand(n),...r);async function*i(e,t,...i){let a=e.startingToken||void 0,o=!0,s;for(;o;){if(t.NextToken=a,t.MaxResults=e.pageSize,e.client instanceof n.SNSClient)s=await r(e.client,t,...i);else throw Error(`Invalid client, expected SNS | SNSClient`);yield s;let c=a;a=s.NextToken,o=!!(a&&(!e.stopOnSameToken||a!==c))}return void 0}e.paginateListOriginationNumbers=i})),Ju=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.paginateListPhoneNumbersOptedOut=void 0;let t=Zn(),n=Vu(),r=async(e,n,...r)=>await e.send(new t.ListPhoneNumbersOptedOutCommand(n),...r);async function*i(e,t,...i){let a=e.startingToken||void 0,o=!0,s;for(;o;){if(t.nextToken=a,e.client instanceof n.SNSClient)s=await r(e.client,t,...i);else throw Error(`Invalid client, expected SNS | SNSClient`);yield s;let c=a;a=s.nextToken,o=!!(a&&(!e.stopOnSameToken||a!==c))}return void 0}e.paginateListPhoneNumbersOptedOut=i})),Yu=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.paginateListPlatformApplications=void 0;let t=z(),n=Vu(),r=async(e,n,...r)=>await e.send(new t.ListPlatformApplicationsCommand(n),...r);async function*i(e,t,...i){let a=e.startingToken||void 0,o=!0,s;for(;o;){if(t.NextToken=a,e.client instanceof n.SNSClient)s=await r(e.client,t,...i);else throw Error(`Invalid client, expected SNS | SNSClient`);yield s;let c=a;a=s.NextToken,o=!!(a&&(!e.stopOnSameToken||a!==c))}return void 0}e.paginateListPlatformApplications=i})),Xu=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.paginateListSMSSandboxPhoneNumbers=void 0;let t=Qn(),n=Vu(),r=async(e,n,...r)=>await e.send(new t.ListSMSSandboxPhoneNumbersCommand(n),...r);async function*i(e,t,...i){let a=e.startingToken||void 0,o=!0,s;for(;o;){if(t.NextToken=a,t.MaxResults=e.pageSize,e.client instanceof n.SNSClient)s=await r(e.client,t,...i);else throw Error(`Invalid client, expected SNS | SNSClient`);yield s;let c=a;a=s.NextToken,o=!!(a&&(!e.stopOnSameToken||a!==c))}return void 0}e.paginateListSMSSandboxPhoneNumbers=i})),Zu=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.paginateListSubscriptionsByTopic=void 0;let t=$n(),n=Vu(),r=async(e,n,...r)=>await e.send(new t.ListSubscriptionsByTopicCommand(n),...r);async function*i(e,t,...i){let a=e.startingToken||void 0,o=!0,s;for(;o;){if(t.NextToken=a,e.client instanceof n.SNSClient)s=await r(e.client,t,...i);else throw Error(`Invalid client, expected SNS | SNSClient`);yield s;let c=a;a=s.NextToken,o=!!(a&&(!e.stopOnSameToken||a!==c))}return void 0}e.paginateListSubscriptionsByTopic=i})),Qu=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.paginateListSubscriptions=void 0;let t=er(),n=Vu(),r=async(e,n,...r)=>await e.send(new t.ListSubscriptionsCommand(n),...r);async function*i(e,t,...i){let a=e.startingToken||void 0,o=!0,s;for(;o;){if(t.NextToken=a,e.client instanceof n.SNSClient)s=await r(e.client,t,...i);else throw Error(`Invalid client, expected SNS | SNSClient`);yield s;let c=a;a=s.NextToken,o=!!(a&&(!e.stopOnSameToken||a!==c))}return void 0}e.paginateListSubscriptions=i})),$u=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.paginateListTopics=void 0;let t=nr(),n=Vu(),r=async(e,n,...r)=>await e.send(new t.ListTopicsCommand(n),...r);async function*i(e,t,...i){let a=e.startingToken||void 0,o=!0,s;for(;o;){if(t.NextToken=a,e.client instanceof n.SNSClient)s=await r(e.client,t,...i);else throw Error(`Invalid client, expected SNS | SNSClient`);yield s;let c=a;a=s.NextToken,o=!!(a&&(!e.stopOnSameToken||a!==c))}return void 0}e.paginateListTopics=i})),ed=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=(N(),m(j));t.__exportStar(Gu(),e),t.__exportStar(Ku(),e),t.__exportStar(qu(),e),t.__exportStar(Ju(),e),t.__exportStar(Yu(),e),t.__exportStar(Xu(),e),t.__exportStar(Zu(),e),t.__exportStar(Qu(),e),t.__exportStar($u(),e)})),td=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.SNSServiceException=void 0;let t=(N(),m(j));t.__exportStar(Hu(),e),t.__exportStar(Vu(),e),t.__exportStar(Uu(),e),t.__exportStar(Wu(),e),t.__exportStar(ed(),e);var n=kn();Object.defineProperty(e,`SNSServiceException`,{enumerable:!0,get:function(){return n.SNSServiceException}})})),nd=e=>{let t,n=()=>(t||=e(),t);return n.set=e=>{t=e},n},rd=u(((e,t)=>{t.exports=(e,t=process.argv)=>{let n=e.startsWith(`-`)?``:e.length===1?`-`:`--`,r=t.indexOf(n+e),i=t.indexOf(`--`);return r!==-1&&(i===-1||r<i)}})),id=u(((e,t)=>{let n=h(`os`),r=h(`tty`),i=rd(),{env:a}=process,o;i(`no-color`)||i(`no-colors`)||i(`color=false`)||i(`color=never`)?o=0:(i(`color`)||i(`colors`)||i(`color=true`)||i(`color=always`))&&(o=1),`FORCE_COLOR`in a&&(o=a.FORCE_COLOR===`true`?1:a.FORCE_COLOR===`false`?0:a.FORCE_COLOR.length===0?1:Math.min(parseInt(a.FORCE_COLOR,10),3));function s(e){return e===0?!1:{level:e,hasBasic:!0,has256:e>=2,has16m:e>=3}}function c(e,t){if(o===0)return 0;if(i(`color=16m`)||i(`color=full`)||i(`color=truecolor`))return 3;if(i(`color=256`))return 2;if(e&&!t&&o===void 0)return 0;let r=o||0;if(a.TERM===`dumb`)return r;if(process.platform===`win32`){let e=n.release().split(`.`);return Number(e[0])>=10&&Number(e[2])>=10586?Number(e[2])>=14931?3:2:1}if(`CI`in a)return[`TRAVIS`,`CIRCLECI`,`APPVEYOR`,`GITLAB_CI`,`GITHUB_ACTIONS`,`BUILDKITE`].some(e=>e in a)||a.CI_NAME===`codeship`?1:r;if(`TEAMCITY_VERSION`in a)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(a.TEAMCITY_VERSION)?1:0;if(a.COLORTERM===`truecolor`)return 3;if(`TERM_PROGRAM`in a){let e=parseInt((a.TERM_PROGRAM_VERSION||``).split(`.`)[0],10);switch(a.TERM_PROGRAM){case`iTerm.app`:return e>=3?3:2;case`Apple_Terminal`:return 2}}return/-256(color)?$/i.test(a.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(a.TERM)||`COLORTERM`in a?1:r}function l(e){return s(c(e,e&&e.isTTY))}t.exports={supportsColor:l,stdout:s(c(!0,r.isatty(1))),stderr:s(c(!0,r.isatty(2)))}})),ad=td(),od=nd(()=>new ad.SNSClient({})),sd=e=>{let t={};for(let n in e)t[n]={DataType:`String`,StringValue:e[n]};return t},cd=async({client:e=od(),topic:t,subject:n,payload:r,attributes:i={},region:a=process.env.AWS_REGION,accountId:o=process.env.AWS_ACCOUNT_ID})=>{let s=new ad.PublishCommand({TopicArn:`arn:aws:sns:${a}:${o}:${t}`,Subject:n,Message:r,MessageAttributes:sd({topic:t,...i})});await e.send(s)};const ld=(e,t)=>{let n=process.env.EVENTS_TOPIC;n&&cd({topic:n,payload:ze({event:e,date:new Date,...t}),attributes:{event:e}}).catch(e=>{console.error(`Failed to publish socket event`,e)})},ud=(e,t)=>{let n=me(pe(ne(pe(le(),ee(25),re(e=>typeof e==`string`&&t.includes(e)))),te(1),ee(25)),e);return n.success?{valid:!0,topics:n.output}:{valid:!1,reason:n.issues[0].message}},dd=e=>{ld(`connected`,{socketId:e.data.id,ip:e.data.ip,context:e.data.context})},fd=e=>{hd(e),e.close(),e.data.authenticated&&ld(`disconnected`,{socketId:e.data.id,ip:e.data.ip,context:e.data.context})},pd=(e,t)=>{let n=ud(t,e.data.allowed);if(!n.valid){hd(e),e.close(4e3,`Invalid topic payload`);return}for(let t of n.topics)e.subscribe(t);n.topics.length>0&&ld(`subscribed`,{socketId:e.data.id,ip:e.data.ip,context:e.data.context,topics:n.topics}),e.sendText(`ACK`)},md=(e,t)=>{let n=ud(t,e.data.allowed);if(!n.valid){hd(e),e.close(4e3,`Invalid topic payload`);return}let r=n.topics.filter(t=>e.isSubscribed(t));for(let t of r)e.unsubscribe(t);r.length>0&&ld(`unsubscribed`,{socketId:e.data.id,ip:e.data.ip,context:e.data.context,topics:r}),e.sendText(`ACK`)},hd=e=>{let t=e.subscriptions;for(let n of t)e.unsubscribe(n);t.length>0&&ld(`unsubscribed`,{socketId:e.data.id,ip:e.data.ip,context:e.data.context,topics:t})};var gd=u((e=>{e.HttpAuthLocation=void 0,(function(e){e.HEADER=`header`,e.QUERY=`query`})(e.HttpAuthLocation||={}),e.HttpApiKeyAuthLocation=void 0,(function(e){e.HEADER=`header`,e.QUERY=`query`})(e.HttpApiKeyAuthLocation||={}),e.EndpointURLScheme=void 0,(function(e){e.HTTP=`http`,e.HTTPS=`https`})(e.EndpointURLScheme||={}),e.AlgorithmId=void 0,(function(e){e.MD5=`md5`,e.CRC32=`crc32`,e.CRC32C=`crc32c`,e.SHA1=`sha1`,e.SHA256=`sha256`})(e.AlgorithmId||={});let t=t=>{let n=[];return t.sha256!==void 0&&n.push({algorithmId:()=>e.AlgorithmId.SHA256,checksumConstructor:()=>t.sha256}),t.md5!=null&&n.push({algorithmId:()=>e.AlgorithmId.MD5,checksumConstructor:()=>t.md5}),{addChecksumAlgorithm(e){n.push(e)},checksumAlgorithms(){return n}}},n=e=>{let t={};return e.checksumAlgorithms().forEach(e=>{t[e.algorithmId()]=e.checksumConstructor()}),t};e.FieldPosition=void 0,(function(e){e[e.HEADER=0]=`HEADER`,e[e.TRAILER=1]=`TRAILER`})(e.FieldPosition||={}),e.IniSectionType=void 0,(function(e){e.PROFILE=`profile`,e.SSO_SESSION=`sso-session`,e.SERVICES=`services`})(e.IniSectionType||={}),e.RequestHandlerProtocol=void 0,(function(e){e.HTTP_0_9=`http/0.9`,e.HTTP_1_0=`http/1.0`,e.TDS_8_0=`tds/8.0`})(e.RequestHandlerProtocol||={}),e.SMITHY_CONTEXT_KEY=`__smithy_context`,e.getDefaultClientConfiguration=e=>t(e),e.resolveDefaultRuntimeConfig=e=>n(e)})),_d=u((e=>{var t=gd();let n=e=>({setHttpHandler(t){e.httpHandler=t},httpHandler(){return e.httpHandler},updateHttpClientConfig(t,n){e.httpHandler?.updateHttpClientConfig(t,n)},httpHandlerConfigs(){return e.httpHandler.httpHandlerConfigs()}}),r=e=>({httpHandler:e.httpHandler()});var i=class{name;kind;values;constructor({name:e,kind:n=t.FieldPosition.HEADER,values:r=[]}){this.name=e,this.kind=n,this.values=r}add(e){this.values.push(e)}set(e){this.values=e}remove(e){this.values=this.values.filter(t=>t!==e)}toString(){return this.values.map(e=>e.includes(`,`)||e.includes(` `)?`"${e}"`:e).join(`, `)}get(){return this.values}},a=class{entries={};encoding;constructor({fields:e=[],encoding:t=`utf-8`}){e.forEach(this.setField.bind(this)),this.encoding=t}setField(e){this.entries[e.name.toLowerCase()]=e}getField(e){return this.entries[e.toLowerCase()]}removeField(e){delete this.entries[e.toLowerCase()]}getByType(e){return Object.values(this.entries).filter(t=>t.kind===e)}},o=class e{method;protocol;hostname;port;path;query;headers;username;password;fragment;body;constructor(e){this.method=e.method||`GET`,this.hostname=e.hostname||`localhost`,this.port=e.port,this.query=e.query||{},this.headers=e.headers||{},this.body=e.body,this.protocol=e.protocol?e.protocol.slice(-1)===`:`?e.protocol:`${e.protocol}:`:`https:`,this.path=e.path?e.path.charAt(0)===`/`?e.path:`/${e.path}`:`/`,this.username=e.username,this.password=e.password,this.fragment=e.fragment}static clone(t){let n=new e({...t,headers:{...t.headers}});return n.query&&=s(n.query),n}static isInstance(e){if(!e)return!1;let t=e;return`method`in t&&`protocol`in t&&`hostname`in t&&`path`in t&&typeof t.query==`object`&&typeof t.headers==`object`}clone(){return e.clone(this)}};function s(e){return Object.keys(e).reduce((t,n)=>{let r=e[n];return{...t,[n]:Array.isArray(r)?[...r]:r}},{})}var c=class{statusCode;reason;headers;body;constructor(e){this.statusCode=e.statusCode,this.reason=e.reason,this.headers=e.headers||{},this.body=e.body}static isInstance(e){if(!e)return!1;let t=e;return typeof t.statusCode==`number`&&typeof t.headers==`object`}};function l(e){return/^[a-z0-9][a-z0-9\.\-]*[a-z0-9]$/.test(e)}e.Field=i,e.Fields=a,e.HttpRequest=o,e.HttpResponse=c,e.getHttpHandlerExtensionConfiguration=n,e.isValidHostname=l,e.resolveHttpHandlerRuntimeConfig=r})),vd=u((e=>{var t=_d();function n(e){return e}let r=e=>n=>async r=>{if(!t.HttpRequest.isInstance(r.request))return n(r);let{request:i}=r,{handlerProtocol:a=``}=e.requestHandler.metadata||{};if(a.indexOf(`h2`)>=0&&!i.headers[`:authority`])delete i.headers.host,i.headers[`:authority`]=i.hostname+(i.port?`:`+i.port:``);else if(!i.headers.host){let e=i.hostname;i.port!=null&&(e+=`:${i.port}`),i.headers.host=e}return n(r)},i={name:`hostHeaderMiddleware`,step:`build`,priority:`low`,tags:[`HOST`],override:!0};e.getHostHeaderPlugin=e=>({applyToStack:t=>{t.add(r(e),i)}}),e.hostHeaderMiddleware=r,e.hostHeaderMiddlewareOptions=i,e.resolveHostHeaderConfig=n})),yd=u((e=>{let t=()=>(e,t)=>async n=>{try{let r=await e(n),{clientName:i,commandName:a,logger:o,dynamoDbDocumentClientOptions:s={}}=t,{overrideInputFilterSensitiveLog:c,overrideOutputFilterSensitiveLog:l}=s,u=c??t.inputFilterSensitiveLog,d=l??t.outputFilterSensitiveLog,{$metadata:f,...p}=r.output;return o?.info?.({clientName:i,commandName:a,input:u(n.input),output:d(p),metadata:f}),r}catch(e){let{clientName:r,commandName:i,logger:a,dynamoDbDocumentClientOptions:o={}}=t,{overrideInputFilterSensitiveLog:s}=o,c=s??t.inputFilterSensitiveLog;throw a?.error?.({clientName:r,commandName:i,input:c(n.input),error:e,metadata:e.$metadata}),e}},n={name:`loggerMiddleware`,tags:[`LOGGER`],step:`initialize`,override:!0};e.getLoggerPlugin=e=>({applyToStack:e=>{e.add(t(),n)}}),e.loggerMiddleware=t,e.loggerMiddlewareOptions=n})),bd=d({InvokeStore:()=>Ed,InvokeStoreBase:()=>Cd}),xd,Sd,Cd,wd,Td,Ed,Dd=l((()=>{xd={REQUEST_ID:Symbol.for(`_AWS_LAMBDA_REQUEST_ID`),X_RAY_TRACE_ID:Symbol.for(`_AWS_LAMBDA_X_RAY_TRACE_ID`),TENANT_ID:Symbol.for(`_AWS_LAMBDA_TENANT_ID`)},Sd=[`true`,`1`].includes(process.env?.AWS_LAMBDA_NODEJS_NO_GLOBAL_AWSLAMBDA??``),Sd||(globalThis.awslambda=globalThis.awslambda||{}),Cd=class{static PROTECTED_KEYS=xd;isProtectedKey(e){return Object.values(xd).includes(e)}getRequestId(){return this.get(xd.REQUEST_ID)??`-`}getXRayTraceId(){return this.get(xd.X_RAY_TRACE_ID)}getTenantId(){return this.get(xd.TENANT_ID)}},wd=class extends Cd{currentContext;getContext(){return this.currentContext}hasContext(){return this.currentContext!==void 0}get(e){return this.currentContext?.[e]}set(e,t){if(this.isProtectedKey(e))throw Error(`Cannot modify protected Lambda context field: ${String(e)}`);this.currentContext=this.currentContext||{},this.currentContext[e]=t}run(e,t){return this.currentContext=e,t()}},Td=class e extends Cd{als;static async create(){let t=new e;return t.als=new(await(import(`node:async_hooks`))).AsyncLocalStorage,t}getContext(){return this.als.getStore()}hasContext(){return this.als.getStore()!==void 0}get(e){return this.als.getStore()?.[e]}set(e,t){if(this.isProtectedKey(e))throw Error(`Cannot modify protected Lambda context field: ${String(e)}`);let n=this.als.getStore();if(!n)throw Error(`No context available`);n[e]=t}run(e,t){return this.als.run(e,t)}},(function(e){let t=null;async function n(e){return t||=(async()=>{let t=e===!0||`AWS_LAMBDA_MAX_CONCURRENCY`in process.env?await Td.create():new wd;return!Sd&&globalThis.awslambda?.InvokeStore?globalThis.awslambda.InvokeStore:(!Sd&&globalThis.awslambda&&(globalThis.awslambda.InvokeStore=t),t)})(),t}e.getInstanceAsync=n,e._testing=process.env.AWS_LAMBDA_BENCHMARK_MODE===`1`?{reset:()=>{t=null,globalThis.awslambda?.InvokeStore&&delete globalThis.awslambda.InvokeStore,globalThis.awslambda={InvokeStore:void 0}}}:void 0})(Ed||={})})),Od=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.recursionDetectionMiddleware=void 0;let t=(Dd(),m(bd)),n=_d(),r=`X-Amzn-Trace-Id`;e.recursionDetectionMiddleware=()=>e=>async i=>{let{request:a}=i;if(!n.HttpRequest.isInstance(a))return e(i);let o=Object.keys(a.headers??{}).find(e=>e.toLowerCase()===`x-amzn-trace-id`)??r;if(a.headers.hasOwnProperty(o))return e(i);let s=process.env.AWS_LAMBDA_FUNCTION_NAME,c=process.env._X_AMZN_TRACE_ID,l=(await t.InvokeStore.getInstanceAsync())?.getXRayTraceId()??c,u=e=>typeof e==`string`&&e.length>0;return u(s)&&u(l)&&(a.headers[r]=l),e({...i,request:a})}})),kd=u((e=>{var t=Od();let n={step:`build`,tags:[`RECURSION_DETECTION`],name:`recursionDetectionMiddleware`,override:!0,priority:`low`};e.getRecursionDetectionPlugin=e=>({applyToStack:e=>{e.add(t.recursionDetectionMiddleware(),n)}}),Object.prototype.hasOwnProperty.call(t,`__proto__`)&&!Object.prototype.hasOwnProperty.call(e,`__proto__`)&&Object.defineProperty(e,`__proto__`,{enumerable:!0,value:t.__proto__}),Object.keys(t).forEach(function(n){n!==`default`&&!Object.prototype.hasOwnProperty.call(e,n)&&(e[n]=t[n])})})),Ad,jd,Md=l((()=>{Ad=gd(),jd=e=>e[Ad.SMITHY_CONTEXT_KEY]||(e[Ad.SMITHY_CONTEXT_KEY]={})})),Nd=u((e=>{var t=gd();e.getSmithyContext=e=>e[t.SMITHY_CONTEXT_KEY]||(e[t.SMITHY_CONTEXT_KEY]={}),e.normalizeProvider=e=>{if(typeof e==`function`)return e;let t=Promise.resolve(e);return()=>t}})),Pd,Fd=l((()=>{Pd=(e,t)=>{if(!t||t.length===0)return e;let n=[];for(let r of t)for(let t of e)t.schemeId.split(`#`)[1]===r&&n.push(t);for(let t of e)n.find(({schemeId:e})=>e===t.schemeId)||n.push(t);return n}}));function Id(e){let t=new Map;for(let n of e)t.set(n.schemeId,n);return t}var Ld,Rd,zd=l((()=>{Ld=Nd(),Fd(),Rd=(e,t)=>(n,r)=>async i=>{let a=Pd(e.httpAuthSchemeProvider(await t.httpAuthSchemeParametersProvider(e,r,i.input)),e.authSchemePreference?await e.authSchemePreference():[]),o=Id(e.httpAuthSchemes),s=(0,Ld.getSmithyContext)(r),c=[];for(let n of a){let i=o.get(n.schemeId);if(!i){c.push(`HttpAuthScheme \`${n.schemeId}\` was not enabled for this service.`);continue}let a=i.identityProvider(await t.identityProviderConfigProvider(e));if(!a){c.push(`HttpAuthScheme \`${n.schemeId}\` did not have an IdentityProvider configured.`);continue}let{identityProperties:l={},signingProperties:u={}}=n.propertiesExtractor?.(e,r)||{};n.identityProperties=Object.assign(n.identityProperties||{},l),n.signingProperties=Object.assign(n.signingProperties||{},u),s.selectedHttpAuthScheme={httpAuthOption:n,identity:await a(n.identityProperties),signer:i.signer};break}if(!s.selectedHttpAuthScheme)throw Error(c.join(`
29
29
  `));return n(i)}})),Bd,Vd,Hd=l((()=>{zd(),Bd={step:`serialize`,tags:[`HTTP_AUTH_SCHEME`],name:`httpAuthSchemeMiddleware`,override:!0,relation:`before`,toMiddleware:`endpointV2Middleware`},Vd=(e,{httpAuthSchemeParametersProvider:t,identityProviderConfigProvider:n})=>({applyToStack:r=>{r.addRelativeTo(Rd(e,{httpAuthSchemeParametersProvider:t,identityProviderConfigProvider:n}),Bd)}})})),Ud,Wd,Gd=l((()=>{zd(),Ud={step:`serialize`,tags:[`HTTP_AUTH_SCHEME`],name:`httpAuthSchemeMiddleware`,override:!0,relation:`before`,toMiddleware:`serializerMiddleware`},Wd=(e,{httpAuthSchemeParametersProvider:t,identityProviderConfigProvider:n})=>({applyToStack:r=>{r.addRelativeTo(Rd(e,{httpAuthSchemeParametersProvider:t,identityProviderConfigProvider:n}),Ud)}})})),Kd=l((()=>{zd(),Hd(),Gd()})),qd,Jd,Yd,Xd,Zd,Qd=l((()=>{qd=_d(),Jd=Nd(),Yd=e=>e=>{throw e},Xd=(e,t)=>{},Zd=e=>(e,t)=>async n=>{if(!qd.HttpRequest.isInstance(n.request))return e(n);let r=(0,Jd.getSmithyContext)(t).selectedHttpAuthScheme;if(!r)throw Error(`No HttpAuthScheme was selected: unable to sign request`);let{httpAuthOption:{signingProperties:i={}},identity:a,signer:o}=r,s=await e({...n,request:await o.sign(n.request,a,i)}).catch((o.errorHandler||Yd)(i));return(o.successHandler||Xd)(s.response,i),s}})),$d,ef,tf=l((()=>{Qd(),$d={step:`finalizeRequest`,tags:[`HTTP_SIGNING`],name:`httpSigningMiddleware`,aliases:[`apiKeyMiddleware`,`tokenMiddleware`,`awsAuthMiddleware`],override:!0,relation:`after`,toMiddleware:`retryMiddleware`},ef=e=>({applyToStack:t=>{t.addRelativeTo(Zd(e),$d)}})})),nf=l((()=>{Qd(),tf()})),rf,af=l((()=>{rf=e=>{if(typeof e==`function`)return e;let t=Promise.resolve(e);return()=>t}}));function of(e,t,n,r,i){return async function*(a,o,...s){let c=o,l=a.startingToken??c[n],u=!0,d;for(;u;){if(c[n]=l,i&&(c[i]=c[i]??a.pageSize),a.client instanceof e)d=await sf(t,a.client,o,a.withCommand,...s);else throw Error(`Invalid client, expected instance of ${e.name}`);yield d;let f=l;l=cf(d,r),u=!!(l&&(!a.stopOnSameToken||l!==f))}return void 0}}var sf,cf,lf=l((()=>{sf=async(e,t,n,r=e=>e,...i)=>{let a=new e(n);return a=r(a)??a,await t.send(a,...i)},cf=(e,t)=>{let n=e,r=t.split(`.`);for(let e of r){if(!n||typeof n!=`object`)return;n=n[e]}return n}})),uf=u((e=>{e.isArrayBuffer=e=>typeof ArrayBuffer==`function`&&e instanceof ArrayBuffer||Object.prototype.toString.call(e)===`[object ArrayBuffer]`})),df=u((e=>{var t=uf(),n=h(`buffer`);e.fromArrayBuffer=(e,r=0,i=e.byteLength-r)=>{if(!t.isArrayBuffer(e))throw TypeError(`The "input" argument must be ArrayBuffer. Received type ${typeof e} (${e})`);return n.Buffer.from(e,r,i)},e.fromString=(e,t)=>{if(typeof e!=`string`)throw TypeError(`The "input" argument must be of type string. Received type ${typeof e} (${e})`);return t?n.Buffer.from(e,t):n.Buffer.from(e)}})),ff=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.fromBase64=void 0;let t=df(),n=/^[A-Za-z0-9+/]*={0,2}$/;e.fromBase64=e=>{if(e.length*3%4!=0)throw TypeError(`Incorrect padding on base64 string.`);if(!n.exec(e))throw TypeError(`Invalid base64 string.`);let r=(0,t.fromString)(e,`base64`);return new Uint8Array(r.buffer,r.byteOffset,r.byteLength)}})),pf=u((e=>{var t=df();let n=e=>{let n=t.fromString(e,`utf8`);return new Uint8Array(n.buffer,n.byteOffset,n.byteLength/Uint8Array.BYTES_PER_ELEMENT)};e.fromUtf8=n,e.toUint8Array=e=>typeof e==`string`?n(e):ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength/Uint8Array.BYTES_PER_ELEMENT):new Uint8Array(e),e.toUtf8=e=>{if(typeof e==`string`)return e;if(typeof e!=`object`||typeof e.byteOffset!=`number`||typeof e.byteLength!=`number`)throw Error(`@smithy/util-utf8: toUtf8 encoder function only accepts string | Uint8Array.`);return t.fromArrayBuffer(e.buffer,e.byteOffset,e.byteLength).toString(`utf8`)}})),mf=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.toBase64=void 0;let t=df(),n=pf();e.toBase64=e=>{let r;if(r=typeof e==`string`?(0,n.fromUtf8)(e):e,typeof r!=`object`||typeof r.byteOffset!=`number`||typeof r.byteLength!=`number`)throw Error(`@smithy/util-base64: toBase64 encoder function only accepts string | Uint8Array.`);return(0,t.fromArrayBuffer)(r.buffer,r.byteOffset,r.byteLength).toString(`base64`)}})),hf=u((e=>{var t=ff(),n=mf();Object.prototype.hasOwnProperty.call(t,`__proto__`)&&!Object.prototype.hasOwnProperty.call(e,`__proto__`)&&Object.defineProperty(e,`__proto__`,{enumerable:!0,value:t.__proto__}),Object.keys(t).forEach(function(n){n!==`default`&&!Object.prototype.hasOwnProperty.call(e,n)&&(e[n]=t[n])}),Object.prototype.hasOwnProperty.call(n,`__proto__`)&&!Object.prototype.hasOwnProperty.call(e,`__proto__`)&&Object.defineProperty(e,`__proto__`,{enumerable:!0,value:n.__proto__}),Object.keys(n).forEach(function(t){t!==`default`&&!Object.prototype.hasOwnProperty.call(e,t)&&(e[t]=n[t])})})),gf=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.ChecksumStream=void 0;let t=hf(),n=h(`stream`);e.ChecksumStream=class extends n.Duplex{expectedChecksum;checksumSourceLocation;checksum;source;base64Encoder;pendingCallback=null;constructor({expectedChecksum:e,checksum:n,source:r,checksumSourceLocation:i,base64Encoder:a}){if(super(),typeof r.pipe==`function`)this.source=r;else throw Error(`@smithy/util-stream: unsupported source type ${r?.constructor?.name??r} in ChecksumStream.`);this.base64Encoder=a??t.toBase64,this.expectedChecksum=e,this.checksum=n,this.checksumSourceLocation=i,this.source.pipe(this)}_read(e){if(this.pendingCallback){let e=this.pendingCallback;this.pendingCallback=null,e()}}_write(e,t,n){try{if(this.checksum.update(e),!this.push(e)){this.pendingCallback=n;return}}catch(e){return n(e)}return n()}async _final(e){try{let t=await this.checksum.digest(),n=this.base64Encoder(t);if(this.expectedChecksum!==n)return e(Error(`Checksum mismatch: expected "${this.expectedChecksum}" but received "${n}" in response header "${this.checksumSourceLocation}".`))}catch(t){return e(t)}return this.push(null),e()}}})),_f=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.isBlob=e.isReadableStream=void 0,e.isReadableStream=e=>typeof ReadableStream==`function`&&(e?.constructor?.name===ReadableStream.name||e instanceof ReadableStream),e.isBlob=e=>typeof Blob==`function`&&(e?.constructor?.name===Blob.name||e instanceof Blob)})),vf=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.ChecksumStream=void 0;let t=typeof ReadableStream==`function`?ReadableStream:function(){};e.ChecksumStream=class extends t{}})),yf=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.createChecksumStream=void 0;let t=hf(),n=_f(),r=vf();e.createChecksumStream=({expectedChecksum:e,checksum:i,source:a,checksumSourceLocation:o,base64Encoder:s})=>{if(!(0,n.isReadableStream)(a))throw Error(`@smithy/util-stream: unsupported source type ${a?.constructor?.name??a} in ChecksumStream.`);let c=s??t.toBase64;if(typeof TransformStream!=`function`)throw Error(`@smithy/util-stream: unable to instantiate ChecksumStream because API unavailable: ReadableStream/TransformStream.`);let l=new TransformStream({start(){},async transform(e,t){i.update(e),t.enqueue(e)},async flush(t){let n=c(await i.digest());if(e!==n){let r=Error(`Checksum mismatch: expected "${e}" but received "${n}" in response header "${o}".`);t.error(r)}else t.terminate()}});a.pipeThrough(l);let u=l.readable;return Object.setPrototypeOf(u,r.ChecksumStream.prototype),u}})),bf=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.createChecksumStream=i;let t=_f(),n=gf(),r=yf();function i(e){return typeof ReadableStream==`function`&&(0,t.isReadableStream)(e.source)?(0,r.createChecksumStream)(e):new n.ChecksumStream(e)}})),xf=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.ByteArrayCollector=void 0,e.ByteArrayCollector=class{allocByteArray;byteLength=0;byteArrays=[];constructor(e){this.allocByteArray=e}push(e){this.byteArrays.push(e),this.byteLength+=e.byteLength}flush(){if(this.byteArrays.length===1){let e=this.byteArrays[0];return this.reset(),e}let e=this.allocByteArray(this.byteLength),t=0;for(let n=0;n<this.byteArrays.length;++n){let r=this.byteArrays[n];e.set(r,t),t+=r.byteLength}return this.reset(),e}reset(){this.byteArrays=[],this.byteLength=0}}})),Sf=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.createBufferedReadable=void 0,e.createBufferedReadableStream=n,e.merge=r,e.flush=i,e.sizeOf=a,e.modeOf=o;let t=xf();function n(e,n,s){let c=e.getReader(),l=!1,u=0,d=[``,new t.ByteArrayCollector(e=>new Uint8Array(e))],f=-1,p=async e=>{let{value:t,done:m}=await c.read(),h=t;if(m){if(f!==-1){let t=i(d,f);a(t)>0&&e.enqueue(t)}e.close()}else{let t=o(h,!1);if(f!==t&&(f>=0&&e.enqueue(i(d,f)),f=t),f===-1){e.enqueue(h);return}let c=a(h);u+=c;let m=a(d[f]);if(c>=n&&m===0)e.enqueue(h);else{let t=r(d,f,h);!l&&u>n*2&&(l=!0,s?.warn(`@smithy/util-stream - stream chunk size ${c} is below threshold of ${n}, automatically buffering.`)),t>=n?e.enqueue(i(d,f)):await p(e)}}};return new ReadableStream({pull:p})}e.createBufferedReadable=n;function r(e,t,n){switch(t){case 0:return e[0]+=n,a(e[0]);case 1:case 2:return e[t].push(n),a(e[t])}}function i(e,t){switch(t){case 0:let n=e[0];return e[0]=``,n;case 1:case 2:return e[t].flush()}throw Error(`@smithy/util-stream - invalid index ${t} given to flush()`)}function a(e){return e?.byteLength??e?.length??0}function o(e,t=!0){return t&&typeof Buffer<`u`&&e instanceof Buffer?2:e instanceof Uint8Array?1:typeof e==`string`?0:-1}})),Cf=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.createBufferedReadable=a;let t=h(`node:stream`),n=xf(),r=Sf(),i=_f();function a(e,a,o){if((0,i.isReadableStream)(e))return(0,r.createBufferedReadableStream)(e,a,o);let s=new t.Readable({read(){}}),c=!1,l=0,u=[``,new n.ByteArrayCollector(e=>new Uint8Array(e)),new n.ByteArrayCollector(e=>Buffer.from(new Uint8Array(e)))],d=-1;return e.on(`data`,e=>{let t=(0,r.modeOf)(e,!0);if(d!==t&&(d>=0&&s.push((0,r.flush)(u,d)),d=t),d===-1){s.push(e);return}let n=(0,r.sizeOf)(e);l+=n;let i=(0,r.sizeOf)(u[d]);if(n>=a&&i===0)s.push(e);else{let t=(0,r.merge)(u,d,e);!c&&l>a*2&&(c=!0,o?.warn(`@smithy/util-stream - stream chunk size ${n} is below threshold of ${a}, automatically buffering.`)),t>=a&&s.push((0,r.flush)(u,d))}}),e.on(`end`,()=>{if(d!==-1){let e=(0,r.flush)(u,d);(0,r.sizeOf)(e)>0&&s.push(e)}s.push(null)}),s}})),wf=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.getAwsChunkedEncodingStream=void 0,e.getAwsChunkedEncodingStream=(e,t)=>{let{base64Encoder:n,bodyLengthChecker:r,checksumAlgorithmFn:i,checksumLocationName:a,streamHasher:o}=t,s=n!==void 0&&r!==void 0&&i!==void 0&&a!==void 0&&o!==void 0,c=s?o(i,e):void 0,l=e.getReader();return new ReadableStream({async pull(e){let{value:t,done:i}=await l.read();if(i){if(e.enqueue(`0\r
30
30
  `),s){let t=n(await c);e.enqueue(`${a}:${t}\r\n`),e.enqueue(`\r
31
31
  `)}e.close()}else e.enqueue(`${(r(t)||0).toString(16)}\r\n${t}\r\n`)}})}})),Tf=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.getAwsChunkedEncodingStream=i;let t=h(`node:stream`),n=wf(),r=_f();function i(e,i){let a=e,o=e;if((0,r.isReadableStream)(o))return(0,n.getAwsChunkedEncodingStream)(o,i);let{base64Encoder:s,bodyLengthChecker:c,checksumAlgorithmFn:l,checksumLocationName:u,streamHasher:d}=i,f=s!==void 0&&l!==void 0&&u!==void 0&&d!==void 0,p=f?d(l,a):void 0,m=new t.Readable({read:()=>{}});return a.on(`data`,e=>{let t=c(e)||0;t!==0&&(m.push(`${t.toString(16)}\r\n`),m.push(e),m.push(`\r
@@ -233,4 +233,4 @@ $`+Buffer.byteLength(this.name)+`\r
233
233
  `+n+`\r
234
234
  `}}return t}stringifyArguments(){for(let e=0;e<this.args.length;++e){let t=this.args[e];typeof t==`string`||(t instanceof Buffer?this.bufferMode=!0:this.args[e]=(0,i.toArg)(t))}}transformReply(t){this.replyEncoding&&(t=(0,i.convertBufferToString)(t,this.replyEncoding));let n=e._transformer.reply[this.name];return n&&(t=n(t)),t}setTimeout(e){this._commandTimeoutTimer||=setTimeout(()=>{this.isResolved||this.reject(Error(`Command timed out`))},e)}setBlockingTimeout(e){if(e<=0)return;this._blockingTimeoutTimer&&=(clearTimeout(this._blockingTimeoutTimer),void 0);let t=Date.now();this._blockingDeadline===void 0&&(this._blockingDeadline=t+e);let n=this._blockingDeadline-t;if(n<=0){this.resolve(null);return}this._blockingTimeoutTimer=setTimeout(()=>{if(this.isResolved){this._blockingTimeoutTimer=void 0;return}this._blockingTimeoutTimer=void 0,this.resolve(null)},n)}extractBlockingTimeout(){let t=this.args;if(!t||t.length===0)return;let n=this.name.toLowerCase();if(e.checkFlag(`LAST_ARG_TIMEOUT_COMMANDS`,n))return(0,a.parseSecondsArgument)(t[t.length-1]);if(e.checkFlag(`FIRST_ARG_TIMEOUT_COMMANDS`,n))return(0,a.parseSecondsArgument)(t[0]);if(e.checkFlag(`BLOCK_OPTION_COMMANDS`,n))return(0,a.parseBlockOption)(t)}_clearTimers(){let e=this._commandTimeoutTimer;e&&(clearTimeout(e),delete this._commandTimeoutTimer);let t=this._blockingTimeoutTimer;t&&(clearTimeout(t),delete this._blockingTimeoutTimer)}initPromise(){let t=new Promise((t,n)=>{if(!this.transformed){this.transformed=!0;let t=e._transformer.argument[this.name];t&&(this.args=t(this.args)),this.stringifyArguments()}this.resolve=this._convertValue(t),this.reject=e=>{this._clearTimers(),this.errorStack?n((0,i.optimizeErrorStack)(e,this.errorStack.stack,__dirname)):n(e)}});this.promise=(0,r.default)(t,this.callback)}_iterateKeys(e=e=>e){if(this.keys===void 0&&(this.keys=[],(0,t.exists)(this.name,{caseInsensitive:!0}))){let n=(0,t.getKeyIndexes)(this.name,this.args,{nameCaseInsensitive:!0});for(let t of n)this.args[t]=e(this.args[t]),this.keys.push(this.args[t])}return this.keys}_convertValue(e){return t=>{try{this._clearTimers(),e(this.transformReply(t)),this.isResolved=!0}catch(e){this.reject(e)}return this.promise}}};e.default=o,o.FLAGS={VALID_IN_SUBSCRIBER_MODE:[`subscribe`,`psubscribe`,`unsubscribe`,`punsubscribe`,`ssubscribe`,`sunsubscribe`,`ping`,`quit`],VALID_IN_MONITOR_MODE:[`monitor`,`auth`],ENTER_SUBSCRIBER_MODE:[`subscribe`,`psubscribe`,`ssubscribe`],EXIT_SUBSCRIBER_MODE:[`unsubscribe`,`punsubscribe`,`sunsubscribe`],WILL_DISCONNECT:[`quit`],HANDSHAKE_COMMANDS:[`auth`,`select`,`client`,`readonly`,`info`],IGNORE_RECONNECT_ON_ERROR:[`client`],BLOCKING_COMMANDS:[`blpop`,`brpop`,`brpoplpush`,`blmove`,`bzpopmin`,`bzpopmax`,`bzmpop`,`blmpop`,`xread`,`xreadgroup`],LAST_ARG_TIMEOUT_COMMANDS:[`blpop`,`brpop`,`brpoplpush`,`blmove`,`bzpopmin`,`bzpopmax`],FIRST_ARG_TIMEOUT_COMMANDS:[`bzmpop`,`blmpop`],BLOCK_OPTION_COMMANDS:[`xread`,`xreadgroup`]},o._transformer={argument:{},reply:{}};let s=function(e){if(e.length===1){if(e[0]instanceof Map)return(0,i.convertMapToArray)(e[0]);if(typeof e[0]==`object`&&e[0]!==null)return(0,i.convertObjectToArray)(e[0])}return e},c=function(e){if(e.length===2){if(e[1]instanceof Map)return[e[0]].concat((0,i.convertMapToArray)(e[1]));if(typeof e[1]==`object`&&e[1]!==null)return[e[0]].concat((0,i.convertObjectToArray)(e[1]))}return e};o.setArgumentTransformer(`mset`,s),o.setArgumentTransformer(`msetnx`,s),o.setArgumentTransformer(`hset`,c),o.setArgumentTransformer(`hmset`,c),o.setReplyTransformer(`hgetall`,function(e){if(Array.isArray(e)){let t={};for(let n=0;n<e.length;n+=2){let r=e[n],i=e[n+1];r in t?Object.defineProperty(t,r,{value:i,configurable:!0,enumerable:!0,writable:!0}):t[r]=i}return t}return e});var l=class{constructor(){this.length=0,this.items=[]}push(e){this.length+=Buffer.byteLength(e),this.items.push(e)}toBuffer(){let e=Buffer.allocUnsafe(this.length),t=0;for(let n of this.items){let r=Buffer.byteLength(n);Buffer.isBuffer(n)?n.copy(e,t):e.write(n,t,r),t+=r}return e}}})),vF=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=rF();var n=class extends t.RedisError{constructor(e,t){super(e),this.lastNodeError=t,Error.captureStackTrace(this,this.constructor)}get name(){return this.constructor.name}};e.default=n,n.defaultMessage=`Failed to refresh slots cache.`})),yF=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=h(`stream`);e.default=class extends t.Readable{constructor(e){super(e),this.opt=e,this._redisCursor=`0`,this._redisDrained=!1}_read(){if(this._redisDrained){this.push(null);return}let e=[this._redisCursor];this.opt.key&&e.unshift(this.opt.key),this.opt.match&&e.push(`MATCH`,this.opt.match),this.opt.type&&e.push(`TYPE`,this.opt.type),this.opt.count&&e.push(`COUNT`,String(this.opt.count)),this.opt.noValues&&e.push(`NOVALUES`),this.opt.redis[this.opt.command](e,(e,t)=>{if(e){this.emit(`error`,e);return}this._redisCursor=t[0]instanceof Buffer?t[0].toString():t[0],this._redisCursor===`0`&&(this._redisDrained=!0),this.push(t[1])})}close(){this._redisDrained=!0}}})),bF=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.executeWithAutoPipelining=e.getFirstValueInFlattenedArray=e.shouldUseAutoPipelining=e.notAllowedAutoPipelineCommands=e.kCallbacks=e.kExec=void 0;let t=sF(),n=iF(),r=eF(),i=QP();e.kExec=Symbol(`exec`),e.kCallbacks=Symbol(`callbacks`),e.notAllowedAutoPipelineCommands=[`auth`,`info`,`script`,`quit`,`cluster`,`pipeline`,`multi`,`subscribe`,`psubscribe`,`unsubscribe`,`unpsubscribe`,`select`,`client`];function a(t,n){if(t._runningAutoPipelines.has(n)||!t._autoPipelines.has(n))return;t._runningAutoPipelines.add(n);let r=t._autoPipelines.get(n);t._autoPipelines.delete(n);let i=r[e.kCallbacks];r[e.kCallbacks]=null,r.exec(function(e,r){if(t._runningAutoPipelines.delete(n),e)for(let t=0;t<i.length;t++)process.nextTick(i[t],e);else for(let e=0;e<i.length;e++)process.nextTick(i[e],...r[e]);t._autoPipelines.has(n)&&a(t,n)})}function o(t,n,r){return n&&t.options.enableAutoPipelining&&!t.isPipeline&&!e.notAllowedAutoPipelineCommands.includes(r)&&!t.options.autoPipeliningIgnoredCommands.includes(r)}e.shouldUseAutoPipelining=o;function s(e){for(let n=0;n<e.length;n++){let r=e[n];if(typeof r==`string`)return r;if(Array.isArray(r)||(0,t.isArguments)(r)){if(r.length===0)continue;return r[0]}let i=[r].flat();if(i.length>0)return i[0]}}e.getFirstValueInFlattenedArray=s;function c(o,l,u,d,f){if(o.isCluster&&!o.slots.length)return o.status===`wait`&&o.connect().catch(t.noop),(0,r.default)(new Promise(function(e,t){o.delayUntilReady(n=>{if(n){t(n);return}c(o,l,u,d,null).then(e,t)})}),f);let p=o.options.keyPrefix||``,m=o.isCluster?o.slots[n(`${p}${s(d)}`)].join(`,`):`main`;if(o.isCluster&&o.options.scaleReads!==`master`){let e=(0,i.exists)(u)&&(0,i.hasFlag)(u,`readonly`);m+=e?`:read`:`:write`}if(!o._autoPipelines.has(m)){let t=o.pipeline();t[e.kExec]=!1,t[e.kCallbacks]=[],o._autoPipelines.set(m,t)}let h=o._autoPipelines.get(m);h[e.kExec]||(h[e.kExec]=!0,setImmediate(a,o,m));let g=new Promise(function(t,n){h[e.kCallbacks].push(function(e,r){if(e){n(e);return}t(r)}),l===`call`&&d.unshift(u),h[l](...d)});return(0,r.default)(g,f)}e.executeWithAutoPipelining=c})),xF=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=h(`crypto`),n=_F(),r=eF();e.default=class{constructor(e,r=null,i=``,a=!1){this.lua=e,this.numberOfKeys=r,this.keyPrefix=i,this.readOnly=a,this.sha=(0,t.createHash)(`sha1`).update(e).digest(`hex`);let o=this.sha,s=new WeakSet;this.Command=class extends n.default{toWritable(t){let n=this.reject;return this.reject=e=>{e.message.indexOf(`NOSCRIPT`)!==-1&&s.delete(t),n.call(this,e)},s.has(t)?this.name===`eval`&&(this.name=`evalsha`,this.args[0]=o):(s.add(t),this.name=`eval`,this.args[0]=e),super.toWritable(t)}}}execute(e,t,n,i){typeof this.numberOfKeys==`number`&&t.unshift(this.numberOfKeys),this.keyPrefix&&(n.keyPrefix=this.keyPrefix),this.readOnly&&(n.readOnly=!0);let a=new this.Command(`evalsha`,[this.sha,...t],n);return a.promise=a.promise.catch(r=>{if(r.message.indexOf(`NOSCRIPT`)===-1)throw r;let i=new this.Command(`evalsha`,[this.sha,...t],n);return(e.isPipeline?e.redis:e).sendCommand(i)}),(0,r.default)(a.promise,i),e.sendCommand(a)}}})),SF=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=QP(),n=bF(),r=_F(),i=xF();var a=class{constructor(){this.options={},this.scriptsSet={},this.addedBuiltinSet=new Set}getBuiltinCommands(){return o.slice(0)}createBuiltinCommand(e){return{string:s(null,e,`utf8`),buffer:s(null,e,null)}}addBuiltinCommand(e){this.addedBuiltinSet.add(e),this[e]=s(e,e,`utf8`),this[e+`Buffer`]=s(e+`Buffer`,e,null)}defineCommand(e,t){let n=new i.default(t.lua,t.numberOfKeys,this.options.keyPrefix,t.readOnly);this.scriptsSet[e]=n,this[e]=c(e,e,n,`utf8`),this[e+`Buffer`]=c(e+`Buffer`,e,n,null)}sendCommand(e,t,n){throw Error(`"sendCommand" is not implemented`)}};let o=t.list.filter(e=>e!==`monitor`);o.push(`sentinel`),o.forEach(function(e){a.prototype[e]=s(e,e,`utf8`),a.prototype[e+`Buffer`]=s(e+`Buffer`,e,null)}),a.prototype.call=s(`call`,`utf8`),a.prototype.callBuffer=s(`callBuffer`,null),a.prototype.send_command=a.prototype.call;function s(e,t,i){return i===void 0&&(i=t,t=null),function(...a){let o=t||a.shift(),s=a[a.length-1];typeof s==`function`?a.pop():s=void 0;let c={errorStack:this.options.showFriendlyErrorStack?Error():void 0,keyPrefix:this.options.keyPrefix,replyEncoding:i};return(0,n.shouldUseAutoPipelining)(this,e,o)?(0,n.executeWithAutoPipelining)(this,e,o,a,s):this.sendCommand(new r.default(o,a,c,s))}}function c(e,t,r,i){return function(...a){let o=typeof a[a.length-1]==`function`?a.pop():void 0,s={replyEncoding:i};return this.options.showFriendlyErrorStack&&(s.errorStack=Error()),(0,n.shouldUseAutoPipelining)(this,e,t)?(0,n.executeWithAutoPipelining)(this,e,t,a,o):r.execute(this,a,s,o)}}e.default=a})),CF=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=iF(),n=QP(),r=eF(),i=h(`util`),a=_F(),o=hF(),s=SF();function c(e,n){let r=t(n[0]),i=e._groupsBySlot[r];for(let r=1;r<n.length;r++)if(e._groupsBySlot[t(n[r])]!==i)return-1;return r}var l=class extends s.default{constructor(e){super(),this.redis=e,this.isPipeline=!0,this.replyPending=0,this._queue=[],this._result=[],this._transactions=0,this._shaToScript={},this.isCluster=this.redis.constructor.name===`Cluster`||this.redis.isCluster,this.options=e.options,Object.keys(e.scriptsSet).forEach(t=>{let n=e.scriptsSet[t];this._shaToScript[n.sha]=n,this[t]=e[t],this[t+`Buffer`]=e[t+`Buffer`]}),e.addedBuiltinSet.forEach(t=>{this[t]=e[t],this[t+`Buffer`]=e[t+`Buffer`]}),this.promise=new Promise((e,t)=>{this.resolve=e,this.reject=t});let t=this;Object.defineProperty(this,`length`,{get:function(){return t._queue.length}})}fillResult(e,t){if(this._queue[t].name===`exec`&&Array.isArray(e[1])){let n=e[1].length;for(let r=0;r<n;r++){if(e[1][r]instanceof Error)continue;let i=this._queue[t-(n-r)];try{e[1][r]=i.transformReply(e[1][r])}catch(t){e[1][r]=t}}}if(this._result[t]=e,--this.replyPending)return;if(this.isCluster){let e=!0,t;for(let r=0;r<this._result.length;++r){let i=this._result[r][0],a=this._queue[r];if(i){if(a.name===`exec`&&i.message===`EXECABORT Transaction discarded because of previous errors.`)continue;if(!t)t={name:i.name,message:i.message};else if(t.name!==i.name||t.message!==i.message){e=!1;break}}else if(!a.inTransaction&&!((0,n.exists)(a.name,{caseInsensitive:!0})&&(0,n.hasFlag)(a.name,`readonly`,{nameCaseInsensitive:!0}))){e=!1;break}}if(t&&e){let e=this,n=t.message.split(` `),r=this._queue,i=!1;this._queue=[];for(let e=0;e<r.length;++e){if(n[0]===`ASK`&&!i&&r[e].name!==`asking`&&(!r[e-1]||r[e-1].name!==`asking`)){let e=new a.default(`asking`);e.ignore=!0,this.sendCommand(e)}r[e].initPromise(),this.sendCommand(r[e]),i=r[e].inTransaction}let o=!0;this.leftRedirections===void 0&&(this.leftRedirections={});let s=function(){e.exec()},c=this.redis;if(c.handleError(t,this.leftRedirections,{moved:function(t,r){e.preferKey=r,c.slots[n[1]]?c.slots[n[1]][0]!==r&&(c.slots[n[1]]=[r]):c.slots[n[1]]=[r],c._groupsBySlot[n[1]]=c._groupsIds[c.slots[n[1]].join(`;`)],c.refreshSlotsCache(),e.exec()},ask:function(t,n){e.preferKey=n,e.exec()},tryagain:s,clusterDown:s,connectionClosed:s,maxRedirections:()=>{o=!1},defaults:()=>{o=!1}}),o)return}}let r=0;for(let e=0;e<this._queue.length-r;++e)this._queue[e+r].ignore&&(r+=1),this._result[e]=this._result[e+r];this.resolve(this._result.slice(0,this._result.length-r))}sendCommand(e){this._transactions>0&&(e.inTransaction=!0);let t=this._queue.length;return e.pipelineIndex=t,e.promise.then(e=>{this.fillResult([null,e],t)}).catch(e=>{this.fillResult([e],t)}),this._queue.push(e),this}addBatch(e){let t,n,r;for(let i=0;i<e.length;++i)t=e[i],n=t[0],r=t.slice(1),this[n].apply(this,r);return this}};e.default=l;let u=l.prototype.multi;l.prototype.multi=function(){return this._transactions+=1,u.apply(this,arguments)};let d=l.prototype.execBuffer;l.prototype.execBuffer=(0,i.deprecate)(function(){return this._transactions>0&&--this._transactions,d.apply(this,arguments)},`Pipeline#execBuffer: Use Pipeline#exec instead`),l.prototype.exec=function(e){if(this.isCluster&&!this.redis.slots.length)return this.redis.status===`wait`&&this.redis.connect().catch(o.noop),e&&!this.nodeifiedPromise&&(this.nodeifiedPromise=!0,(0,r.default)(this.promise,e)),this.redis.delayUntilReady(t=>{if(t){this.reject(t);return}this.exec(e)}),this.promise;if(this._transactions>0)return--this._transactions,d.apply(this,arguments);this.nodeifiedPromise||(this.nodeifiedPromise=!0,(0,r.default)(this.promise,e)),this._queue.length||this.resolve([]);let n;if(this.isCluster){let e=[];for(let n=0;n<this._queue.length;n++){let r=this._queue[n].getKeys();if(r.length&&e.push(r[0]),r.length&&t.generateMulti(r)<0)return this.reject(Error(`All the keys in a pipeline command should belong to the same slot`)),this.promise}if(e.length){if(n=c(this.redis,e),n<0)return this.reject(Error(`All keys in the pipeline should belong to the same slots allocation group`)),this.promise}else n=Math.random()*16384|0}let i=this;return a(),this.promise;function a(){let e=i.replyPending=i._queue.length,t;i.isCluster&&(t={slot:n,redis:i.redis.connectionPool.nodes.all[i.preferKey]});let r=``,a,o={isPipeline:!0,destination:i.isCluster?t:{redis:i.redis},write(t){typeof t==`string`?r+=t:(a||=[],r&&=(a.push(Buffer.from(r,`utf8`)),``),a.push(t)),--e||(a?(r&&a.push(Buffer.from(r,`utf8`)),o.destination.redis.stream.write(Buffer.concat(a))):o.destination.redis.stream.write(r),e=i._queue.length,r=``,a=void 0)}};for(let e=0;e<i._queue.length;++e)i.redis.sendCommand(i._queue[e],o,t);return i.promise}}})),wF=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.addTransactionSupport=void 0;let t=hF(),n=eF(),r=CF();function i(e){e.pipeline=function(e){let t=new r.default(this);return Array.isArray(e)&&t.addBatch(e),t};let{multi:i}=e;e.multi=function(e,a){if(a===void 0&&!Array.isArray(e)&&(a=e,e=null),a&&a.pipeline===!1)return i.call(this);let o=new r.default(this);o.multi(),Array.isArray(e)&&o.addBatch(e);let s=o.exec;o.exec=function(e){if(this.isCluster&&!this.redis.slots.length)return this.redis.status===`wait`&&this.redis.connect().catch(t.noop),(0,n.default)(new Promise((e,t)=>{this.redis.delayUntilReady(n=>{if(n){t(n);return}this.exec(o).then(e,t)})}),e);if(this._transactions>0&&s.call(o),this.nodeifiedPromise)return s.call(o);let r=s.call(o);return(0,n.default)(r.then(function(e){let n=e[e.length-1];if(n===void 0)throw Error("Pipeline cannot be used to send any commands when the `exec()` has been called on it.");if(n[0]){n[0].previousErrors=[];for(let t=0;t<e.length-1;++t)e[t][0]&&n[0].previousErrors.push(e[t][0]);throw n[0]}return(0,t.wrapMultiResult)(n[1])}),e)};let{execBuffer:c}=o;return o.execBuffer=function(e){return this._transactions>0&&c.call(o),o.exec(e)},o};let{exec:a}=e;e.exec=function(e){return(0,n.default)(a.call(this).then(function(e){return Array.isArray(e)&&(e=(0,t.wrapMultiResult)(e)),e}),e)}}e.addTransactionSupport=i})),TF=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0});function t(e,t){Object.getOwnPropertyNames(t.prototype).forEach(n=>{Object.defineProperty(e.prototype,n,Object.getOwnPropertyDescriptor(t.prototype,n))})}e.default=t})),EF=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.DEFAULT_CLUSTER_OPTIONS=void 0;let t=h(`dns`);e.DEFAULT_CLUSTER_OPTIONS={clusterRetryStrategy:e=>Math.min(100+e*2,2e3),enableOfflineQueue:!0,enableReadyCheck:!0,scaleReads:`master`,maxRedirections:16,retryDelayOnMoved:0,retryDelayOnFailover:100,retryDelayOnClusterDown:100,retryDelayOnTryAgain:100,slotsRefreshTimeout:1e3,useSRVRecords:!1,resolveSrv:t.resolveSrv,dnsLookup:t.lookup,enableAutoPipelining:!1,autoPipeliningIgnoredCommands:[],shardedSubscribers:!1}})),DF=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.getConnectionName=e.weightSrvRecords=e.groupSrvRecords=e.getUniqueHostnamesFromOptions=e.normalizeNodeOptions=e.nodeKeyToRedisOptions=e.getNodeKey=void 0;let t=hF(),n=h(`net`);function r(e){return e.port=e.port||6379,e.host=e.host||`127.0.0.1`,e.host+`:`+e.port}e.getNodeKey=r;function i(e){let t=e.lastIndexOf(`:`);if(t===-1)throw Error(`Invalid node key ${e}`);return{host:e.slice(0,t),port:Number(e.slice(t+1))}}e.nodeKeyToRedisOptions=i;function a(e){return e.map(e=>{let n={};if(typeof e==`object`)Object.assign(n,e);else if(typeof e==`string`)Object.assign(n,(0,t.parseURL)(e));else if(typeof e==`number`)n.port=e;else throw Error(`Invalid argument `+e);return typeof n.port==`string`&&(n.port=parseInt(n.port,10)),delete n.db,n.port||=6379,n.host||=`127.0.0.1`,(0,t.resolveTLSProfile)(n)})}e.normalizeNodeOptions=a;function o(e){let t={};return e.forEach(e=>{t[e.host]=!0}),Object.keys(t).filter(e=>!(0,n.isIP)(e))}e.getUniqueHostnamesFromOptions=o;function s(e){let t={};for(let n of e)t.hasOwnProperty(n.priority)?(t[n.priority].totalWeight+=n.weight,t[n.priority].records.push(n)):t[n.priority]={totalWeight:n.weight,records:[n]};return t}e.groupSrvRecords=s;function c(e){if(e.records.length===1)return e.totalWeight=0,e.records.shift();let t=Math.floor(Math.random()*(e.totalWeight+e.records.length)),n=0;for(let[r,i]of e.records.entries())if(n+=1+i.weight,n>t)return e.totalWeight-=i.weight,e.records.splice(r,1),i}e.weightSrvRecords=c;function l(e,t){let n=`ioredis-cluster(${e})`;return t?`${n}:${t}`:n}e.getConnectionName=l})),OF=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=DF(),n=hF(),r=YF(),i=(0,n.Debug)(`cluster:subscriber`);e.default=class{constructor(e,n,r=!1){this.connectionPool=e,this.emitter=n,this.isSharded=r,this.started=!1,this.subscriber=null,this.slotRange=[],this.onSubscriberEnd=()=>{if(!this.started){i(`subscriber has disconnected, but ClusterSubscriber is not started, so not reconnecting.`);return}i(`subscriber has disconnected, selecting a new one...`),this.selectSubscriber()},this.connectionPool.on(`-node`,(e,n)=>{!this.started||!this.subscriber||(0,t.getNodeKey)(this.subscriber.options)===n&&(i(`subscriber has left, selecting a new one...`),this.selectSubscriber())}),this.connectionPool.on(`+node`,()=>{!this.started||this.subscriber||(i(`a new node is discovered and there is no subscriber, selecting a new one...`),this.selectSubscriber())})}getInstance(){return this.subscriber}associateSlotRange(e){return this.isSharded&&(this.slotRange=e),this.slotRange}start(){this.started=!0,this.selectSubscriber(),i(`started`)}stop(){this.started=!1,this.subscriber&&=(this.subscriber.disconnect(),null)}isStarted(){return this.started}selectSubscriber(){let e=this.lastActiveSubscriber;e&&(e.off(`end`,this.onSubscriberEnd),e.disconnect()),this.subscriber&&(this.subscriber.off(`end`,this.onSubscriberEnd),this.subscriber.disconnect());let a=(0,n.sample)(this.connectionPool.getNodes());if(!a){i(`selecting subscriber failed since there is no node discovered in the cluster yet`),this.subscriber=null;return}let{options:o}=a;i(`selected a subscriber %s:%s`,o.host,o.port);let s=`subscriber`;this.isSharded&&(s=`ssubscriber`),this.subscriber=new r.default({port:o.port,host:o.host,username:o.username,password:o.password,enableReadyCheck:!0,connectionName:(0,t.getConnectionName)(s,o.connectionName),lazyConnect:!0,tls:o.tls,retryStrategy:null}),this.subscriber.on(`error`,n.noop),this.subscriber.on(`moved`,()=>{this.emitter.emit(`forceRefresh`)}),this.subscriber.once(`end`,this.onSubscriberEnd);let c={subscribe:[],psubscribe:[],ssubscribe:[]};if(e){let t=e.condition||e.prevCondition;t&&t.subscriber&&(c.subscribe=t.subscriber.channels(`subscribe`),c.psubscribe=t.subscriber.channels(`psubscribe`),c.ssubscribe=t.subscriber.channels(`ssubscribe`))}if(c.subscribe.length||c.psubscribe.length||c.ssubscribe.length){let e=0;for(let t of[`subscribe`,`psubscribe`,`ssubscribe`]){let n=c[t];if(n.length!=0)if(i(`%s %d channels`,t,n.length),t===`ssubscribe`)for(let r of n)e+=1,this.subscriber[t](r).then(()=>{--e||(this.lastActiveSubscriber=this.subscriber)}).catch(()=>{i(`failed to ssubscribe to channel: %s`,r)});else e+=1,this.subscriber[t](n).then(()=>{--e||(this.lastActiveSubscriber=this.subscriber)}).catch(()=>{i(`failed to %s %d channels`,t,n.length)})}}else this.lastActiveSubscriber=this.subscriber;for(let e of[`message`,`messageBuffer`])this.subscriber.on(e,(t,n)=>{this.emitter.emit(e,t,n)});for(let e of[`pmessage`,`pmessageBuffer`])this.subscriber.on(e,(t,n,r)=>{this.emitter.emit(e,t,n,r)});if(this.isSharded==1)for(let e of[`smessage`,`smessageBuffer`])this.subscriber.on(e,(t,n)=>{this.emitter.emit(e,t,n)})}}})),kF=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=h(`events`),n=hF(),r=DF(),i=YF(),a=(0,n.Debug)(`cluster:connectionPool`);e.default=class extends t.EventEmitter{constructor(e){super(),this.redisOptions=e,this.nodes={all:{},master:{},slave:{}},this.specifiedOptions={}}getNodes(e=`all`){let t=this.nodes[e];return Object.keys(t).map(e=>t[e])}getInstanceByKey(e){return this.nodes.all[e]}getSampleInstance(e){let t=Object.keys(this.nodes[e]),r=(0,n.sample)(t);return this.nodes[e][r]}addMasterNode(e){let t=(0,r.getNodeKey)(e.options),n=this.createRedisFromOptions(e,e.options.readOnly);return e.options.readOnly?!1:(this.nodes.all[t]=n,this.nodes.master[t]=n,!0)}createRedisFromOptions(e,t){return new i.default((0,n.defaults)({retryStrategy:null,enableOfflineQueue:!0,readOnly:t},e,this.redisOptions,{lazyConnect:!0}))}findOrCreate(e,t=!1){let i=(0,r.getNodeKey)(e);t=!!t,this.specifiedOptions[i]?Object.assign(e,this.specifiedOptions[i]):this.specifiedOptions[i]=e;let o;return this.nodes.all[i]?(o=this.nodes.all[i],o.options.readOnly!==t&&(o.options.readOnly=t,a(`Change role of %s to %s`,i,t?`slave`:`master`),o[t?`readonly`:`readwrite`]().catch(n.noop),t?(delete this.nodes.master[i],this.nodes.slave[i]=o):(delete this.nodes.slave[i],this.nodes.master[i]=o))):(a(`Connecting to %s as %s`,i,t?`slave`:`master`),o=this.createRedisFromOptions(e,t),this.nodes.all[i]=o,this.nodes[t?`slave`:`master`][i]=o,o.once(`end`,()=>{this.removeNode(i),this.emit(`-node`,o,i),Object.keys(this.nodes.all).length||this.emit(`drain`)}),this.emit(`+node`,o,i),o.on(`error`,function(e){this.emit(`nodeError`,e,i)})),o}reset(e){a(`Reset with %O`,e);let t={};e.forEach(e=>{let n=(0,r.getNodeKey)(e);e.readOnly&&t[n]||(t[n]=e)}),Object.keys(this.nodes.all).forEach(e=>{t[e]||(a(`Disconnect %s because the node does not hold any slot`,e),this.nodes.all[e].disconnect(),this.removeNode(e))}),Object.keys(t).forEach(e=>{let n=t[e];this.findOrCreate(n,n.readOnly)})}removeNode(e){let{nodes:t}=this;t.all[e]&&(a(`Remove %s from the pool`,e),delete t.all[e]),delete t.master[e],delete t.slave[e]}}})),AF=u(((e,t)=>{function n(e,t){var t=t||{};this._capacity=t.capacity,this._head=0,this._tail=0,Array.isArray(e)?this._fromArray(e):(this._capacityMask=3,this._list=[,,,,])}n.prototype.peekAt=function(e){var t=e;if(t===(t|0)){var n=this.size();if(!(t>=n||t<-n))return t<0&&(t+=n),t=this._head+t&this._capacityMask,this._list[t]}},n.prototype.get=function(e){return this.peekAt(e)},n.prototype.peek=function(){if(this._head!==this._tail)return this._list[this._head]},n.prototype.peekFront=function(){return this.peek()},n.prototype.peekBack=function(){return this.peekAt(-1)},Object.defineProperty(n.prototype,`length`,{get:function(){return this.size()}}),n.prototype.size=function(){return this._head===this._tail?0:this._head<this._tail?this._tail-this._head:this._capacityMask+1-(this._head-this._tail)},n.prototype.unshift=function(e){if(arguments.length===0)return this.size();var t=this._list.length;return this._head=this._head-1+t&this._capacityMask,this._list[this._head]=e,this._tail===this._head&&this._growArray(),this._capacity&&this.size()>this._capacity&&this.pop(),this._head<this._tail?this._tail-this._head:this._capacityMask+1-(this._head-this._tail)},n.prototype.shift=function(){var e=this._head;if(e!==this._tail){var t=this._list[e];return this._list[e]=void 0,this._head=e+1&this._capacityMask,e<2&&this._tail>1e4&&this._tail<=this._list.length>>>2&&this._shrinkArray(),t}},n.prototype.push=function(e){if(arguments.length===0)return this.size();var t=this._tail;return this._list[t]=e,this._tail=t+1&this._capacityMask,this._tail===this._head&&this._growArray(),this._capacity&&this.size()>this._capacity&&this.shift(),this._head<this._tail?this._tail-this._head:this._capacityMask+1-(this._head-this._tail)},n.prototype.pop=function(){var e=this._tail;if(e!==this._head){var t=this._list.length;this._tail=e-1+t&this._capacityMask;var n=this._list[this._tail];return this._list[this._tail]=void 0,this._head<2&&e>1e4&&e<=t>>>2&&this._shrinkArray(),n}},n.prototype.removeOne=function(e){var t=e;if(t===(t|0)&&this._head!==this._tail){var n=this.size(),r=this._list.length;if(!(t>=n||t<-n)){t<0&&(t+=n),t=this._head+t&this._capacityMask;var i=this._list[t],a;if(e<n/2){for(a=e;a>0;a--)this._list[t]=this._list[t=t-1+r&this._capacityMask];this._list[t]=void 0,this._head=this._head+1+r&this._capacityMask}else{for(a=n-1-e;a>0;a--)this._list[t]=this._list[t=t+1+r&this._capacityMask];this._list[t]=void 0,this._tail=this._tail-1+r&this._capacityMask}return i}}},n.prototype.remove=function(e,t){var n=e,r,i=t;if(n===(n|0)&&this._head!==this._tail){var a=this.size(),o=this._list.length;if(!(n>=a||n<-a||t<1)){if(n<0&&(n+=a),t===1||!t)return r=[,],r[0]=this.removeOne(n),r;if(n===0&&n+t>=a)return r=this.toArray(),this.clear(),r;n+t>a&&(t=a-n);var s;for(r=Array(t),s=0;s<t;s++)r[s]=this._list[this._head+n+s&this._capacityMask];if(n=this._head+n&this._capacityMask,e+t===a){for(this._tail=this._tail-t+o&this._capacityMask,s=t;s>0;s--)this._list[n=n+1+o&this._capacityMask]=void 0;return r}if(e===0){for(this._head=this._head+t+o&this._capacityMask,s=t-1;s>0;s--)this._list[n=n+1+o&this._capacityMask]=void 0;return r}if(n<a/2){for(this._head=this._head+e+t+o&this._capacityMask,s=e;s>0;s--)this.unshift(this._list[n=n-1+o&this._capacityMask]);for(n=this._head-1+o&this._capacityMask;i>0;)this._list[n=n-1+o&this._capacityMask]=void 0,i--;e<0&&(this._tail=n)}else{for(this._tail=n,n=n+t+o&this._capacityMask,s=a-(t+e);s>0;s--)this.push(this._list[n++]);for(n=this._tail;i>0;)this._list[n=n+1+o&this._capacityMask]=void 0,i--}return this._head<2&&this._tail>1e4&&this._tail<=o>>>2&&this._shrinkArray(),r}}},n.prototype.splice=function(e,t){var n=e;if(n===(n|0)){var r=this.size();if(n<0&&(n+=r),!(n>r))if(arguments.length>2){var i,a,o,s=arguments.length,c=this._list.length,l=2;if(!r||n<r/2){for(a=Array(n),i=0;i<n;i++)a[i]=this._list[this._head+i&this._capacityMask];for(t===0?(o=[],n>0&&(this._head=this._head+n+c&this._capacityMask)):(o=this.remove(n,t),this._head=this._head+n+c&this._capacityMask);s>l;)this.unshift(arguments[--s]);for(i=n;i>0;i--)this.unshift(a[i-1])}else{a=Array(r-(n+t));var u=a.length;for(i=0;i<u;i++)a[i]=this._list[this._head+n+t+i&this._capacityMask];for(t===0?(o=[],n!=r&&(this._tail=this._head+n+c&this._capacityMask)):(o=this.remove(n,t),this._tail=this._tail-u+c&this._capacityMask);l<s;)this.push(arguments[l++]);for(i=0;i<u;i++)this.push(a[i])}return o}else return this.remove(n,t)}},n.prototype.clear=function(){this._list=Array(this._list.length),this._head=0,this._tail=0},n.prototype.isEmpty=function(){return this._head===this._tail},n.prototype.toArray=function(){return this._copyArray(!1)},n.prototype._fromArray=function(e){var t=e.length,n=this._nextPowerOf2(t);this._list=Array(n),this._capacityMask=n-1,this._tail=t;for(var r=0;r<t;r++)this._list[r]=e[r]},n.prototype._copyArray=function(e,t){var n=this._list,r=n.length,i=this.length;if(t|=i,t==i&&this._head<this._tail)return this._list.slice(this._head,this._tail);var a=Array(t),o=0,s;if(e||this._head>this._tail){for(s=this._head;s<r;s++)a[o++]=n[s];for(s=0;s<this._tail;s++)a[o++]=n[s]}else for(s=this._head;s<this._tail;s++)a[o++]=n[s];return a},n.prototype._growArray=function(){if(this._head!=0){var e=this._copyArray(!0,this._list.length<<1);this._tail=this._list.length,this._head=0,this._list=e}else this._tail=this._list.length,this._list.length<<=1;this._capacityMask=this._capacityMask<<1|1},n.prototype._shrinkArray=function(){this._list.length>>>=1,this._capacityMask>>>=1},n.prototype._nextPowerOf2=function(e){var t=1<<Math.log(e)/Math.log(2)+1;return Math.max(t,4)},t.exports=n})),jF=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=hF(),n=AF(),r=(0,t.Debug)(`delayqueue`);e.default=class{constructor(){this.queues={},this.timeouts={}}push(e,t,r){let i=r.callback||process.nextTick;this.queues[e]||(this.queues[e]=new n),this.queues[e].push(t),this.timeouts[e]||(this.timeouts[e]=setTimeout(()=>{i(()=>{this.timeouts[e]=null,this.execute(e)})},r.timeout))}execute(e){let t=this.queues[e];if(!t)return;let{length:n}=t;if(n)for(r(`send %d commands in %s queue`,n,e),this.queues[e]=null;t.length>0;)t.shift()()}}})),MF=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=DF(),n=hF(),r=YF(),i=(0,n.Debug)(`cluster:subscriberGroup:shardedSubscriber`),a={IDLE:`idle`,STARTING:`starting`,CONNECTED:`connected`,STOPPING:`stopping`,ENDED:`ended`},o={[a.IDLE]:[a.STARTING,a.STOPPING,a.ENDED],[a.STARTING]:[a.CONNECTED,a.STOPPING,a.ENDED],[a.CONNECTED]:[a.STOPPING,a.ENDED],[a.STOPPING]:[a.ENDED],[a.ENDED]:[]};e.default=class{constructor(e,i,o){this.emitter=e,this.status=a.IDLE,this.instance=null,this.connectPromise=null,this.messageListeners=new Map,this.onEnd=()=>{this.updateStatus(a.ENDED),this.emitter.emit(`-node`,this.instance,this.nodeKey)},this.onError=e=>{this.emitter.emit(`nodeError`,e,this.nodeKey)},this.onMoved=()=>{this.emitter.emit(`moved`)},this.instance=new r.default((0,n.defaults)({enableReadyCheck:!1,enableOfflineQueue:!0,connectionName:(0,t.getConnectionName)(`ssubscriber`,i.connectionName),retryStrategy:null,lazyConnect:!0},i,o)),this.lazyConnect=o?.lazyConnect??!0,this.nodeKey=(0,t.getNodeKey)(i),this.instance.on(`end`,this.onEnd),this.instance.on(`error`,this.onError),this.instance.on(`moved`,this.onMoved);for(let e of[`smessage`,`smessageBuffer`]){let t=(...t)=>{this.emitter.emit(e,...t)};this.messageListeners.set(e,t),this.instance.on(e,t)}}async start(){if(this.connectPromise)return this.connectPromise;if(!(this.status===a.STARTING||this.status===a.CONNECTED)){if(this.status===a.ENDED||!this.instance)throw Error(`Sharded subscriber ${this.nodeKey} cannot be restarted once ended.`);this.updateStatus(a.STARTING),this.connectPromise=this.instance.connect();try{await this.connectPromise,this.updateStatus(a.CONNECTED)}catch(e){throw this.updateStatus(a.ENDED),e}finally{this.connectPromise=null}}}stop(){this.updateStatus(a.STOPPING),this.instance&&=(this.instance.disconnect(),this.instance.removeAllListeners(),this.messageListeners.clear(),null),this.updateStatus(a.ENDED),i(`stopped %s`,this.nodeKey)}isStarted(){return[a.CONNECTED,a.STARTING].includes(this.status)}get subscriberStatus(){return this.status}isHealthy(){return(this.status===a.IDLE||this.status===a.CONNECTED||this.status===a.STARTING)&&this.instance!==null}getInstance(){return this.instance}getNodeKey(){return this.nodeKey}isLazyConnect(){return this.lazyConnect}updateStatus(e){if(this.status!==e){if(!o[this.status].includes(e)){i(`Invalid status transition for %s: %s -> %s`,this.nodeKey,this.status,e);return}this.status=e}}}})),NF=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=hF(),n=DF(),r=iF(),i=MF(),a=(0,t.Debug)(`cluster:subscriberGroup`);var o=class e{constructor(t,n){this.subscriberGroupEmitter=t,this.options=n,this.shardedSubscribers=new Map,this.clusterSlots=[],this.subscriberToSlotsIndex=new Map,this.channels=new Map,this.failedAttemptsByNode=new Map,this.isResetting=!1,this.pendingReset=null,this.handleSubscriberConnectFailed=(t,n)=>{let r=(this.failedAttemptsByNode.get(n)||0)+1;this.failedAttemptsByNode.set(n,r);let i=Math.min(r,e.MAX_RETRY_ATTEMPTS),o=Math.min(e.BASE_BACKOFF_MS*2**i,e.MAX_BACKOFF_MS),s=Math.floor((Math.random()-.5)*(o*.5)),c=Math.max(0,o+s);a(`Failed to connect subscriber for %s. Refreshing slots in %dms`,n,c),this.subscriberGroupEmitter.emit(`subscriberConnectFailed`,{delay:c,error:t})},this.handleSubscriberConnectSucceeded=e=>{this.failedAttemptsByNode.delete(e)}}getResponsibleSubscriber(e){let t=this.clusterSlots[e][0],n=this.shardedSubscribers.get(t);return n&&n.subscriberStatus===`idle`&&n.start().then(()=>{this.handleSubscriberConnectSucceeded(n.getNodeKey())}).catch(e=>{this.handleSubscriberConnectFailed(e,n.getNodeKey())}),n}addChannels(e){let t=r(e[0]);for(let n of e)if(r(n)!==t)return-1;let n=this.channels.get(t);return n?this.channels.set(t,n.concat(e)):this.channels.set(t,e),Array.from(this.channels.values()).reduce((e,t)=>e+t.length,0)}removeChannels(e){let t=r(e[0]);for(let n of e)if(r(n)!==t)return-1;let n=this.channels.get(t);if(n){let r=n.filter(t=>!e.includes(t));this.channels.set(t,r)}return Array.from(this.channels.values()).reduce((e,t)=>e+t.length,0)}stop(){for(let e of this.shardedSubscribers.values())e.stop();this.pendingReset=null,this.shardedSubscribers.clear(),this.subscriberToSlotsIndex.clear()}start(){let e=[];for(let t of this.shardedSubscribers.values())this.shouldStartSubscriber(t)&&(e.push(t.start().then(()=>{this.handleSubscriberConnectSucceeded(t.getNodeKey())}).catch(e=>{this.handleSubscriberConnectFailed(e,t.getNodeKey())})),this.subscriberGroupEmitter.emit(`+subscriber`));return Promise.all(e)}async reset(e,t){if(this.isResetting){this.pendingReset={slots:e,nodes:t};return}this.isResetting=!0;try{let r=this._refreshSlots(e),o=this.hasUnhealthySubscribers();if(!r&&!o){a(`No topology change detected or failed subscribers. Skipping reset.`);return}for(let[e,t]of this.shardedSubscribers){if(this.subscriberToSlotsIndex.has(e)&&t.isHealthy()){a(`Skipping deleting subscriber for %s`,e);continue}a(`Removing subscriber for %s`,e),t.stop(),this.shardedSubscribers.delete(e),this.subscriberGroupEmitter.emit(`-subscriber`)}let s=[];for(let[e,r]of this.subscriberToSlotsIndex){let r=this.shardedSubscribers.get(e);if(r&&r.isHealthy()){a(`Skipping creating new subscriber for %s`,e),!r.isStarted()&&this.shouldStartSubscriber(r)&&s.push(r.start().then(()=>{this.handleSubscriberConnectSucceeded(e)}).catch(t=>{this.handleSubscriberConnectFailed(t,e)}));continue}r&&!r.isHealthy()&&(a(`Replacing subscriber for %s`,e),r.stop(),this.shardedSubscribers.delete(e),this.subscriberGroupEmitter.emit(`-subscriber`)),a(`Creating new subscriber for %s`,e);let o=t.find(t=>(0,n.getNodeKey)(t.options)===e);if(!o){a(`Failed to find node for key %s`,e);continue}let c=new i.default(this.subscriberGroupEmitter,o.options,this.options.redisOptions);this.shardedSubscribers.set(e,c),this.shouldStartSubscriber(c)&&s.push(c.start().then(()=>{this.handleSubscriberConnectSucceeded(e)}).catch(t=>{this.handleSubscriberConnectFailed(t,e)})),this.subscriberGroupEmitter.emit(`+subscriber`)}await Promise.all(s),this._resubscribe(),this.subscriberGroupEmitter.emit(`subscribersReady`)}finally{if(this.isResetting=!1,this.pendingReset){let{slots:e,nodes:t}=this.pendingReset;this.pendingReset=null,await this.reset(e,t)}}}_refreshSlots(e){if(this._slotsAreEqual(e)&&this.subscriberToSlotsIndex.size>0)return a(`Nothing to refresh because the new cluster map is equal to the previous one.`),!1;a(`Refreshing the slots of the subscriber group.`),this.subscriberToSlotsIndex=new Map;for(let t=0;t<e.length;t++){let n=e[t][0];this.subscriberToSlotsIndex.has(n)||this.subscriberToSlotsIndex.set(n,[]),this.subscriberToSlotsIndex.get(n).push(Number(t))}return this.clusterSlots=JSON.parse(JSON.stringify(e)),!0}_resubscribe(){this.shardedSubscribers&&this.shardedSubscribers.forEach((e,t)=>{let n=this.subscriberToSlotsIndex.get(t);n&&n.forEach(n=>{let r=e.getInstance(),i=this.channels.get(n);if(i&&i.length>0){if(!r||r.status===`end`)return;r.status===`ready`?r.ssubscribe(...i).catch(e=>{a(`Failed to ssubscribe on node %s: %s`,t,e)}):r.once(`ready`,()=>{r.ssubscribe(...i).catch(e=>{a(`Failed to ssubscribe on node %s: %s`,t,e)})})}})})}_slotsAreEqual(e){return this.clusterSlots===void 0?!1:JSON.stringify(this.clusterSlots)===JSON.stringify(e)}hasUnhealthySubscribers(){let e=Array.from(this.shardedSubscribers.values()).some(e=>!e.isHealthy()),t=Array.from(this.subscriberToSlotsIndex.keys()).some(e=>!this.shardedSubscribers.has(e));return e||t}shouldStartSubscriber(e){if(e.isStarted())return!1;if(!e.isLazyConnect())return!0;let t=this.subscriberToSlotsIndex.get(e.getNodeKey());return t?t.some(e=>{let t=this.channels.get(e);return!!(t&&t.length>0)}):!1}};e.default=o,o.MAX_RETRY_ATTEMPTS=10,o.MAX_BACKOFF_MS=2e3,o.BASE_BACKOFF_MS=100})),PF=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=QP(),n=h(`events`),r=rF(),i=eF(),a=_F(),o=vF(),s=YF(),c=yF(),l=wF(),u=hF(),d=TF(),f=SF(),p=EF(),m=OF(),g=kF(),_=jF(),v=DF(),y=AF(),b=NF(),x=(0,u.Debug)(`cluster`),S=new WeakSet;var C=class e extends f.default{constructor(e,t={}){if(super(),this.slots=[],this._groupsIds={},this._groupsBySlot=Array(16384),this.isCluster=!0,this.retryAttempts=0,this.delayQueue=new _.default,this.offlineQueue=new y,this.isRefreshing=!1,this._refreshSlotsCacheCallbacks=[],this._autoPipelines=new Map,this._runningAutoPipelines=new Set,this._readyDelayedCallbacks=[],this.connectionEpoch=0,n.EventEmitter.call(this),this.startupNodes=e,this.options=(0,u.defaults)({},t,p.DEFAULT_CLUSTER_OPTIONS,this.options),this.options.shardedSubscribers&&this.createShardedSubscriberGroup(),this.options.redisOptions&&this.options.redisOptions.keyPrefix&&!this.options.keyPrefix&&(this.options.keyPrefix=this.options.redisOptions.keyPrefix),typeof this.options.scaleReads!=`function`&&[`all`,`master`,`slave`].indexOf(this.options.scaleReads)===-1)throw Error(`Invalid option scaleReads "`+this.options.scaleReads+`". Expected "all", "master", "slave" or a custom function`);this.connectionPool=new g.default(this.options.redisOptions),this.connectionPool.on(`-node`,(e,t)=>{this.emit(`-node`,e)}),this.connectionPool.on(`+node`,e=>{this.emit(`+node`,e)}),this.connectionPool.on(`drain`,()=>{this.setStatus(`close`)}),this.connectionPool.on(`nodeError`,(e,t)=>{this.emit(`node error`,e,t)}),this.subscriber=new m.default(this.connectionPool,this),this.options.scripts&&Object.entries(this.options.scripts).forEach(([e,t])=>{this.defineCommand(e,t)}),this.options.lazyConnect?this.setStatus(`wait`):this.connect().catch(e=>{x(`connecting failed: %s`,e)})}connect(){return new Promise((e,t)=>{if(this.status===`connecting`||this.status===`connect`||this.status===`ready`){t(Error(`Redis is already connecting/connected`));return}let n=++this.connectionEpoch;this.setStatus(`connecting`),this.resolveStartupNodeHostnames().then(i=>{if(this.connectionEpoch!==n){x(`discard connecting after resolving startup nodes because epoch not match: %d != %d`,n,this.connectionEpoch),t(new r.RedisError(`Connection is discarded because a new connection is made`));return}if(this.status!==`connecting`){x(`discard connecting after resolving startup nodes because the status changed to %s`,this.status),t(new r.RedisError(`Connection is aborted`));return}this.connectionPool.reset(i),this.options.shardedSubscribers&&this.shardedSubscribers.reset(this.slots,this.connectionPool.getNodes(`all`)).catch(e=>{x(`Error while starting subscribers: %s`,e)});let a=()=>{this.setStatus(`ready`),this.retryAttempts=0,this.executeOfflineCommands(),this.resetNodesRefreshInterval(),e()},c,l=()=>{this.invokeReadyDelayedCallbacks(void 0),this.removeListener(`close`,c),this.manuallyClosing=!1,this.setStatus(`connect`),this.options.enableReadyCheck?this.readyCheck((e,t)=>{e||t?(x(`Ready check failed (%s). Reconnecting...`,e||t),this.status===`connect`&&this.disconnect(!0)):a()}):a()};c=()=>{let e=Error(`None of startup nodes is available`);this.removeListener(`refresh`,l),this.invokeReadyDelayedCallbacks(e),t(e)},this.once(`refresh`,l),this.once(`close`,c),this.once(`close`,this.handleCloseEvent.bind(this)),this.refreshSlotsCache(e=>{e&&e.message===o.default.defaultMessage&&(s.default.prototype.silentEmit.call(this,`error`,e),this.connectionPool.reset([]))}),this.subscriber.start(),this.options.shardedSubscribers&&this.shardedSubscribers.start().catch(e=>{x(`Error while starting subscribers: %s`,e)})}).catch(e=>{this.setStatus(`close`),this.handleCloseEvent(e),this.invokeReadyDelayedCallbacks(e),t(e)})})}disconnect(e=!1){let t=this.status;this.setStatus(`disconnecting`),e||(this.manuallyClosing=!0),this.reconnectTimeout&&!e&&(clearTimeout(this.reconnectTimeout),this.reconnectTimeout=null,x(`Canceled reconnecting attempts`)),this.clearNodesRefreshInterval(),this.subscriber.stop(),this.options.shardedSubscribers&&this.shardedSubscribers.stop(),t===`wait`?(this.setStatus(`close`),this.handleCloseEvent()):this.connectionPool.reset([])}quit(e){let t=this.status;if(this.setStatus(`disconnecting`),this.manuallyClosing=!0,this.reconnectTimeout&&=(clearTimeout(this.reconnectTimeout),null),this.clearNodesRefreshInterval(),this.subscriber.stop(),this.options.shardedSubscribers&&this.shardedSubscribers.stop(),t===`wait`){let t=(0,i.default)(Promise.resolve(`OK`),e);return setImmediate(function(){this.setStatus(`close`),this.handleCloseEvent()}.bind(this)),t}return(0,i.default)(Promise.all(this.nodes().map(e=>e.quit().catch(e=>{if(e.message===u.CONNECTION_CLOSED_ERROR_MSG)return`OK`;throw e}))).then(()=>`OK`),e)}duplicate(t=[],n={}){return new e(t.length>0?t:this.startupNodes.slice(0),Object.assign({},this.options,n))}nodes(e=`all`){if(e!==`all`&&e!==`master`&&e!==`slave`)throw Error(`Invalid role "`+e+`". Expected "all", "master" or "slave"`);return this.connectionPool.getNodes(e)}delayUntilReady(e){this._readyDelayedCallbacks.push(e)}get autoPipelineQueueSize(){let e=0;for(let t of this._autoPipelines.values())e+=t.length;return e}refreshSlotsCache(e){if(e&&this._refreshSlotsCacheCallbacks.push(e),this.isRefreshing)return;this.isRefreshing=!0;let t=this,n=e=>{this.isRefreshing=!1;for(let t of this._refreshSlotsCacheCallbacks)t(e);this._refreshSlotsCacheCallbacks=[]},r=(0,u.shuffle)(this.connectionPool.getNodes()),i=null;function a(e){if(e===r.length)return n(new o.default(o.default.defaultMessage,i));let s=r[e],c=`${s.options.host}:${s.options.port}`;x(`getting slot cache from %s`,c),t.getInfoFromNode(s,function(r){switch(t.status){case`close`:case`end`:return n(Error(`Cluster is disconnected.`));case`disconnecting`:return n(Error(`Cluster is disconnecting.`))}r?(t.emit(`node error`,r,c),i=r,a(e+1)):(t.emit(`refresh`),n())})}a(0)}sendCommand(e,n,i){if(this.status===`wait`&&this.connect().catch(u.noop),this.status===`end`)return e.reject(Error(u.CONNECTION_CLOSED_ERROR_MSG)),e.promise;let o=this.options.scaleReads;o!==`master`&&(e.isReadOnly||(0,t.exists)(e.name)&&(0,t.hasFlag)(e.name,`readonly`)||(o=`master`));let s=i?i.slot:e.getSlot(),c={},l=this;if(!i&&!S.has(e)){S.add(e);let t=e.reject;e.reject=function(n){let r=d.bind(null,!0);l.handleError(n,c,{moved:function(t,n){x(`command %s is moved to %s`,e.name,n),s=Number(t),l.slots[t]?l.slots[t][0]=n:l.slots[t]=[n],l._groupsBySlot[t]=l._groupsIds[l.slots[t].join(`;`)],l.connectionPool.findOrCreate(l.natMapper(n)),d(),x(`refreshing slot caches... (triggered by MOVED error)`),l.refreshSlotsCache()},ask:function(t,n){x(`command %s is required to ask %s:%s`,e.name,n);let r=l.natMapper(n);l.connectionPool.findOrCreate(r),d(!1,`${r.host}:${r.port}`)},tryagain:r,clusterDown:r,connectionClosed:r,maxRedirections:function(n){t.call(e,n)},defaults:function(){t.call(e,n)}})}}d();function d(t,c){if(l.status===`end`){e.reject(new r.AbortError(`Cluster is ended.`));return}let d;if(l.status===`ready`||e.name===`cluster`){if(i&&i.redis)d=i.redis;else if(a.default.checkFlag(`ENTER_SUBSCRIBER_MODE`,e.name)||a.default.checkFlag(`EXIT_SUBSCRIBER_MODE`,e.name)){if(l.options.shardedSubscribers&&(e.name==`ssubscribe`||e.name==`sunsubscribe`)){let t=l.shardedSubscribers.getResponsibleSubscriber(s);if(!t){e.reject(new r.AbortError(`No sharded subscriber for slot: ${s}`));return}let n=-1;e.name==`ssubscribe`&&(n=l.shardedSubscribers.addChannels(e.getKeys())),e.name==`sunsubscribe`&&(n=l.shardedSubscribers.removeChannels(e.getKeys())),n===-1?e.reject(new r.AbortError(`Possible CROSSSLOT error: All channels must hash to the same slot`)):d=t.getInstance()}else d=l.subscriber.getInstance();if(!d){e.reject(new r.AbortError(`No subscriber for the cluster`));return}}else{if(!t){if(typeof s==`number`&&l.slots[s]){let t=l.slots[s];if(typeof o==`function`){let n=t.map(function(e){return l.connectionPool.getInstanceByKey(e)});d=o(n,e),Array.isArray(d)&&(d=(0,u.sample)(d)),d||=n[0]}else{let e;e=o===`all`?(0,u.sample)(t):o===`slave`&&t.length>1?(0,u.sample)(t,1):t[0],d=l.connectionPool.getInstanceByKey(e)}}c&&(d=l.connectionPool.getInstanceByKey(c),d.asking())}d||=(typeof o==`function`?null:l.connectionPool.getSampleInstance(o))||l.connectionPool.getSampleInstance(`all`)}i&&!i.redis&&(i.redis=d)}d?d.sendCommand(e,n):l.options.enableOfflineQueue?l.offlineQueue.push({command:e,stream:n,node:i}):e.reject(Error(`Cluster isn't ready and enableOfflineQueue options is false`))}return e.promise}sscanStream(e,t){return this.createScanStream(`sscan`,{key:e,options:t})}sscanBufferStream(e,t){return this.createScanStream(`sscanBuffer`,{key:e,options:t})}hscanStream(e,t){return this.createScanStream(`hscan`,{key:e,options:t})}hscanBufferStream(e,t){return this.createScanStream(`hscanBuffer`,{key:e,options:t})}zscanStream(e,t){return this.createScanStream(`zscan`,{key:e,options:t})}zscanBufferStream(e,t){return this.createScanStream(`zscanBuffer`,{key:e,options:t})}handleError(e,t,n){if(t.value===void 0?t.value=this.options.maxRedirections:--t.value,t.value<=0){n.maxRedirections(Error(`Too many Cluster redirections. Last error: `+e));return}let r=e.message.split(` `);if(r[0]===`MOVED`){let e=this.options.retryDelayOnMoved;e&&typeof e==`number`?this.delayQueue.push(`moved`,n.moved.bind(null,r[1],r[2]),{timeout:e}):n.moved(r[1],r[2])}else r[0]===`ASK`?n.ask(r[1],r[2]):r[0]===`TRYAGAIN`?this.delayQueue.push(`tryagain`,n.tryagain,{timeout:this.options.retryDelayOnTryAgain}):r[0]===`CLUSTERDOWN`&&this.options.retryDelayOnClusterDown>0?this.delayQueue.push(`clusterdown`,n.connectionClosed,{timeout:this.options.retryDelayOnClusterDown,callback:this.refreshSlotsCache.bind(this)}):e.message===u.CONNECTION_CLOSED_ERROR_MSG&&this.options.retryDelayOnFailover>0&&this.status===`ready`?this.delayQueue.push(`failover`,n.connectionClosed,{timeout:this.options.retryDelayOnFailover,callback:this.refreshSlotsCache.bind(this)}):n.defaults()}resetOfflineQueue(){this.offlineQueue=new y}clearNodesRefreshInterval(){this.slotsTimer&&=(clearTimeout(this.slotsTimer),null)}resetNodesRefreshInterval(){if(this.slotsTimer||!this.options.slotsRefreshInterval)return;let e=()=>{this.slotsTimer=setTimeout(()=>{x(`refreshing slot caches... (triggered by "slotsRefreshInterval" option)`),this.refreshSlotsCache(()=>{e()})},this.options.slotsRefreshInterval)};e()}setStatus(e){x(`status: %s -> %s`,this.status||`[empty]`,e),this.status=e,process.nextTick(()=>{this.emit(e)})}handleCloseEvent(e){var t;e&&x(`closed because %s`,e);let n;!this.manuallyClosing&&typeof this.options.clusterRetryStrategy==`function`&&(n=this.options.clusterRetryStrategy.call(this,++this.retryAttempts,e)),typeof n==`number`?(this.setStatus(`reconnecting`),this.reconnectTimeout=setTimeout(()=>{this.reconnectTimeout=null,x(`Cluster is disconnected. Retrying after %dms`,n),this.connect().catch(function(e){x(`Got error %s when reconnecting. Ignoring...`,e)})},n)):(this.options.shardedSubscribers&&((t=this.subscriberGroupEmitter)==null||t.removeAllListeners()),this.setStatus(`end`),this.flushQueue(Error(`None of startup nodes is available`)))}flushQueue(e){let t;for(;t=this.offlineQueue.shift();)t.command.reject(e)}executeOfflineCommands(){if(this.offlineQueue.length){x(`send %d commands in offline queue`,this.offlineQueue.length);let e=this.offlineQueue;this.resetOfflineQueue();let t;for(;t=e.shift();)this.sendCommand(t.command,t.stream,t.node)}}natMapper(e){let t=typeof e==`string`?e:`${e.host}:${e.port}`,n=null;return this.options.natMap&&typeof this.options.natMap==`function`?n=this.options.natMap(t):this.options.natMap&&typeof this.options.natMap==`object`&&(n=this.options.natMap[t]),n?(x(`NAT mapping %s -> %O`,t,n),Object.assign({},n)):typeof e==`string`?(0,v.nodeKeyToRedisOptions)(e):e}getInfoFromNode(e,t){if(!e)return t(Error(`Node is disconnected`));let n=e.duplicate({enableOfflineQueue:!0,enableReadyCheck:!1,retryStrategy:null,connectionName:(0,v.getConnectionName)(`refresher`,this.options.redisOptions&&this.options.redisOptions.connectionName)});n.on(`error`,u.noop),n.cluster(`SLOTS`,(0,u.timeout)((e,r)=>{if(n.disconnect(),e)return x(`error encountered running CLUSTER.SLOTS: %s`,e),t(e);if(this.status===`disconnecting`||this.status===`close`||this.status===`end`){x(`ignore CLUSTER.SLOTS results (count: %d) since cluster status is %s`,r.length,this.status),t();return}let i=[];x(`cluster slots result count: %d`,r.length);for(let e=0;e<r.length;++e){let t=r[e],n=t[0],a=t[1],o=[];for(let e=2;e<t.length;e++){if(!t[e][0])continue;let n=this.natMapper({host:t[e][0],port:t[e][1]});n.readOnly=e!==2,i.push(n),o.push(n.host+`:`+n.port)}x(`cluster slots result [%d]: slots %d~%d served by %s`,e,n,a,o);for(let e=n;e<=a;e++)this.slots[e]=o}this._groupsIds=Object.create(null);let a=0;for(let e=0;e<16384;e++){let t=(this.slots[e]||[]).join(`;`);if(!t.length){this._groupsBySlot[e]=void 0;continue}this._groupsIds[t]||(this._groupsIds[t]=++a),this._groupsBySlot[e]=this._groupsIds[t]}this.connectionPool.reset(i),this.options.shardedSubscribers&&this.shardedSubscribers.reset(this.slots,this.connectionPool.getNodes(`all`)).catch(e=>{x(`Error while starting subscribers: %s`,e)}),t()},this.options.slotsRefreshTimeout))}invokeReadyDelayedCallbacks(e){for(let t of this._readyDelayedCallbacks)process.nextTick(t,e);this._readyDelayedCallbacks=[]}readyCheck(e){this.cluster(`INFO`,(t,n)=>{if(t)return e(t);if(typeof n!=`string`)return e();let r,i=n.split(`\r
235
235
  `);for(let e=0;e<i.length;++e){let t=i[e].split(`:`);if(t[0]===`cluster_state`){r=t[1];break}}r===`fail`?(x(`cluster state not ok (%s)`,r),e(null,r)):e()})}resolveSrv(e){return new Promise((t,n)=>{this.options.resolveSrv(e,(e,r)=>{if(e)return n(e);let i=this,a=(0,v.groupSrvRecords)(r),o=Object.keys(a).sort((e,t)=>parseInt(e)-parseInt(t));function s(e){if(!o.length)return n(e);let r=a[o[0]],c=(0,v.weightSrvRecords)(r);r.records.length||o.shift(),i.dnsLookup(c.name).then(e=>t({host:e,port:c.port}),s)}s()})})}dnsLookup(e){return new Promise((t,n)=>{this.options.dnsLookup(e,(r,i)=>{r?(x(`failed to resolve hostname %s to IP: %s`,e,r.message),n(r)):(x(`resolved hostname %s to IP %s`,e,i),t(i))})})}async resolveStartupNodeHostnames(){if(!Array.isArray(this.startupNodes)||this.startupNodes.length===0)throw Error("`startupNodes` should contain at least one node.");let e=(0,v.normalizeNodeOptions)(this.startupNodes),t=(0,v.getUniqueHostnamesFromOptions)(e);if(t.length===0)return e;let n=await Promise.all(t.map((this.options.useSRVRecords?this.resolveSrv:this.dnsLookup).bind(this))),r=(0,u.zipMap)(t,n);return e.map(e=>{let t=r.get(e.host);return t?this.options.useSRVRecords?Object.assign({},e,t):Object.assign({},e,{host:t}):e})}createScanStream(e,{key:t,options:n={}}){return new c.default({objectMode:!0,key:t,redis:this,command:e,...n})}createShardedSubscriberGroup(){this.subscriberGroupEmitter=new n.EventEmitter,this.shardedSubscribers=new b.default(this.subscriberGroupEmitter,this.options);let e=e=>{e instanceof o.default&&this.disconnect(!0)};this.subscriberGroupEmitter.on(`-node`,(t,n)=>{this.emit(`-node`,t,n),this.refreshSlotsCache(e)}),this.subscriberGroupEmitter.on(`subscriberConnectFailed`,({delay:t,error:n})=>{this.emit(`error`,n),setTimeout(()=>{this.refreshSlotsCache(e)},t)}),this.subscriberGroupEmitter.on(`moved`,()=>{this.refreshSlotsCache(e)}),this.subscriberGroupEmitter.on(`-subscriber`,()=>{this.emit(`-subscriber`)}),this.subscriberGroupEmitter.on(`+subscriber`,()=>{this.emit(`+subscriber`)}),this.subscriberGroupEmitter.on(`nodeError`,(e,t)=>{this.emit(`nodeError`,e,t)}),this.subscriberGroupEmitter.on(`subscribersReady`,()=>{this.emit(`subscribersReady`)});for(let e of[`smessage`,`smessageBuffer`])this.subscriberGroupEmitter.on(e,(t,n,r)=>{this.emit(e,t,n,r)})}};(0,d.default)(C,n.EventEmitter),(0,l.addTransactionSupport)(C.prototype),e.default=C})),FF=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=(0,hF().Debug)(`AbstractConnector`);e.default=class{constructor(e){this.connecting=!1,this.disconnectTimeout=e}check(e){return!0}disconnect(){if(this.connecting=!1,this.stream){let e=this.stream,n=setTimeout(()=>{t(`stream %s:%s still open, destroying it`,e.remoteAddress,e.remotePort),e.destroy()},this.disconnectTimeout);e.on(`close`,()=>clearTimeout(n)),e.end()}}}})),IF=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=h(`net`),n=h(`tls`),r=hF(),i=FF();e.default=class extends i.default{constructor(e){super(e.disconnectTimeout),this.options=e}connect(e){let{options:i}=this;this.connecting=!0;let a;return`path`in i&&i.path?a={path:i.path}:(a={},`port`in i&&i.port!=null&&(a.port=i.port),`host`in i&&i.host!=null&&(a.host=i.host),`family`in i&&i.family!=null&&(a.family=i.family)),i.tls&&Object.assign(a,i.tls),new Promise((e,o)=>{process.nextTick(()=>{if(!this.connecting){o(Error(r.CONNECTION_CLOSED_ERROR_MSG));return}try{i.tls?this.stream=(0,n.connect)(a):this.stream=(0,t.createConnection)(a)}catch(e){o(e);return}this.stream.once(`error`,e=>{this.firstError=e}),e(this.stream)})})}}})),LF=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0});function t(e,t){return(e.host||`127.0.0.1`)===(t.host||`127.0.0.1`)&&(e.port||26379)===(t.port||26379)}e.default=class{constructor(e){this.cursor=0,this.sentinels=e.slice(0)}next(){let e=this.cursor>=this.sentinels.length;return{done:e,value:e?void 0:this.sentinels[this.cursor++]}}reset(e){e&&this.sentinels.length>1&&this.cursor!==1&&this.sentinels.unshift(...this.sentinels.splice(this.cursor-1)),this.cursor=0}add(e){for(let n=0;n<this.sentinels.length;n++)if(t(e,this.sentinels[n]))return!1;return this.sentinels.push(e),!0}toString(){return`${JSON.stringify(this.sentinels)} @${this.cursor}`}}})),RF=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.FailoverDetector=void 0;let t=(0,hF().Debug)(`FailoverDetector`),n=`+switch-master`;e.FailoverDetector=class{constructor(e,t){this.isDisconnected=!1,this.connector=e,this.sentinels=t}cleanup(){this.isDisconnected=!0;for(let e of this.sentinels)e.client.disconnect()}async subscribe(){t(`Starting FailoverDetector`);let e=[];for(let r of this.sentinels){let i=r.client.subscribe(n).catch(e=>{t(`Failed to subscribe to failover messages on sentinel %s:%s (%s)`,r.address.host||`127.0.0.1`,r.address.port||26739,e.message)});e.push(i),r.client.on(`message`,e=>{!this.isDisconnected&&e===n&&this.disconnect()})}await Promise.all(e)}disconnect(){this.isDisconnected=!0,t(`Failover detected, disconnecting`),this.connector.disconnect()}}})),zF=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.SentinelIterator=void 0;let t=h(`net`),n=hF(),r=h(`tls`),i=LF();e.SentinelIterator=i.default;let a=FF(),o=YF(),s=RF(),c=(0,n.Debug)(`SentinelConnector`);e.default=class extends a.default{constructor(e){if(super(e.disconnectTimeout),this.options=e,this.emitter=null,this.failoverDetector=null,!this.options.sentinels.length)throw Error(`Requires at least one sentinel to connect to.`);if(!this.options.name)throw Error(`Requires the name of master.`);this.sentinelIterator=new i.default(this.options.sentinels)}check(e){let t=!e.role||this.options.role===e.role;return t||(c(`role invalid, expected %s, but got %s`,this.options.role,e.role),this.sentinelIterator.next(),this.sentinelIterator.next(),this.sentinelIterator.reset(!0)),t}disconnect(){super.disconnect(),this.failoverDetector&&this.failoverDetector.cleanup()}connect(e){this.connecting=!0,this.retryAttempts=0;let i,a=async()=>{let o=this.sentinelIterator.next();if(o.done){this.sentinelIterator.reset(!1);let t=typeof this.options.sentinelRetryStrategy==`function`?this.options.sentinelRetryStrategy(++this.retryAttempts):null,n=typeof t==`number`?`All sentinels are unreachable. Retrying from scratch after ${t}ms.`:`All sentinels are unreachable and retry is disabled.`;i&&(n+=` Last error: ${i.message}`),c(n);let r=Error(n);if(typeof t==`number`)return e(`error`,r),await new Promise(e=>setTimeout(e,t)),a();throw r}let s=null,l=null;try{s=await this.resolve(o.value)}catch(e){l=e}if(!this.connecting)throw Error(n.CONNECTION_CLOSED_ERROR_MSG);let u=o.value.host+`:`+o.value.port;if(s)return c(`resolved: %s:%s from sentinel %s`,s.host,s.port,u),this.options.enableTLSForSentinelMode&&this.options.tls?(Object.assign(s,this.options.tls),this.stream=(0,r.connect)(s),this.stream.once(`secureConnect`,this.initFailoverDetector.bind(this))):(this.stream=(0,t.createConnection)(s),this.stream.once(`connect`,this.initFailoverDetector.bind(this))),this.stream.once(`error`,e=>{this.firstError=e}),this.stream;{let t=l?`failed to connect to sentinel `+u+` because `+l.message:`connected to sentinel `+u+` successfully, but got an invalid reply: `+s;return c(t),e(`sentinelError`,Error(t)),l&&(i=l),a()}};return a()}async updateSentinels(e){if(!this.options.updateSentinels)return;let t=await e.sentinel(`sentinels`,this.options.name);Array.isArray(t)&&(t.map(n.packObject).forEach(e=>{if((e.flags?e.flags.split(`,`):[]).indexOf(`disconnected`)===-1&&e.ip&&e.port){let t=this.sentinelNatResolve(u(e));this.sentinelIterator.add(t)&&c(`adding sentinel %s:%s`,t.host,t.port)}}),c(`Updated internal sentinels: %s`,this.sentinelIterator))}async resolveMaster(e){let t=await e.sentinel(`get-master-addr-by-name`,this.options.name);return await this.updateSentinels(e),this.sentinelNatResolve(Array.isArray(t)?{host:t[0],port:Number(t[1])}:null)}async resolveSlave(e){let t=await e.sentinel(`slaves`,this.options.name);if(!Array.isArray(t))return null;let r=t.map(n.packObject).filter(e=>e.flags&&!e.flags.match(/(disconnected|s_down|o_down)/));return this.sentinelNatResolve(l(r,this.options.preferredSlaves))}sentinelNatResolve(e){if(!e||!this.options.natMap)return e;let t=`${e.host}:${e.port}`,n=e;return typeof this.options.natMap==`function`?n=this.options.natMap(t)||e:typeof this.options.natMap==`object`&&(n=this.options.natMap[t]||e),n}connectToSentinel(e,t){return new o.default({port:e.port||26379,host:e.host,username:this.options.sentinelUsername||null,password:this.options.sentinelPassword||null,family:e.family||(`path`in this.options&&this.options.path?void 0:this.options.family),tls:this.options.sentinelTLS,retryStrategy:null,enableReadyCheck:!1,connectTimeout:this.options.connectTimeout,commandTimeout:this.options.sentinelCommandTimeout,...t})}async resolve(e){let t=this.connectToSentinel(e);t.on(`error`,d);try{return this.options.role===`slave`?await this.resolveSlave(t):await this.resolveMaster(t)}finally{t.disconnect()}}async initFailoverDetector(){var e;if(!this.options.failoverDetector)return;this.sentinelIterator.reset(!0);let t=[];for(;t.length<this.options.sentinelMaxConnections;){let{done:e,value:n}=this.sentinelIterator.next();if(e)break;let r=this.connectToSentinel(n,{lazyConnect:!0,retryStrategy:this.options.sentinelReconnectStrategy});r.on(`reconnecting`,()=>{var e;(e=this.emitter)==null||e.emit(`sentinelReconnecting`)}),t.push({address:n,client:r})}this.sentinelIterator.reset(!1),this.failoverDetector&&this.failoverDetector.cleanup(),this.failoverDetector=new s.FailoverDetector(this,t),await this.failoverDetector.subscribe(),(e=this.emitter)==null||e.emit(`failoverSubscribed`)}};function l(e,t){if(e.length===0)return null;let r;if(typeof t==`function`)r=t(e);else if(typeof t==`object`&&t){let n=Array.isArray(t)?t:[t];n.sort((e,t)=>(e.prio||=1,t.prio||=1,e.prio<t.prio?-1:e.prio>t.prio?1:0));for(let t=0;t<n.length;t++){for(let i=0;i<e.length;i++){let a=e[i];if(a.ip===n[t].ip&&a.port===n[t].port){r=a;break}}if(r)break}}return r||=(0,n.sample)(e),u(r)}function u(e){return{host:e.ip,port:Number(e.port)}}function d(){}})),BF=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.SentinelConnector=e.StandaloneConnector=void 0,e.StandaloneConnector=IF().default,e.SentinelConnector=zF().default})),VF=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=rF();e.default=class extends t.AbortError{constructor(e){let t=`Reached the max retries per request limit (which is ${e}). Refer to "maxRetriesPerRequest" option for details.`;super(t),Error.captureStackTrace(this,this.constructor)}get name(){return this.constructor.name}}})),HF=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.MaxRetriesPerRequestError=void 0,e.MaxRetriesPerRequestError=VF().default})),UF=u(((e,t)=>{let n=h(`buffer`).Buffer,r=h(`string_decoder`).StringDecoder,i=new r,a=rF(),o=a.ReplyError,s=a.ParserError;var c=n.allocUnsafe(32*1024),l=0,u=null,d=0,f=0;function p(e){let t=e.buffer.length-1;var n=e.offset,r=0,i=1;for(e.buffer[n]===45&&(i=-1,n++);n<t;){let t=e.buffer[n++];if(t===13)return e.offset=n+1,i*r;r=r*10+(t-48)}}function m(e){let t=e.buffer.length-1;var n=e.offset,r=0,i=``;for(e.buffer[n]===45&&(i+=`-`,n++);n<t;){var a=e.buffer[n++];if(a===13)return e.offset=n+1,r!==0&&(i+=r),i;r>429496728?(i+=r*10+(a-48),r=0):a===48&&r===0?i+=0:r=r*10+(a-48)}}function g(e){let t=e.offset,n=e.buffer,r=n.length-1;for(var i=t;i<r;)if(n[i++]===13)return e.offset=i+1,e.optionReturnBuffers===!0?e.buffer.slice(t,i-1):e.buffer.toString(`utf8`,t,i-1)}function _(e){let t=e.buffer.length-1;for(var n=e.offset,r=0;n<t;){let t=e.buffer[n++];if(t===13)return e.offset=n+1,r;r=r*10+(t-48)}}function v(e){return e.optionStringNumbers===!0?m(e):p(e)}function y(e){let t=_(e);if(t===void 0)return;if(t<0)return null;let n=e.offset+t;if(n+2>e.buffer.length){e.bigStrSize=n+2,e.totalChunkSize=e.buffer.length,e.bufferCache.push(e.buffer);return}let r=e.offset;return e.offset=n+2,e.optionReturnBuffers===!0?e.buffer.slice(r,n):e.buffer.toString(`utf8`,r,n)}function b(e){var t=g(e);if(t!==void 0)return e.optionReturnBuffers===!0&&(t=t.toString()),new o(t)}function x(e,t){let n=new s(`Protocol error, got `+JSON.stringify(String.fromCharCode(t))+` as reply type byte`,JSON.stringify(e.buffer),e.offset);e.buffer=null,e.returnFatalError(n)}function S(e){let t=_(e);if(t!==void 0)return t<0?null:ee(e,Array(t),0)}function C(e,t,n){e.arrayCache.push(t),e.arrayPos.push(n)}function w(e){let t=e.arrayCache.pop();var n=e.arrayPos.pop();if(e.arrayCache.length){let r=w(e);if(r===void 0){C(e,t,n);return}t[n++]=r}return ee(e,t,n)}function ee(e,t,n){let r=e.buffer.length;for(;n<t.length;){let i=e.offset;if(e.offset>=r){C(e,t,n);return}let a=te(e,e.buffer[e.offset++]);if(a===void 0){e.arrayCache.length||e.bufferCache.length||(e.offset=i),C(e,t,n);return}t[n]=a,n++}return t}function te(e,t){switch(t){case 36:return y(e);case 43:return g(e);case 42:return S(e);case 58:return v(e);case 45:return b(e);default:return x(e,t)}}function T(){if(c.length>50*1024)if(d===1||f>d*2){let e=Math.floor(c.length/10),t=e<l?l:e;l=0,c=c.slice(t,c.length)}else f++,d--;else clearInterval(u),d=0,f=0,u=null}function E(e){if(c.length<e+l){let t=e>1024*1024*75?2:3;l>1024*1024*111&&(l=1024*1024*50),c=n.allocUnsafe(e*t+l),l=0,d++,u===null&&(u=setInterval(T,50))}}function ne(e){let t=e.bufferCache,n=e.offset;var r=t.length,a=e.bigStrSize-e.totalChunkSize;if(e.offset=a,a<=2){if(r===2)return t[0].toString(`utf8`,n,t[0].length+a-2);r--,a=t[t.length-2].length+a}for(var o=i.write(t[0].slice(n)),s=1;s<r-1;s++)o+=i.write(t[s]);return o+=i.end(t[s].slice(0,a-2)),o}function re(e){let t=e.bufferCache,n=e.offset,r=e.bigStrSize-n-2;var i=t.length,a=e.bigStrSize-e.totalChunkSize;if(e.offset=a,a<=2){if(i===2)return t[0].slice(n,t[0].length+a-2);i--,a=t[t.length-2].length+a}E(r);let o=l;t[0].copy(c,o,n,t[0].length),l+=t[0].length-n;for(var s=1;s<i-1;s++)t[s].copy(c,l),l+=t[s].length;return t[s].copy(c,l,0,a-2),l+=a-2,c.slice(o,l)}t.exports=class{constructor(e){if(!e)throw TypeError(`Options are mandatory.`);if(typeof e.returnError!=`function`||typeof e.returnReply!=`function`)throw TypeError(`The returnReply and returnError options have to be functions.`);this.setReturnBuffers(!!e.returnBuffers),this.setStringNumbers(!!e.stringNumbers),this.returnError=e.returnError,this.returnFatalError=e.returnFatalError||e.returnError,this.returnReply=e.returnReply,this.reset()}reset(){this.offset=0,this.buffer=null,this.bigStrSize=0,this.totalChunkSize=0,this.bufferCache=[],this.arrayCache=[],this.arrayPos=[]}setReturnBuffers(e){if(typeof e!=`boolean`)throw TypeError(`The returnBuffers argument has to be a boolean`);this.optionReturnBuffers=e}setStringNumbers(e){if(typeof e!=`boolean`)throw TypeError(`The stringNumbers argument has to be a boolean`);this.optionStringNumbers=e}execute(e){if(this.buffer===null)this.buffer=e,this.offset=0;else if(this.bigStrSize===0){let t=this.buffer.length,r=t-this.offset,i=n.allocUnsafe(r+e.length);if(this.buffer.copy(i,0,this.offset,t),e.copy(i,r,0,e.length),this.buffer=i,this.offset=0,this.arrayCache.length){let e=w(this);if(e===void 0)return;this.returnReply(e)}}else if(this.totalChunkSize+e.length>=this.bigStrSize){this.bufferCache.push(e);var t=this.optionReturnBuffers?re(this):ne(this);if(this.bigStrSize=0,this.bufferCache=[],this.buffer=e,this.arrayCache.length&&(this.arrayCache[0][this.arrayPos[0]++]=t,t=w(this),t===void 0))return;this.returnReply(t)}else{this.bufferCache.push(e),this.totalChunkSize+=e.length;return}for(;this.offset<this.buffer.length;){let e=this.offset,t=this.buffer[this.offset++],n=te(this,t);if(n===void 0){this.arrayCache.length||this.bufferCache.length||(this.offset=e);return}t===45?this.returnError(n):this.returnReply(n)}this.buffer=null}}})),WF=u(((e,t)=>{t.exports=UF()})),GF=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=class{constructor(){this.set={subscribe:{},psubscribe:{},ssubscribe:{}}}add(e,n){this.set[t(e)][n]=!0}del(e,n){delete this.set[t(e)][n]}channels(e){return Object.keys(this.set[t(e)])}isEmpty(){return this.channels(`subscribe`).length===0&&this.channels(`psubscribe`).length===0&&this.channels(`ssubscribe`).length===0}};function t(e){return e===`unsubscribe`?`subscribe`:e===`punsubscribe`?`psubscribe`:e===`sunsubscribe`?`ssubscribe`:e}})),KF=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=_F(),n=hF(),r=WF(),i=GF(),a=(0,n.Debug)(`dataHandler`);e.default=class{constructor(e,t){this.redis=e;let n=new r({stringNumbers:t.stringNumbers,returnBuffers:!0,returnError:e=>{this.returnError(e)},returnFatalError:e=>{this.returnFatalError(e)},returnReply:e=>{this.returnReply(e)}});e.stream.prependListener(`data`,e=>{n.execute(e)}),e.stream.resume()}returnFatalError(e){e.message+=`. Please report this.`,this.redis.recoverFromFatalError(e,e,{offlineQueue:!1})}returnError(e){let t=this.shiftCommand(e);if(t){if(e.command={name:t.command.name,args:t.command.args},t.command.name==`ssubscribe`&&e.message.includes(`MOVED`)){this.redis.emit(`moved`);return}this.redis.handleReconnection(e,t)}}returnReply(e){if(this.handleMonitorReply(e)||this.handleSubscriberReply(e))return;let n=this.shiftCommand(e);n&&(t.default.checkFlag(`ENTER_SUBSCRIBER_MODE`,n.command.name)?(this.redis.condition.subscriber=new i.default,this.redis.condition.subscriber.add(n.command.name,e[1].toString()),s(n.command,e[2])||this.redis.commandQueue.unshift(n)):t.default.checkFlag(`EXIT_SUBSCRIBER_MODE`,n.command.name)?c(n.command,e[2])||this.redis.commandQueue.unshift(n):n.command.resolve(e))}handleSubscriberReply(e){if(!this.redis.condition.subscriber)return!1;let t=Array.isArray(e)?e[0].toString():null;switch(a(`receive reply "%s" in subscriber mode`,t),t){case`message`:this.redis.listeners(`message`).length>0&&this.redis.emit(`message`,e[1].toString(),e[2]?e[2].toString():``),this.redis.emit(`messageBuffer`,e[1],e[2]);break;case`pmessage`:{let t=e[1].toString();this.redis.listeners(`pmessage`).length>0&&this.redis.emit(`pmessage`,t,e[2].toString(),e[3].toString()),this.redis.emit(`pmessageBuffer`,t,e[2],e[3]);break}case`smessage`:this.redis.listeners(`smessage`).length>0&&this.redis.emit(`smessage`,e[1].toString(),e[2]?e[2].toString():``),this.redis.emit(`smessageBuffer`,e[1],e[2]);break;case`ssubscribe`:case`subscribe`:case`psubscribe`:{let n=e[1].toString();this.redis.condition.subscriber.add(t,n);let r=this.shiftCommand(e);if(!r)return;s(r.command,e[2])||this.redis.commandQueue.unshift(r);break}case`sunsubscribe`:case`unsubscribe`:case`punsubscribe`:{let n=e[1]?e[1].toString():null;n&&this.redis.condition.subscriber.del(t,n);let r=e[2];Number(r)===0&&(this.redis.condition.subscriber=!1);let i=this.shiftCommand(e);if(!i)return;c(i.command,r)||this.redis.commandQueue.unshift(i);break}default:{let t=this.shiftCommand(e);if(!t)return;t.command.resolve(e)}}return!0}handleMonitorReply(e){if(this.redis.status!==`monitoring`)return!1;let t=e.toString();if(t===`OK`)return!1;let n=t.indexOf(` `),r=t.slice(0,n),i=t.indexOf(`"`),a=t.slice(i+1,-1).split(`" "`).map(e=>e.replace(/\\"/g,`"`)),o=t.slice(n+2,i-2).split(` `);return this.redis.emit(`monitor`,r,a,o[1],o[0]),!0}shiftCommand(e){let t=this.redis.commandQueue.shift();if(!t){let t=Error(`Command queue state error. If you can reproduce this, please report it.`+(e instanceof Error?` Last error: ${e.message}`:` Last reply: ${e.toString()}`));return this.redis.emit(`error`,t),null}return t}};let o=new WeakMap;function s(e,t){let n=o.has(e)?o.get(e):e.args.length;return--n,n<=0?(e.resolve(t),o.delete(e),!0):(o.set(e,n),!1)}function c(e,t){let n=o.has(e)?o.get(e):e.args.length;return n===0?Number(t)===0?(o.delete(e),e.resolve(t),!0):!1:(--n,n<=0?(e.resolve(t),!0):(o.set(e,n),!1))}})),qF=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.readyHandler=e.errorHandler=e.closeHandler=e.connectHandler=void 0;let t=rF(),n=_F(),r=HF(),i=hF(),a=KF(),o=(0,i.Debug)(`connection`);function s(t){return function(){t.setStatus(`connect`),t.resetCommandQueue();let n=!1,{connectionEpoch:r}=t;t.condition.auth&&t.auth(t.condition.auth,function(e){r===t.connectionEpoch&&e&&(e.message.indexOf(`no password is set`)===-1?e.message.indexOf(`without any password configured for the default user`)===-1?e.message.indexOf(`wrong number of arguments for 'auth' command`)===-1?(n=!0,t.recoverFromFatalError(e,e)):console.warn(`[ERROR] The server returned "wrong number of arguments for 'auth' command". You are probably passing both username and password to Redis version 5 or below. You should only pass the 'password' option for Redis version 5 and under.`):console.warn("[WARN] This Redis server's `default` user does not require a password, but a password was supplied"):console.warn(`[WARN] Redis server does not require a password, but a password was supplied.`))}),t.condition.select&&t.select(t.condition.select).catch(e=>{t.silentEmit(`error`,e)}),new a.default(t,{stringNumbers:t.options.stringNumbers});let s=[];t.options.connectionName&&(o(`set the connection name [%s]`,t.options.connectionName),s.push(t.client(`setname`,t.options.connectionName).catch(i.noop))),t.options.disableClientInfo||(o(`set the client info`),s.push((0,i.getPackageMeta)().then(e=>t.client(`SETINFO`,`LIB-VER`,e.version).catch(i.noop)).catch(i.noop)),s.push(t.client(`SETINFO`,`LIB-NAME`,t.options?.clientInfoTag?`ioredis(${t.options.clientInfoTag})`:`ioredis`).catch(i.noop))),Promise.all(s).catch(i.noop).finally(()=>{t.options.enableReadyCheck||e.readyHandler(t)(),t.options.enableReadyCheck&&t._readyCheck(function(i,a){r===t.connectionEpoch&&(i?n||t.recoverFromFatalError(Error(`Ready check failed: `+i.message),i):t.connector.check(a)?e.readyHandler(t)():t.disconnect(!0))})})}}e.connectHandler=s;function c(e){let n=new t.AbortError(`Command aborted due to connection close`);return n.command={name:e.name,args:e.args},n}function l(e){let t=0;for(let n=0;n<e.length;){let r=e.peekAt(n)?.command,i=r.pipelineIndex;if((i===void 0||i===0)&&(t=0),i!==void 0&&i!==t++){e.remove(n,1),r.reject(c(r));continue}n++}}function u(e){for(let t=0;t<e.length;){let n=e.peekAt(t)?.command;if(n.name===`multi`)break;if(n.name===`exec`){e.remove(t,1),n.reject(c(n));break}n.inTransaction?(e.remove(t,1),n.reject(c(n))):t++}}function d(e){return function(){let n=e.status;if(e.setStatus(`close`),e.commandQueue.length&&l(e.commandQueue),e.offlineQueue.length&&u(e.offlineQueue),n===`ready`&&(e.prevCondition||=e.condition,e.commandQueue.length&&(e.prevCommandQueue=e.commandQueue)),e.manuallyClosing)return e.manuallyClosing=!1,o(`skip reconnecting since the connection is manually closed.`),t();if(typeof e.options.retryStrategy!=`function`)return o("skip reconnecting because `retryStrategy` is not a function"),t();let a=e.options.retryStrategy(++e.retryAttempts);if(typeof a!=`number`)return o("skip reconnecting because `retryStrategy` doesn't return a number"),t();o(`reconnect in %sms`,a),e.setStatus(`reconnecting`,a),e.reconnectTimeout=setTimeout(function(){e.reconnectTimeout=null,e.connect().catch(i.noop)},a);let{maxRetriesPerRequest:s}=e.options;typeof s==`number`&&(s<0?o(`maxRetriesPerRequest is negative, ignoring...`):e.retryAttempts%(s+1)===0&&(o(`reach maxRetriesPerRequest limitation, flushing command queue...`),e.flushQueue(new r.MaxRetriesPerRequestError(s))))};function t(){e.setStatus(`end`),e.flushQueue(Error(i.CONNECTION_CLOSED_ERROR_MSG))}}e.closeHandler=d;function f(e){return function(t){o(`error: %s`,t),e.silentEmit(`error`,t)}}e.errorHandler=f;function p(e){return function(){if(e.setStatus(`ready`),e.retryAttempts=0,e.options.monitor){e.call(`monitor`).then(()=>e.setStatus(`monitoring`),t=>e.emit(`error`,t));let{sendCommand:t}=e;e.sendCommand=function(r){return n.default.checkFlag(`VALID_IN_MONITOR_MODE`,r.name)?t.call(e,r):(r.reject(Error(`Connection is in monitoring mode, can't process commands.`)),r.promise)},e.once(`close`,function(){delete e.sendCommand});return}let t=e.prevCondition?e.prevCondition.select:e.condition.select;if(e.options.readOnly&&(o(`set the connection to readonly mode`),e.readonly().catch(i.noop)),e.prevCondition){let n=e.prevCondition;if(e.prevCondition=null,n.subscriber&&e.options.autoResubscribe){e.condition.select!==t&&(o(`connect to db [%d]`,t),e.select(t));let r=n.subscriber.channels(`subscribe`);r.length&&(o(`subscribe %d channels`,r.length),e.subscribe(r));let i=n.subscriber.channels(`psubscribe`);i.length&&(o(`psubscribe %d channels`,i.length),e.psubscribe(i));let a=n.subscriber.channels(`ssubscribe`);if(a.length){o(`ssubscribe %s`,a.length);for(let t of a)e.ssubscribe(t)}}}if(e.prevCommandQueue)if(e.options.autoResendUnfulfilledCommands)for(o(`resend %d unfulfilled commands`,e.prevCommandQueue.length);e.prevCommandQueue.length>0;){let t=e.prevCommandQueue.shift();t.select!==e.condition.select&&t.command.name!==`select`&&e.select(t.select),e.sendCommand(t.command,t.stream)}else e.prevCommandQueue=null;if(e.offlineQueue.length){o(`send %d commands in offline queue`,e.offlineQueue.length);let t=e.offlineQueue;for(e.resetOfflineQueue();t.length>0;){let n=t.shift();n.select!==e.condition.select&&n.command.name!==`select`&&e.select(n.select),e.sendCommand(n.command,n.stream)}}e.condition.select!==t&&(o(`connect to db [%d]`,t),e.select(t))}}e.readyHandler=p})),JF=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.DEFAULT_REDIS_OPTIONS=void 0,e.DEFAULT_REDIS_OPTIONS={port:6379,host:`localhost`,family:0,connectTimeout:1e4,disconnectTimeout:2e3,retryStrategy:function(e){return Math.min(e*50,2e3)},keepAlive:0,noDelay:!0,connectionName:null,disableClientInfo:!1,clientInfoTag:void 0,sentinels:null,name:null,role:`master`,sentinelRetryStrategy:function(e){return Math.min(e*10,1e3)},sentinelReconnectStrategy:function(){return 6e4},natMap:null,enableTLSForSentinelMode:!1,updateSentinels:!0,failoverDetector:!1,username:null,password:null,db:0,enableOfflineQueue:!0,enableReadyCheck:!0,autoResubscribe:!0,autoResendUnfulfilledCommands:!0,lazyConnect:!1,keyPrefix:``,reconnectOnError:null,readOnly:!1,stringNumbers:!1,maxRetriesPerRequest:20,maxLoadingRetryTime:1e4,enableAutoPipelining:!1,autoPipeliningIgnoredCommands:[],sentinelMaxConnections:10,blockingTimeoutGrace:100}})),YF=u((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=QP(),n=h(`events`),r=eF(),i=PF(),a=_F(),o=BF(),s=zF(),c=qF(),l=JF(),u=yF(),d=wF(),f=hF(),p=TF(),m=SF(),g=sF(),_=AF(),v=(0,f.Debug)(`redis`);var y=class e extends m.default{constructor(e,t,r){if(super(),this.status=`wait`,this.isCluster=!1,this.reconnectTimeout=null,this.connectionEpoch=0,this.retryAttempts=0,this.manuallyClosing=!1,this._autoPipelines=new Map,this._runningAutoPipelines=new Set,this.parseOptions(e,t,r),n.EventEmitter.call(this),this.resetCommandQueue(),this.resetOfflineQueue(),this.options.Connector)this.connector=new this.options.Connector(this.options);else if(this.options.sentinels){let e=new s.default(this.options);e.emitter=this,this.connector=e}else this.connector=new o.StandaloneConnector(this.options);this.options.scripts&&Object.entries(this.options.scripts).forEach(([e,t])=>{this.defineCommand(e,t)}),this.options.lazyConnect?this.setStatus(`wait`):this.connect().catch(g.noop)}static createClient(...t){return new e(...t)}get autoPipelineQueueSize(){let e=0;for(let t of this._autoPipelines.values())e+=t.length;return e}connect(e){let t=new Promise((e,t)=>{if(this.status===`connecting`||this.status===`connect`||this.status===`ready`){t(Error(`Redis is already connecting/connected`));return}this.connectionEpoch+=1,this.setStatus(`connecting`);let{options:n}=this;this.condition={select:n.db,auth:n.username?[n.username,n.password]:n.password,subscriber:!1};let i=this;(0,r.default)(this.connector.connect(function(e,t){i.silentEmit(e,t)}),function(r,a){if(r){i.flushQueue(r),i.silentEmit(`error`,r),t(r),i.setStatus(`end`);return}let o=n.tls?`secureConnect`:`connect`;if(`sentinels`in n&&n.sentinels&&!n.enableTLSForSentinelMode&&(o=`connect`),i.stream=a,n.noDelay&&a.setNoDelay(!0),typeof n.keepAlive==`number`&&(a.connecting?a.once(o,()=>{a.setKeepAlive(!0,n.keepAlive)}):a.setKeepAlive(!0,n.keepAlive)),a.connecting){if(a.once(o,c.connectHandler(i)),n.connectTimeout){let e=!1;a.setTimeout(n.connectTimeout,function(){if(e)return;a.setTimeout(0),a.destroy();let t=Error(`connect ETIMEDOUT`);t.errorno=`ETIMEDOUT`,t.code=`ETIMEDOUT`,t.syscall=`connect`,c.errorHandler(i)(t)}),a.once(o,function(){e=!0,a.setTimeout(0)})}}else if(a.destroyed){let e=i.connector.firstError;e&&process.nextTick(()=>{c.errorHandler(i)(e)}),process.nextTick(c.closeHandler(i))}else process.nextTick(c.connectHandler(i));a.destroyed||(a.once(`error`,c.errorHandler(i)),a.once(`close`,c.closeHandler(i)));let s=function(){i.removeListener(`close`,l),e()};var l=function(){i.removeListener(`ready`,s),t(Error(f.CONNECTION_CLOSED_ERROR_MSG))};i.once(`ready`,s),i.once(`close`,l)})});return(0,r.default)(t,e)}disconnect(e=!1){e||(this.manuallyClosing=!0),this.reconnectTimeout&&!e&&(clearTimeout(this.reconnectTimeout),this.reconnectTimeout=null),this.status===`wait`?c.closeHandler(this)():this.connector.disconnect()}end(){this.disconnect()}duplicate(t){return new e({...this.options,...t})}get mode(){return this.options.monitor?`monitor`:this.condition?.subscriber?`subscriber`:`normal`}monitor(e){let t=this.duplicate({monitor:!0,lazyConnect:!1});return(0,r.default)(new Promise(function(e,n){t.once(`error`,n),t.once(`monitoring`,function(){e(t)})}),e)}sendCommand(e,n){if(this.status===`wait`&&this.connect().catch(g.noop),this.status===`end`)return e.reject(Error(f.CONNECTION_CLOSED_ERROR_MSG)),e.promise;if(this.condition?.subscriber&&!a.default.checkFlag(`VALID_IN_SUBSCRIBER_MODE`,e.name))return e.reject(Error(`Connection in subscriber mode, only subscriber commands may be used`)),e.promise;typeof this.options.commandTimeout==`number`&&e.setTimeout(this.options.commandTimeout);let r=this.getBlockingTimeoutInMs(e),i=this.status===`ready`||!n&&this.status===`connect`&&(0,t.exists)(e.name,{caseInsensitive:!0})&&((0,t.hasFlag)(e.name,`loading`,{nameCaseInsensitive:!0})||a.default.checkFlag(`HANDSHAKE_COMMANDS`,e.name));if(this.stream&&this.stream.writable?this.stream._writableState&&this.stream._writableState.ended&&(i=!1):i=!1,i)v.enabled&&v(`write command[%s]: %d -> %s(%o)`,this._getDescription(),this.condition?.select,e.name,e.args),n?`isPipeline`in n&&n.isPipeline?n.write(e.toWritable(n.destination.redis.stream)):n.write(e.toWritable(n)):this.stream.write(e.toWritable(this.stream)),this.commandQueue.push({command:e,stream:n,select:this.condition.select}),r!==void 0&&e.setBlockingTimeout(r),a.default.checkFlag(`WILL_DISCONNECT`,e.name)&&(this.manuallyClosing=!0),this.options.socketTimeout!==void 0&&this.socketTimeoutTimer===void 0&&this.setSocketTimeout();else{if(!this.options.enableOfflineQueue)return e.reject(Error(`Stream isn't writeable and enableOfflineQueue options is false`)),e.promise;if(e.name===`quit`&&this.offlineQueue.length===0)return this.disconnect(),e.resolve(Buffer.from(`OK`)),e.promise;if(v.enabled&&v(`queue command[%s]: %d -> %s(%o)`,this._getDescription(),this.condition.select,e.name,e.args),this.offlineQueue.push({command:e,stream:n,select:this.condition.select}),a.default.checkFlag(`BLOCKING_COMMANDS`,e.name)){let t=this.getConfiguredBlockingTimeout();t!==void 0&&e.setBlockingTimeout(t)}}if(e.name===`select`&&(0,f.isInt)(e.args[0])){let t=parseInt(e.args[0],10);this.condition.select!==t&&(this.condition.select=t,this.emit(`select`,t),v(`switch to db [%d]`,this.condition.select))}return e.promise}getBlockingTimeoutInMs(e){if(!a.default.checkFlag(`BLOCKING_COMMANDS`,e.name))return;let t=this.getConfiguredBlockingTimeout();if(t===void 0)return;let n=e.extractBlockingTimeout();if(typeof n==`number`)return n>0?n+(this.options.blockingTimeoutGrace??l.DEFAULT_REDIS_OPTIONS.blockingTimeoutGrace):t;if(n===null)return t}getConfiguredBlockingTimeout(){if(typeof this.options.blockingTimeout==`number`&&this.options.blockingTimeout>0)return this.options.blockingTimeout}setSocketTimeout(){this.socketTimeoutTimer=setTimeout(()=>{this.stream.destroy(Error(`Socket timeout. Expecting data, but didn't receive any in ${this.options.socketTimeout}ms.`)),this.socketTimeoutTimer=void 0},this.options.socketTimeout),this.stream.once(`data`,()=>{clearTimeout(this.socketTimeoutTimer),this.socketTimeoutTimer=void 0,this.commandQueue.length!==0&&this.setSocketTimeout()})}scanStream(e){return this.createScanStream(`scan`,{options:e})}scanBufferStream(e){return this.createScanStream(`scanBuffer`,{options:e})}sscanStream(e,t){return this.createScanStream(`sscan`,{key:e,options:t})}sscanBufferStream(e,t){return this.createScanStream(`sscanBuffer`,{key:e,options:t})}hscanStream(e,t){return this.createScanStream(`hscan`,{key:e,options:t})}hscanBufferStream(e,t){return this.createScanStream(`hscanBuffer`,{key:e,options:t})}zscanStream(e,t){return this.createScanStream(`zscan`,{key:e,options:t})}zscanBufferStream(e,t){return this.createScanStream(`zscanBuffer`,{key:e,options:t})}silentEmit(e,t){let n;if(!(e===`error`&&(n=t,this.status===`end`||this.manuallyClosing&&n instanceof Error&&(n.message===f.CONNECTION_CLOSED_ERROR_MSG||n.syscall===`connect`||n.syscall===`read`))))return this.listeners(e).length>0?this.emit.apply(this,arguments):(n&&n instanceof Error&&console.error(`[ioredis] Unhandled error event:`,n.stack),!1)}recoverFromFatalError(e,t,n){this.flushQueue(t,n),this.silentEmit(`error`,t),this.disconnect(!0)}handleReconnection(e,t){let n=!1;switch(this.options.reconnectOnError&&!a.default.checkFlag(`IGNORE_RECONNECT_ON_ERROR`,t.command.name)&&(n=this.options.reconnectOnError(e)),n){case 1:case!0:this.status!==`reconnecting`&&this.disconnect(!0),t.command.reject(e);break;case 2:this.status!==`reconnecting`&&this.disconnect(!0),this.condition?.select!==t.select&&t.command.name!==`select`&&this.select(t.select),this.sendCommand(t.command);break;default:t.command.reject(e)}}_getDescription(){let e;return e=`path`in this.options&&this.options.path?this.options.path:this.stream&&this.stream.remoteAddress&&this.stream.remotePort?this.stream.remoteAddress+`:`+this.stream.remotePort:`host`in this.options&&this.options.host?this.options.host+`:`+this.options.port:``,this.options.connectionName&&(e+=` (${this.options.connectionName})`),e}resetCommandQueue(){this.commandQueue=new _}resetOfflineQueue(){this.offlineQueue=new _}parseOptions(...t){let n={},r=!1;for(let e=0;e<t.length;++e){let i=t[e];if(i!=null)if(typeof i==`object`)(0,g.defaults)(n,i);else if(typeof i==`string`)(0,g.defaults)(n,(0,f.parseURL)(i)),i.startsWith(`rediss://`)&&(r=!0);else if(typeof i==`number`)n.port=i;else throw Error(`Invalid argument `+i)}r&&(0,g.defaults)(n,{tls:!0}),(0,g.defaults)(n,e.defaultOptions),typeof n.port==`string`&&(n.port=parseInt(n.port,10)),typeof n.db==`string`&&(n.db=parseInt(n.db,10)),this.options=(0,f.resolveTLSProfile)(n)}setStatus(e,t){v.enabled&&v(`status[%s]: %s -> %s`,this._getDescription(),this.status||`[empty]`,e),this.status=e,process.nextTick(this.emit.bind(this,e,t))}createScanStream(e,{key:t,options:n={}}){return new u.default({objectMode:!0,key:t,redis:this,command:e,...n})}flushQueue(e,t){t=(0,g.defaults)({},t,{offlineQueue:!0,commandQueue:!0});let n;if(t.offlineQueue)for(;n=this.offlineQueue.shift();)n.command.reject(e);if(t.commandQueue&&this.commandQueue.length>0)for(this.stream&&this.stream.removeAllListeners(`data`);n=this.commandQueue.shift();)n.command.reject(e)}_readyCheck(e){let t=this;this.info(function(n,r){if(n)return n.message&&n.message.includes(`NOPERM`)?(console.warn(`Skipping the ready check because INFO command fails: "${n.message}". You can disable ready check with "enableReadyCheck". More: https://github.com/luin/ioredis/wiki/Disable-ready-check.`),e(null,{})):e(n);if(typeof r!=`string`)return e(null,r);let i={},a=r.split(`\r
236
- `);for(let e=0;e<a.length;++e){let[t,...n]=a[e].split(`:`),r=n.join(`:`);r&&(i[t]=r)}if(!i.loading||i.loading===`0`)e(null,i);else{let n=(i.loading_eta_seconds||1)*1e3,r=t.options.maxLoadingRetryTime&&t.options.maxLoadingRetryTime<n?t.options.maxLoadingRetryTime:n;v(`Redis server still loading, trying again in `+r+`ms`),setTimeout(function(){t._readyCheck(e)},r)}}).catch(g.noop)}};y.Cluster=i.default,y.Command=a.default,y.defaultOptions=l.DEFAULT_REDIS_OPTIONS,(0,p.default)(y,n.EventEmitter),(0,d.addTransactionSupport)(y.prototype),e.default=y})),XF=u(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.print=e.ReplyError=e.SentinelIterator=e.SentinelConnector=e.AbstractConnector=e.Pipeline=e.ScanStream=e.Command=e.Cluster=e.Redis=e.default=void 0,e=t.exports=YF().default;var n=YF();Object.defineProperty(e,`default`,{enumerable:!0,get:function(){return n.default}});var r=YF();Object.defineProperty(e,`Redis`,{enumerable:!0,get:function(){return r.default}});var i=PF();Object.defineProperty(e,`Cluster`,{enumerable:!0,get:function(){return i.default}});var a=_F();Object.defineProperty(e,`Command`,{enumerable:!0,get:function(){return a.default}});var o=yF();Object.defineProperty(e,`ScanStream`,{enumerable:!0,get:function(){return o.default}});var s=CF();Object.defineProperty(e,`Pipeline`,{enumerable:!0,get:function(){return s.default}});var c=FF();Object.defineProperty(e,`AbstractConnector`,{enumerable:!0,get:function(){return c.default}});var l=zF();Object.defineProperty(e,`SentinelConnector`,{enumerable:!0,get:function(){return l.default}}),Object.defineProperty(e,`SentinelIterator`,{enumerable:!0,get:function(){return l.SentinelIterator}}),e.ReplyError=rF().ReplyError,Object.defineProperty(e,`Promise`,{get(){return console.warn(`ioredis v5 does not support plugging third-party Promise library anymore. Native Promise will be used.`),Promise},set(e){console.warn(`ioredis v5 does not support plugging third-party Promise library anymore. Native Promise will be used.`)}});function u(e,t){e?console.log(`Error: `+e):console.log(`Reply: `+t)}e.print=u}))();const ZF=e=>{let t=process.env.REDIS_HOST,n=Number(process.env.REDIS_PORT??6379),r=process.env.CHANNEL;if(!t||!r)return console.warn(`Relay disabled: missing REDIS_HOST or CHANNEL`),{async stop(){}};let i=new XF.Redis({host:t,port:n,tls:{},keepAlive:0,noDelay:!0,enableReadyCheck:!1,connectTimeout:5e3,retryStrategy(e){return e>20?null:Math.min(e*500,5e3)}});return i.on(`error`,e=>{console.error(`Relay redis error`,e)}),i.on(`end`,()=>{console.error(`Relay redis connection ended`),process.exit(1)}),i.subscribe(r).catch(e=>{console.error(`Relay subscribe failed`,e),process.exit(1)}),i.on(`message`,(t,n)=>{let r;try{r=Le(n)}catch{return}if(typeof r!=`object`||!r||!(`topic`in r)||typeof r.topic!=`string`||!(`event`in r)||typeof r.event!=`string`)return;let i=`payload`in r&&typeof r.payload==`string`?r.payload:``;e.publish(r.topic,`${r.event} ${i}`)}),{async stop(){await i.quit().catch(()=>{})}}},QF=Number(process.env.PORT??3e3),$F=process.env.ORIGIN_SECRET,eI=Bun.serve({port:QF,routes:{"/health":()=>new Response(`ok`),"/ws":(e,n)=>{if($F&&e.headers.get(`x-origin-secret`)!==$F)return new Response(`Forbidden`,{status:403});if(!n.upgrade(e,{data:{id:t(),authenticated:!1,allowed:[]}}))return new Response(`Upgrade failed`,{status:500})}},websocket:{data:{},sendPings:!0,idleTimeout:15,open(e){e.data.authTimeout=setTimeout(()=>{e.close(4001,`Authentication timeout`)},1e4)},async message(e,t){if(typeof t!=`string`){e.close(4e3,`Invalid message payload`);return}if(t===`PING`){e.send(`PONG`);return}let[n,...r]=t.split(` `);if(!e.data.authenticated){if(n!==`AUTH`||e.data.authenticating){e.close(4001,`Not authenticated`);return}e.data.authenticating=!0;let t=r.join(` `),i=await XP(t===``?void 0:t);if(e.readyState!==WebSocket.OPEN)return;if(!i.authorized){e.close(4001,i.reason);return}clearTimeout(e.data.authTimeout),e.data.authenticated=!0,e.data.authenticating=!1,e.data.context=i.context,e.data.allowed=i.allowed,e.sendText(`ACK`),dd(e);return}let i=r.join(` `).split(`,`);if(n===`SUB`){pd(e,i);return}if(n===`UNSUB`){md(e,i);return}e.close(4e3,`Invalid message payload`)},close(e){clearTimeout(e.data.authTimeout),fd(e)}}}),tI=ZF(eI);process.on(`SIGTERM`,async()=>{eI.stop(),await tI.stop(),process.exit(0)}),console.log(`Socket server running on port ${QF}`);export{};
236
+ `);for(let e=0;e<a.length;++e){let[t,...n]=a[e].split(`:`),r=n.join(`:`);r&&(i[t]=r)}if(!i.loading||i.loading===`0`)e(null,i);else{let n=(i.loading_eta_seconds||1)*1e3,r=t.options.maxLoadingRetryTime&&t.options.maxLoadingRetryTime<n?t.options.maxLoadingRetryTime:n;v(`Redis server still loading, trying again in `+r+`ms`),setTimeout(function(){t._readyCheck(e)},r)}}).catch(g.noop)}};y.Cluster=i.default,y.Command=a.default,y.defaultOptions=l.DEFAULT_REDIS_OPTIONS,(0,p.default)(y,n.EventEmitter),(0,d.addTransactionSupport)(y.prototype),e.default=y})),XF=u(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.print=e.ReplyError=e.SentinelIterator=e.SentinelConnector=e.AbstractConnector=e.Pipeline=e.ScanStream=e.Command=e.Cluster=e.Redis=e.default=void 0,e=t.exports=YF().default;var n=YF();Object.defineProperty(e,`default`,{enumerable:!0,get:function(){return n.default}});var r=YF();Object.defineProperty(e,`Redis`,{enumerable:!0,get:function(){return r.default}});var i=PF();Object.defineProperty(e,`Cluster`,{enumerable:!0,get:function(){return i.default}});var a=_F();Object.defineProperty(e,`Command`,{enumerable:!0,get:function(){return a.default}});var o=yF();Object.defineProperty(e,`ScanStream`,{enumerable:!0,get:function(){return o.default}});var s=CF();Object.defineProperty(e,`Pipeline`,{enumerable:!0,get:function(){return s.default}});var c=FF();Object.defineProperty(e,`AbstractConnector`,{enumerable:!0,get:function(){return c.default}});var l=zF();Object.defineProperty(e,`SentinelConnector`,{enumerable:!0,get:function(){return l.default}}),Object.defineProperty(e,`SentinelIterator`,{enumerable:!0,get:function(){return l.SentinelIterator}}),e.ReplyError=rF().ReplyError,Object.defineProperty(e,`Promise`,{get(){return console.warn(`ioredis v5 does not support plugging third-party Promise library anymore. Native Promise will be used.`),Promise},set(e){console.warn(`ioredis v5 does not support plugging third-party Promise library anymore. Native Promise will be used.`)}});function u(e,t){e?console.log(`Error: `+e):console.log(`Reply: `+t)}e.print=u}))();const ZF=e=>{let t=process.env.REDIS_HOST,n=Number(process.env.REDIS_PORT??6379),r=process.env.CHANNEL;if(!t||!r)return console.warn(`Relay disabled: missing REDIS_HOST or CHANNEL`),{async stop(){}};let i=new XF.Redis({host:t,port:n,tls:{},keepAlive:0,noDelay:!0,enableReadyCheck:!1,connectTimeout:5e3,retryStrategy(e){return e>20?null:Math.min(e*500,5e3)}});return i.on(`error`,e=>{console.error(`Relay redis error`,e)}),i.on(`end`,()=>{console.error(`Relay redis connection ended`),process.exit(1)}),i.subscribe(r).catch(e=>{console.error(`Relay subscribe failed`,e),process.exit(1)}),i.on(`message`,(t,n)=>{let r;try{r=Le(n)}catch{return}if(typeof r!=`object`||!r||!(`topic`in r)||typeof r.topic!=`string`||!(`event`in r)||typeof r.event!=`string`)return;let i=`payload`in r&&typeof r.payload==`string`?r.payload:``;e.publish(r.topic,`${r.event} ${i}`)}),{async stop(){await i.quit().catch(()=>{})}}},QF=Number(process.env.PORT??3e3),$F=process.env.ORIGIN_SECRET,eI=(e,t)=>{let n=e.headers.get(`x-forwarded-for`);if(n){let e=n.split(`,`).map(e=>e.trim()).filter(Boolean);return e.length>=2?e[e.length-2]:e[0]}return t.requestIP(e)?.address},tI=Bun.serve({port:QF,routes:{"/health":()=>new Response(`ok`),"/ws":(e,n)=>{if($F&&e.headers.get(`x-origin-secret`)!==$F)return new Response(`Forbidden`,{status:403});let r=eI(e,n);if(!r)return new Response(`Unable to determine the client address`,{status:400});if(!n.upgrade(e,{data:{id:t(),ip:r,authenticated:!1,allowed:[]}}))return new Response(`Upgrade failed`,{status:500})}},websocket:{data:{},sendPings:!0,idleTimeout:15,open(e){e.data.authTimeout=setTimeout(()=>{e.close(4001,`Authentication timeout`)},1e4)},async message(e,t){if(typeof t!=`string`){e.close(4e3,`Invalid message payload`);return}if(t===`PING`){e.send(`PONG`);return}let[n,...r]=t.split(` `);if(!e.data.authenticated){if(n!==`AUTH`||e.data.authenticating){e.close(4001,`Not authenticated`);return}e.data.authenticating=!0;let t=r.join(` `),i=await XP(t===``?void 0:t);if(e.readyState!==WebSocket.OPEN)return;if(!i.authorized){e.close(4001,i.reason);return}clearTimeout(e.data.authTimeout),e.data.authenticated=!0,e.data.authenticating=!1,e.data.context=i.context,e.data.allowed=i.allowed,e.sendText(`ACK`),dd(e);return}let i=r.join(` `).split(`,`);if(n===`SUB`){pd(e,i);return}if(n===`UNSUB`){md(e,i);return}e.close(4e3,`Invalid message payload`)},close(e){clearTimeout(e.data.authTimeout),fd(e)}}}),nI=ZF(tI);process.on(`SIGTERM`,async()=>{tI.stop(),await nI.stop(),process.exit(0)}),console.log(`Socket server running on port ${QF}`);export{};