@bkm016/basalt 0.1.13 → 0.1.14

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.
Files changed (243) hide show
  1. package/README.md +3 -2
  2. package/{chunk-bng72094.js → chunk-03wzwnn6.js} +1 -1
  3. package/{chunk-9e8vhzy7.js → chunk-0crbhhna.js} +1 -1
  4. package/{chunk-h9zxqeqr.js → chunk-0rasqm8y.js} +2 -2
  5. package/{chunk-0x9netvr.js → chunk-1w4nh5t6.js} +1 -1
  6. package/{chunk-dk6fgprw.js → chunk-2eaehpp6.js} +1 -1
  7. package/{chunk-6sea12mw.js → chunk-30dxcr91.js} +1 -1
  8. package/{chunk-2zbj8ny6.js → chunk-343jsm46.js} +2 -2
  9. package/chunk-38g4jd6v.js +5 -0
  10. package/{chunk-zx75vnw8.js → chunk-39mh7h58.js} +22 -22
  11. package/chunk-44b9yx79.js +2 -0
  12. package/{chunk-r1jn77q6.js → chunk-4f6p4n7k.js} +2 -2
  13. package/{chunk-sgz87ht5.js → chunk-4w8j6n7z.js} +1 -1
  14. package/{chunk-szj85dqe.js → chunk-4yxd2kg1.js} +2 -2
  15. package/{chunk-bp61xdsc.js → chunk-59hg9a84.js} +1 -1
  16. package/{chunk-bq54argx.js → chunk-62ebm0bn.js} +1 -1
  17. package/{chunk-6d9r9p91.js → chunk-6ef085c1.js} +4 -4
  18. package/{chunk-zk91579b.js → chunk-6hx9y86d.js} +2 -2
  19. package/chunk-73t051r6.js +2 -0
  20. package/{chunk-pryvvs96.js → chunk-7mgkpn94.js} +22 -22
  21. package/{chunk-2q56egb8.js → chunk-81x8r8w4.js} +1 -1
  22. package/{chunk-rn3jwyh1.js → chunk-8np9b2y8.js} +2 -2
  23. package/{chunk-1q6e3mj7.js → chunk-9ew8cap5.js} +2 -2
  24. package/chunk-9v3b7jjv.js +2 -0
  25. package/{chunk-tjg0gcks.js → chunk-9vam83py.js} +1 -1
  26. package/{chunk-ct77cdg7.js → chunk-9xjecw6c.js} +1 -1
  27. package/{chunk-8cgz8xv7.js → chunk-b2wpj81x.js} +2 -2
  28. package/{chunk-302n9g7p.js → chunk-bjvv3403.js} +1 -1
  29. package/{chunk-tfhze1vq.js → chunk-c8g9jjqs.js} +2 -2
  30. package/{chunk-0a7ft50x.js → chunk-cs91rmbf.js} +8 -8
  31. package/{chunk-gpnqmtbk.js → chunk-edcf97ka.js} +1 -1
  32. package/{chunk-74wwdx3y.js → chunk-en7z6ne5.js} +2 -2
  33. package/{chunk-f0h2bv11.js → chunk-evnqkyt7.js} +10 -10
  34. package/{chunk-4rnmxtpx.js → chunk-ge38dhv9.js} +2 -2
  35. package/chunk-hggam3je.js +2 -0
  36. package/{chunk-mf04h0yy.js → chunk-k38jaz6c.js} +4 -4
  37. package/{chunk-jjtt9aq8.js → chunk-kcn05erf.js} +3 -3
  38. package/{chunk-y23dpz5e.js → chunk-m5km74eq.js} +2 -2
  39. package/{chunk-095adzn5.js → chunk-mfb3dgs8.js} +2 -2
  40. package/{chunk-0nedq669.js → chunk-mh4bjtfs.js} +3 -3
  41. package/{chunk-yy1f9jxc.js → chunk-nysatg77.js} +429 -312
  42. package/{chunk-bja7p3em.js → chunk-p886jr17.js} +13 -13
  43. package/{chunk-xvm0y99b.js → chunk-pdt65s31.js} +2 -2
  44. package/{chunk-ymg7mtcx.js → chunk-pjgt1bdx.js} +2 -2
  45. package/{chunk-959z9efn.js → chunk-pyj6avd5.js} +2 -2
  46. package/chunk-qd2enpr2.js +3 -0
  47. package/{chunk-tnj2kqb8.js → chunk-qe76naq9.js} +1 -1
  48. package/{chunk-z0c8ek0j.js → chunk-qjnx4fsn.js} +2 -2
  49. package/{chunk-2tf7qfbx.js → chunk-qs161f2q.js} +2 -2
  50. package/{chunk-nbjnwd54.js → chunk-rghqprav.js} +1 -1
  51. package/{chunk-7chv3knf.js → chunk-t33bm5aa.js} +1 -1
  52. package/chunk-vd5332ps.js +2 -0
  53. package/{chunk-22az84sh.js → chunk-w55cnj0f.js} +2 -2
  54. package/{chunk-4k9t9jvx.js → chunk-wnd3y4c0.js} +1 -1
  55. package/{chunk-snz19yc2.js → chunk-xafx1p7z.js} +2 -2
  56. package/{chunk-15ve3nmv.js → chunk-xf7zw32f.js} +12 -12
  57. package/chunk-xk3t5ves.js +482 -0
  58. package/{chunk-kbpbrr11.js → chunk-xq74x4gc.js} +2 -2
  59. package/{chunk-mdkfm1ak.js → chunk-y0274xr2.js} +3 -3
  60. package/{chunk-y4pvhes1.js → chunk-z9p6s986.js} +6 -6
  61. package/{chunk-41das1ty.js → chunk-zcwz44db.js} +1 -1
  62. package/{chunk-77c2cqp2.js → chunk-zhyzhekt.js} +1 -1
  63. package/compiled.js +12 -12
  64. package/package.json +1 -1
  65. package/ui-test-worker.js +51 -51
  66. package/web/chunk-15g9pnzy.js +1 -0
  67. package/web/{chunk-16jc5m0f.js → chunk-17wwzrp4.js} +1 -1
  68. package/web/chunk-19tkjg9w.js +1 -0
  69. package/web/chunk-1y387f45.js +1 -0
  70. package/web/{chunk-mykrm8ba.js → chunk-25sn840r.js} +2 -2
  71. package/web/chunk-26sp6jre.js +1 -0
  72. package/web/{chunk-wpxtkxjt.js → chunk-2c7kxr4v.js} +2 -2
  73. package/web/{chunk-et1rsgmp.js → chunk-2gsf89vs.js} +2 -2
  74. package/web/{chunk-jpem3qvs.js → chunk-2gvz70wr.js} +5 -5
  75. package/web/chunk-2s3my1jn.js +1 -0
  76. package/web/{chunk-yn4t5s9r.js → chunk-32dh0hft.js} +1 -1
  77. package/web/{chunk-5cwxhhae.js → chunk-3haw3wcw.js} +2 -2
  78. package/web/{chunk-t82sngk9.js → chunk-3rxhs9qm.js} +7 -7
  79. package/web/chunk-410qdvmv.js +1 -0
  80. package/web/chunk-4qehf2xx.js +2 -0
  81. package/web/{chunk-b9jry5a3.js → chunk-51b8n5e1.js} +1 -1
  82. package/web/{chunk-xe121vg7.js → chunk-54mgncq3.js} +1 -1
  83. package/web/{chunk-ze6azq7z.js → chunk-59g6rrew.js} +4 -4
  84. package/web/{chunk-h6k1x096.js → chunk-5d9veaef.js} +2 -2
  85. package/web/chunk-6481wt3t.js +1 -0
  86. package/web/chunk-6ehecat3.js +1 -0
  87. package/web/chunk-6m8hq6ph.js +1 -0
  88. package/web/chunk-73941p08.js +1 -0
  89. package/web/{chunk-0jbf73pr.js → chunk-783s8jds.js} +3 -3
  90. package/web/{chunk-qbmtah1x.js → chunk-78m018ya.js} +1 -1
  91. package/web/{chunk-3p9w8sg5.js → chunk-797bh7z6.js} +3 -3
  92. package/web/{chunk-1xm9x7d6.js → chunk-7hpqrfgg.js} +2 -2
  93. package/web/{chunk-zxrbbbtp.js → chunk-7kywe73f.js} +2 -2
  94. package/web/chunk-7qq1ypvj.js +1 -0
  95. package/web/{chunk-awkdw9rw.js → chunk-7wzszsf5.js} +2 -2
  96. package/web/{chunk-c57f714b.js → chunk-7zfqppsx.js} +2 -2
  97. package/web/{chunk-jh33m2mq.js → chunk-8sr9w61v.js} +3 -3
  98. package/web/{chunk-4py9sndw.js → chunk-8ttp8fh3.js} +6 -6
  99. package/web/chunk-8zg89764.js +1 -0
  100. package/web/{chunk-ct7z7bea.js → chunk-988e9wx6.js} +3 -3
  101. package/web/{chunk-vk7ch6fh.js → chunk-9h0f3gar.js} +2 -2
  102. package/web/{chunk-p6e2vr51.js → chunk-9vr6hpmk.js} +6 -6
  103. package/web/chunk-9vrp249f.js +2 -0
  104. package/web/{chunk-eqxy6535.js → chunk-a205cj09.js} +2 -2
  105. package/web/{chunk-980zhtht.js → chunk-ahn2frbt.js} +1 -1
  106. package/web/{chunk-xvm66b7v.js → chunk-aknsydan.js} +4 -4
  107. package/web/chunk-at0xtfhy.js +1 -0
  108. package/web/chunk-bahccwb9.js +1 -0
  109. package/web/{chunk-w4tfad6c.js → chunk-c7fqrs8j.js} +1 -1
  110. package/web/{chunk-zqcg6frm.js → chunk-d3hyf9yd.js} +1 -1
  111. package/web/chunk-dcegr80c.js +1 -0
  112. package/web/{chunk-v4cqc9f9.js → chunk-dwtatme7.js} +1 -1
  113. package/web/{chunk-cr04125j.js → chunk-ex8rmqn1.js} +12 -12
  114. package/web/{chunk-jh3k7xex.js → chunk-faskbfjf.js} +3 -3
  115. package/web/{chunk-zb61mf0a.js → chunk-feanedhx.js} +1 -1
  116. package/web/{chunk-xk1vkcj4.js → chunk-ffywf5w5.js} +4 -4
  117. package/web/chunk-fx3d48e6.js +1 -0
  118. package/web/{chunk-3jjksgze.js → chunk-g3szt4c4.js} +1 -1
  119. package/web/chunk-g7bcntpm.js +1 -0
  120. package/web/chunk-gr1tjqbd.js +1 -0
  121. package/web/{chunk-2sef2wft.js → chunk-hbwxtbq3.js} +2 -2
  122. package/web/{chunk-6e87m0nm.js → chunk-hdtvrh0f.js} +2 -2
  123. package/web/chunk-j031r08w.js +1 -0
  124. package/web/{chunk-5ym5ffd5.js → chunk-j6wcszxq.js} +2 -2
  125. package/web/{chunk-jccz14ye.js → chunk-jdx7qp2w.js} +2 -2
  126. package/web/chunk-jge7nn3s.js +1 -0
  127. package/web/chunk-jy8zat04.js +1 -0
  128. package/web/{chunk-0rhx7qb8.js → chunk-jzge034r.js} +1 -1
  129. package/web/{chunk-qq6m2my8.js → chunk-k4qrqmdk.js} +2 -2
  130. package/web/chunk-k8s7kye3.js +1 -0
  131. package/web/{chunk-ke8dffnk.js → chunk-k9fyqrhp.js} +2 -2
  132. package/web/chunk-k9zn1n6d.js +1 -0
  133. package/web/chunk-kg3tksv7.js +1 -0
  134. package/web/chunk-kk5rw81s.js +2 -0
  135. package/web/{chunk-y9waq403.js → chunk-kpmd893m.js} +2 -2
  136. package/web/chunk-md9j949p.js +1 -0
  137. package/web/{chunk-e57h40qa.js → chunk-mn2wv9ye.js} +2 -2
  138. package/web/{chunk-14vmr99v.js → chunk-mv7jgmnb.js} +3 -3
  139. package/web/{chunk-qq06x2ce.js → chunk-mvm68qtt.js} +2 -2
  140. package/web/chunk-nbcpbqq4.js +1 -0
  141. package/web/{chunk-6rsr2cyw.js → chunk-nfpff7yf.js} +8 -8
  142. package/web/chunk-nk7jkpam.js +1 -0
  143. package/web/chunk-nmvt1rn3.js +1 -0
  144. package/web/{chunk-3ctmehg4.js → chunk-npw1s1h2.js} +1 -1
  145. package/web/chunk-nzzxv84v.js +8 -0
  146. package/web/{chunk-a9er7a7c.js → chunk-p4pqtybm.js} +19 -19
  147. package/web/{chunk-ba9qy65y.js → chunk-p79c7aak.js} +1 -1
  148. package/web/{chunk-frnh4zqf.js → chunk-pafw34vg.js} +2 -2
  149. package/web/{chunk-ct90yf8z.js → chunk-pf65cank.js} +2 -2
  150. package/web/{chunk-g0be12na.js → chunk-ppa21760.js} +1 -1
  151. package/web/{chunk-g7hqafb8.js → chunk-ptpkv0te.js} +1 -1
  152. package/web/{chunk-ddg8rz82.js → chunk-qcdej581.js} +1 -1
  153. package/web/{chunk-xxmaqj1m.js → chunk-qftcdcps.js} +2 -2
  154. package/web/{chunk-eqndhs21.js → chunk-qv1w36ja.js} +2 -2
  155. package/web/{chunk-mnf4ngj9.js → chunk-r8p741qj.js} +2 -2
  156. package/web/chunk-rcexbkjj.js +1 -0
  157. package/web/{chunk-w28dn4dw.js → chunk-rjakb64x.js} +1 -1
  158. package/web/{chunk-k0cg4n2k.js → chunk-s0xy00v5.js} +2 -2
  159. package/web/{chunk-cr05dttm.js → chunk-s2ps0ct5.js} +1 -1
  160. package/web/{chunk-xcyqd7cn.js → chunk-s45g7fp6.js} +1 -1
  161. package/web/{chunk-h1k2kqbs.js → chunk-s70aj1v5.js} +4 -4
  162. package/web/chunk-say8bvkc.js +1 -0
  163. package/web/{chunk-qh62nkem.js → chunk-sd3cdqcm.js} +2 -2
  164. package/web/{chunk-a6g3nqp0.js → chunk-sgkevxdf.js} +2 -2
  165. package/web/chunk-sjffrcq9.js +1 -0
  166. package/web/{chunk-2y1avvqj.js → chunk-snaepr87.js} +3 -3
  167. package/web/{chunk-p7pa02k9.js → chunk-tdzh6nsz.js} +2 -2
  168. package/web/{chunk-ga07tv37.js → chunk-tjd8qp87.js} +1 -1
  169. package/web/chunk-tncc9e57.js +1 -0
  170. package/web/{chunk-ve8gy05p.js → chunk-ty2rmwda.js} +92 -92
  171. package/web/chunk-v22hp18w.js +1 -0
  172. package/web/{chunk-zh7193nq.js → chunk-ve9dz857.js} +2 -2
  173. package/web/{chunk-s935z8er.js → chunk-vg346gxc.js} +2 -2
  174. package/web/{chunk-b4gcpsbg.js → chunk-vpegzgzb.js} +5 -5
  175. package/web/{chunk-pzg25qqe.js → chunk-vvvd3grf.js} +2 -2
  176. package/web/{chunk-ss96cz1f.js → chunk-vwv6pqy7.js} +1 -1
  177. package/web/{chunk-sq75q603.js → chunk-vxm7n7w6.js} +6 -6
  178. package/web/{chunk-qb8mbptk.js → chunk-w5q7978e.js} +1 -1
  179. package/web/{chunk-97t3ngqf.js → chunk-we4mhfmq.js} +7 -7
  180. package/web/{chunk-20jxvmbw.js → chunk-wfgrdabk.js} +1 -1
  181. package/web/{chunk-3wpxymxa.js → chunk-wkhj4hsw.js} +3 -3
  182. package/web/{chunk-q4vy3dkk.js → chunk-wspk8qbg.js} +2 -2
  183. package/web/{chunk-9wz8jne3.js → chunk-xf1hnpme.js} +1 -1
  184. package/web/{chunk-fnvgdvrg.js → chunk-xhqvzmfj.js} +4 -4
  185. package/web/chunk-xq70hgre.js +1 -0
  186. package/web/chunk-xtss82z2.js +1 -0
  187. package/web/{chunk-8j4tzff5.js → chunk-y3tb6410.js} +3 -3
  188. package/web/{chunk-mkxeenph.js → chunk-y6mcxfm0.js} +1 -1
  189. package/web/{chunk-0rvwj2wh.js → chunk-ya696bfe.js} +2 -2
  190. package/web/{chunk-2x7vmhm0.js → chunk-ysw5fs45.js} +3 -3
  191. package/web/{chunk-atppv8fk.js → chunk-zkq1xknc.js} +1 -1
  192. package/web/chunk-zkv025s5.js +1 -0
  193. package/web/{chunk-dmha2y9c.js → chunk-zpzvz973.js} +18 -18
  194. package/web/{chunk-c6m4vfn5.js → chunk-zsat72qd.js} +68 -68
  195. package/web/{chunk-9k7fkx80.js → chunk-zx3h7v72.js} +1 -1
  196. package/web/index.html +1 -1
  197. package/chunk-1dbfmejf.js +0 -2
  198. package/chunk-4w9zqv0k.js +0 -2
  199. package/chunk-6f4ht2hw.js +0 -2
  200. package/chunk-edbq461k.js +0 -5
  201. package/chunk-m71pj3g1.js +0 -2
  202. package/chunk-n22vd4at.js +0 -2
  203. package/chunk-sgrrxsnz.js +0 -482
  204. package/chunk-ydzag81d.js +0 -3
  205. package/web/chunk-12qf1r6m.js +0 -1
  206. package/web/chunk-1m6fx2h7.js +0 -2
  207. package/web/chunk-2n5xbnrt.js +0 -1
  208. package/web/chunk-36s08nye.js +0 -1
  209. package/web/chunk-4swea9sn.js +0 -1
  210. package/web/chunk-4zz5a483.js +0 -1
  211. package/web/chunk-6y55gk1n.js +0 -1
  212. package/web/chunk-7aep7k4v.js +0 -1
  213. package/web/chunk-8tgavnwx.js +0 -1
  214. package/web/chunk-a00vg115.js +0 -1
  215. package/web/chunk-a4gbxnm3.js +0 -1
  216. package/web/chunk-bq6mep6p.js +0 -2
  217. package/web/chunk-bwy3e58v.js +0 -1
  218. package/web/chunk-de29pe57.js +0 -1
  219. package/web/chunk-eeesa5q1.js +0 -1
  220. package/web/chunk-f7jpakwh.js +0 -1
  221. package/web/chunk-fp62avjh.js +0 -1
  222. package/web/chunk-gr163fex.js +0 -1
  223. package/web/chunk-gx340asc.js +0 -1
  224. package/web/chunk-gxtz10wf.js +0 -1
  225. package/web/chunk-k9qnvx86.js +0 -2
  226. package/web/chunk-kcnj0gan.js +0 -1
  227. package/web/chunk-kpp5xqsb.js +0 -1
  228. package/web/chunk-m33yted6.js +0 -1
  229. package/web/chunk-me5jqqn6.js +0 -1
  230. package/web/chunk-mzqqwbmr.js +0 -1
  231. package/web/chunk-mzzaet63.js +0 -1
  232. package/web/chunk-q34as3v6.js +0 -1
  233. package/web/chunk-q6c8p73w.js +0 -1
  234. package/web/chunk-qn93we3a.js +0 -1
  235. package/web/chunk-r1f1egve.js +0 -1
  236. package/web/chunk-tt9410zw.js +0 -8
  237. package/web/chunk-vg1ebkce.js +0 -1
  238. package/web/chunk-vnt34mkb.js +0 -1
  239. package/web/chunk-xh4xn1az.js +0 -1
  240. package/web/chunk-xrk5ewsn.js +0 -1
  241. package/web/chunk-xzwxcxb4.js +0 -1
  242. package/web/chunk-ydhnkws0.js +0 -1
  243. package/web/chunk-ys2tns0p.js +0 -1
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{Te,U}from"./chunk-0nedq669.js";import{St,Fe,_e,Z,x,ee,z}from"./chunk-0a7ft50x.js";import{r}from"./chunk-ydzag81d.js";var oi=r(function(Is){var{hasOwn:ie,fromUtf8:pr,fromHex:ys,toHex:te,toUint8Array:we,isArrayBuffer:Ss}=ee(),{normalizeProvider:yr}=Z(),{escapeUri:je,HttpRequest:xr}=z();class Er{format(e){let t=[];for(let o in e){if(!ie(e,o))continue;let i=pr(o);t.push(Uint8Array.from([i.byteLength]),i,this.formatHeaderValue(e[o]))}let n=new Uint8Array(t.reduce((o,i)=>o+i.byteLength,0)),s=0;for(let o of t)n.set(o,s),s+=o.byteLength;return n}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 n=new DataView(new ArrayBuffer(5));return n.setUint8(0,4),n.setInt32(1,e.value,!1),new Uint8Array(n.buffer);case"long":let s=new Uint8Array(9);return s[0]=5,s.set(e.value.bytes,1),s;case"binary":let o=new DataView(new ArrayBuffer(3+e.value.byteLength));o.setUint8(0,6),o.setUint16(1,e.value.byteLength,!1);let i=new Uint8Array(o.buffer);return i.set(e.value,3),i;case"string":let c=pr(e.value),a=new DataView(new ArrayBuffer(3+c.byteLength));a.setUint8(0,7),a.setUint16(1,c.byteLength,!1);let f=new Uint8Array(a.buffer);return f.set(c,3),f;case"timestamp":let u=new Uint8Array(9);return u[0]=8,u.set(yt.fromNumber(e.value.valueOf()).bytes,1),u;case"uuid":if(!ws.test(e.value))throw Error(`Invalid UUID received: ${e.value}`);let h=new Uint8Array(17);return h[0]=9,h.set(ys(e.value.replace(/-/g,"")),1),h}}}var Sr;(function(e){e[e.boolTrue=0]="boolTrue",e[e.boolFalse=1]="boolFalse",e[e.byte=2]="byte",e[e.short=3]="short",e[e.integer=4]="integer",e[e.long=5]="long",e[e.byteArray=6]="byteArray",e[e.string=7]="string",e[e.timestamp=8]="timestamp",e[e.uuid=9]="uuid"})(Sr||(Sr={}));var ws=/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/;class yt{bytes;constructor(e){if(this.bytes=e,e.byteLength!==8)throw Error("Int64 buffers must be exactly 8 bytes")}static fromNumber(e){if(e>9223372036854776000||e<-9223372036854776000)throw Error(`${e} is too large (or, if negative, too small) to represent as an Int64`);let t=new Uint8Array(8);for(let n=7,s=Math.abs(Math.round(e));n>-1&&s>0;n--,s/=256)t[n]=s;if(e<0)wr(t);return new yt(t)}valueOf(){let e=this.bytes.slice(0),t=e[0]&128;if(t)wr(e);return parseInt(te(e),16)*(t?-1:1)}toString(){return String(this.valueOf())}}function wr(e){for(let t=0;t<8;t++)e[t]^=255;for(let t=7;t>-1;t--)if(e[t]++,e[t]!==0)break}var Nr="X-Amz-Algorithm",_r="X-Amz-Credential",wt="X-Amz-Date",Cr="X-Amz-SignedHeaders",Ar="X-Amz-Expires",bt="X-Amz-Signature",xt="X-Amz-Security-Token",bs="X-Amz-Region-Set",Et="authorization",Nt=wt.toLowerCase(),Tr="date",Ir=[Et,Nt,Tr],kr=bt.toLowerCase(),Ve="x-amz-content-sha256",Rr=xt.toLowerCase(),xs="host",Mr={authorization:!0,"cache-control":!0,connection:!0,expect:!0,from:!0,"keep-alive":!0,"max-forwards":!0,pragma:!0,referer:!0,te:!0,trailer:!0,"transfer-encoding":!0,upgrade:!0,"user-agent":!0,"x-amzn-trace-id":!0},Br=/^proxy-/,Ur=/^sec-/,Es=[/^proxy-/i,/^sec-/i],ze="AWS4-HMAC-SHA256",Ns="AWS4-ECDSA-P256-SHA256",Dr="AWS4-HMAC-SHA256-PAYLOAD",jr="UNSIGNED-PAYLOAD",zr=50,_t="aws4_request",Or=604800,Lr=({query:e={}})=>{let t=[],n={};for(let s in e){if(!ie(e,s))continue;if(s.toLowerCase()===kr)continue;let o=je(s);t.push(o);let i=e[s];if(typeof i==="string")n[o]=`${o}=${je(i)}`;else if(Array.isArray(i))n[o]=i.slice(0).reduce((c,a)=>c.concat([`${o}=${je(a)}`]),[]).sort().join("&")}return t.sort().map((s)=>n[s]).filter((s)=>s).join("&")},_s=(e)=>Cs(e).toISOString().replace(/\.\d{3}Z$/,"Z"),Cs=(e)=>{if(typeof e==="number")return new Date(e*1000);if(typeof e==="string"){if(Number(e))return new Date(Number(e)*1000);return new Date(e)}return e};class Ct{service;regionProvider;credentialProvider;sha256;uriEscapePath;applyChecksum;constructor({applyChecksum:e,credentials:t,region:n,service:s,sha256:o,uriEscapePath:i=!0}){this.service=s,this.sha256=o,this.uriEscapePath=i,this.applyChecksum=typeof e==="boolean"?e:!0,this.regionProvider=yr(n),this.credentialProvider=yr(t)}createCanonicalRequest(e,t,n){let s=Object.keys(t).sort();return`${e.method}
2
+ import{Pe,B}from"./chunk-mh4bjtfs.js";import{St,Fe,_e,Z,v,ee,z}from"./chunk-cs91rmbf.js";import{r}from"./chunk-qd2enpr2.js";var oi=r(function(Is){var{hasOwn:ie,fromUtf8:pr,fromHex:ys,toHex:te,toUint8Array:we,isArrayBuffer:Ss}=ee(),{normalizeProvider:yr}=Z(),{escapeUri:De,HttpRequest:xr}=z();class Er{format(e){let t=[];for(let o in e){if(!ie(e,o))continue;let i=pr(o);t.push(Uint8Array.from([i.byteLength]),i,this.formatHeaderValue(e[o]))}let n=new Uint8Array(t.reduce((o,i)=>o+i.byteLength,0)),s=0;for(let o of t)n.set(o,s),s+=o.byteLength;return n}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 n=new DataView(new ArrayBuffer(5));return n.setUint8(0,4),n.setInt32(1,e.value,!1),new Uint8Array(n.buffer);case"long":let s=new Uint8Array(9);return s[0]=5,s.set(e.value.bytes,1),s;case"binary":let o=new DataView(new ArrayBuffer(3+e.value.byteLength));o.setUint8(0,6),o.setUint16(1,e.value.byteLength,!1);let i=new Uint8Array(o.buffer);return i.set(e.value,3),i;case"string":let c=pr(e.value),a=new DataView(new ArrayBuffer(3+c.byteLength));a.setUint8(0,7),a.setUint16(1,c.byteLength,!1);let f=new Uint8Array(a.buffer);return f.set(c,3),f;case"timestamp":let u=new Uint8Array(9);return u[0]=8,u.set(yt.fromNumber(e.value.valueOf()).bytes,1),u;case"uuid":if(!ws.test(e.value))throw Error(`Invalid UUID received: ${e.value}`);let h=new Uint8Array(17);return h[0]=9,h.set(ys(e.value.replace(/-/g,"")),1),h}}}var Sr;(function(e){e[e.boolTrue=0]="boolTrue",e[e.boolFalse=1]="boolFalse",e[e.byte=2]="byte",e[e.short=3]="short",e[e.integer=4]="integer",e[e.long=5]="long",e[e.byteArray=6]="byteArray",e[e.string=7]="string",e[e.timestamp=8]="timestamp",e[e.uuid=9]="uuid"})(Sr||(Sr={}));var ws=/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/;class yt{bytes;constructor(e){if(this.bytes=e,e.byteLength!==8)throw Error("Int64 buffers must be exactly 8 bytes")}static fromNumber(e){if(e>9223372036854776000||e<-9223372036854776000)throw Error(`${e} is too large (or, if negative, too small) to represent as an Int64`);let t=new Uint8Array(8);for(let n=7,s=Math.abs(Math.round(e));n>-1&&s>0;n--,s/=256)t[n]=s;if(e<0)wr(t);return new yt(t)}valueOf(){let e=this.bytes.slice(0),t=e[0]&128;if(t)wr(e);return parseInt(te(e),16)*(t?-1:1)}toString(){return String(this.valueOf())}}function wr(e){for(let t=0;t<8;t++)e[t]^=255;for(let t=7;t>-1;t--)if(e[t]++,e[t]!==0)break}var Nr="X-Amz-Algorithm",_r="X-Amz-Credential",wt="X-Amz-Date",Cr="X-Amz-SignedHeaders",Ar="X-Amz-Expires",bt="X-Amz-Signature",xt="X-Amz-Security-Token",bs="X-Amz-Region-Set",Et="authorization",Nt=wt.toLowerCase(),Tr="date",Ir=[Et,Nt,Tr],kr=bt.toLowerCase(),$e="x-amz-content-sha256",Rr=xt.toLowerCase(),xs="host",Mr={authorization:!0,"cache-control":!0,connection:!0,expect:!0,from:!0,"keep-alive":!0,"max-forwards":!0,pragma:!0,referer:!0,te:!0,trailer:!0,"transfer-encoding":!0,upgrade:!0,"user-agent":!0,"x-amzn-trace-id":!0},Br=/^proxy-/,Ur=/^sec-/,Es=[/^proxy-/i,/^sec-/i],je="AWS4-HMAC-SHA256",Ns="AWS4-ECDSA-P256-SHA256",Dr="AWS4-HMAC-SHA256-PAYLOAD",jr="UNSIGNED-PAYLOAD",zr=50,_t="aws4_request",Or=604800,Lr=({query:e={}})=>{let t=[],n={};for(let s in e){if(!ie(e,s))continue;if(s.toLowerCase()===kr)continue;let o=De(s);t.push(o);let i=e[s];if(typeof i==="string")n[o]=`${o}=${De(i)}`;else if(Array.isArray(i))n[o]=i.slice(0).reduce((c,a)=>c.concat([`${o}=${De(a)}`]),[]).sort().join("&")}return t.sort().map((s)=>n[s]).filter((s)=>s).join("&")},_s=(e)=>Cs(e).toISOString().replace(/\.\d{3}Z$/,"Z"),Cs=(e)=>{if(typeof e==="number")return new Date(e*1000);if(typeof e==="string"){if(Number(e))return new Date(Number(e)*1000);return new Date(e)}return e};class Ct{service;regionProvider;credentialProvider;sha256;uriEscapePath;applyChecksum;constructor({applyChecksum:e,credentials:t,region:n,service:s,sha256:o,uriEscapePath:i=!0}){this.service=s,this.sha256=o,this.uriEscapePath=i,this.applyChecksum=typeof e==="boolean"?e:!0,this.regionProvider=yr(n),this.credentialProvider=yr(t)}createCanonicalRequest(e,t,n){let s=Object.keys(t).sort();return`${e.method}
3
3
  ${this.getCanonicalPath(e)}
4
4
  ${Lr(e)}
5
5
  ${s.map((o)=>`${o}:${t[o]}`).join(`
@@ -9,12 +9,12 @@ ${s.join(";")}
9
9
  ${n}`}async createStringToSign(e,t,n,s){let o=new this.sha256;o.update(we(n));let i=await o.digest();return`${s}
10
10
  ${e}
11
11
  ${t}
12
- ${te(i)}`}getCanonicalPath({path:e}){if(this.uriEscapePath){let t=[];for(let o of e.split("/")){if(o?.length===0)continue;if(o===".")continue;if(o==="..")t.pop();else t.push(o)}let n=`${e?.startsWith("/")?"/":""}${t.join("/")}${t.length>0&&e?.endsWith("/")?"/":""}`;return je(n).replace(/%2F/g,"/")}return e}validateResolvedCredentials(e){if(typeof e!=="object"||typeof e.accessKeyId!=="string"||typeof e.secretAccessKey!=="string")throw Error("Resolved credential object is not valid")}formatDate(e){let t=_s(e).replace(/[-:]/g,"");return{longDate:t,shortDate:t.slice(0,8)}}getCanonicalHeaderList(e){return Object.keys(e).sort().join(";")}}var se={},Oe=[],Le=(e,t,n)=>`${e}/${t}/${n}/${_t}`,$r=async(e,t,n,s,o)=>{let i=await br(e,t.secretAccessKey,t.accessKeyId),c=`${n}:${s}:${o}:${te(i)}:${t.sessionToken}`;if(c in se)return se[c];Oe.push(c);while(Oe.length>zr)delete se[Oe.shift()];let a=`AWS4${t.secretAccessKey}`;for(let f of[n,s,o,_t])a=await br(e,a,f);return se[c]=a},As=()=>{Oe.length=0,Object.keys(se).forEach((e)=>{delete se[e]})},br=(e,t,n)=>{let s=new e(t);return s.update(we(n)),s.digest()},gt=({headers:e},t,n)=>{let s={};for(let o of Object.keys(e).sort()){if(e[o]==null)continue;let i=o.toLowerCase();if(i in Mr||t?.has(i)||Br.test(i)||Ur.test(i)){if(!n||n&&!n.has(i))continue}s[i]=e[o].replace(/[\r\n]/g," ").replace(/[ \t]+/g," ").replace(/^ | $/g,"")}return s},$e=async({headers:e,body:t},n)=>{for(let s in e){if(!ie(e,s))continue;if(s.toLowerCase()===Ve)return e[s]}if(t==null)return"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855";else if(typeof t==="string"||ArrayBuffer.isView(t)||Ss(t)){let s=new n;return s.update(we(t)),te(await s.digest())}return jr},Vr=(e,t)=>{e=e.toLowerCase();for(let n in t){if(!ie(t,n))continue;if(e===n.toLowerCase())return!0}return!1},Fr=(e,t={})=>{let{headers:n,query:s={}}=xr.clone(e);for(let o in n){if(!ie(n,o))continue;let i=o.toLowerCase();if(i.slice(0,6)==="x-amz-"&&!t.unhoistableHeaders?.has(i)||t.hoistableHeaders?.has(i))s[o]=n[o],delete n[o]}return{...e,headers:n,query:s}},pt=(e)=>{e=xr.clone(e);for(let t in e.headers){if(!ie(e.headers,t))continue;if(Ir.indexOf(t.toLowerCase())>-1)delete e.headers[t]}return e};class Pr extends Ct{headerFormatter=new Er;constructor({applyChecksum:e,credentials:t,region:n,service:s,sha256:o,uriEscapePath:i=!0}){super({applyChecksum:e,credentials:t,region:n,service:s,sha256:o,uriEscapePath:i})}async presign(e,t={}){let{signingDate:n=new Date,expiresIn:s=3600,unsignableHeaders:o,unhoistableHeaders:i,signableHeaders:c,hoistableHeaders:a,signingRegion:f,signingService:u}=t,h=await this.credentialProvider();this.validateResolvedCredentials(h);let l=f??await this.regionProvider(),{longDate:d,shortDate:m}=this.formatDate(n);if(s>Or)return Promise.reject("Signature version 4 presigned URLs must have an expiration date less than one week in the future");let y=Le(m,l,u??this.service),g=Fr(pt(e),{unhoistableHeaders:i,hoistableHeaders:a});if(h.sessionToken)g.query[xt]=h.sessionToken;g.query[Nr]=ze,g.query[_r]=`${h.accessKeyId}/${y}`,g.query[wt]=d,g.query[Ar]=s.toString(10);let N=gt(g,o,c);return g.query[Cr]=this.getCanonicalHeaderList(N),g.query[bt]=await this.getSignature(d,y,this.getSigningKey(h,l,m,u),this.createCanonicalRequest(g,N,await $e(e,this.sha256))),g}async sign(e,t){if(typeof e==="string")return this.signString(e,t);else if(e.headers&&e.payload)return this.signEvent(e,t);else if(e.message)return this.signMessage(e,t);else return this.signRequest(e,t)}async signEvent({headers:e,payload:t},{signingDate:n=new Date,priorSignature:s,signingRegion:o,signingService:i,eventStreamCredentials:c}){let a=o??await this.regionProvider(),{shortDate:f,longDate:u}=this.formatDate(n),h=Le(f,a,i??this.service),l=await $e({headers:{},body:t},this.sha256),d=new this.sha256;d.update(e);let m=te(await d.digest()),y=[Dr,u,h,s,m,l].join(`
13
- `);return this.signString(y,{signingDate:n,signingRegion:a,signingService:i,eventStreamCredentials:c})}async signMessage(e,{signingDate:t=new Date,signingRegion:n,signingService:s,eventStreamCredentials:o}){return this.signEvent({headers:this.headerFormatter.format(e.message.headers),payload:e.message.body},{signingDate:t,signingRegion:n,signingService:s,priorSignature:e.priorSignature,eventStreamCredentials:o}).then((c)=>({message:e.message,signature:c}))}async signString(e,{signingDate:t=new Date,signingRegion:n,signingService:s,eventStreamCredentials:o}={}){let i=o??await this.credentialProvider();this.validateResolvedCredentials(i);let c=n??await this.regionProvider(),{shortDate:a}=this.formatDate(t),f=new this.sha256(await this.getSigningKey(i,c,a,s));return f.update(we(e)),te(await f.digest())}async signRequest(e,{signingDate:t=new Date,signableHeaders:n,unsignableHeaders:s,signingRegion:o,signingService:i}={}){let c=await this.credentialProvider();this.validateResolvedCredentials(c);let a=o??await this.regionProvider(),f=pt(e),{longDate:u,shortDate:h}=this.formatDate(t),l=Le(h,a,i??this.service);if(f.headers[Nt]=u,c.sessionToken)f.headers[Rr]=c.sessionToken;let d=await $e(f,this.sha256);if(!Vr(Ve,f.headers)&&this.applyChecksum)f.headers[Ve]=d;let m=gt(f,s,n),y=await this.getSignature(u,l,this.getSigningKey(c,a,h,i),this.createCanonicalRequest(f,m,d));return f.headers[Et]=`${ze} Credential=${c.accessKeyId}/${l}, SignedHeaders=${this.getCanonicalHeaderList(m)}, Signature=${y}`,f}async getSignature(e,t,n,s){let o=await this.createStringToSign(e,t,s,ze),i=new this.sha256(await n);return i.update(we(o)),te(await i.digest())}getSigningKey(e,t,n,s){return $r(this.sha256,e,n,t,s||this.service)}}var Ts={SignatureV4a:null};Is.ALGORITHM_IDENTIFIER=ze;Is.ALGORITHM_IDENTIFIER_V4A=Ns;Is.ALGORITHM_QUERY_PARAM=Nr;Is.ALWAYS_UNSIGNABLE_HEADERS=Mr;Is.AMZ_DATE_HEADER=Nt;Is.AMZ_DATE_QUERY_PARAM=wt;Is.AUTH_HEADER=Et;Is.CREDENTIAL_QUERY_PARAM=_r;Is.DATE_HEADER=Tr;Is.EVENT_ALGORITHM_IDENTIFIER=Dr;Is.EXPIRES_QUERY_PARAM=Ar;Is.GENERATED_HEADERS=Ir;Is.HOST_HEADER=xs;Is.KEY_TYPE_IDENTIFIER=_t;Is.MAX_CACHE_SIZE=zr;Is.MAX_PRESIGNED_TTL=Or;Is.PROXY_HEADER_PATTERN=Br;Is.REGION_SET_PARAM=bs;Is.SEC_HEADER_PATTERN=Ur;Is.SHA256_HEADER=Ve;Is.SIGNATURE_HEADER=kr;Is.SIGNATURE_QUERY_PARAM=bt;Is.SIGNED_HEADERS_QUERY_PARAM=Cr;Is.SignatureV4=Pr;Is.SignatureV4Base=Ct;Is.TOKEN_HEADER=Rr;Is.TOKEN_QUERY_PARAM=xt;Is.UNSIGNABLE_PATTERNS=Es;Is.UNSIGNED_PAYLOAD=jr;Is.clearCredentialCache=As;Is.createScope=Le;Is.getCanonicalHeaders=gt;Is.getCanonicalQuery=Lr;Is.getPayloadHash=$e;Is.getSigningKey=$r;Is.hasHeader=Vr;Is.moveHeadersToQuery=Fr;Is.prepareRequest=pt;Is.signatureV4aContainer=Ts});var He=r(function(Di){var{ProviderError:Hr,booleanSelector:Kr,SelectorType:qr,loadConfig:gi}=x(),{setCredentialFeature:pi}=U(),{normalizeProvider:oe,memoizeIdentityProvider:yi,isIdentityExpired:Si,doesIdentityRequireRefresh:wi}=Te(),{SignatureV4:Qr}=oi(),{HttpResponse:vr,HttpRequest:en}=z(),{SMITHY_CONTEXT_KEY:bi}=St(),Gr=(e)=>vr.isInstance(e)?e.headers?.date??e.headers?.Date:void 0,Wr=(e)=>vr.isInstance(e)?e.headers?.age??e.headers?.Age:void 0,tn=(e)=>new Date(Date.now()+e),Xr=(e,t,n,s)=>{if(s!==void 0)return t;let o=Date.parse(e),i=Date.now();if(n!==void 0&&i-n>900000)return t;return n!==void 0?o-(n+i)/2:o-i},be=(e,t)=>{if(!t)throw Error(`Property \`${e}\` is not resolved for AWS SDK SigV4Auth`);return t},xi=(e)=>e.context?.[bi]?.eventStream?.output===!0,At=async(e)=>{let t=be("context",e.context),n=be("config",e.config),s=t.endpointV2?.properties?.authSchemes?.[0],i=await be("signer",n.signer)(s),c=e?.signingRegion,a=e?.signingRegionSet,f=e?.signingName;return{config:n,signer:i,signingRegion:c,signingRegionSet:a,signingName:f}};class Pe{async sign(e,t,n){if(!en.isInstance(e))throw Error("The request is not an instance of `HttpRequest` and cannot be signed");let s=await At(n),{config:o,signer:i}=s,{signingRegion:c,signingName:a}=s,f=n.context;if(f?.authSchemes?.length??!1){let[d,m]=f.authSchemes;if(d?.name==="sigv4a"&&m?.name==="sigv4")c=m?.signingRegion??c,a=m?.signingName??a}let u=await o.disableClockSkewCorrection?.()===!0;n._disableClockSkewCorrection=u;let h=u||xi(n);if(n._skipClockSkewSampling=h,!h)n._preRequestSystemClockOffset=o.systemClockOffset,n._requestSentAt=Date.now();return await i.sign(e,{signingDate:u?new Date:tn(o.systemClockOffset),signingRegion:c,signingService:a})}errorHandler(e){return(t)=>{let n=t;if(!e._skipClockSkewSampling&&!e._disableClockSkewCorrection){let s=n.ServerTime??Gr(n.$response);if(s){let o=be("config",e.config),{_preRequestSystemClockOffset:i,_requestSentAt:c}=e,a=Wr(n.$response),f=Xr(s,o.systemClockOffset,c,a);if(o.systemClockOffset=f,Math.abs(f)>=240000&&(f!==i||i!==void 0&&i!==f)&&n.$metadata)n.$metadata.clockSkewCorrected=!0}}throw t}}successHandler(e,t){if(t._skipClockSkewSampling||t._disableClockSkewCorrection)return;let n=Gr(e);if(n){let s=be("config",t.config),o=t._requestSentAt,i=Wr(e);s.systemClockOffset=Xr(n,s.systemClockOffset,o,i)}}}var Ei=Pe;class rn extends Pe{async sign(e,t,n){if(!en.isInstance(e))throw Error("The request is not an instance of `HttpRequest` and cannot be signed");let{config:s,signer:o,signingRegion:i,signingRegionSet:c,signingName:a}=await At(n),u=(await s.sigv4aSigningRegionSet?.()??c??[i]).join(","),h=await s.disableClockSkewCorrection?.()===!0;if(n._disableClockSkewCorrection=h,!h)n._preRequestSystemClockOffset=s.systemClockOffset,n._requestSentAt=Date.now();return await o.sign(e,{signingDate:h?new Date:tn(s.systemClockOffset),signingRegion:u,signingService:a})}}var Jr=(e)=>typeof e==="string"&&e.length>0?e.split(",").map((t)=>t.trim()):[],nn=(e)=>`AWS_BEARER_TOKEN_${e.replace(/[\s-]/g,"_").toUpperCase()}`,Zr="AWS_AUTH_SCHEME_PREFERENCE",Yr="auth_scheme_preference",Ni={environmentVariableSelector:(e,t)=>{if(t?.signingName){if(nn(t.signingName)in e)return["httpBearerAuth"]}if(!(Zr in e))return;return Jr(e[Zr])},configFileSelector:(e)=>{if(!(Yr in e))return;return Jr(e[Yr])},default:[]},_i=(e)=>(e.sigv4aSigningRegionSet=oe(e.sigv4aSigningRegionSet),e),Ci={environmentVariableSelector(e){if(e.AWS_SIGV4A_SIGNING_REGION_SET)return e.AWS_SIGV4A_SIGNING_REGION_SET.split(",").map((t)=>t.trim());throw new Hr("AWS_SIGV4A_SIGNING_REGION_SET not set in env.",{tryNextLink:!0})},configFileSelector(e){if(e.sigv4a_signing_region_set)return(e.sigv4a_signing_region_set??"").split(",").map((t)=>t.trim());throw new Hr("sigv4a_signing_region_set not set in profile.",{tryNextLink:!0})},default:void 0},Ai=(e)=>(t)=>{let n=t.credentials,s=!!t.credentials,o=void 0;Object.defineProperty(t,"credentials",{set(h){if(h&&h!==n&&h!==o)s=!0;n=h;let l=Ti(t,{credentials:n,credentialDefaultProvider:t.credentialDefaultProvider}),d=Ii(t,l);if(s&&!d.attributed){let m=typeof n==="object"&&n!==null;o=async(y)=>{let N=await d(y);if(m&&(!N.$source||Object.keys(N.$source).length===0))return pi(N,"CREDENTIALS_CODE","e");return N},o.memoized=d.memoized,o.configBound=d.configBound,o.attributed=!0}else o=d},get(){return o},enumerable:!0,configurable:!0}),t.credentials=n;let{signingEscapePath:i=!0,systemClockOffset:c=t.systemClockOffset||0,sha256:a}=t,f;if(t.signer)f=oe(t.signer);else if(t.regionInfoProvider)f=()=>oe(t.region)().then(async(h)=>[await t.regionInfoProvider(h,{useFipsEndpoint:await t.useFipsEndpoint(),useDualstackEndpoint:await t.useDualstackEndpoint()})||{},h]).then(([h,l])=>{let{signingRegion:d,signingService:m}=h;t.signingRegion=t.signingRegion||d||l,t.signingName=t.signingName||m||t.serviceId;let y={...t,credentials:t.credentials,region:t.signingRegion,service:t.signingName,sha256:a,uriEscapePath:i};return new(t.signerConstructor||Qr)(y)});else f=async(h)=>{h=Object.assign({},{name:"sigv4",signingName:t.signingName||t.defaultSigningName,signingRegion:await oe(t.region)(),properties:{}},h);let l=h.signingRegion,d=h.signingName;t.signingRegion=t.signingRegion||l,t.signingName=t.signingName||d||t.serviceId;let m={...t,credentials:t.credentials,region:t.signingRegion,service:t.signingName,sha256:a,uriEscapePath:i};return new(t.signerConstructor||Qr)(m)};return Object.assign(t,{systemClockOffset:c,signingEscapePath:i,signer:f,disableClockSkewCorrection:oe(t.disableClockSkewCorrection??e)})};function Ti(e,{credentials:t,credentialDefaultProvider:n}){let s;if(t)if(!t?.memoized)s=yi(t,Si,wi);else s=t;else if(n)s=oe(n(Object.assign({},e,{parentClientConfig:e})));else s=async()=>{throw Error("@aws-sdk/core::resolveAwsSdkSigV4Config - `credentials` not provided and no credentialDefaultProvider was configured.")};return s.memoized=!0,s}function Ii(e,t){if(t.configBound)return t;let n=async(s)=>t({...s,callerClientConfig:e});return n.memoized=t.memoized,n.configBound=!0,n}var ki="AWS_DISABLE_CLOCK_SKEW_CORRECTION",Ri="disable_clock_skew_correction",Mi={environmentVariableSelector:(e)=>Kr(e,ki,qr.ENV),configFileSelector:(e)=>Kr(e,Ri,qr.CONFIG),default:!1},Bi=gi(Mi),sn=Ai(Bi),Ui=sn;Di.AWSSDKSigV4Signer=Ei;Di.AwsSdkSigV4ASigner=rn;Di.AwsSdkSigV4Signer=Pe;Di.NODE_AUTH_SCHEME_PREFERENCE_OPTIONS=Ni;Di.NODE_SIGV4A_CONFIG_OPTIONS=Ci;Di.getBearerTokenEnvKey=nn;Di.resolveAWSSDKSigV4Config=Ui;Di.resolveAwsSdkSigV4AConfig=_i;Di.resolveAwsSdkSigV4Config=sn;Di.validateSigningProperties=At});var Bn=r(function($o){var{nv:pn,NumericValue:Ie,calculateBodyLength:qi,generateIdempotencyToken:yn,fromBase64:Ot,_parseEpochTimestamp:Ce}=ee(),{hasOwn:D,getSmithyContext:Qi}=Fe(),{HttpRequest:Gi,collectBody:Wi,SerdeContext:ke,RpcProtocol:Xi}=z(),{NormalizedSchema:F,deref:Ji,TypeRegistry:on}=_e();function de(e){return typeof Buffer<"u"?Buffer.alloc(e):new Uint8Array(e)}var Re=Symbol("@smithy/core/cbor::tagSymbol");function Lt(e){return e[Re]=!0,e}var Sn=typeof Buffer<"u",$t=new TextDecoder,C=de(0),Vt=!1,P=new DataView(C.buffer,C.byteOffset,C.byteLength),E=0;function Zi(e){C=e,Vt=Sn&&C instanceof Buffer,P=new DataView(C.buffer,C.byteOffset,C.byteLength)}function J(e,t){if(e>=t)throw Error("unexpected end of (decode) payload.");let n=(C[e]&224)>>5,s=C[e]&31;if(s===31&&2<=n&&n<=5)return Yi(e,t);switch(n){case 0:case 1:case 6:{let o,i;if(s<24)o=s,i=1;else switch(s){case 24:if(t-e<2)q(1);o=C[e+1],i=2;break;case 25:if(t-e<3)q(2);o=P.getUint16(e+1),i=3;break;case 26:if(t-e<5)q(4);o=P.getUint32(e+1),i=5;break;case 27:if(t-e<9)q(8);{let c=P.getUint32(e+1);if(c<2097152)o=c*4294967296+P.getUint32(e+5);else o=P.getBigUint64(e+1)}i=9;break;default:Pt(s)}if(n===0)return E=i,Bt(o);else if(n===1){let c;if(typeof o==="bigint")c=BigInt(-1)-o;else c=-1-o;return E=i,Bt(c)}else return oo(e,t,s,o,i)}case 3:return Ae(e,t);case 5:return eo(e,t);case 4:return no(e,t);case 2:return Ft(e,t);default:return co(e,t)}}function Yi(e,t){let n=(C[e]&224)>>5;if((C[e]&31)===31)switch(n){case 3:return uo(e,t);case 5:return ao(e,t);case 4:return fo(e,t);case 2:return ho(e,t)}}function vi(e,t){let n=e>>7,s=(e&124)>>2,o=(e&3)<<8|t,i=n===0?1:-1;if(s===0){if(o===0)return 0;return i*(Math.pow(2,-14)*(o/1024))}else if(s===31){if(o===0)return i*(1/0);return NaN}return i*(Math.pow(2,s-15)*(1+o/1024))}function eo(e,t){let n=Me(e,t);if(n<25)return ro(e,t,n);return to(e,t,n)}function to(e,t,n){let s=E;e+=s;let o=e,i=Object.create(null);for(let c=0;c<n;++c){let a=Ae(e,t);if(e+=E,(C[e]&224)>>5===3)i[a]=Ae(e,t);else i[a]=J(e,t);e+=E}return E=s+(e-o),Object.setPrototypeOf(i,Object.prototype),i}function ro(e,t,n){let s=E;e+=s;let o=e,i={};for(let c=0;c<n;++c){let a=Ae(e,t);e+=E,i[a]=J(e,t),e+=E}return E=s+(e-o),i}function no(e,t){let n=Me(e,t),s=E;e+=s;let o=e,i=Array(n);for(let c=0;c<n;++c)i[c]=J(e,t),e+=E;return E=s+(e-o),i}function Ae(e,t){let n=Me(e,t),s=E;if(e+=s,t-e<n)q(n);if(E=s+n,n<24)return io(e,n);if(Vt)return C.toString("utf-8",e,e+n);return $t.decode(C.subarray(e,e+n))}var cn=Array(2048),Tt=new Uint16Array(2048),xe=0;function so(){xe=xe+1&65535}function io(e,t){let n=t;for(let c=0;c<t;++c)n=n*31+C[e+c]|0;let s=n>>>0&2047,o=cn[s];if(o!==void 0){if(o.length===t){let c=!0;for(let a=0;a<t;++a)if(o.charCodeAt(a)!==C[e+a]){c=!1;break}if(c)return Tt[s]=xe,o}}let i=Vt?C.toString("utf-8",e,e+t):$t.decode(C.subarray(e,e+t));if(Tt[s]!==xe)cn[s]=i,Tt[s]=xe;return i}function Ft(e,t){let n=Me(e,t),s=E;if(e+=s,t-e<n)q(n);let o=C.subarray(e,e+n);return E=s+n,o}function oo(e,t,n,s,o){if(n===2||n===3){let i=Me(e+o,t),c=BigInt(0),a=e+o+E;for(let f=a;f<a+i;++f)c=c<<BigInt(8)|BigInt(C[f]);return E=o+E+i,n===3?-c-BigInt(1):c}else if(n===4){let i=J(e+o,t),[c,a]=i,f=a<0?-1:1,u=BigInt(f)*BigInt(a),h=String(u),l=a<0?"-":"",d;if(typeof c==="number"&&Math.abs(c)<=268435456){let y=c,g="0".repeat(Math.abs(y)+1)+h;if(d=y===0?g:g.slice(0,g.length+y)+"."+g.slice(y),d=d.replace(/^0+/g,""),d==="")d="0";if(d[0]===".")d="0"+d;d=l+d}else{let y=BigInt(c);if(h.length===1)d=l+h+"e"+String(y);else{let g=y+BigInt(h.length-1);d=l+h[0]+"."+h.slice(1)+"e"+String(g)}}return E=o+E,pn(d)}else{let i=J(e+o,t);return E=o+E,Lt({tag:Bt(s),value:i})}}function co(e,t){let n=C[e]&31;switch(n){case 21:case 20:return E=1,n===21;case 22:return E=1,null;case 23:return E=1,null;case 25:if(t-e<3)throw Error("incomplete float16 at end of buf.");return E=3,vi(C[e+1],C[e+2]);case 26:if(t-e<5)throw Error("incomplete float32 at end of buf.");return E=5,P.getFloat32(e+1);case 27:if(t-e<9)throw Error("incomplete float64 at end of buf.");return E=9,P.getFloat64(e+1);default:Pt(n)}}function Me(e,t){let n=C[e]&31;if(n<24)return E=1,n;switch(n){case 24:if(t-e<2)q(1);return E=2,C[e+1];case 25:if(t-e<3)q(2);return E=3,P.getUint16(e+1);case 26:if(t-e<5)q(4);return E=5,P.getUint32(e+1);case 27:if(t-e<9)q(8);return E=9,lo(P.getBigUint64(e+1));default:Pt(n)}}function ao(e,t){e+=1;let n=e,s={};for(;e<t;){if(C[e]===255)return E=e-n+2,s;let o=Ae(e,t);e+=E,s[o]=J(e,t),e+=E}throw Error("expected break marker.")}function fo(e,t){e+=1;let n=[];for(let s=e;e<t;){if(C[e]===255)return E=e-s+2,n;n.push(J(e,t)),e+=E}throw Error("expected break marker.")}function uo(e,t){e+=1;let n=[];for(let s=e;e<t;){if(C[e]===255){let f=de(n.length);if(f.set(n,0),E=e-s+2,Sn)return f.toString("utf-8",0,f.length);return $t.decode(f)}let o=(C[e]&224)>>5,i=C[e]&31;if(o!==3)wn(o);if(i===31)throw Error("nested indefinite string.");let c=Ft(e,t);e+=E;for(let f=0;f<c.length;++f)n.push(c[f])}throw Error("expected break marker.")}function ho(e,t){e+=1;let n=[];for(let s=e;e<t;){if(C[e]===255){let f=de(n.length);return f.set(n,0),E=e-s+2,f}let o=(C[e]&224)>>5,i=C[e]&31;if(o!==2)wn(o);if(i===31)throw Error("nested indefinite string.");let c=Ft(e,t);e+=E;for(let f=0;f<c.length;++f)n.push(c[f])}throw Error("expected break marker.")}function Bt(e){if(typeof e==="number")return e;let t=Number(e);if(Number.MIN_SAFE_INTEGER<=t&&t<=Number.MAX_SAFE_INTEGER)return t;return e}function lo(e){let t=Number(e);if(t<Number.MIN_SAFE_INTEGER||Number.MAX_SAFE_INTEGER<t)console.warn(Error(`@smithy/core/cbor - truncating BigInt(${e}) to ${t} with loss of precision.`));return t}function q(e){throw Error(`length ${e} greater than remaining buf len.`)}function Pt(e){throw Error(`unexpected minor value ${e}.`)}function wn(e){throw Error(`unexpected major type ${e} in indefinite string.`)}var mo=typeof Buffer<"u",ce=new Map,Ee=0,Ut=!1,go=2048,w=de(go),V=new DataView(w.buffer,w.byteOffset,w.byteLength),p=0;function po(e){let t=[e];while(t.length){let n=t.pop();if(typeof n==="string"){let s=n.length;if(mo)if(ae(s*3+9),s>23)It(3,Buffer.byteLength(n)),p+=w.write(n,p);else So(n);else{let o=s*3;ae(o+9);let i=p,a=new TextEncoder().encodeInto(n,w.subarray(p+9)).written,f;if(a<24)f=1;else if(a<256)f=2;else if(a<65536)f=3;else if(a<4294967296)f=5;else f=9;if(f<9)w.copyWithin(i+f,i+9,i+9+a);p=i,re(3,a),p+=a}continue}if(w.byteLength-p<9)ae(64);if(typeof n==="number"){if(Number.isInteger(n)&&n>=-9007199254740992&&n<=9007199254740991){let s=n>=0,o=s?0:1,i=s?n:-n-1;if(i<24)w[p++]=o<<5|i;else if(i<256)w[p++]=o<<5|24,w[p++]=i;else if(i<65536)w[p++]=o<<5|25,w[p++]=i>>8,w[p++]=i&255;else if(i<4294967296)w[p++]=o<<5|26,V.setUint32(p,i),p+=4;else{w[p++]=o<<5|27;let c=i/4294967296|0,a=i-c*4294967296|0;V.setUint32(p,c),V.setUint32(p+4,a),p+=8}continue}w[p++]=251,V.setFloat64(p,n),p+=8;continue}else if(typeof n==="bigint"){let s=n>=0,o=s?0:1,i=s?n:-n-BigInt(1);if(i<BigInt("18446744073709551616")){let c=Number(i);if(c<4294967296)re(o,c);else w[p++]=o<<5|27,V.setBigUint64(p,i),p+=8}else{let c=i.toString(2),a=new Uint8Array(Math.ceil(c.length/8)),f=i,u=0;while(a.byteLength-++u>=0)a[a.byteLength-u]=Number(f&BigInt(255)),f>>=BigInt(8);ae(a.byteLength*2+16),w[p++]=s?194:195,It(2,a.byteLength),w.set(a,p),p+=a.byteLength}continue}else if(n===null){w[p++]=246;continue}else if(typeof n==="boolean"){w[p++]=224|(n?21:20);continue}else if(typeof n>"u")throw Error("@smithy/core/cbor: client may not serialize undefined value.");else if(Array.isArray(n)){re(4,n.length),ae(n.length*9+64);for(let s=n.length-1;s>=0;--s)t.push(n[s]);continue}else if(typeof n.byteLength==="number"){ae(n.length*2+9),re(2,n.length),w.set(n,p),p+=n.byteLength;continue}else if(typeof n==="object"){if(n instanceof Ie){let i=n.string,c=BigInt(0),a=i.search(/[eE]/);if(a!==-1)c=BigInt(i.slice(a+1)),i=i.slice(0,a);let f=i.indexOf("."),u=f===-1?0:i.length-f-1,h=c-BigInt(u),l=BigInt(i.replace(".",""));w[p++]=196,re(4,2),t.push(l),t.push(h>=-0x20000000000000n&&h<=0x1fffffffffffffn?Number(h):h);continue}if(n[Re])if("tag"in n&&"value"in n){t.push(n.value),It(6,n.tag);continue}else throw Error("tag encountered with missing fields, need 'tag' and 'value', found: "+JSON.stringify(n));let s=Object.keys(n),o=s.length;re(5,o);for(let i=o-1;i>=0;--i)t.push(n[s[i]]),t.push(s[i]);continue}throw Error(`data type ${n?.constructor?.name??typeof n} not compatible for encoding.`)}}function yo(){Ee=Ee+1&65535,Ut=!1}function an(){let e=de(p);return e.set(w.subarray(0,p),0),p=0,e}function Dt(e){let t=w;if(w=de(e),t)if(t.copy)t.copy(w,0,0,t.byteLength);else w.set(t,0);V=new DataView(w.buffer,w.byteOffset,w.byteLength)}function So(e){let t=ce.get(e);if(t!==void 0){w.set(t.bytes,p),p+=t.bytes.length,t.epoch=Ee;return}let n=p,s=Buffer.byteLength(e);re(3,s),p+=w.write(e,p);let o=Uint8Array.prototype.slice.call(w,n,p);if(ce.size>=2048){if(Ut)return;let i=0;for(let[c,a]of ce){if(i>=1024)break;if(a.epoch!==Ee)ce.delete(c),i++}if(i===0){Ut=!0;return}}if(ce.size<2048)ce.set(e,{epoch:Ee,bytes:o})}function ae(e){if(w.byteLength-p<e)if(p<16000000)Dt(Math.max(w.byteLength*4,w.byteLength+e));else Dt(w.byteLength+e+16000000)}function It(e,t){if(t<24)w[p++]=e<<5|t;else if(t<256)w[p++]=e<<5|24,w[p++]=t;else if(t<65536)w[p++]=e<<5|25,V.setUint16(p,t),p+=2;else if(t<4294967296)w[p++]=e<<5|26,V.setUint32(p,t),p+=4;else w[p++]=e<<5|27,V.setBigUint64(p,typeof t==="bigint"?t:BigInt(t)),p+=8}function re(e,t){if(t<24)w[p++]=e<<5|t;else if(t<256)w[p++]=e<<5|24,w[p++]=t;else if(t<65536)w[p++]=e<<5|25,w[p++]=t>>8,w[p++]=t&255;else if(t<4294967296)w[p++]=e<<5|26,V.setUint32(p,t),p+=4;else{w[p++]=e<<5|27;let n=t/4294967296|0,s=t-n*4294967296|0;V.setUint32(p,n),V.setUint32(p+4,s),p+=8}}var We={deserialize(e){return so(),Zi(e),J(0,e.length)},serialize(e){yo();try{return po(e),an()}catch(t){throw an(),t}},resizeEncodingBuffer(e){Dt(e)}},bn=(e,t)=>Wi(e,t).then(async(n)=>{if(n.length)try{return We.deserialize(n)}catch(s){throw Object.defineProperty(s,"$responseBodyText",{value:t.utf8Encoder(n)}),s}return{}}),Ke=(e)=>Lt({tag:1,value:e.getTime()/1000}),wo=async(e,t)=>{let n=await bn(e,t);return n.message=n.message??n.Message,n},xn=(e,t)=>{let n=(s)=>{let o=s;if(typeof o==="number")o=o.toString();if(o.indexOf(",")>=0)o=o.split(",")[0];if(o.indexOf(":")>=0)o=o.split(":")[0];return o};if(t.__type!==void 0)return n(t.__type)},bo=(e)=>{if(String(e.headers["smithy-protocol"]).toLowerCase()!=="rpc-v2-cbor")throw Error("Malformed RPCv2 CBOR response, status: "+e.statusCode)},xo=async(e,t,n,s,o)=>{let i=await e.endpoint(),{hostname:c,protocol:a="https",port:f,path:u}=i,h={protocol:a,hostname:c,port:f,method:"POST",path:u.endsWith("/")?u.slice(0,-1)+n:u+n,headers:{...t}};if(s!==void 0)h.hostname=s;if(i.headers)for(let l in i.headers){if(!D(i.headers,l))continue;h.headers[l]=i.headers[l]}if(o!==void 0){h.body=o;try{h.headers["content-length"]=String(qi(o))}catch(l){}}return new Gi(h)};class Ht extends ke{write(e,t){b=0;let n=F.of(e);ue(n,t,void 0,this.serdeContext)}flush(){let e=_.subarray(0,b);return b=0,_=En(jt),ne=new DataView(_.buffer,_.byteOffset,_.byteLength),e}}var fn=Symbol.for("@smithy/cbor-struct-cache");function Kt(e){let t=e.getSchema(),n=t[fn];if(n)return n;let s=[],o=[];for(let[a,f]of e.structIterator())s.push(a),o.push(f);let i=Array(s.length);for(let a=0;a<s.length;++a)i[a]=Eo(s[a]);let c={memberNames:s,memberSchemas:o,encodedKeys:i};return t[fn]=c,c}function Eo(e){let t;if(Xe)t=Buffer.from(e,"utf-8");else t=new TextEncoder().encode(e);let n=t.length,s;if(n<24)s=1;else if(n<256)s=2;else s=3;let o=new Uint8Array(s+n);if(s===1)o[0]=96|n;else if(s===2)o[0]=120,o[1]=n;else o[0]=121,o[1]=n>>8,o[2]=n&255;return o.set(t,s),o}var Xe=typeof Buffer<"u",No=new TextEncoder,jt=2048,_=Xe?Buffer.allocUnsafe(jt):new Uint8Array(jt),ne=new DataView(_.buffer,_.byteOffset,_.byteLength),b=0,un=2048,fe=new Map,kt=0,hn=!1;function En(e){return Xe?Buffer.allocUnsafe(e):new Uint8Array(e)}function ue(e,t,n,s){if(t==null){if(t===void 0&&e.isIdempotencyToken()){Q(yn());return}A(1),_[b++]=246;return}if(e.isUnitSchema()){A(1),M(5,0);return}if(typeof t==="object"){if(e.isBlobSchema()){if(t instanceof Uint8Array){qe(t);return}}if(e.isTimestampSchema()){if(t instanceof Date){zt(t);return}}if(e.isStructSchema()){_o(e,t,s);return}if(Array.isArray(t)&&(e.isListSchema()||e.isDocumentSchema())){ln(e,t,e.isDocumentSchema(),s);return}if(e.isMapSchema()){Rt(e,t,!1,s);return}if(t instanceof Date){zt(t);return}if(t instanceof Uint8Array){qe(t);return}if(t instanceof Ie){Cn(t);return}if(t[Re]){let i=t;_n(i.tag,i.value);return}if(e.isDocumentSchema()){if(Array.isArray(t))ln(e,t,!0,s);else Rt(e,t,!0,s);return}if(e.isBigDecimalSchema()){he(t);return}Rt(e,t,!0,s);return}if(typeof t==="string"){if(e.isBlobSchema()){let i=(s?.base64Decoder??Ot)(t);qe(i);return}Q(t);return}if(typeof t==="number"){if(A(9),Number.isInteger(t)&&t>=-9007199254740992&&t<=9007199254740991)Je(t);else qt(t);return}if(typeof t==="boolean"){A(1),_[b++]=224|(t?21:20);return}if(typeof t==="bigint"){Ge(t);return}Q(String(t))}function _o(e,t,n){if(e.isUnionSchema()){let l=!1;for(let[d,m]of e.structIterator()){let y=t[d];if(y!=null){A(9),M(5,1),Q(d),ue(m,y,e,n),l=!0;break}}if(!l){let{$unknown:d}=t;if(Array.isArray(d))A(9),M(5,1),Q(d[0]),he(d[1]);else A(9),M(5,0)}return}let s=Kt(e),{memberNames:o,memberSchemas:i,encodedKeys:c}=s,a=o.length,f;if(a<24)f=1;else if(a<256)f=2;else f=3;A(f);let u=b;b+=f;let h=0;for(let l=0;l<a;++l){let d=t[o[l]];if(d==null&&!i[l].isIdempotencyToken())continue;let m=c[l];A(m.length),_.set(m,b),b+=m.length,ue(i[l],d,e,n),++h}if(typeof t.__type==="string")for(let l in t){if(!D(t,l))continue;if(!o.includes(l))Q(l),he(t[l]),++h}if(f===1)_[u]=160|h;else if(f===2)_[u]=184,_[u+1]=h;else _[u]=185,_[u+1]=h>>8,_[u+2]=h&255}function ln(e,t,n,s){let o=!!e.getMergedTraits().sparse,i=e.getValueSchema();if(n||o){let c=[];for(let a=0;a<t.length;++a){let f=t[a];if(n){if(f!==void 0)c.push(f)}else if(f!=null||o)c.push(f)}A(9),M(4,c.length);for(let a=0;a<c.length;++a)ue(i,c[a],void 0,s)}else{let c=0;for(let a=0;a<t.length;++a)if(t[a]!=null)++c;A(9),M(4,c);for(let a=0;a<t.length;++a)if(t[a]!=null)ue(i,t[a],void 0,s)}}function Rt(e,t,n,s){let o=!!e.getMergedTraits().sparse,i=e.getValueSchema(),c=[];for(let a in t){if(!D(t,a))continue;let f=t[a];if(n?f!==void 0:f!=null||o)c.push(a)}A(9),M(5,c.length);for(let a=0;a<c.length;++a){let f=c[a];Q(f),ue(i,t[f],void 0,s)}}function he(e){if(e==null){A(1),_[b++]=246;return}if(typeof e==="string"){Q(e);return}if(typeof e==="number"){if(A(9),Number.isInteger(e)&&e>=-9007199254740992&&e<=9007199254740991)Je(e);else qt(e);return}if(typeof e==="boolean"){A(1),_[b++]=224|(e?21:20);return}if(typeof e==="bigint"){Ge(e);return}if(e instanceof Uint8Array){qe(e);return}if(e instanceof Date){zt(e);return}if(e instanceof Ie){Cn(e);return}if(e[Re]){let t=e;_n(t.tag,t.value);return}if(Array.isArray(e)){A(9),M(4,e.length);for(let t=0;t<e.length;++t)he(e[t]);return}if(typeof e==="object"){let t=Object.keys(e);A(9),M(5,t.length);for(let n=0;n<t.length;++n)Q(t[n]),he(e[t[n]]);return}Q(String(e))}function A(e){if(b+e>_.length){let t=_.length*2;while(t<b+e)t*=2;let n=En(t);n.set(_.subarray(0,b)),_=n,ne=new DataView(n.buffer,n.byteOffset,n.byteLength)}}function M(e,t){if(t<24)_[b++]=e<<5|t;else if(t<256)_[b++]=e<<5|24,_[b++]=t;else if(t<65536)_[b++]=e<<5|25,_[b++]=t>>8,_[b++]=t&255;else if(t<4294967296)_[b++]=e<<5|26,ne.setUint32(b,t),b+=4;else{_[b++]=e<<5|27;let n=t/4294967296|0,s=t-n*4294967296|0;ne.setUint32(b,n),ne.setUint32(b+4,s),b+=8}}function Nn(e,t){let n=Number(t);if(n<4294967296){M(e,n);return}_[b++]=e<<5|27,ne.setBigUint64(b,t),b+=8}function Q(e){let t=e.length;if(t<=23){let n=fe.get(e);if(n){A(n.bytes.length),_.set(n.bytes,b),b+=n.bytes.length,n.epoch=kt;return}let s=b;dn(e,t);let o=b,i=Uint8Array.prototype.slice.call(_,s,o);if(fe.size>=un){if(hn)return;let c=0;for(let[a,f]of fe){if(c>=1024)break;if(f.epoch!==kt)fe.delete(a),++c}if(c===0){hn=!0;return}}if(fe.size<un)fe.set(e,{epoch:kt,bytes:i});return}dn(e,t)}function dn(e,t){if(Xe){let n=t*3;A(n+9);let s=Buffer.byteLength(e);M(3,s),b+=_.write(e,b)}else{let n=t*3;A(n+9);let s=b,i=No.encodeInto(e,_.subarray(s+9)).written,c;if(i<24)c=1;else if(i<256)c=2;else if(i<65536)c=3;else if(i<4294967296)c=5;else c=9;if(c<9)_.copyWithin(s+c,s+9,s+9+i);b=s,M(3,i),b+=i}}function qt(e){A(9),_[b++]=251,ne.setFloat64(b,e),b+=8}function Je(e){A(9);let t=e>=0,n=t?0:1,s=t?e:-e-1;M(n,s)}function Ge(e){let t=e>=0,n=t?0:1,s=t?e:-e-BigInt(1);if(s<BigInt("18446744073709551616"))A(9),Nn(n,s);else{let o=s.toString(2),i=Math.ceil(o.length/8),c=new Uint8Array(i),a=s;for(let f=i-1;f>=0;--f)c[f]=Number(a&BigInt(255)),a>>=BigInt(8);A(i+16),_[b++]=t?194:195,M(2,i),_.set(c,b),b+=i}}function qe(e){A(e.length+9),M(2,e.length),_.set(e,b),b+=e.length}function _n(e,t){if(A(9),typeof e==="bigint")Nn(6,e);else M(6,e);he(t)}function Cn(e){let t=e.string,n=BigInt(0),s=t.search(/[eE]/);if(s!==-1)n=BigInt(t.slice(s+1)),t=t.slice(0,s);let o=t.indexOf("."),i=o===-1?0:t.length-o-1,c=n-BigInt(i),a=BigInt(t.replace(".",""));if(A(9),_[b++]=196,M(4,2),A(9),c>=-0x20000000000000n&&c<=0x1fffffffffffffn)Je(Number(c));else Ge(c);Ge(a)}function zt(e){A(18),M(6,1);let t=e.getTime()/1000;if(Number.isInteger(t))Je(t);else qt(t)}class Qt extends ke{read(e,t){return k=t,Wt=An&&t instanceof Buffer,X=new DataView(t.buffer,t.byteOffset,t.byteLength),S=0,R=t.length,Ne=Ne+1&65535,L(F.of(e))}readValue(e,t){return Qe(F.of(e),t)}}var An=typeof Buffer<"u",Gt=new TextDecoder,k=new Uint8Array(0),Wt=!1,X=new DataView(new ArrayBuffer(0)),S=0,R=0,Xt=2048,mn=Array(Xt),Mt=new Uint16Array(Xt),Ne=0;function L(e){if(S>=R)throw Error("unexpected end of CBOR payload.");let t=(k[S]&224)>>5;if((k[S]&31)===31&&t>=2&&t<=5)return ko(e,t);switch(t){case 0:return Do();case 1:return jo();case 2:return ve();case 3:return le();case 4:return Co(e);case 5:return Ao(e);case 6:return Io();case 7:return Oo();default:throw Error(`unexpected CBOR major type ${t}.`)}}function Co(e){let t=Ye(),n=e.isListSchema()?e.getValueSchema():e,s=Array(t);for(let o=0;o<t;++o)s[o]=L(n);return s}function Ao(e){let t=Ye();if(e.isStructSchema())return To(e,t,S);let n=e.isMapSchema()?e.getValueSchema():e,s={};for(let o=0;o<t;++o){let i=le();s[i]=L(n)}return s}function To(e,t,n){let s=e.isUnionSchema(),o=Kt(e),{memberSchemas:i,encodedKeys:c,memberNames:a}=o,f=c.length,u={},h,l,d=0,m=!1,y=0;for(let g=0;g<t;++g){let N=Tn(c,f,y);if(N>=0){if(y=N+1,y>=f)y=0;let I=L(i[N]);if(I!=null)u[a[N]]=I}else{let I=le(),j=L(F.of(15));if(I==="__type"&&typeof j==="string")m=!0;else h=I,l=j,++d}}if(s){let g=!0;for(let N in u){if(!D(u,N))continue;g=!1;break}if(g&&d===1)u.$unknown=[h,l]}else if(m){S=n;let g=F.of(15);for(let N=0;N<t;++N){let I=le(),j=L(g);if(!(I in u))u[I]=j}}return u}function Io(e){let t=Ze(),n=typeof t==="bigint"?Number(t):t;if(n===1){let i=F.of(15),c=L(i);return Ce(c)}if(n===2||n===3){let i=ve(),c=BigInt(0);for(let a=0;a<i.length;++a)c=c<<BigInt(8)|BigInt(i[a]);return n===3?-c-BigInt(1):c}if(n===4){let i=F.of(15),c=L(i),[a,f]=c,u=f<0?-1:1,h=BigInt(u)*BigInt(f),l=String(h),d=f<0?"-":"",m;if(typeof a==="number"&&Math.abs(a)<=268435456){let g=a,N="0".repeat(Math.abs(g)+1)+l;if(m=g===0?N:N.slice(0,N.length+g)+"."+N.slice(g),m=m.replace(/^0+/g,""),m==="")m="0";if(m[0]===".")m="0"+m;m=d+m}else{let g=BigInt(a);if(l.length===1)m=d+l+"e"+String(g);else{let N=g+BigInt(l.length-1);m=d+l[0]+"."+l.slice(1)+"e"+String(N)}}return pn(m)}let s=F.of(15),o=L(s);return{tag:In(t),value:o}}function ko(e,t){switch(t){case 3:return Ro();case 2:return Mo();case 4:return Bo(e);case 5:return Uo(e);default:throw Error(`unexpected indefinite length for major ${t}.`)}}function Ro(){S+=1;let e=[],t=0;while(S<R){if(k[S]===255){S+=1;let s=new Uint8Array(t),o=0;for(let i=0;i<e.length;++i)s.set(e[i],o),o+=e[i].length;if(An)return Buffer.from(s.buffer,s.byteOffset,s.byteLength).toString("utf-8");return Gt.decode(s)}let n=ve();e.push(n),t+=n.length}throw Error("expected break marker.")}function Mo(){S+=1;let e=[],t=0;while(S<R){if(k[S]===255){S+=1;let s=new Uint8Array(t),o=0;for(let i=0;i<e.length;++i)s.set(e[i],o),o+=e[i].length;return s}let n=ve();e.push(n),t+=n.length}throw Error("expected break marker.")}function Bo(e){S+=1;let t=e.isListSchema()?e.getValueSchema():e,n=[];while(S<R){if(k[S]===255)return S+=1,n;n.push(L(t))}throw Error("expected break marker.")}function Uo(e){if(S+=1,e.isStructSchema()){let s=Kt(e),{memberSchemas:o,encodedKeys:i,memberNames:c}=s,a=i.length,f=e.isUnionSchema(),u={},h,l,d=0,m=0;while(S<R){if(k[S]===255){if(S+=1,f){let g=!0;for(let N in u){if(!D(u,N))continue;g=!1;break}if(g&&d===1)u.$unknown=[h,l]}return u}let y=Tn(i,a,m);if(y>=0){if(m=y+1,m>=a)m=0;let g=L(o[y]);if(g!=null)u[c[y]]=g}else{let g=le(),N=L(F.of(15));if(g!=="__type")h=g,l=N,++d}}throw Error("expected break marker.")}let t=e.isMapSchema()?e.getValueSchema():e,n={};while(S<R){if(k[S]===255)return S+=1,n;let s=le();n[s]=L(t)}throw Error("expected break marker.")}function Tn(e,t,n){let s=e[n];if(S+s.length<=R&&gn(S,s))return S+=s.length,n;for(let o=0;o<t;++o){if(o===n)continue;let i=e[o];if(S+i.length<=R&&gn(S,i))return S+=i.length,o}return-1}function gn(e,t){let n=t.length;if(k[e]!==t[0])return!1;for(let s=1;s<n;++s)if(k[e+s]!==t[s])return!1;return!0}function Ze(){let e=k[S]&31;if(e<24)return S+=1,e;switch(e){case 24:if(R-S<2)W(1);return S+=2,k[S-1];case 25:if(R-S<3)W(2);return S+=3,X.getUint16(S-2);case 26:if(R-S<5)W(4);return S+=5,X.getUint32(S-4);case 27:{if(R-S<9)W(8);S+=9;let t=X.getUint32(S-8);if(t<2097152)return t*4294967296+X.getUint32(S-4);return X.getBigUint64(S-8)}default:throw Error(`unexpected minor value ${e}.`)}}function Ye(){let e=Ze();return typeof e==="bigint"?Number(e):e}function Do(){let e=Ze();return In(e)}function jo(){let e=Ze();if(typeof e==="bigint")return BigInt(-1)-e;return-1-e}function ve(){let e=Ye();if(R-S<e)W(e);let t=S;return S+=e,k.subarray(t,t+e)}function le(){let e=Ye();if(R-S<e)W(e);let t=S;if(S+=e,e<24)return zo(t,e);if(Wt)return k.toString("utf-8",t,t+e);return Gt.decode(k.subarray(t,t+e))}function zo(e,t){let n=t;for(let c=0;c<t;++c)n=n*31+k[e+c]|0;let s=n>>>0&Xt-1,o=mn[s];if(o!==void 0&&o.length===t){let c=!0;for(let a=0;a<t;++a)if(o.charCodeAt(a)!==k[e+a]){c=!1;break}if(c)return Mt[s]=Ne,o}let i=Wt?k.toString("utf-8",e,e+t):Gt.decode(k.subarray(e,e+t));if(Mt[s]!==Ne)mn[s]=i,Mt[s]=Ne;return i}function Oo(){let e=S,t=k[e]&31;switch(t){case 21:return S=e+1,!0;case 20:return S=e+1,!1;case 22:return S=e+1,null;case 23:return S=e+1,null;case 25:{if(R-e<3)W(2);return S=e+3,Lo(k[e+1],k[e+2])}case 26:{if(R-e<5)W(4);return S=e+5,X.getFloat32(e+1)}case 27:{if(R-e<9)W(8);return S=e+9,X.getFloat64(e+1)}default:throw Error(`unexpected minor value ${t} for major 7.`)}}function Lo(e,t){let n=e>>7,s=(e&124)>>2,o=(e&3)<<8|t,i=n===0?1:-1;if(s===0){if(o===0)return 0;return i*(Math.pow(2,-14)*(o/1024))}else if(s===31){if(o===0)return i*(1/0);return NaN}return i*(Math.pow(2,s-15)*(1+o/1024))}function In(e){if(typeof e==="number")return e;let t=Number(e);if(Number.MIN_SAFE_INTEGER<=t&&t<=Number.MAX_SAFE_INTEGER)return t;return e}function W(e){throw Error(`CBOR: length ${e} greater than remaining buffer length.`)}function Qe(e,t){if(e.isTimestampSchema()){if(typeof t==="number")return Ce(t);if(typeof t==="object"&&t!==null){if(t.tag===1&&"value"in t)return Ce(t.value)}}if(e.isBlobSchema())return t;if(typeof t>"u"||typeof t==="boolean"||typeof t==="number"||typeof t==="string"||typeof t==="bigint"||typeof t==="symbol")return t;if(typeof t!=="object"||t===null)return t;if("byteLength"in t)return t;if(t instanceof Date)return t;if(t instanceof Ie)return t;if(e.isDocumentSchema())return t;if(e.isListSchema()){let s=e.getValueSchema(),o=[];for(let i of t)o.push(Qe(s,i));return o}let n={};if(e.isMapSchema()){let s=e.getValueSchema();for(let o in t){if(!D(t,o))continue;n[o]=Qe(s,t[o])}}else if(e.isStructSchema()){let s=e.isUnionSchema(),o;if(s){o=new Set;for(let i in t){if(!D(t,i))continue;if(i!=="__type")o.add(i)}}for(let[i,c]of e.structIterator()){if(s)o.delete(i);if(t[i]!=null)n[i]=Qe(c,t[i])}if(s&&o?.size===1){let i=!0;for(let c in n){if(!D(n,c))continue;i=!1;break}if(i){let c=o.values().next().value;n.$unknown=[c,t[c]]}}else if(typeof t.__type==="string")for(let i in t){if(!D(t,i))continue;if(!(i in n))n[i]=t[i]}}return n}class Jt extends ke{createSerializer(){let e=new Ht;return e.setSerdeContext(this.serdeContext),e}createDeserializer(){let e=new Qt;return e.setSerdeContext(this.serdeContext),e}}class kn extends Xi{codec=new Jt;serializer=this.codec.createSerializer();deserializer=this.codec.createDeserializer();constructor({defaultNamespace:e,errorTypeRegistries:t}){super({defaultNamespace:e,errorTypeRegistries:t})}getShapeId(){return"smithy.protocols#rpcv2Cbor"}getPayloadCodec(){return this.codec}async serializeRequest(e,t,n){let s=await super.serializeRequest(e,t,n);if(Object.assign(s.headers,{"content-type":this.getDefaultContentType(),"smithy-protocol":"rpc-v2-cbor",accept:this.getDefaultContentType()}),Ji(e.input)==="unit")delete s.body,delete s.headers["content-type"];else{if(!s.body)this.serializer.write(15,{}),s.body=this.serializer.flush();if(s.body instanceof Uint8Array)s.headers["content-length"]=String(s.body.byteLength)}let{service:o,operation:i}=Qi(n),c=`/service/${o}/operation/${i}`;if(s.path.endsWith("/"))s.path+=c.slice(1);else s.path+=c;return s}async deserializeResponse(e,t,n){return super.deserializeResponse(e,t,n)}async handleError(e,t,n,s,o){let i=xn(n,s)??"Unknown",c=["*"],{defaultNamespace:a}=this.options;c.unshift(a);let[f,u]=(()=>{if(i.includes("#"))return i.split("#");return[void 0,i]})();if(f)c.unshift(f);let h={$metadata:o,$fault:n.statusCode<500?"client":"server"},l=[this.compositeErrorRegistry];if(f)l.push(on.for(f));l.push(on.for(a));let[d,m,y]=this.resolveError(u,c,l);if(y==="native"||y==="synthetic"){if(s.Message)s.message=s.Message;let O=y==="synthetic"?new m({name:u}):Error(u);throw Object.assign(O,h,s)}let g=F.of(d),N=s.message??s.Message??"Unknown",I=new m({}),j={};for(let[O,v]of g.structIterator())j[O]=this.deserializer.readValue(v,s[O]);throw Object.assign(I,h,{$fault:g.getMergedTraits().error,message:N},j)}getDefaultContentType(){return"application/cbor"}}class Rn extends ke{value;write(e,t){this.value=this.serialize(e,t)}serialize(e,t){let n=F.of(e);if(t==null){if(n.isIdempotencyToken())return yn();return t}if(n.isBlobSchema()){if(typeof t==="string")return(this.serdeContext?.base64Decoder??Ot)(t);return t}if(n.isTimestampSchema()){if(typeof t==="number"||typeof t==="bigint")return Ke(new Date(Number(t)/1000|0));return Ke(t)}if(typeof t==="function"||typeof t==="object"){let s=t;if(n.isListSchema()&&Array.isArray(s)){let i=!!n.getMergedTraits().sparse,c=[],a=0;for(let f of s){let u=this.serialize(n.getValueSchema(),f);if(u!=null||i)c[a++]=u}return c}if(s instanceof Date)return Ke(s);let o={};if(n.isMapSchema()){let i=!!n.getMergedTraits().sparse;for(let c in s){if(!D(s,c))continue;let a=this.serialize(n.getValueSchema(),s[c]);if(a!=null||i)o[c]=a}}else if(n.isStructSchema()){for(let[c,a]of n.structIterator()){let f=this.serialize(a,s[c]);if(f!=null)o[c]=f}if(n.isUnionSchema()&&Array.isArray(s.$unknown)){let[c,a]=s.$unknown;o[c]=a}else if(typeof s.__type==="string")for(let c in s){if(!D(s,c))continue;if(!(c in o))o[c]=this.serialize(15,s[c])}}else if(n.isDocumentSchema()){if(Array.isArray(s)){let i=[],c=0;for(let a of s)i[c++]=this.serialize(n.getValueSchema(),a);return i}for(let i in s){if(!D(s,i))continue;o[i]=this.serialize(n.getValueSchema(),s[i])}}else if(n.isBigDecimalSchema())return s;return o}return t}flush(){let e=We.serialize(this.value);return this.value=void 0,e}}class Mn extends ke{read(e,t){let n=We.deserialize(t);return this.readValue(e,n)}readValue(e,t){let n=F.of(e);if(n.isTimestampSchema()){if(typeof t==="number")return Ce(t);if(typeof t==="object"){if(t.tag===1&&"value"in t)return Ce(t.value)}}if(n.isBlobSchema()){if(typeof t==="string")return(this.serdeContext?.base64Decoder??Ot)(t);return t}if(typeof t>"u"||typeof t==="boolean"||typeof t==="number"||typeof t==="string"||typeof t==="bigint"||typeof t==="symbol")return t;else if(typeof t==="object"){if(t===null)return null;if("byteLength"in t)return t;if(t instanceof Date)return t;if(n.isDocumentSchema())return t;if(n.isListSchema()){let o=[],i=n.getValueSchema();for(let c of t){let a=this.readValue(i,c);o.push(a)}return o}let s={};if(n.isMapSchema()){let o=n.getValueSchema();for(let i in t){if(!D(t,i))continue;let c=this.readValue(o,t[i]);s[i]=c}}else if(n.isStructSchema()){let o=n.isUnionSchema(),i;if(o){i=new Set;for(let c in t){if(!D(t,c))continue;if(c!=="__type")i.add(c)}}for(let[c,a]of n.structIterator()){if(o)i.delete(c);if(t[c]!=null)s[c]=this.readValue(a,t[c])}if(o&&i?.size===1){let c=!0;for(let a in s){if(!D(s,a))continue;c=!1;break}if(c){let a=i.values().next().value;s.$unknown=[a,t[a]]}}else if(typeof t.__type==="string")for(let c in t){if(!D(t,c))continue;if(!(c in s))s[c]=t[c]}}else if(t instanceof Ie)return t;return s}else return t}}$o.CborCodec=Jt;$o.CborShapeDeserializer=Mn;$o.CborShapeDeserializer2=Qt;$o.CborShapeSerializer=Rn;$o.CborShapeSerializer2=Ht;$o.SmithyRpcV2CborProtocol=kn;$o.buildHttpRpcRequest=xo;$o.cbor=We;$o.checkCborResponse=bo;$o.dateToTag=Ke;$o.loadSmithyRpcV2CborErrorCode=xn;$o.parseCborBody=bn;$o.parseCborErrorBody=wo;$o.tag=Lt;$o.tagSymbol=Re});var Un=r(function(ac){var tc=/[&<>"]/g,rc={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;"};function nc(e){return e.replace(tc,(t)=>rc[t])}var sc=/[&"'<>\r\n\u0085\u2028]/g,ic={"&":"&amp;",'"':"&quot;","'":"&apos;","<":"&lt;",">":"&gt;","\r":"&#x0D;","\n":"&#x0A;","\x85":"&#x85;","\u2028":"&#x2028;"};function oc(e){return e.replace(sc,(t)=>ic[t])}class Yt{value;constructor(e){this.value=e}toString(){return oc(""+this.value)}}class Be{name;children;attributes={};static of(e,t,n){let s=new Be(e);if(t!==void 0)s.addChildNode(new Yt(t));if(n!==void 0)s.withName(n);return s}constructor(e,t=[]){this.name=e,this.children=t}withName(e){return this.name=e,this}addAttribute(e,t){return this.attributes[e]=t,this}addChildNode(e){return this.children.push(e),this}removeAttribute(e){return delete this.attributes[e],this}n(e){return this.name=e,this}c(e){return this.children.push(e),this}a(e,t){if(t!=null)this.attributes[e]=t;return this}cc(e,t,n=t){if(e[t]!=null){let s=Be.of(t,e[t]).withName(n);this.c(s)}}l(e,t,n,s){if(e[t]!=null)s().map((i)=>{i.withName(n),this.c(i)})}lc(e,t,n,s){if(e[t]!=null){let o=s(),i=new Be(n);o.map((c)=>{i.c(c)}),this.c(i)}}toString(){let e=Boolean(this.children.length),t=`<${this.name}`,n=this.attributes;for(let s of Object.keys(n)){let o=n[s];if(o!=null)t+=` ${s}="${nc(""+o)}"`}return t+=!e?"/>":`>${this.children.map((s)=>s.toString()).join("")}</${this.name}>`}}function Zt(e){Object.defineProperty(e,"__proto__",{value:void 0,writable:!0,enumerable:!0,configurable:!0})}function cc(e){return new vt(e).parse()}class vt{x;i=0;z;constructor(e){this.x=e,this.x=e.replace(/\r\n?/g,`
12
+ ${te(i)}`}getCanonicalPath({path:e}){if(this.uriEscapePath){let t=[];for(let o of e.split("/")){if(o?.length===0)continue;if(o===".")continue;if(o==="..")t.pop();else t.push(o)}let n=`${e?.startsWith("/")?"/":""}${t.join("/")}${t.length>0&&e?.endsWith("/")?"/":""}`;return De(n).replace(/%2F/g,"/")}return e}validateResolvedCredentials(e){if(typeof e!=="object"||typeof e.accessKeyId!=="string"||typeof e.secretAccessKey!=="string")throw Error("Resolved credential object is not valid")}formatDate(e){let t=_s(e).replace(/[-:]/g,"");return{longDate:t,shortDate:t.slice(0,8)}}getCanonicalHeaderList(e){return Object.keys(e).sort().join(";")}}var se={},ze=[],Oe=(e,t,n)=>`${e}/${t}/${n}/${_t}`,$r=async(e,t,n,s,o)=>{let i=await br(e,t.secretAccessKey,t.accessKeyId),c=`${n}:${s}:${o}:${te(i)}:${t.sessionToken}`;if(c in se)return se[c];ze.push(c);while(ze.length>zr)delete se[ze.shift()];let a=`AWS4${t.secretAccessKey}`;for(let f of[n,s,o,_t])a=await br(e,a,f);return se[c]=a},As=()=>{ze.length=0,Object.keys(se).forEach((e)=>{delete se[e]})},br=(e,t,n)=>{let s=new e(t);return s.update(we(n)),s.digest()},gt=({headers:e},t,n)=>{let s={};for(let o of Object.keys(e).sort()){if(e[o]==null)continue;let i=o.toLowerCase();if(i in Mr||t?.has(i)||Br.test(i)||Ur.test(i)){if(!n||n&&!n.has(i))continue}s[i]=e[o].replace(/[\r\n]/g," ").replace(/[ \t]+/g," ").replace(/^ | $/g,"")}return s},Le=async({headers:e,body:t},n)=>{for(let s in e){if(!ie(e,s))continue;if(s.toLowerCase()===$e)return e[s]}if(t==null)return"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855";else if(typeof t==="string"||ArrayBuffer.isView(t)||Ss(t)){let s=new n;return s.update(we(t)),te(await s.digest())}return jr},Vr=(e,t)=>{e=e.toLowerCase();for(let n in t){if(!ie(t,n))continue;if(e===n.toLowerCase())return!0}return!1},Fr=(e,t={})=>{let{headers:n,query:s={}}=xr.clone(e);for(let o in n){if(!ie(n,o))continue;let i=o.toLowerCase();if(i.slice(0,6)==="x-amz-"&&!t.unhoistableHeaders?.has(i)||t.hoistableHeaders?.has(i))s[o]=n[o],delete n[o]}return{...e,headers:n,query:s}},pt=(e)=>{e=xr.clone(e);for(let t in e.headers){if(!ie(e.headers,t))continue;if(Ir.indexOf(t.toLowerCase())>-1)delete e.headers[t]}return e};class Pr extends Ct{headerFormatter=new Er;constructor({applyChecksum:e,credentials:t,region:n,service:s,sha256:o,uriEscapePath:i=!0}){super({applyChecksum:e,credentials:t,region:n,service:s,sha256:o,uriEscapePath:i})}async presign(e,t={}){let{signingDate:n=new Date,expiresIn:s=3600,unsignableHeaders:o,unhoistableHeaders:i,signableHeaders:c,hoistableHeaders:a,signingRegion:f,signingService:u}=t,h=await this.credentialProvider();this.validateResolvedCredentials(h);let l=f??await this.regionProvider(),{longDate:d,shortDate:m}=this.formatDate(n);if(s>Or)return Promise.reject("Signature version 4 presigned URLs must have an expiration date less than one week in the future");let y=Oe(m,l,u??this.service),g=Fr(pt(e),{unhoistableHeaders:i,hoistableHeaders:a});if(h.sessionToken)g.query[xt]=h.sessionToken;g.query[Nr]=je,g.query[_r]=`${h.accessKeyId}/${y}`,g.query[wt]=d,g.query[Ar]=s.toString(10);let E=gt(g,o,c);return g.query[Cr]=this.getCanonicalHeaderList(E),g.query[bt]=await this.getSignature(d,y,this.getSigningKey(h,l,m,u),this.createCanonicalRequest(g,E,await Le(e,this.sha256))),g}async sign(e,t){if(typeof e==="string")return this.signString(e,t);else if(e.headers&&e.payload)return this.signEvent(e,t);else if(e.message)return this.signMessage(e,t);else return this.signRequest(e,t)}async signEvent({headers:e,payload:t},{signingDate:n=new Date,priorSignature:s,signingRegion:o,signingService:i,eventStreamCredentials:c}){let a=o??await this.regionProvider(),{shortDate:f,longDate:u}=this.formatDate(n),h=Oe(f,a,i??this.service),l=await Le({headers:{},body:t},this.sha256),d=new this.sha256;d.update(e);let m=te(await d.digest()),y=[Dr,u,h,s,m,l].join(`
13
+ `);return this.signString(y,{signingDate:n,signingRegion:a,signingService:i,eventStreamCredentials:c})}async signMessage(e,{signingDate:t=new Date,signingRegion:n,signingService:s,eventStreamCredentials:o}){return this.signEvent({headers:this.headerFormatter.format(e.message.headers),payload:e.message.body},{signingDate:t,signingRegion:n,signingService:s,priorSignature:e.priorSignature,eventStreamCredentials:o}).then((c)=>({message:e.message,signature:c}))}async signString(e,{signingDate:t=new Date,signingRegion:n,signingService:s,eventStreamCredentials:o}={}){let i=o??await this.credentialProvider();this.validateResolvedCredentials(i);let c=n??await this.regionProvider(),{shortDate:a}=this.formatDate(t),f=new this.sha256(await this.getSigningKey(i,c,a,s));return f.update(we(e)),te(await f.digest())}async signRequest(e,{signingDate:t=new Date,signableHeaders:n,unsignableHeaders:s,signingRegion:o,signingService:i}={}){let c=await this.credentialProvider();this.validateResolvedCredentials(c);let a=o??await this.regionProvider(),f=pt(e),{longDate:u,shortDate:h}=this.formatDate(t),l=Oe(h,a,i??this.service);if(f.headers[Nt]=u,c.sessionToken)f.headers[Rr]=c.sessionToken;let d=await Le(f,this.sha256);if(!Vr($e,f.headers)&&this.applyChecksum)f.headers[$e]=d;let m=gt(f,s,n),y=await this.getSignature(u,l,this.getSigningKey(c,a,h,i),this.createCanonicalRequest(f,m,d));return f.headers[Et]=`${je} Credential=${c.accessKeyId}/${l}, SignedHeaders=${this.getCanonicalHeaderList(m)}, Signature=${y}`,f}async getSignature(e,t,n,s){let o=await this.createStringToSign(e,t,s,je),i=new this.sha256(await n);return i.update(we(o)),te(await i.digest())}getSigningKey(e,t,n,s){return $r(this.sha256,e,n,t,s||this.service)}}var Ts={SignatureV4a:null};Is.ALGORITHM_IDENTIFIER=je;Is.ALGORITHM_IDENTIFIER_V4A=Ns;Is.ALGORITHM_QUERY_PARAM=Nr;Is.ALWAYS_UNSIGNABLE_HEADERS=Mr;Is.AMZ_DATE_HEADER=Nt;Is.AMZ_DATE_QUERY_PARAM=wt;Is.AUTH_HEADER=Et;Is.CREDENTIAL_QUERY_PARAM=_r;Is.DATE_HEADER=Tr;Is.EVENT_ALGORITHM_IDENTIFIER=Dr;Is.EXPIRES_QUERY_PARAM=Ar;Is.GENERATED_HEADERS=Ir;Is.HOST_HEADER=xs;Is.KEY_TYPE_IDENTIFIER=_t;Is.MAX_CACHE_SIZE=zr;Is.MAX_PRESIGNED_TTL=Or;Is.PROXY_HEADER_PATTERN=Br;Is.REGION_SET_PARAM=bs;Is.SEC_HEADER_PATTERN=Ur;Is.SHA256_HEADER=$e;Is.SIGNATURE_HEADER=kr;Is.SIGNATURE_QUERY_PARAM=bt;Is.SIGNED_HEADERS_QUERY_PARAM=Cr;Is.SignatureV4=Pr;Is.SignatureV4Base=Ct;Is.TOKEN_HEADER=Rr;Is.TOKEN_QUERY_PARAM=xt;Is.UNSIGNABLE_PATTERNS=Es;Is.UNSIGNED_PAYLOAD=jr;Is.clearCredentialCache=As;Is.createScope=Oe;Is.getCanonicalHeaders=gt;Is.getCanonicalQuery=Lr;Is.getPayloadHash=Le;Is.getSigningKey=$r;Is.hasHeader=Vr;Is.moveHeadersToQuery=Fr;Is.prepareRequest=pt;Is.signatureV4aContainer=Ts});var He=r(function(Di){var{ProviderError:Hr,booleanSelector:Kr,SelectorType:qr,loadConfig:gi}=v(),{setCredentialFeature:pi}=B(),{normalizeProvider:oe,memoizeIdentityProvider:yi,isIdentityExpired:Si,doesIdentityRequireRefresh:wi}=Pe(),{SignatureV4:Qr}=oi(),{HttpResponse:vr,HttpRequest:en}=z(),{SMITHY_CONTEXT_KEY:bi}=St(),Gr=(e)=>vr.isInstance(e)?e.headers?.date??e.headers?.Date:void 0,Wr=(e)=>vr.isInstance(e)?e.headers?.age??e.headers?.Age:void 0,tn=(e)=>new Date(Date.now()+e),Xr=(e,t,n,s)=>{if(s!==void 0)return t;let o=Date.parse(e),i=Date.now();if(n!==void 0&&i-n>900000)return t;return n!==void 0?o-(n+i)/2:o-i},be=(e,t)=>{if(!t)throw Error(`Property \`${e}\` is not resolved for AWS SDK SigV4Auth`);return t},xi=(e)=>e.context?.[bi]?.eventStream?.output===!0,At=async(e)=>{let t=be("context",e.context),n=be("config",e.config),s=t.endpointV2?.properties?.authSchemes?.[0],i=await be("signer",n.signer)(s),c=e?.signingRegion,a=e?.signingRegionSet,f=e?.signingName;return{config:n,signer:i,signingRegion:c,signingRegionSet:a,signingName:f}};class Ve{async sign(e,t,n){if(!en.isInstance(e))throw Error("The request is not an instance of `HttpRequest` and cannot be signed");let s=await At(n),{config:o,signer:i}=s,{signingRegion:c,signingName:a}=s,f=n.context;if(f?.authSchemes?.length??!1){let[d,m]=f.authSchemes;if(d?.name==="sigv4a"&&m?.name==="sigv4")c=m?.signingRegion??c,a=m?.signingName??a}let u=await o.disableClockSkewCorrection?.()===!0;n._disableClockSkewCorrection=u;let h=u||xi(n);if(n._skipClockSkewSampling=h,!h)n._preRequestSystemClockOffset=o.systemClockOffset,n._requestSentAt=Date.now();return await i.sign(e,{signingDate:u?new Date:tn(o.systemClockOffset),signingRegion:c,signingService:a})}errorHandler(e){return(t)=>{let n=t;if(!e._skipClockSkewSampling&&!e._disableClockSkewCorrection){let s=n.ServerTime??Gr(n.$response);if(s){let o=be("config",e.config),{_preRequestSystemClockOffset:i,_requestSentAt:c}=e,a=Wr(n.$response),f=Xr(s,o.systemClockOffset,c,a);if(o.systemClockOffset=f,Math.abs(f)>=240000&&(f!==i||i!==void 0&&i!==f)&&n.$metadata)n.$metadata.clockSkewCorrected=!0}}throw t}}successHandler(e,t){if(t._skipClockSkewSampling||t._disableClockSkewCorrection)return;let n=Gr(e);if(n){let s=be("config",t.config),o=t._requestSentAt,i=Wr(e);s.systemClockOffset=Xr(n,s.systemClockOffset,o,i)}}}var Ei=Ve;class rn extends Ve{async sign(e,t,n){if(!en.isInstance(e))throw Error("The request is not an instance of `HttpRequest` and cannot be signed");let{config:s,signer:o,signingRegion:i,signingRegionSet:c,signingName:a}=await At(n),u=(await s.sigv4aSigningRegionSet?.()??c??[i]).join(","),h=await s.disableClockSkewCorrection?.()===!0;if(n._disableClockSkewCorrection=h,!h)n._preRequestSystemClockOffset=s.systemClockOffset,n._requestSentAt=Date.now();return await o.sign(e,{signingDate:h?new Date:tn(s.systemClockOffset),signingRegion:u,signingService:a})}}var Jr=(e)=>typeof e==="string"&&e.length>0?e.split(",").map((t)=>t.trim()):[],nn=(e)=>`AWS_BEARER_TOKEN_${e.replace(/[\s-]/g,"_").toUpperCase()}`,Zr="AWS_AUTH_SCHEME_PREFERENCE",Yr="auth_scheme_preference",Ni={environmentVariableSelector:(e,t)=>{if(t?.signingName){if(nn(t.signingName)in e)return["httpBearerAuth"]}if(!(Zr in e))return;return Jr(e[Zr])},configFileSelector:(e)=>{if(!(Yr in e))return;return Jr(e[Yr])},default:[]},_i=(e)=>(e.sigv4aSigningRegionSet=oe(e.sigv4aSigningRegionSet),e),Ci={environmentVariableSelector(e){if(e.AWS_SIGV4A_SIGNING_REGION_SET)return e.AWS_SIGV4A_SIGNING_REGION_SET.split(",").map((t)=>t.trim());throw new Hr("AWS_SIGV4A_SIGNING_REGION_SET not set in env.",{tryNextLink:!0})},configFileSelector(e){if(e.sigv4a_signing_region_set)return(e.sigv4a_signing_region_set??"").split(",").map((t)=>t.trim());throw new Hr("sigv4a_signing_region_set not set in profile.",{tryNextLink:!0})},default:void 0},Ai=(e)=>(t)=>{let n=t.credentials,s=!!t.credentials,o=void 0;Object.defineProperty(t,"credentials",{set(h){if(h&&h!==n&&h!==o)s=!0;n=h;let l=Ti(t,{credentials:n,credentialDefaultProvider:t.credentialDefaultProvider}),d=Ii(t,l);if(s&&!d.attributed){let m=typeof n==="object"&&n!==null;o=async(y)=>{let E=await d(y);if(m&&(!E.$source||Object.keys(E.$source).length===0))return pi(E,"CREDENTIALS_CODE","e");return E},o.memoized=d.memoized,o.configBound=d.configBound,o.attributed=!0}else o=d},get(){return o},enumerable:!0,configurable:!0}),t.credentials=n;let{signingEscapePath:i=!0,systemClockOffset:c=t.systemClockOffset||0,sha256:a}=t,f;if(t.signer)f=oe(t.signer);else if(t.regionInfoProvider)f=()=>oe(t.region)().then(async(h)=>[await t.regionInfoProvider(h,{useFipsEndpoint:await t.useFipsEndpoint(),useDualstackEndpoint:await t.useDualstackEndpoint()})||{},h]).then(([h,l])=>{let{signingRegion:d,signingService:m}=h;t.signingRegion=t.signingRegion||d||l,t.signingName=t.signingName||m||t.serviceId;let y={...t,credentials:t.credentials,region:t.signingRegion,service:t.signingName,sha256:a,uriEscapePath:i};return new(t.signerConstructor||Qr)(y)});else f=async(h)=>{h=Object.assign({},{name:"sigv4",signingName:t.signingName||t.defaultSigningName,signingRegion:await oe(t.region)(),properties:{}},h);let l=h.signingRegion,d=h.signingName;t.signingRegion=t.signingRegion||l,t.signingName=t.signingName||d||t.serviceId;let m={...t,credentials:t.credentials,region:t.signingRegion,service:t.signingName,sha256:a,uriEscapePath:i};return new(t.signerConstructor||Qr)(m)};return Object.assign(t,{systemClockOffset:c,signingEscapePath:i,signer:f,disableClockSkewCorrection:oe(t.disableClockSkewCorrection??e)})};function Ti(e,{credentials:t,credentialDefaultProvider:n}){let s;if(t)if(!t?.memoized)s=yi(t,Si,wi);else s=t;else if(n)s=oe(n(Object.assign({},e,{parentClientConfig:e})));else s=async()=>{throw Error("@aws-sdk/core::resolveAwsSdkSigV4Config - `credentials` not provided and no credentialDefaultProvider was configured.")};return s.memoized=!0,s}function Ii(e,t){if(t.configBound)return t;let n=async(s)=>t({...s,callerClientConfig:e});return n.memoized=t.memoized,n.configBound=!0,n}var ki="AWS_DISABLE_CLOCK_SKEW_CORRECTION",Ri="disable_clock_skew_correction",Mi={environmentVariableSelector:(e)=>Kr(e,ki,qr.ENV),configFileSelector:(e)=>Kr(e,Ri,qr.CONFIG),default:!1},Bi=gi(Mi),sn=Ai(Bi),Ui=sn;Di.AWSSDKSigV4Signer=Ei;Di.AwsSdkSigV4ASigner=rn;Di.AwsSdkSigV4Signer=Ve;Di.NODE_AUTH_SCHEME_PREFERENCE_OPTIONS=Ni;Di.NODE_SIGV4A_CONFIG_OPTIONS=Ci;Di.getBearerTokenEnvKey=nn;Di.resolveAWSSDKSigV4Config=Ui;Di.resolveAwsSdkSigV4AConfig=_i;Di.resolveAwsSdkSigV4Config=sn;Di.validateSigningProperties=At});var Bn=r(function($o){var{nv:pn,NumericValue:Te,calculateBodyLength:qi,generateIdempotencyToken:yn,fromBase64:Ot,_parseEpochTimestamp:Ce}=ee(),{hasOwn:U,getSmithyContext:Qi}=Fe(),{HttpRequest:Gi,collectBody:Wi,SerdeContext:Ie,RpcProtocol:Xi}=z(),{NormalizedSchema:V,deref:Ji,TypeRegistry:on}=_e();function de(e){return typeof Buffer<"u"?Buffer.alloc(e):new Uint8Array(e)}var ke=Symbol("@smithy/core/cbor::tagSymbol");function Lt(e){return e[ke]=!0,e}var Sn=typeof Buffer<"u",$t=new TextDecoder,_=de(0),Vt=!1,F=new DataView(_.buffer,_.byteOffset,_.byteLength),x=0;function Zi(e){_=e,Vt=Sn&&_ instanceof Buffer,F=new DataView(_.buffer,_.byteOffset,_.byteLength)}function X(e,t){if(e>=t)throw Error("unexpected end of (decode) payload.");let n=(_[e]&224)>>5,s=_[e]&31;if(s===31&&2<=n&&n<=5)return Yi(e,t);switch(n){case 0:case 1:case 6:{let o,i;if(s<24)o=s,i=1;else switch(s){case 24:if(t-e<2)K(1);o=_[e+1],i=2;break;case 25:if(t-e<3)K(2);o=F.getUint16(e+1),i=3;break;case 26:if(t-e<5)K(4);o=F.getUint32(e+1),i=5;break;case 27:if(t-e<9)K(8);{let c=F.getUint32(e+1);if(c<2097152)o=c*4294967296+F.getUint32(e+5);else o=F.getBigUint64(e+1)}i=9;break;default:Pt(s)}if(n===0)return x=i,Bt(o);else if(n===1){let c;if(typeof o==="bigint")c=BigInt(-1)-o;else c=-1-o;return x=i,Bt(c)}else return oo(e,t,s,o,i)}case 3:return Ae(e,t);case 5:return eo(e,t);case 4:return no(e,t);case 2:return Ft(e,t);default:return co(e,t)}}function Yi(e,t){let n=(_[e]&224)>>5;if((_[e]&31)===31)switch(n){case 3:return uo(e,t);case 5:return ao(e,t);case 4:return fo(e,t);case 2:return ho(e,t)}}function vi(e,t){let n=e>>7,s=(e&124)>>2,o=(e&3)<<8|t,i=n===0?1:-1;if(s===0){if(o===0)return 0;return i*(Math.pow(2,-14)*(o/1024))}else if(s===31){if(o===0)return i*(1/0);return NaN}return i*(Math.pow(2,s-15)*(1+o/1024))}function eo(e,t){let n=Re(e,t);if(n<25)return ro(e,t,n);return to(e,t,n)}function to(e,t,n){let s=x;e+=s;let o=e,i=Object.create(null);for(let c=0;c<n;++c){let a=Ae(e,t);if(e+=x,(_[e]&224)>>5===3)i[a]=Ae(e,t);else i[a]=X(e,t);e+=x}return x=s+(e-o),Object.setPrototypeOf(i,Object.prototype),i}function ro(e,t,n){let s=x;e+=s;let o=e,i={};for(let c=0;c<n;++c){let a=Ae(e,t);e+=x,i[a]=X(e,t),e+=x}return x=s+(e-o),i}function no(e,t){let n=Re(e,t),s=x;e+=s;let o=e,i=Array(n);for(let c=0;c<n;++c)i[c]=X(e,t),e+=x;return x=s+(e-o),i}function Ae(e,t){let n=Re(e,t),s=x;if(e+=s,t-e<n)K(n);if(x=s+n,n<24)return io(e,n);if(Vt)return _.toString("utf-8",e,e+n);return $t.decode(_.subarray(e,e+n))}var cn=Array(2048),Tt=new Uint16Array(2048),xe=0;function so(){xe=xe+1&65535}function io(e,t){let n=t;for(let c=0;c<t;++c)n=n*31+_[e+c]|0;let s=n>>>0&2047,o=cn[s];if(o!==void 0){if(o.length===t){let c=!0;for(let a=0;a<t;++a)if(o.charCodeAt(a)!==_[e+a]){c=!1;break}if(c)return Tt[s]=xe,o}}let i=Vt?_.toString("utf-8",e,e+t):$t.decode(_.subarray(e,e+t));if(Tt[s]!==xe)cn[s]=i,Tt[s]=xe;return i}function Ft(e,t){let n=Re(e,t),s=x;if(e+=s,t-e<n)K(n);let o=_.subarray(e,e+n);return x=s+n,o}function oo(e,t,n,s,o){if(n===2||n===3){let i=Re(e+o,t),c=BigInt(0),a=e+o+x;for(let f=a;f<a+i;++f)c=c<<BigInt(8)|BigInt(_[f]);return x=o+x+i,n===3?-c-BigInt(1):c}else if(n===4){let i=X(e+o,t),[c,a]=i,f=a<0?-1:1,u=BigInt(f)*BigInt(a),h=String(u),l=a<0?"-":"",d;if(typeof c==="number"&&Math.abs(c)<=268435456){let y=c,g="0".repeat(Math.abs(y)+1)+h;if(d=y===0?g:g.slice(0,g.length+y)+"."+g.slice(y),d=d.replace(/^0+/g,""),d==="")d="0";if(d[0]===".")d="0"+d;d=l+d}else{let y=BigInt(c);if(h.length===1)d=l+h+"e"+String(y);else{let g=y+BigInt(h.length-1);d=l+h[0]+"."+h.slice(1)+"e"+String(g)}}return x=o+x,pn(d)}else{let i=X(e+o,t);return x=o+x,Lt({tag:Bt(s),value:i})}}function co(e,t){let n=_[e]&31;switch(n){case 21:case 20:return x=1,n===21;case 22:return x=1,null;case 23:return x=1,null;case 25:if(t-e<3)throw Error("incomplete float16 at end of buf.");return x=3,vi(_[e+1],_[e+2]);case 26:if(t-e<5)throw Error("incomplete float32 at end of buf.");return x=5,F.getFloat32(e+1);case 27:if(t-e<9)throw Error("incomplete float64 at end of buf.");return x=9,F.getFloat64(e+1);default:Pt(n)}}function Re(e,t){let n=_[e]&31;if(n<24)return x=1,n;switch(n){case 24:if(t-e<2)K(1);return x=2,_[e+1];case 25:if(t-e<3)K(2);return x=3,F.getUint16(e+1);case 26:if(t-e<5)K(4);return x=5,F.getUint32(e+1);case 27:if(t-e<9)K(8);return x=9,lo(F.getBigUint64(e+1));default:Pt(n)}}function ao(e,t){e+=1;let n=e,s={};for(;e<t;){if(_[e]===255)return x=e-n+2,s;let o=Ae(e,t);e+=x,s[o]=X(e,t),e+=x}throw Error("expected break marker.")}function fo(e,t){e+=1;let n=[];for(let s=e;e<t;){if(_[e]===255)return x=e-s+2,n;n.push(X(e,t)),e+=x}throw Error("expected break marker.")}function uo(e,t){e+=1;let n=[];for(let s=e;e<t;){if(_[e]===255){let f=de(n.length);if(f.set(n,0),x=e-s+2,Sn)return f.toString("utf-8",0,f.length);return $t.decode(f)}let o=(_[e]&224)>>5,i=_[e]&31;if(o!==3)wn(o);if(i===31)throw Error("nested indefinite string.");let c=Ft(e,t);e+=x;for(let f=0;f<c.length;++f)n.push(c[f])}throw Error("expected break marker.")}function ho(e,t){e+=1;let n=[];for(let s=e;e<t;){if(_[e]===255){let f=de(n.length);return f.set(n,0),x=e-s+2,f}let o=(_[e]&224)>>5,i=_[e]&31;if(o!==2)wn(o);if(i===31)throw Error("nested indefinite string.");let c=Ft(e,t);e+=x;for(let f=0;f<c.length;++f)n.push(c[f])}throw Error("expected break marker.")}function Bt(e){if(typeof e==="number")return e;let t=Number(e);if(Number.MIN_SAFE_INTEGER<=t&&t<=Number.MAX_SAFE_INTEGER)return t;return e}function lo(e){let t=Number(e);if(t<Number.MIN_SAFE_INTEGER||Number.MAX_SAFE_INTEGER<t)console.warn(Error(`@smithy/core/cbor - truncating BigInt(${e}) to ${t} with loss of precision.`));return t}function K(e){throw Error(`length ${e} greater than remaining buf len.`)}function Pt(e){throw Error(`unexpected minor value ${e}.`)}function wn(e){throw Error(`unexpected major type ${e} in indefinite string.`)}var mo=typeof Buffer<"u",ce=new Map,Ee=0,Ut=!1,go=2048,w=de(go),L=new DataView(w.buffer,w.byteOffset,w.byteLength),p=0;function po(e){let t=[e];while(t.length){let n=t.pop();if(typeof n==="string"){let s=n.length;if(mo)if(ae(s*3+9),s>23)It(3,Buffer.byteLength(n)),p+=w.write(n,p);else So(n);else{let o=s*3;ae(o+9);let i=p,a=new TextEncoder().encodeInto(n,w.subarray(p+9)).written,f;if(a<24)f=1;else if(a<256)f=2;else if(a<65536)f=3;else if(a<4294967296)f=5;else f=9;if(f<9)w.copyWithin(i+f,i+9,i+9+a);p=i,re(3,a),p+=a}continue}if(w.byteLength-p<9)ae(64);if(typeof n==="number"){if(Number.isInteger(n)&&n>=-9007199254740992&&n<=9007199254740991){let s=n>=0,o=s?0:1,i=s?n:-n-1;if(i<24)w[p++]=o<<5|i;else if(i<256)w[p++]=o<<5|24,w[p++]=i;else if(i<65536)w[p++]=o<<5|25,w[p++]=i>>8,w[p++]=i&255;else if(i<4294967296)w[p++]=o<<5|26,L.setUint32(p,i),p+=4;else{w[p++]=o<<5|27;let c=i/4294967296|0,a=i-c*4294967296|0;L.setUint32(p,c),L.setUint32(p+4,a),p+=8}continue}w[p++]=251,L.setFloat64(p,n),p+=8;continue}else if(typeof n==="bigint"){let s=n>=0,o=s?0:1,i=s?n:-n-BigInt(1);if(i<BigInt("18446744073709551616")){let c=Number(i);if(c<4294967296)re(o,c);else w[p++]=o<<5|27,L.setBigUint64(p,i),p+=8}else{let c=i.toString(2),a=new Uint8Array(Math.ceil(c.length/8)),f=i,u=0;while(a.byteLength-++u>=0)a[a.byteLength-u]=Number(f&BigInt(255)),f>>=BigInt(8);ae(a.byteLength*2+16),w[p++]=s?194:195,It(2,a.byteLength),w.set(a,p),p+=a.byteLength}continue}else if(n===null){w[p++]=246;continue}else if(typeof n==="boolean"){w[p++]=224|(n?21:20);continue}else if(typeof n>"u")throw Error("@smithy/core/cbor: client may not serialize undefined value.");else if(Array.isArray(n)){re(4,n.length),ae(n.length*9+64);for(let s=n.length-1;s>=0;--s)t.push(n[s]);continue}else if(typeof n.byteLength==="number"){ae(n.length*2+9),re(2,n.length),w.set(n,p),p+=n.byteLength;continue}else if(typeof n==="object"){if(n instanceof Te){let i=n.string,c=BigInt(0),a=i.search(/[eE]/);if(a!==-1)c=BigInt(i.slice(a+1)),i=i.slice(0,a);let f=i.indexOf("."),u=f===-1?0:i.length-f-1,h=c-BigInt(u),l=BigInt(i.replace(".",""));w[p++]=196,re(4,2),t.push(l),t.push(h>=-0x20000000000000n&&h<=0x1fffffffffffffn?Number(h):h);continue}if(n[ke])if("tag"in n&&"value"in n){t.push(n.value),It(6,n.tag);continue}else throw Error("tag encountered with missing fields, need 'tag' and 'value', found: "+JSON.stringify(n));let s=Object.keys(n),o=s.length;re(5,o);for(let i=o-1;i>=0;--i)t.push(n[s[i]]),t.push(s[i]);continue}throw Error(`data type ${n?.constructor?.name??typeof n} not compatible for encoding.`)}}function yo(){Ee=Ee+1&65535,Ut=!1}function an(){let e=de(p);return e.set(w.subarray(0,p),0),p=0,e}function Dt(e){let t=w;if(w=de(e),t)if(t.copy)t.copy(w,0,0,t.byteLength);else w.set(t,0);L=new DataView(w.buffer,w.byteOffset,w.byteLength)}function So(e){let t=ce.get(e);if(t!==void 0){w.set(t.bytes,p),p+=t.bytes.length,t.epoch=Ee;return}let n=p,s=Buffer.byteLength(e);re(3,s),p+=w.write(e,p);let o=Uint8Array.prototype.slice.call(w,n,p);if(ce.size>=2048){if(Ut)return;let i=0;for(let[c,a]of ce){if(i>=1024)break;if(a.epoch!==Ee)ce.delete(c),i++}if(i===0){Ut=!0;return}}if(ce.size<2048)ce.set(e,{epoch:Ee,bytes:o})}function ae(e){if(w.byteLength-p<e)if(p<16000000)Dt(Math.max(w.byteLength*4,w.byteLength+e));else Dt(w.byteLength+e+16000000)}function It(e,t){if(t<24)w[p++]=e<<5|t;else if(t<256)w[p++]=e<<5|24,w[p++]=t;else if(t<65536)w[p++]=e<<5|25,L.setUint16(p,t),p+=2;else if(t<4294967296)w[p++]=e<<5|26,L.setUint32(p,t),p+=4;else w[p++]=e<<5|27,L.setBigUint64(p,typeof t==="bigint"?t:BigInt(t)),p+=8}function re(e,t){if(t<24)w[p++]=e<<5|t;else if(t<256)w[p++]=e<<5|24,w[p++]=t;else if(t<65536)w[p++]=e<<5|25,w[p++]=t>>8,w[p++]=t&255;else if(t<4294967296)w[p++]=e<<5|26,L.setUint32(p,t),p+=4;else{w[p++]=e<<5|27;let n=t/4294967296|0,s=t-n*4294967296|0;L.setUint32(p,n),L.setUint32(p+4,s),p+=8}}var We={deserialize(e){return so(),Zi(e),X(0,e.length)},serialize(e){yo();try{return po(e),an()}catch(t){throw an(),t}},resizeEncodingBuffer(e){Dt(e)}},bn=(e,t)=>Wi(e,t).then(async(n)=>{if(n.length)try{return We.deserialize(n)}catch(s){throw Object.defineProperty(s,"$responseBodyText",{value:t.utf8Encoder(n)}),s}return{}}),Ke=(e)=>Lt({tag:1,value:e.getTime()/1000}),wo=async(e,t)=>{let n=await bn(e,t);return n.message=n.message??n.Message,n},xn=(e,t)=>{let n=(s)=>{let o=s;if(typeof o==="number")o=o.toString();if(o.indexOf(",")>=0)o=o.split(",")[0];if(o.indexOf(":")>=0)o=o.split(":")[0];return o};if(t.__type!==void 0)return n(t.__type)},bo=(e)=>{if(String(e.headers["smithy-protocol"]).toLowerCase()!=="rpc-v2-cbor")throw Error("Malformed RPCv2 CBOR response, status: "+e.statusCode)},xo=async(e,t,n,s,o)=>{let i=await e.endpoint(),{hostname:c,protocol:a="https",port:f,path:u}=i,h={protocol:a,hostname:c,port:f,method:"POST",path:u.endsWith("/")?u.slice(0,-1)+n:u+n,headers:{...t}};if(s!==void 0)h.hostname=s;if(i.headers)for(let l in i.headers){if(!U(i.headers,l))continue;h.headers[l]=i.headers[l]}if(o!==void 0){h.body=o;try{h.headers["content-length"]=String(qi(o))}catch(l){}}return new Gi(h)};class Ht extends Ie{write(e,t){b=0;let n=V.of(e);ue(n,t,void 0,this.serdeContext)}flush(){let e=N.subarray(0,b);return b=0,N=En(jt),ne=new DataView(N.buffer,N.byteOffset,N.byteLength),e}}var fn=Symbol.for("@smithy/cbor-struct-cache");function Kt(e){let t=e.getSchema(),n=t[fn];if(n)return n;let s=[],o=[];for(let[a,f]of e.structIterator())s.push(a),o.push(f);let i=Array(s.length);for(let a=0;a<s.length;++a)i[a]=Eo(s[a]);let c={memberNames:s,memberSchemas:o,encodedKeys:i};return t[fn]=c,c}function Eo(e){let t;if(Xe)t=Buffer.from(e,"utf-8");else t=new TextEncoder().encode(e);let n=t.length,s;if(n<24)s=1;else if(n<256)s=2;else s=3;let o=new Uint8Array(s+n);if(s===1)o[0]=96|n;else if(s===2)o[0]=120,o[1]=n;else o[0]=121,o[1]=n>>8,o[2]=n&255;return o.set(t,s),o}var Xe=typeof Buffer<"u",No=new TextEncoder,jt=2048,N=Xe?Buffer.allocUnsafe(jt):new Uint8Array(jt),ne=new DataView(N.buffer,N.byteOffset,N.byteLength),b=0,un=2048,fe=new Map,kt=0,hn=!1;function En(e){return Xe?Buffer.allocUnsafe(e):new Uint8Array(e)}function ue(e,t,n,s){if(t==null){if(t===void 0&&e.isIdempotencyToken()){q(yn());return}C(1),N[b++]=246;return}if(e.isUnitSchema()){C(1),R(5,0);return}if(typeof t==="object"){if(e.isBlobSchema()){if(t instanceof Uint8Array){qe(t);return}}if(e.isTimestampSchema()){if(t instanceof Date){zt(t);return}}if(e.isStructSchema()){_o(e,t,s);return}if(Array.isArray(t)&&(e.isListSchema()||e.isDocumentSchema())){ln(e,t,e.isDocumentSchema(),s);return}if(e.isMapSchema()){Rt(e,t,!1,s);return}if(t instanceof Date){zt(t);return}if(t instanceof Uint8Array){qe(t);return}if(t instanceof Te){Cn(t);return}if(t[ke]){let i=t;_n(i.tag,i.value);return}if(e.isDocumentSchema()){if(Array.isArray(t))ln(e,t,!0,s);else Rt(e,t,!0,s);return}if(e.isBigDecimalSchema()){he(t);return}Rt(e,t,!0,s);return}if(typeof t==="string"){if(e.isBlobSchema()){let i=(s?.base64Decoder??Ot)(t);qe(i);return}q(t);return}if(typeof t==="number"){if(C(9),Number.isInteger(t)&&t>=-9007199254740992&&t<=9007199254740991)Je(t);else qt(t);return}if(typeof t==="boolean"){C(1),N[b++]=224|(t?21:20);return}if(typeof t==="bigint"){Ge(t);return}q(String(t))}function _o(e,t,n){if(e.isUnionSchema()){let l=!1;for(let[d,m]of e.structIterator()){let y=t[d];if(y!=null){C(9),R(5,1),q(d),ue(m,y,e,n),l=!0;break}}if(!l){let{$unknown:d}=t;if(Array.isArray(d))C(9),R(5,1),q(d[0]),he(d[1]);else C(9),R(5,0)}return}let s=Kt(e),{memberNames:o,memberSchemas:i,encodedKeys:c}=s,a=o.length,f;if(a<24)f=1;else if(a<256)f=2;else f=3;C(f);let u=b;b+=f;let h=0;for(let l=0;l<a;++l){let d=t[o[l]];if(d==null&&!i[l].isIdempotencyToken())continue;let m=c[l];C(m.length),N.set(m,b),b+=m.length,ue(i[l],d,e,n),++h}if(typeof t.__type==="string")for(let l in t){if(!U(t,l))continue;if(!o.includes(l))q(l),he(t[l]),++h}if(f===1)N[u]=160|h;else if(f===2)N[u]=184,N[u+1]=h;else N[u]=185,N[u+1]=h>>8,N[u+2]=h&255}function ln(e,t,n,s){let o=!!e.getMergedTraits().sparse,i=e.getValueSchema();if(n||o){let c=[];for(let a=0;a<t.length;++a){let f=t[a];if(n){if(f!==void 0)c.push(f)}else if(f!=null||o)c.push(f)}C(9),R(4,c.length);for(let a=0;a<c.length;++a)ue(i,c[a],void 0,s)}else{let c=0;for(let a=0;a<t.length;++a)if(t[a]!=null)++c;C(9),R(4,c);for(let a=0;a<t.length;++a)if(t[a]!=null)ue(i,t[a],void 0,s)}}function Rt(e,t,n,s){let o=!!e.getMergedTraits().sparse,i=e.getValueSchema(),c=[];for(let a in t){if(!U(t,a))continue;let f=t[a];if(n?f!==void 0:f!=null||o)c.push(a)}C(9),R(5,c.length);for(let a=0;a<c.length;++a){let f=c[a];q(f),ue(i,t[f],void 0,s)}}function he(e){if(e==null){C(1),N[b++]=246;return}if(typeof e==="string"){q(e);return}if(typeof e==="number"){if(C(9),Number.isInteger(e)&&e>=-9007199254740992&&e<=9007199254740991)Je(e);else qt(e);return}if(typeof e==="boolean"){C(1),N[b++]=224|(e?21:20);return}if(typeof e==="bigint"){Ge(e);return}if(e instanceof Uint8Array){qe(e);return}if(e instanceof Date){zt(e);return}if(e instanceof Te){Cn(e);return}if(e[ke]){let t=e;_n(t.tag,t.value);return}if(Array.isArray(e)){C(9),R(4,e.length);for(let t=0;t<e.length;++t)he(e[t]);return}if(typeof e==="object"){let t=Object.keys(e);C(9),R(5,t.length);for(let n=0;n<t.length;++n)q(t[n]),he(e[t[n]]);return}q(String(e))}function C(e){if(b+e>N.length){let t=N.length*2;while(t<b+e)t*=2;let n=En(t);n.set(N.subarray(0,b)),N=n,ne=new DataView(n.buffer,n.byteOffset,n.byteLength)}}function R(e,t){if(t<24)N[b++]=e<<5|t;else if(t<256)N[b++]=e<<5|24,N[b++]=t;else if(t<65536)N[b++]=e<<5|25,N[b++]=t>>8,N[b++]=t&255;else if(t<4294967296)N[b++]=e<<5|26,ne.setUint32(b,t),b+=4;else{N[b++]=e<<5|27;let n=t/4294967296|0,s=t-n*4294967296|0;ne.setUint32(b,n),ne.setUint32(b+4,s),b+=8}}function Nn(e,t){let n=Number(t);if(n<4294967296){R(e,n);return}N[b++]=e<<5|27,ne.setBigUint64(b,t),b+=8}function q(e){let t=e.length;if(t<=23){let n=fe.get(e);if(n){C(n.bytes.length),N.set(n.bytes,b),b+=n.bytes.length,n.epoch=kt;return}let s=b;dn(e,t);let o=b,i=Uint8Array.prototype.slice.call(N,s,o);if(fe.size>=un){if(hn)return;let c=0;for(let[a,f]of fe){if(c>=1024)break;if(f.epoch!==kt)fe.delete(a),++c}if(c===0){hn=!0;return}}if(fe.size<un)fe.set(e,{epoch:kt,bytes:i});return}dn(e,t)}function dn(e,t){if(Xe){let n=t*3;C(n+9);let s=Buffer.byteLength(e);R(3,s),b+=N.write(e,b)}else{let n=t*3;C(n+9);let s=b,i=No.encodeInto(e,N.subarray(s+9)).written,c;if(i<24)c=1;else if(i<256)c=2;else if(i<65536)c=3;else if(i<4294967296)c=5;else c=9;if(c<9)N.copyWithin(s+c,s+9,s+9+i);b=s,R(3,i),b+=i}}function qt(e){C(9),N[b++]=251,ne.setFloat64(b,e),b+=8}function Je(e){C(9);let t=e>=0,n=t?0:1,s=t?e:-e-1;R(n,s)}function Ge(e){let t=e>=0,n=t?0:1,s=t?e:-e-BigInt(1);if(s<BigInt("18446744073709551616"))C(9),Nn(n,s);else{let o=s.toString(2),i=Math.ceil(o.length/8),c=new Uint8Array(i),a=s;for(let f=i-1;f>=0;--f)c[f]=Number(a&BigInt(255)),a>>=BigInt(8);C(i+16),N[b++]=t?194:195,R(2,i),N.set(c,b),b+=i}}function qe(e){C(e.length+9),R(2,e.length),N.set(e,b),b+=e.length}function _n(e,t){if(C(9),typeof e==="bigint")Nn(6,e);else R(6,e);he(t)}function Cn(e){let t=e.string,n=BigInt(0),s=t.search(/[eE]/);if(s!==-1)n=BigInt(t.slice(s+1)),t=t.slice(0,s);let o=t.indexOf("."),i=o===-1?0:t.length-o-1,c=n-BigInt(i),a=BigInt(t.replace(".",""));if(C(9),N[b++]=196,R(4,2),C(9),c>=-0x20000000000000n&&c<=0x1fffffffffffffn)Je(Number(c));else Ge(c);Ge(a)}function zt(e){C(18),R(6,1);let t=e.getTime()/1000;if(Number.isInteger(t))Je(t);else qt(t)}class Qt extends Ie{read(e,t){return I=t,Wt=An&&t instanceof Buffer,W=new DataView(t.buffer,t.byteOffset,t.byteLength),S=0,k=t.length,Ne=Ne+1&65535,O(V.of(e))}readValue(e,t){return Qe(V.of(e),t)}}var An=typeof Buffer<"u",Gt=new TextDecoder,I=new Uint8Array(0),Wt=!1,W=new DataView(new ArrayBuffer(0)),S=0,k=0,Xt=2048,mn=Array(Xt),Mt=new Uint16Array(Xt),Ne=0;function O(e){if(S>=k)throw Error("unexpected end of CBOR payload.");let t=(I[S]&224)>>5;if((I[S]&31)===31&&t>=2&&t<=5)return ko(e,t);switch(t){case 0:return Do();case 1:return jo();case 2:return ve();case 3:return le();case 4:return Co(e);case 5:return Ao(e);case 6:return Io();case 7:return Oo();default:throw Error(`unexpected CBOR major type ${t}.`)}}function Co(e){let t=Ye(),n=e.isListSchema()?e.getValueSchema():e,s=Array(t);for(let o=0;o<t;++o)s[o]=O(n);return s}function Ao(e){let t=Ye();if(e.isStructSchema())return To(e,t,S);let n=e.isMapSchema()?e.getValueSchema():e,s={};for(let o=0;o<t;++o){let i=le();s[i]=O(n)}return s}function To(e,t,n){let s=e.isUnionSchema(),o=Kt(e),{memberSchemas:i,encodedKeys:c,memberNames:a}=o,f=c.length,u={},h,l,d=0,m=!1,y=0;for(let g=0;g<t;++g){let E=Tn(c,f,y);if(E>=0){if(y=E+1,y>=f)y=0;let T=O(i[E]);if(T!=null)u[a[E]]=T}else{let T=le(),D=O(V.of(15));if(T==="__type"&&typeof D==="string")m=!0;else h=T,l=D,++d}}if(s){let g=!0;for(let E in u){if(!U(u,E))continue;g=!1;break}if(g&&d===1)u.$unknown=[h,l]}else if(m){S=n;let g=V.of(15);for(let E=0;E<t;++E){let T=le(),D=O(g);if(!(T in u))u[T]=D}}return u}function Io(e){let t=Ze(),n=typeof t==="bigint"?Number(t):t;if(n===1){let i=V.of(15),c=O(i);return Ce(c)}if(n===2||n===3){let i=ve(),c=BigInt(0);for(let a=0;a<i.length;++a)c=c<<BigInt(8)|BigInt(i[a]);return n===3?-c-BigInt(1):c}if(n===4){let i=V.of(15),c=O(i),[a,f]=c,u=f<0?-1:1,h=BigInt(u)*BigInt(f),l=String(h),d=f<0?"-":"",m;if(typeof a==="number"&&Math.abs(a)<=268435456){let g=a,E="0".repeat(Math.abs(g)+1)+l;if(m=g===0?E:E.slice(0,E.length+g)+"."+E.slice(g),m=m.replace(/^0+/g,""),m==="")m="0";if(m[0]===".")m="0"+m;m=d+m}else{let g=BigInt(a);if(l.length===1)m=d+l+"e"+String(g);else{let E=g+BigInt(l.length-1);m=d+l[0]+"."+l.slice(1)+"e"+String(E)}}return pn(m)}let s=V.of(15),o=O(s);return{tag:In(t),value:o}}function ko(e,t){switch(t){case 3:return Ro();case 2:return Mo();case 4:return Bo(e);case 5:return Uo(e);default:throw Error(`unexpected indefinite length for major ${t}.`)}}function Ro(){S+=1;let e=[],t=0;while(S<k){if(I[S]===255){S+=1;let s=new Uint8Array(t),o=0;for(let i=0;i<e.length;++i)s.set(e[i],o),o+=e[i].length;if(An)return Buffer.from(s.buffer,s.byteOffset,s.byteLength).toString("utf-8");return Gt.decode(s)}let n=ve();e.push(n),t+=n.length}throw Error("expected break marker.")}function Mo(){S+=1;let e=[],t=0;while(S<k){if(I[S]===255){S+=1;let s=new Uint8Array(t),o=0;for(let i=0;i<e.length;++i)s.set(e[i],o),o+=e[i].length;return s}let n=ve();e.push(n),t+=n.length}throw Error("expected break marker.")}function Bo(e){S+=1;let t=e.isListSchema()?e.getValueSchema():e,n=[];while(S<k){if(I[S]===255)return S+=1,n;n.push(O(t))}throw Error("expected break marker.")}function Uo(e){if(S+=1,e.isStructSchema()){let s=Kt(e),{memberSchemas:o,encodedKeys:i,memberNames:c}=s,a=i.length,f=e.isUnionSchema(),u={},h,l,d=0,m=0;while(S<k){if(I[S]===255){if(S+=1,f){let g=!0;for(let E in u){if(!U(u,E))continue;g=!1;break}if(g&&d===1)u.$unknown=[h,l]}return u}let y=Tn(i,a,m);if(y>=0){if(m=y+1,m>=a)m=0;let g=O(o[y]);if(g!=null)u[c[y]]=g}else{let g=le(),E=O(V.of(15));if(g!=="__type")h=g,l=E,++d}}throw Error("expected break marker.")}let t=e.isMapSchema()?e.getValueSchema():e,n={};while(S<k){if(I[S]===255)return S+=1,n;let s=le();n[s]=O(t)}throw Error("expected break marker.")}function Tn(e,t,n){let s=e[n];if(S+s.length<=k&&gn(S,s))return S+=s.length,n;for(let o=0;o<t;++o){if(o===n)continue;let i=e[o];if(S+i.length<=k&&gn(S,i))return S+=i.length,o}return-1}function gn(e,t){let n=t.length;if(I[e]!==t[0])return!1;for(let s=1;s<n;++s)if(I[e+s]!==t[s])return!1;return!0}function Ze(){let e=I[S]&31;if(e<24)return S+=1,e;switch(e){case 24:if(k-S<2)G(1);return S+=2,I[S-1];case 25:if(k-S<3)G(2);return S+=3,W.getUint16(S-2);case 26:if(k-S<5)G(4);return S+=5,W.getUint32(S-4);case 27:{if(k-S<9)G(8);S+=9;let t=W.getUint32(S-8);if(t<2097152)return t*4294967296+W.getUint32(S-4);return W.getBigUint64(S-8)}default:throw Error(`unexpected minor value ${e}.`)}}function Ye(){let e=Ze();return typeof e==="bigint"?Number(e):e}function Do(){let e=Ze();return In(e)}function jo(){let e=Ze();if(typeof e==="bigint")return BigInt(-1)-e;return-1-e}function ve(){let e=Ye();if(k-S<e)G(e);let t=S;return S+=e,I.subarray(t,t+e)}function le(){let e=Ye();if(k-S<e)G(e);let t=S;if(S+=e,e<24)return zo(t,e);if(Wt)return I.toString("utf-8",t,t+e);return Gt.decode(I.subarray(t,t+e))}function zo(e,t){let n=t;for(let c=0;c<t;++c)n=n*31+I[e+c]|0;let s=n>>>0&Xt-1,o=mn[s];if(o!==void 0&&o.length===t){let c=!0;for(let a=0;a<t;++a)if(o.charCodeAt(a)!==I[e+a]){c=!1;break}if(c)return Mt[s]=Ne,o}let i=Wt?I.toString("utf-8",e,e+t):Gt.decode(I.subarray(e,e+t));if(Mt[s]!==Ne)mn[s]=i,Mt[s]=Ne;return i}function Oo(){let e=S,t=I[e]&31;switch(t){case 21:return S=e+1,!0;case 20:return S=e+1,!1;case 22:return S=e+1,null;case 23:return S=e+1,null;case 25:{if(k-e<3)G(2);return S=e+3,Lo(I[e+1],I[e+2])}case 26:{if(k-e<5)G(4);return S=e+5,W.getFloat32(e+1)}case 27:{if(k-e<9)G(8);return S=e+9,W.getFloat64(e+1)}default:throw Error(`unexpected minor value ${t} for major 7.`)}}function Lo(e,t){let n=e>>7,s=(e&124)>>2,o=(e&3)<<8|t,i=n===0?1:-1;if(s===0){if(o===0)return 0;return i*(Math.pow(2,-14)*(o/1024))}else if(s===31){if(o===0)return i*(1/0);return NaN}return i*(Math.pow(2,s-15)*(1+o/1024))}function In(e){if(typeof e==="number")return e;let t=Number(e);if(Number.MIN_SAFE_INTEGER<=t&&t<=Number.MAX_SAFE_INTEGER)return t;return e}function G(e){throw Error(`CBOR: length ${e} greater than remaining buffer length.`)}function Qe(e,t){if(e.isTimestampSchema()){if(typeof t==="number")return Ce(t);if(typeof t==="object"&&t!==null){if(t.tag===1&&"value"in t)return Ce(t.value)}}if(e.isBlobSchema())return t;if(typeof t>"u"||typeof t==="boolean"||typeof t==="number"||typeof t==="string"||typeof t==="bigint"||typeof t==="symbol")return t;if(typeof t!=="object"||t===null)return t;if("byteLength"in t)return t;if(t instanceof Date)return t;if(t instanceof Te)return t;if(e.isDocumentSchema())return t;if(e.isListSchema()){let s=e.getValueSchema(),o=[];for(let i of t)o.push(Qe(s,i));return o}let n={};if(e.isMapSchema()){let s=e.getValueSchema();for(let o in t){if(!U(t,o))continue;n[o]=Qe(s,t[o])}}else if(e.isStructSchema()){let s=e.isUnionSchema(),o;if(s){o=new Set;for(let i in t){if(!U(t,i))continue;if(i!=="__type")o.add(i)}}for(let[i,c]of e.structIterator()){if(s)o.delete(i);if(t[i]!=null)n[i]=Qe(c,t[i])}if(s&&o?.size===1){let i=!0;for(let c in n){if(!U(n,c))continue;i=!1;break}if(i){let c=o.values().next().value;n.$unknown=[c,t[c]]}}else if(typeof t.__type==="string")for(let i in t){if(!U(t,i))continue;if(!(i in n))n[i]=t[i]}}return n}class Jt extends Ie{createSerializer(){let e=new Ht;return e.setSerdeContext(this.serdeContext),e}createDeserializer(){let e=new Qt;return e.setSerdeContext(this.serdeContext),e}}class kn extends Xi{codec=new Jt;serializer=this.codec.createSerializer();deserializer=this.codec.createDeserializer();constructor({defaultNamespace:e,errorTypeRegistries:t}){super({defaultNamespace:e,errorTypeRegistries:t})}getShapeId(){return"smithy.protocols#rpcv2Cbor"}getPayloadCodec(){return this.codec}async serializeRequest(e,t,n){let s=await super.serializeRequest(e,t,n);if(Object.assign(s.headers,{"content-type":this.getDefaultContentType(),"smithy-protocol":"rpc-v2-cbor",accept:this.getDefaultContentType()}),Ji(e.input)==="unit")delete s.body,delete s.headers["content-type"];else{if(!s.body)this.serializer.write(15,{}),s.body=this.serializer.flush();if(s.body instanceof Uint8Array)s.headers["content-length"]=String(s.body.byteLength)}let{service:o,operation:i}=Qi(n),c=`/service/${o}/operation/${i}`;if(s.path.endsWith("/"))s.path+=c.slice(1);else s.path+=c;return s}async deserializeResponse(e,t,n){return super.deserializeResponse(e,t,n)}async handleError(e,t,n,s,o){let i=xn(n,s)??"Unknown",c=["*"],{defaultNamespace:a}=this.options;c.unshift(a);let[f,u]=(()=>{if(i.includes("#"))return i.split("#");return[void 0,i]})();if(f)c.unshift(f);let h={$metadata:o,$fault:n.statusCode<500?"client":"server"},l=[this.compositeErrorRegistry];if(f)l.push(on.for(f));l.push(on.for(a));let[d,m,y]=this.resolveError(u,c,l);if(y==="native"||y==="synthetic"){if(s.Message)s.message=s.Message;let j=y==="synthetic"?new m({name:u}):Error(u);throw Object.assign(j,h,s)}let g=V.of(d),E=s.message??s.Message??"Unknown",T=new m({}),D={};for(let[j,Y]of g.structIterator())D[j]=this.deserializer.readValue(Y,s[j]);throw Object.assign(T,h,{$fault:g.getMergedTraits().error,message:E},D)}getDefaultContentType(){return"application/cbor"}}class Rn extends Ie{value;write(e,t){this.value=this.serialize(e,t)}serialize(e,t){let n=V.of(e);if(t==null){if(n.isIdempotencyToken())return yn();return t}if(n.isBlobSchema()){if(typeof t==="string")return(this.serdeContext?.base64Decoder??Ot)(t);return t}if(n.isTimestampSchema()){if(typeof t==="number"||typeof t==="bigint")return Ke(new Date(Number(t)/1000|0));return Ke(t)}if(typeof t==="function"||typeof t==="object"){let s=t;if(n.isListSchema()&&Array.isArray(s)){let i=!!n.getMergedTraits().sparse,c=[],a=0;for(let f of s){let u=this.serialize(n.getValueSchema(),f);if(u!=null||i)c[a++]=u}return c}if(s instanceof Date)return Ke(s);let o={};if(n.isMapSchema()){let i=!!n.getMergedTraits().sparse;for(let c in s){if(!U(s,c))continue;let a=this.serialize(n.getValueSchema(),s[c]);if(a!=null||i)o[c]=a}}else if(n.isStructSchema()){for(let[c,a]of n.structIterator()){let f=this.serialize(a,s[c]);if(f!=null)o[c]=f}if(n.isUnionSchema()&&Array.isArray(s.$unknown)){let[c,a]=s.$unknown;o[c]=a}else if(typeof s.__type==="string")for(let c in s){if(!U(s,c))continue;if(!(c in o))o[c]=this.serialize(15,s[c])}}else if(n.isDocumentSchema()){if(Array.isArray(s)){let i=[],c=0;for(let a of s)i[c++]=this.serialize(n.getValueSchema(),a);return i}for(let i in s){if(!U(s,i))continue;o[i]=this.serialize(n.getValueSchema(),s[i])}}else if(n.isBigDecimalSchema())return s;return o}return t}flush(){let e=We.serialize(this.value);return this.value=void 0,e}}class Mn extends Ie{read(e,t){let n=We.deserialize(t);return this.readValue(e,n)}readValue(e,t){let n=V.of(e);if(n.isTimestampSchema()){if(typeof t==="number")return Ce(t);if(typeof t==="object"){if(t.tag===1&&"value"in t)return Ce(t.value)}}if(n.isBlobSchema()){if(typeof t==="string")return(this.serdeContext?.base64Decoder??Ot)(t);return t}if(typeof t>"u"||typeof t==="boolean"||typeof t==="number"||typeof t==="string"||typeof t==="bigint"||typeof t==="symbol")return t;else if(typeof t==="object"){if(t===null)return null;if("byteLength"in t)return t;if(t instanceof Date)return t;if(n.isDocumentSchema())return t;if(n.isListSchema()){let o=[],i=n.getValueSchema();for(let c of t){let a=this.readValue(i,c);o.push(a)}return o}let s={};if(n.isMapSchema()){let o=n.getValueSchema();for(let i in t){if(!U(t,i))continue;let c=this.readValue(o,t[i]);s[i]=c}}else if(n.isStructSchema()){let o=n.isUnionSchema(),i;if(o){i=new Set;for(let c in t){if(!U(t,c))continue;if(c!=="__type")i.add(c)}}for(let[c,a]of n.structIterator()){if(o)i.delete(c);if(t[c]!=null)s[c]=this.readValue(a,t[c])}if(o&&i?.size===1){let c=!0;for(let a in s){if(!U(s,a))continue;c=!1;break}if(c){let a=i.values().next().value;s.$unknown=[a,t[a]]}}else if(typeof t.__type==="string")for(let c in t){if(!U(t,c))continue;if(!(c in s))s[c]=t[c]}}else if(t instanceof Te)return t;return s}else return t}}$o.CborCodec=Jt;$o.CborShapeDeserializer=Mn;$o.CborShapeDeserializer2=Qt;$o.CborShapeSerializer=Rn;$o.CborShapeSerializer2=Ht;$o.SmithyRpcV2CborProtocol=kn;$o.buildHttpRpcRequest=xo;$o.cbor=We;$o.checkCborResponse=bo;$o.dateToTag=Ke;$o.loadSmithyRpcV2CborErrorCode=xn;$o.parseCborBody=bn;$o.parseCborErrorBody=wo;$o.tag=Lt;$o.tagSymbol=ke});var Un=r(function(ac){var tc=/[&<>"]/g,rc={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;"};function nc(e){return e.replace(tc,(t)=>rc[t])}var sc=/[&"'<>\r\n\u0085\u2028]/g,ic={"&":"&amp;",'"':"&quot;","'":"&apos;","<":"&lt;",">":"&gt;","\r":"&#x0D;","\n":"&#x0A;","\x85":"&#x85;","\u2028":"&#x2028;"};function oc(e){return e.replace(sc,(t)=>ic[t])}class Yt{value;constructor(e){this.value=e}toString(){return oc(""+this.value)}}class Me{name;children;attributes={};static of(e,t,n){let s=new Me(e);if(t!==void 0)s.addChildNode(new Yt(t));if(n!==void 0)s.withName(n);return s}constructor(e,t=[]){this.name=e,this.children=t}withName(e){return this.name=e,this}addAttribute(e,t){return this.attributes[e]=t,this}addChildNode(e){return this.children.push(e),this}removeAttribute(e){return delete this.attributes[e],this}n(e){return this.name=e,this}c(e){return this.children.push(e),this}a(e,t){if(t!=null)this.attributes[e]=t;return this}cc(e,t,n=t){if(e[t]!=null){let s=Me.of(t,e[t]).withName(n);this.c(s)}}l(e,t,n,s){if(e[t]!=null)s().map((i)=>{i.withName(n),this.c(i)})}lc(e,t,n,s){if(e[t]!=null){let o=s(),i=new Me(n);o.map((c)=>{i.c(c)}),this.c(i)}}toString(){let e=Boolean(this.children.length),t=`<${this.name}`,n=this.attributes;for(let s of Object.keys(n)){let o=n[s];if(o!=null)t+=` ${s}="${nc(""+o)}"`}return t+=!e?"/>":`>${this.children.map((s)=>s.toString()).join("")}</${this.name}>`}}function Zt(e){Object.defineProperty(e,"__proto__",{value:void 0,writable:!0,enumerable:!0,configurable:!0})}function cc(e){return new vt(e).parse()}class vt{x;i=0;z;constructor(e){this.x=e,this.x=e.replace(/\r\n?/g,`
14
14
  `),this.z=this.x.length}parse(){let e=this,{z:t}=e;while(e.i<t){if(e.trim(),e.i>=t)break;if(e.isNext("<?"))e.readTo("?>"),e.trim();else if(e.isNext("<!--"))e.readTo("-->"),e.trim();else if(e.isNext("<!DOCTYPE",!1))e.skipDoctype(),e.trim();else if(e.x[e.i]==="<"){let n=e.parseTag();return{[n.tag]:n.value}}else throw Error("@aws-sdk XML parse error: unexpected content.")}throw Error("@aws-sdk XML parse error: no root element.")}isNext(e,t=!0){let n=this;if(t)return n.x.startsWith(e,n.i);return n.x.toLowerCase().startsWith(e.toLowerCase(),n.i)}readTo(e){let t=this,n=t.x.indexOf(e,t.i);if(n===-1)throw Error(`@aws-sdk XML parse error: expected "${e}" not found.`);let s=t.x.slice(t.i,n);return t.i=n+e.length,s}trim(){let e=this;while(e.i<e.z&&` \r
15
15
  `.includes(e.x[e.i]))++e.i}readAttrValue(){let e=this,t=e.x[e.i];++e.i;let n="";while(e.i<e.z&&e.x[e.i]!==t)n+=e.x[e.i++];return++e.i,e.decodeEntities(n)}parseTag(){let e=this;++e.i;let t="";while(e.i<e.z&&!` \r
16
16
  >/`.includes(e.x[e.i]))t+=e.x[e.i++];let n=!1,s={};while(e.i<e.z){if(e.trim(),">/".includes(e.x[e.i]))break;let u="";while(e.i<e.z&&!`= \r
17
17
  >/?`.includes(e.x[e.i]))u+=e.x[e.i++];if(e.trim(),e.x[e.i]!=="=")break;if(++e.i,e.trim(),u==="__proto__")Zt(s);s[u]=e.readAttrValue(),n=!0}if(e.i>=e.z)throw Error("@aws-sdk XML parse error: unexpected end of input.");if(e.x[e.i]==="/"){if(++e.i,e.i>=e.z||e.x[e.i]!==">")throw Error("@aws-sdk XML parse error: expected > at the end of self-closing tag.");return++e.i,{tag:t,value:n?s:""}}if(e.x[e.i]!==">")throw Error("@aws-sdk XML parse error: expected > at the end of opening tag.");++e.i;let o=[],i=[],c=!1;while(e.i<e.z){if(e.isNext("</"))break;if(e.x[e.i]==="<")if(e.isNext("<!--"))e.readTo("-->");else if(e.isNext("<![CDATA["))e.i+=9,o.push(e.readTo("]]>"));else if(e.isNext("<?"))e.readTo("?>");else c=!0,i.push(e.parseTag());else{let u="";while(e.i<e.z&&e.x[e.i]!=="<")u+=e.x[e.i++];o.push(e.decodeEntities(u))}}if(!e.isNext("</"))throw Error(`@aws-sdk XML parse error: missing closing tag </${t}>.`);e.i+=2;let a=e.readTo(">").trim();if(a!==t)throw Error(`@aws-sdk XML parse error: mismatched tags <${t}> and </${a}>.`);if(!n&&o.length===0&&!c)return{tag:t,value:""};if(!n&&!c){let u=o.length===1?o[0]:o.join("");if(u.trim()===""&&u.includes(`
18
18
  `))return{tag:t,value:""};return{tag:t,value:u}}let f={};for(let u of o){if(u.trim()===""&&u.includes(`
19
- `))continue;f["#text"]="#text"in f?f["#text"]+u:u}for(let u of i){if(u.tag==="__proto__")Zt(f);if(u.tag in f)if(Array.isArray(f[u.tag]))f[u.tag].push(u.value);else f[u.tag]=[f[u.tag],u.value];else f[u.tag]=u.value}for(let[u,h]of Object.entries(s)){if(u==="__proto__")Zt(f);f[u]=h}return{tag:t,value:f}}static ENTITIES={amp:"&",lt:"<",gt:">",quot:'"',apos:"'"};skipDoctype(){let e=this;e.i+=9;let t=0;while(e.i<e.z){let n=e.x[e.i];if(n==="[")++t;else if(n==="]")--t;else if(n===">"&&t===0){++e.i;return}++e.i}throw Error("@aws-sdk XML parse error: unclosed DOCTYPE.")}decodeEntities(e){return e.replace(/&(?:#x([0-9a-fA-F]{1,6})|#(\d{1,7})|([a-zA-Z][a-zA-Z0-9]{0,30}));/g,(t,n,s,o)=>{if(n)return String.fromCharCode(parseInt(n,16));if(s)return String.fromCharCode(parseInt(s,10));return vt.ENTITIES[o]??""})}}ac.XmlNode=Be;ac.XmlText=Yt;ac.parseXML=cc});var at=r(function(Rc){var{SmithyRpcV2CborProtocol:lc,loadSmithyRpcV2CborErrorCode:dc}=Bn(),{TypeRegistry:Dn,NormalizedSchema:T,deref:qn}=_e(),{decorateServiceException:jn,getValueFromTextNode:Qn}=Z(),{collectBody:nt,determineTimestampFormat:pe,RpcProtocol:Gn,HttpBindingProtocol:Wn,HttpInterceptingShapeSerializer:Xn,HttpInterceptingShapeDeserializer:Jn,FromStringShapeDeserializer:mc,extendedEncodeURIComponent:zn}=z(),{NumericValue:B,toUtf8:sr,fromBase64:ir,LazyJsonString:ot,parseEpochTimestamp:Zn,parseRfc7231DateTime:Yn,parseRfc3339DateTimeWithOffset:vn,generateIdempotencyToken:ct,toBase64:ge,dateToUtcString:De,expectUnion:gc}=ee(),{parseXML:es,XmlNode:H,XmlText:On}=Un();class ye{queryCompat;errorRegistry;constructor(e=!1){this.queryCompat=e}resolveRestContentType(e,t){let n=t.getMemberSchemas(),s=Object.values(n).find((o)=>!!o.getMergedTraits().httpPayload);if(s){let o=s.getMergedTraits().mediaType;if(o)return o;else if(s.isStringSchema())return"text/plain";else if(s.isBlobSchema())return"application/octet-stream";else return e}else if(!t.isUnitSchema()){if(Object.values(n).find((i)=>{let{httpQuery:c,httpQueryParams:a,httpHeader:f,httpLabel:u,httpPrefixHeaders:h}=i.getMergedTraits();return!c&&!a&&!f&&!u&&h===void 0}))return e}}async getErrorSchemaOrThrowBaseException(e,t,n,s,o,i){let c=e;if(e.includes("#"))[,c]=e.split("#");let a={$metadata:o,$fault:n.statusCode<500?"client":"server"};if(!this.errorRegistry)throw Error("@aws-sdk/core/protocols - error handler not initialized.");try{return{errorSchema:i?.(this.errorRegistry,c)??this.errorRegistry.getSchema(e),errorMetadata:a}}catch(f){s.message=s.message??s.Message??"UnknownError";let u=this.errorRegistry,h=u.getBaseException();if(h){let m=u.getErrorCtor(h)??Error;throw this.decorateServiceException(Object.assign(new m({name:c}),a),s)}let l=s,d=l?.message??l?.Message??l?.Error?.Message??l?.Error?.message;throw this.decorateServiceException(Object.assign(Error(d),{name:c},a),s)}}compose(e,t,n){let s=n;if(t.includes("#"))[s]=t.split("#");let o=Dn.for(s),i=Dn.for("smithy.ts.sdk.synthetic."+n);e.copyFrom(o),e.copyFrom(i),this.errorRegistry=e}decorateServiceException(e,t={}){if(this.queryCompat){let n=e.Message??t.Message,s=jn(e,t);if(n)s.message=n;let o=s.Error??{};o.Type=s.Error?.Type,o.Code=s.Error?.Code,o.Message=s.Error?.message??s.Error?.Message??n,s.Error=o;let i=s.$metadata.requestId;if(i)s.RequestId=i;return s}return jn(e,t)}setQueryCompatError(e,t){let n=t.headers?.["x-amzn-query-error"];if(e!==void 0&&n!=null){let[s,o]=n.split(";"),i=Object.keys(e),c={Code:s,Type:o};e.Code=s,e.Type=o;for(let a=0;a<i.length;a++){let f=i[a];c[f==="message"?"Message":f]=e[f]}delete c.__type,e.Error=c}}queryCompatOutput(e,t){if(e.Error)t.Error=e.Error;if(e.Type)t.Type=e.Type;if(e.Code)t.Code=e.Code}findQueryCompatibleError(e,t){try{return e.getSchema(t)}catch(n){return e.find((s)=>T.of(s).getMergedTraits().awsQueryError?.[0]===t)}}}class ts extends lc{awsQueryCompatible;mixin;constructor({defaultNamespace:e,errorTypeRegistries:t,awsQueryCompatible:n}){super({defaultNamespace:e,errorTypeRegistries:t});this.awsQueryCompatible=!!n,this.mixin=new ye(this.awsQueryCompatible)}async serializeRequest(e,t,n){let s=await super.serializeRequest(e,t,n);if(this.awsQueryCompatible)s.headers["x-amzn-query-mode"]="true";return s}async handleError(e,t,n,s,o){if(this.awsQueryCompatible)this.mixin.setQueryCompatError(s,n);let i=(()=>{let m=n.headers["x-amzn-query-error"];if(m&&this.awsQueryCompatible)return m.split(";")[0];return dc(n,s)??"Unknown"})();this.mixin.compose(this.compositeErrorRegistry,i,this.options.defaultNamespace);let{errorSchema:c,errorMetadata:a}=await this.mixin.getErrorSchemaOrThrowBaseException(i,this.options.defaultNamespace,n,s,o,this.awsQueryCompatible?this.mixin.findQueryCompatibleError:void 0),f=T.of(c),u=s.message??s.Message??"UnknownError",l=new(this.compositeErrorRegistry.getErrorCtor(c)??Error)({}),d={};for(let[m,y]of f.structIterator())if(s[m]!=null)d[m]=this.deserializer.readValue(y,s[m]);if(this.awsQueryCompatible)this.mixin.queryCompatOutput(s,d);throw this.mixin.decorateServiceException(Object.assign(l,a,{$fault:f.getMergedTraits().error,message:u},d),s)}}class K{serdeContext;setSerdeContext(e){this.serdeContext=e}}class ft{from;to;keys;constructor(e,t){this.from=e,this.to=t;let n=Object.keys(this.from),s=new Set(n);s.delete("__type"),this.keys=s}mark(e){this.keys.delete(e)}hasUnknown(){return this.keys.size===1&&Object.keys(this.to).length===0}writeUnknown(){if(this.hasUnknown()){let e=this.keys.values().next().value,t=this.from[e];this.to.$unknown=[e,t]}}}var Ue;function rs(){if(Ue===void 0)try{if(typeof Buffer!=="function")Ue=!1;else{let e=JSON.parse(Buffer.from([123,125]));Ue=e!==null&&typeof e==="object"}}catch{Ue=!1}return Ue}function or(e,t,n){if(n?.source){let s=n.source;if(typeof t==="number")if(t<=Number.MAX_SAFE_INTEGER&&t>=Number.MIN_SAFE_INTEGER){if(yc(s,t))return t;return new B(s,"bigDecimal")}else{if(pc(s))return new B(s,"bigDecimal");if(/[eE]/.test(s))return Sc(s);return BigInt(s)}}return t}function pc(e){let t=e.indexOf(".");if(t===-1)return!1;let n=e.search(/[eE]/);if(n===-1)return!0;let s=n-t-1;return parseInt(e.slice(n+1),10)<s}function yc(e,t){if(e===String(t))return!0;if(Object.is(t,-0))return!0;if(/[eE]/.test(e))return er(e)===er(String(t));let n=e.replace(/(\.\d*?)0+$/,"$1").replace(/\.$/,""),s=String(t);if(n===s)return!0;if(/[eE]/.test(s))return n===er(s);return!1}function er(e){let t=e.startsWith("-"),n=t?e.slice(1):e,s=n.search(/[eE]/),o;if(s===-1)o=n;else{let i=parseInt(n.slice(s+1),10),c=n.slice(0,s),a=c.indexOf("."),f,u;if(a===-1)f=c,u=c.length;else f=c.slice(0,a)+c.slice(a+1),u=a;f=f.replace(/0+$/,"")||"0";let h=u+i;if(f==="0")o="0";else if(h<=0)o="0."+"0".repeat(-h)+f;else if(h>=f.length)o=f+"0".repeat(h-f.length);else o=f.slice(0,h)+"."+f.slice(h)}if(o.includes("."))o=o.replace(/(\.\d*?)0+$/,"$1").replace(/\.$/,"");return(t?"-":"")+o}function Sc(e){let t=e.search(/[eE]/),n=parseInt(e.slice(t+1),10),s=e.startsWith("-"),o=e.slice(s?1:0,t),i=o.indexOf("."),c,a;if(i===-1)c=o,a=n;else{c=o.slice(0,i)+o.slice(i+1);let u=o.length-i-1;a=n-u}c=c.replace(/0+$/,"")||"0";let f=BigInt(c)*10n**BigInt(a+(o.replace(".","").length-c.length));return s?-f:f}var tr=Symbol.for("@aws-sdk/reviver");function cr(e){let t=T.of(e),n=t.getSchema();if(Array.isArray(n)&&t.isStructSchema()){if(tr in n)return n[tr];let s=st(t,new Set);return n[tr]=s,s}return st(t,new Set)}function st(e,t){let n=e.getSchema();if(t.has(n))return!1;if(t.add(n),e.isBigIntegerSchema()||e.isBigDecimalSchema())return!0;if(e.isStructSchema()){for(let[,s]of e.structIterator())if(st(s,t))return!0}else if(e.isListSchema()||e.isMapSchema()){if(st(e.getValueSchema(),t))return!0}else if(e.isDocumentSchema())return!0;return!1}var ns=(e,t)=>nt(e,t).then((n)=>(t?.utf8Encoder??sr)(n));async function ut(e,t,n){let s;if(rs()&&typeof e?.[Symbol.asyncIterator]==="function"){let i=await nt(e,t);if(typeof Buffer==="function")if(Buffer.isBuffer(i))s=i;else s=Buffer.from(i.buffer,i.byteOffset,i.byteLength)}if(!s)s=await ns(e,t);if(s.length===0)return{};let o=n&&cr(n)?or:void 0;try{return JSON.parse(s,o)}catch(i){if(i?.name==="SyntaxError")Object.defineProperty(i,"$responseBodyText",{value:typeof s==="string"?s:s.toString("utf8")});throw i}}var wc=async(e,t)=>{let n=await ut(e,t);return n.message=n.message??n.Message,n},Ln=(e,t)=>Object.keys(e).find((n)=>n.toLowerCase()===t.toLowerCase()),rr=(e)=>{let t=e;if(typeof t==="number")t=t.toString();if(t.indexOf(",")>=0)t=t.split(",")[0];if(t.indexOf(":")>=0)t=t.split(":")[0];if(t.indexOf("#")>=0)t=t.split("#")[1];return t},ss=(e,t)=>os(e,t,["header","code","type"]),is=(e,t,n=!1)=>os(e,t,n?["code","header","type"]:["type","code","header"]),os=({headers:e},t,n)=>{while(n.length>0)switch(n.shift()){case"header":let o=Ln(e??{},"x-amzn-errortype");if(o!==void 0)return rr(e[o]);break;case"code":let i=Ln(t??{},"code");if(i&&t[i]!==void 0)return rr(t[i]);break;case"type":if(t?.__type!==void 0)return rr(t.__type);break}};function Y(e){Object.defineProperty(e,"__proto__",{value:void 0,writable:!0,enumerable:!0,configurable:!0})}class ar extends K{settings;constructor(e){super();this.settings=e}async read(e,t){let n=cr(e)?or:void 0,s;if(typeof t==="string"){if(t.length===0)return{};s=JSON.parse(t,n)}else if(t instanceof Uint8Array&&rs()){if(t.byteLength===0)return{};let o=Buffer.isBuffer(t)?t:Buffer.from(t.buffer,t.byteOffset,t.byteLength);s=JSON.parse(o,n)}else s=await ut(t,this.serdeContext,e);return this._read(e,s)}readObject(e,t){return this._read(e,t)}_read(e,t){let n=t!==null&&typeof t==="object",s=T.of(e);if(n){if(s.isStructSchema())return this._readStruct(s,t);if(Array.isArray(t)&&s.isListSchema()){let i=s.getValueSchema();if(this.needsTransform(i))for(let c=0;c<t.length;++c)t[c]=this._read(i,t[c]);return t}if(s.isMapSchema()){let i=s.getValueSchema(),c=t;if(this.needsTransform(i))for(let a in c){if(a==="__proto__")Y(c);c[a]=this._read(i,c[a])}return c}}if(s.isBlobSchema()&&typeof t==="string")return ir(t);let o=s.getMergedTraits().mediaType;if(s.isStringSchema()&&typeof t==="string"&&o){if(o==="application/json"||o.endsWith("+json"))return ot.from(t);return t}if(s.isTimestampSchema()&&t!=null)switch(pe(s,this.settings)){case 5:return vn(t);case 6:return Yn(t);case 7:return Zn(t);default:return console.warn("Missing timestamp format, parsing value with Date constructor:",t),new Date(t)}if(s.isBigIntegerSchema()&&(typeof t==="number"||typeof t==="string"))return BigInt(t);if(s.isBigDecimalSchema()&&t!=null){if(t instanceof B)return t;let i=t;if(i.type==="bigDecimal"&&"string"in i)return new B(i.string,i.type);return new B(String(t),"bigDecimal")}if(s.isNumericSchema()&&typeof t==="string"){switch(t){case"Infinity":return 1/0;case"-Infinity":return-1/0;case"NaN":return NaN}return t}if(s.isDocumentSchema()){if(n)if(Array.isArray(t))for(let i=0;i<t.length;++i){let c=t[i];if(!(c instanceof B))t[i]=this._read(s,c)}else{let i=t;for(let c in i){if(c==="__proto__")Y(i);let a=i[c];if(!(a instanceof B))i[c]=this._read(s,a)}}}return t}_readStruct(e,t){let n=e.isUnionSchema(),s={},o,i=typeof t.__type==="string",{jsonName:c}=this.settings;if(c&&i)o={};let a;if(n)a=new ft(t,s);for(let[f,u]of e.structIterator()){let h=f;if(c){if(h=u.getMergedTraits().jsonName??h,i)o[h]=f}if(n)a.mark(h);if(t[h]!=null)s[f]=this._read(u,t[h])}if(n)a.writeUnknown();else if(i)for(let f in t){let u=t[f],h=c?o[f]??f:f;if(!(h in s))s[h]=u}return s}needsTransform(e){if(e.isBlobSchema()||e.isTimestampSchema()||e.isBigIntegerSchema()||e.isBigDecimalSchema())return!0;if(e.isDocumentSchema()||e.isStructSchema()||e.isListSchema()||e.isMapSchema())return!0;if(e.isStringSchema()&&e.getMergedTraits().mediaType)return!0;return!1}}class it extends Uint8Array{string=null;static allocUnsafe(e){if(typeof Buffer==="function"){let t=Buffer.allocUnsafe(e);return new it(t.buffer,t.byteOffset,t.byteLength)}return new it(e)}toString(){return this.s()}valueOf(){return this.s()}includes(e,t){if(typeof e==="string")return this.s().includes(e,t);return Uint8Array.prototype.includes.call(this,e,t)}indexOf(e,t){if(typeof e==="string")return this.s().indexOf(e,t);return Uint8Array.prototype.indexOf.call(this,e,t)}lastIndexOf(e,t){if(typeof e==="string")return this.s().lastIndexOf(e,t);let n=Uint8Array.prototype.lastIndexOf;if(t!==void 0)return n.call(this,e,t);return n.call(this,e)}startsWith(e,t){return this.s().startsWith(e,t)}endsWith(e,t){return this.s().endsWith(e,t)}match(e){return this.s().match(e)}replace(e,t){return this.s().replace(e,t)}search(e){return this.s().search(e)}split(e,t){return this.s().split(e,t)}substring(e,t){return this.s().substring(e,t)}trim(){return this.s().trim()}trimStart(){return this.s().trimStart()}trimEnd(){return this.s().trimEnd()}charAt(e){return this.s().charAt(e)}charCodeAt(e){return this.s().charCodeAt(e)}padStart(e,t){return this.s().padStart(e,t)}padEnd(e,t){return this.s().padEnd(e,t)}repeat(e){return this.s().repeat(e)}toUpperCase(){return this.s().toUpperCase()}toLowerCase(){return this.s().toLowerCase()}s(){if(this.string==null){let e=Date.now();if(e>$n+60000)console.warn("@aws-sdk/core/protocols - WARN - JsonCodec2: you have called a string method on a Uint8Array request body. It has been automatically converted to string. In a future version this will throw an error."),$n=e;this.string=sr(this)}return this.string}}var $n=0,et=new TextEncoder,Vn=123,Fn=125,bc=91,xc=93,me=34,tt=58,rt=44,Pn=92,Ec=new Uint8Array([116,114,117,101]),Nc=new Uint8Array([102,97,108,115,101]),_c=new Uint8Array([110,117,108,108]),G=Array(128).fill(null);G[8]="b";G[9]="t";G[10]="n";G[12]="f";G[13]="r";G[34]='"';G[92]="\\";for(let e=0;e<32;e++)if(G[e]===null)G[e]="u00"+e.toString(16).padStart(2,"0");var Hn=2048;function nr(e){return it.allocUnsafe(e)}class ht extends K{settings;json;i=0;rootSchema;rawValue;passthrough=!1;constructor(e){super();this.settings=e,this.json=nr(Hn)}write(e,t){if(this.i=0,this.rawValue=t,this.rootSchema=T.of(e),this.passthrough=this.rootSchema.isBlobSchema()||this.rootSchema.isStringSchema(),!this.passthrough)this.writeValue(this.rootSchema,t,void 0)}writeDiscriminatedDocument(e,t){this.i=0,this.rootSchema=T.of(e);let n=this.rootSchema;if(n.isStructSchema()&&t!=null&&typeof t==="object"){this.writeValue(n,t,void 0);let s=`"__type":"${n.getName(!0)??"Unknown"}",`,o=s.length;this.ensure(o),this.json.copyWithin(1+o,1,this.i),et.encodeInto(s,this.json.subarray(1)),this.i+=o}else this.writeValue(n,t,void 0)}flush(){this.rootSchema=void 0;let e=this.i;this.i=0;let t=this.rawValue;if(this.rawValue=void 0,e===0)return t;let n=this.json.subarray(0,e);return this.json=nr(Hn),n}ensure(e){let{i:t,json:n}=this;if(t+e>n.length){let s=n.length*2;while(s<t+e)s*=2;let o=nr(s);o.set(this.json),this.json=o}}writeAscii(e){let t=e.length;this.ensure(t);let{i:n,json:s}=this;for(let o=0;o<t;++o)s[n]=e.charCodeAt(o),n+=1;this.i=n}writeAsciiQuoted(e){let t=e.length;this.ensure(t+4);let{json:n,i:s}=this;n[s++]=me;for(let o=0;o<t;++o)n[s++]=e.charCodeAt(o);n[s++]=me,this.i=s}writeJsonString(e){this.ensure(e.length*3+2),this.json[this.i++]=me;let t=e.length;for(let n=0;n<t;++n){let s=e.charCodeAt(n);if(s>34&&s<92)this.json[this.i++]=s;else if(s<128){let o=G[s];if(o!==null){this.ensure(o.length+1),this.json[this.i++]=Pn;for(let i=0;i<o.length;i++)this.json[this.i++]=o.charCodeAt(i)}else this.json[this.i++]=s}else if(s>=55296&&s<=56319){let o=n+1<t?e.charCodeAt(n+1):0;if(o>=56320&&o<=57343){this.ensure(4);let{written:i}=et.encodeInto(e.substring(n,n+2),this.json.subarray(this.i));this.i+=i,++n}else this.ensure(6),this.writeUnicodeEscape(s)}else if(s>=56320&&s<=57343)this.ensure(6),this.writeUnicodeEscape(s);else{let{i:o,json:i}=this;if(s<2048)i[o++]=192|s>>6,i[o++]=128|s&63;else i[o++]=224|s>>12,i[o++]=128|s>>6&63,i[o++]=128|s&63;this.i=o}}this.json[this.i++]=me}writeUnicodeEscape(e){let{json:t,i:n}=this;t[n++]=Pn,t[n++]=117;let s=e.toString(16).padStart(4,"0");for(let o=0;o<4;++o)t[n++]=s.charCodeAt(o);this.i=n}static B64=(()=>{let t=new Uint8Array(64);for(let n=0;n<64;++n)t[n]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charCodeAt(n);return t})();writeBase64(e){let t=Math.ceil(e.length/3)*4;this.ensure(t+2);let n=this.json,s=ht.B64,o=this.i;n[o++]=me;let i=e.length,c=i%3,a=i-c;for(let f=0;f<a;f+=3){let u=e[f],h=e[f+1],l=e[f+2];n[o++]=s[u>>2],n[o++]=s[(u&3)<<4|h>>4],n[o++]=s[(h&15)<<2|l>>6],n[o++]=s[l&63]}if(c===2){let f=e[a],u=e[a+1];n[o++]=s[f>>2],n[o++]=s[(f&3)<<4|u>>4],n[o++]=s[(u&15)<<2],n[o++]=61}else if(c===1){let f=e[a];n[o++]=s[f>>2],n[o++]=s[(f&3)<<4],n[o++]=61,n[o++]=61}n[o++]=me,this.i=o}writeValue(e,t,n){if(t==null){if(n?.isStructSchema()){if(t===void 0){if(T.of(e).isIdempotencyToken()){this.writeAsciiQuoted(ct());return}}return}this.ensure(4),this.json.set(_c,this.i),this.i+=4;return}let s=T.of(e),o=typeof t==="object";if(s.isStringSchema()){let i=s.getMergedTraits().mediaType;if(i){if(i==="application/json"||i.endsWith("+json")){this.writeJsonString(ot.from(t).toString());return}}}if(o){if(s.isStructSchema()){this.writeStruct(s,t);return}if(Array.isArray(t)&&(s.isListSchema()||s.isDocumentSchema())){this.writeList(s,t,s.isDocumentSchema());return}if(s.isMapSchema()){this.writeMap(s,t,!1);return}if(t instanceof Uint8Array&&(s.isBlobSchema()||s.isDocumentSchema())){this.writeBase64(t);return}if(t instanceof Date&&(s.isTimestampSchema()||s.isDocumentSchema())){this.writeTimestamp(s,t);return}if(t instanceof B){this.writeAscii(t.string);return}if(s.isDocumentSchema()){if(Array.isArray(t))this.writeList(s,t,!0);else this.writeMap(s,t,!0);return}let i=JSON.stringify(t);this.writeAscii(i);return}if(typeof t==="string"){if(s.isBlobSchema()){let i=(this.serdeContext?.base64Encoder??ge)(t);this.writeAsciiQuoted(i);return}this.writeJsonString(t);return}if(typeof t==="number"){if(Math.abs(t)===1/0||Number.isNaN(t)){this.writeAsciiQuoted(String(t));return}let i=String(t);this.writeAscii(i);return}if(typeof t==="boolean"){this.ensure(5);let{i,json:c}=this;if(t)c.set(Ec,i),i+=4;else c.set(Nc,i),i+=5;this.i=i;return}if(typeof t==="bigint"){this.writeAscii(t.toString());return}this.writeAscii(String(t))}writeStruct(e,t){this.ensure(2),this.json[this.i++]=Vn;let n=!1,s=typeof t.__type==="string",o;if(s)o=new Set;for(let[i,c]of e.structIterator()){let a=t[i];if(a==null&&!c.isIdempotencyToken())continue;if(n)this.ensure(1),this.json[this.i++]=rt;n=!0;let f=this.settings.jsonName?c.getMergedTraits().jsonName??i:i;if(o)o.add(i),o.add(f);this.writeAsciiQuoted(f),this.json[this.i++]=tt,this.writeValue(c,a,e)}if(!n&&e.isUnionSchema()){let{$unknown:i}=t;if(Array.isArray(i)){let[c,a]=i;this.writeAsciiQuoted(c),this.ensure(1),this.json[this.i++]=tt,this.writeValue(15,a,e)}}else if(s)for(let i in t){if(o.has(i))continue;o.add(i);let c=t[i];if(n)this.ensure(1),this.json[this.i++]=rt;n=!0,this.writeAsciiQuoted(i),this.ensure(1),this.json[this.i++]=tt,this.writeValue(15,c,void 0)}this.ensure(1),this.json[this.i++]=Fn}writeList(e,t,n){let s=!!e.getMergedTraits().sparse,o=e.getValueSchema();if(!n){if(o.isStringSchema()||o.isNumericSchema()||o.isBooleanSchema()){let c=!1;for(let f=0;f<t.length;++f){let u=t[f];if(Number.isNaN(u)||u===1/0||u===-1/0||u==null&&!s){c=!0;break}}let a;if(!c)a=JSON.stringify(t);else{let f=[];for(let u=0;u<t.length;++u){let h=t[u];if(h==null&&!s)continue;if(Number.isNaN(h)||h===1/0||h===-1/0)f.push(String(h));else f.push(h)}a=JSON.stringify(f)}this.ensure(a.length*3),this.i+=et.encodeInto(a,this.json.subarray(this.i)).written;return}}this.ensure(2),this.json[this.i++]=bc;let i=!1;for(let c=0;c<t.length;++c){let a=t[c];if(n?a===void 0:a==null&&!s)continue;if(i)this.ensure(1),this.json[this.i++]=rt;this.writeValue(o,a,void 0),i=!0}this.ensure(1),this.json[this.i++]=xc}writeMap(e,t,n){let s=!!e.getMergedTraits().sparse,o=e.getValueSchema();if(!n){if(o.isStringSchema()||o.isNumericSchema()||o.isBooleanSchema()){let c;for(let f in t){let u=t[f];if(Number.isNaN(u)||u===1/0||u===-1/0)(c??={})[f]=u,t[f]=String(u);else if(u===null&&!s)(c??={})[f]=null,t[f]=void 0}let a=JSON.stringify(t);if(c)Object.assign(t,c);this.ensure(a.length*3),this.i+=et.encodeInto(a,this.json.subarray(this.i)).written;return}}this.ensure(2),this.json[this.i++]=Vn;let i=!0;for(let c in t){let a=t[c];if(n?a===void 0:a==null&&!s)continue;if(!i)this.ensure(1),this.json[this.i++]=rt;i=!1,this.writeJsonString(c),this.ensure(1),this.json[this.i++]=tt,this.writeValue(o,a,void 0)}this.ensure(1),this.json[this.i++]=Fn}writeTimestamp(e,t){switch(pe(e,this.settings)){case 5:{let s=t.toISOString().replace(".000Z","Z");this.writeAsciiQuoted(s);return}case 6:{this.writeAsciiQuoted(De(t));return}case 7:{let s=String(t.getTime()/1000);this.writeAscii(s);return}default:{let s=String(t.getTime()/1000);this.writeAscii(s);return}}}}class lt extends K{settings;constructor(e){super();this.settings=e}createSerializer(){let e=new ht(this.settings);return e.setSerdeContext(this.serdeContext),e}createDeserializer(){let e=new ar(this.settings);return e.setSerdeContext(this.serdeContext),e}}class dt extends Gn{serializer;deserializer;serviceTarget;codec;mixin;awsQueryCompatible;constructor({defaultNamespace:e,errorTypeRegistries:t,serviceTarget:n,awsQueryCompatible:s,jsonCodec:o}){super({defaultNamespace:e,errorTypeRegistries:t});this.serviceTarget=n,this.codec=o??new lt({timestampFormat:{useTrait:!0,default:7},jsonName:!1}),this.serializer=this.codec.createSerializer(),this.deserializer=this.codec.createDeserializer(),this.awsQueryCompatible=!!s,this.mixin=new ye(this.awsQueryCompatible)}async serializeRequest(e,t,n){let s=await super.serializeRequest(e,t,n);if(!s.path.endsWith("/"))s.path+="/";if(s.headers["content-type"]=`application/x-amz-json-${this.getJsonRpcVersion()}`,s.headers["x-amz-target"]=`${this.serviceTarget}.${e.name}`,this.awsQueryCompatible)s.headers["x-amzn-query-mode"]="true";if(qn(e.input)==="unit"||!s.body)s.body="{}";return s}getPayloadCodec(){return this.codec}async handleError(e,t,n,s,o){let{awsQueryCompatible:i}=this;if(i)this.mixin.setQueryCompatError(s,n);let c=is(n,s,i)??"Unknown";this.mixin.compose(this.compositeErrorRegistry,c,this.options.defaultNamespace);let{errorSchema:a,errorMetadata:f}=await this.mixin.getErrorSchemaOrThrowBaseException(c,this.options.defaultNamespace,n,s,o,i?this.mixin.findQueryCompatibleError:void 0),u=T.of(a),h=s.message??s.Message??"UnknownError",d=new(this.compositeErrorRegistry.getErrorCtor(a)??Error)({}),m={},y=this.codec.createDeserializer();for(let[g,N]of u.structIterator())if(s[g]!=null)m[g]=y.readObject(N,s[g]);if(i)this.mixin.queryCompatOutput(s,m);throw this.mixin.decorateServiceException(Object.assign(d,f,{$fault:u.getMergedTraits().error,message:h},m),s)}}class cs extends dt{constructor({defaultNamespace:e,errorTypeRegistries:t,serviceTarget:n,awsQueryCompatible:s,jsonCodec:o}){super({defaultNamespace:e,errorTypeRegistries:t,serviceTarget:n,awsQueryCompatible:s,jsonCodec:o})}getShapeId(){return"aws.protocols#awsJson1_0"}getJsonRpcVersion(){return"1.0"}getDefaultContentType(){return"application/x-amz-json-1.0"}}class as extends dt{constructor({defaultNamespace:e,errorTypeRegistries:t,serviceTarget:n,awsQueryCompatible:s,jsonCodec:o}){super({defaultNamespace:e,errorTypeRegistries:t,serviceTarget:n,awsQueryCompatible:s,jsonCodec:o})}getShapeId(){return"aws.protocols#awsJson1_1"}getJsonRpcVersion(){return"1.1"}getDefaultContentType(){return"application/x-amz-json-1.1"}}class fs extends Wn{serializer;deserializer;codec;mixin=new ye;constructor({defaultNamespace:e,errorTypeRegistries:t,jsonCodec:n}){super({defaultNamespace:e,errorTypeRegistries:t});let s={timestampFormat:{useTrait:!0,default:7},httpBindings:!0,jsonName:!0};this.codec=n??new lt(s),this.serializer=new Xn(this.codec.createSerializer(),s),this.deserializer=new Jn(this.codec.createDeserializer(),s)}getShapeId(){return"aws.protocols#restJson1"}getPayloadCodec(){return this.codec}setSerdeContext(e){this.codec.setSerdeContext(e),super.setSerdeContext(e)}async serializeRequest(e,t,n){let s=await super.serializeRequest(e,t,n),o=T.of(e.input);if(!s.headers["content-type"]){let i=this.mixin.resolveRestContentType(this.getDefaultContentType(),o);if(i)s.headers["content-type"]=i}if(s.body==null&&s.headers["content-type"]===this.getDefaultContentType())s.body="{}";return s}async deserializeResponse(e,t,n){let s=await super.deserializeResponse(e,t,n),o=T.of(e.output);for(let[i,c]of o.structIterator())if(c.getMemberTraits().httpPayload&&!(i in s))s[i]=null;return s}async handleError(e,t,n,s,o){let i=ss(n,s)??"Unknown";this.mixin.compose(this.compositeErrorRegistry,i,this.options.defaultNamespace);let{errorSchema:c,errorMetadata:a}=await this.mixin.getErrorSchemaOrThrowBaseException(i,this.options.defaultNamespace,n,s,o),f=T.of(c),u=s.message??s.Message??"UnknownError",l=new(this.compositeErrorRegistry.getErrorCtor(c)??Error)({});await this.deserializeHttpMessage(c,t,n,s);let d={},m=this.codec.createDeserializer();for(let[y,g]of f.structIterator()){let N=g.getMergedTraits().jsonName??y;d[y]=m.readObject(g,s[N])}throw this.mixin.decorateServiceException(Object.assign(l,a,{$fault:f.getMergedTraits().error,message:u},d),s)}getDefaultContentType(){return"application/json"}}class fr extends K{settings;constructor(e){super();this.settings=e}async read(e,t){let n=cr(e)?or:void 0;return this._read(e,typeof t==="string"?JSON.parse(t,n):await ut(t,this.serdeContext,e))}readObject(e,t){return this._read(e,t)}_read(e,t){let n=t!==null&&typeof t==="object",s=T.of(e);if(n){if(s.isStructSchema()){let i=t,c=s.isUnionSchema(),a={},f=void 0,{jsonName:u}=this.settings;if(u)f={};let h;if(c)h=new ft(i,a);for(let[l,d]of s.structIterator()){let m=l;if(u)m=d.getMergedTraits().jsonName??m,f[m]=l;if(c)h.mark(m);if(i[m]!=null)a[l]=this._read(d,i[m])}if(c)h.writeUnknown();else if(typeof i.__type==="string")for(let l in i){let d=i[l],m=u?f[l]??l:l;if(!(m in a))a[m]=d}return a}if(Array.isArray(t)&&s.isListSchema()){let i=s.getValueSchema(),c=[];for(let a of t)c.push(this._read(i,a));return c}if(s.isMapSchema()){let i=s.getValueSchema(),c={};for(let a in t){if(a==="__proto__")Y(c);c[a]=this._read(i,t[a])}return c}}if(s.isBlobSchema()&&typeof t==="string")return ir(t);let o=s.getMergedTraits().mediaType;if(s.isStringSchema()&&typeof t==="string"&&o){if(o==="application/json"||o.endsWith("+json"))return ot.from(t);return t}if(s.isTimestampSchema()&&t!=null)switch(pe(s,this.settings)){case 5:return vn(t);case 6:return Yn(t);case 7:return Zn(t);default:return console.warn("Missing timestamp format, parsing value with Date constructor:",t),new Date(t)}if(s.isBigIntegerSchema()&&(typeof t==="number"||typeof t==="string"))return BigInt(t);if(s.isBigDecimalSchema()&&t!=null){if(t instanceof B)return t;let i=t;if(i.type==="bigDecimal"&&"string"in i)return new B(i.string,i.type);return new B(String(t),"bigDecimal")}if(s.isNumericSchema()&&typeof t==="string"){switch(t){case"Infinity":return 1/0;case"-Infinity":return-1/0;case"NaN":return NaN}return t}if(s.isDocumentSchema())if(n){let i=Array.isArray(t)?[]:{};for(let c in t){if(c==="__proto__")Y(i);let a=t[c];if(a instanceof B)i[c]=a;else i[c]=this._read(s,a)}return i}else return structuredClone(t);return t}}var Kn=String.fromCharCode(925);class us{values=new Map;counter=0;stage=0;createReplacer(){if(this.stage===1)throw Error("@aws-sdk/core/protocols - JsonReplacer already created.");if(this.stage===2)throw Error("@aws-sdk/core/protocols - JsonReplacer exhausted.");return this.stage=1,(e,t)=>{if(t instanceof B){let n=`${Kn+"nv"+this.counter++}_`+t.string;return this.values.set(`"${n}"`,t.string),n}if(typeof t==="bigint"){let n=t.toString(),s=`${Kn+"b"+this.counter++}_`+n;return this.values.set(`"${s}"`,n),s}return t}}replaceInJson(e){if(this.stage===0)throw Error("@aws-sdk/core/protocols - JsonReplacer not created yet.");if(this.stage===2)throw Error("@aws-sdk/core/protocols - JsonReplacer exhausted.");if(this.stage=2,this.counter===0)return e;for(let[t,n]of this.values)e=e.replace(t,n);return e}}class ur extends K{settings;buffer;useReplacer=!1;rootSchema;constructor(e){super();this.settings=e}write(e,t){this.rootSchema=T.of(e),this.buffer=this._write(this.rootSchema,t)}flush(){let{rootSchema:e,useReplacer:t}=this;if(this.rootSchema=void 0,this.useReplacer=!1,e?.isStructSchema()||e?.isDocumentSchema()){if(!t)return JSON.stringify(this.buffer);let n=new us;return n.replaceInJson(JSON.stringify(this.buffer,n.createReplacer(),0))}return this.buffer}writeDiscriminatedDocument(e,t){if(this.write(e,t),typeof this.buffer==="object")this.buffer.__type=T.of(e).getName(!0)}_write(e,t,n){let s=t!==null&&typeof t==="object",o=T.of(e);if(s){if(o.isStructSchema()){let i=t,c={},{jsonName:a}=this.settings,f=void 0;if(a)f={};let u=0;for(let[h,l]of o.structIterator()){let d=this._write(l,i[h],o);if(d!==void 0){let m=h;if(a)m=l.getMergedTraits().jsonName??h,f[h]=m;c[m]=d,u++}}if(o.isUnionSchema()&&u===0){let{$unknown:h}=i;if(Array.isArray(h)){let[l,d]=h;if(l==="__proto__")Y(c);c[l]=this._write(15,d)}}else if(typeof i.__type==="string")for(let h in i){let l=i[h],d=a?f[h]??h:h;if(!(d in c))c[d]=this._write(15,l)}return c}if(Array.isArray(t)&&o.isListSchema()){let i=o.getValueSchema(),c=[],a=!!o.getMergedTraits().sparse;for(let f of t)if(a||f!=null)c.push(this._write(i,f));return c}if(o.isMapSchema()){let i=o.getValueSchema(),c={},a=!!o.getMergedTraits().sparse;for(let f in t){let u=t[f];if(a||u!=null){if(f==="__proto__")Y(c);c[f]=this._write(i,u)}}return c}if(t instanceof Uint8Array&&o.isBlobSchema()){if(o===this.rootSchema)return t;return(this.serdeContext?.base64Encoder??ge)(t)}if(t instanceof Date&&(o.isTimestampSchema()||o.isDocumentSchema()))switch(pe(o,this.settings)){case 5:return t.toISOString().replace(".000Z","Z");case 6:return De(t);case 7:return t.getTime()/1000;default:return console.warn("Missing timestamp format, using epoch seconds",t),t.getTime()/1000}if(t instanceof B)this.useReplacer=!0}if(t===null&&n?.isStructSchema())return;if(o.isStringSchema()){if(typeof t>"u"&&o.isIdempotencyToken())return ct();let i=o.getMergedTraits().mediaType;if(t!=null&&i){if(i==="application/json"||i.endsWith("+json"))return ot.from(t)}return t}if(typeof t==="number"){if(Math.abs(t)===1/0||isNaN(t))return String(t);return t}if(typeof t==="string"&&o.isBlobSchema()){if(o===this.rootSchema)return t;return(this.serdeContext?.base64Encoder??ge)(t)}if(typeof t==="bigint")this.useReplacer=!0;if(o.isDocumentSchema())if(s){if(t instanceof Uint8Array)return(this.serdeContext?.base64Encoder??ge)(t);let i=Array.isArray(t)?[]:{};for(let c in t){let a=t[c];if(c==="__proto__")Y(i);if(a instanceof B)this.useReplacer=!0,i[c]=a;else i[c]=this._write(o,a)}return i}else return structuredClone(t);return t}}class hs extends K{settings;constructor(e){super();this.settings=e}createSerializer(){let e=new ur(this.settings);return e.setSerdeContext(this.serdeContext),e}createDeserializer(){let e=new fr(this.settings);return e.setSerdeContext(this.serdeContext),e}}class mt extends K{settings;stringDeserializer;constructor(e){super();this.settings=e,this.stringDeserializer=new mc(e)}setSerdeContext(e){this.serdeContext=e,this.stringDeserializer.setSerdeContext(e)}read(e,t,n){let s=T.of(e),o=s.getMemberSchemas();if(s.isStructSchema()&&s.isMemberSchema()&&!!Object.values(o).find((f)=>!!f.getMemberTraits().eventPayload)){let f={},u=Object.keys(o)[0];if(o[u].isBlobSchema())f[u]=t;else f[u]=this.read(o[u],t);return f}let c=(this.serdeContext?.utf8Encoder??sr)(t),a=this.parseXml(c);return this.readSchema(e,n?a[n]:a)}readSchema(e,t){let n=T.of(e);if(n.isUnitSchema())return;let s=n.getMergedTraits();if(n.isListSchema()&&!Array.isArray(t))return this.readSchema(n,[t]);if(t==null)return t;if(typeof t==="object"){let o=!!s.xmlFlattened;if(n.isListSchema()){let c=n.getValueSchema(),a=[],f=c.getMergedTraits().xmlName??"member",u=o?t:(t[0]??t)[f];if(u==null)return a;let h=Array.isArray(u)?u:[u];for(let l of h)a.push(this.readSchema(c,l));return a}let i={};if(n.isMapSchema()){let c=n.getKeySchema(),a=n.getValueSchema(),f;if(o)f=Array.isArray(t)?t:[t];else f=Array.isArray(t.entry)?t.entry:[t.entry];let u=c.getMergedTraits().xmlName??"key",h=a.getMergedTraits().xmlName??"value";for(let l of f){let d=l[u],m=l[h];if(d==="__proto__")Y(i);i[d]=this.readSchema(a,m)}return i}if(n.isStructSchema()){let c=n.isUnionSchema(),a;if(c)a=new ft(t,i);for(let[f,u]of n.structIterator()){let h=u.getMergedTraits(),l=!h.httpPayload?u.getMemberTraits().xmlName??f:h.xmlName??u.getName();if(c)a.mark(l);if(t[l]!=null)i[f]=this.readSchema(u,t[l])}if(c)a.writeUnknown();return i}if(n.isDocumentSchema())return t;throw Error(`@aws-sdk/core/protocols - xml deserializer unhandled schema type for ${n.getName(!0)}`)}if(n.isListSchema())return[];if(n.isMapSchema()||n.isStructSchema())return{};return this.stringDeserializer.read(n,t)}parseXml(e){if(e.length){let t;try{t=es(e)}catch(i){if(i&&typeof i==="object")Object.defineProperty(i,"$responseBodyText",{value:e});throw i}let n="#text",s=Object.keys(t)[0],o=t[s];if(o[n])o[s]=o[n],delete o[n];return Qn(o)}return{}}}class hr extends K{settings;buffer;constructor(e){super();this.settings=e}write(e,t,n=""){if(this.buffer===void 0)this.buffer="";let s=T.of(e);if(n&&!n.endsWith("."))n+=".";if(s.isBlobSchema()){if(typeof t==="string"||t instanceof Uint8Array)this.writeKey(n),this.writeValue((this.serdeContext?.base64Encoder??ge)(t))}else if(s.isBooleanSchema()||s.isNumericSchema()||s.isStringSchema()){if(t!=null)this.writeKey(n),this.writeValue(String(t));else if(s.isIdempotencyToken())this.writeKey(n),this.writeValue(ct())}else if(s.isBigIntegerSchema()){if(t!=null)this.writeKey(n),this.writeValue(String(t))}else if(s.isBigDecimalSchema()){if(t!=null)this.writeKey(n),this.writeValue(t instanceof B?t.string:String(t))}else if(s.isTimestampSchema()){if(t instanceof Date)switch(this.writeKey(n),pe(s,this.settings)){case 5:this.writeValue(t.toISOString().replace(".000Z","Z"));break;case 6:this.writeValue(De(t));break;case 7:this.writeValue(String(t.getTime()/1000));break}}else if(s.isDocumentSchema())if(Array.isArray(t))this.write(79,t,n);else if(t instanceof Date)this.write(4,t,n);else if(t instanceof Uint8Array)this.write(21,t,n);else if(t&&typeof t==="object")this.write(143,t,n);else this.writeKey(n),this.writeValue(String(t));else if(s.isListSchema()){if(Array.isArray(t))if(t.length===0){if(this.settings.serializeEmptyLists)this.writeKey(n),this.writeValue("")}else{let o=s.getValueSchema(),i=this.settings.flattenLists||s.getMergedTraits().xmlFlattened,c=1;for(let a of t){if(a==null)continue;let f=o.getMergedTraits(),u=this.getKey("member",f.xmlName,f.ec2QueryName),h=i?`${n}${c}`:`${n}${u}.${c}`;this.write(o,a,h),++c}}}else if(s.isMapSchema()){if(t&&typeof t==="object"){let o=s.getKeySchema(),i=s.getValueSchema(),c=s.getMergedTraits().xmlFlattened,a=1;for(let f in t){let u=t[f];if(u==null)continue;let h=o.getMergedTraits(),l=this.getKey("key",h.xmlName,h.ec2QueryName),d=c?`${n}${a}.${l}`:`${n}entry.${a}.${l}`,m=i.getMergedTraits(),y=this.getKey("value",m.xmlName,m.ec2QueryName),g=c?`${n}${a}.${y}`:`${n}entry.${a}.${y}`;this.write(o,f,d),this.write(i,u,g),++a}}}else if(s.isStructSchema()){if(t&&typeof t==="object"){let o=!1;for(let[i,c]of s.structIterator()){if(t[i]==null&&!c.isIdempotencyToken())continue;let a=c.getMergedTraits(),f=this.getKey(i,a.xmlName,a.ec2QueryName,"struct"),u=`${n}${f}`;this.write(c,t[i],u),o=!0}if(!o&&s.isUnionSchema()){let{$unknown:i}=t;if(Array.isArray(i)){let[c,a]=i,f=`${n}${c}`;this.write(15,a,f)}}}}else if(s.isUnitSchema());else throw Error(`@aws-sdk/core/protocols - QuerySerializer unrecognized schema type ${s.getName(!0)}`)}flush(){if(this.buffer===void 0)throw Error("@aws-sdk/core/protocols - QuerySerializer cannot flush with nothing written to buffer.");let e=this.buffer;return delete this.buffer,e}getKey(e,t,n,s){let{ec2:o,capitalizeKeys:i}=this.settings;if(o&&n)return n;let c=t??e;if(i&&s==="struct")return c[0].toUpperCase()+c.slice(1);return c}writeKey(e){if(e.endsWith("."))e=e.slice(0,e.length-1);this.buffer+=`&${zn(e)}=`}writeValue(e){this.buffer+=zn(e)}}class lr extends Gn{options;serializer;deserializer;mixin=new ye;constructor(e){super({defaultNamespace:e.defaultNamespace,errorTypeRegistries:e.errorTypeRegistries});this.options=e;let t={timestampFormat:{useTrait:!0,default:5},httpBindings:!1,xmlNamespace:e.xmlNamespace,serviceNamespace:e.defaultNamespace,serializeEmptyLists:!0};this.serializer=new hr(t),this.deserializer=new mt(t)}getShapeId(){return"aws.protocols#awsQuery"}setSerdeContext(e){this.serializer.setSerdeContext(e),this.deserializer.setSerdeContext(e)}getPayloadCodec(){throw Error("AWSQuery protocol has no payload codec.")}async serializeRequest(e,t,n){let s=await super.serializeRequest(e,t,n);if(!s.path.endsWith("/"))s.path+="/";if(s.headers["content-type"]="application/x-www-form-urlencoded",qn(e.input)==="unit"||!s.body)s.body="";let o=e.name.split("#")[1]??e.name;if(s.body=`Action=${o}&Version=${this.options.version}`+s.body,s.body.endsWith("&"))s.body=s.body.slice(-1);return s}async deserializeResponse(e,t,n){let s=this.deserializer,o=T.of(e.output),i={};if(n.statusCode>=300){let u=await nt(n.body,t);if(u.byteLength>0)Object.assign(i,await s.read(15,u));await this.handleError(e,t,n,i,this.deserializeMetadata(n))}for(let u in n.headers){let h=n.headers[u];delete n.headers[u],n.headers[u.toLowerCase()]=h}let c=e.name.split("#")[1]??e.name,a=o.isStructSchema()&&this.useNestedResult()?c+"Result":void 0,f=await nt(n.body,t);if(f.byteLength>0)Object.assign(i,await s.read(o,f,a));return i.$metadata=this.deserializeMetadata(n),i}useNestedResult(){return!0}async handleError(e,t,n,s,o){let i=this.loadQueryErrorCode(n,s)??"Unknown";this.mixin.compose(this.compositeErrorRegistry,i,this.options.defaultNamespace);let c=this.loadQueryError(s)??{},a=this.loadQueryErrorMessage(s);c.message=a,c.Error={Type:c.Type,Code:c.Code,Message:a};let{errorSchema:f,errorMetadata:u}=await this.mixin.getErrorSchemaOrThrowBaseException(i,this.options.defaultNamespace,n,c,o,this.mixin.findQueryCompatibleError),h=T.of(f),d=new(this.compositeErrorRegistry.getErrorCtor(f)??Error)({}),m={Type:c.Error.Type,Code:c.Error.Code,Error:c.Error};for(let[y,g]of h.structIterator()){let N=g.getMergedTraits().xmlName??y,I=c[N]??s[N];m[y]=this.deserializer.readSchema(g,I)}throw this.mixin.decorateServiceException(Object.assign(d,u,{$fault:h.getMergedTraits().error,message:a},m),s)}loadQueryErrorCode(e,t){let n=(t.Errors?.[0]?.Error??t.Errors?.Error??t.Error)?.Code;if(n!==void 0)return n;if(e.statusCode==404)return"NotFound"}loadQueryError(e){return e.Errors?.[0]?.Error??e.Errors?.Error??e.Error}loadQueryErrorMessage(e){let t=this.loadQueryError(e);return t?.message??t?.Message??e.message??e.Message??"Unknown"}getDefaultContentType(){return"application/x-www-form-urlencoded"}}class ls extends lr{options;constructor(e){super(e);this.options=e;let t={capitalizeKeys:!0,flattenLists:!0,serializeEmptyLists:!1,ec2:!0};Object.assign(this.serializer.settings,t)}getShapeId(){return"aws.protocols#ec2Query"}useNestedResult(){return!1}}var ds=(e,t)=>ns(e,t).then((n)=>{if(n.length){let s;try{s=es(n)}catch(a){if(a&&typeof a==="object")Object.defineProperty(a,"$responseBodyText",{value:n});throw a}let o="#text",i=Object.keys(s)[0],c=s[i];if(c[o])c[i]=c[o],delete c[o];return Qn(c)}return{}}),Cc=async(e,t)=>{let n=await ds(e,t);if(n.Error)n.Error.message=n.Error.message??n.Error.Message;return n},ms=(e,t)=>{if(t?.Error?.Code!==void 0)return t.Error.Code;if(t?.Code!==void 0)return t.Code;if(e.statusCode==404)return"NotFound"};class dr extends K{settings;stringBuffer;byteBuffer;buffer;constructor(e){super();this.settings=e}write(e,t){let n=T.of(e);if(n.isStringSchema()&&typeof t==="string")this.stringBuffer=t;else if(n.isBlobSchema())this.byteBuffer="byteLength"in t?t:(this.serdeContext?.base64Decoder??ir)(t);else{this.buffer=this.writeStruct(n,t,void 0);let s=n.getMergedTraits();if(s.httpPayload&&!s.xmlName)this.buffer.withName(n.getName())}}flush(){if(this.byteBuffer!==void 0){let t=this.byteBuffer;return delete this.byteBuffer,t}if(this.stringBuffer!==void 0){let t=this.stringBuffer;return delete this.stringBuffer,t}let e=this.buffer;if(this.settings.xmlNamespace){if(!e?.attributes?.xmlns)e.addAttribute("xmlns",this.settings.xmlNamespace)}return delete this.buffer,e.toString()}writeStruct(e,t,n){let s=e.getMergedTraits(),o=e.isMemberSchema()&&!s.httpPayload?e.getMemberTraits().xmlName??e.getMemberName():s.xmlName??e.getName();if(!o||!e.isStructSchema())throw Error(`@aws-sdk/core/protocols - xml serializer, cannot write struct with empty name or non-struct, schema=${e.getName(!0)}.`);let i=H.of(o),[c,a]=this.getXmlnsAttribute(e,n);for(let[u,h]of e.structIterator()){let l=t[u];if(l!=null||h.isIdempotencyToken()){if(h.getMergedTraits().xmlAttribute){i.addAttribute(h.getMergedTraits().xmlName??u,this.writeSimple(h,l));continue}if(h.isListSchema())this.writeList(h,l,i,a);else if(h.isMapSchema())this.writeMap(h,l,i,a);else if(h.isStructSchema())i.addChildNode(this.writeStruct(h,l,a));else{let d=H.of(h.getMergedTraits().xmlName??h.getMemberName());this.writeSimpleInto(h,l,d,a),i.addChildNode(d)}}}let{$unknown:f}=t;if(f&&e.isUnionSchema()&&Array.isArray(f)&&Object.keys(t).length===1){let[u,h]=f,l=H.of(u);if(typeof h!=="string")if(t instanceof H||t instanceof On)i.addChildNode(t);else throw Error("@aws-sdk - $unknown union member in XML requires value of type string, @aws-sdk/xml-builder::XmlNode or XmlText.");this.writeSimpleInto(0,h,l,a),i.addChildNode(l)}if(a)i.addAttribute(c,a);return i}writeList(e,t,n,s){if(!e.isMemberSchema())throw Error(`@aws-sdk/core/protocols - xml serializer, cannot write non-member list: ${e.getName(!0)}`);let o=e.getMergedTraits(),i=e.getValueSchema(),c=i.getMergedTraits(),a=!!c.sparse,f=!!o.xmlFlattened,[u,h]=this.getXmlnsAttribute(e,s),l=(d,m)=>{if(i.isListSchema())this.writeList(i,Array.isArray(m)?m:[m],d,h);else if(i.isMapSchema())this.writeMap(i,m,d,h);else if(i.isStructSchema()){let y=this.writeStruct(i,m,h);d.addChildNode(y.withName(f?o.xmlName??e.getMemberName():c.xmlName??"member"))}else{let y=H.of(f?o.xmlName??e.getMemberName():c.xmlName??"member");this.writeSimpleInto(i,m,y,h),d.addChildNode(y)}};if(f){for(let d of t)if(a||d!=null)l(n,d)}else{let d=H.of(o.xmlName??e.getMemberName());if(h)d.addAttribute(u,h);for(let m of t)if(a||m!=null)l(d,m);n.addChildNode(d)}}writeMap(e,t,n,s,o=!1){if(!e.isMemberSchema())throw Error(`@aws-sdk/core/protocols - xml serializer, cannot write non-member map: ${e.getName(!0)}`);let i=e.getMergedTraits(),c=e.getKeySchema(),f=c.getMergedTraits().xmlName??"key",u=e.getValueSchema(),h=u.getMergedTraits(),l=h.xmlName??"value",d=!!h.sparse,m=!!i.xmlFlattened,[y,g]=this.getXmlnsAttribute(e,s),N=(I,j,O)=>{let v=H.of(f,j),[ps,gr]=this.getXmlnsAttribute(c,g);if(gr)v.addAttribute(ps,gr);I.addChildNode(v);let Se=H.of(l);if(u.isListSchema())this.writeList(u,O,Se,g);else if(u.isMapSchema())this.writeMap(u,O,Se,g,!0);else if(u.isStructSchema())Se=this.writeStruct(u,O,g);else this.writeSimpleInto(u,O,Se,g);I.addChildNode(Se)};if(m)for(let I in t){let j=t[I];if(d||j!=null){let O=H.of(i.xmlName??e.getMemberName());N(O,I,j),n.addChildNode(O)}}else{let I;if(!o){if(I=H.of(i.xmlName??e.getMemberName()),g)I.addAttribute(y,g);n.addChildNode(I)}for(let j in t){let O=t[j];if(d||O!=null){let v=H.of("entry");N(v,j,O),(o?n:I).addChildNode(v)}}}}writeSimple(e,t){if(t===null)throw Error("@aws-sdk/core/protocols - (XML serializer) cannot write null value.");let n=T.of(e),s=null;if(t&&typeof t==="object")if(n.isBlobSchema())s=(this.serdeContext?.base64Encoder??ge)(t);else if(n.isTimestampSchema()&&t instanceof Date)switch(pe(n,this.settings)){case 5:s=t.toISOString().replace(".000Z","Z");break;case 6:s=De(t);break;case 7:s=String(t.getTime()/1000);break;default:console.warn("Missing timestamp format, using http date",t),s=De(t);break}else if(n.isBigDecimalSchema()&&t){if(t instanceof B)return t.string;return String(t)}else if(n.isMapSchema()||n.isListSchema())throw Error("@aws-sdk/core/protocols - xml serializer, cannot call _write() on List/Map schema, call writeList or writeMap() instead.");else throw Error(`@aws-sdk/core/protocols - xml serializer, unhandled schema type for object value and schema: ${n.getName(!0)}`);if(n.isBooleanSchema()||n.isNumericSchema()||n.isBigIntegerSchema()||n.isBigDecimalSchema())s=String(t);if(n.isStringSchema())if(t===void 0&&n.isIdempotencyToken())s=ct();else s=String(t);if(s===null)throw Error(`Unhandled schema-value pair ${n.getName(!0)}=${t}`);return s}writeSimpleInto(e,t,n,s){let o=this.writeSimple(e,t),i=T.of(e),c=new On(o),[a,f]=this.getXmlnsAttribute(i,s);if(f)n.addAttribute(a,f);n.addChildNode(c)}getXmlnsAttribute(e,t){let n=e.getMergedTraits(),[s,o]=n.xmlNamespace??[];if(o&&o!==t)return[s?`xmlns:${s}`:"xmlns",o];return[void 0,void 0]}}class mr extends K{settings;constructor(e){super();this.settings=e}createSerializer(){let e=new dr(this.settings);return e.setSerdeContext(this.serdeContext),e}createDeserializer(){let e=new mt(this.settings);return e.setSerdeContext(this.serdeContext),e}}class gs extends Wn{codec;serializer;deserializer;mixin=new ye;constructor(e){super(e);let t={timestampFormat:{useTrait:!0,default:5},httpBindings:!0,xmlNamespace:e.xmlNamespace,serviceNamespace:e.defaultNamespace};this.codec=new mr(t),this.serializer=new Xn(this.codec.createSerializer(),t),this.deserializer=new Jn(this.codec.createDeserializer(),t)}getPayloadCodec(){return this.codec}getShapeId(){return"aws.protocols#restXml"}async serializeRequest(e,t,n){let s=await super.serializeRequest(e,t,n),o=T.of(e.input);if(!s.headers["content-type"]){let i=this.mixin.resolveRestContentType(this.getDefaultContentType(),o);if(i)s.headers["content-type"]=i}if(typeof s.body==="string"&&s.headers["content-type"]===this.getDefaultContentType()&&!s.body.startsWith("<?xml ")&&!this.hasUnstructuredPayloadBinding(o))s.body='<?xml version="1.0" encoding="UTF-8"?>'+s.body;return s}async deserializeResponse(e,t,n){return super.deserializeResponse(e,t,n)}async handleError(e,t,n,s,o){let i=ms(n,s)??"Unknown";if(this.mixin.compose(this.compositeErrorRegistry,i,this.options.defaultNamespace),s.Error&&typeof s.Error==="object"){for(let y of Object.keys(s.Error))if(s[y]=s.Error[y],y.toLowerCase()==="message")s.message=s.Error[y]}if(s.RequestId&&!o.requestId)o.requestId=s.RequestId;let{errorSchema:c,errorMetadata:a}=await this.mixin.getErrorSchemaOrThrowBaseException(i,this.options.defaultNamespace,n,s,o),f=T.of(c),u=s.Error?.message??s.Error?.Message??s.message??s.Message??"UnknownError",l=new(this.compositeErrorRegistry.getErrorCtor(c)??Error)({});await this.deserializeHttpMessage(c,t,n,s);let d={},m=this.codec.createDeserializer();for(let[y,g]of f.structIterator()){let N=g.getMergedTraits().xmlName??y,I=s.Error?.[N]??s[N];d[y]=m.readSchema(g,I)}throw this.mixin.decorateServiceException(Object.assign(l,a,{$fault:f.getMergedTraits().error,message:u},d),s)}getDefaultContentType(){return"application/xml"}hasUnstructuredPayloadBinding(e){for(let[,t]of e.structIterator())if(t.getMergedTraits().httpPayload)return!(t.isStructSchema()||t.isMapSchema()||t.isListSchema());return!1}}var Ac=(e)=>{if(e==null)return;if(typeof e==="object"&&"__type"in e)delete e.__type;return gc(e)},Tc=(e)=>{if(e==null)return e;if(typeof e==="number"||typeof e==="bigint"){let t=Error(`Received number ${e} where a string was expected.`);return t.name="Warning",console.warn(t),String(e)}if(typeof e==="boolean"){let t=Error(`Received boolean ${e} where a string was expected.`);return t.name="Warning",console.warn(t),String(e)}return e},Ic=(e)=>{if(e==null)return e;if(typeof e==="string"){let t=e.toLowerCase();if(e!==""&&t!=="false"&&t!=="true"){let n=Error(`Received string "${e}" where a boolean was expected.`);n.name="Warning",console.warn(n)}return e!==""&&t!=="false"}return e},kc=(e)=>{if(e==null)return e;if(typeof e==="string"){let t=Number(e);if(t.toString()!==e){let n=Error(`Received string "${e}" where a number was expected.`);return n.name="Warning",console.warn(n),e}return t}return e};Rc.AwsEc2QueryProtocol=ls;Rc.AwsJson1_0Protocol=cs;Rc.AwsJson1_1Protocol=as;Rc.AwsJsonRpcProtocol=dt;Rc.AwsQueryProtocol=lr;Rc.AwsRestJsonProtocol=fs;Rc.AwsRestXmlProtocol=gs;Rc.AwsSmithyRpcV2CborProtocol=ts;Rc.JsonCodec=hs;Rc.JsonCodec2=lt;Rc.JsonShapeDeserializer=fr;Rc.JsonShapeDeserializer2=ar;Rc.JsonShapeSerializer=ur;Rc.JsonShapeSerializer2=ht;Rc.QueryShapeSerializer=hr;Rc.XmlCodec=mr;Rc.XmlShapeDeserializer=mt;Rc.XmlShapeSerializer=dr;Rc._toBool=Ic;Rc._toNum=kc;Rc._toStr=Tc;Rc.awsExpectUnion=Ac;Rc.loadJsonRpcErrorCode=is;Rc.loadRestJsonErrorCode=ss;Rc.loadRestXmlErrorCode=ms;Rc.parseJsonBody=ut;Rc.parseJsonErrorBody=wc;Rc.parseXmlBody=ds;Rc.parseXmlErrorBody=Cc});
19
+ `))continue;f["#text"]="#text"in f?f["#text"]+u:u}for(let u of i){if(u.tag==="__proto__")Zt(f);if(u.tag in f)if(Array.isArray(f[u.tag]))f[u.tag].push(u.value);else f[u.tag]=[f[u.tag],u.value];else f[u.tag]=u.value}for(let[u,h]of Object.entries(s)){if(u==="__proto__")Zt(f);f[u]=h}return{tag:t,value:f}}static ENTITIES={amp:"&",lt:"<",gt:">",quot:'"',apos:"'"};skipDoctype(){let e=this;e.i+=9;let t=0;while(e.i<e.z){let n=e.x[e.i];if(n==="[")++t;else if(n==="]")--t;else if(n===">"&&t===0){++e.i;return}++e.i}throw Error("@aws-sdk XML parse error: unclosed DOCTYPE.")}decodeEntities(e){return e.replace(/&(?:#x([0-9a-fA-F]{1,6})|#(\d{1,7})|([a-zA-Z][a-zA-Z0-9]{0,30}));/g,(t,n,s,o)=>{if(n)return String.fromCharCode(parseInt(n,16));if(s)return String.fromCharCode(parseInt(s,10));return vt.ENTITIES[o]??""})}}ac.XmlNode=Me;ac.XmlText=Yt;ac.parseXML=cc});var at=r(function(Rc){var{SmithyRpcV2CborProtocol:lc,loadSmithyRpcV2CborErrorCode:dc}=Bn(),{TypeRegistry:Dn,NormalizedSchema:A,deref:qn}=_e(),{decorateServiceException:jn,getValueFromTextNode:Qn}=Z(),{collectBody:nt,determineTimestampFormat:pe,RpcProtocol:Gn,HttpBindingProtocol:Wn,HttpInterceptingShapeSerializer:Xn,HttpInterceptingShapeDeserializer:Jn,FromStringShapeDeserializer:mc,extendedEncodeURIComponent:zn}=z(),{NumericValue:M,toUtf8:sr,fromBase64:ir,LazyJsonString:ot,parseEpochTimestamp:Zn,parseRfc7231DateTime:Yn,parseRfc3339DateTimeWithOffset:vn,generateIdempotencyToken:ct,toBase64:ge,dateToUtcString:Ue,expectUnion:gc}=ee(),{parseXML:es,XmlNode:P,XmlText:On}=Un();class ye{queryCompat;errorRegistry;constructor(e=!1){this.queryCompat=e}resolveRestContentType(e,t){let n=t.getMemberSchemas(),s=Object.values(n).find((o)=>!!o.getMergedTraits().httpPayload);if(s){let o=s.getMergedTraits().mediaType;if(o)return o;else if(s.isStringSchema())return"text/plain";else if(s.isBlobSchema())return"application/octet-stream";else return e}else if(!t.isUnitSchema()){if(Object.values(n).find((i)=>{let{httpQuery:c,httpQueryParams:a,httpHeader:f,httpLabel:u,httpPrefixHeaders:h}=i.getMergedTraits();return!c&&!a&&!f&&!u&&h===void 0}))return e}}async getErrorSchemaOrThrowBaseException(e,t,n,s,o,i){let c=e;if(e.includes("#"))[,c]=e.split("#");let a={$metadata:o,$fault:n.statusCode<500?"client":"server"};if(!this.errorRegistry)throw Error("@aws-sdk/core/protocols - error handler not initialized.");try{return{errorSchema:i?.(this.errorRegistry,c)??this.errorRegistry.getSchema(e),errorMetadata:a}}catch(f){s.message=s.message??s.Message??"UnknownError";let u=this.errorRegistry,h=u.getBaseException();if(h){let m=u.getErrorCtor(h)??Error;throw this.decorateServiceException(Object.assign(new m({name:c}),a),s)}let l=s,d=l?.message??l?.Message??l?.Error?.Message??l?.Error?.message;throw this.decorateServiceException(Object.assign(Error(d),{name:c},a),s)}}compose(e,t,n){let s=n;if(t.includes("#"))[s]=t.split("#");let o=Dn.for(s),i=Dn.for("smithy.ts.sdk.synthetic."+n);e.copyFrom(o),e.copyFrom(i),this.errorRegistry=e}decorateServiceException(e,t={}){if(this.queryCompat){let n=e.Message??t.Message,s=jn(e,t);if(n)s.message=n;let o=s.Error??{};o.Type=s.Error?.Type,o.Code=s.Error?.Code,o.Message=s.Error?.message??s.Error?.Message??n,s.Error=o;let i=s.$metadata.requestId;if(i)s.RequestId=i;return s}return jn(e,t)}setQueryCompatError(e,t){let n=t.headers?.["x-amzn-query-error"];if(e!==void 0&&n!=null){let[s,o]=n.split(";"),i=Object.keys(e),c={Code:s,Type:o};e.Code=s,e.Type=o;for(let a=0;a<i.length;a++){let f=i[a];c[f==="message"?"Message":f]=e[f]}delete c.__type,e.Error=c}}queryCompatOutput(e,t){if(e.Error)t.Error=e.Error;if(e.Type)t.Type=e.Type;if(e.Code)t.Code=e.Code}findQueryCompatibleError(e,t){try{return e.getSchema(t)}catch(n){return e.find((s)=>A.of(s).getMergedTraits().awsQueryError?.[0]===t)}}}class ts extends lc{awsQueryCompatible;mixin;constructor({defaultNamespace:e,errorTypeRegistries:t,awsQueryCompatible:n}){super({defaultNamespace:e,errorTypeRegistries:t});this.awsQueryCompatible=!!n,this.mixin=new ye(this.awsQueryCompatible)}async serializeRequest(e,t,n){let s=await super.serializeRequest(e,t,n);if(this.awsQueryCompatible)s.headers["x-amzn-query-mode"]="true";return s}async handleError(e,t,n,s,o){if(this.awsQueryCompatible)this.mixin.setQueryCompatError(s,n);let i=(()=>{let m=n.headers["x-amzn-query-error"];if(m&&this.awsQueryCompatible)return m.split(";")[0];return dc(n,s)??"Unknown"})();this.mixin.compose(this.compositeErrorRegistry,i,this.options.defaultNamespace);let{errorSchema:c,errorMetadata:a}=await this.mixin.getErrorSchemaOrThrowBaseException(i,this.options.defaultNamespace,n,s,o,this.awsQueryCompatible?this.mixin.findQueryCompatibleError:void 0),f=A.of(c),u=s.message??s.Message??"UnknownError",l=new(this.compositeErrorRegistry.getErrorCtor(c)??Error)({}),d={};for(let[m,y]of f.structIterator())if(s[m]!=null)d[m]=this.deserializer.readValue(y,s[m]);if(this.awsQueryCompatible)this.mixin.queryCompatOutput(s,d);throw this.mixin.decorateServiceException(Object.assign(l,a,{$fault:f.getMergedTraits().error,message:u},d),s)}}class H{serdeContext;setSerdeContext(e){this.serdeContext=e}}class ft{from;to;keys;constructor(e,t){this.from=e,this.to=t;let n=Object.keys(this.from),s=new Set(n);s.delete("__type"),this.keys=s}mark(e){this.keys.delete(e)}hasUnknown(){return this.keys.size===1&&Object.keys(this.to).length===0}writeUnknown(){if(this.hasUnknown()){let e=this.keys.values().next().value,t=this.from[e];this.to.$unknown=[e,t]}}}var Be;function rs(){if(Be===void 0)try{if(typeof Buffer!=="function")Be=!1;else{let e=JSON.parse(Buffer.from([123,125]));Be=e!==null&&typeof e==="object"}}catch{Be=!1}return Be}function or(e,t,n){if(n?.source){let s=n.source;if(typeof t==="number")if(t<=Number.MAX_SAFE_INTEGER&&t>=Number.MIN_SAFE_INTEGER){if(yc(s,t))return t;return new M(s,"bigDecimal")}else{if(pc(s))return new M(s,"bigDecimal");if(/[eE]/.test(s))return Sc(s);return BigInt(s)}}return t}function pc(e){let t=e.indexOf(".");if(t===-1)return!1;let n=e.search(/[eE]/);if(n===-1)return!0;let s=n-t-1;return parseInt(e.slice(n+1),10)<s}function yc(e,t){if(e===String(t))return!0;if(Object.is(t,-0))return!0;if(/[eE]/.test(e))return er(e)===er(String(t));let n=e.replace(/(\.\d*?)0+$/,"$1").replace(/\.$/,""),s=String(t);if(n===s)return!0;if(/[eE]/.test(s))return n===er(s);return!1}function er(e){let t=e.startsWith("-"),n=t?e.slice(1):e,s=n.search(/[eE]/),o;if(s===-1)o=n;else{let i=parseInt(n.slice(s+1),10),c=n.slice(0,s),a=c.indexOf("."),f,u;if(a===-1)f=c,u=c.length;else f=c.slice(0,a)+c.slice(a+1),u=a;f=f.replace(/0+$/,"")||"0";let h=u+i;if(f==="0")o="0";else if(h<=0)o="0."+"0".repeat(-h)+f;else if(h>=f.length)o=f+"0".repeat(h-f.length);else o=f.slice(0,h)+"."+f.slice(h)}if(o.includes("."))o=o.replace(/(\.\d*?)0+$/,"$1").replace(/\.$/,"");return(t?"-":"")+o}function Sc(e){let t=e.search(/[eE]/),n=parseInt(e.slice(t+1),10),s=e.startsWith("-"),o=e.slice(s?1:0,t),i=o.indexOf("."),c,a;if(i===-1)c=o,a=n;else{c=o.slice(0,i)+o.slice(i+1);let u=o.length-i-1;a=n-u}c=c.replace(/0+$/,"")||"0";let f=BigInt(c)*10n**BigInt(a+(o.replace(".","").length-c.length));return s?-f:f}var tr=Symbol.for("@aws-sdk/reviver");function cr(e){let t=A.of(e),n=t.getSchema();if(Array.isArray(n)&&t.isStructSchema()){if(tr in n)return n[tr];let s=st(t,new Set);return n[tr]=s,s}return st(t,new Set)}function st(e,t){let n=e.getSchema();if(t.has(n))return!1;if(t.add(n),e.isBigIntegerSchema()||e.isBigDecimalSchema())return!0;if(e.isStructSchema()){for(let[,s]of e.structIterator())if(st(s,t))return!0}else if(e.isListSchema()||e.isMapSchema()){if(st(e.getValueSchema(),t))return!0}else if(e.isDocumentSchema())return!0;return!1}var ns=(e,t)=>nt(e,t).then((n)=>(t?.utf8Encoder??sr)(n));async function ut(e,t,n){let s;if(rs()&&typeof e?.[Symbol.asyncIterator]==="function"){let i=await nt(e,t);if(typeof Buffer==="function")if(Buffer.isBuffer(i))s=i;else s=Buffer.from(i.buffer,i.byteOffset,i.byteLength)}if(!s)s=await ns(e,t);if(s.length===0)return{};let o=n&&cr(n)?or:void 0;try{return JSON.parse(s,o)}catch(i){if(i?.name==="SyntaxError")Object.defineProperty(i,"$responseBodyText",{value:typeof s==="string"?s:s.toString("utf8")});throw i}}var wc=async(e,t)=>{let n=await ut(e,t);return n.message=n.message??n.Message,n},Ln=(e,t)=>Object.keys(e).find((n)=>n.toLowerCase()===t.toLowerCase()),rr=(e)=>{let t=e;if(typeof t==="number")t=t.toString();if(t.indexOf(",")>=0)t=t.split(",")[0];if(t.indexOf(":")>=0)t=t.split(":")[0];if(t.indexOf("#")>=0)t=t.split("#")[1];return t},ss=(e,t)=>os(e,t,["header","code","type"]),is=(e,t,n=!1)=>os(e,t,n?["code","header","type"]:["type","code","header"]),os=({headers:e},t,n)=>{while(n.length>0)switch(n.shift()){case"header":let o=Ln(e??{},"x-amzn-errortype");if(o!==void 0)return rr(e[o]);break;case"code":let i=Ln(t??{},"code");if(i&&t[i]!==void 0)return rr(t[i]);break;case"type":if(t?.__type!==void 0)return rr(t.__type);break}};function J(e){Object.defineProperty(e,"__proto__",{value:void 0,writable:!0,enumerable:!0,configurable:!0})}class ar extends H{settings;constructor(e){super();this.settings=e}async read(e,t){let n=cr(e)?or:void 0,s;if(typeof t==="string"){if(t.length===0)return{};s=JSON.parse(t,n)}else if(t instanceof Uint8Array&&rs()){if(t.byteLength===0)return{};let o=Buffer.isBuffer(t)?t:Buffer.from(t.buffer,t.byteOffset,t.byteLength);s=JSON.parse(o,n)}else s=await ut(t,this.serdeContext,e);return this._read(e,s)}readObject(e,t){return this._read(e,t)}_read(e,t){let n=t!==null&&typeof t==="object",s=A.of(e);if(n){if(s.isStructSchema())return this._readStruct(s,t);if(Array.isArray(t)&&s.isListSchema()){let i=s.getValueSchema();if(this.needsTransform(i))for(let c=0;c<t.length;++c)t[c]=this._read(i,t[c]);return t}if(s.isMapSchema()){let i=s.getValueSchema(),c=t;if(this.needsTransform(i))for(let a in c){if(a==="__proto__")J(c);c[a]=this._read(i,c[a])}return c}}if(s.isBlobSchema()&&typeof t==="string")return ir(t);let o=s.getMergedTraits().mediaType;if(s.isStringSchema()&&typeof t==="string"&&o){if(o==="application/json"||o.endsWith("+json"))return ot.from(t);return t}if(s.isTimestampSchema()&&t!=null)switch(pe(s,this.settings)){case 5:return vn(t);case 6:return Yn(t);case 7:return Zn(t);default:return console.warn("Missing timestamp format, parsing value with Date constructor:",t),new Date(t)}if(s.isBigIntegerSchema()&&(typeof t==="number"||typeof t==="string"))return BigInt(t);if(s.isBigDecimalSchema()&&t!=null){if(t instanceof M)return t;let i=t;if(i.type==="bigDecimal"&&"string"in i)return new M(i.string,i.type);return new M(String(t),"bigDecimal")}if(s.isNumericSchema()&&typeof t==="string"){switch(t){case"Infinity":return 1/0;case"-Infinity":return-1/0;case"NaN":return NaN}return t}if(s.isDocumentSchema()){if(n)if(Array.isArray(t))for(let i=0;i<t.length;++i){let c=t[i];if(!(c instanceof M))t[i]=this._read(s,c)}else{let i=t;for(let c in i){if(c==="__proto__")J(i);let a=i[c];if(!(a instanceof M))i[c]=this._read(s,a)}}}return t}_readStruct(e,t){let n=e.isUnionSchema(),s={},o,i=typeof t.__type==="string",{jsonName:c}=this.settings;if(c&&i)o={};let a;if(n)a=new ft(t,s);for(let[f,u]of e.structIterator()){let h=f;if(c){if(h=u.getMergedTraits().jsonName??h,i)o[h]=f}if(n)a.mark(h);if(t[h]!=null)s[f]=this._read(u,t[h])}if(n)a.writeUnknown();else if(i)for(let f in t){let u=t[f],h=c?o[f]??f:f;if(!(h in s))s[h]=u}return s}needsTransform(e){if(e.isBlobSchema()||e.isTimestampSchema()||e.isBigIntegerSchema()||e.isBigDecimalSchema())return!0;if(e.isDocumentSchema()||e.isStructSchema()||e.isListSchema()||e.isMapSchema())return!0;if(e.isStringSchema()&&e.getMergedTraits().mediaType)return!0;return!1}}class it extends Uint8Array{string=null;static allocUnsafe(e){if(typeof Buffer==="function"){let t=Buffer.allocUnsafe(e);return new it(t.buffer,t.byteOffset,t.byteLength)}return new it(e)}toString(){return this.s()}valueOf(){return this.s()}includes(e,t){if(typeof e==="string")return this.s().includes(e,t);return Uint8Array.prototype.includes.call(this,e,t)}indexOf(e,t){if(typeof e==="string")return this.s().indexOf(e,t);return Uint8Array.prototype.indexOf.call(this,e,t)}lastIndexOf(e,t){if(typeof e==="string")return this.s().lastIndexOf(e,t);let n=Uint8Array.prototype.lastIndexOf;if(t!==void 0)return n.call(this,e,t);return n.call(this,e)}startsWith(e,t){return this.s().startsWith(e,t)}endsWith(e,t){return this.s().endsWith(e,t)}match(e){return this.s().match(e)}replace(e,t){return this.s().replace(e,t)}search(e){return this.s().search(e)}split(e,t){return this.s().split(e,t)}substring(e,t){return this.s().substring(e,t)}trim(){return this.s().trim()}trimStart(){return this.s().trimStart()}trimEnd(){return this.s().trimEnd()}charAt(e){return this.s().charAt(e)}charCodeAt(e){return this.s().charCodeAt(e)}padStart(e,t){return this.s().padStart(e,t)}padEnd(e,t){return this.s().padEnd(e,t)}repeat(e){return this.s().repeat(e)}toUpperCase(){return this.s().toUpperCase()}toLowerCase(){return this.s().toLowerCase()}s(){if(this.string==null){let e=Date.now();if(e>$n+60000)console.warn("@aws-sdk/core/protocols - WARN - JsonCodec2: you have called a string method on a Uint8Array request body. It has been automatically converted to string. In a future version this will throw an error."),$n=e;this.string=sr(this)}return this.string}}var $n=0,et=new TextEncoder,Vn=123,Fn=125,bc=91,xc=93,me=34,tt=58,rt=44,Pn=92,Ec=new Uint8Array([116,114,117,101]),Nc=new Uint8Array([102,97,108,115,101]),_c=new Uint8Array([110,117,108,108]),Q=Array(128).fill(null);Q[8]="b";Q[9]="t";Q[10]="n";Q[12]="f";Q[13]="r";Q[34]='"';Q[92]="\\";for(let e=0;e<32;e++)if(Q[e]===null)Q[e]="u00"+e.toString(16).padStart(2,"0");var Hn=2048;function nr(e){return it.allocUnsafe(e)}class ht extends H{settings;json;i=0;rootSchema;rawValue;passthrough=!1;constructor(e){super();this.settings=e,this.json=nr(Hn)}write(e,t){if(this.i=0,this.rawValue=t,this.rootSchema=A.of(e),this.passthrough=this.rootSchema.isBlobSchema()||this.rootSchema.isStringSchema(),!this.passthrough)this.writeValue(this.rootSchema,t,void 0)}writeDiscriminatedDocument(e,t){this.i=0,this.rootSchema=A.of(e);let n=this.rootSchema;if(n.isStructSchema()&&t!=null&&typeof t==="object"){this.writeValue(n,t,void 0);let s=`"__type":"${n.getName(!0)??"Unknown"}",`,o=s.length;this.ensure(o),this.json.copyWithin(1+o,1,this.i),et.encodeInto(s,this.json.subarray(1)),this.i+=o}else this.writeValue(n,t,void 0)}flush(){this.rootSchema=void 0;let e=this.i;this.i=0;let t=this.rawValue;if(this.rawValue=void 0,e===0)return t;let n=this.json.subarray(0,e);return this.json=nr(Hn),n}ensure(e){let{i:t,json:n}=this;if(t+e>n.length){let s=n.length*2;while(s<t+e)s*=2;let o=nr(s);o.set(this.json),this.json=o}}writeAscii(e){let t=e.length;this.ensure(t);let{i:n,json:s}=this;for(let o=0;o<t;++o)s[n]=e.charCodeAt(o),n+=1;this.i=n}writeAsciiQuoted(e){let t=e.length;this.ensure(t+4);let{json:n,i:s}=this;n[s++]=me;for(let o=0;o<t;++o)n[s++]=e.charCodeAt(o);n[s++]=me,this.i=s}writeJsonString(e){this.ensure(e.length*3+2),this.json[this.i++]=me;let t=e.length;for(let n=0;n<t;++n){let s=e.charCodeAt(n);if(s>34&&s<92)this.json[this.i++]=s;else if(s<128){let o=Q[s];if(o!==null){this.ensure(o.length+1),this.json[this.i++]=Pn;for(let i=0;i<o.length;i++)this.json[this.i++]=o.charCodeAt(i)}else this.json[this.i++]=s}else if(s>=55296&&s<=56319){let o=n+1<t?e.charCodeAt(n+1):0;if(o>=56320&&o<=57343){this.ensure(4);let{written:i}=et.encodeInto(e.substring(n,n+2),this.json.subarray(this.i));this.i+=i,++n}else this.ensure(6),this.writeUnicodeEscape(s)}else if(s>=56320&&s<=57343)this.ensure(6),this.writeUnicodeEscape(s);else{let{i:o,json:i}=this;if(s<2048)i[o++]=192|s>>6,i[o++]=128|s&63;else i[o++]=224|s>>12,i[o++]=128|s>>6&63,i[o++]=128|s&63;this.i=o}}this.json[this.i++]=me}writeUnicodeEscape(e){let{json:t,i:n}=this;t[n++]=Pn,t[n++]=117;let s=e.toString(16).padStart(4,"0");for(let o=0;o<4;++o)t[n++]=s.charCodeAt(o);this.i=n}static B64=(()=>{let t=new Uint8Array(64);for(let n=0;n<64;++n)t[n]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charCodeAt(n);return t})();writeBase64(e){let t=Math.ceil(e.length/3)*4;this.ensure(t+2);let n=this.json,s=ht.B64,o=this.i;n[o++]=me;let i=e.length,c=i%3,a=i-c;for(let f=0;f<a;f+=3){let u=e[f],h=e[f+1],l=e[f+2];n[o++]=s[u>>2],n[o++]=s[(u&3)<<4|h>>4],n[o++]=s[(h&15)<<2|l>>6],n[o++]=s[l&63]}if(c===2){let f=e[a],u=e[a+1];n[o++]=s[f>>2],n[o++]=s[(f&3)<<4|u>>4],n[o++]=s[(u&15)<<2],n[o++]=61}else if(c===1){let f=e[a];n[o++]=s[f>>2],n[o++]=s[(f&3)<<4],n[o++]=61,n[o++]=61}n[o++]=me,this.i=o}writeValue(e,t,n){if(t==null){if(n?.isStructSchema()){if(t===void 0){if(A.of(e).isIdempotencyToken()){this.writeAsciiQuoted(ct());return}}return}this.ensure(4),this.json.set(_c,this.i),this.i+=4;return}let s=A.of(e),o=typeof t==="object";if(s.isStringSchema()){let i=s.getMergedTraits().mediaType;if(i){if(i==="application/json"||i.endsWith("+json")){this.writeJsonString(ot.from(t).toString());return}}}if(o){if(s.isStructSchema()){this.writeStruct(s,t);return}if(Array.isArray(t)&&(s.isListSchema()||s.isDocumentSchema())){this.writeList(s,t,s.isDocumentSchema());return}if(s.isMapSchema()){this.writeMap(s,t,!1);return}if(t instanceof Uint8Array&&(s.isBlobSchema()||s.isDocumentSchema())){this.writeBase64(t);return}if(t instanceof Date&&(s.isTimestampSchema()||s.isDocumentSchema())){this.writeTimestamp(s,t);return}if(t instanceof M){this.writeAscii(t.string);return}if(s.isDocumentSchema()){if(Array.isArray(t))this.writeList(s,t,!0);else this.writeMap(s,t,!0);return}let i=JSON.stringify(t);this.writeAscii(i);return}if(typeof t==="string"){if(s.isBlobSchema()){let i=(this.serdeContext?.base64Encoder??ge)(t);this.writeAsciiQuoted(i);return}this.writeJsonString(t);return}if(typeof t==="number"){if(Math.abs(t)===1/0||Number.isNaN(t)){this.writeAsciiQuoted(String(t));return}let i=String(t);this.writeAscii(i);return}if(typeof t==="boolean"){this.ensure(5);let{i,json:c}=this;if(t)c.set(Ec,i),i+=4;else c.set(Nc,i),i+=5;this.i=i;return}if(typeof t==="bigint"){this.writeAscii(t.toString());return}this.writeAscii(String(t))}writeStruct(e,t){this.ensure(2),this.json[this.i++]=Vn;let n=!1,s=typeof t.__type==="string",o;if(s)o=new Set;for(let[i,c]of e.structIterator()){let a=t[i];if(a==null&&!c.isIdempotencyToken())continue;if(n)this.ensure(1),this.json[this.i++]=rt;n=!0;let f=this.settings.jsonName?c.getMergedTraits().jsonName??i:i;if(o)o.add(i),o.add(f);this.writeAsciiQuoted(f),this.json[this.i++]=tt,this.writeValue(c,a,e)}if(!n&&e.isUnionSchema()){let{$unknown:i}=t;if(Array.isArray(i)){let[c,a]=i;this.writeAsciiQuoted(c),this.ensure(1),this.json[this.i++]=tt,this.writeValue(15,a,e)}}else if(s)for(let i in t){if(o.has(i))continue;o.add(i);let c=t[i];if(n)this.ensure(1),this.json[this.i++]=rt;n=!0,this.writeAsciiQuoted(i),this.ensure(1),this.json[this.i++]=tt,this.writeValue(15,c,void 0)}this.ensure(1),this.json[this.i++]=Fn}writeList(e,t,n){let s=!!e.getMergedTraits().sparse,o=e.getValueSchema();if(!n){if(o.isStringSchema()||o.isNumericSchema()||o.isBooleanSchema()){let c=!1;for(let f=0;f<t.length;++f){let u=t[f];if(Number.isNaN(u)||u===1/0||u===-1/0||u==null&&!s){c=!0;break}}let a;if(!c)a=JSON.stringify(t);else{let f=[];for(let u=0;u<t.length;++u){let h=t[u];if(h==null&&!s)continue;if(Number.isNaN(h)||h===1/0||h===-1/0)f.push(String(h));else f.push(h)}a=JSON.stringify(f)}this.ensure(a.length*3),this.i+=et.encodeInto(a,this.json.subarray(this.i)).written;return}}this.ensure(2),this.json[this.i++]=bc;let i=!1;for(let c=0;c<t.length;++c){let a=t[c];if(n?a===void 0:a==null&&!s)continue;if(i)this.ensure(1),this.json[this.i++]=rt;this.writeValue(o,a,void 0),i=!0}this.ensure(1),this.json[this.i++]=xc}writeMap(e,t,n){let s=!!e.getMergedTraits().sparse,o=e.getValueSchema();if(!n){if(o.isStringSchema()||o.isNumericSchema()||o.isBooleanSchema()){let c;for(let f in t){let u=t[f];if(Number.isNaN(u)||u===1/0||u===-1/0)(c??={})[f]=u,t[f]=String(u);else if(u===null&&!s)(c??={})[f]=null,t[f]=void 0}let a=JSON.stringify(t);if(c)Object.assign(t,c);this.ensure(a.length*3),this.i+=et.encodeInto(a,this.json.subarray(this.i)).written;return}}this.ensure(2),this.json[this.i++]=Vn;let i=!0;for(let c in t){let a=t[c];if(n?a===void 0:a==null&&!s)continue;if(!i)this.ensure(1),this.json[this.i++]=rt;i=!1,this.writeJsonString(c),this.ensure(1),this.json[this.i++]=tt,this.writeValue(o,a,void 0)}this.ensure(1),this.json[this.i++]=Fn}writeTimestamp(e,t){switch(pe(e,this.settings)){case 5:{let s=t.toISOString().replace(".000Z","Z");this.writeAsciiQuoted(s);return}case 6:{this.writeAsciiQuoted(Ue(t));return}case 7:{let s=String(t.getTime()/1000);this.writeAscii(s);return}default:{let s=String(t.getTime()/1000);this.writeAscii(s);return}}}}class lt extends H{settings;constructor(e){super();this.settings=e}createSerializer(){let e=new ht(this.settings);return e.setSerdeContext(this.serdeContext),e}createDeserializer(){let e=new ar(this.settings);return e.setSerdeContext(this.serdeContext),e}}class dt extends Gn{serializer;deserializer;serviceTarget;codec;mixin;awsQueryCompatible;constructor({defaultNamespace:e,errorTypeRegistries:t,serviceTarget:n,awsQueryCompatible:s,jsonCodec:o}){super({defaultNamespace:e,errorTypeRegistries:t});this.serviceTarget=n,this.codec=o??new lt({timestampFormat:{useTrait:!0,default:7},jsonName:!1}),this.serializer=this.codec.createSerializer(),this.deserializer=this.codec.createDeserializer(),this.awsQueryCompatible=!!s,this.mixin=new ye(this.awsQueryCompatible)}async serializeRequest(e,t,n){let s=await super.serializeRequest(e,t,n);if(!s.path.endsWith("/"))s.path+="/";if(s.headers["content-type"]=`application/x-amz-json-${this.getJsonRpcVersion()}`,s.headers["x-amz-target"]=`${this.serviceTarget}.${e.name}`,this.awsQueryCompatible)s.headers["x-amzn-query-mode"]="true";if(qn(e.input)==="unit"||!s.body)s.body="{}";return s}getPayloadCodec(){return this.codec}async handleError(e,t,n,s,o){let{awsQueryCompatible:i}=this;if(i)this.mixin.setQueryCompatError(s,n);let c=is(n,s,i)??"Unknown";this.mixin.compose(this.compositeErrorRegistry,c,this.options.defaultNamespace);let{errorSchema:a,errorMetadata:f}=await this.mixin.getErrorSchemaOrThrowBaseException(c,this.options.defaultNamespace,n,s,o,i?this.mixin.findQueryCompatibleError:void 0),u=A.of(a),h=s.message??s.Message??"UnknownError",d=new(this.compositeErrorRegistry.getErrorCtor(a)??Error)({}),m={},y=this.codec.createDeserializer();for(let[g,E]of u.structIterator())if(s[g]!=null)m[g]=y.readObject(E,s[g]);if(i)this.mixin.queryCompatOutput(s,m);throw this.mixin.decorateServiceException(Object.assign(d,f,{$fault:u.getMergedTraits().error,message:h},m),s)}}class cs extends dt{constructor({defaultNamespace:e,errorTypeRegistries:t,serviceTarget:n,awsQueryCompatible:s,jsonCodec:o}){super({defaultNamespace:e,errorTypeRegistries:t,serviceTarget:n,awsQueryCompatible:s,jsonCodec:o})}getShapeId(){return"aws.protocols#awsJson1_0"}getJsonRpcVersion(){return"1.0"}getDefaultContentType(){return"application/x-amz-json-1.0"}}class as extends dt{constructor({defaultNamespace:e,errorTypeRegistries:t,serviceTarget:n,awsQueryCompatible:s,jsonCodec:o}){super({defaultNamespace:e,errorTypeRegistries:t,serviceTarget:n,awsQueryCompatible:s,jsonCodec:o})}getShapeId(){return"aws.protocols#awsJson1_1"}getJsonRpcVersion(){return"1.1"}getDefaultContentType(){return"application/x-amz-json-1.1"}}class fs extends Wn{serializer;deserializer;codec;mixin=new ye;constructor({defaultNamespace:e,errorTypeRegistries:t,jsonCodec:n}){super({defaultNamespace:e,errorTypeRegistries:t});let s={timestampFormat:{useTrait:!0,default:7},httpBindings:!0,jsonName:!0};this.codec=n??new lt(s),this.serializer=new Xn(this.codec.createSerializer(),s),this.deserializer=new Jn(this.codec.createDeserializer(),s)}getShapeId(){return"aws.protocols#restJson1"}getPayloadCodec(){return this.codec}setSerdeContext(e){this.codec.setSerdeContext(e),super.setSerdeContext(e)}async serializeRequest(e,t,n){let s=await super.serializeRequest(e,t,n),o=A.of(e.input);if(!s.headers["content-type"]){let i=this.mixin.resolveRestContentType(this.getDefaultContentType(),o);if(i)s.headers["content-type"]=i}if(s.body==null&&s.headers["content-type"]===this.getDefaultContentType())s.body="{}";return s}async deserializeResponse(e,t,n){let s=await super.deserializeResponse(e,t,n),o=A.of(e.output);for(let[i,c]of o.structIterator())if(c.getMemberTraits().httpPayload&&!(i in s))s[i]=null;return s}async handleError(e,t,n,s,o){let i=ss(n,s)??"Unknown";this.mixin.compose(this.compositeErrorRegistry,i,this.options.defaultNamespace);let{errorSchema:c,errorMetadata:a}=await this.mixin.getErrorSchemaOrThrowBaseException(i,this.options.defaultNamespace,n,s,o),f=A.of(c),u=s.message??s.Message??"UnknownError",l=new(this.compositeErrorRegistry.getErrorCtor(c)??Error)({});await this.deserializeHttpMessage(c,t,n,s);let d={},m=this.codec.createDeserializer();for(let[y,g]of f.structIterator()){let E=g.getMergedTraits().jsonName??y;d[y]=m.readObject(g,s[E])}throw this.mixin.decorateServiceException(Object.assign(l,a,{$fault:f.getMergedTraits().error,message:u},d),s)}getDefaultContentType(){return"application/json"}}class fr extends H{settings;constructor(e){super();this.settings=e}async read(e,t){let n=cr(e)?or:void 0;return this._read(e,typeof t==="string"?JSON.parse(t,n):await ut(t,this.serdeContext,e))}readObject(e,t){return this._read(e,t)}_read(e,t){let n=t!==null&&typeof t==="object",s=A.of(e);if(n){if(s.isStructSchema()){let i=t,c=s.isUnionSchema(),a={},f=void 0,{jsonName:u}=this.settings;if(u)f={};let h;if(c)h=new ft(i,a);for(let[l,d]of s.structIterator()){let m=l;if(u)m=d.getMergedTraits().jsonName??m,f[m]=l;if(c)h.mark(m);if(i[m]!=null)a[l]=this._read(d,i[m])}if(c)h.writeUnknown();else if(typeof i.__type==="string")for(let l in i){let d=i[l],m=u?f[l]??l:l;if(!(m in a))a[m]=d}return a}if(Array.isArray(t)&&s.isListSchema()){let i=s.getValueSchema(),c=[];for(let a of t)c.push(this._read(i,a));return c}if(s.isMapSchema()){let i=s.getValueSchema(),c={};for(let a in t){if(a==="__proto__")J(c);c[a]=this._read(i,t[a])}return c}}if(s.isBlobSchema()&&typeof t==="string")return ir(t);let o=s.getMergedTraits().mediaType;if(s.isStringSchema()&&typeof t==="string"&&o){if(o==="application/json"||o.endsWith("+json"))return ot.from(t);return t}if(s.isTimestampSchema()&&t!=null)switch(pe(s,this.settings)){case 5:return vn(t);case 6:return Yn(t);case 7:return Zn(t);default:return console.warn("Missing timestamp format, parsing value with Date constructor:",t),new Date(t)}if(s.isBigIntegerSchema()&&(typeof t==="number"||typeof t==="string"))return BigInt(t);if(s.isBigDecimalSchema()&&t!=null){if(t instanceof M)return t;let i=t;if(i.type==="bigDecimal"&&"string"in i)return new M(i.string,i.type);return new M(String(t),"bigDecimal")}if(s.isNumericSchema()&&typeof t==="string"){switch(t){case"Infinity":return 1/0;case"-Infinity":return-1/0;case"NaN":return NaN}return t}if(s.isDocumentSchema())if(n){let i=Array.isArray(t)?[]:{};for(let c in t){if(c==="__proto__")J(i);let a=t[c];if(a instanceof M)i[c]=a;else i[c]=this._read(s,a)}return i}else return structuredClone(t);return t}}var Kn=String.fromCharCode(925);class us{values=new Map;counter=0;stage=0;createReplacer(){if(this.stage===1)throw Error("@aws-sdk/core/protocols - JsonReplacer already created.");if(this.stage===2)throw Error("@aws-sdk/core/protocols - JsonReplacer exhausted.");return this.stage=1,(e,t)=>{if(t instanceof M){let n=`${Kn+"nv"+this.counter++}_`+t.string;return this.values.set(`"${n}"`,t.string),n}if(typeof t==="bigint"){let n=t.toString(),s=`${Kn+"b"+this.counter++}_`+n;return this.values.set(`"${s}"`,n),s}return t}}replaceInJson(e){if(this.stage===0)throw Error("@aws-sdk/core/protocols - JsonReplacer not created yet.");if(this.stage===2)throw Error("@aws-sdk/core/protocols - JsonReplacer exhausted.");if(this.stage=2,this.counter===0)return e;for(let[t,n]of this.values)e=e.replace(t,n);return e}}class ur extends H{settings;buffer;useReplacer=!1;rootSchema;constructor(e){super();this.settings=e}write(e,t){this.rootSchema=A.of(e),this.buffer=this._write(this.rootSchema,t)}flush(){let{rootSchema:e,useReplacer:t}=this;if(this.rootSchema=void 0,this.useReplacer=!1,e?.isStructSchema()||e?.isDocumentSchema()){if(!t)return JSON.stringify(this.buffer);let n=new us;return n.replaceInJson(JSON.stringify(this.buffer,n.createReplacer(),0))}return this.buffer}writeDiscriminatedDocument(e,t){if(this.write(e,t),typeof this.buffer==="object")this.buffer.__type=A.of(e).getName(!0)}_write(e,t,n){let s=t!==null&&typeof t==="object",o=A.of(e);if(s){if(o.isStructSchema()){let i=t,c={},{jsonName:a}=this.settings,f=void 0;if(a)f={};let u=0;for(let[h,l]of o.structIterator()){let d=this._write(l,i[h],o);if(d!==void 0){let m=h;if(a)m=l.getMergedTraits().jsonName??h,f[h]=m;c[m]=d,u++}}if(o.isUnionSchema()&&u===0){let{$unknown:h}=i;if(Array.isArray(h)){let[l,d]=h;if(l==="__proto__")J(c);c[l]=this._write(15,d)}}else if(typeof i.__type==="string")for(let h in i){let l=i[h],d=a?f[h]??h:h;if(!(d in c))c[d]=this._write(15,l)}return c}if(Array.isArray(t)&&o.isListSchema()){let i=o.getValueSchema(),c=[],a=!!o.getMergedTraits().sparse;for(let f of t)if(a||f!=null)c.push(this._write(i,f));return c}if(o.isMapSchema()){let i=o.getValueSchema(),c={},a=!!o.getMergedTraits().sparse;for(let f in t){let u=t[f];if(a||u!=null){if(f==="__proto__")J(c);c[f]=this._write(i,u)}}return c}if(t instanceof Uint8Array&&o.isBlobSchema()){if(o===this.rootSchema)return t;return(this.serdeContext?.base64Encoder??ge)(t)}if(t instanceof Date&&(o.isTimestampSchema()||o.isDocumentSchema()))switch(pe(o,this.settings)){case 5:return t.toISOString().replace(".000Z","Z");case 6:return Ue(t);case 7:return t.getTime()/1000;default:return console.warn("Missing timestamp format, using epoch seconds",t),t.getTime()/1000}if(t instanceof M)this.useReplacer=!0}if(t===null&&n?.isStructSchema())return;if(o.isStringSchema()){if(typeof t>"u"&&o.isIdempotencyToken())return ct();let i=o.getMergedTraits().mediaType;if(t!=null&&i){if(i==="application/json"||i.endsWith("+json"))return ot.from(t)}return t}if(typeof t==="number"){if(Math.abs(t)===1/0||isNaN(t))return String(t);return t}if(typeof t==="string"&&o.isBlobSchema()){if(o===this.rootSchema)return t;return(this.serdeContext?.base64Encoder??ge)(t)}if(typeof t==="bigint")this.useReplacer=!0;if(o.isDocumentSchema())if(s){if(t instanceof Uint8Array)return(this.serdeContext?.base64Encoder??ge)(t);let i=Array.isArray(t)?[]:{};for(let c in t){let a=t[c];if(c==="__proto__")J(i);if(a instanceof M)this.useReplacer=!0,i[c]=a;else i[c]=this._write(o,a)}return i}else return structuredClone(t);return t}}class hs extends H{settings;constructor(e){super();this.settings=e}createSerializer(){let e=new ur(this.settings);return e.setSerdeContext(this.serdeContext),e}createDeserializer(){let e=new fr(this.settings);return e.setSerdeContext(this.serdeContext),e}}class mt extends H{settings;stringDeserializer;constructor(e){super();this.settings=e,this.stringDeserializer=new mc(e)}setSerdeContext(e){this.serdeContext=e,this.stringDeserializer.setSerdeContext(e)}read(e,t,n){let s=A.of(e),o=s.getMemberSchemas();if(s.isStructSchema()&&s.isMemberSchema()&&!!Object.values(o).find((f)=>!!f.getMemberTraits().eventPayload)){let f={},u=Object.keys(o)[0];if(o[u].isBlobSchema())f[u]=t;else f[u]=this.read(o[u],t);return f}let c=(this.serdeContext?.utf8Encoder??sr)(t),a=this.parseXml(c);return this.readSchema(e,n?a[n]:a)}readSchema(e,t){let n=A.of(e);if(n.isUnitSchema())return;let s=n.getMergedTraits();if(n.isListSchema()&&!Array.isArray(t))return this.readSchema(n,[t]);if(t==null)return t;if(typeof t==="object"){let o=!!s.xmlFlattened;if(n.isListSchema()){let c=n.getValueSchema(),a=[],f=c.getMergedTraits().xmlName??"member",u=o?t:(t[0]??t)[f];if(u==null)return a;let h=Array.isArray(u)?u:[u];for(let l of h)a.push(this.readSchema(c,l));return a}let i={};if(n.isMapSchema()){let c=n.getKeySchema(),a=n.getValueSchema(),f;if(o)f=Array.isArray(t)?t:[t];else f=Array.isArray(t.entry)?t.entry:[t.entry];let u=c.getMergedTraits().xmlName??"key",h=a.getMergedTraits().xmlName??"value";for(let l of f){let d=l[u],m=l[h];if(d==="__proto__")J(i);i[d]=this.readSchema(a,m)}return i}if(n.isStructSchema()){let c=n.isUnionSchema(),a;if(c)a=new ft(t,i);for(let[f,u]of n.structIterator()){let h=u.getMergedTraits(),l=!h.httpPayload?u.getMemberTraits().xmlName??f:h.xmlName??u.getName();if(c)a.mark(l);if(t[l]!=null)i[f]=this.readSchema(u,t[l])}if(c)a.writeUnknown();return i}if(n.isDocumentSchema())return t;throw Error(`@aws-sdk/core/protocols - xml deserializer unhandled schema type for ${n.getName(!0)}`)}if(n.isListSchema())return[];if(n.isMapSchema()||n.isStructSchema())return{};return this.stringDeserializer.read(n,t)}parseXml(e){if(e.length){let t;try{t=es(e)}catch(i){if(i&&typeof i==="object")Object.defineProperty(i,"$responseBodyText",{value:e});throw i}let n="#text",s=Object.keys(t)[0],o=t[s];if(o[n])o[s]=o[n],delete o[n];return Qn(o)}return{}}}class hr extends H{settings;buffer;constructor(e){super();this.settings=e}write(e,t,n=""){if(this.buffer===void 0)this.buffer="";let s=A.of(e);if(n&&!n.endsWith("."))n+=".";if(s.isBlobSchema()){if(typeof t==="string"||t instanceof Uint8Array)this.writeKey(n),this.writeValue((this.serdeContext?.base64Encoder??ge)(t))}else if(s.isBooleanSchema()||s.isNumericSchema()||s.isStringSchema()){if(t!=null)this.writeKey(n),this.writeValue(String(t));else if(s.isIdempotencyToken())this.writeKey(n),this.writeValue(ct())}else if(s.isBigIntegerSchema()){if(t!=null)this.writeKey(n),this.writeValue(String(t))}else if(s.isBigDecimalSchema()){if(t!=null)this.writeKey(n),this.writeValue(t instanceof M?t.string:String(t))}else if(s.isTimestampSchema()){if(t instanceof Date)switch(this.writeKey(n),pe(s,this.settings)){case 5:this.writeValue(t.toISOString().replace(".000Z","Z"));break;case 6:this.writeValue(Ue(t));break;case 7:this.writeValue(String(t.getTime()/1000));break}}else if(s.isDocumentSchema())if(Array.isArray(t))this.write(79,t,n);else if(t instanceof Date)this.write(4,t,n);else if(t instanceof Uint8Array)this.write(21,t,n);else if(t&&typeof t==="object")this.write(143,t,n);else this.writeKey(n),this.writeValue(String(t));else if(s.isListSchema()){if(Array.isArray(t))if(t.length===0){if(this.settings.serializeEmptyLists)this.writeKey(n),this.writeValue("")}else{let o=s.getValueSchema(),i=this.settings.flattenLists||s.getMergedTraits().xmlFlattened,c=1;for(let a of t){if(a==null)continue;let f=o.getMergedTraits(),u=this.getKey("member",f.xmlName,f.ec2QueryName),h=i?`${n}${c}`:`${n}${u}.${c}`;this.write(o,a,h),++c}}}else if(s.isMapSchema()){if(t&&typeof t==="object"){let o=s.getKeySchema(),i=s.getValueSchema(),c=s.getMergedTraits().xmlFlattened,a=1;for(let f in t){let u=t[f];if(u==null)continue;let h=o.getMergedTraits(),l=this.getKey("key",h.xmlName,h.ec2QueryName),d=c?`${n}${a}.${l}`:`${n}entry.${a}.${l}`,m=i.getMergedTraits(),y=this.getKey("value",m.xmlName,m.ec2QueryName),g=c?`${n}${a}.${y}`:`${n}entry.${a}.${y}`;this.write(o,f,d),this.write(i,u,g),++a}}}else if(s.isStructSchema()){if(t&&typeof t==="object"){let o=!1;for(let[i,c]of s.structIterator()){if(t[i]==null&&!c.isIdempotencyToken())continue;let a=c.getMergedTraits(),f=this.getKey(i,a.xmlName,a.ec2QueryName,"struct"),u=`${n}${f}`;this.write(c,t[i],u),o=!0}if(!o&&s.isUnionSchema()){let{$unknown:i}=t;if(Array.isArray(i)){let[c,a]=i,f=`${n}${c}`;this.write(15,a,f)}}}}else if(s.isUnitSchema());else throw Error(`@aws-sdk/core/protocols - QuerySerializer unrecognized schema type ${s.getName(!0)}`)}flush(){if(this.buffer===void 0)throw Error("@aws-sdk/core/protocols - QuerySerializer cannot flush with nothing written to buffer.");let e=this.buffer;return delete this.buffer,e}getKey(e,t,n,s){let{ec2:o,capitalizeKeys:i}=this.settings;if(o&&n)return n;let c=t??e;if(i&&s==="struct")return c[0].toUpperCase()+c.slice(1);return c}writeKey(e){if(e.endsWith("."))e=e.slice(0,e.length-1);this.buffer+=`&${zn(e)}=`}writeValue(e){this.buffer+=zn(e)}}class lr extends Gn{options;serializer;deserializer;mixin=new ye;constructor(e){super({defaultNamespace:e.defaultNamespace,errorTypeRegistries:e.errorTypeRegistries});this.options=e;let t={timestampFormat:{useTrait:!0,default:5},httpBindings:!1,xmlNamespace:e.xmlNamespace,serviceNamespace:e.defaultNamespace,serializeEmptyLists:!0};this.serializer=new hr(t),this.deserializer=new mt(t)}getShapeId(){return"aws.protocols#awsQuery"}setSerdeContext(e){this.serializer.setSerdeContext(e),this.deserializer.setSerdeContext(e)}getPayloadCodec(){throw Error("AWSQuery protocol has no payload codec.")}async serializeRequest(e,t,n){let s=await super.serializeRequest(e,t,n);if(!s.path.endsWith("/"))s.path+="/";if(s.headers["content-type"]="application/x-www-form-urlencoded",qn(e.input)==="unit"||!s.body)s.body="";let o=e.name.split("#")[1]??e.name;if(s.body=`Action=${o}&Version=${this.options.version}`+s.body,s.body.endsWith("&"))s.body=s.body.slice(-1);return s}async deserializeResponse(e,t,n){let s=this.deserializer,o=A.of(e.output),i={};if(n.statusCode>=300){let u=await nt(n.body,t);if(u.byteLength>0)Object.assign(i,await s.read(15,u));await this.handleError(e,t,n,i,this.deserializeMetadata(n))}for(let u in n.headers){let h=n.headers[u];delete n.headers[u],n.headers[u.toLowerCase()]=h}let c=e.name.split("#")[1]??e.name,a=o.isStructSchema()&&this.useNestedResult()?c+"Result":void 0,f=await nt(n.body,t);if(f.byteLength>0)Object.assign(i,await s.read(o,f,a));return i.$metadata=this.deserializeMetadata(n),i}useNestedResult(){return!0}async handleError(e,t,n,s,o){let i=this.loadQueryErrorCode(n,s)??"Unknown";this.mixin.compose(this.compositeErrorRegistry,i,this.options.defaultNamespace);let c=this.loadQueryError(s)??{},a=this.loadQueryErrorMessage(s);c.message=a,c.Error={Type:c.Type,Code:c.Code,Message:a};let{errorSchema:f,errorMetadata:u}=await this.mixin.getErrorSchemaOrThrowBaseException(i,this.options.defaultNamespace,n,c,o,this.mixin.findQueryCompatibleError),h=A.of(f),d=new(this.compositeErrorRegistry.getErrorCtor(f)??Error)({}),m={Type:c.Error.Type,Code:c.Error.Code,Error:c.Error};for(let[y,g]of h.structIterator()){let E=g.getMergedTraits().xmlName??y,T=c[E]??s[E];m[y]=this.deserializer.readSchema(g,T)}throw this.mixin.decorateServiceException(Object.assign(d,u,{$fault:h.getMergedTraits().error,message:a},m),s)}loadQueryErrorCode(e,t){let n=(t.Errors?.[0]?.Error??t.Errors?.Error??t.Error)?.Code;if(n!==void 0)return n;if(e.statusCode==404)return"NotFound"}loadQueryError(e){return e.Errors?.[0]?.Error??e.Errors?.Error??e.Error}loadQueryErrorMessage(e){let t=this.loadQueryError(e);return t?.message??t?.Message??e.message??e.Message??"Unknown"}getDefaultContentType(){return"application/x-www-form-urlencoded"}}class ls extends lr{options;constructor(e){super(e);this.options=e;let t={capitalizeKeys:!0,flattenLists:!0,serializeEmptyLists:!1,ec2:!0};Object.assign(this.serializer.settings,t)}getShapeId(){return"aws.protocols#ec2Query"}useNestedResult(){return!1}}var ds=(e,t)=>ns(e,t).then((n)=>{if(n.length){let s;try{s=es(n)}catch(a){if(a&&typeof a==="object")Object.defineProperty(a,"$responseBodyText",{value:n});throw a}let o="#text",i=Object.keys(s)[0],c=s[i];if(c[o])c[i]=c[o],delete c[o];return Qn(c)}return{}}),Cc=async(e,t)=>{let n=await ds(e,t);if(n.Error)n.Error.message=n.Error.message??n.Error.Message;return n},ms=(e,t)=>{if(t?.Error?.Code!==void 0)return t.Error.Code;if(t?.Code!==void 0)return t.Code;if(e.statusCode==404)return"NotFound"};class dr extends H{settings;stringBuffer;byteBuffer;buffer;constructor(e){super();this.settings=e}write(e,t){let n=A.of(e);if(n.isStringSchema()&&typeof t==="string")this.stringBuffer=t;else if(n.isBlobSchema())this.byteBuffer="byteLength"in t?t:(this.serdeContext?.base64Decoder??ir)(t);else{this.buffer=this.writeStruct(n,t,void 0);let s=n.getMergedTraits();if(s.httpPayload&&!s.xmlName)this.buffer.withName(n.getName())}}flush(){if(this.byteBuffer!==void 0){let t=this.byteBuffer;return delete this.byteBuffer,t}if(this.stringBuffer!==void 0){let t=this.stringBuffer;return delete this.stringBuffer,t}let e=this.buffer;if(this.settings.xmlNamespace){if(!e?.attributes?.xmlns)e.addAttribute("xmlns",this.settings.xmlNamespace)}return delete this.buffer,e.toString()}writeStruct(e,t,n){let s=e.getMergedTraits(),o=e.isMemberSchema()&&!s.httpPayload?e.getMemberTraits().xmlName??e.getMemberName():s.xmlName??e.getName();if(!o||!e.isStructSchema())throw Error(`@aws-sdk/core/protocols - xml serializer, cannot write struct with empty name or non-struct, schema=${e.getName(!0)}.`);let i=P.of(o),[c,a]=this.getXmlnsAttribute(e,n);for(let[u,h]of e.structIterator()){let l=t[u];if(l!=null||h.isIdempotencyToken()){if(h.getMergedTraits().xmlAttribute){i.addAttribute(h.getMergedTraits().xmlName??u,this.writeSimple(h,l));continue}if(h.isListSchema())this.writeList(h,l,i,a);else if(h.isMapSchema())this.writeMap(h,l,i,a);else if(h.isStructSchema())i.addChildNode(this.writeStruct(h,l,a));else{let d=P.of(h.getMergedTraits().xmlName??h.getMemberName());this.writeSimpleInto(h,l,d,a),i.addChildNode(d)}}}let{$unknown:f}=t;if(f&&e.isUnionSchema()&&Array.isArray(f)&&Object.keys(t).length===1){let[u,h]=f,l=P.of(u);if(typeof h!=="string")if(t instanceof P||t instanceof On)i.addChildNode(t);else throw Error("@aws-sdk - $unknown union member in XML requires value of type string, @aws-sdk/xml-builder::XmlNode or XmlText.");this.writeSimpleInto(0,h,l,a),i.addChildNode(l)}if(a)i.addAttribute(c,a);return i}writeList(e,t,n,s){if(!e.isMemberSchema())throw Error(`@aws-sdk/core/protocols - xml serializer, cannot write non-member list: ${e.getName(!0)}`);let o=e.getMergedTraits(),i=e.getValueSchema(),c=i.getMergedTraits(),a=!!c.sparse,f=!!o.xmlFlattened,[u,h]=this.getXmlnsAttribute(e,s),l=(d,m)=>{if(i.isListSchema())this.writeList(i,Array.isArray(m)?m:[m],d,h);else if(i.isMapSchema())this.writeMap(i,m,d,h);else if(i.isStructSchema()){let y=this.writeStruct(i,m,h);d.addChildNode(y.withName(f?o.xmlName??e.getMemberName():c.xmlName??"member"))}else{let y=P.of(f?o.xmlName??e.getMemberName():c.xmlName??"member");this.writeSimpleInto(i,m,y,h),d.addChildNode(y)}};if(f){for(let d of t)if(a||d!=null)l(n,d)}else{let d=P.of(o.xmlName??e.getMemberName());if(h)d.addAttribute(u,h);for(let m of t)if(a||m!=null)l(d,m);n.addChildNode(d)}}writeMap(e,t,n,s,o=!1){if(!e.isMemberSchema())throw Error(`@aws-sdk/core/protocols - xml serializer, cannot write non-member map: ${e.getName(!0)}`);let i=e.getMergedTraits(),c=e.getKeySchema(),f=c.getMergedTraits().xmlName??"key",u=e.getValueSchema(),h=u.getMergedTraits(),l=h.xmlName??"value",d=!!h.sparse,m=!!i.xmlFlattened,[y,g]=this.getXmlnsAttribute(e,s),E=(T,D,j)=>{let Y=P.of(f,D),[ps,gr]=this.getXmlnsAttribute(c,g);if(gr)Y.addAttribute(ps,gr);T.addChildNode(Y);let Se=P.of(l);if(u.isListSchema())this.writeList(u,j,Se,g);else if(u.isMapSchema())this.writeMap(u,j,Se,g,!0);else if(u.isStructSchema())Se=this.writeStruct(u,j,g);else this.writeSimpleInto(u,j,Se,g);T.addChildNode(Se)};if(m)for(let T in t){let D=t[T];if(d||D!=null){let j=P.of(i.xmlName??e.getMemberName());E(j,T,D),n.addChildNode(j)}}else{let T;if(!o){if(T=P.of(i.xmlName??e.getMemberName()),g)T.addAttribute(y,g);n.addChildNode(T)}for(let D in t){let j=t[D];if(d||j!=null){let Y=P.of("entry");E(Y,D,j),(o?n:T).addChildNode(Y)}}}}writeSimple(e,t){if(t===null)throw Error("@aws-sdk/core/protocols - (XML serializer) cannot write null value.");let n=A.of(e),s=null;if(t&&typeof t==="object")if(n.isBlobSchema())s=(this.serdeContext?.base64Encoder??ge)(t);else if(n.isTimestampSchema()&&t instanceof Date)switch(pe(n,this.settings)){case 5:s=t.toISOString().replace(".000Z","Z");break;case 6:s=Ue(t);break;case 7:s=String(t.getTime()/1000);break;default:console.warn("Missing timestamp format, using http date",t),s=Ue(t);break}else if(n.isBigDecimalSchema()&&t){if(t instanceof M)return t.string;return String(t)}else if(n.isMapSchema()||n.isListSchema())throw Error("@aws-sdk/core/protocols - xml serializer, cannot call _write() on List/Map schema, call writeList or writeMap() instead.");else throw Error(`@aws-sdk/core/protocols - xml serializer, unhandled schema type for object value and schema: ${n.getName(!0)}`);if(n.isBooleanSchema()||n.isNumericSchema()||n.isBigIntegerSchema()||n.isBigDecimalSchema())s=String(t);if(n.isStringSchema())if(t===void 0&&n.isIdempotencyToken())s=ct();else s=String(t);if(s===null)throw Error(`Unhandled schema-value pair ${n.getName(!0)}=${t}`);return s}writeSimpleInto(e,t,n,s){let o=this.writeSimple(e,t),i=A.of(e),c=new On(o),[a,f]=this.getXmlnsAttribute(i,s);if(f)n.addAttribute(a,f);n.addChildNode(c)}getXmlnsAttribute(e,t){let n=e.getMergedTraits(),[s,o]=n.xmlNamespace??[];if(o&&o!==t)return[s?`xmlns:${s}`:"xmlns",o];return[void 0,void 0]}}class mr extends H{settings;constructor(e){super();this.settings=e}createSerializer(){let e=new dr(this.settings);return e.setSerdeContext(this.serdeContext),e}createDeserializer(){let e=new mt(this.settings);return e.setSerdeContext(this.serdeContext),e}}class gs extends Wn{codec;serializer;deserializer;mixin=new ye;constructor(e){super(e);let t={timestampFormat:{useTrait:!0,default:5},httpBindings:!0,xmlNamespace:e.xmlNamespace,serviceNamespace:e.defaultNamespace};this.codec=new mr(t),this.serializer=new Xn(this.codec.createSerializer(),t),this.deserializer=new Jn(this.codec.createDeserializer(),t)}getPayloadCodec(){return this.codec}getShapeId(){return"aws.protocols#restXml"}async serializeRequest(e,t,n){let s=await super.serializeRequest(e,t,n),o=A.of(e.input);if(!s.headers["content-type"]){let i=this.mixin.resolveRestContentType(this.getDefaultContentType(),o);if(i)s.headers["content-type"]=i}if(typeof s.body==="string"&&s.headers["content-type"]===this.getDefaultContentType()&&!s.body.startsWith("<?xml ")&&!this.hasUnstructuredPayloadBinding(o))s.body='<?xml version="1.0" encoding="UTF-8"?>'+s.body;return s}async deserializeResponse(e,t,n){return super.deserializeResponse(e,t,n)}async handleError(e,t,n,s,o){let i=ms(n,s)??"Unknown";if(this.mixin.compose(this.compositeErrorRegistry,i,this.options.defaultNamespace),s.Error&&typeof s.Error==="object"){for(let y of Object.keys(s.Error))if(s[y]=s.Error[y],y.toLowerCase()==="message")s.message=s.Error[y]}if(s.RequestId&&!o.requestId)o.requestId=s.RequestId;let{errorSchema:c,errorMetadata:a}=await this.mixin.getErrorSchemaOrThrowBaseException(i,this.options.defaultNamespace,n,s,o),f=A.of(c),u=s.Error?.message??s.Error?.Message??s.message??s.Message??"UnknownError",l=new(this.compositeErrorRegistry.getErrorCtor(c)??Error)({});await this.deserializeHttpMessage(c,t,n,s);let d={},m=this.codec.createDeserializer();for(let[y,g]of f.structIterator()){let E=g.getMergedTraits().xmlName??y,T=s.Error?.[E]??s[E];d[y]=m.readSchema(g,T)}throw this.mixin.decorateServiceException(Object.assign(l,a,{$fault:f.getMergedTraits().error,message:u},d),s)}getDefaultContentType(){return"application/xml"}hasUnstructuredPayloadBinding(e){for(let[,t]of e.structIterator())if(t.getMergedTraits().httpPayload)return!(t.isStructSchema()||t.isMapSchema()||t.isListSchema());return!1}}var Ac=(e)=>{if(e==null)return;if(typeof e==="object"&&"__type"in e)delete e.__type;return gc(e)},Tc=(e)=>{if(e==null)return e;if(typeof e==="number"||typeof e==="bigint"){let t=Error(`Received number ${e} where a string was expected.`);return t.name="Warning",console.warn(t),String(e)}if(typeof e==="boolean"){let t=Error(`Received boolean ${e} where a string was expected.`);return t.name="Warning",console.warn(t),String(e)}return e},Ic=(e)=>{if(e==null)return e;if(typeof e==="string"){let t=e.toLowerCase();if(e!==""&&t!=="false"&&t!=="true"){let n=Error(`Received string "${e}" where a boolean was expected.`);n.name="Warning",console.warn(n)}return e!==""&&t!=="false"}return e},kc=(e)=>{if(e==null)return e;if(typeof e==="string"){let t=Number(e);if(t.toString()!==e){let n=Error(`Received string "${e}" where a number was expected.`);return n.name="Warning",console.warn(n),e}return t}return e};Rc.AwsEc2QueryProtocol=ls;Rc.AwsJson1_0Protocol=cs;Rc.AwsJson1_1Protocol=as;Rc.AwsJsonRpcProtocol=dt;Rc.AwsQueryProtocol=lr;Rc.AwsRestJsonProtocol=fs;Rc.AwsRestXmlProtocol=gs;Rc.AwsSmithyRpcV2CborProtocol=ts;Rc.JsonCodec=hs;Rc.JsonCodec2=lt;Rc.JsonShapeDeserializer=fr;Rc.JsonShapeDeserializer2=ar;Rc.JsonShapeSerializer=ur;Rc.JsonShapeSerializer2=ht;Rc.QueryShapeSerializer=hr;Rc.XmlCodec=mr;Rc.XmlShapeDeserializer=mt;Rc.XmlShapeSerializer=dr;Rc._toBool=Ic;Rc._toNum=kc;Rc._toStr=Tc;Rc.awsExpectUnion=Ac;Rc.loadJsonRpcErrorCode=is;Rc.loadRestJsonErrorCode=ss;Rc.loadRestXmlErrorCode=ms;Rc.parseJsonBody=ut;Rc.parseJsonErrorBody=wc;Rc.parseXmlBody=ds;Rc.parseXmlErrorBody=Cc});
20
20
  export{oi,He,at};
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import{S}from"./chunk-15ve3nmv.js";import{v}from"./chunk-4rnmxtpx.js";import"./chunk-edbq461k.js";import{ut,tt,pt}from"./chunk-z0c8ek0j.js";import{Pt,Tt}from"./chunk-snz19yc2.js";import{Ke}from"./chunk-86yr2c0r.js";import{ne}from"./chunk-959z9efn.js";import{ue}from"./chunk-vqm94hz2.js";import{Re,dt,X}from"./chunk-2tf7qfbx.js";import{j,J}from"./chunk-rn3jwyh1.js";import{Q}from"./chunk-tfhp09nj.js";import{ie,xe,ve,V}from"./chunk-y4pvhes1.js";import{D}from"./chunk-szj85dqe.js";var P=new Set(["openai","openai-codex","opencode","chatgpt:subscription"]),O=16,E="https://chatgpt.com/settings/usage";function _(e,s){return(e.provider==="openai"||e.provider==="chatgpt:subscription")&&e.baseUrl==="https://api.openai.com/v1"&&s!==void 0&&!s.startsWith("sk-")}function h(e,s){if(!e)return!1;let r=s.toLowerCase();for(let[t,i]of Object.entries(e))if(t.toLowerCase()===r&&i!==null&&i.trim().length>0)return!0;return!1}function T(e,s,r){if(s)return s;if(h(r,"authorization")||h(r,"cf-aig-authorization"))return"unused";throw Error(`No API key for provider: ${e}`)}function I(e){return e.provider==="openrouter"||e.baseUrl.includes("openrouter.ai")?"openrouter":"openai"}function R(e,s){if(e)return e;if(v("PI_CACHE_RETENTION",s)==="long")return"long";return"short"}function d(e){return{supportsDeveloperRole:e.compat?.supportsDeveloperRole??!0,supportsMidConvoSystemMessages:e.compat?.supportsMidConvoSystemMessages??!1,sessionAffinityFormat:e.compat?.sessionAffinityFormat??I(e),supportsLongCacheRetention:e.compat?.supportsLongCacheRetention??!0,supportsStrictMode:e.compat?.supportsStrictMode??!1,supportsOpenAIGrammarTools:e.compat?.supportsOpenAIGrammarTools??!1,supportsAdditionalTools:e.compat?.supportsAdditionalTools??!1,supportsToolSearch:e.compat?.supportsToolSearch??!1,supportsExplicitPromptCacheMode:e.compat?.supportsExplicitPromptCacheMode??!1,supportsMaxOutputTokens:e.compat?.supportsMaxOutputTokens??!0}}function w(e,s){return s==="long"&&e.supportsLongCacheRetention&&!e.supportsExplicitPromptCacheMode?"24h":void 0}function x(e,s){if(!e.supportsExplicitPromptCacheMode)return;if(s==="none")return{mode:"explicit"};if(s==="long"&&e.supportsLongCacheRetention)return{ttl:"30m"};return}var b=(e,s,r)=>{let t=new D,i=ie(s,d(e).supportsMidConvoSystemMessages);return(async()=>{let o={role:"assistant",content:[],api:e.api,provider:e.provider,model:e.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:"pending",timestamp:Date.now()};try{let c=T(e.provider,r?.apiKey,r?.headers),p=R(r?.cacheRetention,r?.env)==="none"?void 0:r?.sessionId,n=d(e),u=Re(xe(i.messages),n.supportsOpenAIGrammarTools),l=k(e,i,c,r?.headers,r?.fetch,p),f=L(e,i,r,n,u),m=await r?.onPayload?.(f,e);if(m!==void 0)f=m;let y={...r?.signal?{signal:r.signal}:{},...r?.timeoutMs!==void 0?{timeout:r.timeoutMs}:{},maxRetries:0},{data:M,response:g}=await ue(()=>l.responses.create(f,y).withResponse(),{maxRetries:r?.maxRetries,maxRetryDelayMs:r?.maxRetryDelayMs,signal:r?.signal});if(await r?.onResponse?.({status:g.status,headers:Q(g.headers)},e),t.push({type:"start",partial:o}),await pt(M,o,t,e,{onProviderStreamEvent:r?.onProviderStreamEvent,serviceTier:r?.serviceTier,grammarToolInputProperties:u,applyServiceTierPricing:(C,A)=>U(C,A,e)}),r?.signal?.aborted)throw Error("Request was aborted");if(o.stopReason==="pending")throw Error("OpenAI Responses stream ended without a stop reason");if(o.stopReason==="aborted"||o.stopReason==="error")throw Error(o.errorMessage||"An unknown error occurred");t.push({type:"done",reason:o.stopReason,message:o}),t.end()}catch(c){for(let p of o.content)delete p.index,delete p.partialJson,delete p.customInput;o.stopReason=r?.signal?.aborted?"aborted":"error";let a=J(j(c),`${e.provider==="openai"?"OpenAI":e.provider} API error`);o.errorMessage=a.includes("subscription_sharing_usage_limit_exceeded")?`${a}
3
- Check your ChatGPT usage: ${E}`:a,t.push({type:"error",reason:o.stopReason,error:o}),t.end()}})(),t},oe=(e,s,r)=>{T(e.provider,r?.apiKey,r?.headers);let t={...X(e,s,r,r?.apiKey),toolChoice:r?.toolChoice},i=r?.reasoning?V(e,r.reasoning):void 0;return b(e,s,{...t,reasoningEffort:i==="off"?void 0:i})};function k(e,s,r,t,i,o){let c=d(e),a={"User-Agent":ne(),...e.headers};if(e.provider==="github-copilot"){let p=Pt(s.messages),n=Tt({messages:s.messages,hasImages:p});Object.assign(a,n)}if(o)if(c.sessionAffinityFormat==="openrouter")a["x-session-id"]=o;else{if(c.sessionAffinityFormat==="openai")a.session_id=o;a["x-client-request-id"]=o}if(t)Object.assign(a,t);return new S({apiKey:r,baseURL:e.baseUrl,dangerouslyAllowBrowser:!0,fetch:i,defaultHeaders:a})}function L(e,s,r,t=d(e),i=Re(xe(s.messages),t.supportsOpenAIGrammarTools)){let o=ve(s.messages,t.supportsAdditionalTools||t.supportsToolSearch),c=ut(e,s,P,{grammarToolInputProperties:i,supportsMidConvoSystemMessages:t.supportsMidConvoSystemMessages,supportsAdditionalTools:t.supportsAdditionalTools,supportsToolSearch:t.supportsToolSearch,toolOptions:{supportsStrictMode:t.supportsStrictMode,supportsOpenAIGrammarTools:t.supportsOpenAIGrammarTools}}),a=R(r?.cacheRetention,r?.env),p=_(e,r?.apiKey),n={model:e.id,input:c,stream:!0,prompt_cache_key:a==="none"?void 0:Ke(r?.sessionId),prompt_cache_retention:p?void 0:w(t,a),prompt_cache_options:p?void 0:x(t,a),store:!1};if(r?.maxTokens&&t.supportsMaxOutputTokens&&!p)n.max_output_tokens=Math.max(r.maxTokens,O);if(r?.temperature!==void 0&&!p)n.temperature=r?.temperature;if(r?.serviceTier!==void 0)n.service_tier=r.serviceTier;if(o.requestTools.length>0)n.tools=tt(o.requestTools,{supportsStrictMode:t.supportsStrictMode,supportsOpenAIGrammarTools:t.supportsOpenAIGrammarTools});if(r?.toolChoice!==void 0)n.tool_choice=r.toolChoice;let u=r?.reasoningEffort??(r?.reasoningSummary?"medium":void 0);if(e.reasoning){if(u){let f=r?.reasoningEffort?e.thinkingLevelMap?.[r.reasoningEffort]??r.reasoningEffort:u;n.reasoning={effort:f,summary:r?.reasoningSummary||"auto"},n.include=["reasoning.encrypted_content"]}else if(e.provider!=="github-copilot"&&e.thinkingLevelMap?.off!==null)n.reasoning={effort:e.thinkingLevelMap?.off??"none"};if(e.provider==="xai")n.include=["reasoning.encrypted_content"]}let l=dt(e,u??"off",r?.samplingParams);if(l)Object.assign(n,l);return n}function G(e,s){switch(s){case"flex":return 0.5;case"priority":case"fast":return e.id==="gpt-5.5"?2.5:2;default:return 1}}function U(e,s,r){let t=G(r,s);if(t===1)return;e.cost.input*=t,e.cost.output*=t,e.cost.cacheRead*=t,e.cost.cacheWrite*=t,e.cost.total=e.cost.input+e.cost.output+e.cost.cacheRead+e.cost.cacheWrite}export{b as stream,oe as streamSimple};
2
+ import{S}from"./chunk-xf7zw32f.js";import{_}from"./chunk-ge38dhv9.js";import"./chunk-38g4jd6v.js";import{ut,tt,pt}from"./chunk-qjnx4fsn.js";import{Tt,Pt}from"./chunk-xafx1p7z.js";import{Ke}from"./chunk-86yr2c0r.js";import{oe}from"./chunk-pyj6avd5.js";import{ue}from"./chunk-vqm94hz2.js";import{Re,dt,X}from"./chunk-qs161f2q.js";import{V,J}from"./chunk-8np9b2y8.js";import{Q}from"./chunk-tfhp09nj.js";import{se,xe,ve,K}from"./chunk-z9p6s986.js";import{U}from"./chunk-4yxd2kg1.js";var A=new Set(["openai","openai-codex","opencode","chatgpt:subscription"]),P=16,O="https://chatgpt.com/settings/usage";function E(e,s){return(e.provider==="openai"||e.provider==="chatgpt:subscription")&&e.baseUrl==="https://api.openai.com/v1"&&s!==void 0&&!s.startsWith("sk-")}function h(e,s){if(!e)return!1;let r=s.toLowerCase();for(let[t,i]of Object.entries(e))if(t.toLowerCase()===r&&i!==null&&i.trim().length>0)return!0;return!1}function T(e,s,r){if(s)return s;if(h(r,"authorization")||h(r,"cf-aig-authorization"))return"unused";throw Error(`No API key for provider: ${e}`)}function I(e){return e.provider==="openrouter"||e.baseUrl.includes("openrouter.ai")?"openrouter":"openai"}function v(e,s){if(e)return e;if(_("PI_CACHE_RETENTION",s)==="long")return"long";return"short"}function d(e){return{supportsDeveloperRole:e.compat?.supportsDeveloperRole??!0,supportsMidConvoSystemMessages:e.compat?.supportsMidConvoSystemMessages??!1,sessionAffinityFormat:e.compat?.sessionAffinityFormat??I(e),supportsLongCacheRetention:e.compat?.supportsLongCacheRetention??!0,supportsStrictMode:e.compat?.supportsStrictMode??!1,supportsOpenAIGrammarTools:e.compat?.supportsOpenAIGrammarTools??!1,supportsAdditionalTools:e.compat?.supportsAdditionalTools??!1,supportsToolSearch:e.compat?.supportsToolSearch??!1,supportsExplicitPromptCacheMode:e.compat?.supportsExplicitPromptCacheMode??!1,supportsMaxOutputTokens:e.compat?.supportsMaxOutputTokens??!0}}function w(e,s){return s==="long"&&e.supportsLongCacheRetention&&!e.supportsExplicitPromptCacheMode?"24h":void 0}function x(e,s){if(!e.supportsExplicitPromptCacheMode)return;if(s==="none")return{mode:"explicit"};if(s==="long"&&e.supportsLongCacheRetention)return{ttl:"30m"};return}var b=(e,s,r)=>{let t=new U,i=se(s,d(e).supportsMidConvoSystemMessages);return(async()=>{let o={role:"assistant",content:[],api:e.api,provider:e.provider,model:e.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:"pending",timestamp:Date.now()};try{let c=T(e.provider,r?.apiKey,r?.headers),p=v(r?.cacheRetention,r?.env)==="none"?void 0:r?.sessionId,n=d(e),u=Re(xe(i.messages),n.supportsOpenAIGrammarTools),l=k(e,i,c,r?.headers,r?.fetch,p),f=L(e,i,r,n,u),m=await r?.onPayload?.(f,e);if(m!==void 0)f=m;let R={...r?.signal?{signal:r.signal}:{},...r?.timeoutMs!==void 0?{timeout:r.timeoutMs}:{},maxRetries:0},{data:y,response:g}=await ue(()=>l.responses.create(f,R).withResponse(),{maxRetries:r?.maxRetries,maxRetryDelayMs:r?.maxRetryDelayMs,signal:r?.signal});if(await r?.onResponse?.({status:g.status,headers:Q(g.headers)},e),t.push({type:"start",partial:o}),await pt(y,o,t,e,{onProviderStreamEvent:r?.onProviderStreamEvent,serviceTier:r?.serviceTier,grammarToolInputProperties:u,applyServiceTierPricing:(M,C)=>D(M,C,e)}),r?.signal?.aborted)throw Error("Request was aborted");if(o.stopReason==="pending")throw Error("OpenAI Responses stream ended without a stop reason");if(o.stopReason==="aborted"||o.stopReason==="error")throw Error(o.errorMessage||"An unknown error occurred");t.push({type:"done",reason:o.stopReason,message:o}),t.end()}catch(c){for(let p of o.content)delete p.index,delete p.partialJson,delete p.customInput;o.stopReason=r?.signal?.aborted?"aborted":"error";let a=J(V(c),`${e.provider==="openai"?"OpenAI":e.provider} API error`);o.errorMessage=a.includes("subscription_sharing_usage_limit_exceeded")?`${a}
3
+ Check your ChatGPT usage: ${O}`:a,t.push({type:"error",reason:o.stopReason,error:o}),t.end()}})(),t},ae=(e,s,r)=>{T(e.provider,r?.apiKey,r?.headers);let t={...X(e,s,r,r?.apiKey),toolChoice:r?.toolChoice},i=r?.reasoning?K(e,r.reasoning):void 0;return b(e,s,{...t,reasoningEffort:i==="off"?void 0:i})};function k(e,s,r,t,i,o){let c=d(e),a={"User-Agent":oe(),...e.headers};if(e.provider==="github-copilot"){let p=Tt(s.messages),n=Pt({messages:s.messages,hasImages:p});Object.assign(a,n)}if(o)if(c.sessionAffinityFormat==="openrouter")a["x-session-id"]=o;else{if(c.sessionAffinityFormat==="openai")a.session_id=o;a["x-client-request-id"]=o}if(t)Object.assign(a,t);return new S({apiKey:r,baseURL:e.baseUrl,dangerouslyAllowBrowser:!0,fetch:i,defaultHeaders:a})}function L(e,s,r,t=d(e),i=Re(xe(s.messages),t.supportsOpenAIGrammarTools)){let o=ve(s.messages,t.supportsAdditionalTools||t.supportsToolSearch),c=ut(e,s,A,{grammarToolInputProperties:i,supportsMidConvoSystemMessages:t.supportsMidConvoSystemMessages,supportsAdditionalTools:t.supportsAdditionalTools,supportsToolSearch:t.supportsToolSearch,toolOptions:{supportsStrictMode:t.supportsStrictMode,supportsOpenAIGrammarTools:t.supportsOpenAIGrammarTools}}),a=v(r?.cacheRetention,r?.env),p=E(e,r?.apiKey),n={model:e.id,input:c,stream:!0,prompt_cache_key:a==="none"?void 0:Ke(r?.sessionId),prompt_cache_retention:p?void 0:w(t,a),prompt_cache_options:p?void 0:x(t,a),store:!1};if(r?.maxTokens&&t.supportsMaxOutputTokens&&!p)n.max_output_tokens=Math.max(r.maxTokens,P);if(r?.temperature!==void 0&&!p)n.temperature=r?.temperature;if(r?.serviceTier!==void 0)n.service_tier=r.serviceTier;if(o.requestTools.length>0)n.tools=tt(o.requestTools,{supportsStrictMode:t.supportsStrictMode,supportsOpenAIGrammarTools:t.supportsOpenAIGrammarTools});if(r?.toolChoice!==void 0)n.tool_choice=r.toolChoice;let u=r?.reasoningEffort??(r?.reasoningSummary?"medium":void 0);if(e.reasoning){if(u){let f=r?.reasoningEffort?e.thinkingLevelMap?.[r.reasoningEffort]??r.reasoningEffort:u;n.reasoning={effort:f,summary:r?.reasoningSummary||"auto"},n.include=["reasoning.encrypted_content"]}else if(e.provider!=="github-copilot"&&e.thinkingLevelMap?.off!==null)n.reasoning={effort:e.thinkingLevelMap?.off??"none"};if(e.provider==="xai")n.include=["reasoning.encrypted_content"]}let l=dt(e,u??"off",r?.samplingParams);if(l)Object.assign(n,l);return n}function G(e,s){switch(s){case"flex":return 0.5;case"priority":case"fast":return e.id==="gpt-5.5"?2.5:2;default:return 1}}function D(e,s,r){let t=G(r,s);if(t===1)return;e.cost.input*=t,e.cost.output*=t,e.cost.cacheRead*=t,e.cost.cacheWrite*=t,e.cost.total=e.cost.input+e.cost.output+e.cost.cacheRead+e.cost.cacheWrite}export{b as stream,ae as streamSimple};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{Do,Et,ct,P,Un,Uo}from"./chunk-vd5332ps.js";export{Do as child_process,Et as crypto,ct as fs,P as path,Un as stream,Uo as util};