import{j as u,n as b,t as S}from"./chunk-YYJUG63O.js";import{a as w}from"./chunk-CHWVD37K.js";var z=class extends S{async serializeRequest(n,i,t){let s=this.serializer,o={},a={},d=await t.endpoint(),e=b.of(n?.input),l=e.getSchema(),f,r=new w({protocol:"",hostname:"",port:void 0,path:"/",fragment:void 0,query:o,headers:a,body:void 0});d&&(this.updateServiceEndpoint(r,d),this.setHostPrefix(r,n,i));let c={...i};if(i){let h=e.getEventStreamMember();if(h){if(c[h]){let y={};for(let[m,g]of e.structIterator())m!==h&&c[m]&&(s.write(g,c[m]),y[m]=s.flush());f=await this.serializeEventStream({eventStream:c[h],requestSchema:e,initialRequest:y})}}else s.write(l,c),f=s.flush()}return r.headers=Object.assign(r.headers,a),r.query=o,r.body=f,r.method="POST",r}async deserializeResponse(n,i,t){let s=this.deserializer,o=b.of(n.output),a={};if(t.statusCode>=300){let e=await u(t.body,i);throw e.byteLength>0&&Object.assign(a,await s.read(15,e)),await this.handleError(n,i,t,a,this.deserializeMetadata(t)),new Error("@smithy/core/protocols - RPC Protocol error handler failed to throw.")}for(let e in t.headers){let l=t.headers[e];delete t.headers[e],t.headers[e.toLowerCase()]=l}let d=o.getEventStreamMember();if(d)a[d]=await this.deserializeEventStream({response:t,responseSchema:o,initialResponseContainer:a});else{let e=await u(t.body,i);e.byteLength>0&&Object.assign(a,await s.read(o,e))}return a.$metadata=this.deserializeMetadata(t),a}};export{z as a};
