1import{b as H,c as _,l as Y,m as v,r as ee,s as te,t as re,u as ne}from"./chunk-V2RIMSQ2.js";import{a as Z,b as P,c as V}from"./chunk-YDOPGCYI.js";import{a as R,f as b,g as l,h as p,j as g}from"./chunk-VTHXE323.js";var ce=(function(){function a(){this.crc32=new F}return a.prototype.update=function(e){te(e)||this.crc32.update(ee(e))},a.prototype.digest=function(){return Z(this,void 0,void 0,function(){return P(this,function(e){return[2,re(this.crc32.digest())]})})},a.prototype.reset=function(){this.crc32=new F},a})();var F=(function(){function a(){this.checksum=4294967295}return a.prototype.update=function(e){var t,r;try{for(var s=V(e),n=s.next();!n.done;n=s.next()){var o=n.value;this.checksum=this.checksum>>>8^fe[(this.checksum^o)&255]}}catch(i){t={error:i}}finally{try{n&&!n.done&&(r=s.return)&&r.call(s)}finally{if(t)throw t.error}}return this},a.prototype.digest=function(){return(this.checksum^4294967295)>>>0},a})();var le=[0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918e3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117],fe=ne(le);var E=class a{bytes;constructor(e){if(this.bytes=e,e.byteLength!==8)throw new Error("Int64 buffers must be exactly 8 bytes")}static fromNumber(e){if(e>9223372036854776e3||e<-9223372036854776e3)throw new Error(`${e} is too large (or, if negative, too small) to represent as an Int64`);let t=new Uint8Array(8);for(let r=7,s=Math.abs(Math.round(e));r>-1&&s>0;r--,s/=256)t[r]=s;return e<0&&se(t),new a(t)}valueOf(){let e=this.bytes.slice(0),t=e[0]&128;return t&&se(e),parseInt(v(e),16)*(t?-1:1)}toString(){return String(this.valueOf())}};function se(a){for(let e=0;e<8;e++)a[e]^=255;for(let e=7;e>-1&&(a[e]++,a[e]===0);e--);}var k=class{toUtf8;fromUtf8;constructor(e,t){this.toUtf8=e,this.fromUtf8=t}format(e){let t=[];for(let n of Object.keys(e)){let o=this.fromUtf8(n);t.push(Uint8Array.from([o.byteLength]),o,this.formatHeaderValue(e[
1n]))}let r=new Uint8Array(t.reduce((n,o)=>n+o.byteLength,0)),s=0;for(let n of t)r.set(n,s),s+=n.byteLength;return r}formatHeaderValue(e){switch(e.type){case"boolean":return Uint8Array.from([e.value?0:1]);case"byte":return Uint8Array.from([2,e.value]);case"short":let t=new DataView(new ArrayBuffer(3));return t.setUint8(0,3),t.setInt16(1,e.value,!1),new Uint8Array(t.buffer);case"integer":let r=new DataView(new ArrayBuffer(5));return r.setUint8(0,4),r.setInt32(1,e.value,!1),new Uint8Array(r.buffer);case"long":let s=new Uint8Array(9);return s[0]=5,s.set(e.value.bytes,1),s;case"binary":let n=new DataView(new ArrayBuffer(3+e.value.byteLength));n.setUint8(0,6),n.setUint16(1,e.value.byteLength,!1);let o=new Uint8Array(n.buffer);return o.set(e.value,3),o;case"string":let i=this.fromUtf8(e.value),c=new DataView(new ArrayBuffer(3+i.byteLength));c.setUint8(0,7),c.setUint16(1,i.byteLength,!1);let h=new Uint8Array(c.buffer);return h.set(i,3),h;case"timestamp":let B=new Uint8Array(9);return B[0]=8,B.set(E.fromNumber(e.value.valueOf()).bytes,1),B;case"uuid":if(!De.test(e.value))throw new Error(`Invalid UUID received: ${e.value}`);let m=new Uint8Array(17);return m[0]=9,m.set(Y(e.value.replace(/\-/g,"")),1),m}}parse(e){let t={},r=0;for(;r<e.byteLength;){let s=e.getUint8(r++),n=this.toUtf8(new Uint8Array(e.buffer,e.byteOffset+r,s));switch(r+=s,e.getUint8(r++)){case 0:t[n]={type:ae,value:!0};break;case 1:t[n]={type:ae,value:!1};break;case 2:t[n]={type:xe,value:e.getInt8(r++)};break;case 3:t[n]={type:ue,value:e.getInt16(r,!1)},r+=2;break;case 4:t[n]={type:me,value:e.getInt32(r,!1)},r+=4;break;case 5:t[n]={type:ye,value:new E(new Uint8Array(e.buffer,e.byteOffset+r,8))},r+=8;break;case 6:let o=e.getUint16(r,!1);r+=2,t[n]={type:de,value:new Uint8Array(e.buffer,e.byteOffset+r,o)},r+=o;break;case 7:let i=e.getUint16(r,!1);r+=2,t[n]={type:he,value:this.toUtf8(new Uint8Array(e.buffer,e.byteOffset+r,i))},r+=i;break;case 8:t[n]={type:Be,value:new Date(new E(new Uint8Array(e.buffer,e.byteOffset+r,8)).valueOf())},r+=8;break;case 9:let c=new Uint8Array(e.buffer,e.byteOffset+r,16);r+=16,t[n]={type:pe,value:`${v(c.subarray(0,4))}-${v(c.subarray(4,6))}-${v(c.subarray(6,8))}-${v(c.subarray(8,10))}-${v(c.subarray(10))}`};break;default:throw new Error("Unrecognized header type tag")}}return t}};var ae="boolean",xe="byte",ue="short",me="integer",ye="long",de="binary",he="string",Be="timestamp",pe="uuid",De=/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/;var oe=4,A=oe*2,U=4,ge=A+U*2;function ie({byteLength:a,byteOffset:e,buffer:t}){if(a<ge)throw new Error("Provided message too short to accommodate event stream message overhead");let r=new DataView(t,e,a),s=r.getUint32(0,!1);if(a!==s)throw new Error("Reported message length does not match received message length");let n=r.getUint32(oe,!1),o=r.getUint32(A,!1),i=r.getUint32(a-U,!1),c=new F().update(new Uint8Array(t,e,A));if(o!==c.digest())throw new Error(`The prelude checksum specified in the message (${o}) does not match the calculated CRC32 checksum (${c.digest()})`);if(c.update(new Uint8Array(t,e+A,a-(A+U))),i!==c.digest())throw new Error(`The message checksum (${c.digest()}) did not match the expected value of ${i}`);return{headers:new DataView(t,e+A+U,n),body:new Uint8Array(t,e+A+U+n,s-n-(A+U+U))}}var T=class{headerMarshaller;messageBuffer;isEndOfStream;constructor(e,t){this.headerMarshaller=new k(e,t),this.messageBuffer=[],this.isEndOfStream=!1}feed(e){this.messageBuffer.push(this.decode(e))}endOfStream(){this.isEndOfStream=!0}getMessage(){let e=this.messageBuffer.pop(),t=this.isEndOfStream;return{getMessage(){return e},isEndOfStream(){return t}}}getAvailableMessages(){let e=this.messageBuffer;this.messageBuffer=[];let t=this.isEndOfStream;return{getMessages(){return e},isEndOfStream(){return t}}}encode({headers:e,body:t}){let r=this.headerMarshaller.format(e),s=r.byteLength+t.byteLength+16,n=new Uint8Array(s),o=new DataView(n.buffer,n.byteOffset,n.byteLength),i=new F;return o.setUint32(0,s,!1),o.setUint32(4,r.byteLength,!1),o.setUint32(8,i.update(n.subarray(0,8)).digest(),!1),n.set(r,12),n.set(t,r.byteLength+12),o.setUint32(s-4,i.update(n.subarray(8,s-4)).digest(),!1),n}decode(e){let{headers:t,body:r}=ie(e);return{headers:this.headerMarshaller.parse(t),body:r}}formatHeaders(e){return this.headerMarshaller.format(e)}};var z=class{options;constructor(e){this.options=e}[Symbol.asyncIterator](){return this.asyncIterator()}asyncIterator(){return p(this,null,function*(){try{for(var e=g(this.options.inputStream),t,r,s;t=!(r=yield new l(e.next())).done;t=!1){let n=r.value;yield this.options.decoder.decode(n)}}catch(r){s=[r]}finally{try{t&&(r=e.return)&&(yield new l(r.call(e)))}finally{if(s)throw s[0]}}})}};var O=class{options;constructor(e){this.options=e}[Symbol.asyncIterator](){return this.asyncIterator()}asyncIterator(){return p(this,null,function*(){try{for(var e=g(this.options.messageStream),t,r,s;t=!(r=yield new l(e.next())).done;t=!1){let n=r.value;yield this.options.encoder.encode(n)}}catch(r){s=[r]}finally{try{t&&(r=e.return)&&(yield new l(r.call(e)))}finally{if(s)throw s[0]}}this.options.includeEndFrame&&(yield new Uint8Array(0))})}};var N=class{options;constructor(e){this.options=e}[Symbol.asyncIterator](){return this.asyncIterator()}asyncIterator(){return p(this,null,function*(){try{for(var e=g(this.options.messageStream),t,r,s;t=!(r=yield new l(e.next())).done;t=!1){let n=r.value;let o=yield new l(this.options.deserializer(n));o!==void 0&&(yield o)}}catch(r){s=[r]}finally{try{t&&(r=e.return)&&(yield new l(r.call(e)))}finally{if(s)throw s[0]}}})}};var G=class{options;constructor(e){this.options=e}[Symbol.asyncIterator](){return this.asyncIterator()}asyncIterator(){return p(this,null,function*(){try{for(var e=g(this.options.inputStream),t,r,s;t=!(r=yield new l(e.next())).done;t=!1){let n=r.value;yield this.options.serializer(n)}}catch(r){s=[r]}finally{try{t&&(r=e.return)&&(yield new l(r.call(e)))}finally{if(s)throw s[0]}}})}};function K(a){let e=0,t=0,r=null,s=null,n=i=>{if(typeof i!="number")throw new Error("Attempted to allocate an event message where size was not a number: "+i);e=i,t=4,r=new Uint8Array(i),new DataView(r.buffer).setUint32(0,i,!1)},o=function(){return p(this,null,function*(){let i=a[Symbol.asyncIterator]();for(;;){let{value:c,done:h}=yield new l(i.next());if(h){if(e)if(e===t)yield r;else throw new Error("Truncated event message received.");else return;return}let B=c.length,m=0;for(;m<B;){if(!r){let y=B-m;s||(s=new Uint8Array(4));let f=Math.min(4-t,y);if(s.set(c.slice(m,m+f),t),t+=f,m+=f,t<4)break;n(new DataView(s.buffer).getUint32(0,!1)),s=null}let x=Math.min(e-t,B-m);r.set(c.slice(m,m+x),t),t+=x,m+=x,e&&e===t&&(yield r,r=null,e=0,t=0)}}})};return{[Symbol.asyncIterator]:o}}function Ce(a,e){let t=L(e.deserializer,e.toUtf8);return{[Symbol.asyncIterator]:function(){return p(this,null,function*(){try{for(var r=g(a),s,n,o;s=!(n=yield new l(r.next())).done;s=!1){let i=n.value;
1let c=e.eventStreamCodec.decode(i),h=yield new l(t(c));h!==void 0&&(yield h)}}catch(n){o=[n]}finally{try{s&&(n=r.return)&&(yield new l(n.call(r)))}finally{if(o)throw o[0]}}})}}}function L(a,e){return function(t){return b(this,null,function*(){let{value:r}=t.headers[":message-type"];if(r==="error"){let s=new Error(t.headers[":error-message"].value||"UnknownError");throw s.name=t.headers[":error-code"].value,s}else if(r==="exception"){let s=t.headers[":exception-type"].value,n={[s]:t},o=yield a(n);if(o.$unknown){let i=new Error(e(t.body));throw i.name=s,i}throw o[s]}else if(r==="event"){let s={[t.headers[":event-type"].value]:t},n=yield a(s);return n.$unknown?void 0:n}else throw Error(`Unrecognizable event type: ${t.headers[":event-type"].value}`)})}}var I=class{eventStreamCodec;utfEncoder;constructor({utf8Encoder:e,utf8Decoder:t}){this.eventStreamCodec=new T(e,t),this.utfEncoder=e}deserialize(e,t){let r=K(e);return new N({messageStream:new z({inputStream:r,decoder:this.eventStreamCodec}),deserializer:L(t,this.utfEncoder)})}serialize(e,t){return new O({messageStream:new G({inputStream:e,serializer:t}),encoder:this.eventStreamCodec,includeEndFrame:!0})}},we=a=>new I(a);var q=a=>({[Symbol.asyncIterator]:function(){return p(this,null,function*(){let e=a.getReader();try{for(;;){let{done:t,value:r}=yield new l(e.read());if(t)return;yield r}}finally{e.releaseLock()}})}}),W=a=>{let e=a[Symbol.asyncIterator]();return new ReadableStream({pull(r){return b(this,null,function*(){let{done:s,value:n}=yield e.next();if(s)return r.close();r.enqueue(n)})}})};var j=class{universalMarshaller;constructor({utf8Encoder:e,utf8Decoder:t}){this.universalMarshaller=new I({utf8Decoder:t,utf8Encoder:e})}deserialize(e,t){let r=be(e)?q(e):e;return this.universalMarshaller.deserialize(r,t)}serialize(e,t){let r=this.universalMarshaller.serialize(e,t);return typeof ReadableStream=="function"?W(r):r}},be=a=>typeof ReadableStream=="function"&&a instanceof ReadableStream,ve=a=>new j(a);var Ae=a=>Object.assign(a,{eventStreamMarshaller:a.eventStreamSerdeProvider(a)});var J=class{marshaller;serializer;deserializer;serdeContext;defaultContentType;constructor({marshaller:e,serializer:t,deserializer:r,serdeContext:s,defaultContentType:n}){this.marshaller=e,this.serializer=t,this.deserializer=r,this.serdeContext=s,this.defaultContentType=n}serializeEventStream(s){return b(this,arguments,function*({eventStream:e,requestSchema:t,initialRequest:r}){let n=this.marshaller,o=t.getEventStreamMember(),i=t.getMemberSchema(o),c=this.serializer,h=this.defaultContentType,B=Symbol("initialRequestMarker"),m={[Symbol.asyncIterator](){return p(this,null,function*(){if(r){let u={":event-type":{type:"string",value:"initial-request"},":message-type":{type:"string",value:"event"},":content-type":{type:"string",value:h}};c.write(t,r);let d=c.flush();yield{[B]:!0,headers:u,body:d}}try{for(var y=g(e),f,D,C;f=!(D=yield new l(y.next())).done;f=!1){let u=D.value;yield u}}catch(D){C=[D]}finally{try{f&&(D=y.return)&&(yield new l(D.call(y)))}finally{if(C)throw C[0]}}})}};return n.serialize(m,y=>{if(y[B])return{headers:y.headers,body:y.body};let f="";for(let w in y)if(w!=="__type"){f=w;break}let{additionalHeaders:D,body:C,eventType:u,explicitPayloadContentType:d}=this.writeEventBody(f,i,y);return{headers:R({":event-type":{type:"string",value:u},":message-type":{type:"string",value:"event"},":content-type":{type:"string",value:d??h}},D),body:C}})})}deserializeEventStream(s){return b(this,arguments,function*({response:e,responseSchema:t,initialResponseContainer:r}){let n=this.marshaller,o=t.getEventStreamMember(),c=t.getMemberSchema(o).getMemberSchemas(),h=Symbol("initialResponseMarker"),B=n.deserialize(e.body,f=>b(this,null,function*(){let D="";for(let u in f)if(u!=="__type"){D=u;break}let C=f[D].body;if(D==="initial-response"){let u=yield this.deserializer.read(t,C);return delete u[o],R({[h]:!0},u)}else if(D in c){let u=c[D];if(u.isStructSchema()){let d={},$=!1;for(let[w,M]of u.structIterator()){let{eventHeader:Q,eventPayload:X}=M.getMergedTraits();if($=$||!!(Q||X),X)M.isBlobSchema()?d[w]=C:M.isStringSchema()?d[w]=(this.serdeContext?.utf8Encoder??_)(C):M.isStructSchema()&&(d[w]=yield this.deserializer.read(M,C));else if(Q){let S=f[D].headers[w]?.value;S!=null&&(M.isNumericSchema()?S&&typeof S=="object"&&"bytes"in S?d[w]=BigInt(S.toString()):d[w]=Number(S):d[w]=S)}}if($)return{[D]:d};if(C.byteLength===0)return{[D]:{}}}return{[D]:yield this.deserializer.read(u,C)}}else return{$unknown:f}})),m=B[Symbol.asyncIterator](),x=yield m.next();if(x.done)return B;if(x.value?.[h]){if(!t)throw new Error("@smithy::core/protocols - initial-response event encountered in event stream but no response schema given.");for(let f in x.value)r[f]=x.value[f]}return{[Symbol.asyncIterator](){return p(this,null,function*(){for(x?.value?.[h]||(yield x.value);;){let{done:f,value:D}=yield new l(m.next());if(f)break;yield D}})}}})}writeEventBody(e,t,r){let s=this.serializer,n=e,o=null,i,c=t.getSchema()[4].includes(e),h={};if(c){let x=t.getMemberSchema(e);if(x.isStructSchema()){for(let[y,f]of x.structIterator()){let{eventHeader:D,eventPayload:C}=f.getMergedTraits();if(C)o=y;else if(D){let u=r[e][y],d="binary";f.isNumericSchema()?(-2)**31<=u&&u<=2**31-1?d="integer":d="long":f.isTimestampSchema()?d="timestamp":f.isStringSchema()?d="str
1ing":f.isBooleanSchema()&&(d="boolean"),u!=null&&(h[y]={type:d,value:u},delete r[e][y])}}if(o!==null){let y=x.getMemberSchema(o);y.isBlobSchema()?i="application/octet-stream":y.isStringSchema()&&(i="text/plain"),s.write(y,r[e][o])}else s.write(x,r[e])}else if(x.isUnitSchema())s.write(x,{});else throw new Error("@smithy/core/event-streams - non-struct member not supported in event stream union.")}else{let[x,y]=r[e];n=x,s.write(15,y)}let B=s.flush()??new Uint8Array;return{body:typeof B=="string"?(this.serdeContext?.utf8Decoder??H)(B):B,eventType:n,explicitPayloadContentType:i,additionalHeaders:h}}};export{T as EventStreamCodec,j as EventStreamMarshaller,J as EventStreamSerde,k as HeaderMarshaller,E as Int64,z as MessageDecoderStream,O as MessageEncoderStream,N as SmithyMessageDecoderStream,G as SmithyMessageEncoderStream,I as UniversalEventStreamMarshaller,ve as eventStreamSerdeProvider,K as getChunkedStream,L as getMessageUnmarshaller,Ce as getUnmarshalledStream,W as iterableToReadableStream,q as readableStreamToIterable,Ae as resolveEventStreamSerdeConfig,we as universalEventStreamSerdeProvider};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.