@bkm016/basalt 0.0.0-stage → 0.1.0

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 (252) hide show
  1. package/README.md +275 -2
  2. package/chunk-0hbjv3y6.js +11 -0
  3. package/chunk-0rya8cxe.js +3 -0
  4. package/chunk-0szjy61m.js +2 -0
  5. package/chunk-0tdv0t5q.js +3 -0
  6. package/chunk-1egbcp85.js +59 -0
  7. package/chunk-1fv27j4b.js +3 -0
  8. package/chunk-1yzt0qm0.js +2 -0
  9. package/chunk-2zqny2sy.js +2 -0
  10. package/chunk-32at88hc.js +3 -0
  11. package/chunk-356q8e0y.js +10 -0
  12. package/chunk-3jz9g8ab.js +10 -0
  13. package/chunk-3p7q2pyp.js +3 -0
  14. package/chunk-501zkf9b.js +3 -0
  15. package/chunk-58vz2qsq.js +2 -0
  16. package/chunk-5fdgy0q2.js +16 -0
  17. package/chunk-5wp4egky.js +7 -0
  18. package/chunk-665jzf2w.js +25 -0
  19. package/chunk-6gyhajhx.js +3 -0
  20. package/chunk-7yw8aa5j.js +31 -0
  21. package/chunk-8wjgbd9k.js +3 -0
  22. package/chunk-913tfr9c.js +2 -0
  23. package/chunk-97kjn55j.js +2 -0
  24. package/chunk-9y69ywyg.js +3 -0
  25. package/chunk-a6r4z44b.js +2 -0
  26. package/chunk-agntrqs9.js +2 -0
  27. package/chunk-b9bg5fhd.js +2 -0
  28. package/chunk-bj14jshr.js +3 -0
  29. package/chunk-c25s4w6a.js +5 -0
  30. package/chunk-d48bfd2e.js +3 -0
  31. package/chunk-d913kpyw.js +3 -0
  32. package/chunk-dakrpbe6.js +3 -0
  33. package/chunk-g2k3yhgh.js +12 -0
  34. package/chunk-hat3s3pr.js +3 -0
  35. package/chunk-hcn9cf6v.js +2 -0
  36. package/chunk-j2x0g1vg.js +2 -0
  37. package/chunk-k0t23cmx.js +2 -0
  38. package/chunk-k7w7ac9q.js +18 -0
  39. package/chunk-kgdrjqsy.js +3 -0
  40. package/chunk-kjr81mrd.js +9 -0
  41. package/chunk-m38ber71.js +2 -0
  42. package/chunk-n6e43rvk.js +3 -0
  43. package/chunk-qbf8x2ft.js +5 -0
  44. package/chunk-qcwnkr5y.js +2 -0
  45. package/chunk-qffb7een.js +3 -0
  46. package/chunk-qnr1f5pj.js +3 -0
  47. package/chunk-r9aatvwm.js +3 -0
  48. package/chunk-rad3dm0q.js +2 -0
  49. package/chunk-rjdhaasf.js +3 -0
  50. package/chunk-rm3kcxq9.js +20 -0
  51. package/chunk-rv06x0kn.js +7 -0
  52. package/chunk-sf13azm4.js +12 -0
  53. package/chunk-sytpmbfp.js +471 -0
  54. package/chunk-t057xfrt.js +5 -0
  55. package/chunk-tjpvayr1.js +2 -0
  56. package/chunk-tnrqkc7b.js +8 -0
  57. package/chunk-v9fea96h.js +3 -0
  58. package/chunk-ve7qx8wm.js +3 -0
  59. package/chunk-vkkj4awb.js +2 -0
  60. package/chunk-wc5j0hfw.js +39 -0
  61. package/chunk-wd9zxhza.js +2 -0
  62. package/chunk-wx7kdf0b.js +2 -0
  63. package/chunk-x9982ek7.js +25 -0
  64. package/chunk-xhk54h2q.js +7 -0
  65. package/chunk-xsbxykr4.js +2 -0
  66. package/chunk-y69ewdn2.js +3 -0
  67. package/chunk-y8ced1jm.js +5 -0
  68. package/chunk-y9xe9ct2.js +2 -0
  69. package/chunk-yb1jxgnk.js +2 -0
  70. package/chunk-zt1wvkyf.js +3 -0
  71. package/compiled.js +3773 -0
  72. package/icon-dp9pmcvp.png +0 -0
  73. package/package.json +20 -4
  74. package/ui-test-worker.js +226 -0
  75. package/web/KaTeX_AMS-Regular-n7eqehx2.woff2 +0 -0
  76. package/web/KaTeX_Caligraphic-Bold-20r3b6fv.woff2 +0 -0
  77. package/web/KaTeX_Caligraphic-Regular-kkjm8f18.woff2 +0 -0
  78. package/web/KaTeX_Fraktur-Bold-pz5vg4t0.woff2 +0 -0
  79. package/web/KaTeX_Fraktur-Regular-a1e9wkwk.woff2 +0 -0
  80. package/web/KaTeX_Main-Bold-mcp098h8.woff2 +0 -0
  81. package/web/KaTeX_Main-BoldItalic-fy74z249.woff2 +0 -0
  82. package/web/KaTeX_Main-Italic-hw2gxy7f.woff2 +0 -0
  83. package/web/KaTeX_Main-Regular-xvp1b75c.woff2 +0 -0
  84. package/web/KaTeX_Math-BoldItalic-mf5nf33d.woff2 +0 -0
  85. package/web/KaTeX_Math-Italic-ap60jrna.woff2 +0 -0
  86. package/web/KaTeX_SansSerif-Bold-we3bymb6.woff2 +0 -0
  87. package/web/KaTeX_SansSerif-Italic-ent92bjx.woff2 +0 -0
  88. package/web/KaTeX_SansSerif-Regular-0573pbz9.woff2 +0 -0
  89. package/web/KaTeX_Script-Regular-z2rtj6vq.woff2 +0 -0
  90. package/web/KaTeX_Size1-Regular-dfr3w1hv.woff2 +0 -0
  91. package/web/KaTeX_Size2-Regular-kted78zb.woff2 +0 -0
  92. package/web/KaTeX_Size3-Regular-e6k1k5jk.woff2 +0 -0
  93. package/web/KaTeX_Size4-Regular-abedc1pd.woff2 +0 -0
  94. package/web/KaTeX_Typewriter-Regular-scw9zx1z.woff2 +0 -0
  95. package/web/apple-touch-icon-7dkm33qp.png +0 -0
  96. package/web/apple-touch-icon.png +0 -0
  97. package/web/chunk-00mq7bhx.js +1 -0
  98. package/web/chunk-0atfn8jf.js +1 -0
  99. package/web/chunk-0k0hvh59.js +40 -0
  100. package/web/chunk-0mrkjnte.js +1 -0
  101. package/web/chunk-0pbjgdgp.js +2 -0
  102. package/web/chunk-0s80zw00.js +1 -0
  103. package/web/chunk-0xck277j.js +140 -0
  104. package/web/chunk-1t760bg0.js +1 -0
  105. package/web/chunk-1v3d60pp.js +217 -0
  106. package/web/chunk-1x8fn8w9.js +1 -0
  107. package/web/chunk-20q90epj.js +2 -0
  108. package/web/chunk-24mfx6w1.js +2 -0
  109. package/web/chunk-29e1trsq.js +78 -0
  110. package/web/chunk-2j4m0bh1.js +2 -0
  111. package/web/chunk-310yey4q.js +1 -0
  112. package/web/chunk-32ezm0ry.js +1136 -0
  113. package/web/chunk-3ahpr030.js +2 -0
  114. package/web/chunk-3bqh2dkw.js +7 -0
  115. package/web/chunk-3cfabjey.js +370 -0
  116. package/web/chunk-3hvgs5aw.js +1 -0
  117. package/web/chunk-3kh6zefg.js +1 -0
  118. package/web/chunk-3pf33xsm.js +98 -0
  119. package/web/chunk-3pm4645m.js +2 -0
  120. package/web/chunk-401v5ht6.js +8 -0
  121. package/web/chunk-4b5mt5pd.js +70 -0
  122. package/web/chunk-4gavbw65.js +1 -0
  123. package/web/chunk-4rm1vy7w.js +1 -0
  124. package/web/chunk-4wd9r73y.js +1 -0
  125. package/web/chunk-4y2td14d.js +24 -0
  126. package/web/chunk-54thej0t.js +2 -0
  127. package/web/chunk-55kw67nv.js +1 -0
  128. package/web/chunk-59kqahb3.js +1 -0
  129. package/web/chunk-5hex8g0y.js +24 -0
  130. package/web/chunk-5r5kv4gh.js +1 -0
  131. package/web/chunk-6atq9qtt.js +7 -0
  132. package/web/chunk-6beqrmtq.js +1 -0
  133. package/web/chunk-6m69hczt.js +2 -0
  134. package/web/chunk-6r912gfj.js +34 -0
  135. package/web/chunk-74j07k8k.js +2 -0
  136. package/web/chunk-7f0m2yrd.js +169 -0
  137. package/web/chunk-8g239029.js +1 -0
  138. package/web/chunk-942prjb6.js +332 -0
  139. package/web/chunk-95q1bwxn.js +1 -0
  140. package/web/chunk-9s7c178f.js +1 -0
  141. package/web/chunk-9v1f6yc8.js +1 -0
  142. package/web/chunk-a3xt6840.js +38 -0
  143. package/web/chunk-ad6x47yy.js +1 -0
  144. package/web/chunk-b5brnfv9.js +2 -0
  145. package/web/chunk-benmmqt2.js +1 -0
  146. package/web/chunk-bgqdcnke.js +1 -0
  147. package/web/chunk-bhe4jzha.js +1 -0
  148. package/web/chunk-bwyw10wx.js +39 -0
  149. package/web/chunk-c85wxnpw.js +292 -0
  150. package/web/chunk-canbct9d.js +55 -0
  151. package/web/chunk-cg3jterp.js +2 -0
  152. package/web/chunk-d18r4m14.js +141 -0
  153. package/web/chunk-d4d3mnak.js +84 -0
  154. package/web/chunk-dmqtdeb4.js +1 -0
  155. package/web/chunk-dy2gm1fs.js +1 -0
  156. package/web/chunk-e5rmr47n.js +2 -0
  157. package/web/chunk-ea9swkkt.js +1 -0
  158. package/web/chunk-ejd43q75.js +19 -0
  159. package/web/chunk-eqegxtdt.js +1 -0
  160. package/web/chunk-ev1g5cqw.js +2 -0
  161. package/web/chunk-ezyvv4ab.js +3 -0
  162. package/web/chunk-f91wzwtk.js +1 -0
  163. package/web/chunk-fdkp6tzq.js +36 -0
  164. package/web/chunk-g1ev11wx.js +1 -0
  165. package/web/chunk-g9qv15hq.js +41 -0
  166. package/web/chunk-ghxe4gam.js +2 -0
  167. package/web/chunk-gmfp7fg4.js +1 -0
  168. package/web/chunk-gxay64d5.js +1 -0
  169. package/web/chunk-gxn0bey7.js +142 -0
  170. package/web/chunk-haphmhz8.js +200 -0
  171. package/web/chunk-hejz98gw.js +1 -0
  172. package/web/chunk-hfaffkrh.js +1 -0
  173. package/web/chunk-hp167dbv.js +1 -0
  174. package/web/chunk-hryhthxr.js +16 -0
  175. package/web/chunk-j2vt8c8v.js +1 -0
  176. package/web/chunk-jg6nzn6q.js +1 -0
  177. package/web/chunk-jtwhjp20.js +303 -0
  178. package/web/chunk-jvhmna7z.js +89 -0
  179. package/web/chunk-ka3q31t1.js +1 -0
  180. package/web/chunk-kbtbbarw.js +2 -0
  181. package/web/chunk-ktqt87qw.js +1 -0
  182. package/web/chunk-kx2xk3bb.js +1 -0
  183. package/web/chunk-m2d1sp30.js +1 -0
  184. package/web/chunk-mdsgekpk.js +1 -0
  185. package/web/chunk-mq92vqb1.js +2 -0
  186. package/web/chunk-n1dmrz44.js +2 -0
  187. package/web/chunk-n5fn9khr.js +1 -0
  188. package/web/chunk-n90cqdvg.js +2 -0
  189. package/web/chunk-nerx2q12.js +139 -0
  190. package/web/chunk-ngpq43vn.js +1 -0
  191. package/web/chunk-nj0cv1cq.js +257 -0
  192. package/web/chunk-nzey7cpv.js +1 -0
  193. package/web/chunk-p8y0hjx9.js +2 -0
  194. package/web/chunk-pxe3vna4.js +1 -0
  195. package/web/chunk-pz934t6t.js +30 -0
  196. package/web/chunk-r1dnh0s8.js +1 -0
  197. package/web/chunk-r5eakmw6.js +1 -0
  198. package/web/chunk-rkesqprv.js +1 -0
  199. package/web/chunk-rsn8j7xv.js +120 -0
  200. package/web/chunk-rtf2zzzv.js +1 -0
  201. package/web/chunk-ry9256r7.js +1 -0
  202. package/web/chunk-rykfak98.js +2 -0
  203. package/web/chunk-rz6wwdd5.js +106 -0
  204. package/web/chunk-s8vapqgr.js +12 -0
  205. package/web/chunk-sc63gh9d.js +2 -0
  206. package/web/chunk-srrfphes.js +1 -0
  207. package/web/chunk-svdzmaxb.js +2 -0
  208. package/web/chunk-svmhj9hd.js +1 -0
  209. package/web/chunk-t6agpn2z.js +1 -0
  210. package/web/chunk-tfyxp2qs.js +89 -0
  211. package/web/chunk-ts7zrf5b.js +2 -0
  212. package/web/chunk-ttg6tbwx.js +2 -0
  213. package/web/chunk-v47rhg7b.js +1 -0
  214. package/web/chunk-v5cnt7c8.js +1 -0
  215. package/web/chunk-v6v831tc.js +214 -0
  216. package/web/chunk-vadqkz3x.js +99 -0
  217. package/web/chunk-vfqdy860.js +1 -0
  218. package/web/chunk-vfqe8298.js +1 -0
  219. package/web/chunk-vqjs551t.js +7 -0
  220. package/web/chunk-wtawdeej.css +1 -0
  221. package/web/chunk-x3zwjkwg.js +62 -0
  222. package/web/chunk-x59p8sg2.js +1 -0
  223. package/web/chunk-x9q4kh67.js +4 -0
  224. package/web/chunk-xet1jjy9.js +1 -0
  225. package/web/chunk-xzp7jf7e.js +2 -0
  226. package/web/chunk-y7z144e3.js +1 -0
  227. package/web/chunk-ydgqrfvw.js +2 -0
  228. package/web/chunk-ydtrc1ay.js +2 -0
  229. package/web/chunk-yj1a2d37.js +1 -0
  230. package/web/chunk-ykxpb3wv.js +2 -0
  231. package/web/chunk-ytpwz01r.js +291 -0
  232. package/web/chunk-z09emmrb.js +1 -0
  233. package/web/chunk-z1jtv4c0.js +2 -0
  234. package/web/chunk-zakv2xdf.js +1 -0
  235. package/web/chunk-zbj1trar.js +2 -0
  236. package/web/chunk-zk2f7x5e.js +4 -0
  237. package/web/icon-192.png +0 -0
  238. package/web/icon-512.png +0 -0
  239. package/web/icon-maskable-512.png +0 -0
  240. package/web/icon-yx2p2pye.svg +13 -0
  241. package/web/icon.svg +13 -0
  242. package/web/index.html +23 -0
  243. package/web/install.ps1 +91 -0
  244. package/web/install.sh +177 -0
  245. package/web/inter-latin-wght-normal-an0py913.woff2 +0 -0
  246. package/web/jetbrains-mono-latin-wght-normal-hj2e42wt.woff2 +0 -0
  247. package/web/manifest-txf6vfbq.webmanifest +35 -0
  248. package/web/manifest.webmanifest +35 -0
  249. package/web/source-serif-4-latin-wght-italic-ta5tqqvz.woff2 +0 -0
  250. package/web/source-serif-4-latin-wght-normal-1yyvbhsz.woff2 +0 -0
  251. package/web/sw.js +90 -0
  252. package/worker.js +2 -0
@@ -0,0 +1,59 @@
1
+ // @bun
2
+ var pr;pr=globalThis.crypto?.webcrypto??globalThis.crypto??import("crypto").then((e)=>e.webcrypto);async function Nu(e){return(await pr).getRandomValues(new Uint8Array(e))}async function ju(e){let r=Math.pow(2,8)-Math.pow(2,8)%66,o="";while(o.length<e){let n=await Nu(e-o.length);for(let i of n)if(i<r)o+="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~"[i%66]}return o}async function Lu(e){return await ju(e)}async function Du(e){let t=await(await pr).subtle.digest("SHA-256",new TextEncoder().encode(e));return btoa(String.fromCharCode(...new Uint8Array(t))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}async function fr(e){if(!e)e=43;if(e<43||e>128)throw`Expected a length between 43 and 128. Received ${e}.`;let t=await Lu(e),r=await Du(t);return{code_verifier:t,code_challenge:r}}function Ue(e){let t=Object.values(e).filter((o)=>typeof o==="number");return Object.entries(e).filter(([o,n])=>t.indexOf(+o)===-1).map(([o,n])=>n)}function mr(e,t="|"){return e.map((r)=>zr(r)).join(t)}function Me(e,t){if(typeof t==="bigint")return t.toString();return t}class zn{constructor(e){this._getter=e,this._value=void 0}get value(){let e=this._getter;if(e!==void 0)this._value=e(),this._getter=void 0;return this._value}}function Fe(e){return new zn(e)}function xn(e){return e===null||e===void 0}function ct(e){let t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}function yn(e,t){let r=e/t,o=Math.round(r),n=4*Number.EPSILON*Math.max(Math.abs(r),1);if(Math.abs(r-o)<n)return 0;return r-o}function oe(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function Je(e){let t=Object.getOwnPropertyDescriptor(e,"shape");return t?.get?t.get.raw:t?.value}function he(e){return Je(e._zod.def)??e._zod.def.shape}function bn(e,t,r){Object.defineProperty(e,t,{get(){let o=r();return oe(this,t,o),o},enumerable:!0,configurable:!0})}function vn(e,t,r){if(t in e)oe(e,t,r);else e[t]=r}function $e(e,t,r,o){let n=he(t);for(let i of r){let s=Object.getOwnPropertyDescriptor(n,i);if(!s.enumerable)continue;if(s.get)bn(e,i,()=>{let c=t._zod.def.shape[i];return o?o(c,i):c});else vn(e,i,o?o(s.value,i):s.value)}}function Uu(e,t){for(let r of Reflect.ownKeys(t)){let o=Object.getOwnPropertyDescriptor(t,r);if(!o.enumerable)continue;if(o.get)bn(e,r,()=>t[r]);else vn(e,r,o.value)}}function ee(...e){let t={};for(let r of e){let o=Object.getOwnPropertyDescriptors(r);Object.assign(t,o)}return Object.defineProperties({},t)}function wn(e){return JSON.stringify(e)}function $n(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var hr="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Pe(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}var Sn=Fe(()=>{if(X.jitless)return!1;if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch(e){return!1}});function Se(e){if(Pe(e)===!1)return!1;let t=e.constructor;if(t===void 0)return!0;if(typeof t!=="function")return!0;let r=t.prototype;if(Pe(r)===!1)return!1;if(Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)return!1;return!0}function gr(e){if(Se(e))return{...e};if(Array.isArray(e))return[...e];if(e instanceof Map)return new Map(e);if(e instanceof Set)return new Set(e);return e}var kn=new Set(["string","number","symbol"]);function xe(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ue(e,t,r){let o=new e._zod.constr(t??e._zod.def);if(!t||r?.parent)o._zod.parent=e;return o}function x(e){let t=e;if(!t)return{};if(typeof t==="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}if(delete t.message,typeof t.error==="string")return{...t,error:()=>t.error};return t}function zr(e){if(typeof e==="bigint")return e.toString()+"n";if(typeof e==="string")return`"${e}"`;return`${e}`}function Pn(e){return Object.keys(e).filter((t)=>e[t]._zod.optin!==void 0&&e[t]._zod.optout==="optional")}var at=(()=>({safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-340282346638528860000000000000000000000,340282346638528860000000000000000000000],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]}))(),xr={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function Mu(e,t){let r=e._zod.def,o=r.checks;if(o&&o.length>0)throw Error(".pick() cannot be used on object schemas containing refinements");let i={};return $e(i,e,ut(e,t)),ue(e,ee(r,{shape:i,checks:[]}))}function ut(e,t){let r=he(e),o=[];for(let n of Reflect.ownKeys(t)){if(!Object.getOwnPropertyDescriptor(r,n)?.enumerable)throw Error(`Unrecognized key: "${String(n)}"`);if(t[n])o.push(n)}return o}function Fu(e,t){let r=e._zod.def,o=r.checks;if(o&&o.length>0)throw Error(".omit() cannot be used on object schemas containing refinements");let i=new Set(ut(e,t)),s={};return $e(s,e,Reflect.ownKeys(he(e)).filter((c)=>!i.has(c))),ue(e,ee(r,{shape:s,checks:[]}))}function Bu(e,t){if(!Se(t))throw Error("Invalid input to extend: expected a plain object");let r=e._zod.def.checks;if(r&&r.length>0){let n=he(e);for(let i of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(n,i)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return ue(e,ee(e._zod.def,{shape:On(e,t)}))}function On(e,t){let r={};return $e(r,e,Reflect.ownKeys(he(e))),Uu(r,t),r}function Ju(e,t){if(!Se(t))throw Error("Invalid input to safeExtend: expected a plain object");return ue(e,ee(e._zod.def,{shape:On(e,t)}))}function qu(e,t){if(!t?._zod?.def)throw Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(e._zod.def.checks?.length)throw Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");let r={};$e(r,e,Reflect.ownKeys(he(e))),$e(r,t,Reflect.ownKeys(he(t)));let o=ee(e._zod.def,{shape:r,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return ue(e,o)}function Rn(e,t,r,o="partial"){let i=t._zod.def.checks;if(i&&i.length>0)throw Error(`.${o}() cannot be used on object schemas containing refinements`);let c=r?new Set(ut(t,r)):void 0,a={};return $e(a,t,Reflect.ownKeys(he(t)),e&&((l,p)=>c&&!c.has(p)?l:new e({type:"optional",innerType:l}))),ue(t,ee(t._zod.def,{shape:a,checks:[]}))}function Vu(e,t,r){let o=r?new Set(ut(t,r)):void 0,n={};return $e(n,t,Reflect.ownKeys(he(t)),(i,s)=>o&&!o.has(s)?i:new e({type:"nonoptional",innerType:i})),ue(t,ee(t._zod.def,{shape:n}))}function fe(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue!==!0)return!0;return!1}function Cn(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue===!1)return!0;return!1}function ye(e,t){return t.map((r)=>{var o;return(o=r).path??(o.path=[]),r.path.unshift(e),r})}function De(e){return typeof e==="string"?e:e?.message}function yr(e){let t=[];for(let r of e??[]){let o=r._zod.def;if(!/_(length|size)$|_equals$/.test(o.check))break;let n=o.maximum??o.length??o.size;if(n>=0)t.push([n,r])}return t}function pt(e,t,r){var o;for(let n=t;n<e.length;n++)(o=e[n]).schema??(o.schema=r)}function de(e,t,r){var o;let n=e.inst?._zod?.traits;if(n?.has("$ZodType"))if(n.has("$ZodCheck"))(o=e).schema??(o.schema=e.inst);else e.schema=e.inst;let i=e.schema!==e.inst?e.schema?._zod.def?.error:void 0,s=e.message?e.message:De(e.inst?._zod.def?.error?.(e))??De(i?.(e))??De(t?.error?.(e))??De(r.customError?.(e))??De(r.localeError?.(e))??"Invalid input",c={};for(let a of Object.keys(e)){if(a==="inst"||a==="schema"||a==="continue"||a==="input"||a==="__proto__")continue;c[a]=e[a]}if(c.path??(c.path=[]),c.message=s,t?.reportInput)c.input=e.input;return c}var Ku=/[\uD800-\uDBFF]/;function ft(e){let t=e.length;if(!Ku.test(e))return t;let r=t;for(let o=0;o<t-1;o++)if((e.charCodeAt(o)&64512)===55296&&(e.charCodeAt(o+1)&64512)===56320)r--,o++;return r}function dt(e){if(Array.isArray(e))return"array";if(typeof e==="string")return"string";return"unknown"}function In(e){let t=typeof e;switch(t){case"number":return Number.isNaN(e)?"nan":"number";case"object":{if(e===null)return"null";if(Array.isArray(e))return"array";let r=e;if(r&&Object.getPrototypeOf(r)!==Object.prototype&&"constructor"in r&&r.constructor)return r.constructor.name}}return t}function ke(...e){let[t,r,o]=e;if(typeof t==="string")return{message:t,code:"custom",input:r,inst:o};return{...t}}function Tn(e,t){for(let r in t){let o=Object.getOwnPropertyDescriptor(t,r);if(o.get)Object.defineProperty(e,r,{...o,enumerable:!1});else Wu(e,r,o.value)}}function ge(e,t,r,o=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:o,value:r}),r}function mt(e,t,r){return ge(e,t,r,!1)}function An(e,t){for(let r in e){let o=e[r];Object.defineProperty(t,r,{configurable:!0,enumerable:!0,get(){return ge(this,r,o(this))},set(n){ge(this,r,n)}})}return t}function Wu(e,t,r){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?r:ge(this,t,r.bind(this))},set(o){ge(this,t,o)}})}function Gu(e,t){let r=Object.getPrototypeOf(e);return t in r?void 0:r}var dr,ze=!1,Hu={configurable:!0,get(){ze=!0;return}};function k(e,t,r){let o=Object.getPrototypeOf(e._zod);if(t in o&&dr!==e._zod){dr=void 0;return}dr=e._zod,Object.defineProperty(o,t,{configurable:!0,get(){Object.defineProperty(this,t,Hu);let n=ze;ze=!1;try{let i=r(this);if(ze)delete this[t];else Object.defineProperty(this,t,{configurable:!0,writable:!0,value:i});return ze=ze||n,i}catch(i){throw delete this[t],ze=ze||n,i}},set(n){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:n})}})}function Xu(e,t,r,o){let n=Gu(e,t);if(!n)return;Object.defineProperty(n,t,{configurable:!0,get(){let i={configurable:!0,writable:!0,enumerable:o,value:void 0};return Object.defineProperty(this,t,i),i.value=r(this),Object.defineProperty(this,t,i),i.value},set(i){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:o,value:i})}})}var Yu="~constantCatch";function En(e){let t=()=>e;return t[Yu]=!0,t}var Nn,vr=Object.freeze({status:"aborted"}),br={value:void 0,enumerable:!1},jn="captureStackTrace"in Error?Error:null;function Qu(e){let t=jn;if(t){let r=t.stackTraceLimit;if(typeof r==="number"){try{t.stackTraceLimit=0}catch{return jn=null,new e}try{return new e}finally{t.stackTraceLimit=r}}}return new e}function f(e,t,r,o){let n={};function i(h){this.def=h,this.constr=d,this.traits=new Set}i.prototype=n;let s=r,c=s&&new WeakSet;function a(h,m){if(!h._zod){br.value=new i(m);try{Object.defineProperty(h,"_zod",br)}finally{br.value=void 0}}else if(h._zod.traits.has(e))return;if(h._zod.traits.add(e),t(h,m),c){let b=Object.getPrototypeOf(h),v=h._zod.constr.prototype,P=b;while(P&&P!==v)P=Object.getPrototypeOf(P);let H=P??b;if(!c.has(H))c.add(H),Tn(H,s)}let g=d.prototype;for(let b in g){if(!Object.prototype.hasOwnProperty.call(g,b))continue;if(!(b in h))h[b]=g[b].bind(h)}}let l=o?.Parent??Object;class p extends l{}Object.defineProperty(p,"name",{value:e});function d(h){let m=o?.Parent?Qu(p):this;a(m,h);let g=m._zod.deferred;if(g){for(let v of g)v();m._zod.deferred=void 0}let b=globalThis.__zod_globalConfig?.postProcessor;if(b)b(m);return m}return Object.defineProperty(d,"init",{value:a}),Object.defineProperty(d,Symbol.hasInstance,{value:(h)=>{if(o?.Parent&&h instanceof o.Parent)return!0;return h?._zod?.traits?.has(e)}}),Object.defineProperty(d,"name",{value:e}),d}class me extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class qe extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`);this.name="ZodEncodeError"}}(Nn=globalThis).__zod_globalConfig??(Nn.__zod_globalConfig={});var X=globalThis.__zod_globalConfig;function Y(e){if(e)Object.assign(X,e);return X}function el(){let e=this._zod;return e.message??(e.message=JSON.stringify(e.def,Me,2)),e.message}function tl(e){this._zod.message=e}var rl={get:el,set:tl,enumerable:!0,configurable:!0},$r={value:void 0,enumerable:!1},Ln=new WeakSet([Object.prototype,Error.prototype]),Dn=(e,t)=>{e.name="$ZodError",$r.value=t,Object.defineProperty(e,"issues",$r),$r.value=void 0,Object.defineProperty(e,"message",rl);let r=Object.getPrototypeOf(e);if(!Ln.has(r))Ln.add(r),Object.defineProperty(r,"toString",{configurable:!0,enumerable:!1,get(){let o=()=>this.message;return Object.defineProperty(this,"toString",{value:o,configurable:!0,writable:!0}),o},set(o){Object.defineProperty(this,"toString",{value:o,configurable:!0,writable:!0})}})},Un=f("$ZodError",Dn),Mn=f("$ZodError",Dn,void 0,{Parent:Error});function ol(e,t,r){if(!Object.prototype.hasOwnProperty.call(e,t))if(t==="__proto__")Object.defineProperty(e,t,{value:r(),writable:!0,enumerable:!0,configurable:!0});else e[t]=r();return e[t]}function Sr(e,t=(r)=>r.message){let r={},o=[];for(let n of e.issues)if(n.path.length>0)ol(r,n.path[0],()=>[]).push(t(n));else o.push(t(n));return{formErrors:o,fieldErrors:r}}function kr(e,t=(r)=>r.message){let r={_errors:[]},o=(n,i=[])=>{for(let s of n.issues)if(s.code==="invalid_union"&&s.errors.length)s.errors.map((c)=>o({issues:c},[...i,...s.path]));else if(s.code==="invalid_key")o({issues:s.issues},[...i,...s.path]);else if(s.code==="invalid_element")o({issues:s.issues},[...i,...s.path]);else{let c=[...i,...s.path];if(c.length===0)r._errors.push(t(s));else{let a=r,l=0;while(l<c.length){let p=c[l],d=l===c.length-1;if(p==="_errors"){if(d)a._errors.push(t(s));l++;continue}if(!Object.prototype.hasOwnProperty.call(a,p))Object.defineProperty(a,p,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let h=a[p];if(d)h._errors.push(t(s));a=h,l++}}}};return o(e),r}function ht(e,t){return{callee:t?.callee??e,Err:t?.Err}}var gt=(e)=>{let t=(r,o,n,i)=>{let s=n?{...n,async:!1}:{async:!1},c=r._zod.run({value:o,issues:[]},s);if(c instanceof Promise)throw new me;if(c.issues.length){let a=new(i?.Err??e)(c.issues.map((l)=>de(l,s,Y())));throw hr(a,i?.callee??t),a}return c.value};return t};var _t=(e)=>{let t=async(r,o,n,i)=>{let s=n?{...n,async:!0}:{async:!0},c=r._zod.run({value:o,issues:[]},s);if(c instanceof Promise)c=await c;if(c.issues.length){let a=new(i?.Err??e)(c.issues.map((l)=>de(l,s,Y())));throw hr(a,i?.callee??t),a}return c.value};return t};var Ve=(e)=>(t,r,o)=>{let n=o?{...o,async:!1}:{async:!1},i=t._zod.run({value:r,issues:[]},n);if(i instanceof Promise)throw new me;return i.issues.length?Fn(e,i.issues,n):{success:!0,data:i.value}},Jn=Ve(Mn);function Fn(e,t,r){let o;return{success:!1,get error(){if(!o)o=new e(t.map((n)=>de(n,r,Y()))),t=void 0,r=void 0;return o},set error(n){o=n,t=void 0,r=void 0}}}var zt=(e)=>async(t,r,o)=>{let n=o?{...o,async:!0}:{async:!0},i=t._zod.run({value:r,issues:[]},n);if(i instanceof Promise)i=await i;return i.issues.length?Fn(e,i.issues,n):{success:!0,data:i.value}};var il=Symbol.for("zod.compile.invalid"),sl=Symbol.for("zod.compile.fallback"),Zr=(e,t,r)=>{let o=e._zod.bag.validator;if(o!==void 0){if(o(t)!==il)return!0;if(o.definite===!0&&r===void 0)return!1}return cl(e,t,r)};function cl(e,t,r){let o=r?{...r,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},n=e._zod.bag.fallbackRun,i;if(n)o[sl]=!0,i=n({value:t,issues:[]},o);else i=e._zod.run({value:t,issues:[]},o);if(i instanceof Promise)throw new me;return i.issues.length===0}var Or=async(e,t,r)=>{let o=r?{...r,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0},n=e._zod.run({value:t,issues:[]},o);if(n instanceof Promise)n=await n;return n.issues.length===0},Bn=(e)=>{let t=gt(e),r=(o,n,i,s)=>{let c=i?{...i,direction:"backward"}:{direction:"backward"};return t(o,n,c,ht(r,s))};return r};var qn=(e)=>{let t=gt(e),r=(o,n,i,s)=>t(o,n,i,ht(r,s));return r};var Vn=(e)=>{let t=_t(e),r=async(o,n,i,s)=>{let c=i?{...i,direction:"backward"}:{direction:"backward"};return await t(o,n,c,ht(r,s))};return r};var Kn=(e)=>{let t=_t(e),r=async(o,n,i,s)=>await t(o,n,i,ht(r,s));return r};var Wn=(e)=>(t,r,o)=>{let n=o?{...o,direction:"backward"}:{direction:"backward"};return Ve(e)(t,r,n)};var Gn=(e)=>(t,r,o)=>Ve(e)(t,r,o);var Hn=(e)=>async(t,r,o)=>{let n=o?{...o,direction:"backward"}:{direction:"backward"};return zt(e)(t,r,n)};var Xn=(e)=>async(t,r,o)=>zt(e)(t,r,o);var Yn=/^[cC][0-9a-z]{6,}$/,Qn=/^[0-9a-z]+$/,ei=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,ti=/^[0-9a-vA-V]{20}$/,ri=/^[A-Za-z0-9]{27}$/,oi=/^[a-zA-Z0-9_-]{21}$/;function ni(e){return new RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}var ii=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;var si=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,Cr=(e)=>{if(!e)return/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/;return new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`)};var ci=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;var al="^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$";function ai(){return new RegExp(al,"u")}var ui=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,li=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/;var pi=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,fi=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,di=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,mi=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/;var hi=/^https?$/,gi=/^\+[1-9]\d{6,14}$/;var _i="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))";function ul(e){return new RegExp(`^${e}$`)}var zi=ul(_i);function Rr(e){return typeof e.precision==="number"?e.precision===-1?"(?:[01]\\d|2[0-3]):[0-5]\\d":e.precision===0?"(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d":`(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d\\.\\d{${e.precision}}`:e.seconds?"(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?":"(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?"}function xi(e){return new RegExp(`^${Rr(e)}$`)}function yi(e){let t=["Z"];if(e.offset)t.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let r=`${Rr({precision:e.precision,seconds:!0})}(?:${t.join("|")})`,o=e.local?`${r}|${Rr({precision:e.precision})}`:r;return new RegExp(`^${_i}T(?:${o})$`)}var bi=/^[\s\S]{0,}$/;var Ir=/^-?\d+$/,Ke=/^-?\d+(?:\.\d+)?$/,vi=/^(?:true|false)$/i,wi=/^null$/i;var $i=/^[^A-Z]*$/,Si=/^[^a-z]*$/;var q=f("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])});var Ar=(e)=>{let t=e.value;return!xn(t)&&t.length!==void 0},xt={number:"number",bigint:"bigint",object:"date"},Er=f("$ZodCheckLessThan",(e,t)=>{q.init(e,t);let r=xt[typeof t.value];e._zod.check=(o)=>{if(t.inclusive?o.value<=t.value:o.value<t.value)return;o.issues.push({origin:xt[typeof o.value]??r,code:"too_big",maximum:typeof t.value==="object"?t.value.getTime():t.value,input:o.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Nr=f("$ZodCheckGreaterThan",(e,t)=>{q.init(e,t);let r=xt[typeof t.value];e._zod.check=(o)=>{if(t.inclusive?o.value>=t.value:o.value>t.value)return;o.issues.push({origin:xt[typeof o.value]??r,code:"too_small",minimum:typeof t.value==="object"?t.value.getTime():t.value,input:o.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),ki=f("$ZodCheckMultipleOf",(e,t)=>{q.init(e,t),e._zod.check=(r)=>{if(typeof r.value!==typeof t.value)throw Error("Cannot mix number and bigint in multiple_of check.");if(typeof r.value==="bigint"?t.value!==BigInt(0)&&r.value%t.value===BigInt(0):yn(r.value,t.value)===0)return;r.issues.push({origin:typeof r.value,code:"not_multiple_of",divisor:t.value,input:r.value,inst:e,continue:!t.abort})}}),Pi=f("$ZodCheckNumberFormat",(e,t)=>{q.init(e,t),t.format=t.format||"float64";let r=t.format?.includes("int"),o=r?"int":"number",[n,i]=at[t.format];e._zod.check=(s)=>{let c=s.value;if(r){if(!Number.isInteger(c)){s.issues.push({expected:o,format:t.format,code:"invalid_type",continue:!1,input:c,inst:e});return}if(!Number.isSafeInteger(c)){if(c>0)s.issues.push({input:c,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:o,inclusive:!0,continue:!t.abort});else s.issues.push({input:c,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:o,inclusive:!0,continue:!t.abort});return}}if(c<n)s.issues.push({origin:"number",input:c,code:"too_small",minimum:n,inclusive:!0,inst:e,continue:!t.abort});if(c>i)s.issues.push({origin:"number",input:c,code:"too_big",maximum:i,inclusive:!0,inst:e,continue:!t.abort})}});var Zi=f("$ZodCheckMaxLength",(e,t)=>{var r;q.init(e,t),(r=e._zod.def).when??(r.when=Ar),e._zod.check=(o)=>{let n=o.value,i=n.length;if((typeof n==="string"&&i>t.maximum?ft(n):i)<=t.maximum)return;let c=dt(n);o.issues.push({origin:c,code:"too_big",maximum:t.maximum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),Oi=f("$ZodCheckMinLength",(e,t)=>{var r;q.init(e,t),(r=e._zod.def).when??(r.when=Ar),e._zod.check=(o)=>{let n=o.value,i=n.length;if((typeof n==="string"&&i>=t.minimum&&i<t.minimum*2?ft(n):i)>=t.minimum)return;let c=dt(n);o.issues.push({origin:c,code:"too_small",minimum:t.minimum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),Ri=f("$ZodCheckLengthEquals",(e,t)=>{var r;q.init(e,t),(r=e._zod.def).when??(r.when=Ar),e._zod.check=(o)=>{let n=o.value,i=n.length,s=typeof n==="string"&&i>=t.length&&i<=t.length*2?ft(n):i;if(s===t.length)return;let c=dt(n),a=s>t.length;o.issues.push({origin:c,...a?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:o.value,inst:e,continue:!t.abort})}}),We=f("$ZodCheckStringFormat",(e,t)=>{var r,o;if(q.init(e,t),t.pattern)(r=e._zod).check??(r.check=(n)=>{if(t.pattern.lastIndex=0,t.pattern.test(n.value))return;n.issues.push({origin:"string",code:"invalid_format",format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})});else(o=e._zod).check??(o.check=()=>{})}),Ci=f("$ZodCheckRegex",(e,t)=>{We.init(e,t),e._zod.check=(r)=>{if(t.pattern.lastIndex=0,t.pattern.test(r.value))return;r.issues.push({origin:"string",code:"invalid_format",format:"regex",input:r.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Ii=f("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=$i),We.init(e,t)}),Ti=f("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=Si),We.init(e,t)}),Ai=f("$ZodCheckIncludes",(e,t)=>{q.init(e,t);let r=xe(t.includes),o=new RegExp(typeof t.position==="number"?`^.{${t.position},}${r}`:r);t.pattern=o,e._zod.check=(n)=>{if(n.value.includes(t.includes,t.position))return;n.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),Ei=f("$ZodCheckStartsWith",(e,t)=>{q.init(e,t);let r=new RegExp(`^${xe(t.prefix)}.*`);t.pattern??(t.pattern=r),e._zod.check=(o)=>{if(o.value.startsWith(t.prefix))return;o.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:o.value,inst:e,continue:!t.abort})}}),Ni=f("$ZodCheckEndsWith",(e,t)=>{q.init(e,t);let r=new RegExp(`.*${xe(t.suffix)}$`);t.pattern??(t.pattern=r),e._zod.check=(o)=>{if(o.value.endsWith(t.suffix))return;o.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:o.value,inst:e,continue:!t.abort})}});var ji=f("$ZodCheckOverwrite",(e,t)=>{q.init(e,t),e._zod.check=(r)=>{r.value=t.tx(r.value)}});class jr{constructor(e=[],t={}){this.content=[],this.indent=0,this.args=e,this.closed=t}indented(e){this.indent+=1;try{e(this)}finally{this.indent-=1}}write(e){if(typeof e==="function"){e(this,{execution:"sync"}),e(this,{execution:"async"});return}let r=e.split(`
3
+ `).filter((i)=>i),o=Math.min(...r.map((i)=>i.length-i.trimStart().length)),n=r.map((i)=>i.slice(o)).map((i)=>" ".repeat(this.indent*2)+i);for(let i of n)this.content.push(i)}compile(){let e=Function,t=this?.content??[""];return new e(...Object.keys(this.closed),`return function (${this.args.join(", ")}) {
4
+ ${t.join(`
5
+ `)}
6
+ };`)(...Object.values(this.closed))}}var Di={major:4,minor:6,patch:7};var R=f("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Di;let o=e._zod.def.checks,n=e._zod.traits.has("$ZodCheck")?[e,...o??[]]:o?.length?[...o]:[];for(let i of n)for(let s of i._zod.onattach)s(e);if(n.length===0)(r=e._zod).deferred??(r.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let i=(c,a,l)=>{if(c.memo)return c;let p=fe(c),d;for(let h of a){if(h._zod.def.when){if(Cn(c))continue;if(!h._zod.def.when(c))continue}else if(p)continue;let m=c.issues.length,g=h._zod.check(c);if(g instanceof Promise&&l?.async===!1)throw new me;if(d||g instanceof Promise)d=(d??Promise.resolve()).then(async()=>{if(await g,c.issues.length===m)return;if(pt(c.issues,m,e),!p)p=fe(c,m)});else{if(c.issues.length===m)continue;if(pt(c.issues,m,e),!p)p=fe(c,m)}}if(d)return d.then(()=>c);return c},s=(c,a,l)=>{if(fe(c))return c.aborted=!0,c;let p=i(a,n,l);if(p instanceof Promise){if(l.async===!1)throw new me;return p.then((d)=>e._zod.parse(d,l))}return e._zod.parse(p,l)};e._zod.run=(c,a)=>{if(a.skipChecks)return e._zod.parse(c,a);if(a.direction==="backward"){let p=e._zod.parse({value:c.value,issues:[]},{...a,skipChecks:!0});if(p instanceof Promise)return p.then((d)=>s(d,c,a));return s(p,c,a)}let l=e._zod.parse(c,a);if(l instanceof Promise){if(a.async===!1)throw new me;return l.then((p)=>i(p,n,a))}return i(l,n,a)}}},{get "~standard"(){return mt(this,"~standard",Dr(this))},set "~standard"(e){ge(this,"~standard",e)}}),Hi=(e,t)=>e.issues.length?{issues:e.issues.map((r)=>de(r,t,Y()))}:{value:e.value};async function ll(e,t){let r={async:!0};return Hi(await e._zod.run({value:t,issues:[]},r),r)}function Dr(e){return{validate:(t)=>{let r={async:!1};try{let o=e._zod.run({value:t,issues:[]},r);if(!(o instanceof Promise))return Hi(o,r)}catch(o){}return ll(e,t)},vendor:"zod",version:1}}var $t=f("$ZodString",(e,t)=>{R.init(e,t),e._zod.pattern=t.pattern??bi,e._zod.parse=(r,o)=>{if(t.coerce)try{r.value=String(r.value)}catch(n){}if(typeof r.value==="string")return r;return r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:e}),r}}),I=f("$ZodStringFormat",(e,t)=>{We.init(e,t),$t.init(e,t)}),Xi=f("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=si),I.init(e,t)}),Yi=f("$ZodUUID",(e,t)=>{if(t.version){let o={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(o===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=Cr(o))}else t.pattern??(t.pattern=Cr());I.init(e,t)}),Qi=f("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=ci),I.init(e,t)}),es=1,vt=2;function ts(e){try{if(typeof URL<"u"&&typeof URL.canParse==="function")return URL.canParse(e);return new URL(e),!0}catch{return!1}}function pl(e,t){if(!("normalize"in t)&&!("hostname"in t)&&!("protocol"in t))return ts(e)||vt;return fl(e,t)}function fl(e,t){if(!t.normalize&&t.protocol?.source===hi.source&&!/^https?:\/\//i.test(e))return es;try{if(typeof URL<"u"){let r=URL;if(typeof r.parse==="function")return r.parse(e)??vt}return new URL(e)}catch{return vt}}var dl=/[\t\n\r]/g;function Ui(e){return e.replace(dl,"")}function ml(e,t){return t.lastIndex=0,t.test(e.hostname)}function hl(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(":")?e.protocol.slice(0,-1):e.protocol)}var rs=f("$ZodURL",(e,t)=>{I.init(e,t),e._zod.check=(r)=>{try{let o=r.value.trim(),n=pl(o,t);if(n===es){r.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:r.value,inst:e,continue:!t.abort});return}if(n===vt){r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort});return}if(n===!0){r.value=Ui(o);return}if(t.hostname&&!ml(n,t.hostname))r.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:r.value,inst:e,continue:!t.abort});if(t.protocol&&!hl(n,t.protocol))r.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:r.value,inst:e,continue:!t.abort});r.value=t.normalize?n.href:Ui(o);return}catch(o){r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort})}}}),os=f("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=ai()),I.init(e,t)}),ns=f("$ZodNanoID",(e,t)=>{if(t.length!==void 0&&(!Number.isInteger(t.length)||t.length<1))throw Error(`Invalid nanoid length: ${t.length}`);t.pattern??(t.pattern=t.length===void 0?oi:ni(t.length)),I.init(e,t)}),is=f("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=Yn),I.init(e,t)}),ss=f("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=Qn),I.init(e,t)}),cs=f("$ZodULID",(e,t)=>{t.pattern??(t.pattern=ei),I.init(e,t)}),as=f("$ZodXID",(e,t)=>{t.pattern??(t.pattern=ti),I.init(e,t)}),us=f("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=ri),I.init(e,t)}),ls=f("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=yi(t)),I.init(e,t)}),ps=f("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=zi),I.init(e,t)}),fs=f("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=xi(t)),I.init(e,t)}),ds=f("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=ii),I.init(e,t)}),ms=f("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=ui),I.init(e,t)}),gl=/^[0-9a-fA-F:.]+$/;function hs(e){if(!gl.test(e))return!1;return ts(`http://[${e}]`)}var gs=f("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=li),I.init(e,t),e._zod.check=(r)=>{if(!hs(r.value))r.issues.push({code:"invalid_format",format:"ipv6",input:r.value,inst:e,continue:!t.abort})}});var _s=f("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=pi),I.init(e,t)});function _l(e){let t=e.split("/");if(t.length!==2)return!1;let[r,o]=t;if(!o)return!1;let n=Number(o);if(`${n}`!==o)return!1;if(n<0||n>128)return!1;return hs(r)}var zs=f("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=fi),I.init(e,t),e._zod.check=(r)=>{if(!_l(r.value))r.issues.push({code:"invalid_format",format:"cidrv6",input:r.value,inst:e,continue:!t.abort})}});function xs(e){if(e==="")return!0;if(/\s/.test(e))return!1;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}var Ur=/^[0-9a-zA-Z+/]*={0,2}$/,ys=f("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=Ur),I.init(e,t),e._zod.check=(r)=>{if(xs(r.value))return;r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:e,continue:!t.abort})}}),kt=/^[A-Za-z0-9_-]*$/;function zl(e){if(!kt.test(e))return!1;let t=e.replace(/[-_]/g,(o)=>o==="-"?"+":"/"),r=t.padEnd(Math.ceil(t.length/4)*4,"=");return xs(r)}var bs=f("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=kt),I.init(e,t),e._zod.check=(r)=>{if(zl(r.value))return;r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:e,continue:!t.abort})}}),vs=f("$ZodE164",(e,t)=>{t.pattern??(t.pattern=gi),I.init(e,t)});function xl(e,t=null){try{let r=e.split(".");if(r.length!==3)return!1;let[o]=r;if(!o)return!1;let n=JSON.parse(atob(o));if("typ"in n&&n?.typ!=="JWT")return!1;if(!n.alg)return!1;if(t&&(!("alg"in n)||n.alg!==t))return!1;return!0}catch{return!1}}var ws=f("$ZodJWT",(e,t)=>{I.init(e,t),e._zod.check=(r)=>{if(xl(r.value,t.alg))return;r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:e,continue:!t.abort})}});var Mr=f("$ZodNumber",(e,t)=>{R.init(e,t),e._zod.pattern=Ke,e._zod.parse=(r,o)=>{if(t.coerce)try{r.value=Number(r.value)}catch(s){}let n=r.value;if(typeof n==="number"&&!Number.isNaN(n)&&Number.isFinite(n))return r;let i=typeof n==="number"?Number.isNaN(n)?"NaN":!Number.isFinite(n)?String(n):void 0:void 0;return r.issues.push({expected:"number",code:"invalid_type",input:n,inst:e,...i?{received:i}:{}}),r}}),$s=f("$ZodNumberFormat",(e,t)=>{Pi.init(e,t),Mr.init(e,t)}),Ss=f("$ZodBoolean",(e,t)=>{R.init(e,t),e._zod.pattern=vi,e._zod.parse=(r,o)=>{if(t.coerce)try{r.value=Boolean(r.value)}catch(i){}let n=r.value;if(typeof n==="boolean")return r;return r.issues.push({expected:"boolean",code:"invalid_type",input:n,inst:e}),r}});var ks=f("$ZodNull",(e,t)=>{R.init(e,t),e._zod.pattern=wi,e._zod.values=new Set([null]),e._zod.parse=(r,o)=>{let n=r.value;if(n===null)return r;return r.issues.push({expected:"null",code:"invalid_type",input:n,inst:e}),r}}),Ps=f("$ZodAny",(e,t)=>{R.init(e,t),e._zod.parse=(r)=>r}),Zs=f("$ZodUnknown",(e,t)=>{R.init(e,t),e._zod.parse=(r)=>r}),Os=f("$ZodNever",(e,t)=>{R.init(e,t),e._zod.parse=(r,o)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:e}),r)});function yl(e,t){let r=yr(e._zod.def.checks);if(!r.length)return;let o=Math.min(...r.map((i)=>i[0])),n=e._zod.parse;e._zod.parse=(i,s)=>{let c=t(i.value);if(c>o&&!s?.skipChecks&&s?.direction!=="backward"){for(let[a,l]of yr(e._zod.def.checks))if(c>a&&l._zod.def.when(i)){let p=i.issues.length;return l._zod.check(i),i.issues[p].continue=!1,pt(i.issues,p,e),i}}return n(i,s)}}var bl=(e)=>Array.isArray(e)?e.length:-1;function Mi(e,t,r){if(e.issues.length)t.issues.push(...ye(r,e.issues));t.value[r]=e.value}var Rs=f("$ZodArray",(e,t)=>{R.init(e,t);let r=X.memoizer;r?.attach(e),e._zod.parse=(o,n)=>{let i=o.value;if(!Array.isArray(i))return o.issues.push({expected:"array",code:"invalid_type",input:i,inst:e}),o;o.value=r?r.alloc(e,o,Array(i.length),n):Array(i.length);let s=[],c=n?.abortEarly;for(let a=0;a<i.length;a++){let l=i[a],p=t.element._zod.run({value:l,issues:[]},n);if(p instanceof Promise)s.push(p.then((d)=>Mi(d,o,a)));else if(Mi(p,o,a),c&&p.issues.length!==0&&fe(p))break}if(s.length)return Promise.all(s).then(()=>o);return o},yl(e,bl)});function wt(e,t,r,o,n,i){let s=r in o,c=i==="optional";if(!s&&c&&n==="optional")return;if(e.issues.length){if(n!==void 0&&c&&!s)return;t.issues.push(...ye(r,e.issues))}if(!s&&n===void 0){if(!e.issues.length)t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[r]});return}if(e.value===void 0){if(s||n==="defaulted"&&!c)t.value[r]=void 0}else t.value[r]=e.value}var vl=[];function Cs(e){let t=Object.keys(e.shape),r=Object.getOwnPropertySymbols(e.shape),o=r.length?r:vl,n=o.length?[...t,...o]:t;for(let s of n)if(!e.shape?.[s]?._zod?.traits?.has("$ZodType"))throw Error(`Invalid element at key "${String(s)}": expected a Zod schema`);let i=Pn(e.shape);return{...e,allKeys:n,symbolKeys:o,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(i)}}function Is(e,t,r,o,n,i,s){let c=[],a=n.keySet,l=n.catchall._zod,p=l.def.type,{optin:d,optout:h}=l,m=0;for(let g in t){if(s&&r.issues.length!==m){if(fe(r,m))break;m=r.issues.length}if(a.has(g))continue;if(g==="__proto__"){if(p==="never")c.push(g);continue}if(p==="never"){c.push(g);continue}let b=l.run({value:t[g],issues:[]},o);if(b instanceof Promise)e.push(b.then((v)=>wt(v,r,g,t,d,h)));else wt(b,r,g,t,d,h)}if(c.length)r.issues.push({code:"unrecognized_keys",keys:c,input:t,inst:i,continue:!0});if(!e.length)return r;return Promise.all(e).then(()=>r)}var wl=f("$ZodObject",(e,t)=>{R.init(e,t);let r=Object.getOwnPropertyDescriptor(t,"shape"),o=r?.get?r.get.raw:t.shape??{};if(o){let l=()=>{let p={...o};return Object.defineProperty(t,"shape",{value:p}),l.raw=p,p};l.raw=o,Object.defineProperty(t,"shape",{get:l})}let n=Fe(()=>Cs(t));k(e,"propValues",(l)=>{let p=l.def.shape,d={};for(let h in p){let m=p[h]._zod;if(m.values){if(!Object.prototype.hasOwnProperty.call(d,h))oe(d,h,new Set);for(let g of m.values)d[h].add(g);if(m.optin!==void 0)d[h].add(void 0)}}return d});let i=Pe,s=t.catchall,c,a=X.memoizer;a?.attach(e),e._zod.parse=(l,p)=>{c??(c=n.value);let d=l.value;if(!i(d))return l.issues.push({expected:"object",code:"invalid_type",input:d,inst:e}),l;l.value=a?a.alloc(e,l,{},p):{};let h=[],m=c.shape,g=p?.abortEarly,b=l.issues.length;for(let v of c.allKeys){if(g&&l.issues.length!==b){if(fe(l,b))break;b=l.issues.length}if(v==="__proto__")continue;let P=m[v],H=P._zod.optin,F=P._zod.optout,ae=P._zod.run({value:d[v],issues:[]},p);if(ae instanceof Promise)h.push(ae.then((U)=>wt(U,l,v,d,H,F)));else wt(ae,l,v,d,H,F)}if(!s)return h.length?Promise.all(h).then(()=>l):l;return Is(h,d,l,p,n.value,e,g===!0)}}),Ts=f("$ZodObjectJIT",(e,t)=>{wl.init(e,t);let r=e._zod.parse,o=Fe(()=>Cs(t)),n=X.memoizer,i=(m)=>{let g=o.value,b=g.symbolKeys,v=new jr(["payload","ctx"],{shape:m,inst:e,memo:n,syms:b}),P=(U)=>`shape[${U}]._zod.run({ value: input[${U}], issues: [] }, ctx)`,H=(U,Z)=>`
7
+ let ${U}_ab = false;
8
+ for (let i = 0; i < ${U}.issues.length; i++) {
9
+ const iss = ${U}.issues[i];
10
+ iss.path = iss.path ? [${Z}, ...iss.path] : [${Z}];
11
+ payload.issues.push(iss);
12
+ if (iss.continue !== true) ${U}_ab = true;
13
+ }
14
+ if (${U}_ab && ctx && ctx.abortEarly) {
15
+ payload.value = newResult;
16
+ return payload;
17
+ }`;v.write("const input = payload.value;");let F=Object.create(null),ae=0;for(let U of g.allKeys)F[U]=`key_${ae++}`;v.write(n?"const newResult = memo.alloc(inst, payload, {}, ctx);":"const newResult = {};");for(let U of g.allKeys){if(U==="__proto__")continue;let Z=F[U],le=typeof U==="symbol"?`syms[${b.indexOf(U)}]`:wn(U),ur=`${le} in input`,gn=m[U],lr=gn?._zod?.optin,_n=lr!==void 0,Au=gn?._zod?.optout==="optional";if(v.write(`const ${Z} = ${P(le)};`),_n&&Au){let Eu=lr==="optional"?`${Z}_present`:`${Z}.value !== undefined || ${Z}_present`;v.write(`
18
+ const ${Z}_present = ${ur};
19
+ if (!${Z}.issues.length || ${Z}_present) {
20
+ if (${Z}.issues.length) {${H(Z,le)}
21
+ }
22
+
23
+ if (${Eu}) {
24
+ newResult[${le}] = ${Z}.value;
25
+ }
26
+ }
27
+
28
+ `)}else if(!_n)v.write(`
29
+ const ${Z}_present = ${ur};
30
+ if (${Z}.issues.length) {${H(Z,le)}
31
+ }
32
+ if (!${Z}_present && !${Z}.issues.length) {
33
+ payload.issues.push({
34
+ code: "invalid_type",
35
+ expected: "nonoptional",
36
+ input: undefined,
37
+ path: [${le}]
38
+ });
39
+ if (ctx && ctx.abortEarly) {
40
+ payload.value = newResult;
41
+ return payload;
42
+ }
43
+ }
44
+
45
+ if (${Z}_present) {
46
+ newResult[${le}] = ${Z}.value;
47
+ }
48
+
49
+ `);else if(v.write(`
50
+ if (${Z}.issues.length) {${H(Z,le)}
51
+ }
52
+ `),lr==="defaulted")v.write(`newResult[${le}] = ${Z}.value;`);else v.write(`
53
+ if (${Z}.value !== undefined || ${ur}) {
54
+ newResult[${le}] = ${Z}.value;
55
+ }
56
+ `)}return v.write("payload.value = newResult;"),v.write("return payload;"),v.compile()},s,c=Pe,a=!X.jitless,p=a&&Sn.value,d=t.catchall,h;e._zod.parse=(m,g)=>{h??(h=o.value);let b=m.value;if(!c(b))return m.issues.push({expected:"object",code:"invalid_type",input:b,inst:e}),m;if(a&&p&&g?.async===!1&&g.jitless!==!0){if(!s)s=i(t.shape);if(m=s(m,g),!d)return m;return Is([],b,m,g,h,e,g?.abortEarly===!0)}return r(m,g)}});function Fi(e,t,r,o){for(let i of e)if(i.issues.length===0)return t.value=i.value,t;let n=e.filter((i)=>!fe(i));if(n.length===1)return t.value=n[0].value,n[0];return t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:e.map((i)=>i.issues.map((s)=>de(s,o,Y())))}),t}var Fr=f("$ZodUnion",(e,t)=>{R.init(e,t),k(e,"optin",(o)=>o.def.options.some((n)=>n._zod.optin==="defaulted")?"defaulted":o.def.options.some((n)=>n._zod.optin!==void 0)?"optional":void 0),k(e,"optout",(o)=>o.def.options.some((n)=>n._zod.optout==="optional")?"optional":void 0),k(e,"values",(o)=>{if(o.def.options.every((n)=>n._zod.values))return new Set(o.def.options.flatMap((n)=>Array.from(n._zod.values)));return}),k(e,"pattern",(o)=>{if(o.def.options.every((n)=>n._zod.pattern)){let n=o.def.options.map((i)=>i._zod.pattern);return new RegExp(`^(${n.map((i)=>ct(i.source)).join("|")})$`)}return});let r=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(o,n)=>{if(r)return r(o,n);let i=!1,s=[];for(let c of t.options){let a=c._zod.run({value:o.value,issues:[]},n);if(a instanceof Promise)s.push(a),i=!0;else{if(a.issues.length===0)return a;s.push(a)}}if(!i)return Fi(s,o,e,n);return Promise.all(s).then((c)=>Fi(c,o,e,n))}});function $l(e){let t=new Map;for(let r of e.options){let o=r._zod.propValues?.[e.discriminator];if(!o||o.size===0)throw Error(`Invalid discriminated union option at index "${e.options.indexOf(r)}"`);for(let n of o)if(t.has(n)){if(n!==void 0)throw Error(`Duplicate discriminator value "${String(n)}"`);t.set(n,null)}else t.set(n,r)}return t}var As=f("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,Fr.init(e,t);let r=e._zod.parse;k(e,"propValues",(n)=>{let i={},s=0;for(let c of n.def.options){let a=c._zod.propValues;if(!a||Object.keys(a).length===0)throw Error(`Invalid discriminated union option at index "${n.def.options.indexOf(c)}"`);if(a[n.def.discriminator]?.has(void 0))s++;for(let[l,p]of Object.entries(a)){if(!Object.prototype.hasOwnProperty.call(i,l))oe(i,l,new Set);for(let d of p)i[l].add(d)}}if(!n.def.unionFallback&&s>1)i[n.def.discriminator]?.delete(void 0);return i}),t.options.forEach((n,i)=>{let s=Je(n._zod.def);if(s&&!Object.prototype.hasOwnProperty.call(s,t.discriminator))throw Error(`Invalid discriminated union option at index "${i}"`)});let o=Fe(()=>$l(t));e._zod.parse=(n,i)=>{let s=n.value;if(!Pe(s))return n.issues.push({code:"invalid_type",expected:"object",input:s,inst:e}),n;let c=s?.[t.discriminator],a=o.value.get(c);if(a&&(c!==void 0||i.direction!=="backward"))return a._zod.run(n,i);if(t.unionFallback||i.direction==="backward")return r(n,i);return n.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,options:Array.from(o.value.keys()).filter((l)=>o.value.get(l)!==null),input:s,path:[t.discriminator],inst:e}),n}}),Es=f("$ZodIntersection",(e,t)=>{R.init(e,t),e._zod.parse=(r,o)=>{let n=r.value,i=t.left._zod.run({value:n,issues:[]},o),s=t.right._zod.run({value:n,issues:[]},o);if(i instanceof Promise||s instanceof Promise)return Promise.all([i,s]).then(([a,l])=>Bi(r,a,l));return Bi(r,i,s)}});function Lr(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e===+t)return{valid:!0,data:e};if(Se(e)&&Se(t)){let r=Object.keys(t),o=Object.keys(e).filter((i)=>r.indexOf(i)!==-1),n={...e,...t};if(Object.prototype.hasOwnProperty.call(n,"__proto__"))delete n.__proto__;for(let i of o){if(i==="__proto__")continue;let s=Lr(e[i],t[i]);if(!s.valid)return{valid:!1,mergeErrorPath:[i,...s.mergeErrorPath]};n[i]=s.data}return{valid:!0,data:n}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let r=[];for(let o=0;o<e.length;o++){let n=e[o],i=t[o],s=Lr(n,i);if(!s.valid)return{valid:!1,mergeErrorPath:[o,...s.mergeErrorPath]};r.push(s.data)}return{valid:!0,data:r}}return{valid:!1,mergeErrorPath:[]}}function Bi(e,t,r){let o=new Map,n,i=new Map,s=(l,p)=>{let d;if(l.code==="unrecognized_keys"&&!l.path?.length)n??(n=l),d=l.keys;else if(l.code==="invalid_key"&&l.origin==="record"&&l.path?.length===1){let h=String(l.path[0]);if(!i.has(h))i.set(h,l);d=[h]}else return!1;for(let h of d){if(!o.has(h))o.set(h,{});o.get(h)[p]=!0}return!0};for(let l of t.issues)if(!s(l,"l"))e.issues.push(l);for(let l of r.issues)if(!s(l,"r"))e.issues.push(l);let c=[...o].filter(([,l])=>l.l&&l.r).map(([l])=>l);if(c.length){let l=n?c.filter((p)=>n.keys.includes(p)):[];if(l.length)e.issues.push({...n,keys:l});for(let p of c)if(!l.includes(p)&&i.has(p))e.issues.push(i.get(p))}let a=Lr(t.value,r.value);if(!a.valid){if(fe(e))return e;throw Error(`Unmergable intersection. Error path: ${JSON.stringify(a.mergeErrorPath)}`)}return e.value=a.data,e}var Ns=f("$ZodRecord",(e,t)=>{R.init(e,t);let r=X.memoizer;r?.attach(e),e._zod.parse=(o,n)=>{let i=o.value;if(!Se(i))return o.issues.push({expected:"record",code:"invalid_type",input:i,inst:e}),o;let s=[],c=t.keyType._zod.values;if(c&&!t.partial){o.value=r?r.alloc(e,o,{},n):{};let a=new Set;for(let p of c)if(typeof p==="string"||typeof p==="number"||typeof p==="symbol"){if(a.add(typeof p==="number"?p.toString():p),p==="__proto__")continue;let d=t.keyType._zod.run({value:p,issues:[]},n);if(d instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(d.issues.length){o.issues.push({code:"invalid_key",origin:"record",issues:d.issues.map((g)=>de(g,n,Y())),input:p,path:[p],inst:e});continue}let h=d.value;if(h==="__proto__")continue;let m=t.valueType._zod.run({value:i[p],issues:[]},n);if(m instanceof Promise)s.push(m.then((g)=>{if(g.issues.length)o.issues.push(...ye(p,g.issues));o.value[h]=g.value}));else{if(m.issues.length)o.issues.push(...ye(p,m.issues));o.value[h]=m.value}}let l;for(let p in i)if(!a.has(p))if(t.mode==="loose"){if(p==="__proto__")continue;o.value[p]=i[p]}else l=l??[],l.push(p);if(l&&l.length>0)o.issues.push({code:"unrecognized_keys",input:i,inst:e,keys:l,continue:!0})}else{o.value=r?r.alloc(e,o,{},n):{};let a;for(let l of Reflect.ownKeys(i)){if(l==="__proto__")continue;if(!Object.prototype.propertyIsEnumerable.call(i,l))continue;let p=t.keyType._zod.run({value:l,issues:[]},n);if(p instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(typeof l==="string"&&Ke.test(l)&&p.issues.length){let g=t.keyType._zod.run({value:Number(l),issues:[]},n);if(g instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(g.issues.length===0)p=g}if(p.issues.length){if(t.mode==="loose")o.value[l]=i[l];else if(c)a=a??[],a.push(l);else o.issues.push({code:"invalid_key",origin:"record",issues:p.issues.map((g)=>de(g,n,Y())),input:l,path:[l],inst:e});continue}let h=p.value;if(h==="__proto__")continue;let m=t.valueType._zod.run({value:i[l],issues:[]},n);if(m instanceof Promise)s.push(m.then((g)=>{if(g.issues.length)o.issues.push(...ye(l,g.issues));o.value[h]=g.value}));else{if(m.issues.length)o.issues.push(...ye(l,m.issues));o.value[h]=m.value}}if(a&&a.length>0)o.issues.push({code:"unrecognized_keys",input:i,inst:e,keys:a,continue:!0})}if(s.length)return Promise.all(s).then(()=>o);return o}});var js=f("$ZodEnum",(e,t)=>{R.init(e,t);let r=Ue(t.entries),o=new Set(r);e._zod.values=o,k(e,"pattern",(n)=>{let i=Ue(n.def.entries).filter((s)=>kn.has(typeof s));return new RegExp(i.length?`^(${i.map((s)=>xe(s.toString())).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(n,i)=>{let s=n.value;if(o.has(s))return n;return n.issues.push({code:"invalid_value",values:r,input:s,inst:e}),n}}),Ls=f("$ZodLiteral",(e,t)=>{R.init(e,t);let r=new Set(t.values);e._zod.values=r,k(e,"pattern",(o)=>{let n=o.def.values;return new RegExp(n.length?`^(${n.map((i)=>typeof i==="string"?xe(i):i?xe(i.toString()):String(i)).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(o,n)=>{let i=o.value;if(r.has(i))return o;return o.issues.push({code:"invalid_value",values:t.values,input:i,inst:e}),o}});var Ds=f("$ZodTransform",(e,t)=>{R.init(e,t),e._zod.optin="optional",X.memoizer?.guard(e),e._zod.parse=(r,o)=>{if(o.direction==="backward")throw new qe(e.constructor.name);let n=t.transform(r.value,r);if(o.async)return(n instanceof Promise?n:Promise.resolve(n)).then((s)=>(r.value=s,r));if(n instanceof Promise)throw new me;return r.value=n,r}});function Ji(e,t){return e.value=t.issues.length?void 0:t.value,e}var Br=f("$ZodOptional",(e,t)=>{R.init(e,t),k(e,"optin",(r)=>r.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),e._zod.optout="optional",k(e,"values",(r)=>{let o=r.def.innerType._zod.values;return o?new Set([...o,void 0]):void 0}),k(e,"pattern",(r)=>{let o=r.def.innerType._zod.pattern;return o?new RegExp(`^(${ct(o.source)})?$`):void 0}),e._zod.parse=(r,o)=>{if(r.value===void 0){if(t.innerType._zod.optin!=="defaulted")return r;let n=t.innerType._zod.run({value:r.value,issues:[]},o);if(n instanceof Promise)return n.then((i)=>Ji(r,i));return Ji(r,n)}return t.innerType._zod.run(r,o)}}),Us=f("$ZodExactOptional",(e,t)=>{Br.init(e,t),k(e,"values",(r)=>r.def.innerType._zod.values),k(e,"pattern",(r)=>r.def.innerType._zod.pattern),e._zod.parse=(r,o)=>t.innerType._zod.run(r,o)}),Ms=f("$ZodNullable",(e,t)=>{R.init(e,t),k(e,"optin",(r)=>r.def.innerType._zod.optin),k(e,"optout",(r)=>r.def.innerType._zod.optout),k(e,"pattern",(r)=>{let o=r.def.innerType._zod.pattern;return o?new RegExp(`^(${ct(o.source)}|null)$`):void 0}),k(e,"values",(r)=>r.def.innerType._zod.values?new Set([...r.def.innerType._zod.values,null]):void 0),e._zod.parse=(r,o)=>{if(r.value===null)return r;return t.innerType._zod.run(r,o)}}),Fs=f("$ZodDefault",(e,t)=>{R.init(e,t),e._zod.optin="defaulted",k(e,"values",(r)=>r.def.innerType._zod.values),e._zod.parse=(r,o)=>{if(o.direction==="backward")return t.innerType._zod.run(r,o);if(r.value===void 0)return r.value=t.defaultValue,r;let n=t.innerType._zod.run(r,o);if(n instanceof Promise)return n.then((i)=>qi(i,t));return qi(n,t)}});function qi(e,t){if(e.value===void 0)e.value=t.defaultValue;return e}var Bs=f("$ZodPrefault",(e,t)=>{R.init(e,t),e._zod.optin="defaulted",k(e,"values",(r)=>r.def.innerType._zod.values),e._zod.parse=(r,o)=>{if(o.direction==="backward")return t.innerType._zod.run(r,o);if(r.value===void 0)r.value=t.defaultValue;return t.innerType._zod.run(r,o)}}),Js=f("$ZodNonOptional",(e,t)=>{R.init(e,t),k(e,"values",(r)=>{let o=r.def.innerType._zod.values;return o?new Set([...o].filter((n)=>n!==void 0)):void 0}),e._zod.parse=(r,o)=>{let n=t.innerType._zod.run(r,o);if(n instanceof Promise)return n.then((i)=>Vi(i,e));return Vi(n,e)}});function Vi(e,t){if(!e.issues.length&&e.value===void 0)e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t});return e}function Ki(e,t,r,o){if(!t.issues.length){if(e.value=t.value,t.memo)e.memo=!0;return e}return e.value=r.catchValue({...t,value:e.value,error:{issues:t.issues.map((n)=>de(n,o,Y()))},input:e.value}),e}var qs=f("$ZodCatch",(e,t)=>{R.init(e,t),k(e,"optin",(r)=>r.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),k(e,"optout",(r)=>r.def.innerType._zod.optout),k(e,"values",(r)=>r.def.innerType._zod.values),e._zod.parse=(r,o)=>{if(o.direction==="backward")return t.innerType._zod.run(r,o);let n=t.innerType._zod.run({value:r.value,issues:[]},o);if(n instanceof Promise)return n.then((i)=>Ki(r,i,t,o));return Ki(r,n,t,o)}});var Jr=f("$ZodPipe",(e,t)=>{R.init(e,t),k(e,"values",(r)=>r.def.in._zod.values),k(e,"optin",(r)=>r.def.in._zod.optin),k(e,"optout",(r)=>r.def.out._zod.optout),k(e,"propValues",(r)=>r.def.in._zod.propValues),e._zod.parse=(r,o)=>{if(o.direction==="backward"){let i=t.out._zod.run(r,o);if(i instanceof Promise)return i.then((s)=>yt(s,t.in,o));return yt(i,t.in,o)}let n=t.in._zod.run(r,o);if(n instanceof Promise)return n.then((i)=>yt(i,t.out,o));return yt(n,t.out,o)}});function yt(e,t,r){if(e.issues.some((o)=>o.code!=="unrecognized_keys"))return e.aborted=!0,e;return t._zod.run({value:e.value,issues:e.issues},r)}var Vs=f("$ZodPreprocess",(e,t)=>{Jr.init(e,t)}),Ks=f("$ZodReadonly",(e,t)=>{R.init(e,t),k(e,"propValues",(r)=>r.def.innerType._zod.propValues),k(e,"values",(r)=>r.def.innerType._zod.values),k(e,"optin",(r)=>r.def.innerType?._zod?.optin),k(e,"optout",(r)=>r.def.innerType?._zod?.optout),e._zod.parse=(r,o)=>{if(o.direction==="backward")return t.innerType._zod.run(r,o);let n=t.innerType._zod.run(r,o);if(n instanceof Promise)return n.then(Wi);return Wi(n)}});function Wi(e){if(!e.memo)e.value=Object.freeze(e.value);return e}var Ws=f("$ZodCustom",(e,t)=>{q.init(e,t),R.init(e,t),e._zod.parse=(r,o)=>r,e._zod.check=(r)=>{let o=r.value,n=t.fn(o);if(n instanceof Promise)return n.then((i)=>Gi(i,r,o,e));Gi(n,r,o,e);return}});function Gi(e,t,r,o){if(!e){let n={code:"custom",input:r,inst:o,path:[...o._zod.def.path??[]],continue:!o._zod.def.abort};if(o._zod.def.params)n.params=o._zod.def.params;t.issues.push(ke(n))}}class Hs extends Error{constructor(){super("Cannot parse a reference cycle that closes through a transform");this.name="ZodCyclicError"}}var Vr="~memo",Gs=[];function Xs(e){return e!==null&&typeof e==="object"}function qr(e){return e.map((t)=>t.path?{...t,path:t.path.slice()}:{...t})}var Ys=new WeakMap,Ge=0,Rt=1,He=2;function It(e,t,r){let o=Ys.get(e);if(o!==void 0)return o?He:Ge;if(t.has(e))return He;t.add(e);let n=Ge,i=(p)=>{if(n!==He&&p?._zod){let d=It(p,t,r);if(d>n)n=d}},s=(p,d)=>{let h=Ge;for(let m of Reflect.ownKeys(p)){let g=Object.getOwnPropertyDescriptor(p,m);if(d&&!g.enumerable)continue;let b=g.get?Rt:g.value?._zod?It(g.value,t,r):Ge;if(b>h)h=b}return h},c=(p)=>{if(p>n)n=p},a=e._zod.def,l=a.type;switch(l){case"object":{let p=Je(a);c(p?s(p,!0):Rt),i(a.catchall);break}case"array":i(a.element);break;case"tuple":for(let p of a.items)i(p);i(a.rest);break;case"record":case"map":i(a.keyType),i(a.valueType);break;case"set":i(a.valueType);break;case"union":for(let p of a.options)i(p);break;case"intersection":i(a.left),i(a.right);break;case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":i(a.innerType);break;case"pipe":i(a.in),i(a.out);break;case"function":i(a.input),i(a.output);break;case"lazy":{let p=a._cachedInner??(r?e._zod.innerType:void 0);c(p?It(p,t,!1):Rt);break}case"template_literal":case"string":case"number":case"int":case"boolean":case"bigint":case"symbol":case"undefined":case"null":case"void":case"never":case"any":case"unknown":case"date":case"nan":case"enum":case"literal":case"file":case"transform":case"custom":break;default:for(let p in a){let d=Object.getOwnPropertyDescriptor(a,p);if(!d||d.get)continue;let h=d.value;if(!h||typeof h!=="object")continue;if(h._zod)i(h);else if(Array.isArray(h))for(let m of h)i(m)}}return t.delete(e),Sl(e,n)}function Sl(e,t){if(t!==Rt)Ys.set(e,t===He);return t}function kl(e,t){let r=e.buckets.get(t);if(!r)r=new WeakMap,e.buckets.set(t,r);return r}var Pt,Zt=[],Pl={alloc(e,t,r){let o=Pt;if(!o)return r;Pt=void 0;let n={value:r,issues:null};return o.set(t.value,n),Zt.push(n),r},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let r=e._zod.parse,o=(n,i)=>{if(i.direction!=="backward"&&Zl(i,n.value))throw new Hs;return r(n,i)};if(e._zod.parse=o,e._zod.run===r)e._zod.run=o})},attach(e){var t;let r,o=!1,n,i;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let s=e._zod.parse,c=(a,l)=>{if(r===void 0){let P=It(e,new Set,!1);if(P===Ge){if(e._zod.parse=s,e._zod.run===c)e._zod.run=s;return s(a,l)}if(P===He||o)r=!0;else o=!0}let p=a.value;if(!Xs(p))return s(a,l);let d=l[Vr];if(!d)d={buckets:new WeakMap,backEdges:void 0},l[Vr]=d;let h;if(n===l)h=i;else h=kl(d,e),n=l,i=h;let m=h.get(p);if(m){if(a.value=m.value,m.issues){if(m.issues.length)a.issues.push(...qr(m.issues))}else a.memo=!0,d.backEdges??(d.backEdges=new WeakSet),d.backEdges.add(m.value);return a}Pt=h;let g=Zt.length,b=s(a,l);Pt=void 0;let v=Zt.length>g?Zt.pop():void 0;if(b instanceof Promise)return b.then((P)=>{if(v)v.issues=P.issues.length?qr(P.issues):Gs;return P});if(v)v.issues=b.issues.length?qr(b.issues):Gs;return b};if(e._zod.parse=c,e._zod.run===s)e._zod.run=c})}};function Kr(){return Pl}function Zl(e,t){let r=e[Vr]?.backEdges;return r!==void 0&&Xs(t)&&r.has(t)}var Ol=()=>{let e={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"},map:{unit:"entries",verb:"to have"}};function t(i){return e[i]??null}let r={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",currency_code:"currency code",credit_card:"credit card number",iban:"IBAN",jwt:"JWT",template_literal:"input"},o={nan:"NaN"};function n(i,s){if(i==="number"&&typeof s==="number"&&!Number.isFinite(s))return String(s);return o[i]??i}return(i)=>{switch(i.code){case"invalid_type":{let s=n(i.expected),c=In(i.input),a=n(c,i.input);return`Invalid input: expected ${s}, received ${a}`}case"invalid_value":if(i.values.length===1)return`Invalid input: expected ${zr(i.values[0])}`;return`Invalid option: expected one of ${mr(i.values,"|")}`;case"too_big":{let s=i.exact?"exactly ":i.inclusive?"<=":"<",c=t(i.origin);if(c)return`Too big: expected ${i.origin??"value"} to have ${s}${i.maximum.toString()} ${c.unit??"elements"}`;return`Too big: expected ${i.origin??"value"} to be ${s}${i.maximum.toString()}`}case"too_small":{let s=i.exact?"exactly ":i.inclusive?">=":">",c=t(i.origin);if(c)return`Too small: expected ${i.origin} to have ${s}${i.minimum.toString()} ${c.unit}`;return`Too small: expected ${i.origin} to be ${s}${i.minimum.toString()}`}case"invalid_format":{let s=i;if(s.format==="starts_with")return`Invalid string: must start with "${s.prefix}"`;if(s.format==="ends_with")return`Invalid string: must end with "${s.suffix}"`;if(s.format==="includes")return`Invalid string: must include "${s.includes}"`;if(s.format==="regex")return`Invalid string: must match pattern ${s.pattern}`;return`Invalid ${r[s.format]??i.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${i.divisor}`;case"unrecognized_keys":return`Unrecognized key${i.keys.length>1?"s":""}: ${mr(i.keys,", ")}`;case"invalid_key":return`Invalid key in ${i.origin}`;case"invalid_union":if(i.options&&Array.isArray(i.options)&&i.options.length>0)return`Invalid discriminator value. Expected ${i.options.map((c)=>`'${c}'`).join(" | ")}`;if(i.inclusive===!1)return"Invalid input: more than one option matched";return"Invalid input";case"invalid_element":return`Invalid value in ${i.origin}`;default:return"Invalid input"}}};function Wr(){return{localeError:Ol()}}var Qs;class ec{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let r=t[0];if(this._map.set(e,r),r&&typeof r==="object"&&"id"in r)this._idmap.set(r.id,e);return this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);if(t&&typeof t==="object"&&"id"in t)this._idmap.delete(t.id);return this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let r={...this.get(t)??{}};delete r.id;let o={...r,...this._map.get(e)};return Object.keys(o).length?o:void 0}return this._map.get(e)}has(e){return this._map.has(e)}}function tc(){return new ec}(Qs=globalThis).__zod_globalRegistry??(Qs.__zod_globalRegistry=tc());var be=globalThis.__zod_globalRegistry;function Gr(e){if(e.checks)e.checks=[...e.checks];return e}function rc(e,t){return new e(Gr({type:"string",...x(t)}))}function oc(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...x(t)})}function nc(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...x(t)})}function ic(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...x(t)})}function sc(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...x(t)})}function cc(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...x(t)})}function ac(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...x(t)})}function Hr(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...x(t)})}function uc(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...x(t)})}function lc(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...x(t)})}function pc(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...x(t)})}function fc(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...x(t)})}function dc(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...x(t)})}function mc(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...x(t)})}function hc(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...x(t)})}function gc(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...x(t)})}function _c(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...x(t)})}function zc(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...x(t)})}function xc(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...x(t)})}function yc(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...x(t)})}function bc(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...x(t)})}function vc(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...x(t)})}function wc(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...x(t)})}function Tt(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...x(t)})}function Xr(e,t){return new e({type:"string",format:"date",check:"string_format",...x(t)})}function Yr(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...x(t)})}function Qr(e,t){return new e({type:"string",format:"duration",check:"string_format",...x(t)})}function $c(e,t){return new e(Gr({type:"number",checks:[],...x(t)}))}function Sc(e,t){return new e(Gr({type:"number",coerce:!0,checks:[],...x(t)}))}function kc(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...x(t)})}function Pc(e,t){return new e({type:"boolean",...x(t)})}function Zc(e,t){return new e({type:"null",...x(t)})}function Oc(e){return new e({type:"any"})}function Rc(e){return new e({type:"unknown"})}function Cc(e,t){return new e({type:"never",...x(t)})}function At(e,t){return new Er({check:"less_than",...x(t),value:e,inclusive:!1})}function Xe(e,t){return new Er({check:"less_than",...x(t),value:e,inclusive:!0})}function Et(e,t){return new Nr({check:"greater_than",...x(t),value:e,inclusive:!1})}function Ye(e,t){return new Nr({check:"greater_than",...x(t),value:e,inclusive:!0})}function Nt(e,t){return new ki({check:"multiple_of",...x(t),value:e})}function jt(e,t){return new Zi({check:"max_length",...x(t),maximum:e})}function Oe(e,t){return new Oi({check:"min_length",...x(t),minimum:e})}function Dt(e,t){return new Ri({check:"length_equals",...x(t),length:e})}function fo(e,t){return new Ci({check:"string_format",format:"regex",...x(t),pattern:e})}function go(e){return new Ii({check:"string_format",format:"lowercase",...x(e)})}function _o(e){return new Ti({check:"string_format",format:"uppercase",...x(e)})}function zo(e,t){return new Ai({check:"string_format",format:"includes",...x(t),includes:e})}function xo(e,t){return new Ei({check:"string_format",format:"starts_with",...x(t),prefix:e})}function yo(e,t){return new Ni({check:"string_format",format:"ends_with",...x(t),suffix:e})}function ve(e){return new ji({check:"overwrite",tx:e})}function bo(e){return ve((t)=>t.normalize(e))}function vo(){return ve((e)=>e.trim())}function wo(){return ve((e)=>e.toLowerCase())}function $o(){return ve((e)=>e.toUpperCase())}function So(){return ve((e)=>$n(e))}function Ic(e,t,r){return new e({type:"array",element:t,...x(r)})}function Tc(e,t,r){let o=x(r);return o.abort??(o.abort=!0),new e({type:"custom",check:"custom",fn:t,...o})}function Ac(e,t,r){return new e({type:"custom",check:"custom",fn:t,...x(r)})}function Ec(e,t){let r=Rl((o)=>(o.addIssue=(n)=>{if(typeof n==="string")o.issues.push(ke(n,o.value,r._zod.def));else{let i=n;if(i.fatal)i.continue=!1;if(i.code??(i.code="custom"),!("input"in i))i.input=o.value;i.inst??(i.inst=r),i.continue??(i.continue=!r._zod.def.abort),o.issues.push(ke(i))}},e(o.value,o)),t);return r}function Rl(e,t){let r=new q({check:"custom",...x(t)});return r._zod.check=e,r}function Qe(e,...t){for(let r of t)for(let o of Reflect.ownKeys(r))if(Object.prototype.propertyIsEnumerable.call(r,o))oe(e,o,r[o]);return e}function Po(e){let t=e?.target??"draft-2020-12";if(t==="draft-4")t="draft-04";if(t==="draft-7")t="draft-07";return{processors:e.processors??{},metadataRegistry:e?.metadata??be,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:e?.cycles??"ref",reused:e?.reused??"inline",intersections:[],deferred:[],external:e?.external??void 0}}function _e(e,t,r,o,n){let i=typeof t.unrepresentable==="function"?t.unrepresentable({zodSchema:e,path:o.path,message:n}):t.unrepresentable;if(i==="any")return!1;if(i===void 0||i==="throw")throw Error(n);return Object.assign(r,i),!0}function D(e,t,r={path:[],schemaPath:[]}){var o;let n=e._zod.def,i=t.seen.get(e);if(i){if(i.count++,r.schemaPath.includes(e))i.cycle=r.path;return i.schema}let s={schema:{},count:1,cycle:void 0,path:r.path};t.seen.set(e,s),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;let c=e._zod.toJSONSchema?.();if(c)s.schema=c;else{let p={...r,schemaPath:[...r.schemaPath,e],path:r.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,s.schema,p);else{let h=s.schema,m=t.processors[n.type];if(!m)throw Error(`[toJSONSchema]: Non-representable type encountered: ${n.type}`);m(e,t,h,p)}let d=e._zod.parent;if(d){if(!s.ref)s.ref=d;D(d,t,p),t.seen.get(d).isParent=!0}}let a=t.metadataRegistry.get(e);if(a)Qe(s.schema,a);if(t.io==="input"&&G(e))delete s.schema.examples,delete s.schema.default;if(t.io==="input"&&"_prefault"in s.schema)(o=s.schema).default??(o.default=s.schema._prefault);return delete s.schema._prefault,t.seen.get(e).schema}function Nc(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function Zo(e,t){let r=e.seen.get(t);if(!r)throw Error("Unprocessed schema. This is a bug in Zod.");if(e.external&&e.sharedDefsExtractedFor===e.external)return;let o=new Map;for(let s of e.seen.entries()){let c=e.metadataRegistry.get(s[0])?.id;if(c){let a=o.get(c);if(a&&a!==s[0])throw Error(`Duplicate schema id "${c}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);o.set(c,s[0])}}let n=(s)=>{let c=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){let d=e.external.registry.get(s[0])?.id,h=e.external.uri??((g)=>g);if(d)return{ref:h(d)};let m=s[1].defId??s[1].schema.id??`schema${e.counter++}`;return s[1].defId=m,{defId:m,ref:`${h("__shared")}#/${c}/${Nc(m)}`}}let a="#",l=`${a}/${c}/`;if(s[1]===r&&!s[1].schema.id)return{ref:a};let p=s[1].schema.id??`__schema${e.counter++}`;return{defId:p,ref:l+Nc(p)}},i=(s)=>{if(s[1].schema.$ref)return;let c=s[1],{ref:a,defId:l}=n(s);if(c.def={...c.schema},l)c.defId=l;let p=c.schema;for(let d in p)delete p[d];p.$ref=a};if(e.cycles==="throw")for(let s of e.seen.entries()){let c=s[1];if(c.cycle)throw Error(`Cycle detected: #/${c.cycle?.join("/")}/<root>
57
+
58
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let s of e.seen.entries()){let c=s[1];if(t===s[0]){i(s);continue}if(e.external){let l=e.external.registry.get(s[0])?.id;if(t!==s[0]&&l){i(s);continue}}if(e.metadataRegistry.get(s[0])?.id){i(s);continue}if(c.cycle){i(s);continue}if(c.count>1){if(e.reused==="ref")i(s)}}if(e.external)e.sharedDefsExtractedFor=e.external}function Dc(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let r=[];for(let o of t){if(!o||typeof o!=="object")return;Dc(o);let n=Object.keys(o);if(n.length!==1||n[0]!=="type")return;let i=o.type;for(let s of Array.isArray(i)?i:[i]){if(typeof s!=="string")return;if(!r.includes(s))r.push(s)}}delete e.anyOf,e.type=r.length===1?r[0]:r}var Uc=new Set(["type","properties","required","additionalProperties"]),jc=["oneOf","anyOf"];function Lc(e){let t=e.additionalProperties;if(t===void 0||t===!1||typeof t!=="object"||t===null)return null;return Object.keys(t).length?t:null}function ko(e){let t=[];for(let i of e){if(typeof i!=="object"||i.type!=="object")return null;for(let s in i)if(!Uc.has(s))return null;t.push(i)}let r={},o=new Set;for(let i of t){for(let s in i.properties){if(Object.prototype.hasOwnProperty.call(r,s))continue;let c=[];for(let l of t){let p=l.properties?.[s]??Lc(l);if(p===null||p===void 0)continue;if(!c.some((d)=>JSON.stringify(d)===JSON.stringify(p)))c.push(p)}let a=c.length===1?c[0]:ko(c)??{allOf:c};oe(r,s,a)}for(let s of i.required??[])o.add(s)}let n={type:"object",properties:r};if(o.size)n.required=[...o];if(t.every((i)=>i.additionalProperties===!1))n.additionalProperties=!1;else{let i=[];for(let s of t){let c=Lc(s);if(c&&!i.some((a)=>JSON.stringify(a)===JSON.stringify(c)))i.push(c)}if(i.length===1)n.additionalProperties=i[0];else if(i.length>1)n.additionalProperties={allOf:i}}return n}function Cl(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let n of Uc)if(n in e)return;let r=t.filter((n)=>jc.some((i)=>Array.isArray(n[i]))),o=null;if(!r.length)o=ko(t);else{let n=r[0],i=jc.find((a)=>Array.isArray(n[a]));if(Object.keys(n).length!==1)return;let s=t.filter((a)=>a!==n),c=n[i].map((a)=>ko([...s,a]));if(c.some((a)=>!a))return;o={[i]:c}}if(!o)return;delete e.allOf,Qe(e,o)}function Oo(e,t){let r=e.seen.get(t);if(!r)throw Error("Unprocessed schema. This is a bug in Zod.");let o=(c)=>{let a=e.seen.get(c);if(a.ref===null)return;let l=a.def??a.schema,p={...l},d=a.ref;if(a.ref=null,d){o(d);let m=e.seen.get(d),g=m.schema;if(g.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0"))l.allOf=l.allOf??[],l.allOf.push(g);else Qe(l,g);if(Qe(l,p),c._zod.parent===d)for(let v in l){if(v==="$ref"||v==="allOf")continue;if(!(v in p))delete l[v]}if(g.$ref&&m.def)for(let v in l){if(v==="$ref"||v==="allOf")continue;if(v in m.def&&JSON.stringify(l[v])===JSON.stringify(m.def[v]))delete l[v]}}let h=c._zod.parent;if(h&&h!==d){o(h);let m=e.seen.get(h);if(m?.schema.$ref){if(l.$ref=m.schema.$ref,m.def)for(let g in l){if(g==="$ref"||g==="allOf")continue;if(g in m.def&&JSON.stringify(l[g])===JSON.stringify(m.def[g]))delete l[g]}}}e.override({zodSchema:c,jsonSchema:l,path:a.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let c of[...e.seen.entries()].reverse())o(c[0]);if(e.target!=="openapi-3.0")for(let c of e.seen.entries())Dc(c[1].def??c[1].schema);for(let c of e.deferred)c();if(e.intersections.length){let c=new Map;for(let a of e.seen.values())for(let l of[a.schema,a.def]){let p=l?.allOf;if(!Array.isArray(p))continue;let d=c.get(p);if(d)d.push(l);else c.set(p,[l])}for(let a of e.intersections)for(let l of c.get(a)??[])Cl(l)}}let n={};if(e.target==="draft-2020-12")n.$schema="https://json-schema.org/draft/2020-12/schema";else if(e.target==="draft-07")n.$schema="http://json-schema.org/draft-07/schema#";else if(e.target==="draft-04")n.$schema="http://json-schema.org/draft-04/schema#";else if(e.target==="openapi-3.0");if(e.external?.uri){let c=e.external.registry.get(t)?.id;if(!c)throw Error("Schema is missing an `id` property");n.$id=e.external.uri(c)}Qe(n,r.defId?r.schema:r.def??r.schema);let i=e.metadataRegistry.get(t)?.id;if(i!==void 0&&n.id===i)delete n.id;let s=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let c of e.seen.entries()){let a=c[1];if(a.def&&a.defId){if(a.def.id===a.defId)delete a.def.id;oe(s,a.defId,a.def)}}if(e.external)e.sharedEmitDoneFor=e.external;if(e.external);else if(Object.keys(s).length>0)if(e.target==="draft-2020-12")n.$defs=s;else n.definitions=s;try{let c=JSON.parse(JSON.stringify(n));return Object.defineProperty(c,"~standard",{value:{...t["~standard"],jsonSchema:{input:et(t,"input",e.processors),output:et(t,"output",e.processors)}},enumerable:!1,writable:!1}),c}catch(c){throw Error("Error converting schema to JSON.")}}function G(e,t){let r=t??{seen:new Set};if(r.seen.has(e))return!1;r.seen.add(e);let o=e._zod.def;if(o.type==="transform")return!0;if(o.type==="array")return G(o.element,r);if(o.type==="set")return G(o.valueType,r);if(o.type==="lazy")return G(o.getter(),r);if(o.type==="promise"||o.type==="optional"||o.type==="nonoptional"||o.type==="nullable"||o.type==="readonly"||o.type==="default"||o.type==="prefault"||o.type==="catch")return G(o.innerType,r);if(o.type==="intersection")return G(o.left,r)||G(o.right,r);if(o.type==="record"||o.type==="map")return G(o.keyType,r)||G(o.valueType,r);if(o.type==="pipe"){if(e._zod.traits.has("$ZodCodec"))return!0;return G(o.in,r)||G(o.out,r)}if(o.type==="object"){for(let n in o.shape)if(G(o.shape[n],r))return!0;return!1}if(o.type==="union"){for(let n of o.options)if(G(n,r))return!0;return!1}if(o.type==="tuple"){for(let n of o.items)if(G(n,r))return!0;if(o.rest&&G(o.rest,r))return!0;return!1}return!1}var Mc=(e,t={})=>(r)=>{let o=Po({...r,processors:t});return D(e,o),Zo(o,e),Oo(o,e)},et=(e,t,r={})=>(o)=>{let{libraryOptions:n,target:i}=o??{},s=Po({...n??{},target:i,io:t,processors:r});return D(e,s),Zo(s,e),Oo(s,e)};var Re=(e,t,r)=>{if(e[t]===void 0||r>e[t])e[t]=r},Ce=(e,t,r)=>{if(e[t]===void 0||r<e[t])e[t]=r},Fc=(e,t)=>{Re(e,"minimum",t),Ce(e,"maximum",t)},Vc=(e,t)=>{if(e.multipleOf??(e.multipleOf=[]),!e.multipleOf.includes(t))e.multipleOf.push(t)},Kc=(e,t)=>{e.patterns??(e.patterns=new Set),e.patterns.add(t)},Wc=(e,t)=>{e.mime=e.mime?e.mime.filter((r)=>t.includes(r)):[...t]},Gc=(e,t)=>{if(e.format=t,t.includes("int"))e.isInt=!0},Bc=(e,t)=>Re(e,"minimum",t.minimum),Jc=(e,t)=>Ce(e,"maximum",t.maximum),qc=(e)=>(t,r)=>{Gc(t,r.format);let[o,n]=e[r.format];Re(t,"minimum",o),Ce(t,"maximum",n)},Il={greater_than:(e,t)=>Re(e,t.inclusive?"minimum":"exclusiveMinimum",t.value),less_than:(e,t)=>Ce(e,t.inclusive?"maximum":"exclusiveMaximum",t.value),multiple_of:(e,t)=>Vc(e,t.value),number_format:qc(at),bigint_format:qc(xr),min_length:Bc,max_length:Jc,length_equals:(e,t)=>Fc(e,t.length),min_size:Bc,max_size:Jc,size_equals:(e,t)=>Fc(e,t.size),string_format:(e,t)=>{if(Gc(e,t.format),t.pattern)Kc(e,t.pattern);if(t.format==="base64"||t.format==="base64url")e.contentEncoding=t.format;if(t.local||t.precision===-1)e.laxFormat=!0},mime_type:(e,t)=>Wc(e,t.mime)};function ie(e){let t={},r=e._zod.def,o=e._zod.traits.has("$ZodCheck")?[e,...r.checks??[]]:r.checks??[];for(let i of o)Il[i._zod.def.check]?.(t,i._zod.def);let n=e._zod.bag;if(n.minimum!==void 0)Re(t,"minimum",n.minimum);if(n.exclusiveMinimum!==void 0)Re(t,"exclusiveMinimum",n.exclusiveMinimum);if(n.maximum!==void 0)Ce(t,"maximum",n.maximum);if(n.exclusiveMaximum!==void 0)Ce(t,"exclusiveMaximum",n.exclusiveMaximum);if(n.multipleOf!==void 0)Vc(t,n.multipleOf);if(n.format!==void 0){if(t.format??(t.format=n.format),n.format.includes("int"))t.isInt=!0}if(n.mime)Wc(t,n.mime);for(let i of n.patterns??[])Kc(t,i);return t}var Tl={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},Al=new Map([[Ur,di],[kt,mi]]),Hc=(e)=>Al.get(e)??e,Xc=(e,t,r,o)=>{let n=r;n.type="string";let{minimum:i,maximum:s,format:c,patterns:a,contentEncoding:l,laxFormat:p}=ie(e);if(typeof i==="number")n.minLength=i;if(typeof s==="number")n.maxLength=s;if(c){if(n.format=Tl[c]??c,n.format==="")delete n.format;if(c==="time"||p)delete n.format}if(l)n.contentEncoding=l;if(a&&a.size>0){let d=[...a].map(Hc);if(d.length===1)n.pattern=d[0].source;else if(d.length>1)n.allOf=[...d.map((h)=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:h.source}))]}},Yc=(e,t,r,o)=>{let n=r,{minimum:i,maximum:s,multipleOf:c,exclusiveMaximum:a,exclusiveMinimum:l,isInt:p}=ie(e);n.type=p?"integer":"number";let d=typeof l==="number"&&l>=(i??Number.NEGATIVE_INFINITY),h=typeof a==="number"&&a<=(s??Number.POSITIVE_INFINITY),m=t.target==="draft-04"||t.target==="openapi-3.0";if(d)if(m)n.minimum=l,n.exclusiveMinimum=!0;else n.exclusiveMinimum=l;else if(typeof i==="number")n.minimum=i;if(h)if(m)n.maximum=a,n.exclusiveMaximum=!0;else n.exclusiveMaximum=a;else if(typeof s==="number")n.maximum=s;if(c){let g=new Set;for(let P of c)if(Number.isFinite(P)&&P!==0)g.add(Math.abs(P));else _e(e,t,n,o,`A multipleOf divisor of ${P} cannot be represented in JSON Schema`);let[b,...v]=g;if(b!==void 0)n.multipleOf=b;if(v.length)n.allOf=[...n.allOf??[],...v.map((P)=>({multipleOf:P}))]}},Qc=(e,t,r,o)=>{r.type="boolean"};var ea=(e,t,r,o)=>{if(t.target==="openapi-3.0")r.type="string",r.nullable=!0,r.enum=[null];else r.type="null"};var ta=(e,t,r,o)=>{r.not={}},ra=(e,t,r,o)=>{},oa=(e,t,r,o)=>{};var na=(e,t,r,o)=>{let n=e._zod.def,i=Ue(n.entries);if(i.length===0){r.not={};return}if(i.every((s)=>typeof s==="number"))r.type="number";if(i.every((s)=>typeof s==="string"))r.type="string";r.enum=i},ia=(e,t,r,o)=>{let n=e._zod.def;if(n.values.length===0){r.not={};return}let i=[];for(let s of n.values)if(s===void 0){if(_e(e,t,r,o,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof s==="bigint"){if(_e(e,t,r,o,"BigInt literals cannot be represented in JSON Schema"))return;i.push(Number(s))}else i.push(s);if(i.length===0);else if(i.length===1){let s=i[0];if(r.type=s===null?"null":typeof s,t.target==="draft-04"||t.target==="openapi-3.0")r.enum=[s];else r.const=s}else{if(i.every((s)=>typeof s==="number"))r.type="number";if(i.every((s)=>typeof s==="string"))r.type="string";if(i.every((s)=>typeof s==="boolean"))r.type="boolean";if(i.every((s)=>s===null))r.type="null";r.enum=i}};var sa=(e,t,r,o)=>{_e(e,t,r,o,"Custom types cannot be represented in JSON Schema")};var ca=(e,t,r,o)=>{_e(e,t,r,o,"Transforms cannot be represented in JSON Schema")};var aa=(e,t,r,o)=>{let n=r,i=e._zod.def,{minimum:s,maximum:c}=ie(e);if(typeof s==="number")n.minItems=s;if(typeof c==="number")n.maxItems=c;n.type="array",n.items=D(i.element,t,{...o,path:[...o.path,"items"]})};function Ut(e){let t=e._zod.def;if(t.type==="pipe"&&t.in._zod.traits.has("$ZodTransform"))return Ut(t.out);if(t.type==="catch")return Ut(t.innerType);return e._zod.optin}var ua=(e,t,r,o)=>{let n=r,i=e._zod.def,s=i.shape;if(Object.getOwnPropertySymbols(s).length&&_e(e,t,n,o,"Symbol keys cannot be represented in JSON Schema"))return;n.type="object",n.properties={};for(let l in s)oe(n.properties,l,D(s[l],t,{...o,path:[...o.path,"properties",l]}));let a=[];for(let l of Object.keys(s)){let p=i.shape[l];if(t.io==="input"?Ut(p)===void 0:p._zod.optout===void 0)a.push(l)}if(a.length>0)n.required=a;if(i.catchall?._zod.def.type==="never")n.additionalProperties=!1;else if(!i.catchall){if(t.io==="output")n.additionalProperties=!1}else if(i.catchall)n.additionalProperties=D(i.catchall,t,{...o,path:[...o.path,"additionalProperties"]})},la=(e,t,r,o)=>{let n=e._zod.def,i=n.inclusive===!1,s=n.options.map((c,a)=>D(c,t,{...o,path:[...o.path,i?"oneOf":"anyOf",a]}));if(i)r.oneOf=s;else r.anyOf=s},pa=(e,t,r,o)=>{let n=e._zod.def,i=D(n.left,t,{...o,path:[...o.path,"allOf",0]}),s=D(n.right,t,{...o,path:[...o.path,"allOf",1]}),c=(l)=>("allOf"in l)&&Object.keys(l).length===1,a=[...c(i)?i.allOf:[i],...c(s)?s.allOf:[s]];r.allOf=a,t.intersections.push(a)};function Ro(e,t,r){if(t.$ref){if(r.has(t))return t;r.add(t);let g=e.get(t)?.def;if(!g)return t;let b=Ro(e,g,r);return b===g?t:b}for(let g of["anyOf","oneOf"]){let b=t[g];if(!Array.isArray(b))continue;let v=b.map((P)=>Ro(e,P,r));if(v.some((P,H)=>P!==b[H]))t={...t,[g]:v}}let o=Array.isArray(t.type)?t.type:[t.type],n=!o.includes("string")&&o.some((g)=>g==="number"||g==="integer"),i=t.enum??(t.const!==void 0?[t.const]:void 0);if(!n&&!i?.some((g)=>typeof g==="number"))return t;let{minimum:s,maximum:c,exclusiveMinimum:a,exclusiveMaximum:l,multipleOf:p,format:d,id:h,...m}=t;if(m.enum)m.enum=m.enum.map((g)=>typeof g==="number"?String(g):g);else if(typeof m.const==="number")m.const=String(m.const);if(!n)return m;if(m.type="string",!i)m.pattern=(o.includes("number")?Ke:Ir).source;return m}var Co=new WeakMap;function El(e){let t=new Map;for(let o of e.seen.values())if(o.def&&!t.has(o.schema))t.set(o.schema,o);let r=new Map;for(let o of Co.get(e)??[]){let n=e.seen.get(o),i=(n?.def??n?.schema)?.propertyNames;if(!i||i===!0||r.has(i))continue;let s=Ro(t,i,new Set);if(s!==i)r.set(i,s)}if(!r.size)return;for(let o of e.seen.values())for(let n of[o.schema,o.def]){let i=n&&r.get(n.propertyNames);if(i)n.propertyNames=i}}var fa=(e,t,r,o)=>{let n=r,i=e._zod.def;n.type="object";let s=i.keyType,c=ie(s).patterns;if(i.mode==="loose"&&c&&c.size>0){let p=D(i.valueType,t,{...o,path:[...o.path,"patternProperties","*"]});n.patternProperties={};for(let d of c)oe(n.patternProperties,Hc(d).source,p)}else{if(t.target==="draft-07"||t.target==="draft-2020-12"){n.propertyNames=D(i.keyType,t,{...o,path:[...o.path,"propertyNames"]});let p=Co.get(t);if(!p)p=[],Co.set(t,p),t.deferred.push(()=>El(t));p.push(e)}n.additionalProperties=D(i.valueType,t,{...o,path:[...o.path,"additionalProperties"]})}let a=s._zod.values,l=t.io==="input"&&Ut(i.valueType)!==void 0;if(a&&!i.partial&&!l){let p=[...a].filter((d)=>typeof d==="string"||typeof d==="number");if(p.length>0)n.required=p.map(String)}},da=(e,t,r,o)=>{let n=e._zod.def,i=D(n.innerType,t,o),s=t.seen.get(e);if(t.target==="openapi-3.0")s.ref=n.innerType,r.nullable=!0;else r.anyOf=[i,{type:"null"}]},ma=(e,t,r,o)=>{let n=e._zod.def;D(n.innerType,t,o);let i=t.seen.get(e);i.ref=n.innerType},Io=Symbol();function ha(e,t,r,o,n){let i=!1,s=JSON.stringify(e,(c,a)=>{if(typeof a!=="bigint")return a;return i=!0,null});if(!i)return JSON.parse(s);return _e(t,r,o,n,"BigInt defaults cannot be represented in JSON Schema"),Io}var ga=(e,t,r,o)=>{let n=e._zod.def;D(n.innerType,t,o);let i=t.seen.get(e);i.ref=n.innerType;let s=ha(n.defaultValue,e,t,r,o);if(s!==Io)r.default=s},_a=(e,t,r,o)=>{let n=e._zod.def;D(n.innerType,t,o);let i=t.seen.get(e);if(i.ref=n.innerType,t.io!=="input")return;let s=ha(n.defaultValue,e,t,r,o);if(s!==Io)r._prefault=s},za=(e,t,r,o)=>{let n=e._zod.def;D(n.innerType,t,o);let i=t.seen.get(e);i.ref=n.innerType;let s;try{s=n.catchValue(void 0)}catch{_e(e,t,r,o,"Dynamic catch values are not supported in JSON Schema");return}r.default=s},xa=(e,t,r,o)=>{let n=e._zod.def,i=n.in._zod.traits.has("$ZodTransform"),s=t.io==="input"?i?n.out:n.in:n.out;D(s,t,o);let c=t.seen.get(e);c.ref=s},ya=(e,t,r,o)=>{let n=e._zod.def;D(n.innerType,t,o);let i=t.seen.get(e);i.ref=n.innerType,r.readOnly=!0};var To=(e,t,r,o)=>{let n=e._zod.def;D(n.innerType,t,o);let i=t.seen.get(e);i.ref=n.innerType};var ba=new WeakSet([Object.prototype,Error.prototype]);function Ft(e,t,r){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let o=r(this);return Object.defineProperty(this,t,{value:o,configurable:!0,writable:!0}),o},set(o){Object.defineProperty(this,t,{value:o,configurable:!0,writable:!0})}})}var Jl=(e,t)=>{Un.init(e,t),e.name="ZodError";let r=Object.getPrototypeOf(e);if(ba.has(r))return;ba.add(r),Ft(r,"format",(o)=>(n)=>kr(o,n)),Ft(r,"flatten",(o)=>(n)=>Sr(o,n)),Ft(r,"addIssue",(o)=>(n)=>{o.issues.push(n),o.message=JSON.stringify(o.issues,Me,2)}),Ft(r,"addIssues",(o)=>(n)=>{o.issues.push(...n),o.message=JSON.stringify(o.issues,Me,2)}),Object.defineProperty(r,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}})};var te=f("ZodError",Jl,void 0,{Parent:Error});var va=gt(te),wa=_t(te),$a=Ve(te),Sa=zt(te),ka=Bn(te),Pa=qn(te),Za=Vn(te),Oa=Kn(te),Ra=Wn(te),Ca=Gn(te),Ia=Hn(te),Ta=Xn(te);function Vl(){if(!X.localeError)Y(Wr())}function Jt(){if(!X.memoizer)Y({memoizer:Kr()})}var T=f("ZodType",(e,t)=>(Vl(),R.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(ee(t,{checks:[...t.checks??[],...e.map((r)=>typeof r==="function"?{_zod:{check:r,def:{check:"custom"},onattach:[]}}:r)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return ue(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(Tp(e,t))},superRefine(e,t){return this.check(Ap(e,t))},overwrite(e){return this.check(ve(e))},optional(){return j(this)},exactOptional(){return bp(this)},nullable(){return Na(this)},nullish(){return j(Na(this))},nonoptional(e){return Pp(this,e)},array(){return _(this)},or(e){return E([this,e])},and(e){return Vt(this,e)},transform(e){return ja(this,Ha(e))},default(e){return $p(this,e)},prefault(e){return kp(this,e)},catch(e){return Op(this,e)},pipe(e){return ja(this,e)},readonly(){return Ip(this)},describe(e){let t=this.clone();return be.add(t,{description:e}),t},meta(...e){if(e.length===0)return be.get(this);let t=this.clone();return be.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get "~standard"(){return mt(this,"~standard",{...Dr(this),jsonSchema:{input:et(this,"input"),output:et(this,"output")}})},set "~standard"(e){ge(this,"~standard",e)},parse:function e(t,r){return va(this,t,r,{callee:e})},parseAsync:async function e(t,r){return await wa(this,t,r,{callee:e})},safeParse(e,t){return $a(this,e,t)},async safeParseAsync(e,t){return Sa(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){ge(this,"spa",e)},validate(e,t){return Zr(this,e,t)},validateAsync(e,t){return Or(this,e,t)},encode:function e(t,r){return ka(this,t,r,{callee:e})},decode:function e(t,r){return Pa(this,t,r,{callee:e})},encodeAsync:async function e(t,r){return await Za(this,t,r,{callee:e})},decodeAsync:async function e(t,r){return await Oa(this,t,r,{callee:e})},safeEncode(e,t){return Ra(this,e,t)},safeDecode(e,t){return Ca(this,e,t)},async safeEncodeAsync(e,t){return Ia(this,e,t)},async safeDecodeAsync(e,t){return Ta(this,e,t)},toJSONSchema(e){return Mc(this,{})(e)},get description(){return be.get(this)?.description},get _def(){return this._zod.def}}),La=f("_ZodString",(e,t)=>{$t.init(e,t),T.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Xc(e,r,o,n)},An({format:(e)=>ie(e).format??null,minLength:(e)=>ie(e).minimum??null,maxLength:(e)=>ie(e).maximum??null},{regex(...e){return this.check(fo(...e))},includes(...e){return this.check(zo(...e))},startsWith(...e){return this.check(xo(...e))},endsWith(...e){return this.check(yo(...e))},min(...e){return this.check(Oe(...e))},max(...e){return this.check(jt(...e))},length(...e){return this.check(Dt(...e))},nonempty(...e){return this.check(Oe(1,...e))},lowercase(e){return this.check(go(e))},uppercase(e){return this.check(_o(e))},trim(){return this.check(vo())},normalize(...e){return this.check(bo(...e))},toLowerCase(){return this.check(wo())},toUpperCase(){return this.check($o())},slugify(){return this.check(So())}})),Da=f("ZodString",(e,t)=>{$t.init(e,t),La.init(e,t)},{email(e){return this.check(oc(Kl,e))},url(e){return this.check(Hr(Ba,e))},jwt(e){return this.check(wc(up,e))},emoji(e){return this.check(uc(Gl,e))},guid(e){return this.check(nc(Wl,e))},uuid(e){return this.check(ic(Bt,e))},uuidv4(e){return this.check(sc(Bt,e))},uuidv6(e){return this.check(cc(Bt,e))},uuidv7(e){return this.check(ac(Bt,e))},nanoid(e){return this.check(lc(Hl,e))},cuid(e){return this.check(pc(Xl,e))},cuid2(e){return this.check(fc(Yl,e))},ulid(e){return this.check(dc(Ql,e))},base64(e){return this.check(yc(sp,e))},base64url(e){return this.check(bc(cp,e))},xid(e){return this.check(mc(ep,e))},ksuid(e){return this.check(hc(tp,e))},ipv4(e){return this.check(gc(rp,e))},ipv6(e){return this.check(_c(op,e))},cidrv4(e){return this.check(zc(np,e))},cidrv6(e){return this.check(xc(ip,e))},e164(e){return this.check(vc(ap,e))},datetime(e){return this.check(Tt(Eo,e))},date(e){return this.check(Xr(Ua,e))},time(e){return this.check(Yr(Ma,e))},duration(e){return this.check(Qr(Fa,e))}});function u(e){return rc(Da,e)}var L=f("ZodStringFormat",(e,t)=>{I.init(e,t),La.init(e,t)}),Eo=f("ZodISODateTime",(e,t)=>{ls.init(e,t),L.init(e,t)}),Ua=f("ZodISODate",(e,t)=>{ps.init(e,t),L.init(e,t)}),Ma=f("ZodISOTime",(e,t)=>{fs.init(e,t),L.init(e,t)}),Fa=f("ZodISODuration",(e,t)=>{ds.init(e,t),L.init(e,t)}),Kl=f("ZodEmail",(e,t)=>{Qi.init(e,t),L.init(e,t)});var Wl=f("ZodGUID",(e,t)=>{Xi.init(e,t),L.init(e,t)});var Bt=f("ZodUUID",(e,t)=>{Yi.init(e,t),L.init(e,t)});var Ba=f("ZodURL",(e,t)=>{rs.init(e,t),L.init(e,t)});function Ja(e){return Hr(Ba,e)}var Gl=f("ZodEmoji",(e,t)=>{os.init(e,t),L.init(e,t)});var Hl=f("ZodNanoID",(e,t)=>{ns.init(e,t),L.init(e,t)});var Xl=f("ZodCUID",(e,t)=>{is.init(e,t),L.init(e,t)});var Yl=f("ZodCUID2",(e,t)=>{ss.init(e,t),L.init(e,t)});var Ql=f("ZodULID",(e,t)=>{cs.init(e,t),L.init(e,t)});var ep=f("ZodXID",(e,t)=>{as.init(e,t),L.init(e,t)});var tp=f("ZodKSUID",(e,t)=>{us.init(e,t),L.init(e,t)});var rp=f("ZodIPv4",(e,t)=>{ms.init(e,t),L.init(e,t)});var op=f("ZodIPv6",(e,t)=>{gs.init(e,t),L.init(e,t)});var np=f("ZodCIDRv4",(e,t)=>{_s.init(e,t),L.init(e,t)});var ip=f("ZodCIDRv6",(e,t)=>{zs.init(e,t),L.init(e,t)});var sp=f("ZodBase64",(e,t)=>{ys.init(e,t),L.init(e,t)});var cp=f("ZodBase64URL",(e,t)=>{bs.init(e,t),L.init(e,t)});var ap=f("ZodE164",(e,t)=>{vs.init(e,t),L.init(e,t)});var up=f("ZodJWT",(e,t)=>{ws.init(e,t),L.init(e,t)});var qt=f("ZodNumber",(e,t)=>{Mr.init(e,t),T.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Yc(e,r,o,n),e.isFinite=!0},An({minValue:(e)=>{let{minimum:t,exclusiveMinimum:r}=ie(e);return Math.max(t??Number.NEGATIVE_INFINITY,r??Number.NEGATIVE_INFINITY)},maxValue:(e)=>{let{maximum:t,exclusiveMaximum:r}=ie(e);return Math.min(t??Number.POSITIVE_INFINITY,r??Number.POSITIVE_INFINITY)},isInt:(e)=>{let{isInt:t,multipleOf:r}=ie(e);return!!t||!!r?.some(Number.isSafeInteger)},format:(e)=>ie(e).format??null},{gt(e,t){return this.check(Et(e,t))},gte(e,t){return this.check(Ye(e,t))},min(e,t){return this.check(Ye(e,t))},lt(e,t){return this.check(At(e,t))},lte(e,t){return this.check(Xe(e,t))},max(e,t){return this.check(Xe(e,t))},int(e){return this.check(Aa(e))},safe(e){return this.check(Aa(e))},positive(e){return this.check(Et(0,e))},nonnegative(e){return this.check(Ye(0,e))},negative(e){return this.check(At(0,e))},nonpositive(e){return this.check(Xe(0,e))},multipleOf(e,t){return this.check(Nt(e,t))},step(e,t){return this.check(Nt(e,t))},finite(){return this}}));function w(e){return $c(qt,e)}var lp=f("ZodNumberFormat",(e,t)=>{$s.init(e,t),qt.init(e,t)});function Aa(e){return kc(lp,e)}var qa=f("ZodBoolean",(e,t)=>{Ss.init(e,t),T.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Qc(e,r,o,n)});function O(e){return Pc(qa,e)}var pp=f("ZodNull",(e,t)=>{ks.init(e,t),T.init(e,t),e._zod.processJSONSchema=(r,o,n)=>ea(e,r,o,n)});function Va(e){return Zc(pp,e)}var fp=f("ZodAny",(e,t)=>{Ps.init(e,t),T.init(e,t),e._zod.processJSONSchema=(r,o,n)=>ra(e,r,o,n)});function Ka(){return Oc(fp)}var dp=f("ZodUnknown",(e,t)=>{Zs.init(e,t),T.init(e,t),e._zod.processJSONSchema=(r,o,n)=>oa(e,r,o,n)});function N(){return Rc(dp)}var mp=f("ZodNever",(e,t)=>{Os.init(e,t),T.init(e,t),e._zod.processJSONSchema=(r,o,n)=>ta(e,r,o,n)});function hp(e){return Cc(mp,e)}var gp=f("ZodArray",(e,t)=>{Jt(),Rs.init(e,t),T.init(e,t),e._zod.processJSONSchema=(r,o,n)=>aa(e,r,o,n),e.element=t.element},{min(e,t){return this.check(Oe(e,t))},nonempty(e){return this.check(Oe(1,e))},max(e,t){return this.check(jt(e,t))},length(e,t){return this.check(Dt(e,t))},unwrap(){return this.element}});function _(e,t){return Ic(gp,e,t)}var Wa=f("ZodObject",(e,t)=>{Jt(),Ts.init(e,t),T.init(e,t),e._zod.processJSONSchema=(r,o,n)=>ua(e,r,o,n),Xu(e,"shape",(r)=>r._zod.def.shape,!1)},{keyof(){return Q(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(ee(this._zod.def,{catchall:e}))},passthrough(){return this.clone(ee(this._zod.def,{catchall:N()}))},loose(){return this.clone(ee(this._zod.def,{catchall:N()}))},strict(){return this.clone(ee(this._zod.def,{catchall:hp()}))},strip(){return this.clone(ee(this._zod.def,{catchall:void 0}))},extend(e){return Bu(this,e)},safeExtend(e){return Ju(this,e)},merge(e){return qu(this,e)},pick(e){return Mu(this,e)},omit(e){return Fu(this,e)},partial(...e){return Rn(Xa,this,e[0])},exactPartial(...e){return Rn(Ya,this,e[0],"exactPartial")},required(...e){return Vu(Qa,this,e[0])}});function z(e,t){let r={type:"object",shape:e??{},...x(t)};return new Wa(r)}function B(e,t){return new Wa({type:"object",shape:e,catchall:N(),...x(t)})}var Ga=f("ZodUnion",(e,t)=>{Fr.init(e,t),T.init(e,t),e._zod.processJSONSchema=(r,o,n)=>la(e,r,o,n),e.options=t.options});function E(e,t){return new Ga({type:"union",options:e,...x(t)})}var _p=f("ZodDiscriminatedUnion",(e,t)=>{Ga.init(e,t),As.init(e,t)});function No(e,t,r){return new _p({type:"union",options:t,discriminator:e,...x(r)})}var zp=f("ZodIntersection",(e,t)=>{Es.init(e,t),T.init(e,t),e._zod.processJSONSchema=(r,o,n)=>pa(e,r,o,n)});function Vt(e,t){return new zp({type:"intersection",left:e,right:t})}var Ea=f("ZodRecord",(e,t)=>{Jt(),Ns.init(e,t),T.init(e,t),e._zod.processJSONSchema=(r,o,n)=>fa(e,r,o,n),e.keyType=t.keyType,e.valueType=t.valueType});function C(e,t,r){if(!t||!t._zod)return new Ea({type:"record",keyType:u(),valueType:e,...x(t)});return new Ea({type:"record",keyType:e,valueType:t,...x(r)})}var Ao=f("ZodEnum",(e,t)=>{js.init(e,t),T.init(e,t),e._zod.processJSONSchema=(o,n,i)=>na(e,o,n,i),e.enum=t.entries,e.options=[...e._zod.values];let r=new Set(Object.keys(t.entries));e.extract=(o,n)=>{let i={};for(let s of o)if(r.has(s))i[s]=t.entries[s];else throw Error(`Key ${s} not found in enum`);return new Ao({...t,checks:[],...x(n),entries:i})},e.exclude=(o,n)=>{let i={...t.entries};for(let s of o)if(r.has(s))delete i[s];else throw Error(`Key ${s} not found in enum`);return new Ao({...t,checks:[],...x(n),entries:i})}});function Q(e,t){let r=Array.isArray(e)?Object.fromEntries(e.map((o)=>[o,o])):e;return new Ao({type:"enum",entries:r,...x(t)})}var xp=f("ZodLiteral",(e,t)=>{Ls.init(e,t),T.init(e,t),e._zod.processJSONSchema=(r,o,n)=>ia(e,r,o,n),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function y(e,t){return new xp({type:"literal",values:Array.isArray(e)?e:[e],...x(t)})}var yp=f("ZodTransform",(e,t)=>{Jt(),Ds.init(e,t),T.init(e,t),e._zod.processJSONSchema=(r,o,n)=>ca(e,r,o,n),e._zod.parse=(r,o)=>{if(o.direction==="backward")throw new qe(e.constructor.name);r.addIssue=(i)=>{if(typeof i==="string")r.issues.push(ke(i,r.value,t));else{let s=i;if(s.fatal)s.continue=!1;if(s.code??(s.code="custom"),!("input"in s))s.input=r.value;s.inst??(s.inst=e),r.issues.push(ke(s))}};let n=t.transform(r.value,r);if(n instanceof Promise)return n.then((i)=>(r.value=i,r));return r.value=n,r}});function Ha(e){return new yp({type:"transform",transform:e})}var Xa=f("ZodOptional",(e,t)=>{Br.init(e,t),T.init(e,t),e._zod.processJSONSchema=(r,o,n)=>To(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});function j(e){return new Xa({type:"optional",innerType:e})}var Ya=f("ZodExactOptional",(e,t)=>{Us.init(e,t),T.init(e,t),e._zod.processJSONSchema=(r,o,n)=>To(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});function bp(e){return new Ya({type:"optional",innerType:e})}var vp=f("ZodNullable",(e,t)=>{Ms.init(e,t),T.init(e,t),e._zod.processJSONSchema=(r,o,n)=>da(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});function Na(e){return new vp({type:"nullable",innerType:e})}var wp=f("ZodDefault",(e,t)=>{Fs.init(e,t),T.init(e,t),e._zod.processJSONSchema=(r,o,n)=>ga(e,r,o,n),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function $p(e,t){return new wp({type:"default",innerType:e,get defaultValue(){return typeof t==="function"?t():gr(t)}})}var Sp=f("ZodPrefault",(e,t)=>{Bs.init(e,t),T.init(e,t),e._zod.processJSONSchema=(r,o,n)=>_a(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});function kp(e,t){return new Sp({type:"prefault",innerType:e,get defaultValue(){return typeof t==="function"?t():gr(t)}})}var Qa=f("ZodNonOptional",(e,t)=>{Js.init(e,t),T.init(e,t),e._zod.processJSONSchema=(r,o,n)=>ma(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});function Pp(e,t){return new Qa({type:"nonoptional",innerType:e,...x(t)})}var Zp=f("ZodCatch",(e,t)=>{qs.init(e,t),T.init(e,t),e._zod.processJSONSchema=(r,o,n)=>za(e,r,o,n),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Op(e,t){return new Zp({type:"catch",innerType:e,catchValue:typeof t==="function"?t:En(t)})}var eu=f("ZodPipe",(e,t)=>{Jr.init(e,t),T.init(e,t),e._zod.processJSONSchema=(r,o,n)=>xa(e,r,o,n),e.in=t.in,e.out=t.out});function ja(e,t){return new eu({type:"pipe",in:e,out:t})}var Rp=f("ZodPreprocess",(e,t)=>{eu.init(e,t),Vs.init(e,t)}),Cp=f("ZodReadonly",(e,t)=>{Ks.init(e,t),T.init(e,t),e._zod.processJSONSchema=(r,o,n)=>ya(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});function Ip(e){return new Cp({type:"readonly",innerType:e})}var tu=f("ZodCustom",(e,t)=>{Ws.init(e,t),T.init(e,t),e._zod.processJSONSchema=(r,o,n)=>sa(e,r,o,n)});function ru(e,t){return Tc(tu,e??(()=>!0),t)}function Tp(e,t={}){return Ac(tu,e,t)}function Ap(e,t){return Ec(e,t)}function Lo(e,t){return new Rp({type:"pipe",in:Ha(e),out:t})}var nu={invalid_type:"invalid_type",too_big:"too_big",too_small:"too_small",invalid_format:"invalid_format",not_multiple_of:"not_multiple_of",unrecognized_keys:"unrecognized_keys",invalid_union:"invalid_union",invalid_key:"invalid_key",invalid_element:"invalid_element",invalid_value:"invalid_value",custom:"custom"};var ou;(function(e){})(ou||(ou={}));function Np(e){return Tt(Eo,e)}function jp(e){return Sc(qt,e)}var Qt="2025-11-25";var jo=[Qt,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],bt="io.modelcontextprotocol/related-task",Wt="2.0",J=ru((e)=>e!==null&&(typeof e==="object"||typeof e==="function")),cu=E([u(),w().int()]),au=u(),_g=B({ttl:w().optional(),pollInterval:w().optional()}),Dp=z({ttl:w().optional()}),Up=z({taskId:u()}),Do=B({progressToken:cu.optional(),[bt]:Up.optional()}),re=z({_meta:Do.optional()}),tt=re.extend({task:Dp.optional()}),Vo=(e)=>tt.safeParse(e).success,V=z({method:u(),params:re.loose().optional()}),se=z({_meta:Do.optional()}),ce=z({method:u(),params:se.loose().optional()}),K=B({_meta:Do.optional()}),Gt=E([u(),w().int()]),uu=z({jsonrpc:y(Wt),id:Gt,...V.shape}).strict(),_r=(e)=>uu.safeParse(e).success,lu=z({jsonrpc:y(Wt),...ce.shape}).strict(),Ko=(e)=>lu.safeParse(e).success,Uo=z({jsonrpc:y(Wt),id:Gt,result:K}).strict(),Ct=(e)=>Uo.safeParse(e).success;var A;(function(e){e[e.ConnectionClosed=-32000]="ConnectionClosed",e[e.RequestTimeout=-32001]="RequestTimeout",e[e.ParseError=-32700]="ParseError",e[e.InvalidRequest=-32600]="InvalidRequest",e[e.MethodNotFound=-32601]="MethodNotFound",e[e.InvalidParams=-32602]="InvalidParams",e[e.InternalError=-32603]="InternalError",e[e.UrlElicitationRequired=-32042]="UrlElicitationRequired"})(A||(A={}));var Mo=z({jsonrpc:y(Wt),id:Gt.optional(),error:z({code:w().int(),message:u(),data:N().optional()})}).strict();var Qo=(e)=>Mo.safeParse(e).success;var St=E([uu,lu,Uo,Mo]),zg=E([Uo,Mo]),Mt=K.strict(),Mp=se.extend({requestId:Gt.optional(),reason:u().optional()}),en=ce.extend({method:y("notifications/cancelled"),params:Mp}),Fp=z({src:u(),mimeType:u().optional(),sizes:_(u()).optional(),theme:Q(["light","dark"]).optional()}),rt=z({icons:_(Fp).optional()}),Te=z({name:u(),title:u().optional()}),pu=Te.extend({...Te.shape,...rt.shape,version:u(),websiteUrl:u().optional(),description:u().optional()}),Bp=Vt(z({applyDefaults:O().optional()}),C(u(),N())),Jp=Lo((e)=>{if(e&&typeof e==="object"&&!Array.isArray(e)){if(Object.keys(e).length===0)return{form:{}}}return e},Vt(z({form:Bp.optional(),url:J.optional()}),C(u(),N()).optional())),qp=B({list:J.optional(),cancel:J.optional(),requests:B({sampling:B({createMessage:J.optional()}).optional(),elicitation:B({create:J.optional()}).optional()}).optional()}),Vp=B({list:J.optional(),cancel:J.optional(),requests:B({tools:B({call:J.optional()}).optional()}).optional()}),Kp=z({experimental:C(u(),J).optional(),sampling:z({context:J.optional(),tools:J.optional()}).optional(),elicitation:Jp.optional(),roots:z({listChanged:O().optional()}).optional(),tasks:qp.optional(),extensions:C(u(),J).optional()}),Wp=re.extend({protocolVersion:u(),capabilities:Kp,clientInfo:pu}),Gp=V.extend({method:y("initialize"),params:Wp});var Hp=z({experimental:C(u(),J).optional(),logging:J.optional(),completions:J.optional(),prompts:z({listChanged:O().optional()}).optional(),resources:z({subscribe:O().optional(),listChanged:O().optional()}).optional(),tools:z({listChanged:O().optional()}).optional(),tasks:Vp.optional(),extensions:C(u(),J).optional()}),Zn=K.extend({protocolVersion:u(),capabilities:Hp,serverInfo:pu,instructions:u().optional()}),fu=ce.extend({method:y("notifications/initialized"),params:se.optional()}),Yo=(e)=>fu.safeParse(e).success,tn=V.extend({method:y("ping"),params:re.optional()}),Xp=z({progress:w(),total:j(w()),message:j(u())}),Yp=z({...se.shape,...Xp.shape,progressToken:cu}),rn=ce.extend({method:y("notifications/progress"),params:Yp}),Qp=re.extend({cursor:au.optional()}),ot=V.extend({params:Qp.optional()}),nt=K.extend({nextCursor:au.optional()}),ef=Q(["working","input_required","completed","failed","cancelled"]),it=z({taskId:u(),status:ef,ttl:E([w(),Va()]),createdAt:u(),lastUpdatedAt:u(),pollInterval:j(w()),statusMessage:j(u())}),Lt=K.extend({task:it}),tf=se.merge(it),Pr=ce.extend({method:y("notifications/tasks/status"),params:tf}),nn=V.extend({method:y("tasks/get"),params:re.extend({taskId:u()})}),on=K.merge(it),sn=V.extend({method:y("tasks/result"),params:re.extend({taskId:u()})}),xg=K.loose(),an=ot.extend({method:y("tasks/list")}),ln=nt.extend({tasks:_(it)}),cn=V.extend({method:y("tasks/cancel"),params:re.extend({taskId:u()})}),Xo=K.merge(it),du=z({uri:u(),mimeType:j(u()),_meta:C(u(),N()).optional()}),mu=du.extend({text:u()}),Fo=u().refine((e)=>{try{return atob(e),!0}catch{return!1}},{message:"Invalid Base64 string"}),hu=du.extend({blob:Fo}),st=Q(["user","assistant"]),Ae=z({audience:_(st).optional(),priority:w().min(0).max(1).optional(),lastModified:Np({offset:!0}).optional()}),gu=z({...Te.shape,...rt.shape,uri:u(),description:j(u()),mimeType:j(u()),size:j(w()),annotations:Ae.optional(),_meta:j(B({}))}),rf=z({...Te.shape,...rt.shape,uriTemplate:u(),description:j(u()),mimeType:j(u()),annotations:Ae.optional(),_meta:j(B({}))}),of=ot.extend({method:y("resources/list")}),eo=nt.extend({resources:_(gu)}),nf=ot.extend({method:y("resources/templates/list")}),to=nt.extend({resourceTemplates:_(rf)}),Bo=re.extend({uri:u()}),sf=Bo,cf=V.extend({method:y("resources/read"),params:sf}),ro=K.extend({contents:_(E([mu,hu]))}),no=ce.extend({method:y("notifications/resources/list_changed"),params:se.optional()}),af=Bo,uf=V.extend({method:y("resources/subscribe"),params:af}),lf=Bo,pf=V.extend({method:y("resources/unsubscribe"),params:lf}),ff=se.extend({uri:u()}),df=ce.extend({method:y("notifications/resources/updated"),params:ff}),mf=z({name:u(),description:j(u()),required:j(O())}),hf=z({...Te.shape,...rt.shape,description:j(u()),arguments:j(_(mf)),_meta:j(B({}))}),gf=ot.extend({method:y("prompts/list")}),oo=nt.extend({prompts:_(hf)}),_f=re.extend({name:u(),arguments:C(u(),u()).optional()}),zf=V.extend({method:y("prompts/get"),params:_f}),qo=z({type:y("text"),text:u(),annotations:Ae.optional(),_meta:C(u(),N()).optional()}),Wo=z({type:y("image"),data:Fo,mimeType:u(),annotations:Ae.optional(),_meta:C(u(),N()).optional()}),Go=z({type:y("audio"),data:Fo,mimeType:u(),annotations:Ae.optional(),_meta:C(u(),N()).optional()}),xf=z({type:y("tool_use"),name:u(),id:u(),input:C(u(),N()),_meta:C(u(),N()).optional()}),yf=z({type:y("resource"),resource:E([mu,hu]),annotations:Ae.optional(),_meta:C(u(),N()).optional()}),bf=gu.extend({type:y("resource_link")}),Ho=E([qo,Wo,Go,bf,yf]),vf=z({role:st,content:Ho}),io=K.extend({description:u().optional(),messages:_(vf)}),so=ce.extend({method:y("notifications/prompts/list_changed"),params:se.optional()}),wf=z({title:u().optional(),readOnlyHint:O().optional(),destructiveHint:O().optional(),idempotentHint:O().optional(),openWorldHint:O().optional()}),$f=z({taskSupport:Q(["required","optional","forbidden"]).optional()}),_u=z({...Te.shape,...rt.shape,description:u().optional(),inputSchema:z({type:y("object"),properties:C(u(),J).optional(),required:_(u()).optional()}).catchall(N()),outputSchema:z({type:y("object"),properties:C(u(),J).optional(),required:_(u()).optional()}).catchall(N()).optional(),annotations:wf.optional(),execution:$f.optional(),_meta:C(u(),N()).optional()}),Sf=ot.extend({method:y("tools/list")}),ao=nt.extend({tools:_(_u)}),lt=K.extend({content:_(Ho).default([]),structuredContent:C(u(),N()).optional(),isError:O().optional()}),yg=lt.or(K.extend({toolResult:N()})),kf=tt.extend({name:u(),arguments:C(u(),N()).optional()}),Pf=V.extend({method:y("tools/call"),params:kf}),Tr=ce.extend({method:y("notifications/tools/list_changed"),params:se.optional()}),Jo=z({autoRefresh:O().default(!0),debounceMs:w().int().nonnegative().default(300)}),zu=Q(["debug","info","notice","warning","error","critical","alert","emergency"]),Zf=re.extend({level:zu}),Of=V.extend({method:y("logging/setLevel"),params:Zf}),Rf=se.extend({level:zu,logger:u().optional(),data:N()}),Cf=ce.extend({method:y("notifications/message"),params:Rf}),If=z({name:u().optional()}),Tf=z({hints:_(If).optional(),costPriority:w().min(0).max(1).optional(),speedPriority:w().min(0).max(1).optional(),intelligencePriority:w().min(0).max(1).optional()}),Af=z({mode:Q(["auto","required","none"]).optional()}),Ef=z({type:y("tool_result"),toolUseId:u().describe("The unique identifier for the corresponding tool call."),content:_(Ho).default([]),structuredContent:z({}).loose().optional(),isError:O().optional(),_meta:C(u(),N()).optional()}),Nf=No("type",[qo,Wo,Go]),Kt=No("type",[qo,Wo,Go,xf,Ef]),jf=z({role:st,content:E([Kt,_(Kt)]),_meta:C(u(),N()).optional()}),Lf=tt.extend({messages:_(jf),modelPreferences:Tf.optional(),systemPrompt:u().optional(),includeContext:Q(["none","thisServer","allServers"]).optional(),temperature:w().optional(),maxTokens:w().int(),stopSequences:_(u()).optional(),metadata:J.optional(),tools:_(_u).optional(),toolChoice:Af.optional()}),lo=V.extend({method:y("sampling/createMessage"),params:Lf}),co=K.extend({model:u(),stopReason:j(Q(["endTurn","stopSequence","maxTokens"]).or(u())),role:st,content:Nf}),uo=K.extend({model:u(),stopReason:j(Q(["endTurn","stopSequence","maxTokens","toolUse"]).or(u())),role:st,content:E([Kt,_(Kt)])}),Df=z({type:y("boolean"),title:u().optional(),description:u().optional(),default:O().optional()}),Uf=z({type:y("string"),title:u().optional(),description:u().optional(),minLength:w().optional(),maxLength:w().optional(),format:Q(["email","uri","date","date-time"]).optional(),default:u().optional()}),Mf=z({type:Q(["number","integer"]),title:u().optional(),description:u().optional(),minimum:w().optional(),maximum:w().optional(),default:w().optional()}),Ff=z({type:y("string"),title:u().optional(),description:u().optional(),enum:_(u()),default:u().optional()}),Bf=z({type:y("string"),title:u().optional(),description:u().optional(),oneOf:_(z({const:u(),title:u()})),default:u().optional()}),Jf=z({type:y("string"),title:u().optional(),description:u().optional(),enum:_(u()),enumNames:_(u()).optional(),default:u().optional()}),qf=E([Ff,Bf]),Vf=z({type:y("array"),title:u().optional(),description:u().optional(),minItems:w().optional(),maxItems:w().optional(),items:z({type:y("string"),enum:_(u())}),default:_(u()).optional()}),Kf=z({type:y("array"),title:u().optional(),description:u().optional(),minItems:w().optional(),maxItems:w().optional(),items:z({anyOf:_(z({const:u(),title:u()}))}),default:_(u()).optional()}),Wf=E([Vf,Kf]),Gf=E([Jf,qf,Wf]),Hf=E([Gf,Df,Uf,Mf]),Xf=tt.extend({mode:y("form").optional(),message:u(),requestedSchema:z({type:y("object"),properties:C(u(),Hf),required:_(u()).optional()})}),Yf=tt.extend({mode:y("url"),message:u(),elicitationId:u(),url:u().url()}),Qf=E([Xf,Yf]),po=V.extend({method:y("elicitation/create"),params:Qf}),ed=se.extend({elicitationId:u()}),td=ce.extend({method:y("notifications/elicitation/complete"),params:ed}),mo=K.extend({action:Q(["accept","decline","cancel"]),content:Lo((e)=>e===null?void 0:e,C(u(),E([u(),w(),O(),_(u())])).optional())}),rd=z({type:y("ref/resource"),uri:u()});var od=z({type:y("ref/prompt"),name:u()}),nd=re.extend({ref:E([od,rd]),argument:z({name:u(),value:u()}),context:z({arguments:C(u(),u()).optional()}).optional()}),id=V.extend({method:y("completion/complete"),params:nd});var ho=K.extend({completion:B({values:_(u()).max(100),total:j(w().int()),hasMore:j(O())})}),sd=z({uri:u().startsWith("file://"),name:u().optional(),_meta:C(u(),N()).optional()}),cd=V.extend({method:y("roots/list"),params:re.optional()}),ad=K.extend({roots:_(sd)}),ud=ce.extend({method:y("notifications/roots/list_changed"),params:se.optional()}),bg=E([tn,Gp,id,Of,zf,gf,of,nf,cf,uf,pf,Pf,Sf,nn,sn,an,cn]),vg=E([en,rn,fu,ud,Pr]),wg=E([Mt,co,uo,mo,ad,on,ln,Lt]),$g=E([tn,lo,po,cd,nn,sn,an,cn]),Sg=E([en,rn,Cf,df,no,Tr,so,Pr,td]),kg=E([Mt,Zn,ho,io,oo,eo,to,ro,lt,ao,on,ln,Lt]);class S extends Error{constructor(e,t,r){super(`MCP error ${e}: ${t}`);this.code=e,this.data=r,this.name="McpError"}static fromError(e,t,r){if(e===A.UrlElicitationRequired&&r){let o=r;if(o.elicitations)return new xu(o.elicitations,t)}return new S(e,t,r)}}class xu extends S{constructor(e,t=`URL elicitation${e.length>1?"s":""} required`){super(A.UrlElicitationRequired,t,{elicitations:e})}get elicitations(){return this.data?.elicitations??[]}}var W=Ja().superRefine((e,t)=>{if(!URL.canParse(e))return t.addIssue({code:nu.custom,message:"URL must be parseable",fatal:!0}),vr}).refine((e)=>{let t=new URL(e);return t.protocol!=="javascript:"&&t.protocol!=="data:"&&t.protocol!=="vbscript:"},{message:"URL cannot use javascript:, data:, or vbscript: scheme"}),bu=B({resource:u().url(),authorization_servers:_(W).optional(),jwks_uri:u().url().optional(),scopes_supported:_(u()).optional(),bearer_methods_supported:_(u()).optional(),resource_signing_alg_values_supported:_(u()).optional(),resource_name:u().optional(),resource_documentation:u().optional(),resource_policy_uri:u().url().optional(),resource_tos_uri:u().url().optional(),tls_client_certificate_bound_access_tokens:O().optional(),authorization_details_types_supported:_(u()).optional(),dpop_signing_alg_values_supported:_(u()).optional(),dpop_bound_access_tokens_required:O().optional()}),un=B({issuer:u(),authorization_endpoint:W,token_endpoint:W,registration_endpoint:W.optional(),scopes_supported:_(u()).optional(),response_types_supported:_(u()),response_modes_supported:_(u()).optional(),grant_types_supported:_(u()).optional(),token_endpoint_auth_methods_supported:_(u()).optional(),token_endpoint_auth_signing_alg_values_supported:_(u()).optional(),service_documentation:W.optional(),revocation_endpoint:W.optional(),revocation_endpoint_auth_methods_supported:_(u()).optional(),revocation_endpoint_auth_signing_alg_values_supported:_(u()).optional(),introspection_endpoint:u().optional(),introspection_endpoint_auth_methods_supported:_(u()).optional(),introspection_endpoint_auth_signing_alg_values_supported:_(u()).optional(),code_challenge_methods_supported:_(u()).optional(),client_id_metadata_document_supported:O().optional()}),ld=B({issuer:u(),authorization_endpoint:W,token_endpoint:W,userinfo_endpoint:W.optional(),jwks_uri:W,registration_endpoint:W.optional(),scopes_supported:_(u()).optional(),response_types_supported:_(u()),response_modes_supported:_(u()).optional(),grant_types_supported:_(u()).optional(),acr_values_supported:_(u()).optional(),subject_types_supported:_(u()),id_token_signing_alg_values_supported:_(u()),id_token_encryption_alg_values_supported:_(u()).optional(),id_token_encryption_enc_values_supported:_(u()).optional(),userinfo_signing_alg_values_supported:_(u()).optional(),userinfo_encryption_alg_values_supported:_(u()).optional(),userinfo_encryption_enc_values_supported:_(u()).optional(),request_object_signing_alg_values_supported:_(u()).optional(),request_object_encryption_alg_values_supported:_(u()).optional(),request_object_encryption_enc_values_supported:_(u()).optional(),token_endpoint_auth_methods_supported:_(u()).optional(),token_endpoint_auth_signing_alg_values_supported:_(u()).optional(),display_values_supported:_(u()).optional(),claim_types_supported:_(u()).optional(),claims_supported:_(u()).optional(),service_documentation:u().optional(),claims_locales_supported:_(u()).optional(),ui_locales_supported:_(u()).optional(),claims_parameter_supported:O().optional(),request_parameter_supported:O().optional(),request_uri_parameter_supported:O().optional(),require_request_uri_registration:O().optional(),op_policy_uri:W.optional(),op_tos_uri:W.optional(),client_id_metadata_document_supported:O().optional()}),vu=z({...ld.shape,...un.pick({code_challenge_methods_supported:!0}).shape}),wu=z({access_token:u(),id_token:u().optional(),token_type:u(),expires_in:jp().optional(),scope:u().optional(),refresh_token:u().optional()}).strip(),$u=z({error:u(),error_description:u().optional(),error_uri:u().optional()}),yu=W.optional().or(y("").transform(()=>{return})),pd=z({redirect_uris:_(W),token_endpoint_auth_method:u().optional(),grant_types:_(u()).optional(),response_types:_(u()).optional(),client_name:u().optional(),client_uri:W.optional(),logo_uri:yu,scope:u().optional(),contacts:_(u()).optional(),tos_uri:yu,policy_uri:u().optional(),jwks_uri:W.optional(),jwks:Ka().optional(),software_id:u().optional(),software_version:u().optional(),software_statement:u().optional()}).strip(),fd=z({client_id:u(),client_secret:u().optional(),client_id_issued_at:w().optional(),client_secret_expires_at:w().optional()}).strip(),Su=pd.merge(fd),Zg=z({error:u(),error_description:u().optional()}).strip(),Og=z({token:u(),token_type_hint:u().optional()}).strip();function ku(e){let t=typeof e==="string"?new URL(e):new URL(e.href);return t.hash="",t}function Pu({requestedResource:e,configuredResource:t}){let r=typeof e==="string"?new URL(e):new URL(e.href),o=typeof t==="string"?new URL(t):new URL(t.href);if(r.origin!==o.origin)return!1;if(r.pathname.length<o.pathname.length)return!1;let n=r.pathname.endsWith("/")?r.pathname:r.pathname+"/",i=o.pathname.endsWith("/")?o.pathname:o.pathname+"/";return n.startsWith(i)}class M extends Error{constructor(e,t){super(e);this.errorUri=t,this.name=this.constructor.name}toResponseObject(){let e={error:this.errorCode,error_description:this.message};if(this.errorUri)e.error_uri=this.errorUri;return e}get errorCode(){return this.constructor.errorCode}}class Ht extends M{}Ht.errorCode="invalid_request";class Ee extends M{}Ee.errorCode="invalid_client";class Ne extends M{}Ne.errorCode="invalid_grant";class je extends M{}je.errorCode="unauthorized_client";class Xt extends M{}Xt.errorCode="unsupported_grant_type";class Yt extends M{}Yt.errorCode="invalid_scope";class er extends M{}er.errorCode="access_denied";class we extends M{}we.errorCode="server_error";class tr extends M{}tr.errorCode="temporarily_unavailable";class rr extends M{}rr.errorCode="unsupported_response_type";class or extends M{}or.errorCode="unsupported_token_type";class nr extends M{}nr.errorCode="invalid_token";class ir extends M{}ir.errorCode="method_not_allowed";class sr extends M{}sr.errorCode="too_many_requests";class Le extends M{}Le.errorCode="invalid_client_metadata";class cr extends M{}cr.errorCode="insufficient_scope";class ar extends M{}ar.errorCode="invalid_target";var Zu={[Ht.errorCode]:Ht,[Ee.errorCode]:Ee,[Ne.errorCode]:Ne,[je.errorCode]:je,[Xt.errorCode]:Xt,[Yt.errorCode]:Yt,[er.errorCode]:er,[we.errorCode]:we,[tr.errorCode]:tr,[rr.errorCode]:rr,[or.errorCode]:or,[nr.errorCode]:nr,[ir.errorCode]:ir,[sr.errorCode]:sr,[Le.errorCode]:Le,[cr.errorCode]:cr,[ar.errorCode]:ar};class pe extends Error{constructor(e){super(e??"Unauthorized")}}function dd(e){return["client_secret_basic","client_secret_post","none"].includes(e)}var pn="code",fn="S256";function md(e,t){let r=e.client_secret!==void 0;if("token_endpoint_auth_method"in e&&e.token_endpoint_auth_method&&dd(e.token_endpoint_auth_method)&&(t.length===0||t.includes(e.token_endpoint_auth_method)))return e.token_endpoint_auth_method;if(t.length===0)return r?"client_secret_basic":"none";if(r&&t.includes("client_secret_basic"))return"client_secret_basic";if(r&&t.includes("client_secret_post"))return"client_secret_post";if(t.includes("none"))return"none";return r?"client_secret_post":"none"}function hd(e,t,r,o){let{client_id:n,client_secret:i}=t;switch(e){case"client_secret_basic":gd(n,i,r);return;case"client_secret_post":_d(n,i,o);return;case"none":zd(n,o);return;default:throw Error(`Unsupported client authentication method: ${e}`)}}function gd(e,t,r){if(!t)throw Error("client_secret_basic authentication requires a client_secret");let o=btoa(`${e}:${t}`);r.set("Authorization",`Basic ${o}`)}function _d(e,t,r){if(r.set("client_id",e),t)r.set("client_secret",t)}function zd(e,t){t.set("client_id",e)}async function Ru(e){let t=e instanceof Response?e.status:void 0,r=e instanceof Response?await e.text():e;try{let o=$u.parse(JSON.parse(r)),{error:n,error_description:i,error_uri:s}=o;return new(Zu[n]||we)(i||"",s)}catch(o){let n=`${t?`HTTP ${t}: `:""}Invalid OAuth error response: ${o}. Raw body: ${r}`;return new we(n)}}async function Be(e,t){try{return await dn(e,t)}catch(r){if(r instanceof Ee||r instanceof je)return await e.invalidateCredentials?.("all"),await dn(e,t);else if(r instanceof Ne)return await e.invalidateCredentials?.("tokens"),await dn(e,t);throw r}}async function dn(e,{serverUrl:t,authorizationCode:r,scope:o,resourceMetadataUrl:n,fetchFn:i}){let s=await e.discoveryState?.(),c,a,l,p=n;if(!p&&s?.resourceMetadataUrl)p=new URL(s.resourceMetadataUrl);if(s?.authorizationServerUrl){if(a=s.authorizationServerUrl,c=s.resourceMetadata,l=s.authorizationServerMetadata??await Iu(a,{fetchFn:i}),!c)try{c=await Cu(t,{resourceMetadataUrl:p},i)}catch{}if(l!==s.authorizationServerMetadata||c!==s.resourceMetadata)await e.saveDiscoveryState?.({authorizationServerUrl:String(a),resourceMetadataUrl:p?.toString(),resourceMetadata:c,authorizationServerMetadata:l})}else{let F=await Sd(t,{resourceMetadataUrl:p,fetchFn:i});a=F.authorizationServerUrl,l=F.authorizationServerMetadata,c=F.resourceMetadata,await e.saveDiscoveryState?.({authorizationServerUrl:String(a),resourceMetadataUrl:p?.toString(),resourceMetadata:c,authorizationServerMetadata:l})}let d=await yd(t,e,c),h=o||c?.scopes_supported?.join(" ")||e.clientMetadata.scope,m=await Promise.resolve(e.clientInformation());if(!m){if(r!==void 0)throw Error("Existing OAuth client information is required when exchanging an authorization code");let F=l?.client_id_metadata_document_supported===!0,ae=e.clientMetadataUrl;if(ae&&!xd(ae))throw new Le(`clientMetadataUrl must be a valid HTTPS URL with a non-root pathname, got: ${ae}`);if(F&&ae)m={client_id:ae},await e.saveClientInformation?.(m);else{if(!e.saveClientInformation)throw Error("OAuth client information must be saveable for dynamic registration");let Z=await Rd(a,{metadata:l,clientMetadata:e.clientMetadata,scope:h,fetchFn:i});await e.saveClientInformation(Z),m=Z}}let g=!e.redirectUrl;if(r!==void 0||g){let F=await Od(e,a,{metadata:l,resource:d,authorizationCode:r,fetchFn:i});return await e.saveTokens(F),"AUTHORIZED"}let b=await e.tokens();if(b?.refresh_token)try{let F=await Zd(a,{metadata:l,clientInformation:m,refreshToken:b.refresh_token,resource:d,addClientAuthentication:e.addClientAuthentication,fetchFn:i});return await e.saveTokens(F),"AUTHORIZED"}catch(F){if(!(F instanceof M)||F instanceof we);else throw F}let v=e.state?await e.state():void 0,{authorizationUrl:P,codeVerifier:H}=await kd(a,{metadata:l,clientInformation:m,state:v,redirectUrl:e.redirectUrl,scope:h,resource:d});return await e.saveCodeVerifier(H),await e.redirectToAuthorization(P),"REDIRECT"}function xd(e){if(!e)return!1;try{let t=new URL(e);return t.protocol==="https:"&&t.pathname!=="/"}catch{return!1}}async function yd(e,t,r){let o=ku(e);if(t.validateResourceURL)return await t.validateResourceURL(o,r?.resource);if(!r)return;if(!Pu({requestedResource:o,configuredResource:r.resource}))throw Error(`Protected resource ${r.resource} does not match expected ${o} (or origin)`);return new URL(r.resource)}function Ot(e){let t=e.headers.get("WWW-Authenticate");if(!t)return{};let[r,o]=t.split(" ");if(r.toLowerCase()!=="bearer"||!o)return{};let n=mn(e,"resource_metadata")||void 0,i;if(n)try{i=new URL(n)}catch{}let s=mn(e,"scope")||void 0,c=mn(e,"error")||void 0;return{resourceMetadataUrl:i,scope:s,error:c}}function mn(e,t){let r=e.headers.get("WWW-Authenticate");if(!r)return null;let o=new RegExp(`${t}=(?:"([^"]+)"|([^\\s,]+))`),n=r.match(o);if(n)return n[1]||n[2];return null}async function Cu(e,t,r=fetch){let o=await wd(e,"oauth-protected-resource",r,{protocolVersion:t?.protocolVersion,metadataUrl:t?.resourceMetadataUrl});if(!o||o.status===404)throw await o?.body?.cancel(),Error("Resource server does not implement OAuth 2.0 Protected Resource Metadata.");if(!o.ok)throw await o.body?.cancel(),Error(`HTTP ${o.status} trying to load well-known OAuth protected resource metadata.`);return bu.parse(await o.json())}async function hn(e,t,r=fetch){try{return await r(e,{headers:t})}catch(o){if(o instanceof TypeError)if(t)return hn(e,void 0,r);else return;throw o}}function bd(e,t="",r={}){if(t.endsWith("/"))t=t.slice(0,-1);return r.prependPathname?`${t}/.well-known/${e}`:`/.well-known/${e}${t}`}async function Ou(e,t,r=fetch){return await hn(e,{"MCP-Protocol-Version":t},r)}function vd(e,t){return!e||e.status>=400&&e.status<500&&t!=="/"}async function wd(e,t,r,o){let n=new URL(e),i=o?.protocolVersion??Qt,s;if(o?.metadataUrl)s=new URL(o.metadataUrl);else{let a=bd(t,n.pathname);s=new URL(a,o?.metadataServerUrl??n),s.search=n.search}let c=await Ou(s,i,r);if(!o?.metadataUrl&&vd(c,n.pathname)){let a=new URL(`/.well-known/${t}`,n);c=await Ou(a,i,r)}return c}function $d(e){let t=typeof e==="string"?new URL(e):e,r=t.pathname!=="/",o=[];if(!r)return o.push({url:new URL("/.well-known/oauth-authorization-server",t.origin),type:"oauth"}),o.push({url:new URL("/.well-known/openid-configuration",t.origin),type:"oidc"}),o;let n=t.pathname;if(n.endsWith("/"))n=n.slice(0,-1);return o.push({url:new URL(`/.well-known/oauth-authorization-server${n}`,t.origin),type:"oauth"}),o.push({url:new URL(`/.well-known/openid-configuration${n}`,t.origin),type:"oidc"}),o.push({url:new URL(`${n}/.well-known/openid-configuration`,t.origin),type:"oidc"}),o}async function Iu(e,{fetchFn:t=fetch,protocolVersion:r=Qt}={}){let o={"MCP-Protocol-Version":r,Accept:"application/json"},n=$d(e);for(let{url:i,type:s}of n){let c=await hn(i,o,t);if(!c)continue;if(!c.ok){if(await c.body?.cancel(),c.status>=400&&c.status<500)continue;throw Error(`HTTP ${c.status} trying to load ${s==="oauth"?"OAuth":"OpenID provider"} metadata from ${i}`)}if(s==="oauth")return un.parse(await c.json());else return vu.parse(await c.json())}return}async function Sd(e,t){let r,o;try{if(r=await Cu(e,{resourceMetadataUrl:t?.resourceMetadataUrl},t?.fetchFn),r.authorization_servers&&r.authorization_servers.length>0)o=r.authorization_servers[0]}catch{}if(!o)o=String(new URL("/",e));let n=await Iu(o,{fetchFn:t?.fetchFn});return{authorizationServerUrl:o,authorizationServerMetadata:n,resourceMetadata:r}}async function kd(e,{metadata:t,clientInformation:r,redirectUrl:o,scope:n,state:i,resource:s}){let c;if(t){if(c=new URL(t.authorization_endpoint),!t.response_types_supported.includes(pn))throw Error(`Incompatible auth server: does not support response type ${pn}`);if(t.code_challenge_methods_supported&&!t.code_challenge_methods_supported.includes(fn))throw Error(`Incompatible auth server: does not support code challenge method ${fn}`)}else c=new URL("/authorize",e);let a=await fr(),{code_verifier:l,code_challenge:p}=a;if(c.searchParams.set("response_type",pn),c.searchParams.set("client_id",r.client_id),c.searchParams.set("code_challenge",p),c.searchParams.set("code_challenge_method",fn),c.searchParams.set("redirect_uri",String(o)),i)c.searchParams.set("state",i);if(n)c.searchParams.set("scope",n);if(n?.includes("offline_access"))c.searchParams.append("prompt","consent");if(s)c.searchParams.set("resource",s.href);return{authorizationUrl:c,codeVerifier:l}}function Pd(e,t,r){return new URLSearchParams({grant_type:"authorization_code",code:e,code_verifier:t,redirect_uri:String(r)})}async function Tu(e,{metadata:t,tokenRequestParams:r,clientInformation:o,addClientAuthentication:n,resource:i,fetchFn:s}){let c=t?.token_endpoint?new URL(t.token_endpoint):new URL("/token",e),a=new Headers({"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"});if(i)r.set("resource",i.href);if(n)await n(a,r,c,t);else if(o){let p=t?.token_endpoint_auth_methods_supported??[],d=md(o,p);hd(d,o,a,r)}let l=await(s??fetch)(c,{method:"POST",headers:a,body:r});if(!l.ok)throw await Ru(l);return wu.parse(await l.json())}async function Zd(e,{metadata:t,clientInformation:r,refreshToken:o,resource:n,addClientAuthentication:i,fetchFn:s}){let c=new URLSearchParams({grant_type:"refresh_token",refresh_token:o}),a=await Tu(e,{metadata:t,tokenRequestParams:c,clientInformation:r,addClientAuthentication:i,resource:n,fetchFn:s});return{refresh_token:o,...a}}async function Od(e,t,{metadata:r,resource:o,authorizationCode:n,fetchFn:i}={}){let s=e.clientMetadata.scope,c;if(e.prepareTokenRequest)c=await e.prepareTokenRequest(s);if(!c){if(!n)throw Error("Either provider.prepareTokenRequest() or authorizationCode is required");if(!e.redirectUrl)throw Error("redirectUrl is required for authorization_code flow");let l=await e.codeVerifier();c=Pd(n,l,e.redirectUrl)}let a=await e.clientInformation();return Tu(t,{metadata:r,tokenRequestParams:c,clientInformation:a??void 0,addClientAuthentication:e.addClientAuthentication,resource:o,fetchFn:i})}async function Rd(e,{metadata:t,clientMetadata:r,scope:o,fetchFn:n}){let i;if(t){if(!t.registration_endpoint)throw Error("Incompatible auth server: does not support dynamic client registration");i=new URL(t.registration_endpoint)}else i=new URL("/register",e);let s=await(n??fetch)(i,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...r,...o!==void 0?{scope:o}:{}})});if(!s.ok)throw await Ru(s);return Su.parse(await s.json())}
59
+ export{Jn,Qt,jo,bt,Vo,_r,Ko,Ct,A,Qo,St,Mt,en,Zn,Yo,tn,rn,Lt,Pr,nn,on,sn,an,ln,cn,Xo,eo,to,ro,no,oo,io,so,ao,lt,Tr,Jo,lo,co,uo,po,mo,ho,S,pe,Be,Ot};
@@ -0,0 +1,3 @@
1
+ // @bun
2
+ import{f}from"./chunk-7yw8aa5j.js";import{_}from"./chunk-hat3s3pr.js";import"./chunk-c25s4w6a.js";import{st,Xe,at}from"./chunk-g2k3yhgh.js";import{He}from"./chunk-ve7qx8wm.js";import{At,Et}from"./chunk-r9aatvwm.js";import{q,j}from"./chunk-y69ewdn2.js";import{Ee,ct,V,ee}from"./chunk-rjdhaasf.js";import{ie}from"./chunk-d48bfd2e.js";import{z}from"./chunk-dakrpbe6.js";import{te,ge,ye,H}from"./chunk-sf13azm4.js";import{M}from"./chunk-0rya8cxe.js";var P=new Set(["openai","openai-codex","opencode"]),O=16,E="https://chatgpt.com/settings/usage";function I(e,s){return e.provider==="openai"&&e.baseUrl==="https://api.openai.com/v1"&&s!==void 0&&!s.startsWith("sk-")}function T(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 v(e,s,r){if(s)return s;if(T(r,"authorization")||T(r,"cf-aig-authorization"))return"unused";throw Error(`No API key for provider: ${e}`)}function w(e){return e.provider==="openrouter"||e.baseUrl.includes("openrouter.ai")?"openrouter":"openai"}function R(e,s){if(e)return e;if(_("PI_CACHE_RETENTION",s)==="long")return"long";return"short"}function m(e){return{supportsDeveloperRole:e.compat?.supportsDeveloperRole??!0,supportsMidConvoSystemMessages:e.compat?.supportsMidConvoSystemMessages??!1,sessionAffinityFormat:e.compat?.sessionAffinityFormat??w(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 x(e,s){return s==="long"&&e.supportsLongCacheRetention&&!e.supportsExplicitPromptCacheMode?"24h":void 0}function b(e,s){if(!e.supportsExplicitPromptCacheMode)return;if(s==="none")return{mode:"explicit"};if(s==="long"&&e.supportsLongCacheRetention)return{ttl:"30m"};return}var k=(e,s,r)=>{let t=new M,i=te(s,m(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=v(e.provider,r?.apiKey,r?.headers),p=R(r?.cacheRetention,r?.env)==="none"?void 0:r?.sessionId,n=m(e),u=Ee(ge(i.messages),n.supportsOpenAIGrammarTools),d=L(e,i,c,r?.headers,r?.fetch,p),l=G(e,i,r,n,u),g=await r?.onPayload?.(l,e);if(g!==void 0)l=g;let y={...r?.signal?{signal:r.signal}:{},...r?.timeoutMs!==void 0?{timeout:r.timeoutMs}:{},maxRetries:0},{data:S,response:h}=await ie(()=>d.responses.create(l,y).withResponse(),{maxRetries:r?.maxRetries,maxRetryDelayMs:r?.maxRetryDelayMs,signal:r?.signal});if(await r?.onResponse?.({status:h.status,headers:z(h.headers)},e),t.push({type:"start",partial:o}),await at(S,o,t,e,{onProviderStreamEvent:r?.onProviderStreamEvent,serviceTier:r?.serviceTier,grammarToolInputProperties:u,applyServiceTierPricing:(C,A)=>D(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(q(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},ae=(e,s,r)=>{v(e.provider,r?.apiKey,r?.headers);let t={...V(e,s,r,r?.apiKey),toolChoice:r?.toolChoice},i=r?.reasoning?H(e,r.reasoning):void 0;return k(e,s,{...t,reasoningEffort:i==="off"?void 0:i})};function L(e,s,r,t,i,o){let c=m(e),a={"User-Agent":ee(),...e.headers};if(e.provider==="github-copilot"){let p=At(s.messages),n=Et({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 f({apiKey:r,baseURL:e.baseUrl,dangerouslyAllowBrowser:!0,fetch:i,defaultHeaders:a})}function G(e,s,r,t=m(e),i=Ee(ge(s.messages),t.supportsOpenAIGrammarTools)){let o=ye(s.messages,t.supportsAdditionalTools||t.supportsToolSearch),c=st(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=I(e,r?.apiKey),n={model:e.id,input:c,stream:!0,prompt_cache_key:a==="none"?void 0:He(r?.sessionId),prompt_cache_retention:p?void 0:x(t,a),prompt_cache_options:p?void 0:b(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=Xe(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 l=r?.reasoningEffort?e.thinkingLevelMap?.[r.reasoningEffort]??r.reasoningEffort:u;n.reasoning={effort:l,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 d=ct(e,u??"off",r?.samplingParams);if(d)Object.assign(n,d);return n}function U(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=U(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{k as stream,ae as streamSimple};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{Ue,ot}from"./chunk-rm3kcxq9.js";import{Fe}from"./chunk-t057xfrt.js";import{qe,ve,L}from"./chunk-0hbjv3y6.js";import{be,Y,b,Se,X,Qe,B}from"./chunk-k7w7ac9q.js";var{awsEndpointFunctions:Ce,emitWarningIfUnsupportedVersion:Ae,createDefaultUserAgentProvider:ye,NODE_APP_ID_CONFIG_OPTIONS:Te,getAwsRegionExtensionConfiguration:Oe,resolveAwsRegionExtensionConfiguration:we,resolveUserAgentConfig:De,resolveHostHeaderConfig:Re,getUserAgentPlugin:ke,getHostHeaderPlugin:$e,getLoggerPlugin:Ne,getRecursionDetectionPlugin:ze}=L(),{NoAuthSigner:He,getHttpAuthSchemeEndpointRuleSetPlugin:Ge,DefaultIdentityProviderConfig:Me,getHttpSigningPlugin:je}=ve(),{normalizeProvider:j,getSmithyContext:Ke,ServiceException:Ve,NoOpLogger:Le,emitWarningIfUnsupportedVersion:Be,loadConfigsForDefaultMode:We,getDefaultExtensionConfiguration:Ye,resolveDefaultRuntimeConfig:Je,Client:K,makeBuilder:Xe,createAggregatedClient:Ze}=Y(),{Command:et}=Y();var Kr=et,Vr=K;var{resolveDefaultsModeConfig:tt,loadConfig:h,NODE_USE_FIPS_ENDPOINT_CONFIG_OPTIONS:rt,NODE_USE_DUALSTACK_ENDPOINT_CONFIG_OPTIONS:nt,NODE_REGION_CONFIG_OPTIONS:st,NODE_REGION_CONFIG_FILE_OPTIONS:it,resolveRegionConfig:ct}=b(),{BinaryDecisionDiagram:at,EndpointCache:dt,decideEndpoint:pt,customEndpointFunctions:ut,resolveEndpointConfig:lt,getEndpointPlugin:ht}=Se(),{parseUrl:Et,getHttpHandlerExtensionConfiguration:gt,resolveHttpHandlerRuntimeConfig:_t,getContentLengthPlugin:mt}=B(),{DEFAULT_RETRY_MODE:xt,NODE_RETRY_MODE_CONFIG_OPTIONS:St,NODE_MAX_ATTEMPT_CONFIG_OPTIONS:ft,resolveRetryConfig:It,getRetryPlugin:vt}=qe(),{TypeRegistry:V,getSchemaSerdePlugin:Pt}=be(),{resolveAwsSdkSigV4Config:Ct,AwsSdkSigV4Signer:At,NODE_AUTH_SCHEME_PREFERENCE_OPTIONS:yt}=Ue(),{toUtf8:Tt,fromUtf8:Ot,toBase64:wt,fromBase64:Dt,calculateBodyLength:Rt}=X(),{streamCollector:kt,NodeHttpHandler:$t}=Fe(),{AwsRestJsonProtocol:Nt}=ot(),{Sha256:bt}=Qe(),Ut=async(e,t,n)=>({operation:Ke(t).operation,region:await j(e.region)()||(()=>{throw Error("expected `region` to be configured for `aws.auth#sigv4`")})()});function Ft(e){return{schemeId:"aws.auth#sigv4",signingProperties:{name:"sso-oauth",region:e.region},propertiesExtractor:(t,n)=>({signingProperties:{config:t,context:n}})}}function qt(e){return{schemeId:"smithy.api#noAuth"}}var zt=(e)=>{let t=[];switch(e.operation){case"CreateToken":{t.push(qt());break}default:t.push(Ft(e))}return t},Ht=(e)=>{let t=Ct(e);return Object.assign(t,{authSchemePreference:j(e.authSchemePreference??[])})},Gt=(e)=>Object.assign(e,{useDualstackEndpoint:e.useDualstackEndpoint??!1,useFipsEndpoint:e.useFipsEndpoint??!1,defaultSigningName:"sso-oauth"}),Mt={UseFIPS:{type:"builtInParams",name:"useFipsEndpoint"},Endpoint:{type:"builtInParams",name:"endpoint"},Region:{type:"builtInParams",name:"region"},UseDualStack:{type:"builtInParams",name:"useDualstackEndpoint"}},jt="3.997.47",Kt={version:jt},_="ref",E=-1,x=!0,z="isSet",W="PartitionResult",S="booleanEquals",k="getAttr",H={[_]:"Endpoint"},N={[_]:W},g={},G=[{[_]:"Region"}],M={conditions:[[z,[H]],[z,G],["aws.partition",G,W],[S,[{[_]:"UseFIPS"},x]],[S,[{[_]:"UseDualStack"},x]],[S,[{fn:k,argv:[N,"supportsDualStack"]},x]],[S,[{fn:k,argv:[N,"supportsFIPS"]},x]],["stringEquals",[{fn:k,argv:[N,"name"]},"aws-us-gov"]]],results:[[E],[E,"Invalid Configuration: FIPS and custom endpoint are not supported"],[E,"Invalid Configuration: Dualstack and custom endpoint are not supported"],[H,g],["https://oidc-fips.{Region}.{PartitionResult#dualStackDnsSuffix}",g],[E,"FIPS and DualStack are enabled, but this partition does not support one or both"],["https://oidc.{Region}.amazonaws.com",g],["https://oidc-fips.{Region}.{PartitionResult#dnsSuffix}",g],[E,"FIPS is enabled but this partition does not support FIPS"],["https://oidc.{Region}.{PartitionResult#dualStackDnsSuffix}",g],[E,"DualStack is enabled but this partition does not support DualStack"],["https://oidc.{Region}.{PartitionResult#dnsSuffix}",g],[E,"Invalid Configuration: Missing Region"]]},Vt=2,c=1e8,Lt=new Int32Array([-1,1,-1,0,13,3,1,4,c+12,2,5,c+12,3,8,6,4,7,c+11,5,c+9,c+10,4,11,9,6,10,c+8,7,c+6,c+7,5,12,c+5,6,c+4,c+5,3,c+1,14,4,c+2,c+3]),Bt=at.from(Lt,Vt,M.conditions,M.results),Wt=new dt({size:50,params:["Endpoint","Region","UseDualStack","UseFIPS"]}),Yt=(e,t={})=>Wt.get(e,()=>pt(Bt,{endpointParams:e,logger:t.logger}));ut.aws=Ce;class i extends Ve{static shapeId="smithy.ts.sdk.synthetic.com.amazonaws.ssooidc#SSOOIDCServiceException";constructor(e){super(e);Object.setPrototypeOf(this,i.prototype)}}class f extends i{static shapeId="com.amazonaws.ssooidc#AccessDeniedException";name="AccessDeniedException";$fault="client";error;reason;error_description;constructor(e){super({name:"AccessDeniedException",$fault:"client",...e});Object.setPrototypeOf(this,f.prototype),this.error=e.error,this.reason=e.reason,this.error_description=e.error_description}}class I extends i{static shapeId="com.amazonaws.ssooidc#AuthorizationPendingException";name="AuthorizationPendingException";$fault="client";error;error_description;constructor(e){super({name:"AuthorizationPendingException",$fault:"client",...e});Object.setPrototypeOf(this,I.prototype),this.error=e.error,this.error_description=e.error_description}}class v extends i{static shapeId="com.amazonaws.ssooidc#ExpiredTokenException";name="ExpiredTokenException";$fault="client";error;error_description;constructor(e){super({name:"ExpiredTokenException",$fault:"client",...e});Object.setPrototypeOf(this,v.prototype),this.error=e.error,this.error_description=e.error_description}}class P extends i{static shapeId="com.amazonaws.ssooidc#InternalServerException";name="InternalServerException";$fault="server";error;error_description;constructor(e){super({name:"InternalServerException",$fault:"server",...e});Object.setPrototypeOf(this,P.prototype),this.error=e.error,this.error_description=e.error_description}}class C extends i{static shapeId="com.amazonaws.ssooidc#InvalidClientException";name="InvalidClientException";$fault="client";error;error_description;constructor(e){super({name:"InvalidClientException",$fault:"client",...e});Object.setPrototypeOf(this,C.prototype),this.error=e.error,this.error_description=e.error_description}}class A extends i{static shapeId="com.amazonaws.ssooidc#InvalidGrantException";name="InvalidGrantException";$fault="client";error;error_description;constructor(e){super({name:"InvalidGrantException",$fault:"client",...e});Object.setPrototypeOf(this,A.prototype),this.error=e.error,this.error_description=e.error_description}}class y extends i{static shapeId="com.amazonaws.ssooidc#InvalidRequestException";name="InvalidRequestException";$fault="client";error;reason;error_description;constructor(e){super({name:"InvalidRequestException",$fault:"client",...e});Object.setPrototypeOf(this,y.prototype),this.error=e.error,this.reason=e.reason,this.error_description=e.error_description}}class T extends i{static shapeId="com.amazonaws.ssooidc#InvalidScopeException";name="InvalidScopeException";$fault="client";error;error_description;constructor(e){super({name:"InvalidScopeException",$fault:"client",...e});Object.setPrototypeOf(this,T.prototype),this.error=e.error,this.error_description=e.error_description}}class O extends i{static shapeId="com.amazonaws.ssooidc#SlowDownException";name="SlowDownException";$fault="client";error;error_description;constructor(e){super({name:"SlowDownException",$fault:"client",...e});Object.setPrototypeOf(this,O.prototype),this.error=e.error,this.error_description=e.error_description}}class w extends i{static shapeId="com.amazonaws.ssooidc#UnauthorizedClientException";name="UnauthorizedClientException";$fault="client";error;error_description;constructor(e){super({name:"UnauthorizedClientException",$fault:"client",...e});Object.setPrototypeOf(this,w.prototype),this.error=e.error,this.error_description=e.error_description}}class D extends i{static shapeId="com.amazonaws.ssooidc#UnsupportedGrantTypeException";name="UnsupportedGrantTypeException";$fault="client";error;error_description;constructor(e){super({name:"UnsupportedGrantTypeException",$fault:"client",...e});Object.setPrototypeOf(this,D.prototype),this.error=e.error,this.error_description=e.error_description}}var Jt="AccessDeniedException",Xt="AuthorizationPendingException",Qt="AccessToken",Zt="ClientSecret",er="CreateToken",tr="CreateTokenRequest",rr="CreateTokenResponse",or="CodeVerifier",nr="ExpiredTokenException",sr="InvalidClientException",ir="InvalidGrantException",cr="InvalidRequestException",ar="InternalServerException",dr="InvalidScopeException",pr="IdToken",ur="RefreshToken",lr="SlowDownException",hr="UnauthorizedClientException",Er="UnsupportedGrantTypeException",gr="accessToken",l="client",_r="clientId",mr="clientSecret",xr="codeVerifier",Sr="code",fr="deviceCode",r="error",Ir="expiresIn",p="error_description",vr="grantType",Pr="http",u="httpError",Cr="idToken",J="reason",Q="refreshToken",Ar="redirectUri",Z="smithy.ts.sdk.synthetic.com.amazonaws.ssooidc",yr="scope",Tr="server",Or="tokenType",o="com.amazonaws.ssooidc",ee=new V(Z),te=[-3,Z,"SSOOIDCServiceException",0,[],[]];ee.registerError(te,i);var a=new V(o),re=[-3,o,Jt,{[r]:l,[u]:400},[r,J,p],[0,0,0]];a.registerError(re,f);var oe=[-3,o,Xt,{[r]:l,[u]:400},[r,p],[0,0]];a.registerError(oe,I);var ne=[-3,o,nr,{[r]:l,[u]:400},[r,p],[0,0]];a.registerError(ne,v);var se=[-3,o,ar,{[r]:Tr,[u]:500},[r,p],[0,0]];a.registerError(se,P);var ie=[-3,o,sr,{[r]:l,[u]:401},[r,p],[0,0]];a.registerError(ie,C);var ce=[-3,o,ir,{[r]:l,[u]:400},[r,p],[0,0]];a.registerError(ce,A);var ae=[-3,o,cr,{[r]:l,[u]:400},[r,J,p],[0,0,0]];a.registerError(ae,y);var de=[-3,o,dr,{[r]:l,[u]:400},[r,p],[0,0]];a.registerError(de,T);var pe=[-3,o,lr,{[r]:l,[u]:400},[r,p],[0,0]];a.registerError(pe,O);var ue=[-3,o,hr,{[r]:l,[u]:400},[r,p],[0,0]];a.registerError(ue,w);var le=[-3,o,Er,{[r]:l,[u]:400},[r,p],[0,0]];a.registerError(le,D);var he=[ee,a],wr=[0,o,Qt,8,0],Dr=[0,o,Zt,8,0],Rr=[0,o,or,8,0],kr=[0,o,pr,8,0],Ee=[0,o,ur,8,0],ge=[3,o,tr,0,[_r,mr,vr,fr,Sr,Q,yr,Ar,xr],[0,[()=>Dr,0],0,0,0,[()=>Ee,0],64,0,[()=>Rr,0]],3],_e=[3,o,rr,0,[gr,Or,Ir,Q,Cr],[[()=>wr,0],0,1,[()=>Ee,0],[()=>kr,0]]],me=[9,o,er,{[Pr]:["POST","/token",200]},()=>ge,()=>_e],$r=(e)=>({apiVersion:"2019-06-10",base64Decoder:e?.base64Decoder??Dt,base64Encoder:e?.base64Encoder??wt,disableHostPrefix:e?.disableHostPrefix??!1,endpointProvider:e?.endpointProvider??Yt,extensions:e?.extensions??[],httpAuthSchemeProvider:e?.httpAuthSchemeProvider??zt,httpAuthSchemes:e?.httpAuthSchemes??[{schemeId:"aws.auth#sigv4",identityProvider:(t)=>t.getIdentityProvider("aws.auth#sigv4"),signer:new At},{schemeId:"smithy.api#noAuth",identityProvider:(t)=>t.getIdentityProvider("smithy.api#noAuth")||(async()=>({})),signer:new He}],logger:e?.logger??new Le,protocol:e?.protocol??Nt,protocolSettings:e?.protocolSettings??{defaultNamespace:"com.amazonaws.ssooidc",errorTypeRegistries:he,version:"2019-06-10",serviceTarget:"AWSSSOOIDCService"},serviceId:e?.serviceId??"SSO OIDC",sha256:e?.sha256??bt,urlParser:e?.urlParser??Et,utf8Decoder:e?.utf8Decoder??Ot,utf8Encoder:e?.utf8Encoder??Tt}),Nr=(e)=>{Be(process.version);let t=tt(e),n=()=>t().then(We),d=$r(e);Ae(process.version);let s={profile:e?.profile,logger:d.logger};return{...d,...e,runtime:"node",defaultsMode:t,authSchemePreference:e?.authSchemePreference??h(yt,s),bodyLengthChecker:e?.bodyLengthChecker??Rt,defaultUserAgentProvider:e?.defaultUserAgentProvider??ye({serviceId:d.serviceId,clientVersion:Kt.version}),maxAttempts:e?.maxAttempts??h(ft,e),region:e?.region??h(st,{...it,...s}),requestHandler:$t.create(e?.requestHandler??n),retryMode:e?.retryMode??h({...St,default:async()=>(await n()).retryMode||xt},e),streamCollector:e?.streamCollector??kt,useDualstackEndpoint:e?.useDualstackEndpoint??h(nt,s),useFipsEndpoint:e?.useFipsEndpoint??h(rt,s),userAgentAppId:e?.userAgentAppId??h(Te,s)}},br=(e)=>{let{httpAuthSchemes:t,httpAuthSchemeProvider:n,credentials:d}=e;return{setHttpAuthScheme(s){let m=t.findIndex((R)=>R.schemeId===s.schemeId);if(m===-1)t.push(s);else t.splice(m,1,s)},httpAuthSchemes(){return t},setHttpAuthSchemeProvider(s){n=s},httpAuthSchemeProvider(){return n},setCredentials(s){d=s},credentials(){return d}}},Ur=(e)=>({httpAuthSchemes:e.httpAuthSchemes(),httpAuthSchemeProvider:e.httpAuthSchemeProvider(),credentials:e.credentials()}),Fr=(e,t)=>{let n=Object.assign(Oe(e),Ye(e),gt(e),br(e));return t.forEach((d)=>d.configure(n)),Object.assign(e,we(n),Je(n),_t(n),Ur(n))};class U extends K{config;constructor(...[e]){let t=Nr(e||{});super(t);this.initConfig=t;let n=Gt(t),d=De(n),s=It(d),m=ct(s),R=Re(m),xe=lt(R),fe=Ht(xe),Ie=Fr(fe,e?.extensions||[]);this.config=Ie,this.middlewareStack.use(Pt(this.config)),this.middlewareStack.use(ke(this.config)),this.middlewareStack.use(vt(this.config)),this.middlewareStack.use(mt(this.config)),this.middlewareStack.use($e(this.config)),this.middlewareStack.use(Ne(this.config)),this.middlewareStack.use(ze(this.config)),this.middlewareStack.use(Ge(this.config,{httpAuthSchemeParametersProvider:Ut,identityProviderConfigProvider:async(Pe)=>new Me({"aws.auth#sigv4":Pe.credentials})})),this.middlewareStack.use(je(this.config))}destroy(){super.destroy()}}var qr=Xe(Mt,"AWSSSOOIDCService","SSOOIDCClient",ht),zr={},Hr=(e,t,n,d)=>[];class F extends qr(zr,Hr,"CreateToken",me){}var Gr={CreateTokenCommand:F};class q extends U{}Ze(Gr,q);var Mr={KMS_ACCESS_DENIED:"KMS_AccessDeniedException"},jr={KMS_DISABLED_KEY:"KMS_DisabledException",KMS_INVALID_KEY_USAGE:"KMS_InvalidKeyUsageException",KMS_INVALID_STATE:"KMS_InvalidStateException",KMS_KEY_NOT_FOUND:"KMS_NotFoundException"};var Lr=f,Br=re,Wr=Mr,Yr=I,Jr=oe,Xr=me,Qr=F,Zr=ge,eo=_e,to=v,ro=ne,oo=P,no=se,so=C,io=ie,co=A,ao=ce,po=y,uo=ae,lo=jr,ho=T,Eo=de,go=q,_o=U,mo=i,xo=te,So=O,fo=pe,Io=w,vo=ue,Po=D,Co=le,Ao=he;export{Kr as $Command,Vr as __Client,Lr as AccessDeniedException,Br as AccessDeniedException$,Wr as AccessDeniedExceptionReason,Yr as AuthorizationPendingException,Jr as AuthorizationPendingException$,Xr as CreateToken$,Qr as CreateTokenCommand,Zr as CreateTokenRequest$,eo as CreateTokenResponse$,to as ExpiredTokenException,ro as ExpiredTokenException$,oo as InternalServerException,no as InternalServerException$,so as InvalidClientException,io as InvalidClientException$,co as InvalidGrantException,ao as InvalidGrantException$,po as InvalidRequestException,uo as InvalidRequestException$,lo as InvalidRequestExceptionReason,ho as InvalidScopeException,Eo as InvalidScopeException$,go as SSOOIDC,_o as SSOOIDCClient,mo as SSOOIDCServiceException,xo as SSOOIDCServiceException$,So as SlowDownException,fo as SlowDownException$,Io as UnauthorizedClientException,vo as UnauthorizedClientException$,Po as UnsupportedGrantTypeException,Co as UnsupportedGrantTypeException$,Ao as errorTypeRegistries};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{Ue,ot}from"./chunk-rm3kcxq9.js";import{Fe}from"./chunk-t057xfrt.js";import{qe,ve,L}from"./chunk-0hbjv3y6.js";import{be,Y,b,Se,X,Qe,B}from"./chunk-k7w7ac9q.js";var{awsEndpointFunctions:ze,emitWarningIfUnsupportedVersion:We,createDefaultUserAgentProvider:Le,NODE_APP_ID_CONFIG_OPTIONS:Be,getAwsRegionExtensionConfiguration:je,resolveAwsRegionExtensionConfiguration:Ge,resolveUserAgentConfig:Ke,resolveHostHeaderConfig:Xe,getUserAgentPlugin:Ye,getHostHeaderPlugin:Je,getLoggerPlugin:Ze,getRecursionDetectionPlugin:et}=L(),{NoAuthSigner:tt,getHttpAuthSchemeEndpointRuleSetPlugin:st,DefaultIdentityProviderConfig:nt,getHttpSigningPlugin:rt}=ve(),{normalizeProvider:ae,getSmithyContext:it,ServiceException:at,NoOpLogger:ct,emitWarningIfUnsupportedVersion:ut,loadConfigsForDefaultMode:pt,getDefaultExtensionConfiguration:dt,resolveDefaultRuntimeConfig:ht,Client:ce,makeBuilder:gt,createAggregatedClient:lt}=Y(),{Command:mt}=Y();var Ls=mt,Bs=ce;var{resolveDefaultsModeConfig:Et,loadConfig:m,NODE_USE_FIPS_ENDPOINT_CONFIG_OPTIONS:At,NODE_USE_DUALSTACK_ENDPOINT_CONFIG_OPTIONS:_t,NODE_REGION_CONFIG_OPTIONS:It,NODE_REGION_CONFIG_FILE_OPTIONS:St,resolveRegionConfig:Ot}=b(),{BinaryDecisionDiagram:Ct,EndpointCache:Rt,decideEndpoint:vt,customEndpointFunctions:Pt,resolveEndpointConfig:Tt,getEndpointPlugin:ft}=Se(),{parseUrl:kt,getHttpHandlerExtensionConfiguration:xt,resolveHttpHandlerRuntimeConfig:yt,getContentLengthPlugin:Dt}=B(),{DEFAULT_RETRY_MODE:wt,NODE_RETRY_MODE_CONFIG_OPTIONS:Nt,NODE_MAX_ATTEMPT_CONFIG_OPTIONS:$t,resolveRetryConfig:Ut,getRetryPlugin:Ft}=qe(),{TypeRegistry:ue,getSchemaSerdePlugin:bt}=be(),{resolveAwsSdkSigV4Config:qt,AwsSdkSigV4Signer:Mt,NODE_AUTH_SCHEME_PREFERENCE_OPTIONS:Ht}=Ue(),{toUtf8:Vt,fromUtf8:zt,toBase64:Wt,fromBase64:Lt,calculateBodyLength:Bt}=X(),{streamCollector:jt,NodeHttpHandler:Gt}=Fe(),{AwsRestJsonProtocol:Kt}=ot(),{Sha256:Xt}=Qe(),Qt=async(e,s,n)=>({operation:it(s).operation,region:await ae(e.region)()||(()=>{throw Error("expected `region` to be configured for `aws.auth#sigv4`")})()});function Yt(e){return{schemeId:"aws.auth#sigv4",signingProperties:{name:"signin",region:e.region},propertiesExtractor:(s,n)=>({signingProperties:{config:s,context:n}})}}function Jt(e){return{schemeId:"smithy.api#noAuth"}}var Zt=(e)=>{let s=[];switch(e.operation){case"CreateOAuth2Token":{s.push(Jt());break}default:s.push(Yt(e))}return s},es=(e)=>{let s=qt(e);return Object.assign(s,{authSchemePreference:ae(e.authSchemePreference??[])})},ts=(e)=>Object.assign(e,{useDualstackEndpoint:e.useDualstackEndpoint??!1,useFipsEndpoint:e.useFipsEndpoint??!1,defaultSigningName:"signin"}),ss={UseFIPS:{type:"builtInParams",name:"useFipsEndpoint"},Endpoint:{type:"builtInParams",name:"endpoint"},Region:{type:"builtInParams",name:"region"},UseDualStack:{type:"builtInParams",name:"useDualstackEndpoint"}},ns="3.997.47",os={version:ns},h="ref",p=-1,z=!1,E=!0,W="isSet",A="booleanEquals",j="coalesce",N="PartitionResult",u="stringEquals",k="getAttr",G="https://signin.{Region}.{PartitionResult#dualStackDnsSuffix}",K={[h]:"Endpoint"},d={fn:k,argv:[{[h]:N},"name"]},pe={[h]:"Region"},Q={[h]:N},S={authSchemes:[{name:"sigv4",signingName:"signin",signingRegion:"{Region}"}]},r={},J=[pe],Z={conditions:[[W,J],[A,[{fn:j,argv:[{[h]:"IsControlPlane"},z]},E]],[W,[K]],["aws.partition",J,N],[A,[{[h]:"UseFIPS"},E]],[u,[d,"aws"]],[A,[{fn:j,argv:[{[h]:"IsOAuthEndpoint"},z]},E]],[A,[{[h]:"UseDualStack"},E]],[u,[d,"aws-cn"]],[u,[pe,"us-gov-west-1"]],[u,[d,"aws-us-gov"]],[A,[{fn:k,argv:[Q,"supportsFIPS"]},E]],[u,[d,"aws-iso"]],[u,[d,"aws-iso-b"]],[u,[d,"aws-iso-f"]],[u,[d,"aws-iso-e"]],[u,[d,"aws-eusc"]],[A,[{fn:k,argv:[Q,"supportsDualStack"]},E]]],results:[[p],["https://signin.{Region}.api.aws",S],["https://signin.{Region}.api.amazonwebservices.com.cn",S],[G,S],[p,"FIPS endpoints are not supported for OAuth operations. Disable FIPS or use a non-OAuth operation."],["https://{Region}.oauth.signin.aws",S],["https://{Region}.signin.aws.amazon.com",r],["https://{Region}.signin.amazonaws.cn",r],["https://{Region}.signin.amazonaws-us-gov.com",r],["https://{Region}.signin.c2shome.ic.gov",r],["https://{Region}.signin.sc2shome.sgov.gov",r],["https://{Region}.signin.csphome.hci.ic.gov",r],["https://{Region}.signin.csphome.adc-e.uk",r],["https://{Region}.signin.amazonaws-eusc.eu",r],["https://signin-fips.amazonaws-us-gov.com",r],["https://{Region}.signin-fips.amazonaws-us-gov.com",r],["https://{Region}.signin.{PartitionResult#dnsSuffix}",r],[p,"Invalid Configuration: FIPS and custom endpoint are not supported"],[p,"Invalid Configuration: Dualstack and custom endpoint are not supported"],[K,r],["https://signin-fips.{Region}.{PartitionResult#dualStackDnsSuffix}",r],[p,"FIPS and DualStack are enabled, but this partition does not support one or both"],["https://signin-fips.{Region}.{PartitionResult#dnsSuffix}",r],[p,"FIPS is enabled but this partition does not support FIPS"],[G,r],[p,"DualStack is enabled but this partition does not support DualStack"],["https://signin.{Region}.{PartitionResult#dnsSuffix}",r],[p,"Invalid Configuration: Missing Region"]]},rs=2,t=1e8,is=new Int32Array([-1,1,-1,0,6,3,2,36,4,4,5,t+27,6,t+4,t+27,1,29,7,2,36,8,3,9,31,4,22,10,5,19,11,7,21,12,8,t+7,13,10,t+8,14,12,t+9,15,13,t+10,16,14,t+11,17,15,t+12,18,16,t+13,t+16,6,t+5,20,7,21,t+6,17,t+24,t+25,6,t+4,23,7,27,24,9,t+14,25,10,t+15,26,11,t+22,t+23,11,28,t+21,17,t+20,t+21,2,35,30,3,39,31,4,32,t+27,6,t+4,33,7,t+27,34,9,t+14,t+27,3,39,36,4,38,37,7,t+18,t+19,6,t+4,t+17,5,t+1,40,8,t+2,t+3]),as=Ct.from(is,rs,Z.conditions,Z.results),cs=new Rt({size:50,params:["Endpoint","IsControlPlane","IsOAuthEndpoint","Region","UseDualStack","UseFIPS"]}),us=(e,s={})=>cs.get(e,()=>vt(as,{endpointParams:e,logger:s.logger}));Pt.aws=ze;class l extends at{static shapeId="smithy.ts.sdk.synthetic.com.amazonaws.signin#SigninServiceException";constructor(e){super(e);Object.setPrototypeOf(this,l.prototype)}}class C extends l{static shapeId="com.amazonaws.signin#AccessDeniedException";name="AccessDeniedException";$fault="client";error;constructor(e){super({name:"AccessDeniedException",$fault:"client",...e});Object.setPrototypeOf(this,C.prototype),this.error=e.error}}class R extends l{static shapeId="com.amazonaws.signin#InternalServerException";name="InternalServerException";$fault="server";error;constructor(e){super({name:"InternalServerException",$fault:"server",...e});Object.setPrototypeOf(this,R.prototype),this.error=e.error}}class v extends l{static shapeId="com.amazonaws.signin#TooManyRequestsError";name="TooManyRequestsError";$fault="client";error;constructor(e){super({name:"TooManyRequestsError",$fault:"client",...e});Object.setPrototypeOf(this,v.prototype),this.error=e.error}}class P extends l{static shapeId="com.amazonaws.signin#ValidationException";name="ValidationException";$fault="client";error;constructor(e){super({name:"ValidationException",$fault:"client",...e});Object.setPrototypeOf(this,P.prototype),this.error=e.error}}var ps="AccessDeniedException",ds="AccessToken",hs="CreateOAuth2Token",gs="CreateOAuth2TokenRequest",ls="CreateOAuth2TokenRequestBody",ms="CreateOAuth2TokenResponseBody",Es="CreateOAuth2TokenResponse",As="CreateOAuth2TokenWithIAM",_s="CreateOAuth2TokenWithIAMRequest",Is="CreateOAuth2TokenWithIAMResponse",Ss="InternalServerException",Os="OAuthAccessToken",Cs="RefreshToken",Rs="TooManyRequestsError",vs="ValidationException",ee="accessKeyId",x="accessToken",Ps="access_token",U="client",te="clientId",se="codeVerifier",Ts="code",g="error",y="expiresIn",fs="expires_in",D="grantType",ks="grant_type",de="http",F="httpError",ne="idToken",o="jsonName",T="message",xs="resource",O="refreshToken",oe="redirectUri",he="smithy.ts.sdk.synthetic.com.amazonaws.signin",re="secretAccessKey",ie="sessionToken",ys="server",Ds="tokenInput",ws="tokenOutput",w="tokenType",Ns="token_type",i="com.amazonaws.signin",ge=new ue(he),le=[-3,he,"SigninServiceException",0,[],[]];ge.registerError(le,l);var _=new ue(i),me=[-3,i,ps,{[g]:U},[g,T],[0,0],2];_.registerError(me,C);var Ee=[-3,i,Ss,{[g]:ys,[F]:500},[g,T],[0,0],2];_.registerError(Ee,R);var Ae=[-3,i,Rs,{[g]:U,[F]:429},[g,T],[0,0],2];_.registerError(Ae,v);var _e=[-3,i,vs,{[g]:U,[F]:400},[g,T],[0,0],2];_.registerError(_e,P);var Ie=[ge,_],$s=[0,i,Os,8,0],Oe=[0,i,Cs,8,0],Ce=[3,i,ds,8,[ee,re,ie],[[0,{[o]:ee}],[0,{[o]:re}],[0,{[o]:ie}]],3],Re=[3,i,gs,0,[Ds],[[()=>Pe,16]],1],Pe=[3,i,ls,0,[te,D,Ts,oe,se,O],[[0,{[o]:te}],[0,{[o]:D}],0,[0,{[o]:oe}],[0,{[o]:se}],[()=>Oe,{[o]:O}]],2],Te=[3,i,Es,0,[ws],[[()=>fe,16]],1],fe=[3,i,ms,0,[x,w,y,O,ne],[[()=>Ce,{[o]:x}],[0,{[o]:w}],[1,{[o]:y}],[()=>Oe,{[o]:O}],[0,{[o]:ne}]],4],ke=[3,i,_s,0,[D,xs],[[0,{[o]:ks}],0],2],xe=[3,i,Is,0,[x,w,y],[[()=>$s,{[o]:Ps}],[0,{[o]:Ns}],[1,{[o]:fs}]],3],ye=[9,i,hs,{[de]:["POST","/v1/token",200]},()=>Re,()=>Te],De=[9,i,As,{[de]:["POST","/v1/token?x-amz-client-auth-method=iam",200]},()=>ke,()=>xe],Us=(e)=>({apiVersion:"2023-01-01",base64Decoder:e?.base64Decoder??Lt,base64Encoder:e?.base64Encoder??Wt,disableHostPrefix:e?.disableHostPrefix??!1,endpointProvider:e?.endpointProvider??us,extensions:e?.extensions??[],httpAuthSchemeProvider:e?.httpAuthSchemeProvider??Zt,httpAuthSchemes:e?.httpAuthSchemes??[{schemeId:"aws.auth#sigv4",identityProvider:(s)=>s.getIdentityProvider("aws.auth#sigv4"),signer:new Mt},{schemeId:"smithy.api#noAuth",identityProvider:(s)=>s.getIdentityProvider("smithy.api#noAuth")||(async()=>({})),signer:new tt}],logger:e?.logger??new ct,protocol:e?.protocol??Kt,protocolSettings:e?.protocolSettings??{defaultNamespace:"com.amazonaws.signin",errorTypeRegistries:Ie,version:"2023-01-01",serviceTarget:"Signin"},serviceId:e?.serviceId??"Signin",sha256:e?.sha256??Xt,urlParser:e?.urlParser??kt,utf8Decoder:e?.utf8Decoder??zt,utf8Encoder:e?.utf8Encoder??Vt}),Fs=(e)=>{ut(process.version);let s=Et(e),n=()=>s().then(pt),c=Us(e);We(process.version);let a={profile:e?.profile,logger:c.logger};return{...c,...e,runtime:"node",defaultsMode:s,authSchemePreference:e?.authSchemePreference??m(Ht,a),bodyLengthChecker:e?.bodyLengthChecker??Bt,defaultUserAgentProvider:e?.defaultUserAgentProvider??Le({serviceId:c.serviceId,clientVersion:os.version}),maxAttempts:e?.maxAttempts??m($t,e),region:e?.region??m(It,{...St,...a}),requestHandler:Gt.create(e?.requestHandler??n),retryMode:e?.retryMode??m({...Nt,default:async()=>(await n()).retryMode||wt},e),streamCollector:e?.streamCollector??jt,useDualstackEndpoint:e?.useDualstackEndpoint??m(_t,a),useFipsEndpoint:e?.useFipsEndpoint??m(At,a),userAgentAppId:e?.userAgentAppId??m(Be,a)}},bs=(e)=>{let{httpAuthSchemes:s,httpAuthSchemeProvider:n,credentials:c}=e;return{setHttpAuthScheme(a){let I=s.findIndex((f)=>f.schemeId===a.schemeId);if(I===-1)s.push(a);else s.splice(I,1,a)},httpAuthSchemes(){return s},setHttpAuthSchemeProvider(a){n=a},httpAuthSchemeProvider(){return n},setCredentials(a){c=a},credentials(){return c}}},qs=(e)=>({httpAuthSchemes:e.httpAuthSchemes(),httpAuthSchemeProvider:e.httpAuthSchemeProvider(),credentials:e.credentials()}),Ms=(e,s)=>{let n=Object.assign(je(e),dt(e),xt(e),bs(e));return s.forEach((c)=>c.configure(n)),Object.assign(e,Ge(n),ht(n),yt(n),qs(n))};class q extends ce{config;constructor(...[e]){let s=Fs(e||{});super(s);this.initConfig=s;let n=ts(s),c=Ke(n),a=Ut(c),I=Ot(a),f=Xe(I),$e=Tt(f),Me=es($e),He=Ms(Me,e?.extensions||[]);this.config=He,this.middlewareStack.use(bt(this.config)),this.middlewareStack.use(Ye(this.config)),this.middlewareStack.use(Ft(this.config)),this.middlewareStack.use(Dt(this.config)),this.middlewareStack.use(Je(this.config)),this.middlewareStack.use(Ze(this.config)),this.middlewareStack.use(et(this.config)),this.middlewareStack.use(st(this.config,{httpAuthSchemeParametersProvider:Qt,identityProviderConfigProvider:async(Ve)=>new nt({"aws.auth#sigv4":Ve.credentials})})),this.middlewareStack.use(rt(this.config))}destroy(){super.destroy()}}var we=gt(ss,"Signin","SigninClient",ft),Hs={IsControlPlane:{type:"staticContextParams",value:!1}},Vs={IsOAuthEndpoint:{type:"staticContextParams",value:!0}},Ne=(e,s,n,c)=>[];class M extends we(Hs,Ne,"CreateOAuth2Token",ye){}class H extends we(Vs,Ne,"CreateOAuth2TokenWithIAM",De){}var zs={CreateOAuth2TokenCommand:M,CreateOAuth2TokenWithIAMCommand:H};class V extends q{}lt(zs,V);var Ws={AUTHCODE_EXPIRED:"AUTHCODE_EXPIRED",CONFLICT:"CONFLICT",INSUFFICIENT_PERMISSIONS:"INSUFFICIENT_PERMISSIONS",INVALID_REQUEST:"INVALID_REQUEST",RESOURCE_NOT_FOUND:"RESOURCE_NOT_FOUND",SERVER_ERROR:"server_error",SERVICE_QUOTA_EXCEEDED:"SERVICE_QUOTA_EXCEEDED",TOKEN_EXPIRED:"TOKEN_EXPIRED",USER_CREDENTIALS_CHANGED:"USER_CREDENTIALS_CHANGED"};var js=C,Gs=me,Ks=Ce,Xs=ye,Qs=M,Ys=Re,Js=Pe,Zs=Te,en=fe,tn=De,sn=H,nn=ke,on=xe,rn=R,an=Ee,cn=Ws,un=V,pn=q,dn=l,hn=le,gn=v,ln=Ae,mn=P,En=_e,An=Ie;export{Ls as $Command,Bs as __Client,js as AccessDeniedException,Gs as AccessDeniedException$,Ks as AccessToken$,Xs as CreateOAuth2Token$,Qs as CreateOAuth2TokenCommand,Ys as CreateOAuth2TokenRequest$,Js as CreateOAuth2TokenRequestBody$,Zs as CreateOAuth2TokenResponse$,en as CreateOAuth2TokenResponseBody$,tn as CreateOAuth2TokenWithIAM$,sn as CreateOAuth2TokenWithIAMCommand,nn as CreateOAuth2TokenWithIAMRequest$,on as CreateOAuth2TokenWithIAMResponse$,rn as InternalServerException,an as InternalServerException$,cn as OAuth2ErrorCode,un as Signin,pn as SigninClient,dn as SigninServiceException,hn as SigninServiceException$,gn as TooManyRequestsError,ln as TooManyRequestsError$,mn as ValidationException,En as ValidationException$,An as errorTypeRegistries};
@@ -0,0 +1,3 @@
1
+ // @bun
2
+ import{b,B}from"./chunk-k7w7ac9q.js";import{i}from"./chunk-qnr1f5pj.js";var I=i(b());var h=(e)=>Boolean(e)&&typeof e==="object"&&typeof e.AccessKeyId==="string"&&typeof e.SecretAccessKey==="string"&&typeof e.Token==="string"&&typeof e.Expiration==="string",C=(e)=>({accessKeyId:e.AccessKeyId,secretAccessKey:e.SecretAccessKey,sessionToken:e.Token,expiration:new Date(e.Expiration),...e.AccountId&&{accountId:e.AccountId}});var v=({maxRetries:e=0,timeout:t=1000})=>({maxRetries:e,timeout:t});var g=i(b());import y from"http";function _(e){return new Promise((t,n)=>{let o=y.request({method:"GET",...e,hostname:e.hostname?.replace(/^\[(.+)\]$/,"$1")});o.on("error",(r)=>{n(Object.assign(new g.ProviderError("Unable to connect to instance metadata service"),r)),o.destroy()}),o.on("timeout",()=>{n(new g.ProviderError("TimeoutError from instance metadata service")),o.destroy()}),o.on("response",(r)=>{let{statusCode:a=400}=r;if(a<200||300<=a)n(Object.assign(new g.ProviderError("Error response received from instance metadata service"),{statusCode:a})),o.destroy();let m=[];r.on("data",(s)=>{m.push(s)}),r.on("end",()=>{t(Buffer.concat(m)),o.destroy()})}),o.end()})}var A=(e,t)=>{let n=e();for(let o=0;o<t;o++)n=n.catch(e);return n};var S="AWS_CONTAINER_CREDENTIALS_FULL_URI",O="AWS_CONTAINER_CREDENTIALS_RELATIVE_URI",w="AWS_CONTAINER_AUTHORIZATION_TOKEN",Y=(e={})=>{let{timeout:t,maxRetries:n}=v(e);return()=>A(async()=>{let o=await Z({logger:e.logger}),r=JSON.parse(await j(t,o));if(!h(r))throw new I.CredentialsProviderError("Invalid response received from instance metadata service.",{logger:e.logger});return C(r)},n)},j=async(e,t)=>{if(process.env[w])t.headers={...t.headers,Authorization:process.env[w]};return(await _({...t,timeout:e})).toString()},J="169.254.170.2",X=new Set(["localhost","127.0.0.1"]),z=new Set(["http:","https:"]),Z=async({logger:e})=>{if(process.env[O])return{hostname:J,path:process.env[O]};if(process.env[S]){let t;try{t=new URL(process.env[S])}catch{throw new I.CredentialsProviderError(`${process.env[S]} is not a valid container metadata service URL`,{tryNextLink:!1,logger:e})}if(!t.hostname||!X.has(t.hostname))throw new I.CredentialsProviderError(`${t.hostname} is not a valid container metadata service hostname`,{tryNextLink:!1,logger:e});if(!t.protocol||!z.has(t.protocol))throw new I.CredentialsProviderError(`${t.protocol} is not a valid container metadata service protocol`,{tryNextLink:!1,logger:e});return{protocol:t.protocol,hostname:t.hostname,path:t.pathname+t.search,port:t.port?parseInt(t.port,10):void 0}}throw new I.CredentialsProviderError(`The container metadata credential provider cannot be used unless the ${O} or ${S} environment variable is set`,{tryNextLink:!1,logger:e})};var N=i(b());var P=i(b());class D extends P.CredentialsProviderError{tryNextLink;name="InstanceMetadataV1FallbackError";constructor(e,t=!0){super(e,t);this.tryNextLink=t,Object.setPrototypeOf(this,D.prototype)}}var M=i(b()),V=i(B());var u;(function(e){e.IPv4="http://169.254.169.254",e.IPv6="http://[fd00:ec2::254]"})(u||(u={}));var L={environmentVariableSelector:(e)=>e.AWS_EC2_METADATA_SERVICE_ENDPOINT,configFileSelector:(e)=>e.ec2_metadata_service_endpoint,default:void 0};var p;(function(e){e.IPv4="IPv4",e.IPv6="IPv6"})(p||(p={}));var Q="AWS_EC2_METADATA_SERVICE_ENDPOINT_MODE",ee="ec2_metadata_service_endpoint_mode",F={environmentVariableSelector:(e)=>e[Q],configFileSelector:(e)=>e[ee],default:p.IPv4};var k=async()=>V.parseUrl(await te()||await oe()),te=async()=>M.loadConfig(L)(),oe=async()=>{let e=await M.loadConfig(F)();switch(e){case p.IPv4:return u.IPv4;case p.IPv6:return u.IPv6;default:throw Error(`Unsupported endpoint mode: ${e}. Select from ${Object.values(p)}`)}};var x=(e,t)=>{let n=300+Math.floor(Math.random()*300),o=new Date(Date.now()+n*1000);t.warn(`Attempting credential expiration extension due to a credential service availability issue. A refresh of these credentials will be attempted after ${new Date(o)}.
3
+ For more information, please visit: https://docs.aws.amazon.com/sdkref/latest/guide/feature-static-credentials.html`);let r=e.originalExpiration??e.expiration;return{...e,...r?{originalExpiration:r}:{},expiration:o}};var U=(e,t={})=>{let n=t?.logger||console,o;return async()=>{let r;try{if(r=await e(),r.expiration&&r.expiration.getTime()<Date.now())r=x(r,n)}catch(a){if(o)n.warn("Credential renew failed: ",a),r=x(o,n);else throw a}return o=r,r}};var G="/latest/meta-data/iam/security-credentials/",re="/latest/api/token",R="AWS_EC2_METADATA_V1_DISABLED",W="ec2_metadata_v1_disabled",K="x-aws-ec2-metadata-token",ne=(e={})=>U(ae(e),{logger:e.logger}),ae=(e={})=>{let t=!1,{logger:n,profile:o}=e,{timeout:r,maxRetries:a}=v(e),m=async(s,f)=>{if(t||f.headers?.[K]==null){let c=!1,d=!1,q=await N.loadConfig({environmentVariableSelector:(l)=>{let E=l[R];if(d=!!E&&E!=="false",E===void 0)throw new N.CredentialsProviderError(`${R} not set in env, checking config file next.`,{logger:e.logger});return d},configFileSelector:(l)=>{let E=l[W];return c=!!E&&E!=="false",c},default:!1},{profile:o})();if(e.ec2MetadataV1Disabled||q){let l=[];if(e.ec2MetadataV1Disabled)l.push("credential provider initialization (runtime option ec2MetadataV1Disabled)");if(c)l.push(`config file profile (${W})`);if(d)l.push(`process environment variable (${R})`);throw new D(`AWS EC2 Metadata v1 fallback has been blocked by AWS SDK configuration in the following: [${l.join(", ")}].`)}}let H=(await A(async()=>{let c;try{c=await ie(f)}catch(d){if(d.statusCode===401)t=!1;throw d}return c},s)).trim();return A(async()=>{let c;try{c=await ce(H,f,e)}catch(d){if(d.statusCode===401)t=!1;throw d}return c},s)};return async()=>{let s=await k();if(t)return n?.debug("AWS SDK Instance Metadata","using v1 fallback (no token fetch)"),m(a,{...s,timeout:r});else{let f;try{f=(await se({...s,timeout:r})).toString()}catch(T){if(T?.statusCode===400)throw Object.assign(T,{message:"EC2 Metadata token request returned error"});else if(T.message==="TimeoutError"||[403,404,405].includes(T.statusCode))t=!0;return n?.debug("AWS SDK Instance Metadata","using v1 fallback (initial)"),m(a,{...s,timeout:r})}return m(a,{...s,headers:{[K]:f},timeout:r})}}},se=async(e)=>_({...e,path:re,method:"PUT",headers:{"x-aws-ec2-metadata-token-ttl-seconds":"21600"}}),ie=async(e)=>(await _({...e,path:G})).toString(),ce=async(e,t,n)=>{let o=JSON.parse((await _({...t,path:G+e})).toString());if(!h(o))throw new N.CredentialsProviderError("Invalid response received from instance metadata service.",{logger:n.logger});return C(o)};export{S as ENV_CMDS_FULL_URI,O as ENV_CMDS_RELATIVE_URI,Y as fromContainerMetadata,ne as fromInstanceMetadata};
@@ -0,0 +1,10 @@
1
+ // @bun
2
+ import"./chunk-hat3s3pr.js";import"./chunk-c25s4w6a.js";import{xr}from"./chunk-v9fea96h.js";import{st,Xe,at}from"./chunk-g2k3yhgh.js";import{He}from"./chunk-ve7qx8wm.js";import{Er}from"./chunk-bj14jshr.js";import{q,j}from"./chunk-y69ewdn2.js";import{Ee,V,ee}from"./chunk-rjdhaasf.js";import{z}from"./chunk-dakrpbe6.js";import{$n,Gr}from"./chunk-9y69ywyg.js";import{N,ht,ue,te,ge,ye,H}from"./chunk-sf13azm4.js";import{M,Ve,qt,Te}from"./chunk-0rya8cxe.js";var ve="https://chatgpt.com/backend-api",Re="https://api.openai.com/auth",Ce=0,re=1000,xe=60000,Oe=15000,Ae=3,fe=new Set(["openai","openai-codex","opencode"]),Me=1009,We="websocket_connection_limit_reached",Le="previous_response_not_found",De=new Set(["completed","incomplete","failed","cancelled","queued","in_progress"]);function ne(e){if(e.stopReason==="pending")throw Error("Codex stream ended without a stop reason");if(e.stopReason==="error"||e.stopReason==="aborted")throw Error(e.errorMessage||"An unknown error occurred")}function Ne(e){return/GoUsageLimitError|FreeUsageLimitError|Monthly usage limit reached|available balance|insufficient_quota|out of budget|quota exceeded|billing/i.test(e)}function qe(e,r){if(e===429&&Ne(r))return!1;if(e===429||e===500||e===502||e===503||e===504)return!0;return/rate.?limit|overloaded|service.?unavailable|upstream.?connect|connection.?refused/i.test(r)}function Be(e){let r=e.get("retry-after-ms");if(r!==null){let s=Number(r);if(Number.isFinite(s))return Math.max(0,s)}let t=e.get("retry-after");if(!t)return;let n=Number(t);if(Number.isFinite(n))return Math.max(0,n*1000);let o=Date.parse(t);if(!Number.isNaN(o))return Math.max(0,o-Date.now());return}class Y extends Error{}function Pe(e,r){let t=r?.maxRetryDelayMs??xe;if(t>0&&e>t)throw new Y(`Server requested ${Math.ceil(e/1000)}s retry delay (max: ${Math.ceil(t/1000)}s)`);return e}function se(e,r){return new Promise((t,n)=>{if(r?.aborted){n(Error("Request was aborted"));return}let o=setTimeout(t,e);r?.addEventListener("abort",()=>{clearTimeout(o),n(Error("Request was aborted"))})})}function oe(e){if(e===void 0)return;if(!Number.isFinite(e)||e<0)throw Error(`Invalid timeoutMs: ${String(e)}`);return Math.floor(e)}function Ie(){if(typeof process>"u"||!(process.versions?.node||process.versions?.bun))return null;return process.getBuiltinModule?.("node:zlib")??null}function Fe(e){let r=Ie();if(!r||typeof r.zstdCompressSync!=="function")return null;try{let t=r.zstdCompressSync(e,{params:{[r.constants.ZSTD_c_compressionLevel]:Ae}});return new Uint8Array(t)}catch{return null}}var Ue=(e,r,t)=>{let n=new M,o=te(r,e.compat?.supportsMidConvoSystemMessages);return(async()=>{let s={role:"assistant",content:[],api:"openai-codex-responses",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 i=t?.apiKey;if(!i)throw Error(`No API key for provider: ${e.provider}`);let u=_t(i),a=Ee(ge(o.messages),e.compat?.supportsOpenAIGrammarTools??!1),d=t?.cacheRetention==="none"?void 0:t?.sessionId,p=He(d),c=$e(e,o,t,p,a),l=await t?.onPayload?.(c,e);if(l!==void 0)c=l;let f=p||Gr(),m=kt(e.headers,t?.headers,u,i,p),b=Tt(e.headers,t?.headers,u,i,f),h=JSON.stringify(c),E=oe(t?.timeoutMs),w=oe(t?.websocketConnectTimeoutMs),v=t?.transport||"auto",T=!1,y=v!=="sse"&&be(d);if(y)ie(d);if(v!=="sse"&&!y){let S=!1,k=!1,O=!1;while(!0){S=!1;try{if(await St(Je(e.baseUrl),c,b,s,n,e,()=>{if(S=!0,!T)T=!0,n.push({type:"start",partial:s})},E,w,d,u,a,t),t?.signal?.aborted)throw Error("Request was aborted");ne(s),n.push({type:"done",reason:s.stopReason,message:s}),n.end();return}catch(R){let B=t?.signal?.aborted,P=!S&&je(R),W=Ye(R);if(!B&&W&&!O){O=!0;continue}if(!B&&P&&!k){k=!0;continue}if(B||Ge(R)&&!P)throw R;if(Te(s,qt("provider_transport_failure",R,{configuredTransport:v,...S?{}:{fallbackTransport:"sse"},eventsEmitted:S,phase:S?"after_message_stream_start":"before_message_stream_start",requestBytes:new TextEncoder().encode(h).byteLength})),it(d,R),S)throw R;ie(d);break}}}let x=Fe(h);if(x)m.set("content-encoding","zstd");let A=x??h,_,D,K=t?.maxRetries??Ce;for(let S=0;S<=K;S++){if(t?.signal?.aborted)throw Error("Request was aborted");try{let k=E!==void 0&&E>0?AbortSignal.timeout(E):void 0,O=xr([t?.signal,k]);try{_=await(t?.fetch??globalThis.fetch)(pe(e.baseUrl),{method:"POST",headers:m,body:A,signal:O.signal})}catch(W){if(k?.aborted&&!t?.signal?.aborted)throw Error(`Codex SSE response headers timed out after ${E}ms`);throw W}finally{O.cleanup()}if(await t?.onResponse?.({status:_.status,headers:z(_.headers)},e),_.ok)break;let R=await _.text();if(S<K&&qe(_.status,R)){let W=Be(_.headers),ke=W===void 0?re*2**S:Pe(W,t);await se(ke,t?.signal);continue}let B=new Response(R,{status:_.status,statusText:_.statusText}),P=await Et(B);throw Error(P.friendlyMessage||P.message)}catch(k){if(k instanceof Error){if(k.name==="AbortError"||k.message==="Request was aborted")throw Error("Request was aborted")}if(D=k instanceof Error?k:Error(String(k)),S<K&&!(D instanceof Y)&&!D.message.includes("usage limit")){let O=re*2**S;await se(O,t?.signal);continue}throw D}}if(!_?.ok)throw D??Error("Failed after retries");if(!_.body)throw Error("No response body");if(!T)T=!0,n.push({type:"start",partial:s});if(await Ke(_,s,n,e,a,t),t?.signal?.aborted)throw Error("Request was aborted");ne(s),n.push({type:"done",reason:s.stopReason,message:s}),n.end()}catch(i){for(let u of s.content)delete u.partialJson,delete u.customInput;s.stopReason=t?.signal?.aborted?"aborted":"error",s.errorMessage=j(q(i)),n.push({type:"error",reason:s.stopReason,error:s}),n.end()}})(),n},$t=(e,r,t)=>{let n=t?.apiKey;if(!n)throw Error(`No API key for provider: ${e.provider}`);let o={...V(e,r,t,n),toolChoice:t?.toolChoice},s=t?.reasoning?H(e,t.reasoning):void 0;return Ue(e,r,{...o,reasoningEffort:s==="off"?void 0:s})};function $e(e,r,t,n,o=Ee(ge(r.messages),e.compat?.supportsOpenAIGrammarTools??!1)){let s=e.compat?.supportsStrictMode??!0,i=e.compat?.supportsOpenAIGrammarTools??!1,u=e.compat?.supportsAdditionalTools??!1,a=e.compat?.supportsToolSearch??!1,d=ye(r.messages,u||a),p=st(e,r,fe,{includeSystemPrompt:!1,grammarToolInputProperties:o,supportsMidConvoSystemMessages:e.compat?.supportsMidConvoSystemMessages??!1,supportsAdditionalTools:u,supportsToolSearch:a,toolOptions:{strict:null,supportsStrictMode:s,supportsOpenAIGrammarTools:i}}),c=ue(r.messages),l=c?N(c):"",f={model:e.id,store:!1,stream:!0,instructions:l||"You are a helpful assistant.",input:p,text:{verbosity:t?.textVerbosity||"low"},include:["reasoning.encrypted_content"],prompt_cache_key:n,tool_choice:t?.toolChoice??"auto",parallel_tool_calls:!0};if(t?.temperature!==void 0)f.temperature=t.temperature;if(t?.serviceTier!==void 0)f.service_tier=t.serviceTier;if(d.requestTools.length>0)f.tools=Xe(d.requestTools,{strict:null,supportsStrictMode:s,supportsOpenAIGrammarTools:i});if(t?.reasoningEffort!==void 0){let m=t.reasoningEffort==="none"?e.thinkingLevelMap?.off===void 0?"none":e.thinkingLevelMap.off:e.thinkingLevelMap?.[t.reasoningEffort]??t.reasoningEffort;if(m!==null)f.reasoning={effort:m,summary:t.reasoningSummary??"auto"}}else if(e.reasoning&&e.thinkingLevelMap?.off!==null)f.reasoning={effort:e.thinkingLevelMap?.off??"none"};return f}function ze(e,r){switch(r){case"flex":return 0.5;case"priority":return e.id==="gpt-5.5"?2.5:2;default:return 1}}function le(e,r,t){let n=ze(t,r);if(n===1)return;e.cost.input*=n,e.cost.output*=n,e.cost.cacheRead*=n,e.cost.cacheWrite*=n,e.cost.total=e.cost.input+e.cost.output+e.cost.cacheRead+e.cost.cacheWrite}function de(e,r){if(e==="default"&&(r==="flex"||r==="priority"))return r;return e??r}function pe(e){let t=(e&&e.trim().length>0?e:ve).replace(/\/+$/,"");if(t.endsWith("/codex/responses"))return t;if(t.endsWith("/codex"))return`${t}/responses`;return`${t}/codex/responses`}function Je(e){let r=new URL(pe(e));if(r.protocol==="https:")r.protocol="wss:";if(r.protocol==="http:")r.protocol="ws:";return r.toString()}async function Ke(e,r,t,n,o,s){await at(me(et(e,s?.signal),r,n,s?.onProviderStreamEvent),r,t,n,{serviceTier:s?.serviceTier,grammarToolInputProperties:o,resolveServiceTier:de,applyServiceTierPricing:(i,u)=>le(i,u,n)})}class L extends Error{code;payload;constructor(e,r){super(e);this.name="CodexApiError",this.code=r?.code,this.payload=r?.payload,this.cause=r?.cause}}class J extends Error{payload;constructor(e,r){super(e);this.name="CodexProtocolError",this.payload=r?.payload,this.cause=r?.cause}}class Z extends Error{constructor(e){super(Ve(e));this.name="ProviderStreamEventCallbackError",this.cause=e}}function Ge(e){return e instanceof L||e instanceof J||e instanceof Z}function je(e){return e instanceof L&&e.code===We}function Ye(e){return e instanceof L&&e.code===Le}function Ze(e){let r=e.error&&typeof e.error==="object"?e.error:void 0;return{code:typeof e.code==="string"?e.code:typeof r?.code==="string"?r.code:void 0,message:typeof e.message==="string"?e.message:typeof r?.message==="string"?r.message:void 0}}async function*me(e,r,t,n){for await(let o of e){try{await n?.(o,t)}catch(i){throw new Z(i)}let s=typeof o.type==="string"?o.type:void 0;if(!s)continue;if(s==="error"){let{code:i,message:u}=Ze(o);throw new L(`Codex error: ${u||i||JSON.stringify(o)}`,{code:i,payload:o})}if(s==="response.failed"){let i=o.response,u=i?.error?.code,a=i?.error?.message;throw new L(a||"Codex response failed",{code:u,payload:o})}if(s==="response.done"||s==="response.completed"||s==="response.incomplete"){let i=o.response;if(typeof i?.end_turn==="boolean")r.endTurn=i.end_turn;let u=i?{...i,status:Qe(i.status)}:i;yield{...o,type:"response.completed",response:u};return}yield o}}function Qe(e){if(typeof e!=="string")return;return De.has(e)?e:void 0}async function*et(e,r){if(!e.body)return;let t=e.body.getReader(),n=new TextDecoder,o="",s=()=>{t.cancel().catch(()=>{})};r?.addEventListener("abort",s,{once:!0});try{while(!0){if(r?.aborted)throw Error("Request was aborted");let{done:i,value:u}=await t.read();if(r?.aborted)throw Error("Request was aborted");if(o+=i?n.decode():n.decode(u,{stream:!0}),i&&o.trim())o+=`
3
+
4
+ `;let a=o.indexOf(`
5
+
6
+ `);while(a!==-1){let d=o.slice(0,a);o=o.slice(a+2);let p=d.split(`
7
+ `).filter((c)=>c.startsWith("data:")).map((c)=>c.slice(5).trim());if(p.length>0){let c=p.join(`
8
+ `).trim();if(c&&c!=="[DONE]")try{yield JSON.parse(c)}catch(l){throw new J(`Invalid Codex SSE JSON: ${Ve(l)}`,{cause:l,payload:c})}}a=o.indexOf(`
9
+
10
+ `)}if(i)break}}finally{r?.removeEventListener("abort",s);try{await t.cancel()}catch{}try{t.releaseLock()}catch{}}}var tt="responses_websockets=2026-02-06",rt=300000,nt=3300000,g=new Map,I=new Map,U=new Set;function Q(e){let r=I.get(e);if(!r)r={requests:0,connectionsCreated:0,connectionsReused:0,cachedContextRequests:0,storeTrueRequests:0,fullContextRequests:0,deltaRequests:0,lastInputItems:0,websocketFailures:0,sseFallbacks:0},I.set(e,r);return r}function zt(e){let r=I.get(e);return r?{...r}:void 0}function Jt(e){if(e){I.delete(e),U.delete(e);return}I.clear(),U.clear()}function ot(e){let r=(t)=>{if(t.idleTimer)clearTimeout(t.idleTimer);C(t.socket,1000,"debug_close")};if(e){for(let t of g.get(e)?.values()??[])r(t);g.delete(e);return}for(let t of g.values())for(let n of t.values())r(n);g.clear()}$n(ot);function be(e){return e?U.has(e):!1}function ie(e){if(!e)return;let r=Q(e);r.sseFallbacks++,r.websocketFallbackActive=be(e)}function it(e,r){if(!e)return;U.add(e);let t=Q(e);t.websocketFailures++,t.lastWebSocketError=Ve(r),t.websocketFallbackActive=!0}var G=null;async function ct(e){if(!e&&G)return G;if(typeof process<"u"&&process.versions?.bun){let t=class extends WebSocket{constructor(n,o){let s={};if(Array.isArray(o)||typeof o==="string")s={protocols:o};else s={...o};let i=Er(n.toString().replace(/^wss:/,"https:").replace(/^ws:/,"http:"),e);super(n,{...s,...i?{proxy:i.toString()}:{}})}};if(!e)G=t;return t}let r=globalThis.WebSocket;if(typeof r!=="function")return null;return r}class he extends Error{code;reason;wasClean;constructor(e,r){super(e);this.name="WebSocketCloseError",this.code=r?.code,this.reason=r?.reason,this.wasClean=r?.wasClean}}function ut(e){let r=e.readyState;return typeof r==="number"?r:void 0}function F(e){let r=ut(e);return r===void 0||r===1}function ft(e){return Date.now()-e.createdAt>=nt}function C(e,r=1000,t="done"){try{e.close(r,t)}catch{}}function ae(e,r,t){if(t.idleTimer)clearTimeout(t.idleTimer);t.idleTimer=setTimeout(()=>{if(t.busy)return;C(t.socket,1000,"idle_timeout");let n=g.get(e);if(n?.get(r)===t)n.delete(r);if(n?.size===0)g.delete(e)},rt)}async function X(e,r,t,n=Oe,o){let s=await ct(o);if(!s)throw Error("WebSocket transport is not available in this runtime");let i=z(r);return delete i["OpenAI-Beta"],new Promise((u,a)=>{let d=!1,p,c;try{c=new s(e,{headers:i})}catch(w){a(w instanceof Error?w:Error(String(w)));return}let l=()=>{if(p)clearTimeout(p),p=void 0;c.removeEventListener("open",m),c.removeEventListener("error",b),c.removeEventListener("close",h),t?.removeEventListener("abort",E)},f=(w,v)=>{if(d)return;if(d=!0,l(),v)C(c,1000,v);a(w)},m=()=>{if(d)return;d=!0,l(),u(c)},b=(w)=>{f(we(w))},h=(w)=>{f(Se(w))},E=()=>{f(Error("Request was aborted"),"aborted")};if(c.addEventListener("open",m),c.addEventListener("error",b),c.addEventListener("close",h),t?.addEventListener("abort",E),n>0)p=setTimeout(()=>{f(Error(`WebSocket connect timeout after ${n}ms`),"connect_timeout")},n);if(t?.aborted)E()})}async function lt(e,r,t,n,o,s,i){if(!t){let c=await X(e,r,o,s,i);return{socket:c,reused:!1,release:()=>C(c)}}let u=g.get(t),a=u?.get(n);if(a){if(a.idleTimer)clearTimeout(a.idleTimer),a.idleTimer=void 0;if(!a.busy&&ft(a)){if(C(a.socket,1000,"connection_age_limit"),u?.delete(n),u?.size===0)g.delete(t)}else if(!a.busy&&F(a.socket))return a.busy=!0,{socket:a.socket,entry:a,reused:!0,release:({keep:c}={})=>{if(!c||!F(a.socket)){C(a.socket);let l=g.get(t);if(l?.get(n)===a)l.delete(n);if(l?.size===0)g.delete(t);return}a.busy=!1,ae(t,n,a)}};if(a.busy){let c=await X(e,r,o,s,i);return{socket:c,reused:!1,release:()=>{C(c)}}}if(!F(a.socket)){if(C(a.socket),u?.delete(n),u?.size===0)g.delete(t)}}let d=await X(e,r,o,s,i),p={socket:d,busy:!0,createdAt:Date.now()};if(u=g.get(t),!u)u=new Map,g.set(t,u);return u.set(n,p),{socket:d,entry:p,reused:!1,release:({keep:c}={})=>{if(!c||!F(p.socket)){if(C(p.socket),p.idleTimer)clearTimeout(p.idleTimer);let l=g.get(t);if(l?.get(n)===p)l.delete(n);if(l?.size===0)g.delete(t);return}p.busy=!1,ae(t,n,p)}}}function we(e){if(e&&typeof e==="object"){let r="message"in e?e.message:void 0;if(typeof r==="string"&&r.length>0)return Error(r);let t="error"in e?e.error:void 0;if(t instanceof Error&&t.message.length>0)return t;if(t&&typeof t==="object"&&"message"in t){let n=t.message;if(typeof n==="string"&&n.length>0)return Error(n)}}return Error("WebSocket error")}function Se(e){if(e&&typeof e==="object"){let r="code"in e?e.code:void 0,t="reason"in e?e.reason:void 0,n="wasClean"in e?e.wasClean:void 0,o=typeof r==="number"?` ${r}`:"",s=typeof t==="string"&&t.length>0?` ${t}`:"";if(!s&&r===Me)s=" message too big";return new he(`WebSocket closed${o}${s}`.trim(),{code:typeof r==="number"?r:void 0,reason:typeof t==="string"&&t.length>0?t:void 0,wasClean:typeof n==="boolean"?n:void 0})}return Error("WebSocket closed")}async function dt(e){if(typeof e==="string")return e;if(e instanceof ArrayBuffer)return new TextDecoder().decode(new Uint8Array(e));if(ArrayBuffer.isView(e)){let r=e;return new TextDecoder().decode(new Uint8Array(r.buffer,r.byteOffset,r.byteLength))}if(e&&typeof e==="object"&&"arrayBuffer"in e){let t=await e.arrayBuffer();return new TextDecoder().decode(new Uint8Array(t))}return null}async function*pt(e,r,t){let n=[],o=null,s=!1,i=null,u=!1,a=()=>{if(!o)return;let f=o;o=null,f()},d=(f)=>{(async()=>{let m=null;try{if(!f||typeof f!=="object"||!("data"in f))return;if(m=await dt(f.data),!m)return;let b=JSON.parse(m),h=typeof b.type==="string"?b.type:"";if(h==="response.completed"||h==="response.done"||h==="response.incomplete")u=!0,s=!0;n.push(b),a()}catch(b){i=new J(`Invalid Codex WebSocket JSON: ${Ve(b)}`,{cause:b,payload:m}),s=!0,a()}})()},p=(f)=>{i=we(f),s=!0,a()},c=(f)=>{if(u){s=!0,a();return}if(!i)i=Se(f);s=!0,a()},l=()=>{i=Error("Request was aborted"),s=!0,a()};e.addEventListener("message",d),e.addEventListener("error",p),e.addEventListener("close",c),r?.addEventListener("abort",l);try{while(!0){if(r?.aborted)throw Error("Request was aborted");if(n.length>0){yield n.shift();continue}if(s)break;let f;await new Promise((m,b)=>{if(o=m,t!==void 0&&t>0)f=setTimeout(()=>{let h=Error(`WebSocket idle timeout after ${t}ms`);i=h,s=!0,o=null,C(e,1000,"idle_timeout"),b(h)},t)}).finally(()=>{if(f)clearTimeout(f)})}if(i)throw i;if(!u)throw Error("WebSocket stream closed before response.completed")}finally{e.removeEventListener("message",d),e.removeEventListener("error",p),e.removeEventListener("close",c),r?.removeEventListener("abort",l)}}function ce(e){let{input:r,previous_response_id:t,...n}=e;return n}function mt(e,r){return JSON.stringify(e??[])===JSON.stringify(r??[])}function yt(e,r){return JSON.stringify(ce(e))===JSON.stringify(ce(r))}function bt(e,r){if(!yt(e,r.lastRequestBody))return;let t=e.input??[],n=[...r.lastRequestBody.input??[],...r.lastResponseItems];if(t.length<n.length)return;let o=t.slice(0,n.length);if(!mt(o,n))return;return t.slice(n.length)}function wt(e,r){let t=e.continuation;if(!t)return r;let n=bt(r,t);if(!n||!t.lastResponseId)return e.continuation=void 0,r;return{...r,previous_response_id:t.lastResponseId,input:n}}async function*gt(e,r){let t=!1;for await(let n of e){if(!t)t=!0,r();yield n}}async function St(e,r,t,n,o,s,i,u,a,d,p,c,l){let{socket:f,entry:m,reused:b,release:h}=await lt(e,t,d,p,l?.signal,a,l?.env),E=!0,w=l?.transport==="websocket-cached"||l?.transport==="auto",v=r,T=w&&m?wt(m,v):v,y=d?Q(d):void 0;if(y){if(y.requests++,b)y.connectionsReused++;else y.connectionsCreated++;if(w)y.cachedContextRequests++;if(T.store===!0)y.storeTrueRequests++;if(y.lastInputItems=T.input?.length??0,T.previous_response_id)y.deltaRequests++,y.lastDeltaInputItems=T.input?.length??0,y.lastPreviousResponseId=T.previous_response_id;else y.fullContextRequests++,y.lastDeltaInputItems=void 0,y.lastPreviousResponseId=void 0}try{if(f.send(JSON.stringify({type:"response.create",...T})),await at(gt(me(pt(f,l?.signal,u),n,s,l?.onProviderStreamEvent),i),n,o,s,{serviceTier:l?.serviceTier,grammarToolInputProperties:c,resolveServiceTier:de,applyServiceTierPricing:(x,A)=>le(x,A,s)}),l?.signal?.aborted)E=!1;else if(w&&m&&n.responseId){let x=st(s,ht({messages:[n]}),fe,{includeSystemPrompt:!1,grammarToolInputProperties:c}).filter((A)=>A.type!=="function_call_output"&&A.type!=="custom_tool_call_output");m.continuation={lastRequestBody:v,lastResponseId:n.responseId,lastResponseItems:x}}}catch(x){if(m)m.continuation=void 0;throw E=!1,x}finally{h({keep:E})}}async function Et(e){let r=await e.text(),t=r||e.statusText||"Request failed",n;try{let s=JSON.parse(r)?.error;if(s){let i=s.code||s.type||"";if(/usage_limit_reached|usage_not_included|rate_limit_exceeded/i.test(i)||e.status===429){let u=s.plan_type?` (${s.plan_type.toLowerCase()} plan)`:"",a=s.resets_at?Math.max(0,Math.round((s.resets_at*1000-Date.now())/60000)):void 0,d=a!==void 0?` Try again in ~${a} min.`:"";n=`You have hit your ChatGPT usage limit${u}.${d}`.trim()}t=s.message||n||t}}catch{}return{message:t,friendlyMessage:n}}function _t(e){try{let r=e.split(".");if(r.length!==3)throw Error("Invalid token");let n=JSON.parse(atob(r[1]))?.[Re]?.chatgpt_account_id;if(!n)throw Error("No account ID in token");return n}catch{throw Error("Failed to extract accountId from token")}}function _e(e,r,t,n){let o=new Headers({originator:"pi","User-Agent":ee()});for(let[s,i]of Object.entries(e||{}))o.set(s,i);for(let[s,i]of Object.entries(r||{}))if(i===null)o.delete(s);else o.set(s,i);return o.set("Authorization",`Bearer ${n}`),o.set("chatgpt-account-id",t),o}function kt(e,r,t,n,o){let s=_e(e,r,t,n);if(s.set("OpenAI-Beta","responses=experimental"),s.set("accept","text/event-stream"),s.set("content-type","application/json"),o)s.set("session-id",o),s.set("x-client-request-id",o);return s}function Tt(e,r,t,n,o){let s=_e(e,r,t,n);return s.delete("accept"),s.delete("content-type"),s.delete("OpenAI-Beta"),s.delete("openai-beta"),s.set("OpenAI-Beta",tt),s.set("x-client-request-id",o),s.set("session-id",o),s}export{ot as closeOpenAICodexWebSocketSessions,zt as getOpenAICodexWebSocketDebugStats,Jt as resetOpenAICodexWebSocketDebugStats,Ue as stream,$t as streamSimple};