"use strict";var _o=Object.create;var et=Object.defineProperty;var Yo=Object.getOwnPropertyDescriptor;var Qo=Object.getOwnPropertyNames;var Jo=Object.getPrototypeOf,Wo=Object.prototype.hasOwnProperty;var Xo=(e,t)=>{for(var r in t)et(e,r,{get:t[r],enumerable:!0})},ur=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Qo(t))!Wo.call(e,n)&&n!==r&&et(e,n,{get:()=>t[n],enumerable:!(o=Yo(t,n))||o.enumerable});return e};var z=(e,t,r)=>(r=e!=null?_o(Jo(e)):{},ur(t||!e||!e.__esModule?et(r,"default",{value:e,enumerable:!0}):r,e)),en=e=>ur(et({},"__esModule",{value:!0}),e);var ks={};Xo(ks,{BuiltinLogger:()=>Ze,DependsOnMethod:()=>Ee,Documentation:()=>Tt,DocumentationError:()=>I,EndpointsFactory:()=>Ie,InputValidationError:()=>K,Integration:()=>It,Middleware:()=>_,MissingPeerError:()=>xe,OutputValidationError:()=>Q,ResultHandler:()=>ze,RoutingError:()=>ie,ServeStatic:()=>je,arrayEndpointsFactory:()=>jr,arrayResultHandler:()=>ft,attachRouting:()=>po,createConfig:()=>gr,createServer:()=>co,defaultEndpointsFactory:()=>vr,defaultResultHandler:()=>Ce,ensureHttpError:()=>$e,ez:()=>Go,getExamples:()=>V,getMessageFromError:()=>W,testEndpoint:()=>Co,testMiddleware:()=>Io});module.exports=en(ks);var C=require("ramda"),ce=require("zod");var be=require("ramda"),fr=require("zod");var A={json:"application/json",upload:"multipart/form-data",raw:"application/octet-stream"};var ie=class extends Error{name="RoutingError"},I=class extends Error{name="DocumentationError";cause;constructor(t,{method:r,path:o,isResponse:n}){super(t),this.cause=`${n?"Response":"Input"} schema of an Endpoint assigned to ${r.toUpperCase()} method of ${o} path.`}},tt=class extends Error{name="IOSchemaError"},Q=class extends tt{constructor(r){super(W(r),{cause:r});this.cause=r}name="OutputValidationError"},K=class extends tt{constructor(r){super(W(r),{cause:r});this.cause=r}name="InputValidationError"},J=class extends Error{constructor(r,o){super(W(r),{cause:r});this.cause=r;this.handled=o}name="ResultHandlerError"},xe=class extends Error{name="MissingPeerError";constructor(t){super(`Missing peer dependency: ${t}. Please install it to use the feature.`)}};var tn=e=>{let r=(e.header("content-type")||"").toLowerCase().startsWith(A.upload);return"files"in e&&r},vt={get:["query","params"],post:["body","params","files"],put:["body","params"],patch:["body","params"],delete:["query","params"]},rn=["body","query","params"],jt=e=>e.method.toLowerCase(),Nt=e=>e.startsWith("x-"),on=e=>(0,be.pickBy)((t,r)=>Nt(r),e),rt=(e,t={})=>{let r=jt(e);return r==="options"?{}:(t[r]||vt[r]||rn).filter(o=>o==="files"?tn(e):!0).map(o=>o==="headers"?on(e[o]):e[o]).reduce((o,n)=>Object.assign(o,n),{})},X=e=>e instanceof Error?e:new Error(String(e)),W=e=>e instanceof fr.z.ZodError?e.issues.map(({path:t,message:r})=>(t.length?[t.join("/")]:[]).concat(r).join(": ")).join("; "):e instanceof Q?`output${e.cause.issues[0]?.path.length>0?"/":": "}${e.message}`:e.message,V=({schema:e,variant:t="original",validate:r=t==="parsed"})=>{let o=e._def[x]?.examples||[];if(!r&&t==="original")return o;let n=[];for(let i of o){let a=e.safeParse(i);a.success&&n.push(t==="parsed"?a.data:i)}return n},ae=(e,t,r)=>e.length&&t.length?(0,be.xprod)(e,t).map(r):e.concat(t),Fe=e=>"coerce"in e._def&&typeof e._def.coerce=="boolean"?e._def.coerce:!1,Lt=e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase(),k=(...e)=>e.flatMap(t=>t.split(/[^A-Z0-9]/gi)).flatMap(t=>t.replaceAll(/[A-Z]+/g,r=>`/${r}`).split("/")).map(Lt).join(""),ot=(e,t)=>{try{return typeof e.parse(t)}catch{return}},pe=e=>typeof e=="object"&&e!==null,Se=(0,be.memoizeWith)(()=>"static",()=>process.env.NODE_ENV==="production");var nt=require("ramda"),x=Symbol.for("express-zod-api"),st=e=>{let t=e.describe(e.description);return t._def[x]=(0,nt.clone)(t._def[x])||{examples:[]},t},yr=(e,t)=>{if(!(x in e._def))return t;let r=st(t);return r._def[x].examples=ae(r._def[x].examples,e._def[x].examples,([o,n])=>typeof o=="object"&&typeof n=="object"?(0,nt.mergeDeepRight)({...o},{...n}):n),r};var nn=function(e){let t=st(this);return t._def[x].examples.push(e),t},sn=function(e){let t=st(this);return t._def[x].defaultLabel=e,t},an=function(e){return new ce.z.ZodBranded({typeName:ce.z.ZodFirstPartyTypeKind.ZodBranded,type:this,description:this._def.description,errorMap:this._def.errorMap,[x]:{examples:[],...(0,C.clone)(this._def[x]),brand:e}})},pn=function(e){let t=typeof e=="function"?e:(0,C.pipe)(C.toPairs,(0,C.map)(([n,i])=>(0,C.pair)(e[String(n)]||n,i)),C.fromPairs),r=t((0,C.clone)(this.shape)),o=ce.z.object(r)[this._def.unknownKeys]();return this.transform(t).pipe(o)};x in globalThis||(globalThis[x]=!0,Object.defineProperties(ce.z.ZodType.prototype,{example:{get(){return nn.bind(this)}},brand:{set(){},get(){return an.bind(this)}}}),Object.defineProperty(ce.z.ZodDefault.prototype,"label",{get(){return sn.bind(this)}}),Object.defineProperty(ce.z.ZodObject.prototype,"remap",{get(){return pn.bind(this)}}));function gr(e){return e}var Er=require("zod");var qt=require("zod");var P=require("node:assert/strict");var Te=require("zod");var it=e=>!isNaN(e.getTime());var de=Symbol("DateIn"),hr=()=>Te.z.union([Te.z.string().date(),Te.z.string().datetime(),Te.z.string().datetime({local:!0})]).transform(t=>new Date(t)).pipe(Te.z.date().refine(it)).brand(de);var xr=require("zod");var le=Symbol("DateOut"),br=()=>xr.z.date().refine(it).transform(e=>e.toISOString()).brand(le);var Be=require("zod"),D=Symbol("File"),Sr=Be.z.custom(e=>Buffer.isBuffer(e),{message:"Expected Buffer"}),cn={buffer:()=>Sr.brand(D),string:()=>Be.z.string().brand(D),binary:()=>Sr.or(Be.z.string()).brand(D),base64:()=>Be.z.string().base64().brand(D)};function at(e){return cn[e||"string"]()}var Tr=require("zod");var ee=Symbol("Raw"),Or=(e={})=>Tr.z.object({raw:at("buffer")}).extend(e).brand(ee);var Rr=require("zod"),Oe=Symbol("Upload"),Ar=()=>Rr.z.custom(e=>typeof e=="object"&&e!==null&&"name"in e&&"encoding"in e&&"mimetype"in e&&"data"in e&&"tempFilePath"in e&&"truncated"in e&&"size"in e&&"md5"in e&&"mv"in e&&typeof e.name=="string"&&typeof e.encoding=="string"&&typeof e.mimetype=="string"&&Buffer.isBuffer(e.data)&&typeof e.tempFilePath=="string"&&typeof e.truncated=="boolean"&&typeof e.size=="number"&&typeof e.md5=="string"&&typeof e.mv=="function",e=>({message:`Expected file upload, received ${typeof e}`})).brand(Oe);var Pr=(e,{next:t})=>e.options.some(t),dn=({_def:e},{next:t})=>[e.left,e.right].some(t),pt=(e,{next:t})=>t(e.unwrap()),kt={ZodObject:({shape:e},{next:t})=>Object.values(e).some(t),ZodUnion:Pr,ZodDiscriminatedUnion:Pr,ZodIntersection:dn,ZodEffects:(e,{next:t})=>t(e.innerType()),ZodOptional:pt,ZodNullable:pt,ZodRecord:({valueSchema:e},{next:t})=>t(e),ZodArray:({element:e},{next:t})=>t(e),ZodDefault:({_def:e},{next:t})=>t(e.innerType)},ct=(e,{condition:t,rules:r=kt,depth:o=1,maxDepth:n=Number.POSITIVE_INFINITY})=>{if(t?.(e))return!0;let i=oct(a,{condition:t,rules:r,maxDepth:n,depth:o+1})}):!1},wr=e=>ct(e,{condition:t=>t._def[x]?.brand===Oe}),zr=e=>ct(e,{condition:t=>t._def[x]?.brand===ee,maxDepth:3}),Mt=(e,t)=>{let r=new WeakSet;return ct(e,{maxDepth:300,rules:{...kt,ZodBranded:pt,ZodReadonly:pt,ZodCatch:({_def:{innerType:o}},{next:n})=>n(o),ZodPipeline:({_def:o},{next:n})=>n(o[t]),ZodLazy:(o,{next:n})=>r.has(o)?!1:r.add(o)&&n(o.schema),ZodTuple:({items:o,_def:{rest:n}},{next:i})=>[...o].concat(n??[]).some(i),ZodEffects:{out:void 0,in:kt.ZodEffects}[t],ZodNaN:()=>(0,P.fail)("z.nan()"),ZodSymbol:()=>(0,P.fail)("z.symbol()"),ZodFunction:()=>(0,P.fail)("z.function()"),ZodMap:()=>(0,P.fail)("z.map()"),ZodSet:()=>(0,P.fail)("z.set()"),ZodBigInt:()=>(0,P.fail)("z.bigint()"),ZodVoid:()=>(0,P.fail)("z.void()"),ZodPromise:()=>(0,P.fail)("z.promise()"),ZodNever:()=>(0,P.fail)("z.never()"),ZodDate:()=>t==="in"&&(0,P.fail)("z.date()"),[le]:()=>t==="in"&&(0,P.fail)("ez.dateOut()"),[de]:()=>t==="out"&&(0,P.fail)("ez.dateIn()"),[ee]:()=>t==="out"&&(0,P.fail)("ez.raw()"),[Oe]:()=>t==="out"&&(0,P.fail)("ez.upload()"),[D]:()=>!1}})};var dt=z(require("http-errors"),1);var qe=z(require("http-errors"),1),Cr=require("zod");var Ut=(e,{variant:t,args:r,...o})=>{if(typeof e=="function"&&(e=e(...r)),e instanceof Cr.z.ZodType)return[{schema:e,...o}];if(Array.isArray(e)&&!e.length){let n=new Error(`At least one ${t} response schema required.`);throw new J(n)}return(Array.isArray(e)?e:[e]).map(({schema:n,statusCode:i,mimeType:a})=>({schema:n,statusCodes:typeof i=="number"?[i]:i||o.statusCodes,mimeTypes:typeof a=="string"?[a]:a===void 0?o.mimeTypes:a}))},Ht=(e,t,{url:r},o)=>!e.expose&&t.error("Server side error",{error:e,url:r,payload:o}),$e=e=>(0,qe.isHttpError)(e)?e:(0,qe.default)(e instanceof K?400:500,W(e),{cause:e.cause||e}),Ge=e=>Se()&&!e.expose?(0,qe.default)(e.statusCode).message:e.message;var lt=({error:e,logger:t,response:r})=>{t.error("Result handler failure",e);let o=Ge((0,dt.default)(500,`An error occurred while serving the result: ${e.message}.`+(e.handled?` Original error: ${e.handled.message}.`:""),{expose:(0,dt.isHttpError)(e.cause)?e.cause.expose:!1}));r.status(500).type("text/plain").end(o)};var Ir=require("ramda");var me=e=>pe(e)&&"or"in e,Ae=e=>pe(e)&&"and"in e,Kt=e=>({and:(0,Ir.chain)(t=>Ae(t)?t.and:[t],e)}),mt=(e,t)=>Ae(e)?{and:e.and.map(r=>me(r)?{or:r.or.map(t)}:t(r))}:me(e)?{or:e.or.map(r=>Ae(r)?{and:r.and.map(t)}:t(r))}:t(e),Dt=e=>e.and.reduce((t,r)=>({or:ae(t.or,me(r)?r.or:[r],Kt)}),{or:[]}),Re=(e,t)=>Ae(e)?me(t)?Re(Dt(e),t):Kt([e,t]):me(e)?Ae(t)?Re(t,e):me(t)?{or:ae(e.or,t.or,Kt)}:Re(e,{and:[t]}):Ae(t)||me(t)?Re(t,e):{and:[e,t]};var Ft=require("zod");var Bt=class{},_=class extends Bt{#e;#t;#r;constructor({input:t=Ft.z.object({}),security:r,handler:o}){super(),this.#e=t,this.#t=r,this.#r=o}getSecurity(){return this.#t}getSchema(){return this.#e}async execute({input:t,...r}){try{let o=await this.#e.parseAsync(t);return this.#r({...r,input:o})}catch(o){throw o instanceof Ft.z.ZodError?new K(o):o}}},Pe=class extends _{constructor(t,{provider:r=()=>({}),transformer:o=n=>n}={}){super({handler:async({request:n,response:i})=>new Promise((a,p)=>{let d=c=>{if(c&&c instanceof Error)return p(o(c));a(r(n,i))};t(n,i,d)?.catch(d)})})}};var we=class{nest(t){return Object.assign(t,{"":this})}};var Ve=class extends we{},ut=class extends Ve{#e;#t;#r;#n;#s;#i;#o;#a;#p;#c;#d;constructor({methods:t,inputSchema:r,outputSchema:o,handler:n,resultHandler:i,getOperationId:a=()=>{},scopes:p=[],middlewares:d=[],tags:c=[],description:u,shortDescription:m}){super(),this.#s=n,this.#i=i,this.#r=d,this.#c=a,this.#t=Object.freeze(t),this.#a=Object.freeze(p),this.#p=Object.freeze(c),this.#e={long:u,short:m},this.#o={input:r,output:o},this.#n={positive:Object.freeze(i.getPositiveResponse(o)),negative:Object.freeze(i.getNegativeResponse())},this.#d=wr(r)?"upload":zr(r)?"raw":"json"}getDescription(t){return this.#e[t]}getMethods(){return this.#t}getSchema(t){return this.#o[t]}getRequestType(){return this.#d}getResponses(t){return this.#n[t]}getSecurity(){return this.#r.reduce((t,r)=>{let o=r.getSecurity();return o?Re(t,o):t},{and:[]})}getScopes(){return this.#a}getTags(){return this.#p}getOperationId(t){return this.#c(t)}async#l(t){try{return await this.#o.output.parseAsync(t)}catch(r){throw r instanceof qt.z.ZodError?new Q(r):r}}async#m({method:t,logger:r,options:o,response:n,...i}){for(let a of this.#r)if(!(t==="options"&&!(a instanceof Pe))&&(Object.assign(o,await a.execute({...i,options:o,response:n,logger:r})),n.writableEnded)){r.warn("A middleware has closed the stream. Accumulated options:",o);break}}async#u({input:t,...r}){let o;try{o=await this.#o.input.parseAsync(t)}catch(n){throw n instanceof qt.z.ZodError?new K(n):n}return this.#s({...r,input:o})}async#f({error:t,...r}){try{await this.#i.execute({...r,error:t})}catch(o){lt({...r,error:new J(X(o),t||void 0)})}}async execute({request:t,response:r,logger:o,config:n}){let i=jt(t),a={},p=null,d=null,c=rt(t,n.inputSources);try{if(await this.#m({method:i,input:c,request:t,response:r,logger:o,options:a}),r.writableEnded)return;if(i==="options")return void r.status(200).end();p=await this.#l(await this.#u({input:c,logger:o,options:a}))}catch(u){d=X(u)}await this.#f({input:c,output:p,request:t,response:r,error:d,logger:o,options:a})}};var Zr=(e,t)=>{let r=e.map(n=>n.getSchema()).concat(t),o=r.reduce((n,i)=>n.and(i));return r.reduce((n,i)=>yr(i,n),o)};var M=require("zod");var ue={positive:200,negative:400};var $t=class{#e;constructor(t){this.#e=t}execute(...t){return this.#e(...t)}},ze=class extends $t{#e;#t;constructor(t){super(t.handler),this.#e=t.positive,this.#t=t.negative}getPositiveResponse(t){return Ut(this.#e,{variant:"positive",args:[t],statusCodes:[ue.positive],mimeTypes:[A.json]})}getNegativeResponse(){return Ut(this.#t,{variant:"negative",args:[],statusCodes:[ue.negative],mimeTypes:[A.json]})}},Ce=new ze({positive:e=>{let t=V({schema:e}),r=M.z.object({status:M.z.literal("success"),data:e});return t.reduce((o,n)=>o.example({status:"success",data:n}),r)},negative:M.z.object({status:M.z.literal("error"),error:M.z.object({message:M.z.string()})}).example({status:"error",error:{message:"Sample error message"}}),handler:({error:e,input:t,output:r,request:o,response:n,logger:i})=>{if(e){let a=$e(e);return Ht(a,i,o,t),void n.status(a.statusCode).json({status:"error",error:{message:Ge(a)}})}n.status(ue.positive).json({status:"success",data:r})}}),ft=new ze({positive:e=>{let t=V({schema:e}),r="shape"in e&&"items"in e.shape&&e.shape.items instanceof M.z.ZodArray?e.shape.items:M.z.array(M.z.any());return t.reduce((o,n)=>pe(n)&&"items"in n&&Array.isArray(n.items)?o.example(n.items):o,r)},negative:M.z.string().example("Sample error message"),handler:({response:e,output:t,error:r,logger:o,request:n,input:i})=>{if(r){let a=$e(r);return Ht(a,o,n,i),void e.status(a.statusCode).type("text/plain").send(Ge(a))}if(t&&"items"in t&&Array.isArray(t.items))return void e.status(ue.positive).json(t.items);throw new Error("Property 'items' is missing in the endpoint output")}});var Ie=class e{resultHandler;middlewares=[];constructor(t){this.resultHandler="resultHandler"in t?t.resultHandler:t}static#e(t,r){let o=new e(r);return o.middlewares=t,o}addMiddleware(t){return e.#e(this.middlewares.concat(t instanceof _?t:new _(t)),this.resultHandler)}use=this.addExpressMiddleware;addExpressMiddleware(...t){return e.#e(this.middlewares.concat(new Pe(...t)),this.resultHandler)}addOptions(t){return e.#e(this.middlewares.concat(new _({handler:t})),this.resultHandler)}build({input:t=Er.z.object({}),handler:r,output:o,description:n,shortDescription:i,operationId:a,scope:p,tag:d,method:c}){let{middlewares:u,resultHandler:m}=this,y=typeof c=="string"?[c]:c,b=typeof a=="function"?a:()=>a,O=typeof p=="string"?[p]:p||[],R=typeof d=="string"?[d]:d||[];return new ut({handler:r,middlewares:u,outputSchema:o,resultHandler:m,scopes:O,tags:R,methods:y,getOperationId:b,description:n,shortDescription:i,inputSchema:Zr(u,t)})}},vr=new Ie(Ce),jr=new Ie(ft);var Z=require("ansis"),Kr=require("node:util"),Gt=require("node:perf_hooks");var gt={debug:10,info:20,warn:30,error:40},Lr=e=>pe(e)&&Object.keys(gt).some(t=>t in e),kr=e=>e in gt,Mr=(e,t)=>gt[e]Intl.NumberFormat(void 0,{useGrouping:!1,minimumFractionDigits:0,maximumFractionDigits:e}),yt=Ur(),Nr=Ur(2),ln=e=>e<1e-6?["picosecond",e/1e-9,yt]:e<.001?["nanosecond",e/1e-6,yt]:e<1?["microsecond",e/.001,yt]:e<1e3?["millisecond",e,yt]:e<6e4?["second",e/1e3,Nr]:["minute",e/6e4,Nr],Hr=e=>{let[t,r,o]=ln(e);return`${o.format(r)} ${t}${r>1?"s":""}`};var Ze=class e{config;styles={debug:Z.blue,info:Z.green,warn:(0,Z.hex)("#FFA500"),error:Z.red};constructor(t={}){let{color:r=new Z.Ansis().isSupported(),level:o=Se()?"warn":"debug",depth:n=2,ctx:i={}}=t;this.config={color:r,level:o,depth:n,ctx:i}}prettyPrint(t){let{depth:r,color:o,level:n}=this.config;return(0,Kr.inspect)(t,{depth:r,colors:o,breakLength:n==="debug"?80:1/0,compact:n==="debug"?3:!0})}print(t,r,o){let{level:n,ctx:{requestId:i,...a},color:p}=this.config;if(n==="silent"||Mr(t,n))return;let d=[new Date().toISOString()];i&&d.push(p?(0,Z.cyanBright)(i):i),d.push(p?`${this.styles[t](t)}:`:`${t}:`,r),o!==void 0&&d.push(this.prettyPrint(o)),Object.keys(a).length>0&&d.push(this.prettyPrint(a)),console.log(d.join(" "))}debug(t,r){this.print("debug",t,r)}info(t,r){this.print("info",t,r)}warn(t,r){this.print("warn",t,r)}error(t,r){this.print("error",t,r)}child(t){return new e({...this.config,ctx:t})}profile(t){let r=Gt.performance.now();return()=>{let o=Gt.performance.now()-r,{message:n,severity:i="debug",formatter:a=Hr}=typeof t=="object"?t:{message:t};this.print(typeof i=="function"?i(o):i,n,a(o))}}};var ve=require("ramda");var Ee=class extends we{entries;constructor(t){super();let r=[],o=(0,ve.keys)(t);for(let n of o){let i=t[n];i&&r.push([n,i,(0,ve.reject)((0,ve.equals)(n),o)])}this.entries=Object.freeze(r)}};var Dr=z(require("express"),1),je=class{params;constructor(...t){this.params=t}apply(t,r){return r(t,Dr.default.static(...this.params))}};var xt=z(require("express"),1),so=z(require("node:http"),1),io=z(require("node:https"),1);var Ne=async(e,t="default")=>{try{return(await Promise.resolve().then(()=>z(require(e))))[t]}catch{}throw new xe(e)};var ht=class{constructor(t){this.logger=t}#e=new WeakSet;check(t,r){if(!this.#e.has(t)){if(t.getRequestType()==="json")try{Mt(t.getSchema("input"),"in")}catch(o){this.logger.warn("The final input schema of the endpoint contains an unsupported JSON payload type.",Object.assign(r,{reason:o}))}for(let o of["positive","negative"])for(let{mimeTypes:n,schema:i}of t.getResponses(o))if(n?.includes(A.json))try{Mt(i,"out")}catch(a){this.logger.warn(`The final ${o} response schema of the endpoint contains an unsupported JSON payload type.`,Object.assign(r,{reason:a}))}this.#e.add(t)}}};var Fr=(e,t)=>Object.entries(e).map(([r,o])=>{if(r.includes("/"))throw new ie(`The entry '${r}' must avoid having slashes \u2014 use nesting instead.`);let n=r.trim();return[`${t||""}${n?`/${n}`:""}`,o]}),Le=({routing:e,onEndpoint:t,onStatic:r})=>{let o=Fr(e);for(;o.length;){let[n,i]=o.shift();if(i instanceof Ve){let a=i.getMethods()||["get"];for(let p of a)t(i,n,p)}else if(i instanceof je)r&&i.apply(n,r);else if(i instanceof Ee)for(let[a,p,d]of i.entries){let c=p.getMethods();if(c&&!c.includes(a))throw new ie(`Endpoint assigned to ${a} method of ${n} must support ${a} method.`);t(p,n,a,d)}else o.unshift(...Fr(i,n))}};var Vt=({app:e,getLogger:t,config:r,routing:o,parsers:n})=>{let i=new ht(t()),a=new Set;Le({routing:o,onStatic:(p,d)=>void e.use(p,d),onEndpoint:(p,d,c,u)=>{Se()||i.check(p,{path:d,method:c});let m=n?.[p.getRequestType()]||[],y=async(b,O)=>{let R=t(b);if(r.cors){let N={"Access-Control-Allow-Origin":"*","Access-Control-Allow-Methods":[c,...u||[],"options"].join(", ").toUpperCase(),"Access-Control-Allow-Headers":"content-type"},U=typeof r.cors=="function"?await r.cors({request:b,endpoint:p,logger:R,defaultHeaders:N}):N;for(let B in U)O.set(B,U[B])}return p.execute({request:b,response:O,logger:R,config:r})};r.cors&&!a.has(d)&&(e.options(d,...m,y),a.add(d)),e[c](d,...m,y)}})};var _e=z(require("http-errors"),1);var _r=require("node:timers/promises");var Br=e=>"_httpMessage"in e&&typeof e._httpMessage=="object"&&e._httpMessage!==null&&"headersSent"in e._httpMessage&&typeof e._httpMessage.headersSent=="boolean"&&"setHeader"in e._httpMessage&&typeof e._httpMessage.setHeader=="function",qr=e=>"server"in e&&typeof e.server=="object"&&e.server!==null&&"close"in e.server&&typeof e.server.close=="function",$r=e=>"encrypted"in e&&typeof e.encrypted=="boolean"&&e.encrypted,Gr=({},e)=>void(!e.headersSent&&e.setHeader("connection","close")),Vr=e=>new Promise((t,r)=>void e.close(o=>o?r(o):t()));var Yr=(e,{timeout:t=1e3,logger:r}={})=>{let o,n=new Set,i=c=>void n.delete(c.destroy()),a=c=>void(Br(c)?!c._httpMessage.headersSent&&c._httpMessage.setHeader("connection","close"):i(c)),p=c=>void(o?c.destroy():n.add(c.once("close",()=>void n.delete(c))));for(let c of e)for(let u of["connection","secureConnection"])c.on(u,p);let d=async()=>{for(let c of e)c.on("request",Gr);r?.info("Graceful shutdown",{sockets:n.size,timeout:t});for(let c of n)($r(c)||qr(c))&&a(c);for await(let c of(0,_r.setInterval)(10,Date.now()))if(n.size===0||Date.now()-c>=t)break;for(let c of n)i(c);return Promise.allSettled(e.map(Vr))};return{sockets:n,shutdown:()=>o??=d()}};var Qr=({errorHandler:e,getLogger:t})=>async(r,o,n,i)=>r?e.execute({error:(0,_e.isHttpError)(r)?r:(0,_e.default)(400,X(r).message),request:o,response:n,input:null,output:null,options:{},logger:t(o)}):i(),Jr=({errorHandler:e,getLogger:t})=>async(r,o)=>{let n=(0,_e.default)(404,`Can not ${r.method} ${r.path}`),i=t(r);try{e.execute({request:r,response:o,logger:i,error:n,input:null,output:null,options:{}})}catch(a){lt({response:o,logger:i,error:new J(X(a),n)})}},mn=e=>(t,{},r)=>{if(Object.values(t?.files||[]).flat().find(({truncated:n})=>n))return r(e);r()},un=e=>({log:e.debug.bind(e)}),Wr=async({getLogger:e,config:t})=>{let r=await Ne("express-fileupload"),{limitError:o,beforeUpload:n,...i}={...typeof t.upload=="object"&&t.upload},a=[];return a.push(async(p,d,c)=>{let u=e(p);try{await n?.({request:p,logger:u})}catch(m){return c(m)}return r({debug:!0,...i,abortOnLimit:!1,parseNested:!0,logger:un(u)})(p,d,c)}),o&&a.push(mn(o)),a},Xr=(e,{},t)=>{Buffer.isBuffer(e.body)&&(e.body={raw:e.body}),t()},eo=({logger:e,config:t})=>async(r,o,n)=>{let i=await t.childLoggerProvider?.({request:r,parent:e})||e;i.debug(`${r.method}: ${r.path}`),r.res&&(r.res.locals[x]={logger:i}),n()},to=e=>t=>t?.res?.locals[x]?.logger||e,ro=e=>process.on("deprecation",({message:t,namespace:r,name:o,stack:n})=>e.warn(`${o} (${r}): ${t}`,n.split(` `).slice(1))),oo=({servers:e,logger:t,options:{timeout:r,events:o=["SIGINT","SIGTERM"]}})=>{let n=Yr(e,{logger:t,timeout:r}),i=()=>n.shutdown().then(()=>process.exit());for(let a of o)process.on(a,i)};var E=require("ansis"),no=e=>{if(e.columns<132)return;let t=(0,E.italic)("Proudly supports transgender community.".padStart(109)),r=(0,E.italic)("Start your API server with I/O schema validation and custom middlewares in minutes.".padStart(109)),o=(0,E.italic)("Thank you for choosing Express Zod API for your project.".padStart(132)),n=(0,E.italic)("for Kesaria".padEnd(20)),i=(0,E.hex)("#F5A9B8"),a=(0,E.hex)("#5BCEFA"),p=new Array(14).fill(a,1,3).fill(i,3,5).fill(E.whiteBright,5,7).fill(i,7,9).fill(a,9,12).fill(E.gray,12,13),d=` 8888888888 8888888888P 888 d8888 8888888b. 8888888 888 d88P 888 d88888 888 Y88b 888 888 d88P 888 d88P888 888 888 888 8888888 888 888 88888b. 888d888 .d88b. .d8888b .d8888b d88P .d88b. .d88888 d88P 888 888 d88P 888 888 \u1FEFY8bd8P' 888 "88b 888P" d8P Y8b 88K 88K d88P d88""88b d88" 888 d88P 888 8888888P" 888 888 X88K 888 888 888 88888888 "Y8888b. "Y8888b. d88P 888 888 888 888 d88P 888 888 888 888 .d8""8b. 888 d88P 888 Y8b. X88 X88 d88P Y88..88P Y88b 888 d8888888888 888 888 8888888888 888 888 88888P" 888 "Y8888 88888P' 88888P' d8888888888 "Y88P" "Y88888 d88P 888 888 8888888 888 888${t} ${n}888${r} ${o} `;e.write(d.split(` `).map((c,u)=>p[u]?p[u](c):c).join(` `))};var ao=e=>{e.startupLogo!==!1&&no(process.stdout);let t=e.errorHandler||Ce,r=Lr(e.logger)?e.logger:new Ze(e.logger);r.debug("Running",{build:"v21.1.0 (CJS)",env:process.env.NODE_ENV||"development"}),ro(r);let o=eo({logger:r,config:e}),i={getLogger:to(r),errorHandler:t},a=Jr(i),p=Qr(i);return{...i,logger:r,notFoundHandler:a,parserFailureHandler:p,loggingMiddleware:o}},po=(e,t)=>{let{logger:r,getLogger:o,notFoundHandler:n,loggingMiddleware:i}=ao(e);return Vt({app:e.app.use(i),routing:t,getLogger:o,config:e}),{notFoundHandler:n,logger:r}},co=async(e,t)=>{let{logger:r,getLogger:o,notFoundHandler:n,parserFailureHandler:i,loggingMiddleware:a}=ao(e),p=(0,xt.default)().disable("x-powered-by").use(a);if(e.compression){let y=await Ne("compression");p.use(y(typeof e.compression=="object"?e.compression:void 0))}let d={json:[e.jsonParser||xt.default.json()],raw:[e.rawParser||xt.default.raw(),Xr],upload:e.upload?await Wr({config:e,getLogger:o}):[]};await e.beforeRouting?.({app:p,getLogger:o}),Vt({app:p,routing:t,getLogger:o,config:e,parsers:d}),p.use(i,n);let c=[],u=(y,b)=>()=>y.listen(b,()=>r.info("Listening",b)),m=[];if(e.http){let y=so.default.createServer(p);c.push(y),m.push(u(y,e.http.listen))}if(e.https){let y=io.default.createServer(e.https.options,p);c.push(y),m.push(u(y,e.https.listen))}return e.gracefulShutdown&&oo({logger:r,servers:c,options:e.gracefulShutdown===!0?{}:e.gracefulShutdown}),{app:p,logger:r,servers:m.map(y=>y())}};var wo=require("openapi3-ts/oas31"),Ot=require("ramda");var Y=require("openapi3-ts/oas31"),l=require("ramda"),S=require("zod");var fe=(e,{onEach:t,rules:r,onMissing:o,ctx:n={}})=>{let i=r[e._def[x]?.brand]||r[e._def.typeName],p=i?i(e,{...n,next:c=>fe(c,{ctx:n,onEach:t,rules:r,onMissing:o})}):o(e,n),d=t&&t(e,{prev:p,...n});return d?{...p,...d}:p};var lo=50,uo="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString",fn={integer:0,number:0,string:"",boolean:!1,object:{},null:null,array:[]},fo=/:([A-Za-z0-9_]+)/g,yn=e=>e.match(fo)?.map(t=>t.slice(1))||[],yo=e=>e.replace(fo,t=>`{${t.slice(1)}}`),gn=({_def:e},{next:t})=>({...t(e.innerType),default:e[x]?.defaultLabel||e.defaultValue()}),hn=({_def:{innerType:e}},{next:t})=>t(e),xn=()=>({format:"any"}),bn=({},e)=>{if(e.isResponse)throw new I("Please use ez.upload() only for input.",e);return{type:"string",format:"binary"}},Sn=e=>{let t=e.unwrap();return{type:"string",format:t instanceof S.z.ZodString?t._def.checks.find(r=>r.kind==="base64")?"byte":"file":"binary"}},Tn=({options:e},{next:t})=>({oneOf:e.map(t)}),On=({options:e,discriminator:t},{next:r})=>({discriminator:{propertyName:t},oneOf:e.map(r)}),Rn=(e,t)=>{if(Array.isArray(e)&&Array.isArray(t))return(0,l.concat)(e,t);if(e===t)return t;throw new Error("Can not flatten properties")},An=e=>{let[t,r]=e.filter(Y.isSchemaObject).filter(n=>n.type==="object"&&Object.keys(n).every(i=>["type","properties","required","examples"].includes(i)));if(!t||!r)throw new Error("Can not flatten objects");let o={type:"object"};return(t.properties||r.properties)&&(o.properties=(0,l.mergeDeepWith)(Rn,t.properties||{},r.properties||{})),(t.required||r.required)&&(o.required=(0,l.union)(t.required||[],r.required||[])),(t.examples||r.examples)&&(o.examples=ae(t.examples||[],r.examples||[],([n,i])=>(0,l.mergeDeepRight)(n,i))),o},Pn=({_def:{left:e,right:t}},{next:r})=>{let o=[e,t].map(r);try{return An(o)}catch{}return{allOf:o}},wn=(e,{next:t})=>t(e.unwrap()),zn=(e,{next:t})=>t(e.unwrap()),Cn=(e,{next:t})=>{let r=t(e.unwrap());return(0,Y.isSchemaObject)(r)&&(r.type=ho(r)),r},go=e=>{let t=(0,l.toLower)((0,l.type)(e));return typeof e=="bigint"?"integer":t==="number"||t==="string"||t==="boolean"||t==="object"||t==="null"||t==="array"?t:void 0},mo=e=>({type:go(Object.values(e.enum)[0]),enum:Object.values(e.enum)}),In=({value:e})=>({type:go(e),const:e}),Zn=(e,{isResponse:t,next:r})=>{let o=Object.keys(e.shape),n=p=>t&&Fe(p)?p instanceof S.z.ZodOptional:p.isOptional(),i=o.filter(p=>!n(e.shape[p])),a={type:"object"};return o.length&&(a.properties=bt(e,r)),i.length&&(a.required=i),a},En=()=>({type:"null"}),vn=({},e)=>{if(e.isResponse)throw new I("Please use ez.dateOut() for output.",e);return{description:"YYYY-MM-DDTHH:mm:ss.sssZ",type:"string",format:"date-time",pattern:/^\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}:\d{2}(\.\d+)?)?Z?$/.source,externalDocs:{url:uo}}},jn=({},e)=>{if(!e.isResponse)throw new I("Please use ez.dateIn() for input.",e);return{description:"YYYY-MM-DDTHH:mm:ss.sssZ",type:"string",format:"date-time",externalDocs:{url:uo}}},Nn=({},e)=>{throw new I(`Using z.date() within ${e.isResponse?"output":"input"} schema is forbidden. Please use ez.date${e.isResponse?"Out":"In"}() instead. Check out the documentation for details.`,e)},Ln=()=>({type:"boolean"}),kn=()=>({type:"integer",format:"bigint"}),Mn=e=>e.every(t=>t instanceof S.z.ZodLiteral),Un=({keySchema:e,valueSchema:t},{next:r})=>{if(e instanceof S.z.ZodEnum||e instanceof S.z.ZodNativeEnum){let o=Object.values(e.enum),n={type:"object"};return o.length&&(n.properties=bt(S.z.object((0,l.fromPairs)((0,l.xprod)(o,[t]))),r),n.required=o),n}if(e instanceof S.z.ZodLiteral)return{type:"object",properties:bt(S.z.object({[e.value]:t}),r),required:[e.value]};if(e instanceof S.z.ZodUnion&&Mn(e.options)){let o=(0,l.map)(i=>`${i.value}`,e.options),n=(0,l.fromPairs)((0,l.xprod)(o,[t]));return{type:"object",properties:bt(S.z.object(n),r),required:o}}return{type:"object",additionalProperties:r(t)}},Hn=({_def:{minLength:e,maxLength:t},element:r},{next:o})=>{let n={type:"array",items:o(r)};return e&&(n.minItems=e.value),t&&(n.maxItems=t.value),n},Kn=({items:e,_def:{rest:t}},{next:r})=>({type:"array",prefixItems:e.map(r),items:t===null?{not:{}}:r(t)}),Dn=({isEmail:e,isURL:t,minLength:r,maxLength:o,isUUID:n,isCUID:i,isCUID2:a,isULID:p,isIP:d,isEmoji:c,isDatetime:u,_def:{checks:m}})=>{let y=m.find(w=>w.kind==="regex"),b=m.find(w=>w.kind==="datetime"),O=y?y.regex:b?b.offset?new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(([+-]\\d{2}:\\d{2})|Z)$"):new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?Z$"):void 0,R={type:"string"},h={"date-time":u,email:e,url:t,uuid:n,cuid:i,cuid2:a,ulid:p,ip:d,emoji:c};for(let w in h)if(h[w]){R.format=w;break}return r!==null&&(R.minLength=r),o!==null&&(R.maxLength=o),O&&(R.pattern=O.source),R},Fn=({isInt:e,maxValue:t,minValue:r,_def:{checks:o}})=>{let n=o.find(m=>m.kind==="min"),i=r===null?e?Number.MIN_SAFE_INTEGER:-Number.MAX_VALUE:r,a=n?n.inclusive:!0,p=o.find(m=>m.kind==="max"),d=t===null?e?Number.MAX_SAFE_INTEGER:Number.MAX_VALUE:t,c=p?p.inclusive:!0,u={type:e?"integer":"number",format:e?"int64":"double"};return a?u.minimum=i:u.exclusiveMinimum=i,c?u.maximum=d:u.exclusiveMaximum=d,u},bt=({shape:e},t)=>(0,l.map)(t,e),Bn=e=>{let t=Array.isArray(e.type)?e.type[0]:e.type;return fn?.[t]},ho=({type:e})=>e==="null"?e:typeof e=="string"?[e,"null"]:e?[...new Set(e).add("null")]:"null",qn=(e,{isResponse:t,next:r})=>{let o=r(e.innerType()),{effect:n}=e._def;if(t&&n.type==="transform"&&(0,Y.isSchemaObject)(o)){let i=ot(e,Bn(o));return i&&["number","string","boolean"].includes(i)?{type:i}:r(S.z.any())}if(!t&&n.type==="preprocess"&&(0,Y.isSchemaObject)(o)){let{type:i,...a}=o;return{...a,format:`${a.format||i} (preprocessed)`}}return o},$n=({_def:e},{isResponse:t,next:r})=>r(e[t?"out":"in"]),Gn=(e,{next:t})=>t(e.unwrap()),Vn=(e,{next:t,makeRef:r})=>r(e,()=>t(e.schema)),_n=(e,{next:t})=>t(e.unwrap().shape.raw),xo=e=>e.length?(0,l.fromPairs)((0,l.zip)((0,l.range)(1,e.length+1).map(t=>`example${t}`),(0,l.map)((0,l.objOf)("value"),e))):void 0,bo=(e,t,r=[])=>(0,l.pipe)(V,(0,l.map)((0,l.when)(o=>(0,l.type)(o)==="Object",(0,l.omit)(r))),xo)({schema:e,variant:t?"parsed":"original",validate:!0}),Yn=(e,t)=>(0,l.pipe)(V,(0,l.filter)((0,l.has)(t)),(0,l.pluck)(t),xo)({schema:e,variant:"original",validate:!0}),ye=e=>e instanceof S.z.ZodObject?e:e instanceof S.z.ZodBranded?ye(e.unwrap()):e instanceof S.z.ZodUnion||e instanceof S.z.ZodDiscriminatedUnion?e.options.map(t=>ye(t)).reduce((t,r)=>t.merge(r.partial()),S.z.object({})):e instanceof S.z.ZodEffects?ye(e._def.schema):e instanceof S.z.ZodPipeline?ye(e._def.in):ye(e._def.left).merge(ye(e._def.right)),So=({path:e,method:t,schema:r,inputSources:o,makeRef:n,composition:i,brandHandling:a,description:p=`${t.toUpperCase()} ${e} Parameter`})=>{let{shape:d}=ye(r),c=yn(e),u=o.includes("query"),m=o.includes("params"),y=o.includes("headers"),b=h=>m&&c.includes(h),O=h=>y&&Nt(h);return Object.keys(d).map(h=>({name:h,location:b(h)?"path":O(h)?"header":u?"query":void 0})).filter(h=>h.location!==void 0).map(({name:h,location:w})=>{let N=fe(d[h],{rules:{...a,...Yt},onEach:Qt,onMissing:Jt,ctx:{isResponse:!1,makeRef:n,path:e,method:t}}),U=i==="components"?n(d[h],N,k(p,h)):N;return{name:h,in:w,required:!d[h].isOptional(),description:N.description||p,schema:U,examples:Yn(r,h)}})},Yt={ZodString:Dn,ZodNumber:Fn,ZodBigInt:kn,ZodBoolean:Ln,ZodNull:En,ZodArray:Hn,ZodTuple:Kn,ZodRecord:Un,ZodObject:Zn,ZodLiteral:In,ZodIntersection:Pn,ZodUnion:Tn,ZodAny:xn,ZodDefault:gn,ZodEnum:mo,ZodNativeEnum:mo,ZodEffects:qn,ZodOptional:wn,ZodNullable:Cn,ZodDiscriminatedUnion:On,ZodBranded:Gn,ZodDate:Nn,ZodCatch:hn,ZodPipeline:$n,ZodLazy:Vn,ZodReadonly:zn,[D]:Sn,[Oe]:bn,[le]:jn,[de]:vn,[ee]:_n},Qt=(e,{isResponse:t,prev:r})=>{if((0,Y.isReferenceObject)(r))return{};let{description:o}=e,n=e instanceof S.z.ZodLazy,i=r.type!==void 0,a=t&&Fe(e),p=!n&&i&&!a&&e.isNullable(),d={};if(o&&(d.description=o),p&&(d.type=ho(r)),!n){let c=V({schema:e,variant:t?"parsed":"original",validate:!0});c.length&&(d.examples=c.slice())}return d},Jt=(e,t)=>{throw new I(`Zod type ${e.constructor.name} is unsupported.`,t)},_t=(e,t)=>{if((0,Y.isReferenceObject)(e))return e;let r={...e};return r.properties&&(r.properties=(0,l.omit)(t,r.properties)),r.examples&&(r.examples=r.examples.map(o=>(0,l.omit)(t,o))),r.required&&(r.required=r.required.filter(o=>!t.includes(o))),r.allOf&&(r.allOf=r.allOf.map(o=>_t(o,t))),r.oneOf&&(r.oneOf=r.oneOf.map(o=>_t(o,t))),r},To=e=>(0,Y.isReferenceObject)(e)?e:(0,l.omit)(["examples"],e),Oo=({method:e,path:t,schema:r,mimeTypes:o,variant:n,makeRef:i,composition:a,hasMultipleStatusCodes:p,statusCode:d,brandHandling:c,description:u=`${e.toUpperCase()} ${t} ${Lt(n)} response ${p?d:""}`.trim()})=>{if(!o)return{description:u};let m=To(fe(r,{rules:{...c,...Yt},onEach:Qt,onMissing:Jt,ctx:{isResponse:!0,makeRef:i,path:t,method:e}})),y={schema:a==="components"?i(r,m,k(u)):m,examples:bo(r,!0)};return{description:u,content:(0,l.fromPairs)((0,l.xprod)(o,[y]))}},Qn=()=>({type:"http",scheme:"basic"}),Jn=({format:e})=>{let t={type:"http",scheme:"bearer"};return e&&(t.bearerFormat=e),t},Wn=({name:e},t)=>{let r={type:"apiKey",in:"query",name:e};return t?.includes("body")&&(t?.includes("query")?(r["x-in-alternative"]="body",r.description=`${e} CAN also be supplied within the request body`):(r["x-in-actual"]="body",r.description=`${e} MUST be supplied within the request body instead of query`)),r},Xn=({name:e})=>({type:"apiKey",in:"header",name:e}),es=({name:e})=>({type:"apiKey",in:"cookie",name:e}),ts=({url:e})=>({type:"openIdConnect",openIdConnectUrl:e}),rs=({flows:e={}})=>({type:"oauth2",flows:(0,l.map)(t=>({...t,scopes:t.scopes||{}}),(0,l.reject)(l.isNil,e))}),Ro=(e,t)=>{let r={basic:Qn,bearer:Jn,input:Wn,header:Xn,cookie:es,openid:ts,oauth2:rs};return mt(e,o=>r[o.type](o,t))},St=e=>"or"in e?e.or.map(t=>"and"in t?(0,l.mergeAll)((0,l.map)(({name:r,scopes:o})=>(0,l.objOf)(r,o),t.and)):{[t.name]:t.scopes}):"and"in e?St(Dt(e)):St({or:[e]}),Ao=({method:e,path:t,schema:r,mimeType:o,makeRef:n,composition:i,brandHandling:a,paramNames:p,description:d=`${e.toUpperCase()} ${t} Request body`})=>{let c=To(_t(fe(r,{rules:{...a,...Yt},onEach:Qt,onMissing:Jt,ctx:{isResponse:!1,makeRef:n,path:t,method:e}}),p)),u={schema:i==="components"?n(r,c,k(d)):c,examples:bo(r,!1,p)};return{description:d,content:{[o]:u}}},Po=e=>Object.keys(e).map(t=>{let r=e[t],o={name:t,description:typeof r=="string"?r:r.description};return typeof r=="object"&&r.url&&(o.externalDocs={url:r.url}),o}),Wt=e=>e.length<=lo?e:e.slice(0,lo-1)+"\u2026";var Tt=class extends wo.OpenApiBuilder{lastSecuritySchemaIds=new Map;lastOperationIdSuffixes=new Map;responseVariants=(0,Ot.keys)(ue);references=new Map;makeRef(t,r,o=this.references.get(t)){return o||(o=`Schema${this.references.size+1}`,this.references.set(t,o),typeof r=="function"&&(r=r())),typeof r=="object"&&this.addSchema(o,r),{$ref:`#/components/schemas/${o}`}}ensureUniqOperationId(t,r,o){let n=o||k(r,t),i=this.lastOperationIdSuffixes.get(n);if(i===void 0)return this.lastOperationIdSuffixes.set(n,1),n;if(o)throw new I(`Duplicated operationId: "${o}"`,{method:r,isResponse:!1,path:t});return i++,this.lastOperationIdSuffixes.set(n,i),`${n}${i}`}ensureUniqSecuritySchemaName(t){let r=JSON.stringify(t);for(let n in this.rootDoc.components?.securitySchemes||{})if(r===JSON.stringify(this.rootDoc.components?.securitySchemes?.[n]))return n;let o=(this.lastSecuritySchemaIds.get(t.type)||0)+1;return this.lastSecuritySchemaIds.set(t.type,o),`${t.type.toUpperCase()}_${o}`}constructor({routing:t,config:r,title:o,version:n,serverUrl:i,descriptions:a,brandHandling:p,hasSummaryFromDescription:d=!0,composition:c="inline"}){super(),this.addInfo({title:o,version:n});for(let m of typeof i=="string"?[i]:i)this.addServer({url:m});Le({routing:t,onEndpoint:(m,y,b)=>{let O={path:y,method:b,endpoint:m,composition:c,brandHandling:p,makeRef:this.makeRef.bind(this)},[R,h]=["short","long"].map(m.getDescription.bind(m)),w=R?Wt(R):d&&h?Wt(h):void 0,N=m.getTags(),U=r.inputSources?.[b]||vt[b],B=this.ensureUniqOperationId(y,b,m.getOperationId(b)),ke=So({...O,inputSources:U,schema:m.getSchema("input"),description:a?.requestParameter?.call(null,{method:b,path:y,operationId:B})}),Je={};for(let q of this.responseVariants){let oe=m.getResponses(q);for(let{mimeTypes:Me,schema:Et,statusCodes:Xe}of oe)for(let Ue of Xe)Je[Ue]=Oo({...O,variant:q,schema:Et,mimeTypes:Me,statusCode:Ue,hasMultipleStatusCodes:oe.length>1||Xe.length>1,description:a?.[`${q}Response`]?.call(null,{method:b,path:y,operationId:B,statusCode:Ue})})}let Zt=U.includes("body")?Ao({...O,paramNames:(0,Ot.pluck)("name",ke),schema:m.getSchema("input"),mimeType:A[m.getRequestType()],description:a?.requestBody?.call(null,{method:b,path:y,operationId:B})}):void 0,We=St(mt(Ro(m.getSecurity(),U),q=>{let oe=this.ensureUniqSecuritySchemaName(q),Me=["oauth2","openIdConnect"].includes(q.type)?m.getScopes().slice():[];return this.addSecurityScheme(oe,q),{name:oe,scopes:Me}}));this.addPath(yo(y),{[b]:{operationId:B,summary:w,description:h,tags:N.length>0?N:void 0,parameters:ke.length>0?ke:void 0,requestBody:Zt,security:We.length>0?We:void 0,responses:Je}})}}),this.rootDoc.tags=r.tags?Po(r.tags):[]}};var Rt=require("node-mocks-http"),os=e=>(0,Rt.createRequest)({...e,headers:{"content-type":A.json,...e?.headers}}),ns=e=>(0,Rt.createResponse)(e),ss=e=>{let t={warn:[],error:[],info:[],debug:[]};return new Proxy(e||{},{get(r,o,n){return o==="_getLogs"?()=>t:kr(o)?(...i)=>t[o].push(i):Reflect.get(r,o,n)}})},zo=({requestProps:e,responseOptions:t,configProps:r,loggerProps:o})=>{let n=os(e),i=ns({req:n,...t});i.req=t?.req||n,n.res=i;let a=ss(o),p={cors:!1,logger:a,...r};return{requestMock:n,responseMock:i,loggerMock:a,configMock:p}},Co=async({endpoint:e,...t})=>{let{requestMock:r,responseMock:o,loggerMock:n,configMock:i}=zo(t);return await e.execute({request:r,response:o,config:i,logger:n}),{requestMock:r,responseMock:o,loggerMock:n}},Io=async({middleware:e,options:t={},errorHandler:r,...o})=>{let{requestMock:n,responseMock:i,loggerMock:a,configMock:p}=zo(o),d=rt(n,p.inputSources);try{let c=await e.execute({request:n,response:i,logger:a,input:d,options:t});return{requestMock:n,responseMock:i,loggerMock:a,output:c}}catch(c){if(!r)throw c;return r(X(c),i),{requestMock:n,responseMock:i,loggerMock:a,output:{}}}};var j=z(require("typescript"),1),$o=require("zod");var v=z(require("typescript"),1),Xt=require("ramda"),s=v.default.factory,te=[s.createModifier(v.default.SyntaxKind.ExportKeyword)],is=[s.createModifier(v.default.SyntaxKind.AsyncKeyword)],as=[s.createModifier(v.default.SyntaxKind.PublicKeyword),s.createModifier(v.default.SyntaxKind.ReadonlyKeyword)],Zo=[s.createModifier(v.default.SyntaxKind.ProtectedKeyword),s.createModifier(v.default.SyntaxKind.ReadonlyKeyword)],ps=s.createTemplateHead(""),cs=s.createTemplateMiddle(" "),Ye=s.createTemplateTail(""),er=e=>s.createTemplateLiteralType(ps,e.map((t,r)=>s.createTemplateLiteralTypeSpan(s.createTypeReferenceNode(t),r===e.length-1?Ye:cs))),tr=er(["M","P"]),At=(e,t,r)=>s.createParameterDeclaration(r,void 0,e,void 0,t,void 0),Pt=(e,t)=>(0,Xt.chain)(([r,o])=>[At(s.createIdentifier(r),o,t)],Object.entries(e)),rr=(e,t)=>s.createExpressionWithTypeArguments(s.createIdentifier("Record"),[typeof e=="number"?s.createKeywordTypeNode(e):s.createTypeReferenceNode(e),s.createKeywordTypeNode(t)]),Eo=e=>s.createConstructorDeclaration(void 0,e,s.createBlock([])),vo=(e,t)=>s.createPropertySignature(void 0,e,void 0,s.createTypeReferenceNode(t)),F=(e,t,r)=>s.createVariableDeclarationList([s.createVariableDeclaration(e,void 0,r,t)],v.default.NodeFlags.Const),or=(e,t)=>s.createTypeAliasDeclaration(te,e,void 0,s.createUnionTypeNode(t.map(r=>s.createLiteralTypeNode(s.createStringLiteral(r))))),wt=(e,t)=>s.createTypeAliasDeclaration(te,e,void 0,t),jo=(e,t,r)=>s.createPropertyDeclaration(as,e,void 0,t,r),No=(e,t,r)=>s.createClassDeclaration(te,e,void 0,void 0,[t,...r]),Lo=(e,t)=>s.createTypeReferenceNode("Promise",[s.createIndexedAccessTypeNode(s.createTypeReferenceNode(e),t)]),ko=()=>s.createTypeReferenceNode("Promise",[s.createKeywordTypeNode(v.default.SyntaxKind.AnyKeyword)]),Mo=(e,t,r)=>s.createInterfaceDeclaration(te,e,void 0,t,r),ds=(0,Xt.chain)(([e,t])=>[s.createTypeParameterDeclaration([],e,s.createTypeReferenceNode(t))]),Uo=e=>ds(Object.entries(e)),nr=(e,t,r)=>s.createArrowFunction(r?is:void 0,void 0,e.map(o=>At(o)),void 0,void 0,t),sr=(e,t,r)=>s.createCallExpression(s.createPropertyAccessExpression(s.createCallExpression(s.createPropertyAccessExpression(s.createIdentifier("Object"),"keys"),void 0,[e]),"reduce"),void 0,[s.createArrowFunction(void 0,void 0,Pt({acc:void 0,key:void 0}),void 0,void 0,t),r]),Ho=(...e)=>`"${e.join(" ")}"`,Ko=(e,t,r)=>s.createConditionalExpression(e,s.createToken(v.default.SyntaxKind.QuestionToken),t,s.createToken(v.default.SyntaxKind.ColonToken),r);var Do=["get","post","put","delete","patch"];var g=z(require("typescript"),1),Ct=require("zod");var T=z(require("typescript"),1),{factory:zt}=T.default,ir=(e,t)=>T.default.addSyntheticLeadingComment(e,T.default.SyntaxKind.MultiLineCommentTrivia,`* ${t} `,!0),ge=(e,t,r)=>{let o=zt.createTypeAliasDeclaration(void 0,zt.createIdentifier(t),void 0,e);return r?ir(o,r):o},ar=(e,t)=>{let r=T.default.createSourceFile("print.ts","",T.default.ScriptTarget.Latest,!1,T.default.ScriptKind.TS);return T.default.createPrinter(t).printNode(T.default.EmitHint.Unspecified,e,r)},ls=/^[A-Za-z_$][A-Za-z0-9_$]*$/,Fo=e=>ls.test(e)?zt.createIdentifier(e):zt.createStringLiteral(e),ms=[T.default.SyntaxKind.AnyKeyword,T.default.SyntaxKind.BigIntKeyword,T.default.SyntaxKind.BooleanKeyword,T.default.SyntaxKind.NeverKeyword,T.default.SyntaxKind.NumberKeyword,T.default.SyntaxKind.ObjectKeyword,T.default.SyntaxKind.StringKeyword,T.default.SyntaxKind.SymbolKeyword,T.default.SyntaxKind.UndefinedKeyword,T.default.SyntaxKind.UnknownKeyword,T.default.SyntaxKind.VoidKeyword],Bo=e=>ms.includes(e.kind);var{factory:f}=g.default,us={[g.default.SyntaxKind.AnyKeyword]:"",[g.default.SyntaxKind.BigIntKeyword]:BigInt(0),[g.default.SyntaxKind.BooleanKeyword]:!1,[g.default.SyntaxKind.NumberKeyword]:0,[g.default.SyntaxKind.ObjectKeyword]:{},[g.default.SyntaxKind.StringKeyword]:"",[g.default.SyntaxKind.UndefinedKeyword]:void 0},fs=({value:e})=>f.createLiteralTypeNode(typeof e=="number"?f.createNumericLiteral(e):typeof e=="boolean"?e?f.createTrue():f.createFalse():f.createStringLiteral(e)),ys=({shape:e},{isResponse:t,next:r,optionalPropStyle:{withQuestionMark:o}})=>{let n=Object.entries(e).map(([i,a])=>{let p=t&&Fe(a)?a instanceof Ct.z.ZodOptional:a.isOptional(),d=f.createPropertySignature(void 0,Fo(i),p&&o?f.createToken(g.default.SyntaxKind.QuestionToken):void 0,r(a));return a.description?ir(d,a.description):d});return f.createTypeLiteralNode(n)},gs=({element:e},{next:t})=>f.createArrayTypeNode(t(e)),hs=({options:e})=>f.createUnionTypeNode(e.map(t=>f.createLiteralTypeNode(f.createStringLiteral(t)))),qo=({options:e},{next:t})=>{let r=new Map;for(let o of e){let n=t(o);r.set(Bo(n)?n.kind:n,n)}return f.createUnionTypeNode(Array.from(r.values()))},xs=e=>us?.[e.kind],bs=(e,{next:t,isResponse:r})=>{let o=t(e.innerType());if(r&&e._def.effect.type==="transform"){let n=ot(e,xs(o)),i={number:g.default.SyntaxKind.NumberKeyword,bigint:g.default.SyntaxKind.BigIntKeyword,boolean:g.default.SyntaxKind.BooleanKeyword,string:g.default.SyntaxKind.StringKeyword,undefined:g.default.SyntaxKind.UndefinedKeyword,object:g.default.SyntaxKind.ObjectKeyword};return f.createKeywordTypeNode(n&&i[n]||g.default.SyntaxKind.AnyKeyword)}return o},Ss=e=>f.createUnionTypeNode(Object.values(e.enum).map(t=>f.createLiteralTypeNode(typeof t=="number"?f.createNumericLiteral(t):f.createStringLiteral(t)))),Ts=(e,{next:t,optionalPropStyle:{withUndefined:r}})=>{let o=t(e.unwrap());return r?f.createUnionTypeNode([o,f.createKeywordTypeNode(g.default.SyntaxKind.UndefinedKeyword)]):o},Os=(e,{next:t})=>f.createUnionTypeNode([t(e.unwrap()),f.createLiteralTypeNode(f.createNull())]),Rs=({items:e,_def:{rest:t}},{next:r})=>f.createTupleTypeNode(e.map(r).concat(t===null?[]:f.createRestTypeNode(r(t)))),As=({keySchema:e,valueSchema:t},{next:r})=>f.createExpressionWithTypeArguments(f.createIdentifier("Record"),[e,t].map(r)),Ps=({_def:{left:e,right:t}},{next:r})=>{let o=[e,t].map(r);return o.every(g.default.isTypeLiteralNode)?f.createTypeLiteralNode(o.flatMap(({members:i})=>i)):f.createIntersectionTypeNode(o)},ws=({_def:e},{next:t})=>t(e.innerType),re=e=>()=>f.createKeywordTypeNode(e),zs=(e,{next:t})=>t(e.unwrap()),Cs=(e,{next:t})=>t(e.unwrap()),Is=({_def:e},{next:t})=>t(e.innerType),Zs=({_def:e},{next:t,isResponse:r})=>t(e[r?"out":"in"]),Es=()=>f.createLiteralTypeNode(f.createNull()),vs=(e,{makeAlias:t,next:r})=>t(e,()=>r(e.schema)),js=e=>{let t=e.unwrap(),r=f.createKeywordTypeNode(g.default.SyntaxKind.StringKeyword),o=f.createTypeReferenceNode("Buffer"),n=f.createUnionTypeNode([r,o]);return t instanceof Ct.z.ZodString?r:t instanceof Ct.z.ZodUnion?n:o},Ns=(e,{next:t})=>t(e.unwrap().shape.raw),Ls={ZodString:re(g.default.SyntaxKind.StringKeyword),ZodNumber:re(g.default.SyntaxKind.NumberKeyword),ZodBigInt:re(g.default.SyntaxKind.BigIntKeyword),ZodBoolean:re(g.default.SyntaxKind.BooleanKeyword),ZodAny:re(g.default.SyntaxKind.AnyKeyword),ZodUndefined:re(g.default.SyntaxKind.UndefinedKeyword),[de]:re(g.default.SyntaxKind.StringKeyword),[le]:re(g.default.SyntaxKind.StringKeyword),ZodNull:Es,ZodArray:gs,ZodTuple:Rs,ZodRecord:As,ZodObject:ys,ZodLiteral:fs,ZodIntersection:Ps,ZodUnion:qo,ZodDefault:ws,ZodEnum:hs,ZodNativeEnum:Ss,ZodEffects:bs,ZodOptional:Ts,ZodNullable:Os,ZodDiscriminatedUnion:qo,ZodBranded:zs,ZodCatch:Is,ZodPipeline:Zs,ZodLazy:vs,ZodReadonly:Cs,[D]:js,[ee]:Ns},Qe=(e,{brandHandling:t,ctx:r})=>fe(e,{rules:{...t,...Ls},onMissing:()=>f.createKeywordTypeNode(g.default.SyntaxKind.AnyKeyword),ctx:r});var It=class{program=[];usage=[];registry=new Map;paths=[];aliases=new Map;ids={pathType:s.createIdentifier("Path"),methodType:s.createIdentifier("Method"),methodPathType:s.createIdentifier("MethodPath"),inputInterface:s.createIdentifier("Input"),posResponseInterface:s.createIdentifier("PositiveResponse"),negResponseInterface:s.createIdentifier("NegativeResponse"),responseInterface:s.createIdentifier("Response"),jsonEndpointsConst:s.createIdentifier("jsonEndpoints"),endpointTagsConst:s.createIdentifier("endpointTags"),providerType:s.createIdentifier("Provider"),implementationType:s.createIdentifier("Implementation"),clientClass:s.createIdentifier("ExpressZodAPIClient"),keyParameter:s.createIdentifier("key"),pathParameter:s.createIdentifier("path"),paramsArgument:s.createIdentifier("params"),methodParameter:s.createIdentifier("method"),accumulator:s.createIdentifier("acc"),provideMethod:s.createIdentifier("provide"),implementationArgument:s.createIdentifier("implementation"),headersProperty:s.createIdentifier("headers"),hasBodyConst:s.createIdentifier("hasBody"),undefinedValue:s.createIdentifier("undefined"),bodyProperty:s.createIdentifier("body"),responseConst:s.createIdentifier("response"),searchParamsConst:s.createIdentifier("searchParams"),exampleImplementationConst:s.createIdentifier("exampleImplementation"),clientConst:s.createIdentifier("client"),contentTypeConst:s.createIdentifier("contentType"),isJsonConst:s.createIdentifier("isJSON")};interfaces=[];makeAlias(t,r){let o=this.aliases.get(t)?.name?.text;if(!o){o=`Type${this.aliases.size+1}`;let n=s.createLiteralTypeNode(s.createNull());this.aliases.set(t,ge(n,o)),this.aliases.set(t,ge(r(),o))}return s.createTypeReferenceNode(o)}constructor({routing:t,brandHandling:r,variant:o="client",splitResponse:n=!1,optionalPropStyle:i={withQuestionMark:!0,withUndefined:!0},noContent:a=$o.z.undefined()}){Le({routing:t,onEndpoint:($,H,ne)=>{let he={makeAlias:this.makeAlias.bind(this),optionalPropStyle:i},He=k(ne,H,"input"),Ke=Qe($.getSchema("input"),{brandHandling:r,ctx:{...he,isResponse:!1}}),L=n?k(ne,H,"positive.response"):void 0,pr=$.getResponses("positive").map(({schema:G,mimeTypes:se})=>se?G:a).reduce((G,se)=>G.or(se)),cr=n?Qe(pr,{brandHandling:r,ctx:{...he,isResponse:!0}}):void 0,De=n?k(ne,H,"negative.response"):void 0,dr=$.getResponses("negative").map(({schema:G,mimeTypes:se})=>se?G:a).reduce((G,se)=>G.or(se)),lr=n?Qe(dr,{brandHandling:r,ctx:{...he,isResponse:!0}}):void 0,mr=k(ne,H,"response"),Vo=L&&De?s.createUnionTypeNode([s.createTypeReferenceNode(L),s.createTypeReferenceNode(De)]):Qe(pr.or(dr),{brandHandling:r,ctx:{...he,isResponse:!0}});this.program.push(ge(Ke,He)),cr&&L&&this.program.push(ge(cr,L)),lr&&De&&this.program.push(ge(lr,De)),this.program.push(ge(Vo,mr)),this.paths.push(H),this.registry.set({method:ne,path:H},{input:He,positive:L,negative:De,response:mr,isJson:$.getResponses("positive").some(G=>G.mimeTypes?.includes(A.json)),tags:$.getTags()})}}),this.program.unshift(...this.aliases.values()),this.program.push(or(this.ids.pathType,this.paths)),this.program.push(or(this.ids.methodType,Do)),this.program.push(wt(this.ids.methodPathType,er([this.ids.methodType,this.ids.pathType])));let p=[s.createHeritageClause(j.default.SyntaxKind.ExtendsKeyword,[rr(this.ids.methodPathType,j.default.SyntaxKind.AnyKeyword)])];this.interfaces.push({id:this.ids.inputInterface,kind:"input",props:[]}),n&&this.interfaces.push({id:this.ids.posResponseInterface,kind:"positive",props:[]},{id:this.ids.negResponseInterface,kind:"negative",props:[]}),this.interfaces.push({id:this.ids.responseInterface,kind:"response",props:[]});let d=[],c=[];for(let[{method:$,path:H},{isJson:ne,tags:he,...He}]of this.registry){let Ke=Ho($,H);for(let L of this.interfaces)L.kind in He&&L.props.push(vo(Ke,He[L.kind]));o!=="types"&&(ne&&d.push(s.createPropertyAssignment(Ke,s.createTrue())),c.push(s.createPropertyAssignment(Ke,s.createArrayLiteralExpression(he.map(L=>s.createStringLiteral(L))))))}for(let{id:$,props:H}of this.interfaces)this.program.push(Mo($,p,H));if(o==="types")return;let u=s.createVariableStatement(te,F(this.ids.jsonEndpointsConst,s.createObjectLiteralExpression(d))),m=s.createVariableStatement(te,F(this.ids.endpointTagsConst,s.createObjectLiteralExpression(c))),y=wt(this.ids.providerType,s.createFunctionTypeNode(Uo({M:this.ids.methodType,P:this.ids.pathType}),Pt({method:s.createTypeReferenceNode("M"),path:s.createTypeReferenceNode("P"),params:s.createIndexedAccessTypeNode(s.createTypeReferenceNode(this.ids.inputInterface),tr)}),Lo(this.ids.responseInterface,tr))),b=wt(this.ids.implementationType,s.createFunctionTypeNode(void 0,Pt({method:s.createTypeReferenceNode(this.ids.methodType),path:s.createKeywordTypeNode(j.default.SyntaxKind.StringKeyword),params:rr(j.default.SyntaxKind.StringKeyword,j.default.SyntaxKind.AnyKeyword)}),ko())),O=s.createTemplateExpression(s.createTemplateHead(":"),[s.createTemplateSpan(this.ids.keyParameter,Ye)]),R=sr(this.ids.paramsArgument,s.createCallExpression(s.createPropertyAccessExpression(this.ids.accumulator,"replace"),void 0,[O,s.createElementAccessExpression(this.ids.paramsArgument,this.ids.keyParameter)]),this.ids.pathParameter),h=sr(this.ids.paramsArgument,s.createConditionalExpression(s.createBinaryExpression(s.createCallExpression(s.createPropertyAccessExpression(this.ids.pathParameter,"indexOf"),void 0,[O]),j.default.SyntaxKind.GreaterThanEqualsToken,s.createNumericLiteral(0)),void 0,this.ids.accumulator,void 0,s.createObjectLiteralExpression([s.createSpreadAssignment(this.ids.accumulator),s.createPropertyAssignment(s.createComputedPropertyName(this.ids.keyParameter),s.createElementAccessExpression(this.ids.paramsArgument,this.ids.keyParameter))])),s.createObjectLiteralExpression()),w=No(this.ids.clientClass,Eo([At(this.ids.implementationArgument,s.createTypeReferenceNode(this.ids.implementationType),Zo)]),[jo(this.ids.provideMethod,s.createTypeReferenceNode(this.ids.providerType),nr([this.ids.methodParameter,this.ids.pathParameter,this.ids.paramsArgument],s.createCallExpression(s.createPropertyAccessExpression(s.createThis(),this.ids.implementationArgument),void 0,[this.ids.methodParameter,R,h]),!0))]);this.program.push(u,m,y,b,w);let N=s.createPropertyAssignment(this.ids.methodParameter,s.createCallExpression(s.createPropertyAccessExpression(this.ids.methodParameter,"toUpperCase"),void 0,void 0)),U=s.createPropertyAssignment(this.ids.headersProperty,s.createConditionalExpression(this.ids.hasBodyConst,void 0,s.createObjectLiteralExpression([s.createPropertyAssignment(s.createStringLiteral("Content-Type"),s.createStringLiteral(A.json))]),void 0,this.ids.undefinedValue)),B=s.createPropertyAssignment(this.ids.bodyProperty,s.createConditionalExpression(this.ids.hasBodyConst,void 0,s.createCallExpression(s.createPropertyAccessExpression(s.createIdentifier("JSON"),"stringify"),void 0,[this.ids.paramsArgument]),void 0,this.ids.undefinedValue)),ke=s.createVariableStatement(void 0,F(this.ids.responseConst,s.createAwaitExpression(s.createCallExpression(s.createIdentifier("fetch"),void 0,[s.createTemplateExpression(s.createTemplateHead("https://example.com"),[s.createTemplateSpan(this.ids.pathParameter,s.createTemplateMiddle("")),s.createTemplateSpan(this.ids.searchParamsConst,Ye)]),s.createObjectLiteralExpression([N,U,B])])))),Je=s.createVariableStatement(void 0,F(this.ids.hasBodyConst,s.createLogicalNot(s.createCallExpression(s.createPropertyAccessExpression(s.createArrayLiteralExpression([s.createStringLiteral("get"),s.createStringLiteral("delete")]),"includes"),void 0,[this.ids.methodParameter])))),Zt=s.createVariableStatement(void 0,F(this.ids.searchParamsConst,s.createConditionalExpression(this.ids.hasBodyConst,void 0,s.createStringLiteral(""),void 0,s.createTemplateExpression(s.createTemplateHead("?"),[s.createTemplateSpan(s.createNewExpression(s.createIdentifier("URLSearchParams"),void 0,[this.ids.paramsArgument]),Ye)])))),We=s.createVariableStatement(void 0,F(this.ids.contentTypeConst,s.createCallExpression(s.createPropertyAccessExpression(s.createPropertyAccessExpression(this.ids.responseConst,this.ids.headersProperty),s.createIdentifier("get")),void 0,[s.createStringLiteral("content-type")]))),q=s.createIfStatement(s.createPrefixUnaryExpression(j.default.SyntaxKind.ExclamationToken,this.ids.contentTypeConst),s.createReturnStatement(void 0),void 0),oe=s.createVariableStatement(void 0,F(this.ids.isJsonConst,s.createCallChain(s.createPropertyAccessChain(this.ids.contentTypeConst,void 0,s.createIdentifier("startsWith")),void 0,void 0,[s.createStringLiteral(A.json)]))),Me=s.createReturnStatement(s.createCallExpression(s.createElementAccessExpression(this.ids.responseConst,Ko(this.ids.isJsonConst,s.createStringLiteral("json"),s.createStringLiteral("text"))),void 0,[])),Et=s.createVariableStatement(te,F(this.ids.exampleImplementationConst,nr([this.ids.methodParameter,this.ids.pathParameter,this.ids.paramsArgument],s.createBlock([Je,Zt,ke,We,q,oe,Me]),!0),s.createTypeReferenceNode(this.ids.implementationType))),Xe=s.createExpressionStatement(s.createCallExpression(s.createPropertyAccessExpression(this.ids.clientConst,this.ids.provideMethod),void 0,[s.createStringLiteral("get"),s.createStringLiteral("/v1/user/retrieve"),s.createObjectLiteralExpression([s.createPropertyAssignment("id",s.createStringLiteral("10"))])])),Ue=s.createVariableStatement(void 0,F(this.ids.clientConst,s.createNewExpression(this.ids.clientClass,void 0,[this.ids.exampleImplementationConst])));this.usage.push(Et,Ue,Xe)}printUsage(t){return this.usage.length?this.usage.map(r=>typeof r=="string"?r:ar(r,t)).join(` `):void 0}print(t){let r=this.printUsage(t),o=r&&j.default.addSyntheticLeadingComment(j.default.addSyntheticLeadingComment(s.createEmptyStatement(),j.default.SyntaxKind.SingleLineCommentTrivia," Usage example:"),j.default.SyntaxKind.MultiLineCommentTrivia,` ${r}`);return this.program.concat(o||[]).map((n,i)=>ar(n,ia(p,{filepath:"client.ts"})}catch{}let n=this.printUsage(t);this.usage=n&&o?[await o(n)]:this.usage;let i=this.print(t);return o?o(i):i}};var Go={dateIn:hr,dateOut:br,file:at,upload:Ar,raw:Or};0&&(module.exports={BuiltinLogger,DependsOnMethod,Documentation,DocumentationError,EndpointsFactory,InputValidationError,Integration,Middleware,MissingPeerError,OutputValidationError,ResultHandler,RoutingError,ServeStatic,arrayEndpointsFactory,arrayResultHandler,attachRouting,createConfig,createServer,defaultEndpointsFactory,defaultResultHandler,ensureHttpError,ez,getExamples,getMessageFromError,testEndpoint,testMiddleware});