@hey-api/openapi-ts 0.85.1 → 0.86.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/internal.cjs CHANGED
@@ -1,25 +1 @@
1
- 'use strict';var Pt=require('path'),Ht=require('ansi-colors'),c12=require('c12'),Ko=require('fs'),url=require('url'),b=require('typescript'),os$1=require('os'),hn=require('semver'),codegenCore=require('@hey-api/codegen-core'),jsonSchemaRefParser=require('@hey-api/json-schema-ref-parser');var _documentCurrentScript=typeof document!=='undefined'?document.currentScript:null;function _interopDefault(e){return e&&e.__esModule?e:{default:e}}function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var Pt__default=/*#__PURE__*/_interopDefault(Pt);var Ht__default=/*#__PURE__*/_interopDefault(Ht);var Ko__default=/*#__PURE__*/_interopDefault(Ko);var b__default=/*#__PURE__*/_interopDefault(b);var hn__namespace=/*#__PURE__*/_interopNamespace(hn);var Nc=url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('internal.cjs', document.baseURI).href))),Wo=Pt__default.default.dirname(Nc);var zo=e=>{if(e===null)return null;if(e){let r=Pt__default.default.isAbsolute(e)?e:Pt__default.default.resolve(Wo,e);return Ko__default.default.existsSync(r)?r:null}let t=Wo;for(;t!==Pt__default.default.dirname(t);){let s=Ko__default.default.readdirSync(t).filter(o=>o.startsWith("tsconfig")&&o.endsWith(".json")).sort(o=>o==="tsconfig.json"?-1:1);if(s[0])return Pt__default.default.join(t,s[0]);t=Pt__default.default.dirname(t);}return null},_o=e=>{if(!e)return null;let t=b__default.default.readConfigFile(e,b__default.default.sys.readFile);if(t.error)throw new Error(`Couldn't read tsconfig from path: ${e}`);return b__default.default.parseJsonConfigFileContent(t.config,b__default.default.sys,Pt__default.default.dirname(e))};var rn=e=>{Ko__default.default.existsSync(e)||Ko__default.default.mkdirSync(e,{recursive:true});};var Zt=({moduleOutput:e,sourceOutput:t})=>{let r=t.split("/");return `${Array.from({length:r.length}).fill("").join("../")||"./"}${e}`};var Er=class extends Error{constructor(t){super(t),this.name="ConfigError";}};var nn=class extends Error{args;event;pluginName;constructor({args:t,error:r,event:s,name:o,pluginName:i}){let p=r instanceof Error?r.message:"Unknown error";super(p),this.args=t,this.cause=r.cause,this.event=s,this.name=o||r.name,this.pluginName=i,this.stack=r.stack;}};var ie=e=>{let t=P(e);return t.name==="@hey-api/client-axios"||t.name==="@hey-api/client-nuxt"?"baseURL":"baseUrl"},P=e=>{for(let t of e.pluginOrder){let r=e.plugins[t];if(r?.tags?.includes("client"))return r}return {config:{name:""},name:""}};var Qo,I=()=>{let e=Qo,t=P(e);return e.client=t,e},Zo=e=>(Qo=e,I()),U=e=>P(e).name.startsWith("legacy/"),Et=e=>{if(U(e))return e.name};var Cc=/^([\w-]+)\/([\w-]+)(?:\?([\w=&.-]*))?$/,Ut="https://get.heyapi.dev",vc=(e,t,r)=>`${Ut}/${e}/${t}${r?`?${r}`:""}`,wc=e=>{let t=e.organization,r=e.project,s;if(e.path){let i=e.path.match(Cc);if(!i)throw new Error(`Invalid Hey API shorthand format. Expected "organization/project?queryParams" or "organization/project", received: ${e.path}`);t=i[1],r=i[2],s=i[3];}if(!t)throw new Error("The Hey API organization cannot be empty.");if(!r)throw new Error("The Hey API project cannot be empty.");return {organization:t,project:r,queryParams:s}},Vs=e=>{let t=wc(e);return {path:vc(t.organization,t.project,t.queryParams),registry:"hey-api"}};var qc=/^(@([\w-]+)\/([\w\-.]+)#)?([\w-]+)$/,$c=e=>`https://dash.readme.com/api/v1/api-registry/${e}`,sn="readme",Mc=e=>{let t=e.match(qc);if(!t)throw new Error(`Invalid ReadMe shorthand format. Expected "${sn}:@organization/project#uuid" or "${sn}:uuid", received: ${sn}:${e}`);let[,,r,s,o]=t;if(!o)throw new Error("The ReadMe UUID cannot be empty.");return {organization:r,project:s,uuid:o}},Uo=e=>{let t=e.slice(`${sn}:`.length),r=Mc(t);return {...r,path:$c(r.uuid),registry:"readme"}};var Lc=/^(@[\w-]+)\/([\w.-]+)$/,Vc=(e,t)=>`https://registry.scalar.com/${e}/apis/${t}/latest?format=json`,Ds="scalar",Dc=e=>{let t=e.match(Lc);if(!t)throw new Error(`Invalid Scalar shorthand format. Expected "${Ds}:@organization/project", received: ${Ds}:${e}`);let[,r,s]=t;if(!r)throw new Error("The Scalar organization cannot be empty.");if(!s)throw new Error("The Scalar project cannot be empty.");return {organization:r,project:s}},Xo=e=>{let t=e.slice(`${Ds}:`.length),r=Dc(t);return {...r,path:Vc(r.organization,r.project),registry:"scalar"}};var Jo=e=>{if(e.path.startsWith("readme:")){Object.assign(e,Uo(e.path));return}if(e.path.startsWith("scalar:")){Object.assign(e,Xo(e.path));return}if(e.path.startsWith("."))return;if(e.path.startsWith(Ut)){e.path=e.path.slice(Ut.length+1),Object.assign(e,Vs(e));return}let t=e.path.split("/");if(t.length===2&&t.filter(Boolean).length===2){Object.assign(e,Vs(e));return}};var Ir={enabled:false,interval:1e3,timeout:6e4},Go=e=>{let t={...Ir};return typeof e.path!="string"||(typeof e.watch=="boolean"?t.enabled=e.watch:typeof e.watch=="number"?(t.enabled=true,t.interval=e.watch):e.watch&&(t={...t,...e.watch})),t},Fs=e=>{let t=e.input instanceof Array?e.input:[e.input],r=[];for(let s of t){let o={path:"",watch:Ir};typeof s=="string"?o.path=s:s&&(s.path!==void 0||s.organization!==void 0)?(o={...o,path:Ut,...s},o.watch!==void 0&&(o.watch=Go(o))):o={...o,path:s},typeof o.path=="string"&&Jo(o),e.watch!==void 0&&o.watch.enabled===Ir.enabled&&o.watch.interval===Ir.interval&&o.watch.timeout===Ir.timeout&&(o.watch=Go({path:o.path,watch:e.watch})),o.path&&r.push(o);}return r};var Yo=e=>{let t={file:true,level:"info",path:process.cwd()};return typeof e?.logs=="string"?t.path=e.logs:t={...t,...e?.logs},t};var Fc=(e,t)=>({...e||{},...t||{}}),Bs=(e,t)=>{let r=e||{},s=t||{},o={...r,...s};return typeof o.logs=="object"&&(o.logs=Fc(r.logs,s.logs)),o};var Bc=e=>typeof e=="object"&&e!==null&&!Array.isArray(e)&&typeof e!="function",Xt=(e,t)=>{for(let[r,s]of Object.entries(t))s!==void 0&&s!==""&&(e[r]=s);return e},me=({defaultValue:e,mappers:t,value:r})=>{let s={...e};switch(typeof r){case "boolean":if(t&&"boolean"in t){let o=t.boolean;s=Xt(s,o(r));}break;case "function":if(t&&"function"in t){let o=t.function;s=Xt(s,o(r));}break;case "number":if(t&&"number"in t){let o=t.number;s=Xt(s,o(r));}break;case "string":if(t&&"string"in t){let o=t.string;s=Xt(s,o(r));}break;case "object":if(Bc(r))if(t&&"object"in t&&typeof t.object=="function"){let o=t.object;s=Xt(s,o(r,e));}else s=Xt(s,r);break}return s};var ei=e=>{if(e.output instanceof Array)throw new Error("Unexpected array of outputs in user configuration. This should have been expanded already.");let t=me({defaultValue:{clean:true,fileName:{case:"preserve",name:"{{name}}",suffix:".gen"},format:null,indexFile:true,lint:null,path:""},mappers:{object:(r,s)=>({...r,fileName:me({defaultValue:{...s.fileName},mappers:{function:o=>({name:o}),string:o=>({name:o})},value:r.fileName})}),string:r=>({path:r})},value:e.output});return t.tsConfig=_o(zo(t.tsConfigPath)),t.importFileExtension===void 0&&t.tsConfig?.options.moduleResolution===b__default.default.ModuleResolutionKind.NodeNext&&(t.importFileExtension=".js"),t.importFileExtension&&!t.importFileExtension.startsWith(".")&&(t.importFileExtension=`.${t.importFileExtension}`),t};var ri=e=>{let t=e?Pt__default.default.dirname(e):process.cwd();for(;t!==Pt__default.default.dirname(t);){let r=Pt__default.default.join(t,"package.json");if(Ko__default.default.existsSync(r))try{let o=JSON.parse(Ko__default.default.readFileSync(r,"utf8"));return {...o.dependencies,...o.devDependencies,...o.peerDependencies,...o.optionalDependencies}}catch{}let s=Pt__default.default.dirname(t);if(s===t)break;t=s;}return {}};var Wc=["after","before","cursor","offset","page","start"],ni=e=>me({defaultValue:{hooks:{},pagination:{keywords:Wc},transforms:{enums:{case:"PascalCase",enabled:false,mode:"root",name:"{{name}}Enum"},propertiesRequiredByDefault:false,readWrite:{enabled:true,requests:{case:"preserve",name:"{{name}}Writable"},responses:{case:"preserve",name:"{{name}}"}}},validate_EXPERIMENTAL:false},mappers:{object:(r,s)=>({...r,pagination:me({defaultValue:{...s.pagination},value:r.pagination}),transforms:me({defaultValue:{...s.transforms},mappers:{object:(o,i)=>({...o,enums:me({defaultValue:{...i.enums,enabled:o.enums!==void 0?!!o.enums:i.enums.enabled},mappers:{boolean:p=>({enabled:p}),string:p=>({mode:p})},value:o.enums}),propertiesRequiredByDefault:o.propertiesRequiredByDefault!==void 0?o.propertiesRequiredByDefault:i.propertiesRequiredByDefault,readWrite:me({defaultValue:{...i.readWrite,enabled:o.readWrite!==void 0?!!o.readWrite:i.readWrite.enabled},mappers:{boolean:p=>({enabled:p}),object:(p,a)=>({...p,requests:me({defaultValue:{...a.requests},mappers:{function:c=>({name:c}),string:c=>({name:c})},value:p.requests}),responses:me({defaultValue:{...a.responses},mappers:{function:c=>({name:c}),string:c=>({name:c})},value:p.responses})})},value:o.readWrite})})},value:r.transforms}),validate_EXPERIMENTAL:r.validate_EXPERIMENTAL===true?"warn":r.validate_EXPERIMENTAL})},value:e.parser});var je={boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})};var an=class{constructor(t){this.meta=t;}getSelector(...t){return [this.meta.name,...t]}};var si=/[\p{Lu}]/u,Ks=/[\p{Ll}]/u,ii=/([\p{Alpha}\p{N}_]|$)/u,Jt=/[_.\- `\\[\]{}\\/]+/,zc=new RegExp(`^${Jt.source}`),Ws=new RegExp(`${Jt.source}${ii.source}`,"gu"),oi=new RegExp(`\\d+${ii.source}`,"gu"),_c=({case:e,string:t})=>{let r=false,s=false,o=false,i=false,p=e==="snake_case"||e==="SCREAMING_SNAKE_CASE"?"_":"-";for(let a=0;a<t.length;a++){let c=t[a];i=a>2?t[a-3]===p:true;let m=a+1,l=t[m];for(Jt.lastIndex=0;l&&Jt.test(l);)m+=1,l=t[m];let f=m!==a+1;if(Ks.lastIndex=0,si.lastIndex=0,si.test(c)&&(r||l&&!f&&l!=="s"&&Ks.test(l)))t=`${t.slice(0,a)}${p}${t.slice(a)}`,a++,o=s,r=false,s=true;else if(s&&o&&Ks.test(c)&&!i&&!(c==="s"&&(!l||l.toLocaleLowerCase()!==l)))t=`${t.slice(0,a-1)}${p}${t.slice(a-1)}`,o=s,r=true,s=false;else {let d=c.toLocaleLowerCase(),y=c.toLocaleUpperCase();o=s,r=d===c&&y!==c,s=y===c&&d!==c;}}return t},q=({case:e,stripLeadingSeparators:t=true,value:r})=>{let s=r.trim();return s.length?!e||e==="preserve"?s:s.length===1?(Jt.lastIndex=0,Jt.test(s)?"":e==="PascalCase"||e==="SCREAMING_SNAKE_CASE"?s.toLocaleUpperCase():s.toLocaleLowerCase()):(s!==s.toLocaleLowerCase()&&(s=_c({case:e,string:s})),(t||s[0]!==r[0])&&(s=s.replace(zc,"")),s=e==="SCREAMING_SNAKE_CASE"?s.toLocaleUpperCase():s.toLocaleLowerCase(),e==="PascalCase"&&(s=`${s.charAt(0).toLocaleUpperCase()}${s.slice(1)}`),e==="snake_case"||e==="SCREAMING_SNAKE_CASE"?(s=s.replaceAll(Ws,(i,p,a)=>a===0&&!t?i:`_${p}`),s[s.length-1]==="_"&&(s=s.slice(0,s.length-1))):(Ws.lastIndex=0,oi.lastIndex=0,s=s.replaceAll(oi,(i,p,a)=>["_","-","."].includes(s.charAt(a+i.length))?i:i.toLocaleUpperCase()),s=s.replaceAll(Ws,(i,p,a)=>a===0&&!t&&i[0]&&r.startsWith(i[0])?i:p.toLocaleUpperCase())),s):""};var O=({config:e,name:t})=>{if(typeof e.name=="function")t=e.name(t);else if(e.name){let r=e.case==="preserve"?"":"-";t=e.name.replace("{{name}}",`${r}${t}${r}`);}return q({case:e.case,value:t})};var Gt=/^[^$_\p{ID_Start}]+/u,X=/^-?\d+(\.\d+)?$/,ai=/^(document|history|location|navigator|window)$/g,pi=/^(console|Array|Date|Error|Function|JSON|Map|Math|Object|Promise|RegExp|Set|WeakMap|WeakSet)$/g,ue=/^(arguments|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|eval|export|extends|false|finally|for|from|function|if|implements|import|in|instanceof|interface|let|new|null|package|private|protected|public|return|static|super|switch|this|throw|true|try|typeof|var|void|while|with|yield)$/g,ci=/^(global|process|Buffer)$/g,mi=/^(any|as|bigint|boolean|namespace|never|null|number|string|symbol|type|undefined|unknown|void)$/g,Ae=/^[$_\p{ID_Start}][$\u200c\u200d\p{ID_Continue}]*$/u;var Xe=e=>(e||e==="")&&(Ae.lastIndex=0,!Ae.test(e))?`'${e}'`:e,kr=e=>e&&e.startsWith("'")&&e.endsWith("'")?e.slice(1,e.length-1):e,K=e=>e.replace(/\*\//g,"*").replace(/\/\*/g,"*").replace(/\r?\n(.*)/g,(t,r)=>os$1.EOL+r.trim());var Qc=b__default.default.createPrinter({newLine:b__default.default.NewLineKind.LineFeed,removeComments:false}),Zc=e=>b__default.default.createSourceFile("",e,b__default.default.ScriptTarget.ESNext,false,b__default.default.ScriptKind.TS),Uc=Zc(""),Xc=e=>e.replace(/\\u([0-9a-fA-F]{4})/g,(t,r)=>String.fromCharCode(Number.parseInt(r,16)));function se({node:e,unescape:t=false}){let r=Qc.printNode(b__default.default.EmitHint.Unspecified,e,Uc);if(!t)return r;try{return Xc(r)}catch{return I().logs.level==="debug"&&console.warn("Could not decode value:",r),r}}var A=({text:e})=>b__default.default.factory.createIdentifier(e),li=()=>b__default.default.factory.createThis(),H=({keyword:e})=>{let t=zs({keyword:e});return b__default.default.factory.createModifier(t)},fi=({initializer:e,modifier:t,name:r,type:s})=>b__default.default.factory.createPropertyDeclaration(t?[H({keyword:t})]:void 0,r,void 0,s,e),le={boolean:e=>e?b__default.default.factory.createTrue():b__default.default.factory.createFalse(),export:({alias:e,asType:t=false,name:r})=>{let s=A({text:r});if(e){let o=A({text:e});return b__default.default.factory.createExportSpecifier(t,s,o)}return b__default.default.factory.createExportSpecifier(t,void 0,s)},import:({alias:e,asType:t=false,name:r})=>{let s=A({text:r});if(e){let o=A({text:e});return b__default.default.factory.createImportSpecifier(t,s,o)}return b__default.default.factory.createImportSpecifier(t,void 0,s)},number:e=>e<0?b__default.default.factory.createPrefixUnaryExpression(b__default.default.SyntaxKind.MinusToken,b__default.default.factory.createNumericLiteral(Math.abs(e))):b__default.default.factory.createNumericLiteral(e),string:(e,t=false)=>{let r=e;t&&(r=kr(r));let s=r.includes("'")&&r.includes('"'),o=r.includes(`
2
- `),i=r.startsWith("`"),p=r.startsWith("\\`")&&r.endsWith("\\`");return (o||s||i)&&!p&&(r=`\`${r.replace(/(?<!\\)`/g,"\\`").replace(/\${/g,"\\${")}\``),r.startsWith("`")?A({text:r}):kt({text:r})}},It=e=>e!==null&&typeof e=="object"&&typeof e.kind=="number"&&typeof e.flags=="number"&&typeof e.pos=="number"&&typeof e.end=="number",dt=e=>e!==void 0,Jc=({commentObject:e,node:t})=>{let r=e.lines.filter(p=>!!p||p==="");if(!r.length)return;if(!e.jsdoc){for(let p of r)b__default.default.addSyntheticLeadingComment(t,b__default.default.SyntaxKind.SingleLineCommentTrivia,` ${p}`,true);return}let s=r.map((p,a)=>{let c=p;return a!==r.length&&(c=`${c}
3
- `),b__default.default.factory.createJSDocText(c)}),o=b__default.default.factory.createJSDocComment(b__default.default.factory.createNodeArray(s),void 0),i=se({node:o,unescape:true}).replace("/*","").replace("* */","");b__default.default.addSyntheticLeadingComment(t,b__default.default.SyntaxKind.MultiLineCommentTrivia,i,true);},ee=({comments:e=[],node:t})=>{let r=!!e.find(o=>typeof o=="object"&&o),s=e;r||(s=[{jsdoc:true,lines:e}]);for(let o of s)Jc({commentObject:o,node:t});};var te=(e,t)=>b__default.default.isTypeNode(e)?e:typeof e=="number"?b__default.default.factory.createLiteralTypeNode(le.number(e)):ye({typeArguments:t?.map(r=>te(r)),typeName:b__default.default.isIdentifier(e)?e.text:e}),_s=({expression:e,name:t})=>b__default.default.factory.createPropertyAccessChain(e,b__default.default.factory.createToken(b__default.default.SyntaxKind.QuestionDotToken),t),Ce=({expression:e,isOptional:t,name:r})=>{let s=typeof e=="string"?A({text:e}):e;if(t&&typeof r!="number")return _s({expression:s,name:r});if(typeof r=="string"){if(Ae.lastIndex=0,!Ae.test(r)){!r.startsWith("'")&&!r.endsWith("'")&&(r=`'${r}'`);let i=A({text:r});return b__default.default.factory.createElementAccessExpression(s,i)}let o=A({text:r});return b__default.default.factory.createPropertyAccessExpression(s,o)}if(typeof r=="number"){let o=b__default.default.factory.createNumericLiteral(r);return b__default.default.factory.createElementAccessExpression(s,o)}return b__default.default.factory.createPropertyAccessExpression(s,r)},Hs=()=>b__default.default.factory.createNull(),Ne=({identifiers:e=[],isValueAccess:t,shorthand:r,unescape:s,value:o})=>{if(o===null)return Hs();if(Array.isArray(o))return Qs({elements:o});if(typeof o=="object")return ln({identifiers:e,obj:o,shorthand:r});if(typeof o=="number")return le.number(o);if(typeof o=="boolean")return le.boolean(o);if(typeof o=="string"){if(t){let i=o.split(".");return Ce({expression:i[0],name:i[1]})}return le.string(o,s)}},jr=e=>e.map(t=>{if("destructure"in t)return Yt({name:b__default.default.factory.createObjectBindingPattern(t.destructure.map(s=>"destructure"in s?void 0:b__default.default.factory.createBindingElement(void 0,void 0,A({text:s.name}),void 0)).filter(Boolean)),type:t.type!==void 0?te(t.type):void 0});let r=t.accessLevel?[H({keyword:t.accessLevel})]:[];return t.isReadOnly&&r.push(H({keyword:"readonly"})),Yt({initializer:t.default!==void 0?Ne({value:t.default}):void 0,modifiers:r,name:A({text:t.name}),required:t.isRequired!==false,type:t.type!==void 0?te(t.type):void 0})}),zs=({keyword:e})=>{switch(e){case "any":return b__default.default.SyntaxKind.AnyKeyword;case "async":return b__default.default.SyntaxKind.AsyncKeyword;case "boolean":return b__default.default.SyntaxKind.BooleanKeyword;case "export":return b__default.default.SyntaxKind.ExportKeyword;case "never":return b__default.default.SyntaxKind.NeverKeyword;case "number":return b__default.default.SyntaxKind.NumberKeyword;case "private":return b__default.default.SyntaxKind.PrivateKeyword;case "protected":return b__default.default.SyntaxKind.ProtectedKeyword;case "public":return b__default.default.SyntaxKind.PublicKeyword;case "readonly":return b__default.default.SyntaxKind.ReadonlyKeyword;case "static":return b__default.default.SyntaxKind.StaticKeyword;case "string":return b__default.default.SyntaxKind.StringKeyword;case "undefined":return b__default.default.SyntaxKind.UndefinedKeyword;case "unknown":return b__default.default.SyntaxKind.UnknownKeyword;case "void":return b__default.default.SyntaxKind.VoidKeyword;default:throw new Error(`unsupported syntax kind keyword "${e}"`)}},jt=({keyword:e})=>{let t=zs({keyword:e});return b__default.default.factory.createKeywordTypeNode(t)},Nr=e=>e.map(t=>b__default.default.isTypeParameterDeclaration(t)?t:Cr({constraint:t.extends?typeof t.extends=="string"?jt({keyword:"boolean"}):t.extends:void 0,defaultType:t.default!==void 0?It(t.default)?t.default:b__default.default.factory.createLiteralTypeNode(t.default?b__default.default.factory.createTrue():b__default.default.factory.createFalse()):void 0,name:t.name})),di=({operator:e,type:t})=>{let r=e==="keyof"?b__default.default.SyntaxKind.KeyOfKeyword:e==="readonly"?b__default.default.SyntaxKind.ReadonlyKeyword:b__default.default.SyntaxKind.UniqueKeyword;return b__default.default.factory.createTypeOperatorNode(r,t)},Cr=({constraint:e,defaultType:t,modifiers:r,name:s})=>b__default.default.factory.createTypeParameterDeclaration(r,s,e,t),cn=({members:e,nameType:t,questionToken:r,readonlyToken:s,type:o,typeParameter:i})=>b__default.default.factory.createMappedTypeNode(s,i,t,r,o,e),ui=({literal:e})=>b__default.default.factory.createLiteralTypeNode(e),mn=({async:e,comment:t,multiLine:r,parameters:s=[],returnType:o,statements:i=[],types:p=[]})=>{let a=b__default.default.factory.createArrowFunction(e?[H({keyword:"async"})]:void 0,p?Nr(p):void 0,jr(s),o?te(o):void 0,void 0,Array.isArray(i)?fe({multiLine:r,statements:i}):i);return ee({comments:t,node:a}),a},yi=({async:e,comment:t,multiLine:r,parameters:s=[],returnType:o,statements:i=[],types:p=[]})=>{let a=b__default.default.factory.createFunctionExpression(e?[H({keyword:"async"})]:void 0,void 0,void 0,p?Nr(p):void 0,jr(s),o?te(o):void 0,fe({multiLine:r,statements:i}));return ee({comments:t,node:a}),a},Qs=({elements:e,multiLine:t=false})=>b__default.default.factory.createArrayLiteralExpression(e.map(s=>It(s)?s:Ne({value:s})).filter(dt),t||!Array.isArray(e[0])&&typeof e[0]=="object"),hi=({expression:e})=>b__default.default.factory.createAwaitExpression(e),gi=({parameters:e=[],returnType:t,typeParameters:r})=>b__default.default.factory.createFunctionTypeNode(r,e,t),ln=({comments:e,identifiers:t=[],multiLine:r=true,obj:s,shorthand:o,unescape:i=false})=>{let p=Array.isArray(s)?s.map(c=>{let m=false;if("key"in c){let{key:f}=c;m=f===c.value,(f.match(/^[0-9]/)&&f.match(/\D+/g)||f.match(/\W/g)||f==="")&&!f.startsWith("'")&&!f.endsWith("'")&&(c.key=`'${f}'`);}let l;if("spread"in c){let f=It(c.spread)?c.spread:A({text:c.spread});l=b__default.default.factory.createSpreadAssignment(c.assertion?wr({expression:f,type:typeof c.assertion=="string"?jt({keyword:c.assertion}):c.assertion}):f);}else if(c.shorthand||o&&m)l=b__default.default.factory.createShorthandPropertyAssignment(c.value);else {let f=It(c.value)?c.value:Array.isArray(c.value)&&(!c.value.length||typeof c.value[0]=="object")?ln({multiLine:r,obj:c.value,shorthand:o,unescape:i}):Ne({identifiers:t.includes(c.key)?Object.keys(c.value):[],isValueAccess:c.isValueAccess,shorthand:o,unescape:i,value:c.value});if(!f)return;t.includes(c.key)&&!b__default.default.isObjectLiteralExpression(f)&&(f=A({text:c.value})),l=pn({initializer:f,name:c.key});}return ee({comments:c.comments,node:l}),l}).filter(dt):Object.entries(s).map(([c,m])=>{let l=Ne({identifiers:t.includes(c)?Object.keys(m):[],shorthand:o,unescape:i,value:m});if(!l)return;t.includes(c)&&!b__default.default.isObjectLiteralExpression(l)&&(l=A({text:m}));let f=c===m;return c.match(/^[0-9]/)&&c.match(/\D+/g)&&!c.startsWith("'")&&!c.endsWith("'")&&(c=`'${c}'`),c.match(/\W/g)&&!c.startsWith("'")&&!c.endsWith("'")&&(c=`'${c}'`),o&&f?b__default.default.factory.createShorthandPropertyAssignment(m):pn({initializer:l,name:c})}).filter(dt),a=b__default.default.factory.createObjectLiteralExpression(p,r);return ee({comments:e,node:a}),a},xi=({asConst:e,comments:t={},leadingComment:r,name:s,obj:o})=>{let i=Array.isArray(o)?o.map(l=>{let f=Yc({initializer:Ne({value:l.value}),name:l.key});return ee({comments:l.comments,node:f}),f}):Object.entries(o).map(([l,f])=>{let d=b__default.default.factory.createEnumMember(l,Ne({unescape:true,value:f}));return ee({comments:t[l],node:d}),d}),p=[H({keyword:"export"})],a=e?[b__default.default.factory.createToken(b__default.default.SyntaxKind.ConstKeyword)]:[],c=[...p,...a],m=b__default.default.factory.createEnumDeclaration(c,typeof s=="string"?A({text:s}):s,i);return ee({comments:r,node:m}),m},Yc=({initializer:e,name:t})=>{let r=t;return typeof r=="string"&&(r.includes("'")?r=kt({isSingleQuote:false,text:r}):r=Xe(r)),b__default.default.factory.createEnumMember(r,e)},bi=({name:e,statements:t})=>b__default.default.factory.createModuleDeclaration([H({keyword:"export"})],A({text:e}),b__default.default.factory.createModuleBlock(t),b__default.default.NodeFlags.Namespace),Si=({indexType:e,objectType:t})=>b__default.default.factory.createIndexedAccessTypeNode(t,e),Oi=({name:e,returnType:t,statements:r})=>b__default.default.factory.createGetAccessorDeclaration(void 0,e,[],t?ye({typeName:t}):void 0,fe({statements:r})),kt=({isSingleQuote:e,text:t})=>(e===void 0&&(e=!t.includes("'")),b__default.default.factory.createStringLiteral(t,e)),Ti=({condition:e,whenFalse:t,whenTrue:r})=>b__default.default.factory.createConditionalExpression(e,b__default.default.factory.createToken(b__default.default.SyntaxKind.QuestionToken),r,b__default.default.factory.createToken(b__default.default.SyntaxKind.ColonToken),t),Ri=({text:e})=>b__default.default.factory.createTypeOfExpression(typeof e=="string"?A({text:e}):e),Ai=({comment:e,exportType:t,name:r,type:s,typeParameters:o=[]})=>{let i=b__default.default.factory.createTypeAliasDeclaration(t?[H({keyword:"export"})]:void 0,typeof r=="string"?A({text:r}):r,Nr(o),te(s));return ee({comments:e,node:i}),i},ye=({typeArguments:e,typeName:t})=>b__default.default.factory.createTypeReferenceNode(t,e),Pi=({type:e})=>b__default.default.factory.createParenthesizedType(e),Yt=({initializer:e,modifiers:t,name:r,required:s=true,type:o})=>b__default.default.factory.createParameterDeclaration(t,void 0,r,s?void 0:b__default.default.factory.createToken(b__default.default.SyntaxKind.QuestionToken),o,e),vr=({argumentsArray:e,expression:t,typeArguments:r})=>b__default.default.factory.createNewExpression(t,r,e),Ei=({awaitModifier:e,expression:t,initializer:r,statement:s})=>b__default.default.factory.createForOfStatement(e,r,t,s),Ii=({left:e,right:t})=>b__default.default.factory.createAssignment(e,t),fe=({multiLine:e=true,statements:t})=>b__default.default.factory.createBlock(t,e),pn=({initializer:e,name:t})=>b__default.default.factory.createPropertyAssignment(t,e),ki=({flags:e=[],text:t})=>{let o=`/${(t.startsWith("/")&&t.endsWith("/")?t.slice(1,-1):t).replace(/(?<!\\)\//g,"\\/")}/`;return b__default.default.factory.createRegularExpressionLiteral(`${o}${e.join("")}`)},wr=({expression:e,type:t})=>b__default.default.factory.createAsExpression(e,t),ji=({value:e})=>{let t=[],r="";for(let o of e.slice(0).reverse())if(typeof o=="string")r=`${o}${r}`;else {let i=t.length?b__default.default.factory.createTemplateMiddle(r):b__default.default.factory.createTemplateTail(r),p=b__default.default.factory.createTemplateLiteralTypeSpan(o,i);t.push(p),r="";}return b__default.default.factory.createTemplateLiteralType(b__default.default.factory.createTemplateHead(r),t.reverse())};var Ni=({module:e,shouldAppendJs:t})=>b__default.default.factory.createExportDeclaration(void 0,false,void 0,le.string(t?`${e}.js`:e)),ve=({functionName:e,parameters:t=[],types:r})=>{let s=typeof e=="string"?A({text:e}):e,o=t.filter(p=>p!==void 0).map(p=>typeof p=="string"?A({text:p}):p);return b__default.default.factory.createCallExpression(s,r,o)},Ci=({exports:e,module:t})=>{let r=Array.isArray(e)?e:[e],s=r.some(c=>typeof c!="object"||!c.asType),o=r.map(c=>{let m=typeof c=="string"?{name:c}:c;return le.export({alias:m.alias,asType:s&&m.asType,name:m.name})}),i=b__default.default.factory.createNamedExports(o),p=le.string(t);return b__default.default.factory.createExportDeclaration(void 0,!s,i,p)},vi=({assertion:e,comment:t,destructure:r,exportConst:s,expression:o,name:i,typeName:p})=>{let a=e?wr({expression:o,type:typeof e=="string"?ye({typeName:e}):e}):o,c=typeof i=="string"?A({text:i}):i,m=b__default.default.factory.createVariableDeclaration(r?b__default.default.factory.createObjectBindingPattern([b__default.default.factory.createBindingElement(void 0,void 0,c,void 0)]):c,void 0,p?typeof p=="string"?ye({typeName:p}):p:void 0,a),l=b__default.default.factory.createVariableStatement(s?[H({keyword:"export"})]:void 0,b__default.default.factory.createVariableDeclarationList([m],b__default.default.NodeFlags.Const));return ee({comments:t,node:l}),l},wi=({imports:e,module:t})=>{let r=Array.isArray(e)?e:[e],s=r.some(l=>typeof l!="object"||!l.asType),o,i=[];r.forEach(l=>{let f=typeof l=="string"?{name:l}:l;f.name==="*"&&f.alias?o=f:i.push(le.import({alias:f.alias,asType:s&&f.asType,name:f.name}));});let p=o?b__default.default.factory.createNamespaceImport(A({text:o.alias})):b__default.default.factory.createNamedImports(i),a=b__default.default.factory.createImportClause(!s,void 0,p),c=le.string(t);return b__default.default.factory.createImportDeclaration(void 0,a,c)};var qi=({accessLevel:e,comment:t,multiLine:r=true,parameters:s=[],statements:o=[]})=>{let i=e?[H({keyword:e})]:void 0,p=b__default.default.factory.createConstructorDeclaration(i,jr(s),fe({multiLine:r,statements:o}));return ee({comments:t,node:p}),p},$i=({accessLevel:e,comment:t,isStatic:r=false,multiLine:s=true,name:o,parameters:i=[],returnType:p,statements:a=[],types:c=[]})=>{let m=e?[H({keyword:e})]:[];r&&m.push(H({keyword:"static"}));let l=b__default.default.factory.createMethodDeclaration(m,void 0,A({text:o}),void 0,c?Nr(c):void 0,jr(i),p?te(p):void 0,fe({multiLine:s,statements:a}));return ee({comments:t,node:l}),l},Mi=({decorator:e,exportClass:t,extendedClasses:r,name:s,nodes:o})=>{let i=[];t&&i.push(H({keyword:"export"})),e&&i.unshift(b__default.default.factory.createDecorator(ve({functionName:e.name,parameters:e.args.map(a=>Ne({value:a})).filter(dt)})));let p=[];if(r)for(let a of r)p.push(b__default.default.factory.createHeritageClause(b__default.default.SyntaxKind.ExtendsKeyword,[b__default.default.factory.createExpressionWithTypeArguments(A({text:a}),void 0)]));return b__default.default.factory.createClassDeclaration(i,A({text:s}),void 0,p,o)};var Ct=({expression:e})=>b__default.default.factory.createExpressionStatement(e);var fn=({expression:e})=>b__default.default.factory.createReturnStatement(e),Vi=({args:e=[],name:t,types:r=[]})=>{let s=r.map(a=>ye({typeName:a})),o=e.map(a=>b__default.default.isExpression(a)?a:A({text:a})).filter(dt),i=ve({functionName:t,parameters:o,types:s});return fn({expression:i})},Di=({expression:e})=>fn({expression:typeof e=="string"?A({text:e}):e});var er=e=>e.slice(1).reduce((t,r)=>(Ae.lastIndex=0,Ae.test(r)?_s({expression:t,name:r}):b__default.default.factory.createElementAccessChain(t,b__default.default.factory.createToken(b__default.default.SyntaxKind.QuestionDotToken),A({text:r}))),A({text:e[0]})),dn=e=>e.slice(1).reduce((t,r)=>Ce({expression:t,name:r}),A({text:e[0]})),Fi=({expressions:e})=>e.reduce((r,s)=>Ce({expression:r,name:s})),un=({left:e,operator:t="=",right:r})=>b__default.default.factory.createBinaryExpression(e,t==="="?b__default.default.SyntaxKind.EqualsToken:t==="==="?b__default.default.SyntaxKind.EqualsEqualsEqualsToken:t==="!=="?b__default.default.SyntaxKind.ExclamationEqualsEqualsToken:t==="??"?b__default.default.SyntaxKind.QuestionQuestionToken:b__default.default.SyntaxKind.InKeyword,typeof r=="string"?A({text:r}):r),tr=({elseStatement:e,expression:t,thenStatement:r})=>b__default.default.factory.createIfStatement(t,r,e),Bi=({path:e})=>{let t=er(e),r=dn(e),s=fe({statements:[Ct({expression:un({left:r,right:vr({argumentsArray:[r],expression:A({text:"Date"})})})})]});return tr({expression:t,thenStatement:s})},Ki=({path:e,transformerName:t})=>{let r=er(e),s=dn(e),o=fe({statements:[Ct({expression:ve({functionName:t,parameters:[s]})})]});return [tr({expression:r,thenStatement:o})]},Wi=({path:e,transformerName:t})=>{let r=er(e),s=dn(e);return tr({expression:ve({functionName:Ce({expression:"Array",name:"isArray"}),parameters:[r]}),thenStatement:fe({statements:[Ct({expression:b__default.default.factory.createCallChain(Ce({expression:s,name:"forEach"}),void 0,void 0,[A({text:t})])})]})})},zi=({parameterName:e})=>{let t=A({text:"Date"});return vr({argumentsArray:[A({text:e})],expression:t})},_i=({path:e,transformExpression:t})=>{let r=er(e),s=dn(e);return tr({expression:ve({functionName:Ce({expression:"Array",name:"isArray"}),parameters:[r]}),thenStatement:fe({statements:[Ct({expression:un({left:s,right:b__default.default.factory.createCallChain(Ce({expression:s,name:"map"}),void 0,void 0,[mn({parameters:[{name:"item"}],statements:t})])})})]})})};var am=ye({typeName:"null"}),rr=({isNullable:e,node:t})=>e?b__default.default.factory.createUnionTypeNode([t,am]):t,Zs=({indexKey:e,indexProperty:t,isNullable:r,properties:s,useLegacyResolution:o})=>{let p=s.map(m=>{let l=m.isReadOnly?[H({keyword:"readonly"})]:void 0,f=m.isRequired!==false?void 0:b__default.default.factory.createToken(b__default.default.SyntaxKind.QuestionToken),d=te(m.type);let y=b__default.default.factory.createPropertySignature(l,o||typeof m.name=="string"&&m.name.match(Ae)||typeof m.name!="string"&&b__default.default.isPropertyName(m.name)?m.name:kt({text:m.name}),f,d);return ee({comments:m.comment,node:y}),y}),a=false;if(t)if(!s.length&&e){let m=cn({questionToken:b__default.default.factory.createToken(b__default.default.SyntaxKind.QuestionToken),type:t.type??jt({keyword:"string"}),typeParameter:Cr({constraint:e,name:A({text:String(t.name)})})});p.push(m),a=true;}else {let m=t.isReadOnly?[H({keyword:"readonly"})]:void 0,l=b__default.default.factory.createIndexSignature(m,[Yt({name:A({text:String(t.name)}),type:jt({keyword:"string"})})],te(t.type));p.push(l);}let c=a?p[0]:b__default.default.factory.createTypeLiteralNode(p);return rr({isNullable:r,node:c})},qr=({isNullable:e,types:t})=>{let r=[];for(let o of t){let i=te(o);b__default.default.isUnionTypeNode(i)?r.push(...i.types):r.push(i);}let s=b__default.default.factory.createUnionTypeNode(r);return rr({isNullable:e,node:s})},Hi=({isNullable:e,types:t})=>{let r=[];for(let o of t){let i=te(o);b__default.default.isIntersectionTypeNode(i)?r.push(...i.types):r.push(i);}let s=b__default.default.factory.createIntersectionTypeNode(r);return rr({isNullable:e,node:s})},Qi=({isNullable:e=false,types:t})=>{let r=t.map(o=>te(o)),s=b__default.default.factory.createTupleTypeNode(r);return rr({isNullable:e,node:s})},Zi=(e,t,r=false,s=true)=>{let o=qr({types:e}),i=qr({types:t}),p=Zs({properties:[{name:`[key: ${se({node:o,unescape:true})}]`,type:i}],useLegacyResolution:s});return rr({isNullable:r,node:p})},Ui=(e,t=false)=>{let r=ye({typeArguments:[Array.isArray(e)?qr({types:e}):e],typeName:"Array"});return rr({isNullable:t,node:r})};var n={anonymousFunction:yi,arrayLiteralExpression:Qs,arrowFunction:mn,asExpression:wr,assignment:Ii,awaitExpression:hi,binaryExpression:un,block:fe,callExpression:ve,classDeclaration:Mi,conditionalExpression:Ti,constVariable:vi,constructorDeclaration:qi,enumDeclaration:xi,exportAllDeclaration:Ni,exportNamedDeclaration:Ci,expressionToStatement:Ct,forOfStatement:Ei,functionTypeNode:gi,getAccessorDeclaration:Oi,identifier:A,ifStatement:tr,indexedAccessTypeNode:Si,isTsNode:It,keywordTypeNode:jt,literalTypeNode:ui,mappedTypeNode:cn,methodDeclaration:$i,namedImportDeclarations:wi,namespaceDeclaration:bi,newExpression:vr,nodeToString:se,null:Hs,objectExpression:ln,ots:le,parameterDeclaration:Yt,propertyAccessExpression:Ce,propertyAccessExpressions:Fi,propertyAssignment:pn,propertyDeclaration:fi,regularExpressionLiteral:ki,returnFunctionCall:Vi,returnStatement:fn,returnVariable:Di,safeAccessExpression:er,stringLiteral:kt,templateLiteralType:ji,this:li,transformArrayMap:_i,transformArrayMutation:Wi,transformDateMutation:Bi,transformFunctionMutation:Ki,transformNewDate:zi,typeAliasDeclaration:Ai,typeArrayNode:Ui,typeInterfaceNode:Zs,typeIntersectionNode:Hi,typeNode:te,typeOfExpression:Ri,typeOperatorNode:di,typeParameterDeclaration:Cr,typeParenthesizedNode:Pi,typeRecordNode:Zi,typeReferenceNode:ye,typeTupleNode:Qi,typeUnionNode:qr,valueToExpression:Ne};var yn=({context:e,parameter:t})=>{if(!t.pagination)return;if(t.pagination===true)return t.schema;let r=t.schema;return r.$ref&&(r=e.resolveIrRef(r.$ref)),r.properties[t.pagination]},ut=e=>{for(let t in e)if(e[t].required)return true;return false},Xi=e=>e?!!(ut(e.cookie)||ut(e.header)||ut(e.path)||ut(e.query)):false,Us=({context:e,parameters:t})=>{if(t){for(let r in t.cookie){let s=t.cookie[r];if(s.pagination)return {in:s.location,name:s.pagination===true?s.name:`${s.name}.${s.pagination}`,schema:yn({context:e,parameter:s})}}for(let r in t.header){let s=t.header[r];if(s.pagination)return {in:s.location,name:s.pagination===true?s.name:`${s.name}.${s.pagination}`,schema:yn({context:e,parameter:s})}}for(let r in t.path){let s=t.path[r];if(s.pagination)return {in:s.location,name:s.pagination===true?s.name:`${s.name}.${s.pagination}`,schema:yn({context:e,parameter:s})}}for(let r in t.query){let s=t.query[r];if(s.pagination)return {in:s.location,name:s.pagination===true?s.name:`${s.name}.${s.pagination}`,schema:yn({context:e,parameter:s})}}}};var z=({detectFormat:e=true,schema:t})=>{if(!t.items)return t;let r=[],s=[];for(let i of t.items){if(!i.type&&i.items||t.type==="tuple"){r.push(i);continue}if(!i.type||i.type==="boolean"||i.type==="integer"||i.type==="null"||i.type==="number"||i.type==="string"||i.type==="unknown"||i.type==="void"){let p=i.const!==void 0?`const-${i.const}`:"",a=i.format!==void 0&&e?`format-${i.format}`:"",c=[i.minLength!==void 0?`minLength-${i.minLength}`:"",i.maxLength!==void 0?`maxLength-${i.maxLength}`:"",i.minimum!==void 0?`minimum-${i.minimum}`:"",i.maximum!==void 0?`maximum-${i.maximum}`:"",i.exclusiveMinimum!==void 0?`exclusiveMinimum-${i.exclusiveMinimum}`:"",i.exclusiveMaximum!==void 0?`exclusiveMaximum-${i.exclusiveMaximum}`:"",i.minItems!==void 0?`minItems-${i.minItems}`:"",i.maxItems!==void 0?`maxItems-${i.maxItems}`:"",i.pattern!==void 0?`pattern-${i.pattern}`:""].join(""),m=`${i.$ref??""}${i.type??""}${p}${a}${c}`;s.includes(m)||(s.push(m),r.push(i));continue}r.push(i);}let o={...t};if(o.items=r,o.items.length<=1&&o.type!=="array"&&o.type!=="enum"&&o.type!=="tuple"){let i=o.items[0];delete o.logicalOperator,delete o.items,o={...o,...i};}return o.type==="unknown"?{}:o};var B=({items:e,logicalOperator:t="or",mutateSchemaOneItem:r=false,schema:s})=>e.length?s.type==="tuple"?(s.items=e,s):e.length!==1?(s.items=e,s.logicalOperator=t,s):r?(s={...s,...e[0]},s):(s.items=e,s):s;var nr=e=>!!(Xi(e.parameters)||e.body?.required),D=({method:e,path:t})=>`${e.toUpperCase()} ${t}`,Ji=({context:e,operation:t})=>{let r=t.body;if(!r||!r.pagination)return Us({context:e,parameters:t.parameters});if(r.pagination===true)return {in:"body",name:"body",schema:r.schema};let s=r.schema,o=s.$ref?e.resolveIrRef(s.$ref):s,p=("schema"in o?o.schema:o)?.properties?.[r.pagination];return p?{in:"body",name:r.pagination,schema:p}:Us({context:e,parameters:t.parameters})},Xs=({statusCode:e})=>{switch(e){case "1XX":return "1XX";case "2XX":return "2XX";case "3XX":return "3XX";case "4XX":return "4XX";case "5XX":return "5XX";case "default":return "default";default:return `${e[0]}XX`}},we=e=>{let t={};if(!e.responses)return t;let r={properties:{},type:"object"},s={properties:{},type:"object"},o;for(let a in e.responses){let c=e.responses[a];switch(Xs({statusCode:a})){case "1XX":case "3XX":break;case "2XX":s.properties[a]=c.schema;break;case "4XX":case "5XX":r.properties[a]=c.schema;break;case "default":o=c;break}}if(o){let a=false;Object.keys(s.properties).length||(s.properties.default=o.schema,a=true);let c=(o.schema.description??"").toLocaleLowerCase(),m=(o.schema.$ref??"").toLocaleLowerCase();["success"].some(d=>c.includes(d)||m.includes(d))&&(s.properties.default=o.schema,a=true),["error","problem"].some(d=>c.includes(d)||m.includes(d))&&(r.properties.default=o.schema,a=true),a||(r.properties.default=o.schema);}let i=Object.keys(r.properties);if(i.length){r.required=i,t.errors=r;let a=B({items:Object.values(r.properties),mutateSchemaOneItem:true,schema:{}});a=z({schema:a}),Object.keys(a).length&&a.type!=="unknown"&&(t.error=a);}let p=Object.keys(s.properties);if(p.length){s.required=p,t.responses=s;let a=B({items:Object.values(s.properties),mutateSchemaOneItem:true,schema:{}});a=z({schema:a}),Object.keys(a).length&&a.type!=="unknown"&&(t.response=a);}return t};var vt=(...e)=>hn__namespace.satisfies(...e),gn=e=>({getVersion:t=>{let r=e[t];try{if(r)return hn__namespace.parse(r)||void 0}catch{}},isInstalled:t=>!!e[t],satisfies:(t,r,s)=>{let o=typeof t=="string"?e[t]:t;return o?vt(o,r,s):false}});var cm=[ue,mi,pi,ci,ai],wt=e=>{let t=e.replace(/[^$\u200c\u200d\p{ID_Continue}]/gu,"_");if(Gt.lastIndex=0,Gt.test(t))return `_${t}`;for(let r of cm){if(t.startsWith("_"))return t;t=t.replace(r,"_$1");}return t};var fm=new Set(["buffer","child_process","cluster","console","constants","crypto","dgram","dns","domain","events","freelist","fs","http","https","module","net","os","path","process","punycode","querystring","readline","repl","stream","string_decoder","timers","tls","tty","url","util","v8","vm","worker_threads","zlib"]),xn=class{addBinding({bindings:t,file:r,meta:s,project:o,symbol:i}){if(!i.external&&!o.symbols.hasValue(i.id))return;let[p]=o.symbolIdToFiles(i.id);if(!p)return;let a=this.getBindingPath(r,p,s),c=t.get(a),m=codegenCore.createBinding({file:r,modulePath:a,symbol:i,symbolFile:p});c?(codegenCore.mergeBindings(c,m),t.set(a,c)):t.set(a,m);}getBindingPath(t,r,s){if(!t.path||!r.path)return "";if(r.external&&!Pt__default.default.isAbsolute(r.path))return r.path;let o=Pt__default.default.posix.relative(Pt__default.default.posix.dirname(t.path.split(Pt__default.default.sep).join(Pt__default.default.posix.sep)),r.path.split(Pt__default.default.sep).join(Pt__default.default.posix.sep));return !o.startsWith(".")&&o!==""&&(o=`./${o}`),r.extension===".ts"&&(o.endsWith(r.extension)&&(o=o.slice(0,-r.extension.length)),s?.importFileExtension?o+=s.importFileExtension:o.endsWith("/index")&&(o=o.slice(0,-6))),o}getBodyLines(t,r){let s=[];for(let o of t.symbols.body){let i=r.symbols.getValue(o);if(typeof i=="string")s.push(i);else if(i instanceof Array)for(let p of i)s.push(se({node:p,unescape:true}));else i!=null&&s.push(se({node:i,unescape:true}));}return s}getExportLines(t,r,s){let o=[];for(let[i,p]of t.entries()){let a=[],c,m=false;if(p.namespaceBinding!==void 0)typeof p.namespaceBinding=="string"&&(c=codegenCore.renderIds(p.namespaceBinding,d=>{let y=s.symbols.get(d);return this.replacerFn({file:r,project:s,symbol:y})})),p.typeNamespaceBinding&&(m=true);else if(p.names&&p.names.length>0){p.names.every(d=>(p.typeNames??[]).includes(d))&&(m=true);for(let d of p.names){let y=p.aliases?.[d],h=d,g;y&&y!==h&&(g=h,h=y),h=codegenCore.renderIds(h,S=>{let k=s.symbols.get(S),E=this.replacerFn({file:r,project:s,symbol:k}),[C]=s.symbolIdToFiles(S),j=C?C.resolvedNames.get(S):void 0;return j&&j!==E&&(g||(g=j)),E}),g&&(g=codegenCore.renderIds(g,S=>{let k=s.symbols.get(S);return this.replacerFn({file:r,project:s,symbol:k})}),g===h&&(g=void 0));let x=b__default.default.factory.createExportSpecifier(m?false:p.typeNames?.includes(d)??false,g?n.identifier({text:g}):void 0,n.identifier({text:h}));a.push(x);}}let l=c?b__default.default.factory.createNamespaceExport(n.identifier({text:c})):a.length?b__default.default.factory.createNamedExports(a):void 0,f=b__default.default.factory.createExportDeclaration(void 0,m,l,n.stringLiteral({isSingleQuote:true,text:i}));o.push(se({node:f,unescape:true}));}return o}getHeaderLines(){return ["// This file is auto-generated by @hey-api/openapi-ts"]}getImportLines(t,r,s){let o=[],i=-1,p=c=>{let m=c.from;return m.startsWith(".")?m.startsWith("./")?[2,0,m]:[2,m.match(/\.\.\//g)?.length??0,m]:fm.has(m.split("/")[0])?[0,0,m]:[1,0,m]},a=Array.from(t.values()).map(c=>({...c,k:p(c)})).sort((c,m)=>c.k[0]-m.k[0]||c.k[1]-m.k[1]||c.k[2].localeCompare(m.k[2]));for(let c of a){let m=[],l,f,d=false;if(c.defaultBinding){let g=codegenCore.renderIds(c.defaultBinding,x=>{let S=s.symbols.get(x);return this.replacerFn({file:r,project:s,symbol:S})});l=n.identifier({text:g}),c.typeDefaultBinding&&(d=true);}else if(typeof c.namespaceBinding=="string")f=codegenCore.renderIds(c.namespaceBinding,g=>{let x=s.symbols.get(g);return this.replacerFn({file:r,project:s,symbol:x})}),c.typeNamespaceBinding&&(d=true);else if(c.names&&c.names.length>0){c.names.every(x=>c.typeNames?.includes(x))&&(d=true);let g=[];for(let x of c.names){let S=c.aliases?.[x],k=x,E;S&&S!==k&&(E=k,k=S),k=codegenCore.renderIds(k,C=>{let j=s.symbols.get(C),F=this.replacerFn({file:r,project:s,symbol:j}),[M]=s.symbolIdToFiles(C),v=M?M.resolvedNames.get(C):void 0;return v&&v!==F&&(E||(E=v)),F}),E&&(E=codegenCore.renderIds(E,C=>{let j=s.symbols.get(C);return this.replacerFn({file:r,project:s,symbol:j})}),E===k&&(E=void 0)),g.push({isTypeOnly:d?false:c.typeNames?.includes(x)??false,name:k,propertyName:E?n.identifier({text:E}):void 0});}m=g.sort((x,S)=>x.name.localeCompare(S.name)).map(({isTypeOnly:x,name:S,propertyName:k})=>b__default.default.factory.createImportSpecifier(x,k,n.identifier({text:S})));}let y=b__default.default.factory.createImportClause(d,l,f?b__default.default.factory.createNamespaceImport(n.identifier({text:f})):m.length?b__default.default.factory.createNamedImports(m):void 0),h=b__default.default.factory.createImportDeclaration(void 0,y,n.stringLiteral({isSingleQuote:true,text:c.from}));i!==-1&&c.k[0]!==i&&o.push(""),o.push(se({node:h,unescape:true})),i=c.k[0];}return o}getUniqueName(t,r){let s=2,o=t;for(;r.hasValue(o);)o=`${t}${s}`,s+=1;return o}renderFile(t,r,s,o){let i=new Map;if(t=codegenCore.renderIds(t,m=>{let l=s.symbols.get(m),f=this.replacerFn({file:r,project:s,symbol:l});return l&&this.addBinding({bindings:i,file:r,meta:o,project:s,symbol:l}),f}),!t.length)return "";let p="",a=this.getHeaderLines();p+=`${a.join(`
4
- `)}${a.length?`
5
-
6
- `:""}`;let c=this.getImportLines(i,r,s);return p+=`${c.join(`
7
- `)}${c.length?`
8
-
9
- `:""}`,`${p}${t}`}renderSymbols(t,r,s){let o=new Map,i="",p=this.getBodyLines(t,r);i+=`${p.join(`
10
-
11
- `)}${p.length?`
12
- `:""}`,i=codegenCore.renderIds(i,c=>{if(!t.symbols.body.includes(c))return;let m=r.symbols.get(c);return this.replacerFn({file:t,project:r,symbol:m})});for(let c of t.symbols.exports){let m=r.symbols.get(c);m&&this.addBinding({bindings:o,file:t,meta:s,project:r,symbol:m});}for(let c of o.values())c.namespaceBinding=true,c.typeNamespaceBinding=c.names&&c.typeNames&&c.names.length===c.typeNames.length&&c.names.every(m=>(c.typeNames??[]).includes(m));let a=this.getExportLines(o,t,r);return i+=`${a.join(`
13
- `)}${a.length?`
14
- `:""}`,i}replacerFn({file:t,project:r,symbol:s}){if(!s)return;let o=t.resolvedNames.get(s.id);if(o)return o;if(!s.name)return;let[i]=r.symbolIdToFiles(s.id),p=i?.resolvedNames.get(s.id),a=wt(p??s.name);return t.resolvedNames.hasValue(a)&&(a=this.getUniqueName(a,t.resolvedNames)),t.resolvedNames.set(s.id,a),a}};var um=e=>{if(e.meta?.pluginName)return e.meta.pluginName.startsWith("@hey-api/client-")?"client":e.meta.pluginName==="@hey-api/typescript"?"types":e.meta.pluginName.startsWith("@hey-api/")?e.meta.pluginName.split("/")[1]:e.meta.pluginName},ym=e=>{switch(e.method){case "delete":case "patch":case "post":case "put":return ["mutation"];case "get":return ["query"];default:return}},bn=class{api;config;context;dependencies=[];gen;handler;name;output;package;constructor(t){this.api=t.api??{},this.config=t.config,this.context=t.context,this.dependencies=t.dependencies,this.gen=t.gen,this.handler=t.handler,this.name=t.name,this.output=t.output,this.package=t.context.package;}forEach(...t){let r=t.slice(0,-1),s=t[t.length-1],o=new Set(r.length?r:["operation","parameter","requestBody","schema","server","webhook"]);if(o.has("server")&&this.context.ir.servers)for(let i of this.context.ir.servers){let p={server:i,type:"server"};try{s(p);}catch(a){this.forEachError(a,p);}}if(o.has("schema")&&this.context.ir.components?.schemas)for(let i in this.context.ir.components.schemas){let p={$ref:`#/components/schemas/${i}`,name:i,schema:this.context.ir.components.schemas[i],type:"schema"};try{s(p);}catch(a){this.forEachError(a,p);}}if(o.has("parameter")&&this.context.ir.components?.parameters)for(let i in this.context.ir.components.parameters){let p={$ref:`#/components/parameters/${i}`,name:i,parameter:this.context.ir.components.parameters[i],type:"parameter"};try{s(p);}catch(a){this.forEachError(a,p);}}if(o.has("requestBody")&&this.context.ir.components?.requestBodies)for(let i in this.context.ir.components.requestBodies){let p={$ref:`#/components/requestBodies/${i}`,name:i,requestBody:this.context.ir.components.requestBodies[i],type:"requestBody"};try{s(p);}catch(a){this.forEachError(a,p);}}if(o.has("operation")&&this.context.ir.paths)for(let i in this.context.ir.paths){let p=this.context.ir.paths[i];for(let a in p){let c=a,m={method:c,operation:p[c],path:i,type:"operation"};try{s(m);}catch(l){this.forEachError(l,m);}}}if(o.has("webhook")&&this.context.ir.webhooks)for(let i in this.context.ir.webhooks){let p=this.context.ir.webhooks[i];for(let a in p){let c=a,m={key:i,method:c,operation:p[c],type:"webhook"};try{s(m);}catch(l){this.forEachError(l,m);}}}}forEachError(t,r){let s=t instanceof Error?t:new Error(String(t));throw new nn({args:[r],error:s,event:r.type,name:"Error",pluginName:this.name})}getPlugin(t){return this.context.plugins[t]}getPluginOrThrow(t){let r=this.getPlugin(t);if(!r)throw new Error(`plugin not found ${t}`);return r}getSymbol(t){return this.gen.symbols.get(t)}getSymbolFilePath(t){let r=this.config["~hooks"]?.symbols?.getFilePath,s=r?.(t);if(s!==void 0)return s;let o=this.context.config.parser.hooks.symbols?.getFilePath,i=o?.(t);return i!==void 0?i:um(t)}getSymbolValue(t){return this.gen.symbols.getValue(this.symbolToId(t))}hasSymbolValue(t){return this.gen.symbols.hasValue(this.symbolToId(t))}hooks={operation:{isMutation:t=>this.isOperationKind(t,"mutation"),isQuery:t=>this.isOperationKind(t,"query")},symbol:{getFilePath:t=>this.getSymbolFilePath(t)}};isOperationKind(t,r){let s=r==="query"?"isQuery":"isMutation",o=this.config["~hooks"]?.operations?.[s],i=o?.(t);if(i!==void 0)return i;let p=this.config["~hooks"]?.operations?.getKind,a=p?.(t);if(a!==void 0)return a.includes(r);let c=this.context.config.parser.hooks.operations?.[s],m=c?.(t);if(m!==void 0)return m;let l=this.context.config.parser.hooks.operations?.getKind,f=l?.(t);return f!==void 0?f.includes(r):(ym(t)??[]).includes(r)}referenceSymbol(t){return this.gen.symbols.reference(t)}registerSymbol(t){return this.gen.symbols.register({...t,exportFrom:t.exportFrom??(!t.external&&this.context.config.output.indexFile&&this.config.exportFromIndex?["index"]:void 0),getFilePath:t.getFilePath??this.hooks.symbol.getFilePath,meta:{pluginName:Pt__default.default.isAbsolute(this.name)?"custom":this.name,...t.meta}})}async run(){await this.handler({plugin:this});}setSymbolValue(t,r){return this.gen.symbols.setValue(this.symbolToId(t),r)}symbolToId(t){return typeof t=="number"?t:t.id}};var hm=/~1/g,gm=/~0/g,L=e=>{let t=qe(e),r=t[t.length-1];return decodeURI(r)},xm=e=>String(e).replace(/~/g,"~0").replace(/\//g,"~1"),qe=e=>{let t=e.trim();return t.startsWith("#")&&(t=t.slice(1)),t.startsWith("/")&&(t=t.slice(1)),t?t.split("/").map(r=>r.replace(hm,"/").replace(gm,"~")):[]},Gi=e=>{let t=e.trim();return t.startsWith("#")||(t=`#${t}`),t.length>1&&t.endsWith("/")&&(t=t.slice(0,-1)),t=t.replace(/\/+/g,"/"),t},Yi=e=>{let t=e.map(xm).join("/");return "#"+(t?`/${t}`:"")},Js=({$ref:e,spec:t})=>{let r=qe(decodeURI(e)),s=t;for(let o of r){let i=o;if(s[i]===void 0)throw new Error(`Reference not found: ${e}`);s=s[i];}return s};var Sn=class{config;gen;ir={};logger;package;plugins={};spec;constructor({config:t,dependencies:r,logger:s,spec:o}){this.config=t,this.gen=new codegenCore.Project({defaultFileName:"index",fileName:i=>{let p=O({config:t.output.fileName,name:i}),{suffix:a}=t.output.fileName;return a?p==="index"||p.endsWith(a)?p:`${p}${a}`:p},renderers:{".ts":new xn},root:t.output.path}),this.logger=s,this.package=gn(r),this.spec=o;}dereference(t){let r=this.resolveRef(t.$ref),s={...t,...r};return delete s.$ref,s}registerPlugin(t){let r=this.config.plugins[t],s=new bn({api:r.api,config:r.config,context:this,dependencies:r.dependencies??[],gen:this.gen,handler:r.handler,name:r.name,output:r.output});return this.plugins[s.name]=s,s}registerPlugins(){return this.config.pluginOrder.map(t=>this.registerPlugin(t))}resolveIrRef(t){return Js({$ref:t,spec:this.ir})}resolveRef(t){return Js({$ref:t,spec:this.spec})}};var $t=e=>{let t=e.replace(/[^$\u200c\u200d\p{ID_Continue}]/gu,"_");return Gt.lastIndex=0,Gt.test(t)?`_${t}`:t},yt=e=>e.replace(/^[^\p{ID_Start}]+/u,"").replace(/[^$\u200c\u200d\p{ID_Continue}]/gu,"-").replace(/[$+]/g,"-"),Gs=e=>{let t=e.replace("[]","Array");return yt(t)};var G=["delete","get","head","options","patch","post","put","trace"],Mt=({context:e,count:t=1,id:r,method:s,path:o,state:i})=>{let p,{output:a}=e.config,c=(a!==void 0&&typeof a=="object"&&"case"in a?a.case:void 0)??"camelCase";if(r&&(!e.config.plugins["@hey-api/sdk"]||e.config.plugins["@hey-api/sdk"].config.operationId))p=q({case:c,value:yt(r)});else {let m=o.replace(/{(.*?)}/g,"by-$1").replace(/[/:+]/g,"-");p=q({case:c,value:`${s}-${m}`});}return t>1&&(p=`${p}${t}`),i.ids.has(p)?Mt({context:e,count:t+1,id:r,method:s,path:o,state:i}):(i.ids.set(p,D({method:s,path:o})),p)};var ea="/",N=(e,t="")=>`${e}${ea}${t}`,J=e=>{let t=e.indexOf(ea);return {name:e.slice(t+1),namespace:e.slice(0,t)}},ta=e=>{switch(e){case "parameters":return "parameter";case "requestBodies":return "body";case "responses":return "response";case "definitions":case "schemas":return "schema";default:return "unknown"}},$e=(e,t)=>{let r=[],s=[];if(t)for(let o of t)o.startsWith("/")&&o.endsWith("/")?s.push(new RegExp(o.slice(1,o.length-1))):r.push(N(e,o));return {regexps:s,set:new Set(r)}},Sm=({excludeOperations:e,excludeSchemas:t,includeOperations:r,includeSchemas:s,spec:o})=>{if((e.regexps.length||r.regexps.length)&&o.paths)for(let i of Object.entries(o.paths)){let p=i[0],a=i[1];for(let c of G){if(!a[c])continue;let l=D({method:c,path:p});e.regexps.some(f=>f.test(l))&&e.set.add(N("operation",l)),r.regexps.some(f=>f.test(l))&&r.set.add(N("operation",l));}}if(o.definitions&&(t.regexps.length||s.regexps.length))for(let i of Object.keys(o.definitions))t.regexps.some(p=>p.test(i))&&t.set.add(N("schema",i)),s.regexps.some(p=>p.test(i))&&s.set.add(N("schema",i));},Om=({excludeOperations:e,excludeParameters:t,excludeRequestBodies:r,excludeResponses:s,excludeSchemas:o,includeOperations:i,includeParameters:p,includeRequestBodies:a,includeResponses:c,includeSchemas:m,spec:l})=>{if((e.regexps.length||i.regexps.length)&&l.paths)for(let f of Object.entries(l.paths)){let d=f[0],y=f[1];for(let h of G){if(!y[h])continue;let x=D({method:h,path:d});e.regexps.some(S=>S.test(x))&&e.set.add(N("operation",x)),i.regexps.some(S=>S.test(x))&&i.set.add(N("operation",x));}}if(l.components){if((t.regexps.length||p.regexps.length)&&l.components.parameters)for(let f of Object.keys(l.components.parameters))t.regexps.some(d=>d.test(f))&&t.set.add(N("parameter",f)),p.regexps.some(d=>d.test(f))&&p.set.add(N("parameter",f));if((r.regexps.length||a.regexps.length)&&l.components.requestBodies)for(let f of Object.keys(l.components.requestBodies))r.regexps.some(d=>d.test(f))&&r.set.add(N("body",f)),a.regexps.some(d=>d.test(f))&&a.set.add(N("body",f));if((s.regexps.length||c.regexps.length)&&l.components.responses)for(let f of Object.keys(l.components.responses))s.regexps.some(d=>d.test(f))&&s.set.add(N("response",f)),c.regexps.some(d=>d.test(f))&&c.set.add(N("response",f));if((o.regexps.length||m.regexps.length)&&l.components.schemas)for(let f of Object.keys(l.components.schemas))o.regexps.some(d=>d.test(f))&&o.set.add(N("schema",f)),m.regexps.some(d=>d.test(f))&&m.set.add(N("schema",f));}},Tm=({spec:e,...t})=>{"swagger"in e?Sm({...t,spec:e}):Om({...t,spec:e});},sr=(e,t,r)=>{let s=r.timeEvent("create-filters"),o=$e("operation",e?.operations?.exclude),i=$e("operation",e?.operations?.include),p=$e("parameter",e?.parameters?.exclude),a=$e("parameter",e?.parameters?.include),c=$e("body",e?.requestBodies?.exclude),m=$e("body",e?.requestBodies?.include),l=$e("response",e?.responses?.exclude),f=$e("response",e?.responses?.include),d=$e("schema",e?.schemas?.exclude),y=$e("schema",e?.schemas?.include);Tm({excludeOperations:o,excludeParameters:p,excludeRequestBodies:c,excludeResponses:l,excludeSchemas:d,includeOperations:i,includeParameters:a,includeRequestBodies:m,includeResponses:f,includeSchemas:y,spec:t});let h={deprecated:e?.deprecated??true,operations:{exclude:o.set,include:i.set},orphans:e?.orphans??false,parameters:{exclude:p.set,include:a.set},preserveOrder:e?.preserveOrder??false,requestBodies:{exclude:c.set,include:m.set},responses:{exclude:l.set,include:f.set},schemas:{exclude:d.set,include:y.set},tags:{exclude:new Set(e?.tags?.exclude),include:new Set(e?.tags?.include)}};return s.timeEnd(),h},or=e=>e?e.orphans===false||e.deprecated===false?true:!!(e.operations?.exclude?.length||e.operations?.include?.length||e.parameters?.exclude?.length||e.parameters?.include?.length||e.requestBodies?.exclude?.length||e.requestBodies?.include?.length||e.responses?.exclude?.length||e.responses?.include?.length||e.schemas?.exclude?.length||e.schemas?.include?.length||e.tags?.exclude?.length||e.tags?.include?.length):false,Rm=({filters:e,parameters:t,requestBodies:r,resourceMetadata:s,responses:o,schemas:i})=>{let p=new Set,c=[...e.operations.include.size?e.operations.include:new Set(s.operations.keys())];for(;c.length;){let m=c.pop();if(e.operations.exclude.has(m)||p.has(m))continue;let l=s.operations.get(m);l&&(!e.deprecated&&l.deprecated||e.tags.exclude.size&&l.tags.size&&[...e.tags.exclude].some(f=>l.tags.has(f))||e.tags.include.size&&!new Set([...e.tags.include].filter(f=>l.tags.has(f))).size||[...l.dependencies].some(f=>{let{namespace:d}=J(f);switch(d){case "body":return !r.has(f);case "parameter":return !t.has(f);case "response":return !o.has(f);case "schema":return !i.has(f);default:return false}})||p.add(m));}return {operations:p}},Am=({filters:e,resourceMetadata:t,schemas:r})=>{let s=new Set,i=[...e.parameters.include.size?e.parameters.include:new Set(t.parameters.keys())];for(;i.length;){let p=i.pop();if(e.parameters.exclude.has(p)||s.has(p))continue;let a=t.parameters.get(p);if(a&&!(!e.deprecated&&a.deprecated)&&(s.add(p),!!a.dependencies.size))for(let c of a.dependencies){let{namespace:m}=J(c);switch(m){case "body":{e.requestBodies.exclude.has(c)?s.delete(p):s.has(c)||i.push(c);break}case "schema":{e.schemas.exclude.has(c)?s.delete(p):r.has(c)||r.add(c);break}}}}return {parameters:s}},Pm=({filters:e,resourceMetadata:t,schemas:r})=>{let s=new Set,i=[...e.requestBodies.include.size?e.requestBodies.include:new Set(t.requestBodies.keys())];for(;i.length;){let p=i.pop();if(e.requestBodies.exclude.has(p)||s.has(p))continue;let a=t.requestBodies.get(p);if(a&&!(!e.deprecated&&a.deprecated)&&(s.add(p),!!a.dependencies.size))for(let c of a.dependencies){let{namespace:m}=J(c);switch(m){case "body":{e.requestBodies.exclude.has(c)?s.delete(p):s.has(c)||i.push(c);break}case "schema":{e.schemas.exclude.has(c)?s.delete(p):r.has(c)||r.add(c);break}}}}return {requestBodies:s}},Em=({filters:e,resourceMetadata:t,schemas:r})=>{let s=new Set,i=[...e.responses.include.size?e.responses.include:new Set(t.responses.keys())];for(;i.length;){let p=i.pop();if(e.responses.exclude.has(p)||s.has(p))continue;let a=t.responses.get(p);if(a&&!(!e.deprecated&&a.deprecated)&&(s.add(p),!!a.dependencies.size))for(let c of a.dependencies){let{namespace:m}=J(c);switch(m){case "body":{e.requestBodies.exclude.has(c)?s.delete(p):s.has(c)||i.push(c);break}case "schema":{e.schemas.exclude.has(c)?s.delete(p):r.has(c)||r.add(c);break}}}}return {responses:s}},Im=({filters:e,resourceMetadata:t})=>{let r=new Set,o=[...e.schemas.include.size?e.schemas.include:new Set(t.schemas.keys())];for(;o.length;){let i=o.pop();if(e.schemas.exclude.has(i)||r.has(i))continue;let p=t.schemas.get(i);if(p&&!(!e.deprecated&&p.deprecated)&&(r.add(i),!!p.dependencies.size))for(let a of p.dependencies){let{namespace:c}=J(a);switch(c){case "schema":{!r.has(a)&&!e.schemas.exclude.has(a)&&o.push(a);break}}}}return {schemas:r}},km=({filters:e,parameters:t,resourceMetadata:r})=>{if(e.parameters.exclude.size)for(let s of t){let o=r.parameters.get(s);if(o?.dependencies.size){for(let i of e.parameters.exclude)if(o.dependencies.has(i)){t.delete(s);break}}}},jm=({filters:e,requestBodies:t,resourceMetadata:r})=>{if(e.requestBodies.exclude.size)for(let s of t){let o=r.requestBodies.get(s);if(o?.dependencies.size){for(let i of e.requestBodies.exclude)if(o.dependencies.has(i)){t.delete(s);break}}}},Nm=({filters:e,resourceMetadata:t,responses:r})=>{if(e.responses.exclude.size)for(let s of r){let o=t.responses.get(s);if(o?.dependencies.size){for(let i of e.responses.exclude)if(o.dependencies.has(i)){r.delete(s);break}}}},Cm=({filters:e,resourceMetadata:t,schemas:r})=>{if(e.schemas.exclude.size)for(let s of r){let o=t.schemas.get(s);if(o?.dependencies.size){for(let i of e.schemas.exclude)if(o.dependencies.has(i)){r.delete(s);break}}}},vm=({operationDependencies:e,parameters:t,requestBodies:r,responses:s,schemas:o})=>{for(let i of o)e.has(i)||o.delete(i);for(let i of t)e.has(i)||t.delete(i);for(let i of r)e.has(i)||r.delete(i);for(let i of s)e.has(i)||s.delete(i);},wm=({operations:e,resourceMetadata:t})=>{let r=new Set,o=[...new Set([...e].flatMap(i=>[...t.operations.get(i)?.dependencies??[]]))];for(;o.length;){let i=o.pop();if(r.has(i))continue;r.add(i);let{namespace:p}=J(i),a;if(p==="body"?a=t.requestBodies.get(i)?.dependencies:p==="operation"?a=t.operations.get(i)?.dependencies:p==="parameter"?a=t.parameters.get(i)?.dependencies:p==="response"?a=t.responses.get(i)?.dependencies:p==="schema"&&(a=t.schemas.get(i)?.dependencies),!!a?.size)for(let c of a)r.has(c)||o.push(c);}return {operationDependencies:r}},ir=({filters:e,logger:t,resourceMetadata:r})=>{let s=t.timeEvent("create-filtered-dependencies"),{schemas:o}=Im({filters:e,resourceMetadata:r}),{parameters:i}=Am({filters:e,resourceMetadata:r,schemas:o}),{requestBodies:p}=Pm({filters:e,resourceMetadata:r,schemas:o}),{responses:a}=Em({filters:e,resourceMetadata:r,schemas:o});Cm({filters:e,resourceMetadata:r,schemas:o}),km({filters:e,parameters:i,resourceMetadata:r}),jm({filters:e,requestBodies:p,resourceMetadata:r}),Nm({filters:e,resourceMetadata:r,responses:a});let{operations:c}=Rm({filters:e,parameters:i,requestBodies:p,resourceMetadata:r,responses:a,schemas:o});if(!e.orphans&&c.size){let{operationDependencies:m}=wm({operations:c,resourceMetadata:r});vm({operationDependencies:m,parameters:i,requestBodies:p,responses:a,schemas:o});}return s.timeEnd(),{operations:c,parameters:i,requestBodies:p,responses:a,schemas:o}};var ar=(e,t)=>{let r=t.timeEvent("build-resource-metadata"),s={operations:new Map,parameters:new Map,requestBodies:new Map,responses:new Map,schemas:new Map},o=i=>{let p=new Set,a=e.allDependencies.get(i);if(a?.size)for(let c of a){let m=qe(c),l=m[m.length-2],f=m[m.length-1];if(l&&f){let d=ta(l);d==="unknown"&&console.warn(`unsupported type: ${l}`),p.add(N(d,f));}}return p};for(let[i,p]of e.nodes){let a=qe(i);if(a[0]==="components"){if(a.length===3){if(a[1]==="schemas"){let c=a[a.length-1];s.schemas.set(N("schema",c),{dependencies:o(i),deprecated:p.deprecated??false});}else if(a[1]==="parameters"){let c=a[a.length-1];s.parameters.set(N("parameter",c),{dependencies:o(i),deprecated:p.deprecated??false});}else if(a[1]==="requestBodies"){let c=a[a.length-1];s.requestBodies.set(N("body",c),{dependencies:o(i),deprecated:p.deprecated??false});}else if(a[1]==="responses"){let c=a[a.length-1];s.responses.set(N("response",c),{dependencies:o(i),deprecated:p.deprecated??false});}}continue}if(a[0]==="paths"){if(a.length===3&&G.includes(a[2])){let c=a[a.length-1],m=a.slice(1,-1).join("/"),l=D({method:c,path:m});s.operations.set(N("operation",l),{dependencies:o(i),deprecated:p.deprecated??false,tags:p.tags??new Set});}continue}if(a[0]==="definitions"){if(a.length===2){let c=a[a.length-1];s.schemas.set(N("schema",c),{dependencies:o(i),deprecated:p.deprecated??false});}continue}}return r.timeEnd(),{resourceMetadata:s}};var $r=e=>JSON.parse(JSON.stringify(e));var Me=[["additionalProperties","single"],["allOf","array"],["anyOf","array"],["contains","single"],["dependentSchemas","objectMap"],["else","single"],["if","single"],["items","singleOrArray"],["oneOf","array"],["patternProperties","objectMap"],["properties","objectMap"],["propertyNames","single"],["then","single"]];var Mr=e=>{if(On(e))return e.components.schemas;if(Tn(e))return e.definitions},On=e=>typeof e=="object"&&e!==null&&"components"in e&&typeof e.components=="object"&&e.components!==null&&"schemas"in e.components&&typeof e.components.schemas=="object"&&e.components.schemas!==null,Tn=e=>typeof e=="object"&&e!==null&&"definitions"in e&&typeof e.definitions=="object"&&e.definitions!==null;var ra=(e,t)=>e instanceof Set?e.has(t):e instanceof Array?e.includes(t):t in e,Lr=({base:e,components:t,extraComponents:r})=>{let s=2,o=e;for(;ra(t,o)||r&&ra(r,o);)o=`${e}${s}`,s+=1;return o},Rn=e=>e.length===3&&e[0]==="components"&&e[1]==="schemas"||e.length===2&&e[0]==="definitions",pr=e=>{if(e&&typeof e=="object"){if("swagger"in e)return "#/definitions/";if("openapi"in e)return "#/components/schemas/"}return ""};var Ys=e=>{if(!e||typeof e!="object"||!("enum"in e)||!(e.enum instanceof Array))return;let t=("type"in e?e.type:void 0)||"",r=[...e.enum].sort();return JSON.stringify({type:t,values:r})},eo=({key:e,node:t,parent:r,path:s,visitor:o})=>{if(!t||typeof t!="object"||t instanceof Array)return;let i=t;("type"in i||"enum"in i||Me.some(([p])=>p in i))&&o({key:e,node:t,parent:r,path:s});for(let[p,a]of Object.entries(i))typeof a=="object"&&a!==null&&(a instanceof Array?a.forEach((c,m)=>eo({key:m,node:c,parent:a,path:[...s,p,m],visitor:o})):eo({key:p,node:a,parent:t,path:[...s,p],visitor:o}));},qm=({spec:e})=>{let t=Mr(e);if(!t)return;let r=pr(e),s={};for(let[i,p]of Object.entries(t))Ys(p)&&(s[`${r}${i}`]=p);let o=i=>{if(i instanceof Array)i.forEach(o);else if(i&&typeof i=="object")for(let[p,a]of Object.entries(i))p==="$ref"&&typeof a=="string"&&a in s?(Object.assign(i,$r(s[a])),delete i.$ref):o(a);};o(e);for(let i of Object.keys(s)){let p=qe(i),a=p[p.length-1];a&&delete t[a];}},$m=({config:e,spec:t})=>{let r=Mr(t);if(!r)return;let s={};for(let[c,m]of Object.entries(r)){let l=Ys(m);l&&(s[l]=c);}let o=[];eo({key:null,node:t,parent:null,path:[],visitor:c=>{if(!Rn(c.path)){let m=Ys(c.node);m&&o.push({...c,signature:m});}}});let i={},p={};for(let{key:c,node:m,signature:l}of o){if(l in i)continue;if(l in s){i[l]=s[l];continue}let f=O({config:e,name:typeof m=="object"&&m&&"title"in m&&typeof m.title=="string"?m.title:String(c)}),d=Lr({base:f,components:r,extraComponents:Object.values(i)});i[l]=d,p[l]=m;}for(let[c,m]of Object.entries(i)){let l=p[c];m&&!(m in r)&&l&&typeof l=="object"&&(r[m]=l);}let a=pr(t);for(let{key:c,parent:m,signature:l}of o){let f=i[l];f&&c!=null&&m&&typeof m=="object"&&(m[c]={$ref:`${a}${f}`});}},na=({config:e,spec:t})=>{if(e.mode==="inline"){qm({spec:t});return}if(e.mode==="root"){$m({config:e,spec:t});return}};var to=({key:e,node:t,parent:r,path:s,visitor:o})=>{if(!t||typeof t!="object"||t instanceof Array)return;let i=t;("type"in i||Me.some(([p])=>p in i))&&o({key:e,node:t,parent:r,path:s});for(let[p,a]of Object.entries(i))typeof a=="object"&&a!==null&&(a instanceof Array?a.forEach((c,m)=>to({key:m,node:c,parent:a,path:[...s,p,m],visitor:o})):to({key:p,node:a,parent:t,path:[...s,p],visitor:o}));},sa=({spec:e})=>{to({key:null,node:e,parent:null,path:[],visitor:t=>{if(t.node&&typeof t.node=="object"&&"type"in t.node&&t.node.type==="object"&&"properties"in t.node&&t.node.properties&&typeof t.node.properties=="object"&&!("required"in t.node)){let r=Object.keys(t.node.properties);r.length>0&&(t.node.required=r);}}});};var ro=(e,t)=>{if(e===t)return true;if(e===null||t===null)return e===t;let r=typeof e;if(r!==typeof t||r!=="object")return false;if(Array.isArray(e)||Array.isArray(t)){if(!Array.isArray(e)||!Array.isArray(t)||e.length!==t.length)return false;for(let c=0;c<e.length;c++)if(!ro(e[c],t[c]))return false;return true}let o=e,i=t,p=Object.keys(o).sort(),a=Object.keys(i).sort();if(p.length!==a.length)return false;for(let c=0;c<p.length;c++)if(p[c]!==a[c])return false;for(let c of p)if(!ro(o[c],i[c]))return false;return true},no=ro;var Mm=e=>{for(let[,t]of e)if(!t.scopes&&t.parentPointer){let r=e.get(t.parentPointer);r?.scopes&&(t.scopes=new Set(r.scopes));}},oo=({cache:e,graph:t,pointer:r,visited:s})=>{let o=e.allDependencies.get(r);if(o)return o;if(s.has(r))return new Set;if(s.add(r),!t.nodes.get(r))return new Set;let p=new Set,a=t.dependencies.get(r);if(a)for(let m of a){p.add(m);let l=oo({cache:e,graph:t,pointer:m,visited:s});for(let f of l)p.add(f);}let c=e.parentToChildren.get(r);if(c)for(let m of c){let l=e.childDependencies.get(m);l||(l=oo({cache:e,graph:t,pointer:m,visited:s}),e.childDependencies.set(m,l));for(let f of l)p.add(f);}return e.allDependencies.set(r,p),p},Lm=e=>{let t=new Set(Array.from(e.nodes.entries()).filter(([,o])=>o.scopes&&o.scopes.size>0).map(([o])=>o)),r=(o,i,p)=>{i.parentPointer&&t.add(i.parentPointer);let a=e.reverseDependencies.get(o);if(a)for(let c of a)t.add(c);if(p){let c=p.match(/(.*)\/(allOf|anyOf|oneOf)\/\d+$/);if(c){let m=c[1];m&&t.add(m);}}},s=(o,i,p)=>{if(!i?.scopes)return;let a=e.nodes.get(p);if(!a?.scopes)return;so(a,i)&&r(o,i,p);};for(;t.size>0;){let o=t.values().next().value;t.delete(o);let i=e.nodes.get(o);if(!i)continue;i.scopes||(i.scopes=new Set);let p=i.node;for(let[c,m]of Me){if(!p||typeof p!="object"||!(c in p))continue;let l=p[c];if(m==="array"&&l instanceof Array)for(let f=0;f<l.length;f++){let d=`${o}/${c}/${f}`;s(o,i,d);}else if(m==="objectMap"&&typeof l=="object"&&l!==null&&!(l instanceof Array))for(let f of Object.keys(l)){let d=`${o}/${c}/${f}`;s(o,i,d);}else if(m==="single"&&typeof l=="object"&&l!==null){let f=`${o}/${c}`;s(o,i,f);}else if(m==="singleOrArray"){if(l instanceof Array)for(let f=0;f<l.length;f++){let d=`${o}/${c}/${f}`;s(o,i,d);}else if(typeof l=="object"&&l!==null){let f=`${o}/${c}`;s(o,i,f);}}}let a=e.dependencies.get(o);if(a)for(let c of a){let m=e.nodes.get(c);m?.scopes&&so(m,i)&&r(o,i);}if(i.parentPointer){let c=e.nodes.get(i.parentPointer);c&&so(i,c)&&r(i.parentPointer,c);}}},so=(e,t)=>{if(!e.scopes)return false;t.scopes||(t.scopes=new Set);let r=false;for(let s of e.scopes)t.scopes.has(s)||(t.scopes.add(s),r=true);return r},Vm=e=>{for(let[t,r]of e){let{node:s}=r;typeof s!="object"||s===null||s instanceof Array||("readOnly"in s&&s.readOnly===true?r.scopes=new Set(["read"]):"writeOnly"in s&&s.writeOnly===true?r.scopes=new Set(["write"]):t.match(/\/properties\/[^/]+$/)&&(r.scopes=new Set(["normal"])));}},ht=(e,t)=>{let r=t.timeEvent("build-graph"),s={allDependencies:new Map,dependencies:new Map,nodes:new Map,reverseDependencies:new Map},o=({key:p,node:a,parentPointer:c,path:m})=>{if(typeof a!="object"||a===null)return;let l=Yi(m),f,d;if(typeof a=="object"&&a!==null){if("deprecated"in a&&typeof a.deprecated=="boolean"&&(f=!!a.deprecated),"$ref"in a&&typeof a.$ref=="string"){let y=Gi(a.$ref);s.dependencies.has(l)||s.dependencies.set(l,new Set),s.dependencies.get(l).add(y);}"tags"in a&&a.tags instanceof Array&&(d=new Set(a.tags.filter(y=>typeof y=="string")));}if(s.nodes.set(l,{deprecated:f,key:p,node:a,parentPointer:c,tags:d}),a instanceof Array)a.forEach((y,h)=>o({key:h,node:y,parentPointer:l,path:[...m,h]}));else for(let[y,h]of Object.entries(a))o({key:y,node:h,parentPointer:l,path:[...m,y]});};o({key:null,node:e,parentPointer:null,path:[]});let i={allDependencies:new Map,childDependencies:new Map,parentToChildren:new Map};for(let[p,a]of s.nodes){let c=a.parentPointer;c&&(i.parentToChildren.has(c)||i.parentToChildren.set(c,[]),i.parentToChildren.get(c).push(p));}for(let[p,a]of s.dependencies)for(let c of a)s.reverseDependencies.has(c)||s.reverseDependencies.set(c,new Set),s.reverseDependencies.get(c).add(p);Vm(s.nodes),Lm(s),Mm(s.nodes);for(let p of s.nodes.keys()){let a=oo({cache:i,graph:s,pointer:p,visited:new Set});s.allDependencies.set(p,a);}return r.timeEnd(),{graph:s}};var Dm=new Set(["additionalProperties","allOf","anyOf","items","not","oneOf","patternProperties","properties","schema"]),Fm=e=>{if(e.length===3&&e[0]==="components"){let t=e[1];if(t==="parameters"||t==="requestBodies")return "write";if(t==="responses"||t==="headers")return "read"}if(e.length===2){let t=e[0];if(t==="parameters")return "write";if(t==="responses")return "read"}},Bm=(e,t)=>{let r=t.timeEvent("capture-original-schemas"),s={};if(On(e))for(let[o,i]of Object.entries(e.components.schemas))s[`#/components/schemas/${o}`]=i;else if(Tn(e))for(let[o,i]of Object.entries(e.definitions))s[`#/definitions/${o}`]=i;return r.timeEnd(),s},Km=({logger:e,spec:t,split:r})=>{let s=e.timeEvent("insert-split-schemas-into-spec");On(t)?Object.assign(t.components.schemas,r.schemas):Tn(t)&&Object.assign(t.definitions,r.schemas),s.timeEnd();},Lt=(e,t,r)=>{if(t&&typeof t=="object"){if("$ref"in t&&typeof t.$ref=="string"){let s=e.nodes.get(t.$ref);if(s?.scopes&&(r==="writeOnly"&&s.scopes.size===1&&s.scopes.has("write")||r==="readOnly"&&s.scopes.size===1&&s.scopes.has("read"))&&(delete t.$ref,!Me.some(([o])=>o in t)))return true}for(let[s,o]of Me){if(!(s in t))continue;let i=t[s];if(o==="array"&&i instanceof Array){for(let p=i.length-1;p>=0;p--){let a=i[p];(a&&typeof a=="object"&&a[r]===true||Lt(e,a,r))&&i.splice(p,1);}i.length||delete t[s];}else if(o==="objectMap"&&typeof i=="object"&&i!==null&&!(i instanceof Array)){let p=i,a=new Set;for(let c of Object.keys(p)){let m=p[c];(m&&typeof m=="object"&&m[r]===true||Lt(e,m,r))&&(delete p[c],s==="properties"&&a.add(c));}if(a.size>0&&s==="properties"&&"required"in t&&Array.isArray(t.required)){let m=t.required.filter(l=>!a.has(l));m.length?t.required=m:delete t.required;}Object.keys(p).length||delete t[s];}else if(o==="single"&&typeof i=="object"&&i!==null)(i[r]===true||Lt(e,i,r))&&delete t[s];else if(o==="singleOrArray")if(i instanceof Array){for(let p=i.length-1;p>=0;p--){let a=i[p];(a&&typeof a=="object"&&a[r]===true||Lt(e,a,r))&&i.splice(p,1);}i.length||delete t[s];}else typeof i=="object"&&i!==null&&(i[r]===true||Lt(e,i,r))&&delete t[s];}if(t.type==="object"&&!Me.some(([s])=>s in t))return true}return false},Wm=({logger:e,originalSchemas:t,spec:r,split:s})=>{let o=e.timeEvent("remove-original-split-schemas"),i=Mr(r);for(let p of Object.keys(s.mapping)){let a=qe(p),c=a[a.length-1];typeof c=="string"&&i&&Object.prototype.hasOwnProperty.call(i,c)&&i[c]===t[p]&&delete i[c];}o.timeEnd();},zm=({config:e,graph:t,logger:r,spec:s})=>{let o=r.timeEvent("split-schemas"),i=new Set,p={mapping:{},reverseMapping:{},schemas:{}},a=pr(s),c=a.split("/").length-1,m=l=>{if(l.startsWith(a)){let f=qe(l);if(f.length===c)return f[c-1]||""}return ""};for(let l of t.nodes.keys()){let f=m(l);f&&i.add(f);}for(let[l,f]of t.nodes){let d=m(l);if(!d||!(f.scopes?.has("read")||f.scopes?.has("write"))||!f.scopes?.has("normal"))continue;let y=$r(f.node);Lt(t,y,"writeOnly");let h=O({config:e.responses,name:d}),g=h===d?h:Lr({base:h,components:i});i.add(g),p.schemas[g]=y;let x=`${a}${g}`,S=$r(f.node);if(Lt(t,S,"readOnly"),no(y,S)&&no(y,f.node))continue;let k=O({config:e.requests,name:d}),E=k===d&&k!==g?k:Lr({base:k,components:i});i.add(E),p.schemas[E]=S;let C=`${a}${E}`;p.mapping[l]={read:x,write:C},p.reverseMapping[x]=l,p.reverseMapping[C]=l;}return o.timeEnd(),p},_m=({logger:e,spec:t,split:r})=>{let s=e.timeEvent("update-refs-in-spec"),o=pr(t),i=({context:p,currentPointer:a,inSchema:c,node:m,path:l})=>{if(m instanceof Array)m.forEach((f,d)=>i({context:p,currentPointer:a,inSchema:c,node:f,path:[...l,d]}));else if(m&&typeof m=="object"){let f=a,d=p;if(Rn(l)){let h=l[l.length-1];f=`${o}${h}`;let g=r.reverseMapping[f];if(g){let x=r.mapping[g];x?.read===f?d="read":x?.write===f&&(d="write");}}let y=Fm(l);if(y!==void 0){for(let h in m)Object.prototype.hasOwnProperty.call(m,h)&&i({context:y,currentPointer:f,inSchema:false,node:m[h],path:[...l,h]});return}for(let h in m){if(!Object.prototype.hasOwnProperty.call(m,h))continue;let g=m[h];if(!c){if(h==="requestBody"){i({context:"write",currentPointer:f,inSchema:false,node:g,path:[...l,h]});continue}if(h==="responses"){i({context:"read",currentPointer:f,inSchema:false,node:g,path:[...l,h]});continue}if(h==="parameters"&&Array.isArray(g)){g.forEach((x,S)=>{x&&typeof x=="object"&&"schema"in x&&i({context:"write",currentPointer:f,inSchema:true,node:x.schema,path:[...l,h,S,"schema"]}),x&&typeof x=="object"&&"content"in x&&i({context:"write",currentPointer:f,inSchema:false,node:x.content,path:[...l,h,S,"content"]});});continue}if(h==="headers"&&typeof g=="object"&&g!==null){for(let x in g)Object.prototype.hasOwnProperty.call(g,x)&&i({context:"read",currentPointer:f,inSchema:false,node:g[x],path:[...l,h,x]});continue}}if(Dm.has(h))i({context:d,currentPointer:f,inSchema:true,node:g,path:[...l,h]});else if(h==="$ref"&&typeof g=="string"){let x=r.mapping[g];x&&(x.read&&(!d||d==="read")?m[h]=x.read:x.write&&(!d||d==="write")&&(m[h]=x.write));}else i({context:d,currentPointer:f,inSchema:c,node:g,path:[...l,h]});}}};i({context:null,currentPointer:null,inSchema:false,node:t,path:[]}),s.timeEnd();},oa=({config:e,logger:t,spec:r})=>{let{graph:s}=ht(r,t),o=Bm(r,t),i=zm({config:e,graph:s,logger:t,spec:r});Km({logger:t,spec:r,split:i}),_m({logger:t,spec:r,split:i}),Wm({logger:t,originalSchemas:o,spec:r,split:i});};var cr=({context:e})=>{let{logger:t}=e,r=t.timeEvent("transform-openapi-spec");e.config.parser.transforms.enums.enabled&&na({config:e.config.parser.transforms.enums,spec:e.spec}),e.config.parser.transforms.propertiesRequiredByDefault&&sa({spec:e.spec}),e.config.parser.transforms.readWrite.enabled&&oa({config:e.config.parser.transforms.readWrite,logger:t,spec:e.spec}),r.timeEnd();};var w=({source:e,target:t})=>{let r={...t};if(e&&(e.cookie&&(r.cookie?r.cookie={...r.cookie,...e.cookie}:r.cookie=e.cookie),e.header&&(r.header?r.header={...r.header,...e.header}:r.header=e.header),e.path&&(r.path?r.path={...r.path,...e.path}:r.path=e.path),e.query&&(r.query?r.query={...r.query,...e.query}:r.query=e.query)),!!Object.keys(r).length)return r};var Hm=e=>/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(e),Qm=e=>e.map((t,r)=>typeof t=="number"?`[${t}]`:r===0?t:Hm(t)?`.${t}`:`['${t.replace(/"/g,"\\'")}']`).join(""),Zm=e=>{let t=Qm(e.path),r=e.severity==="error"?Ht__default.default.bold.red:Ht__default.default.bold.yellow,s=e.message.replace(/`([^`]+)`/g,(o,i)=>Ht__default.default.yellow(`\`${i}\``));return `${r(`[${e.severity.toUpperCase()}]`)} ${Ht__default.default.cyan(t)}: ${s}`},Um=({context:e,issue:t})=>e.config.logs.level==="silent"?false:t.severity==="error"?e.config.logs.level!=="warn":true,mr=({context:e,result:t})=>{for(let r of t.issues)Um({context:e,issue:r})&&console.log(Zm(r));t.valid||process.exit(1);};var ia=({logger:e,operations:t,preserveOrder:r,schemas:s,spec:o})=>{let i=e.timeEvent("filter-spec");if(o.definitions){let p={};if(r)for(let[a,c]of Object.entries(o.definitions))s.has(N("schema",a))&&(p[a]=c);else for(let a of s){let{name:c}=J(a),m=o.definitions[c];m&&(p[c]=m);}o.definitions=p;}if(o.paths)for(let p of Object.entries(o.paths)){let a=p[0],c=p[1];for(let m of G){if(!c[m])continue;let f=N("operation",D({method:m,path:a}));t.has(f)||delete c[m];}Object.keys(c).length||delete o.paths[a];}i.timeEnd();};var aa=/^(application\/(pdf|rtf|msword|vnd\.(ms-|openxmlformats-officedocument\.)|zip|x-(7z|tar|rar|zip|iso)|octet-stream|gzip|x-msdownload|json\+download|xml|x-yaml|x-7z-compressed|x-tar)|text\/(yaml|css|javascript)|audio\/(mpeg|wav)|video\/(mp4|x-matroska)|image\/(vnd\.adobe\.photoshop|svg\+xml))(; ?charset=[^;]+)?$/i,pa=/^application\/(.*\+)?json(;.*)?$/i,ca=/^multipart\/form-data(;.*)?$/i,ma=/^text\/[a-z0-9.+-]+(;.*)?$/i,la=/^application\/x-www-form-urlencoded(;.*)?$/i,fa=/^application\/octet-stream(;.*)?$/i,Ye=({mediaType:e})=>(aa.lastIndex=0,aa.test(e)),lr=({mediaType:e})=>{if(pa.lastIndex=0,pa.test(e))return "json";if(ca.lastIndex=0,ca.test(e))return "form-data";if(ma.lastIndex=0,ma.test(e))return "text";if(la.lastIndex=0,la.test(e))return "url-search-params";if(fa.lastIndex=0,fa.test(e))return "octet-stream"};var da=({content:e})=>{let{mediaType:t,schema:r}=e;return r&&"$ref"in r?{allOf:[{...r}]}:r?r.type==="string"&&!r.format&&Ye({mediaType:t})?{...r,format:"binary"}:r:Ye({mediaType:t})?{format:"binary",type:"string"}:void 0},io=({mimeTypes:e,response:t})=>{let r=[];for(let s of e??[])r.push({mediaType:s,schema:t.schema,type:lr({mediaType:s})});return r};function de(e){let t=`^(${e.keywords.join("|")})$`;return new RegExp(t)}var Le=(e,t,r)=>{let s=[];for(let o in t)t[o]===e&&s.push(o);return !s.length&&(!r||r())?[L(e)]:s};var Vr=({schema:e})=>{if(e.type)return e.type;if(e.properties)return "object"},Xm=({irSchema:e,schema:t})=>{t.example&&(e.example=t.example),t.description&&(e.description=t.description),t.title&&(e.title=t.title);},Pn=({irSchema:e,schema:t})=>{t.default!==void 0&&(e.default=t.default),t.exclusiveMaximum?t.maximum!==void 0&&(e.exclusiveMaximum=t.maximum):t.maximum!==void 0&&(e.maximum=t.maximum),t.exclusiveMinimum?t.minimum!==void 0&&(e.exclusiveMinimum=t.minimum):t.minimum!==void 0&&(e.minimum=t.minimum),t.format&&(e.format=t.format),t.maxItems!==void 0&&(e.maxItems=t.maxItems),t.maxLength!==void 0&&(e.maxLength=t.maxLength),t.minItems!==void 0&&(e.minItems=t.minItems),t.minLength!==void 0&&(e.minLength=t.minLength),t.pattern&&(e.pattern=t.pattern),t.readOnly&&(e.accessScope="read");},Jm=({context:e,irSchema:t={},schema:r,state:s})=>{r.maxItems&&r.maxItems===r.minItems?t.type="tuple":t.type="array";let o=[];if(r.items){let i=ge({context:e,schema:r.items,state:s});if(!o.length&&r.maxItems&&r.maxItems===r.minItems)o=Array(r.maxItems).fill(i);else if("$ref"in r.items)o.push(i);else {let p=r.items.allOf;p&&p.length>1&&!r.items["x-nullable"]?t={...t,...i}:o.push(i);}}return t=B({items:o,schema:t}),t},Gm=({irSchema:e={}})=>(e.type="boolean",e),Ym=({irSchema:e={},schema:t})=>(e.type=t.type,e),el=({context:e,irSchema:t={},schema:r,state:s})=>{t.type="object";let o={};for(let i in r.properties){let p=r.properties[i];if(typeof p!="boolean"){let a=ge({context:e,schema:p,state:s});o[i]=a;}}if(Object.keys(o).length&&(t.properties=o),r.additionalProperties===void 0)t.properties||(t.additionalProperties={type:"unknown"});else if(typeof r.additionalProperties=="boolean")s.inAllOf&&r.additionalProperties===false&&(!r.properties||!Object.keys(r.properties).length)||(t.additionalProperties={type:r.additionalProperties?"unknown":"never"});else {let i=ge({context:e,schema:r.additionalProperties,state:s});t.additionalProperties=i;}return r.required&&(t.required=r.required),t},tl=({irSchema:e={}})=>(e.type="string",e),fr=({schema:e})=>{let t={};return Xm({irSchema:t,schema:e}),t},rl=({context:e,schema:t,state:r})=>{let s=fr({schema:t}),o=[],i=Vr({schema:t}),p=t.allOf;for(let a of p){let c=r.inAllOf;"$ref"in a||(r.inAllOf=true);let m=ge({context:e,schema:a,state:r});if(r.inAllOf=c,r.inAllOf===void 0&&delete r.inAllOf,t.required&&(m.required?m.required=[...m.required,...t.required]:m.required=t.required),o.push(m),a.$ref){let l=e.resolveRef(a.$ref);if(l.discriminator&&r.$ref){let d=Le(r.$ref).map(h=>({const:h,type:"string"})),y={properties:{[l.discriminator]:d.length>1?{items:d,logicalOperator:"or"}:d[0]},type:"object"};l.required?.includes(l.discriminator)&&(y.required=[l.discriminator]),o.push(y);}}}if(i==="object"){let a=Dr({context:e,schema:{...t,type:"object"},state:r});if(a.properties){for(let c of a.required??[])if(!a.properties[c])for(let m of p){let l=m.$ref?e.resolveRef(m.$ref):m;if(Vr({schema:l})==="object"){let f=Dr({context:e,schema:{...l,type:"object"},state:r});if(f.properties?.[c]){a.properties[c]=f.properties[c];break}}}o.push(a);}}if(s=B({items:o,logicalOperator:"and",mutateSchemaOneItem:true,schema:s}),t["x-nullable"]){let a=[{type:"null"}];o.length&&a.unshift(s),s={items:a,logicalOperator:"or"},a[0].deprecated&&(s.deprecated=a[0].deprecated),a[0].description&&(s.description=a[0].description);}return s},nl=({context:e,schema:t,state:r})=>{let s=fr({schema:t});s.type="enum";let o=[];for(let[i,p]of t.enum.entries()){let a=typeof p,c;if(a==="string"||a==="number"||a==="boolean"?c=a:a==="object"&&Array.isArray(p)?c="array":p===null?t["x-nullable"]&&(c="null"):console.warn("\u{1F6A8}",`unhandled "${a}" typeof value "${p}" for enum`,t.enum),!c)continue;let m=Dr({context:e,schema:{description:t["x-enum-descriptions"]?.[i],title:t["x-enum-varnames"]?.[i]??t["x-enumNames"]?.[i],type:c==="null"?"string":c},state:r});m.const=p,c==="null"&&(m.type=c),m.type==="array"&&(m.type="tuple"),o.push(m);}return s=B({items:o,schema:s}),s},sl=({context:e,schema:t,state:r})=>{let s={};if(!t.$ref.startsWith("#/definitions/")&&!r.circularReferenceTracker.has(t.$ref)){r.refStack.push(t.$ref);let i=e.resolveRef(t.$ref),p=r.$ref;r.$ref=t.$ref;let a=ge({context:e,schema:i,state:r});return r.$ref=p,r.refStack.pop(),a}if(s.$ref=decodeURI(t.$ref),s.$ref=s.$ref.replace(/#\/definitions\/([^/]+)/g,"#/components/schemas/$1"),r.refStack.includes(t.$ref)&&(r.refStack[0]===t.$ref&&(r.circularRef=t.$ref),s.circular=true),!r.circularReferenceTracker.has(t.$ref)){r.refStack.push(t.$ref);let i=e.resolveRef(t.$ref),p=r.$ref;r.$ref=t.$ref,ge({context:e,schema:i,state:r}),r.circularRef&&r.refStack[0]===r.circularRef&&(s.circular=true),r.$ref=p,r.refStack.pop();}return s},ol=({context:e,irSchema:t,schema:r,state:s})=>{t||(t=fr({schema:r}));let o={};Pn({irSchema:o,schema:r}),o.default===null&&delete o.default;let i=[Dr({context:e,irSchema:o,schema:r,state:s}),{type:"null"}];return t=B({items:i,schema:t}),t},il=({context:e,schema:t,state:r})=>{let s=fr({schema:t});Pn({irSchema:s,schema:t});let o=Vr({schema:t});return o?t["x-nullable"]?ol({context:e,irSchema:s,schema:{...t,type:o},state:r}):Dr({context:e,irSchema:s,schema:{...t,type:o},state:r}):s},Dr=({context:e,irSchema:t,schema:r,state:s})=>{switch(t||(t=fr({schema:r}),Pn({irSchema:t,schema:r})),r.type){case "array":return Jm({context:e,irSchema:t,schema:r,state:s});case "boolean":return Gm({irSchema:t});case "integer":case "number":return Ym({irSchema:t,schema:r});case "object":return el({context:e,irSchema:t,schema:r,state:s});case "string":return tl({irSchema:t});default:return ua({irSchema:t,schema:r})}},ua=({irSchema:e,schema:t})=>(e||(e=fr({schema:t})),e.type="unknown",Pn({irSchema:e,schema:t}),e),ge=({context:e,schema:t,state:r})=>(r||(r={circularReferenceTracker:new Set,refStack:[]}),r.$ref&&r.circularReferenceTracker.add(r.$ref),t.$ref?sl({context:e,schema:t,state:r}):t.enum?nl({context:e,schema:t,state:r}):t.allOf?rl({context:e,schema:t,state:r}):t.type||t.properties?il({context:e,schema:t,state:r}):ua({schema:t})),ya=({$ref:e,context:t,schema:r})=>{t.ir.components||(t.ir.components={}),t.ir.components.schemas||(t.ir.components.schemas={}),t.ir.components.schemas[L(e)]=ge({context:t,schema:r,state:{$ref:e,circularReferenceTracker:new Set,refStack:[e]}});};var al=e=>e==="boolean"||e==="integer"||e==="number"||e==="string",gt=({context:e,name:t,schema:r})=>{if(de(e.config.parser.pagination).test(t))return true;if("$ref"in r){let o=e.resolveRef(r.$ref??"");if("in"in o&&o.in){let i="schema"in o?o.schema:{...o,in:void 0};return gt({context:e,name:t,schema:i})}return gt({context:e,name:t,schema:o})}if("in"in r){if(!r.in)return false;let o="schema"in r?r.schema:{...r,in:void 0};return gt({context:e,name:t,schema:o})}for(let o in r.properties)if(de(e.config.parser.pagination).test(o)){let p=r.properties[o];if(typeof p!="boolean"&&!("$ref"in p)){let a=Vr({schema:p});if(al(a))return o}}for(let o of r.allOf??[]){let i=gt({context:e,name:t,schema:o});if(i)return i}return false};var pl=({irOperation:e,operation:t})=>{t.deprecated!==void 0&&(e.deprecated=t.deprecated),t.description&&(e.description=t.description),t.summary&&(e.summary=t.summary),t.tags?.length&&(e.tags=t.tags);},cl=({context:e,method:t,operation:r,path:s,state:o})=>{let i={id:Mt({context:e,id:r.operationId,method:t,path:s,state:o}),method:t,path:s};return r.operationId&&(i.operationId=r.operationId),pl({irOperation:i,operation:r}),i},ml=({context:e,method:t,operation:r,path:s,securitySchemesMap:o,state:i})=>{let p=cl({context:e,method:t,operation:r,path:s,state:i});r.parameters&&(p.parameters=r.parameters);let a=false,c={mediaType:"",schema:{properties:{},required:[],type:"object"}},m=[];for(let l of r.requestBody??[]){let f="$ref"in l?e.resolveRef(l.$ref):l,d=f.in==="body"?f.schema:{...f,format:f.type==="file"?"binary":f.format,required:void 0,type:f.type==="file"?"string":f.type},y=io({mimeTypes:r.consumes,response:{schema:d}}),h=y.find(g=>g.type==="json")||y[0];if(h){let g=gt({context:e,name:"",schema:h.schema&&"$ref"in h.schema?{allOf:[{...h.schema}],description:f.description}:{description:f.description,...h.schema}}),x=ge({context:e,schema:"$ref"in f?{allOf:[{...f,$ref:f.$ref,required:[],type:"string"}],description:f.description}:h.schema&&"$ref"in h.schema?{allOf:[{...h.schema}],description:f.description}:{description:f.description,...h.schema},state:void 0});c.mediaType=h.mediaType,f.in==="body"?c.schema=x:(c.schema.properties[f.name]=x,f.required&&m.push(f.name)),g&&(c.pagination=g),h.type&&(c.type=h.type);}f.required&&(a=true);}c.mediaType&&(m.length&&(c.schema.required=m),p.body=c,a&&(p.body.required=a));for(let l in r.responses){p.responses||(p.responses={});let f=r.responses[l],d="$ref"in f?e.resolveRef(f.$ref):f,y=io({mimeTypes:r.produces?r.produces:["application/json"],response:d}),h=y.find(g=>g.type==="json")||y[0];h?p.responses[l]={mediaType:h.mediaType,schema:ge({context:e,schema:{description:d.description,...da({content:h})},state:void 0})}:p.responses[l]={schema:{description:d.description,type:l==="204"?"void":"unknown"}};}if(r.security){let l=new Map;for(let f of r.security)for(let d in f){let y=o.get(d);if(!y)continue;let h;if(y.type==="apiKey"&&(h=y),y.type==="basic"&&(h={description:y.description,scheme:"basic",type:"http"}),y.type==="oauth2")switch(h={description:y.description,flows:{},type:"oauth2"},y.flow){case "accessCode":h.flows.authorizationCode={authorizationUrl:y.authorizationUrl,scopes:y.scopes,tokenUrl:y.tokenUrl};break;case "application":h.flows.clientCredentials={scopes:y.scopes,tokenUrl:y.tokenUrl};break;case "implicit":h.flows.implicit={authorizationUrl:y.authorizationUrl,scopes:y.scopes};break;case "password":h.flows.password={scopes:y.scopes,tokenUrl:y.tokenUrl};break}h&&l.set(d,h);}l.size&&(p.security=Array.from(l.values()));}return p},xt=({context:e,method:t,operation:r,path:s,securitySchemesMap:o,state:i})=>{e.ir.paths||(e.ir.paths={}),e.ir.paths[s]||(e.ir.paths[s]={}),e.ir.paths[s][t]=ml({context:e,method:t,operation:r,path:s,securitySchemesMap:o,state:i});};var ll=e=>{switch(e){case "multi":return true;case "csv":case "pipes":case "ssv":case "tsv":default:return false}},fl=e=>{switch(e){case "header":case "path":return "simple";case "query":default:return "form"}},et=({context:e,operation:t,parameters:r})=>{if(!r||!Object.keys(r).length)return;let s={};for(let o of r){let i="$ref"in o?e.dereference(o):o;if(i.in==="body"||i.in==="formData"){t.requestBody||(t.requestBody=[]),t.requestBody.push(i);continue}s[i.in]||(s[i.in]={}),s[i.in][i.name.toLocaleLowerCase()]=dl({$ref:`#/todo/real/path/to/parameter/${i.name}`,context:e,parameter:i});}return s},dl=({$ref:e,context:t,parameter:r})=>{let s=r,o=s&&"$ref"in s?{allOf:[{...s,$ref:s.$ref,required:Array.isArray(s.required)?s.required:[],type:s.type}],description:r.description}:{description:r.description,...s,required:Array.isArray(s.required)?s.required:[],type:s.type},i=gt({context:t,name:r.name,schema:o}),p=fl(r.in),m={allowReserved:false,explode:ll(r.collectionFormat),location:r.in,name:r.name,schema:ge({context:t,schema:o,state:{$ref:e,circularReferenceTracker:new Set,refStack:[e]}}),style:p};return r.description&&(m.description=r.description),i&&(m.pagination=i),r.required&&(m.required=r.required),m};var ha=/^(([^:/?#]+):)?((\/\/)?([^:/?#]*)(:?([^/?#]*)))?([^?#]*)(\?([^#]*))?(#(.*))?/,Ve=e=>{let t={host:"",path:"",port:"",protocol:""};ha.lastIndex=0;let r=e.match(ha);if(!r)return t;let s=r[5]||"";if(s==="."||s==="..")return t;let o=r[8]||"",i=r[2]||"";return i.length===1?t:{host:s,path:o==="/"?"":o,port:r[7]||"",protocol:i}};var ga=({context:e})=>{let t=e.spec.schemes??[],r=e.spec.host??"",s=e.spec.basePath??"";for(let i of e.config.input)if(typeof i.path=="string"){let p=Ve(i.path);t.length||p.protocol&&(t=[p.protocol]),r||(r=`${p.host}${p.port?`:${p.port}`:""}`);}t.length||(t=[""]);let o=t.map(i=>`${i?`${i}://`:""}${r}${s}`).filter(Boolean);o.length&&(e.ir.servers=o.map(i=>({url:i})));};var xa=(e,t)=>{let r=t.timeEvent("validate"),s=[],o=new Map;if(e.paths)for(let i of Object.entries(e.paths)){let p=i[0],a=i[1];for(let c of G){if(c==="trace")continue;let m=a[c];if(!m)continue;let l=D({method:c,path:p});m.operationId&&(o.has(m.operationId)?s.push({code:"duplicate_key",context:{key:"operationId",value:m.operationId},message:"Duplicate `operationId` found. Each `operationId` must be unique.",path:["paths",p,c,"operationId"],severity:"error"}):o.set(m.operationId,l));}}return r.timeEnd(),{issues:s,valid:!s.some(i=>i.severity==="error")}};var ao=e=>{if(e.config.parser.validate_EXPERIMENTAL){let o=xa(e.spec,e.logger);mr({context:e,result:o});}if(or(e.config.parser.filters)){let o=sr(e.config.parser.filters,e.spec,e.logger),{graph:i}=ht(e.spec,e.logger),{resourceMetadata:p}=ar(i,e.logger),a=ir({filters:o,logger:e.logger,resourceMetadata:p});ia({...a,logger:e.logger,preserveOrder:o.preserveOrder,spec:e.spec});}cr({context:e});let r={ids:new Map},s=new Map;for(let o in e.spec.securityDefinitions){let i=e.spec.securityDefinitions[o];s.set(o,i);}if(e.spec.definitions)for(let o in e.spec.definitions){let i=`#/definitions/${o}`,p=e.spec.definitions[o];ya({$ref:i,context:e,schema:p});}ga({context:e});for(let o in e.spec.paths){if(o.startsWith("x-"))continue;let i=e.spec.paths[o],p=i.$ref?{...e.resolveRef(i.$ref),...i}:i,a={consumes:e.spec.consumes,produces:e.spec.produces,responses:{},security:e.spec.security},c={context:e,operation:{...a,parameters:et({context:e,operation:a,parameters:p.parameters})},path:o,securitySchemesMap:s,state:r};if(p.delete){let m=w({source:et({context:e,operation:p.delete,parameters:p.delete.parameters}),target:c.operation.parameters});xt({...c,method:"delete",operation:{...c.operation,...p.delete,parameters:m}});}if(p.get){let m=w({source:et({context:e,operation:p.get,parameters:p.get.parameters}),target:c.operation.parameters});xt({...c,method:"get",operation:{...c.operation,...p.get,parameters:m}});}if(p.head){let m=w({source:et({context:e,operation:p.head,parameters:p.head.parameters}),target:c.operation.parameters});xt({...c,method:"head",operation:{...c.operation,...p.head,parameters:m}});}if(p.options){let m=w({source:et({context:e,operation:p.options,parameters:p.options.parameters}),target:c.operation.parameters});xt({...c,method:"options",operation:{...c.operation,...p.options,parameters:m}});}if(p.patch){let m=w({source:et({context:e,operation:p.patch,parameters:p.patch.parameters}),target:c.operation.parameters});xt({...c,method:"patch",operation:{...c.operation,...p.patch,parameters:m}});}if(p.post){let m=w({source:et({context:e,operation:p.post,parameters:p.post.parameters}),target:c.operation.parameters});xt({...c,method:"post",operation:{...c.operation,...p.post,parameters:m}});}if(p.put){let m=w({source:et({context:e,operation:p.put,parameters:p.put.parameters}),target:c.operation.parameters});xt({...c,method:"put",operation:{...c.operation,...p.put,parameters:m}});}}};var ba=({logger:e,operations:t,parameters:r,preserveOrder:s,requestBodies:o,responses:i,schemas:p,spec:a})=>{let c=e.timeEvent("filter-spec");if(a.components){if(a.components.parameters){let m={};if(s)for(let[l,f]of Object.entries(a.components.parameters))r.has(N("parameter",l))&&(m[l]=f);else for(let l of r){let{name:f}=J(l),d=a.components.parameters[f];d&&(m[f]=d);}a.components.parameters=m;}if(a.components.requestBodies){let m={};if(s)for(let[l,f]of Object.entries(a.components.requestBodies))o.has(N("body",l))&&(m[l]=f);else for(let l of o){let{name:f}=J(l),d=a.components.requestBodies[f];d&&(m[f]=d);}a.components.requestBodies=m;}if(a.components.responses){let m={};if(s)for(let[l,f]of Object.entries(a.components.responses))i.has(N("response",l))&&(m[l]=f);else for(let l of i){let{name:f}=J(l),d=a.components.responses[f];d&&(m[f]=d);}a.components.responses=m;}if(a.components.schemas){let m={};if(s)for(let[l,f]of Object.entries(a.components.schemas))p.has(N("schema",l))&&(m[l]=f);else for(let l of p){let{name:f}=J(l),d=a.components.schemas[f];d&&(m[f]=d);}a.components.schemas=m;}}if(a.paths)for(let m of Object.entries(a.paths)){let l=m[0],f=m[1];for(let d of G){if(!f[d])continue;let h=N("operation",D({method:d,path:l}));t.has(h)||delete f[d];}Object.keys(f).length||delete a.paths[l];}c.timeEnd();};var Sa=({content:e})=>{let{mediaType:t,schema:r}=e;return r&&"$ref"in r?{allOf:[{...r}]}:r?r.type==="string"&&!r.format&&Ye({mediaType:t})?{...r,format:"binary"}:r:Ye({mediaType:t})?{format:"binary",type:"string"}:void 0},tt=({content:e})=>{let t=[];for(let r in e)t.push({mediaType:r,schema:e[r].schema,type:lr({mediaType:r})});return t};var Vt=({schema:e})=>{if(e.type)return e.type;if(e.properties)return "object"},ul=({irSchema:e,schema:t})=>{t.deprecated!==void 0&&(e.deprecated=t.deprecated),t.example&&(e.example=t.example),t.description&&(e.description=t.description),t.title&&(e.title=t.title);},En=({irSchema:e,schema:t})=>{t.default!==void 0&&(e.default=t.default),t.exclusiveMaximum?t.maximum!==void 0&&(e.exclusiveMaximum=t.maximum):t.maximum!==void 0&&(e.maximum=t.maximum),t.exclusiveMinimum?t.minimum!==void 0&&(e.exclusiveMinimum=t.minimum):t.minimum!==void 0&&(e.minimum=t.minimum),t.format&&(e.format=t.format),t.maxItems!==void 0&&(e.maxItems=t.maxItems),t.maxLength!==void 0&&(e.maxLength=t.maxLength),t.minItems!==void 0&&(e.minItems=t.minItems),t.minLength!==void 0&&(e.minLength=t.minLength),t.pattern&&(e.pattern=t.pattern),t.readOnly?e.accessScope="read":t.writeOnly&&(e.accessScope="write");},yl=({context:e,irSchema:t={},schema:r,state:s})=>{r.maxItems&&r.maxItems===r.minItems?t.type="tuple":t.type="array";let o=[];if(r.items){let i=re({context:e,schema:r.items,state:s});if(!o.length&&r.maxItems&&r.maxItems===r.minItems)o=Array(r.maxItems).fill(i);else if("$ref"in r.items)o.push(i);else {let p=r.items.allOf||r.items.anyOf||r.items.oneOf;p&&p.length>1&&!r.items.nullable?t={...t,...i}:o.push(i);}}return t=B({items:o,schema:t}),t},hl=({irSchema:e={}})=>(e.type="boolean",e),gl=({irSchema:e={},schema:t})=>(e.type=t.type,e),xl=({context:e,irSchema:t={},schema:r,state:s})=>{t.type="object";let o={};for(let i in r.properties){let p=r.properties[i];typeof p=="boolean"||(o[i]=re({context:e,schema:p,state:s}));}if(Object.keys(o).length&&(t.properties=o),r.additionalProperties===void 0)t.properties||(t.additionalProperties={type:"unknown"});else if(typeof r.additionalProperties=="boolean")s.inAllOf&&r.additionalProperties===false&&(!r.properties||!Object.keys(r.properties).length)||(t.additionalProperties={type:r.additionalProperties?"unknown":"never"});else {let i=re({context:e,schema:r.additionalProperties,state:s});t.additionalProperties=i;}return r.required&&(t.required=r.required),t},bl=({irSchema:e={}})=>(e.type="string",e),bt=({schema:e})=>{let t={};return ul({irSchema:t,schema:e}),t},Sl=({context:e,schema:t,state:r})=>{let s=bt({schema:t}),o=[],i=Vt({schema:t}),p=t.allOf;for(let a of p){let c=r.inAllOf;"$ref"in a||(r.inAllOf=true);let m=re({context:e,schema:a,state:r});if(r.inAllOf=c,r.inAllOf===void 0&&delete r.inAllOf,t.required&&(m.required?m.required=[...m.required,...t.required]:m.required=t.required),o.push(m),"$ref"in a){let l=e.resolveRef(a.$ref);if(l.discriminator&&r.$ref){let f=Le(r.$ref,l.discriminator.mapping,l.oneOf?()=>l.oneOf.some(d=>"$ref"in d&&d.$ref===r.$ref):void 0);if(f.length>0){let d=f.map(h=>({const:h,type:"string"})),y={properties:{[l.discriminator.propertyName]:d.length>1?{items:d,logicalOperator:"or"}:d[0]},type:"object"};l.required?.includes(l.discriminator.propertyName)&&(y.required=[l.discriminator.propertyName]),o.push(y);}}}}if(i==="object"){let a=Dt({context:e,schema:{...t,type:"object"},state:r});if(a.properties){for(let c of a.required??[])if(!a.properties[c])for(let m of p){let l="$ref"in m?e.resolveRef(m.$ref):m;if(Vt({schema:l})==="object"){let f=Dt({context:e,schema:{...l,type:"object"},state:r});if(f.properties?.[c]){a.properties[c]=f.properties[c];break}}}o.push(a);}}if(s=B({items:o,logicalOperator:"and",mutateSchemaOneItem:true,schema:s}),t.nullable){let a=[{type:"null"}];o.length&&a.unshift(s),s={items:a,logicalOperator:"or"},a[0].deprecated&&(s.deprecated=a[0].deprecated),a[0].description&&(s.description=a[0].description);}return s},Ol=({context:e,schema:t,state:r})=>{let s=bt({schema:t}),o=[],i=Vt({schema:t}),p=t.anyOf;for(let a of p){let c=re({context:e,schema:a,state:r});if(t.discriminator&&c.$ref!=null){let l=Le(c.$ref,t.discriminator.mapping).map(d=>({const:d,type:"string"}));c={items:[{properties:{[t.discriminator.propertyName]:l.length>1?{items:l,logicalOperator:"or"}:l[0]},type:"object"},c],logicalOperator:"and"};}o.push(c);}if(t.nullable&&o.push({type:"null"}),s=B({items:o,mutateSchemaOneItem:true,schema:s}),i==="object"){let a=Dt({context:e,schema:{...t,type:"object"},state:r});a.properties&&(s={items:[s,a],logicalOperator:"and"});}return s},Tl=({context:e,schema:t,state:r})=>{let s=bt({schema:t});s.type="enum";let o=[];for(let[i,p]of t.enum.entries()){let a=typeof p,c;if(a==="string"||a==="number"||a==="boolean"?c=a:a==="object"&&Array.isArray(p)?c="array":p===null?t.nullable&&(c="null"):console.warn("\u{1F6A8}",`unhandled "${a}" typeof value "${p}" for enum`,t.enum),!c)continue;let m=Dt({context:e,schema:{description:t["x-enum-descriptions"]?.[i],title:t["x-enum-varnames"]?.[i]??t["x-enumNames"]?.[i],type:c==="null"?"string":c},state:r});m.const=p,c==="null"&&(m.type=c),m.type==="array"&&(m.type="tuple"),o.push(m);}return s=B({items:o,schema:s}),s},Rl=({context:e,schema:t,state:r})=>{let s=bt({schema:t}),o=[],i=Vt({schema:t}),p=t.oneOf;for(let a of p){let c=re({context:e,schema:a,state:r});if(t.discriminator&&c.$ref!=null){let l=Le(c.$ref,t.discriminator.mapping).map(d=>({const:d,type:"string"}));c={items:[{properties:{[t.discriminator.propertyName]:l.length>1?{items:l,logicalOperator:"or"}:l[0]},required:[t.discriminator.propertyName],type:"object"},c],logicalOperator:"and"};}c.logicalOperator==="or"&&c.type!=="array"&&c.items?o=o.concat(c.items):o.push(c);}if(t.nullable&&o.push({type:"null"}),s=B({items:o,mutateSchemaOneItem:true,schema:s}),i==="object"){let a=Dt({context:e,schema:{...t,type:"object"},state:r});a.properties&&(s={items:[s,a],logicalOperator:"and"});}return s},Al=({context:e,schema:t,state:r})=>{if(!t.$ref.startsWith("#/components/")&&!r.circularReferenceTracker.has(t.$ref)){r.refStack.push(t.$ref);let i=e.resolveRef(t.$ref),p=r.$ref;r.$ref=t.$ref;let a=re({context:e,schema:i,state:r});return r.$ref=p,r.refStack.pop(),a}let o={};if(o.$ref=decodeURI(t.$ref),r.refStack.includes(t.$ref)&&(r.refStack[0]===t.$ref&&(r.circularRef=t.$ref),o.circular=true),!r.circularReferenceTracker.has(t.$ref)){r.refStack.push(t.$ref);let i=e.resolveRef(t.$ref),p=r.$ref;r.$ref=t.$ref,re({context:e,schema:i,state:r}),r.circularRef&&r.refStack[0]===r.circularRef&&(o.circular=true),r.$ref=p,r.refStack.pop();}return o},Pl=({context:e,irSchema:t,schema:r,state:s})=>{t||(t=bt({schema:r}));let o={};En({irSchema:o,schema:r}),o.default===null&&delete o.default;let i=[Dt({context:e,irSchema:o,schema:r,state:s}),{type:"null"}];return t=B({items:i,schema:t}),t},El=({context:e,schema:t,state:r})=>{let s=bt({schema:t});En({irSchema:s,schema:t});let o=Vt({schema:t});return o?t.nullable?Pl({context:e,irSchema:s,schema:{...t,type:o},state:r}):Dt({context:e,irSchema:s,schema:{...t,type:o},state:r}):s},Dt=({context:e,irSchema:t,schema:r,state:s})=>{switch(t||(t=bt({schema:r}),En({irSchema:t,schema:r})),r.type){case "array":return yl({context:e,irSchema:t,schema:r,state:s});case "boolean":return hl({irSchema:t});case "integer":case "number":return gl({irSchema:t,schema:r});case "object":return xl({context:e,irSchema:t,schema:r,state:s});case "string":return bl({irSchema:t});default:return Oa({irSchema:t,schema:r})}},Oa=({irSchema:e,schema:t})=>(e||(e=bt({schema:t})),e.type="unknown",En({irSchema:e,schema:t}),e),re=({context:e,schema:t,state:r})=>(r||(r={circularReferenceTracker:new Set,refStack:[]}),r.$ref&&r.circularReferenceTracker.add(r.$ref),"$ref"in t?Al({context:e,schema:t,state:r}):t.enum?Tl({context:e,schema:t,state:r}):t.allOf?Sl({context:e,schema:t,state:r}):t.anyOf?Ol({context:e,schema:t,state:r}):t.oneOf?Rl({context:e,schema:t,state:r}):t.type||t.properties?El({context:e,schema:t,state:r}):Oa({schema:t})),Ta=({$ref:e,context:t,schema:r})=>{t.ir.components||(t.ir.components={}),t.ir.components.schemas||(t.ir.components.schemas={}),t.ir.components.schemas[L(e)]=re({context:t,schema:r,state:{$ref:e,circularReferenceTracker:new Set,refStack:[e]}});};var Il=e=>e==="boolean"||e==="integer"||e==="number"||e==="string",Ft=({context:e,name:t,schema:r})=>{if(de(e.config.parser.pagination).test(t))return true;if("$ref"in r){let o=e.resolveRef(r.$ref);if("content"in o||"in"in o){let i;if("in"in o&&(i=o.schema),!i){let p=tt({content:o.content}),a=p.find(c=>c.type==="json")||p[0];a?.schema&&(i=a.schema);}return i?Ft({context:e,name:t,schema:i}):false}return Ft({context:e,name:t,schema:o})}for(let o in r.properties)if(de(e.config.parser.pagination).test(o)){let p=r.properties[o];if(typeof p!="boolean"&&!("$ref"in p)){let a=Vt({schema:p});if(Il(a))return o}}for(let o of r.allOf??[]){let i=Ft({context:e,name:t,schema:o});if(i)return i}return false};var kl=({irOperation:e,operation:t})=>{t.deprecated!==void 0&&(e.deprecated=t.deprecated),t.description&&(e.description=t.description),t.summary&&(e.summary=t.summary),t.tags?.length&&(e.tags=t.tags);},jl=({context:e,method:t,operation:r,path:s,state:o})=>{let i={id:Mt({context:e,id:r.operationId,method:t,path:s,state:o}),method:t,path:s};return r.operationId&&(i.operationId=r.operationId),kl({irOperation:i,operation:r}),i},Nl=({context:e,method:t,operation:r,path:s,securitySchemesMap:o,state:i})=>{let p=jl({context:e,method:t,operation:r,path:s,state:i});if(r.parameters&&(p.parameters=r.parameters),r.requestBody){let a="$ref"in r.requestBody?e.resolveRef(r.requestBody.$ref):r.requestBody,c=tt({content:a.content}),m=c.find(l=>l.type==="json")||c[0];if(m){let l=Ft({context:e,name:"",schema:m.schema&&"$ref"in m.schema?{allOf:[{...m.schema}],description:a.description}:{description:a.description,...m.schema}});p.body={mediaType:m.mediaType,schema:re({context:e,schema:"$ref"in r.requestBody?{allOf:[{...r.requestBody}],description:a.description}:m.schema&&"$ref"in m.schema?{allOf:[{...m.schema}],description:a.description}:{description:a.description,...m.schema},state:void 0})},l&&(p.body.pagination=l),a.required&&(p.body.required=a.required),m.type&&(p.body.type=m.type);}}for(let a in r.responses){p.responses||(p.responses={});let c=r.responses[a],m="$ref"in c?e.resolveRef(c.$ref):c,l=tt({content:m.content}),f=l.find(d=>d.type==="json")||l[0];f?p.responses[a]={mediaType:f.mediaType,schema:re({context:e,schema:{description:m.description,...Sa({content:f})},state:void 0})}:p.responses[a]={schema:{description:m.description,type:a==="204"?"void":"unknown"}};}if(r.security){let a=new Map;for(let c of r.security)for(let m in c){let l=o.get(m);l&&a.set(m,l);}a.size&&(p.security=Array.from(a.values()));}return p},rt=({context:e,method:t,operation:r,path:s,securitySchemesMap:o,state:i})=>{e.ir.paths||(e.ir.paths={}),e.ir.paths[s]||(e.ir.paths[s]={}),r.servers&&(e.ir.servers=[...e.ir.servers??[],...r.servers]),e.ir.paths[s][t]=Nl({context:e,method:t,operation:r,path:s,securitySchemesMap:o,state:i});};var Cl=e=>{switch(e){case "query":return false;default:return}},vl=e=>{switch(e){case "deepObject":case "form":return true;default:return false}},wl=e=>{switch(e){case "header":case "path":return "simple";case "cookie":case "query":return "form"}},De=({context:e,parameters:t})=>{if(!t||!Object.keys(t).length)return;let r={};for(let s of t){let o="$ref"in s?e.dereference(s):s;r[o.in]||(r[o.in]={}),r[o.in][o.name.toLocaleLowerCase()]=Ra({$ref:`#/todo/real/path/to/parameter/${o.name}`,context:e,parameter:o});}return r},Ra=({$ref:e,context:t,parameter:r})=>{let s=r.schema;if(!s){let l=tt({content:r.content}),f=l.find(d=>d.type==="json")||l[0];f&&(s=f.schema);}let o=s&&"$ref"in s?{allOf:[{...s}],deprecated:r.deprecated,description:r.description}:{deprecated:r.deprecated,description:r.description,...s},i=Ft({context:t,name:r.name,schema:o}),p=r.style||wl(r.in),a=r.explode!==void 0?r.explode:vl(p),m={allowReserved:r.allowReserved!==void 0?r.allowReserved:Cl(r.in),explode:a,location:r.in,name:r.name,schema:re({context:t,schema:o,state:{$ref:e,circularReferenceTracker:new Set,refStack:[e]}}),style:p};return r.deprecated&&(m.deprecated=r.deprecated),r.description&&(m.description=r.description),i&&(m.pagination=i),r.required&&(m.required=r.required),m},Aa=({$ref:e,context:t,parameter:r})=>{t.ir.components||(t.ir.components={}),t.ir.components.parameters||(t.ir.components.parameters={}),t.ir.components.parameters[L(e)]=Ra({$ref:e,context:t,parameter:r});};var ql=({$ref:e,context:t,requestBody:r})=>{let s=tt({content:r.content}),o=s.find(c=>c.type==="json")||s[0],i=o?o.schema:void 0,p={description:r.description,...i},a={schema:re({context:t,schema:p,state:{$ref:e,circularReferenceTracker:new Set,refStack:[e]}})};return r.description&&(a.description=r.description),r.required&&(a.required=r.required),a},Pa=({$ref:e,context:t,requestBody:r})=>{t.ir.components||(t.ir.components={}),t.ir.components.requestBodies||(t.ir.components.requestBodies={}),t.ir.components.requestBodies[L(e)]=ql({$ref:e,context:t,requestBody:r});};var Ea=({context:e})=>{if(e.spec.servers){e.ir.servers=e.spec.servers;return}for(let t of e.config.input)if(typeof t.path=="string"){let r=Ve(t.path);e.ir.servers=[{url:`${r.protocol?`${r.protocol}://`:""}${r.host}${r.port?`:${r.port}`:""}`}];}e.ir.servers||(e.ir.servers=[{url:"/"}]);};var Ia=(e,t)=>{let r=t.timeEvent("validate"),s=[],o=new Map;if(e.paths)for(let i of Object.entries(e.paths)){let p=i[0],a=i[1];for(let c of G){let m=a[c];if(!m)continue;let l=D({method:c,path:p});m.operationId&&(o.has(m.operationId)?s.push({code:"duplicate_key",context:{key:"operationId",value:m.operationId},message:"Duplicate `operationId` found. Each `operationId` must be unique.",path:["paths",p,c,"operationId"],severity:"error"}):o.set(m.operationId,l));}}if(e.servers){(typeof e.servers!="object"||!Array.isArray(e.servers))&&s.push({code:"invalid_type",message:"`servers` must be an array.",path:[],severity:"error"});for(let i=0;i<e.servers.length;i++){let p=e.servers[i];!p||typeof p!="object"?s.push({code:"invalid_type",context:{actual:typeof p,expected:"object"},message:"Each entry in `servers` must be an object.",path:["servers",i],severity:"error"}):p.url||s.push({code:"missing_required_field",context:{field:"url"},message:"Missing required field `url` in server object.",path:["servers",i],severity:"error"});}}return r.timeEnd(),{issues:s,valid:!s.some(i=>i.severity==="error")}};var po=e=>{if(e.config.parser.validate_EXPERIMENTAL){let o=Ia(e.spec,e.logger);mr({context:e,result:o});}if(or(e.config.parser.filters)){let o=sr(e.config.parser.filters,e.spec,e.logger),{graph:i}=ht(e.spec,e.logger),{resourceMetadata:p}=ar(i,e.logger),a=ir({filters:o,logger:e.logger,resourceMetadata:p});ba({...a,logger:e.logger,preserveOrder:o.preserveOrder,spec:e.spec});}cr({context:e});let r={ids:new Map},s=new Map;if(e.spec.components){for(let o in e.spec.components.securitySchemes){let i=e.spec.components.securitySchemes[o],p="$ref"in i?e.resolveRef(i.$ref):i;s.set(o,p);}for(let o in e.spec.components.parameters){let i=`#/components/parameters/${o}`,p=e.spec.components.parameters[o],a="$ref"in p?e.resolveRef(p.$ref):p;Aa({$ref:i,context:e,parameter:a});}for(let o in e.spec.components.requestBodies){let i=`#/components/requestBodies/${o}`,p=e.spec.components.requestBodies[o],a="$ref"in p?e.resolveRef(p.$ref):p;Pa({$ref:i,context:e,requestBody:a});}for(let o in e.spec.components.schemas){let i=`#/components/schemas/${o}`,p=e.spec.components.schemas[o];Ta({$ref:i,context:e,schema:p});}}Ea({context:e});for(let o in e.spec.paths){let i=e.spec.paths[o],p=i.$ref?{...e.resolveRef(i.$ref),...i}:i,a={context:e,operation:{description:p.description,parameters:De({context:e,parameters:p.parameters}),security:e.spec.security,servers:p.servers,summary:p.summary},path:o,securitySchemesMap:s,state:r};p.delete&&rt({...a,method:"delete",operation:{...a.operation,...p.delete,parameters:w({source:De({context:e,parameters:p.delete.parameters}),target:a.operation.parameters})}}),p.get&&rt({...a,method:"get",operation:{...a.operation,...p.get,parameters:w({source:De({context:e,parameters:p.get.parameters}),target:a.operation.parameters})}}),p.head&&rt({...a,method:"head",operation:{...a.operation,...p.head,parameters:w({source:De({context:e,parameters:p.head.parameters}),target:a.operation.parameters})}}),p.options&&rt({...a,method:"options",operation:{...a.operation,...p.options,parameters:w({source:De({context:e,parameters:p.options.parameters}),target:a.operation.parameters})}}),p.patch&&rt({...a,method:"patch",operation:{...a.operation,...p.patch,parameters:w({source:De({context:e,parameters:p.patch.parameters}),target:a.operation.parameters})}}),p.post&&rt({...a,method:"post",operation:{...a.operation,...p.post,parameters:w({source:De({context:e,parameters:p.post.parameters}),target:a.operation.parameters})}}),p.put&&rt({...a,method:"put",operation:{...a.operation,...p.put,parameters:w({source:De({context:e,parameters:p.put.parameters}),target:a.operation.parameters})}}),p.trace&&rt({...a,method:"trace",operation:{...a.operation,...p.trace,parameters:w({source:De({context:e,parameters:p.trace.parameters}),target:a.operation.parameters})}});}};var ka=({logger:e,operations:t,parameters:r,preserveOrder:s,requestBodies:o,responses:i,schemas:p,spec:a})=>{let c=e.timeEvent("filter-spec");if(a.components){if(a.components.parameters){let m={};if(s)for(let[l,f]of Object.entries(a.components.parameters))r.has(N("parameter",l))&&(m[l]=f);else for(let l of r){let{name:f}=J(l),d=a.components.parameters[f];d&&(m[f]=d);}a.components.parameters=m;}if(a.components.requestBodies){let m={};if(s)for(let[l,f]of Object.entries(a.components.requestBodies))o.has(N("body",l))&&(m[l]=f);else for(let l of o){let{name:f}=J(l),d=a.components.requestBodies[f];d&&(m[f]=d);}a.components.requestBodies=m;}if(a.components.responses){let m={};if(s)for(let[l,f]of Object.entries(a.components.responses))i.has(N("response",l))&&(m[l]=f);else for(let l of i){let{name:f}=J(l),d=a.components.responses[f];d&&(m[f]=d);}a.components.responses=m;}if(a.components.schemas){let m={};if(s)for(let[l,f]of Object.entries(a.components.schemas))p.has(N("schema",l))&&(m[l]=f);else for(let l of p){let{name:f}=J(l),d=a.components.schemas[f];d&&(m[f]=d);}a.components.schemas=m;}}if(a.paths)for(let m of Object.entries(a.paths)){let l=m[0],f=m[1];for(let d of G){if(!f[d])continue;let h=N("operation",D({method:d,path:l}));t.has(h)||delete f[d];}Object.keys(f).length||delete a.paths[l];}c.timeEnd();};var ja=({content:e})=>{let{mediaType:t,schema:r}=e;return r?r.type==="string"&&!r.format&&Ye({mediaType:t})?{...r,format:"binary"}:r:Ye({mediaType:t})?{format:"binary",type:"string"}:void 0},nt=({content:e})=>{let t=[];for(let r in e)t.push({mediaType:r,schema:e[r].schema,type:lr({mediaType:r})});return t};var Fe=({schema:e})=>typeof e.type=="string"?[e.type]:e.type?e.type:e.properties?["object"]:[],$l=({irSchema:e,schema:t})=>{t.deprecated!==void 0&&(e.deprecated=t.deprecated),t.example&&(e.example=t.example),t.description&&(e.description=t.description),t.title&&(e.title=t.title);},In=({irSchema:e,schema:t})=>{if(t.const!==void 0&&(e.const=t.const,!t.type))if(t.const===null)e.type="null";else switch(typeof t.const){case "bigint":case "number":e.type="number";break;case "boolean":e.type="boolean";break;case "string":e.type="string";break}t.default!==void 0&&(e.default=t.default),t.exclusiveMaximum!==void 0&&(e.exclusiveMaximum=t.exclusiveMaximum),t.exclusiveMinimum!==void 0&&(e.exclusiveMinimum=t.exclusiveMinimum),t.format&&(e.format=t.format),t.maximum!==void 0&&(e.maximum=t.maximum),t.maxItems!==void 0&&(e.maxItems=t.maxItems),t.maxLength!==void 0&&(e.maxLength=t.maxLength),t.minimum!==void 0&&(e.minimum=t.minimum),t.minItems!==void 0&&(e.minItems=t.minItems),t.minLength!==void 0&&(e.minLength=t.minLength),t.pattern&&(e.pattern=t.pattern),t.readOnly?e.accessScope="read":t.writeOnly&&(e.accessScope="write");},Ml=({context:e,irSchema:t={},schema:r,state:s})=>{r.prefixItems&&r.prefixItems.length||r.maxItems&&r.maxItems===r.minItems||r.const!==void 0?t.type="tuple":t.type="array";let o=[];for(let i of r.prefixItems??[]){let p=Q({context:e,schema:i,state:s});o.push(p);}if(r.items){let i=Q({context:e,schema:r.items,state:s});if(!o.length&&r.maxItems&&r.maxItems===r.minItems)o=Array(r.maxItems).fill(i);else {let p=r.items.allOf||r.items.anyOf||r.items.oneOf;p&&p.length>1&&!Fe({schema:r.items}).includes("null")?t={...t,...i}:o.push(i);}}return t=B({items:o,schema:t}),t},Ll=({irSchema:e={}})=>(e.type="boolean",e),Vl=({irSchema:e={}})=>(e.type="null",e),Dl=({irSchema:e={},schema:t})=>(e.type=t.type,e),Fl=({context:e,irSchema:t={},schema:r,state:s})=>{t.type="object";let o={};for(let i in r.properties){let p=r.properties[i];if(typeof p!="boolean"){let a=Q({context:e,schema:p,state:s});o[i]=a;}}if(Object.keys(o).length&&(t.properties=o),r.additionalProperties===void 0)t.properties||(t.additionalProperties={type:"unknown"});else if(typeof r.additionalProperties=="boolean")s.inAllOf&&r.additionalProperties===false&&(!r.properties||!Object.keys(r.properties).length)&&(!r.patternProperties||!Object.keys(r.patternProperties).length)||(t.additionalProperties={type:r.additionalProperties?"unknown":"never"});else {let i=Q({context:e,schema:r.additionalProperties,state:s});t.additionalProperties=i;}if(r.patternProperties){let i={};for(let p in r.patternProperties){let a=r.patternProperties[p],c=Q({context:e,schema:a,state:s});i[p]=c;}Object.keys(i).length&&(t.patternProperties=i);}return r.propertyNames&&(t.propertyNames=Q({context:e,schema:r.propertyNames,state:s})),r.required&&(t.required=r.required),t},Bl=({irSchema:e={}})=>(e.type="string",e),st=({schema:e})=>{let t={};return $l({irSchema:t,schema:e}),t},Kl=({context:e,schema:t,state:r})=>{let s=st({schema:t}),o=[],i=Fe({schema:t}),p=t.allOf;for(let a of p){let c=r.inAllOf;"$ref"in a||(r.inAllOf=true);let m=Q({context:e,schema:a,state:r});if(r.inAllOf=c,r.inAllOf===void 0&&delete r.inAllOf,t.required&&(m.required?m.required=[...m.required,...t.required]:m.required=t.required),o.push(m),a.$ref){let l=e.resolveRef(a.$ref);if(l.discriminator&&r.$ref){let f=Le(r.$ref,l.discriminator.mapping,l.oneOf?()=>l.oneOf.some(d=>"$ref"in d&&d.$ref===r.$ref):void 0);if(f.length>0){let d=f.map(h=>({const:h,type:"string"})),y={properties:{[l.discriminator.propertyName]:d.length>1?{items:d,logicalOperator:"or"}:d[0]},type:"object"};l.required?.includes(l.discriminator.propertyName)&&(y.required=[l.discriminator.propertyName]),o.push(y);}}}}if(i.includes("object")){let a=Bt({context:e,schema:{...t,type:"object"},state:r});if(a.properties){for(let c of a.required??[])if(!a.properties[c])for(let m of p){let l=m.$ref?e.resolveRef(m.$ref):m;if(Fe({schema:l}).includes("object")){let f=Bt({context:e,schema:{...l,type:"object"},state:r});if(f.properties?.[c]){a.properties[c]=f.properties[c];break}}}o.push(a);}}if(s=B({items:o,logicalOperator:"and",mutateSchemaOneItem:true,schema:s}),i.includes("null")){let a=[{type:"null"}];o.length&&a.unshift(s),s={items:a,logicalOperator:"or"};}return s},Wl=({context:e,schema:t,state:r})=>{let s=st({schema:t}),o=[],i=Fe({schema:t}),p=t.anyOf;for(let a of p){let c=Q({context:e,schema:a,state:r});if(t.discriminator&&c.$ref!=null){let l=Le(c.$ref,t.discriminator.mapping).map(d=>({const:d,type:"string"}));c={items:[{properties:{[t.discriminator.propertyName]:l.length>1?{items:l,logicalOperator:"or"}:l[0]},type:"object"},c],logicalOperator:"and"};}o.push(c);}if(i.includes("null")&&o.push({type:"null"}),s=B({items:o,mutateSchemaOneItem:true,schema:s}),i.includes("object")){let a=Bt({context:e,schema:{...t,type:"object"},state:r});a.properties&&(s={items:[s,a],logicalOperator:"and"});}return s},zl=({context:e,schema:t,state:r})=>{let s=st({schema:t});s.type="enum";let o=[],i=Fe({schema:t});for(let[p,a]of t.enum.entries()){let c=typeof a,m;if(c==="string"||c==="number"||c==="boolean"?m=c:c==="object"&&Array.isArray(a)?m="array":a===null?i.includes("null")&&(m="null"):console.warn("\u{1F6A8}",`unhandled "${c}" typeof value "${a}" for enum`,t.enum),!m)continue;let l=Bt({context:e,schema:{const:a,description:t["x-enum-descriptions"]?.[p],title:t["x-enum-varnames"]?.[p]??t["x-enumNames"]?.[p],type:m},state:r});o.push(l);}return s=B({items:o,schema:s}),s},_l=({context:e,schema:t,state:r})=>{let s=st({schema:t}),o=[],i=Fe({schema:t}),p=t.oneOf;for(let a of p){let c=Q({context:e,schema:a,state:r});if(t.discriminator&&c.$ref!=null){let l=Le(c.$ref,t.discriminator.mapping).map(d=>({const:d,type:"string"}));c={items:[{properties:{[t.discriminator.propertyName]:l.length>1?{items:l,logicalOperator:"or"}:l[0]},required:[t.discriminator.propertyName],type:"object"},c],logicalOperator:"and"};}c.logicalOperator==="or"&&c.type!=="array"&&c.items?o=o.concat(c.items):o.push(c);}if(i.includes("null")&&o.push({type:"null"}),s=B({items:o,mutateSchemaOneItem:true,schema:s}),i.includes("object")){let a=Bt({context:e,schema:{...t,type:"object"},state:r});a.properties&&(s={items:[s,a],logicalOperator:"and"});}return s},Hl=({context:e,schema:t,state:r})=>{if(!t.$ref.startsWith("#/components/")&&!r.circularReferenceTracker.has(t.$ref)){r.refStack.push(t.$ref);let a=e.resolveRef(t.$ref),c=r.$ref;r.$ref=t.$ref;let m=Q({context:e,schema:a,state:r});return r.$ref=c,r.refStack.pop(),m}let o=st({schema:t}),i={};if(i.$ref=decodeURI(t.$ref),r.refStack.includes(t.$ref)&&(r.refStack[0]===t.$ref&&(r.circularRef=t.$ref),o.circular=true),!r.circularReferenceTracker.has(t.$ref)){r.refStack.push(t.$ref);let a=e.resolveRef(t.$ref),c=r.$ref;r.$ref=t.$ref,Q({context:e,schema:a,state:r}),r.circularRef&&r.refStack[0]===r.circularRef&&(o.circular=true),r.$ref=c,r.refStack.pop();}let p=[];return p.push(i),t.type&&typeof t.type!="string"&&t.type.includes("null")&&p.push({type:"null"}),o=B({items:p,mutateSchemaOneItem:true,schema:o}),o},Bt=({context:e,irSchema:t,schema:r,state:s})=>{switch(t||(t=st({schema:r}),In({irSchema:t,schema:r})),r.type){case "array":return Ml({context:e,irSchema:t,schema:r,state:s});case "boolean":return Ll({irSchema:t});case "integer":case "number":return Dl({irSchema:t,schema:r});case "null":return Vl({irSchema:t});case "object":return Fl({context:e,irSchema:t,schema:r,state:s});case "string":return Bl({irSchema:t});default:return Na({irSchema:t,schema:r})}},Ql=({context:e,irSchema:t,schema:r,state:s})=>{t||(t=st({schema:r}));let o={};In({irSchema:o,schema:r}),r.type.includes("null")&&o.default===null&&delete o.default;let i=[];for(let p of r.type)if(p==="null")i.push({type:"null"});else {let a=Bt({context:e,irSchema:{...o},schema:{...r,type:p},state:s});i.push(a);}return t=B({items:i,schema:t}),t},Zl=({context:e,schema:t,state:r})=>{let s=st({schema:t});In({irSchema:s,schema:t});let o=Fe({schema:t});return o.length===1?Bt({context:e,irSchema:s,schema:{...t,type:o[0]},state:r}):Ql({context:e,irSchema:s,schema:{...t,type:o},state:r})},Na=({irSchema:e,schema:t})=>(e||(e=st({schema:t})),e.type="unknown",In({irSchema:e,schema:t}),e),Q=({context:e,schema:t,state:r})=>(r||(r={circularReferenceTracker:new Set,refStack:[]}),r.$ref&&r.circularReferenceTracker.add(r.$ref),t.$ref?Hl({context:e,schema:t,state:r}):t.enum?zl({context:e,schema:t,state:r}):t.allOf?Kl({context:e,schema:t,state:r}):t.anyOf?Wl({context:e,schema:t,state:r}):t.oneOf?_l({context:e,schema:t,state:r}):t.type||t.properties?Zl({context:e,schema:t,state:r}):Na({schema:t})),Ca=({$ref:e,context:t,schema:r})=>{t.ir.components||(t.ir.components={}),t.ir.components.schemas||(t.ir.components.schemas={}),t.ir.components.schemas[L(e)]=Q({context:t,schema:r,state:{$ref:e,circularReferenceTracker:new Set,refStack:[e]}});};var va=e=>e.includes("boolean")||e.includes("integer")||e.includes("number")||e.includes("string"),Kt=({context:e,name:t,schema:r})=>{if(de(e.config.parser.pagination).test(t))return true;if(r.$ref){let o=e.resolveRef(r.$ref);if("content"in o||"in"in o){let i;if("in"in o&&(i=o.schema),!i){let p=nt({content:o.content}),a=p.find(c=>c.type==="json")||p[0];a?.schema&&(i=a.schema);}return i?Kt({context:e,name:t,schema:i}):false}return Kt({context:e,name:t,schema:o})}for(let o in r.properties)if(de(e.config.parser.pagination).test(o)){let p=r.properties[o];if(typeof p!="boolean"){let a=Fe({schema:p});if(!a.length){let m=(p.anyOf??p.oneOf??[]).filter(l=>l.type!=="null");if(m.length===1){let l=Fe({schema:m[0]});if(va(l))return o}}if(va(a))return o}}for(let o of r.allOf??[]){let i=Kt({context:e,name:t,schema:o});if(i)return i}return false};var Ul=({irOperation:e,operation:t})=>{t.deprecated!==void 0&&(e.deprecated=t.deprecated),t.description&&(e.description=t.description),t.summary&&(e.summary=t.summary),t.tags?.length&&(e.tags=t.tags);},Xl=({context:e,method:t,operation:r,path:s,state:o})=>{let i={id:Mt({context:e,id:r.operationId,method:t,path:s,state:o}),method:t,path:s};return r.operationId&&(i.operationId=r.operationId),Ul({irOperation:i,operation:r}),i},Jl=({context:e,method:t,operation:r,path:s,securitySchemesMap:o,state:i})=>{let p=Xl({context:e,method:t,operation:r,path:s,state:i});if(r.parameters&&(p.parameters=r.parameters),r.requestBody){let a="$ref"in r.requestBody?e.resolveRef(r.requestBody.$ref):r.requestBody,c=nt({content:a.content}),m=c.find(l=>l.type==="json")||c[0];if(m){let l=Kt({context:e,name:"",schema:{description:a.description,...m.schema}});p.body={mediaType:m.mediaType,schema:Q({context:e,schema:{description:a.description,..."$ref"in r.requestBody?r.requestBody:m.schema},state:void 0})},l&&(p.body.pagination=l),a.required&&(p.body.required=a.required),m.type&&(p.body.type=m.type);}}for(let a in r.responses){p.responses||(p.responses={});let c=r.responses[a],m="$ref"in c?e.resolveRef(c.$ref):c,l=nt({content:m.content}),f=l.find(d=>d.type==="json")||l[0];f?p.responses[a]={mediaType:f.mediaType,schema:Q({context:e,schema:{description:m.description,...ja({content:f})},state:void 0})}:p.responses[a]={schema:{description:m.description,type:a==="204"?"void":"unknown"}};}if(r.security){let a=new Map;for(let c of r.security)for(let m in c){let l=o.get(m);l&&a.set(m,l);}a.size&&(p.security=Array.from(a.values()));}return p},wa=({context:e,method:t,operation:r,path:s,securitySchemesMap:o,state:i})=>(r.servers&&(e.ir.servers=[...e.ir.servers??[],...r.servers]),{parsed:Jl({context:e,method:t,operation:r,path:s,securitySchemesMap:o,state:i})}),ot=({context:e,method:t,path:r,...s})=>{e.ir.paths||(e.ir.paths={}),e.ir.paths[r]||(e.ir.paths[r]={});let{parsed:o}=wa({context:e,method:t,path:r,...s});e.ir.paths[r][t]=o;},it=({context:e,key:t,method:r,...s})=>{e.ir.webhooks||(e.ir.webhooks={}),e.ir.webhooks[t]||(e.ir.webhooks[t]={});let{parsed:o}=wa({context:e,method:r,path:t,...s});e.ir.webhooks[t][r]=o;};var Gl=e=>{switch(e){case "query":return false;default:return}},Yl=e=>{switch(e){case "deepObject":case "form":return true;default:return false}},ef=e=>{switch(e){case "header":case "path":return "simple";case "cookie":case "query":return "form"}},_=({context:e,parameters:t})=>{if(!t||!Object.keys(t).length)return;let r={};for(let s of t){let o="$ref"in s?e.dereference(s):s;r[o.in]||(r[o.in]={}),r[o.in][o.name.toLocaleLowerCase()]=qa({$ref:`#/todo/real/path/to/parameter/${o.name}`,context:e,parameter:o});}return r},qa=({$ref:e,context:t,parameter:r})=>{let s=r.schema;if(!s){let l=nt({content:r.content}),f=l.find(d=>d.type==="json")||l[0];f&&(s=f.schema);}let o={deprecated:r.deprecated,description:r.description,...s},i=Kt({context:t,name:r.name,schema:o}),p=r.style||ef(r.in),a=r.explode!==void 0?r.explode:Yl(p),m={allowReserved:r.allowReserved!==void 0?r.allowReserved:Gl(r.in),explode:a,location:r.in,name:r.name,schema:Q({context:t,schema:o,state:{$ref:e,circularReferenceTracker:new Set,refStack:[e]}}),style:p};return r.deprecated&&(m.deprecated=r.deprecated),r.description&&(m.description=r.description),i&&(m.pagination=i),r.required&&(m.required=r.required),m},$a=({$ref:e,context:t,parameter:r})=>{t.ir.components||(t.ir.components={}),t.ir.components.parameters||(t.ir.components.parameters={}),t.ir.components.parameters[L(e)]=qa({$ref:e,context:t,parameter:r});};var tf=({$ref:e,context:t,requestBody:r})=>{let s=nt({content:r.content}),o=s.find(c=>c.type==="json")||s[0],i=o?o.schema:void 0,p={description:r.description,...i},a={schema:Q({context:t,schema:p,state:{$ref:e,circularReferenceTracker:new Set,refStack:[e]}})};return r.description&&(a.description=r.description),r.required&&(a.required=r.required),a},Ma=({$ref:e,context:t,requestBody:r})=>{t.ir.components||(t.ir.components={}),t.ir.components.requestBodies||(t.ir.components.requestBodies={}),t.ir.components.requestBodies[L(e)]=tf({$ref:e,context:t,requestBody:r});};var La=({context:e})=>{if(e.spec.servers){e.ir.servers=e.spec.servers;return}for(let t of e.config.input)if(typeof t.path=="string"){let r=Ve(t.path);e.ir.servers=[{url:`${r.protocol?`${r.protocol}://`:""}${r.host}${r.port?`:${r.port}`:""}`}];}e.ir.servers||(e.ir.servers=[{url:"/"}]);};var Va=(e,t)=>{let r=t.timeEvent("validate"),s=[],o=new Map;if(e.paths)for(let i of Object.entries(e.paths)){let p=i[0],a=i[1];for(let c of G){let m=a[c];if(!m)continue;let l=D({method:c,path:p});m.operationId&&(o.has(m.operationId)?s.push({code:"duplicate_key",context:{key:"operationId",value:m.operationId},message:"Duplicate `operationId` found. Each `operationId` must be unique.",path:["paths",p,c,"operationId"],severity:"error"}):o.set(m.operationId,l));}}if(e.servers){(typeof e.servers!="object"||!Array.isArray(e.servers))&&s.push({code:"invalid_type",message:"`servers` must be an array.",path:[],severity:"error"});for(let i=0;i<e.servers.length;i++){let p=e.servers[i];!p||typeof p!="object"?s.push({code:"invalid_type",context:{actual:typeof p,expected:"object"},message:"Each entry in `servers` must be an object.",path:["servers",i],severity:"error"}):p.url||s.push({code:"missing_required_field",context:{field:"url"},message:"Missing required field `url` in server object.",path:["servers",i],severity:"error"});}}return r.timeEnd(),{issues:s,valid:!s.some(i=>i.severity==="error")}};var Da=({context:e,securitySchemesMap:t})=>{let r={ids:new Map};for(let s in e.spec.webhooks){let o=e.spec.webhooks[s],i="$ref"in o?{...e.resolveRef(o.$ref),...o}:o,p={context:e,key:s,operation:{description:i.description,parameters:_({context:e,parameters:i.parameters}),security:e.spec.security,servers:i.servers,summary:i.summary},securitySchemesMap:t,state:r};i.delete&&it({...p,method:"delete",operation:{...p.operation,...i.delete,parameters:w({source:_({context:e,parameters:i.delete.parameters}),target:p.operation.parameters})}}),i.get&&it({...p,method:"get",operation:{...p.operation,...i.get,parameters:w({source:_({context:e,parameters:i.get.parameters}),target:p.operation.parameters})}}),i.head&&it({...p,method:"head",operation:{...p.operation,...i.head,parameters:w({source:_({context:e,parameters:i.head.parameters}),target:p.operation.parameters})}}),i.options&&it({...p,method:"options",operation:{...p.operation,...i.options,parameters:w({source:_({context:e,parameters:i.options.parameters}),target:p.operation.parameters})}}),i.patch&&it({...p,method:"patch",operation:{...p.operation,...i.patch,parameters:w({source:_({context:e,parameters:i.patch.parameters}),target:p.operation.parameters})}}),i.post&&it({...p,method:"post",operation:{...p.operation,...i.post,parameters:w({source:_({context:e,parameters:i.post.parameters}),target:p.operation.parameters})}}),i.put&&it({...p,method:"put",operation:{...p.operation,...i.put,parameters:w({source:_({context:e,parameters:i.put.parameters}),target:p.operation.parameters})}}),i.trace&&it({...p,method:"trace",operation:{...p.operation,...i.trace,parameters:w({source:_({context:e,parameters:i.trace.parameters}),target:p.operation.parameters})}});}};var co=e=>{if(e.config.parser.validate_EXPERIMENTAL){let o=Va(e.spec,e.logger);mr({context:e,result:o});}if(or(e.config.parser.filters)){let o=sr(e.config.parser.filters,e.spec,e.logger),{graph:i}=ht(e.spec,e.logger),{resourceMetadata:p}=ar(i,e.logger),a=ir({filters:o,logger:e.logger,resourceMetadata:p});ka({...a,logger:e.logger,preserveOrder:o.preserveOrder,spec:e.spec});}cr({context:e});let r={ids:new Map},s=new Map;if(e.spec.components){for(let o in e.spec.components.securitySchemes){let i=e.spec.components.securitySchemes[o],p="$ref"in i?e.resolveRef(i.$ref):i;s.set(o,p);}for(let o in e.spec.components.parameters){let i=`#/components/parameters/${o}`,p=e.spec.components.parameters[o],a="$ref"in p?e.resolveRef(p.$ref):p;$a({$ref:i,context:e,parameter:a});}for(let o in e.spec.components.requestBodies){let i=`#/components/requestBodies/${o}`,p=e.spec.components.requestBodies[o],a="$ref"in p?e.resolveRef(p.$ref):p;Ma({$ref:i,context:e,requestBody:a});}for(let o in e.spec.components.schemas){let i=`#/components/schemas/${o}`,p=e.spec.components.schemas[o];Ca({$ref:i,context:e,schema:p});}}La({context:e});for(let o in e.spec.paths){let i=e.spec.paths[o],p=i.$ref?{...e.resolveRef(i.$ref),...i}:i,a={context:e,operation:{description:p.description,parameters:_({context:e,parameters:p.parameters}),security:e.spec.security,servers:p.servers,summary:p.summary},path:o,securitySchemesMap:s,state:r};p.delete&&ot({...a,method:"delete",operation:{...a.operation,...p.delete,parameters:w({source:_({context:e,parameters:p.delete.parameters}),target:a.operation.parameters})}}),p.get&&ot({...a,method:"get",operation:{...a.operation,...p.get,parameters:w({source:_({context:e,parameters:p.get.parameters}),target:a.operation.parameters})}}),p.head&&ot({...a,method:"head",operation:{...a.operation,...p.head,parameters:w({source:_({context:e,parameters:p.head.parameters}),target:a.operation.parameters})}}),p.options&&ot({...a,method:"options",operation:{...a.operation,...p.options,parameters:w({source:_({context:e,parameters:p.options.parameters}),target:a.operation.parameters})}}),p.patch&&ot({...a,method:"patch",operation:{...a.operation,...p.patch,parameters:w({source:_({context:e,parameters:p.patch.parameters}),target:a.operation.parameters})}}),p.post&&ot({...a,method:"post",operation:{...a.operation,...p.post,parameters:w({source:_({context:e,parameters:p.post.parameters}),target:a.operation.parameters})}}),p.put&&ot({...a,method:"put",operation:{...a.operation,...p.put,parameters:w({source:_({context:e,parameters:p.put.parameters}),target:a.operation.parameters})}}),p.trace&&ot({...a,method:"trace",operation:{...a.operation,...p.trace,parameters:w({source:_({context:e,parameters:p.trace.parameters}),target:a.operation.parameters})}});}Da({context:e,securitySchemesMap:s});};var kn="#/components/schemas/";var dr=({config:e,name:t})=>{let r=e.plugins["@hey-api/sdk"];if(r?.config.classNameBuilder){let s="";return typeof r.config.classNameBuilder=="function"?s=r.config.classNameBuilder(t):s=r.config.classNameBuilder.replace("{{name}}",t),s}return t},Fa=e=>I().plugins["@hey-api/typescript"]?.config.style==="PascalCase"?q({case:"PascalCase",value:e}):e,Ba=e=>{let t=Fa(e);return $t(t).replace(ue,"_$1")};function St(e,t,r){return r.indexOf(e)===t}function _a(e,t){let r=e.toLocaleLowerCase(),s=t.toLocaleLowerCase();return r.localeCompare(s,"en")}var Fr=(e,t)=>_a(e.name,t.name);function Ha(e){return e.sort(Fr)}var sf=(e,t)=>{if(t)return t;if(typeof e=="number")return `'_${e}'`;let r="";return typeof e=="string"&&(r=e.replace(/[^$\u200c\u200d\p{ID_Continue}]/gu,"_").replace(/^([^$_\p{ID_Start}])/u,"_$1").replace(/(\p{Lowercase})(\p{Uppercase}+)/gu,"$1_$2")),r=r.trim(),r||(r="empty_string"),r.toUpperCase()},Qa=e=>e.map(t=>jn(t.value,true)).filter(St).join(" | "),jn=(e,t=false)=>typeof e=="string"?e.includes("'")&&t?`"${e}"`:`'${e}'`:e,mo=e=>{let t=sf(e.value,e.customName),r=jn(e.value);return {key:t,value:r}};var lo=e=>{let t=Ba(e);return {$ref:kn+e,name:t}};var Br=e=>e.format==="date"||e.format==="date-time",fo=e=>{let t=I();return e.base==="binary"?n.typeUnionNode({types:["Blob","File"]}):t.plugins["@hey-api/transformers"]?.config.dates&&Br(e)?n.typeNode("Date"):n.typeNode(e.base)},of=e=>{let t=e.base==="null"?false:e.isNullable,r=fo(e);if(e.export==="reference"&&e.$refs.length===1&&e.$refs[0].startsWith(kn)){let o=lo(e.base);r=n.typeNode(o.name);}return n.typeUnionNode({isNullable:t,types:[r]})},af=e=>{if(e.link){if(Array.isArray(e.link)){let t=e.link.map(s=>be(s));return n.typeTupleNode({isNullable:e.isNullable,types:t})}if(e.export==="array"&&e.maxItems&&e.minItems&&e.maxItems===e.minItems&&e.maxItems<=100){let t=Array(e.maxItems).fill(be(e.link));return n.typeTupleNode({isNullable:e.isNullable,types:t})}return n.typeArrayNode([be(e.link)],e.isNullable)}return n.typeArrayNode([fo(e)],e.isNullable)},pf=e=>{let t=e.enum.map(r=>jn(r.value));return n.typeUnionNode({isNullable:e.isNullable,types:t})},cf=e=>{let t=e.link&&!Array.isArray(e.link)?be(e.link):fo(e);return n.typeRecordNode(["string"],[t],e.isNullable,true)},Za=({model:e,style:t})=>{let r=e.properties.map(o=>n.nodeToString({node:be(o),unescape:true})).filter(St),s=t==="union"?n.typeUnionNode({isNullable:e.isNullable&&!e.properties.find(o=>o.isNullable),types:r}):n.typeIntersectionNode({isNullable:e.isNullable,types:r});return e.meta?s:n.typeParenthesizedNode({type:s})},mf=e=>{if(!e.properties.length)return n.typeNode("unknown");let t=I(),r=U(t),s=e.properties.map(o=>{let i=o.isRequired?"":"?",p=be(o),a=r?/^\dXX$/.test(o.name)?Xe(o.name):o.name:Xe(kr(Xa(o.name)));return o.name==="[key: string]"&&(a=o.name,i&&(i="",p=n.typeUnionNode({types:[p,"undefined"]}))),{comment:[o.description&&K(o.description),o.deprecated&&"@deprecated"],isReadOnly:o.isReadOnly,isRequired:i==="",name:a,type:p}});return n.typeInterfaceNode({isNullable:e.isNullable,properties:s,useLegacyResolution:true})},be=e=>{switch(e.export){case "all-of":return Za({model:e,style:"intersection"});case "any-of":case "one-of":return Za({model:e,style:"union"});case "array":return af(e);case "dictionary":return cf(e);case "enum":return pf(e);case "interface":return mf(e);case "const":case "generic":case "reference":default:return of(e)}},Se=({client:e,count:t=1,create:r=false,meta:s,nameTransformer:o})=>{let i={created:false,name:""},p=s.name;o&&(p=o(p)),t>1&&(p=`${p}${t}`);let a=e.types[p];return a?a.$ref===s.$ref?i={created:false,name:p}:i=Se({client:e,count:t+1,create:r,meta:s,nameTransformer:o}):r&&(e.types[p]=s,i={created:true,name:p}),i},Ua=({client:e,name:t})=>{let r={deleted:false,name:""};return e.types[t]&&(delete e.types[t],r={deleted:true,name:t}),r},Xa=e=>{let t=I();return U(t)?q({case:"camelCase",value:Gs(e)}).replace(ue,"_$1"):e};var Ke=e=>e.some(r=>r.isRequired);var jf=({config:e,dependencies:t,logger:r,spec:s})=>{let o=new Sn({config:e,dependencies:t,logger:r,spec:s});if("swagger"in o.spec)return ao(o),o;if(vt(o.spec.openapi,">=3.0.0 <3.1.0"))return po(o),o;if(vt(o.spec.openapi,">=3.1.0"))return co(o),o;throw new Error("Unsupported OpenAPI specification")};var Nf=({securitySchemeObject:e})=>{if(e.type==="openIdConnect")return {scheme:"bearer",type:"http"};if(e.type==="oauth2")return e.flows.password||e.flows.authorizationCode||e.flows.clientCredentials||e.flows.implicit?{scheme:"bearer",type:"http"}:void 0;if(e.type==="apiKey")return e.in==="header"?{name:e.name,type:"apiKey"}:e.in==="query"||e.in=="cookie"?{in:e.in,name:e.name,type:"apiKey"}:void 0;if(e.type==="http"){let t=e.scheme.toLowerCase();return t==="bearer"||t==="basic"?{scheme:t,type:"http"}:void 0}},Ga=({operation:e,plugin:t})=>{if(!e.security||!t.config.auth)return [];let r=[];for(let s of e.security){let o=Nf({securitySchemeObject:s});o?r.push(o):console.warn(`\u2757\uFE0F SDK warning: unsupported security scheme. Please open an issue if you'd like it added https://github.com/hey-api/openapi-ts/issues
15
- ${JSON.stringify(s,null,2)}`);}return r};var ur="TComposable",We="DefaultT",ho="ResT";var Ya=({operation:e,plugin:t})=>{if(!t.config.validator.request)return;let r=t.getPluginOrThrow(t.config.validator.request);if(r.api.createRequestValidator)return r.api.createRequestValidator({operation:e,plugin:r})},ep=({operation:e,plugin:t})=>{if(!t.config.validator.response)return;let r=t.getPluginOrThrow(t.config.validator.response);if(r.api.createResponseValidator)return r.api.createResponseValidator({operation:e,plugin:r})};var tp=({context:e,value:t})=>{let r=q({case:"PascalCase",value:yt(t)});return dr({config:e.config,name:r})},Cf=({operation:e,plugin:t})=>t.config.methodNameBuilder?t.config.methodNameBuilder(e):!t.config.asClass&&e.id.match(ue)?`${e.id}_`:e.id,Pe=({context:e,operation:t,plugin:r})=>{let s=new Map,o,i,p=[];if(r.config.classStructure==="auto"&&t.operationId&&(p=t.operationId.split(/[./]/).filter(Boolean),p.length>1)){let c=p.pop();i=q({case:"camelCase",value:yt(c)}),o=p.pop();}let a=r.config.instance?[r.config.instance]:t.tags??["default"];for(let c of a){let m=tp({context:e,value:o||c}),l=[c];o&&(p.includes(c)||c===o?l=[...p,o]:l=[c,...p,o]),s.set(c,{className:m,methodName:i||Cf({operation:t,plugin:r}),path:l.map(f=>tp({context:e,value:f}))});}return s},Kr=({operation:e,plugin:t,throwOnError:r})=>{let o=P(t.context.config).name==="@hey-api/client-nuxt",i=t.getPluginOrThrow("@hey-api/typescript"),p=t.getSymbol(i.api.getSelector("data",e.id)),a=p?.placeholder||"unknown",c=t.referenceSymbol(t.api.getSelector("Options"));if(o){let l=t.getSymbol(i.api.getSelector("response",e.id))?.placeholder||"unknown";return `${c.placeholder}<${ur}, ${a}, ${l}, ${We}>`}return r?`${c.placeholder}<${a}, ${r}>`:p?`${c.placeholder}<${p.placeholder}>`:c.placeholder},go=({isRequiredOptions:e,operation:t,plugin:r})=>{let s={argNames:[],fields:[],parameters:[]},o=r.getPluginOrThrow("@hey-api/typescript"),p=P(r.context.config).name==="@hey-api/client-nuxt";if(r.config.params_EXPERIMENTAL==="experiment"){if(t.parameters?.path)for(let a in t.parameters.path){let c=t.parameters.path[a],m=wt(c.name);s.argNames.push(m),s.fields.push({in:"path",key:m}),s.parameters.push({isRequired:c.required,name:m,type:o.api.schemaToType({plugin:o,schema:c.schema})});}if(t.parameters?.query)for(let a in t.parameters.query){let c=t.parameters.query[a],m=wt(c.name);s.argNames.push(m),s.fields.push({in:"path",key:m}),s.parameters.push({isRequired:c.required,name:m,type:o.api.schemaToType({plugin:o,schema:c.schema})});}if(t.body){let a="body";s.argNames.push(a),s.fields.push({in:"body"}),s.parameters.push({isRequired:t.body.required,name:a,type:o.api.schemaToType({plugin:o,schema:t.body.schema})});}}return s.parameters.push({isRequired:e,name:"options",type:Kr({operation:t,plugin:r,throwOnError:p?void 0:"ThrowOnError"})}),s},vf=e=>{if(!e)return;let t=e.split(";")[0]?.trim();if(t){if(t.startsWith("application/json")||t.endsWith("+json"))return "json";if(["application/","audio/","image/","video/"].some(r=>t.startsWith(r)))return "blob";if(t.startsWith("text/"))return "text"}},xo=({isRequiredOptions:e,opParameters:t,operation:r,plugin:s})=>{let o=P(s.context.config),i=o.name==="@hey-api/client-nuxt",p=s.getPluginOrThrow("@hey-api/typescript"),c=s.getSymbol(p.api.getSelector(i?"response":"responses",r.id))?.placeholder||"unknown",l=s.getSymbol(p.api.getSelector(i?"error":"errors",r.id))?.placeholder||"unknown",f=[];if(r.body)switch(r.body.type){case "form-data":{let v=s.referenceSymbol(s.api.getSelector("formDataBodySerializer"));f.push({spread:v.placeholder});break}case "json":break;case "text":case "octet-stream":f.push({key:"bodySerializer",value:null});break;case "url-search-params":{let v=s.referenceSymbol(s.api.getSelector("urlSearchParamsBodySerializer"));f.push({spread:v.placeholder});break}}for(let v in r.parameters?.query){let $=r.parameters.query[v];if(($.schema.type==="array"||$.schema.type==="tuple")&&($.style!=="form"||!$.explode)){f.push({key:"querySerializer",value:[{key:"array",value:[{key:"explode",value:false},{key:"style",value:"form"}]}]});break}}let d=Ya({operation:r,plugin:s});if(d&&f.push({key:"requestValidator",value:d}),s.config.transformer==="@hey-api/transformers"){let v=s.getPluginOrThrow(s.config.transformer),$=s.getSymbol(v.api.getSelector("response",r.id));$&&s.getSymbolValue($)&&f.push({key:"responseTransformer",value:$.placeholder});}let y=false,h;for(let v in r.responses){let $=r.responses[v];!h&&o.name==="@hey-api/client-axios"&&Xs({statusCode:v})==="2XX"&&(h=vf($.mediaType),h&&f.push({key:"responseType",value:h})),$.mediaType==="text/event-stream"&&(y=true);}let g=ep({operation:r,plugin:s});g&&f.push({key:"responseValidator",value:g}),s.config.responseStyle==="data"&&f.push({key:"responseStyle",value:s.config.responseStyle});let x=Ga({context:s.context,operation:r,plugin:s});x.length&&f.push({key:"security",value:n.arrayLiteralExpression({elements:x})}),f.push({key:"url",value:r.path}),f.push({spread:"options"});let S=[],k=t.argNames.length;if(k){let v=[],$=[];for(let ke of t.argNames)v.push(n.identifier({text:ke}));for(let ke of t.fields){let Qt=[];"in"in ke&&(Qt.push({key:"in",value:ke.in}),ke.key&&Qt.push({key:"key",value:ke.key}),ke.map&&Qt.push({key:"map",value:ke.map})),$.push(n.objectExpression({obj:Qt}));}let ft=s.referenceSymbol(s.api.getSelector("buildClientParams"));S.push(n.constVariable({expression:n.callExpression({functionName:ft.placeholder,parameters:[n.arrayLiteralExpression({elements:v}),n.arrayLiteralExpression({elements:$})]}),name:"params"})),f.push({spread:"params"});}if(r.body){let v=r.parameters?.header?.["content-type"];if(!!!v?.required){let ft=[{key:v?.name??"Content-Type",value:r.body.type==="form-data"?null:r.body.mediaType},{spread:n.propertyAccessExpression({expression:n.identifier({text:"options"}),isOptional:!e,name:"headers"})}];k&&ft.push({spread:n.propertyAccessExpression({expression:n.identifier({text:"params"}),name:"headers"})}),f.push({key:"headers",value:ft});}}let E=s.config.client&&o.api&&"getSelector"in o.api?s.getSymbol(o.api.getSelector("client")):void 0,C=n.propertyAccessExpression({expression:n.identifier({text:"options"}),isOptional:!e,name:"client"}),j;s.config.instance?j=n.binaryExpression({left:C,operator:"??",right:n.propertyAccessExpression({expression:n.this(),name:"_client"})}):E?j=n.binaryExpression({left:C,operator:"??",right:E.placeholder}):j=C;let F=[];i?F.push(ur,`${c} | ${We}`,l,We):F.push(c,l,"ThrowOnError"),s.config.responseStyle==="data"&&F.push(n.stringLiteral({text:s.config.responseStyle}));let M=y?n.propertyAccessExpression({expression:j,name:n.identifier({text:"sse"})}):j;return M=n.propertyAccessExpression({expression:M,name:n.identifier({text:r.method})}),S.push(n.returnFunctionCall({args:[n.objectExpression({identifiers:["responseTransformer"],obj:f})],name:M,types:F})),S};var W=({operation:e})=>{let t=[];return e.summary&&t.push(K(e.summary)),e.description&&t.push(K(e.description)),e.deprecated&&t.push("@deprecated"),t.length?t:void 0},Y=({context:e,operation:t})=>{let s=P(e.config).name==="@hey-api/client-nuxt",o=e.config.plugins["@hey-api/sdk"];return o&&!o.config.client&&!o.config.instance||s||nr(t)},yr=({operation:e})=>{for(let t in e.responses)if(e.responses[t].mediaType==="text/event-stream")return true;return false};var wf=({plugin:e})=>{let t=new Map,r=new Set,s=e.getPluginOrThrow("@hey-api/sdk");e.forEach("operation",({operation:i})=>{let p=Y({context:e.context,operation:i}),a=Pe({context:e.context,operation:i,plugin:s});for(let c of a.values())c.path.forEach((m,l)=>{t.has(m)||t.set(m,{className:m,classes:new Set,methods:new Set,nodes:[],root:!l});let f=c.path[l-1];if(f&&f!==m){let x=t.get(f);x.classes.add(m),t.set(f,x);}if(!(c.path.length===l+1))return;let y=t.get(m),h=e.config.httpRequests.methodNameBuilder(i);if(y.methods.has(h))return;let g=$f({isRequiredOptions:p,methodName:h,operation:i,plugin:e});y.nodes.length?y.nodes.push(n.identifier({text:`
16
- `}),g):y.nodes.push(g),y.methods.add(h),t.set(m,y);});});let o=i=>{if(r.has(i.className))return;if(i.classes.size)for(let m of i.classes){let l=t.get(m);o(l),i.nodes.push(n.propertyDeclaration({initializer:n.newExpression({argumentsArray:[],expression:n.identifier({text:O({config:{case:"preserve",name:e.config.httpRequests.classNameBuilder},name:l.className})})}),name:q({case:"camelCase",value:l.className})}));}let p=e.referenceSymbol(e.api.getSelector("Injectable")),a=e.registerSymbol({exported:true,name:O({config:{case:"preserve",name:e.config.httpRequests.classNameBuilder},name:i.className}),selector:e.api.getSelector("class",i.className)}),c=n.classDeclaration({decorator:i.root?{args:[{providedIn:"root"}],name:p.placeholder}:void 0,exportClass:a.exported,name:a.placeholder,nodes:i.nodes});e.setSymbolValue(a,c),r.add(i.className);};for(let i of t.values())o(i);},qf=({plugin:e})=>{e.forEach("operation",({operation:t})=>{let r=Y({context:e.context,operation:t}),s=e.registerSymbol({exported:true,name:e.config.httpRequests.methodNameBuilder(t),selector:e.api.getSelector("httpRequest",t.id)}),o=Mf({isRequiredOptions:r,operation:t,plugin:e,symbol:s});e.setSymbolValue(s,o);});},rp=({operation:e,plugin:t})=>{let r=P(t.context.config),s=r.api&&"getSelector"in r.api?t.getSymbol(r.api.getSelector("client")):void 0,o=n.propertyAccessExpression({expression:n.identifier({text:"options"}),isOptional:true,name:"client"}),i;return s?i=n.binaryExpression({left:o,operator:"??",right:s.placeholder}):i=o,n.callExpression({functionName:n.propertyAccessExpression({expression:i,name:"requestOptions"}),parameters:[n.objectExpression({obj:[{key:"responseStyle",value:n.identifier({text:"'data'"})},{key:"method",value:n.identifier({text:`'${e.method.toUpperCase()}'`})},{key:"url",value:n.identifier({text:`'${e.path}'`})},{spread:"options"}]})]})},$f=({isRequiredOptions:e,methodName:t,operation:r,plugin:s})=>{let o=s.getPluginOrThrow("@hey-api/typescript"),i=s.referenceSymbol(s.api.getSelector("HttpRequest")),p=s.getPluginOrThrow("@hey-api/sdk"),a=s.referenceSymbol(p.api.getSelector("Options")),m=s.getSymbol(o.api.getSelector("data",r.id))?.placeholder||"unknown";return n.methodDeclaration({accessLevel:"public",comment:W({operation:r}),name:t,parameters:[{isRequired:e,name:"options",type:`${a.placeholder}<${m}, ThrowOnError>`}],returnType:`${i.placeholder}<unknown>`,statements:[n.returnStatement({expression:rp({operation:r,plugin:s})})],types:[{default:false,extends:"boolean",name:"ThrowOnError"}]})},Mf=({isRequiredOptions:e,operation:t,plugin:r,symbol:s})=>{let o=r.getPluginOrThrow("@hey-api/typescript"),i=r.referenceSymbol(r.api.getSelector("HttpRequest")),p=r.getPluginOrThrow("@hey-api/sdk"),a=r.referenceSymbol(p.api.getSelector("Options")),m=r.getSymbol(o.api.getSelector("data",t.id))?.placeholder||"unknown";return n.constVariable({comment:W({operation:t}),exportConst:s.exported,expression:n.arrowFunction({parameters:[{isRequired:e,name:"options",type:`${a.placeholder}<${m}, ThrowOnError>`}],returnType:`${i.placeholder}<unknown>`,statements:[n.returnStatement({expression:rp({operation:t,plugin:r})})],types:[{default:false,extends:"boolean",name:"ThrowOnError"}]}),name:s.placeholder})},np=({plugin:e})=>{e.config.httpRequests.asClass?wf({plugin:e}):qf({plugin:e});};var Lf=({plugin:e})=>{let t=new Map,r=new Set,s=e.getPluginOrThrow("@hey-api/sdk");e.forEach("operation",({operation:i})=>{let p=Y({context:e.context,operation:i}),a=Pe({context:e.context,operation:i,plugin:s});for(let c of a.values())c.path.forEach((m,l)=>{t.has(m)||t.set(m,{className:m,classes:new Set,methods:new Set,nodes:[],root:!l});let f=c.path[l-1];if(f&&f!==m){let x=t.get(f);x.classes.add(m),t.set(f,x);}if(!(c.path.length===l+1))return;let y=t.get(m),h=e.config.httpResources.methodNameBuilder(i);if(y.methods.has(h))return;let g=Df({isRequiredOptions:p,methodName:h,operation:i,plugin:e});y.nodes.length?y.nodes.push(n.identifier({text:`
17
- `}),g):y.nodes.push(g),y.methods.add(h),t.set(m,y);});});let o=i=>{if(r.has(i.className))return;if(i.classes.size)for(let m of i.classes){let l=t.get(m);o(l),i.nodes.push(n.propertyDeclaration({initializer:n.newExpression({argumentsArray:[],expression:n.identifier({text:O({config:{case:"preserve",name:e.config.httpResources.classNameBuilder},name:l.className})})}),name:q({case:"camelCase",value:l.className})}));}let p=e.referenceSymbol(e.api.getSelector("Injectable")),a=e.registerSymbol({exported:true,name:O({config:{case:"preserve",name:e.config.httpResources.classNameBuilder},name:i.className})}),c=n.classDeclaration({decorator:i.root?{args:[{providedIn:"root"}],name:p.placeholder}:void 0,exportClass:a.exported,name:a.placeholder,nodes:i.nodes});e.setSymbolValue(a,c),r.add(i.className);};for(let i of t.values())o(i);},Vf=({plugin:e})=>{e.forEach("operation",({operation:t})=>{let r=Y({context:e.context,operation:t}),s=e.registerSymbol({exported:true,name:e.config.httpResources.methodNameBuilder(t)}),o=Ff({isRequiredOptions:r,operation:t,plugin:e,symbol:s});e.setSymbolValue(s,o);});},sp=({operation:e,plugin:t})=>{let r=t.getPluginOrThrow("@hey-api/sdk"),s=t.getPluginOrThrow("@hey-api/typescript"),o=t.referenceSymbol(t.api.getSelector("httpResource")),p=t.getSymbol(s.api.getSelector("response",e.id))?.placeholder||"unknown";if(t.config.httpRequests.asClass){let a=Pe({context:t.context,operation:e,plugin:r}),c=Array.from(a.values())[0];if(c){let m=c.path[0],l=t.referenceSymbol(t.api.getSelector("class",m)),f=t.referenceSymbol(t.api.getSelector("inject")),d=n.callExpression({functionName:f.placeholder,parameters:[n.identifier({text:l.placeholder})]});for(let y=1;y<c.path.length;y++){let h=c.path[y];h&&(d=n.propertyAccessExpression({expression:d,name:q({case:"camelCase",value:h})}));}return d=n.propertyAccessExpression({expression:d,name:t.config.httpRequests.methodNameBuilder(e)}),n.callExpression({functionName:o.placeholder,parameters:[n.arrowFunction({parameters:[],statements:[n.constVariable({expression:n.conditionalExpression({condition:n.identifier({text:"options"}),whenFalse:n.identifier({text:"undefined"}),whenTrue:n.callExpression({functionName:"options",parameters:[]})}),name:"opts"}),n.returnStatement({expression:n.conditionalExpression({condition:n.identifier({text:"opts"}),whenFalse:n.identifier({text:"undefined"}),whenTrue:n.callExpression({functionName:d,parameters:[n.identifier({text:"opts"})]})})})]})],types:[n.typeNode(p)]})}}else {let a=t.referenceSymbol(t.api.getSelector("httpRequest",e.id));return n.callExpression({functionName:o.placeholder,parameters:[n.arrowFunction({parameters:[],statements:[n.constVariable({expression:n.conditionalExpression({condition:n.identifier({text:"options"}),whenFalse:n.identifier({text:"undefined"}),whenTrue:n.callExpression({functionName:"options",parameters:[]})}),name:"opts"}),n.returnStatement({expression:n.conditionalExpression({condition:n.identifier({text:"opts"}),whenFalse:n.identifier({text:"undefined"}),whenTrue:n.callExpression({functionName:a.placeholder,parameters:[n.identifier({text:"opts"})]})})})]})],types:[n.typeNode(p)]})}return n.callExpression({functionName:o.placeholder,parameters:[n.arrowFunction({parameters:[],statements:[n.returnStatement({expression:n.identifier({text:"undefined"})})]})],types:[n.typeNode(p)]})},Df=({isRequiredOptions:e,methodName:t,operation:r,plugin:s})=>{let o=s.getPluginOrThrow("@hey-api/typescript"),i=s.getPluginOrThrow("@hey-api/sdk"),p=s.referenceSymbol(i.api.getSelector("Options")),c=s.getSymbol(o.api.getSelector("data",r.id))?.placeholder||"unknown";return n.methodDeclaration({accessLevel:"public",comment:W({operation:r}),name:t,parameters:[{isRequired:e,name:"options",type:`() => ${p.placeholder}<${c}, ThrowOnError> | undefined`}],returnType:void 0,statements:[n.returnStatement({expression:sp({operation:r,plugin:s})})],types:[{default:false,extends:"boolean",name:"ThrowOnError"}]})},Ff=({isRequiredOptions:e,operation:t,plugin:r,symbol:s})=>{let o=r.getPluginOrThrow("@hey-api/typescript"),i=r.getPluginOrThrow("@hey-api/sdk"),p=r.referenceSymbol(i.api.getSelector("Options")),c=r.getSymbol(o.api.getSelector("data",t.id))?.placeholder||"unknown";return n.constVariable({comment:W({operation:t}),exportConst:s.exported,expression:n.arrowFunction({parameters:[{isRequired:e,name:"options",type:`() => ${p.placeholder}<${c}, ThrowOnError> | undefined`}],statements:[n.returnStatement({expression:sp({operation:t,plugin:r})})],types:[{default:false,extends:"boolean",name:"ThrowOnError"}]}),name:s.placeholder})},op=({plugin:e})=>{e.config.httpResources.asClass?Lf({plugin:e}):Vf({plugin:e});};var ip=({plugin:e})=>{e.registerSymbol({external:"@angular/common/http",meta:{kind:"type"},name:"HttpRequest",selector:e.api.getSelector("HttpRequest")}),e.registerSymbol({external:"@angular/core",name:"inject",selector:e.api.getSelector("inject")}),e.registerSymbol({external:"@angular/core",name:"Injectable",selector:e.api.getSelector("Injectable")}),e.registerSymbol({external:"@angular/common/http",name:"httpResource",selector:e.api.getSelector("httpResource")}),e.config.httpRequests.enabled&&np({plugin:e}),e.config.httpResources.enabled&&op({plugin:e});};var Nn={api:new an({name:"@angular/common"}),config:{exportFromIndex:false},dependencies:["@hey-api/client-angular","@hey-api/sdk"],handler:ip,name:"@angular/common",output:"@angular/common",resolveConfig:(e,t)=>{if(e.config.httpRequests=t.valueToObject({defaultValue:{asClass:false,classNameBuilder:"{{name}}Requests",enabled:true},mappers:{boolean:r=>({enabled:r})},value:e.config.httpRequests}),!e.config.httpRequests.methodNameBuilder){let{asClass:r}=e.config.httpRequests;e.config.httpRequests.methodNameBuilder=s=>r?String(s.id):`${String(s.id)}Request`;}if(e.config.httpResources=t.valueToObject({defaultValue:{asClass:false,classNameBuilder:"{{name}}Resources",enabled:true},mappers:{boolean:r=>({enabled:r})},value:e.config.httpResources}),!e.config.httpResources.methodNameBuilder){let{asClass:r}=e.config.httpResources;e.config.httpResources.methodNameBuilder=s=>r?String(s.id):`${String(s.id)}Resource`;}}};var Oe={baseUrl:true,bundle:true,exportFromIndex:false},Te={dependencies:["@hey-api/typescript"],tags:["client"]};var Wf=url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('internal.cjs', document.baseURI).href)));Pt__default.default.dirname(Wf);var Wt=({config:e,sourceOutput:t})=>{let r=P(e);if("bundle"in r.config&&r.config.bundle)return Zt({moduleOutput:"client",sourceOutput:t});if(Pt__default.default.isAbsolute(r.name)){let s=Pt__default.default.dirname(r.name),o=Pt__default.default.resolve(e.output.path);return Pt__default.default.relative(o,s).replace(/\\/g,"/")}return r.name},ze=e=>{let t=P(e);if("bundle"in t.config&&t.config.bundle){let r=e._FRAGILE_CLIENT_BUNDLE_RENAMED;return Pt__default.default.resolve(e.output.path,"client",`${r?.get("index")??"index"}.ts`)}return t.name};var zf=({plugin:e})=>{let{baseUrl:t}=e.config;if(t===false)return;if(typeof t=="string")return t;let{servers:r}=e.context.ir;if(r)return r[typeof t=="number"?t:0]?.url},ap=({plugin:e})=>{let t=ze(e.context.config),r=e.registerSymbol({external:t,name:"createClient"}),s=e.registerSymbol({external:t,name:"createConfig"}),o=e.getPluginOrThrow("@hey-api/typescript"),i=e.referenceSymbol(o.api.getSelector("ClientOptions")),{runtimeConfigPath:p}=e.config,a=p?e.registerSymbol({external:p,name:"createClientConfig"}):void 0,c=[],m=zf({plugin:e});if(m){let y=Ve(m);if(y.protocol&&y.host&&!m.includes("{"))c.push({key:ie(e.context.config),value:m});else if(m!=="/"&&m.startsWith("/")){let h=m.endsWith("/")?m.slice(0,-1):m;c.push({key:ie(e.context.config),value:h});}}"throwOnError"in e.config&&e.config.throwOnError&&c.push({key:"throwOnError",value:true});let l=[n.callExpression({functionName:s.placeholder,parameters:c.length?[n.objectExpression({obj:c})]:void 0,types:[n.typeReferenceNode({typeName:i.placeholder})]})],f=e.registerSymbol({name:"client",selector:e.api.getSelector("client")}),d=n.constVariable({exportConst:true,expression:n.callExpression({functionName:r.placeholder,parameters:a?[n.callExpression({functionName:a.placeholder,parameters:l})]:l}),name:f.placeholder});e.setSymbolValue(f,d);};var pp=({plugin:e})=>{let t=ze(e.context.config),r=e.getPluginOrThrow("@hey-api/typescript"),s=e.referenceSymbol(r.api.getSelector("ClientOptions")),o=e.registerSymbol({external:t,meta:{kind:"type"},name:"Config"}),i=e.registerSymbol({external:t,meta:{kind:"type"},name:"ClientOptions"}),p=e.registerSymbol({exported:true,meta:{kind:"type"},name:"CreateClientConfig"}),a=n.typeReferenceNode({typeName:i.placeholder}),c=n.typeReferenceNode({typeName:"T"}),m=n.typeAliasDeclaration({comment:["The `createClientConfig()` function will be called on client initialization","and the returned object will become the client's initial configuration.","","You may want to initialize your client this way instead of calling","`setConfig()`. This is useful for example if you're using Next.js","to ensure your client always has the correct values."],exportType:p.exported,name:p.placeholder,type:n.functionTypeNode({parameters:[n.parameterDeclaration({name:"override",required:false,type:n.typeReferenceNode({typeArguments:[n.typeIntersectionNode({types:[a,c]})],typeName:o.placeholder})})],returnType:n.typeReferenceNode({typeArguments:[n.typeIntersectionNode({types:[n.typeReferenceNode({typeArguments:[a],typeName:"Required"}),c]})],typeName:o.placeholder})}),typeParameters:[{default:n.typeReferenceNode({typeName:s.placeholder}),extends:a,name:"T"}]});e.setSymbolValue(p,m);};var Re=({plugin:e})=>{pp({plugin:e}),ap({plugin:e});};var Cn=class{constructor(t){this.meta=t;}getSelector(...t){return [this.meta.name,...t]}};var vn={...Te,api:new Cn({name:"@hey-api/client-angular"}),config:{...Oe,throwOnError:false},handler:Re,name:"@hey-api/client-angular"};var wn=class{constructor(t){this.meta=t;}getSelector(...t){return [this.meta.name,...t]}};var qn={...Te,api:new wn({name:"@hey-api/client-axios"}),config:{...Oe,throwOnError:false},handler:Re,name:"@hey-api/client-axios"};var $n=class{constructor(t){this.meta=t;}getSelector(...t){return [this.meta.name,...t]}};var Mn={...Te,api:new $n({name:"@hey-api/client-fetch"}),config:{...Oe,throwOnError:false},handler:Re,name:"@hey-api/client-fetch"};var Ln=class{constructor(t){this.meta=t;}getSelector(...t){return [this.meta.name,...t]}};var Vn={...Te,api:new Ln({name:"@hey-api/client-next"}),config:{...Oe,throwOnError:false},handler:Re,name:"@hey-api/client-next"};var Dn=class{constructor(t){this.meta=t;}getSelector(...t){return [this.meta.name,...t]}};var Fn={...Te,api:new Dn({name:"@hey-api/client-nuxt"}),config:Oe,handler:Re,name:"@hey-api/client-nuxt"};var Bn=class{constructor(t){this.meta=t;}getSelector(...t){return [this.meta.name,...t]}};var Kn={...Te,api:new Bn({name:"@hey-api/client-ofetch"}),config:{...Oe,throwOnError:false},handler:Re,name:"@hey-api/client-ofetch"};var Wn={config:{},handler:()=>{},name:"legacy/angular",output:"client",tags:["client"]};var zn={config:{},handler:()=>{},name:"legacy/axios",output:"client",tags:["client"]};var _n={config:{},handler:()=>{},name:"legacy/fetch",output:"client",tags:["client"]};var Hn={config:{},handler:()=>{},name:"legacy/node",output:"client",tags:["client"]};var Qn={config:{},handler:()=>{},name:"legacy/xhr",output:"client",tags:["client"]};var Zn=class{constructor(t){this.meta=t;}getSelector(...t){return [this.meta.name,...t]}};var bo=({plugin:e,schema:t})=>{e.config.type==="form"&&(t.description&&delete t.description,t["x-enum-descriptions"]&&delete t["x-enum-descriptions"],t["x-enum-varnames"]&&delete t["x-enum-varnames"],t["x-enumNames"]&&delete t["x-enumNames"],t.title&&delete t.title);},gr=({context:e,plugin:t,schema:r})=>{if(Array.isArray(r))return r.map(o=>gr({context:e,plugin:t,schema:o}));let s=structuredClone(r);if(s.$ref)return s.$ref=decodeURI(s.$ref),s;if(bo({plugin:t,schema:s}),s.additionalProperties&&typeof s.additionalProperties!="boolean"&&(s.additionalProperties=gr({context:e,plugin:t,schema:s.additionalProperties})),s.allOf&&(s.allOf=s.allOf.map(o=>gr({context:e,plugin:t,schema:o}))),s.items&&(s.items=gr({context:e,plugin:t,schema:s.items})),s.properties)for(let o in s.properties){let i=s.properties[o];typeof i!="boolean"&&(s.properties[o]=gr({context:e,plugin:t,schema:i}));}return s},Tt=({context:e,plugin:t,schema:r})=>{if(Array.isArray(r))return r.map(o=>Tt({context:e,plugin:t,schema:o}));let s=structuredClone(r);if("$ref"in s)return s.$ref=decodeURI(s.$ref),s;if(bo({plugin:t,schema:s}),s.additionalProperties&&typeof s.additionalProperties!="boolean"&&(s.additionalProperties=Tt({context:e,plugin:t,schema:s.additionalProperties})),s.allOf&&(s.allOf=s.allOf.map(o=>Tt({context:e,plugin:t,schema:o}))),s.anyOf&&(s.anyOf=s.anyOf.map(o=>Tt({context:e,plugin:t,schema:o}))),s.items&&(s.items=Tt({context:e,plugin:t,schema:s.items})),s.oneOf&&(s.oneOf=s.oneOf.map(o=>Tt({context:e,plugin:t,schema:o}))),s.properties)for(let o in s.properties){let i=s.properties[o];typeof i!="boolean"&&(s.properties[o]=Tt({context:e,plugin:t,schema:i}));}return s},at=({context:e,plugin:t,schema:r})=>{if(Array.isArray(r))return r.map(o=>at({context:e,plugin:t,schema:o}));let s=structuredClone(r);if(bo({plugin:t,schema:s}),s.$ref&&(s.$ref=decodeURI(s.$ref)),s.additionalProperties&&typeof s.additionalProperties!="boolean"&&(s.additionalProperties=at({context:e,plugin:t,schema:s.additionalProperties})),s.allOf&&(s.allOf=s.allOf.map(o=>at({context:e,plugin:t,schema:o}))),s.anyOf&&(s.anyOf=s.anyOf.map(o=>at({context:e,plugin:t,schema:o}))),s.items&&(s.items=at({context:e,plugin:t,schema:s.items})),s.oneOf&&(s.oneOf=s.oneOf.map(o=>at({context:e,plugin:t,schema:o}))),s.prefixItems&&(s.prefixItems=s.prefixItems.map(o=>at({context:e,plugin:t,schema:o}))),s.properties)for(let o in s.properties){let i=s.properties[o];typeof i!="boolean"&&(s.properties[o]=at({context:e,plugin:t,schema:i}));}return s},So=({name:e,plugin:t,schema:r})=>{let s="";return t.config.nameBuilder&&(typeof t.config.nameBuilder=="function"?s=t.config.nameBuilder(e,r):s=t.config.nameBuilder.replace("{{name}}",e)),s||(s=`${e}Schema`),wt(s)},rd=({context:e,plugin:t})=>{if(e.spec.definitions)for(let r in e.spec.definitions){let s=e.spec.definitions[r],o=t.registerSymbol({exported:true,name:So({name:r,plugin:t,schema:s}),selector:t.api.getSelector("ref",r)}),i=gr({context:e,plugin:t,schema:s}),p=n.constVariable({assertion:"const",exportConst:o.exported,expression:n.objectExpression({obj:i}),name:o.placeholder});t.setSymbolValue(o,p);}},nd=({context:e,plugin:t})=>{if(e.spec.components)for(let r in e.spec.components.schemas){let s=e.spec.components.schemas[r],o=t.registerSymbol({exported:true,name:So({name:r,plugin:t,schema:s}),selector:t.api.getSelector("ref",r)}),i=Tt({context:e,plugin:t,schema:s}),p=n.constVariable({assertion:"const",exportConst:o.exported,expression:n.objectExpression({obj:i}),name:o.placeholder});t.setSymbolValue(o,p);}},sd=({context:e,plugin:t})=>{if(e.spec.components)for(let r in e.spec.components.schemas){let s=e.spec.components.schemas[r],o=t.registerSymbol({exported:true,name:So({name:r,plugin:t,schema:s}),selector:t.api.getSelector("ref",r)}),i=at({context:e,plugin:t,schema:s}),p=n.constVariable({assertion:"const",exportConst:o.exported,expression:n.objectExpression({obj:i}),name:o.placeholder});t.setSymbolValue(o,p);}},cp=({plugin:e})=>{if("swagger"in e.context.spec){rd({context:e.context,plugin:e});return}if(vt(e.context.spec.openapi,">=3.0.0 <3.1.0")){nd({context:e.context,plugin:e});return}if(vt(e.context.spec.openapi,">=3.1.0")){sd({context:e.context,plugin:e});return}throw new Error("Unsupported OpenAPI specification")};var Rt=class{_exportFromIndex;_headers=[];_id;_imports=new Map;_items=[];_name;_path;constructor({dir:t,exportFromIndex:r=false,header:s=true,id:o,name:i}){this._exportFromIndex=r,this._id=o,this._name=this._setName(i),this._path=Pt__default.default.resolve(t,this._name),s&&this._headers.push("// This file is auto-generated by @hey-api/openapi-ts");}add(...t){this._items=this._items.concat(t);}get exportFromIndex(){return this._exportFromIndex}get id(){return this._id}import({module:t,...r}){if(!r.name)return {name:void 0};let s=this._imports.get(t);s||(s=new Map,this._imports.set(t,s));let o=s.get(r.name);return o?{...o,name:o.alias||o.name}:(s.set(r.name,r),{...r,name:r.alias||r.name})}isEmpty(){return !this._items.length}nameWithoutExtension(){let{name:t}=lp(this._name);return t}remove(t){Ko__default.default.rmSync(this._path,t);}removeNode_LEGACY(){this._items=this._items.slice(0,this._items.length-1);}_setName(t){if(t.includes("index"))return t;let{extension:r,name:s}=lp(t);return [s,"gen",r].filter(Boolean).join(".")}_toString(t,r){let s=[];this._headers.length&&s.push(this._headers.join(`
18
- `));let o=r?.options.moduleResolution===b__default.default.ModuleResolutionKind.NodeNext,i=[];for(let[p,a]of this._imports.entries()){let c=Array.from(a.values()),m=p;o&&(m.startsWith("./")||m.startsWith("../"))&&(m==="./client"?m="./client/index.js":m=`${m}.js`);let l=n.namedImportDeclarations({imports:c,module:m});i.push(se({node:l}));}return i.length&&s.push(i.join(`
19
- `)),s=s.concat(this._items.map(p=>typeof p=="string"?p:se({node:p,unescape:true}))),s.join(t)}write(t=`
20
- `,r=null){if(this.isEmpty()){this.remove({force:true});return}let s=this._path;if(typeof this._path=="string"){let o=this._path.split(Pt__default.default.sep);s=o.slice(0,o.length-1).join(Pt__default.default.sep);}rn(s),Ko__default.default.writeFileSync(this._path,this._toString(t,r));}},lp=e=>{let t=e.match(/\.[0-9a-z]+$/i),r=t?t[0].slice(1):"",s=e.slice(0,e.length-(r?r.length+1:0));return {extension:r,name:s}};var To=(e,t)=>{let r=I();if(Array.isArray(e))return e.map(o=>To(o));if(typeof e!="object"||e===null)return e;let s={...e};return Object.entries(s).forEach(([o,i])=>{if(r.plugins["@hey-api/schemas"]?.config.type==="form"&&["description","x-enum-descriptions","x-enum-varnames","x-enumNames","title"].includes(o)&&t!=="properties"){delete s[o];return}o==="$ref"&&typeof i=="string"&&(s[o]=decodeURIComponent(i)),i&&typeof i=="object"&&(s[o]=To(i,o));}),s},id=(e,t)=>{let r=I(),s=$t(e),o=r.plugins["@hey-api/schemas"];return o?.config.nameBuilder?typeof o.config.nameBuilder=="function"?o.config.nameBuilder(s,t):o.config.nameBuilder.replace("{{name}}",s):`${s}Schema`},fp=({files:e,openApi:t,plugin:r})=>{let s=I();e.schemas=new Rt({dir:s.output.path,exportFromIndex:r.config.exportFromIndex,id:"schemas",name:"schemas.ts"});let o=(i,p)=>{let a=To(p),c=n.objectExpression({obj:a}),m=n.constVariable({assertion:"const",exportConst:true,expression:c,name:id(i,p)});e.schemas.add(m);};"swagger"in t&&Object.entries(t.definitions??{}).forEach(([i,p])=>{o(i,p);}),"openapi"in t&&Object.entries(t.components?.schemas??{}).forEach(([i,p])=>{o(i,p);});};var Un={api:new Zn({name:"@hey-api/schemas"}),config:{exportFromIndex:false,nameBuilder:e=>`${e}Schema`,type:"json"},handler:cp,handlerLegacy:fp,name:"@hey-api/schemas"};var Xn=class{constructor(t){this.meta=t;}getSelector(...t){return [this.meta.name,...t]}};var zt=({meta:e,onImport:t,...r})=>{if(!e)return {created:false,name:""};let{created:s,name:o}=Se({meta:e,...r});return o&&t(o),{created:s,name:o}},gp=e=>`${e}ModelResponseTransformer`,_t=e=>`${q({case:"PascalCase",value:e})}Data`,xr=e=>`${q({case:"PascalCase",value:e})}Error`,Ro=e=>`${e}Transformer`,He=e=>`${q({case:"PascalCase",value:e})}Response`,Ao=({importedType:e,throwOnError:t})=>{let r="OptionsLegacyParser";return t?`${r}<${e||"unknown"}, ${t}>`:e?`${r}<${e}>`:r},dp=(e,t)=>{let r=I(),{name:s}=Se({client:e,meta:{$ref:t.name,name:t.name},nameTransformer:_t}),o=Ke(t.parameters);if(!U(r))return [{isRequired:o,name:"options",type:Ao({importedType:s,throwOnError:"ThrowOnError"})}];if(!t.parameters.length)return [];let i=p=>{if(p.default!==void 0)return JSON.stringify(p.default,null,4)};return r.useOptions?[{default:o?void 0:{},name:"data",type:s}]:t.parameters.map(p=>{let a=`${s}['${p.name}']`;return {default:p?.default,isRequired:(!p.isRequired&&!i(p)?"?":"")=="",name:p.name,type:a}})},up=(e,t)=>{let r=I(),s=n.typeNode("void");if(t.responses.filter(p=>p.responseTypes.includes("success")).length){let{name:p}=Se({client:e,meta:{$ref:t.name,name:t.name},nameTransformer:He});s=n.typeUnionNode({types:[p]});}return r.useOptions&&r.plugins["@hey-api/sdk"]?.config.response==="response"&&(s=n.typeNode("ApiResult",[s])),P(r).name==="legacy/angular"?s=n.typeNode("Observable",[s]):s=n.typeNode("CancelablePromise",[s]),s},yp=e=>{let t=I();if(!U(t))return [e.deprecated&&"@deprecated",e.summary&&K(e.summary),e.description&&K(e.description)];let r=[];e.parameters.length&&(t.useOptions?r=["@param data The data for the request.",...e.parameters.map(i=>`@param data.${i.name} ${i.description?K(i.description):""}`)]:r=e.parameters.map(i=>`@param ${i.name} ${i.description?K(i.description):""}`));let s=e.responses.filter(i=>i.responseTypes.includes("success"));return [e.deprecated&&"@deprecated",e.summary&&K(e.summary),e.description&&K(e.description),...r,...s.map(i=>`@returns ${i.type} ${i.description?K(i.description):""}`),"@throws ApiError"]},pd=({client:e,onClientImport:t,onImport:r,operation:s})=>{let o=I(),i=He(s.name),{name:p}=Se({client:e,meta:{$ref:`transformers/${i}`,name:i},nameTransformer:Ro});if(p&&r(p),!U(o)){let l=[{spread:"options"}],d=s.parameters.filter(y=>y.in==="body"||y.in==="formData").map(y=>y.mediaType||(y.in==="formData"?"multipart/form-data":void 0)).filter(Boolean).filter(St);return d.length===1&&(d[0]==="multipart/form-data"&&(l=[...l,{spread:"formDataBodySerializer"},{key:"headers",value:[{key:"Content-Type",value:null},{spread:"options?.headers"}]}],t?.("formDataBodySerializer")),d[0]==="application/x-www-form-urlencoded"&&(l=[...l,{spread:"urlSearchParamsBodySerializer"},{key:"headers",value:[{key:"Content-Type",value:d[0]},{spread:"options?.headers"}]}],t?.("urlSearchParamsBodySerializer"))),l=[...l,{key:"url",value:s.path}],p&&(l=[...l,{key:"responseTransformer",value:p}]),n.objectExpression({identifiers:["responseTransformer"],obj:l})}let a=l=>l.reduce((f,d)=>{let y=d.prop,h=o.useOptions?`data.${d.name}`:d.name;return y===h?f[y]=y:Xe(y)===y?f[y]=h:f[`'${y}'`]=h,f},{}),c={method:s.method,url:s.path};s.parametersPath.length&&(c.path=a(s.parametersPath)),s.parametersCookie.length&&(c.cookies=a(s.parametersCookie)),s.parametersHeader.length&&(c.headers=a(s.parametersHeader)),s.parametersQuery.length&&(c.query=a(s.parametersQuery)),s.parametersForm.length&&(c.formData=a(s.parametersForm)),s.parametersBody&&(s.parametersBody.in==="formData"&&(o.useOptions?c.formData=`data.${s.parametersBody.name}`:c.formData=s.parametersBody.name),s.parametersBody.in==="body"&&(o.useOptions?c.body=`data.${s.parametersBody.name}`:c.body=s.parametersBody.name)),s.parametersBody?.mediaType&&(c.mediaType=s.parametersBody?.mediaType),s.responseHeader&&(c.responseHeader=s.responseHeader),p&&(c.responseTransformer=p);let m=s.responses.filter(l=>l.responseTypes.includes("error"));if(m.length>0){let l={};m.forEach(f=>{l[f.code]=f.description??"";}),c.errors=l;}return n.objectExpression({identifiers:["body","cookies","formData","headers","path","query","responseTransformer"],obj:c,shorthand:true})},_e=({config:e,handleIllegal:t,id:r,operation:s})=>e.plugins["@hey-api/sdk"]?.config.methodNameBuilder?e.plugins["@hey-api/sdk"].config.methodNameBuilder(s):t&&r.match(ue)?`${r}_`:r,hp=({client:e,onClientImport:t,onImport:r,operation:s})=>{let o=I(),i=pd({client:e,onClientImport:t,onImport:r,operation:s});if(!U(o)){let a=Se({client:e,meta:{$ref:s.name,name:s.name},nameTransformer:xr}).name,m=s.responses.filter(l=>l.responseTypes.includes("success")).length?Se({client:e,meta:{$ref:s.name,name:s.name},nameTransformer:He}).name:"void";return [n.returnFunctionCall({args:[i],name:`(options?.client ?? client).${s.method.toLocaleLowerCase()}`,types:a&&m?[m,a,"ThrowOnError"]:a?["unknown",a,"ThrowOnError"]:m?[m,"unknown","ThrowOnError"]:[]})]}return Et(o)?[n.returnFunctionCall({args:[i],name:"this.httpRequest.request"})]:P(o).name==="legacy/angular"?[n.returnFunctionCall({args:["OpenAPI","this.http",i],name:"__request"})]:[n.returnFunctionCall({args:["OpenAPI",i],name:"__request"})]},cd=({client:e,onClientImport:t,onImport:r,onNode:s,service:o})=>{let i=I(),p=P(i),a=U(i);for(let d of o.operations)d.parameters.length&&zt({client:e,meta:{$ref:d.name,name:d.name},nameTransformer:_t,onImport:r}),a||zt({client:e,meta:{$ref:d.name,name:d.name},nameTransformer:xr,onImport:r}),d.responses.filter(h=>h.responseTypes.includes("success")).length&&zt({client:e,meta:{$ref:d.name,name:d.name},nameTransformer:He,onImport:r});let c={default:("throwOnError"in p.config?p.config.throwOnError:false)??false,extends:"boolean",name:"ThrowOnError"};if(!i.plugins["@hey-api/sdk"]?.config.asClass&&!Et(i)){for(let d of o.operations){let y={parameters:dp(e,d),returnType:a?up(e,d):void 0,statements:hp({client:e,onClientImport:t,onImport:r,operation:d}),types:a?void 0:[c]},h=p.name==="legacy/angular"?n.anonymousFunction(y):n.arrowFunction(y),g=n.constVariable({comment:yp(d),exportConst:true,expression:h,name:_e({config:i,handleIllegal:true,id:d.name,operation:d})});s(g);}return}let m=o.operations.map(d=>n.methodDeclaration({accessLevel:"public",comment:yp(d),isStatic:Et(i)===void 0&&p.name!=="legacy/angular",name:_e({config:i,id:d.name,operation:d}),parameters:dp(e,d),returnType:a?up(e,d):void 0,statements:hp({client:e,onClientImport:t,onImport:r,operation:d}),types:a?void 0:[c]}));if(!m.length)return;Et(i)?m=[n.constructorDeclaration({multiLine:false,parameters:[{accessLevel:"public",isReadOnly:true,name:"httpRequest",type:"BaseHttpRequest"}]}),...m]:p.name==="legacy/angular"&&(m=[n.constructorDeclaration({multiLine:false,parameters:[{accessLevel:"public",isReadOnly:true,name:"http",type:"HttpClient"}]}),...m]);let l=[];m.forEach((d,y)=>{y&&l.push(n.identifier({text:`
21
- `})),l.push(d);});let f=n.classDeclaration({decorator:p.name==="legacy/angular"?{args:[{providedIn:"root"}],name:"Injectable"}:void 0,exportClass:true,name:dr({config:i,name:o.name}),nodes:l});s(f);},xp=({client:e,files:t,plugin:r})=>{let s=I(),o=U(s),i="sdk";if(t.sdk=new Rt({dir:s.output.path,exportFromIndex:r.config.exportFromIndex,id:"sdk",name:`${i}.ts`}),!o)t.sdk.import({module:Wt({config:s,sourceOutput:i}),name:"createClient"}),t.sdk.import({module:Wt({config:s,sourceOutput:i}),name:"createConfig"}),t.sdk.import({asType:true,module:Wt({config:s,sourceOutput:i}),name:"OptionsLegacyParser"});else if(P(s).name==="legacy/angular"?(t.sdk.import({module:"@angular/core",name:"Injectable"}),Et(s)||t.sdk.import({module:"@angular/common/http",name:"HttpClient"}),t.sdk.import({asType:true,module:"rxjs",name:"Observable"})):t.sdk.import({asType:true,module:"./core/CancelablePromise",name:"CancelablePromise"}),s.plugins["@hey-api/sdk"]?.config.response==="response"&&t.sdk.import({asType:true,module:"./core/ApiResult",name:"ApiResult"}),Et(s)){let a=P(s);t.sdk.import({asType:a.name!=="legacy/angular",module:"./core/BaseHttpRequest",name:"BaseHttpRequest"});}else t.sdk.import({module:"./core/OpenAPI",name:"OpenAPI"}),t.sdk.import({alias:"__request",module:"./core/request",name:"request"});if(!o){let p=P(s),a=n.constVariable({exportConst:true,expression:n.callExpression({functionName:"createClient",parameters:[n.callExpression({functionName:"createConfig",parameters:["throwOnError"in p&&p.throwOnError?n.objectExpression({obj:[{key:"throwOnError",value:true}]}):void 0]})]}),name:"client"});t.sdk.add(a);}for(let p of e.services)cd({client:e,onClientImport:a=>{t.sdk.import({module:Wt({config:s,sourceOutput:i}),name:a});},onImport:a=>{t.sdk.import({asType:!a.endsWith("Transformer"),module:`./${t.types.nameWithoutExtension()}`,name:a});},onNode:a=>{t.sdk.add(a);},service:p});};var bp=({plugin:e})=>{let t=ze(e.context.config),s=P(e.context.config).name==="@hey-api/client-nuxt",o=e.registerSymbol({external:t,meta:{kind:"type"},name:"TDataShape"}),i=e.registerSymbol({external:t,meta:{kind:"type"},name:"Client",selector:e.api.getSelector("Client")}),p=e.registerSymbol({external:t,meta:{kind:"type"},name:"Options"}),a=e.registerSymbol({exported:true,meta:{kind:"type"},name:"Options",selector:e.api.getSelector("Options")}),c=n.typeAliasDeclaration({exportType:a.exported,name:a.placeholder,type:n.typeIntersectionNode({types:[n.typeReferenceNode({typeArguments:s?[n.typeReferenceNode({typeName:"TComposable"}),n.typeReferenceNode({typeName:"TData"}),n.typeReferenceNode({typeName:ho}),n.typeReferenceNode({typeName:We})]:[n.typeReferenceNode({typeName:"TData"}),n.typeReferenceNode({typeName:"ThrowOnError"})],typeName:p.placeholder}),n.typeInterfaceNode({properties:[{comment:["You can provide a client instance returned by `createClient()` instead of","individual options. This might be also useful if you want to implement a","custom client."],isRequired:!e.config.client,name:"client",type:n.typeReferenceNode({typeName:i.placeholder})},{comment:["You can pass arbitrary values through the `meta` object. This can be","used to access values that aren't defined as part of the SDK function."],isRequired:false,name:"meta",type:n.typeReferenceNode({typeArguments:[n.keywordTypeNode({keyword:"string"}),n.keywordTypeNode({keyword:"unknown"})],typeName:"Record"})}],useLegacyResolution:false})]}),typeParameters:s?[n.typeParameterDeclaration({constraint:n.typeReferenceNode({typeName:e.referenceSymbol(e.api.getSelector("Composable")).placeholder}),defaultType:n.typeNode("'$fetch'"),name:"TComposable"}),n.typeParameterDeclaration({constraint:n.typeReferenceNode({typeName:o.placeholder}),defaultType:n.typeReferenceNode({typeName:o.placeholder}),name:"TData"}),n.typeParameterDeclaration({defaultType:n.keywordTypeNode({keyword:"unknown"}),name:ho}),n.typeParameterDeclaration({defaultType:n.keywordTypeNode({keyword:"undefined"}),name:We})]:[n.typeParameterDeclaration({constraint:n.typeReferenceNode({typeName:o.placeholder}),defaultType:n.typeReferenceNode({typeName:o.placeholder}),name:"TData"}),n.typeParameterDeclaration({constraint:n.keywordTypeNode({keyword:"boolean"}),defaultType:n.keywordTypeNode({keyword:"boolean"}),name:"ThrowOnError"})]});e.setSymbolValue(a,c);};var md=({plugin:e})=>{let t=n.expressionToStatement({expression:n.binaryExpression({left:n.propertyAccessExpression({expression:n.this(),name:"_client"}),operator:"=",right:n.propertyAccessExpression({expression:n.identifier({text:"args"}),name:"client"})})}),r=e.referenceSymbol(e.api.getSelector("Client")),s=P(e.context.config),o=s.api&&"getSelector"in s.api?e.getSymbol(s.api.getSelector("client")):void 0;return [n.propertyDeclaration({initializer:o?n.identifier({text:o.placeholder}):void 0,modifier:"protected",name:"_client",type:n.typeReferenceNode({typeName:r.placeholder})}),n.identifier({text:`
22
- `}),n.constructorDeclaration({multiLine:true,parameters:[{isRequired:!e.config.client,name:"args",type:n.typeInterfaceNode({properties:[{isRequired:!e.config.client,name:"client",type:r.placeholder}],useLegacyResolution:false})}],statements:[e.config.client?n.ifStatement({expression:n.propertyAccessExpression({expression:n.identifier({text:"args"}),isOptional:true,name:"client"}),thenStatement:n.block({statements:[t]})}):t]})]},ld=({plugin:e})=>{let t=P(e.context.config),r=t.name==="@hey-api/client-angular",s=t.name==="@hey-api/client-nuxt",o=new Map,i=new Set,p=e.config.instance?md({plugin:e}):[];e.forEach("operation",({operation:m})=>{let l=Y({context:e.context,operation:m}),f=e.getPluginOrThrow("@hey-api/typescript"),d=s?e.getSymbol(f.api.getSelector("response",m.id)):void 0,y=Pe({context:e.context,operation:m,plugin:e});for(let h of y.values())h.path.forEach((g,x)=>{let S=e.referenceSymbol(e.api.getSelector("class",g));o.has(S.id)||o.set(S.id,{className:g,classes:new Set,id:S.id,methods:new Set,nodes:[],root:!x});let k=h.path[x-1];if(k){let v=e.referenceSymbol(e.api.getSelector("class",k));if(v.placeholder!==S.placeholder){let $=o.get(v.id);$.classes.add(S.id),o.set(v.id,$);}}if(!(h.path.length===x+1))return;let C=o.get(S.id);if(C.methods.has(h.methodName))return;let j=go({isRequiredOptions:l,operation:m,plugin:e}),F=xo({isRequiredOptions:l,opParameters:j,operation:m,plugin:e}),M=n.methodDeclaration({accessLevel:"public",comment:W({operation:m}),isStatic:r?false:!e.config.instance,name:h.methodName,parameters:j.parameters,returnType:void 0,statements:F,types:s?[{default:n.ots.string("$fetch"),extends:n.typeNode(e.referenceSymbol(e.api.getSelector("Composable")).placeholder),name:ur},{default:d?n.typeReferenceNode({typeName:d.placeholder}):n.typeNode("undefined"),extends:d?n.typeReferenceNode({typeName:d.placeholder}):void 0,name:We}]:[{default:("throwOnError"in t.config?t.config.throwOnError:false)??false,extends:"boolean",name:"ThrowOnError"}]});C.nodes.length?C.nodes.push(n.identifier({text:`
23
- `}),M):C.nodes.push(M),C.methods.add(h.methodName),o.set(S.id,C);});});let a=e.registerSymbol({exported:false,name:"_HeyApiClient"}),c=m=>{if(i.has(m.id))return;if(m.classes.size)for(let d of m.classes){let y=o.get(d);c(y),m.nodes.push(n.propertyDeclaration({initializer:e.config.instance?n.newExpression({argumentsArray:e.config.instance?[n.objectExpression({multiLine:false,obj:[{key:"client",value:n.propertyAccessExpression({expression:n.this(),name:"_client"})}]})]:[],expression:n.identifier({text:e.referenceSymbol(y.id).placeholder})}):n.identifier({text:e.referenceSymbol(y.id).placeholder}),modifier:e.config.instance?void 0:"static",name:q({case:"camelCase",value:y.className})}));}let l=e.registerSymbol({exported:true,name:m.className,selector:e.api.getSelector("class",m.className)}),f=n.classDeclaration({decorator:m.root&&r?{args:[{providedIn:"root"}],name:e.referenceSymbol(e.api.getSelector("Injectable")).placeholder}:void 0,exportClass:l.exported,extendedClasses:e.config.instance?[a.placeholder]:void 0,name:l.placeholder,nodes:m.nodes});e.setSymbolValue(l,f),i.add(l.id);};if(p.length){let m=n.classDeclaration({exportClass:a.exported,name:a.placeholder,nodes:p});e.setSymbolValue(a,m);}for(let m of o.values())c(m);},fd=({plugin:e})=>{let t=P(e.context.config),r=t.name==="@hey-api/client-nuxt";e.forEach("operation",({operation:s})=>{let o=Y({context:e.context,operation:s}),i=e.getPluginOrThrow("@hey-api/typescript"),p=r?e.getSymbol(i.api.getSelector("response",s.id)):void 0,a=go({isRequiredOptions:o,operation:s,plugin:e}),c=xo({isRequiredOptions:o,opParameters:a,operation:s,plugin:e}),m=e.registerSymbol({name:_e({config:e.context.config,handleIllegal:true,id:s.id,operation:s}),selector:e.api.getSelector("function",s.id)}),l=n.constVariable({comment:W({operation:s}),exportConst:true,expression:n.arrowFunction({parameters:a.parameters,returnType:void 0,statements:c,types:r?[{default:n.ots.string("$fetch"),extends:n.typeNode(e.referenceSymbol(e.api.getSelector("Composable")).placeholder),name:ur},{default:p?n.typeReferenceNode({typeName:p.placeholder}):n.typeNode("undefined"),extends:p?n.typeReferenceNode({typeName:p.placeholder}):void 0,name:We}]:[{default:("throwOnError"in t.config?t.config.throwOnError:false)??false,extends:"boolean",name:"ThrowOnError"}]}),name:m.placeholder});e.setSymbolValue(m,l);});},Sp=({plugin:e})=>{let t=ze(e.context.config);e.registerSymbol({external:t,name:"formDataBodySerializer",selector:e.api.getSelector("formDataBodySerializer")}),e.registerSymbol({external:t,name:"urlSearchParamsBodySerializer",selector:e.api.getSelector("urlSearchParamsBodySerializer")}),e.registerSymbol({external:t,name:"buildClientParams",selector:e.api.getSelector("buildClientParams")});let r=P(e.context.config),s=r.name==="@hey-api/client-angular";r.name==="@hey-api/client-nuxt"&&e.registerSymbol({external:t,meta:{kind:"type"},name:"Composable",selector:e.api.getSelector("Composable")}),s&&e.config.asClass&&e.registerSymbol({external:"@angular/core",name:"Injectable",selector:e.api.getSelector("Injectable")}),bp({plugin:e}),e.config.asClass?ld({plugin:e}):fd({plugin:e});};var Jn={api:new Xn({name:"@hey-api/sdk"}),config:{asClass:false,auth:true,classNameBuilder:"{{name}}",classStructure:"auto",client:true,exportFromIndex:true,instance:false,operationId:true,params_EXPERIMENTAL:"default",response:"body",responseStyle:"fields",transformer:false,validator:false},dependencies:["@hey-api/typescript"],handler:Sp,handlerLegacy:xp,name:"@hey-api/sdk",resolveConfig:(e,t)=>{e.config.client?(typeof e.config.client=="boolean"&&(e.config.client=t.pluginByTag("client",{defaultPlugin:"@hey-api/client-fetch"})),e.dependencies.add(e.config.client)):e.config.client=false,e.config.transformer?(typeof e.config.transformer=="boolean"&&(e.config.transformer=t.pluginByTag("transformer")),e.dependencies.add(e.config.transformer)):e.config.transformer=false,typeof e.config.validator!="object"&&(e.config.validator={request:e.config.validator,response:e.config.validator}),e.config.validator.request?(typeof e.config.validator.request=="boolean"&&(e.config.validator.request=t.pluginByTag("validator")),e.dependencies.add(e.config.validator.request)):e.config.validator.request=false,e.config.validator.response?(typeof e.config.validator.response=="boolean"&&(e.config.validator.response=t.pluginByTag("validator")),e.dependencies.add(e.config.validator.response)):e.config.validator.response=false,e.config.instance?(typeof e.config.instance!="string"&&(e.config.instance="Sdk"),e.config.asClass=true):e.config.instance=false,e.config.classNameBuilder==="{{name}}"&&e.config.client==="@hey-api/client-angular"&&(e.config.classNameBuilder="{{name}}Service");}};var Gn=class{constructor(t){this.meta=t;}getSelector(...t){return [this.meta.name,...t]}};var Op=({dataExpression:e,schema:t})=>{if(t.type!=="integer"||t.format!=="int64")return;let r=e!==void 0?n.callExpression({functionName:"BigInt",parameters:[n.callExpression({functionName:n.propertyAccessExpression({expression:e,name:"toString"})})]}):void 0;if(r){if(typeof e=="string")return [r];if(e)return [n.assignment({left:e,right:r})]}},Tp=({dataExpression:e,schema:t})=>{if(t.type!=="string"||!(t.format==="date"||t.format==="date-time"))return;let r=n.identifier({text:"Date"});if(typeof e=="string")return [n.newExpression({argumentsArray:[n.identifier({text:e})],expression:r})];if(e)return [n.assignment({left:e,right:n.newExpression({argumentsArray:[e],expression:r})})]};var Yn="data",Wr=e=>e.map(t=>b__default.default.isStatement(t)?t:n.expressionToStatement({expression:t})),Ap=({node:e})=>e.kind===b__default.default.SyntaxKind.ReturnStatement,Pp=({plugin:e,schema:t})=>{let r=n.identifier({text:Yn}),s=zr({dataExpression:r,plugin:e,schema:t});return s.length&&!Ap({node:s[s.length-1]})&&s.push(n.returnStatement({expression:r})),s},zr=({dataExpression:e,plugin:t,schema:r})=>{if(r.$ref){let s=t.api.getSelector("response-ref",r.$ref);if(!t.getSymbol(s)){let i=t.registerSymbol({name:O({config:{case:"camelCase",name:"{{name}}SchemaResponseTransformer"},name:L(r.$ref)}),selector:s}),p=t.context.resolveIrRef(r.$ref),a=Pp({plugin:t,schema:p});if(a.length){let c=n.constVariable({expression:n.arrowFunction({async:false,multiLine:true,parameters:[{name:Yn,type:n.keywordTypeNode({keyword:"any"})}],statements:Wr(a)}),name:i.placeholder});t.setSymbolValue(i,c);}else t.setSymbolValue(i,null);}let o=t.referenceSymbol(s);if(t.getSymbolValue(o)!==null){let i=n.callExpression({functionName:o.placeholder,parameters:[e]});if(e)return typeof e=="string"&&e==="item"?[n.returnStatement({expression:i})]:[typeof e=="string"?i:n.assignment({left:e,right:i})]}return []}if(r.type==="array"){if(!e||typeof e=="string")return [];let s=r.items?zr({dataExpression:"item",plugin:t,schema:r.items?.[0]?r.items[0]:{...r,type:void 0}}):[];if(!s.length)return [];let o=Wr(s);return o.some(p=>Ap({node:p}))||o.push(n.returnStatement({expression:n.identifier({text:"item"})})),[n.assignment({left:e,right:n.callExpression({functionName:n.propertyAccessExpression({expression:e,name:"map"}),parameters:[n.arrowFunction({multiLine:true,parameters:[{name:"item",type:"any"}],statements:o})]})})]}if(r.type==="object"){let s=[],o=r.required??[];for(let i in r.properties){let p=r.properties[i],a=n.propertyAccessExpression({expression:e||Yn,name:i}),c=zr({dataExpression:a,plugin:t,schema:p});if(!c.length)continue;let m=!p.items?.find(f=>f.type==="null");o.includes(i)&&m?s=s.concat(c):s.push(n.ifStatement({expression:a,thenStatement:n.block({statements:Wr(c)})}));}return s}if(r.items){if(r.items.length===1)return zr({dataExpression:"item",plugin:t,schema:r.items[0]});let s=[];if(r.logicalOperator==="and"||r.items.length===2&&r.items.find(o=>o.type==="null"||o.type==="void")){for(let o of r.items){let i=zr({dataExpression:e||"item",plugin:t,schema:o});if(i.length)if(e)s=s.concat(i);else {let p=n.identifier({text:"item"});s.push(n.ifStatement({expression:p,thenStatement:n.block({statements:Wr(i)})}),n.returnStatement({expression:p}));}}return s}r.type!=="enum"&&((r.items??[]).every(o=>["boolean","integer","null","number","string"].includes(o.type))||console.warn(`\u2757\uFE0F Transformers warning: schema ${JSON.stringify(r)} is too complex and won't be currently processed. This will likely produce an incomplete transformer which is not what you want. Please open an issue if you'd like this improved https://github.com/hey-api/openapi-ts/issues`));}for(let s of t.config.transformers){let o=s({config:t.config,dataExpression:e,schema:r});if(o)return o}return []},Ep=({plugin:e})=>{e.forEach("operation",({operation:t})=>{let{response:r}=we(t);if(!r)return;if(r.items&&r.items.length>1){e.context.config.logs.level==="debug"&&console.warn(`\u2757\uFE0F Transformers warning: route ${D(t)} has ${r.items.length} non-void success responses. This is currently not handled and we will not generate a response transformer. Please open an issue if you'd like this feature https://github.com/hey-api/openapi-ts/issues`);return}let s=e.getPluginOrThrow("@hey-api/typescript"),o=e.getSymbol(s.api.getSelector("response",t.id));if(!o)return;let i=e.registerSymbol({exported:true,name:O({config:{case:"camelCase",name:"{{name}}ResponseTransformer"},name:t.id}),selector:e.api.getSelector("response",t.id)}),p=Pp({plugin:e,schema:r});if(p.length){let a=n.constVariable({exportConst:i.exported,expression:n.arrowFunction({async:true,multiLine:true,parameters:[{name:Yn,type:n.keywordTypeNode({keyword:"any"})}],returnType:n.typeReferenceNode({typeArguments:[n.typeReferenceNode({typeName:o.placeholder})],typeName:"Promise"}),statements:Wr(p)}),name:i.placeholder});e.setSymbolValue(i,a);}else e.setSymbolValue(i,null);});};var ud="$OpenApiTs",ne={$refs:[],base:"",description:null,enum:[],enums:[],export:"interface",imports:[],in:"",isDefinition:false,isNullable:false,isReadOnly:false,isRequired:false,link:null,name:"",properties:[],template:null,type:""},yd=({comments:e,leadingComment:t,meta:r,obj:s,onNode:o,...i})=>{if(!r)return;let{created:p,name:a}=Se({create:true,meta:r,...i});if(p){let m=I().plugins["@hey-api/typescript"],l=n.enumDeclaration({asConst:typeof m?.config.enums=="object"&&m.config.enums.mode==="typescript-const",comments:e,leadingComment:t,name:a,obj:s});o(l);}},pt=({comment:e,meta:t,onCreated:r,onNode:s,type:o,...i})=>{if(!t)return {created:false,name:""};let p=Se({create:true,meta:t,...i}),{created:a,name:c}=p;if(a){let m=n.typeAliasDeclaration({comment:e,exportType:true,name:c,type:o});s(m),r?.(c);}return p},hd=e=>{let t=[];Ip(e),e.model.enums.forEach(r=>xd({...e,model:r,onNode:s=>{t.push(s);}})),t.length&&e.onNode(n.namespaceDeclaration({name:e.model.name,statements:t}));},gd=({client:e,model:t,onNode:r})=>{let s=I(),o={},i={};t.enum.forEach(c=>{let{key:m,value:l}=mo(c);o[m]=l;let f=c.customDescription||c.description;f&&(i[m]=[K(f)]);});let p=[t.description&&K(t.description),t.deprecated&&"@deprecated"],a=s.plugins["@hey-api/typescript"];if(a?.config&&typeof a.config.enums=="object"&&a.config.enums.enabled&&(a.config.enums.mode==="typescript"||a.config.enums.mode==="typescript-const")){yd({asConst:a.config.enums.mode==="typescript-const",client:e,comments:i,leadingComment:p,meta:t.meta,obj:o,onNode:r});return}pt({client:e,comment:p,meta:t.meta,onCreated:c=>{let m=s.plugins["@hey-api/typescript"];if(m?.config&&typeof m.config.enums=="object"&&m.config.enums.enabled&&m.config.enums.mode==="javascript"){let l=n.objectExpression({multiLine:true,obj:Object.entries(o).map(([d,y])=>({comments:i[d],key:d,value:y})),unescape:true}),f=n.constVariable({assertion:"const",comment:p,exportConst:true,expression:l,name:c});r(f);}},onNode:r,type:Qa(t.enum)});},xd=({model:e,onNode:t})=>{let r={},s={};e.enum.forEach(p=>{let{key:a,value:c}=mo(p);r[a]=c;let m=p.customDescription||p.description;m&&(s[a]=[K(m)]);});let i=I().plugins["@hey-api/typescript"];t(n.enumDeclaration({asConst:typeof i?.config.enums=="object"&&i.config.enums.mode==="typescript-const",comments:s,leadingComment:[e.description&&K(e.description),e.deprecated&&"@deprecated"],name:e.meta?.name||e.name,obj:r}));},Ip=({client:e,model:t,onNode:r})=>{pt({client:e,comment:[t.description&&K(t.description),t.deprecated&&"@deprecated"],meta:t.meta,onNode:r,type:be(t)});},bd=e=>{switch(e.model.export){case "all-of":case "any-of":case "one-of":case "interface":return hd(e);case "enum":return gd(e);default:return Ip(e)}},Sd=({client:e,onNode:t})=>{let r={},s=I();if(!s.plugins["@hey-api/sdk"]&&!s.plugins["@hey-api/typescript"]?.config.tree)return;let o=U(s);for(let p of e.services)for(let a of p.operations){if(!a.parameters.length&&!a.responses.length)continue;r[a.path]||(r[a.path]={});let c=r[a.path];c[a.method]||(c[a.method]={});let m=c[a.method];if(m.$ref=a.name,a.responses.length>0){if(m.res||(m.res={}),Array.isArray(m.res))continue;a.responses.forEach(f=>{m.res[f.code]=f;});}if(a.parameters.length>0){let f={mediaType:null,...ne,in:"body",name:"body",prop:"body"},d=a.parameters.filter(S=>S.in==="body");d.length||(d=a.parameters.filter(S=>S.in==="formData")),d.length===1?f={...ne,...d[0],in:"body",isRequired:d[0].isRequired,name:"body",prop:"body"}:d.length>1&&(f={...ne,in:"body",isRequired:d.some(S=>S.isRequired),mediaType:"multipart/form-data",name:"body",prop:"body",properties:d});let y={...ne,in:"header",isRequired:Ke(a.parameters.filter(S=>S.in==="header")),mediaType:null,name:o?"header":"headers",prop:o?"header":"headers",properties:a.parameters.filter(S=>S.in==="header").sort(Fr)},h={...ne,in:"path",isRequired:Ke(a.parameters.filter(S=>S.in==="path")),mediaType:null,name:"path",prop:"path",properties:a.parameters.filter(S=>S.in==="path").sort(Fr)},g={...ne,in:"query",isRequired:Ke(a.parameters.filter(S=>S.in==="query")),mediaType:null,name:"query",prop:"query",properties:a.parameters.filter(S=>S.in==="query").sort(Fr)},x=o?Ha([...a.parameters]):[f,y,h,g].filter(S=>S.properties.length||S.$refs.length||S.mediaType);m.req=x,pt({client:e,meta:{$ref:a.name,name:a.name},nameTransformer:_t,onNode:t,type:be({...ne,properties:x})});}let l=a.responses.filter(f=>f.responseTypes.includes("success"));if(l.length>0){pt({client:e,meta:{$ref:a.name,name:a.name},nameTransformer:He,onNode:t,type:be({...ne,export:"any-of",properties:l})});let f=a.responses.filter(d=>d.responseTypes.includes("error"));o||pt({client:e,meta:{$ref:a.name,name:a.name},nameTransformer:xr,onNode:t,type:be(f.length?{...ne,export:"one-of",properties:f}:{...ne,base:"unknown"})});}}let i=Object.entries(r).map(([p,a])=>{let c=Object.entries(a).map(([l,f])=>{let d=l,y=[];if(f.req){let g=f.$ref,{name:x}=Se({client:e,meta:{$ref:g,name:g},nameTransformer:_t}),S={...ne,base:x,export:"reference",isRequired:true,name:"req",properties:[],type:x};y=[...y,S];}if(f.res){let g=Object.entries(f.res).map(([S,k])=>({...ne,...k,isRequired:true,name:String(S)})),x={...ne,isRequired:true,name:"res",properties:g};y=[...y,x];}return {...ne,isRequired:true,name:d.toLocaleLowerCase(),properties:y}}).filter(Boolean);return {...ne,isRequired:true,name:`'${p}'`,properties:c}});s.plugins["@hey-api/typescript"]?.config.tree&&pt({client:e,meta:{$ref:"@hey-api/openapi-ts",name:ud},onNode:t,type:be({...ne,properties:i})});},kp=({client:e,files:t,plugin:r})=>{let s=I();t.types=new Rt({dir:s.output.path,exportFromIndex:r.config.exportFromIndex,id:"types",name:"types.ts"});let o=i=>{t.types?.add(i);};for(let i of e.models)bd({client:e,model:i,onNode:o});Sd({client:e,onNode:o});};var At="data",Od=e=>e.base==="unknown"&&e.export==="generic"&&e.type==="unknown",jp=({client:e,model:t})=>t.$refs.map(s=>{let o=e.models.find(i=>i.meta?.$ref===s);if(!o)throw new Error(`Ref ${s} could not be found. Transformers cannot be generated without having access to all refs.`);return o}),Np=e=>{let t=e.model.meta.name,{name:r}=pt({...e,meta:{$ref:`transformers/${t}`,name:t},nameTransformer:gp,onCreated:o=>{let i=es({...e,meta:{$ref:`transformers/${t}`,name:o},path:[At]});Cp({...e,async:false,name:o,statements:i});},type:`(${At}: any) => ${t}`});return {created:!!e.client.types[r],name:r}},Td=e=>{let{model:t}=e,r=jp(e);if(r.length===1){let{created:s,name:o}=Np({...e,model:r[0]});return s?[n.transformArrayMutation({path:e.path,transformerName:o})]:[]}return Br(t)||t.link&&!Array.isArray(t.link)&&t.link.export==="any-of"&&t.link.properties.find(s=>Br(s))?[n.transformArrayMap({path:e.path,transformExpression:n.conditionalExpression({condition:n.identifier({text:"item"}),whenFalse:n.identifier({text:"item"}),whenTrue:n.transformNewDate({parameterName:"item"})})})]:[]},Rd=e=>{let{model:t}=e,r=[...e.path,t.name];return t.type==="string"&&t.export!=="array"&&Br(t)?[n.transformDateMutation({path:r})]:es({...e,model:t,path:r})},es=e=>{let{model:t}=e;switch(t.export){case "array":return Td(e);case "interface":return t.properties.flatMap(r=>Rd({...e,model:r}));case "reference":{if(t.$refs.length!==1)return [];let r=jp(e),{created:s,name:o}=Np({...e,model:r[0]});return s?t.in==="response"?[n.expressionToStatement({expression:n.callExpression({functionName:o,parameters:[At]})})]:n.transformFunctionMutation({path:e.path,transformerName:o}):[]}default:return []}},Cp=({async:e,client:t,name:r,onNode:s,onRemoveNode:o,statements:i})=>{let p={created:false,name:r};if(!i.length)return Ua({client:t,name:r}),o?.(),p;let a=n.arrowFunction({async:e,multiLine:true,parameters:[{name:At}],statements:[...i,n.returnVariable({expression:At})]}),c=n.constVariable({exportConst:true,expression:a,name:r,typeName:r});return s(c),{created:true,name:r}},vp=({client:e,files:t})=>{let r=I(),s=i=>{t.types?.add(i);},o=()=>{t.types?.removeNode_LEGACY();};for(let i of e.services)for(let p of i.operations){let a=p.responses.filter(l=>l.responseTypes.includes("success"));if(!a.length)continue;let c=a.filter(l=>!Od(l));if(!c.length)continue;if(c.length>1){r.logs.level==="debug"&&console.warn(`\u2757\uFE0F Transformers warning: route ${D(p)} has ${c.length} non-void success responses. This is currently not handled and we will not generate a response transformer. Please open an issue if you'd like this feature https://github.com/hey-api/openapi-ts/issues`);continue}let m=He(p.name);pt({client:e,meta:{$ref:`transformers/${m}`,name:m},nameTransformer:Ro,onCreated:l=>{let f=a.length>1?a.flatMap(d=>{let y=es({client:e,meta:{$ref:`transformers/${m}`,name:m},model:d,onNode:s,onRemoveNode:o,path:[At]});return y.length?[n.ifStatement({expression:n.safeAccessExpression(["data"]),thenStatement:n.block({statements:y})})]:[]}):es({client:e,meta:{$ref:`transformers/${m}`,name:m},model:a[0],onNode:s,onRemoveNode:o,path:[At]});Cp({async:true,client:e,name:l,onNode:s,onRemoveNode:o,statements:f});},onNode:s,type:`(${At}: any) => Promise<${m}>`});}};var ts={api:new Gn({name:"@hey-api/transformers"}),config:{bigInt:true,dates:true,exportFromIndex:false,transformers:[],typeTransformers:[]},dependencies:["@hey-api/typescript"],handler:Ep,handlerLegacy:vp,name:"@hey-api/transformers",resolveConfig:e=>{e.config.transformers||(e.config.transformers=[]),e.config.dates&&(e.config.transformers=[...e.config.transformers,Tp]),e.config.bigInt&&(e.config.transformers=[...e.config.transformers,Op]);},tags:["transformer"]};var qp=({context:e,name:t})=>(X.lastIndex=0,X.test(t)?t.startsWith("-")?b__default.default.factory.createStringLiteral(t):b__default.default.factory.createNumericLiteral(t):q({case:e.config.output.case,value:t}));var ce=({schema:e})=>{let t=[];return e.title&&t.push(K(e.title)),e.description&&t.push(K(e.description)),e.deprecated&&t.push("@deprecated"),t.length?t:void 0};var rs=n.keywordTypeNode({keyword:"string"}),Ed=({server:e})=>{let t=Ve(e.url);return t.protocol&&t.host?n.literalTypeNode({literal:n.stringLiteral({text:e.url})}):n.templateLiteralType({value:[t.protocol||rs,"://",t.host||rs,t.port?`:${t.port}`:"",t.path||""]})},$p=({plugin:e,servers:t,symbolClientOptions:r})=>{let s=P(e.context.config),o=t.map(a=>Ed({server:a}));t.length?"strictBaseUrl"in s.config&&s.config.strictBaseUrl||o.push(n.typeIntersectionNode({types:[rs,b__default.default.factory.createTypeLiteralNode([])]})):o.push(rs);let i=n.typeInterfaceNode({properties:[{name:ie(e.context.config),type:n.typeUnionNode({types:o})}],useLegacyResolution:false}),p=n.typeAliasDeclaration({exportType:r.exported,name:r.placeholder,type:i});e.setSymbolValue(r,p);};var Id=({plugin:e,schema:t})=>{let r=[];return {obj:(t.items??[]).map((o,i)=>{let p=typeof o.const;r.includes(p)||r.push(p);let a;return o.title?a=o.title:p==="number"||p==="string"?a=`${o.const}`:p==="boolean"?a=o.const?"true":"false":o.const===null?a="null":a=`${i}`,a&&(a=q({case:e.config.enums.case,stripLeadingSeparators:false,value:a}),X.lastIndex=0,X.test(a)&&e.config.enums.enabled&&(e.config.enums.mode==="typescript"||e.config.enums.mode==="typescript-const")&&(a=`_${a}`)),{comments:ce({schema:o}),key:a,value:o.const}}),typeofItems:r}},Mp=({plugin:e,schema:t,symbol:r,type:s})=>{if(t.type==="enum"&&e.config.enums.enabled){let i=Id({plugin:e,schema:t});if(e.config.enums.mode==="javascript"){e.config.enums.constantsIgnoreNull&&i.typeofItems.includes("object")&&(i.obj=i.obj.filter(m=>m.value!==null));let p=n.constVariable({assertion:"const",comment:ce({schema:t}),exportConst:true,expression:n.objectExpression({multiLine:true,obj:i.obj}),name:r.placeholder}),a=n.typeOfExpression({text:r.placeholder}),c=n.typeAliasDeclaration({comment:ce({schema:t}),exportType:true,name:r.placeholder,type:n.indexedAccessTypeNode({indexType:n.typeOperatorNode({operator:"keyof",type:a}),objectType:a})});e.setSymbolValue(r,[p,c]);return}else if((e.config.enums.mode==="typescript"||e.config.enums.mode==="typescript-const")&&!i.typeofItems.some(a=>a!=="number"&&a!=="string")){let a=n.enumDeclaration({asConst:e.config.enums.mode==="typescript-const",leadingComment:ce({schema:t}),name:r.placeholder,obj:i.obj});e.setSymbolValue(r,a);return}}let o=n.typeAliasDeclaration({comment:ce({schema:t}),exportType:r.exported,name:r.placeholder,type:s});e.setSymbolValue(r,o);};var Po=({parameters:e})=>{let t={type:"object"};if(e){let r={},s=[];for(let o in e){let i=e[o];r[i.name]=z({detectFormat:false,schema:i.schema}),i.required&&s.push(i.name);}t.properties=r,s.length&&(t.required=s);}return t},kd=({operation:e,plugin:t})=>{let r={type:"object"},s=[];r.properties||(r.properties={}),e.body?(r.properties.body=e.body.schema,e.body.required&&s.push("body")):r.properties.body={type:"never"},e.parameters?.header&&(r.properties.headers=Po({parameters:e.parameters.header}),r.properties.headers.required&&s.push("headers")),e.parameters?.path?(r.properties.path=Po({parameters:e.parameters.path}),r.properties.path.required&&s.push("path")):r.properties.path={type:"never"},e.parameters?.query?(r.properties.query=Po({parameters:e.parameters.query}),r.properties.query.required&&s.push("query")):r.properties.query={type:"never"},r.properties.url={const:e.path,type:"string"},s.push("url"),r.required=s;let o=t.registerSymbol({exported:true,meta:{kind:"type"},name:O({config:t.config.requests,name:e.id}),selector:t.api.getSelector("data",e.id)}),i=Z({plugin:t,schema:r}),p=n.typeAliasDeclaration({exportType:o.exported,name:o.placeholder,type:i});t.setSymbolValue(o,p);},Lp=({operation:e,plugin:t})=>{kd({operation:e,plugin:t});let{error:r,errors:s,response:o,responses:i}=we(e);if(s){let p=t.registerSymbol({exported:true,meta:{kind:"type"},name:O({config:t.config.errors,name:e.id}),selector:t.api.getSelector("errors",e.id)}),a=Z({plugin:t,schema:s}),c=n.typeAliasDeclaration({exportType:p.exported,name:p.placeholder,type:a});if(t.setSymbolValue(p,c),r){let m=t.registerSymbol({exported:true,meta:{kind:"type"},name:O({config:{case:t.config.errors.case,name:t.config.errors.error},name:e.id}),selector:t.api.getSelector("error",e.id)}),l=n.indexedAccessTypeNode({indexType:n.typeOperatorNode({operator:"keyof",type:n.typeReferenceNode({typeName:p.placeholder})}),objectType:n.typeReferenceNode({typeName:p.placeholder})}),f=n.typeAliasDeclaration({exportType:m.exported,name:m.placeholder,type:l});t.setSymbolValue(m,f);}}if(i){let p=t.registerSymbol({exported:true,meta:{kind:"type"},name:O({config:t.config.responses,name:e.id}),selector:t.api.getSelector("responses",e.id)}),a=Z({plugin:t,schema:i}),c=n.typeAliasDeclaration({exportType:p.exported,name:p.placeholder,type:a});if(t.setSymbolValue(p,c),o){let m=t.registerSymbol({exported:true,meta:{kind:"type"},name:O({config:{case:t.config.responses.case,name:t.config.responses.response},name:e.id}),selector:t.api.getSelector("response",e.id)}),l=n.indexedAccessTypeNode({indexType:n.typeOperatorNode({operator:"keyof",type:n.typeReferenceNode({typeName:p.placeholder})}),objectType:n.typeReferenceNode({typeName:p.placeholder})}),f=n.typeAliasDeclaration({exportType:m.exported,name:m.placeholder,type:l});t.setSymbolValue(m,f);}}};var jd=({operation:e,plugin:t})=>{let r={type:"object"},s=[];if(r.properties||(r.properties={}),e.body){let a=t.registerSymbol({exported:true,meta:{kind:"type"},name:O({config:{case:t.config.webhooks.case,name:t.config.webhooks.payload},name:e.id}),selector:t.api.getSelector("webhook-payload",e.id)}),c=Z({plugin:t,schema:e.body.schema}),m=n.typeAliasDeclaration({comment:ce({schema:e.body.schema}),exportType:a.exported,name:a.placeholder,type:c});t.setSymbolValue(a,m),t.registerSymbol({exported:true,meta:{kind:"type"},name:a.name,placeholder:a.placeholder,selector:t.api.getSelector("ref",a.placeholder)}),r.properties.body={$ref:a.placeholder},s.push("body");}else r.properties.body={type:"never"};r.properties.key={const:e.path,type:"string"},s.push("key"),r.properties.path={type:"never"},r.properties.query={type:"never"},r.required=s;let o=t.registerSymbol({exported:true,meta:{kind:"type"},name:O({config:t.config.webhooks,name:e.id}),selector:t.api.getSelector("webhook-request",e.id)}),i=Z({plugin:t,schema:r}),p=n.typeAliasDeclaration({exportType:o.exported,name:o.placeholder,type:i});return t.setSymbolValue(o,p),o.placeholder},Vp=({operation:e,plugin:t})=>jd({operation:e,plugin:t});var Dp=({plugin:e,symbolWebhooks:t,webhookNames:r})=>{if(!r.length)return;let s=n.typeUnionNode({types:r.map(i=>n.typeReferenceNode({typeName:i}))}),o=n.typeAliasDeclaration({exportType:t.exported,name:t.placeholder,type:s});e.setSymbolValue(t,o);};var Nd=({plugin:e,schema:t})=>{if(!t.items)return n.typeArrayNode(n.keywordTypeNode({keyword:e.config.topType}));t=z({detectFormat:true,schema:t});let r=[];for(let s of t.items){let o=Z({plugin:e,schema:s});r.push(o);}return r.length===1?n.typeArrayNode(r[0]):t.logicalOperator==="and"?n.typeArrayNode(n.typeIntersectionNode({types:r})):n.typeArrayNode(n.typeUnionNode({types:r}))},Cd=({schema:e})=>e.const!==void 0?n.literalTypeNode({literal:n.ots.boolean(e.const)}):n.keywordTypeNode({keyword:"boolean"}),vd=({plugin:e,schema:t})=>Z({plugin:e,schema:{...t,type:void 0}}),wd=({plugin:e,schema:t})=>t.const!==void 0?n.literalTypeNode({literal:n.ots.number(t.const)}):t.type==="integer"&&t.format==="int64"&&e.getPlugin("@hey-api/transformers")?.config.bigInt?n.typeReferenceNode({typeName:"bigint"}):n.keywordTypeNode({keyword:"number"}),qd=({plugin:e,schema:t})=>{let r,s,o=[],i=[],p=t.required??[],a=false;for(let d in t.properties){let y=t.properties[d],h=Z({plugin:e,schema:y}),g=p.includes(d);o.push({comment:ce({schema:y}),isReadOnly:y.accessScope==="read",isRequired:g,name:qp({context:e.context,name:d}),type:h}),i.push(y),g||(a=true);}if(t.patternProperties)for(let d in t.patternProperties){let y=t.patternProperties[d];i.unshift(y);}let c=!!t.patternProperties&&Object.keys(t.patternProperties).length>0,m=t.additionalProperties,l=m!==false&&m?m:void 0;if(c||!!l&&(l.type!=="never"||!i.length)){let d=l;d&&d.type!=="never"?i.unshift(d):!c&&!i.length&&d&&d.type==="never"&&(i=[d]),a&&i.push({type:"undefined"}),s={isRequired:!t.propertyNames,name:"key",type:i.length===1?Z({plugin:e,schema:i[0]}):Z({plugin:e,schema:{items:i,logicalOperator:"or"}})},t.propertyNames?.$ref&&(r=Z({plugin:e,schema:{$ref:t.propertyNames.$ref}}));}return n.typeInterfaceNode({indexKey:r,indexProperty:s,properties:o,useLegacyResolution:false})},$d=({plugin:e,schema:t})=>{if(t.const!==void 0)return n.literalTypeNode({literal:n.stringLiteral({text:t.const})});if(t.format){if(t.format==="binary")return n.typeUnionNode({types:[n.typeReferenceNode({typeName:"Blob"}),n.typeReferenceNode({typeName:"File"})]});if((t.format==="date-time"||t.format==="date")&&e.getPlugin("@hey-api/transformers")?.config.dates)return n.typeReferenceNode({typeName:"Date"});if(t.format==="typeid"&&typeof t.example=="string"){let r=String(t.example).split("_");r.pop();let s=r.join("_"),o=e.api.getSelector("TypeID",s);if(!e.getSymbol(o)){let p=e.api.getSelector("TypeID");if(!e.getSymbol(p)){let l=e.registerSymbol({exported:true,meta:{kind:"type"},name:"TypeID",selector:p}),f=n.typeAliasDeclaration({exportType:l.exported,name:l.placeholder,type:n.templateLiteralType({value:[n.typeReferenceNode({typeName:"T"}),"_",n.keywordTypeNode({keyword:"string"})]}),typeParameters:[n.typeParameterDeclaration({constraint:n.keywordTypeNode({keyword:"string"}),name:"T"})]});e.setSymbolValue(l,f);}let a=e.referenceSymbol(p),c=e.registerSymbol({exported:true,meta:{kind:"type"},name:q({case:e.config.case,value:`${s}_id`}),selector:o}),m=n.typeAliasDeclaration({exportType:c.exported,name:c.placeholder,type:n.typeReferenceNode({typeArguments:[n.literalTypeNode({literal:n.stringLiteral({text:s})})],typeName:a.placeholder})});e.setSymbolValue(c,m);}let i=e.referenceSymbol(o);return n.typeReferenceNode({typeName:i.placeholder})}}return n.keywordTypeNode({keyword:"string"})},Md=({plugin:e,schema:t})=>{let r=[];if(t.const&&Array.isArray(t.const))r=t.const.map(s=>n.valueToExpression({value:s})??n.identifier({text:e.config.topType}));else if(t.items)for(let s of t.items){let o=Z({plugin:e,schema:s});r.push(o);}return n.typeTupleNode({types:r})},Fp=({plugin:e,schema:t})=>{let r=e.getPlugin("@hey-api/transformers");if(r?.config.typeTransformers)for(let s of r.config.typeTransformers){let o=s({schema:t});if(o)return o}switch(t.type){case "array":return Nd({plugin:e,schema:t});case "boolean":return Cd({schema:t});case "enum":return vd({plugin:e,schema:t});case "integer":case "number":return wd({plugin:e,schema:t});case "never":return n.keywordTypeNode({keyword:"never"});case "null":return n.literalTypeNode({literal:n.null()});case "object":return qd({plugin:e,schema:t});case "string":return $d({plugin:e,schema:t});case "tuple":return Md({plugin:e,schema:t});case "undefined":return n.keywordTypeNode({keyword:"undefined"});case "unknown":return n.keywordTypeNode({keyword:e.config.topType});case "void":return n.keywordTypeNode({keyword:"void"})}},Z=({plugin:e,schema:t})=>{if(t.$ref){let r=e.referenceSymbol(e.api.getSelector("ref",t.$ref));return n.typeReferenceNode({typeName:r.placeholder})}if(t.type)return Fp({plugin:e,schema:t});if(t.items){if(t=z({detectFormat:false,schema:t}),t.items){let r=[];for(let s of t.items){let o=Z({plugin:e,schema:s});r.push(o);}return t.logicalOperator==="and"?n.typeIntersectionNode({types:r}):n.typeUnionNode({types:r})}return Z({plugin:e,schema:t})}return Fp({plugin:e,schema:{type:"unknown"}})},Eo=({id:e,plugin:t,schema:r})=>{let s=Z({plugin:t,schema:r}),o=r.type==="enum"&&t.config.enums.enabled,i=t.registerSymbol({exported:true,meta:{kind:o?void 0:"type"},name:O({config:t.config.definitions,name:L(e)}),selector:t.api.getSelector("ref",e)});Mp({plugin:t,schema:r,symbol:i,type:s});},Bp=({plugin:e})=>{let t=e.registerSymbol({exported:true,meta:{kind:"type"},name:O({config:{case:e.config.case},name:"ClientOptions"}),selector:e.api.getSelector("ClientOptions")}),r=e.registerSymbol({exported:true,meta:{kind:"type"},name:O({config:{case:e.config.case},name:"Webhooks"}),selector:e.api.getSelector("Webhooks")}),s=[],o=[];e.forEach("operation","parameter","requestBody","schema","server","webhook",i=>{switch(i.type){case "operation":Lp({operation:i.operation,plugin:e});break;case "parameter":Eo({id:i.$ref,plugin:e,schema:i.parameter.schema});break;case "requestBody":Eo({id:i.$ref,plugin:e,schema:i.requestBody.schema});break;case "schema":Eo({id:i.$ref,plugin:e,schema:i.schema});break;case "server":s.push(i.server);break;case "webhook":o.push(Vp({operation:i.operation,plugin:e}));break}}),$p({plugin:e,servers:s,symbolClientOptions:t}),Dp({plugin:e,symbolWebhooks:r,webhookNames:o});};var ns=class{constructor(t){this.meta=t;}getSelector(...t){return [this.meta.name,...t]}schemaToType(t){return Z(t)}};var ss={api:new ns({name:"@hey-api/typescript"}),config:{case:"PascalCase",exportFromIndex:true,style:"preserve",topType:"unknown",tree:false},handler:Bp,handlerLegacy:kp,name:"@hey-api/typescript",resolveConfig:(e,t)=>{e.config.definitions=t.valueToObject({defaultValue:{case:e.config.case??"PascalCase",name:"{{name}}"},mappers:{function:r=>({name:r}),string:r=>({name:r})},value:e.config.definitions}),e.config.enums=t.valueToObject({defaultValue:{case:"SCREAMING_SNAKE_CASE",constantsIgnoreNull:false,enabled:!!e.config.enums,mode:"javascript"},mappers:{boolean:r=>({enabled:r}),string:r=>({mode:r})},value:e.config.enums}),e.config.errors=t.valueToObject({defaultValue:{case:e.config.case??"PascalCase",error:"{{name}}Error",name:"{{name}}Errors"},mappers:{function:r=>({name:r}),string:r=>({name:r})},value:e.config.errors}),e.config.requests=t.valueToObject({defaultValue:{case:e.config.case??"PascalCase",name:"{{name}}Data"},mappers:{function:r=>({name:r}),string:r=>({name:r})},value:e.config.requests}),e.config.responses=t.valueToObject({defaultValue:{case:e.config.case??"PascalCase",name:"{{name}}Responses",response:"{{name}}Response"},mappers:{function:r=>({name:r}),string:r=>({name:r})},value:e.config.responses}),e.config.webhooks=t.valueToObject({defaultValue:{case:e.config.case??"PascalCase",name:"{{name}}WebhookRequest",payload:"{{name}}WebhookPayload"},mappers:{function:r=>({name:r}),string:r=>({name:r})},value:e.config.webhooks});}};var os=class{constructor(t){this.meta=t;}getSelector(...t){return [this.meta.name,...t]}};var is=(e,t,r)=>{let s=e.config[r].meta;if(!s)return;let o=s(t);if(Object.keys(o).length)return n.valueToExpression({value:o})};var br=({operation:e,plugin:t})=>{let r=t.getPluginOrThrow("@hey-api/sdk");return Kr({operation:e,plugin:r})},Kp=({operation:e,plugin:t})=>{let r=P(t.context.config),s=t.getPluginOrThrow("@hey-api/typescript"),i=t.getSymbol(s.api.getSelector("error",e.id))?.placeholder;return i||(i="Error"),r.name==="@hey-api/client-axios"&&(i=`${t.referenceSymbol(t.api.getSelector("AxiosError")).placeholder}<${i}>`),i},Wp=({operation:e,plugin:t})=>{let r=t.getPluginOrThrow("@hey-api/typescript");return t.getSymbol(r.api.getSelector("response",e.id))?.placeholder||"unknown"};var Sr=({plugin:e,typeData:t})=>{let s=P(e.context.config).name==="@hey-api/client-nuxt",o=s?`Omit<${t}, 'composable'>`:t;return {isNuxtClient:s,strippedTypeData:o}};var zp=({operation:e,plugin:t,queryFn:r})=>{let s=t.referenceSymbol(t.api.getSelector("UseMutationOptions")),o=br({operation:e,plugin:t}),i=Kp({operation:e,plugin:t}),p=Wp({operation:e,plugin:t}),{isNuxtClient:a,strippedTypeData:c}=Sr({plugin:t,typeData:o}),m=a?`${s.placeholder}<${p}, ${c}, ${i}>`:`${s.placeholder}<${p}, ${o}, ${i}>`,l="fnOptions",f=n.awaitExpression({expression:n.callExpression({functionName:r,parameters:[n.objectExpression({multiLine:true,obj:[{spread:"options"},{spread:l},{key:"throwOnError",value:true}]})]})}),d=[];t.getPluginOrThrow("@hey-api/sdk").config.responseStyle==="data"?d.push(n.returnVariable({expression:f})):d.push(n.constVariable({destructure:true,expression:f,name:"data"}),n.returnVariable({expression:"data"}));let y=[{key:"mutation",value:n.arrowFunction({async:true,multiLine:true,parameters:[a?{name:l,type:`Partial<${c}>`}:{name:l}],statements:d})}],h=is(t,e,"mutationOptions");h&&y.push({key:"meta",value:h});let g=t.registerSymbol({exported:true,name:O({config:t.config.mutationOptions,name:e.id})}),x=n.constVariable({comment:t.config.comments?W({operation:e}):void 0,exportConst:g.exported,expression:n.arrowFunction({parameters:[{isRequired:false,name:"options",type:`Partial<${c}>`}],returnType:m,statements:[n.returnStatement({expression:n.objectExpression({obj:y})})]}),name:g.placeholder});t.setSymbolValue(g.id,x);};var _r="TOptions",Io=n.identifier({text:"options"}),_p=({plugin:e})=>{let t=e.registerSymbol({name:O({config:{case:e.config.case},name:"createQueryKey"}),selector:e.api.getSelector("createQueryKey")}),r=e.referenceSymbol(e.api.getSelector("QueryKey")),s=e.referenceSymbol(e.api.getSelector("_JSONValue")),o=n.indexedAccessTypeNode({indexType:n.literalTypeNode({literal:n.ots.number(0)}),objectType:n.typeReferenceNode({typeArguments:[n.typeReferenceNode({typeName:_r})],typeName:r.placeholder})}),i=ie(e.context.config),p=e.getPluginOrThrow("@hey-api/sdk"),a=e.referenceSymbol(p.api.getSelector("Options")),c=P(e.context.config),m=c.api&&"getSelector"in c.api?e.getSymbol(c.api.getSelector("client")):void 0,l=ze(e.context.config),f=e.registerSymbol({external:l,name:"serializeQueryKeyValue"}),d=n.constVariable({expression:n.arrowFunction({multiLine:true,parameters:[{name:"id",type:n.typeReferenceNode({typeName:"string"})},{isRequired:false,name:"options",type:n.typeReferenceNode({typeName:_r})},{isRequired:false,name:"tags",type:n.typeReferenceNode({typeName:"ReadonlyArray<string>"})}],returnType:n.typeTupleNode({types:[o]}),statements:[n.constVariable({assertion:o,expression:n.objectExpression({multiLine:false,obj:[{key:"_id",value:n.identifier({text:"id"})},{key:i,value:n.identifier({text:`options?.${i} || (options?.client ?? ${m?.placeholder}).getConfig().${i}`})}]}),name:"params",typeName:o}),n.ifStatement({expression:n.identifier({text:"tags"}),thenStatement:n.block({statements:[n.expressionToStatement({expression:n.binaryExpression({left:n.propertyAccessExpression({expression:"params",name:"tags"}),right:n.asExpression({expression:n.asExpression({expression:n.identifier({text:"tags"}),type:n.keywordTypeNode({keyword:"unknown"})}),type:n.typeReferenceNode({typeName:s.placeholder})})})})]})}),n.ifStatement({expression:n.binaryExpression({left:n.propertyAccessExpression({expression:Io,isOptional:true,name:n.identifier({text:"body"})}),operator:"!==",right:"undefined"}),thenStatement:n.block({statements:[n.constVariable({expression:n.callExpression({functionName:f.placeholder,parameters:[n.propertyAccessExpression({expression:"options",name:"body"})]}),name:"normalizedBody"}),n.ifStatement({expression:n.binaryExpression({left:n.identifier({text:"normalizedBody"}),operator:"!==",right:"undefined"}),thenStatement:n.block({statements:[n.expressionToStatement({expression:n.binaryExpression({left:n.propertyAccessExpression({expression:"params",name:"body"}),right:n.identifier({text:"normalizedBody"})})})]})})]})}),n.ifStatement({expression:n.propertyAccessExpression({expression:Io,isOptional:true,name:n.identifier({text:"path"})}),thenStatement:n.block({statements:[n.expressionToStatement({expression:n.binaryExpression({left:n.propertyAccessExpression({expression:"params",name:"path"}),right:n.propertyAccessExpression({expression:"options",name:"path"})})})]})}),n.ifStatement({expression:n.binaryExpression({left:n.propertyAccessExpression({expression:Io,isOptional:true,name:n.identifier({text:"query"})}),operator:"!==",right:"undefined"}),thenStatement:n.block({statements:[n.constVariable({expression:n.callExpression({functionName:f.placeholder,parameters:[n.propertyAccessExpression({expression:"options",name:"query"})]}),name:"normalizedQuery"}),n.ifStatement({expression:n.binaryExpression({left:n.identifier({text:"normalizedQuery"}),operator:"!==",right:"undefined"}),thenStatement:n.block({statements:[n.expressionToStatement({expression:n.binaryExpression({left:n.propertyAccessExpression({expression:"params",name:"query"}),right:n.identifier({text:"normalizedQuery"})})})]})})]})}),n.returnStatement({expression:n.arrayLiteralExpression({elements:[n.identifier({text:"params"})]})})],types:[{extends:n.typeReferenceNode({typeName:n.identifier({text:a.placeholder})}),name:_r}]}),name:t.placeholder});e.setSymbolValue(t,d);},Vd=({id:e,operation:t,plugin:r})=>{let s=r.config.queryKeys,o;s.tags&&t.tags&&t.tags.length>0&&(o=n.arrayLiteralExpression({elements:t.tags.map(a=>n.stringLiteral({text:a}))}));let i=r.referenceSymbol(r.api.getSelector("createQueryKey"));return n.callExpression({functionName:i.placeholder,parameters:[n.ots.string(e),"options",o]})},Hp=({plugin:e})=>{let t=e.referenceSymbol(e.api.getSelector("_JSONValue")),r=[{name:"_id",type:n.keywordTypeNode({keyword:"string"})},{isRequired:false,name:ie(e.context.config),type:n.typeReferenceNode({typeName:t.placeholder})},{isRequired:false,name:"body",type:n.typeReferenceNode({typeName:t.placeholder})},{isRequired:false,name:"query",type:n.typeReferenceNode({typeName:t.placeholder})},{isRequired:false,name:"tags",type:n.typeReferenceNode({typeName:t.placeholder})}],s=e.getPluginOrThrow("@hey-api/sdk"),o=e.referenceSymbol(s.api.getSelector("Options")),i=e.registerSymbol({exported:true,meta:{kind:"type"},name:"QueryKey",selector:e.api.getSelector("QueryKey")}),p=n.typeAliasDeclaration({exportType:i.exported,name:i.placeholder,type:n.typeTupleNode({types:[n.typeIntersectionNode({types:[n.typeReferenceNode({typeName:`Pick<${_r}, 'path'>`}),n.typeInterfaceNode({properties:r,useLegacyResolution:true})]})]}),typeParameters:[{extends:n.typeReferenceNode({typeName:n.identifier({text:o.placeholder})}),name:_r}]});e.setSymbolValue(i,p);},Qp=({operation:e,plugin:t,symbol:r})=>{let s=br({operation:e,plugin:t}),{strippedTypeData:o}=Sr({plugin:t,typeData:s});return n.constVariable({exportConst:r.exported,expression:n.arrowFunction({parameters:[{isRequired:nr(e),name:"options",type:o}],statements:Vd({id:e.id,operation:e,plugin:t})}),name:r.placeholder})};var as="options",Zp="context",Up=({operation:e,plugin:t,queryFn:r})=>{if(yr({operation:e}))return;let s=Y({context:t.context,operation:e});t.getSymbol(t.api.getSelector("createQueryKey"))||(Hp({plugin:t}),_p({plugin:t}));let o;if(t.config.queryKeys.enabled){let h=t.registerSymbol({exported:true,name:O({config:t.config.queryKeys,name:e.id})}),g=Qp({operation:e,plugin:t,symbol:h});t.setSymbolValue(h,g),o=n.callExpression({functionName:h.placeholder,parameters:[as]});}else {let h=t.referenceSymbol(t.api.getSelector("createQueryKey")),g;t.config.queryKeys.tags&&e.tags&&e.tags.length>0&&(g=n.arrayLiteralExpression({elements:e.tags.map(x=>n.stringLiteral({text:x}))})),o=n.callExpression({functionName:h.placeholder,parameters:[n.ots.string(e.id),as,g]});}let i=br({operation:e,plugin:t}),{strippedTypeData:p}=Sr({plugin:t,typeData:i}),a=n.awaitExpression({expression:n.callExpression({functionName:r,parameters:[n.objectExpression({multiLine:true,obj:[{spread:as},{spread:Zp},{key:"throwOnError",value:true}]})]})}),c=[];t.getPluginOrThrow("@hey-api/sdk").config.responseStyle==="data"?c.push(n.returnVariable({expression:a})):c.push(n.constVariable({destructure:true,expression:a,name:"data"}),n.returnVariable({expression:"data"}));let m=[{key:"key",value:o},{key:"query",value:n.arrowFunction({async:true,multiLine:true,parameters:[{name:Zp}],statements:c})}],l=is(t,e,"queryOptions");l&&m.push({key:"meta",value:l});let f=t.registerSymbol({exported:true,name:O({config:t.config.queryOptions,name:e.id}),selector:t.api.getSelector("queryOptionsFn",e.id)}),d=t.registerSymbol({external:t.name,name:"defineQueryOptions",selector:t.api.getSelector("defineQueryOptions")}),y=n.constVariable({comment:t.config.comments?W({operation:e}):void 0,exportConst:f.exported,expression:n.callExpression({functionName:d.placeholder,parameters:[n.arrowFunction({parameters:[{isRequired:s,name:as,type:p}],statements:n.objectExpression({obj:m})})]}),name:f.placeholder});t.setSymbolValue(f,y);};var Xp=({plugin:e})=>{e.registerSymbol({external:e.name,meta:{kind:"type"},name:"UseMutationOptions",selector:e.api.getSelector("UseMutationOptions")}),e.registerSymbol({external:e.name,meta:{kind:"type"},name:"UseQueryOptions",selector:e.api.getSelector("UseQueryOptions")}),e.registerSymbol({external:e.name,meta:{kind:"type"},name:"_JSONValue",selector:e.api.getSelector("_JSONValue")}),e.registerSymbol({external:"axios",meta:{kind:"type"},name:"AxiosError",selector:e.api.getSelector("AxiosError")});let t=e.getPluginOrThrow("@hey-api/sdk");e.forEach("operation",({operation:r})=>{let s=t.config.asClass?Pe({context:e.context,operation:r,plugin:t}):void 0,o=s?s.values().next().value:void 0,i=o?[e.referenceSymbol(t.api.getSelector("class",o.path[0])).placeholder,...o.path.slice(1).map(p=>q({case:"camelCase",value:p})),o.methodName].filter(Boolean).join("."):e.referenceSymbol(t.api.getSelector("function",r.id)).placeholder;e.hooks.operation.isQuery(r)&&e.config.queryOptions.enabled&&Up({operation:r,plugin:e,queryFn:i}),e.hooks.operation.isMutation(r)&&e.config.mutationOptions.enabled&&zp({operation:r,plugin:e,queryFn:i});});};var ps={api:new os({name:"@pinia/colada"}),config:{case:"camelCase",comments:true,exportFromIndex:false},dependencies:["@hey-api/typescript","@hey-api/sdk"],handler:Xp,name:"@pinia/colada",resolveConfig:(e,t)=>{e.config.mutationOptions=t.valueToObject({defaultValue:{case:e.config.case??"camelCase",enabled:true,name:"{{name}}Mutation"},mappers:{boolean:r=>({enabled:r}),function:r=>({name:r}),string:r=>({name:r})},value:e.config.mutationOptions}),e.config.queryKeys=t.valueToObject({defaultValue:{case:e.config.case??"camelCase",enabled:true,name:"{{name}}QueryKey",tags:false},mappers:{boolean:r=>({enabled:r}),function:r=>({name:r}),string:r=>({name:r})},value:e.config.queryKeys}),e.config.queryOptions=t.valueToObject({defaultValue:{case:e.config.case??"camelCase",enabled:true,name:"{{name}}Query"},mappers:{boolean:r=>({enabled:r}),function:r=>({name:r}),string:r=>({name:r})},value:e.config.queryOptions});}};var Or=(e,t,r)=>{let s=e.config[r].meta;if(!s)return;let o=s(t);if(Object.keys(o).length)return n.valueToExpression({value:o})};var Qe=({operation:e,plugin:t})=>{let r=t.getPluginOrThrow("@hey-api/sdk");return Kr({operation:e,plugin:r})},cs=({operation:e,plugin:t})=>{let r=P(t.context.config),s=t.getPluginOrThrow("@hey-api/typescript"),i=t.getSymbol(s.api.getSelector("error",e.id))?.placeholder;return i||(i=t.referenceSymbol(t.api.getSelector("DefaultError")).placeholder),r.name==="@hey-api/client-axios"&&(i=`${t.referenceSymbol(t.api.getSelector("AxiosError")).placeholder}<${i}>`),i},ms=({operation:e,plugin:t})=>{let r=t.getPluginOrThrow("@hey-api/typescript");return t.getSymbol(r.api.getSelector("response",e.id))?.placeholder||"unknown"};var Hr="TOptions",Jp=n.identifier({text:"infinite"}),ls=n.identifier({text:"options"}),fs=({plugin:e})=>{let t=e.registerSymbol({name:O({config:{case:e.config.case},name:"createQueryKey"}),selector:e.api.getSelector("createQueryKey")}),r=e.referenceSymbol(e.api.getSelector("QueryKey")),s=n.indexedAccessTypeNode({indexType:n.literalTypeNode({literal:n.ots.number(0)}),objectType:n.typeReferenceNode({typeArguments:[n.typeReferenceNode({typeName:Hr})],typeName:r.placeholder})}),o=ie(e.context.config),i=P(e.context.config),p=i.api&&"getSelector"in i.api?e.getSymbol(i.api.getSelector("client")):void 0,a=e.getPluginOrThrow("@hey-api/sdk"),c=e.referenceSymbol(a.api.getSelector("Options")),m=n.constVariable({expression:n.arrowFunction({multiLine:true,parameters:[{name:"id",type:n.typeReferenceNode({typeName:"string"})},{isRequired:false,name:"options",type:n.typeReferenceNode({typeName:Hr})},{isRequired:false,name:"infinite",type:n.typeReferenceNode({typeName:"boolean"})},{isRequired:false,name:"tags",type:n.typeReferenceNode({typeName:"ReadonlyArray<string>"})}],returnType:n.typeTupleNode({types:[s]}),statements:[n.constVariable({assertion:s,expression:n.objectExpression({multiLine:false,obj:[{key:"_id",value:n.identifier({text:"id"})},{key:o,value:n.identifier({text:`options?.${o} || (options?.client ?? ${p?.placeholder}).getConfig().${o}`})}]}),name:"params",typeName:s}),n.ifStatement({expression:Jp,thenStatement:n.block({statements:[n.expressionToStatement({expression:n.binaryExpression({left:n.propertyAccessExpression({expression:"params",name:"_infinite"}),right:Jp})})]})}),n.ifStatement({expression:n.identifier({text:"tags"}),thenStatement:n.block({statements:[n.expressionToStatement({expression:n.binaryExpression({left:n.propertyAccessExpression({expression:"params",name:"tags"}),right:n.identifier({text:"tags"})})})]})}),n.ifStatement({expression:n.propertyAccessExpression({expression:ls,isOptional:true,name:n.identifier({text:"body"})}),thenStatement:n.block({statements:[n.expressionToStatement({expression:n.binaryExpression({left:n.propertyAccessExpression({expression:"params",name:"body"}),right:n.propertyAccessExpression({expression:"options",name:"body"})})})]})}),n.ifStatement({expression:n.propertyAccessExpression({expression:ls,isOptional:true,name:n.identifier({text:"headers"})}),thenStatement:n.block({statements:[n.expressionToStatement({expression:n.binaryExpression({left:n.propertyAccessExpression({expression:"params",name:"headers"}),right:n.propertyAccessExpression({expression:"options",name:"headers"})})})]})}),n.ifStatement({expression:n.propertyAccessExpression({expression:ls,isOptional:true,name:n.identifier({text:"path"})}),thenStatement:n.block({statements:[n.expressionToStatement({expression:n.binaryExpression({left:n.propertyAccessExpression({expression:"params",name:"path"}),right:n.propertyAccessExpression({expression:"options",name:"path"})})})]})}),n.ifStatement({expression:n.propertyAccessExpression({expression:ls,isOptional:true,name:n.identifier({text:"query"})}),thenStatement:n.block({statements:[n.expressionToStatement({expression:n.binaryExpression({left:n.propertyAccessExpression({expression:"params",name:"query"}),right:n.propertyAccessExpression({expression:"options",name:"query"})})})]})}),n.returnStatement({expression:n.arrayLiteralExpression({elements:[n.identifier({text:"params"})]})})],types:[{extends:n.typeReferenceNode({typeName:n.identifier({text:c.placeholder})}),name:Hr}]}),name:t.placeholder});e.setSymbolValue(t,m);},Fd=({id:e,isInfinite:t,operation:r,plugin:s})=>{let o=t?s.config.infiniteQueryKeys:s.config.queryKeys,i;o.tags&&r.tags&&r.tags.length>0&&(i=n.arrayLiteralExpression({elements:r.tags.map(c=>n.stringLiteral({text:c}))}));let p=s.referenceSymbol(s.api.getSelector("createQueryKey"));return n.callExpression({functionName:p.placeholder,parameters:[n.ots.string(e),"options",t||i?n.ots.boolean(!!t):void 0,i]})},ds=({plugin:e})=>{let t=[{name:"_id",type:n.keywordTypeNode({keyword:"string"})},{isRequired:false,name:"_infinite",type:n.keywordTypeNode({keyword:"boolean"})},{isRequired:false,name:"tags",type:n.typeReferenceNode({typeName:"ReadonlyArray<string>"})}],r=e.getPluginOrThrow("@hey-api/sdk"),s=e.referenceSymbol(r.api.getSelector("Options")),o=e.registerSymbol({exported:true,meta:{kind:"type"},name:"QueryKey",selector:e.api.getSelector("QueryKey")}),i=n.typeAliasDeclaration({exportType:o.exported,name:o.placeholder,type:n.typeTupleNode({types:[n.typeIntersectionNode({types:[n.typeReferenceNode({typeName:`Pick<${Hr}, '${ie(e.context.config)}' | 'body' | 'headers' | 'path' | 'query'>`}),n.typeInterfaceNode({properties:t,useLegacyResolution:true})]})]}),typeParameters:[{extends:n.typeReferenceNode({typeName:n.identifier({text:s.placeholder})}),name:Hr}]});e.setSymbolValue(o,i);},us=({isInfinite:e,operation:t,plugin:r,symbol:s,typeQueryKey:o})=>{let i=Qe({operation:t,plugin:r});return n.constVariable({exportConst:s.exported,expression:n.arrowFunction({parameters:[{isRequired:nr(t),name:"options",type:i}],returnType:e?o:void 0,statements:Fd({id:t.id,isInfinite:e,operation:t,plugin:r})}),name:s.placeholder})};var Kd=({plugin:e})=>{let t=e.registerSymbol({name:O({config:{case:e.config.case},name:"createInfiniteParams"}),selector:e.api.getSelector("createInfiniteParams")}),r=n.constVariable({expression:n.arrowFunction({multiLine:true,parameters:[{name:"queryKey",type:n.typeReferenceNode({typeName:"QueryKey<Options>"})},{name:"page",type:n.typeReferenceNode({typeName:"K"})}],statements:[n.constVariable({expression:n.objectExpression({obj:[{spread:n.propertyAccessExpression({expression:"queryKey",name:0})}]}),name:"params"}),n.ifStatement({expression:n.propertyAccessExpression({expression:n.identifier({text:"page"}),name:n.identifier({text:"body"})}),thenStatement:n.block({statements:[n.expressionToStatement({expression:n.binaryExpression({left:n.propertyAccessExpression({expression:"params",name:"body"}),right:n.objectExpression({multiLine:true,obj:[{assertion:"any",spread:"queryKey[0].body"},{assertion:"any",spread:"page.body"}]})})})]})}),n.ifStatement({expression:n.propertyAccessExpression({expression:n.identifier({text:"page"}),name:n.identifier({text:"headers"})}),thenStatement:n.block({statements:[n.expressionToStatement({expression:n.binaryExpression({left:n.propertyAccessExpression({expression:"params",name:"headers"}),right:n.objectExpression({multiLine:true,obj:[{spread:"queryKey[0].headers"},{spread:"page.headers"}]})})})]})}),n.ifStatement({expression:n.propertyAccessExpression({expression:n.identifier({text:"page"}),name:n.identifier({text:"path"})}),thenStatement:n.block({statements:[n.expressionToStatement({expression:n.binaryExpression({left:n.propertyAccessExpression({expression:"params",name:"path"}),right:n.objectExpression({multiLine:true,obj:[{assertion:"any",spread:"queryKey[0].path"},{assertion:"any",spread:"page.path"}]})})})]})}),n.ifStatement({expression:n.propertyAccessExpression({expression:n.identifier({text:"page"}),name:n.identifier({text:"query"})}),thenStatement:n.block({statements:[n.expressionToStatement({expression:n.binaryExpression({left:n.propertyAccessExpression({expression:"params",name:"query"}),right:n.objectExpression({multiLine:true,obj:[{assertion:"any",spread:"queryKey[0].query"},{assertion:"any",spread:"page.query"}]})})})]})}),n.returnVariable({expression:n.asExpression({expression:n.asExpression({expression:n.identifier({text:"params"}),type:n.keywordTypeNode({keyword:"unknown"})}),type:b__default.default.factory.createTypeQueryNode(n.identifier({text:"page"}))})})],types:[{extends:n.typeReferenceNode({typeName:n.identifier({text:"Pick<QueryKey<Options>[0], 'body' | 'headers' | 'path' | 'query'>"})}),name:"K"}]}),name:t.placeholder});e.setSymbolValue(t,r);},Gp=({operation:e,plugin:t,queryFn:r})=>{let s=Ji({context:t.context,operation:e});if(!s)return;let o=Y({context:t.context,operation:e});t.getSymbol(t.api.getSelector("createQueryKey"))||(ds({plugin:t}),fs({plugin:t})),t.getSymbol(t.api.getSelector("createInfiniteParams"))||Kd({plugin:t});let i=t.referenceSymbol(t.api.getSelector("infiniteQueryOptions")),p=t.referenceSymbol(t.api.getSelector("InfiniteData")),a=Qe({operation:e,plugin:t}),c=cs({operation:e,plugin:t}),m=ms({operation:e,plugin:t}),f=`${t.referenceSymbol(t.api.getSelector("QueryKey")).placeholder}<${a}>`,d=`Pick<${f}[0], 'body' | 'headers' | 'path' | 'query'>`,y=t.getPluginOrThrow("@hey-api/typescript"),h=y.api.schemaToType({plugin:y,schema:s.schema}),g=`${se({node:h,unescape:true})} | ${d}`,x=t.registerSymbol({exported:true,name:O({config:t.config.infiniteQueryKeys,name:e.id})}),S=us({isInfinite:true,operation:e,plugin:t,symbol:x,typeQueryKey:f});t.setSymbolValue(x,S);let k=n.awaitExpression({expression:n.callExpression({functionName:r,parameters:[n.objectExpression({multiLine:true,obj:[{spread:"options"},{spread:"params"},{key:"signal",shorthand:true,value:n.identifier({text:"signal"})},{key:"throwOnError",value:true}]})]})}),E=t.referenceSymbol(t.api.getSelector("createInfiniteParams")),C=[n.constVariable({comment:[{jsdoc:false,lines:["@ts-ignore"]}],expression:n.conditionalExpression({condition:n.binaryExpression({left:n.typeOfExpression({text:"pageParam"}),operator:"===",right:n.ots.string("object")}),whenFalse:n.objectExpression({multiLine:true,obj:[{key:s.in,value:n.objectExpression({multiLine:true,obj:[{key:s.name,value:n.identifier({text:"pageParam"})}]})}]}),whenTrue:n.identifier({text:"pageParam"})}),name:"page",typeName:d}),n.constVariable({expression:n.callExpression({functionName:E.placeholder,parameters:["queryKey","page"]}),name:"params"})];t.getPluginOrThrow("@hey-api/sdk").config.responseStyle==="data"?C.push(n.returnVariable({expression:k})):C.push(n.constVariable({destructure:true,expression:k,name:"data"}),n.returnVariable({expression:"data"}));let j=[{key:"queryFn",value:n.arrowFunction({async:true,multiLine:true,parameters:[{destructure:[{name:"pageParam"},{name:"queryKey"},{name:"signal"}]}],statements:C})},{key:"queryKey",value:n.callExpression({functionName:x.placeholder,parameters:["options"]})}],F=Or(t,e,"infiniteQueryOptions");F&&j.push({key:"meta",value:F});let M=t.registerSymbol({exported:true,name:O({config:t.config.infiniteQueryOptions,name:e.id})}),v=n.constVariable({comment:t.config.comments?W({operation:e}):void 0,exportConst:M.exported,expression:n.arrowFunction({parameters:[{isRequired:o,name:"options",type:a}],statements:[n.returnFunctionCall({args:[n.objectExpression({comments:[{jsdoc:false,lines:["@ts-ignore"]}],obj:j})],name:i.placeholder,types:[m,c||"unknown",`${p.placeholder}<${m}>`,f,g]})]}),name:M.placeholder});t.setSymbolValue(M,v);};var Yp=({operation:e,plugin:t,queryFn:r})=>{let s=t.referenceSymbol(t.api.getSelector("MutationOptions")),o=Qe({operation:e,plugin:t}),i=cs({operation:e,plugin:t}),p=ms({operation:e,plugin:t}),a=`${s.placeholder}<${p}, ${i}, ${o}>`,c="fnOptions",m=n.awaitExpression({expression:n.callExpression({functionName:r,parameters:[n.objectExpression({multiLine:true,obj:[{spread:"options"},{spread:c},{key:"throwOnError",value:true}]})]})}),l=[];t.getPluginOrThrow("@hey-api/sdk").config.responseStyle==="data"?l.push(n.returnVariable({expression:m})):l.push(n.constVariable({destructure:true,expression:m,name:"data"}),n.returnVariable({expression:"data"}));let f=[{key:"mutationFn",value:n.arrowFunction({async:true,multiLine:true,parameters:[{name:c}],statements:l})}],d=Or(t,e,"mutationOptions");d&&f.push({key:"meta",value:d});let y="mutationOptions",h=n.arrowFunction({parameters:[{isRequired:false,name:"options",type:`Partial<${o}>`}],returnType:a,statements:[n.constVariable({expression:n.objectExpression({obj:f}),name:y,typeName:a}),n.returnVariable({expression:y})]}),g=t.registerSymbol({exported:true,name:O({config:t.config.mutationOptions,name:e.id})}),x=n.constVariable({comment:t.config.comments?W({operation:e}):void 0,exportConst:g.exported,expression:h,name:g.placeholder});t.setSymbolValue(g,x);};var ko="options",ec=({operation:e,plugin:t,queryFn:r})=>{if(yr({operation:e}))return;let s=Y({context:t.context,operation:e});t.getSymbol(t.api.getSelector("createQueryKey"))||(ds({plugin:t}),fs({plugin:t}));let o=t.referenceSymbol(t.api.getSelector("queryOptions")),i=t.registerSymbol({exported:true,name:O({config:t.config.queryKeys,name:e.id})}),p=us({isInfinite:false,operation:e,plugin:t,symbol:i});t.setSymbolValue(i,p);let a=Qe({operation:e,plugin:t}),c=n.awaitExpression({expression:n.callExpression({functionName:r,parameters:[n.objectExpression({multiLine:true,obj:[{spread:ko},{spread:"queryKey[0]"},{key:"signal",shorthand:true,value:n.identifier({text:"signal"})},{key:"throwOnError",value:true}]})]})}),m=[];t.getPluginOrThrow("@hey-api/sdk").config.responseStyle==="data"?m.push(n.returnVariable({expression:c})):m.push(n.constVariable({destructure:true,expression:c,name:"data"}),n.returnVariable({expression:"data"}));let l=[{key:"queryFn",value:n.arrowFunction({async:true,multiLine:true,parameters:[{destructure:[{name:"queryKey"},{name:"signal"}]}],statements:m})},{key:"queryKey",value:n.callExpression({functionName:i.placeholder,parameters:[ko]})}],f=Or(t,e,"queryOptions");f&&l.push({key:"meta",value:f});let d=t.registerSymbol({exported:t.config.queryOptions.exported,name:O({config:t.config.queryOptions,name:e.id}),selector:t.api.getSelector("queryOptionsFn",e.id)}),y=n.constVariable({comment:t.config.comments?W({operation:e}):void 0,exportConst:d.exported,expression:n.arrowFunction({parameters:[{isRequired:s,name:ko,type:a}],statements:[n.returnFunctionCall({args:[n.objectExpression({obj:l})],name:o.placeholder})]}),name:d.placeholder});t.setSymbolValue(d,y);};var tc="options",rc=({operation:e,plugin:t})=>{if(yr({operation:e})||!("useQuery"in t.config))return;let r=t.registerSymbol({exported:true,name:O({config:t.config.useQuery,name:e.id})}),s=t.referenceSymbol(t.api.getSelector("useQuery")),o=Y({context:t.context,operation:e}),i=Qe({operation:e,plugin:t}),p=t.referenceSymbol(t.api.getSelector("queryOptionsFn",e.id)),a=n.constVariable({comment:t.config.comments?W({operation:e}):void 0,exportConst:r.exported,expression:n.arrowFunction({parameters:[{isRequired:o,name:tc,type:i}],statements:[n.returnStatement({expression:n.callExpression({functionName:s.placeholder,parameters:[n.callExpression({functionName:p.placeholder,parameters:[tc]})]})})]}),name:r.placeholder});t.setSymbolValue(r,a);};var Ze=({plugin:e})=>{e.registerSymbol({external:e.name,meta:{kind:"type"},name:"DefaultError",selector:e.api.getSelector("DefaultError")}),e.registerSymbol({external:e.name,meta:{kind:"type"},name:"InfiniteData",selector:e.api.getSelector("InfiniteData")});let t=e.name==="@tanstack/angular-query-experimental"||e.name==="@tanstack/svelte-query"||e.name==="@tanstack/solid-query"?"MutationOptions":"UseMutationOptions";e.registerSymbol({external:e.name,meta:{kind:"type"},name:t,selector:e.api.getSelector("MutationOptions")}),e.registerSymbol({external:e.name,name:"infiniteQueryOptions",selector:e.api.getSelector("infiniteQueryOptions")}),e.registerSymbol({external:e.name,name:"queryOptions",selector:e.api.getSelector("queryOptions")}),e.registerSymbol({external:e.name,name:"useQuery",selector:e.api.getSelector("useQuery")}),e.registerSymbol({external:"axios",meta:{kind:"type"},name:"AxiosError",selector:e.api.getSelector("AxiosError")});let r=e.getPluginOrThrow("@hey-api/sdk");e.forEach("operation",({operation:s})=>{let o=r.config.asClass?Pe({context:e.context,operation:s,plugin:r}):void 0,i=o?o.values().next().value:void 0,p=i?[e.referenceSymbol(r.api.getSelector("class",i.path[0])).placeholder,...i.path.slice(1).map(a=>q({case:"camelCase",value:a})),i.methodName].filter(Boolean).join("."):e.referenceSymbol(r.api.getSelector("function",s.id)).placeholder;e.hooks.operation.isQuery(s)&&(e.config.queryOptions.enabled&&ec({operation:s,plugin:e,queryFn:p}),e.config.infiniteQueryOptions.enabled&&Gp({operation:s,plugin:e,queryFn:p}),"useQuery"in e.config&&e.config.useQuery.enabled&&rc({operation:s,plugin:e})),e.hooks.operation.isMutation(s)&&e.config.mutationOptions.enabled&&Yp({operation:s,plugin:e,queryFn:p});});};var Wd=e=>`${_e({config:I(),id:e.name,operation:e})}InfiniteOptions`,zd=e=>`${_e({config:I(),id:e.name,operation:e})}Mutation`,_d=({config:e,id:t,operation:r})=>`${_e({config:e,id:t,operation:r})}Options`,ys=({config:e,id:t,isInfinite:r,operation:s})=>`${_e({config:e,id:t,operation:s})}${r?"Infinite":""}QueryKey`,Hd=e=>{switch(e.in){case "formData":return "body";case "header":return "headers";default:return e.in}},Qd="createInfiniteParams",lc="createQueryKey",nc="infiniteQueryOptions",sc="mutationOptions",No="QueryKey",oc="queryOptions",Zr="TOptions",Zd=({file:e})=>{let t=n.constVariable({expression:n.arrowFunction({multiLine:true,parameters:[{name:"queryKey",type:n.typeNode("QueryKey<OptionsLegacyParser>")},{name:"page",type:n.typeNode("K")}],statements:[n.constVariable({expression:n.identifier({text:"queryKey[0]"}),name:"params"}),n.ifStatement({expression:n.propertyAccessExpression({expression:n.identifier({text:"page"}),name:n.identifier({text:"body"})}),thenStatement:n.block({statements:[n.expressionToStatement({expression:n.binaryExpression({left:n.propertyAccessExpression({expression:"params",name:"body"}),right:n.objectExpression({multiLine:true,obj:[{assertion:"any",spread:"queryKey[0].body"},{assertion:"any",spread:"page.body"}]})})})]})}),n.ifStatement({expression:n.propertyAccessExpression({expression:n.identifier({text:"page"}),name:n.identifier({text:"headers"})}),thenStatement:n.block({statements:[n.expressionToStatement({expression:n.binaryExpression({left:n.propertyAccessExpression({expression:"params",name:"headers"}),right:n.objectExpression({multiLine:true,obj:[{spread:"queryKey[0].headers"},{spread:"page.headers"}]})})})]})}),n.ifStatement({expression:n.propertyAccessExpression({expression:n.identifier({text:"page"}),name:n.identifier({text:"path"})}),thenStatement:n.block({statements:[n.expressionToStatement({expression:n.binaryExpression({left:n.propertyAccessExpression({expression:"params",name:"path"}),right:n.objectExpression({multiLine:true,obj:[{spread:"queryKey[0].path"},{spread:"page.path"}]})})})]})}),n.ifStatement({expression:n.propertyAccessExpression({expression:n.identifier({text:"page"}),name:n.identifier({text:"query"})}),thenStatement:n.block({statements:[n.expressionToStatement({expression:n.binaryExpression({left:n.propertyAccessExpression({expression:"params",name:"query"}),right:n.objectExpression({multiLine:true,obj:[{spread:"queryKey[0].query"},{spread:"page.query"}]})})})]})}),n.returnVariable({expression:b__default.default.factory.createAsExpression(b__default.default.factory.createAsExpression(n.identifier({text:"params"}),b__default.default.factory.createKeywordTypeNode(b__default.default.SyntaxKind.UnknownKeyword)),b__default.default.factory.createTypeQueryNode(n.identifier({text:"page"})))})],types:[{extends:n.typeReferenceNode({typeName:n.identifier({text:"Pick<QueryKey<OptionsLegacyParser>[0], 'body' | 'headers' | 'path' | 'query'>"})}),name:"K"}]}),name:Qd});e.add(t);},ic=({file:e})=>{let t=n.indexedAccessTypeNode({indexType:n.typeNode(0),objectType:n.typeNode(No,[n.typeNode(Zr)])}),r=n.identifier({text:"infinite"}),s=ie(I()),o=n.constVariable({expression:n.arrowFunction({multiLine:true,parameters:[{name:"id",type:n.typeNode("string")},{isRequired:false,name:"options",type:n.typeNode(Zr)},{isRequired:false,name:"infinite",type:n.typeNode("boolean")}],returnType:t,statements:[n.constVariable({assertion:t,expression:n.objectExpression({multiLine:false,obj:[{key:"_id",value:n.identifier({text:"id"})},{key:s,value:n.identifier({text:`options?.${s} || (options?.client ?? _heyApiClient).getConfig().${s}`})}]}),name:"params",typeName:t}),n.ifStatement({expression:r,thenStatement:n.block({statements:[n.expressionToStatement({expression:n.binaryExpression({left:n.propertyAccessExpression({expression:"params",name:"_infinite"}),right:r})})]})}),n.ifStatement({expression:n.propertyAccessExpression({expression:n.identifier({text:"options"}),isOptional:true,name:n.identifier({text:"body"})}),thenStatement:n.block({statements:[n.expressionToStatement({expression:n.binaryExpression({left:n.propertyAccessExpression({expression:"params",name:"body"}),right:n.propertyAccessExpression({expression:"options",name:"body"})})})]})}),n.ifStatement({expression:n.propertyAccessExpression({expression:n.identifier({text:"options"}),isOptional:true,name:n.identifier({text:"headers"})}),thenStatement:n.block({statements:[n.expressionToStatement({expression:n.binaryExpression({left:n.propertyAccessExpression({expression:"params",name:"headers"}),right:n.propertyAccessExpression({expression:"options",name:"headers"})})})]})}),n.ifStatement({expression:n.propertyAccessExpression({expression:n.identifier({text:"options"}),isOptional:true,name:n.identifier({text:"path"})}),thenStatement:n.block({statements:[n.expressionToStatement({expression:n.binaryExpression({left:n.propertyAccessExpression({expression:"params",name:"path"}),right:n.propertyAccessExpression({expression:"options",name:"path"})})})]})}),n.ifStatement({expression:n.propertyAccessExpression({expression:n.identifier({text:"options"}),isOptional:true,name:n.identifier({text:"query"})}),thenStatement:n.block({statements:[n.expressionToStatement({expression:n.binaryExpression({left:n.propertyAccessExpression({expression:"params",name:"query"}),right:n.propertyAccessExpression({expression:"options",name:"query"})})})]})}),n.returnVariable({expression:"params"})],types:[{extends:n.typeReferenceNode({typeName:n.identifier({text:"OptionsLegacyParser"})}),name:Zr}]}),name:lc});e.add(o);},ac=({file:e})=>{let t=[{name:"_id",type:n.keywordTypeNode({keyword:"string"})},{isRequired:false,name:"_infinite",type:n.keywordTypeNode({keyword:"boolean"})}],r=n.typeAliasDeclaration({name:No,type:n.typeTupleNode({types:[n.typeIntersectionNode({types:[n.typeReferenceNode({typeName:`Pick<${Zr}, '${ie(I())}' | 'body' | 'headers' | 'path' | 'query'>`}),n.typeInterfaceNode({properties:t,useLegacyResolution:true})]})]}),typeParameters:[{extends:n.typeReferenceNode({typeName:n.identifier({text:"OptionsLegacyParser"})}),name:Zr}]});e.add(r);},jo=({client:e,file:t,operation:r,typesModulePath:s})=>{let{name:o}=zt({client:e,meta:r.parameters.length?{$ref:r.name,name:r.name}:void 0,nameTransformer:_t,onImport:p=>{t.import({asType:true,module:s,name:p});}});return {typeData:Ao({importedType:o})}},pc=({client:e,file:t,operation:r,pluginName:s,typesModulePath:o})=>{let i=I(),{name:p}=zt({client:e,meta:{$ref:r.name,name:r.name},nameTransformer:xr,onImport:m=>{t.import({asType:true,module:o,name:m});}}),a={asType:true,name:p};if(a.name||(a=t.import({asType:true,module:s,name:"DefaultError"})),P(i).name==="@hey-api/client-axios"){let m=t.import({asType:true,module:"axios",name:"AxiosError"});a={...m,name:`${m.name}<${a.name}>`};}return {typeError:a}},cc=({client:e,file:t,operation:r,typesModulePath:s})=>{let{name:o}=zt({client:e,meta:{$ref:r.name,name:r.name},nameTransformer:He,onImport:p=>{t.import({asType:true,module:s,name:p});}});return {typeResponse:o||"void"}},mc=({id:e,isInfinite:t})=>n.arrayLiteralExpression({elements:[n.callExpression({functionName:lc,parameters:[n.ots.string(e),"options",t?n.ots.boolean(true):void 0]})],multiLine:false}),Ue=({client:e,files:t,plugin:r})=>{let s=I();if(U(s))throw new Error("TanStack Query plugin does not support legacy clients");let o=t[r.name];o.import({asType:true,module:Wt({config:s,sourceOutput:r.output}),name:"OptionsLegacyParser"});let i=Zt({moduleOutput:t.types.nameWithoutExtension(),sourceOutput:r.output}),p=r.name==="@tanstack/angular-query-experimental"||r.name==="@tanstack/svelte-query"||r.name==="@tanstack/solid-query"?"MutationOptions":"UseMutationOptions",a,c=false,m=false,l=false,f=false,d=false,y=new Map;for(let h of e.services)for(let g of h.operations){let x=D(g);if(y.has(x))continue;y.set(x,true);let S=[s.plugins["@hey-api/sdk"]?.config.asClass&&dr({config:s,name:h.name}),_e({config:s,handleIllegal:!s.plugins["@hey-api/sdk"]?.config.asClass,id:g.name,operation:g})].filter(Boolean).join("."),k=false;if(r.config.queryOptions.enabled&&["GET","POST"].includes(g.method)){d||(d=true,m||(ac({file:o}),ic({file:o}),m=true),o.import({module:r.name,name:oc})),k=true;let{typeData:E}=jo({client:e,file:o,operation:g,typesModulePath:i}),C=Ke(g.parameters),j=n.constVariable({exportConst:true,expression:n.arrowFunction({parameters:[{isRequired:C,name:"options",type:E}],statements:mc({id:g.name})}),name:ys({config:s,id:g.name,operation:g})});o.add(j);let F=n.constVariable({comment:[],exportConst:true,expression:n.arrowFunction({parameters:[{isRequired:C,name:"options",type:E}],statements:[n.returnFunctionCall({args:[n.objectExpression({obj:[{key:"queryFn",value:n.arrowFunction({async:true,multiLine:true,parameters:[{destructure:[{name:"queryKey"},{name:"signal"}]}],statements:[n.constVariable({destructure:true,expression:n.awaitExpression({expression:n.callExpression({functionName:S,parameters:[n.objectExpression({multiLine:true,obj:[{spread:"options"},{spread:"queryKey[0]"},{key:"signal",shorthand:true,value:n.identifier({text:"signal"})},{key:"throwOnError",value:true}]})]})}),name:"data"}),n.returnVariable({expression:"data"})]})},{key:"queryKey",value:n.callExpression({functionName:ys({config:s,id:g.name,operation:g}),parameters:["options"]})}]})],name:oc})]}),name:_d({config:s,id:g.name,operation:g})});o.add(F);}if(r.config.infiniteQueryOptions&&["GET","POST"].includes(g.method)){let E,C=g.parameters.find(j=>{if(de(s.parser.pagination).test(j.name))return E=j,true;if(j.in==="body"){if(j.export==="reference"){let M=j.$refs[0];return e.models.find($=>$.meta?.$ref===M)?.properties.find($=>{if(de(s.parser.pagination).test($.name))return E=$,true})}return j.properties.find(M=>{if(de(s.parser.pagination).test(M.name))return E=M,true})}});if(C&&E){l||(l=true,m||(ac({file:o}),ic({file:o}),m=true),c||(Zd({file:o}),c=true),o.import({module:r.name,name:nc}),a=o.import({asType:true,module:r.name,name:"InfiniteData"})),k=true;let{typeData:j}=jo({client:e,file:o,operation:g,typesModulePath:i}),{typeError:F}=pc({client:e,file:o,operation:g,pluginName:r.name,typesModulePath:i}),{typeResponse:M}=cc({client:e,file:o,operation:g,typesModulePath:i}),v=Ke(g.parameters),$=`${No}<${j}>`,ft=`Pick<${$}[0], 'body' | 'headers' | 'path' | 'query'>`,ke=`${E.base} | ${ft}`,Qt=n.constVariable({exportConst:true,expression:n.arrowFunction({parameters:[{isRequired:v,name:"options",type:j}],returnType:$,statements:mc({id:g.name,isInfinite:true})}),name:ys({config:s,id:g.name,isInfinite:true,operation:g})});o.add(Qt);let kc=n.constVariable({comment:[],exportConst:true,expression:n.arrowFunction({parameters:[{isRequired:v,name:"options",type:j}],statements:[n.returnFunctionCall({args:[n.objectExpression({comments:[{jsdoc:false,lines:["@ts-ignore"]}],obj:[{key:"queryFn",value:n.arrowFunction({async:true,multiLine:true,parameters:[{destructure:[{name:"pageParam"},{name:"queryKey"},{name:"signal"}]}],statements:[n.constVariable({comment:[{jsdoc:false,lines:["@ts-ignore"]}],expression:n.conditionalExpression({condition:n.binaryExpression({left:n.typeOfExpression({text:"pageParam"}),operator:"===",right:n.ots.string("object")}),whenFalse:n.objectExpression({multiLine:true,obj:[{key:Hd(C),value:n.objectExpression({multiLine:true,obj:[{key:E.name,value:n.identifier({text:"pageParam"})}]})}]}),whenTrue:n.identifier({text:"pageParam"})}),name:"page",typeName:ft}),n.constVariable({expression:n.callExpression({functionName:"createInfiniteParams",parameters:["queryKey","page"]}),name:"params"}),n.constVariable({destructure:true,expression:n.awaitExpression({expression:n.callExpression({functionName:S,parameters:[n.objectExpression({multiLine:true,obj:[{spread:"options"},{spread:"params"},{key:"signal",shorthand:true,value:n.identifier({text:"signal"})},{key:"throwOnError",value:true}]})]})}),name:"data"}),n.returnVariable({expression:"data"})]})},{key:"queryKey",value:n.callExpression({functionName:ys({config:s,id:g.name,isInfinite:true,operation:g}),parameters:["options"]})}]})],name:nc,types:[M,F.name,`${typeof a=="string"?a:a.name}<${M}>`,$,ke]})]}),name:Wd(g)});o.add(kc);}}if(r.config.mutationOptions&&["DELETE","PATCH","POST","PUT"].includes(g.method)){f||(f=true,o.import({asType:true,module:r.name,name:p})),k=true;let{typeData:E}=jo({client:e,file:o,operation:g,typesModulePath:i}),{typeError:C}=pc({client:e,file:o,operation:g,pluginName:r.name,typesModulePath:i}),{typeResponse:j}=cc({client:e,file:o,operation:g,typesModulePath:i}),F="fnOptions",M=n.arrowFunction({parameters:[{isRequired:false,name:"options",type:`Partial<${E}>`}],statements:[n.constVariable({expression:n.objectExpression({obj:[{key:"mutationFn",value:n.arrowFunction({async:true,multiLine:true,parameters:[{name:F}],statements:[n.constVariable({destructure:true,expression:n.awaitExpression({expression:n.callExpression({functionName:S,parameters:[n.objectExpression({multiLine:true,obj:[{spread:"options"},{spread:F},{key:"throwOnError",value:true}]})]})}),name:"data"}),n.returnVariable({expression:"data"})]})}]}),name:sc,typeName:`${p}<${j}, ${C.name}, ${E}>`}),n.returnVariable({expression:sc})]}),v=n.constVariable({comment:[],exportConst:true,expression:M,name:zd(g)});o.add(v);}(d||l)&&o.import({alias:"_heyApiClient",module:Zt({moduleOutput:t.client.nameWithoutExtension(),sourceOutput:r.output}),name:"client"}),k&&o.import({module:Zt({moduleOutput:t.sdk.nameWithoutExtension(),sourceOutput:r.output}),name:S.split(".")[0]});}};var hs=class{constructor(t){this.meta=t;}getSelector(...t){return [this.meta.name,...t]}};var gs={api:new hs({name:"@tanstack/angular-query-experimental"}),config:{case:"camelCase",comments:true,exportFromIndex:false},dependencies:["@hey-api/sdk","@hey-api/typescript"],handler:Ze,handlerLegacy:Ue,name:"@tanstack/angular-query-experimental",output:"@tanstack/angular-query-experimental",resolveConfig:(e,t)=>{e.config.infiniteQueryKeys=t.valueToObject({defaultValue:{case:e.config.case??"camelCase",enabled:true,name:"{{name}}InfiniteQueryKey",tags:false},mappers:{boolean:r=>({enabled:r}),function:r=>({name:r}),string:r=>({name:r})},value:e.config.infiniteQueryKeys}),e.config.infiniteQueryOptions=t.valueToObject({defaultValue:{case:e.config.case??"camelCase",enabled:true,name:"{{name}}InfiniteOptions"},mappers:{boolean:r=>({enabled:r}),function:r=>({name:r}),string:r=>({name:r})},value:e.config.infiniteQueryOptions}),e.config.mutationOptions=t.valueToObject({defaultValue:{case:e.config.case??"camelCase",enabled:true,name:"{{name}}Mutation"},mappers:{boolean:r=>({enabled:r}),function:r=>({name:r}),string:r=>({name:r})},value:e.config.mutationOptions}),e.config.queryKeys=t.valueToObject({defaultValue:{case:e.config.case??"camelCase",enabled:true,name:"{{name}}QueryKey",tags:false},mappers:{boolean:r=>({enabled:r}),function:r=>({name:r}),string:r=>({name:r})},value:e.config.queryKeys}),e.config.queryOptions=t.valueToObject({defaultValue:{case:e.config.case??"camelCase",enabled:true,exported:true,name:"{{name}}Options"},mappers:{boolean:r=>({enabled:r}),function:r=>({name:r}),string:r=>({name:r})},value:e.config.queryOptions});}};var xs=class{constructor(t){this.meta=t;}getSelector(...t){return [this.meta.name,...t]}};var bs={api:new xs({name:"@tanstack/react-query"}),config:{case:"camelCase",comments:true,exportFromIndex:false},dependencies:["@hey-api/sdk","@hey-api/typescript"],handler:Ze,handlerLegacy:Ue,name:"@tanstack/react-query",output:"@tanstack/react-query",resolveConfig:(e,t)=>{e.config.infiniteQueryKeys=t.valueToObject({defaultValue:{case:e.config.case??"camelCase",enabled:true,name:"{{name}}InfiniteQueryKey",tags:false},mappers:{boolean:r=>({enabled:r}),function:r=>({name:r}),string:r=>({name:r})},value:e.config.infiniteQueryKeys}),e.config.infiniteQueryOptions=t.valueToObject({defaultValue:{case:e.config.case??"camelCase",enabled:true,name:"{{name}}InfiniteOptions"},mappers:{boolean:r=>({enabled:r}),function:r=>({name:r}),string:r=>({name:r})},value:e.config.infiniteQueryOptions}),e.config.mutationOptions=t.valueToObject({defaultValue:{case:e.config.case??"camelCase",enabled:true,name:"{{name}}Mutation"},mappers:{boolean:r=>({enabled:r}),function:r=>({name:r}),string:r=>({name:r})},value:e.config.mutationOptions}),e.config.queryKeys=t.valueToObject({defaultValue:{case:e.config.case??"camelCase",enabled:true,name:"{{name}}QueryKey",tags:false},mappers:{boolean:r=>({enabled:r}),function:r=>({name:r}),string:r=>({name:r})},value:e.config.queryKeys}),e.config.queryOptions=t.valueToObject({defaultValue:{case:e.config.case??"camelCase",enabled:true,exported:true,name:"{{name}}Options"},mappers:{boolean:r=>({enabled:r}),function:r=>({name:r}),string:r=>({name:r})},value:e.config.queryOptions}),e.config.useQuery=t.valueToObject({defaultValue:{case:e.config.case??"camelCase",enabled:false,name:"use{{name}}Query"},mappers:{boolean:r=>({enabled:r}),function:r=>({enabled:true,name:r}),object:r=>({enabled:true,...r}),string:r=>({enabled:true,name:r})},value:e.config.useQuery}),e.config.useQuery.enabled&&(e.config.queryOptions.enabled||(e.config.queryOptions.enabled=true,e.config.queryOptions.exported=false));}};var Ss=class{constructor(t){this.meta=t;}getSelector(...t){return [this.meta.name,...t]}};var Os={api:new Ss({name:"@tanstack/solid-query"}),config:{case:"camelCase",comments:true,exportFromIndex:false},dependencies:["@hey-api/sdk","@hey-api/typescript"],handler:Ze,handlerLegacy:Ue,name:"@tanstack/solid-query",output:"@tanstack/solid-query",resolveConfig:(e,t)=>{e.config.infiniteQueryKeys=t.valueToObject({defaultValue:{case:e.config.case??"camelCase",enabled:true,name:"{{name}}InfiniteQueryKey",tags:false},mappers:{boolean:r=>({enabled:r}),function:r=>({name:r}),string:r=>({name:r})},value:e.config.infiniteQueryKeys}),e.config.infiniteQueryOptions=t.valueToObject({defaultValue:{case:e.config.case??"camelCase",enabled:true,name:"{{name}}InfiniteOptions"},mappers:{boolean:r=>({enabled:r}),function:r=>({name:r}),string:r=>({name:r})},value:e.config.infiniteQueryOptions}),e.config.mutationOptions=t.valueToObject({defaultValue:{case:e.config.case??"camelCase",enabled:true,name:"{{name}}Mutation"},mappers:{boolean:r=>({enabled:r}),function:r=>({name:r}),string:r=>({name:r})},value:e.config.mutationOptions}),e.config.queryKeys=t.valueToObject({defaultValue:{case:e.config.case??"camelCase",enabled:true,name:"{{name}}QueryKey",tags:false},mappers:{boolean:r=>({enabled:r}),function:r=>({name:r}),string:r=>({name:r})},value:e.config.queryKeys}),e.config.queryOptions=t.valueToObject({defaultValue:{case:e.config.case??"camelCase",enabled:true,exported:true,name:"{{name}}Options"},mappers:{boolean:r=>({enabled:r}),function:r=>({name:r}),string:r=>({name:r})},value:e.config.queryOptions});}};var Ts=class{constructor(t){this.meta=t;}getSelector(...t){return [this.meta.name,...t]}};var Rs={api:new Ts({name:"@tanstack/svelte-query"}),config:{case:"camelCase",comments:true,exportFromIndex:false},dependencies:["@hey-api/sdk","@hey-api/typescript"],handler:Ze,handlerLegacy:Ue,name:"@tanstack/svelte-query",output:"@tanstack/svelte-query",resolveConfig:(e,t)=>{e.config.infiniteQueryKeys=t.valueToObject({defaultValue:{case:e.config.case??"camelCase",enabled:true,name:"{{name}}InfiniteQueryKey",tags:false},mappers:{boolean:r=>({enabled:r}),function:r=>({name:r}),string:r=>({name:r})},value:e.config.infiniteQueryKeys}),e.config.infiniteQueryOptions=t.valueToObject({defaultValue:{case:e.config.case??"camelCase",enabled:true,name:"{{name}}InfiniteOptions"},mappers:{boolean:r=>({enabled:r}),function:r=>({name:r}),string:r=>({name:r})},value:e.config.infiniteQueryOptions}),e.config.mutationOptions=t.valueToObject({defaultValue:{case:e.config.case??"camelCase",enabled:true,name:"{{name}}Mutation"},mappers:{boolean:r=>({enabled:r}),function:r=>({name:r}),string:r=>({name:r})},value:e.config.mutationOptions}),e.config.queryKeys=t.valueToObject({defaultValue:{case:e.config.case??"camelCase",enabled:true,name:"{{name}}QueryKey",tags:false},mappers:{boolean:r=>({enabled:r}),function:r=>({name:r}),string:r=>({name:r})},value:e.config.queryKeys}),e.config.queryOptions=t.valueToObject({defaultValue:{case:e.config.case??"camelCase",enabled:true,exported:true,name:"{{name}}Options"},mappers:{boolean:r=>({enabled:r}),function:r=>({name:r}),string:r=>({name:r})},value:e.config.queryOptions});}};var As=class{constructor(t){this.meta=t;}getSelector(...t){return [this.meta.name,...t]}};var Ps={api:new As({name:"@tanstack/vue-query"}),config:{case:"camelCase",comments:true,exportFromIndex:false},dependencies:["@hey-api/sdk","@hey-api/typescript"],handler:Ze,handlerLegacy:Ue,name:"@tanstack/vue-query",output:"@tanstack/vue-query",resolveConfig:(e,t)=>{e.config.infiniteQueryKeys=t.valueToObject({defaultValue:{case:e.config.case??"camelCase",enabled:true,name:"{{name}}InfiniteQueryKey",tags:false},mappers:{boolean:r=>({enabled:r}),function:r=>({name:r}),string:r=>({name:r})},value:e.config.infiniteQueryKeys}),e.config.infiniteQueryOptions=t.valueToObject({defaultValue:{case:e.config.case??"camelCase",enabled:true,name:"{{name}}InfiniteOptions"},mappers:{boolean:r=>({enabled:r}),function:r=>({name:r}),string:r=>({name:r})},value:e.config.infiniteQueryOptions}),e.config.mutationOptions=t.valueToObject({defaultValue:{case:e.config.case??"camelCase",enabled:true,name:"{{name}}Mutation"},mappers:{boolean:r=>({enabled:r}),function:r=>({name:r}),string:r=>({name:r})},value:e.config.mutationOptions}),e.config.queryKeys=t.valueToObject({defaultValue:{case:e.config.case??"camelCase",enabled:true,name:"{{name}}QueryKey",tags:false},mappers:{boolean:r=>({enabled:r}),function:r=>({name:r}),string:r=>({name:r})},value:e.config.queryKeys}),e.config.queryOptions=t.valueToObject({defaultValue:{case:e.config.case??"camelCase",enabled:true,exported:true,name:"{{name}}Options"},mappers:{boolean:r=>({enabled:r}),function:r=>({name:r}),string:r=>({name:r})},value:e.config.queryOptions});}};var Es=class{constructor(t){this.meta=t;}getSelector(...t){return [this.meta.name,...t]}};var eu=({operation:e,plugin:t})=>{let r=[],s=t.getPluginOrThrow("@hey-api/typescript"),o=t.getSymbol(s.api.getSelector("data",e.id));o&&(e.body&&r.push({isRequired:e.body.required,name:"Body",type:`${o.placeholder}['body']`}),e.parameters&&(e.parameters.header&&r.push({isRequired:ut(e.parameters.header),name:"Headers",type:`${o.placeholder}['headers']`}),e.parameters.path&&r.push({isRequired:ut(e.parameters.path),name:"Params",type:`${o.placeholder}['path']`}),e.parameters.query&&r.push({isRequired:ut(e.parameters.query),name:"Querystring",type:`${o.placeholder}['query']`})));let{errors:i,responses:p}=we(e),a,c=t.getSymbol(s.api.getSelector("errors",e.id));if(c&&i&&i.properties){let h=Object.keys(i.properties);if(h.length){if(!h.includes("default"))a=n.typeReferenceNode({typeName:c.placeholder});else if(h.length>1){let x=n.typeReferenceNode({typeName:c.placeholder}),S=n.literalTypeNode({literal:n.stringLiteral({text:"default"})});a=n.typeReferenceNode({typeArguments:[x,S],typeName:"Omit"});}}}let m,l=t.getSymbol(s.api.getSelector("responses",e.id));if(l&&p&&p.properties){let h=Object.keys(p.properties);if(h.length){if(!h.includes("default"))m=n.typeReferenceNode({typeName:l.placeholder});else if(h.length>1){let x=n.typeReferenceNode({typeName:l.placeholder}),S=n.literalTypeNode({literal:n.stringLiteral({text:"default"})});m=n.typeReferenceNode({typeArguments:[x,S],typeName:"Omit"});}}}let f=[a,m].filter(Boolean);if(f.length&&r.push({name:"Reply",type:n.typeIntersectionNode({types:f})}),!r.length)return;let d=t.referenceSymbol(t.api.getSelector("RouteHandler"));return {name:e.id,type:n.typeReferenceNode({typeArguments:[n.typeInterfaceNode({properties:r,useLegacyResolution:false})],typeName:d.placeholder})}},fc=({plugin:e})=>{e.registerSymbol({external:"fastify",meta:{kind:"type"},name:"RouteHandler",selector:e.api.getSelector("RouteHandler")});let t=e.registerSymbol({exported:true,meta:{kind:"type"},name:"RouteHandlers"}),r=[];e.forEach("operation",({operation:o})=>{let i=eu({operation:o,plugin:e});i&&r.push(i);});let s=n.typeAliasDeclaration({exportType:t.exported,name:t.placeholder,type:n.typeInterfaceNode({properties:r,useLegacyResolution:false})});e.setSymbolValue(t,s);};var Is={api:new Es({name:"fastify"}),config:{exportFromIndex:false},dependencies:["@hey-api/typescript"],handler:fc,name:"fastify"};var T={actions:{args:n.identifier({text:"args"}),base64:n.identifier({text:"base64"}),bic:n.identifier({text:"bic"}),brand:n.identifier({text:"brand"}),bytes:n.identifier({text:"bytes"}),check:n.identifier({text:"check"}),checkItems:n.identifier({text:"checkItems"}),creditCard:n.identifier({text:"creditCard"}),cuid2:n.identifier({text:"cuid2"}),decimal:n.identifier({text:"decimal"}),description:n.identifier({text:"description"}),digits:n.identifier({text:"digits"}),email:n.identifier({text:"email"}),emoji:n.identifier({text:"emoji"}),empty:n.identifier({text:"empty"}),endsWith:n.identifier({text:"endsWith"}),entries:n.identifier({text:"entries"}),everyItem:n.identifier({text:"everyItem"}),excludes:n.identifier({text:"excludes"}),filterItems:n.identifier({text:"filterItems"}),findItem:n.identifier({text:"findItem"}),finite:n.identifier({text:"finite"}),flavor:n.identifier({text:"flavor"}),graphemes:n.identifier({text:"graphemes"}),gtValue:n.identifier({text:"gtValue"}),hash:n.identifier({text:"hash"}),hexColor:n.identifier({text:"hexColor"}),hexadecimal:n.identifier({text:"hexadecimal"}),imei:n.identifier({text:"imei"}),includes:n.identifier({text:"includes"}),integer:n.identifier({text:"integer"}),ip:n.identifier({text:"ip"}),ipv4:n.identifier({text:"ipv4"}),ipv6:n.identifier({text:"ipv6"}),isoDate:n.identifier({text:"isoDate"}),isoDateTime:n.identifier({text:"isoDateTime"}),isoTime:n.identifier({text:"isoTime"}),isoTimeSecond:n.identifier({text:"isoTimeSecond"}),isoTimestamp:n.identifier({text:"isoTimestamp"}),isoWeek:n.identifier({text:"isoWeek"}),length:n.identifier({text:"length"}),ltValue:n.identifier({text:"ltValue"}),mac:n.identifier({text:"mac"}),mac48:n.identifier({text:"mac48"}),mac64:n.identifier({text:"mac64"}),mapItems:n.identifier({text:"mapItems"}),maxBytes:n.identifier({text:"maxBytes"}),maxEntries:n.identifier({text:"maxEntries"}),maxGraphemes:n.identifier({text:"maxGraphemes"}),maxLength:n.identifier({text:"maxLength"}),maxSize:n.identifier({text:"maxSize"}),maxValue:n.identifier({text:"maxValue"}),maxWords:n.identifier({text:"maxWords"}),metadata:n.identifier({text:"metadata"}),mimeType:n.identifier({text:"mimeType"}),minBytes:n.identifier({text:"minBytes"}),minEntries:n.identifier({text:"minEntries"}),minGraphemes:n.identifier({text:"minGraphemes"}),minLength:n.identifier({text:"minLength"}),minSize:n.identifier({text:"minSize"}),minValue:n.identifier({text:"minValue"}),minWords:n.identifier({text:"minWords"}),multipleOf:n.identifier({text:"multipleOf"}),nanoid:n.identifier({text:"nanoid"}),nonEmpty:n.identifier({text:"nonEmpty"}),normalize:n.identifier({text:"normalize"}),notBytes:n.identifier({text:"notBytes"}),notEntries:n.identifier({text:"notEntries"}),notGraphemes:n.identifier({text:"notGraphemes"}),notLength:n.identifier({text:"notLength"}),notSize:n.identifier({text:"notSize"}),notValue:n.identifier({text:"notValue"}),notValues:n.identifier({text:"notValues"}),notWords:n.identifier({text:"notWords"}),octal:n.identifier({text:"octal"}),parseJson:n.identifier({text:"parseJson"}),partialCheck:n.identifier({text:"partialCheck"}),rawCheck:n.identifier({text:"rawCheck"}),rawTransform:n.identifier({text:"rawTransform"}),readonly:n.identifier({text:"readonly"}),reduceItems:n.identifier({text:"reduceItems"}),regex:n.identifier({text:"regex"}),returns:n.identifier({text:"returns"}),rfcEmail:n.identifier({text:"rfcEmail"}),safeInteger:n.identifier({text:"safeInteger"}),size:n.identifier({text:"size"}),slug:n.identifier({text:"slug"}),someItem:n.identifier({text:"someItem"}),sortItems:n.identifier({text:"sortItems"}),startsWith:n.identifier({text:"startsWith"}),stringifyJson:n.identifier({text:"stringifyJson"}),title:n.identifier({text:"title"}),toLowerCase:n.identifier({text:"toLowerCase"}),toMaxValue:n.identifier({text:"toMaxValue"}),toMinValue:n.identifier({text:"toMinValue"}),toUpperCase:n.identifier({text:"toUpperCase"}),transform:n.identifier({text:"transform"}),trim:n.identifier({text:"trim"}),trimEnd:n.identifier({text:"trimEnd"}),trimStart:n.identifier({text:"trimStart"}),ulid:n.identifier({text:"ulid"}),url:n.identifier({text:"url"}),uuid:n.identifier({text:"uuid"}),value:n.identifier({text:"value"}),values:n.identifier({text:"values"}),words:n.identifier({text:"words"})},async:{argsAsync:n.identifier({text:"argsAsync"}),arrayAsync:n.identifier({text:"arrayAsync"}),awaitAsync:n.identifier({text:"awaitAsync"}),checkAsync:n.identifier({text:"checkAsync"}),checkItemsAsync:n.identifier({text:"checkItemsAsync"}),customAsync:n.identifier({text:"customAsync"}),exactOptionalAsync:n.identifier({text:"exactOptionalAsync"}),fallbackAsync:n.identifier({text:"fallbackAsync"}),forwardAsync:n.identifier({text:"forwardAsync"}),getDefaultsAsync:n.identifier({text:"getDefaultsAsync"}),getFallbacksAsync:n.identifier({text:"getFallbacksAsync"}),intersectAsync:n.identifier({text:"intersectAsync"}),lazyAsync:n.identifier({text:"lazyAsync"}),looseObjectAsync:n.identifier({text:"looseObjectAsync"}),looseTupleAsync:n.identifier({text:"looseTupleAsync"}),mapAsync:n.identifier({text:"mapAsync"}),nonNullableAsync:n.identifier({text:"nonNullableAsync"}),nonNullishAsync:n.identifier({text:"nonNullishAsync"}),nonOptionalAsync:n.identifier({text:"nonOptionalAsync"}),nullableAsync:n.identifier({text:"nullableAsync"}),nullishAsync:n.identifier({text:"nullishAsync"}),objectAsync:n.identifier({text:"objectAsync"}),objectWithRestAsync:n.identifier({text:"objectWithRestAsync"}),optionalAsync:n.identifier({text:"optionalAsync"}),parseAsync:n.identifier({text:"parseAsync"}),parserAsync:n.identifier({text:"parserAsync"}),partialAsync:n.identifier({text:"partialAsync"}),partialCheckAsync:n.identifier({text:"partialCheckAsync"}),pipeAsync:n.identifier({text:"pipeAsync"}),rawCheckAsync:n.identifier({text:"rawCheckAsync"}),rawTransformAsync:n.identifier({text:"rawTransformAsync"}),recordAsync:n.identifier({text:"recordAsync"}),requiredAsync:n.identifier({text:"requiredAsync"}),returnsAsync:n.identifier({text:"returnsAsync"}),safeParseAsync:n.identifier({text:"safeParseAsync"}),safeParserAsync:n.identifier({text:"safeParserAsync"}),setAsync:n.identifier({text:"setAsync"}),strictObjectAsync:n.identifier({text:"strictObjectAsync"}),strictTupleAsync:n.identifier({text:"strictTupleAsync"}),transformAsync:n.identifier({text:"transformAsync"}),tupleAsync:n.identifier({text:"tupleAsync"}),tupleWithRestAsync:n.identifier({text:"tupleWithRestAsync"}),undefinedableAsync:n.identifier({text:"undefinedableAsync"}),unionAsync:n.identifier({text:"unionAsync"}),variantAsync:n.identifier({text:"variantAsync"})},methods:{assert:n.identifier({text:"assert"}),config:n.identifier({text:"config"}),fallback:n.identifier({text:"fallback"}),flatten:n.identifier({text:"flatten"}),forward:n.identifier({text:"forward"}),getDefault:n.identifier({text:"getDefault"}),getDefaults:n.identifier({text:"getDefaults"}),getDescription:n.identifier({text:"getDescription"}),getFallback:n.identifier({text:"getFallback"}),getFallbacks:n.identifier({text:"getFallbacks"}),getMetadata:n.identifier({text:"getMetadata"}),getTitle:n.identifier({text:"getTitle"}),is:n.identifier({text:"is"}),keyof:n.identifier({text:"keyof"}),message:n.identifier({text:"message"}),omit:n.identifier({text:"omit"}),parse:n.identifier({text:"parse"}),parser:n.identifier({text:"parser"}),partial:n.identifier({text:"partial"}),pick:n.identifier({text:"pick"}),pipe:n.identifier({text:"pipe"}),required:n.identifier({text:"required"}),safeParse:n.identifier({text:"safeParse"}),safeParser:n.identifier({text:"safeParser"}),summarize:n.identifier({text:"summarize"}),unwrap:n.identifier({text:"unwrap"})},schemas:{any:n.identifier({text:"any"}),array:n.identifier({text:"array"}),bigInt:n.identifier({text:"bigint"}),blob:n.identifier({text:"blob"}),boolean:n.identifier({text:"boolean"}),custom:n.identifier({text:"custom"}),date:n.identifier({text:"date"}),enum:n.identifier({text:"enum"}),exactOptional:n.identifier({text:"exactOptional"}),file:n.identifier({text:"file"}),function:n.identifier({text:"function"}),instance:n.identifier({text:"instance"}),intersect:n.identifier({text:"intersect"}),lazy:n.identifier({text:"lazy"}),literal:n.identifier({text:"literal"}),looseObject:n.identifier({text:"looseObject"}),looseTuple:n.identifier({text:"looseTuple"}),map:n.identifier({text:"map"}),nan:n.identifier({text:"nan"}),never:n.identifier({text:"never"}),nonNullable:n.identifier({text:"nonNullable"}),nonNullish:n.identifier({text:"nonNullish"}),nonOptional:n.identifier({text:"nonOptional"}),null:n.identifier({text:"null"}),nullable:n.identifier({text:"nullable"}),nullish:n.identifier({text:"nullish"}),number:n.identifier({text:"number"}),object:n.identifier({text:"object"}),objectWithRest:n.identifier({text:"objectWithRest"}),optional:n.identifier({text:"optional"}),picklist:n.identifier({text:"picklist"}),promise:n.identifier({text:"promise"}),record:n.identifier({text:"record"}),set:n.identifier({text:"set"}),strictObject:n.identifier({text:"strictObject"}),strictTuple:n.identifier({text:"strictTuple"}),string:n.identifier({text:"string"}),symbol:n.identifier({text:"symbol"}),tuple:n.identifier({text:"tuple"}),tupleWithRest:n.identifier({text:"tupleWithRest"}),undefined:n.identifier({text:"undefined"}),undefinedable:n.identifier({text:"undefinedable"}),union:n.identifier({text:"union"}),unknown:n.identifier({text:"unknown"}),variant:n.identifier({text:"variant"}),void:n.identifier({text:"void"})},types:{GenericSchema:n.identifier({text:"GenericSchema"})}};var ks=class{constructor(t){this.meta=t;}createRequestValidator({operation:t,plugin:r}){let s=r.getSymbol(r.api.getSelector("data",t.id));if(!s)return;let o=r.referenceSymbol(r.api.getSelector("import","valibot")),i="data";return n.arrowFunction({async:true,parameters:[{name:i}],statements:[n.returnStatement({expression:n.awaitExpression({expression:n.callExpression({functionName:n.propertyAccessExpression({expression:o.placeholder,name:T.async.parseAsync}),parameters:[n.identifier({text:s.placeholder}),n.identifier({text:i})]})})})]})}createResponseValidator({operation:t,plugin:r}){let s=r.getSymbol(r.api.getSelector("responses",t.id));if(!s)return;let o=r.referenceSymbol(r.api.getSelector("import","valibot")),i="data";return n.arrowFunction({async:true,parameters:[{name:i}],statements:[n.returnStatement({expression:n.awaitExpression({expression:n.callExpression({functionName:n.propertyAccessExpression({expression:o.placeholder,name:T.async.parseAsync}),parameters:[n.identifier({text:s.placeholder}),n.identifier({text:i})]})})})]})}getSelector(...t){return [this.meta.name,...t]}};var js={int16:{max:32767,maxError:"Invalid value: Expected int16 to be <= 2^15-1",min:-32768,minError:"Invalid value: Expected int16 to be >= -2^15",needsBigInt:false},int32:{max:2147483647,maxError:"Invalid value: Expected int32 to be <= 2^31-1",min:-2147483648,minError:"Invalid value: Expected int32 to be >= -2^31",needsBigInt:false},int64:{max:"9223372036854775807",maxError:"Invalid value: Expected int64 to be <= 2^63-1",min:"-9223372036854775808",minError:"Invalid value: Expected int64 to be >= -2^63",needsBigInt:true},int8:{max:127,maxError:"Invalid value: Expected int8 to be <= 2^7-1",min:-128,minError:"Invalid value: Expected int8 to be >= -2^7",needsBigInt:false},uint16:{max:65535,maxError:"Invalid value: Expected uint16 to be <= 2^16-1",min:0,minError:"Invalid value: Expected uint16 to be >= 0",needsBigInt:false},uint32:{max:4294967295,maxError:"Invalid value: Expected uint32 to be <= 2^32-1",min:0,minError:"Invalid value: Expected uint32 to be >= 0",needsBigInt:false},uint64:{max:"18446744073709551615",maxError:"Invalid value: Expected uint64 to be <= 2^64-1",min:"0",minError:"Invalid value: Expected uint64 to be >= 0",needsBigInt:true},uint8:{max:255,maxError:"Invalid value: Expected uint8 to be <= 2^8-1",min:0,minError:"Invalid value: Expected uint8 to be >= 0",needsBigInt:false}},Co=e=>e!==void 0&&e in js,dc=e=>Co(e)&&js[e].needsBigInt,Tr=({isBigInt:e,value:t})=>{let r=n.valueToExpression({value:t});return e&&(typeof t=="bigint"||typeof t=="number"||typeof t=="string"||typeof t=="boolean")?n.callExpression({functionName:"BigInt",parameters:[r]}):r};var uc=({operation:e,plugin:t,state:r})=>{if(t.config.requests.enabled){let s=new Set,o={properties:{body:{type:"never"},path:{type:"never"},query:{type:"never"}},type:"object"};if(e.parameters){if(e.parameters.header){let p={},a=[];for(let c in e.parameters.header){let m=e.parameters.header[c];p[m.name]=m.schema,m.required&&(a.push(m.name),s.add("headers"));}Object.keys(p).length&&(o.properties.headers={properties:p,required:a,type:"object"});}if(e.parameters.path){let p={},a=[];for(let c in e.parameters.path){let m=e.parameters.path[c];p[m.name]=m.schema,m.required&&(a.push(m.name),s.add("path"));}Object.keys(p).length&&(o.properties.path={properties:p,required:a,type:"object"});}if(e.parameters.query){let p={},a=[];for(let c in e.parameters.query){let m=e.parameters.query[c];p[m.name]=m.schema,m.required&&(a.push(m.name),s.add("query"));}Object.keys(p).length&&(o.properties.query={properties:p,required:a,type:"object"});}}e.body&&(o.properties.body=e.body.schema,e.body.required&&s.add("body")),o.required=[...s];let i=t.registerSymbol({exported:true,name:O({config:t.config.requests,name:e.id}),selector:t.api.getSelector("data",e.id)});oe({plugin:t,schema:o,state:r,symbol:i});}if(t.config.responses.enabled&&e.responses){let{response:s}=we(e);if(s){let o=t.registerSymbol({exported:true,name:O({config:t.config.responses,name:e.id}),selector:t.api.getSelector("responses",e.id)});oe({plugin:t,schema:s,state:r,symbol:o});}}};var yc=({operation:e,plugin:t,state:r})=>{if(t.config.webhooks.enabled){let s=new Set,o={properties:{body:{type:"never"},path:{type:"never"},query:{type:"never"}},type:"object"};if(e.parameters){if(e.parameters.header){let p={},a=[];for(let c in e.parameters.header){let m=e.parameters.header[c];p[m.name]=m.schema,m.required&&(a.push(m.name),s.add("headers"));}Object.keys(p).length&&(o.properties.headers={properties:p,required:a,type:"object"});}if(e.parameters.path){let p={},a=[];for(let c in e.parameters.path){let m=e.parameters.path[c];p[m.name]=m.schema,m.required&&(a.push(m.name),s.add("path"));}Object.keys(p).length&&(o.properties.path={properties:p,required:a,type:"object"});}if(e.parameters.query){let p={},a=[];for(let c in e.parameters.query){let m=e.parameters.query[c];p[m.name]=m.schema,m.required&&(a.push(m.name),s.add("query"));}Object.keys(p).length&&(o.properties.query={properties:p,required:a,type:"object"});}}e.body&&(o.properties.body=e.body.schema,e.body.required&&s.add("body")),o.required=[...s];let i=t.registerSymbol({exported:true,name:O({config:t.config.webhooks,name:e.id}),selector:t.api.getSelector("webhook-request",e.id)});oe({plugin:t,schema:o,state:r,symbol:i});}};var Ee=({pipes:e,plugin:t})=>{if(e.length===1)return e[0];let r=t.referenceSymbol(t.api.getSelector("import","valibot"));return n.callExpression({functionName:n.propertyAccessExpression({expression:r.placeholder,name:T.methods.pipe}),parameters:e})},ru=({plugin:e,schema:t,state:r})=>{let s=e.referenceSymbol(e.api.getSelector("import","valibot")),o=n.propertyAccessExpression({expression:s.placeholder,name:T.schemas.array}),i=[];if(t.items){t=z({schema:t});let p=t.items.map(a=>{let c=oe({plugin:e,schema:a,state:r});return Ee({pipes:c,plugin:e})});if(p.length===1){let a=n.callExpression({functionName:o,parameters:p});i.push(a);}else {t.logicalOperator;let a=n.callExpression({functionName:o,parameters:[Ur({plugin:e})]});i.push(a);}}else {let p=n.callExpression({functionName:o,parameters:[Ur({plugin:e})]});i.push(p);}if(t.minItems===t.maxItems&&t.minItems!==void 0){let p=n.callExpression({functionName:n.propertyAccessExpression({expression:s.placeholder,name:T.actions.length}),parameters:[n.valueToExpression({value:t.minItems})]});i.push(p);}else {if(t.minItems!==void 0){let p=n.callExpression({functionName:n.propertyAccessExpression({expression:s.placeholder,name:T.actions.minLength}),parameters:[n.valueToExpression({value:t.minItems})]});i.push(p);}if(t.maxItems!==void 0){let p=n.callExpression({functionName:n.propertyAccessExpression({expression:s.placeholder,name:T.actions.maxLength}),parameters:[n.valueToExpression({value:t.maxItems})]});i.push(p);}}return Ee({pipes:i,plugin:e})},nu=({plugin:e,schema:t})=>{let r=e.referenceSymbol(e.api.getSelector("import","valibot"));return typeof t.const=="boolean"?n.callExpression({functionName:n.propertyAccessExpression({expression:r.placeholder,name:T.schemas.literal}),parameters:[n.ots.boolean(t.const)]}):n.callExpression({functionName:n.propertyAccessExpression({expression:r.placeholder,name:T.schemas.boolean})})},su=({plugin:e,schema:t})=>{let r=[],s=false;for(let p of t.items??[])p.type==="string"&&typeof p.const=="string"?r.push(n.stringLiteral({text:p.const})):(p.type==="null"||p.const===null)&&(s=true);if(!r.length)return Ur({plugin:e});let o=e.referenceSymbol(e.api.getSelector("import","valibot")),i=n.callExpression({functionName:n.propertyAccessExpression({expression:o.placeholder,name:T.schemas.picklist}),parameters:[n.arrayLiteralExpression({elements:r,multiLine:false})]});return s&&(i=n.callExpression({functionName:n.propertyAccessExpression({expression:o.placeholder,name:T.schemas.nullable}),parameters:[i]})),i},ou=({plugin:e})=>{let t=e.referenceSymbol(e.api.getSelector("import","valibot"));return n.callExpression({functionName:n.propertyAccessExpression({expression:t.placeholder,name:T.schemas.never})})},iu=({plugin:e})=>{let t=e.referenceSymbol(e.api.getSelector("import","valibot"));return n.callExpression({functionName:n.propertyAccessExpression({expression:t.placeholder,name:T.schemas.null})})},hc=({plugin:e,schema:t})=>{let r=t.format,s=t.type==="integer",o=dc(r),i=Co(r)?js[r]:null,p=e.referenceSymbol(e.api.getSelector("import","valibot"));if(t.const!==void 0&&t.const!==null){let c=t.const,m;if(typeof c=="number"&&!r)m=n.ots.number(c);else if(typeof c=="number"&&r)o?m=n.callExpression({functionName:"BigInt",parameters:[n.ots.string(c.toString())]}):m=n.ots.number(c);else if(typeof c=="string"&&o){let l=c.endsWith("n")?c.slice(0,-1):c;m=n.callExpression({functionName:"BigInt",parameters:[n.ots.string(l)]});}else if(typeof c=="bigint"){let l=c.toString(),f=l.endsWith("n")?l.slice(0,-1):l;m=n.callExpression({functionName:"BigInt",parameters:[n.ots.string(f)]});}else m=n.valueToExpression({value:c});return n.callExpression({functionName:n.propertyAccessExpression({expression:p.placeholder,name:T.schemas.literal}),parameters:[m]})}let a=[];if(o){let c=n.callExpression({functionName:n.propertyAccessExpression({expression:p.placeholder,name:T.schemas.union}),parameters:[n.arrayLiteralExpression({elements:[n.callExpression({functionName:n.propertyAccessExpression({expression:p.placeholder,name:T.schemas.number})}),n.callExpression({functionName:n.propertyAccessExpression({expression:p.placeholder,name:T.schemas.string})}),n.callExpression({functionName:n.propertyAccessExpression({expression:p.placeholder,name:T.schemas.bigInt})})],multiLine:false})]});a.push(c);let m=n.callExpression({functionName:n.propertyAccessExpression({expression:p.placeholder,name:T.actions.transform}),parameters:[n.arrowFunction({parameters:[{name:"x"}],statements:n.callExpression({functionName:"BigInt",parameters:[n.identifier({text:"x"})]})})]});a.push(m);}else {let c=n.callExpression({functionName:n.propertyAccessExpression({expression:p.placeholder,name:T.schemas.number})});a.push(c);}if(!o&&s){let c=n.callExpression({functionName:n.propertyAccessExpression({expression:p.placeholder,name:T.actions.integer})});a.push(c);}if(i){let c=i.min,m=i.max,l=i.minError,f=i.maxError,d=n.callExpression({functionName:n.propertyAccessExpression({expression:p.placeholder,name:T.actions.minValue}),parameters:[o?n.callExpression({functionName:"BigInt",parameters:[n.ots.string(c.toString())]}):n.ots.number(c),n.ots.string(l)]});a.push(d);let y=n.callExpression({functionName:n.propertyAccessExpression({expression:p.placeholder,name:T.actions.maxValue}),parameters:[o?n.callExpression({functionName:"BigInt",parameters:[n.ots.string(m.toString())]}):n.ots.number(m),n.ots.string(f)]});a.push(y);}if(t.exclusiveMinimum!==void 0){let c=n.callExpression({functionName:n.propertyAccessExpression({expression:p.placeholder,name:T.actions.gtValue}),parameters:[Tr({isBigInt:o,value:t.exclusiveMinimum})]});a.push(c);}else if(t.minimum!==void 0){let c=n.callExpression({functionName:n.propertyAccessExpression({expression:p.placeholder,name:T.actions.minValue}),parameters:[Tr({isBigInt:o,value:t.minimum})]});a.push(c);}if(t.exclusiveMaximum!==void 0){let c=n.callExpression({functionName:n.propertyAccessExpression({expression:p.placeholder,name:T.actions.ltValue}),parameters:[Tr({isBigInt:o,value:t.exclusiveMaximum})]});a.push(c);}else if(t.maximum!==void 0){let c=n.callExpression({functionName:n.propertyAccessExpression({expression:p.placeholder,name:T.actions.maxValue}),parameters:[Tr({isBigInt:o,value:t.maximum})]});a.push(c);}return Ee({pipes:a,plugin:e})},au=({plugin:e,schema:t,state:r})=>{let s=[],o=t.required??[];for(let a in t.properties){let c=t.properties[a],m=o.includes(a),l=oe({optional:!m,plugin:e,schema:c,state:r});X.lastIndex=0;let f;X.test(a)?f=a.startsWith("-")?b__default.default.factory.createStringLiteral(a):b__default.default.factory.createNumericLiteral(a):f=a,(a.match(/^[0-9]/)&&a.match(/\D+/g)||a.match(/\W/g))&&!a.startsWith("'")&&!a.endsWith("'")&&(f=`'${a}'`),s.push(n.propertyAssignment({initializer:Ee({pipes:l,plugin:e}),name:f}));}let i=e.referenceSymbol(e.api.getSelector("import","valibot"));if(t.additionalProperties&&t.additionalProperties.type==="object"&&!Object.keys(s).length){let a=oe({plugin:e,schema:t.additionalProperties,state:r});return {anyType:"AnyZodObject",expression:n.callExpression({functionName:n.propertyAccessExpression({expression:i.placeholder,name:T.schemas.record}),parameters:[n.callExpression({functionName:n.propertyAccessExpression({expression:i.placeholder,name:T.schemas.string}),parameters:[]}),Ee({pipes:a,plugin:e})]})}}let p=n.callExpression({functionName:n.propertyAccessExpression({expression:i.placeholder,name:T.schemas.object}),parameters:[b__default.default.factory.createObjectLiteralExpression(s,true)]});return {anyType:T.types.GenericSchema.text,expression:p}},pu=({plugin:e,schema:t})=>{let r=e.referenceSymbol(e.api.getSelector("import","valibot"));if(typeof t.const=="string")return n.callExpression({functionName:n.propertyAccessExpression({expression:r.placeholder,name:T.schemas.literal}),parameters:[n.ots.string(t.const)]});let s=[],o=n.callExpression({functionName:n.propertyAccessExpression({expression:r.placeholder,name:T.schemas.string})});if(s.push(o),t.format)switch(t.format){case "date":s.push(n.callExpression({functionName:n.propertyAccessExpression({expression:r.placeholder,name:T.actions.isoDate})}));break;case "date-time":s.push(n.callExpression({functionName:n.propertyAccessExpression({expression:r.placeholder,name:T.actions.isoTimestamp})}));break;case "ipv4":case "ipv6":s.push(n.callExpression({functionName:n.propertyAccessExpression({expression:r.placeholder,name:T.actions.ip})}));break;case "uri":s.push(n.callExpression({functionName:n.propertyAccessExpression({expression:r.placeholder,name:T.actions.url})}));break;case "email":case "time":case "uuid":s.push(n.callExpression({functionName:n.propertyAccessExpression({expression:r.placeholder,name:n.identifier({text:t.format})})}));break}if(t.minLength===t.maxLength&&t.minLength!==void 0){let i=n.callExpression({functionName:n.propertyAccessExpression({expression:r.placeholder,name:T.actions.length}),parameters:[n.valueToExpression({value:t.minLength})]});s.push(i);}else {if(t.minLength!==void 0){let i=n.callExpression({functionName:n.propertyAccessExpression({expression:r.placeholder,name:T.actions.minLength}),parameters:[n.valueToExpression({value:t.minLength})]});s.push(i);}if(t.maxLength!==void 0){let i=n.callExpression({functionName:n.propertyAccessExpression({expression:r.placeholder,name:T.actions.maxLength}),parameters:[n.valueToExpression({value:t.maxLength})]});s.push(i);}}if(t.pattern){let i=n.callExpression({functionName:n.propertyAccessExpression({expression:r.placeholder,name:T.actions.regex}),parameters:[n.regularExpressionLiteral({text:t.pattern})]});s.push(i);}return Ee({pipes:s,plugin:e})},cu=({plugin:e,schema:t,state:r})=>{let s=e.referenceSymbol(e.api.getSelector("import","valibot"));if(t.const&&Array.isArray(t.const)){let o=t.const.map(p=>n.callExpression({functionName:n.propertyAccessExpression({expression:s.placeholder,name:T.schemas.literal}),parameters:[n.valueToExpression({value:p})]}));return n.callExpression({functionName:n.propertyAccessExpression({expression:s.placeholder,name:T.schemas.tuple}),parameters:[n.arrayLiteralExpression({elements:o})]})}if(t.items){let o=t.items.map(p=>{let a=oe({plugin:e,schema:p,state:r});return Ee({pipes:a,plugin:e})});return n.callExpression({functionName:n.propertyAccessExpression({expression:s.placeholder,name:T.schemas.tuple}),parameters:[n.arrayLiteralExpression({elements:o})]})}return Ur({plugin:e})},mu=({plugin:e})=>{let t=e.referenceSymbol(e.api.getSelector("import","valibot"));return n.callExpression({functionName:n.propertyAccessExpression({expression:t.placeholder,name:T.schemas.undefined})})},Ur=({plugin:e})=>{let t=e.referenceSymbol(e.api.getSelector("import","valibot"));return n.callExpression({functionName:n.propertyAccessExpression({expression:t.placeholder,name:T.schemas.unknown})})},lu=({plugin:e})=>{let t=e.referenceSymbol(e.api.getSelector("import","valibot"));return n.callExpression({functionName:n.propertyAccessExpression({expression:t.placeholder,name:T.schemas.void})})},gc=({plugin:e,schema:t,state:r})=>{switch(t.type){case "array":return {expression:ru({plugin:e,schema:t,state:r})};case "boolean":return {expression:nu({plugin:e,schema:t})};case "enum":return {expression:su({plugin:e,schema:t})};case "integer":case "number":return {expression:hc({plugin:e,schema:t})};case "never":return {expression:ou({plugin:e})};case "null":return {expression:iu({plugin:e})};case "object":return au({plugin:e,schema:t,state:r});case "string":return t.format==="int64"||t.format==="uint64"?{expression:hc({plugin:e,schema:t})}:{expression:pu({plugin:e,schema:t})};case "tuple":return {expression:cu({plugin:e,schema:t,state:r})};case "undefined":return {expression:mu({plugin:e})};case "unknown":return {expression:Ur({plugin:e})};case "void":return {expression:lu({plugin:e})}}},oe=({$ref:e,optional:t,plugin:r,schema:s,state:o,symbol:i})=>{let p,a=[];if(e&&(o.circularReferenceTracker.add(e),!i)){let m=r.api.getSelector("ref",e);r.getSymbol(m)||(i=r.referenceSymbol(m));}let c=r.referenceSymbol(r.api.getSelector("import","valibot"));if(s.$ref){let m=o.circularReferenceTracker.has(s.$ref),l=r.api.getSelector("ref",s.$ref),f=r.getSymbol(l);if(!f){let d=r.context.resolveIrRef(s.$ref),y=oe({$ref:s.$ref,plugin:r,schema:d,state:o});a.push(...y),f=r.getSymbol(l);}if(f){let d=n.identifier({text:f.placeholder});if(m){let y=n.callExpression({functionName:n.propertyAccessExpression({expression:c.placeholder,name:T.schemas.lazy}),parameters:[n.arrowFunction({statements:[n.returnStatement({expression:d})]})]});a.push(y),o.hasCircularReference=true;}else a.push(d);}}else if(s.type){let m=gc({plugin:r,schema:s,state:o});if(p=m.anyType,a.push(m.expression),r.config.metadata&&s.description){let l=n.callExpression({functionName:n.propertyAccessExpression({expression:c.placeholder,name:T.actions.metadata}),parameters:[n.objectExpression({obj:[{key:"description",value:n.stringLiteral({text:s.description})}]})]});a.push(l);}}else if(s.items)if(s=z({schema:s}),s.items){let m=s.items.map(l=>{let f=oe({plugin:r,schema:l,state:o});return Ee({pipes:f,plugin:r})});if(s.logicalOperator==="and"){let l=n.callExpression({functionName:n.propertyAccessExpression({expression:c.placeholder,name:T.schemas.intersect}),parameters:[n.arrayLiteralExpression({elements:m})]});a.push(l);}else {let l=n.callExpression({functionName:n.propertyAccessExpression({expression:c.placeholder,name:T.schemas.union}),parameters:[n.arrayLiteralExpression({elements:m})]});a.push(l);}}else {let m=oe({plugin:r,schema:s,state:o});a.push(...m);}else {let m=gc({plugin:r,schema:{type:"unknown"},state:o});p=m.anyType,a.push(m.expression);}if(e&&o.circularReferenceTracker.delete(e),a.length&&s.accessScope==="read"){let m=n.callExpression({functionName:n.propertyAccessExpression({expression:c.placeholder,name:T.actions.readonly})});a.push(m);}if(a.length){let m;if(s.default!==void 0){let l=s.type==="integer"&&s.format==="int64";m=Tr({isBigInt:l,value:s.default}),m&&(a=[n.callExpression({functionName:n.propertyAccessExpression({expression:c.placeholder,name:T.schemas.optional}),parameters:[Ee({pipes:a,plugin:r}),m]})]);}t&&!m&&(a=[n.callExpression({functionName:n.propertyAccessExpression({expression:c.placeholder,name:T.schemas.optional}),parameters:[Ee({pipes:a,plugin:r})]})]);}if(i){e&&(i=r.registerSymbol({exported:true,name:O({config:{case:o.nameCase,name:o.nameTransformer},name:L(e)}),selector:r.api.getSelector("ref",e)}));let m=n.constVariable({comment:r.config.comments?ce({schema:s}):void 0,exportConst:i.exported,expression:Ee({pipes:a,plugin:r}),name:i.placeholder,typeName:o.hasCircularReference?n.propertyAccessExpression({expression:c.placeholder,name:p||T.types.GenericSchema.text}):void 0});return r.setSymbolValue(i,m),[]}return a},xc=({plugin:e})=>{e.registerSymbol({external:"valibot",meta:{importKind:"namespace"},name:"v",selector:e.api.getSelector("import","valibot")}),e.forEach("operation","parameter","requestBody","schema","webhook",t=>{let r={circularReferenceTracker:new Set,hasCircularReference:false,nameCase:e.config.definitions.case,nameTransformer:e.config.definitions.name};switch(t.type){case "operation":uc({operation:t.operation,plugin:e,state:r});break;case "parameter":oe({$ref:t.$ref,plugin:e,schema:t.parameter.schema,state:r});break;case "requestBody":oe({$ref:t.$ref,plugin:e,schema:t.requestBody.schema,state:r});break;case "schema":oe({$ref:t.$ref,plugin:e,schema:t.schema,state:r});break;case "webhook":yc({operation:t.operation,plugin:e,state:r});break}});};var Ns={api:new ks({name:"valibot"}),config:{case:"camelCase",comments:true,exportFromIndex:false,metadata:false},handler:xc,name:"valibot",resolveConfig:(e,t)=>{e.config.definitions=t.valueToObject({defaultValue:{case:e.config.case??"camelCase",enabled:true,name:"v{{name}}"},mappers:{boolean:r=>({enabled:r}),function:r=>({name:r}),string:r=>({name:r})},value:e.config.definitions}),e.config.requests=t.valueToObject({defaultValue:{case:e.config.case??"camelCase",enabled:true,name:"v{{name}}Data"},mappers:{boolean:r=>({enabled:r}),function:r=>({name:r}),string:r=>({name:r})},value:e.config.requests}),e.config.responses=t.valueToObject({defaultValue:{case:e.config.case??"camelCase",enabled:true,name:"v{{name}}Response"},mappers:{boolean:r=>({enabled:r}),function:r=>({name:r}),string:r=>({name:r})},value:e.config.responses}),e.config.webhooks=t.valueToObject({defaultValue:{case:e.config.case??"camelCase",enabled:true,name:"v{{name}}WebhookRequest"},mappers:{boolean:r=>({enabled:r}),function:r=>({name:r}),string:r=>({name:r})},value:e.config.webhooks});},tags:["validator"]};var u={ZodMiniOptional:n.identifier({text:"ZodMiniOptional"}),ZodOptional:n.identifier({text:"ZodOptional"}),_default:n.identifier({text:"_default"}),and:n.identifier({text:"and"}),array:n.identifier({text:"array"}),bigint:n.identifier({text:"bigint"}),boolean:n.identifier({text:"boolean"}),check:n.identifier({text:"check"}),coerce:n.identifier({text:"coerce"}),date:n.identifier({text:"date"}),datetime:n.identifier({text:"datetime"}),default:n.identifier({text:"default"}),describe:n.identifier({text:"describe"}),email:n.identifier({text:"email"}),enum:n.identifier({text:"enum"}),globalRegistry:n.identifier({text:"globalRegistry"}),gt:n.identifier({text:"gt"}),gte:n.identifier({text:"gte"}),infer:n.identifier({text:"infer"}),int:n.identifier({text:"int"}),intersection:n.identifier({text:"intersection"}),ip:n.identifier({text:"ip"}),ipv4:n.identifier({text:"ipv4"}),ipv6:n.identifier({text:"ipv6"}),iso:n.identifier({text:"iso"}),lazy:n.identifier({text:"lazy"}),length:n.identifier({text:"length"}),literal:n.identifier({text:"literal"}),lt:n.identifier({text:"lt"}),lte:n.identifier({text:"lte"}),max:n.identifier({text:"max"}),maxLength:n.identifier({text:"maxLength"}),min:n.identifier({text:"min"}),minLength:n.identifier({text:"minLength"}),never:n.identifier({text:"never"}),null:n.identifier({text:"null"}),nullable:n.identifier({text:"nullable"}),number:n.identifier({text:"number"}),object:n.identifier({text:"object"}),optional:n.identifier({text:"optional"}),parseAsync:n.identifier({text:"parseAsync"}),readonly:n.identifier({text:"readonly"}),record:n.identifier({text:"record"}),regex:n.identifier({text:"regex"}),register:n.identifier({text:"register"}),string:n.identifier({text:"string"}),time:n.identifier({text:"time"}),tuple:n.identifier({text:"tuple"}),undefined:n.identifier({text:"undefined"}),union:n.identifier({text:"union"}),unknown:n.identifier({text:"unknown"}),url:n.identifier({text:"url"}),uuid:n.identifier({text:"uuid"}),void:n.identifier({text:"void"})};var Cs=class{constructor(t){this.meta=t;}createRequestValidator({operation:t,plugin:r}){let s=r.getSymbol(r.api.getSelector("data",t.id));if(!s)return;let o="data";return n.arrowFunction({async:true,parameters:[{name:o}],statements:[n.returnStatement({expression:n.awaitExpression({expression:n.callExpression({functionName:n.propertyAccessExpression({expression:s.placeholder,name:u.parseAsync}),parameters:[n.identifier({text:o})]})})})]})}createResponseValidator({operation:t,plugin:r}){let s=r.getSymbol(r.api.getSelector("responses",t.id));if(!s)return;let o="data";return n.arrowFunction({async:true,parameters:[{name:o}],statements:[n.returnStatement({expression:n.awaitExpression({expression:n.callExpression({functionName:n.propertyAccessExpression({expression:s.placeholder,name:u.parseAsync}),parameters:[n.identifier({text:o})]})})})]})}getSelector(...t){return [this.meta.name,...t]}};var Ie=({plugin:e,schema:t,symbol:r,typeInferSymbol:s,zodSchema:o})=>{let i=e.referenceSymbol(e.api.getSelector("import","zod")),p=n.constVariable({comment:e.config.comments?ce({schema:t}):void 0,exportConst:r.exported,expression:o.expression,name:r.placeholder,typeName:o.typeName?n.propertyAccessExpression({expression:i.placeholder,name:o.typeName}):void 0});if(e.setSymbolValue(r,p),s){let a=n.typeAliasDeclaration({exportType:s.exported,name:s.placeholder,type:n.typeReferenceNode({typeArguments:[n.typeOfExpression({text:r.placeholder})],typeName:n.propertyAccessExpression({expression:i.placeholder,name:u.infer})})});e.setSymbolValue(s,a);}};var Rr=({plugin:e})=>{let t=e.package.getVersion("zod");if(t&&e.package.satisfies(t,"<4.0.0"))switch(e.config.compatibilityVersion){case 3:default:return "zod";case 4:return "zod/v4";case "mini":return "zod/v4-mini"}switch(e.config.compatibilityVersion){case 3:return "zod/v3";case 4:default:return "zod";case "mini":return "zod/mini"}};var Ar=({getZodSchema:e,operation:t,plugin:r})=>{if(r.config.requests.enabled){let s=new Set,o={properties:{body:{type:"never"},path:{type:"never"},query:{type:"never"}},type:"object"};if(t.parameters){if(t.parameters.header){let c={},m=[];for(let l in t.parameters.header){let f=t.parameters.header[l];c[f.name]=f.schema,f.required&&(m.push(f.name),s.add("headers"));}Object.keys(c).length&&(o.properties.headers={properties:c,required:m,type:"object"});}if(t.parameters.path){let c={},m=[];for(let l in t.parameters.path){let f=t.parameters.path[l];c[f.name]=f.schema,f.required&&(m.push(f.name),s.add("path"));}Object.keys(c).length&&(o.properties.path={properties:c,required:m,type:"object"});}if(t.parameters.query){let c={},m=[];for(let l in t.parameters.query){let f=t.parameters.query[l];c[f.name]=f.schema,f.required&&(m.push(f.name),s.add("query"));}Object.keys(c).length&&(o.properties.query={properties:c,required:m,type:"object"});}}t.body&&(o.properties.body=t.body.schema,t.body.required&&s.add("body")),o.required=[...s];let i=e(o),p=r.registerSymbol({exported:true,name:O({config:r.config.requests,name:t.id}),selector:r.api.getSelector("data",t.id)}),a=r.config.requests.types.infer.enabled?r.registerSymbol({exported:true,meta:{kind:"type"},name:O({config:r.config.requests.types.infer,name:t.id}),selector:r.api.getSelector("type-infer-data",t.id)}):void 0;Ie({plugin:r,schema:o,symbol:p,typeInferSymbol:a,zodSchema:i});}if(r.config.responses.enabled&&t.responses){let{response:s}=we(t);if(s){let o=e(s),i=r.registerSymbol({exported:true,name:O({config:r.config.responses,name:t.id}),selector:r.api.getSelector("responses",t.id)}),p=r.config.responses.types.infer.enabled?r.registerSymbol({exported:true,meta:{kind:"type"},name:O({config:r.config.responses.types.infer,name:t.id}),selector:r.api.getSelector("type-infer-responses",t.id)}):void 0;Ie({plugin:r,schema:s,symbol:i,typeInferSymbol:p,zodSchema:o});}}};var Pr=({getZodSchema:e,operation:t,plugin:r})=>{if(r.config.webhooks.enabled){let s=new Set,o={properties:{body:{type:"never"},path:{type:"never"},query:{type:"never"}},type:"object"};if(t.parameters){if(t.parameters.header){let c={},m=[];for(let l in t.parameters.header){let f=t.parameters.header[l];c[f.name]=f.schema,f.required&&(m.push(f.name),s.add("headers"));}Object.keys(c).length&&(o.properties.headers={properties:c,required:m,type:"object"});}if(t.parameters.path){let c={},m=[];for(let l in t.parameters.path){let f=t.parameters.path[l];c[f.name]=f.schema,f.required&&(m.push(f.name),s.add("path"));}Object.keys(c).length&&(o.properties.path={properties:c,required:m,type:"object"});}if(t.parameters.query){let c={},m=[];for(let l in t.parameters.query){let f=t.parameters.query[l];c[f.name]=f.schema,f.required&&(m.push(f.name),s.add("query"));}Object.keys(c).length&&(o.properties.query={properties:c,required:m,type:"object"});}}t.body&&(o.properties.body=t.body.schema,t.body.required&&s.add("body")),o.required=[...s];let i=e(o),p=r.registerSymbol({exported:true,name:O({config:r.config.webhooks,name:t.id}),selector:r.api.getSelector("webhook-request",t.id)}),a=r.config.webhooks.types.infer.enabled?r.registerSymbol({exported:true,meta:{kind:"type"},name:O({config:r.config.webhooks.types.infer,name:t.id}),selector:r.api.getSelector("type-infer-webhook-request",t.id)}):void 0;Ie({plugin:r,schema:o,symbol:p,typeInferSymbol:a,zodSchema:i});}};var du=({plugin:e,schema:t,state:r})=>{let s=e.referenceSymbol(e.api.getSelector("import","zod")),o={},i=n.propertyAccessExpression({expression:s.placeholder,name:u.array});if(!t.items)o.expression=n.callExpression({functionName:i,parameters:[qo({plugin:e}).expression]});else {t=z({schema:t});let a=t.items.map(c=>{let m=ct({plugin:e,schema:c,state:r});return m.hasCircularReference&&(o.hasCircularReference=true),m.expression});if(a.length===1)o.expression=n.callExpression({functionName:i,parameters:a});else if(t.logicalOperator==="and"){let c=t.items[0],m;if(c.logicalOperator==="or"||c.type&&c.type!=="object")m=n.callExpression({functionName:n.propertyAccessExpression({expression:s.placeholder,name:u.intersection}),parameters:a});else {m=a[0];for(let l=1;l<a.length;l++)m=n.callExpression({functionName:n.propertyAccessExpression({expression:s.placeholder,name:u.intersection}),parameters:[m,a[l]]});}o.expression=n.callExpression({functionName:i,parameters:[m]});}else o.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:s.placeholder,name:u.array}),parameters:[n.callExpression({functionName:n.propertyAccessExpression({expression:s.placeholder,name:u.union}),parameters:[n.arrayLiteralExpression({elements:a})]})]});}let p=[];return t.minItems===t.maxItems&&t.minItems!==void 0?p.push(n.callExpression({functionName:n.propertyAccessExpression({expression:s.placeholder,name:u.length}),parameters:[n.valueToExpression({value:t.minItems})]})):(t.minItems!==void 0&&p.push(n.callExpression({functionName:n.propertyAccessExpression({expression:s.placeholder,name:u.minLength}),parameters:[n.valueToExpression({value:t.minItems})]})),t.maxItems!==void 0&&p.push(n.callExpression({functionName:n.propertyAccessExpression({expression:s.placeholder,name:u.maxLength}),parameters:[n.valueToExpression({value:t.maxItems})]}))),p.length&&(o.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:o.expression,name:u.check}),parameters:p})),o},uu=({plugin:e,schema:t})=>{let r=e.referenceSymbol(e.api.getSelector("import","zod")),s={};return typeof t.const=="boolean"?(s.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:r.placeholder,name:u.literal}),parameters:[n.ots.boolean(t.const)]}),s):(s.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:r.placeholder,name:u.boolean})}),s)},yu=({plugin:e,schema:t})=>{let r=e.referenceSymbol(e.api.getSelector("import","zod")),s={},o=[],i=[],p=false,a=true;for(let c of t.items??[])if(c.type==="string"&&typeof c.const=="string"){let m=n.stringLiteral({text:c.const});o.push(m),i.push(n.callExpression({functionName:n.propertyAccessExpression({expression:r.placeholder,name:u.literal}),parameters:[m]}));}else if((c.type==="number"||c.type==="integer")&&typeof c.const=="number"){a=false;let m=n.ots.number(c.const);i.push(n.callExpression({functionName:n.propertyAccessExpression({expression:r.placeholder,name:u.literal}),parameters:[m]}));}else if(c.type==="boolean"&&typeof c.const=="boolean"){a=false;let m=n.ots.boolean(c.const);i.push(n.callExpression({functionName:n.propertyAccessExpression({expression:r.placeholder,name:u.literal}),parameters:[m]}));}else (c.type==="null"||c.const===null)&&(p=true);return i.length?(a&&o.length>0?s.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:r.placeholder,name:u.enum}),parameters:[n.arrayLiteralExpression({elements:o,multiLine:false})]}):i.length===1?s.expression=i[0]:s.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:r.placeholder,name:u.union}),parameters:[n.arrayLiteralExpression({elements:i,multiLine:i.length>3})]}),p&&(s.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:r.placeholder,name:u.nullable}),parameters:[s.expression]})),s):qo({plugin:e})},hu=({plugin:e})=>{let t=e.referenceSymbol(e.api.getSelector("import","zod")),r={};return r.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:t.placeholder,name:u.never})}),r},gu=({plugin:e})=>{let t=e.referenceSymbol(e.api.getSelector("import","zod")),r={};return r.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:t.placeholder,name:u.null})}),r},Xr=({isBigInt:e,value:t})=>{let r=n.valueToExpression({value:t});return e&&(typeof t=="bigint"||typeof t=="number"||typeof t=="string"||typeof t=="boolean")?n.callExpression({functionName:"BigInt",parameters:[r]}):r},xu=({plugin:e,schema:t})=>{let r=e.referenceSymbol(e.api.getSelector("import","zod")),s={},o=t.type==="integer"&&t.format==="int64";if(typeof t.const=="number")return s.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:r.placeholder,name:u.literal}),parameters:[n.ots.number(t.const)]}),s;s.expression=n.callExpression({functionName:o?n.propertyAccessExpression({expression:n.propertyAccessExpression({expression:r.placeholder,name:u.coerce}),name:u.bigint}):n.propertyAccessExpression({expression:r.placeholder,name:u.number})}),!o&&t.type==="integer"&&(s.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:r.placeholder,name:u.int})}));let i=[];return t.exclusiveMinimum!==void 0?i.push(n.callExpression({functionName:n.propertyAccessExpression({expression:r.placeholder,name:u.gt}),parameters:[Xr({isBigInt:o,value:t.exclusiveMinimum})]})):t.minimum!==void 0&&i.push(n.callExpression({functionName:n.propertyAccessExpression({expression:r.placeholder,name:u.gte}),parameters:[Xr({isBigInt:o,value:t.minimum})]})),t.exclusiveMaximum!==void 0?i.push(n.callExpression({functionName:n.propertyAccessExpression({expression:r.placeholder,name:u.lt}),parameters:[Xr({isBigInt:o,value:t.exclusiveMaximum})]})):t.maximum!==void 0&&i.push(n.callExpression({functionName:n.propertyAccessExpression({expression:r.placeholder,name:u.lte}),parameters:[Xr({isBigInt:o,value:t.maximum})]})),i.length&&(s.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:s.expression,name:u.check}),parameters:i})),s},bu=({plugin:e,schema:t,state:r})=>{let s=e.referenceSymbol(e.api.getSelector("import","zod")),o={},i=[],p=t.required??[];for(let a in t.properties){let c=t.properties[a],m=p.includes(a),l=ct({optional:!m,plugin:e,schema:c,state:r});l.hasCircularReference&&(o.hasCircularReference=true),X.lastIndex=0;let f;X.test(a)?f=a.startsWith("-")?b__default.default.factory.createStringLiteral(a):b__default.default.factory.createNumericLiteral(a):f=a,(a.match(/^[0-9]/)&&a.match(/\D+/g)||a.match(/\W/g))&&!a.startsWith("'")&&!a.endsWith("'")&&(f=`'${a}'`),l.hasCircularReference?i.push(n.getAccessorDeclaration({name:f,returnType:l.typeName?n.propertyAccessExpression({expression:s.placeholder,name:l.typeName}):void 0,statements:[n.returnStatement({expression:l.expression})]})):i.push(n.propertyAssignment({initializer:l.expression,name:f}));}if(t.additionalProperties&&(!t.properties||!Object.keys(t.properties).length)){let a=ct({plugin:e,schema:t.additionalProperties,state:r});return o.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:s.placeholder,name:u.record}),parameters:[n.callExpression({functionName:n.propertyAccessExpression({expression:s.placeholder,name:u.string}),parameters:[]}),a.expression]}),a.hasCircularReference&&(o.hasCircularReference=true),o}return o.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:s.placeholder,name:u.object}),parameters:[b__default.default.factory.createObjectLiteralExpression(i,true)]}),o},Su=({plugin:e,schema:t})=>{let r=e.referenceSymbol(e.api.getSelector("import","zod")),s={};if(typeof t.const=="string")return s.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:r.placeholder,name:u.literal}),parameters:[n.ots.string(t.const)]}),s;s.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:r.placeholder,name:u.string})});let o=[];if(e.config.dates.offset&&o.push({key:"offset",value:true}),e.config.dates.local&&o.push({key:"local",value:true}),t.format)switch(t.format){case "date":s.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:n.propertyAccessExpression({expression:r.placeholder,name:u.iso}),name:u.date})});break;case "date-time":s.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:n.propertyAccessExpression({expression:r.placeholder,name:u.iso}),name:u.datetime}),parameters:o.length>0?[n.objectExpression({obj:o})]:[]});break;case "email":s.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:r.placeholder,name:u.email})});break;case "ipv4":s.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:r.placeholder,name:u.ipv4})});break;case "ipv6":s.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:r.placeholder,name:u.ipv6})});break;case "time":s.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:n.propertyAccessExpression({expression:r.placeholder,name:u.iso}),name:u.time})});break;case "uri":s.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:r.placeholder,name:u.url})});break;case "uuid":s.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:r.placeholder,name:u.uuid})});break}let i=[];return t.minLength===t.maxLength&&t.minLength!==void 0?i.push(n.callExpression({functionName:n.propertyAccessExpression({expression:r.placeholder,name:u.length}),parameters:[n.valueToExpression({value:t.minLength})]})):(t.minLength!==void 0&&i.push(n.callExpression({functionName:n.propertyAccessExpression({expression:r.placeholder,name:u.minLength}),parameters:[n.valueToExpression({value:t.minLength})]})),t.maxLength!==void 0&&i.push(n.callExpression({functionName:n.propertyAccessExpression({expression:r.placeholder,name:u.maxLength}),parameters:[n.valueToExpression({value:t.maxLength})]}))),t.pattern&&i.push(n.callExpression({functionName:n.propertyAccessExpression({expression:r.placeholder,name:u.regex}),parameters:[n.regularExpressionLiteral({text:t.pattern})]})),i.length&&(s.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:s.expression,name:u.check}),parameters:i})),s},Ou=({plugin:e,schema:t,state:r})=>{let s=e.referenceSymbol(e.api.getSelector("import","zod")),o={};if(t.const&&Array.isArray(t.const)){let p=t.const.map(a=>n.callExpression({functionName:n.propertyAccessExpression({expression:s.placeholder,name:u.literal}),parameters:[n.valueToExpression({value:a})]}));return o.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:s.placeholder,name:u.tuple}),parameters:[n.arrayLiteralExpression({elements:p})]}),o}let i=[];for(let p of t.items??[]){let a=ct({plugin:e,schema:p,state:r});i.push(a.expression),a.hasCircularReference&&(o.hasCircularReference=true);}return o.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:s.placeholder,name:u.tuple}),parameters:[n.arrayLiteralExpression({elements:i})]}),o},Tu=({plugin:e})=>{let t=e.referenceSymbol(e.api.getSelector("import","zod")),r={};return r.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:t.placeholder,name:u.undefined})}),r},qo=({plugin:e})=>{let t=e.referenceSymbol(e.api.getSelector("import","zod")),r={};return r.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:t.placeholder,name:u.unknown})}),r},Ru=({plugin:e})=>{let t=e.referenceSymbol(e.api.getSelector("import","zod")),r={};return r.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:t.placeholder,name:u.void})}),r},bc=({plugin:e,schema:t,state:r})=>{switch(t.type){case "array":return du({plugin:e,schema:t,state:r});case "boolean":return uu({plugin:e,schema:t});case "enum":return yu({plugin:e,schema:t});case "integer":case "number":return xu({plugin:e,schema:t});case "never":return hu({plugin:e});case "null":return gu({plugin:e});case "object":return bu({plugin:e,schema:t,state:r});case "string":return Su({plugin:e,schema:t});case "tuple":return Ou({plugin:e,schema:t,state:r});case "undefined":return Tu({plugin:e});case "unknown":return qo({plugin:e});case "void":return Ru({plugin:e})}},ct=({optional:e,plugin:t,schema:r,state:s})=>{let o={},i=t.referenceSymbol(t.api.getSelector("import","zod"));if(r.$ref){let p=s.circularReferenceTracker.includes(r.$ref),a=s.currentReferenceTracker.includes(r.$ref);s.circularReferenceTracker.push(r.$ref),s.currentReferenceTracker.push(r.$ref);let c=t.api.getSelector("ref",r.$ref),m=t.getSymbol(c);if(p)m||(m=t.referenceSymbol(c)),a?o.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:i.placeholder,name:u.lazy}),parameters:[n.arrowFunction({returnType:n.keywordTypeNode({keyword:"any"}),statements:[n.returnStatement({expression:n.identifier({text:m.placeholder})})]})]}):o.expression=n.identifier({text:m.placeholder}),o.hasCircularReference=r.circular;else {if(m)o.hasCircularReference=r.circular;else {let f=t.context.resolveIrRef(r.$ref);vs({id:r.$ref,plugin:t,schema:f,state:s});}let l=t.referenceSymbol(c);o.expression=n.identifier({text:l.placeholder});}s.circularReferenceTracker.pop(),s.currentReferenceTracker.pop();}else if(r.type){let p=bc({plugin:t,schema:r,state:s});o.expression=p.expression,o.hasCircularReference=p.hasCircularReference,t.config.metadata&&r.description&&(o.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:o.expression,name:u.register}),parameters:[n.propertyAccessExpression({expression:i.placeholder,name:u.globalRegistry}),n.objectExpression({obj:[{key:"description",value:n.stringLiteral({text:r.description})}]})]}));}else if(r.items)if(r=z({schema:r}),r.items){let p=r.items.map(a=>ct({plugin:t,schema:a,state:s}));if(r.logicalOperator==="and"){let a=r.items[0];a.logicalOperator==="or"||a.type&&a.type!=="object"?o.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:i.placeholder,name:u.intersection}),parameters:p.map(c=>c.expression)}):(o.expression=p[0].expression,p.slice(1).forEach(c=>{o.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:i.placeholder,name:u.intersection}),parameters:[o.expression,c.hasCircularReference?n.callExpression({functionName:n.propertyAccessExpression({expression:i.placeholder,name:u.lazy}),parameters:[n.arrowFunction({statements:[n.returnStatement({expression:c.expression})]})]}):c.expression]});}));}else o.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:i.placeholder,name:u.union}),parameters:[n.arrayLiteralExpression({elements:p.map(a=>a.expression)})]});}else o=ct({plugin:t,schema:r,state:s});else {let p=bc({plugin:t,schema:{type:"unknown"},state:s});o.expression=p.expression;}if(o.expression&&(r.accessScope==="read"&&(o.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:i.placeholder,name:u.readonly}),parameters:[o.expression]})),e&&(o.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:i.placeholder,name:u.optional}),parameters:[o.expression]}),o.typeName=u.ZodMiniOptional),r.default!==void 0)){let p=r.type==="integer"&&r.format==="int64",a=Xr({isBigInt:p,value:r.default});a&&(o.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:i.placeholder,name:u._default}),parameters:[o.expression,a]}));}return o},vs=({id:e,plugin:t,schema:r,state:s})=>{let o={circularReferenceTracker:[e],hasCircularReference:false,...s,currentReferenceTracker:[e]},i=t.api.getSelector("ref",e),p=t.getSymbol(i);if(p&&!t.getSymbolValue(p))return;let a=ct({plugin:t,schema:r,state:o}),c=L(e);p=t.registerSymbol({exported:true,name:O({config:t.config.definitions,name:c}),selector:i});let m=t.config.definitions.types.infer.enabled?t.registerSymbol({exported:true,meta:{kind:"type"},name:O({config:t.config.definitions.types.infer,name:c}),selector:t.api.getSelector("type-infer-ref",e)}):void 0;Ie({plugin:t,schema:r,symbol:p,typeInferSymbol:m,zodSchema:a});},Sc=({plugin:e})=>{e.registerSymbol({external:Rr({plugin:e}),meta:{importKind:"namespace"},name:"z",selector:e.api.getSelector("import","zod")}),e.forEach("operation","parameter","requestBody","schema","webhook",t=>{switch(t.type){case "operation":Ar({getZodSchema:r=>ct({plugin:e,schema:r,state:{circularReferenceTracker:[],currentReferenceTracker:[],hasCircularReference:false}}),operation:t.operation,plugin:e});break;case "parameter":vs({id:t.$ref,plugin:e,schema:t.parameter.schema});break;case "requestBody":vs({id:t.$ref,plugin:e,schema:t.requestBody.schema});break;case "schema":vs({id:t.$ref,plugin:e,schema:t.schema});break;case "webhook":Pr({getZodSchema:r=>ct({plugin:e,schema:r,state:{circularReferenceTracker:[],currentReferenceTracker:[],hasCircularReference:false}}),operation:t.operation,plugin:e});break}});};var Au=({plugin:e,schema:t,state:r})=>{let s=e.referenceSymbol(e.api.getSelector("import","zod")),o=n.propertyAccessExpression({expression:s.placeholder,name:u.array}),i,p=false;if(!t.items)i=n.callExpression({functionName:o,parameters:[Mo({plugin:e})]});else {t=z({schema:t});let a=t.items.map(c=>{let m=mt({plugin:e,schema:c,state:r});return m.hasCircularReference&&(p=true),m.expression});if(a.length===1)i=n.callExpression({functionName:o,parameters:a});else if(t.logicalOperator==="and"){let c=t.items[0],m;if(c.logicalOperator==="or"||c.type&&c.type!=="object")m=n.callExpression({functionName:n.propertyAccessExpression({expression:s.placeholder,name:u.intersection}),parameters:a});else {m=a[0];for(let l=1;l<a.length;l++)m=n.callExpression({functionName:n.propertyAccessExpression({expression:m,name:u.and}),parameters:[a[l]]});}i=n.callExpression({functionName:o,parameters:[m]});}else i=n.callExpression({functionName:n.propertyAccessExpression({expression:s.placeholder,name:u.array}),parameters:[n.callExpression({functionName:n.propertyAccessExpression({expression:s.placeholder,name:u.union}),parameters:[n.arrayLiteralExpression({elements:a})]})]});}return t.minItems===t.maxItems&&t.minItems!==void 0?i=n.callExpression({functionName:n.propertyAccessExpression({expression:i,name:u.length}),parameters:[n.valueToExpression({value:t.minItems})]}):(t.minItems!==void 0&&(i=n.callExpression({functionName:n.propertyAccessExpression({expression:i,name:u.min}),parameters:[n.valueToExpression({value:t.minItems})]})),t.maxItems!==void 0&&(i=n.callExpression({functionName:n.propertyAccessExpression({expression:i,name:u.max}),parameters:[n.valueToExpression({value:t.maxItems})]}))),{expression:i,hasCircularReference:p}},Pu=({plugin:e,schema:t})=>{let r=e.referenceSymbol(e.api.getSelector("import","zod"));return typeof t.const=="boolean"?n.callExpression({functionName:n.propertyAccessExpression({expression:r.placeholder,name:u.literal}),parameters:[n.ots.boolean(t.const)]}):n.callExpression({functionName:n.propertyAccessExpression({expression:r.placeholder,name:u.boolean})})},Eu=({plugin:e,schema:t})=>{let r=e.referenceSymbol(e.api.getSelector("import","zod")),s=[],o=[],i=false,p=true;for(let c of t.items??[])if(c.type==="string"&&typeof c.const=="string"){let m=n.stringLiteral({text:c.const});s.push(m),o.push(n.callExpression({functionName:n.propertyAccessExpression({expression:r.placeholder,name:u.literal}),parameters:[m]}));}else if((c.type==="number"||c.type==="integer")&&typeof c.const=="number"){p=false;let m=n.ots.number(c.const);o.push(n.callExpression({functionName:n.propertyAccessExpression({expression:r.placeholder,name:u.literal}),parameters:[m]}));}else if(c.type==="boolean"&&typeof c.const=="boolean"){p=false;let m=n.ots.boolean(c.const);o.push(n.callExpression({functionName:n.propertyAccessExpression({expression:r.placeholder,name:u.literal}),parameters:[m]}));}else (c.type==="null"||c.const===null)&&(i=true);if(!o.length)return Mo({plugin:e});let a;return p&&s.length>0?a=n.callExpression({functionName:n.propertyAccessExpression({expression:r.placeholder,name:u.enum}),parameters:[n.arrayLiteralExpression({elements:s,multiLine:false})]}):o.length===1?a=o[0]:a=n.callExpression({functionName:n.propertyAccessExpression({expression:r.placeholder,name:u.union}),parameters:[n.arrayLiteralExpression({elements:o,multiLine:o.length>3})]}),i&&(a=n.callExpression({functionName:n.propertyAccessExpression({expression:a,name:u.nullable})})),a},Iu=({plugin:e})=>{let t=e.referenceSymbol(e.api.getSelector("import","zod"));return n.callExpression({functionName:n.propertyAccessExpression({expression:t.placeholder,name:u.never})})},ku=({plugin:e})=>{let t=e.referenceSymbol(e.api.getSelector("import","zod"));return n.callExpression({functionName:n.propertyAccessExpression({expression:t.placeholder,name:u.null})})},Jr=({isBigInt:e,value:t})=>{let r=n.valueToExpression({value:t});return e&&(typeof t=="bigint"||typeof t=="number"||typeof t=="string"||typeof t=="boolean")?n.callExpression({functionName:"BigInt",parameters:[r]}):r},ju=({plugin:e,schema:t})=>{let r=e.referenceSymbol(e.api.getSelector("import","zod")),s=t.type==="integer"&&t.format==="int64";if(typeof t.const=="number")return n.callExpression({functionName:n.propertyAccessExpression({expression:r.placeholder,name:u.literal}),parameters:[n.ots.number(t.const)]});let o=n.callExpression({functionName:s?n.propertyAccessExpression({expression:n.propertyAccessExpression({expression:r.placeholder,name:u.coerce}),name:u.bigint}):n.propertyAccessExpression({expression:r.placeholder,name:u.number})});return !s&&t.type==="integer"&&(o=n.callExpression({functionName:n.propertyAccessExpression({expression:o,name:u.int})})),t.exclusiveMinimum!==void 0?o=n.callExpression({functionName:n.propertyAccessExpression({expression:o,name:u.gt}),parameters:[Jr({isBigInt:s,value:t.exclusiveMinimum})]}):t.minimum!==void 0&&(o=n.callExpression({functionName:n.propertyAccessExpression({expression:o,name:u.gte}),parameters:[Jr({isBigInt:s,value:t.minimum})]})),t.exclusiveMaximum!==void 0?o=n.callExpression({functionName:n.propertyAccessExpression({expression:o,name:u.lt}),parameters:[Jr({isBigInt:s,value:t.exclusiveMaximum})]}):t.maximum!==void 0&&(o=n.callExpression({functionName:n.propertyAccessExpression({expression:o,name:u.lte}),parameters:[Jr({isBigInt:s,value:t.maximum})]})),o},Nu=({plugin:e,schema:t,state:r})=>{let s=e.referenceSymbol(e.api.getSelector("import","zod")),o=false,i=[],p=t.required??[];for(let c in t.properties){let m=t.properties[c],l=p.includes(c),f=mt({optional:!l,plugin:e,schema:m,state:r});f.hasCircularReference&&(o=true),X.lastIndex=0;let d;X.test(c)?d=c.startsWith("-")?b__default.default.factory.createStringLiteral(c):b__default.default.factory.createNumericLiteral(c):d=c,(c.match(/^[0-9]/)&&c.match(/\D+/g)||c.match(/\W/g))&&!c.startsWith("'")&&!c.endsWith("'")&&(d=`'${c}'`),i.push(n.propertyAssignment({initializer:f.expression,name:d}));}if(t.additionalProperties&&(!t.properties||!Object.keys(t.properties).length)){let c=mt({plugin:e,schema:t.additionalProperties,state:r});return {anyType:"AnyZodObject",expression:n.callExpression({functionName:n.propertyAccessExpression({expression:s.placeholder,name:u.record}),parameters:[c.expression]}),hasCircularReference:c.hasCircularReference}}return {anyType:"AnyZodObject",expression:n.callExpression({functionName:n.propertyAccessExpression({expression:s.placeholder,name:u.object}),parameters:[b__default.default.factory.createObjectLiteralExpression(i,true)]}),hasCircularReference:o}},Cu=({plugin:e,schema:t})=>{let r=e.referenceSymbol(e.api.getSelector("import","zod"));if(typeof t.const=="string")return n.callExpression({functionName:n.propertyAccessExpression({expression:r.placeholder,name:u.literal}),parameters:[n.ots.string(t.const)]});let s=n.callExpression({functionName:n.propertyAccessExpression({expression:r.placeholder,name:u.string})}),o=[];if(e.config.dates.offset&&o.push({key:"offset",value:true}),e.config.dates.local&&o.push({key:"local",value:true}),t.format)switch(t.format){case "date":s=n.callExpression({functionName:n.propertyAccessExpression({expression:s,name:u.date})});break;case "date-time":s=n.callExpression({functionName:n.propertyAccessExpression({expression:s,name:u.datetime}),parameters:o.length>0?[n.objectExpression({obj:o})]:[]});break;case "email":s=n.callExpression({functionName:n.propertyAccessExpression({expression:s,name:u.email})});break;case "ipv4":case "ipv6":s=n.callExpression({functionName:n.propertyAccessExpression({expression:s,name:u.ip})});break;case "time":s=n.callExpression({functionName:n.propertyAccessExpression({expression:s,name:u.time})});break;case "uri":s=n.callExpression({functionName:n.propertyAccessExpression({expression:s,name:u.url})});break;case "uuid":s=n.callExpression({functionName:n.propertyAccessExpression({expression:s,name:u.uuid})});break}return t.minLength===t.maxLength&&t.minLength!==void 0?s=n.callExpression({functionName:n.propertyAccessExpression({expression:s,name:u.length}),parameters:[n.valueToExpression({value:t.minLength})]}):(t.minLength!==void 0&&(s=n.callExpression({functionName:n.propertyAccessExpression({expression:s,name:u.min}),parameters:[n.valueToExpression({value:t.minLength})]})),t.maxLength!==void 0&&(s=n.callExpression({functionName:n.propertyAccessExpression({expression:s,name:u.max}),parameters:[n.valueToExpression({value:t.maxLength})]}))),t.pattern&&(s=n.callExpression({functionName:n.propertyAccessExpression({expression:s,name:u.regex}),parameters:[n.regularExpressionLiteral({text:t.pattern})]})),s},vu=({plugin:e,schema:t,state:r})=>{let s=e.referenceSymbol(e.api.getSelector("import","zod")),o=false;if(t.const&&Array.isArray(t.const)){let a=t.const.map(m=>n.callExpression({functionName:n.propertyAccessExpression({expression:s.placeholder,name:u.literal}),parameters:[n.valueToExpression({value:m})]}));return {expression:n.callExpression({functionName:n.propertyAccessExpression({expression:s.placeholder,name:u.tuple}),parameters:[n.arrayLiteralExpression({elements:a})]}),hasCircularReference:o}}let i=[];for(let a of t.items??[]){let c=mt({plugin:e,schema:a,state:r});c.hasCircularReference&&(o=true),i.push(c.expression);}return {expression:n.callExpression({functionName:n.propertyAccessExpression({expression:s.placeholder,name:u.tuple}),parameters:[n.arrayLiteralExpression({elements:i})]}),hasCircularReference:o}},wu=({plugin:e})=>{let t=e.referenceSymbol(e.api.getSelector("import","zod"));return n.callExpression({functionName:n.propertyAccessExpression({expression:t.placeholder,name:u.undefined})})},Mo=({plugin:e})=>{let t=e.referenceSymbol(e.api.getSelector("import","zod"));return n.callExpression({functionName:n.propertyAccessExpression({expression:t.placeholder,name:u.unknown})})},qu=({plugin:e})=>{let t=e.referenceSymbol(e.api.getSelector("import","zod"));return n.callExpression({functionName:n.propertyAccessExpression({expression:t.placeholder,name:u.void})})},Oc=({plugin:e,schema:t,state:r})=>{switch(t.type){case "array":return Au({plugin:e,schema:t,state:r});case "boolean":return {expression:Pu({plugin:e,schema:t})};case "enum":return {expression:Eu({plugin:e,schema:t})};case "integer":case "number":return {expression:ju({plugin:e,schema:t})};case "never":return {expression:Iu({plugin:e})};case "null":return {expression:ku({plugin:e})};case "object":return Nu({plugin:e,schema:t,state:r});case "string":return {expression:Cu({plugin:e,schema:t})};case "tuple":return vu({plugin:e,schema:t,state:r});case "undefined":return {expression:wu({plugin:e})};case "unknown":return {expression:Mo({plugin:e})};case "void":return {expression:qu({plugin:e})}}},mt=({optional:e,plugin:t,schema:r,state:s})=>{let o={},i=t.referenceSymbol(t.api.getSelector("import","zod"));if(r.$ref){let p=s.circularReferenceTracker.includes(r.$ref);s.circularReferenceTracker.push(r.$ref),s.currentReferenceTracker.push(r.$ref);let a=t.api.getSelector("ref",r.$ref),c=t.getSymbol(a);if(p)c||(c=t.referenceSymbol(a)),o.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:i.placeholder,name:u.lazy}),parameters:[n.arrowFunction({statements:[n.returnStatement({expression:n.identifier({text:c.placeholder})})]})]}),o.hasCircularReference=r.circular;else {if(c)o.hasCircularReference=r.circular;else {let l=t.context.resolveIrRef(r.$ref);ws({id:r.$ref,plugin:t,schema:l,state:{...s,currentReferenceTracker:[r.$ref]}});}let m=t.referenceSymbol(a);o.expression=n.identifier({text:m.placeholder});}s.circularReferenceTracker.pop(),s.currentReferenceTracker.pop();}else if(r.type){let p=Oc({plugin:t,schema:r,state:s});o.expression=p.expression,o.hasCircularReference=p.hasCircularReference,o.typeName=p.anyType,t.config.metadata&&r.description&&(o.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:o.expression,name:u.describe}),parameters:[n.stringLiteral({text:r.description})]}));}else if(r.items)if(r=z({schema:r}),r.items){let p=r.items.map(a=>{let c=mt({plugin:t,schema:a,state:s});return c.hasCircularReference&&(o.hasCircularReference=true),c.expression});if(r.logicalOperator==="and"){let a=r.items[0];a.logicalOperator==="or"||a.type&&a.type!=="object"?o.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:i.placeholder,name:u.intersection}),parameters:p}):(o.expression=p[0],p.slice(1).forEach(c=>{o.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:o.expression,name:u.and}),parameters:[c]});}));}else o.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:i.placeholder,name:u.union}),parameters:[n.arrayLiteralExpression({elements:p})]});}else o=mt({plugin:t,schema:r,state:s});else {let p=Oc({plugin:t,schema:{type:"unknown"},state:s});o.expression=p.expression,o.hasCircularReference=p.hasCircularReference,o.typeName=p.anyType;}if(o.expression&&(r.accessScope==="read"&&(o.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:o.expression,name:u.readonly})})),e&&(o.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:o.expression,name:u.optional})})),r.default!==void 0)){let p=r.type==="integer"&&r.format==="int64",a=Jr({isBigInt:p,value:r.default});a&&(o.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:o.expression,name:u.default}),parameters:[a]}));}return o.hasCircularReference?o.typeName||(o.typeName="ZodTypeAny"):o.typeName&&(o.typeName=void 0),o},ws=({id:e,plugin:t,schema:r,state:s})=>{s||(s={circularReferenceTracker:[e],currentReferenceTracker:[e],hasCircularReference:false});let o=t.api.getSelector("ref",e),i=t.getSymbol(o);if(i)return;let p=mt({plugin:t,schema:r,state:s}),a=L(e);i=t.registerSymbol({exported:true,name:O({config:t.config.definitions,name:a}),selector:o});let c=t.config.definitions.types.infer.enabled?t.registerSymbol({exported:true,meta:{kind:"type"},name:O({config:t.config.definitions.types.infer,name:a}),selector:t.api.getSelector("type-infer-ref",e)}):void 0;Ie({plugin:t,schema:r,symbol:i,typeInferSymbol:c,zodSchema:p});},Tc=({plugin:e})=>{e.registerSymbol({external:Rr({plugin:e}),name:"z",selector:e.api.getSelector("import","zod")}),e.forEach("operation","parameter","requestBody","schema","webhook",t=>{switch(t.type){case "operation":Ar({getZodSchema:r=>mt({plugin:e,schema:r,state:{circularReferenceTracker:[],currentReferenceTracker:[],hasCircularReference:false}}),operation:t.operation,plugin:e});break;case "parameter":ws({id:t.$ref,plugin:e,schema:t.parameter.schema});break;case "requestBody":ws({id:t.$ref,plugin:e,schema:t.requestBody.schema});break;case "schema":ws({id:t.$ref,plugin:e,schema:t.schema});break;case "webhook":Pr({getZodSchema:r=>mt({plugin:e,schema:r,state:{circularReferenceTracker:[],currentReferenceTracker:[],hasCircularReference:false}}),operation:t.operation,plugin:e});break}});};var $u=({plugin:e,schema:t,state:r})=>{let s={},o=e.referenceSymbol(e.api.getSelector("import","zod")),i=n.propertyAccessExpression({expression:o.placeholder,name:u.array});if(!t.items)s.expression=n.callExpression({functionName:i,parameters:[Vo({plugin:e}).expression]});else {t=z({schema:t});let p=t.items.map(a=>{let c=lt({plugin:e,schema:a,state:r});return c.hasCircularReference&&(s.hasCircularReference=true),c.expression});if(p.length===1)s.expression=n.callExpression({functionName:i,parameters:p});else if(t.logicalOperator==="and"){let a=t.items[0],c;if(a.logicalOperator==="or"||a.type&&a.type!=="object")c=n.callExpression({functionName:n.propertyAccessExpression({expression:o.placeholder,name:u.intersection}),parameters:p});else {c=p[0];for(let m=1;m<p.length;m++)c=n.callExpression({functionName:n.propertyAccessExpression({expression:c,name:u.and}),parameters:[p[m]]});}s.expression=n.callExpression({functionName:i,parameters:[c]});}else s.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:o.placeholder,name:u.array}),parameters:[n.callExpression({functionName:n.propertyAccessExpression({expression:o.placeholder,name:u.union}),parameters:[n.arrayLiteralExpression({elements:p})]})]});}return t.minItems===t.maxItems&&t.minItems!==void 0?s.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:s.expression,name:u.length}),parameters:[n.valueToExpression({value:t.minItems})]}):(t.minItems!==void 0&&(s.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:s.expression,name:u.min}),parameters:[n.valueToExpression({value:t.minItems})]})),t.maxItems!==void 0&&(s.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:s.expression,name:u.max}),parameters:[n.valueToExpression({value:t.maxItems})]}))),s},Mu=({plugin:e,schema:t})=>{let r={},s=e.referenceSymbol(e.api.getSelector("import","zod"));return typeof t.const=="boolean"?(r.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:s.placeholder,name:u.literal}),parameters:[n.ots.boolean(t.const)]}),r):(r.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:s.placeholder,name:u.boolean})}),r)},Lu=({plugin:e,schema:t})=>{let r={},s=e.referenceSymbol(e.api.getSelector("import","zod")),o=[],i=[],p=false,a=true;for(let c of t.items??[])if(c.type==="string"&&typeof c.const=="string"){let m=n.stringLiteral({text:c.const});o.push(m),i.push(n.callExpression({functionName:n.propertyAccessExpression({expression:s.placeholder,name:u.literal}),parameters:[m]}));}else if((c.type==="number"||c.type==="integer")&&typeof c.const=="number"){a=false;let m=n.ots.number(c.const);i.push(n.callExpression({functionName:n.propertyAccessExpression({expression:s.placeholder,name:u.literal}),parameters:[m]}));}else if(c.type==="boolean"&&typeof c.const=="boolean"){a=false;let m=n.ots.boolean(c.const);i.push(n.callExpression({functionName:n.propertyAccessExpression({expression:s.placeholder,name:u.literal}),parameters:[m]}));}else (c.type==="null"||c.const===null)&&(p=true);return i.length?(a&&o.length>0?r.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:s.placeholder,name:u.enum}),parameters:[n.arrayLiteralExpression({elements:o,multiLine:false})]}):i.length===1?r.expression=i[0]:r.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:s.placeholder,name:u.union}),parameters:[n.arrayLiteralExpression({elements:i,multiLine:i.length>3})]}),p&&(r.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:s.placeholder,name:u.nullable}),parameters:[r.expression]})),r):Vo({plugin:e})},Vu=({plugin:e})=>{let t={},r=e.referenceSymbol(e.api.getSelector("import","zod"));return t.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:r.placeholder,name:u.never})}),t},Du=({plugin:e})=>{let t={},r=e.referenceSymbol(e.api.getSelector("import","zod"));return t.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:r.placeholder,name:u.null})}),t},Gr=({isBigInt:e,value:t})=>{let r=n.valueToExpression({value:t});return e&&(typeof t=="bigint"||typeof t=="number"||typeof t=="string"||typeof t=="boolean")?n.callExpression({functionName:"BigInt",parameters:[r]}):r},Fu=({plugin:e,schema:t})=>{let r={},s=t.type==="integer"&&t.format==="int64",o=e.referenceSymbol(e.api.getSelector("import","zod"));return typeof t.const=="number"?(r.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:o.placeholder,name:u.literal}),parameters:[n.ots.number(t.const)]}),r):(r.expression=n.callExpression({functionName:s?n.propertyAccessExpression({expression:n.propertyAccessExpression({expression:o.placeholder,name:u.coerce}),name:u.bigint}):n.propertyAccessExpression({expression:o.placeholder,name:u.number})}),!s&&t.type==="integer"&&(r.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:o.placeholder,name:u.int})})),t.exclusiveMinimum!==void 0?r.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:r.expression,name:u.gt}),parameters:[Gr({isBigInt:s,value:t.exclusiveMinimum})]}):t.minimum!==void 0&&(r.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:r.expression,name:u.gte}),parameters:[Gr({isBigInt:s,value:t.minimum})]})),t.exclusiveMaximum!==void 0?r.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:r.expression,name:u.lt}),parameters:[Gr({isBigInt:s,value:t.exclusiveMaximum})]}):t.maximum!==void 0&&(r.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:r.expression,name:u.lte}),parameters:[Gr({isBigInt:s,value:t.maximum})]})),r)},Bu=({plugin:e,schema:t,state:r})=>{let s={},o=[],i=t.required??[],p=e.referenceSymbol(e.api.getSelector("import","zod"));for(let a in t.properties){let c=t.properties[a],m=i.includes(a),l=lt({optional:!m,plugin:e,schema:c,state:r});l.hasCircularReference&&(s.hasCircularReference=true),X.lastIndex=0;let f;X.test(a)?f=a.startsWith("-")?b__default.default.factory.createStringLiteral(a):b__default.default.factory.createNumericLiteral(a):f=a,(a.match(/^[0-9]/)&&a.match(/\D+/g)||a.match(/\W/g))&&!a.startsWith("'")&&!a.endsWith("'")&&(f=`'${a}'`),l.hasCircularReference?o.push(n.getAccessorDeclaration({name:f,returnType:l.typeName?n.propertyAccessExpression({expression:p.placeholder,name:l.typeName}):void 0,statements:[n.returnStatement({expression:l.expression})]})):o.push(n.propertyAssignment({initializer:l.expression,name:f}));}if(t.additionalProperties&&(!t.properties||!Object.keys(t.properties).length)){let a=lt({plugin:e,schema:t.additionalProperties,state:r});return s.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:p.placeholder,name:u.record}),parameters:[n.callExpression({functionName:n.propertyAccessExpression({expression:p.placeholder,name:u.string}),parameters:[]}),a.expression]}),a.hasCircularReference&&(s.hasCircularReference=true),s.hasCircularReference?{...s,typeName:"ZodType"}:s}return s.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:p.placeholder,name:u.object}),parameters:[b__default.default.factory.createObjectLiteralExpression(o,true)]}),s.hasCircularReference?{...s,typeName:"ZodType"}:s},Ku=({plugin:e,schema:t})=>{let r={},s=e.referenceSymbol(e.api.getSelector("import","zod"));if(typeof t.const=="string")return r.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:s.placeholder,name:u.literal}),parameters:[n.ots.string(t.const)]}),r;r.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:s.placeholder,name:u.string})});let o=[];if(e.config.dates.offset&&o.push({key:"offset",value:true}),e.config.dates.local&&o.push({key:"local",value:true}),t.format)switch(t.format){case "date":r.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:n.propertyAccessExpression({expression:s.placeholder,name:u.iso}),name:u.date})});break;case "date-time":r.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:n.propertyAccessExpression({expression:s.placeholder,name:u.iso}),name:u.datetime}),parameters:o.length>0?[n.objectExpression({obj:o})]:[]});break;case "email":r.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:s.placeholder,name:u.email})});break;case "ipv4":r.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:s.placeholder,name:u.ipv4})});break;case "ipv6":r.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:s.placeholder,name:u.ipv6})});break;case "time":r.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:n.propertyAccessExpression({expression:s.placeholder,name:u.iso}),name:u.time})});break;case "uri":r.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:s.placeholder,name:u.url})});break;case "uuid":r.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:s.placeholder,name:u.uuid})});break}return t.minLength===t.maxLength&&t.minLength!==void 0?r.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:r.expression,name:u.length}),parameters:[n.valueToExpression({value:t.minLength})]}):(t.minLength!==void 0&&(r.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:r.expression,name:u.min}),parameters:[n.valueToExpression({value:t.minLength})]})),t.maxLength!==void 0&&(r.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:r.expression,name:u.max}),parameters:[n.valueToExpression({value:t.maxLength})]}))),t.pattern&&(r.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:r.expression,name:u.regex}),parameters:[n.regularExpressionLiteral({text:t.pattern})]})),r},Wu=({plugin:e,schema:t,state:r})=>{let s={},o=e.referenceSymbol(e.api.getSelector("import","zod"));if(t.const&&Array.isArray(t.const)){let p=t.const.map(a=>n.callExpression({functionName:n.propertyAccessExpression({expression:o.placeholder,name:u.literal}),parameters:[n.valueToExpression({value:a})]}));return s.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:o.placeholder,name:u.tuple}),parameters:[n.arrayLiteralExpression({elements:p})]}),s}let i=[];for(let p of t.items??[]){let a=lt({plugin:e,schema:p,state:r});i.push(a.expression),a.hasCircularReference&&(s.hasCircularReference=true);}return s.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:o.placeholder,name:u.tuple}),parameters:[n.arrayLiteralExpression({elements:i})]}),s},zu=({plugin:e})=>{let t={},r=e.referenceSymbol(e.api.getSelector("import","zod"));return t.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:r.placeholder,name:u.undefined})}),t},Vo=({plugin:e})=>{let t={},r=e.referenceSymbol(e.api.getSelector("import","zod"));return t.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:r.placeholder,name:u.unknown})}),t},_u=({plugin:e})=>{let t={},r=e.referenceSymbol(e.api.getSelector("import","zod"));return t.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:r.placeholder,name:u.void})}),t},Rc=({plugin:e,schema:t,state:r})=>{switch(t.type){case "array":return $u({plugin:e,schema:t,state:r});case "boolean":return Mu({plugin:e,schema:t});case "enum":return Lu({plugin:e,schema:t});case "integer":case "number":return Fu({plugin:e,schema:t});case "never":return Vu({plugin:e});case "null":return Du({plugin:e});case "object":return Bu({plugin:e,schema:t,state:r});case "string":return Ku({plugin:e,schema:t});case "tuple":return Wu({plugin:e,schema:t,state:r});case "undefined":return zu({plugin:e});case "unknown":return Vo({plugin:e});case "void":return _u({plugin:e})}},lt=({optional:e,plugin:t,schema:r,state:s})=>{let o={},i=t.referenceSymbol(t.api.getSelector("import","zod"));if(r.$ref){let p=s.circularReferenceTracker.includes(r.$ref),a=s.currentReferenceTracker.includes(r.$ref);s.circularReferenceTracker.push(r.$ref),s.currentReferenceTracker.push(r.$ref);let c=t.api.getSelector("ref",r.$ref),m=t.getSymbol(c);if(p)m||(m=t.referenceSymbol(c)),a?o.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:i.placeholder,name:u.lazy}),parameters:[n.arrowFunction({returnType:n.keywordTypeNode({keyword:"any"}),statements:[n.returnStatement({expression:n.identifier({text:m.placeholder})})]})]}):o.expression=n.identifier({text:m.placeholder}),o.hasCircularReference=r.circular;else {if(m)o.hasCircularReference=r.circular;else {let f=t.context.resolveIrRef(r.$ref);qs({id:r.$ref,plugin:t,schema:f,state:s});}let l=t.referenceSymbol(c);o.expression=n.identifier({text:l.placeholder});}s.circularReferenceTracker.pop(),s.currentReferenceTracker.pop();}else if(r.type){let p=Rc({plugin:t,schema:r,state:s});o.expression=p.expression,o.hasCircularReference=p.hasCircularReference,t.config.metadata&&r.description&&(o.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:o.expression,name:u.register}),parameters:[n.propertyAccessExpression({expression:i.placeholder,name:u.globalRegistry}),n.objectExpression({obj:[{key:"description",value:n.stringLiteral({text:r.description})}]})]}));}else if(r.items)if(r=z({schema:r}),r.items){let p=r.items.map(a=>lt({plugin:t,schema:a,state:s}));if(r.logicalOperator==="and"){let a=r.items[0];a.logicalOperator==="or"||a.type&&a.type!=="object"?o.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:i.placeholder,name:u.intersection}),parameters:p.map(c=>c.expression)}):(o.expression=p[0].expression,p.slice(1).forEach(c=>{o.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:o.expression,name:u.and}),parameters:[c.hasCircularReference?n.callExpression({functionName:n.propertyAccessExpression({expression:i.placeholder,name:u.lazy}),parameters:[n.arrowFunction({statements:[n.returnStatement({expression:c.expression})]})]}):c.expression]});}));}else o.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:i.placeholder,name:u.union}),parameters:[n.arrayLiteralExpression({elements:p.map(a=>a.expression)})]});}else o=lt({plugin:t,schema:r,state:s});else {let p=Rc({plugin:t,schema:{type:"unknown"},state:s});o.expression=p.expression;}if(o.expression&&(r.accessScope==="read"&&(o.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:o.expression,name:u.readonly})})),e&&(o.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:i.placeholder,name:u.optional}),parameters:[o.expression]}),o.typeName=u.ZodOptional),r.default!==void 0)){let p=r.type==="integer"&&r.format==="int64",a=Gr({isBigInt:p,value:r.default});a&&(o.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:o.expression,name:u.default}),parameters:[a]}));}return o},qs=({id:e,plugin:t,schema:r,state:s})=>{let o={circularReferenceTracker:[e],hasCircularReference:false,...s,currentReferenceTracker:[e]},i=t.api.getSelector("ref",e),p=t.getSymbol(i);if(p&&!t.getSymbolValue(p))return;let a=lt({plugin:t,schema:r,state:o}),c=L(e);p=t.registerSymbol({exported:true,name:O({config:t.config.definitions,name:c}),selector:i});let m=t.config.definitions.types.infer.enabled?t.registerSymbol({exported:true,meta:{kind:"type"},name:O({config:t.config.definitions.types.infer,name:c}),selector:t.api.getSelector("type-infer-ref",e)}):void 0;Ie({plugin:t,schema:r,symbol:p,typeInferSymbol:m,zodSchema:a});},Do=({plugin:e})=>{e.registerSymbol({external:Rr({plugin:e}),name:"z",selector:e.api.getSelector("import","zod")}),e.forEach("operation","parameter","requestBody","schema","webhook",t=>{switch(t.type){case "operation":Ar({getZodSchema:r=>lt({plugin:e,schema:r,state:{circularReferenceTracker:[],currentReferenceTracker:[],hasCircularReference:false}}),operation:t.operation,plugin:e});break;case "parameter":qs({id:t.$ref,plugin:e,schema:t.parameter.schema});break;case "requestBody":qs({id:t.$ref,plugin:e,schema:t.requestBody.schema});break;case "schema":qs({id:t.$ref,plugin:e,schema:t.schema});break;case "webhook":Pr({getZodSchema:r=>lt({plugin:e,schema:r,state:{circularReferenceTracker:[],currentReferenceTracker:[],hasCircularReference:false}}),operation:t.operation,plugin:e});break}});};var Ac=e=>{let{plugin:t}=e;switch(t.config.compatibilityVersion){case 3:return Tc(e);case 4:return Do(e);case "mini":return Sc(e);default:return Do(e)}};var $s={api:new Cs({name:"zod"}),config:{case:"camelCase",comments:true,exportFromIndex:false,metadata:false},handler:Ac,name:"zod",resolveConfig:(e,t)=>{let s=t.package.getVersion("zod"),o=()=>s&&(s.major===4||s.major===3)?s.major:4,i=p=>{if(!p)return o();if(!s)return p;if((p===4||p===3||p==="mini")&&!t.package.satisfies(s,">=3.25.0 <5.0.0")){let a=o();return console.warn(`\u{1F50C} ${Ht__default.default.yellow("Warning:")} Installed ${Ht__default.default.cyan("zod")} ${Ht__default.default.cyan(`v${s.version}`)} does not support compatibility version ${Ht__default.default.yellow(String(p))}, using ${Ht__default.default.yellow(String(a))}.`),a}return p};e.config.compatibilityVersion=i(e.config.compatibilityVersion),e.config.dates=t.valueToObject({defaultValue:{local:false,offset:false},value:e.config.dates}),e.config.types=t.valueToObject({defaultValue:{infer:{case:"PascalCase",enabled:false}},mappers:{object:(p,a)=>({...p,infer:t.valueToObject({defaultValue:{...a.infer,enabled:p.infer!==void 0?!!p.infer:a.infer.enabled},mappers:je,value:p.infer})})},value:e.config.types}),e.config.definitions=t.valueToObject({defaultValue:{case:e.config.case??"camelCase",enabled:true,name:"z{{name}}",types:{...e.config.types,infer:{...e.config.types.infer,name:"{{name}}ZodType"}}},mappers:{...je,object:(p,a)=>({...p,types:t.valueToObject({defaultValue:a.types,mappers:{object:(c,m)=>({...c,infer:t.valueToObject({defaultValue:{...m.infer,enabled:c.infer!==void 0?!!c.infer:m.infer.enabled},mappers:je,value:c.infer})})},value:p.types})})},value:e.config.definitions}),e.config.requests=t.valueToObject({defaultValue:{case:e.config.case??"camelCase",enabled:true,name:"z{{name}}Data",types:{...e.config.types,infer:{...e.config.types.infer,name:"{{name}}DataZodType"}}},mappers:{...je,object:(p,a)=>({...p,types:t.valueToObject({defaultValue:a.types,mappers:{object:(c,m)=>({...c,infer:t.valueToObject({defaultValue:{...m.infer,enabled:c.infer!==void 0?!!c.infer:m.infer.enabled},mappers:je,value:c.infer})})},value:p.types})})},value:e.config.requests}),e.config.responses=t.valueToObject({defaultValue:{case:e.config.case??"camelCase",enabled:true,name:"z{{name}}Response",types:{...e.config.types,infer:{...e.config.types.infer,name:"{{name}}ResponseZodType"}}},mappers:{...je,object:(p,a)=>({...p,types:t.valueToObject({defaultValue:a.types,mappers:{object:(c,m)=>({...c,infer:t.valueToObject({defaultValue:{...m.infer,enabled:c.infer!==void 0?!!c.infer:m.infer.enabled},mappers:je,value:c.infer})})},value:p.types})})},value:e.config.responses}),e.config.webhooks=t.valueToObject({defaultValue:{case:e.config.case??"camelCase",enabled:true,name:"z{{name}}WebhookRequest",types:{...e.config.types,infer:{...e.config.types.infer,name:"{{name}}WebhookRequestZodType"}}},mappers:{...je,object:(p,a)=>({...p,types:t.valueToObject({defaultValue:a.types,mappers:{object:(c,m)=>({...c,infer:t.valueToObject({defaultValue:{...m.infer,enabled:c.infer!==void 0?!!c.infer:m.infer.enabled},mappers:je,value:c.infer})})},value:p.types})})},value:e.config.webhooks});},tags:["validator"]};var Ms={"@angular/common":Nn,"@hey-api/client-angular":vn,"@hey-api/client-axios":qn,"@hey-api/client-fetch":Mn,"@hey-api/client-next":Vn,"@hey-api/client-nuxt":Fn,"@hey-api/client-ofetch":Kn,"@hey-api/schemas":Un,"@hey-api/sdk":Jn,"@hey-api/transformers":ts,"@hey-api/typescript":ss,"@pinia/colada":ps,"@tanstack/angular-query-experimental":gs,"@tanstack/react-query":bs,"@tanstack/solid-query":Os,"@tanstack/svelte-query":Rs,"@tanstack/vue-query":Ps,fastify:Is,"legacy/angular":Wn,"legacy/axios":zn,"legacy/fetch":_n,"legacy/node":Hn,"legacy/xhr":Qn,valibot:Ns,zod:$s};var Pc=["@hey-api/typescript","@hey-api/sdk"],Qu=({dependencies:e,userPlugins:t,userPluginsConfig:r})=>{let s=new Set,o=new Set,i={},p=a=>{if(s.has(a))throw new Error(`Circular reference detected at '${a}'`);if(o.has(a))return;s.add(a);let c=Ms[a],m=r[a];if(!c&&!m)throw new Error(`unknown plugin dependency "${a}" - do you need to register a custom plugin with this name?`);let l={...c,...m,config:{...c?.config,...m?.config},dependencies:new Set([...c?.dependencies||[],...m?.dependencies||[]])};if(l.resolveConfig){let f={package:gn(e),pluginByTag:(d,y={})=>{let{defaultPlugin:h,errorMessage:g}=y;for(let x of t){let S=Ms[x]||r[x];if(S&&S.tags?.includes(d)&&x!==a)return x}if(h){let x=Ms[h]||r[h];if(x&&x.tags?.includes(d)&&h!==a)return h}throw new Error(g||`missing plugin - no plugin with tag "${d}" found`)},valueToObject:me};l.resolveConfig(l,f);}for(let f of l.dependencies)p(f);s.delete(a),o.add(a),i[a]=l;};for(let a of t)p(a);return {pluginOrder:Array.from(o),plugins:i}},Zu=e=>typeof e=="string"?e.startsWith("@hey-api/client")||e.startsWith("legacy/"):e.name.startsWith("@hey-api/client")||e.name.startsWith("legacy/")||e.tags&&e.tags.includes("client"),Ec=({dependencies:e,userConfig:t})=>{let r={},s=Pc;t.plugins&&(t.plugins=t.plugins.filter(i=>typeof i=="string"&&i||typeof i!="string"&&i.name),t.plugins.length===1&&Zu(t.plugins[0])?s=[...Pc,...t.plugins]:s=t.plugins);let o=s.map(i=>{if(typeof i=="string")return i;let p=i.name;return p&&(i.handler?r[p]=i:(r[p]={config:{...i}},delete r[p].config.name)),p}).filter(Boolean);return Qu({dependencies:e,userPlugins:o,userPluginsConfig:r})};var Ju=()=>!!(process.stdin.isTTY&&process.stdout.isTTY&&!process.env.CI&&!process.env.NO_INTERACTIVE&&!process.env.NO_INTERACTION),Gu=async({logger:e,userConfigs:t})=>{let r=[],s={},o=e.timeEvent("load");for(let a of t){let c;if(a?.configFile){let y=a.configFile.split(".");c=y.slice(0,y.length-1).join(".");}let m=e.timeEvent("c12"),{config:l,configFile:f}=await c12.loadConfig({configFile:c,name:"openapi-ts"});m.timeEnd(),Object.keys(s).length||(s=ri(Object.keys(l).length?f:void 0));let d=l instanceof Array?l.map(y=>Bs(y,a)):[Bs(l,a)];for(let y of d){let h=Fs(y);if(y.output instanceof Array){let g=h.length,x=y.output.length;if(x>1)if(g!==x){console.warn(`\u2699\uFE0F ${Ht__default.default.yellow("Warning:")} You provided ${Ht__default.default.cyan(String(g))} ${Ht__default.default.cyan(g===1?"input":"inputs")} and ${Ht__default.default.yellow(String(x))} ${Ht__default.default.yellow("outputs")}. This is probably not what you want as it will produce identical output in multiple locations. You most likely want to provide a single output or the same number of outputs as inputs.`);for(let S of y.output)r.push({...y,input:h,output:S});}else y.output.forEach((S,k)=>{r.push({...y,input:h[k],output:S});});else r.push({...y,input:h,output:y.output[0]??""});}else r.push({...y,input:h});}}o.timeEnd();let i=[],p=e.timeEvent("build");for(let a of r){let{base:c,configFile:m="",dryRun:l=false,experimentalParser:f=true,exportCore:d=true,name:y,request:h,useOptions:g=true}=a,x=a.interactive!==void 0?a.interactive:Ju(),S=Yo(a),k=Fs(a),E=ei(a),C=ni(a),j=[];k.length||j.push(new Er("missing input - which OpenAPI specification should we use to generate your output?")),E.path||j.push(new Er("missing output - where should we generate your output?")),g||console.warn("\u2757\uFE0F Deprecation warning: useOptions set to false. This setting will be removed in future versions. Please migrate useOptions to true https://heyapi.dev/openapi-ts/migrating.html#v0-27-38"),E.path=Pt__default.default.resolve(process.cwd(),E.path);let F;try{F=Ec({dependencies:s,userConfig:a});}catch($){j.push($),F={pluginOrder:[],plugins:{}};}let M=Zo({...F,base:c,configFile:m,dryRun:l,experimentalParser:f,exportCore:false,input:k,interactive:x,logs:S,name:y,output:E,parser:C,request:h,useOptions:g});M.exportCore=U(M)?d:false;let v=i.length;if(S.level==="debug"){let $=Ht__default.default.gray(`[Job ${v+1}] `);console.warn(`${$}${Ht__default.default.cyan("config:")}`,M);}i.push({config:M,errors:j,jobIndex:v});}return p.timeEnd(),{dependencies:s,results:i}};var oy=e=>{let t=[];return e.forEach((r,s)=>{t.push([s,r]);}),t},Ls=(...e)=>{let t=new Headers;for(let r of e){if(!r)continue;let s=r instanceof Headers?oy(r):Object.entries(r);for(let[o,i]of s)if(i===null)t.delete(o);else if(Array.isArray(i))for(let p of i)t.append(o,p);else i!==void 0&&t.set(o,typeof i=="object"?JSON.stringify(i):i);}return t};var py=async({fetchOptions:e,inputPath:t,timeout:r,watch:s})=>{let o=jsonSchemaRefParser.getResolvedInput({pathOrUrlOrSchema:t}),i,p,a;if(o.type==="url"){if(s.lastValue&&s.isHeadMethodSupported!==false){try{let c=await jsonSchemaRefParser.sendRequest({fetchOptions:{method:"HEAD",...e,headers:Ls(e?.headers,s.headers)},timeout:r,url:o.path});if(c.response.status>=300)return {error:"not-ok",response:c.response};a=c.response;}catch(c){return {error:"not-ok",response:new Response(c.message)}}if(!a.ok&&s.isHeadMethodSupported)return {error:"not-ok",response:a};if(s.isHeadMethodSupported===void 0&&(s.isHeadMethodSupported=a.ok),a.status===304)return {error:"not-modified",response:a};if(p===void 0){let c=a.headers.get("ETag");c&&(p=c!==s.headers.get("If-None-Match"),p&&s.headers.set("If-None-Match",c));}if(p===void 0){let c=a.headers.get("Last-Modified");c&&(p=c!==s.headers.get("If-Modified-Since"),p&&s.headers.set("If-Modified-Since",c));}if(p===false)return {error:"not-modified",response:a}}try{let c=await jsonSchemaRefParser.sendRequest({fetchOptions:{method:"GET",...e},timeout:r,url:o.path});if(c.response.status>=300)return {error:"not-ok",response:c.response};a=c.response;}catch(c){return {error:"not-ok",response:new Response(c.message)}}if(!a.ok)return {error:"not-ok",response:a};if(i=a.body?await a.arrayBuffer():new ArrayBuffer(0),p===void 0){let c=new TextDecoder().decode(i);p=c!==s.lastValue,s.lastValue=c;}}else s.lastValue?p=false:s.lastValue=o.type;return p===false?{error:"not-modified",response:a}:{arrayBuffer:i,resolvedInput:o}};
24
- exports.getSpec=py;exports.initConfigs=Gu;exports.parseOpenApiSpec=jf;//# sourceMappingURL=internal.cjs.map
25
- //# sourceMappingURL=internal.cjs.map
1
+ const e=require(`./getSpec-_5jk-wUD.cjs`);exports.getSpec=e.getSpec,exports.initConfigs=e.initConfigs,exports.parseOpenApiSpec=e.parseOpenApiSpec;