UNPKG

@kya-os/mcp-i

Version:

The TypeScript MCP framework with identity features built-in

1 lines 49.3 kB
"use strict";exports.id=482,exports.ids=[482],exports.modules={22371:(e,t,r)=>{r.d(t,{k:()=>w});var n=r(96440),s=r(71407);const i="(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun)(?:[ne|u?r]?s?day)?",o="(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)",a="(\\d?\\d):(\\d{2}):(\\d{2})(?:\\.(\\d+))?",l="(\\d?\\d)",c="(\\d{4})",u=new RegExp(/^(\d{4})-(\d\d)-(\d\d)[tT](\d\d):(\d\d):(\d\d)(\.(\d+))?(([-+]\d\d:\d\d)|[zZ])$/),d=new RegExp(`^${i}, ${l} ${o} ${c} ${a} GMT$`),h=new RegExp(`^${i}, ${l}-${o}-(\\d\\d) ${a} GMT$`),p=new RegExp(`^${i} ${o} ( [1-9]|\\d\\d) ${a} ${c}$`),g=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function f(e,t,r){const n=Number(e);if(n<t||n>r)throw new Error(`Value ${n} out of range [${t}, ${r}]`)}var m=r(74910),y=r(52123),x=r(12544),b=r(2914),E=r(79037),S=r(17735);class w extends E.f{settings;constructor(e){super(),this.settings=e}read(e,t){const r=n.l.of(e);if(r.isListSchema())return(0,s.G)(t).map(e=>this.read(r.getValueSchema(),e));if(r.isBlobSchema())return(this.serdeContext?.base64Decoder??x.E)(t);if(r.isTimestampSchema())switch((0,S.V)(r,this.settings)){case 5:return(e=>{if(null==e)return;if("string"!=typeof e)throw new TypeError("RFC3339 timestamps must be strings");const t=u.exec(e);if(!t)throw new TypeError(`Invalid RFC3339 timestamp format ${e}`);const[,r,n,s,i,o,a,,l,c]=t;f(n,1,12),f(s,1,31),f(i,0,23),f(o,0,59),f(a,0,60);const d=new Date(Date.UTC(Number(r),Number(n)-1,Number(s),Number(i),Number(o),Number(a),Number(l)?Math.round(1e3*parseFloat(`0.${l}`)):0));if(d.setUTCFullYear(Number(r)),"Z"!=c.toUpperCase()){const[,e,t,r]=/([+-])(\d\d):(\d\d)/.exec(c)||[void 0,"+",0,0],n="-"===e?1:-1;d.setTime(d.getTime()+n*(60*Number(t)*60*1e3+60*Number(r)*1e3))}return d})(t);case 6:return(e=>{if(null==e)return;if("string"!=typeof e)throw new TypeError("RFC7231 timestamps must be strings.");let t,r,n,s,i,o,a,l;if((l=d.exec(e))?[,t,r,n,s,i,o,a]=l:(l=h.exec(e))?([,t,r,n,s,i,o,a]=l,n=(Number(n)+1900).toString()):(l=p.exec(e))&&([,r,t,s,i,o,a,n]=l),n&&o){const e=Date.UTC(Number(n),g.indexOf(r),Number(t),Number(s),Number(i),Number(o),a?Math.round(1e3*parseFloat(`0.${a}`)):0);f(t,1,31),f(s,0,23),f(i,0,59),f(o,0,60);const l=new Date(e);return l.setUTCFullYear(Number(n)),l}throw new TypeError(`Invalid RFC7231 date-time value ${e}.`)})(t);case 7:return(e=>{if(null==e)return;let t=NaN;if("number"==typeof e)t=e;else if("string"==typeof e){if(!/^-?\d*\.?\d+$/.test(e))throw new TypeError("parseEpochTimestamp - numeric string invalid.");t=Number.parseFloat(e)}else"object"==typeof e&&1===e.tag&&(t=e.value);if(isNaN(t)||Math.abs(t)===1/0)throw new TypeError("Epoch timestamps must be valid finite numbers.");return new Date(Math.round(1e3*t))})(t);default:return console.warn("Missing timestamp format, parsing value with Date constructor:",t),new Date(t)}if(r.isStringSchema()){const e=r.getMergedTraits().mediaType;let n=t;if(e)return r.getMergedTraits().httpHeader&&(n=this.base64ToUtf8(n)),("application/json"===e||e.endsWith("+json"))&&(n=m.A.from(n)),n}return r.isNumericSchema()?Number(t):r.isBigIntegerSchema()?BigInt(t):r.isBigDecimalSchema()?new y.D(t,"bigDecimal"):r.isBooleanSchema()?"true"===String(t).toLowerCase():t}base64ToUtf8(e){return(this.serdeContext?.utf8Encoder??b.P)((this.serdeContext?.base64Decoder??x.E)(e))}}},27590:(e,t,r)=>{r.d(t,{m:()=>n});class n{async sign(e,t,r){return e}}},61210:(e,t,r)=>{function n(e){return encodeURIComponent(e).replace(/[!'()*]/g,function(e){return"%"+e.charCodeAt(0).toString(16).toUpperCase()})}r.d(t,{$:()=>n})},71407:(e,t,r)=>{r.d(t,{G:()=>n});const n=e=>{const t=e.length,r=[];let n,s=!1,i=0;for(let o=0;o<t;++o){const t=e[o];switch(t){case'"':"\\"!==n&&(s=!s);break;case",":s||(r.push(e.slice(i,o)),i=o+1)}n=t}return r.push(e.slice(i)),r.map(e=>{const t=(e=e.trim()).length;return t<2?e:('"'===e[0]&&'"'===e[t-1]&&(e=e.slice(1,t-1)),e.replace(/\\"/g,'"'))})}},74033:e=>{e.exports={rE:"3.940.0"}},84482:(e,t,r)=>{r.d(t,{getDefaultRoleAssumer:()=>dn,getDefaultRoleAssumerWithWebIdentity:()=>hn});var n=r(53243),s=r(53872),i=r(28075);const o=!1;var a=r(17801),l=r(42829);const c={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"}};var u=r(38796),d=r(60763);class h extends d.T{constructor(e){super(e),Object.setPrototypeOf(this,h.prototype)}}class p extends h{name="ExpiredTokenException";$fault="client";constructor(e){super({name:"ExpiredTokenException",$fault:"client",...e}),Object.setPrototypeOf(this,p.prototype)}}class g extends h{name="MalformedPolicyDocumentException";$fault="client";constructor(e){super({name:"MalformedPolicyDocumentException",$fault:"client",...e}),Object.setPrototypeOf(this,g.prototype)}}class f extends h{name="PackedPolicyTooLargeException";$fault="client";constructor(e){super({name:"PackedPolicyTooLargeException",$fault:"client",...e}),Object.setPrototypeOf(this,f.prototype)}}class m extends h{name="RegionDisabledException";$fault="client";constructor(e){super({name:"RegionDisabledException",$fault:"client",...e}),Object.setPrototypeOf(this,m.prototype)}}class y extends h{name="IDPRejectedClaimException";$fault="client";constructor(e){super({name:"IDPRejectedClaimException",$fault:"client",...e}),Object.setPrototypeOf(this,y.prototype)}}class x extends h{name="InvalidIdentityTokenException";$fault="client";constructor(e){super({name:"InvalidIdentityTokenException",$fault:"client",...e}),Object.setPrototypeOf(this,x.prototype)}}class b extends h{name="IDPCommunicationErrorException";$fault="client";constructor(e){super({name:"IDPCommunicationErrorException",$fault:"client",...e}),Object.setPrototypeOf(this,b.prototype)}}const E="AssumedRoleUser",S="Credentials",w="DurationSeconds",v="Policy",T="PolicyArns",N="PackedPolicySize",I="RoleArn",A="RoleSessionName",P="SourceIdentity",C="awsQueryError",D="client",k="error",O="httpError",$="message",R="smithy.ts.sdk.synthetic.com.amazonaws.sts",M="com.amazonaws.sts";var F=[0,M,"accessKeySecretType",8,0],j=[0,M,"clientTokenType",8,0],U=[3,M,E,0,["AssumedRoleId","Arn"],[0,0]],V=[3,M,"AssumeRoleRequest",0,[I,A,T,v,w,"Tags","TransitiveTagKeys","ExternalId","SerialNumber","TokenCode",P,"ProvidedContexts"],[0,0,()=>te,0,1,()=>ne,64,0,0,0,0,()=>re]],_=[3,M,"AssumeRoleResponse",0,[S,E,N,P],[[()=>K,0],()=>U,1,0]],L=[3,M,"AssumeRoleWithWebIdentityRequest",0,[I,A,"WebIdentityToken","ProviderId",T,v,w],[0,0,[()=>j,0],0,()=>te,0,1]],z=[3,M,"AssumeRoleWithWebIdentityResponse",0,[S,"SubjectFromWebIdentityToken",E,N,"Provider","Audience",P],[[()=>K,0],0,()=>U,1,0,0,0]],K=[3,M,S,0,["AccessKeyId","SecretAccessKey","SessionToken","Expiration"],[0,[()=>F,0],0,4]],W=[-3,M,"ExpiredTokenException",{[k]:D,[O]:400,[C]:["ExpiredTokenException",400]},[$],[0]];u.O.for(M).registerError(W,p);var B=[-3,M,"IDPCommunicationErrorException",{[k]:D,[O]:400,[C]:["IDPCommunicationError",400]},[$],[0]];u.O.for(M).registerError(B,b);var q=[-3,M,"IDPRejectedClaimException",{[k]:D,[O]:403,[C]:["IDPRejectedClaim",403]},[$],[0]];u.O.for(M).registerError(q,y);var G=[-3,M,"InvalidIdentityTokenException",{[k]:D,[O]:400,[C]:["InvalidIdentityToken",400]},[$],[0]];u.O.for(M).registerError(G,x);var Z=[-3,M,"MalformedPolicyDocumentException",{[k]:D,[O]:400,[C]:["MalformedPolicyDocument",400]},[$],[0]];u.O.for(M).registerError(Z,g);var Y=[-3,M,"PackedPolicyTooLargeException",{[k]:D,[O]:400,[C]:["PackedPolicyTooLarge",400]},[$],[0]];u.O.for(M).registerError(Y,f);var H=[3,M,"PolicyDescriptorType",0,["arn"],[0]],Q=[3,M,"ProvidedContext",0,["ProviderArn","ContextAssertion"],[0,0]],X=[-3,M,"RegionDisabledException",{[k]:D,[O]:403,[C]:["RegionDisabledException",403]},[$],[0]];u.O.for(M).registerError(X,m);var J=[3,M,"Tag",0,["Key","Value"],[0,0]],ee=[-3,R,"STSServiceException",0,[],[]];u.O.for(R).registerError(ee,h);var te=[1,M,"policyDescriptorListType",0,()=>H],re=[1,M,"ProvidedContextsListType",0,()=>Q],ne=[1,M,"tagListType",0,()=>J],se=[9,M,"AssumeRole",0,()=>V,()=>_],ie=[9,M,"AssumeRoleWithWebIdentity",0,()=>L,()=>z];class oe extends(l.u.classBuilder().ep(c).m(function(e,t,r,n){return[(0,a.r)(r,e.getEndpointParameterInstructions())]}).s("AWSSecurityTokenServiceV20110615","AssumeRole",{}).n("STSClient","AssumeRoleCommand").sc(se).build()){}class ae extends(l.u.classBuilder().ep(c).m(function(e,t,r,n){return[(0,a.r)(r,e.getEndpointParameterInstructions())]}).s("AWSSecurityTokenServiceV20110615","AssumeRoleWithWebIdentity",{}).n("STSClient","AssumeRoleWithWebIdentityCommand").sc(ie).build()){}const le=e=>{if("string"==typeof e?.Arn){const t=e.Arn.split(":");if(t.length>4&&""!==t[4])return t[4]}},ce=async(e,t,r,n={})=>{const a="function"==typeof e?await e():e,l="function"==typeof t?await t():t,c=await function(e={}){return(0,i.Z)({...s.GG,default:async()=>(o||console.warn("@aws-sdk - WARN - default STS region of us-east-1 used. See @aws-sdk/credential-providers README and set a region explicitly."),"us-east-1")},{...s.zH,...e})}(n)();return r?.debug?.("@aws-sdk/client-sts::resolveRegion","accepting first of:",`${a} (credential provider clientConfig)`,`${l} (contextual client)`,`${c} (STS default: AWS_REGION, profile region, or us-east-1)`),a??l??c},ue=e=>"h2"===e?.metadata?.handlerProtocol;var de=r(42355),he=r(79749),pe=r(59537),ge=r(58093),fe=r(90933),me=r(93786),ye=r(85766),xe=r(99522),be=r(62306),Ee=r(83046),Se=r(7317),we=r(55845),ve=r(31965),Te=r(43162),Ne=r(88414),Ie=r(30379),Ae=r(11904),Pe=r(98367);const Ce=async(e,t,r)=>({operation:(0,Ae.u)(t).operation,region:await(0,Pe.t)(e.region)()||(()=>{throw new Error("expected `region` to be configured for `aws.auth#sigv4`")})()}),De=e=>{const t=[];return"AssumeRoleWithWebIdentity"===e.operation?t.push({schemeId:"smithy.api#noAuth"}):t.push(function(e){return{schemeId:"aws.auth#sigv4",signingProperties:{name:"sts",region:e.region},propertiesExtractor:(e,t)=>({signingProperties:{config:e,context:t}})}}(e)),t};var ke=r(74033),Oe=r(55343),$e=r(91677),Re=r(83749),Me=r(82112),Fe=r(56564),je=r(92052),Ue=r(77702),Ve=r(27590),_e=r(52989),Le=r(7940),ze=r(66391),Ke=r(55425),We=r(6141),Be=r(4866),qe=r(77337),Ge=r(79931),Ze=r(96440),Ye=r(51011);const He={preserveOrder:!1,attributeNamePrefix:"@_",attributesGroupName:!1,textNodeName:"#text",ignoreAttributes:!0,removeNSPrefix:!1,allowBooleanAttributes:!1,parseTagValue:!0,parseAttributeValue:!1,trimValues:!0,cdataPropName:!1,numberParseOptions:{hex:!0,leadingZeros:!0,eNotation:!0},tagValueProcessor:function(e,t){return t},attributeValueProcessor:function(e,t){return t},stopNodes:[],alwaysCreateTextNode:!1,isArray:()=>!1,commentPropName:!1,unpairedTags:[],processEntities:!0,htmlEntities:!1,ignoreDeclaration:!1,ignorePiTags:!1,transformTagName:!1,transformAttributeName:!1,updateTag:function(e,t,r){return e},captureMetaData:!1},Qe=":A-Za-z_\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD",Xe=new RegExp("^["+Qe+"]["+Qe+"\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$");function Je(e,t){const r=[];let n=t.exec(e);for(;n;){const s=[];s.startIndex=t.lastIndex-n[0].length;const i=n.length;for(let e=0;e<i;e++)s.push(n[e]);r.push(s),n=t.exec(e)}return r}const et=function(e){return!(null==Xe.exec(e))};let tt;tt="function"!=typeof Symbol?"@@xmlMetadata":Symbol("XML Node Metadata");class rt{constructor(e){this.tagname=e,this.child=[],this[":@"]={}}add(e,t){"__proto__"===e&&(e="#__proto__"),this.child.push({[e]:t})}addChild(e,t){"__proto__"===e.tagname&&(e.tagname="#__proto__"),e[":@"]&&Object.keys(e[":@"]).length>0?this.child.push({[e.tagname]:e.child,":@":e[":@"]}):this.child.push({[e.tagname]:e.child}),void 0!==t&&(this.child[this.child.length-1][tt]={startIndex:t})}static getMetaDataSymbol(){return tt}}function nt(e,t){const r={};if("O"!==e[t+3]||"C"!==e[t+4]||"T"!==e[t+5]||"Y"!==e[t+6]||"P"!==e[t+7]||"E"!==e[t+8])throw new Error("Invalid Tag instead of DOCTYPE");{t+=9;let n=1,s=!1,i=!1,o="";for(;t<e.length;t++)if("<"!==e[t]||i)if(">"===e[t]){if(i?"-"===e[t-1]&&"-"===e[t-2]&&(i=!1,n--):n--,0===n)break}else"["===e[t]?s=!0:o+=e[t];else{if(s&&ct(e,"!ENTITY",t)){let n,s;t+=7,[n,s,t]=it(e,t+1),-1===s.indexOf("&")&&(r[n]={regx:RegExp(`&${n};`,"g"),val:s})}else if(s&&ct(e,"!ELEMENT",t)){t+=8;const{index:r}=lt(e,t+1);t=r}else if(s&&ct(e,"!ATTLIST",t))t+=8;else if(s&&ct(e,"!NOTATION",t)){t+=9;const{index:r}=ot(e,t+1);t=r}else{if(!ct(e,"!--",t))throw new Error("Invalid DOCTYPE");i=!0}n++,o=""}if(0!==n)throw new Error("Unclosed DOCTYPE")}return{entities:r,i:t}}const st=(e,t)=>{for(;t<e.length&&/\s/.test(e[t]);)t++;return t};function it(e,t){t=st(e,t);let r="";for(;t<e.length&&!/\s/.test(e[t])&&'"'!==e[t]&&"'"!==e[t];)r+=e[t],t++;if(ut(r),t=st(e,t),"SYSTEM"===e.substring(t,t+6).toUpperCase())throw new Error("External entities are not supported");if("%"===e[t])throw new Error("Parameter entities are not supported");let n="";return[t,n]=at(e,t,"entity"),[r,n,--t]}function ot(e,t){t=st(e,t);let r="";for(;t<e.length&&!/\s/.test(e[t]);)r+=e[t],t++;ut(r),t=st(e,t);const n=e.substring(t,t+6).toUpperCase();if("SYSTEM"!==n&&"PUBLIC"!==n)throw new Error(`Expected SYSTEM or PUBLIC, found "${n}"`);t+=n.length,t=st(e,t);let s=null,i=null;if("PUBLIC"===n)[t,s]=at(e,t,"publicIdentifier"),'"'!==e[t=st(e,t)]&&"'"!==e[t]||([t,i]=at(e,t,"systemIdentifier"));else if("SYSTEM"===n&&([t,i]=at(e,t,"systemIdentifier"),!i))throw new Error("Missing mandatory system identifier for SYSTEM notation");return{notationName:r,publicIdentifier:s,systemIdentifier:i,index:--t}}function at(e,t,r){let n="";const s=e[t];if('"'!==s&&"'"!==s)throw new Error(`Expected quoted string, found "${s}"`);for(t++;t<e.length&&e[t]!==s;)n+=e[t],t++;if(e[t]!==s)throw new Error(`Unterminated ${r} value`);return[++t,n]}function lt(e,t){t=st(e,t);let r="";for(;t<e.length&&!/\s/.test(e[t]);)r+=e[t],t++;if(!ut(r))throw new Error(`Invalid element name: "${r}"`);let n="";if("E"===e[t=st(e,t)]&&ct(e,"MPTY",t))t+=4;else if("A"===e[t]&&ct(e,"NY",t))t+=2;else{if("("!==e[t])throw new Error(`Invalid Element Expression, found "${e[t]}"`);for(t++;t<e.length&&")"!==e[t];)n+=e[t],t++;if(")"!==e[t])throw new Error("Unterminated content model")}return{elementName:r,contentModel:n.trim(),index:t}}function ct(e,t,r){for(let n=0;n<t.length;n++)if(t[n]!==e[r+n+1])return!1;return!0}function ut(e){if(et(e))return e;throw new Error(`Invalid entity name ${e}`)}const dt=/^[-+]?0x[a-fA-F0-9]+$/,ht=/^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/,pt={hex:!0,leadingZeros:!0,decimalPoint:".",eNotation:!0};const gt=/^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/;class ft{constructor(e){var t;this.options=e,this.currentNode=null,this.tagsNodeStack=[],this.docTypeEntities={},this.lastEntities={apos:{regex:/&(apos|#39|#x27);/g,val:"'"},gt:{regex:/&(gt|#62|#x3E);/g,val:">"},lt:{regex:/&(lt|#60|#x3C);/g,val:"<"},quot:{regex:/&(quot|#34|#x22);/g,val:'"'}},this.ampEntity={regex:/&(amp|#38|#x26);/g,val:"&"},this.htmlEntities={space:{regex:/&(nbsp|#160);/g,val:" "},cent:{regex:/&(cent|#162);/g,val:"¢"},pound:{regex:/&(pound|#163);/g,val:"£"},yen:{regex:/&(yen|#165);/g,val:"¥"},euro:{regex:/&(euro|#8364);/g,val:"€"},copyright:{regex:/&(copy|#169);/g,val:"©"},reg:{regex:/&(reg|#174);/g,val:"®"},inr:{regex:/&(inr|#8377);/g,val:"₹"},num_dec:{regex:/&#([0-9]{1,7});/g,val:(e,t)=>String.fromCodePoint(Number.parseInt(t,10))},num_hex:{regex:/&#x([0-9a-fA-F]{1,6});/g,val:(e,t)=>String.fromCodePoint(Number.parseInt(t,16))}},this.addExternalEntities=mt,this.parseXml=St,this.parseTextData=yt,this.resolveNameSpace=xt,this.buildAttributesMap=Et,this.isItStopNode=Nt,this.replaceEntitiesValue=vt,this.readStopNodeData=Pt,this.saveTextToParentTag=Tt,this.addChild=wt,this.ignoreAttributesFn="function"==typeof(t=this.options.ignoreAttributes)?t:Array.isArray(t)?e=>{for(const r of t){if("string"==typeof r&&e===r)return!0;if(r instanceof RegExp&&r.test(e))return!0}}:()=>!1}}function mt(e){const t=Object.keys(e);for(let r=0;r<t.length;r++){const n=t[r];this.lastEntities[n]={regex:new RegExp("&"+n+";","g"),val:e[n]}}}function yt(e,t,r,n,s,i,o){if(void 0!==e&&(this.options.trimValues&&!n&&(e=e.trim()),e.length>0)){o||(e=this.replaceEntitiesValue(e));const n=this.options.tagValueProcessor(t,e,r,s,i);return null==n?e:typeof n!=typeof e||n!==e?n:this.options.trimValues||e.trim()===e?Ct(e,this.options.parseTagValue,this.options.numberParseOptions):e}}function xt(e){if(this.options.removeNSPrefix){const t=e.split(":"),r="/"===e.charAt(0)?"/":"";if("xmlns"===t[0])return"";2===t.length&&(e=r+t[1])}return e}const bt=new RegExp("([^\\s=]+)\\s*(=\\s*(['\"])([\\s\\S]*?)\\3)?","gm");function Et(e,t,r){if(!0!==this.options.ignoreAttributes&&"string"==typeof e){const r=Je(e,bt),n=r.length,s={};for(let e=0;e<n;e++){const n=this.resolveNameSpace(r[e][1]);if(this.ignoreAttributesFn(n,t))continue;let i=r[e][4],o=this.options.attributeNamePrefix+n;if(n.length)if(this.options.transformAttributeName&&(o=this.options.transformAttributeName(o)),"__proto__"===o&&(o="#__proto__"),void 0!==i){this.options.trimValues&&(i=i.trim()),i=this.replaceEntitiesValue(i);const e=this.options.attributeValueProcessor(n,i,t);s[o]=null==e?i:typeof e!=typeof i||e!==i?e:Ct(i,this.options.parseAttributeValue,this.options.numberParseOptions)}else this.options.allowBooleanAttributes&&(s[o]=!0)}if(!Object.keys(s).length)return;if(this.options.attributesGroupName){const e={};return e[this.options.attributesGroupName]=s,e}return s}}const St=function(e){e=e.replace(/\r\n?/g,"\n");const t=new rt("!xml");let r=t,n="",s="";for(let i=0;i<e.length;i++)if("<"===e[i])if("/"===e[i+1]){const t=It(e,">",i,"Closing Tag is not closed.");let o=e.substring(i+2,t).trim();if(this.options.removeNSPrefix){const e=o.indexOf(":");-1!==e&&(o=o.substr(e+1))}this.options.transformTagName&&(o=this.options.transformTagName(o)),r&&(n=this.saveTextToParentTag(n,r,s));const a=s.substring(s.lastIndexOf(".")+1);if(o&&-1!==this.options.unpairedTags.indexOf(o))throw new Error(`Unpaired tag can not be used as closing tag: </${o}>`);let l=0;a&&-1!==this.options.unpairedTags.indexOf(a)?(l=s.lastIndexOf(".",s.lastIndexOf(".")-1),this.tagsNodeStack.pop()):l=s.lastIndexOf("."),s=s.substring(0,l),r=this.tagsNodeStack.pop(),n="",i=t}else if("?"===e[i+1]){let t=At(e,i,!1,"?>");if(!t)throw new Error("Pi Tag is not closed.");if(n=this.saveTextToParentTag(n,r,s),this.options.ignoreDeclaration&&"?xml"===t.tagName||this.options.ignorePiTags);else{const e=new rt(t.tagName);e.add(this.options.textNodeName,""),t.tagName!==t.tagExp&&t.attrExpPresent&&(e[":@"]=this.buildAttributesMap(t.tagExp,s,t.tagName)),this.addChild(r,e,s,i)}i=t.closeIndex+1}else if("!--"===e.substr(i+1,3)){const t=It(e,"--\x3e",i+4,"Comment is not closed.");if(this.options.commentPropName){const o=e.substring(i+4,t-2);n=this.saveTextToParentTag(n,r,s),r.add(this.options.commentPropName,[{[this.options.textNodeName]:o}])}i=t}else if("!D"===e.substr(i+1,2)){const t=nt(e,i);this.docTypeEntities=t.entities,i=t.i}else if("!["===e.substr(i+1,2)){const t=It(e,"]]>",i,"CDATA is not closed.")-2,o=e.substring(i+9,t);n=this.saveTextToParentTag(n,r,s);let a=this.parseTextData(o,r.tagname,s,!0,!1,!0,!0);null==a&&(a=""),this.options.cdataPropName?r.add(this.options.cdataPropName,[{[this.options.textNodeName]:o}]):r.add(this.options.textNodeName,a),i=t+2}else{let o=At(e,i,this.options.removeNSPrefix),a=o.tagName;const l=o.rawTagName;let c=o.tagExp,u=o.attrExpPresent,d=o.closeIndex;this.options.transformTagName&&(a=this.options.transformTagName(a)),r&&n&&"!xml"!==r.tagname&&(n=this.saveTextToParentTag(n,r,s,!1));const h=r;h&&-1!==this.options.unpairedTags.indexOf(h.tagname)&&(r=this.tagsNodeStack.pop(),s=s.substring(0,s.lastIndexOf("."))),a!==t.tagname&&(s+=s?"."+a:a);const p=i;if(this.isItStopNode(this.options.stopNodes,s,a)){let t="";if(c.length>0&&c.lastIndexOf("/")===c.length-1)"/"===a[a.length-1]?(a=a.substr(0,a.length-1),s=s.substr(0,s.length-1),c=a):c=c.substr(0,c.length-1),i=o.closeIndex;else if(-1!==this.options.unpairedTags.indexOf(a))i=o.closeIndex;else{const r=this.readStopNodeData(e,l,d+1);if(!r)throw new Error(`Unexpected end of ${l}`);i=r.i,t=r.tagContent}const n=new rt(a);a!==c&&u&&(n[":@"]=this.buildAttributesMap(c,s,a)),t&&(t=this.parseTextData(t,a,s,!0,u,!0,!0)),s=s.substr(0,s.lastIndexOf(".")),n.add(this.options.textNodeName,t),this.addChild(r,n,s,p)}else{if(c.length>0&&c.lastIndexOf("/")===c.length-1){"/"===a[a.length-1]?(a=a.substr(0,a.length-1),s=s.substr(0,s.length-1),c=a):c=c.substr(0,c.length-1),this.options.transformTagName&&(a=this.options.transformTagName(a));const e=new rt(a);a!==c&&u&&(e[":@"]=this.buildAttributesMap(c,s,a)),this.addChild(r,e,s,p),s=s.substr(0,s.lastIndexOf("."))}else{const e=new rt(a);this.tagsNodeStack.push(r),a!==c&&u&&(e[":@"]=this.buildAttributesMap(c,s,a)),this.addChild(r,e,s,p),r=e}n="",i=d}}else n+=e[i];return t.child};function wt(e,t,r,n){this.options.captureMetaData||(n=void 0);const s=this.options.updateTag(t.tagname,r,t[":@"]);!1===s||("string"==typeof s?(t.tagname=s,e.addChild(t,n)):e.addChild(t,n))}const vt=function(e){if(this.options.processEntities){for(let t in this.docTypeEntities){const r=this.docTypeEntities[t];e=e.replace(r.regx,r.val)}for(let t in this.lastEntities){const r=this.lastEntities[t];e=e.replace(r.regex,r.val)}if(this.options.htmlEntities)for(let t in this.htmlEntities){const r=this.htmlEntities[t];e=e.replace(r.regex,r.val)}e=e.replace(this.ampEntity.regex,this.ampEntity.val)}return e};function Tt(e,t,r,n){return e&&(void 0===n&&(n=0===t.child.length),void 0!==(e=this.parseTextData(e,t.tagname,r,!1,!!t[":@"]&&0!==Object.keys(t[":@"]).length,n))&&""!==e&&t.add(this.options.textNodeName,e),e=""),e}function Nt(e,t,r){const n="*."+r;for(const r in e){const s=e[r];if(n===s||t===s)return!0}return!1}function It(e,t,r,n){const s=e.indexOf(t,r);if(-1===s)throw new Error(n);return s+t.length-1}function At(e,t,r,n=">"){const s=function(e,t,r=">"){let n,s="";for(let i=t;i<e.length;i++){let t=e[i];if(n)t===n&&(n="");else if('"'===t||"'"===t)n=t;else if(t===r[0]){if(!r[1])return{data:s,index:i};if(e[i+1]===r[1])return{data:s,index:i}}else"\t"===t&&(t=" ");s+=t}}(e,t+1,n);if(!s)return;let i=s.data;const o=s.index,a=i.search(/\s/);let l=i,c=!0;-1!==a&&(l=i.substring(0,a),i=i.substring(a+1).trimStart());const u=l;if(r){const e=l.indexOf(":");-1!==e&&(l=l.substr(e+1),c=l!==s.data.substr(e+1))}return{tagName:l,tagExp:i,closeIndex:o,attrExpPresent:c,rawTagName:u}}function Pt(e,t,r){const n=r;let s=1;for(;r<e.length;r++)if("<"===e[r])if("/"===e[r+1]){const i=It(e,">",r,`${t} is not closed`);if(e.substring(r+2,i).trim()===t&&(s--,0===s))return{tagContent:e.substring(n,r),i};r=i}else if("?"===e[r+1])r=It(e,"?>",r+1,"StopNode is not closed.");else if("!--"===e.substr(r+1,3))r=It(e,"--\x3e",r+3,"StopNode is not closed.");else if("!["===e.substr(r+1,2))r=It(e,"]]>",r,"StopNode is not closed.")-2;else{const n=At(e,r,">");n&&((n&&n.tagName)===t&&"/"!==n.tagExp[n.tagExp.length-1]&&s++,r=n.closeIndex)}}function Ct(e,t,r){if(t&&"string"==typeof e){const t=e.trim();return"true"===t||"false"!==t&&function(e,t={}){if(t=Object.assign({},pt,t),!e||"string"!=typeof e)return e;let r=e.trim();if(void 0!==t.skipLike&&t.skipLike.test(r))return e;if("0"===e)return 0;if(t.hex&&dt.test(r))return function(e){if(parseInt)return parseInt(e,16);if(Number.parseInt)return Number.parseInt(e,16);if(window&&window.parseInt)return window.parseInt(e,16);throw new Error("parseInt, Number.parseInt, window.parseInt are not supported")}(r);if(-1!==r.search(/.+[eE].+/))return function(e,t,r){if(!r.eNotation)return e;const n=t.match(gt);if(n){let s=n[1]||"";const i=-1===n[3].indexOf("e")?"E":"e",o=n[2],a=s?e[o.length+1]===i:e[o.length]===i;return o.length>1&&a?e:1!==o.length||!n[3].startsWith(`.${i}`)&&n[3][0]!==i?r.leadingZeros&&!a?(t=(n[1]||"")+n[3],Number(t)):e:Number(t)}return e}(e,r,t);{const s=ht.exec(r);if(s){const i=s[1]||"",o=s[2];let a=(n=s[3])&&-1!==n.indexOf(".")?("."===(n=n.replace(/0+$/,""))?n="0":"."===n[0]?n="0"+n:"."===n[n.length-1]&&(n=n.substring(0,n.length-1)),n):n;const l=i?"."===e[o.length+1]:"."===e[o.length];if(!t.leadingZeros&&(o.length>1||1===o.length&&!l))return e;{const n=Number(r),s=String(n);if(0===n)return n;if(-1!==s.search(/[eE]/))return t.eNotation?n:e;if(-1!==r.indexOf("."))return"0"===s||s===a||s===`${i}${a}`?n:e;let l=o?a:r;return o?l===s||i+l===s?n:e:l===s||l===i+s?n:e}}return e}var n}(e,r)}return function(e){return void 0!==e}(e)?e:""}const Dt=rt.getMetaDataSymbol();function kt(e,t){return Ot(e,t)}function Ot(e,t,r){let n;const s={};for(let i=0;i<e.length;i++){const o=e[i],a=$t(o);let l="";if(l=void 0===r?a:r+"."+a,a===t.textNodeName)void 0===n?n=o[a]:n+=""+o[a];else{if(void 0===a)continue;if(o[a]){let e=Ot(o[a],t,l);const r=Mt(e,t);void 0!==o[Dt]&&(e[Dt]=o[Dt]),o[":@"]?Rt(e,o[":@"],l,t):1!==Object.keys(e).length||void 0===e[t.textNodeName]||t.alwaysCreateTextNode?0===Object.keys(e).length&&(t.alwaysCreateTextNode?e[t.textNodeName]="":e=""):e=e[t.textNodeName],void 0!==s[a]&&s.hasOwnProperty(a)?(Array.isArray(s[a])||(s[a]=[s[a]]),s[a].push(e)):t.isArray(a,l,r)?s[a]=[e]:s[a]=e}}}return"string"==typeof n?n.length>0&&(s[t.textNodeName]=n):void 0!==n&&(s[t.textNodeName]=n),s}function $t(e){const t=Object.keys(e);for(let e=0;e<t.length;e++){const r=t[e];if(":@"!==r)return r}}function Rt(e,t,r,n){if(t){const s=Object.keys(t),i=s.length;for(let o=0;o<i;o++){const i=s[o];n.isArray(i,r+"."+i,!0,!0)?e[i]=[t[i]]:e[i]=t[i]}}}function Mt(e,t){const{textNodeName:r}=t,n=Object.keys(e).length;return 0===n||!(1!==n||!e[r]&&"boolean"!=typeof e[r]&&0!==e[r])}const Ft={allowBooleanAttributes:!1,unpairedTags:[]};function jt(e){return" "===e||"\t"===e||"\n"===e||"\r"===e}function Ut(e,t){const r=t;for(;t<e.length;t++)if("?"==e[t]||" "==e[t]){const n=e.substr(r,t-r);if(t>5&&"xml"===n)return Wt("InvalidXml","XML declaration allowed only at the start of the document.",Gt(e,t));if("?"==e[t]&&">"==e[t+1]){t++;break}continue}return t}function Vt(e,t){if(e.length>t+5&&"-"===e[t+1]&&"-"===e[t+2]){for(t+=3;t<e.length;t++)if("-"===e[t]&&"-"===e[t+1]&&">"===e[t+2]){t+=2;break}}else if(e.length>t+8&&"D"===e[t+1]&&"O"===e[t+2]&&"C"===e[t+3]&&"T"===e[t+4]&&"Y"===e[t+5]&&"P"===e[t+6]&&"E"===e[t+7]){let r=1;for(t+=8;t<e.length;t++)if("<"===e[t])r++;else if(">"===e[t]&&(r--,0===r))break}else if(e.length>t+9&&"["===e[t+1]&&"C"===e[t+2]&&"D"===e[t+3]&&"A"===e[t+4]&&"T"===e[t+5]&&"A"===e[t+6]&&"["===e[t+7])for(t+=8;t<e.length;t++)if("]"===e[t]&&"]"===e[t+1]&&">"===e[t+2]){t+=2;break}return t}function _t(e,t){let r="",n="",s=!1;for(;t<e.length;t++){if('"'===e[t]||"'"===e[t])""===n?n=e[t]:n!==e[t]||(n="");else if(">"===e[t]&&""===n){s=!0;break}r+=e[t]}return""===n&&{value:r,index:t,tagClosed:s}}const Lt=new RegExp("(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['\"])(([\\s\\S])*?)\\5)?","g");function zt(e,t){const r=Je(e,Lt),n={};for(let e=0;e<r.length;e++){if(0===r[e][1].length)return Wt("InvalidAttr","Attribute '"+r[e][2]+"' has no space in starting.",Zt(r[e]));if(void 0!==r[e][3]&&void 0===r[e][4])return Wt("InvalidAttr","Attribute '"+r[e][2]+"' is without value.",Zt(r[e]));if(void 0===r[e][3]&&!t.allowBooleanAttributes)return Wt("InvalidAttr","boolean attribute '"+r[e][2]+"' is not allowed.",Zt(r[e]));const s=r[e][2];if(!Bt(s))return Wt("InvalidAttr","Attribute '"+s+"' is an invalid name.",Zt(r[e]));if(n.hasOwnProperty(s))return Wt("InvalidAttr","Attribute '"+s+"' is repeated.",Zt(r[e]));n[s]=1}return!0}function Kt(e,t){if(";"===e[++t])return-1;if("#"===e[t])return function(e,t){let r=/\d/;for("x"===e[t]&&(t++,r=/[\da-fA-F]/);t<e.length;t++){if(";"===e[t])return t;if(!e[t].match(r))break}return-1}(e,++t);let r=0;for(;t<e.length;t++,r++)if(!(e[t].match(/\w/)&&r<20)){if(";"===e[t])break;return-1}return t}function Wt(e,t,r){return{err:{code:e,msg:t,line:r.line||r,col:r.col}}}function Bt(e){return et(e)}function qt(e){return et(e)}function Gt(e,t){const r=e.substring(0,t).split(/\r?\n/);return{line:r.length,col:r[r.length-1].length+1}}function Zt(e){return e.startIndex+e[1].length}const Yt=new class{constructor(e){this.externalEntities={},this.options=function(e){return Object.assign({},He,e)}(e)}parse(e,t){if("string"==typeof e);else{if(!e.toString)throw new Error("XML data is accepted in String or Bytes[] form.");e=e.toString()}if(t){!0===t&&(t={});const r=function(e,t){t=Object.assign({},Ft,t);const r=[];let n=!1,s=!1;"\ufeff"===e[0]&&(e=e.substr(1));for(let i=0;i<e.length;i++)if("<"===e[i]&&"?"===e[i+1]){if(i+=2,i=Ut(e,i),i.err)return i}else{if("<"!==e[i]){if(jt(e[i]))continue;return Wt("InvalidChar","char '"+e[i]+"' is not expected.",Gt(e,i))}{let o=i;if(i++,"!"===e[i]){i=Vt(e,i);continue}{let a=!1;"/"===e[i]&&(a=!0,i++);let l="";for(;i<e.length&&">"!==e[i]&&" "!==e[i]&&"\t"!==e[i]&&"\n"!==e[i]&&"\r"!==e[i];i++)l+=e[i];if(l=l.trim(),"/"===l[l.length-1]&&(l=l.substring(0,l.length-1),i--),!qt(l)){let t;return t=0===l.trim().length?"Invalid space after '<'.":"Tag '"+l+"' is an invalid name.",Wt("InvalidTag",t,Gt(e,i))}const c=_t(e,i);if(!1===c)return Wt("InvalidAttr","Attributes for '"+l+"' have open quote.",Gt(e,i));let u=c.value;if(i=c.index,"/"===u[u.length-1]){const r=i-u.length;u=u.substring(0,u.length-1);const s=zt(u,t);if(!0!==s)return Wt(s.err.code,s.err.msg,Gt(e,r+s.err.line));n=!0}else if(a){if(!c.tagClosed)return Wt("InvalidTag","Closing tag '"+l+"' doesn't have proper closing.",Gt(e,i));if(u.trim().length>0)return Wt("InvalidTag","Closing tag '"+l+"' can't have attributes or invalid starting.",Gt(e,o));if(0===r.length)return Wt("InvalidTag","Closing tag '"+l+"' has not been opened.",Gt(e,o));{const t=r.pop();if(l!==t.tagName){let r=Gt(e,t.tagStartPos);return Wt("InvalidTag","Expected closing tag '"+t.tagName+"' (opened in line "+r.line+", col "+r.col+") instead of closing tag '"+l+"'.",Gt(e,o))}0==r.length&&(s=!0)}}else{const a=zt(u,t);if(!0!==a)return Wt(a.err.code,a.err.msg,Gt(e,i-u.length+a.err.line));if(!0===s)return Wt("InvalidXml","Multiple possible root nodes found.",Gt(e,i));-1!==t.unpairedTags.indexOf(l)||r.push({tagName:l,tagStartPos:o}),n=!0}for(i++;i<e.length;i++)if("<"===e[i]){if("!"===e[i+1]){i++,i=Vt(e,i);continue}if("?"!==e[i+1])break;if(i=Ut(e,++i),i.err)return i}else if("&"===e[i]){const t=Kt(e,i);if(-1==t)return Wt("InvalidChar","char '&' is not expected.",Gt(e,i));i=t}else if(!0===s&&!jt(e[i]))return Wt("InvalidXml","Extra text at the end",Gt(e,i));"<"===e[i]&&i--}}}return n?1==r.length?Wt("InvalidTag","Unclosed tag '"+r[0].tagName+"'.",Gt(e,r[0].tagStartPos)):!(r.length>0)||Wt("InvalidXml","Invalid '"+JSON.stringify(r.map(e=>e.tagName),null,4).replace(/\r?\n/g,"")+"' found.",{line:1,col:1}):Wt("InvalidXml","Start tag expected.",1)}(e,t);if(!0!==r)throw Error(`${r.err.msg}:${r.err.line}:${r.err.col}`)}const r=new ft(this.options);r.addExternalEntities(this.externalEntities);const n=r.parseXml(e);return this.options.preserveOrder||void 0===n?n:kt(n,this.options)}addEntity(e,t){if(-1!==t.indexOf("&"))throw new Error("Entity value can't have '&'");if(-1!==e.indexOf("&")||-1!==e.indexOf(";"))throw new Error("An entity must be set without '&' and ';'. Eg. use '#xD' for '&#xD;'");if("&"===t)throw new Error("An entity with value '&' is not permitted");this.externalEntities[e]=t}static getMetaDataSymbol(){return rt.getMetaDataSymbol()}}({attributeNamePrefix:"",htmlEntities:!0,ignoreAttributes:!1,ignoreDeclaration:!0,parseTagValue:!1,trimValues:!1,tagValueProcessor:(e,t)=>""===t.trim()&&t.includes("\n")?"":void 0});Yt.addEntity("#xD","\r"),Yt.addEntity("#10","\n");var Ht=r(22371);const Qt=e=>{const t="#text";for(const r in e)e.hasOwnProperty(r)&&void 0!==e[r][t]?e[r]=e[r][t]:"object"==typeof e[r]&&null!==e[r]&&(e[r]=Qt(e[r]));return e};var Xt=r(2914),Jt=r(57007);class er extends Jt.B{settings;stringDeserializer;constructor(e){super(),this.settings=e,this.stringDeserializer=new Ht.k(e)}setSerdeContext(e){this.serdeContext=e,this.stringDeserializer.setSerdeContext(e)}read(e,t,r){const n=Ze.l.of(e),s=n.getMemberSchemas();if(n.isStructSchema()&&n.isMemberSchema()&&Object.values(s).find(e=>!!e.getMemberTraits().eventPayload)){const e={},r=Object.keys(s)[0];return s[r].isBlobSchema()?e[r]=t:e[r]=this.read(s[r],t),e}const i=(this.serdeContext?.utf8Encoder??Xt.P)(t),o=this.parseXml(i);return this.readSchema(e,r?o[r]:o)}readSchema(e,t){const r=Ze.l.of(e);if(r.isUnitSchema())return;const n=r.getMergedTraits();if(r.isListSchema()&&!Array.isArray(t))return this.readSchema(r,[t]);if(null==t)return t;if("object"==typeof t){const e=!!n.sparse,s=!!n.xmlFlattened;if(r.isListSchema()){const n=r.getValueSchema(),i=[],o=n.getMergedTraits().xmlName??"member",a=s?t:(t[0]??t)[o],l=Array.isArray(a)?a:[a];for(const t of l)(null!=t||e)&&i.push(this.readSchema(n,t));return i}const i={};if(r.isMapSchema()){const n=r.getKeySchema(),o=r.getValueSchema();let a;a=s?Array.isArray(t)?t:[t]:Array.isArray(t.entry)?t.entry:[t.entry];const l=n.getMergedTraits().xmlName??"key",c=o.getMergedTraits().xmlName??"value";for(const t of a){const r=t[l],n=t[c];(null!=n||e)&&(i[r]=this.readSchema(o,n))}return i}if(r.isStructSchema()){for(const[e,n]of r.structIterator()){const r=n.getMergedTraits(),s=r.httpPayload?r.xmlName??n.getName():n.getMemberTraits().xmlName??e;null!=t[s]&&(i[e]=this.readSchema(n,t[s]))}return i}if(r.isDocumentSchema())return t;throw new Error(`@aws-sdk/core/protocols - xml deserializer unhandled schema type for ${r.getName(!0)}`)}return r.isListSchema()?[]:r.isMapSchema()||r.isStructSchema()?{}:this.stringDeserializer.read(r,t)}parseXml(e){if(e.length){let r;try{t=e,r=Yt.parse(t,!0)}catch(t){throw t&&"object"==typeof t&&Object.defineProperty(t,"$responseBodyText",{value:e}),t}const n="#text",s=Object.keys(r)[0],i=r[s];return i[n]&&(i[s]=i[n],delete i[n]),Qt(i)}var t;return{}}}var tr=r(17735),rr=r(61210),nr=r(34708),sr=r(52123),ir=r(37882),or=r(39181),ar=r(98893);class lr extends Jt.B{settings;buffer;constructor(e){super(),this.settings=e}write(e,t,r=""){void 0===this.buffer&&(this.buffer="");const n=Ze.l.of(e);if(r&&!r.endsWith(".")&&(r+="."),n.isBlobSchema())("string"==typeof t||t instanceof Uint8Array)&&(this.writeKey(r),this.writeValue((this.serdeContext?.base64Encoder??or.n)(t)));else if(n.isBooleanSchema()||n.isNumericSchema()||n.isStringSchema())null!=t?(this.writeKey(r),this.writeValue(String(t))):n.isIdempotencyToken()&&(this.writeKey(r),this.writeValue((0,nr.v4)()));else if(n.isBigIntegerSchema())null!=t&&(this.writeKey(r),this.writeValue(String(t)));else if(n.isBigDecimalSchema())null!=t&&(this.writeKey(r),this.writeValue(t instanceof sr.D?t.string:String(t)));else if(n.isTimestampSchema()){if(t instanceof Date)switch(this.writeKey(r),(0,tr.V)(n,this.settings)){case 5:this.writeValue(t.toISOString().replace(".000Z","Z"));break;case 6:this.writeValue((0,ir.JV)(t));break;case 7:this.writeValue(String(t.getTime()/1e3))}}else{if(n.isDocumentSchema())throw new Error(`@aws-sdk/core/protocols - QuerySerializer unsupported document type ${n.getName(!0)}`);if(n.isListSchema()){if(Array.isArray(t))if(0===t.length)this.settings.serializeEmptyLists&&(this.writeKey(r),this.writeValue(""));else{const e=n.getValueSchema(),s=this.settings.flattenLists||n.getMergedTraits().xmlFlattened;let i=1;for(const n of t){if(null==n)continue;const t=this.getKey("member",e.getMergedTraits().xmlName),o=s?`${r}${i}`:`${r}${t}.${i}`;this.write(e,n,o),++i}}}else if(n.isMapSchema()){if(t&&"object"==typeof t){const e=n.getKeySchema(),s=n.getValueSchema(),i=n.getMergedTraits().xmlFlattened;let o=1;for(const[n,a]of Object.entries(t)){if(null==a)continue;const t=this.getKey("key",e.getMergedTraits().xmlName),l=i?`${r}${o}.${t}`:`${r}entry.${o}.${t}`,c=this.getKey("value",s.getMergedTraits().xmlName),u=i?`${r}${o}.${c}`:`${r}entry.${o}.${c}`;this.write(e,n,l),this.write(s,a,u),++o}}}else if(n.isStructSchema()){if(t&&"object"==typeof t)for(const[e,s]of(0,ar.R)(n,t)){if(null==t[e]&&!s.isIdempotencyToken())continue;const n=`${r}${this.getKey(e,s.getMergedTraits().xmlName)}`;this.write(s,t[e],n)}}else if(!n.isUnitSchema())throw new Error(`@aws-sdk/core/protocols - QuerySerializer unrecognized schema type ${n.getName(!0)}`)}}flush(){if(void 0===this.buffer)throw new Error("@aws-sdk/core/protocols - QuerySerializer cannot flush with nothing written to buffer.");const e=this.buffer;return delete this.buffer,e}getKey(e,t){const r=t??e;return this.settings.capitalizeKeys?r[0].toUpperCase()+r.slice(1):r}writeKey(e){e.endsWith(".")&&(e=e.slice(0,e.length-1)),this.buffer+=`&${(0,rr.$)(e)}=`}writeValue(e){this.buffer+=(0,rr.$)(e)}}class cr extends Be.M{options;serializer;deserializer;mixin=new Ye.U;constructor(e){super({defaultNamespace:e.defaultNamespace}),this.options=e;const t={timestampFormat:{useTrait:!0,default:5},httpBindings:!1,xmlNamespace:e.xmlNamespace,serviceNamespace:e.defaultNamespace,serializeEmptyLists:!0};this.serializer=new lr(t),this.deserializer=new er(t)}getShapeId(){return"aws.protocols#awsQuery"}setSerdeContext(e){this.serializer.setSerdeContext(e),this.deserializer.setSerdeContext(e)}getPayloadCodec(){throw new Error("AWSQuery protocol has no payload codec.")}async serializeRequest(e,t,r){const n=await super.serializeRequest(e,t,r);n.path.endsWith("/")||(n.path+="/"),Object.assign(n.headers,{"content-type":"application/x-www-form-urlencoded"}),"unit"!==(0,Ge.L)(e.input)&&n.body||(n.body="");const s=e.name.split("#")[1]??e.name;return n.body=`Action=${s}&Version=${this.options.version}`+n.body,n.body.endsWith("&")&&(n.body=n.body.slice(-1)),n}async deserializeResponse(e,t,r){const n=this.deserializer,s=Ze.l.of(e.output),i={};if(r.statusCode>=300){const s=await(0,qe.P)(r.body,t);s.byteLength>0&&Object.assign(i,await n.read(15,s)),await this.handleError(e,t,r,i,this.deserializeMetadata(r))}for(const e in r.headers){const t=r.headers[e];delete r.headers[e],r.headers[e.toLowerCase()]=t}const o=e.name.split("#")[1]??e.name,a=s.isStructSchema()&&this.useNestedResult()?o+"Result":void 0,l=await(0,qe.P)(r.body,t);return l.byteLength>0&&Object.assign(i,await n.read(s,l,a)),{$metadata:this.deserializeMetadata(r),...i}}useNestedResult(){return!0}async handleError(e,t,r,n,s){const i=this.loadQueryErrorCode(r,n)??"Unknown",o=this.loadQueryError(n),a=this.loadQueryErrorMessage(n);o.message=a,o.Error={Type:o.Type,Code:o.Code,Message:a};const{errorSchema:l,errorMetadata:c}=await this.mixin.getErrorSchemaOrThrowBaseException(i,this.options.defaultNamespace,r,o,s,(e,t)=>{try{return e.getSchema(t)}catch(r){return e.find(e=>Ze.l.of(e).getMergedTraits().awsQueryError?.[0]===t)}}),d=Ze.l.of(l),h=new(u.O.for(l[1]).getErrorCtor(l)??Error)(a),p={Error:o.Error};for(const[e,t]of d.structIterator()){const r=t.getMergedTraits().xmlName??e,s=o[r]??n[r];p[e]=this.deserializer.readSchema(t,s)}throw this.mixin.decorateServiceException(Object.assign(h,c,{$fault:d.getMergedTraits().error,message:a},p),n)}loadQueryErrorCode(e,t){const r=(t.Errors?.[0]?.Error??t.Errors?.Error??t.Error)?.Code;return void 0!==r?r:404==e.statusCode?"NotFound":void 0}loadQueryError(e){return e.Errors?.[0]?.Error??e.Errors?.Error??e.Error}loadQueryErrorMessage(e){const t=this.loadQueryError(e);return t?.message??t?.Message??e.message??e.Message??"Unknown"}getDefaultContentType(){return"application/x-www-form-urlencoded"}}var ur=r(17209),dr=r(71918),hr=r(12544),pr=r(40935),gr=r(99609),fr=r(21954),mr=r(92385),yr=r(97979);const xr="required",br="type",Er="fn",Sr="argv",wr="ref",vr=!1,Tr=!0,Nr="booleanEquals",Ir="stringEquals",Ar="sigv4",Pr="us-east-1",Cr="endpoint",Dr="https://sts.{Region}.{PartitionResult#dnsSuffix}",kr="tree",Or="error",$r="getAttr",Rr={[xr]:!1,[br]:"string"},Mr={[xr]:!0,default:!1,[br]:"boolean"},Fr={[wr]:"Endpoint"},jr={[Er]:"isSet",[Sr]:[{[wr]:"Region"}]},Ur={[wr]:"Region"},Vr={[Er]:"aws.partition",[Sr]:[Ur],assign:"PartitionResult"},_r={[wr]:"UseFIPS"},Lr={[wr]:"UseDualStack"},zr={url:"https://sts.amazonaws.com",properties:{authSchemes:[{name:Ar,signingName:"sts",signingRegion:Pr}]},headers:{}},Kr={},Wr={conditions:[{[Er]:Ir,[Sr]:[Ur,"aws-global"]}],[Cr]:zr,[br]:Cr},Br={[Er]:Nr,[Sr]:[_r,!0]},qr={[Er]:Nr,[Sr]:[Lr,!0]},Gr={[Er]:$r,[Sr]:[{[wr]:"PartitionResult"},"supportsFIPS"]},Zr={[wr]:"PartitionResult"},Yr={[Er]:Nr,[Sr]:[!0,{[Er]:$r,[Sr]:[Zr,"supportsDualStack"]}]},Hr=[{[Er]:"isSet",[Sr]:[Fr]}],Qr=[Br],Xr=[qr],Jr={version:"1.0",parameters:{Region:Rr,UseDualStack:Mr,UseFIPS:Mr,Endpoint:Rr,UseGlobalEndpoint:Mr},rules:[{conditions:[{[Er]:Nr,[Sr]:[{[wr]:"UseGlobalEndpoint"},Tr]},{[Er]:"not",[Sr]:Hr},jr,Vr,{[Er]:Nr,[Sr]:[_r,vr]},{[Er]:Nr,[Sr]:[Lr,vr]}],rules:[{conditions:[{[Er]:Ir,[Sr]:[Ur,"ap-northeast-1"]}],endpoint:zr,[br]:Cr},{conditions:[{[Er]:Ir,[Sr]:[Ur,"ap-south-1"]}],endpoint:zr,[br]:Cr},{conditions:[{[Er]:Ir,[Sr]:[Ur,"ap-southeast-1"]}],endpoint:zr,[br]:Cr},{conditions:[{[Er]:Ir,[Sr]:[Ur,"ap-southeast-2"]}],endpoint:zr,[br]:Cr},Wr,{conditions:[{[Er]:Ir,[Sr]:[Ur,"ca-central-1"]}],endpoint:zr,[br]:Cr},{conditions:[{[Er]:Ir,[Sr]:[Ur,"eu-central-1"]}],endpoint:zr,[br]:Cr},{conditions:[{[Er]:Ir,[Sr]:[Ur,"eu-north-1"]}],endpoint:zr,[br]:Cr},{conditions:[{[Er]:Ir,[Sr]:[Ur,"eu-west-1"]}],endpoint:zr,[br]:Cr},{conditions:[{[Er]:Ir,[Sr]:[Ur,"eu-west-2"]}],endpoint:zr,[br]:Cr},{conditions:[{[Er]:Ir,[Sr]:[Ur,"eu-west-3"]}],endpoint:zr,[br]:Cr},{conditions:[{[Er]:Ir,[Sr]:[Ur,"sa-east-1"]}],endpoint:zr,[br]:Cr},{conditions:[{[Er]:Ir,[Sr]:[Ur,Pr]}],endpoint:zr,[br]:Cr},{conditions:[{[Er]:Ir,[Sr]:[Ur,"us-east-2"]}],endpoint:zr,[br]:Cr},{conditions:[{[Er]:Ir,[Sr]:[Ur,"us-west-1"]}],endpoint:zr,[br]:Cr},{conditions:[{[Er]:Ir,[Sr]:[Ur,"us-west-2"]}],endpoint:zr,[br]:Cr},{endpoint:{url:Dr,properties:{authSchemes:[{name:Ar,signingName:"sts",signingRegion:"{Region}"}]},headers:Kr},[br]:Cr}],[br]:kr},{conditions:Hr,rules:[{conditions:Qr,error:"Invalid Configuration: FIPS and custom endpoint are not supported",[br]:Or},{conditions:Xr,error:"Invalid Configuration: Dualstack and custom endpoint are not supported",[br]:Or},{endpoint:{url:Fr,properties:Kr,headers:Kr},[br]:Cr}],[br]:kr},{conditions:[jr],rules:[{conditions:[Vr],rules:[{conditions:[Br,qr],rules:[{conditions:[{[Er]:Nr,[Sr]:[Tr,Gr]},Yr],rules:[{endpoint:{url:"https://sts-fips.{Region}.{PartitionResult#dualStackDnsSuffix}",properties:Kr,headers:Kr},[br]:Cr}],[br]:kr},{error:"FIPS and DualStack are enabled, but this partition does not support one or both",[br]:Or}],[br]:kr},{conditions:Qr,rules:[{conditions:[{[Er]:Nr,[Sr]:[Gr,Tr]}],rules:[{conditions:[{[Er]:Ir,[Sr]:[{[Er]:$r,[Sr]:[Zr,"name"]},"aws-us-gov"]}],endpoint:{url:"https://sts.{Region}.amazonaws.com",properties:Kr,headers:Kr},[br]:Cr},{endpoint:{url:"https://sts-fips.{Region}.{PartitionResult#dnsSuffix}",properties:Kr,headers:Kr},[br]:Cr}],[br]:kr},{error:"FIPS is enabled but this partition does not support FIPS",[br]:Or}],[br]:kr},{conditions:Xr,rules:[{conditions:[Yr],rules:[{endpoint:{url:"https://sts.{Region}.{PartitionResult#dualStackDnsSuffix}",properties:Kr,headers:Kr},[br]:Cr}],[br]:kr},{error:"DualStack is enabled but this partition does not support DualStack",[br]:Or}],[br]:kr},Wr,{endpoint:{url:Dr,properties:Kr,headers:Kr},[br]:Cr}],[br]:kr}],[br]:kr},{error:"Invalid Configuration: Missing Region",[br]:Or}]},en=new fr.k({size:50,params:["Endpoint","Region","UseDualStack","UseFIPS","UseGlobalEndpoint"]}),tn=(e,t={})=>en.get(e,()=>(0,mr.s)(Jr,{endpointParams:e,logger:t.logger}));yr.m.aws=gr.UF;var rn=r(74783),nn=r(85397),sn=r(56602);var on=r(79532),an=r(81355),ln=r(91415);class cn extends Ne.K{config;constructor(...[e]){const t=(e=>{(0,sn.I)(process.version);const t=(0,nn.I)(e),r=()=>t().then(rn.l),n=(e=>({apiVersion:"2011-06-15",base64Decoder:e?.base64Decoder??hr.E,base64Encoder:e?.base64Encoder??or.n,disableHostPrefix:e?.disableHostPrefix??!1,endpointProvider:e?.endpointProvider??tn,extensions:e?.extensions??[],httpAuthSchemeProvider:e?.httpAuthSchemeProvider??De,httpAuthSchemes:e?.httpAuthSchemes??[{schemeId:"aws.auth#sigv4",identityProvider:e=>e.getIdentityProvider("aws.auth#sigv4"),signer:new Re.f2},{schemeId:"smithy.api#noAuth",identityProvider:e=>e.getIdentityProvider("smithy.api#noAuth")||(async()=>({})),signer:new Ve.m}],logger:e?.logger??new ur.N,protocol:e?.protocol??new cr({defaultNamespace:"com.amazonaws.sts",xmlNamespace:"https://sts.amazonaws.com/doc/2011-06-15/",version:"2011-06-15"}),serviceId:e?.serviceId??"STS",urlParser:e?.urlParser??dr.D,utf8Decoder:e?.utf8Decoder??pr.a,utf8Encoder:e?.utf8Encoder??Xt.P}))(e);(0,Oe.I)(process.version);const o={profile:e?.profile,logger:n.logger};return{...n,...e,runtime:"node",defaultsMode:t,authSchemePreference:e?.authSchemePreference??(0,i.Z)($e.$,o),bodyLengthChecker:e?.bodyLengthChecker??Ke.n,defaultUserAgentProvider:e?.defaultUserAgentProvider??(0,Me.pf)({serviceId:n.serviceId,clientVersion:ke.rE}),httpAuthSchemes:e?.httpAuthSchemes??[{schemeId:"aws.auth#sigv4",identityProvider:t=>t.getIdentityProvider("aws.auth#sigv4")||(async t=>await e.credentialDefaultProvider(t?.__config||{})()),signer:new Re.f2},{schemeId:"smithy.api#noAuth",identityProvider:e=>e.getIdentityProvider("smithy.api#noAuth")||(async()=>({})),signer:new Ve.m}],maxAttempts:e?.maxAttempts??(0,i.Z)(ve.qs,e),region:e?.region??(0,i.Z)(s.GG,{...s.zH,...o}),requestHandler:Le.$.create(e?.requestHandler??r),retryMode:e?.retryMode??(0,i.Z)({...ve.kN,default:async()=>(await r()).retryMode||We.L0},e),sha256:e?.sha256??_e.V.bind(null,"sha256"),streamCollector:e?.streamCollector??ze.k,useDualstackEndpoint:e?.useDualstackEndpoint??(0,i.Z)(je.e$,o),useFipsEndpoint:e?.useFipsEndpoint??(0,i.Z)(Ue.Ko,o),userAgentAppId:e?.userAgentAppId??(0,i.Z)(Fe.hV,o)}})(e||{});super(t),this.initConfig=t;const r=(n=t,Object.assign(n,{useDualstackEndpoint:n.useDualstackEndpoint??!1,useFipsEndpoint:n.useFipsEndpoint??!1,useGlobalEndpoint:n.useGlobalEndpoint??!1,defaultSigningName:"sts"}));var n;const o=(0,ge.D)(r),a=(0,ve.$z)(o),l=(0,me.T)(a),c=(0,de.OV)(l),u=((e,t)=>{const r=Object.assign((0,on.R)(e),(0,ln.xA)(e),(0,an.e)(e),(e=>{const t=e.httpAuthSchemes;let r=e.httpAuthSchemeProvider,n=e.credentials;return{setHttpAuthScheme(e){const r=t.findIndex(t=>t.schemeId===e.schemeId);-1===r?t.push(e):t.splice(r,1,e)},httpAuthSchemes:()=>t,setHttpAuthSchemeProvider(e){r=e},httpAuthSchemeProvider:()=>r,setCredentials(e){n=e},credentials:()=>n}})(e));return t.forEach(e=>e.configure(r)),Object.assign(e,(0,on.$)(r),(0,ln.uv)(r),(0,an.j)(r),{httpAuthSchemes:(n=r).httpAuthSchemes(),httpAuthSchemeProvider:n.httpAuthSchemeProvider(),credentials:n.credentials()});var n})((e=>{const t=(r=e,Object.assign(r,{stsClientCtor:cn}));var r;const n=(0,Ie.h)(t);return Object.assign(n,{authSchemePreference:(0,Pe.t)(e.authSchemePreference??[])})})((0,we.C)(c)),e?.extensions||[]);this.config=u,this.middlewareStack.use((0,Ee.wq)(this.config)),this.middlewareStack.use((0,fe.sM)(this.config)),this.middlewareStack.use((0,Te.ey)(this.config)),this.middlewareStack.use((0,Se.vK)(this.config)),this.middlewareStack.use((0,de.TC)(this.config)),this.middlewareStack.use((0,he.Y7)(this.config)),this.middlewareStack.use((0,pe.n)(this.config)),this.middlewareStack.use((0,ye.w)(this.config,{httpAuthSchemeParametersProvider:Ce,identityProviderConfigProvider:async e=>new xe.h({"aws.auth#sigv4":e.credentials})})),this.middlewareStack.use((0,be.l)(this.config))}destroy(){super.destroy()}}const un=(e,t)=>t?class extends e{constructor(e){super(e);for(const e of t)this.middlewareStack.use(e)}}:e,dn=(e={},t)=>((e,t)=>{let r,s;return async(i,o)=>{if(s=i,!r){const{logger:n=e?.parentClientConfig?.logger,profile:i=e?.parentClientConfig?.profile,region:o,requestHandler:a=e?.parentClientConfig?.requestHandler,credentialProviderLogger:l,userAgentAppId:c=e?.parentClientConfig?.userAgentAppId}=e,u=await ce(o,e?.parentClientConfig?.region,l,{logger:n,profile:i}),d=!ue(a);r=new t({...e,userAgentAppId:c,profile:i,credentialDefaultProvider:()=>async()=>s,region:u,requestHandler:d?a:void 0,logger:n})}const{Credentials:a,AssumedRoleUser:l}=await r.send(new oe(o));if(!a||!a.AccessKeyId||!a.SecretAccessKey)throw new Error(`Invalid response from STS.assumeRole call with role ${o.RoleArn}`);const c=le(l),u={accessKeyId:a.AccessKeyId,secretAccessKey:a.SecretAccessKey,sessionToken:a.SessionToken,expiration:a.Expiration,...a.CredentialScope&&{credentialScope:a.CredentialScope},...c&&{accountId:c}};return(0,n.g)(u,"CREDENTIALS_STS_ASSUME_ROLE","i"),u}})(e,un(cn,t)),hn=(e={},t)=>((e,t)=>{let r;return async s=>{if(!r){const{logger:n=e?.parentClientConfig?.logger,profile:s=e?.parentClientConfig?.profile,region:i,requestHandler:o=e?.parentClientConfig?.requestHandler,credentialProviderLogger:a,userAgentAppId:l=e?.parentClientConfig?.userAgentAppId}=e,c=await ce(i,e?.parentClientConfig?.region,a,{logger:n,profile:s}),u=!ue(o);r=new t({...e,userAgentAppId:l,profile:s,region:c,requestHandler:u?o:void 0,logger:n})}const{Credentials:i,AssumedRoleUser:o}=await r.send(new ae(s));if(!i||!i.AccessKeyId||!i.SecretAccessKey)throw new Error(`Invalid response from STS.assumeRoleWithWebIdentity call with role ${s.RoleArn}`);const a=le(o),l={accessKeyId:i.AccessKeyId,secretAccessKey:i.SecretAccessKey,sessionToken:i.SessionToken,expiration:i.Expiration,...i.CredentialScope&&{credentialScope:i.CredentialScope},...a&&{accountId:a}};return a&&(0,n.g)(l,"RESOLVED_ACCOUNT_ID","T"),(0,n.g)(l,"CREDENTIALS_STS_ASSUME_ROLE_WEB_ID","k"),l}})(e,un(cn,t))}};