@redocly/cli 2.53.3 → 2.54.1

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 (120) hide show
  1. package/README.md +1 -1
  2. package/lib/chunks/{T376AHHQ.js → 23QBFBKB.js} +1 -1
  3. package/lib/chunks/{IMWIJK4I.js → 2MBZI3W3.js} +2 -1
  4. package/lib/chunks/{BST7IEDL.js → 2NS7AGPD.js} +1 -1
  5. package/lib/chunks/2TLIBL23.js +8 -0
  6. package/lib/chunks/{Q3XI4H3K.js → 3BJIJBSJ.js} +1 -1
  7. package/lib/chunks/3RDMQ5CQ.js +13 -0
  8. package/lib/chunks/{O6EXHS4S.js → 4G34OIRT.js} +1 -1
  9. package/lib/chunks/{J2VIXY4S.js → 4JE7GYQB.js} +1 -1
  10. package/lib/chunks/{NMVCH6CZ.js → 5KMAESVG.js} +1 -1
  11. package/lib/chunks/7IULUVWX.js +13 -0
  12. package/lib/chunks/AHGQ4BNI.js +30 -0
  13. package/lib/chunks/ALXOGCUM.js +8 -0
  14. package/lib/chunks/AM6FT7EB.js +9 -0
  15. package/lib/chunks/{C25ULQVR.js → BYIMEGON.js} +1 -1
  16. package/lib/chunks/{C4FLQ63T.js → C27G2ZXO.js} +1 -1
  17. package/lib/chunks/{6ER74AF4.js → CI4NGJ3I.js} +3 -3
  18. package/lib/chunks/{CPXI7K7L.js → CKJYJBJ6.js} +1 -1
  19. package/lib/chunks/{VL4UXBSF.js → ENDHNS6Y.js} +1 -1
  20. package/lib/chunks/{XX6OZNQL.js → FIIFOPJG.js} +1 -1
  21. package/lib/chunks/{CXNOQVEB.js → FTDJMTRX.js} +1 -1
  22. package/lib/chunks/{BNWXU2OA.js → FUCJM4CG.js} +1 -1
  23. package/lib/chunks/H4XURXR7.js +47 -0
  24. package/lib/chunks/{W3YACFG2.js → IPVLUS43.js} +1 -1
  25. package/lib/chunks/{GM5FQCWY.js → IW2J6X26.js} +4 -4
  26. package/lib/chunks/{EDS62CRZ.js → IZ2TZVJD.js} +1 -1
  27. package/lib/chunks/{4BHLSA4G.js → J7GIHRZA.js} +1 -1
  28. package/lib/chunks/{T2XFX5KV.js → JH4AUZLH.js} +1 -1
  29. package/lib/chunks/{RI6WFA4F.js → KEF4233Y.js} +6 -6
  30. package/lib/chunks/{2HTEK7CB.js → KW7NKDOX.js} +1 -1
  31. package/lib/chunks/{QE555QD2.js → KZMFETIJ.js} +1 -1
  32. package/lib/chunks/{7V5AWKRU.js → L24E6ZRY.js} +3 -3
  33. package/lib/chunks/LLGJ3YMR.js +85 -0
  34. package/lib/chunks/{2LLR76SN.js → LT2PEIAT.js} +1 -1
  35. package/lib/chunks/{GBTKUMLF.js → MZCEUZSS.js} +1 -1
  36. package/lib/chunks/{JXAKPU5V.js → Q7ARG2G6.js} +1 -1
  37. package/lib/chunks/QZBHV7SD.js +7 -0
  38. package/lib/chunks/{S7LWRM6M.js → RVQFQGGH.js} +1 -1
  39. package/lib/chunks/{UWKKXZOE.js → RW2ESAIF.js} +80 -80
  40. package/lib/chunks/{PDTJPHOV.js → S4H3MC5R.js} +1 -1
  41. package/lib/chunks/SAJRBHEI.js +19 -0
  42. package/lib/chunks/{MXEA2HJF.js → SZKF6VFY.js} +485 -473
  43. package/lib/chunks/TZMWTSOQ.js +7 -0
  44. package/lib/chunks/{MEVUBG5J.js → UAEEHSSK.js} +2 -2
  45. package/lib/chunks/{TOCY6E4B.js → UWNBPAWG.js} +1 -1
  46. package/lib/chunks/{TXEDXTQA.js → UYHX7364.js} +1 -1
  47. package/lib/chunks/VTKYS75A.js +13 -0
  48. package/lib/chunks/{DFCB4ULY.js → W6X4HEU3.js} +1 -1
  49. package/lib/chunks/{JT5UMLP2.js → XFRPQNF6.js} +1 -1
  50. package/lib/chunks/XRZ5NMQ5.js +13 -0
  51. package/lib/chunks/Y6E4JAM3.js +16 -0
  52. package/lib/chunks/{GJKYTFLY.js → YDSFHQXH.js} +3 -3
  53. package/lib/chunks/ZBK7SJHM.js +7 -0
  54. package/lib/chunks/{4RWMTNRF.js → ZDNSHHXT.js} +1 -1
  55. package/lib/chunks/ZDQDZTQ7.js +7 -0
  56. package/lib/eject-assets/generators/cli/docs.ts +1 -1
  57. package/lib/eject-assets/generators/cli/engine-source.ts +1 -1
  58. package/lib/eject-assets/generators/cli/index.ts +2 -2
  59. package/lib/eject-assets/generators/cli/render.ts +1 -1
  60. package/lib/eject-assets/generators/go/client.ts +1 -1
  61. package/lib/eject-assets/generators/go/descriptor.ts +1 -1
  62. package/lib/eject-assets/generators/go/index.ts +2 -2
  63. package/lib/eject-assets/generators/go/models.ts +1 -1
  64. package/lib/eject-assets/generators/go/naming.ts +1 -1
  65. package/lib/eject-assets/generators/go/operations.ts +1 -1
  66. package/lib/eject-assets/generators/go/pagination.ts +1 -1
  67. package/lib/eject-assets/generators/go/types.ts +1 -1
  68. package/lib/eject-assets/generators/mock/faker.ts +1 -1
  69. package/lib/eject-assets/generators/mock/index.ts +2 -2
  70. package/lib/eject-assets/generators/mock/render.ts +1 -1
  71. package/lib/eject-assets/generators/mock/sample.ts +1 -1
  72. package/lib/eject-assets/generators/mock/values.ts +1 -1
  73. package/lib/eject-assets/generators/php/client.ts +1 -1
  74. package/lib/eject-assets/generators/php/descriptor.ts +1 -1
  75. package/lib/eject-assets/generators/php/index.ts +2 -2
  76. package/lib/eject-assets/generators/php/models.ts +1 -1
  77. package/lib/eject-assets/generators/php/naming.ts +1 -1
  78. package/lib/eject-assets/generators/php/operations.ts +1 -1
  79. package/lib/eject-assets/generators/php/pagination.ts +1 -1
  80. package/lib/eject-assets/generators/php/types.ts +1 -1
  81. package/lib/eject-assets/generators/python/client.ts +1 -1
  82. package/lib/eject-assets/generators/python/descriptor.ts +1 -1
  83. package/lib/eject-assets/generators/python/index.ts +2 -2
  84. package/lib/eject-assets/generators/python/models.ts +1 -1
  85. package/lib/eject-assets/generators/python/naming.ts +1 -1
  86. package/lib/eject-assets/generators/python/operations.ts +1 -1
  87. package/lib/eject-assets/generators/python/pagination.ts +1 -1
  88. package/lib/eject-assets/generators/python/types.ts +1 -1
  89. package/lib/eject-assets/generators/swr/index.ts +2 -2
  90. package/lib/eject-assets/generators/swr/render.ts +1 -1
  91. package/lib/eject-assets/generators/tanstack-query/index.ts +2 -2
  92. package/lib/eject-assets/generators/tanstack-query/render.ts +1 -1
  93. package/lib/eject-assets/generators/transformers/index.ts +2 -2
  94. package/lib/eject-assets/generators/transformers/render.ts +1 -1
  95. package/lib/eject-assets/generators/typescript/banner.ts +1 -1
  96. package/lib/eject-assets/generators/typescript/client.ts +1 -1
  97. package/lib/eject-assets/generators/typescript/descriptor.ts +1 -1
  98. package/lib/eject-assets/generators/typescript/index.ts +2 -2
  99. package/lib/eject-assets/generators/typescript/inline-runtime.ts +1 -1
  100. package/lib/eject-assets/generators/typescript/operation-signature.ts +1 -1
  101. package/lib/eject-assets/generators/typescript/operation-types.ts +1 -1
  102. package/lib/eject-assets/generators/typescript/operations.ts +1 -1
  103. package/lib/eject-assets/generators/typescript/response-headers.ts +1 -1
  104. package/lib/eject-assets/generators/typescript/type-guards.ts +1 -1
  105. package/lib/eject-assets/generators/typescript/types.ts +1 -1
  106. package/lib/eject-assets/generators/zod/index.ts +2 -2
  107. package/lib/eject-assets/generators/zod/schemas.ts +1 -1
  108. package/lib/index.js +157 -276
  109. package/package.json +1 -1
  110. package/lib/chunks/32XCOMOR.js +0 -7
  111. package/lib/chunks/6LHYZTIP.js +0 -48
  112. package/lib/chunks/6NEJXWUE.js +0 -7
  113. package/lib/chunks/BGOL5GAO.js +0 -19
  114. package/lib/chunks/KXHIHQWX.js +0 -13
  115. package/lib/chunks/OFAMJNQ6.js +0 -7
  116. package/lib/chunks/P26PQ2RU.js +0 -7
  117. package/lib/chunks/R6Q6FO6R.js +0 -14
  118. package/lib/chunks/RS5PUOTT.js +0 -18
  119. package/lib/chunks/UF33MFZE.js +0 -22
  120. package/lib/chunks/VH573B5Z.js +0 -7
@@ -4,7 +4,7 @@ import { dirname as __pathDirname } from 'node:path';
4
4
  const require = __createRequire(import.meta.url);
5
5
  var __filename = __fileURLToPath(import.meta.url);
6
6
  var __dirname = __pathDirname(__filename);
7
- import{a as G}from"./CXNOQVEB.js";import{c as x,d as C,e as fe,h as N,j as I,k as ue,v as _,w as B}from"./BNWXU2OA.js";import{a as ie,b as Y,c as ae,f as ce,g as pe}from"./R6Q6FO6R.js";import{b as se}from"./IMWIJK4I.js";import{B as re,C as v,W as S,c as g,da as oe,l as O}from"./UWKKXZOE.js";import"./NEWT5A6S.js";import"./RFWIIJFG.js";import{mkdir as jt,writeFile as kt}from"node:fs/promises";import At from"node:path";var Be=/^[a-zA-Z][a-zA-Z0-9]*(?:[_\-.][a-zA-Z0-9]+)*$/,De=/^[0-9a-f-]{8,}$/i,ze=[["uuid",/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i],["date-time",/^\d{4}-\d{2}-\d{2}[Tt]\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:[Zz]|[+-]\d{2}:\d{2})$/],["date",/^\d{4}-\d{2}-\d{2}$/],["email",/^[^\s@]+@[^\s@]+\.[^\s@]+$/],["uri",/^https?:\/\/\S+$/],["ipv4",/^(?:(?:25[0-5]|2[0-4]\d|1?\d?\d)\.){3}(?:25[0-5]|2[0-4]\d|1?\d?\d)$/]],M=new WeakMap;function D(e){return{formats:ze.filter(([,t])=>t.test(e)).map(([t])=>t),values:[e],count:1,overflow:!1}}function q(e,t){if(!e)return t;if(!t)return e;let n={formats:e.formats.filter(r=>t.formats.includes(r)),values:[],count:e.count+t.count,overflow:e.overflow||t.overflow};if(!n.overflow){let r=[...e.values];for(let o of t.values)r.includes(o)||r.push(o);r.length>10?n.overflow=!0:n.values=r}return n}function z(e,t){M.set(e,t)}function H(e){return M.get(e)}function V(e,t){let n=M.get(e);n&&M.set(t,n)}function He(e){return e.length<=30&&!De.test(e)&&Be.test(e)}function K(e,t){return e.formats.length>0?{format:e.formats[0]}:t&&!e.overflow&&e.count>=4&&e.values.length>0&&e.values.length<=5&&e.values.length*2<=e.count&&e.values.every(He)?{enum:[...e.values].sort()}:{}}function $(e){let t=M.get(e);if(t){let n=typeof e.type=="string"?[e.type]:e.type??[];n.includes("string")&&Object.assign(e,K(t,n.length===1))}for(let n of Object.values(e.properties??{}))$(n);e.additionalProperties&&$(e.additionalProperties),e.items&&$(e.items);for(let n of e.oneOf??[])$(n)}function me(e){for(let t of Object.values(e.paths))for(let n of Object.values(t)){for(let r of Object.values(n.requestBody?.content??{}))$(r.schema);for(let r of Object.values(n.responses))for(let o of Object.values(r.content??{}))$(o.schema)}for(let t of Object.values(e.components?.schemas??{}))$(t);return e}var be=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,F=/^\d+$/,Ve=/^[0-9a-hjkmnp-tv-z]{26}$/i,Ue=/^[a-z][a-z0-9]*_(?=[0-9a-z]*\d)[0-9a-z]{10,}$/i,Fe=/^[a-z](?=[a-z0-9]*\d)[a-z0-9]{23,24}$/,X=new Set(pe),Le=new Set(["get","head"]),de="application/x-www-form-urlencoded",le="multipart/form-data";function Ye(e){return e?F.test(e)||be.test(e)||Ve.test(e)||Ue.test(e)||Fe.test(e)?!0:/^[0-9a-f]{16,}$/i.test(e):!1}function Z(e){let t=e.split("/"),n=[],r=new Set;return{template:t.map((s,c)=>{if(!Ye(s))return s;let i=t[c-1],a=i?`${O(i,1)}Id`:"id",p=1;for(;r.has(a);)p+=1,a=i?`${O(i,1)}Id${p}`:`id${p}`;return r.add(a),n.push({name:a,value:s}),`{${a}}`}).join("/")||"/",params:n}}function j(e){if(e===null)return{type:"null"};if(Array.isArray(e)){if(e.length===0)return{type:"array"};let t=e.slice(0,20).map(j);return{type:"array",items:J(t)}}switch(typeof e){case"string":{let t={type:"string"};return z(t,D(e)),t}case"boolean":return{type:"boolean"};case"number":return Number.isInteger(e)?{type:"integer"}:{type:"number"};case"object":{let t=Object.entries(e);if(t.length>0&&(t.every(([c])=>F.test(c))||t.every(([c])=>be.test(c))))return{type:"object",additionalProperties:J(t.map(([,c])=>j(c)))};let n={},r=[];for(let[s,c]of t)n[s]=j(c),r.push(s);let o={type:"object",properties:n};return r.length>0&&(o.required=r),o}default:return{}}}function J(e){if(e.length===0)return{};let[t,...n]=e,r=t;for(let o of n)r=U(r,o);return r}function he(e){return Object.keys(e).length===0}function k(e){return e.additionalProperties?"map":e.type==="object"?"object":e.type==="array"?"array":"scalar"}function W(e){return e.oneOf?e.oneOf.flatMap(W):Array.isArray(e.type)?e.type.map(t=>{if(t==="object"){let r={type:"object"};return e.properties&&(r.properties=e.properties),e.required&&(r.required=e.required),e.additionalProperties&&(r.additionalProperties=e.additionalProperties),r}if(t==="array")return e.items?{type:"array",items:e.items}:{type:"array"};let n={type:t};return t==="string"&&V(e,n),n}):[e]}var Ke=.5,We=3;function Oe(e,t){let n=Object.keys(e.properties??{}),r=Object.keys(t.properties??{});if(n.length===0||r.length===0)return 1;let o=new Set(r),s=n.filter(c=>o.has(c)).length;return s/(n.length+r.length-s)}function Xe(e,t){let n=k(e);if(n!==k(t))return!1;switch(n){case"scalar":return e.type===t.type||e.type==="integer"&&t.type==="number"||e.type==="number"&&t.type==="integer";case"object":return Oe(e,t)>=Ke;default:return!0}}function ve(e,t){switch(k(e)){case"scalar":{if(e.type!==t.type)return{type:"number"};if(e.type==="string"){let n=q(H(e),H(t));if(n){let r={type:"string"};return z(r,n),r}}return e}case"map":return{type:"object",additionalProperties:U(e.additionalProperties??{},t.additionalProperties??{})};case"object":{let n={...e.properties??{}};for(let[c,i]of Object.entries(t.properties??{}))n[c]=n[c]?U(n[c],i):i;let r=new Set(t.required??[]),o=(e.required??[]).filter(c=>r.has(c)),s={type:"object",properties:n};return o.length>0&&(s.required=o),s}case"array":{if(!e.items||!t.items){let n=e.items??t.items;return n?{type:"array",items:n}:{type:"array"}}return{type:"array",items:U(e.items,t.items)}}}}function Ze(e){let t=[...e],n=()=>t.filter(r=>k(r)==="object").length;for(;n()>We;){let r=-1,o=-1,s=-1;for(let c=0;c<t.length;c++)if(k(t[c])==="object")for(let i=c+1;i<t.length;i++){if(k(t[i])!=="object")continue;let a=Oe(t[c],t[i]);a>s&&(s=a,r=c,o=i)}t[r]=ve(t[r],t[o]),t.splice(o,1)}return t}var Qe=["boolean","integer","number","string","null"];function et(e){if(e.length===1)return e[0];let t=[],n=new Set,r;for(let i of e)k(i)==="scalar"&&typeof i.type=="string"?(n.add(i.type),i.type==="string"&&(r=q(r,H(i)))):t.push(i);let o=Qe.filter(i=>n.has(i)),s=i=>{let a={type:i};return(typeof i=="string"?i==="string":i.includes("string"))&&r&&z(a,r),a};if(t.length===0)return o.length===1?s(o[0]):s(o);if(t.length===1&&o.length===1&&o[0]==="null"&&typeof t[0].type=="string")return{...t[0],type:[t[0].type,"null"]};let c=[...t];return o.length===1?c.push(s(o[0])):o.length>1&&c.push(s(o)),{oneOf:c}}function U(e,t){if(he(e)||he(t))return{};let n=W(e);for(let r of W(t)){let o=n.findIndex(s=>Xe(s,r));o===-1?n.push(r):n[o]=ve(n[o],r)}return et(Ze(n))}function tt(e){if(!e)return;let t=e.trim();if(!(!t.startsWith("{")&&!t.startsWith("[")))try{return JSON.parse(t)}catch{return}}function nt(e,t){let n=t?.match(/boundary="?([^";,]+)"?/i)?.[1];if(!n)return;let r={};for(let o of e.split(`--${n}`)){let s=o.match(/^\r?\n([\s\S]*?)\r?\n\r?\n([\s\S]*)\r?\n$/);if(!s)continue;let[,c,i]=s,a=c.match(/\bname="([^"]*)"/i)?.[1];a!==void 0&&(r[a]=/\bfilename="/i.test(c)?{type:"string",format:"binary"}:j(i))}if(Object.keys(r).length!==0)return{type:"object",properties:r,required:Object.keys(r)}}function ge(e){let t=I(e.contentType);if(e.bodyJson!==void 0)return{mime:ue(t)?t:"application/json",schema:j(e.bodyJson)};if(t===de&&e.bodyText){let r={};for(let[o,s]of new URLSearchParams(e.bodyText))r[o]=s;return Object.keys(r).length===0?void 0:{mime:de,schema:j(r)}}if(t===le&&e.bodyText){let r=nt(e.bodyText,e.contentType);return r?{mime:le,schema:r}:void 0}let n=tt(e.bodyText);if(n!==void 0)return{mime:"application/json",schema:j(n)}}function ye(e,t,n){let r=e.get(t);e.set(t,r?J([r,n]):n)}async function we(e){let t=await C(e.trafficPath);if(t.length===0)throw new Error("No traffic files found in the provided traffic path.");let n=_(e.server),r=new Map,o=new Set,s=0,c=a=>{let p=a.request.method.toLowerCase();if(!X.has(p))return;let f=a.request.path||"/";if(n){let u=B(a.request,n);if(u===void 0)return;f=u}else a.request.host&&!fe(a.request.host)&&o.add(`${a.request.protocol}//${a.request.host}`);let{template:m,params:d}=Z(N(f)),P=`${p} ${m}`,h=r.get(P);h||(h={method:p,template:m,pathParams:new Map,queryParams:new Map,requestBodies:new Map,responses:new Map},r.set(P,h));for(let{name:u,value:l}of d){let y=h.pathParams.get(u);h.pathParams.set(u,{numeric:(y?.numeric??!0)&&F.test(l),observations:q(y?.observations,D(l))})}for(let u of new Set(a.request.query.keys())){let l=a.request.query.getAll(u),y=h.queryParams.get(u),T=l.length>0&&l.every(b=>F.test(b)),R=y?.observations;for(let b of l)R=q(R,D(b));h.queryParams.set(u,{numeric:(y?.numeric??!0)&&T,observations:R})}if(!Le.has(p)){let u=ge(a.request);u&&ye(h.requestBodies,u.mime,u.schema)}if(a.response&&a.response.status>=100){let u=String(a.response.status),l=h.responses.get(u);l||(l={bodies:new Map},h.responses.set(u,l)),l.statusText??=a.response.statusText||void 0;let y=ge(a.response);y&&ye(l.bodies,y.mime,y.schema)}};for(let a of t){let p=await G(a,e.format);if(!p){S.warn(`Skipping traffic file with unrecognized format: ${a}
7
+ import{a as G}from"./FTDJMTRX.js";import{c as x,d as C,e as fe,h as N,j as I,k as ue,v as _,w as B}from"./FUCJM4CG.js";import{a as ie,b as Y,c as ae,d as ce,e as pe}from"./XRZ5NMQ5.js";import"./ALXOGCUM.js";import{C as re,D as v,X as S,c as g,ea as oe,l as O,na as se}from"./RW2ESAIF.js";import"./NEWT5A6S.js";import"./RFWIIJFG.js";import{mkdir as jt,writeFile as kt}from"node:fs/promises";import At from"node:path";var Be=/^[a-zA-Z][a-zA-Z0-9]*(?:[_\-.][a-zA-Z0-9]+)*$/,De=/^[0-9a-f-]{8,}$/i,ze=[["uuid",/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i],["date-time",/^\d{4}-\d{2}-\d{2}[Tt]\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:[Zz]|[+-]\d{2}:\d{2})$/],["date",/^\d{4}-\d{2}-\d{2}$/],["email",/^[^\s@]+@[^\s@]+\.[^\s@]+$/],["uri",/^https?:\/\/\S+$/],["ipv4",/^(?:(?:25[0-5]|2[0-4]\d|1?\d?\d)\.){3}(?:25[0-5]|2[0-4]\d|1?\d?\d)$/]],M=new WeakMap;function D(e){return{formats:ze.filter(([,t])=>t.test(e)).map(([t])=>t),values:[e],count:1,overflow:!1}}function q(e,t){if(!e)return t;if(!t)return e;let n={formats:e.formats.filter(r=>t.formats.includes(r)),values:[],count:e.count+t.count,overflow:e.overflow||t.overflow};if(!n.overflow){let r=[...e.values];for(let o of t.values)r.includes(o)||r.push(o);r.length>10?n.overflow=!0:n.values=r}return n}function z(e,t){M.set(e,t)}function H(e){return M.get(e)}function V(e,t){let n=M.get(e);n&&M.set(t,n)}function He(e){return e.length<=30&&!De.test(e)&&Be.test(e)}function K(e,t){return e.formats.length>0?{format:e.formats[0]}:t&&!e.overflow&&e.count>=4&&e.values.length>0&&e.values.length<=5&&e.values.length*2<=e.count&&e.values.every(He)?{enum:[...e.values].sort()}:{}}function $(e){let t=M.get(e);if(t){let n=typeof e.type=="string"?[e.type]:e.type??[];n.includes("string")&&Object.assign(e,K(t,n.length===1))}for(let n of Object.values(e.properties??{}))$(n);e.additionalProperties&&$(e.additionalProperties),e.items&&$(e.items);for(let n of e.oneOf??[])$(n)}function me(e){for(let t of Object.values(e.paths))for(let n of Object.values(t)){for(let r of Object.values(n.requestBody?.content??{}))$(r.schema);for(let r of Object.values(n.responses))for(let o of Object.values(r.content??{}))$(o.schema)}for(let t of Object.values(e.components?.schemas??{}))$(t);return e}var be=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,F=/^\d+$/,Ve=/^[0-9a-hjkmnp-tv-z]{26}$/i,Ue=/^[a-z][a-z0-9]*_(?=[0-9a-z]*\d)[0-9a-z]{10,}$/i,Fe=/^[a-z](?=[a-z0-9]*\d)[a-z0-9]{23,24}$/,X=new Set(pe),Le=new Set(["get","head"]),de="application/x-www-form-urlencoded",le="multipart/form-data";function Ye(e){return e?F.test(e)||be.test(e)||Ve.test(e)||Ue.test(e)||Fe.test(e)?!0:/^[0-9a-f]{16,}$/i.test(e):!1}function Z(e){let t=e.split("/"),n=[],r=new Set;return{template:t.map((s,c)=>{if(!Ye(s))return s;let i=t[c-1],a=i?`${O(i,1)}Id`:"id",p=1;for(;r.has(a);)p+=1,a=i?`${O(i,1)}Id${p}`:`id${p}`;return r.add(a),n.push({name:a,value:s}),`{${a}}`}).join("/")||"/",params:n}}function j(e){if(e===null)return{type:"null"};if(Array.isArray(e)){if(e.length===0)return{type:"array"};let t=e.slice(0,20).map(j);return{type:"array",items:J(t)}}switch(typeof e){case"string":{let t={type:"string"};return z(t,D(e)),t}case"boolean":return{type:"boolean"};case"number":return Number.isInteger(e)?{type:"integer"}:{type:"number"};case"object":{let t=Object.entries(e);if(t.length>0&&(t.every(([c])=>F.test(c))||t.every(([c])=>be.test(c))))return{type:"object",additionalProperties:J(t.map(([,c])=>j(c)))};let n={},r=[];for(let[s,c]of t)n[s]=j(c),r.push(s);let o={type:"object",properties:n};return r.length>0&&(o.required=r),o}default:return{}}}function J(e){if(e.length===0)return{};let[t,...n]=e,r=t;for(let o of n)r=U(r,o);return r}function he(e){return Object.keys(e).length===0}function k(e){return e.additionalProperties?"map":e.type==="object"?"object":e.type==="array"?"array":"scalar"}function W(e){return e.oneOf?e.oneOf.flatMap(W):Array.isArray(e.type)?e.type.map(t=>{if(t==="object"){let r={type:"object"};return e.properties&&(r.properties=e.properties),e.required&&(r.required=e.required),e.additionalProperties&&(r.additionalProperties=e.additionalProperties),r}if(t==="array")return e.items?{type:"array",items:e.items}:{type:"array"};let n={type:t};return t==="string"&&V(e,n),n}):[e]}var Ke=.5,We=3;function Oe(e,t){let n=Object.keys(e.properties??{}),r=Object.keys(t.properties??{});if(n.length===0||r.length===0)return 1;let o=new Set(r),s=n.filter(c=>o.has(c)).length;return s/(n.length+r.length-s)}function Xe(e,t){let n=k(e);if(n!==k(t))return!1;switch(n){case"scalar":return e.type===t.type||e.type==="integer"&&t.type==="number"||e.type==="number"&&t.type==="integer";case"object":return Oe(e,t)>=Ke;default:return!0}}function ve(e,t){switch(k(e)){case"scalar":{if(e.type!==t.type)return{type:"number"};if(e.type==="string"){let n=q(H(e),H(t));if(n){let r={type:"string"};return z(r,n),r}}return e}case"map":return{type:"object",additionalProperties:U(e.additionalProperties??{},t.additionalProperties??{})};case"object":{let n={...e.properties??{}};for(let[c,i]of Object.entries(t.properties??{}))n[c]=n[c]?U(n[c],i):i;let r=new Set(t.required??[]),o=(e.required??[]).filter(c=>r.has(c)),s={type:"object",properties:n};return o.length>0&&(s.required=o),s}case"array":{if(!e.items||!t.items){let n=e.items??t.items;return n?{type:"array",items:n}:{type:"array"}}return{type:"array",items:U(e.items,t.items)}}}}function Ze(e){let t=[...e],n=()=>t.filter(r=>k(r)==="object").length;for(;n()>We;){let r=-1,o=-1,s=-1;for(let c=0;c<t.length;c++)if(k(t[c])==="object")for(let i=c+1;i<t.length;i++){if(k(t[i])!=="object")continue;let a=Oe(t[c],t[i]);a>s&&(s=a,r=c,o=i)}t[r]=ve(t[r],t[o]),t.splice(o,1)}return t}var Qe=["boolean","integer","number","string","null"];function et(e){if(e.length===1)return e[0];let t=[],n=new Set,r;for(let i of e)k(i)==="scalar"&&typeof i.type=="string"?(n.add(i.type),i.type==="string"&&(r=q(r,H(i)))):t.push(i);let o=Qe.filter(i=>n.has(i)),s=i=>{let a={type:i};return(typeof i=="string"?i==="string":i.includes("string"))&&r&&z(a,r),a};if(t.length===0)return o.length===1?s(o[0]):s(o);if(t.length===1&&o.length===1&&o[0]==="null"&&typeof t[0].type=="string")return{...t[0],type:[t[0].type,"null"]};let c=[...t];return o.length===1?c.push(s(o[0])):o.length>1&&c.push(s(o)),{oneOf:c}}function U(e,t){if(he(e)||he(t))return{};let n=W(e);for(let r of W(t)){let o=n.findIndex(s=>Xe(s,r));o===-1?n.push(r):n[o]=ve(n[o],r)}return et(Ze(n))}function tt(e){if(!e)return;let t=e.trim();if(!(!t.startsWith("{")&&!t.startsWith("[")))try{return JSON.parse(t)}catch{return}}function nt(e,t){let n=t?.match(/boundary="?([^";,]+)"?/i)?.[1];if(!n)return;let r={};for(let o of e.split(`--${n}`)){let s=o.match(/^\r?\n([\s\S]*?)\r?\n\r?\n([\s\S]*)\r?\n$/);if(!s)continue;let[,c,i]=s,a=c.match(/\bname="([^"]*)"/i)?.[1];a!==void 0&&(r[a]=/\bfilename="/i.test(c)?{type:"string",format:"binary"}:j(i))}if(Object.keys(r).length!==0)return{type:"object",properties:r,required:Object.keys(r)}}function ge(e){let t=I(e.contentType);if(e.bodyJson!==void 0)return{mime:ue(t)?t:"application/json",schema:j(e.bodyJson)};if(t===de&&e.bodyText){let r={};for(let[o,s]of new URLSearchParams(e.bodyText))r[o]=s;return Object.keys(r).length===0?void 0:{mime:de,schema:j(r)}}if(t===le&&e.bodyText){let r=nt(e.bodyText,e.contentType);return r?{mime:le,schema:r}:void 0}let n=tt(e.bodyText);if(n!==void 0)return{mime:"application/json",schema:j(n)}}function ye(e,t,n){let r=e.get(t);e.set(t,r?J([r,n]):n)}async function we(e){let t=await C(e.trafficPath);if(t.length===0)throw new Error("No traffic files found in the provided traffic path.");let n=_(e.server),r=new Map,o=new Set,s=0,c=a=>{let p=a.request.method.toLowerCase();if(!X.has(p))return;let f=a.request.path||"/";if(n){let u=B(a.request,n);if(u===void 0)return;f=u}else a.request.host&&!fe(a.request.host)&&o.add(`${a.request.protocol}//${a.request.host}`);let{template:m,params:d}=Z(N(f)),P=`${p} ${m}`,h=r.get(P);h||(h={method:p,template:m,pathParams:new Map,queryParams:new Map,requestBodies:new Map,responses:new Map},r.set(P,h));for(let{name:u,value:l}of d){let y=h.pathParams.get(u);h.pathParams.set(u,{numeric:(y?.numeric??!0)&&F.test(l),observations:q(y?.observations,D(l))})}for(let u of new Set(a.request.query.keys())){let l=a.request.query.getAll(u),y=h.queryParams.get(u),T=l.length>0&&l.every(b=>F.test(b)),R=y?.observations;for(let b of l)R=q(R,D(b));h.queryParams.set(u,{numeric:(y?.numeric??!0)&&T,observations:R})}if(!Le.has(p)){let u=ge(a.request);u&&ye(h.requestBodies,u.mime,u.schema)}if(a.response&&a.response.status>=100){let u=String(a.response.status),l=h.responses.get(u);l||(l={bodies:new Map},h.responses.set(u,l)),l.statusText??=a.response.statusText||void 0;let y=ge(a.response);y&&ye(l.bodies,y.mime,y.schema)}};for(let a of t){let p=await G(a,e.format);if(!p){S.warn(`Skipping traffic file with unrecognized format: ${a}
8
8
  `);continue}s+=1;for await(let f of p.parse(a))c(f)}if(s===0)throw new Error("No supported traffic files found to generate an OpenAPI description from.");if(r.size===0)throw new Error(n?`No HTTP exchanges in the traffic matched the server "${n}".`:"No HTTP exchanges were observed in the traffic. Cannot generate an OpenAPI description.");let i=n?[n]:Array.from(o).sort();return rt(r,e.title??"Generated API",i)}function Pe(e){return Object.values(e.paths).reduce((t,n)=>t+Object.keys(n).length,0)}function Se(e,t){if(e.numeric)return{type:"integer"};let n={type:"string"};return e.observations&&Object.assign(n,K(e.observations,t)),n}function rt(e,t,n){let r={};for(let o of e.values()){let s=r[o.template]??={},c=[...Array.from(o.pathParams).map(([a,p])=>({name:a,in:"path",required:!0,schema:Se(p,!1)})),...Array.from(o.queryParams).map(([a,p])=>({name:a,in:"query",required:!1,schema:Se(p,!0)}))],i={operationId:ot(o.method,o.template),responses:{}};if(c.length>0&&(i.parameters=c),o.requestBodies.size>0){let a={};for(let[p,f]of o.requestBodies)a[p]={schema:f};i.requestBody={content:a}}if(o.responses.size===0)i.responses.default={description:"Observed response"};else for(let[a,p]of o.responses){let f={description:p.statusText||"Observed response"};if(p.bodies.size>0){let m={};for(let[d,P]of p.bodies)m[d]={schema:P};f.content=m}i.responses[a]=f}s[o.method]=i}return{openapi:"3.2.0",info:{title:t,version:"1.0.0"},...n.length>0?{servers:n.map(o=>({url:o}))}:{},paths:r}}function ot(e,t){let n=t.split("/").filter(Boolean).map(r=>r.replace(/[{}]/g,"")).join("-");return`${e}-${n||"root"}`}function L(e,t){return`${e.toUpperCase()} ${t}`}function Te(e,t){let n;if(e.bodyJson!==void 0)try{n=JSON.stringify(e.bodyJson)}catch{n=void 0}if(n??=e.bodyText,!n)return;let r=n.trim();if(r)return r.length>t?`${r.slice(0,t)}\u2026[truncated]`:r}function $e(e){if(!e)return"";let t=e.bodyJson;return t===void 0?e.bodyText?I(e.contentType)||"text":"":t===null?"null":Array.isArray(t)?`array<${t.length>0?je(t[0]):""}>`:je(t)}function je(e){return g(e)?Object.keys(e).sort().join(","):e===null?"null":typeof e}async function ke(e){let t=e.perGroup??2,n=e.perOperation??4,r=e.maxBodyChars??2e3,o=_(e.server),s=await C(e.trafficPath),c=new Map;for(let a of s){let p=await G(a,e.format);if(p)for await(let f of p.parse(a)){let m=f.request.method.toUpperCase();if(!X.has(m.toLowerCase()))continue;let d=f.request.path||"/";if(o){let ne=B(f.request,o);if(ne===void 0)continue;d=ne}let P=N(d),{template:h}=Z(P),u=f.response&&f.response.status>=100?f.response:void 0,l=u?.status,y=`${$e(f.request)}\u2192${$e(u)}`,T=c.get(L(m,h));T||(T=new Map,c.set(L(m,h),T));let R=`${l??""} ${y}`,b=T.get(R);b||(b=[],T.set(R,b)),!(b.length>=t)&&b.push({method:m,path:P,query:f.request.query.toString(),status:l,requestContentType:f.request.contentType,requestBody:Te(f.request,r),responseContentType:u?.contentType,responseBody:u?Te(u,r):void 0})}}let i=new Map;for(let[a,p]of c){let f=[];for(let m=0;m<t&&f.length<n;m++)for(let d of p.values()){if(f.length>=n)break;d[m]&&f.push(d[m])}i.set(a,f)}return i}var st=`You are an expert API designer. You are given one operation from an OpenAPI 3.2 description that was inferred mechanically from recorded HTTP traffic, the component schemas it references, and a sample of the real recorded HTTP exchanges for that operation. The inferred description is only a hypothesis: types are coarse, every observed property is marked required, and descriptions are missing. Alternative body shapes observed in the traffic appear as "oneOf" variants or type unions. Common string formats (uuid, date-time, date, email, uri, ipv4) and small closed enums are detected conservatively from the observed values.
9
9
 
10
10
  Refine the operation into the most accurate OpenAPI 3.2 definition you can justify from the evidence, while staying conservative:
@@ -43,11 +43,11 @@ ${e.reservedComponentNames.join(", ")}`),t.push(`# Recorded HTTP exchanges for t
43
43
 
44
44
  ${it(e.samples)}`),t.push(`Refine ${e.method.toUpperCase()} ${e.path} as instructed and output only the YAML document.`),{system:st,user:t.join(`
45
45
 
46
- `)}}var Re=/^#\/components\/schemas\/(.+)$/;function Q(e,t){if(Array.isArray(e)){for(let n of e)Q(n,t);return}if(g(e)){if(typeof e.$ref=="string"){let n=e.$ref.match(Re);n&&t.add(n[1])}if(g(e.discriminator)&&g(e.discriminator.mapping)){for(let n of Object.values(e.discriminator.mapping))if(typeof n=="string"){let r=n.match(Re);t.add(r?r[1]:n)}}for(let n of Object.values(e))Q(n,t)}}function Je(e,t){let n=new Set,r=[e];for(;r.length>0;){let o=new Set;Q(r.pop(),o);for(let s of o)!n.has(s)&&s in t&&(n.add(s),r.push(t[s]))}return n}function at(e){let t=e.components?.schemas;if(!t)return;let n=Je(e.paths,t);for(let r of Object.keys(t))n.has(r)||delete t[r];Object.keys(t).length===0&&delete e.components}function ct(e,t,n){let r=ie(e),o;try{o=re(r)}catch(f){throw new Error(`the provider did not return valid YAML: ${f instanceof Error?f.message:String(f)}`)}if(!g(o))throw new Error('the response is not a YAML document with a "paths" object');let s=o.paths;if(!g(s))throw new Error('the response is not a YAML document with a "paths" object');let c=s[t];if(!g(c))throw new Error(`the response does not keep the path template "${t}"`);let i=c[n];if(!g(i))throw new Error(`the response does not contain the ${n.toUpperCase()} operation`);let a=o.components,p=g(a)?a.schemas:void 0;return{operation:i,components:g(p)?p:{}}}function pt(e,t){let n=g(t.responses)?t.responses:{};return Object.keys(e.responses).filter(r=>!(r in n))}async function ft(e){let t=e.document.components?.schemas??{},n=Je(e.operation,t),r={};for(let d of n)r[d]=t[d];let o=Object.keys(t).filter(d=>!n.has(d)),{system:s,user:c}=Ae({path:e.path,method:e.method,operation:e.operation,components:r,reservedComponentNames:o,samples:e.samples}),{text:i}=await ae(e.provider,{system:s,user:c,model:e.model}),a=ct(i,e.path,e.method),p=pt(e.operation,a.operation);if(p.length>0)throw new Error(`the response dropped observed response status(es): ${p.join(", ")}`);if(typeof a.operation.operationId!="string")throw new Error("the response dropped the operationId");let f=Object.keys(a.components).filter(d=>o.includes(d));if(f.length>0)throw new Error(`the response redefines reserved component(s): ${f.join(", ")}`);let m={openapi:e.document.openapi,info:e.document.info,paths:{[e.path]:{[e.method]:a.operation}},components:{schemas:{...t,...a.components}}};return await Y(v(m),e.config),a}function ut(e,t,n,r){e.paths[t][n]=r.operation,Object.keys(r.components).length>0&&(e.components??={schemas:{}},Object.assign(e.components.schemas,r.components))}async function Ee(e){let t=structuredClone(e.baseline),n=await oe({extends:["spec"]}),r=[];for(let[i,a]of Object.entries(e.baseline.paths))for(let[p,f]of Object.entries(a))r.push({path:i,method:p,operation:f});let s=(await ce({items:r,concurrency:e.concurrency??1,action:"Refining",successNote:"refined",failureNote:"kept the baseline",label:({path:i,method:a})=>`${a.toUpperCase()} ${i}`,run:async({path:i,method:a,operation:p})=>{let f=await ft({provider:e.provider,model:e.model,document:t,path:i,method:a,operation:p,samples:e.samplesByOperation.get(L(a,i))??[],config:n});return ut(t,i,a,f),f}})).filter(i=>i!==null).length;if(s===0)throw new Error(`the ${e.provider} provider did not produce a usable refinement for any operation`);at(t);let c=v(t);return await Y(c,n),{yaml:c,document:t,refined:s,total:r.length}}var mt=2,dt=2,lt=.75,ht=2,Me=new Set(["integer","number"]),qe=new WeakMap;function w(e){let t=qe.get(e);if(t!==void 0)return t;let n;if(e.$ref!==void 0)n=`ref(${e.$ref})`;else if(e.oneOf)n=`oneOf(${e.oneOf.map(w).sort().join("|")})`;else{let o=[`type=${(Array.isArray(e.type)?[...e.type].sort().join(","):e.type)??""}`];if(e.properties){let s=Object.entries(e.properties).map(([c,i])=>`${JSON.stringify(c)}:${w(i)}`).sort().join(",");o.push(`props{${s}}`)}e.additionalProperties&&o.push(`values(${w(e.additionalProperties)})`),e.items&&o.push(`items(${w(e.items)})`),n=o.join(";")}return qe.set(e,n),n}function gt(e){return e.$ref===void 0&&e.type==="object"&&e.oneOf===void 0&&e.additionalProperties===void 0&&Object.keys(e.properties??{}).length>=mt}function xe(e,t){for(let n of t)e.set(n,(e.get(n)??0)+1)}function E(e,t,n){if(e.oneOf){e.oneOf.forEach((s,c)=>E(s,{...t,path:`${t.path}/oneOf/${c}`,fallbackHints:[]},n));return}let r=t.container,o=`${t.path}/`;if(gt(e)){let s=w(e),c=n.get(s);c||(c={keys:[s],schemas:[],merged:{},contexts:new Set,primaryVotes:new Map,fallbackVotes:new Map},n.set(s,c)),c.schemas.push(e),c.contexts.add(`${t.container}#${t.path}`),xe(c.primaryVotes,t.primaryHints),xe(c.fallbackVotes,t.fallbackHints),r=s,o=""}for(let[s,c]of Object.entries(e.properties??{}))E(c,{container:r,path:`${o}${s}`,primaryHints:[s],fallbackHints:[]},n);e.additionalProperties&&E(e.additionalProperties,{container:r,path:`${o}additionalProperties`,primaryHints:t.primaryHints.map(s=>O(s,1)),fallbackHints:t.fallbackHints.map(s=>O(s,1))},n),e.items&&E(e.items,{container:r,path:`${o}items`,primaryHints:t.primaryHints.map(s=>O(s,1)),fallbackHints:t.fallbackHints.map(s=>O(s,1))},n)}function yt(e){return e.split("/").filter(n=>n&&!n.startsWith("{")).at(-1)}function St(e){let t=new Map;for(let[n,r]of Object.entries(e.paths)){let o=yt(n),s=o?O(o,1):void 0;for(let[c,i]of Object.entries(r)){for(let[a,p]of Object.entries(i.requestBody?.content??{}))E(p.schema,{container:`request ${c} ${n} ${a}`,path:"",primaryHints:s?[s]:[],fallbackHints:s?[`${s} request`]:[]},t);for(let[a,p]of Object.entries(i.responses)){let f=Number(a)>=400;for(let[m,d]of Object.entries(p.content??{}))E(d.schema,{container:`response ${c} ${n} ${a} ${m}`,path:"",primaryHints:f?["error"]:s?[s]:[],fallbackHints:f?s?[`${s} error`]:[]:s?[`${s} response`]:[]},t)}}}return t}function Ce(e){return Object.keys(e.properties??{})}function bt(e,t){let n=Ce(e),r=new Set(Ce(t)),o=n.filter(c=>r.has(c)).length,s=n.length+r.size-o;return s===0?0:o/s}function Ne(e){if(e.$ref!==void 0||e.properties||e.additionalProperties||e.items||e.oneOf)return;let t=typeof e.type=="string"?[e.type]:e.type;if(!(!t||t.some(n=>n==="object"||n==="array")))return t}function ee(e){return Object.keys(e).length===0}function Ge(e,t){if(w(e)===w(t)||ee(e)||ee(t))return!0;let n=Ne(e),r=Ne(t);if(n&&r){let s=new Set(n.filter(i=>i!=="null")),c=new Set(r.filter(i=>i!=="null"));return s.size===c.size&&[...s].every(i=>c.has(i))?!0:[...s].every(i=>Me.has(i))&&[...c].every(i=>Me.has(i))}let o=s=>s.type==="array"||s.items!==void 0;return o(e)&&o(t)?!e.items||!t.items||Ge(e.items,t.items):!1}function Ot(e,t){let n=t.merged.properties??{};return Object.entries(e.merged.properties??{}).every(([r,o])=>!(r in n)||Ge(o,n[r]))}function vt(e){let t=[...e];for(;t.length>1;){let n=-1,r=-1,o=0;for(let i=0;i<t.length;i++)for(let a=i+1;a<t.length;a++){let p=bt(t[i].merged,t[a].merged);p>=lt&&p>o&&Ot(t[i],t[a])&&(o=p,n=i,r=a)}if(n===-1)break;let s=t[n],c=t[r];s.keys.push(...c.keys),s.schemas.push(...c.schemas),s.merged=J([s.merged,c.merged]);for(let i of c.contexts)s.contexts.add(i);for(let[i,a]of c.primaryVotes)s.primaryVotes.set(i,(s.primaryVotes.get(i)??0)+a);for(let[i,a]of c.fallbackVotes)s.fallbackVotes.set(i,(s.fallbackVotes.get(i)??0)+a);t.splice(r,1)}return t}function te(e,t){return e<t?-1:e>t?1:0}function wt(e){return e.split(/[^a-zA-Z0-9]+/).filter(Boolean).map(t=>t[0].toUpperCase()+t.slice(1)).join("")}function Ie(e){return[...e.entries()].sort(([t,n],[r,o])=>o-n||te(t,r)).map(([t])=>t)}function Pt(e){let t=[...e].sort((r,o)=>o.contexts.size-r.contexts.size||o.schemas.length-r.schemas.length||te(r.keys[0],o.keys[0])),n=new Set;return t.map(r=>{let o=[...Ie(r.primaryVotes),...Ie(r.fallbackVotes)].map(wt).filter(c=>c.length>0);o.length===0&&o.push("Schema");let s=o.find(c=>!n.has(c));for(let c=2;s===void 0;c++){let i=`${o[0]}${c}`;n.has(i)||(s=i)}return n.add(s),{group:r,name:s}})}function A(e,t,n=!1){if(!n){let o=t.get(w(e));if(o!==void 0)return{$ref:`#/components/schemas/${o}`}}let r={...e};return V(e,r),e.properties&&(r.properties=Object.fromEntries(Object.entries(e.properties).map(([o,s])=>[o,A(s,t)]))),e.additionalProperties&&(r.additionalProperties=A(e.additionalProperties,t)),e.items&&(r.items=A(e.items,t)),e.oneOf&&(r.oneOf=e.oneOf.map(o=>A(o,t))),r}function Tt(e){let t=Object.values(e.properties??{}),n=t.filter(r=>r.type==="array"&&(!r.items||ee(r.items)));return n.length>0&&t.length-n.length<=ht}function $t(e){let t=0,n=0;for(let r of e.primaryVotes.values())t+=r,n=Math.max(n,r);return n*2>t}function _e(e){let t=St(e);for(let i of t.values())i.merged=J(i.schemas);let r=vt([...t.values()]).filter(i=>i.contexts.size>=dt&&($t(i)||!i.schemas.some(Tt)));if(r.length===0)return e;let o=Pt(r),s=new Map;for(let{group:i,name:a}of o)for(let p of i.keys)s.set(p,a);let c={};for(let{group:i,name:a}of[...o].sort((p,f)=>te(p.name,f.name)))c[a]=A(i.merged,s,!0);for(let i of Object.values(e.paths))for(let a of Object.values(i)){for(let p of Object.values(a.requestBody?.content??{}))p.schema=A(p.schema,s);for(let p of Object.values(a.responses))for(let f of Object.values(p.content??{}))f.schema=A(f.schema,s)}return e.components={schemas:c},e}async function Rt(e,t){let n=x(e);await jt(At.dirname(n),{recursive:!0}),await kt(n,t,"utf8")}function Jt(e){let t=Math.round(e/1e3),n=Math.floor(t/60),r=t%60;return n>0?`${n}m ${r}s`:`${r}s`}async function yn({argv:e}){if(e.type!=="openapi")return se(`Unsupported spec type "${e.type}". Only "openapi" is supported.`);let t=Date.now(),n=x(e.traffic),r=e["traffic-format"],o=me(_e(await we({trafficPath:n,format:r,title:e.title,server:e.server})));S.info(`Inferred a baseline OpenAPI description from traffic: ${Pe(o)} operation(s).
46
+ `)}}var Re=/^#\/components\/schemas\/(.+)$/;function Q(e,t){if(Array.isArray(e)){for(let n of e)Q(n,t);return}if(g(e)){if(typeof e.$ref=="string"){let n=e.$ref.match(Re);n&&t.add(n[1])}if(g(e.discriminator)&&g(e.discriminator.mapping)){for(let n of Object.values(e.discriminator.mapping))if(typeof n=="string"){let r=n.match(Re);t.add(r?r[1]:n)}}for(let n of Object.values(e))Q(n,t)}}function Je(e,t){let n=new Set,r=[e];for(;r.length>0;){let o=new Set;Q(r.pop(),o);for(let s of o)!n.has(s)&&s in t&&(n.add(s),r.push(t[s]))}return n}function at(e){let t=e.components?.schemas;if(!t)return;let n=Je(e.paths,t);for(let r of Object.keys(t))n.has(r)||delete t[r];Object.keys(t).length===0&&delete e.components}function ct(e,t,n){let r=ie(e),o;try{o=re(r)}catch(f){throw new Error(`the provider did not return valid YAML: ${f instanceof Error?f.message:String(f)}`)}if(!g(o))throw new Error('the response is not a YAML document with a "paths" object');let s=o.paths;if(!g(s))throw new Error('the response is not a YAML document with a "paths" object');let c=s[t];if(!g(c))throw new Error(`the response does not keep the path template "${t}"`);let i=c[n];if(!g(i))throw new Error(`the response does not contain the ${n.toUpperCase()} operation`);let a=o.components,p=g(a)?a.schemas:void 0;return{operation:i,components:g(p)?p:{}}}function pt(e,t){let n=g(t.responses)?t.responses:{};return Object.keys(e.responses).filter(r=>!(r in n))}async function ft(e){let t=e.document.components?.schemas??{},n=Je(e.operation,t),r={};for(let d of n)r[d]=t[d];let o=Object.keys(t).filter(d=>!n.has(d)),{system:s,user:c}=Ae({path:e.path,method:e.method,operation:e.operation,components:r,reservedComponentNames:o,samples:e.samples}),{text:i}=await ae(e.provider,{system:s,user:c,model:e.model}),a=ct(i,e.path,e.method),p=pt(e.operation,a.operation);if(p.length>0)throw new Error(`the response dropped observed response status(es): ${p.join(", ")}`);if(typeof a.operation.operationId!="string")throw new Error("the response dropped the operationId");let f=Object.keys(a.components).filter(d=>o.includes(d));if(f.length>0)throw new Error(`the response redefines reserved component(s): ${f.join(", ")}`);let m={openapi:e.document.openapi,info:e.document.info,paths:{[e.path]:{[e.method]:a.operation}},components:{schemas:{...t,...a.components}}};return await Y(v(m),e.config),a}function ut(e,t,n,r){e.paths[t][n]=r.operation,Object.keys(r.components).length>0&&(e.components??={schemas:{}},Object.assign(e.components.schemas,r.components))}async function Ee(e){let t=structuredClone(e.baseline),n=await oe({extends:["spec"]}),r=[];for(let[i,a]of Object.entries(e.baseline.paths))for(let[p,f]of Object.entries(a))r.push({path:i,method:p,operation:f});let s=(await ce({items:r,concurrency:e.concurrency??1,action:"Refining",successNote:"refined",failureNote:"kept the baseline",label:({path:i,method:a})=>`${a.toUpperCase()} ${i}`,run:async({path:i,method:a,operation:p})=>{let f=await ft({provider:e.provider,model:e.model,document:t,path:i,method:a,operation:p,samples:e.samplesByOperation.get(L(a,i))??[],config:n});return ut(t,i,a,f),f}})).filter(i=>i!==null).length;if(s===0)throw new Error(`the ${e.provider} provider did not produce a usable refinement for any operation`);at(t);let c=v(t);return await Y(c,n),{yaml:c,document:t,refined:s,total:r.length}}var mt=2,dt=2,lt=.75,ht=2,Me=new Set(["integer","number"]),qe=new WeakMap;function w(e){let t=qe.get(e);if(t!==void 0)return t;let n;if(e.$ref!==void 0)n=`ref(${e.$ref})`;else if(e.oneOf)n=`oneOf(${e.oneOf.map(w).sort().join("|")})`;else{let o=[`type=${(Array.isArray(e.type)?[...e.type].sort().join(","):e.type)??""}`];if(e.properties){let s=Object.entries(e.properties).map(([c,i])=>`${JSON.stringify(c)}:${w(i)}`).sort().join(",");o.push(`props{${s}}`)}e.additionalProperties&&o.push(`values(${w(e.additionalProperties)})`),e.items&&o.push(`items(${w(e.items)})`),n=o.join(";")}return qe.set(e,n),n}function gt(e){return e.$ref===void 0&&e.type==="object"&&e.oneOf===void 0&&e.additionalProperties===void 0&&Object.keys(e.properties??{}).length>=mt}function xe(e,t){for(let n of t)e.set(n,(e.get(n)??0)+1)}function E(e,t,n){if(e.oneOf){e.oneOf.forEach((s,c)=>E(s,{...t,path:`${t.path}/oneOf/${c}`,fallbackHints:[]},n));return}let r=t.container,o=`${t.path}/`;if(gt(e)){let s=w(e),c=n.get(s);c||(c={keys:[s],schemas:[],merged:{},contexts:new Set,primaryVotes:new Map,fallbackVotes:new Map},n.set(s,c)),c.schemas.push(e),c.contexts.add(`${t.container}#${t.path}`),xe(c.primaryVotes,t.primaryHints),xe(c.fallbackVotes,t.fallbackHints),r=s,o=""}for(let[s,c]of Object.entries(e.properties??{}))E(c,{container:r,path:`${o}${s}`,primaryHints:[s],fallbackHints:[]},n);e.additionalProperties&&E(e.additionalProperties,{container:r,path:`${o}additionalProperties`,primaryHints:t.primaryHints.map(s=>O(s,1)),fallbackHints:t.fallbackHints.map(s=>O(s,1))},n),e.items&&E(e.items,{container:r,path:`${o}items`,primaryHints:t.primaryHints.map(s=>O(s,1)),fallbackHints:t.fallbackHints.map(s=>O(s,1))},n)}function yt(e){return e.split("/").filter(n=>n&&!n.startsWith("{")).at(-1)}function St(e){let t=new Map;for(let[n,r]of Object.entries(e.paths)){let o=yt(n),s=o?O(o,1):void 0;for(let[c,i]of Object.entries(r)){for(let[a,p]of Object.entries(i.requestBody?.content??{}))E(p.schema,{container:`request ${c} ${n} ${a}`,path:"",primaryHints:s?[s]:[],fallbackHints:s?[`${s} request`]:[]},t);for(let[a,p]of Object.entries(i.responses)){let f=Number(a)>=400;for(let[m,d]of Object.entries(p.content??{}))E(d.schema,{container:`response ${c} ${n} ${a} ${m}`,path:"",primaryHints:f?["error"]:s?[s]:[],fallbackHints:f?s?[`${s} error`]:[]:s?[`${s} response`]:[]},t)}}}return t}function Ce(e){return Object.keys(e.properties??{})}function bt(e,t){let n=Ce(e),r=new Set(Ce(t)),o=n.filter(c=>r.has(c)).length,s=n.length+r.size-o;return s===0?0:o/s}function Ne(e){if(e.$ref!==void 0||e.properties||e.additionalProperties||e.items||e.oneOf)return;let t=typeof e.type=="string"?[e.type]:e.type;if(!(!t||t.some(n=>n==="object"||n==="array")))return t}function ee(e){return Object.keys(e).length===0}function Ge(e,t){if(w(e)===w(t)||ee(e)||ee(t))return!0;let n=Ne(e),r=Ne(t);if(n&&r){let s=new Set(n.filter(i=>i!=="null")),c=new Set(r.filter(i=>i!=="null"));return s.size===c.size&&[...s].every(i=>c.has(i))?!0:[...s].every(i=>Me.has(i))&&[...c].every(i=>Me.has(i))}let o=s=>s.type==="array"||s.items!==void 0;return o(e)&&o(t)?!e.items||!t.items||Ge(e.items,t.items):!1}function Ot(e,t){let n=t.merged.properties??{};return Object.entries(e.merged.properties??{}).every(([r,o])=>!(r in n)||Ge(o,n[r]))}function vt(e){let t=[...e];for(;t.length>1;){let n=-1,r=-1,o=0;for(let i=0;i<t.length;i++)for(let a=i+1;a<t.length;a++){let p=bt(t[i].merged,t[a].merged);p>=lt&&p>o&&Ot(t[i],t[a])&&(o=p,n=i,r=a)}if(n===-1)break;let s=t[n],c=t[r];s.keys.push(...c.keys),s.schemas.push(...c.schemas),s.merged=J([s.merged,c.merged]);for(let i of c.contexts)s.contexts.add(i);for(let[i,a]of c.primaryVotes)s.primaryVotes.set(i,(s.primaryVotes.get(i)??0)+a);for(let[i,a]of c.fallbackVotes)s.fallbackVotes.set(i,(s.fallbackVotes.get(i)??0)+a);t.splice(r,1)}return t}function te(e,t){return e<t?-1:e>t?1:0}function wt(e){return e.split(/[^a-zA-Z0-9]+/).filter(Boolean).map(t=>t[0].toUpperCase()+t.slice(1)).join("")}function Ie(e){return[...e.entries()].sort(([t,n],[r,o])=>o-n||te(t,r)).map(([t])=>t)}function Pt(e){let t=[...e].sort((r,o)=>o.contexts.size-r.contexts.size||o.schemas.length-r.schemas.length||te(r.keys[0],o.keys[0])),n=new Set;return t.map(r=>{let o=[...Ie(r.primaryVotes),...Ie(r.fallbackVotes)].map(wt).filter(c=>c.length>0);o.length===0&&o.push("Schema");let s=o.find(c=>!n.has(c));for(let c=2;s===void 0;c++){let i=`${o[0]}${c}`;n.has(i)||(s=i)}return n.add(s),{group:r,name:s}})}function A(e,t,n=!1){if(!n){let o=t.get(w(e));if(o!==void 0)return{$ref:`#/components/schemas/${o}`}}let r={...e};return V(e,r),e.properties&&(r.properties=Object.fromEntries(Object.entries(e.properties).map(([o,s])=>[o,A(s,t)]))),e.additionalProperties&&(r.additionalProperties=A(e.additionalProperties,t)),e.items&&(r.items=A(e.items,t)),e.oneOf&&(r.oneOf=e.oneOf.map(o=>A(o,t))),r}function Tt(e){let t=Object.values(e.properties??{}),n=t.filter(r=>r.type==="array"&&(!r.items||ee(r.items)));return n.length>0&&t.length-n.length<=ht}function $t(e){let t=0,n=0;for(let r of e.primaryVotes.values())t+=r,n=Math.max(n,r);return n*2>t}function _e(e){let t=St(e);for(let i of t.values())i.merged=J(i.schemas);let r=vt([...t.values()]).filter(i=>i.contexts.size>=dt&&($t(i)||!i.schemas.some(Tt)));if(r.length===0)return e;let o=Pt(r),s=new Map;for(let{group:i,name:a}of o)for(let p of i.keys)s.set(p,a);let c={};for(let{group:i,name:a}of[...o].sort((p,f)=>te(p.name,f.name)))c[a]=A(i.merged,s,!0);for(let i of Object.values(e.paths))for(let a of Object.values(i)){for(let p of Object.values(a.requestBody?.content??{}))p.schema=A(p.schema,s);for(let p of Object.values(a.responses))for(let f of Object.values(p.content??{}))f.schema=A(f.schema,s)}return e.components={schemas:c},e}async function Rt(e,t){let n=x(e);await jt(At.dirname(n),{recursive:!0}),await kt(n,t,"utf8")}function Jt(e){let t=Math.round(e/1e3),n=Math.floor(t/60),r=t%60;return n>0?`${n}m ${r}s`:`${r}s`}async function gn({argv:e}){if(e.type!=="openapi")throw new se(`Unsupported spec type "${e.type}". Only "openapi" is supported.`);let t=Date.now(),n=x(e.traffic),r=e["traffic-format"],o=me(_e(await we({trafficPath:n,format:r,title:e.title,server:e.server})));S.info(`Inferred a baseline OpenAPI description from traffic: ${Pe(o)} operation(s).
47
47
  `);let s=v(o);if(e["with-ai"]){let c=e["ai-provider"];S.info(`Refining the description with AI provider "${c}"...
48
48
  `),S.warn(`Note: --with-ai sends samples of the recorded traffic (URLs, query strings, request and response bodies) to the selected AI provider. Make sure the traffic contains no secrets or personal data you are not allowed to share.
49
49
  `);let i=await ke({trafficPath:n,format:r,server:e.server});try{let a=await Ee({provider:c,model:e["ai-model"],baseline:o,samplesByOperation:i,concurrency:e["ai-concurrency"]});s=a.yaml,S.info(`AI refinement complete: ${a.refined} of ${a.total} operation(s) refined (${c}).
50
50
  `)}catch(a){S.warn(`AI refinement failed, falling back to the baseline description: ${a instanceof Error?a.message:String(a)}
51
51
  `)}}e.output?(await Rt(e.output,s),S.info(`Written to: ${x(e.output)}
52
52
  `)):S.output(s),S.info(`Done in ${Jt(Date.now()-t)}.
53
- `)}export{yn as handleGenerateSpec};
53
+ `)}export{gn as handleGenerateSpec};
@@ -4,4 +4,4 @@ import { dirname as __pathDirname } from 'node:path';
4
4
  const require = __createRequire(import.meta.url);
5
5
  var __filename = __fileURLToPath(import.meta.url);
6
6
  var __dirname = __pathDirname(__filename);
7
- import{a,b,c,d,e}from"./EDS62CRZ.js";import"./2U6O26CV.js";import"./T2XFX5KV.js";import"./MEVUBG5J.js";import"./WZXA5XPB.js";import"./UWKKXZOE.js";import"./NEWT5A6S.js";import"./UW4UC7ZI.js";import"./RFWIIJFG.js";export{e as goDocs,c as goGenerator,d as goSample,a as goType,b as renderGoModels};
7
+ import{a,b,c,d,e}from"./IZ2TZVJD.js";import"./2U6O26CV.js";import"./JH4AUZLH.js";import"./UAEEHSSK.js";import"./WZXA5XPB.js";import"./RW2ESAIF.js";import"./NEWT5A6S.js";import"./UW4UC7ZI.js";import"./RFWIIJFG.js";export{e as goDocs,c as goGenerator,d as goSample,a as goType,b as renderGoModels};
@@ -4,4 +4,4 @@ import { dirname as __pathDirname } from 'node:path';
4
4
  const require = __createRequire(import.meta.url);
5
5
  var __filename = __fileURLToPath(import.meta.url);
6
6
  var __dirname = __pathDirname(__filename);
7
- import{a as l}from"./PDTJPHOV.js";import{a as R,b as u,c as f,d}from"./NMVCH6CZ.js";import{d as y,e as G,f as x}from"./JT5UMLP2.js";import{c as g,d as S,e as h}from"./EDS62CRZ.js";import{c as k,d as v,e as b}from"./C25ULQVR.js";import{a as D,b as E,c as q,d as z}from"./GBTKUMLF.js";import{a as o}from"./2LLR76SN.js";import{a,b as p,c as s}from"./DFCB4ULY.js";import"./2U6O26CV.js";import{a as m}from"./XX6OZNQL.js";import{a as i}from"./JM7BMZLD.js";import{a as c}from"./4BHLSA4G.js";import"./BST7IEDL.js";import{a as I,d as M,e as N}from"./W3YACFG2.js";import{a as H,b as K,c as tr,d as or,e as nr,f as ar,g as pr,h as sr,i as mr}from"./T2XFX5KV.js";import"./MEVUBG5J.js";import{a as U}from"./WZXA5XPB.js";import"./UWKKXZOE.js";import"./NEWT5A6S.js";import{e as T,h as j,k as w}from"./LD5MEXEL.js";import{a as _,b as B,c as F,d as J,e as Q,f as P,g as V,h as W,i as X,j as Y,k as Z,l as $,m as rr,n as er}from"./UW4UC7ZI.js";import"./RFWIIJFG.js";var A={typescript:{run:a,sample:s,docs:p},zod:{run:m},transformers:{run:i},"tanstack-query":{run:o("react")},"tanstack-query-vue":{run:o("vue")},"tanstack-query-svelte":{run:o("svelte")},"tanstack-query-solid":{run:o("solid")},swr:{run:c},mock:{run:l},cli:{run:u,sample:d,docs:f},python:{run:y,sample:G,docs:x},go:{run:g,sample:S,docs:h},php:{run:k,sample:v,docs:b}},L=Object.fromEntries(Object.entries(D).map(([e,{load:r,...t}])=>[e,{...t,...A[e]}]));function n(){return new Map(Object.entries(L))}function C(e,r,t=n(),O){E(e,r,t,O)}function br(e,r){let t=r.registry??n();return C(r.generators,r.emit,t,r.outputMode),q(e,{...r,registry:t})}export{mr as AUTHORING_HELPER_NAMES,U as NotSupportedError,_ as Printer,F as RESERVED_WORDS,B as casing,j as codeLiteral,br as collectGeneratedFiles,P as deref,W as discriminatorCases,$ as docText,Z as enumValues,V as flattenAllOf,z as generateClient,er as headerCoerceType,J as identifierFor,nr as isMultipartBody,X as isNullable,tr as jsonSuccessSchema,I as operationSignature,sr as paginationItemSchema,H as paginationRuleFor,w as pascalCase,R as renderComposedCliEntry,K as renderReferencePage,T as safeIdent,rr as schemaAtPointer,pr as securityRequirements,ar as serverUrlParts,or as sseResponse,M as tsJsdoc,N as tsType,Q as uniqueIdentifiers,Y as unwrapNullable};
7
+ import{a as R,b as u,c as f,d}from"./5KMAESVG.js";import{d as y,e as G,f as x}from"./XFRPQNF6.js";import{c as g,d as S,e as h}from"./IZ2TZVJD.js";import{c as k,d as v,e as b}from"./BYIMEGON.js";import{a as D,b as E,c as q,d as z}from"./MZCEUZSS.js";import{a as o}from"./LT2PEIAT.js";import{a,b as p,c as s}from"./W6X4HEU3.js";import"./2U6O26CV.js";import{a as m}from"./FIIFOPJG.js";import{a as i}from"./JM7BMZLD.js";import{a as c}from"./J7GIHRZA.js";import"./2NS7AGPD.js";import{a as I,d as M,e as N}from"./IPVLUS43.js";import{a as l}from"./S4H3MC5R.js";import{a as H,b as K,c as tr,d as or,e as nr,f as ar,g as pr,h as sr,i as mr}from"./JH4AUZLH.js";import"./UAEEHSSK.js";import{a as U}from"./WZXA5XPB.js";import"./RW2ESAIF.js";import"./NEWT5A6S.js";import{e as T,h as j,k as w}from"./LD5MEXEL.js";import{a as _,b as B,c as F,d as J,e as Q,f as P,g as V,h as W,i as X,j as Y,k as Z,l as $,m as rr,n as er}from"./UW4UC7ZI.js";import"./RFWIIJFG.js";var A={typescript:{run:a,sample:s,docs:p},zod:{run:m},transformers:{run:i},"tanstack-query":{run:o("react")},"tanstack-query-vue":{run:o("vue")},"tanstack-query-svelte":{run:o("svelte")},"tanstack-query-solid":{run:o("solid")},swr:{run:c},mock:{run:l},cli:{run:u,sample:d,docs:f},python:{run:y,sample:G,docs:x},go:{run:g,sample:S,docs:h},php:{run:k,sample:v,docs:b}},L=Object.fromEntries(Object.entries(D).map(([e,{load:r,...t}])=>[e,{...t,...A[e]}]));function n(){return new Map(Object.entries(L))}function C(e,r,t=n(),O){E(e,r,t,O)}function br(e,r){let t=r.registry??n();return C(r.generators,r.emit,t,r.outputMode),q(e,{...r,registry:t})}export{mr as AUTHORING_HELPER_NAMES,U as NotSupportedError,_ as Printer,F as RESERVED_WORDS,B as casing,j as codeLiteral,br as collectGeneratedFiles,P as deref,W as discriminatorCases,$ as docText,Z as enumValues,V as flattenAllOf,z as generateClient,er as headerCoerceType,J as identifierFor,nr as isMultipartBody,X as isNullable,tr as jsonSuccessSchema,I as operationSignature,sr as paginationItemSchema,H as paginationRuleFor,w as pascalCase,R as renderComposedCliEntry,K as renderReferencePage,T as safeIdent,rr as schemaAtPointer,pr as securityRequirements,ar as serverUrlParts,or as sseResponse,M as tsJsdoc,N as tsType,Q as uniqueIdentifiers,Y as unwrapNullable};
@@ -4,7 +4,7 @@ import { dirname as __pathDirname } from 'node:path';
4
4
  const require = __createRequire(import.meta.url);
5
5
  var __filename = __fileURLToPath(import.meta.url);
6
6
  var __dirname = __pathDirname(__filename);
7
- import{a as h}from"./MEVUBG5J.js";import{e as g,h as p,k as $}from"./LD5MEXEL.js";import{join as R}from"node:path";var a=" ";function m(e){return`${$(e)}Schema`}var y=new Map;function u(e,r=y,t=""){return j(w(e,r,t),e)}function w(e,r,t){switch(e.kind){case"scalar":return z(e.scalar,e.metadata);case"object":return b(e.properties,r,t);case"array":return`z.array(${u(e.items,r,t)})`;case"record":return`z.record(z.string(), ${u(e.value,r,t)})`;case"ref":return`z.lazy(() => ${m(e.name)})`;case"literal":return`z.literal(${p(e.value)})`;case"enum":return q(e.values);case"union":return k(e.members,r,t);case"intersection":return e.members.map(n=>u(n,r,t)).reduce((n,o)=>`${n}.and(${o})`);case"null":return"z.null()";case"unknown":return"z.unknown()";case"omit":return E(e.base,e.keys,r,t)}}function z(e,r){switch(e){case"string":return r?.format==="binary"?"z.instanceof(Blob)":"z.string()";case"integer":return"z.number().int()";case"number":return"z.number()";case"boolean":return"z.boolean()"}}function c(e){return g(e)===e?e:JSON.stringify(e)}function b(e,r,t){if(e.length===0)return"z.object({})";let n=t+a;return`z.object({
7
+ import{a as h}from"./UAEEHSSK.js";import{e as g,h as p,k as $}from"./LD5MEXEL.js";import{join as R}from"node:path";var a=" ";function m(e){return`${$(e)}Schema`}var y=new Map;function u(e,r=y,t=""){return j(w(e,r,t),e)}function w(e,r,t){switch(e.kind){case"scalar":return z(e.scalar,e.metadata);case"object":return b(e.properties,r,t);case"array":return`z.array(${u(e.items,r,t)})`;case"record":return`z.record(z.string(), ${u(e.value,r,t)})`;case"ref":return`z.lazy(() => ${m(e.name)})`;case"literal":return`z.literal(${p(e.value)})`;case"enum":return q(e.values);case"union":return k(e.members,r,t);case"intersection":return e.members.map(n=>u(n,r,t)).reduce((n,o)=>`${n}.and(${o})`);case"null":return"z.null()";case"unknown":return"z.unknown()";case"omit":return E(e.base,e.keys,r,t)}}function z(e,r){switch(e){case"string":return r?.format==="binary"?"z.instanceof(Blob)":"z.string()";case"integer":return"z.number().int()";case"number":return"z.number()";case"boolean":return"z.boolean()"}}function c(e){return g(e)===e?e:JSON.stringify(e)}function b(e,r,t){if(e.length===0)return"z.object({})";let n=t+a;return`z.object({
8
8
  ${e.map((s,i)=>{let d=u(s.schema,r,n),l=s.required?d:`${d}.optional()`,x=i===e.length-1?"":",";return`${n}${c(s.name)}: ${l}${x}`}).join(`
9
9
  `)}
10
10
  ${t}})`}function q(e){return e.every(r=>typeof r=="string")?`z.enum([${e.map(r=>JSON.stringify(r)).join(", ")}])`:`z.union([${e.map(r=>`z.literal(${p(r)})`).join(", ")}])`}function k(e,r,t){let n=e.map(o=>u(o,r,t));return n.length===1?n[0]:`z.union([${n.join(", ")}])`}function E(e,r,t,n){let o=t.get(e);if(o&&o.kind!=="object")return u(f(o,r,t,new Set([e])),t,n);let s=r.map(i=>`${c(i)}: true`).join(", ");return`${m(e)}.omit({ ${s} })`}function f(e,r,t,n){switch(e.kind){case"object":return{...e,properties:e.properties.filter(o=>!r.includes(o.name))};case"union":case"intersection":return{...e,members:e.members.map(o=>f(o,r,t,n))};case"ref":{if(n.has(e.name))return e;let o=t.get(e.name);if(!o)return e;if(o.kind==="object"){let s=r.filter(i=>o.properties.some(d=>d.name===i));return s.length>0?{kind:"omit",base:e.name,keys:s}:e}return f(o,r,t,new Set([...n,e.name]))}default:return e}}function j(e,r){let t=r.metadata;if(!t)return e;let n=e;return r.kind==="scalar"&&r.scalar==="string"&&(t.minLength!==void 0&&(n=`${n}.min(${t.minLength})`),t.maxLength!==void 0&&(n=`${n}.max(${t.maxLength})`),t.pattern!==void 0&&(n=`${n}.regex(new RegExp(${JSON.stringify(t.pattern)}))`)),r.kind==="scalar"&&(r.scalar==="number"||r.scalar==="integer")&&(t.minimum!==void 0&&(n=`${n}.min(${t.minimum})`),t.maximum!==void 0&&(n=`${n}.max(${t.maximum})`),t.exclusiveMinimum!==void 0&&(n=`${n}.gt(${t.exclusiveMinimum})`),t.exclusiveMaximum!==void 0&&(n=`${n}.lt(${t.exclusiveMaximum})`)),r.kind==="array"&&(t.minItems!==void 0&&(n=`${n}.min(${t.minItems})`),t.maxItems!==void 0&&(n=`${n}.max(${t.maxItems})`)),n}function Z(e,r){let t=[];for(let n of h(e.services)){if(n.sse!==void 0)continue;let o=n.requestBody,s=o&&o.contentType.toLowerCase().includes("json")?u(o.schema,r,a):void 0,i=n.successResponses.find(l=>l.contentType.toLowerCase().includes("json")),d=i?u(i.schema,r,a):void 0;!s&&!d||t.push({name:n.specName??n.name,request:s,response:d})}return t}function I(e){let r=e.flatMap(n=>[`${a}${c(n.name)}: {`,...n.request?[`${a}${a}request: z.ZodType;`]:[],...n.response?[`${a}${a}response: z.ZodType;`]:[],`${a}};`]),t=e.map((n,o)=>{let s=[...n.request?[`request: ${n.request}`]:[],...n.response?[`response: ${n.response}`]:[]].join(", "),i=o===e.length-1?"":",";return`${a}${c(n.name)}: { ${s} }${i}`});return["/**"," * Request/response validators by operationId \u2014 powers `zodValidation`, or import one directly."," */","export const operationSchemas: {",...r,"} = {",...t,"};"].join(`
@@ -4,6 +4,6 @@ import { dirname as __pathDirname } from 'node:path';
4
4
  const require = __createRequire(import.meta.url);
5
5
  var __filename = __fileURLToPath(import.meta.url);
6
6
  var __dirname = __pathDirname(__filename);
7
- import{b as m,j as C,o as a,p,q as T,r as l,s as h,t as f,u as d}from"./BNWXU2OA.js";import{c as g}from"./UWKKXZOE.js";import A from"node:path";function L(e,n){if(C(e)!=="application/x-www-form-urlencoded"||!Array.isArray(n))return;let o=new URLSearchParams;for(let s of n){if(!g(s))continue;let t=a(s.name);t!==void 0&&o.append(t,a(s.value)??"")}return o.size>0?o.toString():void 0}function K(e,n,o){let s=e?.request,t=e?.response;if(!s)return null;let r=s?.postData,i=a(r?.mimeType),u=r?.text??L(i,r?.params),c=a(r?.encoding),y=t?.content?.text,S=a(t?.content?.encoding),q=p(t?.status);return l({method:a(s?.method),url:a(s?.url),requestHeaders:s?.headers,requestBody:T(u,c),requestContentType:i,responseStatus:q===0?void 0:q,responseStatusText:a(t?.statusText),responseHeaders:t?.headers,responseBody:T(y,S),responseContentType:a(t?.content?.mimeType),startedAt:a(e?.startedDateTime),raw:e},n,o)}var b=class{id="har";canParse(n,o){if(A.extname(n).toLowerCase()===".har")return!0;let t=o.toLowerCase();return t.includes('"log"')&&t.includes('"entries"')}async*parse(n){let o=0;for await(let s of f(n,"log.entries")){let t=K(s,o,n);t&&(yield t),o+=1}}};import $ from"node:path";function H(e){let n=a(e.url??e.uri);if(n)return{url:n};let o=a(e.host??e.headers?.host),s=a(e.path??e.request_uri),t=a(e.scheme??e.forwarded_proto);return o&&s?{url:`${t??"http"}://${o}${s}`,schemeKnown:!!t}:{url:s,schemeKnown:!!t}}function z(e,n,o){let s=e?.request??e?.req??e?.http?.request;if(!s)return null;let t=e?.response??e?.res??e?.http?.response,r=t?.body??t?.raw_body??t?.payload??t?.data,i=s?.body??s?.raw_body??s?.payload??s?.data,{url:u,schemeKnown:c}=H(s);return l({method:a(s?.method??s?.http_method),url:u,schemeKnown:c,requestHeaders:s?.headers,requestBody:i,requestContentType:d(s?.headers),responseStatus:p(t?.status??t?.statusCode),responseHeaders:t?.headers,responseBody:r,responseContentType:d(t?.headers),startedAt:a(e?.started_at??e?.startedAt??e?.timestamp),raw:e},n,o)}var x=class{id="kong";canParse(n,o){if($.extname(n).toLowerCase()===".kong")return!0;let t=o.toLowerCase();return t.includes('"latencies"')||t.includes('"request"')&&t.includes('"response"')&&t.includes('"route"')}async*parse(n){let o=(await m(n,16)).trim().slice(0,1),s=0;if(o==="["){for await(let t of f(n)){let r=z(t,s,n);r&&(yield r),s+=1}return}for await(let t of h(n)){let r=z(t,s,n);r&&(yield r),s+=1}}};import R from"node:path";function U(e){return e?.request??e?.req??e?.httpRequest??e?.http?.request??e}function I(e){return e?.response??e?.res??e?.httpResponse??e?.http?.response}function O(e,n){let o=a(n?.url??n?.uri??n?.requestUrl??e?.url);if(o)return{url:o};let s=a(n?.host??n?.headers?.host??e?.host),t=a(n?.path??e?.path??n?.pathname),r=a(n?.scheme??e?.scheme);return s&&t?{url:`${r??"http"}://${s}${t}`,schemeKnown:!!r}:{url:t,schemeKnown:!!r}}function k(e,n,o){let s=U(e),t=I(e),r=s?.body??s?.bodyText??s?.payload??s?.data??s?.rawBody,i=t?.body??t?.bodyText??t?.payload??t?.data??t?.rawBody,{url:u,schemeKnown:c}=O(e,s);return l({method:a(s?.method??s?.httpMethod??e?.method??e?.httpMethod),url:u,schemeKnown:c,requestHeaders:s?.headers,requestBody:r,requestContentType:d(s?.headers),responseStatus:p(t?.status??t?.statusCode??e?.status??e?.statusCode),responseHeaders:t?.headers,responseBody:i,responseContentType:d(t?.headers),startedAt:a(e?.startedAt??e?.timestamp??e?.time),raw:e},n,o)}var w=class{id="ndjson";canParse(n,o){let s=R.extname(n).toLowerCase();if(s===".ndjson"||s===".jsonl"||s===".jsonlines")return!0;let t=o.lastIndexOf(`
7
+ import{b as m,j as C,o as a,p,q as T,r as l,s as h,t as f,u as d}from"./FUCJM4CG.js";import{c as g}from"./RW2ESAIF.js";import A from"node:path";function L(e,n){if(C(e)!=="application/x-www-form-urlencoded"||!Array.isArray(n))return;let o=new URLSearchParams;for(let s of n){if(!g(s))continue;let t=a(s.name);t!==void 0&&o.append(t,a(s.value)??"")}return o.size>0?o.toString():void 0}function K(e,n,o){let s=e?.request,t=e?.response;if(!s)return null;let r=s?.postData,i=a(r?.mimeType),u=r?.text??L(i,r?.params),c=a(r?.encoding),y=t?.content?.text,S=a(t?.content?.encoding),q=p(t?.status);return l({method:a(s?.method),url:a(s?.url),requestHeaders:s?.headers,requestBody:T(u,c),requestContentType:i,responseStatus:q===0?void 0:q,responseStatusText:a(t?.statusText),responseHeaders:t?.headers,responseBody:T(y,S),responseContentType:a(t?.content?.mimeType),startedAt:a(e?.startedDateTime),raw:e},n,o)}var b=class{id="har";canParse(n,o){if(A.extname(n).toLowerCase()===".har")return!0;let t=o.toLowerCase();return t.includes('"log"')&&t.includes('"entries"')}async*parse(n){let o=0;for await(let s of f(n,"log.entries")){let t=K(s,o,n);t&&(yield t),o+=1}}};import $ from"node:path";function H(e){let n=a(e.url??e.uri);if(n)return{url:n};let o=a(e.host??e.headers?.host),s=a(e.path??e.request_uri),t=a(e.scheme??e.forwarded_proto);return o&&s?{url:`${t??"http"}://${o}${s}`,schemeKnown:!!t}:{url:s,schemeKnown:!!t}}function z(e,n,o){let s=e?.request??e?.req??e?.http?.request;if(!s)return null;let t=e?.response??e?.res??e?.http?.response,r=t?.body??t?.raw_body??t?.payload??t?.data,i=s?.body??s?.raw_body??s?.payload??s?.data,{url:u,schemeKnown:c}=H(s);return l({method:a(s?.method??s?.http_method),url:u,schemeKnown:c,requestHeaders:s?.headers,requestBody:i,requestContentType:d(s?.headers),responseStatus:p(t?.status??t?.statusCode),responseHeaders:t?.headers,responseBody:r,responseContentType:d(t?.headers),startedAt:a(e?.started_at??e?.startedAt??e?.timestamp),raw:e},n,o)}var x=class{id="kong";canParse(n,o){if($.extname(n).toLowerCase()===".kong")return!0;let t=o.toLowerCase();return t.includes('"latencies"')||t.includes('"request"')&&t.includes('"response"')&&t.includes('"route"')}async*parse(n){let o=(await m(n,16)).trim().slice(0,1),s=0;if(o==="["){for await(let t of f(n)){let r=z(t,s,n);r&&(yield r),s+=1}return}for await(let t of h(n)){let r=z(t,s,n);r&&(yield r),s+=1}}};import R from"node:path";function U(e){return e?.request??e?.req??e?.httpRequest??e?.http?.request??e}function I(e){return e?.response??e?.res??e?.httpResponse??e?.http?.response}function O(e,n){let o=a(n?.url??n?.uri??n?.requestUrl??e?.url);if(o)return{url:o};let s=a(n?.host??n?.headers?.host??e?.host),t=a(n?.path??e?.path??n?.pathname),r=a(n?.scheme??e?.scheme);return s&&t?{url:`${r??"http"}://${s}${t}`,schemeKnown:!!r}:{url:t,schemeKnown:!!r}}function k(e,n,o){let s=U(e),t=I(e),r=s?.body??s?.bodyText??s?.payload??s?.data??s?.rawBody,i=t?.body??t?.bodyText??t?.payload??t?.data??t?.rawBody,{url:u,schemeKnown:c}=O(e,s);return l({method:a(s?.method??s?.httpMethod??e?.method??e?.httpMethod),url:u,schemeKnown:c,requestHeaders:s?.headers,requestBody:r,requestContentType:d(s?.headers),responseStatus:p(t?.status??t?.statusCode??e?.status??e?.statusCode),responseHeaders:t?.headers,responseBody:i,responseContentType:d(t?.headers),startedAt:a(e?.startedAt??e?.timestamp??e?.time),raw:e},n,o)}var w=class{id="ndjson";canParse(n,o){let s=R.extname(n).toLowerCase();if(s===".ndjson"||s===".jsonl"||s===".jsonlines")return!0;let t=o.lastIndexOf(`
8
8
  `),i=(t===-1?o:o.slice(0,t)).split(`
9
9
  `).map(u=>u.trim()).find(Boolean);if(!i?.startsWith("{")||!i.endsWith("}"))return!1;try{return JSON.parse(i),!0}catch{return!1}}async*parse(n){let o=0;for await(let s of h(n)){let t=k(s,o,n);t&&(yield t),o+=1}}};import J from"node:path";function P(e){if(!e)return{};let n=e.trim().split(/\s+/);return n.length<2?{}:{method:n[0],path:n[1],protocol:n[2]}}function W(e,n){let o=a(n?.url??n?.request_uri??n?.uri??e?.url??e?.request_url??e?.absolute_uri),s=P(a(e?.request??n?.request_line)),t=a(n?.request_uri??n?.uri??n?.path??e?.request_uri??e?.uri)??s.path;if(o?.startsWith("http://")||o?.startsWith("https://"))return{url:o};let r=a(n?.host??n?.headers?.host??e?.host??e?.http_host??e?.server_name??e?.vhost),i=a(e?.scheme??n?.scheme??e?.request_scheme),u=!!i;if(r&&(o||t)){let c=i??"http",y=o??t;return y?.startsWith("/")?{url:`${c}://${r}${y}`,schemeKnown:u}:{url:`${c}://${r}/${y}`,schemeKnown:u}}return{url:o??t,schemeKnown:u}}function E(e,n,o){let s=g(e?.request)?e.request:e,t=g(e?.response)?e.response:void 0,r=P(a(e?.request)),i=a(s?.method??s?.request_method??e?.request_method??e?.method)??r.method,{url:u,schemeKnown:c}=W(e,s);return l({method:i,url:u,schemeKnown:c,requestHeaders:s?.headers??s?.request_headers??e?.request_headers??e?.headers,requestBody:s?.body??s?.request_body??e?.request_body??e?.body,requestContentType:d(s?.headers??s?.request_headers??e?.request_headers),responseStatus:p(t?.status??t?.status_code??e?.status??e?.status_code??e?.response_status),responseHeaders:t?.headers??t?.response_headers??e?.response_headers??e?.headers_out,responseBody:t?.body??t?.response_body??e?.response_body,responseContentType:d(t?.headers??t?.response_headers??e?.response_headers),startedAt:a(e?.time_iso8601??e?.timestamp??e?.time??e?.time_local??e?.["@timestamp"]),raw:e},n,o)}async function*j(e){if((await m(e,16)).trim().slice(0,1)==="["){yield*f(e);return}for await(let o of h(e))yield o}var N=class{id="nginx-json";canParse(n,o){let s=J.extname(n).toLowerCase(),t=n.toLowerCase();if(s===".ndjson"&&t.includes("nginx"))return!0;let r=o.toLowerCase();return r.includes('"request_uri"')||r.includes('"time_iso8601"')||r.includes('"upstream_response_time"')||r.includes('"remote_addr"')}async*parse(n){let o=0;for await(let s of j(n)){let t=E(s,o,n);t&&(yield t),o+=1}}},_=class{id="apache-json";canParse(n,o){let s=J.extname(n).toLowerCase(),t=n.toLowerCase();if(s===".ndjson"&&t.includes("apache"))return!0;let r=o.toLowerCase();return r.includes('"request_method"')||r.includes('"request_uri"')||r.includes('"vhost"')||r.includes('"response_status"')}async*parse(n){let o=0;for await(let s of j(n)){let t=E(s,o,n);t&&(yield t),o+=1}}};var B=[new b,new x,new N,new _,new w];async function le(e,n){if(n!=="auto"){let s=B.find(t=>t.id===n);if(!s)throw new Error(`Unsupported parser format: ${n}`);return s}let o=await m(e);return B.find(s=>s.canParse(e,o))}export{le as a};
@@ -4,5 +4,5 @@ import { dirname as __pathDirname } from 'node:path';
4
4
  const require = __createRequire(import.meta.url);
5
5
  var __filename = __fileURLToPath(import.meta.url);
6
6
  var __dirname = __pathDirname(__filename);
7
- import{c}from"./UWKKXZOE.js";import{open as U,readdir as H,stat as J}from"node:fs/promises";import x from"node:path";var L=new Set([".yaml",".yml",".json"]);async function K(e){let n=[];async function t(r){let o=await H(r,{withFileTypes:!0});for(let s of o){if(s.name.startsWith("."))continue;let i=x.join(r,s.name);if(s.isDirectory()){await t(i);continue}s.isFile()&&L.has(x.extname(s.name).toLowerCase())&&n.push(i)}}return await t(e),n.sort(),n}async function G(e,n=4096){let t=await U(e,"r");try{let r=Buffer.allocUnsafe(n),{bytesRead:o}=await t.read(r,0,n,0);return r.toString("utf8",0,o)}finally{await t.close()}}function X(e){return x.resolve(process.cwd(),e)}async function Y(e){let n=await J(e);if(n.isFile())return[e];if(!n.isDirectory())return[];let t=[];async function r(o){let s=await H(o,{withFileTypes:!0});for(let i of s){if(i.name.startsWith("."))continue;let a=x.join(o,i.name);if(i.isDirectory()){await r(a);continue}i.isFile()&&t.push(a)}}return await r(e),t.sort(),t}var z="drift.local",B=`http://${z}`;function l(e){return e===z}var I=new Set(["accept","accept-charset","accept-encoding","accept-language","authorization","baggage","cache-control","cdn-loop","cookie","connection","content-length","content-type","dpr","dnt","downlink","ect","forwarded","host","if-match","if-modified-since","if-none-match","if-range","if-unmodified-since","origin","pragma","priority","range","referer","sec-fetch-dest","sec-fetch-mode","sec-fetch-site","sec-fetch-user","sec-gpc","sentry-trace","te","traceparent","tracestate","upgrade","upgrade-insecure-requests","user-agent","via","x-client-trace-id","x-cloud-trace-context","x-correlation-id","x-http-method-override","x-hub-signature","x-hub-signature-256","x-method-override","x-real-ip","x-request-id","x-forwarded-for","x-forwarded-host","x-forwarded-port","x-forwarded-proto"]),q=["cf-","sec-ch-","sec-fetch-","x-amz-","x-amzn-","x-b3-","x-envoy-","x-forwarded-","x-github-"],T=`
7
+ import{c}from"./RW2ESAIF.js";import{open as U,readdir as H,stat as J}from"node:fs/promises";import x from"node:path";var L=new Set([".yaml",".yml",".json"]);async function K(e){let n=[];async function t(r){let o=await H(r,{withFileTypes:!0});for(let s of o){if(s.name.startsWith("."))continue;let i=x.join(r,s.name);if(s.isDirectory()){await t(i);continue}s.isFile()&&L.has(x.extname(s.name).toLowerCase())&&n.push(i)}}return await t(e),n.sort(),n}async function G(e,n=4096){let t=await U(e,"r");try{let r=Buffer.allocUnsafe(n),{bytesRead:o}=await t.read(r,0,n,0);return r.toString("utf8",0,o)}finally{await t.close()}}function X(e){return x.resolve(process.cwd(),e)}async function Y(e){let n=await J(e);if(n.isFile())return[e];if(!n.isDirectory())return[];let t=[];async function r(o){let s=await H(o,{withFileTypes:!0});for(let i of s){if(i.name.startsWith("."))continue;let a=x.join(o,i.name);if(i.isDirectory()){await r(a);continue}i.isFile()&&t.push(a)}}return await r(e),t.sort(),t}var z="drift.local",B=`http://${z}`;function l(e){return e===z}var I=new Set(["accept","accept-charset","accept-encoding","accept-language","authorization","baggage","cache-control","cdn-loop","cookie","connection","content-length","content-type","dpr","dnt","downlink","ect","forwarded","host","if-match","if-modified-since","if-none-match","if-range","if-unmodified-since","origin","pragma","priority","range","referer","sec-fetch-dest","sec-fetch-mode","sec-fetch-site","sec-fetch-user","sec-gpc","sentry-trace","te","traceparent","tracestate","upgrade","upgrade-insecure-requests","user-agent","via","x-client-trace-id","x-cloud-trace-context","x-correlation-id","x-http-method-override","x-hub-signature","x-hub-signature-256","x-method-override","x-real-ip","x-request-id","x-forwarded-for","x-forwarded-host","x-forwarded-port","x-forwarded-proto"]),q=["cf-","sec-ch-","sec-fetch-","x-amz-","x-amzn-","x-b3-","x-envoy-","x-forwarded-","x-github-"],T=`
8
8
  `;function Z(e){return e.split(T)}function S(e,n,t){let r=n.toLowerCase(),o=e[r];if(o===void 0){e[r]=t;return}e[r]=r==="set-cookie"?`${o}${T}${t}`:`${o},${t}`}function w(e){if(!c(e)&&!Array.isArray(e))return{};let n={};if(Array.isArray(e)){for(let t of e){if(!c(t))continue;let{name:r,value:o}=t;typeof r=="string"&&o!==void 0&&S(n,r,String(o))}return n}for(let[t,r]of Object.entries(e))if(r!=null){if(Array.isArray(r)){for(let o of r)S(n,t,String(o));continue}S(n,t,String(r))}return n}function m(e){try{return new URL(e)}catch{return new URL(e,B)}}function N(e){return e.length>1&&e.endsWith("/")?e.slice(0,-1):e}function b(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function v(e){let n=[],t=0,r=e.startsWith("/")?e:`/${e}`,s=N(r).split("/").map(i=>{if(!i)return"";let a=[...i.matchAll(/\{([^}]+)\}/g)],h=n.length,u="",p=0,f=0;for(let[y,d]of a.entries()){let R=i.slice(f,d.index);u+=b(R),p+=R.length,n.push(d[1]),f=d.index+d[0].length;let E=a[y+1];if(!E){u+="([^/]+)";continue}let A=i.slice(f,E.index);u+=A?`((?:(?!${b(A)})[^/])+)`:"([^/])"}let g=i.slice(f);return u+=b(g),p+=g.length,n.length===h?t+=2:p>0&&(t+=1),u}).join("/");return{regex:new RegExp(`^${s||"/"}$`),params:n,score:t}}function k(e,n){if(n&&P(e))try{return JSON.parse(n)}catch{return}}function C(e){return e?e.split(";")[0]?.trim().toLowerCase()??"":""}function P(e){let n=C(e);return n==="application/json"||n.endsWith("+json")}function ee(e,n){let t=C(n);if(!t)return e["application/json"]??e["*/*"];if(e[t]!==void 0)return e[t];let[r,o]=t.split("/");if(r&&o){let s=`${r}/*`;if(e[s]!==void 0)return e[s]}return e["*/*"]}function ne(e){let n=new Set,t=[];for(let r of e){let o=r.trim().toLowerCase();o.length!==0&&(o.endsWith("*")?t.push(o.slice(0,-1)):n.add(o))}return{names:n,prefixes:t}}function te(e,n){let t=e.toLowerCase();return t.startsWith(":")||I.has(t)||q.some(r=>t.startsWith(r))?!0:n?n.names.has(t)||n.prefixes.some(r=>t.startsWith(r)):!1}import{createReadStream as F}from"node:fs";import{readFile as j}from"node:fs/promises";import{createInterface as W}from"node:readline";function D(e){if(e!=null){if(typeof e=="string")return e;if(Buffer.isBuffer(e))return e.toString("utf8");if(c(e)||Array.isArray(e))try{return JSON.stringify(e)}catch{return String(e)}return String(e)}}function ue(e){if(typeof e=="number"&&Number.isFinite(e))return e;if(typeof e=="string"&&e.trim()!==""){let n=Number(e);if(Number.isFinite(n))return n}}function $(e,n){if(e!=null){if(n==="base64"&&typeof e=="string")try{return Buffer.from(e,"base64").toString("utf8")}catch{return e}return D(e)}}function fe(e,n,t){let r=e.method?.toUpperCase(),o=e.url;if(!r||!o)return null;let s=w(e.requestHeaders),i=m(o);if(l(i.host)&&s.host)try{i=new URL(`${i.protocol}//${s.host}${i.pathname}${i.search}`)}catch{i=m(o)}let a=e.requestContentType??s["content-type"],h=$(e.requestBody),u={method:r,url:i.toString(),path:i.pathname,query:i.searchParams,protocol:i.protocol,protocolKnown:e.schemeKnown??/^https?:\/\//i.test(o),host:l(i.host)?void 0:i.host||void 0,headers:s,contentType:a,bodyText:h,bodyJson:k(a,h)},p,f=e.responseStatus;if(f!==void 0){let g=w(e.responseHeaders),y=e.responseContentType??g["content-type"],d=$(e.responseBody);p={status:f,statusText:e.responseStatusText,headers:g,contentType:y,bodyText:d,bodyJson:k(y,d)}}return{index:n,source:t,startedAt:e.startedAt,request:u,response:p,raw:e.raw}}async function*de(e){let n=F(e,{encoding:"utf8"}),t=W({input:n,crlfDelay:1/0});for await(let r of t){let o=r.trim();if(o)try{let s=JSON.parse(o);c(s)&&(yield s)}catch{}}}async function*pe(e,n){let t=await j(e,"utf8"),r=JSON.parse(t);if(n)for(let o of n.split("."))r=c(r)?r[o]:void 0;if(Array.isArray(r))for(let o of r)c(o)&&(yield o)}function ge(e){return w(e)["content-type"]}function he(e){return e?.replace(/\/+$/,"")||void 0}function O(e,n){if(!n||n==="/")return e||"/";if(e===n)return"/";if(e.startsWith(`${n}/`))return e.slice(n.length)||"/"}function ye(e,n){if(n.startsWith("/"))return O(e.path,n);let t=m(n.includes("://")?n:`http://${n}`);if(!(l(t.host)||e.host!==void 0&&e.host.toLowerCase()!==t.host))return O(e.path,N(t.pathname))}export{K as a,G as b,X as c,Y as d,l as e,Z as f,m as g,N as h,v as i,C as j,P as k,ee as l,ne as m,te as n,D as o,ue as p,$ as q,fe as r,de as s,pe as t,ge as u,he as v,ye as w};
@@ -0,0 +1,47 @@
1
+ import { createRequire as __createRequire } from 'node:module';
2
+ import { fileURLToPath as __fileURLToPath } from 'node:url';
3
+ import { dirname as __pathDirname } from 'node:path';
4
+ const require = __createRequire(import.meta.url);
5
+ var __filename = __fileURLToPath(import.meta.url);
6
+ var __dirname = __pathDirname(__filename);
7
+ import{$ as kt,C as ye,D as Kt,E as be,H as ve,O as Se,P as At,Q as xe,R as J,V as X,X as x,d as me,da as Ee,e as qt,f as we,ga as Zt,ha as Ct,ja as Ae,l as z,ma as ke,na as $,oa as Ce,t as nt}from"./RW2ESAIF.js";import{performance as Qr}from"perf_hooks";function Oe(t){return t?._?.[0]??""}import{fileURLToPath as Ys}from"node:url";import{posix as Zs,win32 as he}from"node:path";import{fileURLToPath as Xs}from"node:url";import{lstatSync as Qs,readdir as tr,readdirSync as er,readlinkSync as ir,realpathSync as sr}from"fs";import*as rr from"node:fs";import{lstat as nr,readdir as or,readlink as hr,realpath as ar}from"node:fs/promises";import{EventEmitter as ce}from"node:events";import ui from"node:stream";import{StringDecoder as lr}from"node:string_decoder";var Ke=(t,e,i)=>{let s=t instanceof RegExp?Te(t,i):t,r=e instanceof RegExp?Te(e,i):e,n=s!==null&&r!=null&&Hi(s,r,i);return n&&{start:n[0],end:n[1],pre:i.slice(0,n[0]),body:i.slice(n[0]+s.length,n[1]),post:i.slice(n[1]+r.length)}},Te=(t,e)=>{let i=e.match(t);return i?i[0]:null},Hi=(t,e,i)=>{let s,r,n,o,h,a=i.indexOf(t),l=i.indexOf(e,a+1),p=a;if(a>=0&&l>0){if(t===e)return[a,l];for(s=[],n=i.length;p>=0&&!h;){if(p===a)s.push(p),a=i.indexOf(t,p+1);else if(s.length===1){let c=s.pop();c!==void 0&&(h=[c,l])}else r=s.pop(),r!==void 0&&r<n&&(n=r,o=l),l=i.indexOf(e,p+1);p=a<l&&a>=0?a:l}s.length&&o!==void 0&&(h=[n,o])}return h},Ze="\0SLASH"+Math.random()+"\0",Xe="\0OPEN"+Math.random()+"\0",ae="\0CLOSE"+Math.random()+"\0",Qe="\0COMMA"+Math.random()+"\0",ti="\0PERIOD"+Math.random()+"\0",Vi=new RegExp(Ze,"g"),Yi=new RegExp(Xe,"g"),Ji=new RegExp(ae,"g"),qi=new RegExp(Qe,"g"),Ki=new RegExp(ti,"g"),Zi=/\\\\/g,Xi=/\\{/g,Qi=/\\}/g,ts=/\\,/g,es=/\\./g,is=1e5;function Xt(t){return isNaN(t)?t.charCodeAt(0):parseInt(t,10)}function ss(t){return t.replace(Zi,Ze).replace(Xi,Xe).replace(Qi,ae).replace(ts,Qe).replace(es,ti)}function rs(t){return t.replace(Vi,"\\").replace(Yi,"{").replace(Ji,"}").replace(qi,",").replace(Ki,".")}function ei(t){if(!t)return[""];let e=[],i=Ke("{","}",t);if(!i)return t.split(",");let{pre:s,body:r,post:n}=i,o=s.split(",");o[o.length-1]+="{"+r+"}";let h=ei(n);return n.length&&(o[o.length-1]+=h.shift(),o.push.apply(o,h)),e.push.apply(e,o),e}function ns(t,e={}){if(!t)return[];let{max:i=is}=e;return t.slice(0,2)==="{}"&&(t="\\{\\}"+t.slice(2)),mt(ss(t),i,!0).map(rs)}function os(t){return"{"+t+"}"}function hs(t){return/^-?0\d/.test(t)}function as(t,e){return t<=e}function ls(t,e){return t>=e}function mt(t,e,i){let s=[],r=Ke("{","}",t);if(!r)return[t];let n=r.pre,o=r.post.length?mt(r.post,e,!1):[""];if(/\$$/.test(r.pre))for(let h=0;h<o.length&&h<e;h++){let a=n+"{"+r.body+"}"+o[h];s.push(a)}else{let h=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(r.body),a=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(r.body),l=h||a,p=r.body.indexOf(",")>=0;if(!l&&!p)return r.post.match(/,(?!,).*\}/)?(t=r.pre+"{"+r.body+ae+r.post,mt(t,e,!0)):[t];let c;if(l)c=r.body.split(/\.\./);else if(c=ei(r.body),c.length===1&&c[0]!==void 0&&(c=mt(c[0],e,!1).map(os),c.length===1))return o.map(u=>r.pre+c[0]+u);let f;if(l&&c[0]!==void 0&&c[1]!==void 0){let u=Xt(c[0]),d=Xt(c[1]),g=Math.max(c[0].length,c[1].length),w=c.length===3&&c[2]!==void 0?Math.abs(Xt(c[2])):1,m=as;d<u&&(w*=-1,m=ls);let y=c.some(hs);f=[];for(let b=u;m(b,d);b+=w){let v;if(a)v=String.fromCharCode(b),v==="\\"&&(v="");else if(v=String(b),y){let S=g-v.length;if(S>0){let Y=new Array(S+1).join("0");b<0?v="-"+Y+v.slice(1):v=Y+v}}f.push(v)}}else{f=[];for(let u=0;u<c.length;u++)f.push.apply(f,mt(c[u],e,!1))}for(let u=0;u<f.length;u++)for(let d=0;d<o.length&&s.length<e;d++){let g=n+f[u]+o[d];(!i||l||g)&&s.push(g)}}return s}var Wt=t=>{if(typeof t!="string")throw new TypeError("invalid pattern");if(t.length>65536)throw new TypeError("pattern is too long")},cs={"[:alnum:]":["\\p{L}\\p{Nl}\\p{Nd}",!0],"[:alpha:]":["\\p{L}\\p{Nl}",!0],"[:ascii:]":["\\x00-\\x7f",!1],"[:blank:]":["\\p{Zs}\\t",!0],"[:cntrl:]":["\\p{Cc}",!0],"[:digit:]":["\\p{Nd}",!0],"[:graph:]":["\\p{Z}\\p{C}",!0,!0],"[:lower:]":["\\p{Ll}",!0],"[:print:]":["\\p{C}",!0],"[:punct:]":["\\p{P}",!0],"[:space:]":["\\p{Z}\\t\\r\\n\\v\\f",!0],"[:upper:]":["\\p{Lu}",!0],"[:word:]":["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}",!0],"[:xdigit:]":["A-Fa-f0-9",!1]},ct=t=>t.replace(/[[\]\\-]/g,"\\$&"),ps=t=>t.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),Fe=t=>t.join(""),us=(t,e)=>{let i=e;if(t.charAt(i)!=="[")throw new Error("not in a brace expression");let s=[],r=[],n=i+1,o=!1,h=!1,a=!1,l=!1,p=i,c="";t:for(;n<t.length;){let d=t.charAt(n);if((d==="!"||d==="^")&&n===i+1){l=!0,n++;continue}if(d==="]"&&o&&!a){p=n+1;break}if(o=!0,d==="\\"&&!a){a=!0,n++;continue}if(d==="["&&!a){for(let[g,[w,m,y]]of Object.entries(cs))if(t.startsWith(g,n)){if(c)return["$.",!1,t.length-i,!0];n+=g.length,y?r.push(w):s.push(w),h=h||m;continue t}}if(a=!1,c){d>c?s.push(ct(c)+"-"+ct(d)):d===c&&s.push(ct(d)),c="",n++;continue}if(t.startsWith("-]",n+1)){s.push(ct(d+"-")),n+=2;continue}if(t.startsWith("-",n+1)){c=d,n+=2;continue}s.push(ct(d)),n++}if(p<n)return["",!1,0,!1];if(!s.length&&!r.length)return["$.",!1,t.length-i,!0];if(r.length===0&&s.length===1&&/^\\?.$/.test(s[0])&&!l){let d=s[0].length===2?s[0].slice(-1):s[0];return[ps(d),!1,p-i,!1]}let f="["+(l?"^":"")+Fe(s)+"]",u="["+(l?"":"^")+Fe(r)+"]";return[s.length&&r.length?"("+f+"|"+u+")":s.length?f:u,h,p-i,!0]},at=(t,{windowsPathsNoEscape:e=!1,magicalBraces:i=!0}={})=>i?e?t.replace(/\[([^\/\\])\]/g,"$1"):t.replace(/((?!\\).|^)\[([^\/\\])\]/g,"$1$2").replace(/\\([^\/])/g,"$1"):e?t.replace(/\[([^\/\\{}])\]/g,"$1"):t.replace(/((?!\\).|^)\[([^\/\\{}])\]/g,"$1$2").replace(/\\([^\/{}])/g,"$1"),fs=new Set(["!","?","+","*","@"]),Re=t=>fs.has(t),ds="(?!(?:^|/)\\.\\.?(?:$|/))",Ot="(?!\\.)",gs=new Set(["[","."]),ms=new Set(["..","."]),ws=new Set("().*{}+?[]^$\\!"),ys=t=>t.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),le="[^/]",je=le+"*?",Pe=le+"+?",ii=class D{type;#t;#i;#n=!1;#r=[];#o;#v;#w;#c=!1;#h;#u;#p=!1;constructor(e,i,s={}){this.type=e,e&&(this.#i=!0),this.#o=i,this.#t=this.#o?this.#o.#t:this,this.#h=this.#t===this?s:this.#t.#h,this.#w=this.#t===this?[]:this.#t.#w,e==="!"&&!this.#t.#c&&this.#w.push(this),this.#v=this.#o?this.#o.#r.length:0}get hasMagic(){if(this.#i!==void 0)return this.#i;for(let e of this.#r)if(typeof e!="string"&&(e.type||e.hasMagic))return this.#i=!0;return this.#i}toString(){return this.#u!==void 0?this.#u:this.type?this.#u=this.type+"("+this.#r.map(e=>String(e)).join("|")+")":this.#u=this.#r.map(e=>String(e)).join("")}#a(){if(this!==this.#t)throw new Error("should only call on root");if(this.#c)return this;this.toString(),this.#c=!0;let e;for(;e=this.#w.pop();){if(e.type!=="!")continue;let i=e,s=i.#o;for(;s;){for(let r=i.#v+1;!s.type&&r<s.#r.length;r++)for(let n of e.#r){if(typeof n=="string")throw new Error("string part in extglob AST??");n.copyIn(s.#r[r])}i=s,s=i.#o}}return this}push(...e){for(let i of e)if(i!==""){if(typeof i!="string"&&!(i instanceof D&&i.#o===this))throw new Error("invalid part: "+i);this.#r.push(i)}}toJSON(){let e=this.type===null?this.#r.slice().map(i=>typeof i=="string"?i:i.toJSON()):[this.type,...this.#r.map(i=>i.toJSON())];return this.isStart()&&!this.type&&e.unshift([]),this.isEnd()&&(this===this.#t||this.#t.#c&&this.#o?.type==="!")&&e.push({}),e}isStart(){if(this.#t===this)return!0;if(!this.#o?.isStart())return!1;if(this.#v===0)return!0;let e=this.#o;for(let i=0;i<this.#v;i++){let s=e.#r[i];if(!(s instanceof D&&s.type==="!"))return!1}return!0}isEnd(){if(this.#t===this||this.#o?.type==="!")return!0;if(!this.#o?.isEnd())return!1;if(!this.type)return this.#o?.isEnd();let e=this.#o?this.#o.#r.length:0;return this.#v===e-1}copyIn(e){typeof e=="string"?this.push(e):this.push(e.clone(this))}clone(e){let i=new D(this.type,e);for(let s of this.#r)i.copyIn(s);return i}static#s(e,i,s,r){let n=!1,o=!1,h=-1,a=!1;if(i.type===null){let u=s,d="";for(;u<e.length;){let g=e.charAt(u++);if(n||g==="\\"){n=!n,d+=g;continue}if(o){u===h+1?(g==="^"||g==="!")&&(a=!0):g==="]"&&!(u===h+2&&a)&&(o=!1),d+=g;continue}else if(g==="["){o=!0,h=u,a=!1,d+=g;continue}if(!r.noext&&Re(g)&&e.charAt(u)==="("){i.push(d),d="";let w=new D(g,i);u=D.#s(e,w,u,r),i.push(w);continue}d+=g}return i.push(d),u}let l=s+1,p=new D(null,i),c=[],f="";for(;l<e.length;){let u=e.charAt(l++);if(n||u==="\\"){n=!n,f+=u;continue}if(o){l===h+1?(u==="^"||u==="!")&&(a=!0):u==="]"&&!(l===h+2&&a)&&(o=!1),f+=u;continue}else if(u==="["){o=!0,h=l,a=!1,f+=u;continue}if(Re(u)&&e.charAt(l)==="("){p.push(f),f="";let d=new D(u,p);p.push(d),l=D.#s(e,d,l,r);continue}if(u==="|"){p.push(f),f="",c.push(p),p=new D(null,i);continue}if(u===")")return f===""&&i.#r.length===0&&(i.#p=!0),p.push(f),f="",i.push(...c,p),l;f+=u}return i.type=null,i.#i=void 0,i.#r=[e.substring(s-1)],l}static fromGlob(e,i={}){let s=new D(null,void 0,i);return D.#s(e,s,0,i),s}toMMPattern(){if(this!==this.#t)return this.#t.toMMPattern();let e=this.toString(),[i,s,r,n]=this.toRegExpSource();if(!(r||this.#i||this.#h.nocase&&!this.#h.nocaseMagicOnly&&e.toUpperCase()!==e.toLowerCase()))return s;let o=(this.#h.nocase?"i":"")+(n?"u":"");return Object.assign(new RegExp(`^${i}$`,o),{_src:i,_glob:e})}get options(){return this.#h}toRegExpSource(e){let i=e??!!this.#h.dot;if(this.#t===this&&this.#a(),!this.type){let a=this.isStart()&&this.isEnd()&&!this.#r.some(f=>typeof f!="string"),l=this.#r.map(f=>{let[u,d,g,w]=typeof f=="string"?D.#S(f,this.#i,a):f.toRegExpSource(e);return this.#i=this.#i||g,this.#n=this.#n||w,u}).join(""),p="";if(this.isStart()&&typeof this.#r[0]=="string"&&!(this.#r.length===1&&ms.has(this.#r[0]))){let f=gs,u=i&&f.has(l.charAt(0))||l.startsWith("\\.")&&f.has(l.charAt(2))||l.startsWith("\\.\\.")&&f.has(l.charAt(4)),d=!i&&!e&&f.has(l.charAt(0));p=u?ds:d?Ot:""}let c="";return this.isEnd()&&this.#t.#c&&this.#o?.type==="!"&&(c="(?:$|\\/)"),[p+l+c,at(l),this.#i=!!this.#i,this.#n]}let s=this.type==="*"||this.type==="+",r=this.type==="!"?"(?:(?!(?:":"(?:",n=this.#f(i);if(this.isStart()&&this.isEnd()&&!n&&this.type!=="!"){let a=this.toString();return this.#r=[a],this.type=null,this.#i=void 0,[a,at(this.toString()),!1,!1]}let o=!s||e||i||!Ot?"":this.#f(!0);o===n&&(o=""),o&&(n=`(?:${n})(?:${o})*?`);let h="";if(this.type==="!"&&this.#p)h=(this.isStart()&&!i?Ot:"")+Pe;else{let a=this.type==="!"?"))"+(this.isStart()&&!i&&!e?Ot:"")+je+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&o?")":this.type==="*"&&o?")?":`)${this.type}`;h=r+n+a}return[h,at(n),this.#i=!!this.#i,this.#n]}#f(e){return this.#r.map(i=>{if(typeof i=="string")throw new Error("string type in extglob ast??");let[s,r,n,o]=i.toRegExpSource(e);return this.#n=this.#n||o,s}).filter(i=>!(this.isStart()&&this.isEnd())||!!i).join("|")}static#S(e,i,s=!1){let r=!1,n="",o=!1,h=!1;for(let a=0;a<e.length;a++){let l=e.charAt(a);if(r){r=!1,n+=(ws.has(l)?"\\":"")+l;continue}if(l==="*"){if(h)continue;h=!0,n+=s&&/^[*]+$/.test(e)?Pe:je,i=!0;continue}else h=!1;if(l==="\\"){a===e.length-1?n+="\\\\":r=!0;continue}if(l==="["){let[p,c,f,u]=us(e,a);if(f){n+=p,o=o||c,a+=f-1,i=i||u;continue}}if(l==="?"){n+=le,i=!0;continue}n+=ys(l)}return[n,at(e),!!i,o]}},si=(t,{windowsPathsNoEscape:e=!1,magicalBraces:i=!1}={})=>i?e?t.replace(/[?*()[\]{}]/g,"[$&]"):t.replace(/[?*()[\]\\{}]/g,"\\$&"):e?t.replace(/[?*()[\]]/g,"[$&]"):t.replace(/[?*()[\]\\]/g,"\\$&"),R=(t,e,i={})=>(Wt(e),!i.nocomment&&e.charAt(0)==="#"?!1:new Z(e,i).match(t)),bs=/^\*+([^+@!?\*\[\(]*)$/,vs=t=>e=>!e.startsWith(".")&&e.endsWith(t),Ss=t=>e=>e.endsWith(t),xs=t=>(t=t.toLowerCase(),e=>!e.startsWith(".")&&e.toLowerCase().endsWith(t)),Es=t=>(t=t.toLowerCase(),e=>e.toLowerCase().endsWith(t)),As=/^\*+\.\*+$/,ks=t=>!t.startsWith(".")&&t.includes("."),Cs=t=>t!=="."&&t!==".."&&t.includes("."),Os=/^\.\*+$/,Ts=t=>t!=="."&&t!==".."&&t.startsWith("."),Fs=/^\*+$/,Rs=t=>t.length!==0&&!t.startsWith("."),js=t=>t.length!==0&&t!=="."&&t!=="..",Ps=/^\?+([^+@!?\*\[\(]*)?$/,Ds=([t,e=""])=>{let i=ri([t]);return e?(e=e.toLowerCase(),s=>i(s)&&s.toLowerCase().endsWith(e)):i},$s=([t,e=""])=>{let i=ni([t]);return e?(e=e.toLowerCase(),s=>i(s)&&s.toLowerCase().endsWith(e)):i},Ms=([t,e=""])=>{let i=ni([t]);return e?s=>i(s)&&s.endsWith(e):i},Ls=([t,e=""])=>{let i=ri([t]);return e?s=>i(s)&&s.endsWith(e):i},ri=([t])=>{let e=t.length;return i=>i.length===e&&!i.startsWith(".")},ni=([t])=>{let e=t.length;return i=>i.length===e&&i!=="."&&i!==".."},oi=typeof process=="object"&&process?typeof process.env=="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",De={win32:{sep:"\\"},posix:{sep:"/"}},Ws=oi==="win32"?De.win32.sep:De.posix.sep;R.sep=Ws;var F=Symbol("globstar **");R.GLOBSTAR=F;var Ns="[^/]",zs=Ns+"*?",_s="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",Bs="(?:(?!(?:\\/|^)\\.).)*?",Is=(t,e={})=>i=>R(i,t,e);R.filter=Is;var M=(t,e={})=>Object.assign({},t,e),Us=t=>{if(!t||typeof t!="object"||!Object.keys(t).length)return R;let e=R;return Object.assign((i,s,r={})=>e(i,s,M(t,r)),{Minimatch:class extends e.Minimatch{constructor(i,s={}){super(i,M(t,s))}static defaults(i){return e.defaults(M(t,i)).Minimatch}},AST:class extends e.AST{constructor(i,s,r={}){super(i,s,M(t,r))}static fromGlob(i,s={}){return e.AST.fromGlob(i,M(t,s))}},unescape:(i,s={})=>e.unescape(i,M(t,s)),escape:(i,s={})=>e.escape(i,M(t,s)),filter:(i,s={})=>e.filter(i,M(t,s)),defaults:i=>e.defaults(M(t,i)),makeRe:(i,s={})=>e.makeRe(i,M(t,s)),braceExpand:(i,s={})=>e.braceExpand(i,M(t,s)),match:(i,s,r={})=>e.match(i,s,M(t,r)),sep:e.sep,GLOBSTAR:F})};R.defaults=Us;var hi=(t,e={})=>(Wt(t),e.nobrace||!/\{(?:(?!\{).)*\}/.test(t)?[t]:ns(t,{max:e.braceExpandMax}));R.braceExpand=hi;var Gs=(t,e={})=>new Z(t,e).makeRe();R.makeRe=Gs;var Hs=(t,e,i={})=>{let s=new Z(e,i);return t=t.filter(r=>s.match(r)),s.options.nonull&&!t.length&&t.push(e),t};R.match=Hs;var $e=/[?*]|[+@!]\(.*?\)|\[|\]/,Vs=t=>t.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),Z=class{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;regexp;constructor(t,e={}){Wt(t),e=e||{},this.options=e,this.pattern=t,this.platform=e.platform||oi,this.isWindows=this.platform==="win32";let i="allowWindowsEscape";this.windowsPathsNoEscape=!!e.windowsPathsNoEscape||e[i]===!1,this.windowsPathsNoEscape&&(this.pattern=this.pattern.replace(/\\/g,"/")),this.preserveMultipleSlashes=!!e.preserveMultipleSlashes,this.regexp=null,this.negate=!1,this.nonegate=!!e.nonegate,this.comment=!1,this.empty=!1,this.partial=!!e.partial,this.nocase=!!this.options.nocase,this.windowsNoMagicRoot=e.windowsNoMagicRoot!==void 0?e.windowsNoMagicRoot:!!(this.isWindows&&this.nocase),this.globSet=[],this.globParts=[],this.set=[],this.make()}hasMagic(){if(this.options.magicalBraces&&this.set.length>1)return!0;for(let t of this.set)for(let e of t)if(typeof e!="string")return!0;return!1}debug(...t){}make(){let t=this.pattern,e=this.options;if(!e.nocomment&&t.charAt(0)==="#"){this.comment=!0;return}if(!t){this.empty=!0;return}this.parseNegate(),this.globSet=[...new Set(this.braceExpand())],e.debug&&(this.debug=(...r)=>console.error(...r)),this.debug(this.pattern,this.globSet);let i=this.globSet.map(r=>this.slashSplit(r));this.globParts=this.preprocess(i),this.debug(this.pattern,this.globParts);let s=this.globParts.map((r,n,o)=>{if(this.isWindows&&this.windowsNoMagicRoot){let h=r[0]===""&&r[1]===""&&(r[2]==="?"||!$e.test(r[2]))&&!$e.test(r[3]),a=/^[a-z]:/i.test(r[0]);if(h)return[...r.slice(0,4),...r.slice(4).map(l=>this.parse(l))];if(a)return[r[0],...r.slice(1).map(l=>this.parse(l))]}return r.map(h=>this.parse(h))});if(this.debug(this.pattern,s),this.set=s.filter(r=>r.indexOf(!1)===-1),this.isWindows)for(let r=0;r<this.set.length;r++){let n=this.set[r];n[0]===""&&n[1]===""&&this.globParts[r][2]==="?"&&typeof n[3]=="string"&&/^[a-z]:$/i.test(n[3])&&(n[2]="?")}this.debug(this.pattern,this.set)}preprocess(t){if(this.options.noglobstar)for(let i=0;i<t.length;i++)for(let s=0;s<t[i].length;s++)t[i][s]==="**"&&(t[i][s]="*");let{optimizationLevel:e=1}=this.options;return e>=2?(t=this.firstPhasePreProcess(t),t=this.secondPhasePreProcess(t)):e>=1?t=this.levelOneOptimize(t):t=this.adjascentGlobstarOptimize(t),t}adjascentGlobstarOptimize(t){return t.map(e=>{let i=-1;for(;(i=e.indexOf("**",i+1))!==-1;){let s=i;for(;e[s+1]==="**";)s++;s!==i&&e.splice(i,s-i)}return e})}levelOneOptimize(t){return t.map(e=>(e=e.reduce((i,s)=>{let r=i[i.length-1];return s==="**"&&r==="**"?i:s===".."&&r&&r!==".."&&r!=="."&&r!=="**"?(i.pop(),i):(i.push(s),i)},[]),e.length===0?[""]:e))}levelTwoFileOptimize(t){Array.isArray(t)||(t=this.slashSplit(t));let e=!1;do{if(e=!1,!this.preserveMultipleSlashes){for(let s=1;s<t.length-1;s++){let r=t[s];s===1&&r===""&&t[0]===""||(r==="."||r==="")&&(e=!0,t.splice(s,1),s--)}t[0]==="."&&t.length===2&&(t[1]==="."||t[1]==="")&&(e=!0,t.pop())}let i=0;for(;(i=t.indexOf("..",i+1))!==-1;){let s=t[i-1];s&&s!=="."&&s!==".."&&s!=="**"&&(e=!0,t.splice(i-1,2),i-=2)}}while(e);return t.length===0?[""]:t}firstPhasePreProcess(t){let e=!1;do{e=!1;for(let i of t){let s=-1;for(;(s=i.indexOf("**",s+1))!==-1;){let n=s;for(;i[n+1]==="**";)n++;n>s&&i.splice(s+1,n-s);let o=i[s+1],h=i[s+2],a=i[s+3];if(o!==".."||!h||h==="."||h===".."||!a||a==="."||a==="..")continue;e=!0,i.splice(s,1);let l=i.slice(0);l[s]="**",t.push(l),s--}if(!this.preserveMultipleSlashes){for(let n=1;n<i.length-1;n++){let o=i[n];n===1&&o===""&&i[0]===""||(o==="."||o==="")&&(e=!0,i.splice(n,1),n--)}i[0]==="."&&i.length===2&&(i[1]==="."||i[1]==="")&&(e=!0,i.pop())}let r=0;for(;(r=i.indexOf("..",r+1))!==-1;){let n=i[r-1];if(n&&n!=="."&&n!==".."&&n!=="**"){e=!0;let o=r===1&&i[r+1]==="**"?["."]:[];i.splice(r-1,2,...o),i.length===0&&i.push(""),r-=2}}}}while(e);return t}secondPhasePreProcess(t){for(let e=0;e<t.length-1;e++)for(let i=e+1;i<t.length;i++){let s=this.partsMatch(t[e],t[i],!this.preserveMultipleSlashes);if(s){t[e]=[],t[i]=s;break}}return t.filter(e=>e.length)}partsMatch(t,e,i=!1){let s=0,r=0,n=[],o="";for(;s<t.length&&r<e.length;)if(t[s]===e[r])n.push(o==="b"?e[r]:t[s]),s++,r++;else if(i&&t[s]==="**"&&e[r]===t[s+1])n.push(t[s]),s++;else if(i&&e[r]==="**"&&t[s]===e[r+1])n.push(e[r]),r++;else if(t[s]==="*"&&e[r]&&(this.options.dot||!e[r].startsWith("."))&&e[r]!=="**"){if(o==="b")return!1;o="a",n.push(t[s]),s++,r++}else if(e[r]==="*"&&t[s]&&(this.options.dot||!t[s].startsWith("."))&&t[s]!=="**"){if(o==="a")return!1;o="b",n.push(e[r]),s++,r++}else return!1;return t.length===e.length&&n}parseNegate(){if(this.nonegate)return;let t=this.pattern,e=!1,i=0;for(let s=0;s<t.length&&t.charAt(s)==="!";s++)e=!e,i++;i&&(this.pattern=t.slice(i)),this.negate=e}matchOne(t,e,i=!1){let s=this.options;if(this.isWindows){let d=typeof t[0]=="string"&&/^[a-z]:$/i.test(t[0]),g=!d&&t[0]===""&&t[1]===""&&t[2]==="?"&&/^[a-z]:$/i.test(t[3]),w=typeof e[0]=="string"&&/^[a-z]:$/i.test(e[0]),m=!w&&e[0]===""&&e[1]===""&&e[2]==="?"&&typeof e[3]=="string"&&/^[a-z]:$/i.test(e[3]),y=g?3:d?0:void 0,b=m?3:w?0:void 0;if(typeof y=="number"&&typeof b=="number"){let[v,S]=[t[y],e[b]];v.toLowerCase()===S.toLowerCase()&&(e[b]=v,b>y?e=e.slice(b):y>b&&(t=t.slice(y)))}}let{optimizationLevel:r=1}=this.options;r>=2&&(t=this.levelTwoFileOptimize(t)),this.debug("matchOne",this,{file:t,pattern:e}),this.debug("matchOne",t.length,e.length);for(var n=0,o=0,h=t.length,a=e.length;n<h&&o<a;n++,o++){this.debug("matchOne loop");var l=e[o],p=t[n];if(this.debug(e,l,p),l===!1)return!1;if(l===F){this.debug("GLOBSTAR",[e,l,p]);var c=n,f=o+1;if(f===a){for(this.debug("** at the end");n<h;n++)if(t[n]==="."||t[n]===".."||!s.dot&&t[n].charAt(0)===".")return!1;return!0}for(;c<h;){var u=t[c];if(this.debug(`
8
+ globstar while`,t,c,e,f,u),this.matchOne(t.slice(c),e.slice(f),i))return this.debug("globstar found match!",c,h,u),!0;if(u==="."||u===".."||!s.dot&&u.charAt(0)==="."){this.debug("dot detected!",t,c,e,f);break}this.debug("globstar swallow a segment, and continue"),c++}return!!(i&&(this.debug(`
9
+ >>> no match, partial?`,t,c,e,f),c===h))}let d;if(typeof l=="string"?(d=p===l,this.debug("string match",l,p,d)):(d=l.test(p),this.debug("pattern match",l,p,d)),!d)return!1}if(n===h&&o===a)return!0;if(n===h)return i;if(o===a)return n===h-1&&t[n]==="";throw new Error("wtf?")}braceExpand(){return hi(this.pattern,this.options)}parse(t){Wt(t);let e=this.options;if(t==="**")return F;if(t==="")return"";let i,s=null;(i=t.match(Fs))?s=e.dot?js:Rs:(i=t.match(bs))?s=(e.nocase?e.dot?Es:xs:e.dot?Ss:vs)(i[1]):(i=t.match(Ps))?s=(e.nocase?e.dot?$s:Ds:e.dot?Ms:Ls)(i):(i=t.match(As))?s=e.dot?Cs:ks:(i=t.match(Os))&&(s=Ts);let r=ii.fromGlob(t,this.options).toMMPattern();return s&&typeof r=="object"&&Reflect.defineProperty(r,"test",{value:s}),r}makeRe(){if(this.regexp||this.regexp===!1)return this.regexp;let t=this.set;if(!t.length)return this.regexp=!1,this.regexp;let e=this.options,i=e.noglobstar?zs:e.dot?_s:Bs,s=new Set(e.nocase?["i"]:[]),r=t.map(h=>{let a=h.map(p=>{if(p instanceof RegExp)for(let c of p.flags.split(""))s.add(c);return typeof p=="string"?Vs(p):p===F?F:p._src});a.forEach((p,c)=>{let f=a[c+1],u=a[c-1];p!==F||u===F||(u===void 0?f!==void 0&&f!==F?a[c+1]="(?:\\/|"+i+"\\/)?"+f:a[c]=i:f===void 0?a[c-1]=u+"(?:\\/|\\/"+i+")?":f!==F&&(a[c-1]=u+"(?:\\/|\\/"+i+"\\/)"+f,a[c+1]=F))});let l=a.filter(p=>p!==F);if(this.partial&&l.length>=1){let p=[];for(let c=1;c<=l.length;c++)p.push(l.slice(0,c).join("/"));return"(?:"+p.join("|")+")"}return l.join("/")}).join("|"),[n,o]=t.length>1?["(?:",")"]:["",""];r="^"+n+r+o+"$",this.partial&&(r="^(?:\\/|"+n+r.slice(1,-1)+o+")$"),this.negate&&(r="^(?!"+r+").+$");try{this.regexp=new RegExp(r,[...s].join(""))}catch{this.regexp=!1}return this.regexp}slashSplit(t){return this.preserveMultipleSlashes?t.split("/"):this.isWindows&&/^\/\/[^\/]+/.test(t)?["",...t.split(/\/+/)]:t.split(/\/+/)}match(t,e=this.partial){if(this.debug("match",t,this.pattern),this.comment)return!1;if(this.empty)return t==="";if(t==="/"&&e)return!0;let i=this.options;this.isWindows&&(t=t.split("\\").join("/"));let s=this.slashSplit(t);this.debug(this.pattern,"split",s);let r=this.set;this.debug(this.pattern,"set",r);let n=s[s.length-1];if(!n)for(let o=s.length-2;!n&&o>=0;o--)n=s[o];for(let o=0;o<r.length;o++){let h=r[o],a=s;if(i.matchBase&&h.length===1&&(a=[n]),this.matchOne(a,h,e))return i.flipNegate?!0:!this.negate}return i.flipNegate?!1:this.negate}static defaults(t){return R.defaults(t).Minimatch}};R.AST=ii;R.Minimatch=Z;R.escape=si;R.unescape=at;var Js=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,ai=new Set,oe=typeof process=="object"&&process?process:{},li=(t,e,i,s)=>{typeof oe.emitWarning=="function"?oe.emitWarning(t,e,i,s):console.error(`[${i}] ${e}: ${t}`)},Nt=globalThis.AbortController,Me=globalThis.AbortSignal;if(typeof Nt>"u"){Me=class{onabort;_onabort=[];reason;aborted=!1;addEventListener(i,s){this._onabort.push(s)}},Nt=class{constructor(){e()}signal=new Me;abort(i){if(!this.signal.aborted){this.signal.reason=i,this.signal.aborted=!0;for(let s of this.signal._onabort)s(i);this.signal.onabort?.(i)}}};let t=oe.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",e=()=>{t&&(t=!1,li("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.","NO_ABORT_CONTROLLER","ENOTSUP",e))}}var qs=t=>!ai.has(t),K=t=>t&&t===Math.floor(t)&&t>0&&isFinite(t),ci=t=>K(t)?t<=Math.pow(2,8)?Uint8Array:t<=Math.pow(2,16)?Uint16Array:t<=Math.pow(2,32)?Uint32Array:t<=Number.MAX_SAFE_INTEGER?Mt:null:null,Mt=class extends Array{constructor(t){super(t),this.fill(0)}},Ks=class wt{heap;length;static#t=!1;static create(e){let i=ci(e);if(!i)return[];wt.#t=!0;let s=new wt(e,i);return wt.#t=!1,s}constructor(e,i){if(!wt.#t)throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new i(e),this.length=0}push(e){this.heap[this.length++]=e}pop(){return this.heap[--this.length]}},Bt=class pi{#t;#i;#n;#r;#o;#v;#w;#c;get perf(){return this.#c}ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#h;#u;#p;#a;#s;#f;#S;#b;#d;#T;#g;#A;#k;#m;#y;#x;#C;#e;#$;static unsafeExposeInternals(e){return{starts:e.#k,ttls:e.#m,autopurgeTimers:e.#y,sizes:e.#A,keyMap:e.#p,keyList:e.#a,valList:e.#s,next:e.#f,prev:e.#S,get head(){return e.#b},get tail(){return e.#d},free:e.#T,isBackgroundFetch:i=>e.#l(i),backgroundFetch:(i,s,r,n)=>e.#I(i,s,r,n),moveToTail:i=>e.#L(i),indexes:i=>e.#R(i),rindexes:i=>e.#j(i),isStale:i=>e.#E(i)}}get max(){return this.#t}get maxSize(){return this.#i}get calculatedSize(){return this.#u}get size(){return this.#h}get fetchMethod(){return this.#v}get memoMethod(){return this.#w}get dispose(){return this.#n}get onInsert(){return this.#r}get disposeAfter(){return this.#o}constructor(e){let{max:i=0,ttl:s,ttlResolution:r=1,ttlAutopurge:n,updateAgeOnGet:o,updateAgeOnHas:h,allowStale:a,dispose:l,onInsert:p,disposeAfter:c,noDisposeOnSet:f,noUpdateTTL:u,maxSize:d=0,maxEntrySize:g=0,sizeCalculation:w,fetchMethod:m,memoMethod:y,noDeleteOnFetchRejection:b,noDeleteOnStaleGet:v,allowStaleOnFetchRejection:S,allowStaleOnFetchAbort:Y,ignoreFetchAbort:it,perf:st}=e;if(st!==void 0&&typeof st?.now!="function")throw new TypeError("perf option must have a now() method if specified");if(this.#c=st??Js,i!==0&&!K(i))throw new TypeError("max option must be a nonnegative integer");let rt=i?ci(i):Array;if(!rt)throw new Error("invalid max value: "+i);if(this.#t=i,this.#i=d,this.maxEntrySize=g||this.#i,this.sizeCalculation=w,this.sizeCalculation){if(!this.#i&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if(typeof this.sizeCalculation!="function")throw new TypeError("sizeCalculation set to non-function")}if(y!==void 0&&typeof y!="function")throw new TypeError("memoMethod must be a function if defined");if(this.#w=y,m!==void 0&&typeof m!="function")throw new TypeError("fetchMethod must be a function if specified");if(this.#v=m,this.#C=!!m,this.#p=new Map,this.#a=new Array(i).fill(void 0),this.#s=new Array(i).fill(void 0),this.#f=new rt(i),this.#S=new rt(i),this.#b=0,this.#d=0,this.#T=Ks.create(i),this.#h=0,this.#u=0,typeof l=="function"&&(this.#n=l),typeof p=="function"&&(this.#r=p),typeof c=="function"?(this.#o=c,this.#g=[]):(this.#o=void 0,this.#g=void 0),this.#x=!!this.#n,this.#$=!!this.#r,this.#e=!!this.#o,this.noDisposeOnSet=!!f,this.noUpdateTTL=!!u,this.noDeleteOnFetchRejection=!!b,this.allowStaleOnFetchRejection=!!S,this.allowStaleOnFetchAbort=!!Y,this.ignoreFetchAbort=!!it,this.maxEntrySize!==0){if(this.#i!==0&&!K(this.#i))throw new TypeError("maxSize must be a positive integer if specified");if(!K(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");this.#G()}if(this.allowStale=!!a,this.noDeleteOnStaleGet=!!v,this.updateAgeOnGet=!!o,this.updateAgeOnHas=!!h,this.ttlResolution=K(r)||r===0?r:1,this.ttlAutopurge=!!n,this.ttl=s||0,this.ttl){if(!K(this.ttl))throw new TypeError("ttl must be a positive integer if specified");this.#P()}if(this.#t===0&&this.ttl===0&&this.#i===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.#t&&!this.#i){let Jt="LRU_CACHE_UNBOUNDED";qs(Jt)&&(ai.add(Jt),li("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",Jt,pi))}}getRemainingTTL(e){return this.#p.has(e)?1/0:0}#P(){let e=new Mt(this.#t),i=new Mt(this.#t);this.#m=e,this.#k=i;let s=this.ttlAutopurge?new Array(this.#t):void 0;this.#y=s,this.#N=(o,h,a=this.#c.now())=>{if(i[o]=h!==0?a:0,e[o]=h,s?.[o]&&(clearTimeout(s[o]),s[o]=void 0),h!==0&&s){let l=setTimeout(()=>{this.#E(o)&&this.#F(this.#a[o],"expire")},h+1);l.unref&&l.unref(),s[o]=l}},this.#O=o=>{i[o]=e[o]!==0?this.#c.now():0},this.#D=(o,h)=>{if(e[h]){let a=e[h],l=i[h];if(!a||!l)return;o.ttl=a,o.start=l,o.now=r||n();let p=o.now-l;o.remainingTTL=a-p}};let r=0,n=()=>{let o=this.#c.now();if(this.ttlResolution>0){r=o;let h=setTimeout(()=>r=0,this.ttlResolution);h.unref&&h.unref()}return o};this.getRemainingTTL=o=>{let h=this.#p.get(o);if(h===void 0)return 0;let a=e[h],l=i[h];if(!a||!l)return 1/0;let p=(r||n())-l;return a-p},this.#E=o=>{let h=i[o],a=e[o];return!!a&&!!h&&(r||n())-h>a}}#O=()=>{};#D=()=>{};#N=()=>{};#E=()=>!1;#G(){let e=new Mt(this.#t);this.#u=0,this.#A=e,this.#W=i=>{this.#u-=e[i],e[i]=0},this.#z=(i,s,r,n)=>{if(this.#l(s))return 0;if(!K(r))if(n){if(typeof n!="function")throw new TypeError("sizeCalculation must be a function");if(r=n(s,i),!K(r))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");return r},this.#M=(i,s,r)=>{if(e[i]=s,this.#i){let n=this.#i-e[i];for(;this.#u>n;)this.#B(!0)}this.#u+=e[i],r&&(r.entrySize=s,r.totalCalculatedSize=this.#u)}}#W=e=>{};#M=(e,i,s)=>{};#z=(e,i,s,r)=>{if(s||r)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0};*#R({allowStale:e=this.allowStale}={}){if(this.#h)for(let i=this.#d;!(!this.#_(i)||((e||!this.#E(i))&&(yield i),i===this.#b));)i=this.#S[i]}*#j({allowStale:e=this.allowStale}={}){if(this.#h)for(let i=this.#b;!(!this.#_(i)||((e||!this.#E(i))&&(yield i),i===this.#d));)i=this.#f[i]}#_(e){return e!==void 0&&this.#p.get(this.#a[e])===e}*entries(){for(let e of this.#R())this.#s[e]!==void 0&&this.#a[e]!==void 0&&!this.#l(this.#s[e])&&(yield[this.#a[e],this.#s[e]])}*rentries(){for(let e of this.#j())this.#s[e]!==void 0&&this.#a[e]!==void 0&&!this.#l(this.#s[e])&&(yield[this.#a[e],this.#s[e]])}*keys(){for(let e of this.#R()){let i=this.#a[e];i!==void 0&&!this.#l(this.#s[e])&&(yield i)}}*rkeys(){for(let e of this.#j()){let i=this.#a[e];i!==void 0&&!this.#l(this.#s[e])&&(yield i)}}*values(){for(let e of this.#R())this.#s[e]!==void 0&&!this.#l(this.#s[e])&&(yield this.#s[e])}*rvalues(){for(let e of this.#j())this.#s[e]!==void 0&&!this.#l(this.#s[e])&&(yield this.#s[e])}[Symbol.iterator](){return this.entries()}[Symbol.toStringTag]="LRUCache";find(e,i={}){for(let s of this.#R()){let r=this.#s[s],n=this.#l(r)?r.__staleWhileFetching:r;if(n!==void 0&&e(n,this.#a[s],this))return this.get(this.#a[s],i)}}forEach(e,i=this){for(let s of this.#R()){let r=this.#s[s],n=this.#l(r)?r.__staleWhileFetching:r;n!==void 0&&e.call(i,n,this.#a[s],this)}}rforEach(e,i=this){for(let s of this.#j()){let r=this.#s[s],n=this.#l(r)?r.__staleWhileFetching:r;n!==void 0&&e.call(i,n,this.#a[s],this)}}purgeStale(){let e=!1;for(let i of this.#j({allowStale:!0}))this.#E(i)&&(this.#F(this.#a[i],"expire"),e=!0);return e}info(e){let i=this.#p.get(e);if(i===void 0)return;let s=this.#s[i],r=this.#l(s)?s.__staleWhileFetching:s;if(r===void 0)return;let n={value:r};if(this.#m&&this.#k){let o=this.#m[i],h=this.#k[i];if(o&&h){let a=o-(this.#c.now()-h);n.ttl=a,n.start=Date.now()}}return this.#A&&(n.size=this.#A[i]),n}dump(){let e=[];for(let i of this.#R({allowStale:!0})){let s=this.#a[i],r=this.#s[i],n=this.#l(r)?r.__staleWhileFetching:r;if(n===void 0||s===void 0)continue;let o={value:n};if(this.#m&&this.#k){o.ttl=this.#m[i];let h=this.#c.now()-this.#k[i];o.start=Math.floor(Date.now()-h)}this.#A&&(o.size=this.#A[i]),e.unshift([s,o])}return e}load(e){this.clear();for(let[i,s]of e){if(s.start){let r=Date.now()-s.start;s.start=this.#c.now()-r}this.set(i,s.value,s)}}set(e,i,s={}){if(i===void 0)return this.delete(e),this;let{ttl:r=this.ttl,start:n,noDisposeOnSet:o=this.noDisposeOnSet,sizeCalculation:h=this.sizeCalculation,status:a}=s,{noUpdateTTL:l=this.noUpdateTTL}=s,p=this.#z(e,i,s.size||0,h);if(this.maxEntrySize&&p>this.maxEntrySize)return a&&(a.set="miss",a.maxEntrySizeExceeded=!0),this.#F(e,"set"),this;let c=this.#h===0?void 0:this.#p.get(e);if(c===void 0)c=this.#h===0?this.#d:this.#T.length!==0?this.#T.pop():this.#h===this.#t?this.#B(!1):this.#h,this.#a[c]=e,this.#s[c]=i,this.#p.set(e,c),this.#f[this.#d]=c,this.#S[c]=this.#d,this.#d=c,this.#h++,this.#M(c,p,a),a&&(a.set="add"),l=!1,this.#$&&this.#r?.(i,e,"add");else{this.#L(c);let f=this.#s[c];if(i!==f){if(this.#C&&this.#l(f)){f.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:u}=f;u!==void 0&&!o&&(this.#x&&this.#n?.(u,e,"set"),this.#e&&this.#g?.push([u,e,"set"]))}else o||(this.#x&&this.#n?.(f,e,"set"),this.#e&&this.#g?.push([f,e,"set"]));if(this.#W(c),this.#M(c,p,a),this.#s[c]=i,a){a.set="replace";let u=f&&this.#l(f)?f.__staleWhileFetching:f;u!==void 0&&(a.oldValue=u)}}else a&&(a.set="update");this.#$&&this.onInsert?.(i,e,i===f?"update":"replace")}if(r!==0&&!this.#m&&this.#P(),this.#m&&(l||this.#N(c,r,n),a&&this.#D(a,c)),!o&&this.#e&&this.#g){let f=this.#g,u;for(;u=f?.shift();)this.#o?.(...u)}return this}pop(){try{for(;this.#h;){let e=this.#s[this.#b];if(this.#B(!0),this.#l(e)){if(e.__staleWhileFetching)return e.__staleWhileFetching}else if(e!==void 0)return e}}finally{if(this.#e&&this.#g){let e=this.#g,i;for(;i=e?.shift();)this.#o?.(...i)}}}#B(e){let i=this.#b,s=this.#a[i],r=this.#s[i];return this.#C&&this.#l(r)?r.__abortController.abort(new Error("evicted")):(this.#x||this.#e)&&(this.#x&&this.#n?.(r,s,"evict"),this.#e&&this.#g?.push([r,s,"evict"])),this.#W(i),this.#y?.[i]&&(clearTimeout(this.#y[i]),this.#y[i]=void 0),e&&(this.#a[i]=void 0,this.#s[i]=void 0,this.#T.push(i)),this.#h===1?(this.#b=this.#d=0,this.#T.length=0):this.#b=this.#f[i],this.#p.delete(s),this.#h--,i}has(e,i={}){let{updateAgeOnHas:s=this.updateAgeOnHas,status:r}=i,n=this.#p.get(e);if(n!==void 0){let o=this.#s[n];if(this.#l(o)&&o.__staleWhileFetching===void 0)return!1;if(this.#E(n))r&&(r.has="stale",this.#D(r,n));else return s&&this.#O(n),r&&(r.has="hit",this.#D(r,n)),!0}else r&&(r.has="miss");return!1}peek(e,i={}){let{allowStale:s=this.allowStale}=i,r=this.#p.get(e);if(r===void 0||!s&&this.#E(r))return;let n=this.#s[r];return this.#l(n)?n.__staleWhileFetching:n}#I(e,i,s,r){let n=i===void 0?void 0:this.#s[i];if(this.#l(n))return n;let o=new Nt,{signal:h}=s;h?.addEventListener("abort",()=>o.abort(h.reason),{signal:o.signal});let a={signal:o.signal,options:s,context:r},l=(g,w=!1)=>{let{aborted:m}=o.signal,y=s.ignoreFetchAbort&&g!==void 0,b=s.ignoreFetchAbort||!!(s.allowStaleOnFetchAbort&&g!==void 0);if(s.status&&(m&&!w?(s.status.fetchAborted=!0,s.status.fetchError=o.signal.reason,y&&(s.status.fetchAbortIgnored=!0)):s.status.fetchResolved=!0),m&&!y&&!w)return c(o.signal.reason,b);let v=u,S=this.#s[i];return(S===u||y&&w&&S===void 0)&&(g===void 0?v.__staleWhileFetching!==void 0?this.#s[i]=v.__staleWhileFetching:this.#F(e,"fetch"):(s.status&&(s.status.fetchUpdated=!0),this.set(e,g,a.options))),g},p=g=>(s.status&&(s.status.fetchRejected=!0,s.status.fetchError=g),c(g,!1)),c=(g,w)=>{let{aborted:m}=o.signal,y=m&&s.allowStaleOnFetchAbort,b=y||s.allowStaleOnFetchRejection,v=b||s.noDeleteOnFetchRejection,S=u;if(this.#s[i]===u&&(!v||!w&&S.__staleWhileFetching===void 0?this.#F(e,"fetch"):y||(this.#s[i]=S.__staleWhileFetching)),b)return s.status&&S.__staleWhileFetching!==void 0&&(s.status.returnedStale=!0),S.__staleWhileFetching;if(S.__returned===S)throw g},f=(g,w)=>{let m=this.#v?.(e,n,a);m&&m instanceof Promise&&m.then(y=>g(y===void 0?void 0:y),w),o.signal.addEventListener("abort",()=>{(!s.ignoreFetchAbort||s.allowStaleOnFetchAbort)&&(g(void 0),s.allowStaleOnFetchAbort&&(g=y=>l(y,!0)))})};s.status&&(s.status.fetchDispatched=!0);let u=new Promise(f).then(l,p),d=Object.assign(u,{__abortController:o,__staleWhileFetching:n,__returned:void 0});return i===void 0?(this.set(e,d,{...a.options,status:void 0}),i=this.#p.get(e)):this.#s[i]=d,d}#l(e){if(!this.#C)return!1;let i=e;return!!i&&i instanceof Promise&&i.hasOwnProperty("__staleWhileFetching")&&i.__abortController instanceof Nt}async fetch(e,i={}){let{allowStale:s=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:n=this.noDeleteOnStaleGet,ttl:o=this.ttl,noDisposeOnSet:h=this.noDisposeOnSet,size:a=0,sizeCalculation:l=this.sizeCalculation,noUpdateTTL:p=this.noUpdateTTL,noDeleteOnFetchRejection:c=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:f=this.allowStaleOnFetchRejection,ignoreFetchAbort:u=this.ignoreFetchAbort,allowStaleOnFetchAbort:d=this.allowStaleOnFetchAbort,context:g,forceRefresh:w=!1,status:m,signal:y}=i;if(!this.#C)return m&&(m.fetch="get"),this.get(e,{allowStale:s,updateAgeOnGet:r,noDeleteOnStaleGet:n,status:m});let b={allowStale:s,updateAgeOnGet:r,noDeleteOnStaleGet:n,ttl:o,noDisposeOnSet:h,size:a,sizeCalculation:l,noUpdateTTL:p,noDeleteOnFetchRejection:c,allowStaleOnFetchRejection:f,allowStaleOnFetchAbort:d,ignoreFetchAbort:u,status:m,signal:y},v=this.#p.get(e);if(v===void 0){m&&(m.fetch="miss");let S=this.#I(e,v,b,g);return S.__returned=S}else{let S=this.#s[v];if(this.#l(S)){let rt=s&&S.__staleWhileFetching!==void 0;return m&&(m.fetch="inflight",rt&&(m.returnedStale=!0)),rt?S.__staleWhileFetching:S.__returned=S}let Y=this.#E(v);if(!w&&!Y)return m&&(m.fetch="hit"),this.#L(v),r&&this.#O(v),m&&this.#D(m,v),S;let it=this.#I(e,v,b,g),st=it.__staleWhileFetching!==void 0&&s;return m&&(m.fetch=Y?"stale":"refresh",st&&Y&&(m.returnedStale=!0)),st?it.__staleWhileFetching:it.__returned=it}}async forceFetch(e,i={}){let s=await this.fetch(e,i);if(s===void 0)throw new Error("fetch() returned undefined");return s}memo(e,i={}){let s=this.#w;if(!s)throw new Error("no memoMethod provided to constructor");let{context:r,forceRefresh:n,...o}=i,h=this.get(e,o);if(!n&&h!==void 0)return h;let a=s(e,h,{options:o,context:r});return this.set(e,a,o),a}get(e,i={}){let{allowStale:s=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:n=this.noDeleteOnStaleGet,status:o}=i,h=this.#p.get(e);if(h!==void 0){let a=this.#s[h],l=this.#l(a);return o&&this.#D(o,h),this.#E(h)?(o&&(o.get="stale"),l?(o&&s&&a.__staleWhileFetching!==void 0&&(o.returnedStale=!0),s?a.__staleWhileFetching:void 0):(n||this.#F(e,"expire"),o&&s&&(o.returnedStale=!0),s?a:void 0)):(o&&(o.get="hit"),l?a.__staleWhileFetching:(this.#L(h),r&&this.#O(h),a))}else o&&(o.get="miss")}#U(e,i){this.#S[i]=e,this.#f[e]=i}#L(e){e!==this.#d&&(e===this.#b?this.#b=this.#f[e]:this.#U(this.#S[e],this.#f[e]),this.#U(this.#d,e),this.#d=e)}delete(e){return this.#F(e,"delete")}#F(e,i){let s=!1;if(this.#h!==0){let r=this.#p.get(e);if(r!==void 0)if(this.#y?.[r]&&(clearTimeout(this.#y?.[r]),this.#y[r]=void 0),s=!0,this.#h===1)this.#H(i);else{this.#W(r);let n=this.#s[r];if(this.#l(n)?n.__abortController.abort(new Error("deleted")):(this.#x||this.#e)&&(this.#x&&this.#n?.(n,e,i),this.#e&&this.#g?.push([n,e,i])),this.#p.delete(e),this.#a[r]=void 0,this.#s[r]=void 0,r===this.#d)this.#d=this.#S[r];else if(r===this.#b)this.#b=this.#f[r];else{let o=this.#S[r];this.#f[o]=this.#f[r];let h=this.#f[r];this.#S[h]=this.#S[r]}this.#h--,this.#T.push(r)}}if(this.#e&&this.#g?.length){let r=this.#g,n;for(;n=r?.shift();)this.#o?.(...n)}return s}clear(){return this.#H("delete")}#H(e){for(let i of this.#j({allowStale:!0})){let s=this.#s[i];if(this.#l(s))s.__abortController.abort(new Error("deleted"));else{let r=this.#a[i];this.#x&&this.#n?.(s,r,e),this.#e&&this.#g?.push([s,r,e])}}if(this.#p.clear(),this.#s.fill(void 0),this.#a.fill(void 0),this.#m&&this.#k){this.#m.fill(0),this.#k.fill(0);for(let i of this.#y??[])i!==void 0&&clearTimeout(i);this.#y?.fill(void 0)}if(this.#A&&this.#A.fill(0),this.#b=0,this.#d=0,this.#T.length=0,this.#u=0,this.#h=0,this.#e&&this.#g){let i=this.#g,s;for(;s=i?.shift();)this.#o?.(...s)}}},Le=typeof process=="object"&&process?process:{stdout:null,stderr:null},cr=t=>!!t&&typeof t=="object"&&(t instanceof zt||t instanceof ui||pr(t)||ur(t)),pr=t=>!!t&&typeof t=="object"&&t instanceof ce&&typeof t.pipe=="function"&&t.pipe!==ui.Writable.prototype.pipe,ur=t=>!!t&&typeof t=="object"&&t instanceof ce&&typeof t.write=="function"&&typeof t.end=="function",G=Symbol("EOF"),H=Symbol("maybeEmitEnd"),q=Symbol("emittedEnd"),Tt=Symbol("emittingEnd"),pt=Symbol("emittedError"),Ft=Symbol("closed"),We=Symbol("read"),Rt=Symbol("flush"),Ne=Symbol("flushChunk"),_=Symbol("encoding"),ot=Symbol("decoder"),A=Symbol("flowing"),ut=Symbol("paused"),ht=Symbol("resume"),k=Symbol("buffer"),T=Symbol("pipes"),C=Symbol("bufferLength"),Qt=Symbol("bufferPush"),jt=Symbol("bufferShift"),O=Symbol("objectMode"),E=Symbol("destroyed"),te=Symbol("error"),ee=Symbol("emitData"),ze=Symbol("emitEnd"),ie=Symbol("emitEnd2"),I=Symbol("async"),se=Symbol("abort"),Pt=Symbol("aborted"),ft=Symbol("signal"),Q=Symbol("dataListeners"),P=Symbol("discarded"),dt=t=>Promise.resolve().then(t),fr=t=>t(),dr=t=>t==="end"||t==="finish"||t==="prefinish",gr=t=>t instanceof ArrayBuffer||!!t&&typeof t=="object"&&t.constructor&&t.constructor.name==="ArrayBuffer"&&t.byteLength>=0,mr=t=>!Buffer.isBuffer(t)&&ArrayBuffer.isView(t),fi=class{src;dest;opts;ondrain;constructor(t,e,i){this.src=t,this.dest=e,this.opts=i,this.ondrain=()=>t[ht](),this.dest.on("drain",this.ondrain)}unpipe(){this.dest.removeListener("drain",this.ondrain)}proxyErrors(t){}end(){this.unpipe(),this.opts.end&&this.dest.end()}},wr=class extends fi{unpipe(){this.src.removeListener("error",this.proxyErrors),super.unpipe()}constructor(t,e,i){super(t,e,i),this.proxyErrors=s=>e.emit("error",s),t.on("error",this.proxyErrors)}},yr=t=>!!t.objectMode,br=t=>!t.objectMode&&!!t.encoding&&t.encoding!=="buffer",zt=class extends ce{[A]=!1;[ut]=!1;[T]=[];[k]=[];[O];[_];[I];[ot];[G]=!1;[q]=!1;[Tt]=!1;[Ft]=!1;[pt]=null;[C]=0;[E]=!1;[ft];[Pt]=!1;[Q]=0;[P]=!1;writable=!0;readable=!0;constructor(...t){let e=t[0]||{};if(super(),e.objectMode&&typeof e.encoding=="string")throw new TypeError("Encoding and objectMode may not be used together");yr(e)?(this[O]=!0,this[_]=null):br(e)?(this[_]=e.encoding,this[O]=!1):(this[O]=!1,this[_]=null),this[I]=!!e.async,this[ot]=this[_]?new lr(this[_]):null,e&&e.debugExposeBuffer===!0&&Object.defineProperty(this,"buffer",{get:()=>this[k]}),e&&e.debugExposePipes===!0&&Object.defineProperty(this,"pipes",{get:()=>this[T]});let{signal:i}=e;i&&(this[ft]=i,i.aborted?this[se]():i.addEventListener("abort",()=>this[se]()))}get bufferLength(){return this[C]}get encoding(){return this[_]}set encoding(t){throw new Error("Encoding must be set at instantiation time")}setEncoding(t){throw new Error("Encoding must be set at instantiation time")}get objectMode(){return this[O]}set objectMode(t){throw new Error("objectMode must be set at instantiation time")}get async(){return this[I]}set async(t){this[I]=this[I]||!!t}[se](){this[Pt]=!0,this.emit("abort",this[ft]?.reason),this.destroy(this[ft]?.reason)}get aborted(){return this[Pt]}set aborted(t){}write(t,e,i){if(this[Pt])return!1;if(this[G])throw new Error("write after end");if(this[E])return this.emit("error",Object.assign(new Error("Cannot call write after a stream was destroyed"),{code:"ERR_STREAM_DESTROYED"})),!0;typeof e=="function"&&(i=e,e="utf8"),e||(e="utf8");let s=this[I]?dt:fr;if(!this[O]&&!Buffer.isBuffer(t)){if(mr(t))t=Buffer.from(t.buffer,t.byteOffset,t.byteLength);else if(gr(t))t=Buffer.from(t);else if(typeof t!="string")throw new Error("Non-contiguous data written to non-objectMode stream")}return this[O]?(this[A]&&this[C]!==0&&this[Rt](!0),this[A]?this.emit("data",t):this[Qt](t),this[C]!==0&&this.emit("readable"),i&&s(i),this[A]):t.length?(typeof t=="string"&&!(e===this[_]&&!this[ot]?.lastNeed)&&(t=Buffer.from(t,e)),Buffer.isBuffer(t)&&this[_]&&(t=this[ot].write(t)),this[A]&&this[C]!==0&&this[Rt](!0),this[A]?this.emit("data",t):this[Qt](t),this[C]!==0&&this.emit("readable"),i&&s(i),this[A]):(this[C]!==0&&this.emit("readable"),i&&s(i),this[A])}read(t){if(this[E])return null;if(this[P]=!1,this[C]===0||t===0||t&&t>this[C])return this[H](),null;this[O]&&(t=null),this[k].length>1&&!this[O]&&(this[k]=[this[_]?this[k].join(""):Buffer.concat(this[k],this[C])]);let e=this[We](t||null,this[k][0]);return this[H](),e}[We](t,e){if(this[O])this[jt]();else{let i=e;t===i.length||t===null?this[jt]():typeof i=="string"?(this[k][0]=i.slice(t),e=i.slice(0,t),this[C]-=t):(this[k][0]=i.subarray(t),e=i.subarray(0,t),this[C]-=t)}return this.emit("data",e),!this[k].length&&!this[G]&&this.emit("drain"),e}end(t,e,i){return typeof t=="function"&&(i=t,t=void 0),typeof e=="function"&&(i=e,e="utf8"),t!==void 0&&this.write(t,e),i&&this.once("end",i),this[G]=!0,this.writable=!1,(this[A]||!this[ut])&&this[H](),this}[ht](){this[E]||(!this[Q]&&!this[T].length&&(this[P]=!0),this[ut]=!1,this[A]=!0,this.emit("resume"),this[k].length?this[Rt]():this[G]?this[H]():this.emit("drain"))}resume(){return this[ht]()}pause(){this[A]=!1,this[ut]=!0,this[P]=!1}get destroyed(){return this[E]}get flowing(){return this[A]}get paused(){return this[ut]}[Qt](t){this[O]?this[C]+=1:this[C]+=t.length,this[k].push(t)}[jt](){return this[O]?this[C]-=1:this[C]-=this[k][0].length,this[k].shift()}[Rt](t=!1){do;while(this[Ne](this[jt]())&&this[k].length);!t&&!this[k].length&&!this[G]&&this.emit("drain")}[Ne](t){return this.emit("data",t),this[A]}pipe(t,e){if(this[E])return t;this[P]=!1;let i=this[q];return e=e||{},t===Le.stdout||t===Le.stderr?e.end=!1:e.end=e.end!==!1,e.proxyErrors=!!e.proxyErrors,i?e.end&&t.end():(this[T].push(e.proxyErrors?new wr(this,t,e):new fi(this,t,e)),this[I]?dt(()=>this[ht]()):this[ht]()),t}unpipe(t){let e=this[T].find(i=>i.dest===t);e&&(this[T].length===1?(this[A]&&this[Q]===0&&(this[A]=!1),this[T]=[]):this[T].splice(this[T].indexOf(e),1),e.unpipe())}addListener(t,e){return this.on(t,e)}on(t,e){let i=super.on(t,e);if(t==="data")this[P]=!1,this[Q]++,!this[T].length&&!this[A]&&this[ht]();else if(t==="readable"&&this[C]!==0)super.emit("readable");else if(dr(t)&&this[q])super.emit(t),this.removeAllListeners(t);else if(t==="error"&&this[pt]){let s=e;this[I]?dt(()=>s.call(this,this[pt])):s.call(this,this[pt])}return i}removeListener(t,e){return this.off(t,e)}off(t,e){let i=super.off(t,e);return t==="data"&&(this[Q]=this.listeners("data").length,this[Q]===0&&!this[P]&&!this[T].length&&(this[A]=!1)),i}removeAllListeners(t){let e=super.removeAllListeners(t);return(t==="data"||t===void 0)&&(this[Q]=0,!this[P]&&!this[T].length&&(this[A]=!1)),e}get emittedEnd(){return this[q]}[H](){!this[Tt]&&!this[q]&&!this[E]&&this[k].length===0&&this[G]&&(this[Tt]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[Ft]&&this.emit("close"),this[Tt]=!1)}emit(t,...e){let i=e[0];if(t!=="error"&&t!=="close"&&t!==E&&this[E])return!1;if(t==="data")return!this[O]&&!i?!1:this[I]?(dt(()=>this[ee](i)),!0):this[ee](i);if(t==="end")return this[ze]();if(t==="close"){if(this[Ft]=!0,!this[q]&&!this[E])return!1;let r=super.emit("close");return this.removeAllListeners("close"),r}else if(t==="error"){this[pt]=i,super.emit(te,i);let r=!this[ft]||this.listeners("error").length?super.emit("error",i):!1;return this[H](),r}else if(t==="resume"){let r=super.emit("resume");return this[H](),r}else if(t==="finish"||t==="prefinish"){let r=super.emit(t);return this.removeAllListeners(t),r}let s=super.emit(t,...e);return this[H](),s}[ee](t){for(let i of this[T])i.dest.write(t)===!1&&this.pause();let e=this[P]?!1:super.emit("data",t);return this[H](),e}[ze](){return this[q]?!1:(this[q]=!0,this.readable=!1,this[I]?(dt(()=>this[ie]()),!0):this[ie]())}[ie](){if(this[ot]){let e=this[ot].end();if(e){for(let i of this[T])i.dest.write(e);this[P]||super.emit("data",e)}}for(let e of this[T])e.end();let t=super.emit("end");return this.removeAllListeners("end"),t}async collect(){let t=Object.assign([],{dataLength:0});this[O]||(t.dataLength=0);let e=this.promise();return this.on("data",i=>{t.push(i),this[O]||(t.dataLength+=i.length)}),await e,t}async concat(){if(this[O])throw new Error("cannot concat in objectMode");let t=await this.collect();return this[_]?t.join(""):Buffer.concat(t,t.dataLength)}async promise(){return new Promise((t,e)=>{this.on(E,()=>e(new Error("stream destroyed"))),this.on("error",i=>e(i)),this.on("end",()=>t())})}[Symbol.asyncIterator](){this[P]=!1;let t=!1,e=async()=>(this.pause(),t=!0,{value:void 0,done:!0});return{next:()=>{if(t)return e();let i=this.read();if(i!==null)return Promise.resolve({done:!1,value:i});if(this[G])return e();let s,r,n=l=>{this.off("data",o),this.off("end",h),this.off(E,a),e(),r(l)},o=l=>{this.off("error",n),this.off("end",h),this.off(E,a),this.pause(),s({value:l,done:!!this[G]})},h=()=>{this.off("error",n),this.off("data",o),this.off(E,a),e(),s({done:!0,value:void 0})},a=()=>n(new Error("stream destroyed"));return new Promise((l,p)=>{r=p,s=l,this.once(E,a),this.once("error",n),this.once("end",h),this.once("data",o)})},throw:e,return:e,[Symbol.asyncIterator](){return this}}}[Symbol.iterator](){this[P]=!1;let t=!1,e=()=>(this.pause(),this.off(te,e),this.off(E,e),this.off("end",e),t=!0,{done:!0,value:void 0}),i=()=>{if(t)return e();let s=this.read();return s===null?e():{done:!1,value:s}};return this.once("end",e),this.once(te,e),this.once(E,e),{next:i,throw:e,return:e,[Symbol.iterator](){return this}}}destroy(t){if(this[E])return t?this.emit("error",t):this.emit(E),this;this[E]=!0,this[P]=!0,this[k].length=0,this[C]=0;let e=this;return typeof e.close=="function"&&!this[Ft]&&e.close(),t?this.emit("error",t):this.emit(E),this}static get isStream(){return cr}},vr=sr.native,yt={lstatSync:Qs,readdir:tr,readdirSync:er,readlinkSync:ir,realpathSync:vr,promises:{lstat:nr,readdir:or,readlink:hr,realpath:ar}},di=t=>!t||t===yt||t===rr?yt:{...yt,...t,promises:{...yt.promises,...t.promises||{}}},gi=/^\\\\\?\\([a-z]:)\\?$/i,Sr=t=>t.replace(/\//g,"\\").replace(gi,"$1\\"),xr=/[\\\/]/,W=0,mi=1,wi=2,U=4,yi=6,bi=8,tt=10,vi=12,L=15,gt=~L,re=16,_e=32,bt=64,B=128,Dt=256,Lt=512,Be=bt|B|Lt,Er=1023,ne=t=>t.isFile()?bi:t.isDirectory()?U:t.isSymbolicLink()?tt:t.isCharacterDevice()?wi:t.isBlockDevice()?yi:t.isSocket()?vi:t.isFIFO()?mi:W,Ie=new Bt({max:2**12}),vt=t=>{let e=Ie.get(t);if(e)return e;let i=t.normalize("NFKD");return Ie.set(t,i),i},Ue=new Bt({max:2**12}),$t=t=>{let e=Ue.get(t);if(e)return e;let i=vt(t.toLowerCase());return Ue.set(t,i),i},Ge=class extends Bt{constructor(){super({max:256})}},Ar=class extends Bt{constructor(t=16*1024){super({maxSize:t,sizeCalculation:e=>e.length+1})}},Si=Symbol("PathScurry setAsCwd"),j=class{name;root;roots;parent;nocase;isCWD=!1;#t;#i;get dev(){return this.#i}#n;get mode(){return this.#n}#r;get nlink(){return this.#r}#o;get uid(){return this.#o}#v;get gid(){return this.#v}#w;get rdev(){return this.#w}#c;get blksize(){return this.#c}#h;get ino(){return this.#h}#u;get size(){return this.#u}#p;get blocks(){return this.#p}#a;get atimeMs(){return this.#a}#s;get mtimeMs(){return this.#s}#f;get ctimeMs(){return this.#f}#S;get birthtimeMs(){return this.#S}#b;get atime(){return this.#b}#d;get mtime(){return this.#d}#T;get ctime(){return this.#T}#g;get birthtime(){return this.#g}#A;#k;#m;#y;#x;#C;#e;#$;#P;#O;get parentPath(){return(this.parent||this).fullpath()}get path(){return this.parentPath}constructor(t,e=W,i,s,r,n,o){this.name=t,this.#A=r?$t(t):vt(t),this.#e=e&Er,this.nocase=r,this.roots=s,this.root=i||this,this.#$=n,this.#m=o.fullpath,this.#x=o.relative,this.#C=o.relativePosix,this.parent=o.parent,this.parent?this.#t=this.parent.#t:this.#t=di(o.fs)}depth(){return this.#k!==void 0?this.#k:this.parent?this.#k=this.parent.depth()+1:this.#k=0}childrenCache(){return this.#$}resolve(t){if(!t)return this;let e=this.getRootString(t),i=t.substring(e.length).split(this.splitSep);return e?this.getRoot(e).#D(i):this.#D(i)}#D(t){let e=this;for(let i of t)e=e.child(i);return e}children(){let t=this.#$.get(this);if(t)return t;let e=Object.assign([],{provisional:0});return this.#$.set(this,e),this.#e&=~re,e}child(t,e){if(t===""||t===".")return this;if(t==="..")return this.parent||this;let i=this.children(),s=this.nocase?$t(t):vt(t);for(let h of i)if(h.#A===s)return h;let r=this.parent?this.sep:"",n=this.#m?this.#m+r+t:void 0,o=this.newChild(t,W,{...e,parent:this,fullpath:n});return this.canReaddir()||(o.#e|=B),i.push(o),o}relative(){if(this.isCWD)return"";if(this.#x!==void 0)return this.#x;let t=this.name,e=this.parent;if(!e)return this.#x=this.name;let i=e.relative();return i+(!i||!e.parent?"":this.sep)+t}relativePosix(){if(this.sep==="/")return this.relative();if(this.isCWD)return"";if(this.#C!==void 0)return this.#C;let t=this.name,e=this.parent;if(!e)return this.#C=this.fullpathPosix();let i=e.relativePosix();return i+(!i||!e.parent?"":"/")+t}fullpath(){if(this.#m!==void 0)return this.#m;let t=this.name,e=this.parent;if(!e)return this.#m=this.name;let i=e.fullpath()+(e.parent?this.sep:"")+t;return this.#m=i}fullpathPosix(){if(this.#y!==void 0)return this.#y;if(this.sep==="/")return this.#y=this.fullpath();if(!this.parent){let s=this.fullpath().replace(/\\/g,"/");return/^[a-z]:\//i.test(s)?this.#y=`//?/${s}`:this.#y=s}let t=this.parent,e=t.fullpathPosix(),i=e+(!e||!t.parent?"":"/")+this.name;return this.#y=i}isUnknown(){return(this.#e&L)===W}isType(t){return this[`is${t}`]()}getType(){return this.isUnknown()?"Unknown":this.isDirectory()?"Directory":this.isFile()?"File":this.isSymbolicLink()?"SymbolicLink":this.isFIFO()?"FIFO":this.isCharacterDevice()?"CharacterDevice":this.isBlockDevice()?"BlockDevice":this.isSocket()?"Socket":"Unknown"}isFile(){return(this.#e&L)===bi}isDirectory(){return(this.#e&L)===U}isCharacterDevice(){return(this.#e&L)===wi}isBlockDevice(){return(this.#e&L)===yi}isFIFO(){return(this.#e&L)===mi}isSocket(){return(this.#e&L)===vi}isSymbolicLink(){return(this.#e&tt)===tt}lstatCached(){return this.#e&_e?this:void 0}readlinkCached(){return this.#P}realpathCached(){return this.#O}readdirCached(){let t=this.children();return t.slice(0,t.provisional)}canReadlink(){if(this.#P)return!0;if(!this.parent)return!1;let t=this.#e&L;return!(t!==W&&t!==tt||this.#e&Dt||this.#e&B)}calledReaddir(){return!!(this.#e&re)}isENOENT(){return!!(this.#e&B)}isNamed(t){return this.nocase?this.#A===$t(t):this.#A===vt(t)}async readlink(){let t=this.#P;if(t)return t;if(this.canReadlink()&&this.parent)try{let e=await this.#t.promises.readlink(this.fullpath()),i=(await this.parent.realpath())?.resolve(e);if(i)return this.#P=i}catch(e){this.#j(e.code);return}}readlinkSync(){let t=this.#P;if(t)return t;if(this.canReadlink()&&this.parent)try{let e=this.#t.readlinkSync(this.fullpath()),i=this.parent.realpathSync()?.resolve(e);if(i)return this.#P=i}catch(e){this.#j(e.code);return}}#N(t){this.#e|=re;for(let e=t.provisional;e<t.length;e++){let i=t[e];i&&i.#E()}}#E(){this.#e&B||(this.#e=(this.#e|B)&gt,this.#G())}#G(){let t=this.children();t.provisional=0;for(let e of t)e.#E()}#W(){this.#e|=Lt,this.#M()}#M(){if(this.#e&bt)return;let t=this.#e;(t&L)===U&&(t&=gt),this.#e=t|bt,this.#G()}#z(t=""){t==="ENOTDIR"||t==="EPERM"?this.#M():t==="ENOENT"?this.#E():this.children().provisional=0}#R(t=""){t==="ENOTDIR"?this.parent.#M():t==="ENOENT"&&this.#E()}#j(t=""){let e=this.#e;e|=Dt,t==="ENOENT"&&(e|=B),(t==="EINVAL"||t==="UNKNOWN")&&(e&=gt),this.#e=e,t==="ENOTDIR"&&this.parent&&this.parent.#M()}#_(t,e){return this.#I(t,e)||this.#B(t,e)}#B(t,e){let i=ne(t),s=this.newChild(t.name,i,{parent:this}),r=s.#e&L;return r!==U&&r!==tt&&r!==W&&(s.#e|=bt),e.unshift(s),e.provisional++,s}#I(t,e){for(let i=e.provisional;i<e.length;i++){let s=e[i];if((this.nocase?$t(t.name):vt(t.name))===s.#A)return this.#l(t,s,i,e)}}#l(t,e,i,s){let r=e.name;return e.#e=e.#e&gt|ne(t),r!==t.name&&(e.name=t.name),i!==s.provisional&&(i===s.length-1?s.pop():s.splice(i,1),s.unshift(e)),s.provisional++,e}async lstat(){if((this.#e&B)===0)try{return this.#U(await this.#t.promises.lstat(this.fullpath())),this}catch(t){this.#R(t.code)}}lstatSync(){if((this.#e&B)===0)try{return this.#U(this.#t.lstatSync(this.fullpath())),this}catch(t){this.#R(t.code)}}#U(t){let{atime:e,atimeMs:i,birthtime:s,birthtimeMs:r,blksize:n,blocks:o,ctime:h,ctimeMs:a,dev:l,gid:p,ino:c,mode:f,mtime:u,mtimeMs:d,nlink:g,rdev:w,size:m,uid:y}=t;this.#b=e,this.#a=i,this.#g=s,this.#S=r,this.#c=n,this.#p=o,this.#T=h,this.#f=a,this.#i=l,this.#v=p,this.#h=c,this.#n=f,this.#d=u,this.#s=d,this.#r=g,this.#w=w,this.#u=m,this.#o=y;let b=ne(t);this.#e=this.#e&gt|b|_e,b!==W&&b!==U&&b!==tt&&(this.#e|=bt)}#L=[];#F=!1;#H(t){this.#F=!1;let e=this.#L.slice();this.#L.length=0,e.forEach(i=>i(null,t))}readdirCB(t,e=!1){if(!this.canReaddir()){e?t(null,[]):queueMicrotask(()=>t(null,[]));return}let i=this.children();if(this.calledReaddir()){let r=i.slice(0,i.provisional);e?t(null,r):queueMicrotask(()=>t(null,r));return}if(this.#L.push(t),this.#F)return;this.#F=!0;let s=this.fullpath();this.#t.readdir(s,{withFileTypes:!0},(r,n)=>{if(r)this.#z(r.code),i.provisional=0;else{for(let o of n)this.#_(o,i);this.#N(i)}this.#H(i.slice(0,i.provisional))})}#V;async readdir(){if(!this.canReaddir())return[];let t=this.children();if(this.calledReaddir())return t.slice(0,t.provisional);let e=this.fullpath();if(this.#V)await this.#V;else{let i=()=>{};this.#V=new Promise(s=>i=s);try{for(let s of await this.#t.promises.readdir(e,{withFileTypes:!0}))this.#_(s,t);this.#N(t)}catch(s){this.#z(s.code),t.provisional=0}this.#V=void 0,i()}return t.slice(0,t.provisional)}readdirSync(){if(!this.canReaddir())return[];let t=this.children();if(this.calledReaddir())return t.slice(0,t.provisional);let e=this.fullpath();try{for(let i of this.#t.readdirSync(e,{withFileTypes:!0}))this.#_(i,t);this.#N(t)}catch(i){this.#z(i.code),t.provisional=0}return t.slice(0,t.provisional)}canReaddir(){if(this.#e&Be)return!1;let t=L&this.#e;return t===W||t===U||t===tt}shouldWalk(t,e){return(this.#e&U)===U&&!(this.#e&Be)&&!t.has(this)&&(!e||e(this))}async realpath(){if(this.#O)return this.#O;if(!((Lt|Dt|B)&this.#e))try{let t=await this.#t.promises.realpath(this.fullpath());return this.#O=this.resolve(t)}catch{this.#W()}}realpathSync(){if(this.#O)return this.#O;if(!((Lt|Dt|B)&this.#e))try{let t=this.#t.realpathSync(this.fullpath());return this.#O=this.resolve(t)}catch{this.#W()}}[Si](t){if(t===this)return;t.isCWD=!1,this.isCWD=!0;let e=new Set([]),i=[],s=this;for(;s&&s.parent;)e.add(s),s.#x=i.join(this.sep),s.#C=i.join("/"),s=s.parent,i.push("..");for(s=t;s&&s.parent&&!e.has(s);)s.#x=void 0,s.#C=void 0,s=s.parent}},xi=class Ei extends j{sep="\\";splitSep=xr;constructor(e,i=W,s,r,n,o,h){super(e,i,s,r,n,o,h)}newChild(e,i=W,s={}){return new Ei(e,i,this.root,this.roots,this.nocase,this.childrenCache(),s)}getRootString(e){return he.parse(e).root}getRoot(e){if(e=Sr(e.toUpperCase()),e===this.root.name)return this.root;for(let[i,s]of Object.entries(this.roots))if(this.sameRoot(e,i))return this.roots[e]=s;return this.roots[e]=new pe(e,this).root}sameRoot(e,i=this.root.name){return e=e.toUpperCase().replace(/\//g,"\\").replace(gi,"$1\\"),e===i}},Ai=class ki extends j{splitSep="/";sep="/";constructor(e,i=W,s,r,n,o,h){super(e,i,s,r,n,o,h)}getRootString(e){return e.startsWith("/")?"/":""}getRoot(e){return this.root}newChild(e,i=W,s={}){return new ki(e,i,this.root,this.roots,this.nocase,this.childrenCache(),s)}},Ci=class{root;rootPath;roots;cwd;#t;#i;#n;nocase;#r;constructor(t=process.cwd(),e,i,{nocase:s,childrenCacheSize:r=16*1024,fs:n=yt}={}){this.#r=di(n),(t instanceof URL||t.startsWith("file://"))&&(t=Xs(t));let o=e.resolve(t);this.roots=Object.create(null),this.rootPath=this.parseRootPath(o),this.#t=new Ge,this.#i=new Ge,this.#n=new Ar(r);let h=o.substring(this.rootPath.length).split(i);if(h.length===1&&!h[0]&&h.pop(),s===void 0)throw new TypeError("must provide nocase setting to PathScurryBase ctor");this.nocase=s,this.root=this.newRoot(this.#r),this.roots[this.rootPath]=this.root;let a=this.root,l=h.length-1,p=e.sep,c=this.rootPath,f=!1;for(let u of h){let d=l--;a=a.child(u,{relative:new Array(d).fill("..").join(p),relativePosix:new Array(d).fill("..").join("/"),fullpath:c+=(f?"":p)+u}),f=!0}this.cwd=a}depth(t=this.cwd){return typeof t=="string"&&(t=this.cwd.resolve(t)),t.depth()}childrenCache(){return this.#n}resolve(...t){let e="";for(let r=t.length-1;r>=0;r--){let n=t[r];if(!(!n||n===".")&&(e=e?`${n}/${e}`:n,this.isAbsolute(n)))break}let i=this.#t.get(e);if(i!==void 0)return i;let s=this.cwd.resolve(e).fullpath();return this.#t.set(e,s),s}resolvePosix(...t){let e="";for(let r=t.length-1;r>=0;r--){let n=t[r];if(!(!n||n===".")&&(e=e?`${n}/${e}`:n,this.isAbsolute(n)))break}let i=this.#i.get(e);if(i!==void 0)return i;let s=this.cwd.resolve(e).fullpathPosix();return this.#i.set(e,s),s}relative(t=this.cwd){return typeof t=="string"&&(t=this.cwd.resolve(t)),t.relative()}relativePosix(t=this.cwd){return typeof t=="string"&&(t=this.cwd.resolve(t)),t.relativePosix()}basename(t=this.cwd){return typeof t=="string"&&(t=this.cwd.resolve(t)),t.name}dirname(t=this.cwd){return typeof t=="string"&&(t=this.cwd.resolve(t)),(t.parent||t).fullpath()}async readdir(t=this.cwd,e={withFileTypes:!0}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof j||(e=t,t=this.cwd);let{withFileTypes:i}=e;if(t.canReaddir()){let s=await t.readdir();return i?s:s.map(r=>r.name)}else return[]}readdirSync(t=this.cwd,e={withFileTypes:!0}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof j||(e=t,t=this.cwd);let{withFileTypes:i=!0}=e;return t.canReaddir()?i?t.readdirSync():t.readdirSync().map(s=>s.name):[]}async lstat(t=this.cwd){return typeof t=="string"&&(t=this.cwd.resolve(t)),t.lstat()}lstatSync(t=this.cwd){return typeof t=="string"&&(t=this.cwd.resolve(t)),t.lstatSync()}async readlink(t=this.cwd,{withFileTypes:e}={withFileTypes:!1}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof j||(e=t.withFileTypes,t=this.cwd);let i=await t.readlink();return e?i:i?.fullpath()}readlinkSync(t=this.cwd,{withFileTypes:e}={withFileTypes:!1}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof j||(e=t.withFileTypes,t=this.cwd);let i=t.readlinkSync();return e?i:i?.fullpath()}async realpath(t=this.cwd,{withFileTypes:e}={withFileTypes:!1}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof j||(e=t.withFileTypes,t=this.cwd);let i=await t.realpath();return e?i:i?.fullpath()}realpathSync(t=this.cwd,{withFileTypes:e}={withFileTypes:!1}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof j||(e=t.withFileTypes,t=this.cwd);let i=t.realpathSync();return e?i:i?.fullpath()}async walk(t=this.cwd,e={}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof j||(e=t,t=this.cwd);let{withFileTypes:i=!0,follow:s=!1,filter:r,walkFilter:n}=e,o=[];(!r||r(t))&&o.push(i?t:t.fullpath());let h=new Set,a=(p,c)=>{h.add(p),p.readdirCB((f,u)=>{if(f)return c(f);let d=u.length;if(!d)return c();let g=()=>{--d===0&&c()};for(let w of u)(!r||r(w))&&o.push(i?w:w.fullpath()),s&&w.isSymbolicLink()?w.realpath().then(m=>m?.isUnknown()?m.lstat():m).then(m=>m?.shouldWalk(h,n)?a(m,g):g()):w.shouldWalk(h,n)?a(w,g):g()},!0)},l=t;return new Promise((p,c)=>{a(l,f=>{if(f)return c(f);p(o)})})}walkSync(t=this.cwd,e={}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof j||(e=t,t=this.cwd);let{withFileTypes:i=!0,follow:s=!1,filter:r,walkFilter:n}=e,o=[];(!r||r(t))&&o.push(i?t:t.fullpath());let h=new Set([t]);for(let a of h){let l=a.readdirSync();for(let p of l){(!r||r(p))&&o.push(i?p:p.fullpath());let c=p;if(p.isSymbolicLink()){if(!(s&&(c=p.realpathSync())))continue;c.isUnknown()&&c.lstatSync()}c.shouldWalk(h,n)&&h.add(c)}}return o}[Symbol.asyncIterator](){return this.iterate()}iterate(t=this.cwd,e={}){return typeof t=="string"?t=this.cwd.resolve(t):t instanceof j||(e=t,t=this.cwd),this.stream(t,e)[Symbol.asyncIterator]()}[Symbol.iterator](){return this.iterateSync()}*iterateSync(t=this.cwd,e={}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof j||(e=t,t=this.cwd);let{withFileTypes:i=!0,follow:s=!1,filter:r,walkFilter:n}=e;(!r||r(t))&&(yield i?t:t.fullpath());let o=new Set([t]);for(let h of o){let a=h.readdirSync();for(let l of a){(!r||r(l))&&(yield i?l:l.fullpath());let p=l;if(l.isSymbolicLink()){if(!(s&&(p=l.realpathSync())))continue;p.isUnknown()&&p.lstatSync()}p.shouldWalk(o,n)&&o.add(p)}}}stream(t=this.cwd,e={}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof j||(e=t,t=this.cwd);let{withFileTypes:i=!0,follow:s=!1,filter:r,walkFilter:n}=e,o=new zt({objectMode:!0});(!r||r(t))&&o.write(i?t:t.fullpath());let h=new Set,a=[t],l=0,p=()=>{let c=!1;for(;!c;){let f=a.shift();if(!f){l===0&&o.end();return}l++,h.add(f);let u=(g,w,m=!1)=>{if(g)return o.emit("error",g);if(s&&!m){let y=[];for(let b of w)b.isSymbolicLink()&&y.push(b.realpath().then(v=>v?.isUnknown()?v.lstat():v));if(y.length){Promise.all(y).then(()=>u(null,w,!0));return}}for(let y of w)y&&(!r||r(y))&&(o.write(i?y:y.fullpath())||(c=!0));l--;for(let y of w){let b=y.realpathCached()||y;b.shouldWalk(h,n)&&a.push(b)}c&&!o.flowing?o.once("drain",p):d||p()},d=!0;f.readdirCB(u,!0),d=!1}};return p(),o}streamSync(t=this.cwd,e={}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof j||(e=t,t=this.cwd);let{withFileTypes:i=!0,follow:s=!1,filter:r,walkFilter:n}=e,o=new zt({objectMode:!0}),h=new Set;(!r||r(t))&&o.write(i?t:t.fullpath());let a=[t],l=0,p=()=>{let c=!1;for(;!c;){let f=a.shift();if(!f){l===0&&o.end();return}l++,h.add(f);let u=f.readdirSync();for(let d of u)(!r||r(d))&&(o.write(i?d:d.fullpath())||(c=!0));l--;for(let d of u){let g=d;if(d.isSymbolicLink()){if(!(s&&(g=d.realpathSync())))continue;g.isUnknown()&&g.lstatSync()}g.shouldWalk(h,n)&&a.push(g)}}c&&!o.flowing&&o.once("drain",p)};return p(),o}chdir(t=this.cwd){let e=this.cwd;this.cwd=typeof t=="string"?this.cwd.resolve(t):t,this.cwd[Si](e)}},pe=class extends Ci{sep="\\";constructor(t=process.cwd(),e={}){let{nocase:i=!0}=e;super(t,he,"\\",{...e,nocase:i}),this.nocase=i;for(let s=this.cwd;s;s=s.parent)s.nocase=this.nocase}parseRootPath(t){return he.parse(t).root.toUpperCase()}newRoot(t){return new xi(this.rootPath,U,void 0,this.roots,this.nocase,this.childrenCache(),{fs:t})}isAbsolute(t){return t.startsWith("/")||t.startsWith("\\")||/^[a-z]:(\/|\\)/i.test(t)}},ue=class extends Ci{sep="/";constructor(t=process.cwd(),e={}){let{nocase:i=!1}=e;super(t,Zs,"/",{...e,nocase:i}),this.nocase=i}parseRootPath(t){return"/"}newRoot(t){return new Ai(this.rootPath,U,void 0,this.roots,this.nocase,this.childrenCache(),{fs:t})}isAbsolute(t){return t.startsWith("/")}},Oi=class extends ue{constructor(t=process.cwd(),e={}){let{nocase:i=!0}=e;super(t,{...e,nocase:i})}},cn=process.platform==="win32"?xi:Ai,kr=process.platform==="win32"?pe:process.platform==="darwin"?Oi:ue,Cr=t=>t.length>=1,Or=t=>t.length>=1,Tr=Symbol.for("nodejs.util.inspect.custom"),Ti=class Fi{#t;#i;#n;length;#r;#o;#v;#w;#c;#h;#u=!0;constructor(e,i,s,r){if(!Cr(e))throw new TypeError("empty pattern list");if(!Or(i))throw new TypeError("empty glob list");if(i.length!==e.length)throw new TypeError("mismatched pattern list and glob list lengths");if(this.length=e.length,s<0||s>=this.length)throw new TypeError("index out of range");if(this.#t=e,this.#i=i,this.#n=s,this.#r=r,this.#n===0){if(this.isUNC()){let[n,o,h,a,...l]=this.#t,[p,c,f,u,...d]=this.#i;l[0]===""&&(l.shift(),d.shift());let g=[n,o,h,a,""].join("/"),w=[p,c,f,u,""].join("/");this.#t=[g,...l],this.#i=[w,...d],this.length=this.#t.length}else if(this.isDrive()||this.isAbsolute()){let[n,...o]=this.#t,[h,...a]=this.#i;o[0]===""&&(o.shift(),a.shift());let l=n+"/",p=h+"/";this.#t=[l,...o],this.#i=[p,...a],this.length=this.#t.length}}}[Tr](){return"Pattern <"+this.#i.slice(this.#n).join("/")+">"}pattern(){return this.#t[this.#n]}isString(){return typeof this.#t[this.#n]=="string"}isGlobstar(){return this.#t[this.#n]===F}isRegExp(){return this.#t[this.#n]instanceof RegExp}globString(){return this.#v=this.#v||(this.#n===0?this.isAbsolute()?this.#i[0]+this.#i.slice(1).join("/"):this.#i.join("/"):this.#i.slice(this.#n).join("/"))}hasMore(){return this.length>this.#n+1}rest(){return this.#o!==void 0?this.#o:this.hasMore()?(this.#o=new Fi(this.#t,this.#i,this.#n+1,this.#r),this.#o.#h=this.#h,this.#o.#c=this.#c,this.#o.#w=this.#w,this.#o):this.#o=null}isUNC(){let e=this.#t;return this.#c!==void 0?this.#c:this.#c=this.#r==="win32"&&this.#n===0&&e[0]===""&&e[1]===""&&typeof e[2]=="string"&&!!e[2]&&typeof e[3]=="string"&&!!e[3]}isDrive(){let e=this.#t;return this.#w!==void 0?this.#w:this.#w=this.#r==="win32"&&this.#n===0&&this.length>1&&typeof e[0]=="string"&&/^[a-z]:$/i.test(e[0])}isAbsolute(){let e=this.#t;return this.#h!==void 0?this.#h:this.#h=e[0]===""&&e.length>1||this.isDrive()||this.isUNC()}root(){let e=this.#t[0];return typeof e=="string"&&this.isAbsolute()&&this.#n===0?e:""}checkFollowGlobstar(){return!(this.#n===0||!this.isGlobstar()||!this.#u)}markFollowGlobstar(){return this.#n===0||!this.isGlobstar()||!this.#u?!1:(this.#u=!1,!0)}},Fr=typeof process=="object"&&process&&typeof process.platform=="string"?process.platform:"linux",He=class{relative;relativeChildren;absolute;absoluteChildren;platform;mmopts;constructor(t,{nobrace:e,nocase:i,noext:s,noglobstar:r,platform:n=Fr}){this.relative=[],this.absolute=[],this.relativeChildren=[],this.absoluteChildren=[],this.platform=n,this.mmopts={dot:!0,nobrace:e,nocase:i,noext:s,noglobstar:r,optimizationLevel:2,platform:n,nocomment:!0,nonegate:!0};for(let o of t)this.add(o)}add(t){let e=new Z(t,this.mmopts);for(let i=0;i<e.set.length;i++){let s=e.set[i],r=e.globParts[i];if(!s||!r)throw new Error("invalid pattern object");for(;s[0]==="."&&r[0]===".";)s.shift(),r.shift();let n=new Ti(s,r,0,this.platform),o=new Z(n.globString(),this.mmopts),h=r[r.length-1]==="**",a=n.isAbsolute();a?this.absolute.push(o):this.relative.push(o),h&&(a?this.absoluteChildren.push(o):this.relativeChildren.push(o))}}ignored(t){let e=t.fullpath(),i=`${e}/`,s=t.relative()||".",r=`${s}/`;for(let n of this.relative)if(n.match(s)||n.match(r))return!0;for(let n of this.absolute)if(n.match(e)||n.match(i))return!0;return!1}childrenIgnored(t){let e=t.fullpath()+"/",i=(t.relative()||".")+"/";for(let s of this.relativeChildren)if(s.match(i))return!0;for(let s of this.absoluteChildren)if(s.match(e))return!0;return!1}},Rr=class Ri{store;constructor(e=new Map){this.store=e}copy(){return new Ri(new Map(this.store))}hasWalked(e,i){return this.store.get(e.fullpath())?.has(i.globString())}storeWalked(e,i){let s=e.fullpath(),r=this.store.get(s);r?r.add(i.globString()):this.store.set(s,new Set([i.globString()]))}},jr=class{store=new Map;add(t,e,i){let s=(e?2:0)|(i?1:0),r=this.store.get(t);this.store.set(t,r===void 0?s:s&r)}entries(){return[...this.store.entries()].map(([t,e])=>[t,!!(e&2),!!(e&1)])}},Pr=class{store=new Map;add(t,e){if(!t.canReaddir())return;let i=this.store.get(t);i?i.find(s=>s.globString()===e.globString())||i.push(e):this.store.set(t,[e])}get(t){let e=this.store.get(t);if(!e)throw new Error("attempting to walk unknown path");return e}entries(){return this.keys().map(t=>[t,this.store.get(t)])}keys(){return[...this.store.keys()].filter(t=>t.canReaddir())}},Ve=class ji{hasWalkedCache;matches=new jr;subwalks=new Pr;patterns;follow;dot;opts;constructor(e,i){this.opts=e,this.follow=!!e.follow,this.dot=!!e.dot,this.hasWalkedCache=i?i.copy():new Rr}processPatterns(e,i){this.patterns=i;let s=i.map(r=>[e,r]);for(let[r,n]of s){this.hasWalkedCache.storeWalked(r,n);let o=n.root(),h=n.isAbsolute()&&this.opts.absolute!==!1;if(o){r=r.resolve(o==="/"&&this.opts.root!==void 0?this.opts.root:o);let c=n.rest();if(c)n=c;else{this.matches.add(r,!0,!1);continue}}if(r.isENOENT())continue;let a,l,p=!1;for(;typeof(a=n.pattern())=="string"&&(l=n.rest());)r=r.resolve(a),n=l,p=!0;if(a=n.pattern(),l=n.rest(),p){if(this.hasWalkedCache.hasWalked(r,n))continue;this.hasWalkedCache.storeWalked(r,n)}if(typeof a=="string"){let c=a===".."||a===""||a===".";this.matches.add(r.resolve(a),h,c);continue}else if(a===F){(!r.isSymbolicLink()||this.follow||n.checkFollowGlobstar())&&this.subwalks.add(r,n);let c=l?.pattern(),f=l?.rest();if(!l||(c===""||c===".")&&!f)this.matches.add(r,h,c===""||c===".");else if(c===".."){let u=r.parent||r;f?this.hasWalkedCache.hasWalked(u,f)||this.subwalks.add(u,f):this.matches.add(u,h,!0)}}else a instanceof RegExp&&this.subwalks.add(r,n)}return this}subwalkTargets(){return this.subwalks.keys()}child(){return new ji(this.opts,this.hasWalkedCache)}filterEntries(e,i){let s=this.subwalks.get(e),r=this.child();for(let n of i)for(let o of s){let h=o.isAbsolute(),a=o.pattern(),l=o.rest();a===F?r.testGlobstar(n,o,l,h):a instanceof RegExp?r.testRegExp(n,a,l,h):r.testString(n,a,l,h)}return r}testGlobstar(e,i,s,r){if((this.dot||!e.name.startsWith("."))&&(i.hasMore()||this.matches.add(e,r,!1),e.canReaddir()&&(this.follow||!e.isSymbolicLink()?this.subwalks.add(e,i):e.isSymbolicLink()&&(s&&i.checkFollowGlobstar()?this.subwalks.add(e,s):i.markFollowGlobstar()&&this.subwalks.add(e,i)))),s){let n=s.pattern();if(typeof n=="string"&&n!==".."&&n!==""&&n!==".")this.testString(e,n,s.rest(),r);else if(n===".."){let o=e.parent||e;this.subwalks.add(o,s)}else n instanceof RegExp&&this.testRegExp(e,n,s.rest(),r)}}testRegExp(e,i,s,r){i.test(e.name)&&(s?this.subwalks.add(e,s):this.matches.add(e,r,!1))}testString(e,i,s,r){e.isNamed(i)&&(s?this.subwalks.add(e,s):this.matches.add(e,r,!1))}},Dr=(t,e)=>typeof t=="string"?new He([t],e):Array.isArray(t)?new He(t,e):t,Pi=class{path;patterns;opts;seen=new Set;paused=!1;aborted=!1;#t=[];#i;#n;signal;maxDepth;includeChildMatches;constructor(t,e,i){if(this.patterns=t,this.path=e,this.opts=i,this.#n=!i.posix&&i.platform==="win32"?"\\":"/",this.includeChildMatches=i.includeChildMatches!==!1,(i.ignore||!this.includeChildMatches)&&(this.#i=Dr(i.ignore??[],i),!this.includeChildMatches&&typeof this.#i.add!="function")){let s="cannot ignore child matches, ignore lacks add() method.";throw new Error(s)}this.maxDepth=i.maxDepth||1/0,i.signal&&(this.signal=i.signal,this.signal.addEventListener("abort",()=>{this.#t.length=0}))}#r(t){return this.seen.has(t)||!!this.#i?.ignored?.(t)}#o(t){return!!this.#i?.childrenIgnored?.(t)}pause(){this.paused=!0}resume(){if(this.signal?.aborted)return;this.paused=!1;let t;for(;!this.paused&&(t=this.#t.shift());)t()}onResume(t){this.signal?.aborted||(this.paused?this.#t.push(t):t())}async matchCheck(t,e){if(e&&this.opts.nodir)return;let i;if(this.opts.realpath){if(i=t.realpathCached()||await t.realpath(),!i)return;t=i}let s=t.isUnknown()||this.opts.stat?await t.lstat():t;if(this.opts.follow&&this.opts.nodir&&s?.isSymbolicLink()){let r=await s.realpath();r&&(r.isUnknown()||this.opts.stat)&&await r.lstat()}return this.matchCheckTest(s,e)}matchCheckTest(t,e){return t&&(this.maxDepth===1/0||t.depth()<=this.maxDepth)&&(!e||t.canReaddir())&&(!this.opts.nodir||!t.isDirectory())&&(!this.opts.nodir||!this.opts.follow||!t.isSymbolicLink()||!t.realpathCached()?.isDirectory())&&!this.#r(t)?t:void 0}matchCheckSync(t,e){if(e&&this.opts.nodir)return;let i;if(this.opts.realpath){if(i=t.realpathCached()||t.realpathSync(),!i)return;t=i}let s=t.isUnknown()||this.opts.stat?t.lstatSync():t;if(this.opts.follow&&this.opts.nodir&&s?.isSymbolicLink()){let r=s.realpathSync();r&&(r?.isUnknown()||this.opts.stat)&&r.lstatSync()}return this.matchCheckTest(s,e)}matchFinish(t,e){if(this.#r(t))return;if(!this.includeChildMatches&&this.#i?.add){let r=`${t.relativePosix()}/**`;this.#i.add(r)}let i=this.opts.absolute===void 0?e:this.opts.absolute;this.seen.add(t);let s=this.opts.mark&&t.isDirectory()?this.#n:"";if(this.opts.withFileTypes)this.matchEmit(t);else if(i){let r=this.opts.posix?t.fullpathPosix():t.fullpath();this.matchEmit(r+s)}else{let r=this.opts.posix?t.relativePosix():t.relative(),n=this.opts.dotRelative&&!r.startsWith(".."+this.#n)?"."+this.#n:"";this.matchEmit(r?n+r+s:"."+s)}}async match(t,e,i){let s=await this.matchCheck(t,i);s&&this.matchFinish(s,e)}matchSync(t,e,i){let s=this.matchCheckSync(t,i);s&&this.matchFinish(s,e)}walkCB(t,e,i){this.signal?.aborted&&i(),this.walkCB2(t,e,new Ve(this.opts),i)}walkCB2(t,e,i,s){if(this.#o(t))return s();if(this.signal?.aborted&&s(),this.paused){this.onResume(()=>this.walkCB2(t,e,i,s));return}i.processPatterns(t,e);let r=1,n=()=>{--r===0&&s()};for(let[o,h,a]of i.matches.entries())this.#r(o)||(r++,this.match(o,h,a).then(()=>n()));for(let o of i.subwalkTargets()){if(this.maxDepth!==1/0&&o.depth()>=this.maxDepth)continue;r++;let h=o.readdirCached();o.calledReaddir()?this.walkCB3(o,h,i,n):o.readdirCB((a,l)=>this.walkCB3(o,l,i,n),!0)}n()}walkCB3(t,e,i,s){i=i.filterEntries(t,e);let r=1,n=()=>{--r===0&&s()};for(let[o,h,a]of i.matches.entries())this.#r(o)||(r++,this.match(o,h,a).then(()=>n()));for(let[o,h]of i.subwalks.entries())r++,this.walkCB2(o,h,i.child(),n);n()}walkCBSync(t,e,i){this.signal?.aborted&&i(),this.walkCB2Sync(t,e,new Ve(this.opts),i)}walkCB2Sync(t,e,i,s){if(this.#o(t))return s();if(this.signal?.aborted&&s(),this.paused){this.onResume(()=>this.walkCB2Sync(t,e,i,s));return}i.processPatterns(t,e);let r=1,n=()=>{--r===0&&s()};for(let[o,h,a]of i.matches.entries())this.#r(o)||this.matchSync(o,h,a);for(let o of i.subwalkTargets()){if(this.maxDepth!==1/0&&o.depth()>=this.maxDepth)continue;r++;let h=o.readdirSync();this.walkCB3Sync(o,h,i,n)}n()}walkCB3Sync(t,e,i,s){i=i.filterEntries(t,e);let r=1,n=()=>{--r===0&&s()};for(let[o,h,a]of i.matches.entries())this.#r(o)||this.matchSync(o,h,a);for(let[o,h]of i.subwalks.entries())r++,this.walkCB2Sync(o,h,i.child(),n);n()}},Ye=class extends Pi{matches=new Set;constructor(t,e,i){super(t,e,i)}matchEmit(t){this.matches.add(t)}async walk(){if(this.signal?.aborted)throw this.signal.reason;return this.path.isUnknown()&&await this.path.lstat(),await new Promise((t,e)=>{this.walkCB(this.path,this.patterns,()=>{this.signal?.aborted?e(this.signal.reason):t(this.matches)})}),this.matches}walkSync(){if(this.signal?.aborted)throw this.signal.reason;return this.path.isUnknown()&&this.path.lstatSync(),this.walkCBSync(this.path,this.patterns,()=>{if(this.signal?.aborted)throw this.signal.reason}),this.matches}},Je=class extends Pi{results;constructor(t,e,i){super(t,e,i),this.results=new zt({signal:this.signal,objectMode:!0}),this.results.on("drain",()=>this.resume()),this.results.on("resume",()=>this.resume())}matchEmit(t){this.results.write(t),this.results.flowing||this.pause()}stream(){let t=this.path;return t.isUnknown()?t.lstat().then(()=>{this.walkCB(t,this.patterns,()=>this.results.end())}):this.walkCB(t,this.patterns,()=>this.results.end()),this.results}streamSync(){return this.path.isUnknown()&&this.path.lstatSync(),this.walkCBSync(this.path,this.patterns,()=>this.results.end()),this.results}},$r=typeof process=="object"&&process&&typeof process.platform=="string"?process.platform:"linux",et=class{absolute;cwd;root;dot;dotRelative;follow;ignore;magicalBraces;mark;matchBase;maxDepth;nobrace;nocase;nodir;noext;noglobstar;pattern;platform;realpath;scurry;stat;signal;windowsPathsNoEscape;withFileTypes;includeChildMatches;opts;patterns;constructor(t,e){if(!e)throw new TypeError("glob options required");if(this.withFileTypes=!!e.withFileTypes,this.signal=e.signal,this.follow=!!e.follow,this.dot=!!e.dot,this.dotRelative=!!e.dotRelative,this.nodir=!!e.nodir,this.mark=!!e.mark,e.cwd?(e.cwd instanceof URL||e.cwd.startsWith("file://"))&&(e.cwd=Ys(e.cwd)):this.cwd="",this.cwd=e.cwd||"",this.root=e.root,this.magicalBraces=!!e.magicalBraces,this.nobrace=!!e.nobrace,this.noext=!!e.noext,this.realpath=!!e.realpath,this.absolute=e.absolute,this.includeChildMatches=e.includeChildMatches!==!1,this.noglobstar=!!e.noglobstar,this.matchBase=!!e.matchBase,this.maxDepth=typeof e.maxDepth=="number"?e.maxDepth:1/0,this.stat=!!e.stat,this.ignore=e.ignore,this.withFileTypes&&this.absolute!==void 0)throw new Error("cannot set absolute and withFileTypes:true");if(typeof t=="string"&&(t=[t]),this.windowsPathsNoEscape=!!e.windowsPathsNoEscape||e.allowWindowsEscape===!1,this.windowsPathsNoEscape&&(t=t.map(h=>h.replace(/\\/g,"/"))),this.matchBase){if(e.noglobstar)throw new TypeError("base matching requires globstar");t=t.map(h=>h.includes("/")?h:`./**/${h}`)}if(this.pattern=t,this.platform=e.platform||$r,this.opts={...e,platform:this.platform},e.scurry){if(this.scurry=e.scurry,e.nocase!==void 0&&e.nocase!==e.scurry.nocase)throw new Error("nocase option contradicts provided scurry option")}else{let h=e.platform==="win32"?pe:e.platform==="darwin"?Oi:e.platform?ue:kr;this.scurry=new h(this.cwd,{nocase:e.nocase,fs:e.fs})}this.nocase=this.scurry.nocase;let i=this.platform==="darwin"||this.platform==="win32",s={braceExpandMax:1e4,...e,dot:this.dot,matchBase:this.matchBase,nobrace:this.nobrace,nocase:this.nocase,nocaseMagicOnly:i,nocomment:!0,noext:this.noext,nonegate:!0,optimizationLevel:2,platform:this.platform,windowsPathsNoEscape:this.windowsPathsNoEscape,debug:!!this.opts.debug},r=this.pattern.map(h=>new Z(h,s)),[n,o]=r.reduce((h,a)=>(h[0].push(...a.set),h[1].push(...a.globParts),h),[[],[]]);this.patterns=n.map((h,a)=>{let l=o[a];if(!l)throw new Error("invalid pattern object");return new Ti(h,l,0,this.platform)})}async walk(){return[...await new Ye(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).walk()]}walkSync(){return[...new Ye(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).walkSync()]}stream(){return new Je(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).stream()}streamSync(){return new Je(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).streamSync()}iterateSync(){return this.streamSync()[Symbol.iterator]()}[Symbol.iterator](){return this.iterateSync()}iterate(){return this.stream()[Symbol.asyncIterator]()}[Symbol.asyncIterator](){return this.iterate()}},fe=(t,e={})=>{Array.isArray(t)||(t=[t]);for(let i of t)if(new Z(i,e).hasMagic())return!0;return!1};function It(t,e={}){return new et(t,e).streamSync()}function Di(t,e={}){return new et(t,e).stream()}function $i(t,e={}){return new et(t,e).walkSync()}async function qe(t,e={}){return new et(t,e).walk()}function Ut(t,e={}){return new et(t,e).iterateSync()}function Mi(t,e={}){return new et(t,e).iterate()}var Mr=It,Lr=Object.assign(Di,{sync:It}),Wr=Ut,Nr=Object.assign(Mi,{sync:Ut}),zr=Object.assign($i,{stream:It,iterate:Ut}),_t=Object.assign(qe,{glob:qe,globSync:$i,sync:zr,globStream:Di,stream:Lr,globStreamSync:It,streamSync:Mr,globIterate:Mi,iterate:Nr,globIterateSync:Ut,iterateSync:Wr,Glob:et,hasMagic:fe,escape:si,unescape:at});_t.glob=_t;import*as N from"node:fs";import{basename as Li,dirname as xt,extname as St,join as Wi,resolve as lt,relative as _r}from"node:path";import*as V from"node:process";import{performance as Br}from"perf_hooks";var Gt=["json","yaml","yml"];async function _i(t,e){let s=!qt(t)&&we(e.resolvedConfig.apis)?Ur(e):await Gr(t,e),r=s.filter(({path:n})=>!Ir(n));if(qt(r)){for(let{path:n}of r)x.warn(`
10
+ ${Et(n)} ${Se(`does not exist or is invalid.
11
+
12
+ `)}`);throw new $("Please provide a valid path.")}if(s.length===0)throw new $("No APIs were provided. Specify an API via the command argument or define one in your config.");return s}function Vt(t){return t.configPath?xt(t.configPath):V.cwd()}function Ir(t){if(!t.trim())throw new $("Path cannot be empty.");return N.existsSync(t)||nt(t)?t:void 0}function Ur(t){return Object.entries(t.resolvedConfig.apis||{}).map(([e,{root:i,output:s}])=>({path:nt(i)?i:lt(Vt(t),i),alias:e,output:s&&lt(Vt(t),s)}))}function Ni(t,e){let i=Vt(t),s=t.resolvedConfig.apis?.[e];return s?{path:nt(s.root)?s.root:lt(i,s.root),alias:e,output:s.output&&lt(i,s.output)}:{path:e,alias:Object.entries(t.resolvedConfig.apis||{}).find(([r,n])=>lt(i,n.root)===lt(e))?.[0]??void 0}}async function Gr(t,e){return(await Promise.all(t.map(async i=>fe(i)&&!nt(i)?(await _t(i,{cwd:Vt(e)})).map(n=>Ni(e,n)):Ni(e,i)))).flat()}function de(t){return V.env.NODE_ENV==="test"?"<test>ms":`${Math.ceil(Br.now()-t)}ms`}function Un(t,e,i){let s=de(e);x.info(X(`
13
+ ${i}: ${t} processed in ${s}
14
+
15
+ `))}function Gn(t,e){return t==="/"?e:t.replaceAll("~1","/").replaceAll("~0","~").replace(/^\//,"").replaceAll("/",e)}function Hn(t){return t.replace(/#/g,"_sharp").replace(/\//,"_").replace(/\s/g,"")}function Vn(t){return{php:".php","c#":".cs",shell:".sh",curl:".sh",bash:".sh",javascript:".js",js:".js",python:".py",c:".c","c++":".cpp",coffeescript:".litcoffee",dart:".dart",elixir:".ex",go:".go",groovy:".groovy",java:".java",kotlin:".kt","objective-c":".m",perl:".pl",powershell:".ps1",ruby:".rb",rust:".rs",scala:".sc",swift:".swift",typescript:".ts",tsx:".tsx","visual basic":".vb","c/al":".al"}[t.toLowerCase()]??""}var Yt=class t extends Error{constructor(i){super(i.message);this.originalError=i;Object.setPrototypeOf(this,t.prototype)}originalError};function Yn(t,e,i){if(e==="json")try{return JSON.stringify(t,null,2)}catch(s){throw s.message.indexOf("circular")>-1?new Yt(s):s}else return Kt(t,{noRefs:!i,lineWidth:-1})}function Jn(t,e){N.mkdirSync(xt(t),{recursive:!0}),N.writeFileSync(t,e)}function qn(t){return ye(N.readFileSync(t,"utf-8"),{filename:t})}function Kn(t,e,i){if(Yr(e)==="json"){Vr(t,e);return}Hr(t,e,i)}function Hr(t,e,i=!1){let s=Kt(t,{noRefs:i});if(V.env.NODE_ENV==="test"){x.info(s);return}N.mkdirSync(xt(e),{recursive:!0}),N.writeFileSync(e,s)}function Vr(t,e){let i=JSON.stringify(t,null,2);if(V.env.NODE_ENV==="test"){x.info(i);return}N.mkdirSync(xt(e),{recursive:!0}),N.writeFileSync(e,i)}function Yr(t){let e=t.split(".").pop();return Gt.includes(e)?e:(x.warn(`Unsupported file extension: ${e}. Using yaml.
16
+ `),"yaml")}function ge(t,e){switch(t.constructor){case $:throw t;case ve:throw new $(`Failed to resolve API description at ${e}:
17
+
18
+ - ${t.message}`);case be:throw new $(`Failed to parse API description at ${e}:
19
+
20
+ - ${t.message}`);case Yt:throw new $(`Detected circular reference which can't be converted to JSON.
21
+ Try to use ${J("yaml")} output or remove ${J("--dereferenced")}.`);case SyntaxError:throw new $(`Syntax error: ${t.message} ${t.stack?.split(`
22
+
23
+ `)?.[0]}`);case kt:throw new $(t.message);default:throw new $(`Something went wrong when processing ${e}:
24
+
25
+ - ${t.message}`)}}function Bi(t,e){let i=t.ignored?xe(`${t.ignored} ${z("problem is",t.ignored)} explicitly ignored.
26
+
27
+ `):"";t.errors>0?x.error(`\u274C Validation failed with ${t.errors} ${z("error",t.errors)}${t.warnings>0?` and ${t.warnings} ${z("warning",t.warnings)}`:""}.
28
+ ${i}`):t.warnings>0?(x.info(At(`Woohoo! Your API ${z("description is",e)} valid. \u{1F389}
29
+ `)),x.warn(`You have ${t.warnings} ${z("warning",t.warnings)}.
30
+ ${i}`)):x.info(At(`Woohoo! Your API ${z("description is",e)} valid. \u{1F389}
31
+ ${i}`)),t.errors>0&&x.info(X("run `redocly lint --generate-ignore-file` to add all problems to the ignore file.\n")),x.info(`
32
+ `)}function Ii(t,e){t.errors>0?x.error(`\u274C Your config has ${t.errors} ${z("error",t.errors)}.
33
+ `):t.warnings>0?x.warn(`\u26A0\uFE0F Your config has ${t.warnings} ${z("warning",t.warnings)}.
34
+ `):e==="check-config"&&x.info(At(`\u2705 Your config is valid.
35
+ `))}function Zn({entrypoint:t,output:e,argvOutput:i,ext:s,entries:r}){let n=e||i;if(!n)return{ext:s||"yaml"};if(r>1&&i){if(s=s||St(t).substring(1),!Gt.includes(s))throw new Error(`Invalid file extension: ${s}.`);n=Wi(i,Li(t,St(t)))+"."+s}else{if(s=s||St(n).substring(1)||St(t).substring(1),!Gt.includes(s))throw new Error(`Invalid file extension: ${s}.`);n=Wi(xt(n),Li(n,St(n)))+"."+s}return{outputFile:n,ext:s}}function Ui(t){let{preprocessors:e,rules:i,decorators:s}=t.getUnusedRules();i.length&&x.warn(`[WARNING] Unused rules found in ${J(t.configPath||"")}: ${i.join(", ")}.
36
+ `),e.length&&x.warn(`[WARNING] Unused preprocessors found in ${J(t.configPath||"")}: ${e.join(", ")}.
37
+ `),s.length&&x.warn(`[WARNING] Unused decorators found in ${J(t.configPath||"")}: ${s.join(", ")}.
38
+ `),(i.length||e.length)&&x.warn(`Check the spelling and verify the added plugin prefix.
39
+ `)}async function Xn(t,e){try{let i=await Ee({configPath:t.config,customExtends:t.extends});return await zi(t,e,i),i}catch(i){ge(i,"")}}function Jr(t){return t.asyncapi?.startsWith("2")}var qr=["swagger","info","host","basePath","schemes","consumes","produces","security","tags","externalDocs","paths","definitions","parameters","responses","securityDefinitions"],Kr=["openapi","info","jsonSchemaDialect","servers","security","tags","externalDocs","paths","webhooks","x-webhooks","components"],Zr=["asyncapi","id","info","externalDocs","tags","defaultContentType","servers","channels","components"],Xr=["asyncapi","info","defaultContentType","servers","channels","operations","components"];function Qn(t){return"asyncapi"in t?Jr(t)?Ht(t,Zr):Ht(t,Xr):"swagger"in t?Ht(t,qr):Ht(t,Kr)}function Ht(t,e){let i={};for(let s of e)t.hasOwnProperty(s)&&(i[s]=t[s]);return Object.assign(i,t)}function Gi(t){let e={...t.oas2,...t.oas3_0,...t.oas3_1,...t.oas3_2,...t.async2,...t.async3,...t.arazzo1,...t.overlay1,...t.openrpc1,...t.graphql};if(me(e))throw new $("\u26A0\uFE0F No rules were configured. Learn how to configure rules: https://redocly.com/docs/cli/rules/")}function to(t){return t.replace(/\x1b\[\d+m/g,"")}function Et(t){return nt(t)?t:_r(V.cwd(),t)}async function ho({argv:t,config:e,version:i,collectSpecData:s,collectResults:r}){let n=await _i(t.apis,e),o={errors:0,warnings:0,ignored:0},h=0,a=t.format==="checkstyle"||t.format==="junit",l=[];for(let{path:p,alias:c}of n)try{let f=Qr.now(),u=e.forAlias(c);Gi(u.rules),u.skipRules(t["skip-rule"]),u.skipPreprocessors(t["skip-preprocessor"]),typeof e.document?.parsed>"u"&&!t.extends&&x.info(`No configurations were provided -- using built in ${J("recommended")} configuration by default.
40
+
41
+ `),c===void 0?x.info(X(`validating ${Et(p)}...
42
+ `)):x.info(X(`validating ${Et(p)} using lint rules for api '${c}'...
43
+ `));let d=await Ae({ref:p,config:u,collectSpecData:s});r?.(d);let g=Zt(d);if(o.errors+=g.errors,o.warnings+=g.warnings,o.ignored+=g.ignored,t["generate-ignore-file"]){e.clearIgnoreForRef(p);for(let m of d)e.addIgnore(m),h++}else a?l.push(...d):Ct(d,{format:t.format,maxProblems:t["max-problems"],totals:g,version:i,command:"lint"});let w=de(f);x.info(X(`${Et(p)}: validated in ${w}
44
+
45
+ `))}catch(f){ge(f,p)}if(a&&!t["generate-ignore-file"]&&Ct(l,{format:t.format,maxProblems:t["max-problems"],totals:o,version:i,command:"lint"}),t["generate-ignore-file"]?(e.saveIgnore(),x.info(`Explicitly ignored ${h} ${z("problem",h)}.
46
+
47
+ `)):Bi(o,n.length),Ui(e),!(o.errors===0||t["generate-ignore-file"]))throw new Ce("Lint failed.")}async function zi(t,e,i){if(t["lint-config"]==="off"||i.document===void 0||t.format==="json"||t.format==="junit"||t.format==="checkstyle")return;let s=t?Oe(t):void 0,r=await ke({config:i,severity:t["lint-config"]||"warn"}),n=Zt(r);if(Ct(r,{format:t.format,maxProblems:t["max-problems"],totals:n,version:e,command:"check-config"}),Ii(n,s),n.errors>0)throw new kt}export{ho as a,Gt as b,_i as c,Ni as d,de as e,Un as f,Gn as g,Hn as h,Vn as i,Yn as j,Jn as k,qn as l,Kn as m,Yr as n,ge as o,Zn as p,Ui as q,Xn as r,Qn as s,to as t,Et as u};
@@ -4,7 +4,7 @@ import { dirname as __pathDirname } from 'node:path';
4
4
  const require = __createRequire(import.meta.url);
5
5
  var __filename = __fileURLToPath(import.meta.url);
6
6
  var __dirname = __pathDirname(__filename);
7
- import{a as T}from"./MEVUBG5J.js";import{a as R,e as P,f as x,i as v,j as H,k as l,l as M}from"./LD5MEXEL.js";import{n as N}from"./UW4UC7ZI.js";function y(e){let t=new Map(e.pathParams.map(r=>[r.name,r])),n=[];for(let r of e.path.matchAll(/\{([^{}]+)\}/g)){let s=t.get(r[1]);s!==void 0&&n.push(s)}return n}function C(e){let t=y(e),n=e.queryParams.length>0,r=!!e.requestBody,s=e.headerParams.length>0,o=e.cookieParams.length>0;return{hasQuery:n,hasBody:r,hasHeaders:s,hasCookies:o,hasInputs:t.length>0||n||r||s||o,varsRequired:t.length>0||e.queryParams.some(a=>a.required)||(e.requestBody?.required??!1)||e.headerParams.some(a=>a.required)||e.cookieParams.some(a=>a.required),variablesTypeName:`${l(e.name)}Variables`}}var O=" ";function $(e,t,n){let r=H(e,t);return r===void 0?[]:[`${n}/**`,...v(r).split(`
7
+ import{a as T}from"./UAEEHSSK.js";import{a as R,e as P,f as x,i as v,j as H,k as l,l as M}from"./LD5MEXEL.js";import{n as N}from"./UW4UC7ZI.js";function y(e){let t=new Map(e.pathParams.map(r=>[r.name,r])),n=[];for(let r of e.path.matchAll(/\{([^{}]+)\}/g)){let s=t.get(r[1]);s!==void 0&&n.push(s)}return n}function C(e){let t=y(e),n=e.queryParams.length>0,r=!!e.requestBody,s=e.headerParams.length>0,o=e.cookieParams.length>0;return{hasQuery:n,hasBody:r,hasHeaders:s,hasCookies:o,hasInputs:t.length>0||n||r||s||o,varsRequired:t.length>0||e.queryParams.some(a=>a.required)||(e.requestBody?.required??!1)||e.headerParams.some(a=>a.required)||e.cookieParams.some(a=>a.required),variablesTypeName:`${l(e.name)}Variables`}}var O=" ";function $(e,t,n){let r=H(e,t);return r===void 0?[]:[`${n}/**`,...v(r).split(`
8
8
  `).map(s=>`${n} * ${s}`.replace(/ +$/,"")),`${n} */`]}function I(e){return typeof e=="string"?JSON.stringify(e):String(e)}function V(e,t,n){switch(e){case"string":return t?.format==="binary"?"Blob":n==="Date"&&(t?.format==="date-time"||t?.format==="date")?"Date":"string";case"number":case"integer":return"number";case"boolean":return"boolean"}}function B(e){return e.kind==="union"||e.kind==="intersection"||e.kind==="enum"&&e.values.length>1}function c(e,t="string",n=""){switch(e.kind){case"scalar":return V(e.scalar,e.metadata,t);case"ref":return e.name;case"literal":return I(e.value);case"enum":return e.values.map(I).join(" | ");case"null":return"null";case"unknown":return"unknown";case"array":{let r=c(e.items,t,n);return B(e.items)?`(${r})[]`:`${r}[]`}case"record":return`Record<string, ${c(e.value,t,n)}>`;case"object":{if(e.properties.length===0)return"{}";let r=n+O;return`{
9
9
  ${e.properties.flatMap(o=>W(o,t,r)).join(`
10
10
  `)}