@hey-api/openapi-ts 0.84.1 → 0.84.2

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.
@@ -0,0 +1,54 @@
1
+ import {createRequire}from'module';import he from'node:fs';import M from'node:path';import Rt from'ansi-colors';import {fileURLToPath}from'node:url';import S from'typescript';import {EOL}from'os';import*as An from'semver';import {Project,createBinding,mergeBindings,renderIds}from'@hey-api/codegen-core';import {loadConfig}from'c12';import {$RefParser,getResolvedInput,sendRequest}from'@hey-api/json-schema-ref-parser';const require = createRequire(import.meta.url);
2
+ var qm=Object.create;var Ii=Object.defineProperty;var $m=Object.getOwnPropertyDescriptor;var Mm=Object.getOwnPropertyNames;var Lm=Object.getPrototypeOf,Vm=Object.prototype.hasOwnProperty;var ki=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,r)=>(typeof require<"u"?require:t)[r]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var ih=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var Dm=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Mm(t))!Vm.call(e,o)&&o!==r&&Ii(e,o,{get:()=>t[o],enumerable:!(n=$m(t,o))||n.enumerable});return e};var ah=(e,t,r)=>(r=e!=null?qm(Lm(e)):{},Dm(t||!e||!e.__esModule?Ii(r,"default",{value:e,enumerable:true}):r,e));var Bm=fileURLToPath(import.meta.url),Oo=M.dirname(Bm),To=()=>{let e=Oo;for(;e!==M.dirname(e);){let r=he.readdirSync(e).filter(n=>n==="package.json");if(r[0]){let n=M.join(e,r[0]);return JSON.parse(he.readFileSync(n,{encoding:"utf8"}))}e=M.dirname(e);}},dh=e=>{if(e==="off")return null;if(e){let r=M.isAbsolute(e)?e:M.resolve(Oo,e);return he.existsSync(r)?r:null}let t=Oo;for(;t!==M.dirname(t);){let n=he.readdirSync(t).filter(o=>o.startsWith("tsconfig")&&o.endsWith(".json")).sort(o=>o==="tsconfig.json"?-1:1);if(n[0])return M.join(t,n[0]);t=M.dirname(t);}return null},uh=e=>{if(!e)return null;let t=S.readConfigFile(e,S.sys.readFile);if(t.error)throw new Error(`Couldn't read tsconfig from path: ${e}`);return S.parseJsonConfigFileContent(t.config,S.sys,M.dirname(e))};var it=e=>{he.existsSync(e)||he.mkdirSync(e,{recursive:true});},gh=e=>{he.existsSync(e)&&he.rmSync(e,{force:true,recursive:true});},rr=({moduleOutput:e,sourceOutput:t})=>{let r=t.split("/");return `${Array.from({length:r.length}).fill("").join("../")||"./"}${e}`};var $t=class extends Error{},nr=class extends Error{args;event;pluginName;constructor({args:t,error:r,event:n,name:o,pluginName:i}){let a=r instanceof Error?r.message:"Unknown error";super(a),this.args=t,this.cause=r.cause,this.event=n,this.name=o||r.name,this.pluginName=i,this.stack=r.stack;}},Ah=(e,t)=>{if(e instanceof $t)return;let r=`openapi-ts-error-${Date.now()}.log`,n=M.resolve(process.cwd(),t);it(n);let o=M.resolve(n,r),i=`[${new Date().toISOString()}] `;e instanceof nr&&(i+=`${e.name} during event "${e.event}"
3
+ `,e.pluginName&&(i+=`Plugin: ${e.pluginName}
4
+ `),i+=`Arguments: ${JSON.stringify(e.args,null,2)}
5
+
6
+ `);let a=e instanceof Error?e.message:String(e),p=e instanceof Error?e.stack:void 0;return i+=`Error: ${a}
7
+ `,p&&(i+=`Stack:
8
+ ${p}
9
+ `),he.writeFileSync(o,i),o},Ph=async e=>{let t="";e instanceof nr&&(e.pluginName&&(t+=`**Plugin**: \`${e.pluginName}\`
10
+ `),t+=`**Event**: \`${e.event}\`
11
+ `,t+=`**Arguments**:
12
+ \`\`\`ts
13
+ ${JSON.stringify(e.args,null,2)}
14
+ \`\`\`
15
+
16
+ `);let r=e instanceof Error?e.message:String(e),n=e instanceof Error?e.stack:void 0;t+=`**Error**: \`${r}\`
17
+ `,n&&(t+=`
18
+ **Stack Trace**:
19
+ \`\`\`
20
+ ${n}
21
+ \`\`\``);let o=new URLSearchParams({body:t,labels:"bug \u{1F525}",title:"Crash Report"}),i=To(),a;if(i&&typeof i=="object"&&"bugs"in i&&i.bugs&&typeof i.bugs=="object"&&"url"in i.bugs&&typeof i.bugs.url=="string"&&(a=i.bugs.url,a&&!a.endsWith("/")&&(a+="/")),a){let p=`${a}new?${o.toString()}`,c=(await import('open')).default;await c(p);}},Eh=({error:e,logPath:t})=>{let r=To(),n;r&&typeof r=="object"&&"name"in r&&typeof r.name=="string"&&(n=r.name),process.stderr.write(`
22
+ \u{1F6D1} ${Rt.cyan(n||"")} ${Rt.red("encountered an error.")}
23
+
24
+ ${Rt.red("\u2757\uFE0F Error:")} ${Rt.white(typeof e=="string"?e:e instanceof Error?e.message:"Unknown error")}`+(t?`
25
+
26
+ ${Rt.cyan("\u{1F4C4} Crash log saved to:")} ${Rt.gray(t)}`:"")+`
27
+ `);},Ih=async({error:e,isInteractive:t})=>!t||e instanceof $t?false:new Promise(r=>{process.stdout.write(`${Rt.yellow(`
28
+ \u{1F4E2} Open a GitHub issue with crash details?`)} ${Rt.yellow("(y/N):")}`),process.stdin.setEncoding("utf8"),process.stdin.once("data",n=>{r(n.trim().toLowerCase()==="y");});});var Ni=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 Wm=e=>typeof e=="object"&&e!==null&&!Array.isArray(e)&&typeof e!="function",sr=(e,t)=>{for(let[r,n]of Object.entries(t))n!==void 0&&n!==""&&(e[r]=n);return e},xe=({defaultValue:e,mappers:t,value:r})=>{let n={...e};switch(typeof r){case "boolean":if(t&&"boolean"in t){let o=t.boolean;n=sr(n,o(r));}break;case "function":if(t&&"function"in t){let o=t.function;n=sr(n,o(r));}break;case "number":if(t&&"number"in t){let o=t.number;n=sr(n,o(r));}break;case "string":if(t&&"string"in t){let o=t.string;n=sr(n,o(r));}break;case "object":if(Wm(r))if(t&&"object"in t&&typeof t.object=="function"){let o=t.object;n=sr(n,o(r,e));}else n=sr(n,r);break}return n};var zm=["after","before","cursor","offset","page","start"],Ci=e=>xe({defaultValue:{hooks:{},pagination:{keywords:zm},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,n)=>({...r,pagination:xe({defaultValue:{...n.pagination},value:r.pagination}),transforms:xe({defaultValue:{...n.transforms},mappers:{object:(o,i)=>({...o,enums:xe({defaultValue:{...i.enums,enabled:o.enums!==void 0?!!o.enums:i.enums.enabled},mappers:{boolean:a=>({enabled:a}),string:a=>({mode:a})},value:o.enums}),propertiesRequiredByDefault:o.propertiesRequiredByDefault!==void 0?o.propertiesRequiredByDefault:i.propertiesRequiredByDefault,readWrite:xe({defaultValue:{...i.readWrite,enabled:o.readWrite!==void 0?!!o.readWrite:i.readWrite.enabled},mappers:{boolean:a=>({enabled:a}),object:(a,p)=>({...a,requests:xe({defaultValue:{...p.requests},mappers:{function:c=>({name:c}),string:c=>({name:c})},value:a.requests}),responses:xe({defaultValue:{...p.responses},mappers:{function:c=>({name:c}),string:c=>({name:c})},value:a.responses})})},value:o.readWrite})})},value:r.transforms}),validate_EXPERIMENTAL:r.validate_EXPERIMENTAL===true?"warn":r.validate_EXPERIMENTAL})},value:e.parser});var R=e=>t=>({...e,config:{...e.config,...t}}),Ve={boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})};var or=/^[^$_\p{ID_Start}]+/u,te=/^-?\d+(\.\d+)?$/,vi=/^(document|history|location|navigator|window)$/g,wi=/^(console|Array|Date|Error|Function|JSON|Map|Math|Object|Promise|RegExp|Set|WeakMap|WeakSet)$/g,fe=/^(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,qi=/^(global|process|Buffer)$/g,$i=/^(any|as|bigint|boolean|namespace|never|null|number|string|symbol|type|undefined|unknown|void)$/g,Ne=/^[$_\p{ID_Start}][$\u200c\u200d\p{ID_Continue}]*$/u;var Te=e=>(e||e==="")&&(Ne.lastIndex=0,!Ne.test(e))?`'${e}'`:e,ir=e=>e&&e.startsWith("'")&&e.endsWith("'")?e.slice(1,e.length-1):e,z=e=>e.replace(/\*\//g,"*").replace(/\/\*/g,"*").replace(/\r?\n(.*)/g,(t,r)=>EOL+r.trim());var de=e=>{let t=I(e);return t.name==="@hey-api/client-axios"||t.name==="@hey-api/client-nuxt"?"baseURL":"baseUrl"},I=e=>{for(let t of e.pluginOrder){let r=e.plugins[t];if(r?.tags?.includes("client"))return r}return {config:{name:""},name:""}};var Mi,A=()=>{let e=Mi,t=I(e);return e.client=t,e},Li=e=>(Mi=e,A()),Q=e=>I(e).name.startsWith("legacy/"),Mt=e=>{if(Q(e))return e.name};var Hm=S.createPrinter({newLine:S.NewLineKind.LineFeed,removeComments:false}),Qm=e=>S.createSourceFile("",e,S.ScriptTarget.ESNext,false,S.ScriptKind.TS),Zm=Qm(""),Um=e=>e.replace(/\\u([0-9a-fA-F]{4})/g,(t,r)=>String.fromCharCode(Number.parseInt(r,16)));function me({node:e,unescape:t=false}){let r=Hm.printNode(S.EmitHint.Unspecified,e,Zm);if(!t)return r;try{return Um(r)}catch{return A().logs.level==="debug"&&console.warn("Could not decode value:",r),r}}var E=({text:e})=>S.factory.createIdentifier(e),Vi=()=>S.factory.createThis(),G=({keyword:e})=>{let t=Ro({keyword:e});return S.factory.createModifier(t)},Di=({initializer:e,modifier:t,name:r,type:n})=>S.factory.createPropertyDeclaration(t?[G({keyword:t})]:void 0,r,void 0,n,e),be={boolean:e=>e?S.factory.createTrue():S.factory.createFalse(),export:({alias:e,asType:t=false,name:r})=>{let n=E({text:r});if(e){let o=E({text:e});return S.factory.createExportSpecifier(t,n,o)}return S.factory.createExportSpecifier(t,void 0,n)},import:({alias:e,asType:t=false,name:r})=>{let n=E({text:r});if(e){let o=E({text:e});return S.factory.createImportSpecifier(t,n,o)}return S.factory.createImportSpecifier(t,void 0,n)},number:e=>e<0?S.factory.createPrefixUnaryExpression(S.SyntaxKind.MinusToken,S.factory.createNumericLiteral(Math.abs(e))):S.factory.createNumericLiteral(e),string:(e,t=false)=>{let r=e;t&&(r=ir(r));let n=r.includes("'")&&r.includes('"'),o=r.includes(`
29
+ `),i=r.startsWith("`"),a=r.startsWith("\\`")&&r.endsWith("\\`");return (o||n||i)&&!a&&(r=`\`${r.replace(/(?<!\\)`/g,"\\`").replace(/\${/g,"\\${")}\``),r.startsWith("`")?E({text:r}):Vt({text:r})}},Lt=e=>e!==null&&typeof e=="object"&&typeof e.kind=="number"&&typeof e.flags=="number"&&typeof e.pos=="number"&&typeof e.end=="number",At=e=>e!==void 0,Xm=({commentObject:e,node:t})=>{let r=e.lines.filter(a=>!!a||a==="");if(!r.length)return;if(!e.jsdoc){for(let a of r)S.addSyntheticLeadingComment(t,S.SyntaxKind.SingleLineCommentTrivia,` ${a}`,true);return}let n=r.map((a,p)=>{let c=a;return p!==r.length&&(c=`${c}
30
+ `),S.factory.createJSDocText(c)}),o=S.factory.createJSDocComment(S.factory.createNodeArray(n),void 0),i=me({node:o,unescape:true}).replace("/*","").replace("* */","");S.addSyntheticLeadingComment(t,S.SyntaxKind.MultiLineCommentTrivia,i,true);},oe=({comments:e=[],node:t})=>{let r=!!e.find(o=>typeof o=="object"&&o),n=e;r||(n=[{jsdoc:true,lines:e}]);for(let o of n)Xm({commentObject:o,node:t});};var ie=(e,t)=>S.isTypeNode(e)?e:typeof e=="number"?S.factory.createLiteralTypeNode(be.number(e)):Re({typeArguments:t?.map(r=>ie(r)),typeName:S.isIdentifier(e)?e.text:e}),Ao=({expression:e,name:t})=>S.factory.createPropertyAccessChain(e,S.factory.createToken(S.SyntaxKind.QuestionDotToken),t),Fe=({expression:e,isOptional:t,name:r})=>{let n=typeof e=="string"?E({text:e}):e;if(t&&typeof r!="number")return Ao({expression:n,name:r});if(typeof r=="string"){if(Ne.lastIndex=0,!Ne.test(r)){!r.startsWith("'")&&!r.endsWith("'")&&(r=`'${r}'`);let i=E({text:r});return S.factory.createElementAccessExpression(n,i)}let o=E({text:r});return S.factory.createPropertyAccessExpression(n,o)}if(typeof r=="number"){let o=S.factory.createNumericLiteral(r);return S.factory.createElementAccessExpression(n,o)}return S.factory.createPropertyAccessExpression(n,r)},Po=()=>S.factory.createNull(),De=({identifiers:e=[],isValueAccess:t,shorthand:r,unescape:n,value:o})=>{if(o===null)return Po();if(Array.isArray(o))return Eo({elements:o});if(typeof o=="object")return Sn({identifiers:e,obj:o,shorthand:r});if(typeof o=="number")return be.number(o);if(typeof o=="boolean")return be.boolean(o);if(typeof o=="string"){if(t){let i=o.split(".");return Fe({expression:i[0],name:i[1]})}return be.string(o,n)}},Dr=e=>e.map(t=>{if("destructure"in t)return ar({name:S.factory.createObjectBindingPattern(t.destructure.map(n=>"destructure"in n?void 0:S.factory.createBindingElement(void 0,void 0,E({text:n.name}),void 0)).filter(Boolean)),type:t.type!==void 0?ie(t.type):void 0});let r=t.accessLevel?[G({keyword:t.accessLevel})]:[];return t.isReadOnly&&r.push(G({keyword:"readonly"})),ar({initializer:t.default!==void 0?De({value:t.default}):void 0,modifiers:r,name:E({text:t.name}),required:t.isRequired!==false,type:t.type!==void 0?ie(t.type):void 0})}),Ro=({keyword:e})=>{switch(e){case "any":return S.SyntaxKind.AnyKeyword;case "async":return S.SyntaxKind.AsyncKeyword;case "boolean":return S.SyntaxKind.BooleanKeyword;case "export":return S.SyntaxKind.ExportKeyword;case "never":return S.SyntaxKind.NeverKeyword;case "number":return S.SyntaxKind.NumberKeyword;case "private":return S.SyntaxKind.PrivateKeyword;case "protected":return S.SyntaxKind.ProtectedKeyword;case "public":return S.SyntaxKind.PublicKeyword;case "readonly":return S.SyntaxKind.ReadonlyKeyword;case "static":return S.SyntaxKind.StaticKeyword;case "string":return S.SyntaxKind.StringKeyword;case "undefined":return S.SyntaxKind.UndefinedKeyword;case "unknown":return S.SyntaxKind.UnknownKeyword;case "void":return S.SyntaxKind.VoidKeyword;default:throw new Error(`unsupported syntax kind keyword "${e}"`)}},Dt=({keyword:e})=>{let t=Ro({keyword:e});return S.factory.createKeywordTypeNode(t)},Fr=e=>e.map(t=>S.isTypeParameterDeclaration(t)?t:Br({constraint:t.extends?typeof t.extends=="string"?Dt({keyword:"boolean"}):t.extends:void 0,defaultType:t.default!==void 0?Lt(t.default)?t.default:S.factory.createLiteralTypeNode(t.default?S.factory.createTrue():S.factory.createFalse()):void 0,name:t.name})),Fi=({operator:e,type:t})=>{let r=e==="keyof"?S.SyntaxKind.KeyOfKeyword:e==="readonly"?S.SyntaxKind.ReadonlyKeyword:S.SyntaxKind.UniqueKeyword;return S.factory.createTypeOperatorNode(r,t)},Br=({constraint:e,defaultType:t,modifiers:r,name:n})=>S.factory.createTypeParameterDeclaration(r,n,e,t),xn=({members:e,nameType:t,questionToken:r,readonlyToken:n,type:o,typeParameter:i})=>S.factory.createMappedTypeNode(n,i,t,r,o,e),Bi=({literal:e})=>S.factory.createLiteralTypeNode(e),bn=({async:e,comment:t,multiLine:r,parameters:n=[],returnType:o,statements:i=[],types:a=[]})=>{let p=S.factory.createArrowFunction(e?[G({keyword:"async"})]:void 0,a?Fr(a):void 0,Dr(n),o?ie(o):void 0,void 0,Array.isArray(i)?Se({multiLine:r,statements:i}):i);return oe({comments:t,node:p}),p},Ki=({async:e,comment:t,multiLine:r,parameters:n=[],returnType:o,statements:i=[],types:a=[]})=>{let p=S.factory.createFunctionExpression(e?[G({keyword:"async"})]:void 0,void 0,void 0,a?Fr(a):void 0,Dr(n),o?ie(o):void 0,Se({multiLine:r,statements:i}));return oe({comments:t,node:p}),p},Eo=({elements:e,multiLine:t=false})=>S.factory.createArrayLiteralExpression(e.map(n=>Lt(n)?n:De({value:n})).filter(At),t||!Array.isArray(e[0])&&typeof e[0]=="object"),Wi=({expression:e})=>S.factory.createAwaitExpression(e),zi=({parameters:e=[],returnType:t,typeParameters:r})=>S.factory.createFunctionTypeNode(r,e,t),Sn=({comments:e,identifiers:t=[],multiLine:r=true,obj:n,shorthand:o,unescape:i=false})=>{let a=Array.isArray(n)?n.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=Lt(c.spread)?c.spread:E({text:c.spread});l=S.factory.createSpreadAssignment(c.assertion?Wr({expression:f,type:typeof c.assertion=="string"?Dt({keyword:c.assertion}):c.assertion}):f);}else if(c.shorthand||o&&m)l=S.factory.createShorthandPropertyAssignment(c.value);else {let f=Lt(c.value)?c.value:Array.isArray(c.value)&&(!c.value.length||typeof c.value[0]=="object")?Sn({multiLine:r,obj:c.value,shorthand:o,unescape:i}):De({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)&&!S.isObjectLiteralExpression(f)&&(f=E({text:c.value})),l=gn({initializer:f,name:c.key});}return oe({comments:c.comments,node:l}),l}).filter(At):Object.entries(n).map(([c,m])=>{let l=De({identifiers:t.includes(c)?Object.keys(m):[],shorthand:o,unescape:i,value:m});if(!l)return;t.includes(c)&&!S.isObjectLiteralExpression(l)&&(l=E({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?S.factory.createShorthandPropertyAssignment(m):gn({initializer:l,name:c})}).filter(At),p=S.factory.createObjectLiteralExpression(a,r);return oe({comments:e,node:p}),p},_i=({asConst:e,comments:t={},leadingComment:r,name:n,obj:o})=>{let i=Array.isArray(o)?o.map(l=>{let f=Jm({initializer:De({value:l.value}),name:l.key});return oe({comments:l.comments,node:f}),f}):Object.entries(o).map(([l,f])=>{let d=S.factory.createEnumMember(l,De({unescape:true,value:f}));return oe({comments:t[l],node:d}),d}),a=[G({keyword:"export"})],p=e?[S.factory.createToken(S.SyntaxKind.ConstKeyword)]:[],c=[...a,...p],m=S.factory.createEnumDeclaration(c,typeof n=="string"?E({text:n}):n,i);return oe({comments:r,node:m}),m},Jm=({initializer:e,name:t})=>{let r=t;return typeof r=="string"&&(r.includes("'")?r=Vt({isSingleQuote:false,text:r}):r=Te(r)),S.factory.createEnumMember(r,e)},Hi=({name:e,statements:t})=>S.factory.createModuleDeclaration([G({keyword:"export"})],E({text:e}),S.factory.createModuleBlock(t),S.NodeFlags.Namespace),Qi=({indexType:e,objectType:t})=>S.factory.createIndexedAccessTypeNode(t,e),Zi=({name:e,returnType:t,statements:r})=>S.factory.createGetAccessorDeclaration(void 0,e,[],t?Re({typeName:t}):void 0,Se({statements:r})),Vt=({isSingleQuote:e,text:t})=>(e===void 0&&(e=!t.includes("'")),S.factory.createStringLiteral(t,e)),Ui=({condition:e,whenFalse:t,whenTrue:r})=>S.factory.createConditionalExpression(e,S.factory.createToken(S.SyntaxKind.QuestionToken),r,S.factory.createToken(S.SyntaxKind.ColonToken),t),Xi=({text:e})=>S.factory.createTypeOfExpression(typeof e=="string"?E({text:e}):e),Gi=({comment:e,exportType:t,name:r,type:n,typeParameters:o=[]})=>{let i=S.factory.createTypeAliasDeclaration(t?[G({keyword:"export"})]:void 0,typeof r=="string"?E({text:r}):r,Fr(o),ie(n));return oe({comments:e,node:i}),i},Re=({typeArguments:e,typeName:t})=>S.factory.createTypeReferenceNode(t,e),Ji=({type:e})=>S.factory.createParenthesizedType(e),ar=({initializer:e,modifiers:t,name:r,required:n=true,type:o})=>S.factory.createParameterDeclaration(t,void 0,r,n?void 0:S.factory.createToken(S.SyntaxKind.QuestionToken),o,e),Kr=({argumentsArray:e,expression:t,typeArguments:r})=>S.factory.createNewExpression(t,r,e),Yi=({awaitModifier:e,expression:t,initializer:r,statement:n})=>S.factory.createForOfStatement(e,r,t,n),ea=({left:e,right:t})=>S.factory.createAssignment(e,t),Se=({multiLine:e=true,statements:t})=>S.factory.createBlock(t,e),gn=({initializer:e,name:t})=>S.factory.createPropertyAssignment(t,e),ta=({flags:e=[],text:t})=>{let r=t.startsWith("/")&&t.endsWith("/")?t:`/${t}/`;return S.factory.createRegularExpressionLiteral(`${r}${e.join("")}`)},Wr=({expression:e,type:t})=>S.factory.createAsExpression(e,t),ra=({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?S.factory.createTemplateMiddle(r):S.factory.createTemplateTail(r),a=S.factory.createTemplateLiteralTypeSpan(o,i);t.push(a),r="";}return S.factory.createTemplateLiteralType(S.factory.createTemplateHead(r),t.reverse())};var na=({module:e,shouldAppendJs:t})=>S.factory.createExportDeclaration(void 0,false,void 0,be.string(t?`${e}.js`:e)),Be=({functionName:e,parameters:t=[],types:r})=>{let n=typeof e=="string"?E({text:e}):e,o=t.filter(a=>a!==void 0).map(a=>typeof a=="string"?E({text:a}):a);return S.factory.createCallExpression(n,r,o)},sa=({exports:e,module:t})=>{let r=Array.isArray(e)?e:[e],n=r.some(c=>typeof c!="object"||!c.asType),o=r.map(c=>{let m=typeof c=="string"?{name:c}:c;return be.export({alias:m.alias,asType:n&&m.asType,name:m.name})}),i=S.factory.createNamedExports(o),a=be.string(t);return S.factory.createExportDeclaration(void 0,!n,i,a)},oa=({assertion:e,comment:t,destructure:r,exportConst:n,expression:o,name:i,typeName:a})=>{let p=e?Wr({expression:o,type:typeof e=="string"?Re({typeName:e}):e}):o,c=typeof i=="string"?E({text:i}):i,m=S.factory.createVariableDeclaration(r?S.factory.createObjectBindingPattern([S.factory.createBindingElement(void 0,void 0,c,void 0)]):c,void 0,a?typeof a=="string"?Re({typeName:a}):a:void 0,p),l=S.factory.createVariableStatement(n?[G({keyword:"export"})]:void 0,S.factory.createVariableDeclarationList([m],S.NodeFlags.Const));return oe({comments:t,node:l}),l},ia=({imports:e,module:t})=>{let r=Array.isArray(e)?e:[e],n=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(be.import({alias:f.alias,asType:n&&f.asType,name:f.name}));});let a=o?S.factory.createNamespaceImport(E({text:o.alias})):S.factory.createNamedImports(i),p=S.factory.createImportClause(!n,void 0,a),c=be.string(t);return S.factory.createImportDeclaration(void 0,p,c)};var aa=({accessLevel:e,comment:t,multiLine:r=true,parameters:n=[],statements:o=[]})=>{let i=e?[G({keyword:e})]:void 0,a=S.factory.createConstructorDeclaration(i,Dr(n),Se({multiLine:r,statements:o}));return oe({comments:t,node:a}),a},pa=({accessLevel:e,comment:t,isStatic:r=false,multiLine:n=true,name:o,parameters:i=[],returnType:a,statements:p=[],types:c=[]})=>{let m=e?[G({keyword:e})]:[];r&&m.push(G({keyword:"static"}));let l=S.factory.createMethodDeclaration(m,void 0,E({text:o}),void 0,c?Fr(c):void 0,Dr(i),a?ie(a):void 0,Se({multiLine:n,statements:p}));return oe({comments:t,node:l}),l},ca=({decorator:e,exportClass:t,extendedClasses:r,name:n,nodes:o})=>{let i=[];t&&i.push(G({keyword:"export"})),e&&i.unshift(S.factory.createDecorator(Be({functionName:e.name,parameters:e.args.map(p=>De({value:p})).filter(At)})));let a=[];if(r)for(let p of r)a.push(S.factory.createHeritageClause(S.SyntaxKind.ExtendsKeyword,[S.factory.createExpressionWithTypeArguments(E({text:p}),void 0)]));return S.factory.createClassDeclaration(i,E({text:n}),void 0,a,o)};var Bt=({expression:e})=>S.factory.createExpressionStatement(e);var On=({expression:e})=>S.factory.createReturnStatement(e),la=({args:e=[],name:t,types:r=[]})=>{let n=r.map(p=>Re({typeName:p})),o=e.map(p=>S.isExpression(p)?p:E({text:p})).filter(At),i=Be({functionName:t,parameters:o,types:n});return On({expression:i})},fa=({expression:e})=>On({expression:typeof e=="string"?E({text:e}):e});var pr=e=>e.slice(1).reduce((t,r)=>(Ne.lastIndex=0,Ne.test(r)?Ao({expression:t,name:r}):S.factory.createElementAccessChain(t,S.factory.createToken(S.SyntaxKind.QuestionDotToken),E({text:r}))),E({text:e[0]})),Tn=e=>e.slice(1).reduce((t,r)=>Fe({expression:t,name:r}),E({text:e[0]})),da=({expressions:e})=>e.reduce((r,n)=>Fe({expression:r,name:n})),Rn=({left:e,operator:t="=",right:r})=>S.factory.createBinaryExpression(e,t==="="?S.SyntaxKind.EqualsToken:t==="==="?S.SyntaxKind.EqualsEqualsEqualsToken:t==="??"?S.SyntaxKind.QuestionQuestionToken:S.SyntaxKind.InKeyword,typeof r=="string"?E({text:r}):r),cr=({elseStatement:e,expression:t,thenStatement:r})=>S.factory.createIfStatement(t,r,e),ua=({path:e})=>{let t=pr(e),r=Tn(e),n=Se({statements:[Bt({expression:Rn({left:r,right:Kr({argumentsArray:[r],expression:E({text:"Date"})})})})]});return cr({expression:t,thenStatement:n})},ya=({path:e,transformerName:t})=>{let r=pr(e),n=Tn(e),o=Se({statements:[Bt({expression:Be({functionName:t,parameters:[n]})})]});return [cr({expression:r,thenStatement:o})]},ha=({path:e,transformerName:t})=>{let r=pr(e),n=Tn(e);return cr({expression:Be({functionName:Fe({expression:"Array",name:"isArray"}),parameters:[r]}),thenStatement:Se({statements:[Bt({expression:S.factory.createCallChain(Fe({expression:n,name:"forEach"}),void 0,void 0,[E({text:t})])})]})})},ga=({parameterName:e})=>{let t=E({text:"Date"});return Kr({argumentsArray:[E({text:e})],expression:t})},xa=({path:e,transformExpression:t})=>{let r=pr(e),n=Tn(e);return cr({expression:Be({functionName:Fe({expression:"Array",name:"isArray"}),parameters:[r]}),thenStatement:Se({statements:[Bt({expression:Rn({left:n,right:S.factory.createCallChain(Fe({expression:n,name:"map"}),void 0,void 0,[bn({parameters:[{name:"item"}],statements:t})])})})]})})};var il=Re({typeName:"null"}),mr=({isNullable:e,node:t})=>e?S.factory.createUnionTypeNode([t,il]):t,Io=({indexKey:e,indexProperty:t,isNullable:r,properties:n,useLegacyResolution:o})=>{let a=n.map(m=>{let l=m.isReadOnly?[G({keyword:"readonly"})]:void 0,f=m.isRequired!==false?void 0:S.factory.createToken(S.SyntaxKind.QuestionToken),d=ie(m.type);let u=S.factory.createPropertySignature(l,o||typeof m.name=="string"&&m.name.match(Ne)||typeof m.name!="string"&&S.isPropertyName(m.name)?m.name:Vt({text:m.name}),f,d);return oe({comments:m.comment,node:u}),u}),p=false;if(t)if(!n.length&&e){let m=xn({questionToken:S.factory.createToken(S.SyntaxKind.QuestionToken),type:t.type??Dt({keyword:"string"}),typeParameter:Br({constraint:e,name:E({text:String(t.name)})})});a.push(m),p=true;}else {let m=t.isReadOnly?[G({keyword:"readonly"})]:void 0,l=S.factory.createIndexSignature(m,[ar({name:E({text:String(t.name)}),type:Dt({keyword:"string"})})],ie(t.type));a.push(l);}let c=p?a[0]:S.factory.createTypeLiteralNode(a);return mr({isNullable:r,node:c})},zr=({isNullable:e,types:t})=>{let r=[];for(let o of t){let i=ie(o);S.isUnionTypeNode(i)?r.push(...i.types):r.push(i);}let n=S.factory.createUnionTypeNode(r);return mr({isNullable:e,node:n})},ba=({isNullable:e,types:t})=>{let r=[];for(let o of t){let i=ie(o);S.isIntersectionTypeNode(i)?r.push(...i.types):r.push(i);}let n=S.factory.createIntersectionTypeNode(r);return mr({isNullable:e,node:n})},Sa=({isNullable:e=false,types:t})=>{let r=t.map(o=>ie(o)),n=S.factory.createTupleTypeNode(r);return mr({isNullable:e,node:n})},Oa=(e,t,r=false,n=true)=>{let o=zr({types:e}),i=zr({types:t}),a=Io({properties:[{name:`[key: ${me({node:o,unescape:true})}]`,type:i}],useLegacyResolution:n});return mr({isNullable:r,node:a})},Ta=(e,t=false)=>{let r=Re({typeArguments:[Array.isArray(e)?zr({types:e}):e],typeName:"Array"});return mr({isNullable:t,node:r})};var s={anonymousFunction:Ki,arrayLiteralExpression:Eo,arrowFunction:bn,asExpression:Wr,assignment:ea,awaitExpression:Wi,binaryExpression:Rn,block:Se,callExpression:Be,classDeclaration:ca,conditionalExpression:Ui,constVariable:oa,constructorDeclaration:aa,enumDeclaration:_i,exportAllDeclaration:na,exportNamedDeclaration:sa,expressionToStatement:Bt,forOfStatement:Yi,functionTypeNode:zi,getAccessorDeclaration:Zi,identifier:E,ifStatement:cr,indexedAccessTypeNode:Qi,isTsNode:Lt,keywordTypeNode:Dt,literalTypeNode:Bi,mappedTypeNode:xn,methodDeclaration:pa,namedImportDeclarations:ia,namespaceDeclaration:Hi,newExpression:Kr,nodeToString:me,null:Po,objectExpression:Sn,ots:be,parameterDeclaration:ar,propertyAccessExpression:Fe,propertyAccessExpressions:da,propertyAssignment:gn,propertyDeclaration:Di,regularExpressionLiteral:ta,returnFunctionCall:la,returnStatement:On,returnVariable:fa,safeAccessExpression:pr,stringLiteral:Vt,templateLiteralType:ra,this:Vi,transformArrayMap:xa,transformArrayMutation:ha,transformDateMutation:ua,transformFunctionMutation:ya,transformNewDate:ga,typeAliasDeclaration:Gi,typeArrayNode:Ta,typeInterfaceNode:Io,typeIntersectionNode:ba,typeNode:ie,typeOfExpression:Xi,typeOperatorNode:Fi,typeParameterDeclaration:Br,typeParenthesizedNode:Ji,typeRecordNode:Oa,typeReferenceNode:Re,typeTupleNode:Sa,typeUnionNode:zr,valueToExpression:De},gg=s;var Kt=(...e)=>An.satisfies(...e),Pn=e=>({getVersion:t=>{let r=e[t];try{if(r)return An.parse(r)||void 0}catch{}},isInstalled:t=>!!e[t],satisfies:(t,r,n)=>{let o=typeof t=="string"?e[t]:t;return o?Kt(o,r,n):false}});var pl=[fe,$i,wi,qi,vi],Wt=e=>{let t=e.replace(/[^$\u200c\u200d\p{ID_Continue}]/gu,"_");if(or.lastIndex=0,or.test(t))return `_${t}`;for(let r of pl){if(t.startsWith("_"))return t;t=t.replace(r,"_$1");}return t};var ll=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"]),En=class{addBinding({bindings:t,file:r,meta:n,project:o,symbol:i}){if(!i.external&&!o.symbols.hasValue(i.id))return;let[a]=o.symbolIdToFiles(i.id);if(!a)return;let p=this.getBindingPath(r,a,n),c=t.get(p),m=createBinding({file:r,modulePath:p,symbol:i,symbolFile:a});c?(mergeBindings(c,m),t.set(p,c)):t.set(p,m);}getBindingPath(t,r,n){if(!t.path||!r.path)return "";if(r.external&&!M.isAbsolute(r.path))return r.path;let o=M.posix.relative(M.posix.dirname(t.path.split(M.sep).join(M.posix.sep)),r.path.split(M.sep).join(M.posix.sep));return !o.startsWith(".")&&o!==""&&(o=`./${o}`),r.extension===".ts"&&(o.endsWith(r.extension)&&(o=o.slice(0,-r.extension.length)),n?.moduleResolution===S.ModuleResolutionKind.NodeNext?o+=".js":o.endsWith("/index")&&(o=o.slice(0,-6))),o}getBodyLines(t,r){let n=[];for(let o of t.symbols.body){let i=r.symbols.getValue(o);if(typeof i=="string")n.push(i);else if(i instanceof Array)for(let a of i)n.push(me({node:a,unescape:true}));else i!=null&&n.push(me({node:i,unescape:true}));}return n}getExportLines(t,r,n){let o=[];for(let[i,a]of t.entries()){let p=[],c,m=false;if(a.namespaceBinding!==void 0)typeof a.namespaceBinding=="string"&&(c=renderIds(a.namespaceBinding,d=>{let u=n.symbols.get(d);return this.replacerFn({file:r,project:n,symbol:u})})),a.typeNamespaceBinding&&(m=true);else if(a.names&&a.names.length>0){a.names.every(d=>(a.typeNames??[]).includes(d))&&(m=true);for(let d of a.names){let u=a.aliases?.[d],h=d,g;u&&u!==h&&(g=h,h=u),h=renderIds(h,b=>{let j=n.symbols.get(b),k=this.replacerFn({file:r,project:n,symbol:j}),[P]=n.symbolIdToFiles(b),C=P?P.resolvedNames.get(b):void 0;return C&&C!==k&&(g||(g=C)),k}),g&&(g=renderIds(g,b=>{let j=n.symbols.get(b);return this.replacerFn({file:r,project:n,symbol:j})}),g===h&&(g=void 0));let x=S.factory.createExportSpecifier(m?false:a.typeNames?.includes(d)??false,g?s.identifier({text:g}):void 0,s.identifier({text:h}));p.push(x);}}let l=c?S.factory.createNamespaceExport(s.identifier({text:c})):p.length?S.factory.createNamedExports(p):void 0,f=S.factory.createExportDeclaration(void 0,m,l,s.stringLiteral({isSingleQuote:true,text:i}));o.push(me({node:f,unescape:true}));}return o}getHeaderLines(){return ["// This file is auto-generated by @hey-api/openapi-ts"]}getImportLines(t,r,n){let o=[],i=-1,a=c=>{let m=c.from;return m.startsWith(".")?m.startsWith("./")?[2,0,m]:[2,m.match(/\.\.\//g)?.length??0,m]:ll.has(m.split("/")[0])?[0,0,m]:[1,0,m]},p=Array.from(t.values()).map(c=>({...c,k:a(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 p){let m=[],l,f,d=false;if(c.defaultBinding){let g=renderIds(c.defaultBinding,x=>{let b=n.symbols.get(x);return this.replacerFn({file:r,project:n,symbol:b})});l=s.identifier({text:g}),c.typeDefaultBinding&&(d=true);}else if(typeof c.namespaceBinding=="string")f=renderIds(c.namespaceBinding,g=>{let x=n.symbols.get(g);return this.replacerFn({file:r,project:n,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 b=c.aliases?.[x],j=x,k;b&&b!==j&&(k=j,j=b),j=renderIds(j,P=>{let C=n.symbols.get(P),V=this.replacerFn({file:r,project:n,symbol:C}),[D]=n.symbolIdToFiles(P),q=D?D.resolvedNames.get(P):void 0;return q&&q!==V&&(k||(k=q)),V}),k&&(k=renderIds(k,P=>{let C=n.symbols.get(P);return this.replacerFn({file:r,project:n,symbol:C})}),k===j&&(k=void 0)),g.push({isTypeOnly:d?false:c.typeNames?.includes(x)??false,name:j,propertyName:k?s.identifier({text:k}):void 0});}m=g.sort((x,b)=>x.name.localeCompare(b.name)).map(({isTypeOnly:x,name:b,propertyName:j})=>S.factory.createImportSpecifier(x,j,s.identifier({text:b})));}let u=S.factory.createImportClause(d,l,f?S.factory.createNamespaceImport(s.identifier({text:f})):m.length?S.factory.createNamedImports(m):void 0),h=S.factory.createImportDeclaration(void 0,u,s.stringLiteral({isSingleQuote:true,text:c.from}));i!==-1&&c.k[0]!==i&&o.push(""),o.push(me({node:h,unescape:true})),i=c.k[0];}return o}getUniqueName(t,r){let n=2,o=t;for(;r.hasValue(o);)o=`${t}${n}`,n+=1;return o}renderFile(t,r,n,o){let i=new Map;if(t=renderIds(t,m=>{let l=n.symbols.get(m),f=this.replacerFn({file:r,project:n,symbol:l});return l&&this.addBinding({bindings:i,file:r,meta:o,project:n,symbol:l}),f}),!t.length)return "";let a="",p=this.getHeaderLines();a+=`${p.join(`
31
+ `)}${p.length?`
32
+
33
+ `:""}`;let c=this.getImportLines(i,r,n);return a+=`${c.join(`
34
+ `)}${c.length?`
35
+
36
+ `:""}`,`${a}${t}`}renderSymbols(t,r,n){let o=new Map,i="",a=this.getBodyLines(t,r);i+=`${a.join(`
37
+
38
+ `)}${a.length?`
39
+ `:""}`,i=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:n,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 p=this.getExportLines(o,t,r);return i+=`${p.join(`
40
+ `)}${p.length?`
41
+ `:""}`,i}replacerFn({file:t,project:r,symbol:n}){if(!n)return;let o=t.resolvedNames.get(n.id);if(o)return o;if(!n.name)return;let[i]=r.symbolIdToFiles(n.id),a=i?.resolvedNames.get(n.id),p=Wt(a??n.name);return t.resolvedNames.hasValue(p)&&(p=this.getUniqueName(p,t.resolvedNames)),t.resolvedNames.set(n.id,p),p}};var Ra=/[\p{Lu}]/u,ko=/[\p{Ll}]/u,Pa=/([\p{Alpha}\p{N}_]|$)/u,lr=/[_.\- `\\[\]{}\\/]+/,fl=new RegExp(`^${lr.source}`),jo=new RegExp(`${lr.source}${Pa.source}`,"gu"),Aa=new RegExp(`\\d+${Pa.source}`,"gu"),dl=({case:e,string:t})=>{let r=false,n=false,o=false,i=false,a=e==="snake_case"||e==="SCREAMING_SNAKE_CASE"?"_":"-";for(let p=0;p<t.length;p++){let c=t[p];i=p>2?t[p-3]===a:true;let m=p+1,l=t[m];for(lr.lastIndex=0;l&&lr.test(l);)m+=1,l=t[m];let f=m!==p+1;if(ko.lastIndex=0,Ra.lastIndex=0,Ra.test(c)&&(r||l&&!f&&l!=="s"&&ko.test(l)))t=`${t.slice(0,p)}${a}${t.slice(p)}`,p++,o=n,r=false,n=true;else if(n&&o&&ko.test(c)&&!i&&!(c==="s"&&(!l||l.toLocaleLowerCase()!==l)))t=`${t.slice(0,p-1)}${a}${t.slice(p-1)}`,o=n,r=true,n=false;else {let d=c.toLocaleLowerCase(),u=c.toLocaleUpperCase();o=n,r=d===c&&u!==c,n=u===c&&d!==c;}}return t},w=({case:e,stripLeadingSeparators:t=true,value:r})=>{let n=r.trim();return n.length?!e||e==="preserve"?n:n.length===1?(lr.lastIndex=0,lr.test(n)?"":e==="PascalCase"||e==="SCREAMING_SNAKE_CASE"?n.toLocaleUpperCase():n.toLocaleLowerCase()):(n!==n.toLocaleLowerCase()&&(n=dl({case:e,string:n})),(t||n[0]!==r[0])&&(n=n.replace(fl,"")),n=e==="SCREAMING_SNAKE_CASE"?n.toLocaleUpperCase():n.toLocaleLowerCase(),e==="PascalCase"&&(n=`${n.charAt(0).toLocaleUpperCase()}${n.slice(1)}`),e==="snake_case"||e==="SCREAMING_SNAKE_CASE"?(n=n.replaceAll(jo,(i,a,p)=>p===0&&!t?i:`_${a}`),n[n.length-1]==="_"&&(n=n.slice(0,n.length-1))):(jo.lastIndex=0,Aa.lastIndex=0,n=n.replaceAll(Aa,(i,a,p)=>["_","-","."].includes(n.charAt(p+i.length))?i:i.toLocaleUpperCase()),n=n.replaceAll(jo,(i,a,p)=>p===0&&!t&&i[0]&&r.startsWith(i[0])?i:a.toLocaleUpperCase())),n):""};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 w({case:e.case,value:t})};var yl=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},hl=e=>{switch(e.method){case "delete":case "patch":case "post":case "put":return ["mutation"];case "get":return ["query"];default:return}},In=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),n=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 a={server:i,type:"server"};try{n(a);}catch(p){this.forEachError(p,a);}}if(o.has("schema")&&this.context.ir.components?.schemas)for(let i in this.context.ir.components.schemas){let a={$ref:`#/components/schemas/${i}`,name:i,schema:this.context.ir.components.schemas[i],type:"schema"};try{n(a);}catch(p){this.forEachError(p,a);}}if(o.has("parameter")&&this.context.ir.components?.parameters)for(let i in this.context.ir.components.parameters){let a={$ref:`#/components/parameters/${i}`,name:i,parameter:this.context.ir.components.parameters[i],type:"parameter"};try{n(a);}catch(p){this.forEachError(p,a);}}if(o.has("requestBody")&&this.context.ir.components?.requestBodies)for(let i in this.context.ir.components.requestBodies){let a={$ref:`#/components/requestBodies/${i}`,name:i,requestBody:this.context.ir.components.requestBodies[i],type:"requestBody"};try{n(a);}catch(p){this.forEachError(p,a);}}if(o.has("operation")&&this.context.ir.paths)for(let i in this.context.ir.paths){let a=this.context.ir.paths[i];for(let p in a){let c=p,m={method:c,operation:a[c],path:i,type:"operation"};try{n(m);}catch(l){this.forEachError(l,m);}}}if(o.has("webhook")&&this.context.ir.webhooks)for(let i in this.context.ir.webhooks){let a=this.context.ir.webhooks[i];for(let p in a){let c=p,m={key:i,method:c,operation:a[c],type:"webhook"};try{n(m);}catch(l){this.forEachError(l,m);}}}}forEachError(t,r){let n=t instanceof Error?t:new Error(String(t));throw new nr({args:[r],error:n,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,n=r?.(t);if(n!==void 0)return n;let o=this.context.config.parser.hooks.symbols?.getFilePath,i=o?.(t);return i!==void 0?i:yl(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 n=r==="query"?"isQuery":"isMutation",o=this.config["~hooks"]?.operations?.[n],i=o?.(t);if(i!==void 0)return i;let a=this.config["~hooks"]?.operations?.getKind,p=a?.(t);if(p!==void 0)return p.includes(r);let c=this.context.config.parser.hooks.operations?.[n],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):(hl(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:M.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 gl=/~1/g,xl=/~0/g,F=e=>{let t=We(e),r=t[t.length-1];return decodeURI(r)},bl=e=>String(e).replace(/~/g,"~0").replace(/\//g,"~1"),We=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(gl,"/").replace(xl,"~")):[]},Ea=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},Ia=e=>{let t=e.map(bl).join("/");return "#"+(t?`/${t}`:"")},No=({$ref:e,spec:t})=>{let r=We(decodeURI(e)),n=t;for(let o of r){let i=o;if(n[i]===void 0)throw new Error(`Reference not found: ${e}`);n=n[i];}return n};var kn=class{config;gen;ir={};logger;package;plugins={};spec;constructor({config:t,dependencies:r,logger:n,spec:o}){this.config=t,this.gen=new Project({defaultFileName:"index",fileName:i=>{let a=O({config:t.output.fileName,name:i}),{suffix:p}=t.output.fileName;return p?a==="index"||a.endsWith(p)?a:`${a}${p}`:a},renderers:{".ts":new En},root:t.output.path}),this.logger=n,this.package=Pn(r),this.spec=o;}dereference(t){let r=this.resolveRef(t.$ref),n={...t,...r};return delete n.$ref,n}registerPlugin(t){let r=this.config.plugins[t],n=new In({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[n.name]=n,n}registerPlugins(){return this.config.pluginOrder.map(t=>this.registerPlugin(t))}resolveIrRef(t){return No({$ref:t,spec:this.ir})}resolveRef(t){return No({$ref:t,spec:this.spec})}};var jn=({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]},Pt=e=>{for(let t in e)if(e[t].required)return true;return false},ka=e=>e?!!(Pt(e.cookie)||Pt(e.header)||Pt(e.path)||Pt(e.query)):false,Co=({context:e,parameters:t})=>{if(t){for(let r in t.cookie){let n=t.cookie[r];if(n.pagination)return {in:n.location,name:n.pagination===true?n.name:`${n.name}.${n.pagination}`,schema:jn({context:e,parameter:n})}}for(let r in t.header){let n=t.header[r];if(n.pagination)return {in:n.location,name:n.pagination===true?n.name:`${n.name}.${n.pagination}`,schema:jn({context:e,parameter:n})}}for(let r in t.path){let n=t.path[r];if(n.pagination)return {in:n.location,name:n.pagination===true?n.name:`${n.name}.${n.pagination}`,schema:jn({context:e,parameter:n})}}for(let r in t.query){let n=t.query[r];if(n.pagination)return {in:n.location,name:n.pagination===true?n.name:`${n.name}.${n.pagination}`,schema:jn({context:e,parameter:n})}}}};var U=({detectFormat:e=true,schema:t})=>{if(!t.items)return t;let r=[],n=[];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 a=i.const!==void 0?`const-${i.const}`:"",p=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??""}${a}${p}${c}`;n.includes(m)||(n.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 W=({items:e,logicalOperator:t="or",mutateSchemaOneItem:r=false,schema:n})=>e.length?n.type==="tuple"?(n.items=e,n):e.length!==1?(n.items=e,n.logicalOperator=t,n):r?(n={...n,...e[0]},n):(n.items=e,n):n;var fr=e=>!!(ka(e.parameters)||e.body?.required),L=({method:e,path:t})=>`${e.toUpperCase()} ${t}`,ja=({context:e,operation:t})=>{let r=t.body;if(!r||!r.pagination)return Co({context:e,parameters:t.parameters});if(r.pagination===true)return {in:"body",name:"body",schema:r.schema};let n=r.schema,o=n.$ref?e.resolveIrRef(n.$ref):n,a=("schema"in o?o.schema:o)?.properties?.[r.pagination];return a?{in:"body",name:r.pagination,schema:a}:Co({context:e,parameters:t.parameters})},vo=({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`}},ze=e=>{let t={};if(!e.responses)return t;let r={properties:{},type:"object"},n={properties:{},type:"object"},o;for(let p in e.responses){let c=e.responses[p];switch(vo({statusCode:p})){case "1XX":case "3XX":break;case "2XX":n.properties[p]=c.schema;break;case "4XX":case "5XX":r.properties[p]=c.schema;break;case "default":o=c;break}}if(o){let p=false;Object.keys(n.properties).length||(n.properties.default=o.schema,p=true);let c=(o.schema.description??"").toLocaleLowerCase(),m=(o.schema.$ref??"").toLocaleLowerCase();["success"].some(d=>c.includes(d)||m.includes(d))&&(n.properties.default=o.schema,p=true),["error","problem"].some(d=>c.includes(d)||m.includes(d))&&(r.properties.default=o.schema,p=true),p||(r.properties.default=o.schema);}let i=Object.keys(r.properties);if(i.length){r.required=i,t.errors=r;let p=W({items:Object.values(r.properties),mutateSchemaOneItem:true,schema:{}});p=U({schema:p}),Object.keys(p).length&&p.type!=="unknown"&&(t.error=p);}let a=Object.keys(n.properties);if(a.length){n.required=a,t.responses=n;let p=W({items:Object.values(n.properties),mutateSchemaOneItem:true,schema:{}});p=U({schema:p}),Object.keys(p).length&&p.type!=="unknown"&&(t.response=p);}return t};var ve=e=>{let t=e.replace(/[^$\u200c\u200d\p{ID_Continue}]/gu,"_");return or.lastIndex=0,or.test(t)?`_${t}`:t},pt=e=>e.replace(/^[^\p{ID_Start}]+/u,"").replace(/[^$\u200c\u200d\p{ID_Continue}]/gu,"-").replace(/[$+]/g,"-"),wo=e=>{let t=e.replace("[]","Array");return pt(t)};var ne=["delete","get","head","options","patch","post","put","trace"],_t=({context:e,count:t=1,id:r,method:n,path:o,state:i})=>{let a,{output:p}=e.config,c=(p!==void 0&&typeof p=="object"&&"case"in p?p.case:void 0)??"camelCase";if(r&&(!e.config.plugins["@hey-api/sdk"]||e.config.plugins["@hey-api/sdk"].config.operationId))a=w({case:c,value:pt(r)});else {let m=o.replace(/{(.*?)}/g,"by-$1").replace(/[/:+]/g,"-");a=w({case:c,value:`${n}-${m}`});}return t>1&&(a=`${a}${t}`),i.ids.has(a)?_t({context:e,count:t+1,id:r,method:n,path:o,state:i}):(i.ids.set(a,L({method:n,path:o})),a)};var Na="/",v=(e,t="")=>`${e}${Na}${t}`,re=e=>{let t=e.indexOf(Na);return {name:e.slice(t+1),namespace:e.slice(0,t)}},Ca=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=[],n=[];if(t)for(let o of t)o.startsWith("/")&&o.endsWith("/")?n.push(new RegExp(o.slice(1,o.length-1))):r.push(v(e,o));return {regexps:n,set:new Set(r)}},Ol=({excludeOperations:e,excludeSchemas:t,includeOperations:r,includeSchemas:n,spec:o})=>{if((e.regexps.length||r.regexps.length)&&o.paths)for(let i of Object.entries(o.paths)){let a=i[0],p=i[1];for(let c of ne){if(!p[c])continue;let l=L({method:c,path:a});e.regexps.some(f=>f.test(l))&&e.set.add(v("operation",l)),r.regexps.some(f=>f.test(l))&&r.set.add(v("operation",l));}}if(o.definitions&&(t.regexps.length||n.regexps.length))for(let i of Object.keys(o.definitions))t.regexps.some(a=>a.test(i))&&t.set.add(v("schema",i)),n.regexps.some(a=>a.test(i))&&n.set.add(v("schema",i));},Tl=({excludeOperations:e,excludeParameters:t,excludeRequestBodies:r,excludeResponses:n,excludeSchemas:o,includeOperations:i,includeParameters:a,includeRequestBodies:p,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],u=f[1];for(let h of ne){if(!u[h])continue;let x=L({method:h,path:d});e.regexps.some(b=>b.test(x))&&e.set.add(v("operation",x)),i.regexps.some(b=>b.test(x))&&i.set.add(v("operation",x));}}if(l.components){if((t.regexps.length||a.regexps.length)&&l.components.parameters)for(let f of Object.keys(l.components.parameters))t.regexps.some(d=>d.test(f))&&t.set.add(v("parameter",f)),a.regexps.some(d=>d.test(f))&&a.set.add(v("parameter",f));if((r.regexps.length||p.regexps.length)&&l.components.requestBodies)for(let f of Object.keys(l.components.requestBodies))r.regexps.some(d=>d.test(f))&&r.set.add(v("body",f)),p.regexps.some(d=>d.test(f))&&p.set.add(v("body",f));if((n.regexps.length||c.regexps.length)&&l.components.responses)for(let f of Object.keys(l.components.responses))n.regexps.some(d=>d.test(f))&&n.set.add(v("response",f)),c.regexps.some(d=>d.test(f))&&c.set.add(v("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(v("schema",f)),m.regexps.some(d=>d.test(f))&&m.set.add(v("schema",f));}},Rl=({spec:e,...t})=>{"swagger"in e?Ol({...t,spec:e}):Tl({...t,spec:e});},dr=(e,t,r)=>{let n=r.timeEvent("create-filters"),o=_e("operation",e?.operations?.exclude),i=_e("operation",e?.operations?.include),a=_e("parameter",e?.parameters?.exclude),p=_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),u=_e("schema",e?.schemas?.include);Rl({excludeOperations:o,excludeParameters:a,excludeRequestBodies:c,excludeResponses:l,excludeSchemas:d,includeOperations:i,includeParameters:p,includeRequestBodies:m,includeResponses:f,includeSchemas:u,spec:t});let h={deprecated:e?.deprecated??true,operations:{exclude:o.set,include:i.set},orphans:e?.orphans??false,parameters:{exclude:a.set,include:p.set},preserveOrder:e?.preserveOrder??false,requestBodies:{exclude:c.set,include:m.set},responses:{exclude:l.set,include:f.set},schemas:{exclude:d.set,include:u.set},tags:{exclude:new Set(e?.tags?.exclude),include:new Set(e?.tags?.include)}};return n.timeEnd(),h},ur=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,Al=({filters:e,parameters:t,requestBodies:r,resourceMetadata:n,responses:o,schemas:i})=>{let a=new Set,c=[...e.operations.include.size?e.operations.include:new Set(n.operations.keys())];for(;c.length;){let m=c.pop();if(e.operations.exclude.has(m)||a.has(m))continue;let l=n.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}=re(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}})||a.add(m));}return {operations:a}},Pl=({filters:e,resourceMetadata:t,schemas:r})=>{let n=new Set,i=[...e.parameters.include.size?e.parameters.include:new Set(t.parameters.keys())];for(;i.length;){let a=i.pop();if(e.parameters.exclude.has(a)||n.has(a))continue;let p=t.parameters.get(a);if(p&&!(!e.deprecated&&p.deprecated)&&(n.add(a),!!p.dependencies.size))for(let c of p.dependencies){let{namespace:m}=re(c);switch(m){case "body":{e.requestBodies.exclude.has(c)?n.delete(a):n.has(c)||i.push(c);break}case "schema":{e.schemas.exclude.has(c)?n.delete(a):r.has(c)||r.add(c);break}}}}return {parameters:n}},El=({filters:e,resourceMetadata:t,schemas:r})=>{let n=new Set,i=[...e.requestBodies.include.size?e.requestBodies.include:new Set(t.requestBodies.keys())];for(;i.length;){let a=i.pop();if(e.requestBodies.exclude.has(a)||n.has(a))continue;let p=t.requestBodies.get(a);if(p&&!(!e.deprecated&&p.deprecated)&&(n.add(a),!!p.dependencies.size))for(let c of p.dependencies){let{namespace:m}=re(c);switch(m){case "body":{e.requestBodies.exclude.has(c)?n.delete(a):n.has(c)||i.push(c);break}case "schema":{e.schemas.exclude.has(c)?n.delete(a):r.has(c)||r.add(c);break}}}}return {requestBodies:n}},Il=({filters:e,resourceMetadata:t,schemas:r})=>{let n=new Set,i=[...e.responses.include.size?e.responses.include:new Set(t.responses.keys())];for(;i.length;){let a=i.pop();if(e.responses.exclude.has(a)||n.has(a))continue;let p=t.responses.get(a);if(p&&!(!e.deprecated&&p.deprecated)&&(n.add(a),!!p.dependencies.size))for(let c of p.dependencies){let{namespace:m}=re(c);switch(m){case "body":{e.requestBodies.exclude.has(c)?n.delete(a):n.has(c)||i.push(c);break}case "schema":{e.schemas.exclude.has(c)?n.delete(a):r.has(c)||r.add(c);break}}}}return {responses:n}},kl=({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 a=t.schemas.get(i);if(a&&!(!e.deprecated&&a.deprecated)&&(r.add(i),!!a.dependencies.size))for(let p of a.dependencies){let{namespace:c}=re(p);switch(c){case "schema":{!r.has(p)&&!e.schemas.exclude.has(p)&&o.push(p);break}}}}return {schemas:r}},jl=({filters:e,parameters:t,resourceMetadata:r})=>{if(e.parameters.exclude.size)for(let n of t){let o=r.parameters.get(n);if(o?.dependencies.size){for(let i of e.parameters.exclude)if(o.dependencies.has(i)){t.delete(n);break}}}},Nl=({filters:e,requestBodies:t,resourceMetadata:r})=>{if(e.requestBodies.exclude.size)for(let n of t){let o=r.requestBodies.get(n);if(o?.dependencies.size){for(let i of e.requestBodies.exclude)if(o.dependencies.has(i)){t.delete(n);break}}}},Cl=({filters:e,resourceMetadata:t,responses:r})=>{if(e.responses.exclude.size)for(let n of r){let o=t.responses.get(n);if(o?.dependencies.size){for(let i of e.responses.exclude)if(o.dependencies.has(i)){r.delete(n);break}}}},vl=({filters:e,resourceMetadata:t,schemas:r})=>{if(e.schemas.exclude.size)for(let n of r){let o=t.schemas.get(n);if(o?.dependencies.size){for(let i of e.schemas.exclude)if(o.dependencies.has(i)){r.delete(n);break}}}},wl=({operationDependencies:e,parameters:t,requestBodies:r,responses:n,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 n)e.has(i)||n.delete(i);},ql=({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:a}=re(i),p;if(a==="body"?p=t.requestBodies.get(i)?.dependencies:a==="operation"?p=t.operations.get(i)?.dependencies:a==="parameter"?p=t.parameters.get(i)?.dependencies:a==="response"?p=t.responses.get(i)?.dependencies:a==="schema"&&(p=t.schemas.get(i)?.dependencies),!!p?.size)for(let c of p)r.has(c)||o.push(c);}return {operationDependencies:r}},yr=({filters:e,logger:t,resourceMetadata:r})=>{let n=t.timeEvent("create-filtered-dependencies"),{schemas:o}=kl({filters:e,resourceMetadata:r}),{parameters:i}=Pl({filters:e,resourceMetadata:r,schemas:o}),{requestBodies:a}=El({filters:e,resourceMetadata:r,schemas:o}),{responses:p}=Il({filters:e,resourceMetadata:r,schemas:o});vl({filters:e,resourceMetadata:r,schemas:o}),jl({filters:e,parameters:i,resourceMetadata:r}),Nl({filters:e,requestBodies:a,resourceMetadata:r}),Cl({filters:e,resourceMetadata:r,responses:p});let{operations:c}=Al({filters:e,parameters:i,requestBodies:a,resourceMetadata:r,responses:p,schemas:o});if(!e.orphans&&c.size){let{operationDependencies:m}=ql({operations:c,resourceMetadata:r});wl({operationDependencies:m,parameters:i,requestBodies:a,responses:p,schemas:o});}return n.timeEnd(),{operations:c,parameters:i,requestBodies:a,responses:p,schemas:o}};var hr=(e,t)=>{let r=t.timeEvent("build-resource-metadata"),n={operations:new Map,parameters:new Map,requestBodies:new Map,responses:new Map,schemas:new Map},o=i=>{let a=new Set,p=e.allDependencies.get(i);if(p?.size)for(let c of p){let m=We(c),l=m[m.length-2],f=m[m.length-1];if(l&&f){let d=Ca(l);d==="unknown"&&console.warn(`unsupported type: ${l}`),a.add(v(d,f));}}return a};for(let[i,a]of e.nodes){let p=We(i);if(p[0]==="components"){if(p.length===3){if(p[1]==="schemas"){let c=p[p.length-1];n.schemas.set(v("schema",c),{dependencies:o(i),deprecated:a.deprecated??false});}else if(p[1]==="parameters"){let c=p[p.length-1];n.parameters.set(v("parameter",c),{dependencies:o(i),deprecated:a.deprecated??false});}else if(p[1]==="requestBodies"){let c=p[p.length-1];n.requestBodies.set(v("body",c),{dependencies:o(i),deprecated:a.deprecated??false});}else if(p[1]==="responses"){let c=p[p.length-1];n.responses.set(v("response",c),{dependencies:o(i),deprecated:a.deprecated??false});}}continue}if(p[0]==="paths"){if(p.length===3&&ne.includes(p[2])){let c=p[p.length-1],m=p.slice(1,-1).join("/"),l=L({method:c,path:m});n.operations.set(v("operation",l),{dependencies:o(i),deprecated:a.deprecated??false,tags:a.tags??new Set});}continue}if(p[0]==="definitions"){if(p.length===2){let c=p[p.length-1];n.schemas.set(v("schema",c),{dependencies:o(i),deprecated:a.deprecated??false});}continue}}return r.timeEnd(),{resourceMetadata:n}};var _r=e=>JSON.parse(JSON.stringify(e));var He=[["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 Hr=e=>{if(Nn(e))return e.components.schemas;if(Cn(e))return e.definitions},Nn=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,Cn=e=>typeof e=="object"&&e!==null&&"definitions"in e&&typeof e.definitions=="object"&&e.definitions!==null;var va=(e,t)=>e instanceof Set?e.has(t):e instanceof Array?e.includes(t):t in e,Qr=({base:e,components:t,extraComponents:r})=>{let n=2,o=e;for(;va(t,o)||r&&va(r,o);)o=`${e}${n}`,n+=1;return o},vn=e=>e.length===3&&e[0]==="components"&&e[1]==="schemas"||e.length===2&&e[0]==="definitions",gr=e=>{if(e&&typeof e=="object"){if("swagger"in e)return "#/definitions/";if("openapi"in e)return "#/components/schemas/"}return ""};var qo=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})},$o=({key:e,node:t,parent:r,path:n,visitor:o})=>{if(!t||typeof t!="object"||t instanceof Array)return;let i=t;("type"in i||"enum"in i||He.some(([a])=>a in i))&&o({key:e,node:t,parent:r,path:n});for(let[a,p]of Object.entries(i))typeof p=="object"&&p!==null&&(p instanceof Array?p.forEach((c,m)=>$o({key:m,node:c,parent:p,path:[...n,a,m],visitor:o})):$o({key:a,node:p,parent:t,path:[...n,a],visitor:o}));},$l=({spec:e})=>{let t=Hr(e);if(!t)return;let r=gr(e),n={};for(let[i,a]of Object.entries(t))qo(a)&&(n[`${r}${i}`]=a);let o=i=>{if(i instanceof Array)i.forEach(o);else if(i&&typeof i=="object")for(let[a,p]of Object.entries(i))a==="$ref"&&typeof p=="string"&&p in n?(Object.assign(i,_r(n[p])),delete i.$ref):o(p);};o(e);for(let i of Object.keys(n)){let a=We(i),p=a[a.length-1];p&&delete t[p];}},Ml=({config:e,spec:t})=>{let r=Hr(t);if(!r)return;let n={};for(let[c,m]of Object.entries(r)){let l=qo(m);l&&(n[l]=c);}let o=[];$o({key:null,node:t,parent:null,path:[],visitor:c=>{if(!vn(c.path)){let m=qo(c.node);m&&o.push({...c,signature:m});}}});let i={},a={};for(let{key:c,node:m,signature:l}of o){if(l in i)continue;if(l in n){i[l]=n[l];continue}let f=O({config:e,name:typeof m=="object"&&m&&"title"in m&&typeof m.title=="string"?m.title:String(c)}),d=Qr({base:f,components:r,extraComponents:Object.values(i)});i[l]=d,a[l]=m;}for(let[c,m]of Object.entries(i)){let l=a[c];m&&!(m in r)&&l&&typeof l=="object"&&(r[m]=l);}let p=gr(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:`${p}${f}`});}},wa=({config:e,spec:t})=>{if(e.mode==="inline"){$l({spec:t});return}if(e.mode==="root"){Ml({config:e,spec:t});return}};var Mo=({key:e,node:t,parent:r,path:n,visitor:o})=>{if(!t||typeof t!="object"||t instanceof Array)return;let i=t;("type"in i||He.some(([a])=>a in i))&&o({key:e,node:t,parent:r,path:n});for(let[a,p]of Object.entries(i))typeof p=="object"&&p!==null&&(p instanceof Array?p.forEach((c,m)=>Mo({key:m,node:c,parent:p,path:[...n,a,m],visitor:o})):Mo({key:a,node:p,parent:t,path:[...n,a],visitor:o}));},qa=({spec:e})=>{Mo({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 Lo=(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(!Lo(e[c],t[c]))return false;return true}let o=e,i=t,a=Object.keys(o).sort(),p=Object.keys(i).sort();if(a.length!==p.length)return false;for(let c=0;c<a.length;c++)if(a[c]!==p[c])return false;for(let c of a)if(!Lo(o[c],i[c]))return false;return true},Vo=Lo;var Ll=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));}},Fo=({cache:e,graph:t,pointer:r,visited:n})=>{let o=e.allDependencies.get(r);if(o)return o;if(n.has(r))return new Set;if(n.add(r),!t.nodes.get(r))return new Set;let a=new Set,p=t.dependencies.get(r);if(p)for(let m of p){a.add(m);let l=Fo({cache:e,graph:t,pointer:m,visited:n});for(let f of l)a.add(f);}let c=e.parentToChildren.get(r);if(c)for(let m of c){let l=e.childDependencies.get(m);l||(l=Fo({cache:e,graph:t,pointer:m,visited:n}),e.childDependencies.set(m,l));for(let f of l)a.add(f);}return e.allDependencies.set(r,a),a},Vl=e=>{let t=new Set(Array.from(e.nodes.entries()).filter(([,o])=>o.scopes&&o.scopes.size>0).map(([o])=>o)),r=(o,i,a)=>{i.parentPointer&&t.add(i.parentPointer);let p=e.reverseDependencies.get(o);if(p)for(let c of p)t.add(c);if(a){let c=a.match(/(.*)\/(allOf|anyOf|oneOf)\/\d+$/);if(c){let m=c[1];m&&t.add(m);}}},n=(o,i,a)=>{if(!i?.scopes)return;let p=e.nodes.get(a);if(!p?.scopes)return;Do(p,i)&&r(o,i,a);};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 a=i.node;for(let[c,m]of He){if(!a||typeof a!="object"||!(c in a))continue;let l=a[c];if(m==="array"&&l instanceof Array)for(let f=0;f<l.length;f++){let d=`${o}/${c}/${f}`;n(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}`;n(o,i,d);}else if(m==="single"&&typeof l=="object"&&l!==null){let f=`${o}/${c}`;n(o,i,f);}else if(m==="singleOrArray"){if(l instanceof Array)for(let f=0;f<l.length;f++){let d=`${o}/${c}/${f}`;n(o,i,d);}else if(typeof l=="object"&&l!==null){let f=`${o}/${c}`;n(o,i,f);}}}let p=e.dependencies.get(o);if(p)for(let c of p){let m=e.nodes.get(c);m?.scopes&&Do(m,i)&&r(o,i);}if(i.parentPointer){let c=e.nodes.get(i.parentPointer);c&&Do(i,c)&&r(i.parentPointer,c);}}},Do=(e,t)=>{if(!e.scopes)return false;t.scopes||(t.scopes=new Set);let r=false;for(let n of e.scopes)t.scopes.has(n)||(t.scopes.add(n),r=true);return r},Dl=e=>{for(let[t,r]of e){let{node:n}=r;typeof n!="object"||n===null||n instanceof Array||("readOnly"in n&&n.readOnly===true?r.scopes=new Set(["read"]):"writeOnly"in n&&n.writeOnly===true?r.scopes=new Set(["write"]):t.match(/\/properties\/[^/]+$/)&&(r.scopes=new Set(["normal"])));}},Et=(e,t)=>{let r=t.timeEvent("build-graph"),n={allDependencies:new Map,dependencies:new Map,nodes:new Map,reverseDependencies:new Map},o=({key:a,node:p,parentPointer:c,path:m})=>{if(typeof p!="object"||p===null)return;let l=Ia(m),f,d;if(typeof p=="object"&&p!==null){if("deprecated"in p&&typeof p.deprecated=="boolean"&&(f=!!p.deprecated),"$ref"in p&&typeof p.$ref=="string"){let u=Ea(p.$ref);n.dependencies.has(l)||n.dependencies.set(l,new Set),n.dependencies.get(l).add(u);}"tags"in p&&p.tags instanceof Array&&(d=new Set(p.tags.filter(u=>typeof u=="string")));}if(n.nodes.set(l,{deprecated:f,key:a,node:p,parentPointer:c,tags:d}),p instanceof Array)p.forEach((u,h)=>o({key:h,node:u,parentPointer:l,path:[...m,h]}));else for(let[u,h]of Object.entries(p))o({key:u,node:h,parentPointer:l,path:[...m,u]});};o({key:null,node:e,parentPointer:null,path:[]});let i={allDependencies:new Map,childDependencies:new Map,parentToChildren:new Map};for(let[a,p]of n.nodes){let c=p.parentPointer;c&&(i.parentToChildren.has(c)||i.parentToChildren.set(c,[]),i.parentToChildren.get(c).push(a));}for(let[a,p]of n.dependencies)for(let c of p)n.reverseDependencies.has(c)||n.reverseDependencies.set(c,new Set),n.reverseDependencies.get(c).add(a);Dl(n.nodes),Vl(n),Ll(n.nodes);for(let a of n.nodes.keys()){let p=Fo({cache:i,graph:n,pointer:a,visited:new Set});n.allDependencies.set(a,p);}return r.timeEnd(),{graph:n}};var Fl=new Set(["additionalProperties","allOf","anyOf","items","not","oneOf","patternProperties","properties","schema"]),Bl=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"}},Kl=(e,t)=>{let r=t.timeEvent("capture-original-schemas"),n={};if(Nn(e))for(let[o,i]of Object.entries(e.components.schemas))n[`#/components/schemas/${o}`]=i;else if(Cn(e))for(let[o,i]of Object.entries(e.definitions))n[`#/definitions/${o}`]=i;return r.timeEnd(),n},Wl=({logger:e,spec:t,split:r})=>{let n=e.timeEvent("insert-split-schemas-into-spec");Nn(t)?Object.assign(t.components.schemas,r.schemas):Cn(t)&&Object.assign(t.definitions,r.schemas),n.timeEnd();},Ht=(e,t,r)=>{if(t&&typeof t=="object"){if("$ref"in t&&typeof t.$ref=="string"){let n=e.nodes.get(t.$ref);if(n?.scopes&&(r==="writeOnly"&&n.scopes.size===1&&n.scopes.has("write")||r==="readOnly"&&n.scopes.size===1&&n.scopes.has("read"))&&(delete t.$ref,!He.some(([o])=>o in t)))return true}for(let[n,o]of He){if(!(n in t))continue;let i=t[n];if(o==="array"&&i instanceof Array){for(let a=i.length-1;a>=0;a--){let p=i[a];(p&&typeof p=="object"&&p[r]===true||Ht(e,p,r))&&i.splice(a,1);}i.length||delete t[n];}else if(o==="objectMap"&&typeof i=="object"&&i!==null&&!(i instanceof Array)){let a=i,p=new Set;for(let c of Object.keys(a)){let m=a[c];(m&&typeof m=="object"&&m[r]===true||Ht(e,m,r))&&(delete a[c],n==="properties"&&p.add(c));}if(p.size>0&&n==="properties"&&"required"in t&&Array.isArray(t.required)){let m=t.required.filter(l=>!p.has(l));m.length===0?delete t.required:t.required=m;}Object.keys(a).length||delete t[n];}else if(o==="single"&&typeof i=="object"&&i!==null)(i[r]===true||Ht(e,i,r))&&delete t[n];else if(o==="singleOrArray")if(i instanceof Array){for(let a=i.length-1;a>=0;a--){let p=i[a];(p&&typeof p=="object"&&p[r]===true||Ht(e,p,r))&&i.splice(a,1);}i.length||delete t[n];}else typeof i=="object"&&i!==null&&(i[r]===true||Ht(e,i,r))&&delete t[n];}if(t.type==="object"&&!He.some(([n])=>n in t))return true}return false},zl=({logger:e,originalSchemas:t,spec:r,split:n})=>{let o=e.timeEvent("remove-original-split-schemas"),i=Hr(r);for(let a of Object.keys(n.mapping)){let p=We(a),c=p[p.length-1];typeof c=="string"&&i&&Object.prototype.hasOwnProperty.call(i,c)&&i[c]===t[a]&&delete i[c];}o.timeEnd();},_l=({config:e,graph:t,logger:r,spec:n})=>{let o=r.timeEvent("split-schemas"),i=new Set,a={mapping:{},reverseMapping:{},schemas:{}},p=gr(n),c=p.split("/").length-1,m=l=>{if(l.startsWith(p)){let f=We(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 u=_r(f.node);Ht(t,u,"writeOnly");let h=O({config:e.responses,name:d}),g=h===d?h:Qr({base:h,components:i});i.add(g),a.schemas[g]=u;let x=`${p}${g}`,b=_r(f.node);if(Ht(t,b,"readOnly"),Vo(u,b)&&Vo(u,f.node))continue;let j=O({config:e.requests,name:d}),k=j===d&&j!==g?j:Qr({base:j,components:i});i.add(k),a.schemas[k]=b;let P=`${p}${k}`;a.mapping[l]={read:x,write:P},a.reverseMapping[x]=l,a.reverseMapping[P]=l;}return o.timeEnd(),a},Hl=({logger:e,spec:t,split:r})=>{let n=e.timeEvent("update-refs-in-spec"),o=gr(t),i=({context:a,currentPointer:p,inSchema:c,node:m,path:l})=>{if(m instanceof Array)m.forEach((f,d)=>i({context:a,currentPointer:p,inSchema:c,node:f,path:[...l,d]}));else if(m&&typeof m=="object"){let f=p,d=a;if(vn(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 u=Bl(l);if(u!==void 0){for(let h in m)Object.prototype.hasOwnProperty.call(m,h)&&i({context:u,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,b)=>{x&&typeof x=="object"&&"schema"in x&&i({context:"write",currentPointer:f,inSchema:true,node:x.schema,path:[...l,h,b,"schema"]}),x&&typeof x=="object"&&"content"in x&&i({context:"write",currentPointer:f,inSchema:false,node:x.content,path:[...l,h,b,"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(Fl.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:[]}),n.timeEnd();},$a=({config:e,logger:t,spec:r})=>{let{graph:n}=Et(r,t),o=Kl(r,t),i=_l({config:e,graph:n,logger:t,spec:r});Wl({logger:t,spec:r,split:i}),Hl({logger:t,spec:r,split:i}),zl({logger:t,originalSchemas:o,spec:r,split:i});};var xr=({context:e})=>{let{logger:t}=e,r=t.timeEvent("transform-openapi-spec");e.config.parser.transforms.enums.enabled&&wa({config:e.config.parser.transforms.enums,spec:e.spec}),e.config.parser.transforms.propertiesRequiredByDefault&&qa({spec:e.spec}),e.config.parser.transforms.readWrite.enabled&&$a({config:e.config.parser.transforms.readWrite,logger:t,spec:e.spec}),r.timeEnd();};var $=({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 Ql=e=>/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(e),Zl=e=>e.map((t,r)=>typeof t=="number"?`[${t}]`:r===0?t:Ql(t)?`.${t}`:`['${t.replace(/"/g,"\\'")}']`).join(""),Ul=e=>{let t=Zl(e.path),r=e.severity==="error"?Rt.bold.red:Rt.bold.yellow,n=e.message.replace(/`([^`]+)`/g,(o,i)=>Rt.yellow(`\`${i}\``));return `${r(`[${e.severity.toUpperCase()}]`)} ${Rt.cyan(t)}: ${n}`},Xl=({context:e,issue:t})=>e.config.logs.level==="silent"?false:t.severity==="error"?e.config.logs.level!=="warn":true,br=({context:e,result:t})=>{for(let r of t.issues)Xl({context:e,issue:r})&&console.log(Ul(r));t.valid||process.exit(1);};var Ma=({logger:e,operations:t,preserveOrder:r,schemas:n,spec:o})=>{let i=e.timeEvent("filter-spec");if(o.definitions){let a={};if(r)for(let[p,c]of Object.entries(o.definitions))n.has(v("schema",p))&&(a[p]=c);else for(let p of n){let{name:c}=re(p),m=o.definitions[c];m&&(a[c]=m);}o.definitions=a;}if(o.paths)for(let a of Object.entries(o.paths)){let p=a[0],c=a[1];for(let m of ne){if(!c[m])continue;let f=v("operation",L({method:m,path:p}));t.has(f)||delete c[m];}Object.keys(c).length||delete o.paths[p];}i.timeEnd();};var La=/^(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,Va=/^application\/(.*\+)?json(;.*)?$/i,Da=/^multipart\/form-data(;.*)?$/i,Fa=/^text\/[a-z0-9.+-]+(;.*)?$/i,Ba=/^application\/x-www-form-urlencoded(;.*)?$/i,Ka=/^application\/octet-stream(;.*)?$/i,ct=({mediaType:e})=>(La.lastIndex=0,La.test(e)),Sr=({mediaType:e})=>{if(Va.lastIndex=0,Va.test(e))return "json";if(Da.lastIndex=0,Da.test(e))return "form-data";if(Fa.lastIndex=0,Fa.test(e))return "text";if(Ba.lastIndex=0,Ba.test(e))return "url-search-params";if(Ka.lastIndex=0,Ka.test(e))return "octet-stream"};var Wa=({content:e})=>{let{mediaType:t,schema:r}=e;return r&&"$ref"in r?{allOf:[{...r}]}:r?r.type==="string"&&!r.format&&ct({mediaType:t})?{...r,format:"binary"}:r:ct({mediaType:t})?{format:"binary",type:"string"}:void 0},Bo=({mimeTypes:e,response:t})=>{let r=[];for(let n of e??[])r.push({mediaType:n,schema:t.schema,type:Sr({mediaType:n})});return r};function Oe(e){let t=`^(${e.keywords.join("|")})$`;return new RegExp(t)}var Qe=(e,t,r)=>{let n=[];for(let o in t)t[o]===e&&n.push(o);return !n.length&&(!r||r())?[F(e)]:n};var Zr=({schema:e})=>{if(e.type)return e.type;if(e.properties)return "object"},Gl=({irSchema:e,schema:t})=>{t.example&&(e.example=t.example),t.description&&(e.description=t.description),t.title&&(e.title=t.title);},qn=({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");},Jl=({context:e,irSchema:t={},schema:r,state:n})=>{r.maxItems&&r.maxItems===r.minItems?t.type="tuple":t.type="array";let o=[];if(r.items){let i=Ae({context:e,schema:r.items,state:n});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 a=r.items.allOf;a&&a.length>1&&!r.items["x-nullable"]?t={...t,...i}:o.push(i);}}return t=W({items:o,schema:t}),t},Yl=({irSchema:e={}})=>(e.type="boolean",e),ef=({irSchema:e={},schema:t})=>(e.type=t.type,e),tf=({context:e,irSchema:t={},schema:r,state:n})=>{t.type="object";let o={};for(let i in r.properties){let a=r.properties[i];if(typeof a!="boolean"){let p=Ae({context:e,schema:a,state:n});o[i]=p;}}if(Object.keys(o).length&&(t.properties=o),r.additionalProperties===void 0)t.properties||(t.additionalProperties={type:"unknown"});else if(typeof r.additionalProperties=="boolean")n.inAllOf&&r.additionalProperties===false&&(!r.properties||Object.keys(r.properties).length===0)||(t.additionalProperties={type:r.additionalProperties?"unknown":"never"});else {let i=Ae({context:e,schema:r.additionalProperties,state:n});t.additionalProperties=i;}return r.required&&(t.required=r.required),t},rf=({irSchema:e={}})=>(e.type="string",e),Or=({schema:e})=>{let t={};return Gl({irSchema:t,schema:e}),t},nf=({context:e,schema:t,state:r})=>{let n=Or({schema:t}),o=[],i=Zr({schema:t}),a=t.allOf;for(let p of a){let c=r.inAllOf;"$ref"in p||(r.inAllOf=true);let m=Ae({context:e,schema:p,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),p.$ref){let l=e.resolveRef(p.$ref);if(l.discriminator&&r.$ref){let d=Qe(r.$ref).map(h=>({const:h,type:"string"})),u={properties:{[l.discriminator]:d.length>1?{items:d,logicalOperator:"or"}:d[0]},type:"object"};l.required?.includes(l.discriminator)&&(u.required=[l.discriminator]),o.push(u);}}}if(i==="object"){let p=Ur({context:e,schema:{...t,type:"object"},state:r});if(p.properties){for(let c of p.required??[])if(!p.properties[c])for(let m of a){let l=m.$ref?e.resolveRef(m.$ref):m;if(Zr({schema:l})==="object"){let f=Ur({context:e,schema:{...l,type:"object"},state:r});if(f.properties?.[c]){p.properties[c]=f.properties[c];break}}}o.push(p);}}if(n=W({items:o,logicalOperator:"and",mutateSchemaOneItem:true,schema:n}),t["x-nullable"]){let p=[{type:"null"}];o.length&&p.unshift(n),n={items:p,logicalOperator:"or"},p[0].deprecated&&(n.deprecated=p[0].deprecated),p[0].description&&(n.description=p[0].description);}return n},sf=({context:e,schema:t,state:r})=>{let n=Or({schema:t});n.type="enum";let o=[];for(let[i,a]of t.enum.entries()){let p=typeof a,c;if(p==="string"||p==="number"||p==="boolean"?c=p:p==="object"&&Array.isArray(a)?c="array":a===null?t["x-nullable"]&&(c="null"):console.warn("\u{1F6A8}",`unhandled "${p}" typeof value "${a}" for enum`,t.enum),!c)continue;let m=Ur({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=a,c==="null"&&(m.type=c),m.type==="array"&&(m.type="tuple"),o.push(m);}return n=W({items:o,schema:n}),n},of=({context:e,schema:t,state:r})=>{let n={};if(!t.$ref.startsWith("#/definitions/")&&!r.circularReferenceTracker.has(t.$ref)){r.refStack.push(t.$ref);let i=e.resolveRef(t.$ref),a=r.$ref;r.$ref=t.$ref;let p=Ae({context:e,schema:i,state:r});return r.$ref=a,r.refStack.pop(),p}if(n.$ref=decodeURI(t.$ref),n.$ref=n.$ref.replace(/#\/definitions\/([^/]+)/g,"#/components/schemas/$1"),r.refStack.includes(t.$ref)&&(r.refStack[0]===t.$ref&&(r.circularRef=t.$ref),n.circular=true),!r.circularReferenceTracker.has(t.$ref)){r.refStack.push(t.$ref);let i=e.resolveRef(t.$ref),a=r.$ref;r.$ref=t.$ref,Ae({context:e,schema:i,state:r}),r.circularRef&&r.refStack[0]===r.circularRef&&(n.circular=true),r.$ref=a,r.refStack.pop();}return n},af=({context:e,irSchema:t,schema:r,state:n})=>{t||(t=Or({schema:r}));let o={};qn({irSchema:o,schema:r}),o.default===null&&delete o.default;let i=[Ur({context:e,irSchema:o,schema:r,state:n}),{type:"null"}];return t=W({items:i,schema:t}),t},pf=({context:e,schema:t,state:r})=>{let n=Or({schema:t});qn({irSchema:n,schema:t});let o=Zr({schema:t});return o?t["x-nullable"]?af({context:e,irSchema:n,schema:{...t,type:o},state:r}):Ur({context:e,irSchema:n,schema:{...t,type:o},state:r}):n},Ur=({context:e,irSchema:t,schema:r,state:n})=>{switch(t||(t=Or({schema:r}),qn({irSchema:t,schema:r})),r.type){case "array":return Jl({context:e,irSchema:t,schema:r,state:n});case "boolean":return Yl({irSchema:t});case "integer":case "number":return ef({irSchema:t,schema:r});case "object":return tf({context:e,irSchema:t,schema:r,state:n});case "string":return rf({irSchema:t});default:return za({irSchema:t,schema:r})}},za=({irSchema:e,schema:t})=>(e||(e=Or({schema:t})),e.type="unknown",qn({irSchema:e,schema:t}),e),Ae=({context:e,schema:t,state:r})=>(r||(r={circularReferenceTracker:new Set,refStack:[]}),r.$ref&&r.circularReferenceTracker.add(r.$ref),t.$ref?of({context:e,schema:t,state:r}):t.enum?sf({context:e,schema:t,state:r}):t.allOf?nf({context:e,schema:t,state:r}):t.type||t.properties?pf({context:e,schema:t,state:r}):za({schema:t})),_a=({$ref:e,context:t,schema:r})=>{t.ir.components||(t.ir.components={}),t.ir.components.schemas||(t.ir.components.schemas={}),t.ir.components.schemas[F(e)]=Ae({context:t,schema:r,state:{$ref:e,circularReferenceTracker:new Set,refStack:[e]}});};var cf=e=>e==="boolean"||e==="integer"||e==="number"||e==="string",It=({context:e,name:t,schema:r})=>{if(Oe(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 It({context:e,name:t,schema:i})}return It({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 It({context:e,name:t,schema:o})}for(let o in r.properties)if(Oe(e.config.parser.pagination).test(o)){let a=r.properties[o];if(typeof a!="boolean"&&!("$ref"in a)){let p=Zr({schema:a});if(cf(p))return o}}for(let o of r.allOf??[]){let i=It({context:e,name:t,schema:o});if(i)return i}return false};var mf=({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);},lf=({context:e,method:t,operation:r,path:n,state:o})=>{let i={id:_t({context:e,id:r.operationId,method:t,path:n,state:o}),method:t,path:n};return r.operationId&&(i.operationId=r.operationId),mf({irOperation:i,operation:r}),i},ff=({context:e,method:t,operation:r,path:n,securitySchemesMap:o,state:i})=>{let a=lf({context:e,method:t,operation:r,path:n,state:i});r.parameters&&(a.parameters=r.parameters);let p=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},u=Bo({mimeTypes:r.consumes,response:{schema:d}}),h=u.find(g=>g.type==="json")||u[0];if(h){let g=It({context:e,name:"",schema:h.schema&&"$ref"in h.schema?{allOf:[{...h.schema}],description:f.description}:{description:f.description,...h.schema}}),x=Ae({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&&(p=true);}c.mediaType&&(m.length&&(c.schema.required=m),a.body=c,p&&(a.body.required=p));for(let l in r.responses){a.responses||(a.responses={});let f=r.responses[l],d="$ref"in f?e.resolveRef(f.$ref):f,u=Bo({mimeTypes:r.produces?r.produces:["application/json"],response:d}),h=u.find(g=>g.type==="json")||u[0];h?a.responses[l]={mediaType:h.mediaType,schema:Ae({context:e,schema:{description:d.description,...Wa({content:h})},state:void 0})}:a.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 u=o.get(d);if(!u)continue;let h;if(u.type==="apiKey"&&(h=u),u.type==="basic"&&(h={description:u.description,scheme:"basic",type:"http"}),u.type==="oauth2")switch(h={description:u.description,flows:{},type:"oauth2"},u.flow){case "accessCode":h.flows.authorizationCode={authorizationUrl:u.authorizationUrl,scopes:u.scopes,tokenUrl:u.tokenUrl};break;case "application":h.flows.clientCredentials={scopes:u.scopes,tokenUrl:u.tokenUrl};break;case "implicit":h.flows.implicit={authorizationUrl:u.authorizationUrl,scopes:u.scopes};break;case "password":h.flows.password={scopes:u.scopes,tokenUrl:u.tokenUrl};break}h&&l.set(d,h);}l.size&&(a.security=Array.from(l.values()));}return a},kt=({context:e,method:t,operation:r,path:n,securitySchemesMap:o,state:i})=>{e.ir.paths||(e.ir.paths={}),e.ir.paths[n]||(e.ir.paths[n]={}),e.ir.paths[n][t]=ff({context:e,method:t,operation:r,path:n,securitySchemesMap:o,state:i});};var df=e=>{switch(e){case "multi":return true;case "csv":case "pipes":case "ssv":case "tsv":default:return false}},uf=e=>{switch(e){case "header":case "path":return "simple";case "query":default:return "form"}},mt=({context:e,operation:t,parameters:r})=>{if(!r||!Object.keys(r).length)return;let n={};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}n[i.in]||(n[i.in]={}),n[i.in][i.name.toLocaleLowerCase()]=yf({$ref:`#/todo/real/path/to/parameter/${i.name}`,context:e,parameter:i});}return n},yf=({$ref:e,context:t,parameter:r})=>{let n=r,o=n&&"$ref"in n?{allOf:[{...n,$ref:n.$ref,required:Array.isArray(n.required)?n.required:[],type:n.type}],description:r.description}:{description:r.description,...n,required:Array.isArray(n.required)?n.required:[],type:n.type},i=It({context:t,name:r.name,schema:o}),a=uf(r.in),m={allowReserved:false,explode:df(r.collectionFormat),location:r.in,name:r.name,schema:Ae({context:t,schema:o,state:{$ref:e,circularReferenceTracker:new Set,refStack:[e]}}),style:a};return r.description&&(m.description=r.description),i&&(m.pagination=i),r.required&&(m.required=r.required),m};var Ha=/^(([^:/?#]+):)?((\/\/)?([^:/?#]*)(:?([^/?#]*)))?([^?#]*)(\?([^#]*))?(#(.*))?/,Ze=e=>{let t={host:"",path:"",port:"",protocol:""};Ha.lastIndex=0;let r=e.match(Ha);if(!r)return t;let n=r[5]||"";if(n==="."||n==="..")return t;let o=r[8]||"",i=r[2]||"";return i.length===1?t:{host:n,path:o==="/"?"":o,port:r[7]||"",protocol:i}};var Qa=({context:e})=>{let t=e.spec.schemes??[],r=e.spec.host??"",n=e.spec.basePath??"";if(typeof e.config.input.path=="string"){let i=Ze(e.config.input.path);t.length||i.protocol&&(t=[i.protocol]),r||(r=`${i.host}${i.port?`:${i.port}`:""}`);}t.length||(t=[""]);let o=t.map(i=>`${i?`${i}://`:""}${r}${n}`).filter(Boolean);o.length&&(e.ir.servers=o.map(i=>({url:i})));};var Za=(e,t)=>{let r=t.timeEvent("validate"),n=[],o=new Map;if(e.paths)for(let i of Object.entries(e.paths)){let a=i[0],p=i[1];for(let c of ne){if(c==="trace")continue;let m=p[c];if(!m)continue;let l=L({method:c,path:a});m.operationId&&(o.has(m.operationId)?n.push({code:"duplicate_key",context:{key:"operationId",value:m.operationId},message:"Duplicate `operationId` found. Each `operationId` must be unique.",path:["paths",a,c,"operationId"],severity:"error"}):o.set(m.operationId,l));}}return r.timeEnd(),{issues:n,valid:!n.some(i=>i.severity==="error")}};var Ko=e=>{if(e.config.parser.validate_EXPERIMENTAL){let o=Za(e.spec,e.logger);br({context:e,result:o});}if(ur(e.config.parser.filters)){let o=dr(e.config.parser.filters,e.spec,e.logger),{graph:i}=Et(e.spec,e.logger),{resourceMetadata:a}=hr(i,e.logger),p=yr({filters:o,logger:e.logger,resourceMetadata:a});Ma({...p,logger:e.logger,preserveOrder:o.preserveOrder,spec:e.spec});}xr({context:e});let r={ids:new Map},n=new Map;for(let o in e.spec.securityDefinitions){let i=e.spec.securityDefinitions[o];n.set(o,i);}if(e.spec.definitions)for(let o in e.spec.definitions){let i=`#/definitions/${o}`,a=e.spec.definitions[o];_a({$ref:i,context:e,schema:a});}Qa({context:e});for(let o in e.spec.paths){if(o.startsWith("x-"))continue;let i=e.spec.paths[o],a=i.$ref?{...e.resolveRef(i.$ref),...i}:i,p={consumes:e.spec.consumes,produces:e.spec.produces,responses:{},security:e.spec.security},c={context:e,operation:{...p,parameters:mt({context:e,operation:p,parameters:a.parameters})},path:o,securitySchemesMap:n,state:r};if(a.delete){let m=$({source:mt({context:e,operation:a.delete,parameters:a.delete.parameters}),target:c.operation.parameters});kt({...c,method:"delete",operation:{...c.operation,...a.delete,parameters:m}});}if(a.get){let m=$({source:mt({context:e,operation:a.get,parameters:a.get.parameters}),target:c.operation.parameters});kt({...c,method:"get",operation:{...c.operation,...a.get,parameters:m}});}if(a.head){let m=$({source:mt({context:e,operation:a.head,parameters:a.head.parameters}),target:c.operation.parameters});kt({...c,method:"head",operation:{...c.operation,...a.head,parameters:m}});}if(a.options){let m=$({source:mt({context:e,operation:a.options,parameters:a.options.parameters}),target:c.operation.parameters});kt({...c,method:"options",operation:{...c.operation,...a.options,parameters:m}});}if(a.patch){let m=$({source:mt({context:e,operation:a.patch,parameters:a.patch.parameters}),target:c.operation.parameters});kt({...c,method:"patch",operation:{...c.operation,...a.patch,parameters:m}});}if(a.post){let m=$({source:mt({context:e,operation:a.post,parameters:a.post.parameters}),target:c.operation.parameters});kt({...c,method:"post",operation:{...c.operation,...a.post,parameters:m}});}if(a.put){let m=$({source:mt({context:e,operation:a.put,parameters:a.put.parameters}),target:c.operation.parameters});kt({...c,method:"put",operation:{...c.operation,...a.put,parameters:m}});}}};var Ua=({logger:e,operations:t,parameters:r,preserveOrder:n,requestBodies:o,responses:i,schemas:a,spec:p})=>{let c=e.timeEvent("filter-spec");if(p.components){if(p.components.parameters){let m={};if(n)for(let[l,f]of Object.entries(p.components.parameters))r.has(v("parameter",l))&&(m[l]=f);else for(let l of r){let{name:f}=re(l),d=p.components.parameters[f];d&&(m[f]=d);}p.components.parameters=m;}if(p.components.requestBodies){let m={};if(n)for(let[l,f]of Object.entries(p.components.requestBodies))o.has(v("body",l))&&(m[l]=f);else for(let l of o){let{name:f}=re(l),d=p.components.requestBodies[f];d&&(m[f]=d);}p.components.requestBodies=m;}if(p.components.responses){let m={};if(n)for(let[l,f]of Object.entries(p.components.responses))i.has(v("response",l))&&(m[l]=f);else for(let l of i){let{name:f}=re(l),d=p.components.responses[f];d&&(m[f]=d);}p.components.responses=m;}if(p.components.schemas){let m={};if(n)for(let[l,f]of Object.entries(p.components.schemas))a.has(v("schema",l))&&(m[l]=f);else for(let l of a){let{name:f}=re(l),d=p.components.schemas[f];d&&(m[f]=d);}p.components.schemas=m;}}if(p.paths)for(let m of Object.entries(p.paths)){let l=m[0],f=m[1];for(let d of ne){if(!f[d])continue;let h=v("operation",L({method:d,path:l}));t.has(h)||delete f[d];}Object.keys(f).length||delete p.paths[l];}c.timeEnd();};var Xa=({content:e})=>{let{mediaType:t,schema:r}=e;return r&&"$ref"in r?{allOf:[{...r}]}:r?r.type==="string"&&!r.format&&ct({mediaType:t})?{...r,format:"binary"}:r:ct({mediaType:t})?{format:"binary",type:"string"}:void 0},lt=({content:e})=>{let t=[];for(let r in e)t.push({mediaType:r,schema:e[r].schema,type:Sr({mediaType:r})});return t};var Qt=({schema:e})=>{if(e.type)return e.type;if(e.properties)return "object"},hf=({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);},$n=({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");},gf=({context:e,irSchema:t={},schema:r,state:n})=>{r.maxItems&&r.maxItems===r.minItems?t.type="tuple":t.type="array";let o=[];if(r.items){let i=ae({context:e,schema:r.items,state:n});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 a=r.items.allOf||r.items.anyOf||r.items.oneOf;a&&a.length>1&&!r.items.nullable?t={...t,...i}:o.push(i);}}return t=W({items:o,schema:t}),t},xf=({irSchema:e={}})=>(e.type="boolean",e),bf=({irSchema:e={},schema:t})=>(e.type=t.type,e),Sf=({context:e,irSchema:t={},schema:r,state:n})=>{t.type="object";let o={};for(let i in r.properties){let a=r.properties[i];typeof a=="boolean"||(o[i]=ae({context:e,schema:a,state:n}));}if(Object.keys(o).length&&(t.properties=o),r.additionalProperties===void 0)t.properties||(t.additionalProperties={type:"unknown"});else if(typeof r.additionalProperties=="boolean")n.inAllOf&&r.additionalProperties===false&&(!r.properties||Object.keys(r.properties).length===0)||(t.additionalProperties={type:r.additionalProperties?"unknown":"never"});else {let i=ae({context:e,schema:r.additionalProperties,state:n});t.additionalProperties=i;}return r.required&&(t.required=r.required),t},Of=({irSchema:e={}})=>(e.type="string",e),jt=({schema:e})=>{let t={};return hf({irSchema:t,schema:e}),t},Tf=({context:e,schema:t,state:r})=>{let n=jt({schema:t}),o=[],i=Qt({schema:t}),a=t.allOf;for(let p of a){let c=r.inAllOf;"$ref"in p||(r.inAllOf=true);let m=ae({context:e,schema:p,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 p){let l=e.resolveRef(p.$ref);if(l.discriminator&&r.$ref){let f=Qe(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"})),u={properties:{[l.discriminator.propertyName]:d.length>1?{items:d,logicalOperator:"or"}:d[0]},type:"object"};l.required?.includes(l.discriminator.propertyName)&&(u.required=[l.discriminator.propertyName]),o.push(u);}}}}if(i==="object"){let p=Zt({context:e,schema:{...t,type:"object"},state:r});if(p.properties){for(let c of p.required??[])if(!p.properties[c])for(let m of a){let l="$ref"in m?e.resolveRef(m.$ref):m;if(Qt({schema:l})==="object"){let f=Zt({context:e,schema:{...l,type:"object"},state:r});if(f.properties?.[c]){p.properties[c]=f.properties[c];break}}}o.push(p);}}if(n=W({items:o,logicalOperator:"and",mutateSchemaOneItem:true,schema:n}),t.nullable){let p=[{type:"null"}];o.length&&p.unshift(n),n={items:p,logicalOperator:"or"},p[0].deprecated&&(n.deprecated=p[0].deprecated),p[0].description&&(n.description=p[0].description);}return n},Rf=({context:e,schema:t,state:r})=>{let n=jt({schema:t}),o=[],i=Qt({schema:t}),a=t.anyOf;for(let p of a){let c=ae({context:e,schema:p,state:r});if(t.discriminator&&c.$ref!=null){let l=Qe(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"}),n=W({items:o,mutateSchemaOneItem:true,schema:n}),i==="object"){let p=Zt({context:e,schema:{...t,type:"object"},state:r});p.properties&&(n={items:[n,p],logicalOperator:"and"});}return n},Af=({context:e,schema:t,state:r})=>{let n=jt({schema:t});n.type="enum";let o=[];for(let[i,a]of t.enum.entries()){let p=typeof a,c;if(p==="string"||p==="number"||p==="boolean"?c=p:p==="object"&&Array.isArray(a)?c="array":a===null?t.nullable&&(c="null"):console.warn("\u{1F6A8}",`unhandled "${p}" typeof value "${a}" for enum`,t.enum),!c)continue;let m=Zt({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=a,c==="null"&&(m.type=c),m.type==="array"&&(m.type="tuple"),o.push(m);}return n=W({items:o,schema:n}),n},Pf=({context:e,schema:t,state:r})=>{let n=jt({schema:t}),o=[],i=Qt({schema:t}),a=t.oneOf;for(let p of a){let c=ae({context:e,schema:p,state:r});if(t.discriminator&&c.$ref!=null){let l=Qe(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"}),n=W({items:o,mutateSchemaOneItem:true,schema:n}),i==="object"){let p=Zt({context:e,schema:{...t,type:"object"},state:r});p.properties&&(n={items:[n,p],logicalOperator:"and"});}return n},Ef=({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),a=r.$ref;r.$ref=t.$ref;let p=ae({context:e,schema:i,state:r});return r.$ref=a,r.refStack.pop(),p}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),a=r.$ref;r.$ref=t.$ref,ae({context:e,schema:i,state:r}),r.circularRef&&r.refStack[0]===r.circularRef&&(o.circular=true),r.$ref=a,r.refStack.pop();}return o},If=({context:e,irSchema:t,schema:r,state:n})=>{t||(t=jt({schema:r}));let o={};$n({irSchema:o,schema:r}),o.default===null&&delete o.default;let i=[Zt({context:e,irSchema:o,schema:r,state:n}),{type:"null"}];return t=W({items:i,schema:t}),t},kf=({context:e,schema:t,state:r})=>{let n=jt({schema:t});$n({irSchema:n,schema:t});let o=Qt({schema:t});return o?t.nullable?If({context:e,irSchema:n,schema:{...t,type:o},state:r}):Zt({context:e,irSchema:n,schema:{...t,type:o},state:r}):n},Zt=({context:e,irSchema:t,schema:r,state:n})=>{switch(t||(t=jt({schema:r}),$n({irSchema:t,schema:r})),r.type){case "array":return gf({context:e,irSchema:t,schema:r,state:n});case "boolean":return xf({irSchema:t});case "integer":case "number":return bf({irSchema:t,schema:r});case "object":return Sf({context:e,irSchema:t,schema:r,state:n});case "string":return Of({irSchema:t});default:return Ga({irSchema:t,schema:r})}},Ga=({irSchema:e,schema:t})=>(e||(e=jt({schema:t})),e.type="unknown",$n({irSchema:e,schema:t}),e),ae=({context:e,schema:t,state:r})=>(r||(r={circularReferenceTracker:new Set,refStack:[]}),r.$ref&&r.circularReferenceTracker.add(r.$ref),"$ref"in t?Ef({context:e,schema:t,state:r}):t.enum?Af({context:e,schema:t,state:r}):t.allOf?Tf({context:e,schema:t,state:r}):t.anyOf?Rf({context:e,schema:t,state:r}):t.oneOf?Pf({context:e,schema:t,state:r}):t.type||t.properties?kf({context:e,schema:t,state:r}):Ga({schema:t})),Ja=({$ref:e,context:t,schema:r})=>{t.ir.components||(t.ir.components={}),t.ir.components.schemas||(t.ir.components.schemas={}),t.ir.components.schemas[F(e)]=ae({context:t,schema:r,state:{$ref:e,circularReferenceTracker:new Set,refStack:[e]}});};var jf=e=>e==="boolean"||e==="integer"||e==="number"||e==="string",Ut=({context:e,name:t,schema:r})=>{if(Oe(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 a=lt({content:o.content}),p=a.find(c=>c.type==="json")||a[0];p?.schema&&(i=p.schema);}return i?Ut({context:e,name:t,schema:i}):false}return Ut({context:e,name:t,schema:o})}for(let o in r.properties)if(Oe(e.config.parser.pagination).test(o)){let a=r.properties[o];if(typeof a!="boolean"&&!("$ref"in a)){let p=Qt({schema:a});if(jf(p))return o}}for(let o of r.allOf??[]){let i=Ut({context:e,name:t,schema:o});if(i)return i}return false};var Nf=({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);},Cf=({context:e,method:t,operation:r,path:n,state:o})=>{let i={id:_t({context:e,id:r.operationId,method:t,path:n,state:o}),method:t,path:n};return r.operationId&&(i.operationId=r.operationId),Nf({irOperation:i,operation:r}),i},vf=({context:e,method:t,operation:r,path:n,securitySchemesMap:o,state:i})=>{let a=Cf({context:e,method:t,operation:r,path:n,state:i});if(r.parameters&&(a.parameters=r.parameters),r.requestBody){let p="$ref"in r.requestBody?e.resolveRef(r.requestBody.$ref):r.requestBody,c=lt({content:p.content}),m=c.find(l=>l.type==="json")||c[0];if(m){let l=Ut({context:e,name:"",schema:m.schema&&"$ref"in m.schema?{allOf:[{...m.schema}],description:p.description}:{description:p.description,...m.schema}});a.body={mediaType:m.mediaType,schema:ae({context:e,schema:"$ref"in r.requestBody?{allOf:[{...r.requestBody}],description:p.description}:m.schema&&"$ref"in m.schema?{allOf:[{...m.schema}],description:p.description}:{description:p.description,...m.schema},state:void 0})},l&&(a.body.pagination=l),p.required&&(a.body.required=p.required),m.type&&(a.body.type=m.type);}}for(let p in r.responses){a.responses||(a.responses={});let c=r.responses[p],m="$ref"in c?e.resolveRef(c.$ref):c,l=lt({content:m.content}),f=l.find(d=>d.type==="json")||l[0];f?a.responses[p]={mediaType:f.mediaType,schema:ae({context:e,schema:{description:m.description,...Xa({content:f})},state:void 0})}:a.responses[p]={schema:{description:m.description,type:p==="204"?"void":"unknown"}};}if(r.security){let p=new Map;for(let c of r.security)for(let m in c){let l=o.get(m);l&&p.set(m,l);}p.size&&(a.security=Array.from(p.values()));}return a},ft=({context:e,method:t,operation:r,path:n,securitySchemesMap:o,state:i})=>{e.ir.paths||(e.ir.paths={}),e.ir.paths[n]||(e.ir.paths[n]={}),r.servers&&(e.ir.servers=[...e.ir.servers??[],...r.servers]),e.ir.paths[n][t]=vf({context:e,method:t,operation:r,path:n,securitySchemesMap:o,state:i});};var wf=e=>{switch(e){case "query":return false;default:return}},qf=e=>{switch(e){case "deepObject":case "form":return true;default:return false}},$f=e=>{switch(e){case "header":case "path":return "simple";case "cookie":case "query":return "form"}},Ue=({context:e,parameters:t})=>{if(!t||!Object.keys(t).length)return;let r={};for(let n of t){let o="$ref"in n?e.dereference(n):n;r[o.in]||(r[o.in]={}),r[o.in][o.name.toLocaleLowerCase()]=Ya({$ref:`#/todo/real/path/to/parameter/${o.name}`,context:e,parameter:o});}return r},Ya=({$ref:e,context:t,parameter:r})=>{let n=r.schema;if(!n){let l=lt({content:r.content}),f=l.find(d=>d.type==="json")||l[0];f&&(n=f.schema);}let o=n&&"$ref"in n?{allOf:[{...n}],deprecated:r.deprecated,description:r.description}:{deprecated:r.deprecated,description:r.description,...n},i=Ut({context:t,name:r.name,schema:o}),a=r.style||$f(r.in),p=r.explode!==void 0?r.explode:qf(a),m={allowReserved:r.allowReserved!==void 0?r.allowReserved:wf(r.in),explode:p,location:r.in,name:r.name,schema:ae({context:t,schema:o,state:{$ref:e,circularReferenceTracker:new Set,refStack:[e]}}),style:a};return r.deprecated&&(m.deprecated=r.deprecated),r.description&&(m.description=r.description),i&&(m.pagination=i),r.required&&(m.required=r.required),m},ep=({$ref:e,context:t,parameter:r})=>{t.ir.components||(t.ir.components={}),t.ir.components.parameters||(t.ir.components.parameters={}),t.ir.components.parameters[F(e)]=Ya({$ref:e,context:t,parameter:r});};var Mf=({$ref:e,context:t,requestBody:r})=>{let n=lt({content:r.content}),o=n.find(c=>c.type==="json")||n[0],i=o?o.schema:void 0,a={description:r.description,...i},p={schema:ae({context:t,schema:a,state:{$ref:e,circularReferenceTracker:new Set,refStack:[e]}})};return r.description&&(p.description=r.description),r.required&&(p.required=r.required),p},tp=({$ref:e,context:t,requestBody:r})=>{t.ir.components||(t.ir.components={}),t.ir.components.requestBodies||(t.ir.components.requestBodies={}),t.ir.components.requestBodies[F(e)]=Mf({$ref:e,context:t,requestBody:r});};var rp=({context:e})=>{if(e.spec.servers){e.ir.servers=e.spec.servers;return}if(typeof e.config.input.path=="string"){let t=Ze(e.config.input.path);e.ir.servers=[{url:`${t.protocol?`${t.protocol}://`:""}${t.host}${t.port?`:${t.port}`:""}`}];}e.ir.servers||(e.ir.servers=[{url:"/"}]);};var np=(e,t)=>{let r=t.timeEvent("validate"),n=[],o=new Map;if(e.paths)for(let i of Object.entries(e.paths)){let a=i[0],p=i[1];for(let c of ne){let m=p[c];if(!m)continue;let l=L({method:c,path:a});m.operationId&&(o.has(m.operationId)?n.push({code:"duplicate_key",context:{key:"operationId",value:m.operationId},message:"Duplicate `operationId` found. Each `operationId` must be unique.",path:["paths",a,c,"operationId"],severity:"error"}):o.set(m.operationId,l));}}if(e.servers){(typeof e.servers!="object"||!Array.isArray(e.servers))&&n.push({code:"invalid_type",message:"`servers` must be an array.",path:[],severity:"error"});for(let i=0;i<e.servers.length;i++){let a=e.servers[i];!a||typeof a!="object"?n.push({code:"invalid_type",context:{actual:typeof a,expected:"object"},message:"Each entry in `servers` must be an object.",path:["servers",i],severity:"error"}):a.url||n.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:n,valid:!n.some(i=>i.severity==="error")}};var Wo=e=>{if(e.config.parser.validate_EXPERIMENTAL){let o=np(e.spec,e.logger);br({context:e,result:o});}if(ur(e.config.parser.filters)){let o=dr(e.config.parser.filters,e.spec,e.logger),{graph:i}=Et(e.spec,e.logger),{resourceMetadata:a}=hr(i,e.logger),p=yr({filters:o,logger:e.logger,resourceMetadata:a});Ua({...p,logger:e.logger,preserveOrder:o.preserveOrder,spec:e.spec});}xr({context:e});let r={ids:new Map},n=new Map;if(e.spec.components){for(let o in e.spec.components.securitySchemes){let i=e.spec.components.securitySchemes[o],a="$ref"in i?e.resolveRef(i.$ref):i;n.set(o,a);}for(let o in e.spec.components.parameters){let i=`#/components/parameters/${o}`,a=e.spec.components.parameters[o],p="$ref"in a?e.resolveRef(a.$ref):a;ep({$ref:i,context:e,parameter:p});}for(let o in e.spec.components.requestBodies){let i=`#/components/requestBodies/${o}`,a=e.spec.components.requestBodies[o],p="$ref"in a?e.resolveRef(a.$ref):a;tp({$ref:i,context:e,requestBody:p});}for(let o in e.spec.components.schemas){let i=`#/components/schemas/${o}`,a=e.spec.components.schemas[o];Ja({$ref:i,context:e,schema:a});}}rp({context:e});for(let o in e.spec.paths){let i=e.spec.paths[o],a=i.$ref?{...e.resolveRef(i.$ref),...i}:i,p={context:e,operation:{description:a.description,parameters:Ue({context:e,parameters:a.parameters}),security:e.spec.security,servers:a.servers,summary:a.summary},path:o,securitySchemesMap:n,state:r};a.delete&&ft({...p,method:"delete",operation:{...p.operation,...a.delete,parameters:$({source:Ue({context:e,parameters:a.delete.parameters}),target:p.operation.parameters})}}),a.get&&ft({...p,method:"get",operation:{...p.operation,...a.get,parameters:$({source:Ue({context:e,parameters:a.get.parameters}),target:p.operation.parameters})}}),a.head&&ft({...p,method:"head",operation:{...p.operation,...a.head,parameters:$({source:Ue({context:e,parameters:a.head.parameters}),target:p.operation.parameters})}}),a.options&&ft({...p,method:"options",operation:{...p.operation,...a.options,parameters:$({source:Ue({context:e,parameters:a.options.parameters}),target:p.operation.parameters})}}),a.patch&&ft({...p,method:"patch",operation:{...p.operation,...a.patch,parameters:$({source:Ue({context:e,parameters:a.patch.parameters}),target:p.operation.parameters})}}),a.post&&ft({...p,method:"post",operation:{...p.operation,...a.post,parameters:$({source:Ue({context:e,parameters:a.post.parameters}),target:p.operation.parameters})}}),a.put&&ft({...p,method:"put",operation:{...p.operation,...a.put,parameters:$({source:Ue({context:e,parameters:a.put.parameters}),target:p.operation.parameters})}}),a.trace&&ft({...p,method:"trace",operation:{...p.operation,...a.trace,parameters:$({source:Ue({context:e,parameters:a.trace.parameters}),target:p.operation.parameters})}});}};var sp=({logger:e,operations:t,parameters:r,preserveOrder:n,requestBodies:o,responses:i,schemas:a,spec:p})=>{let c=e.timeEvent("filter-spec");if(p.components){if(p.components.parameters){let m={};if(n)for(let[l,f]of Object.entries(p.components.parameters))r.has(v("parameter",l))&&(m[l]=f);else for(let l of r){let{name:f}=re(l),d=p.components.parameters[f];d&&(m[f]=d);}p.components.parameters=m;}if(p.components.requestBodies){let m={};if(n)for(let[l,f]of Object.entries(p.components.requestBodies))o.has(v("body",l))&&(m[l]=f);else for(let l of o){let{name:f}=re(l),d=p.components.requestBodies[f];d&&(m[f]=d);}p.components.requestBodies=m;}if(p.components.responses){let m={};if(n)for(let[l,f]of Object.entries(p.components.responses))i.has(v("response",l))&&(m[l]=f);else for(let l of i){let{name:f}=re(l),d=p.components.responses[f];d&&(m[f]=d);}p.components.responses=m;}if(p.components.schemas){let m={};if(n)for(let[l,f]of Object.entries(p.components.schemas))a.has(v("schema",l))&&(m[l]=f);else for(let l of a){let{name:f}=re(l),d=p.components.schemas[f];d&&(m[f]=d);}p.components.schemas=m;}}if(p.paths)for(let m of Object.entries(p.paths)){let l=m[0],f=m[1];for(let d of ne){if(!f[d])continue;let h=v("operation",L({method:d,path:l}));t.has(h)||delete f[d];}Object.keys(f).length||delete p.paths[l];}c.timeEnd();};var op=({content:e})=>{let{mediaType:t,schema:r}=e;return r?r.type==="string"&&!r.format&&ct({mediaType:t})?{...r,format:"binary"}:r:ct({mediaType:t})?{format:"binary",type:"string"}:void 0},dt=({content:e})=>{let t=[];for(let r in e)t.push({mediaType:r,schema:e[r].schema,type:Sr({mediaType:r})});return t};var Xe=({schema:e})=>typeof e.type=="string"?[e.type]:e.type?e.type:e.properties?["object"]:[],Lf=({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);},Mn=({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");},Vf=({context:e,irSchema:t={},schema:r,state:n})=>{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 a=J({context:e,schema:i,state:n});o.push(a);}if(r.items){let i=J({context:e,schema:r.items,state:n});if(!o.length&&r.maxItems&&r.maxItems===r.minItems)o=Array(r.maxItems).fill(i);else {let a=r.items.allOf||r.items.anyOf||r.items.oneOf;a&&a.length>1&&!Xe({schema:r.items}).includes("null")?t={...t,...i}:o.push(i);}}return t=W({items:o,schema:t}),t},Df=({irSchema:e={}})=>(e.type="boolean",e),Ff=({irSchema:e={}})=>(e.type="null",e),Bf=({irSchema:e={},schema:t})=>(e.type=t.type,e),Kf=({context:e,irSchema:t={},schema:r,state:n})=>{t.type="object";let o={};for(let i in r.properties){let a=r.properties[i];if(typeof a!="boolean"){let p=J({context:e,schema:a,state:n});o[i]=p;}}if(Object.keys(o).length&&(t.properties=o),r.additionalProperties===void 0)t.properties||(t.additionalProperties={type:"unknown"});else if(typeof r.additionalProperties=="boolean")n.inAllOf&&r.additionalProperties===false&&(!r.properties||Object.keys(r.properties).length===0)&&(!r.patternProperties||Object.keys(r.patternProperties).length===0)||(t.additionalProperties={type:r.additionalProperties?"unknown":"never"});else {let i=J({context:e,schema:r.additionalProperties,state:n});t.additionalProperties=i;}if(r.patternProperties){let i={};for(let a in r.patternProperties){let p=r.patternProperties[a],c=J({context:e,schema:p,state:n});i[a]=c;}Object.keys(i).length&&(t.patternProperties=i);}return r.propertyNames&&(t.propertyNames=J({context:e,schema:r.propertyNames,state:n})),r.required&&(t.required=r.required),t},Wf=({irSchema:e={}})=>(e.type="string",e),ut=({schema:e})=>{let t={};return Lf({irSchema:t,schema:e}),t},zf=({context:e,schema:t,state:r})=>{let n=ut({schema:t}),o=[],i=Xe({schema:t}),a=t.allOf;for(let p of a){let c=r.inAllOf;"$ref"in p||(r.inAllOf=true);let m=J({context:e,schema:p,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),p.$ref){let l=e.resolveRef(p.$ref);if(l.discriminator&&r.$ref){let f=Qe(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"})),u={properties:{[l.discriminator.propertyName]:d.length>1?{items:d,logicalOperator:"or"}:d[0]},type:"object"};l.required?.includes(l.discriminator.propertyName)&&(u.required=[l.discriminator.propertyName]),o.push(u);}}}}if(i.includes("object")){let p=Xt({context:e,schema:{...t,type:"object"},state:r});if(p.properties){for(let c of p.required??[])if(!p.properties[c])for(let m of a){let l=m.$ref?e.resolveRef(m.$ref):m;if(Xe({schema:l}).includes("object")){let f=Xt({context:e,schema:{...l,type:"object"},state:r});if(f.properties?.[c]){p.properties[c]=f.properties[c];break}}}o.push(p);}}if(n=W({items:o,logicalOperator:"and",mutateSchemaOneItem:true,schema:n}),i.includes("null")){let p=[{type:"null"}];o.length&&p.unshift(n),n={items:p,logicalOperator:"or"};}return n},_f=({context:e,schema:t,state:r})=>{let n=ut({schema:t}),o=[],i=Xe({schema:t}),a=t.anyOf;for(let p of a){let c=J({context:e,schema:p,state:r});if(t.discriminator&&c.$ref!=null){let l=Qe(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"}),n=W({items:o,mutateSchemaOneItem:true,schema:n}),i.includes("object")){let p=Xt({context:e,schema:{...t,type:"object"},state:r});p.properties&&(n={items:[n,p],logicalOperator:"and"});}return n},Hf=({context:e,schema:t,state:r})=>{let n=ut({schema:t});n.type="enum";let o=[],i=Xe({schema:t});for(let[a,p]of t.enum.entries()){let c=typeof p,m;if(c==="string"||c==="number"||c==="boolean"?m=c:c==="object"&&Array.isArray(p)?m="array":p===null?i.includes("null")&&(m="null"):console.warn("\u{1F6A8}",`unhandled "${c}" typeof value "${p}" for enum`,t.enum),!m)continue;let l=Xt({context:e,schema:{const:p,description:t["x-enum-descriptions"]?.[a],title:t["x-enum-varnames"]?.[a]??t["x-enumNames"]?.[a],type:m},state:r});o.push(l);}return n=W({items:o,schema:n}),n},Qf=({context:e,schema:t,state:r})=>{let n=ut({schema:t}),o=[],i=Xe({schema:t}),a=t.oneOf;for(let p of a){let c=J({context:e,schema:p,state:r});if(t.discriminator&&c.$ref!=null){let l=Qe(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"}),n=W({items:o,mutateSchemaOneItem:true,schema:n}),i.includes("object")){let p=Xt({context:e,schema:{...t,type:"object"},state:r});p.properties&&(n={items:[n,p],logicalOperator:"and"});}return n},Zf=({context:e,schema:t,state:r})=>{if(!t.$ref.startsWith("#/components/")&&!r.circularReferenceTracker.has(t.$ref)){r.refStack.push(t.$ref);let p=e.resolveRef(t.$ref),c=r.$ref;r.$ref=t.$ref;let m=J({context:e,schema:p,state:r});return r.$ref=c,r.refStack.pop(),m}let o=ut({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 p=e.resolveRef(t.$ref),c=r.$ref;r.$ref=t.$ref,J({context:e,schema:p,state:r}),r.circularRef&&r.refStack[0]===r.circularRef&&(o.circular=true),r.$ref=c,r.refStack.pop();}let a=[];return a.push(i),t.type&&typeof t.type!="string"&&t.type.includes("null")&&a.push({type:"null"}),o=W({items:a,mutateSchemaOneItem:true,schema:o}),o},Xt=({context:e,irSchema:t,schema:r,state:n})=>{switch(t||(t=ut({schema:r}),Mn({irSchema:t,schema:r})),r.type){case "array":return Vf({context:e,irSchema:t,schema:r,state:n});case "boolean":return Df({irSchema:t});case "integer":case "number":return Bf({irSchema:t,schema:r});case "null":return Ff({irSchema:t});case "object":return Kf({context:e,irSchema:t,schema:r,state:n});case "string":return Wf({irSchema:t});default:return ip({irSchema:t,schema:r})}},Uf=({context:e,irSchema:t,schema:r,state:n})=>{t||(t=ut({schema:r}));let o={};Mn({irSchema:o,schema:r}),r.type.includes("null")&&o.default===null&&delete o.default;let i=[];for(let a of r.type)if(a==="null")i.push({type:"null"});else {let p=Xt({context:e,irSchema:{...o},schema:{...r,type:a},state:n});i.push(p);}return t=W({items:i,schema:t}),t},Xf=({context:e,schema:t,state:r})=>{let n=ut({schema:t});Mn({irSchema:n,schema:t});let o=Xe({schema:t});return o.length===1?Xt({context:e,irSchema:n,schema:{...t,type:o[0]},state:r}):Uf({context:e,irSchema:n,schema:{...t,type:o},state:r})},ip=({irSchema:e,schema:t})=>(e||(e=ut({schema:t})),e.type="unknown",Mn({irSchema:e,schema:t}),e),J=({context:e,schema:t,state:r})=>(r||(r={circularReferenceTracker:new Set,refStack:[]}),r.$ref&&r.circularReferenceTracker.add(r.$ref),t.$ref?Zf({context:e,schema:t,state:r}):t.enum?Hf({context:e,schema:t,state:r}):t.allOf?zf({context:e,schema:t,state:r}):t.anyOf?_f({context:e,schema:t,state:r}):t.oneOf?Qf({context:e,schema:t,state:r}):t.type||t.properties?Xf({context:e,schema:t,state:r}):ip({schema:t})),ap=({$ref:e,context:t,schema:r})=>{t.ir.components||(t.ir.components={}),t.ir.components.schemas||(t.ir.components.schemas={}),t.ir.components.schemas[F(e)]=J({context:t,schema:r,state:{$ref:e,circularReferenceTracker:new Set,refStack:[e]}});};var pp=e=>e.includes("boolean")||e.includes("integer")||e.includes("number")||e.includes("string"),Gt=({context:e,name:t,schema:r})=>{if(Oe(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 a=dt({content:o.content}),p=a.find(c=>c.type==="json")||a[0];p?.schema&&(i=p.schema);}return i?Gt({context:e,name:t,schema:i}):false}return Gt({context:e,name:t,schema:o})}for(let o in r.properties)if(Oe(e.config.parser.pagination).test(o)){let a=r.properties[o];if(typeof a!="boolean"){let p=Xe({schema:a});if(!p.length){let m=(a.anyOf??a.oneOf??[]).filter(l=>l.type!=="null");if(m.length===1){let l=Xe({schema:m[0]});if(pp(l))return o}}if(pp(p))return o}}for(let o of r.allOf??[]){let i=Gt({context:e,name:t,schema:o});if(i)return i}return false};var Gf=({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);},Jf=({context:e,method:t,operation:r,path:n,state:o})=>{let i={id:_t({context:e,id:r.operationId,method:t,path:n,state:o}),method:t,path:n};return r.operationId&&(i.operationId=r.operationId),Gf({irOperation:i,operation:r}),i},Yf=({context:e,method:t,operation:r,path:n,securitySchemesMap:o,state:i})=>{let a=Jf({context:e,method:t,operation:r,path:n,state:i});if(r.parameters&&(a.parameters=r.parameters),r.requestBody){let p="$ref"in r.requestBody?e.resolveRef(r.requestBody.$ref):r.requestBody,c=dt({content:p.content}),m=c.find(l=>l.type==="json")||c[0];if(m){let l=Gt({context:e,name:"",schema:{description:p.description,...m.schema}});a.body={mediaType:m.mediaType,schema:J({context:e,schema:{description:p.description,..."$ref"in r.requestBody?r.requestBody:m.schema},state:void 0})},l&&(a.body.pagination=l),p.required&&(a.body.required=p.required),m.type&&(a.body.type=m.type);}}for(let p in r.responses){a.responses||(a.responses={});let c=r.responses[p],m="$ref"in c?e.resolveRef(c.$ref):c,l=dt({content:m.content}),f=l.find(d=>d.type==="json")||l[0];f?a.responses[p]={mediaType:f.mediaType,schema:J({context:e,schema:{description:m.description,...op({content:f})},state:void 0})}:a.responses[p]={schema:{description:m.description,type:p==="204"?"void":"unknown"}};}if(r.security){let p=new Map;for(let c of r.security)for(let m in c){let l=o.get(m);l&&p.set(m,l);}p.size&&(a.security=Array.from(p.values()));}return a},cp=({context:e,method:t,operation:r,path:n,securitySchemesMap:o,state:i})=>(r.servers&&(e.ir.servers=[...e.ir.servers??[],...r.servers]),{parsed:Yf({context:e,method:t,operation:r,path:n,securitySchemesMap:o,state:i})}),yt=({context:e,method:t,path:r,...n})=>{e.ir.paths||(e.ir.paths={}),e.ir.paths[r]||(e.ir.paths[r]={});let{parsed:o}=cp({context:e,method:t,path:r,...n});e.ir.paths[r][t]=o;},ht=({context:e,key:t,method:r,...n})=>{e.ir.webhooks||(e.ir.webhooks={}),e.ir.webhooks[t]||(e.ir.webhooks[t]={});let{parsed:o}=cp({context:e,method:r,path:t,...n});e.ir.webhooks[t][r]=o;};var ed=e=>{switch(e){case "query":return false;default:return}},td=e=>{switch(e){case "deepObject":case "form":return true;default:return false}},rd=e=>{switch(e){case "header":case "path":return "simple";case "cookie":case "query":return "form"}},X=({context:e,parameters:t})=>{if(!t||!Object.keys(t).length)return;let r={};for(let n of t){let o="$ref"in n?e.dereference(n):n;r[o.in]||(r[o.in]={}),r[o.in][o.name.toLocaleLowerCase()]=mp({$ref:`#/todo/real/path/to/parameter/${o.name}`,context:e,parameter:o});}return r},mp=({$ref:e,context:t,parameter:r})=>{let n=r.schema;if(!n){let l=dt({content:r.content}),f=l.find(d=>d.type==="json")||l[0];f&&(n=f.schema);}let o={deprecated:r.deprecated,description:r.description,...n},i=Gt({context:t,name:r.name,schema:o}),a=r.style||rd(r.in),p=r.explode!==void 0?r.explode:td(a),m={allowReserved:r.allowReserved!==void 0?r.allowReserved:ed(r.in),explode:p,location:r.in,name:r.name,schema:J({context:t,schema:o,state:{$ref:e,circularReferenceTracker:new Set,refStack:[e]}}),style:a};return r.deprecated&&(m.deprecated=r.deprecated),r.description&&(m.description=r.description),i&&(m.pagination=i),r.required&&(m.required=r.required),m},lp=({$ref:e,context:t,parameter:r})=>{t.ir.components||(t.ir.components={}),t.ir.components.parameters||(t.ir.components.parameters={}),t.ir.components.parameters[F(e)]=mp({$ref:e,context:t,parameter:r});};var nd=({$ref:e,context:t,requestBody:r})=>{let n=dt({content:r.content}),o=n.find(c=>c.type==="json")||n[0],i=o?o.schema:void 0,a={description:r.description,...i},p={schema:J({context:t,schema:a,state:{$ref:e,circularReferenceTracker:new Set,refStack:[e]}})};return r.description&&(p.description=r.description),r.required&&(p.required=r.required),p},fp=({$ref:e,context:t,requestBody:r})=>{t.ir.components||(t.ir.components={}),t.ir.components.requestBodies||(t.ir.components.requestBodies={}),t.ir.components.requestBodies[F(e)]=nd({$ref:e,context:t,requestBody:r});};var dp=({context:e})=>{if(e.spec.servers){e.ir.servers=e.spec.servers;return}if(typeof e.config.input.path=="string"){let t=Ze(e.config.input.path);e.ir.servers=[{url:`${t.protocol?`${t.protocol}://`:""}${t.host}${t.port?`:${t.port}`:""}`}];}e.ir.servers||(e.ir.servers=[{url:"/"}]);};var up=(e,t)=>{let r=t.timeEvent("validate"),n=[],o=new Map;if(e.paths)for(let i of Object.entries(e.paths)){let a=i[0],p=i[1];for(let c of ne){let m=p[c];if(!m)continue;let l=L({method:c,path:a});m.operationId&&(o.has(m.operationId)?n.push({code:"duplicate_key",context:{key:"operationId",value:m.operationId},message:"Duplicate `operationId` found. Each `operationId` must be unique.",path:["paths",a,c,"operationId"],severity:"error"}):o.set(m.operationId,l));}}if(e.servers){(typeof e.servers!="object"||!Array.isArray(e.servers))&&n.push({code:"invalid_type",message:"`servers` must be an array.",path:[],severity:"error"});for(let i=0;i<e.servers.length;i++){let a=e.servers[i];!a||typeof a!="object"?n.push({code:"invalid_type",context:{actual:typeof a,expected:"object"},message:"Each entry in `servers` must be an object.",path:["servers",i],severity:"error"}):a.url||n.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:n,valid:!n.some(i=>i.severity==="error")}};var yp=({context:e,securitySchemesMap:t})=>{let r={ids:new Map};for(let n in e.spec.webhooks){let o=e.spec.webhooks[n],i="$ref"in o?{...e.resolveRef(o.$ref),...o}:o,a={context:e,key:n,operation:{description:i.description,parameters:X({context:e,parameters:i.parameters}),security:e.spec.security,servers:i.servers,summary:i.summary},securitySchemesMap:t,state:r};i.delete&&ht({...a,method:"delete",operation:{...a.operation,...i.delete,parameters:$({source:X({context:e,parameters:i.delete.parameters}),target:a.operation.parameters})}}),i.get&&ht({...a,method:"get",operation:{...a.operation,...i.get,parameters:$({source:X({context:e,parameters:i.get.parameters}),target:a.operation.parameters})}}),i.head&&ht({...a,method:"head",operation:{...a.operation,...i.head,parameters:$({source:X({context:e,parameters:i.head.parameters}),target:a.operation.parameters})}}),i.options&&ht({...a,method:"options",operation:{...a.operation,...i.options,parameters:$({source:X({context:e,parameters:i.options.parameters}),target:a.operation.parameters})}}),i.patch&&ht({...a,method:"patch",operation:{...a.operation,...i.patch,parameters:$({source:X({context:e,parameters:i.patch.parameters}),target:a.operation.parameters})}}),i.post&&ht({...a,method:"post",operation:{...a.operation,...i.post,parameters:$({source:X({context:e,parameters:i.post.parameters}),target:a.operation.parameters})}}),i.put&&ht({...a,method:"put",operation:{...a.operation,...i.put,parameters:$({source:X({context:e,parameters:i.put.parameters}),target:a.operation.parameters})}}),i.trace&&ht({...a,method:"trace",operation:{...a.operation,...i.trace,parameters:$({source:X({context:e,parameters:i.trace.parameters}),target:a.operation.parameters})}});}};var zo=e=>{if(e.config.parser.validate_EXPERIMENTAL){let o=up(e.spec,e.logger);br({context:e,result:o});}if(ur(e.config.parser.filters)){let o=dr(e.config.parser.filters,e.spec,e.logger),{graph:i}=Et(e.spec,e.logger),{resourceMetadata:a}=hr(i,e.logger),p=yr({filters:o,logger:e.logger,resourceMetadata:a});sp({...p,logger:e.logger,preserveOrder:o.preserveOrder,spec:e.spec});}xr({context:e});let r={ids:new Map},n=new Map;if(e.spec.components){for(let o in e.spec.components.securitySchemes){let i=e.spec.components.securitySchemes[o],a="$ref"in i?e.resolveRef(i.$ref):i;n.set(o,a);}for(let o in e.spec.components.parameters){let i=`#/components/parameters/${o}`,a=e.spec.components.parameters[o],p="$ref"in a?e.resolveRef(a.$ref):a;lp({$ref:i,context:e,parameter:p});}for(let o in e.spec.components.requestBodies){let i=`#/components/requestBodies/${o}`,a=e.spec.components.requestBodies[o],p="$ref"in a?e.resolveRef(a.$ref):a;fp({$ref:i,context:e,requestBody:p});}for(let o in e.spec.components.schemas){let i=`#/components/schemas/${o}`,a=e.spec.components.schemas[o];ap({$ref:i,context:e,schema:a});}}dp({context:e});for(let o in e.spec.paths){let i=e.spec.paths[o],a=i.$ref?{...e.resolveRef(i.$ref),...i}:i,p={context:e,operation:{description:a.description,parameters:X({context:e,parameters:a.parameters}),security:e.spec.security,servers:a.servers,summary:a.summary},path:o,securitySchemesMap:n,state:r};a.delete&&yt({...p,method:"delete",operation:{...p.operation,...a.delete,parameters:$({source:X({context:e,parameters:a.delete.parameters}),target:p.operation.parameters})}}),a.get&&yt({...p,method:"get",operation:{...p.operation,...a.get,parameters:$({source:X({context:e,parameters:a.get.parameters}),target:p.operation.parameters})}}),a.head&&yt({...p,method:"head",operation:{...p.operation,...a.head,parameters:$({source:X({context:e,parameters:a.head.parameters}),target:p.operation.parameters})}}),a.options&&yt({...p,method:"options",operation:{...p.operation,...a.options,parameters:$({source:X({context:e,parameters:a.options.parameters}),target:p.operation.parameters})}}),a.patch&&yt({...p,method:"patch",operation:{...p.operation,...a.patch,parameters:$({source:X({context:e,parameters:a.patch.parameters}),target:p.operation.parameters})}}),a.post&&yt({...p,method:"post",operation:{...p.operation,...a.post,parameters:$({source:X({context:e,parameters:a.post.parameters}),target:p.operation.parameters})}}),a.put&&yt({...p,method:"put",operation:{...p.operation,...a.put,parameters:$({source:X({context:e,parameters:a.put.parameters}),target:p.operation.parameters})}}),a.trace&&yt({...p,method:"trace",operation:{...p.operation,...a.trace,parameters:$({source:X({context:e,parameters:a.trace.parameters}),target:p.operation.parameters})}});}yp({context:e,securitySchemesMap:n});};var Ln=["connect","delete","get","head","options","patch","post","put","trace"];function Vn(e="1.0"){return String(e).replace(/^v/gi,"")}var Tr="#/components/parameters/",Dn="#/components/schemas/";var Rr=({config:e,name:t})=>{let r=e.plugins["@hey-api/sdk"];if(r?.config.classNameBuilder){let n="";return typeof r.config.classNameBuilder=="function"?n=r.config.classNameBuilder(t):n=r.config.classNameBuilder.replace("{{name}}",t),n}return t},_o=e=>A().plugins["@hey-api/typescript"]?.config.style==="PascalCase"?w({case:"PascalCase",value:e}):e,hp=e=>{let t=_o(e);return ve(t).replace(fe,"_$1")};var gp=(e,t)=>{if(e.enum&&!t.includes("boolean"))return "enum"},Ho=e=>Ar(e).includes("null"),Nt=e=>e.nullable===true||Ho(e),Ar=({type:e})=>Array.isArray(e)?e:e?[e]:[];var Xr=e=>e.trim().replace(/^#\/definitions\//,"").replace(/^#\/parameters\//,"").replace(/^#\/responses\//,"").replace(/^#\/securityDefinitions\//,"").replace(/^#\/components\/schemas\//,"").replace(/^#\/components\/responses\//,"").replace(/^#\/components\/parameters\//,"").replace(/^#\/components\/examples\//,"").replace(/^#\/components\/requestBodies\//,"").replace(/^#\/components\/headers\//,"").replace(/^#\/components\/securitySchemes\//,"").replace(/^#\/components\/links\//,"").replace(/^#\/components\/callbacks\//,"");var xp=(e,t)=>{if(t==="binary")return "binary";switch(e){case "any":case "object":case "unknown":return "unknown";case "array":return "unknown[]";case "boolean":return "boolean";case "byte":case "double":case "float":case "int":case "integer":case "long":case "number":case "short":return "number";case "char":case "date":case "date-time":case "password":case "string":return "string";case "file":return "binary";case "null":return "null";case "void":return "void";default:return}},bp=/(?<!`1)\[.*\]$/g,N=({debug:e,format:t,type:r="unknown"})=>{let n={$refs:[],base:"unknown",imports:[],isNullable:false,template:null,type:"unknown"};if(Array.isArray(r)){let a=r.filter(p=>p!=="null").map(p=>xp(p,t)).filter(Boolean).join(" | ");return n.type=a,n.base=a,n.isNullable=Ho({type:r}),n}let o=xp(r,t);if(o)return n.type=o,n.base=o,n;let i=decodeURIComponent(Xr(r));if(bp.lastIndex=0,bp.test(i)){let a=i.match(/(.*?)\[(.*)\]$/);if(a?.length){let p=N({debug:e,type:ve(a[1])}),c=N({debug:e,type:ve(a[2])});return p.type==="unknown[]"?(n.type=`${c.type}[]`,n.base=`${c.type}`,p.$refs=[],p.imports=[]):c.type?(n.type=`${p.type}<${c.type}>`,n.base=p.type,n.template=c.type):(n.type=p.type,n.base=p.type,n.template=p.type),n.$refs=[...n.$refs,...p.$refs,...c.$refs],n.imports=[...n.imports,...p.imports,...c.imports],n}}if(i){let a=_o(ve(i));return r.startsWith(Tr)&&(a=`Parameter${a}`),n.type=a,n.base=a,r.startsWith("#")&&(n.$refs=[...n.$refs,decodeURIComponent(r)]),n.imports=[...n.imports,a],n}return n};function Ge(e,t,r){return r.indexOf(e)===t}var Pr=(e,t)=>{if(!Array.isArray(t))return [];let r=(e["x-enum-descriptions"]??[]).filter(o=>typeof o=="string"),n=(e["x-enum-varnames"]??e["x-enumNames"]??[]).filter(o=>typeof o=="string");return t.filter(Ge).filter(o=>typeof o=="number"||typeof o=="string").map((o,i)=>({customDescription:r[i],customName:n[i],description:void 0,value:o}))};var Y=e=>e?.replace(/\\/g,"\\\\").replace(/'/g,"\\'");var Fn=({definition:e,getModel:t,openApi:r,types:n})=>{let o=[];return Object.entries(e.properties??{}).forEach(([i,a])=>{let p=!!e.required?.includes(i);if(a.$ref){let c=N({type:a.$ref});o.push({$refs:[],base:c.base,description:a.description||null,enum:[],enums:[],exclusiveMaximum:a.exclusiveMaximum,exclusiveMinimum:a.exclusiveMinimum,export:"reference",format:a.format,imports:c.imports,in:"",isDefinition:false,isNullable:a["x-nullable"]===true,isReadOnly:a.readOnly===true,isRequired:p,link:null,maxItems:a.maxItems,maxLength:a.maxLength,maxProperties:a.maxProperties,maximum:a.maximum,minItems:a.minItems,minLength:a.minLength,minProperties:a.minProperties,minimum:a.minimum,multipleOf:a.multipleOf,name:Te(i),pattern:Y(a.pattern),properties:[],template:c.template,type:c.type,uniqueItems:a.uniqueItems});}else {let c=t({definition:a,openApi:r,types:n});o.push({$refs:[],base:c.base,description:a.description||null,enum:c.enum,enums:c.enums,exclusiveMaximum:a.exclusiveMaximum,exclusiveMinimum:a.exclusiveMinimum,export:c.export,format:a.format,imports:c.imports,in:"",isDefinition:false,isNullable:a["x-nullable"]===true,isReadOnly:a.readOnly===true,isRequired:p,link:c.link,maxItems:a.maxItems,maxLength:a.maxLength,maxProperties:a.maxProperties,maximum:a.maximum,minItems:a.minItems,minLength:a.minLength,minProperties:a.minProperties,minimum:a.minimum,multipleOf:a.multipleOf,name:Te(i),pattern:Y(a.pattern),properties:c.properties,template:c.template,type:c.type,uniqueItems:a.uniqueItems});}}),o};var sd=/~1/g,od=/~0/g;function _(e,t){if(t.$ref){let r=t.$ref.replace(/^#/g,"").split("/").filter(Boolean),n=e;return r.forEach(o=>{let i=decodeURIComponent(o.replace(sd,"/").replace(od,"~"));if(n.hasOwnProperty(i))n=n[i];else throw new Error(`Could not find reference: "${t.$ref}"`)}),n}return t}var Sp=({definitions:e,getModel:t,openApi:r,required:n,types:o})=>e.reduce((i,a)=>{if(a.$ref){let p=_(r,a);return [...i,...t({definition:p,openApi:r,types:o}).properties]}return [...i,...t({definition:a,openApi:r,types:o}).properties]},[]).filter(i=>!i.isRequired&&n.includes(i.name)).map(i=>({...i,isRequired:true}));var Op=({definition:e,definitions:t,getModel:r,openApi:n,type:o,types:i})=>{let a={$refs:[],enums:[],export:o,imports:[],properties:[]},p=[];if(t.map(c=>r({definition:c,openApi:n,types:i})).filter(c=>{let m=c.properties.length,l=c.enums.length;return !(c.type==="unknown"&&!m&&!l)}).forEach(c=>{a.imports.push(...c.imports),a.enums.push(...c.enums),a.properties.push(c);}),e.required&&o==="all-of"){let c=Sp({definitions:t,getModel:r,openApi:n,required:e.required,types:i});c.forEach(m=>{a.imports.push(...m.imports),a.enums.push(...m.enums);}),p.push(...c);}if(e.properties){let c=Fn({definition:e,getModel:r,openApi:n,types:i});c.forEach(m=>{a.imports.push(...m.imports),a.enums.push(...m.enums),m.export==="enum"&&a.enums.push(m);}),p.push(...c);}return p.length&&a.properties.push({$refs:[],base:"unknown",description:"",enum:[],enums:[],export:"interface",imports:[],in:"",isDefinition:false,isNullable:false,isReadOnly:false,isRequired:false,link:null,name:"properties",properties:p,template:null,type:"unknown"}),a};var Je=({definition:e,isDefinition:t=false,meta:r,openApi:n,types:o})=>{let i={$refs:[],base:"unknown",description:e.description||null,enum:[],enums:[],exclusiveMaximum:e.exclusiveMaximum,exclusiveMinimum:e.exclusiveMinimum,export:"interface",format:e.format,imports:[],in:"",isDefinition:t,isNullable:e["x-nullable"]===true,isReadOnly:e.readOnly===true,isRequired:false,link:null,maxItems:e.maxItems,maxLength:e.maxLength,maxProperties:e.maxProperties,maximum:e.maximum,meta:r,minItems:e.minItems,minLength:e.minLength,minProperties:e.minProperties,minimum:e.minimum,multipleOf:e.multipleOf,name:r?.name??"",pattern:Y(e.pattern),properties:[],template:null,type:"unknown",uniqueItems:e.uniqueItems};if(e.$ref){let a=N({type:e.$ref});return i.export="reference",i.type=a.type,i.base=a.base,i.template=a.template,i.imports.push(...a.imports),i}if(e.enum&&e.type!=="boolean"){let a=Pr(e,e.enum);if(a.length)return i.base="string",i.enum=[...i.enum,...a],i.export="enum",i.type="string",i}if(e.type==="array"&&e.items)if(e.items.$ref){let a=N({type:e.items.$ref});return i.export="array",i.type=a.type,i.base=a.base,i.template=a.template,i.imports.push(...a.imports),i}else {let a=Je({definition:e.items,openApi:n,types:o});return i.export="array",i.type=a.type,i.base=a.base,i.template=a.template,i.link=a,i.imports.push(...a.imports),i}if(e.type==="object"&&typeof e.additionalProperties=="object")if(e.additionalProperties.$ref){let a=N({type:e.additionalProperties.$ref});return i.export="dictionary",i.type=a.type,i.base=a.base,i.template=a.template,i.imports.push(...a.imports),i}else {let a=Je({definition:e.additionalProperties,openApi:n,types:o});return i.export="dictionary",i.type=a.type,i.base=a.base,i.template=a.template,i.link=a,i.imports.push(...a.imports),i}if(e.allOf?.length){let a=Op({definition:e,definitions:e.allOf,getModel:Je,openApi:n,type:"all-of",types:o});return i.export=a.export,i.imports.push(...a.imports),i.properties.push(...a.properties),i.enums=[...i.enums,...a.enums],i}if(e.type==="object")return i.export="interface",i.type="unknown",i.base="unknown",e.properties&&Fn({definition:e,getModel:Je,openApi:n,types:o}).forEach(p=>{i.imports.push(...p.imports),i.enums=[...i.enums,...p.enums],i.properties.push(p),p.export==="enum"&&(i.enums=[...i.enums,p]);}),i;if(e.type){let a=N({format:e.format,type:e.type});return i.export="generic",i.type=a.type,i.base=a.base,i.template=a.template,i.imports.push(...a.imports),i}return i};var Tp=e=>{let t={},r=[];return Object.entries(e.definitions??{}).forEach(([n,o])=>{let a=N({type:n}).base.replace(fe,"_$1"),p={$ref:`#/definitions/${n}`,name:a};t[a]=p;let c=Je({definition:o,isDefinition:true,meta:p,openApi:e,types:t});r=[...r,c];}),{models:r,types:t}};function Qo(e,t){let r=e.toLocaleLowerCase(),n=t.toLocaleLowerCase();return r.localeCompare(n,"en")}var Gr=(e,t)=>Qo(e.name,t.name);function Rp(e){return e.sort(Gr)}var id=(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()},Ap=e=>e.map(t=>Bn(t.value,true)).filter(Ge).join(" | "),Bn=(e,t=false)=>typeof e=="string"?e.includes("'")&&t?`"${e}"`:`'${e}'`:e,Kn=e=>{let t=id(e.value,e.customName),r=Bn(e.value);return {key:t,value:r}},Wn=e=>{let t=e.enum.map(r=>Kn(r)).sort((r,n)=>Qo(r.key,n.key)).map(r=>`${r.key}=${r.value}`).join("&");return {$ref:`enum/${e.name}/${t}`,name:ve(ir(e.name))}};var Pp=e=>{let r=`Parameter${N({type:e}).base.replace(fe,"_$1")}`;return {$ref:Tr+e,name:r}},zn=e=>{let t=hp(e);return {$ref:Dn+e,name:t}};var Jr=e=>e.format==="date"||e.format==="date-time",Zo=e=>{let t=A();return e.base==="binary"?s.typeUnionNode({types:["Blob","File"]}):t.plugins["@hey-api/transformers"]?.config.dates&&Jr(e)?s.typeNode("Date"):s.typeNode(e.base)},ad=e=>{let t=e.base==="null"?false:e.isNullable,r=Zo(e);if(e.export==="reference"&&e.$refs.length===1&&e.$refs[0].startsWith(Dn)){let o=zn(e.base);r=s.typeNode(o.name);}return s.typeUnionNode({isNullable:t,types:[r]})},pd=e=>{if(e.link){if(Array.isArray(e.link)){let t=e.link.map(n=>Pe(n));return s.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(Pe(e.link));return s.typeTupleNode({isNullable:e.isNullable,types:t})}return s.typeArrayNode([Pe(e.link)],e.isNullable)}return s.typeArrayNode([Zo(e)],e.isNullable)},cd=e=>{let t=e.enum.map(r=>Bn(r.value));return s.typeUnionNode({isNullable:e.isNullable,types:t})},md=e=>{let t=e.link&&!Array.isArray(e.link)?Pe(e.link):Zo(e);return s.typeRecordNode(["string"],[t],e.isNullable,true)},Ep=({model:e,style:t})=>{let r=e.properties.map(o=>s.nodeToString({node:Pe(o),unescape:true})).filter(Ge),n=t==="union"?s.typeUnionNode({isNullable:e.isNullable&&!e.properties.find(o=>o.isNullable),types:r}):s.typeIntersectionNode({isNullable:e.isNullable,types:r});return e.meta?n:s.typeParenthesizedNode({type:n})},ld=e=>{if(!e.properties.length)return s.typeNode("unknown");let t=A(),r=Q(t),n=e.properties.map(o=>{let i=o.isRequired?"":"?",a=Pe(o),p=r?/^\dXX$/.test(o.name)?Te(o.name):o.name:Te(ir(Uo(o.name)));return o.name==="[key: string]"&&(p=o.name,i&&(i="",a=s.typeUnionNode({types:[a,"undefined"]}))),{comment:[o.description&&z(o.description),o.deprecated&&"@deprecated"],isReadOnly:o.isReadOnly,isRequired:i==="",name:p,type:a}});return s.typeInterfaceNode({isNullable:e.isNullable,properties:n,useLegacyResolution:true})},Pe=e=>{switch(e.export){case "all-of":return Ep({model:e,style:"intersection"});case "any-of":case "one-of":return Ep({model:e,style:"union"});case "array":return pd(e);case "dictionary":return md(e);case "enum":return cd(e);case "interface":return ld(e);case "const":case "generic":case "reference":default:return ad(e)}},Ee=({client:e,count:t=1,create:r=false,meta:n,nameTransformer:o})=>{let i={created:false,name:""},a=n.name;o&&(a=o(a)),t>1&&(a=`${a}${t}`);let p=e.types[a];return p?p.$ref===n.$ref?i={created:false,name:a}:i=Ee({client:e,count:t+1,create:r,meta:n,nameTransformer:o}):r&&(e.types[a]=n,i={created:true,name:a}),i},Ip=({client:e,name:t})=>{let r={deleted:false,name:""};return e.types[t]&&(delete e.types[t],r={deleted:true,name:t}),r},Uo=e=>{let t=A();return Q(t)?w({case:"camelCase",value:wo(e)}).replace(fe,"_$1"):e};var _n=e=>{let t=e.find(r=>r.in==="header");return t?t.name:null},Ye=e=>e.some(r=>r.isRequired),Hn=e=>{if(e==="default")return "default";if(e==="1XX")return "1XX";if(e==="2XX")return "2XX";if(e==="3XX")return "3XX";if(e==="4XX")return "4XX";if(e==="5XX")return "5XX";if(/\d{3}/g.test(e)){let t=Number.parseInt(e,10);if(t>=100&&t<600)return t}return null},Qn=(e,t)=>e.code>t.code?1:e.code<t.code?-1:0,fd=e=>e==="3XX"||e==="4XX"||e==="5XX"||typeof e=="number"&&e>=300,kp=e=>e==="2XX"||typeof e=="number"&&e>=200&&e<300,dd=(e,t)=>{let r=[],n=m=>{r.includes(m)||(r=[...r,m]);};t.some(({code:m})=>kp(m))||n("success");let i=(e.description??"").toLocaleLowerCase(),a=e.$refs.join("|").toLocaleLowerCase(),p=["error","problem"];return ["success"].some(m=>i.includes(m)||a.includes(m))&&n("success"),p.some(m=>i.includes(m)||a.includes(m))&&n("error"),r.length||n("error"),r},Zn=({config:e,operationKey:t})=>{let r=e.plugins["@hey-api/sdk"]?.config.filter?new RegExp(e.plugins["@hey-api/sdk"]?.config.filter):void 0;return !r||r.test(t)},Un=({config:e,method:t,operationId:r,path:n})=>{if(e.plugins["@hey-api/sdk"]?.config.operationId&&r)return w({case:"camelCase",value:pt(r)});let o=n;return Q(e)&&(o=o.replace(/[^/]*?{api-version}.*?\//g,"")),o=o.replace(/{(.*?)}/g,"by-$1").replace(/[/:+]/g,"-"),w({case:"camelCase",value:`${t}-${o}`})},Xn=e=>{let t=A();return !Q(t)||e.prop!=="api-version"},Gn=e=>{let t=A();return Q(t)?Uo(e.prop):e.prop},Jn=e=>e.map(t=>{let{code:r}=t;return r==="default"?t.responseTypes=dd(t,e):kp(r)?t.responseTypes=["success"]:fd(r)&&(t.responseTypes=["error"]),t});var H=(e,t)=>{if(e.default===void 0||e.default===null)return e.default;switch(Ar(e).find(o=>o!=="null")||typeof e.default){case "int":case "integer":case "number":if(t?.export==="enum"&&t.enum?.[e.default]){let{value:o}=t.enum[e.default];return o}return e.default;case "array":case "boolean":case "object":case "string":return e.default;default:return}};var jp=({openApi:e,parameter:t,types:r})=>{let n={$refs:[],base:"unknown",description:t.description||null,enum:[],enums:[],exclusiveMaximum:t.exclusiveMaximum,exclusiveMinimum:t.exclusiveMinimum,export:"interface",format:t.format,imports:[],in:t.in,isDefinition:false,isNullable:t["x-nullable"]===true,isReadOnly:false,isRequired:t.required===true,link:null,maxItems:t.maxItems,maxLength:t.maxLength,maximum:t.maximum,mediaType:null,minItems:t.minItems,minLength:t.minLength,minimum:t.minimum,multipleOf:t.multipleOf,pattern:Y(t.pattern),prop:t.name,properties:[],template:null,type:"unknown",uniqueItems:t.uniqueItems},o={...n,name:Gn(n)};if(t.$ref){let a=N({type:t.$ref});return o={...o,$refs:[...o.$refs,...a.$refs],base:a.base,export:"reference",imports:[...o.imports,...a.imports],template:a.template,type:a.type},o.default=H(t,o),o}if(t.enum){let a=Pr(t,t.enum);if(a.length)return o={...o,base:"string",enum:[...o.enum,...a],export:"enum",type:"string"},o.default=H(t,o),o}if(t.type==="array"&&t.items){let a=N({format:t.items.format,type:t.items.type});return o={...o,$refs:[...o.$refs,...a.$refs],base:a.base,export:"array",imports:[...o.imports,...a.imports],template:a.template,type:a.type},o.default=H(t,o),o}if(t.type==="object"&&t.items){let a=N({format:t.items.format,type:t.items.type});return o={...o,$refs:[...o.$refs,...a.$refs],base:a.base,export:"dictionary",imports:[...o.imports,...a.imports],template:a.template,type:a.type},o.default=H(t,o),o}let i=t.schema;if(i){if(i.$ref?.startsWith("#/parameters/")&&(i=_(e,i)),i.$ref){let p=N({type:i.$ref});return o={...o,$refs:[...o.$refs,...p.$refs],base:p.base,export:"reference",imports:[...o.imports,...p.imports],template:p.template,type:p.type},o.default=H(t,o),o}let a=Je({definition:i,openApi:e,types:r});return o={...o,$refs:[...o.$refs,...a.$refs],base:a.base,enum:[...o.enum,...a.enum],enums:[...o.enums,...a.enums],export:a.export,imports:[...o.imports,...a.imports],link:a.link,properties:[...o.properties,...a.properties],template:a.template,type:a.type},o.default=H(t,o),o}if(t.type){let a=N({format:t.format,type:t.type});return o={...o,$refs:[...o.$refs,...a.$refs],base:a.base,export:"generic",imports:[...o.imports,...a.imports],template:a.template,type:a.type},o.default=H(t,o),o}return o};var ud=["body","formData","header","path","query"],Yn=({openApi:e,parameters:t,types:r})=>{let n={$refs:[],imports:[],parameters:[],parametersBody:null,parametersCookie:[],parametersForm:[],parametersHeader:[],parametersPath:[],parametersQuery:[]};return t.forEach(o=>{let i=_(e,o),a=jp({openApi:e,parameter:i,types:r}),p=!Xn(a);if(!(!ud.includes(i.in)||p)){switch(i.in){case "body":n.parametersBody=a;break;case "formData":n.parametersForm=[...n.parametersForm,a];break;case "header":n.parametersHeader=[...n.parametersHeader,a];break;case "path":n.parametersPath=[...n.parametersPath,a];break;case "query":n.parametersQuery=[...n.parametersQuery,a];break}n.$refs=[...n.$refs,...a.$refs],n.imports=[...n.imports,...a.imports],n.parameters=[...n.parameters,a];}}),n};function es(e){return e.sort((t,r)=>{let n=t.isRequired&&t.default===void 0,o=r.isRequired&&r.default===void 0;return n&&!o?-1:o&&!n?1:0})}var Np=({code:e,openApi:t,response:r,types:n})=>{let o={$refs:[],base:e!==204?"unknown":"void",code:e,description:r.description||null,enum:[],enums:[],export:"generic",imports:[],in:"response",isDefinition:false,isNullable:false,isReadOnly:false,isRequired:false,link:null,name:"",properties:[],responseTypes:[],template:null,type:e!==204?"unknown":"void"},i=r.schema;if(i){if(i.$ref?.startsWith("#/responses/")&&(i=_(t,i)),i.$ref){let p=N({type:i.$ref});return o.export="reference",o.type=p.type,o.base=p.base,o.template=p.template,o.imports=[...o.imports,...p.imports],o}let a=Je({definition:i,openApi:t,types:n});return o.export=a.export,o.type=a.type,o.base=a.base,o.template=a.template,o.link=a.link,o.isReadOnly=a.isReadOnly,o.isRequired=a.isRequired,o.isNullable=a.isNullable,o.format=a.format,o.maximum=a.maximum,o.exclusiveMaximum=a.exclusiveMaximum,o.minimum=a.minimum,o.exclusiveMinimum=a.exclusiveMinimum,o.multipleOf=a.multipleOf,o.maxLength=a.maxLength,o.minLength=a.minLength,o.maxItems=a.maxItems,o.minItems=a.minItems,o.uniqueItems=a.uniqueItems,o.maxProperties=a.maxProperties,o.minProperties=a.minProperties,o.pattern=Y(a.pattern),o.imports=[...o.imports,...a.imports],o.enum=[...o.enum,...a.enum],o.enums=[...o.enums,...a.enums],o.properties=[...o.properties,...a.properties],o}if(r.headers)for(let a in r.headers)return o.in="header",o.name=a,o.type="string",o.base="string",o;return o};var Cp=({openApi:e,responses:t,types:r})=>{let n=[];return Object.entries(t).forEach(([o,i])=>{let a=Hn(o);if(!a)return;let p=_(e,i),c=Np({code:a,openApi:e,response:p,types:r});n=[...n,c];}),n=Jn(n),n.sort(Qn)};var vp=({method:e,op:t,openApi:r,pathParams:n,types:o,url:i})=>{let a={$refs:[],deprecated:t.deprecated===true,description:t.description||null,id:t.operationId||null,imports:[],method:e.toUpperCase(),parameters:[...n.parameters],parametersBody:n.parametersBody,parametersCookie:[...n.parametersCookie],parametersForm:[...n.parametersForm],parametersHeader:[...n.parametersHeader],parametersPath:[...n.parametersPath],parametersQuery:[...n.parametersQuery],path:i,responseHeader:null,responses:[],summary:t.summary||null,tags:t.tags||null},p={...a,name:Un({config:A(),method:a.method,operationId:t.operationId,path:a.path})};if(t.parameters){let c=Yn({openApi:r,parameters:t.parameters,types:o});p.$refs=[...p.$refs,...c.$refs],p.imports=[...p.imports,...c.imports],p.parameters=[...p.parameters,...c.parameters],p.parametersBody=c.parametersBody,p.parametersCookie=[...p.parametersCookie,...c.parametersCookie],p.parametersForm=[...p.parametersForm,...c.parametersForm],p.parametersHeader=[...p.parametersHeader,...c.parametersHeader],p.parametersPath=[...p.parametersPath,...c.parametersPath],p.parametersQuery=[...p.parametersQuery,...c.parametersQuery];}if(t.responses){p.responses=Cp({openApi:r,responses:t.responses,types:o});let c=p.responses.filter(m=>m.responseTypes.includes("success"));p.responseHeader=_n(c),c.forEach(m=>{p.$refs=[...p.$refs,...m.$refs],p.imports=[...p.imports,...m.imports];});}return p.parameters=es(p.parameters),p};var wp=({openApi:e,types:t})=>{let r=new Map,n=[],o=A();for(let i in e.paths){let a=e.paths[i],p=Yn({openApi:e,parameters:a.parameters??[],types:t});for(let c in a){let m=c,l=L({method:m,path:i});if(Ln.includes(m)){let f=a[m];if(f.operationId&&(r.has(f.operationId)?o.logs.level!=="silent"&&console.warn(`\u2757\uFE0F Duplicate operationId: ${f.operationId} in ${l}. Please ensure your operation IDs are unique. This behavior is not supported and will likely lead to unexpected results.`):r.set(f.operationId,l)),Zn({config:o,operationKey:l})){let d=vp({method:m,op:f,openApi:e,pathParams:p,types:t,url:i});n.push(d);}}}}return n};var qp=e=>{let t=e.schemes?.[0]||"http",r=e.host,n=e.basePath||"";return (r?`${t}://${r}${n}`:n).replace(/\/$/g,"")};var $p=e=>{let t=Vn(e.info.version),r=qp(e),{models:n,types:o}=Tp(e),i=wp({openApi:e,types:o});return {models:n,operations:i,server:r,types:o,version:t}};var yd=e=>{let t={};for(let r in e)t[e[r]]=r;return t},Mp=(e,t)=>{if(e.components&&t){for(let r in e.components.schemas)if(e.components.schemas.hasOwnProperty(r)){let n=e.components.schemas[r];if(n.discriminator&&n.oneOf?.length&&n.oneOf.some(o=>o.$ref&&Xr(o.$ref)==t.name))return n.discriminator}}},Lp=(e,t)=>{if(e.mapping){let r=yd(e.mapping),n=Object.keys(r).find(o=>Xr(o)==t.name);if(n&&r[n])return r[n]}return t.name};var Xo=({debug:e,definition:t,getModel:r,model:n,openApi:o,types:i})=>{let a=typeof t.additionalProperties=="object"?t.additionalProperties:{},p=r({debug:e,definition:a,openApi:o,parentDefinition:t,types:i});if(a.$ref){let c=N({type:a.$ref});return n.base=c.base,n.default=H(t,n),n.export="dictionary",n.imports.push(...c.imports),n.template=c.template,n.type=c.type,n}if(t.additionalProperties&&t.properties&&Object.keys(t.properties).length>0){let c=typeof t.additionalProperties=="object"&&t.additionalProperties.type&&!Array.isArray(t.additionalProperties.type)?t.additionalProperties.type:p.base,m=[N({type:c}).base,...n.properties.map(l=>l.base)];return p.base=m.filter(Ge).join(" | "),p.default=H(t,n),p.export="generic",p.isRequired=t.additionalProperties===true,p.name="[key: string]",p}return n.base=p.base,n.default=H(t,n),n.export="dictionary",n.imports.push(...p.imports),n.link=p,n.template=p.template,n.type=p.type,n},ts=({debug:e,definition:t,getModel:r,openApi:n,parent:o,types:i})=>{let a=[],p=Mp(n,o);return Object.entries(t.properties??{}).forEach(([c,m])=>{let l=!!t.required?.includes(c),f={default:m.default,deprecated:m.deprecated===true,description:m.description||null,exclusiveMaximum:m.exclusiveMaximum,exclusiveMinimum:m.exclusiveMinimum,format:m.type==="array"?m.items?.format??m.format:m.format,in:"",isDefinition:false,isReadOnly:m.readOnly===true,isRequired:l,maxItems:m.maxItems,maxLength:m.maxLength,maxProperties:m.maxProperties,maximum:m.maximum,minItems:m.minItems,minLength:m.minLength,minProperties:m.minProperties,minimum:m.minimum,multipleOf:m.multipleOf,name:Te(c),pattern:Y(m.pattern),uniqueItems:m.uniqueItems};if(o&&p?.propertyName==c){a=[...a,{...f,$refs:[],base:`'${Lp(p,o)}'`,enum:[],enums:[],export:"reference",imports:[],isNullable:Nt(m),link:null,properties:[],template:null,type:"string"}];return}if(m.$ref){let u=N({type:m.$ref});a=[...a,{...f,$refs:u.$refs,base:u.base,enum:[],enums:[],export:"reference",imports:u.imports,isNullable:u.isNullable||Nt(m),link:null,properties:[],template:u.template,type:u.type}];return}let d=r({debug:e,definition:m,initialValues:f,openApi:n,parentDefinition:t,types:i});d.isNullable=d.isNullable||Nt(m),a=[...a,d];}),a};var Vp=({debug:e,definitions:t,getModel:r,openApi:n,required:o,types:i})=>t.reduce((p,c)=>{if(c.$ref){let m=N({type:c.$ref}),l={$ref:c.$ref,name:m.base};i[m.base]=l;let f=_(n,c);return [...p,...r({debug:e,definition:f,meta:l,openApi:n,types:i}).properties]}return [...p,...r({debug:e,definition:c,openApi:n,parentDefinition:c,types:i}).properties]},[]).filter(p=>!p.isRequired&&o.includes(p.name)).map(p=>({...p,isRequired:true}));var rs=e=>[{definitions:e.allOf,type:"all-of"},{definitions:e.anyOf,type:"any-of"},{definitions:e.oneOf,type:"one-of"}].find(r=>r.definitions?.length),Dp=({debug:e,definition:t,definitions:r,getModel:n,model:o,openApi:i,type:a,types:p})=>{let c={$refs:o.$refs,enums:o.enums,export:a,imports:o.imports,properties:o.properties},m=[];if(r.map(l=>n({debug:e,definition:l,openApi:i,parentDefinition:t,types:p})).forEach(l=>{c.$refs=[...c.$refs,...l.$refs],c.imports=[...c.imports,...l.imports],c.enums=[...c.enums,...l.enums],c.properties=[...c.properties,l];}),t.required&&a==="all-of"){let l=Vp({debug:e,definitions:r,getModel:n,openApi:i,required:t.required,types:p});l.forEach(f=>{c.$refs=[...c.$refs,...f.$refs],c.imports=[...c.imports,...f.imports],c.enums=[...c.enums,...f.enums];}),m=[...m,...l];}if(t.properties){let l=ts({definition:t,getModel:n,openApi:i,types:p});l.forEach(f=>{c.$refs=[...c.$refs,...f.$refs],c.imports=[...c.imports,...f.imports],c.enums=[...c.enums,...f.enums],f.export==="enum"&&(c.enums=[...c.enums,f]);}),m=[...m,...l];}if(m.length){let l=rs(t);if(l){let f={$refs:[],base:"unknown",description:"",enum:[],enums:[],export:"interface",imports:[],in:"",isDefinition:false,isNullable:false,isReadOnly:false,isRequired:false,link:null,name:"properties",properties:m,template:null,type:"unknown"};l.type==="one-of"?(c.properties=[{...c,base:"",description:null,enum:[],in:"",isDefinition:false,isNullable:false,isReadOnly:false,isRequired:true,link:null,name:"",template:null,type:""},f],c.export="all-of"):c.properties=[...c.properties,f];}}return c};var pe=({debug:e,definition:t,initialValues:r={},isDefinition:n=false,meta:o,openApi:i,parentDefinition:a=null,types:p})=>{let c=Ar(t),m=gp(t,c),l={$refs:[],base:"unknown",deprecated:!!t.deprecated,description:t.description||null,enum:[],enums:[],exclusiveMaximum:t.exclusiveMaximum,exclusiveMinimum:t.exclusiveMinimum,export:"interface",format:t.format,imports:[],in:"",isDefinition:n,isNullable:Nt(t),isReadOnly:t.readOnly===true,isRequired:false,link:null,maxItems:t.maxItems,maxLength:t.maxLength,maxProperties:t.maxProperties,maximum:t.maximum,meta:o,minItems:t.minItems,minLength:t.minLength,minProperties:t.minProperties,minimum:t.minimum,multipleOf:t.multipleOf,name:o?.name??"",pattern:Y(t.pattern),properties:[],template:null,type:"unknown",uniqueItems:t.uniqueItems,...r};if(t.$ref){let d=N({debug:e,type:t.$ref});return l.$refs=[...l.$refs,decodeURIComponent(t.$ref)],l.base=d.base,l.export="reference",l.imports=[...l.imports,...d.imports],l.template=d.template,l.type=d.type,l.default=H(t,l),l}if(m==="enum"){let d=Pr(t,t.enum);if(d.length)return l.base="string",l.enum=[...l.enum,...d],l.export="enum",l.type="string",l.default=H(t,l),l.meta||(l.meta=Wn(l)),l}if(c.includes("array")&&(t.items||t.prefixItems)){if(t.prefixItems){let h=t.prefixItems.map(g=>pe({definition:g,openApi:i,parentDefinition:t,types:p}));return l.export="array",l.$refs=[...l.$refs,...h.reduce((g,x)=>[...g,...x.$refs],[])],l.imports=[...l.imports,...h.reduce((g,x)=>[...g,...x.imports],[])],l.link=h,l.default=H(t,l),l}if(!t.items)return l;if(t.items.$ref){let h=N({type:t.items.$ref});return l.$refs=[...l.$refs,decodeURIComponent(t.items.$ref)],l.base=h.base,l.export="array",l.imports=[...l.imports,...h.imports],l.template=h.template,l.type=h.type,l.default=H(t,l),l}if(t.items.anyOf&&a&&a.type){let h=rs(a);if(h&&h.definitions.some(g=>!Ar(g).includes("array")))return pe({definition:t.items,openApi:i,parentDefinition:t,types:p})}let d=Array.isArray(t.items)?{anyOf:t.items}:t.items,u=pe({definition:d,openApi:i,parentDefinition:t,types:p});return l.base=u.base,l.export="array",l.$refs=[...l.$refs,...u.$refs],l.imports=[...l.imports,...u.imports],l.link=u,l.template=u.template,l.type=u.type,l.default=H(t,l),l}let f=rs(t);if(f){let d=Dp({...f,debug:e,definition:t,getModel:pe,model:l,openApi:i,types:p});return {...l,...d}}if(c.includes("object")||t.properties||t.additionalProperties){if(t.properties&&(Object.keys(t.properties).length>0||!t.additionalProperties)){if(l.base="unknown",l.export="interface",l.type="unknown",l.default=H(t,l),ts({debug:e,definition:t,getModel:pe,openApi:i,parent:l,types:p}).forEach(h=>{l.$refs=[...l.$refs,...h.$refs],l.enums=[...l.enums,...h.enums],l.imports=[...l.imports,...h.imports],l.properties=[...l.properties,h],h.export==="enum"&&(l.enums=[...l.enums,h]);}),t.additionalProperties){let h=Xo({debug:e,definition:t,getModel:pe,model:l,openApi:i,types:p});l.properties=[...l.properties,h];}return !l.properties.length&&l.base==="unknown"&&l.type==="unknown"&&(l.export="dictionary",l.name||(l.name="[key: string]")),l}return Xo({debug:e,definition:t,getModel:pe,model:l,openApi:i,types:p})}if(t.const!==void 0){let d=t.const,u=typeof d=="string"?`"${d}"`:`${d}`;return l.base=u,l.export="const",l.type=u,l}if(c.length){let d=N({format:t.format,type:t.type});return l.base=d.base,l.export="generic",l.$refs=[...l.$refs,...d.$refs],l.imports=[...l.imports,...d.imports],l.isNullable=d.isNullable||l.isNullable,l.template=d.template,l.type=d.type,l.default=H(t,l),l}return l};var ns=e=>{if(e.schema)return e.schema;if(e.content){let t=Object.entries(e.content);for(let[r,n]of t)if(n.schema){let o=r;return e.content[o].schema}}};var Fp=e=>{let t={},r=[];return e.components?(Object.entries(e.components.schemas??{}).forEach(([n,o])=>{let i=zn(n);t[i.name]=i;let a=pe({definition:o,isDefinition:true,meta:i,openApi:e,types:t});r=[...r,a];}),Object.entries(e.components.parameters??{}).forEach(([n,o])=>{let i=ns(o);if(!i)return;let a=Pp(n);t[a.name]=a;let p=pe({definition:i,isDefinition:true,meta:a,openApi:e,types:t});p.deprecated=o.deprecated,p.description=o.description||null,r=[...r,p];}),{models:r,types:t}):{models:r,types:t}};var Bp=({openApi:e,parameter:t,types:r})=>{let n={$refs:[],base:"unknown",deprecated:t.deprecated===true,description:t.description||null,enum:[],enums:[],export:"interface",imports:[],in:t.in,isDefinition:false,isNullable:Nt(t),isReadOnly:false,isRequired:t.required===true,link:null,mediaType:null,prop:t.name,properties:[],template:null,type:"unknown"},o={...n,name:Gn(n)};if(t.$ref){let a=N({type:t.$ref});return o={...o,$refs:[...o.$refs,...a.$refs],base:a.base,export:"reference",imports:[...o.imports,...a.imports],template:a.template,type:a.type},o}let i=ns(t);if(i){if(i.$ref?.startsWith(Tr)&&(i=_(e,i)),i.$ref){let p=N({type:i.$ref});return o={...o,$refs:[...o.$refs,...p.$refs],base:p.base,export:"reference",imports:[...o.imports,...p.imports],template:p.template,type:p.type},o.default=H(i),o}let a=pe({definition:i,openApi:e,types:r});return o={...o,$refs:[...o.$refs,...a.$refs],base:a.base,enum:[...o.enum,...a.enum],enums:[...o.enums,...a.enums],exclusiveMaximum:a.exclusiveMaximum,exclusiveMinimum:a.exclusiveMinimum,export:a.export,format:a.format,imports:[...o.imports,...a.imports],isNullable:o.isNullable||a.isNullable,isReadOnly:a.isReadOnly,isRequired:o.isRequired||a.isRequired,link:a.link,maxItems:a.maxItems,maxLength:a.maxLength,maxProperties:a.maxProperties,maximum:a.maximum,minItems:a.minItems,minLength:a.minLength,minProperties:a.minProperties,minimum:a.minimum,multipleOf:a.multipleOf,pattern:Y(a.pattern),properties:[...o.properties,...a.properties],template:a.template,type:a.type,uniqueItems:a.uniqueItems},(o.enum.length||o.enums.length)&&!o.meta&&(o.meta=Wn(o)),o.default=a.default,o}return o};var hd=["cookie","formData","header","path","query"],ss=({openApi:e,parameters:t,types:r})=>{let n={$refs:[],imports:[],parameters:[],parametersBody:null,parametersCookie:[],parametersForm:[],parametersHeader:[],parametersPath:[],parametersQuery:[]};return t.forEach(o=>{let i=_(e,o),a=Bp({openApi:e,parameter:i,types:r}),p=!Xn(a);if(!(!hd.includes(i.in)||p)){switch(i.in){case "cookie":n.parametersCookie=[...n.parametersCookie,a];break;case "formData":n.parametersForm=[...n.parametersForm,a];break;case "header":n.parametersHeader=[...n.parametersHeader,a];break;case "path":n.parametersPath=[...n.parametersPath,a];break;case "query":n.parametersQuery=[...n.parametersQuery,a];break}n.$refs=[...n.$refs,...a.$refs],n.imports=[...n.imports,...a.imports],n.parameters=[...n.parameters,a];}}),n};var gd=["application/json-patch+json","application/json","application/ld+json","application/x-www-form-urlencoded","multipart/batch","multipart/form-data","multipart/mixed","multipart/related","text/json","text/plain"],os=(e,t)=>{let r=Object.keys(t).filter(o=>{let i=o.split(";")[0].trim();return gd.includes(i)}).find(o=>!!t[o]?.schema);if(r)return {mediaType:r,schema:t[r].schema};let n=Object.keys(t).find(o=>!!t[o]?.schema);if(n)return {mediaType:n,schema:t[n].schema}};var Kp=({body:e,debug:t,openApi:r,types:n})=>{let o=e["x-body-name"]??"requestBody",i={$refs:[],base:"unknown",default:void 0,description:e.description||null,enum:[],enums:[],export:"interface",imports:[],in:"body",isDefinition:false,isNullable:e.nullable===true,isReadOnly:false,isRequired:e.required===true,link:null,mediaType:null,name:o,prop:o,properties:[],template:null,type:"unknown"};if(!e.content)return i;let a=os(r,e.content);if(!a)return i;switch(i.mediaType=a.mediaType,i.mediaType){case "application/x-www-form-urlencoded":case "multipart/form-data":i.in="formData",i.name="formData",i.prop="formData";break}if(a.schema.$ref){let c=N({type:a.schema.$ref});return i.export="reference",i.type=c.type,i.base=c.base,i.template=c.template,i.$refs=[...i.$refs,...c.$refs],i.imports=[...i.imports,...c.imports],i}let p=pe({debug:t,definition:a.schema,openApi:r,types:n});return i.$refs=[...i.$refs,...p.$refs],i.base=p.base,i.enum=[...i.enum,...p.enum],i.enums=[...i.enums,...p.enums],i.exclusiveMaximum=p.exclusiveMaximum,i.exclusiveMinimum=p.exclusiveMinimum,i.export=p.export,i.format=p.format,i.imports=[...i.imports,...p.imports],i.isNullable=i.isNullable||p.isNullable,i.isReadOnly=p.isReadOnly,i.isRequired=i.isRequired||p.isRequired,i.link=p.link,i.maximum=p.maximum,i.maxItems=p.maxItems,i.maxLength=p.maxLength,i.maxProperties=p.maxProperties,i.minimum=p.minimum,i.minItems=p.minItems,i.minLength=p.minLength,i.minProperties=p.minProperties,i.multipleOf=p.multipleOf,i.pattern=Y(p.pattern),i.properties=[...i.properties,...p.properties],i.template=p.template,i.type=p.type,i.uniqueItems=p.uniqueItems,i};var Wp=({code:e,openApi:t,response:r,types:n})=>{let o={$refs:[],base:e!==204?"unknown":"void",code:e,description:r.description||null,enum:[],enums:[],export:"generic",imports:[],in:"response",isDefinition:false,isNullable:false,isReadOnly:false,isRequired:false,link:null,name:"",properties:[],responseTypes:[],template:null,type:e!==204?"unknown":"void"};if(r.content){let i=os(t,r.content);if(i){if(i.schema.$ref?.startsWith("#/components/responses/")&&(i.schema=_(t,i.schema)),i.schema.$ref){let p=N({type:i.schema.$ref});return o.base=p.base,o.export="reference",o.$refs=[...o.$refs,...p.$refs],o.imports=[...o.imports,...p.imports],o.template=p.template,o.type=p.type,o}let a=pe({definition:i.schema,openApi:t,types:n});return o.export=a.export,o.type=a.type,o.base=a.base,o.template=a.template,o.link=a.link,o.isReadOnly=a.isReadOnly,o.isRequired=a.isRequired,o.isNullable=a.isNullable,o.format=a.format,o.maximum=a.maximum,o.exclusiveMaximum=a.exclusiveMaximum,o.minimum=a.minimum,o.exclusiveMinimum=a.exclusiveMinimum,o.multipleOf=a.multipleOf,o.maxLength=a.maxLength,o.minLength=a.minLength,o.maxItems=a.maxItems,o.minItems=a.minItems,o.uniqueItems=a.uniqueItems,o.maxProperties=a.maxProperties,o.minProperties=a.minProperties,o.pattern=Y(a.pattern),o.$refs=[...o.$refs,...a.$refs],o.imports=[...o.imports,...a.imports],o.enum=[...o.enum,...a.enum],o.enums=[...o.enums,...a.enums],o.properties=[...o.properties,...a.properties],o}}if(r.headers)for(let i in r.headers)return o.in="header",o.name=i,o.type="string",o.base="string",o;return o};var zp=({openApi:e,responses:t,types:r})=>{let n=[];return Object.entries(t).forEach(([o,i])=>{let a=Hn(o);if(!a)return;let p=_(e,i),c=Wp({code:a,openApi:e,response:p,types:r});n=[...n,c];}),n=Jn(n),n.sort(Qn)};var Er=(e,t)=>{let r=[...e],n=[...t];for(;n.length>0;){let o=n[0];n=n.slice(1),r.every(a=>a.in!==o.in||a.name!==o.name)&&(r=[...r,o]);}return r},_p=({debug:e,method:t,op:r,openApi:n,pathParams:o,types:i,url:a})=>{let p={$refs:[],deprecated:!!r.deprecated,description:r.description||null,id:r.operationId||null,imports:[],method:t.toUpperCase(),parameters:[],parametersBody:o.parametersBody,parametersCookie:[],parametersForm:[],parametersHeader:[],parametersPath:[],parametersQuery:[],path:a,responseHeader:null,responses:[],summary:r.summary||null,tags:r.tags||null},c={...p,name:Un({config:A(),method:p.method,operationId:r.operationId,path:p.path})};if(r.parameters){let m=ss({openApi:n,parameters:r.parameters,types:i});c.$refs=[...c.$refs,...m.$refs],c.imports=[...c.imports,...m.imports],c.parameters=[...c.parameters,...m.parameters],c.parametersBody=m.parametersBody,c.parametersCookie=[...c.parametersCookie,...m.parametersCookie],c.parametersForm=[...c.parametersForm,...m.parametersForm],c.parametersHeader=[...c.parametersHeader,...m.parametersHeader],c.parametersPath=[...c.parametersPath,...m.parametersPath],c.parametersQuery=[...c.parametersQuery,...m.parametersQuery];}if(r.requestBody){let m=_(n,r.requestBody),l=Kp({body:m,debug:e,openApi:n,types:i});c.$refs=[...c.$refs,...l.$refs],c.imports=[...c.imports,...l.imports],c.parameters=[...c.parameters,l],c.parametersBody=l;}if(r.responses){c.responses=zp({openApi:n,responses:r.responses,types:i});let m=c.responses.filter(l=>l.responseTypes.includes("success"));c.responseHeader=_n(m),m.forEach(l=>{c.$refs=[...c.$refs,...l.$refs],c.imports=[...c.imports,...l.imports];});}return c.parameters=Er(c.parameters,o.parameters),c.parametersCookie=Er(c.parametersCookie,o.parametersCookie),c.parametersForm=Er(c.parametersForm,o.parametersForm),c.parametersHeader=Er(c.parametersHeader,o.parametersHeader),c.parametersPath=Er(c.parametersPath,o.parametersPath),c.parametersQuery=Er(c.parametersQuery,o.parametersQuery),c.parameters=es(c.parameters),c};var Hp=({openApi:e,types:t})=>{let r=new Map,n=[],o=A();for(let i in e.paths){let a=e.paths[i],p=ss({openApi:e,parameters:a.parameters??[],types:t});for(let c in a){let m=c,l=L({method:m,path:i});if(Ln.includes(m)){let f=a[m];if(f.operationId&&(r.has(f.operationId)?o.logs.level!=="silent"&&console.warn(`\u2757\uFE0F Duplicate operationId: ${f.operationId} in ${l}. Please ensure your operation IDs are unique. This behavior is not supported and will likely lead to unexpected results.`):r.set(f.operationId,l)),Zn({config:o,operationKey:l})){let d=_p({method:m,op:f,openApi:e,pathParams:p,types:t,url:i});n.push(d);}}}}return n};var Qp=e=>{let t=e.servers?.[0],r=t?.variables||{},n=t?.url||"";return Object.entries(r).forEach(([o,i])=>{n=n.replace(`{${o}}`,i.default);}),n.replace(/\/$/g,"")};var Zp=e=>{let t=Vn(e.info.version),r=Qp(e),{models:n,types:o}=Fp(e),i=Hp({openApi:e,types:o});return {models:n,operations:i,server:r,types:o,version:t}};function fP({openApi:e}){let t=e;if("openapi"in t)return Zp(t);if("swagger"in t)return $p(t);throw new Error(`Unsupported OpenAPI specification: ${JSON.stringify(t,null,2)}`)}var dP=({config:e,dependencies:t,logger:r,spec:n})=>{let o=new kn({config:e,dependencies:t,logger:r,spec:n});if("swagger"in o.spec)return Ko(o),o;if(Kt(o.spec.openapi,">=3.0.0 <3.1.0"))return Wo(o),o;if(Kt(o.spec.openapi,">=3.1.0"))return zo(o),o;throw new Error("Unsupported OpenAPI specification")};var Ie={baseUrl:true,bundle:true,exportFromIndex:false},ke={dependencies:["@hey-api/typescript"],tags:["client"]};var Sd=fileURLToPath(import.meta.url),Up=M.dirname(Sd),Jt=({config:e,sourceOutput:t})=>{let r=I(e);if("bundle"in r.config&&r.config.bundle)return rr({moduleOutput:"client",sourceOutput:t});if(M.isAbsolute(r.name)){let n=M.dirname(r.name),o=M.resolve(e.output.path);return M.relative(o,n).replace(/\\/g,"/")}return r.name},Ct=e=>{let t=I(e);if("bundle"in t.config&&t.config.bundle){let r=e._FRAGILE_CLIENT_BUNDLE_RENAMED;return M.resolve(e.output.path,"client",`${r?.get("index")??"index"}.ts`)}return t.name},is=(e,t)=>{if(he.statSync(e).isDirectory()){he.existsSync(t)||he.mkdirSync(t,{recursive:true});let n=he.readdirSync(e);for(let o of n)is(M.join(e,o),M.join(t,o));}else {let n=he.readFileSync(e);he.writeFileSync(t,n);}},Xp=({filePath:e,project:t,renamed:r})=>{let n=M.extname(e),o=M.basename(e,n),i=t.fileName?.(o)||o;if(i!==o){let a=M.dirname(e);he.renameSync(e,M.resolve(a,`${i}${n}`)),r.set(o,i);}},Gp=({filePath:e,meta:t,renamed:r})=>{let n=he.readFileSync(e,"utf8");n=n.replace(/from\s+['"](\.\.?\/[^'"]*?)['"]/g,(i,a)=>{let p=i.indexOf(a),c=M.extname(a),m=M.basename(a,c),l=M.dirname(a),f=(r.get(m)??m)+(t?.moduleResolution===S.ModuleResolutionKind.NodeNext?".js":c);return i.slice(0,p)+[l,f].filter(Boolean).join("/")+i.slice(p+a.length)}),n=`// This file is auto-generated by @hey-api/openapi-ts
42
+
43
+ ${n}`,he.writeFileSync(e,n,"utf8");},PP=({meta:e,outputPath:t,plugin:r,project:n})=>{let o=new Map;if(r.name.startsWith("@hey-api/client-")){let u=M.resolve(t,"core");it(u);let h=M.resolve(Up,"clients","core");is(h,u);let g=M.resolve(t,"client");it(g);let x=r.name.slice(16),b=M.resolve(Up,"clients",x);if(is(b,g),n){let P=he.readdirSync(u);for(let V of P)Xp({filePath:M.resolve(u,V),project:n,renamed:o});let C=he.readdirSync(g);for(let V of C)Xp({filePath:M.resolve(g,V),project:n,renamed:o});}let j=he.readdirSync(u);for(let P of j)Gp({filePath:M.resolve(u,P),meta:e,renamed:o});let k=he.readdirSync(g);for(let P of k)Gp({filePath:M.resolve(g,P),meta:e,renamed:o});return o}let a=M.isAbsolute(r.name)?M.dirname(r.name):void 0;if(a){let u=M.resolve(t,"client");it(u),is(a,u);return}let c=M.normalize(ki.resolve(r.name)).split(M.sep),m=c.slice(0,c.indexOf("dist")+1).join(M.sep),f=[c[c.length-1],"index.d.ts","index.d.cts"],d=M.resolve(t,"client");it(d);for(let u of f)he.copyFileSync(M.resolve(m,u),M.resolve(d,u));};var Od=({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},Jp=({plugin:e})=>{let t=Ct(e.context.config),r=e.registerSymbol({external:t,name:"createClient"}),n=e.registerSymbol({external:t,name:"createConfig"}),o=e.getPluginOrThrow("@hey-api/typescript"),i=e.referenceSymbol(o.api.getSelector("ClientOptions")),{runtimeConfigPath:a}=e.config,p=a?e.registerSymbol({external:a,name:"createClientConfig"}):void 0,c=[],m=Od({plugin:e});if(m){let u=Ze(m);if(u.protocol&&u.host&&!m.includes("{"))c.push({key:de(e.context.config),value:m});else if(m!=="/"&&m.startsWith("/")){let h=m.endsWith("/")?m.slice(0,-1):m;c.push({key:de(e.context.config),value:h});}}"throwOnError"in e.config&&e.config.throwOnError&&c.push({key:"throwOnError",value:true});let l=[s.callExpression({functionName:n.placeholder,parameters:c.length?[s.objectExpression({obj:c})]:void 0,types:[s.typeReferenceNode({typeName:i.placeholder})]})],f=e.registerSymbol({name:"client",selector:e.api.getSelector("client")}),d=s.constVariable({exportConst:true,expression:s.callExpression({functionName:r.placeholder,parameters:p?[s.callExpression({functionName:p.placeholder,parameters:l})]:l}),name:f.placeholder});e.setSymbolValue(f,d);};var Yp=({plugin:e})=>{let t=Ct(e.context.config),r=e.getPluginOrThrow("@hey-api/typescript"),n=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"}),a=e.registerSymbol({exported:true,meta:{kind:"type"},name:"CreateClientConfig"}),p=s.typeReferenceNode({typeName:i.placeholder}),c=s.typeReferenceNode({typeName:"T"}),m=s.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:a.exported,name:a.placeholder,type:s.functionTypeNode({parameters:[s.parameterDeclaration({name:"override",required:false,type:s.typeReferenceNode({typeArguments:[s.typeIntersectionNode({types:[p,c]})],typeName:o.placeholder})})],returnType:s.typeReferenceNode({typeArguments:[s.typeIntersectionNode({types:[s.typeReferenceNode({typeArguments:[p],typeName:"Required"}),c]})],typeName:o.placeholder})}),typeParameters:[{default:s.typeReferenceNode({typeName:n.placeholder}),extends:p,name:"T"}]});e.setSymbolValue(a,m);};var je=({plugin:e})=>{Yp({plugin:e}),Jp({plugin:e});};var as=class{constructor(t){this.meta=t;}getSelector(...t){return [this.meta.name,...t]}};var Td=({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}},ec=({operation:e,plugin:t})=>{if(!e.security||!t.config.auth)return [];let r=[];for(let n of e.security){let o=Td({securitySchemeObject:n});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
44
+ ${JSON.stringify(n,null,2)}`);}return r};var Ir="TComposable",et="DefaultT",Go="ResT";var tc=({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})},rc=({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 nc=({context:e,value:t})=>{let r=w({case:"PascalCase",value:pt(t)});return Rr({config:e.config,name:r})},Rd=({operation:e,plugin:t})=>t.config.methodNameBuilder?t.config.methodNameBuilder(e):!t.config.asClass&&e.id.match(fe)?`${e.id}_`:e.id,we=({context:e,operation:t,plugin:r})=>{let n=new Map,o,i,a=[];if(r.config.classStructure==="auto"&&t.operationId&&(a=t.operationId.split(/[./]/).filter(Boolean),a.length>1)){let c=a.pop();i=w({case:"camelCase",value:pt(c)}),o=a.pop();}let p=r.config.instance?[r.config.instance]:t.tags??["default"];for(let c of p){let m=nc({context:e,value:o||c}),l=[c];o&&(a.includes(c)||c===o?l=[...a,o]:l=[c,...a,o]),n.set(c,{className:m,methodName:i||Rd({operation:t,plugin:r}),path:l.map(f=>nc({context:e,value:f}))});}return n},Yr=({operation:e,plugin:t,throwOnError:r})=>{let o=I(t.context.config).name==="@hey-api/client-nuxt",i=t.getPluginOrThrow("@hey-api/typescript"),a=t.getSymbol(i.api.getSelector("data",e.id)),p=a?.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}<${Ir}, ${p}, ${l}, ${et}>`}return r?`${c.placeholder}<${p}, ${r}>`:a?`${c.placeholder}<${a.placeholder}>`:c.placeholder},Jo=({isRequiredOptions:e,operation:t,plugin:r})=>{let n={argNames:[],fields:[],parameters:[]},o=r.getPluginOrThrow("@hey-api/typescript"),a=I(r.context.config).name==="@hey-api/client-nuxt";if(r.config.params_EXPERIMENTAL==="experiment"){if(t.parameters?.path)for(let p in t.parameters.path){let c=t.parameters.path[p],m=Wt(c.name);n.argNames.push(m),n.fields.push({in:"path",key:m}),n.parameters.push({isRequired:c.required,name:m,type:o.api.schemaToType({plugin:o,schema:c.schema})});}if(t.parameters?.query)for(let p in t.parameters.query){let c=t.parameters.query[p],m=Wt(c.name);n.argNames.push(m),n.fields.push({in:"path",key:m}),n.parameters.push({isRequired:c.required,name:m,type:o.api.schemaToType({plugin:o,schema:c.schema})});}if(t.body){let p="body";n.argNames.push(p),n.fields.push({in:"body"}),n.parameters.push({isRequired:t.body.required,name:p,type:o.api.schemaToType({plugin:o,schema:t.body.schema})});}}return n.parameters.push({isRequired:e,name:"options",type:Yr({operation:t,plugin:r,throwOnError:a?void 0:"ThrowOnError"})}),n},Ad=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"}},Yo=({isRequiredOptions:e,opParameters:t,operation:r,plugin:n})=>{let o=I(n.context.config),i=o.name==="@hey-api/client-nuxt",a=n.getPluginOrThrow("@hey-api/typescript"),c=n.getSymbol(a.api.getSelector(i?"response":"responses",r.id))?.placeholder||"unknown",l=n.getSymbol(a.api.getSelector(i?"error":"errors",r.id))?.placeholder||"unknown",f=[];if(r.body)switch(r.body.type){case "form-data":{let q=n.referenceSymbol(n.api.getSelector("formDataBodySerializer"));f.push({spread:q.placeholder});break}case "json":break;case "text":case "octet-stream":f.push({key:"bodySerializer",value:null});break;case "url-search-params":{let q=n.referenceSymbol(n.api.getSelector("urlSearchParamsBodySerializer"));f.push({spread:q.placeholder});break}}for(let q in r.parameters?.query){let B=r.parameters.query[q];if((B.schema.type==="array"||B.schema.type==="tuple")&&(B.style!=="form"||!B.explode)){f.push({key:"querySerializer",value:[{key:"array",value:[{key:"explode",value:false},{key:"style",value:"form"}]}]});break}}let d=tc({operation:r,plugin:n});if(d&&f.push({key:"requestValidator",value:d}),n.config.transformer==="@hey-api/transformers"){let q=n.getPluginOrThrow(n.config.transformer),B=n.getSymbol(q.api.getSelector("response",r.id));B&&n.getSymbolValue(B)&&f.push({key:"responseTransformer",value:B.placeholder});}let u=false,h;for(let q in r.responses){let B=r.responses[q];!h&&o.name==="@hey-api/client-axios"&&vo({statusCode:q})==="2XX"&&(h=Ad(B.mediaType),h&&f.push({key:"responseType",value:h})),B.mediaType==="text/event-stream"&&(u=true);}let g=rc({operation:r,plugin:n});g&&f.push({key:"responseValidator",value:g}),n.config.responseStyle==="data"&&f.push({key:"responseStyle",value:n.config.responseStyle});let x=ec({context:n.context,operation:r,plugin:n});x.length&&f.push({key:"security",value:s.arrayLiteralExpression({elements:x})}),f.push({key:"url",value:r.path}),f.push({spread:"options"});let b=[],j=t.argNames.length;if(j){let q=[],B=[];for(let Me of t.argNames)q.push(s.identifier({text:Me}));for(let Me of t.fields){let tr=[];"in"in Me&&(tr.push({key:"in",value:Me.in}),Me.key&&tr.push({key:"key",value:Me.key}),Me.map&&tr.push({key:"map",value:Me.map})),B.push(s.objectExpression({obj:tr}));}let Tt=n.referenceSymbol(n.api.getSelector("buildClientParams"));b.push(s.constVariable({expression:s.callExpression({functionName:Tt.placeholder,parameters:[s.arrayLiteralExpression({elements:q}),s.arrayLiteralExpression({elements:B})]}),name:"params"})),f.push({spread:"params"});}if(r.body){let q=r.parameters?.header?.["content-type"];if(!!!q?.required){let Tt=[{key:q?.name??"Content-Type",value:r.body.type==="form-data"?null:r.body.mediaType},{spread:s.propertyAccessExpression({expression:s.identifier({text:"options"}),isOptional:!e,name:"headers"})}];j&&Tt.push({spread:s.propertyAccessExpression({expression:s.identifier({text:"params"}),name:"headers"})}),f.push({key:"headers",value:Tt});}}let k=n.config.client&&o.api&&"getSelector"in o.api?n.getSymbol(o.api.getSelector("client")):void 0,P=s.propertyAccessExpression({expression:s.identifier({text:"options"}),isOptional:!e,name:"client"}),C;n.config.instance?C=s.binaryExpression({left:P,operator:"??",right:s.propertyAccessExpression({expression:s.this(),name:"_client"})}):k?C=s.binaryExpression({left:P,operator:"??",right:k.placeholder}):C=P;let V=[];i?V.push(Ir,`${c} | ${et}`,l,et):V.push(c,l,"ThrowOnError"),n.config.responseStyle==="data"&&V.push(s.stringLiteral({text:n.config.responseStyle}));let D=u?s.propertyAccessExpression({expression:C,name:s.identifier({text:"sse"})}):C;return D=s.propertyAccessExpression({expression:D,name:s.identifier({text:r.method})}),b.push(s.returnFunctionCall({args:[s.objectExpression({identifiers:["responseTransformer"],obj:f})],name:D,types:V})),b};var Z=({operation:e})=>{let t=[];return e.summary&&t.push(z(e.summary)),e.description&&t.push(z(e.description)),e.deprecated&&t.push("@deprecated"),t.length?t:void 0},se=({context:e,operation:t})=>{let n=I(e.config).name==="@hey-api/client-nuxt",o=e.config.plugins["@hey-api/sdk"];return o&&!o.config.client&&!o.config.instance||n||fr(t)},kr=({operation:e})=>{for(let t in e.responses)if(e.responses[t].mediaType==="text/event-stream")return true;return false};var Pd=({plugin:e})=>{let t=new Map,r=new Set,n=e.getPluginOrThrow("@hey-api/sdk");e.forEach("operation",({operation:i})=>{let a=se({context:e.context,operation:i}),p=we({context:e.context,operation:i,plugin:n});for(let c of p.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 u=t.get(m),h=e.config.httpRequests.methodNameBuilder(i);if(u.methods.has(h))return;let g=Id({isRequiredOptions:a,methodName:h,operation:i,plugin:e});u.nodes.length?u.nodes.push(s.identifier({text:`
45
+ `}),g):u.nodes.push(g),u.methods.add(h),t.set(m,u);});});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(s.propertyDeclaration({initializer:s.newExpression({argumentsArray:[],expression:s.identifier({text:O({config:{case:"preserve",name:e.config.httpRequests.classNameBuilder},name:l.className})})}),name:w({case:"camelCase",value:l.className})}));}let a=e.referenceSymbol(e.api.getSelector("Injectable")),p=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=s.classDeclaration({decorator:i.root?{args:[{providedIn:"root"}],name:a.placeholder}:void 0,exportClass:p.exported,name:p.placeholder,nodes:i.nodes});e.setSymbolValue(p,c),r.add(i.className);};for(let i of t.values())o(i);},Ed=({plugin:e})=>{e.forEach("operation",({operation:t})=>{let r=se({context:e.context,operation:t}),n=e.registerSymbol({exported:true,name:e.config.httpRequests.methodNameBuilder(t),selector:e.api.getSelector("httpRequest",t.id)}),o=kd({isRequiredOptions:r,operation:t,plugin:e,symbol:n});e.setSymbolValue(n,o);});},sc=({operation:e,plugin:t})=>{let r=I(t.context.config),n=r.api&&"getSelector"in r.api?t.getSymbol(r.api.getSelector("client")):void 0,o=s.propertyAccessExpression({expression:s.identifier({text:"options"}),isOptional:true,name:"client"}),i;return n?i=s.binaryExpression({left:o,operator:"??",right:n.placeholder}):i=o,s.callExpression({functionName:s.propertyAccessExpression({expression:i,name:"requestOptions"}),parameters:[s.objectExpression({obj:[{key:"responseStyle",value:s.identifier({text:"'data'"})},{key:"method",value:s.identifier({text:`'${e.method.toUpperCase()}'`})},{key:"url",value:s.identifier({text:`'${e.path}'`})},{spread:"options"}]})]})},Id=({isRequiredOptions:e,methodName:t,operation:r,plugin:n})=>{let o=n.getPluginOrThrow("@hey-api/typescript"),i=n.referenceSymbol(n.api.getSelector("HttpRequest")),a=n.getPluginOrThrow("@hey-api/sdk"),p=n.referenceSymbol(a.api.getSelector("Options")),m=n.getSymbol(o.api.getSelector("data",r.id))?.placeholder||"unknown";return s.methodDeclaration({accessLevel:"public",comment:Z({operation:r}),name:t,parameters:[{isRequired:e,name:"options",type:`${p.placeholder}<${m}, ThrowOnError>`}],returnType:`${i.placeholder}<unknown>`,statements:[s.returnStatement({expression:sc({operation:r,plugin:n})})],types:[{default:false,extends:"boolean",name:"ThrowOnError"}]})},kd=({isRequiredOptions:e,operation:t,plugin:r,symbol:n})=>{let o=r.getPluginOrThrow("@hey-api/typescript"),i=r.referenceSymbol(r.api.getSelector("HttpRequest")),a=r.getPluginOrThrow("@hey-api/sdk"),p=r.referenceSymbol(a.api.getSelector("Options")),m=r.getSymbol(o.api.getSelector("data",t.id))?.placeholder||"unknown";return s.constVariable({comment:Z({operation:t}),exportConst:n.exported,expression:s.arrowFunction({parameters:[{isRequired:e,name:"options",type:`${p.placeholder}<${m}, ThrowOnError>`}],returnType:`${i.placeholder}<unknown>`,statements:[s.returnStatement({expression:sc({operation:t,plugin:r})})],types:[{default:false,extends:"boolean",name:"ThrowOnError"}]}),name:n.placeholder})},oc=({plugin:e})=>{e.config.httpRequests.asClass?Pd({plugin:e}):Ed({plugin:e});};var jd=({plugin:e})=>{let t=new Map,r=new Set,n=e.getPluginOrThrow("@hey-api/sdk");e.forEach("operation",({operation:i})=>{let a=se({context:e.context,operation:i}),p=we({context:e.context,operation:i,plugin:n});for(let c of p.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 u=t.get(m),h=e.config.httpResources.methodNameBuilder(i);if(u.methods.has(h))return;let g=Cd({isRequiredOptions:a,methodName:h,operation:i,plugin:e});u.nodes.length?u.nodes.push(s.identifier({text:`
46
+ `}),g):u.nodes.push(g),u.methods.add(h),t.set(m,u);});});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(s.propertyDeclaration({initializer:s.newExpression({argumentsArray:[],expression:s.identifier({text:O({config:{case:"preserve",name:e.config.httpResources.classNameBuilder},name:l.className})})}),name:w({case:"camelCase",value:l.className})}));}let a=e.referenceSymbol(e.api.getSelector("Injectable")),p=e.registerSymbol({exported:true,name:O({config:{case:"preserve",name:e.config.httpResources.classNameBuilder},name:i.className})}),c=s.classDeclaration({decorator:i.root?{args:[{providedIn:"root"}],name:a.placeholder}:void 0,exportClass:p.exported,name:p.placeholder,nodes:i.nodes});e.setSymbolValue(p,c),r.add(i.className);};for(let i of t.values())o(i);},Nd=({plugin:e})=>{e.forEach("operation",({operation:t})=>{let r=se({context:e.context,operation:t}),n=e.registerSymbol({exported:true,name:e.config.httpResources.methodNameBuilder(t)}),o=vd({isRequiredOptions:r,operation:t,plugin:e,symbol:n});e.setSymbolValue(n,o);});},ic=({operation:e,plugin:t})=>{let r=t.getPluginOrThrow("@hey-api/sdk"),n=t.getPluginOrThrow("@hey-api/typescript"),o=t.referenceSymbol(t.api.getSelector("httpResource")),a=t.getSymbol(n.api.getSelector("response",e.id))?.placeholder||"unknown";if(t.config.httpRequests.asClass){let p=we({context:t.context,operation:e,plugin:r}),c=Array.from(p.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=s.callExpression({functionName:f.placeholder,parameters:[s.identifier({text:l.placeholder})]});for(let u=1;u<c.path.length;u++){let h=c.path[u];h&&(d=s.propertyAccessExpression({expression:d,name:w({case:"camelCase",value:h})}));}return d=s.propertyAccessExpression({expression:d,name:t.config.httpRequests.methodNameBuilder(e)}),s.callExpression({functionName:o.placeholder,parameters:[s.arrowFunction({parameters:[],statements:[s.constVariable({expression:s.conditionalExpression({condition:s.identifier({text:"options"}),whenFalse:s.identifier({text:"undefined"}),whenTrue:s.callExpression({functionName:"options",parameters:[]})}),name:"opts"}),s.returnStatement({expression:s.conditionalExpression({condition:s.identifier({text:"opts"}),whenFalse:s.identifier({text:"undefined"}),whenTrue:s.callExpression({functionName:d,parameters:[s.identifier({text:"opts"})]})})})]})],types:[s.typeNode(a)]})}}else {let p=t.referenceSymbol(t.api.getSelector("httpRequest",e.id));return s.callExpression({functionName:o.placeholder,parameters:[s.arrowFunction({parameters:[],statements:[s.constVariable({expression:s.conditionalExpression({condition:s.identifier({text:"options"}),whenFalse:s.identifier({text:"undefined"}),whenTrue:s.callExpression({functionName:"options",parameters:[]})}),name:"opts"}),s.returnStatement({expression:s.conditionalExpression({condition:s.identifier({text:"opts"}),whenFalse:s.identifier({text:"undefined"}),whenTrue:s.callExpression({functionName:p.placeholder,parameters:[s.identifier({text:"opts"})]})})})]})],types:[s.typeNode(a)]})}return s.callExpression({functionName:o.placeholder,parameters:[s.arrowFunction({parameters:[],statements:[s.returnStatement({expression:s.identifier({text:"undefined"})})]})],types:[s.typeNode(a)]})},Cd=({isRequiredOptions:e,methodName:t,operation:r,plugin:n})=>{let o=n.getPluginOrThrow("@hey-api/typescript"),i=n.getPluginOrThrow("@hey-api/sdk"),a=n.referenceSymbol(i.api.getSelector("Options")),c=n.getSymbol(o.api.getSelector("data",r.id))?.placeholder||"unknown";return s.methodDeclaration({accessLevel:"public",comment:Z({operation:r}),name:t,parameters:[{isRequired:e,name:"options",type:`() => ${a.placeholder}<${c}, ThrowOnError> | undefined`}],returnType:void 0,statements:[s.returnStatement({expression:ic({operation:r,plugin:n})})],types:[{default:false,extends:"boolean",name:"ThrowOnError"}]})},vd=({isRequiredOptions:e,operation:t,plugin:r,symbol:n})=>{let o=r.getPluginOrThrow("@hey-api/typescript"),i=r.getPluginOrThrow("@hey-api/sdk"),a=r.referenceSymbol(i.api.getSelector("Options")),c=r.getSymbol(o.api.getSelector("data",t.id))?.placeholder||"unknown";return s.constVariable({comment:Z({operation:t}),exportConst:n.exported,expression:s.arrowFunction({parameters:[{isRequired:e,name:"options",type:`() => ${a.placeholder}<${c}, ThrowOnError> | undefined`}],statements:[s.returnStatement({expression:ic({operation:t,plugin:r})})],types:[{default:false,extends:"boolean",name:"ThrowOnError"}]}),name:n.placeholder})},ac=({plugin:e})=>{e.config.httpResources.asClass?jd({plugin:e}):Nd({plugin:e});};var pc=({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&&oc({plugin:e}),e.config.httpResources.enabled&&ac({plugin:e});};var ps={api:new as({name:"@angular/common"}),config:{exportFromIndex:false},dependencies:["@hey-api/client-angular","@hey-api/sdk"],handler:pc,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=n=>r?String(n.id):`${String(n.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=n=>r?String(n.id):`${String(n.id)}Resource`;}}};var cs=class{constructor(t){this.meta=t;}getSelector(...t){return [this.meta.name,...t]}};var ms={...ke,api:new cs({name:"@hey-api/client-angular"}),config:{...Ie,throwOnError:false},handler:je,name:"@hey-api/client-angular"};var ls=class{constructor(t){this.meta=t;}getSelector(...t){return [this.meta.name,...t]}};var fs={...ke,api:new ls({name:"@hey-api/client-axios"}),config:{...Ie,throwOnError:false},handler:je,name:"@hey-api/client-axios"};var ds=class{constructor(t){this.meta=t;}getSelector(...t){return [this.meta.name,...t]}};var us={...ke,api:new ds({name:"@hey-api/client-fetch"}),config:{...Ie,throwOnError:false},handler:je,name:"@hey-api/client-fetch"};var ys=class{constructor(t){this.meta=t;}getSelector(...t){return [this.meta.name,...t]}};var hs={...ke,api:new ys({name:"@hey-api/client-next"}),config:{...Ie,throwOnError:false},handler:je,name:"@hey-api/client-next"};var gs=class{constructor(t){this.meta=t;}getSelector(...t){return [this.meta.name,...t]}};var xs={...ke,api:new gs({name:"@hey-api/client-nuxt"}),config:Ie,handler:je,name:"@hey-api/client-nuxt"};var bs=class{constructor(t){this.meta=t;}getSelector(...t){return [this.meta.name,...t]}};var Ss={...ke,api:new bs({name:"@hey-api/client-ofetch"}),config:{...Ie,throwOnError:false},handler:je,name:"@hey-api/client-ofetch"};var Os={config:{},handler:()=>{},name:"legacy/angular",output:"client",tags:["client"]};var Ts={config:{},handler:()=>{},name:"legacy/axios",output:"client",tags:["client"]};var Rs={config:{},handler:()=>{},name:"legacy/fetch",output:"client",tags:["client"]};var As={config:{},handler:()=>{},name:"legacy/node",output:"client",tags:["client"]};var Ps={config:{},handler:()=>{},name:"legacy/xhr",output:"client",tags:["client"]};var Es=class{constructor(t){this.meta=t;}getSelector(...t){return [this.meta.name,...t]}};var ei=({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);},jr=({context:e,plugin:t,schema:r})=>{if(Array.isArray(r))return r.map(o=>jr({context:e,plugin:t,schema:o}));let n=structuredClone(r);if(n.$ref)return n.$ref=decodeURI(n.$ref),n;if(ei({plugin:t,schema:n}),n.additionalProperties&&typeof n.additionalProperties!="boolean"&&(n.additionalProperties=jr({context:e,plugin:t,schema:n.additionalProperties})),n.allOf&&(n.allOf=n.allOf.map(o=>jr({context:e,plugin:t,schema:o}))),n.items&&(n.items=jr({context:e,plugin:t,schema:n.items})),n.properties)for(let o in n.properties){let i=n.properties[o];typeof i!="boolean"&&(n.properties[o]=jr({context:e,plugin:t,schema:i}));}return n},vt=({context:e,plugin:t,schema:r})=>{if(Array.isArray(r))return r.map(o=>vt({context:e,plugin:t,schema:o}));let n=structuredClone(r);if("$ref"in n)return n.$ref=decodeURI(n.$ref),n;if(ei({plugin:t,schema:n}),n.additionalProperties&&typeof n.additionalProperties!="boolean"&&(n.additionalProperties=vt({context:e,plugin:t,schema:n.additionalProperties})),n.allOf&&(n.allOf=n.allOf.map(o=>vt({context:e,plugin:t,schema:o}))),n.anyOf&&(n.anyOf=n.anyOf.map(o=>vt({context:e,plugin:t,schema:o}))),n.items&&(n.items=vt({context:e,plugin:t,schema:n.items})),n.oneOf&&(n.oneOf=n.oneOf.map(o=>vt({context:e,plugin:t,schema:o}))),n.properties)for(let o in n.properties){let i=n.properties[o];typeof i!="boolean"&&(n.properties[o]=vt({context:e,plugin:t,schema:i}));}return n},gt=({context:e,plugin:t,schema:r})=>{if(Array.isArray(r))return r.map(o=>gt({context:e,plugin:t,schema:o}));let n=structuredClone(r);if(ei({plugin:t,schema:n}),n.$ref&&(n.$ref=decodeURI(n.$ref)),n.additionalProperties&&typeof n.additionalProperties!="boolean"&&(n.additionalProperties=gt({context:e,plugin:t,schema:n.additionalProperties})),n.allOf&&(n.allOf=n.allOf.map(o=>gt({context:e,plugin:t,schema:o}))),n.anyOf&&(n.anyOf=n.anyOf.map(o=>gt({context:e,plugin:t,schema:o}))),n.items&&(n.items=gt({context:e,plugin:t,schema:n.items})),n.oneOf&&(n.oneOf=n.oneOf.map(o=>gt({context:e,plugin:t,schema:o}))),n.prefixItems&&(n.prefixItems=n.prefixItems.map(o=>gt({context:e,plugin:t,schema:o}))),n.properties)for(let o in n.properties){let i=n.properties[o];typeof i!="boolean"&&(n.properties[o]=gt({context:e,plugin:t,schema:i}));}return n},ti=({name:e,plugin:t,schema:r})=>{let n="";return t.config.nameBuilder&&(typeof t.config.nameBuilder=="function"?n=t.config.nameBuilder(e,r):n=t.config.nameBuilder.replace("{{name}}",e)),n||(n=`${e}Schema`),Wt(n)},_d=({context:e,plugin:t})=>{if(e.spec.definitions)for(let r in e.spec.definitions){let n=e.spec.definitions[r],o=t.registerSymbol({exported:true,name:ti({name:r,plugin:t,schema:n}),selector:t.api.getSelector("ref",r)}),i=jr({context:e,plugin:t,schema:n}),a=s.constVariable({assertion:"const",exportConst:o.exported,expression:s.objectExpression({obj:i}),name:o.placeholder});t.setSymbolValue(o,a);}},Hd=({context:e,plugin:t})=>{if(e.spec.components)for(let r in e.spec.components.schemas){let n=e.spec.components.schemas[r],o=t.registerSymbol({exported:true,name:ti({name:r,plugin:t,schema:n}),selector:t.api.getSelector("ref",r)}),i=vt({context:e,plugin:t,schema:n}),a=s.constVariable({assertion:"const",exportConst:o.exported,expression:s.objectExpression({obj:i}),name:o.placeholder});t.setSymbolValue(o,a);}},Qd=({context:e,plugin:t})=>{if(e.spec.components)for(let r in e.spec.components.schemas){let n=e.spec.components.schemas[r],o=t.registerSymbol({exported:true,name:ti({name:r,plugin:t,schema:n}),selector:t.api.getSelector("ref",r)}),i=gt({context:e,plugin:t,schema:n}),a=s.constVariable({assertion:"const",exportConst:o.exported,expression:s.objectExpression({obj:i}),name:o.placeholder});t.setSymbolValue(o,a);}},cc=({plugin:e})=>{if("swagger"in e.context.spec){_d({context:e.context,plugin:e});return}if(Kt(e.context.spec.openapi,">=3.0.0 <3.1.0")){Hd({context:e.context,plugin:e});return}if(Kt(e.context.spec.openapi,">=3.1.0")){Qd({context:e.context,plugin:e});return}throw new Error("Unsupported OpenAPI specification")};var wt=class{_exportFromIndex;_headers=[];_id;_imports=new Map;_items=[];_name;_path;constructor({dir:t,exportFromIndex:r=false,header:n=true,id:o,name:i}){this._exportFromIndex=r,this._id=o,this._name=this._setName(i),this._path=M.resolve(t,this._name),n&&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 n=this._imports.get(t);n||(n=new Map,this._imports.set(t,n));let o=n.get(r.name);return o?{...o,name:o.alias||o.name}:(n.set(r.name,r),{...r,name:r.alias||r.name})}isEmpty(){return !this._items.length}nameWithoutExtension(){let{name:t}=lc(this._name);return t}remove(t){he.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:n}=lc(t);return [n,"gen",r].filter(Boolean).join(".")}_toString(t,r){let n=[];this._headers.length&&n.push(this._headers.join(`
47
+ `));let o=r?.options.moduleResolution===S.ModuleResolutionKind.NodeNext,i=[];for(let[a,p]of this._imports.entries()){let c=Array.from(p.values()),m=a;o&&(m.startsWith("./")||m.startsWith("../"))&&(m==="./client"?m="./client/index.js":m=`${m}.js`);let l=s.namedImportDeclarations({imports:c,module:m});i.push(me({node:l}));}return i.length&&n.push(i.join(`
48
+ `)),n=n.concat(this._items.map(a=>typeof a=="string"?a:me({node:a,unescape:true}))),n.join(t)}write(t=`
49
+ `,r=null){if(this.isEmpty()){this.remove({force:true});return}let n=this._path;if(typeof this._path=="string"){let o=this._path.split(M.sep);n=o.slice(0,o.length-1).join(M.sep);}it(n),he.writeFileSync(this._path,this._toString(t,r));}},lc=e=>{let t=e.match(/\.[0-9a-z]+$/i),r=t?t[0].slice(1):"",n=e.slice(0,e.length-(r?r.length+1:0));return {extension:r,name:n}};var ni=(e,t)=>{let r=A();if(Array.isArray(e))return e.map(o=>ni(o));if(typeof e!="object"||e===null)return e;let n={...e};return Object.entries(n).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 n[o];return}o==="$ref"&&typeof i=="string"&&(n[o]=decodeURIComponent(i)),i&&typeof i=="object"&&(n[o]=ni(i,o));}),n},Ud=(e,t)=>{let r=A(),n=ve(e),o=r.plugins["@hey-api/schemas"];return o?.config.nameBuilder?typeof o.config.nameBuilder=="function"?o.config.nameBuilder(n,t):o.config.nameBuilder.replace("{{name}}",n):`${n}Schema`},fc=({files:e,openApi:t,plugin:r})=>{let n=A();e.schemas=new wt({dir:n.output.path,exportFromIndex:r.config.exportFromIndex,id:"schemas",name:"schemas.ts"});let o=(i,a)=>{let p=ni(a),c=s.objectExpression({obj:p}),m=s.constVariable({assertion:"const",exportConst:true,expression:c,name:Ud(i,a)});e.schemas.add(m);};"swagger"in t&&Object.entries(t.definitions??{}).forEach(([i,a])=>{o(i,a);}),"openapi"in t&&Object.entries(t.components?.schemas??{}).forEach(([i,a])=>{o(i,a);});};var Is={api:new Es({name:"@hey-api/schemas"}),config:{exportFromIndex:false,nameBuilder:e=>`${e}Schema`,type:"json"},handler:cc,handlerLegacy:fc,name:"@hey-api/schemas"};var ks=class{constructor(t){this.meta=t;}getSelector(...t){return [this.meta.name,...t]}};var Yt=({meta:e,onImport:t,...r})=>{if(!e)return {created:false,name:""};let{created:n,name:o}=Ee({meta:e,...r});return o&&t(o),{created:n,name:o}},gc=e=>`${e}ModelResponseTransformer`,er=e=>`${w({case:"PascalCase",value:e})}Data`,Nr=e=>`${w({case:"PascalCase",value:e})}Error`,si=e=>`${e}Transformer`,rt=e=>`${w({case:"PascalCase",value:e})}Response`,oi=({importedType:e,throwOnError:t})=>{let r="OptionsLegacyParser";return t?`${r}<${e||"unknown"}, ${t}>`:e?`${r}<${e}>`:r},dc=(e,t)=>{let r=A(),{name:n}=Ee({client:e,meta:{$ref:t.name,name:t.name},nameTransformer:er}),o=Ye(t.parameters);if(!Q(r))return [{isRequired:o,name:"options",type:oi({importedType:n,throwOnError:"ThrowOnError"})}];if(!t.parameters.length)return [];let i=a=>{if(a.default!==void 0)return JSON.stringify(a.default,null,4)};return r.useOptions?[{default:o?void 0:{},name:"data",type:n}]:t.parameters.map(a=>{let p=`${n}['${a.name}']`;return {default:a?.default,isRequired:(!a.isRequired&&!i(a)?"?":"")=="",name:a.name,type:p}})},uc=(e,t)=>{let r=A(),n=s.typeNode("void");if(t.responses.filter(a=>a.responseTypes.includes("success")).length){let{name:a}=Ee({client:e,meta:{$ref:t.name,name:t.name},nameTransformer:rt});n=s.typeUnionNode({types:[a]});}return r.useOptions&&r.plugins["@hey-api/sdk"]?.config.response==="response"&&(n=s.typeNode("ApiResult",[n])),I(r).name==="legacy/angular"?n=s.typeNode("Observable",[n]):n=s.typeNode("CancelablePromise",[n]),n},yc=e=>{let t=A();if(!Q(t))return [e.deprecated&&"@deprecated",e.summary&&z(e.summary),e.description&&z(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?z(i.description):""}`)]:r=e.parameters.map(i=>`@param ${i.name} ${i.description?z(i.description):""}`));let n=e.responses.filter(i=>i.responseTypes.includes("success"));return [e.deprecated&&"@deprecated",e.summary&&z(e.summary),e.description&&z(e.description),...r,...n.map(i=>`@returns ${i.type} ${i.description?z(i.description):""}`),"@throws ApiError"]},Gd=({client:e,onClientImport:t,onImport:r,operation:n})=>{let o=A(),i=rt(n.name),{name:a}=Ee({client:e,meta:{$ref:`transformers/${i}`,name:i},nameTransformer:si});if(a&&r(a),!Q(o)){let l=[{spread:"options"}],d=n.parameters.filter(u=>u.in==="body"||u.in==="formData").map(u=>u.mediaType||(u.in==="formData"?"multipart/form-data":void 0)).filter(Boolean).filter(Ge);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:n.path}],a&&(l=[...l,{key:"responseTransformer",value:a}]),s.objectExpression({identifiers:["responseTransformer"],obj:l})}let p=l=>l.reduce((f,d)=>{let u=d.prop,h=o.useOptions?`data.${d.name}`:d.name;return u===h?f[u]=u:Te(u)===u?f[u]=h:f[`'${u}'`]=h,f},{}),c={method:n.method,url:n.path};n.parametersPath.length&&(c.path=p(n.parametersPath)),n.parametersCookie.length&&(c.cookies=p(n.parametersCookie)),n.parametersHeader.length&&(c.headers=p(n.parametersHeader)),n.parametersQuery.length&&(c.query=p(n.parametersQuery)),n.parametersForm.length&&(c.formData=p(n.parametersForm)),n.parametersBody&&(n.parametersBody.in==="formData"&&(o.useOptions?c.formData=`data.${n.parametersBody.name}`:c.formData=n.parametersBody.name),n.parametersBody.in==="body"&&(o.useOptions?c.body=`data.${n.parametersBody.name}`:c.body=n.parametersBody.name)),n.parametersBody?.mediaType&&(c.mediaType=n.parametersBody?.mediaType),n.responseHeader&&(c.responseHeader=n.responseHeader),a&&(c.responseTransformer=a);let m=n.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 s.objectExpression({identifiers:["body","cookies","formData","headers","path","query","responseTransformer"],obj:c,shorthand:true})},tt=({config:e,handleIllegal:t,id:r,operation:n})=>e.plugins["@hey-api/sdk"]?.config.methodNameBuilder?e.plugins["@hey-api/sdk"].config.methodNameBuilder(n):t&&r.match(fe)?`${r}_`:r,hc=({client:e,onClientImport:t,onImport:r,operation:n})=>{let o=A(),i=Gd({client:e,onClientImport:t,onImport:r,operation:n});if(!Q(o)){let p=Ee({client:e,meta:{$ref:n.name,name:n.name},nameTransformer:Nr}).name,m=n.responses.filter(l=>l.responseTypes.includes("success")).length?Ee({client:e,meta:{$ref:n.name,name:n.name},nameTransformer:rt}).name:"void";return [s.returnFunctionCall({args:[i],name:`(options?.client ?? client).${n.method.toLocaleLowerCase()}`,types:p&&m?[m,p,"ThrowOnError"]:p?["unknown",p,"ThrowOnError"]:m?[m,"unknown","ThrowOnError"]:[]})]}return Mt(o)?[s.returnFunctionCall({args:[i],name:"this.httpRequest.request"})]:I(o).name==="legacy/angular"?[s.returnFunctionCall({args:["OpenAPI","this.http",i],name:"__request"})]:[s.returnFunctionCall({args:["OpenAPI",i],name:"__request"})]},Jd=({client:e,onClientImport:t,onImport:r,onNode:n,service:o})=>{let i=A(),a=I(i),p=Q(i);for(let d of o.operations)d.parameters.length&&Yt({client:e,meta:{$ref:d.name,name:d.name},nameTransformer:er,onImport:r}),p||Yt({client:e,meta:{$ref:d.name,name:d.name},nameTransformer:Nr,onImport:r}),d.responses.filter(h=>h.responseTypes.includes("success")).length&&Yt({client:e,meta:{$ref:d.name,name:d.name},nameTransformer:rt,onImport:r});let c={default:("throwOnError"in a.config?a.config.throwOnError:false)??false,extends:"boolean",name:"ThrowOnError"};if(!i.plugins["@hey-api/sdk"]?.config.asClass&&!Mt(i)){for(let d of o.operations){let u={parameters:dc(e,d),returnType:p?uc(e,d):void 0,statements:hc({client:e,onClientImport:t,onImport:r,operation:d}),types:p?void 0:[c]},h=a.name==="legacy/angular"?s.anonymousFunction(u):s.arrowFunction(u),g=s.constVariable({comment:yc(d),exportConst:true,expression:h,name:tt({config:i,handleIllegal:true,id:d.name,operation:d})});n(g);}return}let m=o.operations.map(d=>s.methodDeclaration({accessLevel:"public",comment:yc(d),isStatic:Mt(i)===void 0&&a.name!=="legacy/angular",name:tt({config:i,id:d.name,operation:d}),parameters:dc(e,d),returnType:p?uc(e,d):void 0,statements:hc({client:e,onClientImport:t,onImport:r,operation:d}),types:p?void 0:[c]}));if(!m.length)return;Mt(i)?m=[s.constructorDeclaration({multiLine:false,parameters:[{accessLevel:"public",isReadOnly:true,name:"httpRequest",type:"BaseHttpRequest"}]}),...m]:a.name==="legacy/angular"&&(m=[s.constructorDeclaration({multiLine:false,parameters:[{accessLevel:"public",isReadOnly:true,name:"http",type:"HttpClient"}]}),...m]);let l=[];m.forEach((d,u)=>{u&&l.push(s.identifier({text:`
50
+ `})),l.push(d);});let f=s.classDeclaration({decorator:a.name==="legacy/angular"?{args:[{providedIn:"root"}],name:"Injectable"}:void 0,exportClass:true,name:Rr({config:i,name:o.name}),nodes:l});n(f);},xc=({client:e,files:t,plugin:r})=>{let n=A(),o=Q(n),i="sdk";if(t.sdk=new wt({dir:n.output.path,exportFromIndex:r.config.exportFromIndex,id:"sdk",name:`${i}.ts`}),!o)t.sdk.import({module:Jt({config:n,sourceOutput:i}),name:"createClient"}),t.sdk.import({module:Jt({config:n,sourceOutput:i}),name:"createConfig"}),t.sdk.import({asType:true,module:Jt({config:n,sourceOutput:i}),name:"OptionsLegacyParser"});else if(I(n).name==="legacy/angular"?(t.sdk.import({module:"@angular/core",name:"Injectable"}),Mt(n)||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"}),n.plugins["@hey-api/sdk"]?.config.response==="response"&&t.sdk.import({asType:true,module:"./core/ApiResult",name:"ApiResult"}),Mt(n)){let p=I(n);t.sdk.import({asType:p.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 a=I(n),p=s.constVariable({exportConst:true,expression:s.callExpression({functionName:"createClient",parameters:[s.callExpression({functionName:"createConfig",parameters:["throwOnError"in a&&a.throwOnError?s.objectExpression({obj:[{key:"throwOnError",value:true}]}):void 0]})]}),name:"client"});t.sdk.add(p);}for(let a of e.services)Jd({client:e,onClientImport:p=>{t.sdk.import({module:Jt({config:n,sourceOutput:i}),name:p});},onImport:p=>{t.sdk.import({asType:!p.endsWith("Transformer"),module:`./${t.types.nameWithoutExtension()}`,name:p});},onNode:p=>{t.sdk.add(p);},service:a});};var bc=({plugin:e})=>{let t=Ct(e.context.config),n=I(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")}),a=e.registerSymbol({external:t,meta:{kind:"type"},name:"Options"}),p=e.registerSymbol({exported:true,meta:{kind:"type"},name:"Options",selector:e.api.getSelector("Options")}),c=s.typeAliasDeclaration({exportType:p.exported,name:p.placeholder,type:s.typeIntersectionNode({types:[s.typeReferenceNode({typeArguments:n?[s.typeReferenceNode({typeName:"TComposable"}),s.typeReferenceNode({typeName:"TData"}),s.typeReferenceNode({typeName:Go}),s.typeReferenceNode({typeName:et})]:[s.typeReferenceNode({typeName:"TData"}),s.typeReferenceNode({typeName:"ThrowOnError"})],typeName:a.placeholder}),s.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:s.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:s.typeReferenceNode({typeArguments:[s.keywordTypeNode({keyword:"string"}),s.keywordTypeNode({keyword:"unknown"})],typeName:"Record"})}],useLegacyResolution:false})]}),typeParameters:n?[s.typeParameterDeclaration({constraint:s.typeReferenceNode({typeName:e.referenceSymbol(e.api.getSelector("Composable")).placeholder}),defaultType:s.typeNode("'$fetch'"),name:"TComposable"}),s.typeParameterDeclaration({constraint:s.typeReferenceNode({typeName:o.placeholder}),defaultType:s.typeReferenceNode({typeName:o.placeholder}),name:"TData"}),s.typeParameterDeclaration({defaultType:s.keywordTypeNode({keyword:"unknown"}),name:Go}),s.typeParameterDeclaration({defaultType:s.keywordTypeNode({keyword:"undefined"}),name:et})]:[s.typeParameterDeclaration({constraint:s.typeReferenceNode({typeName:o.placeholder}),defaultType:s.typeReferenceNode({typeName:o.placeholder}),name:"TData"}),s.typeParameterDeclaration({constraint:s.keywordTypeNode({keyword:"boolean"}),defaultType:s.keywordTypeNode({keyword:"boolean"}),name:"ThrowOnError"})]});e.setSymbolValue(p,c);};var Yd=({plugin:e})=>{let t=s.expressionToStatement({expression:s.binaryExpression({left:s.propertyAccessExpression({expression:s.this(),name:"_client"}),operator:"=",right:s.propertyAccessExpression({expression:s.identifier({text:"args"}),name:"client"})})}),r=e.referenceSymbol(e.api.getSelector("Client")),n=I(e.context.config),o=n.api&&"getSelector"in n.api?e.getSymbol(n.api.getSelector("client")):void 0;return [s.propertyDeclaration({initializer:o?s.identifier({text:o.placeholder}):void 0,modifier:"protected",name:"_client",type:s.typeReferenceNode({typeName:r.placeholder})}),s.identifier({text:`
51
+ `}),s.constructorDeclaration({multiLine:true,parameters:[{isRequired:!e.config.client,name:"args",type:s.typeInterfaceNode({properties:[{isRequired:!e.config.client,name:"client",type:r.placeholder}],useLegacyResolution:false})}],statements:[e.config.client?s.ifStatement({expression:s.propertyAccessExpression({expression:s.identifier({text:"args"}),isOptional:true,name:"client"}),thenStatement:s.block({statements:[t]})}):t]})]},eu=({plugin:e})=>{let t=I(e.context.config),r=t.name==="@hey-api/client-angular",n=t.name==="@hey-api/client-nuxt",o=new Map,i=new Set,a=e.config.instance?Yd({plugin:e}):[];e.forEach("operation",({operation:m})=>{let l=se({context:e.context,operation:m}),f=e.getPluginOrThrow("@hey-api/typescript"),d=n?e.getSymbol(f.api.getSelector("response",m.id)):void 0,u=we({context:e.context,operation:m,plugin:e});for(let h of u.values())h.path.forEach((g,x)=>{let b=e.referenceSymbol(e.api.getSelector("class",g));o.has(b.id)||o.set(b.id,{className:g,classes:new Set,id:b.id,methods:new Set,nodes:[],root:!x});let j=h.path[x-1];if(j){let q=e.referenceSymbol(e.api.getSelector("class",j));if(q.placeholder!==b.placeholder){let B=o.get(q.id);B.classes.add(b.id),o.set(q.id,B);}}if(!(h.path.length===x+1))return;let P=o.get(b.id);if(P.methods.has(h.methodName))return;let C=Jo({isRequiredOptions:l,operation:m,plugin:e}),V=Yo({isRequiredOptions:l,opParameters:C,operation:m,plugin:e}),D=s.methodDeclaration({accessLevel:"public",comment:Z({operation:m}),isStatic:r?false:!e.config.instance,name:h.methodName,parameters:C.parameters,returnType:void 0,statements:V,types:n?[{default:s.ots.string("$fetch"),extends:s.typeNode(e.referenceSymbol(e.api.getSelector("Composable")).placeholder),name:Ir},{default:d?s.typeReferenceNode({typeName:d.placeholder}):s.typeNode("undefined"),extends:d?s.typeReferenceNode({typeName:d.placeholder}):void 0,name:et}]:[{default:("throwOnError"in t.config?t.config.throwOnError:false)??false,extends:"boolean",name:"ThrowOnError"}]});P.nodes.length?P.nodes.push(s.identifier({text:`
52
+ `}),D):P.nodes.push(D),P.methods.add(h.methodName),o.set(b.id,P);});});let p=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 u=o.get(d);c(u),m.nodes.push(s.propertyDeclaration({initializer:e.config.instance?s.newExpression({argumentsArray:e.config.instance?[s.objectExpression({multiLine:false,obj:[{key:"client",value:s.propertyAccessExpression({expression:s.this(),name:"_client"})}]})]:[],expression:s.identifier({text:e.referenceSymbol(u.id).placeholder})}):s.identifier({text:e.referenceSymbol(u.id).placeholder}),modifier:e.config.instance?void 0:"static",name:w({case:"camelCase",value:u.className})}));}let l=e.registerSymbol({exported:true,name:m.className,selector:e.api.getSelector("class",m.className)}),f=s.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?[p.placeholder]:void 0,name:l.placeholder,nodes:m.nodes});e.setSymbolValue(l,f),i.add(l.id);};if(a.length){let m=s.classDeclaration({exportClass:p.exported,name:p.placeholder,nodes:a});e.setSymbolValue(p,m);}for(let m of o.values())c(m);},tu=({plugin:e})=>{let t=I(e.context.config),r=t.name==="@hey-api/client-nuxt";e.forEach("operation",({operation:n})=>{let o=se({context:e.context,operation:n}),i=e.getPluginOrThrow("@hey-api/typescript"),a=r?e.getSymbol(i.api.getSelector("response",n.id)):void 0,p=Jo({isRequiredOptions:o,operation:n,plugin:e}),c=Yo({isRequiredOptions:o,opParameters:p,operation:n,plugin:e}),m=e.registerSymbol({name:tt({config:e.context.config,handleIllegal:true,id:n.id,operation:n}),selector:e.api.getSelector("function",n.id)}),l=s.constVariable({comment:Z({operation:n}),exportConst:true,expression:s.arrowFunction({parameters:p.parameters,returnType:void 0,statements:c,types:r?[{default:s.ots.string("$fetch"),extends:s.typeNode(e.referenceSymbol(e.api.getSelector("Composable")).placeholder),name:Ir},{default:a?s.typeReferenceNode({typeName:a.placeholder}):s.typeNode("undefined"),extends:a?s.typeReferenceNode({typeName:a.placeholder}):void 0,name:et}]:[{default:("throwOnError"in t.config?t.config.throwOnError:false)??false,extends:"boolean",name:"ThrowOnError"}]}),name:m.placeholder});e.setSymbolValue(m,l);});},Sc=({plugin:e})=>{let t=Ct(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=I(e.context.config),n=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")}),n&&e.config.asClass&&e.registerSymbol({external:"@angular/core",name:"Injectable",selector:e.api.getSelector("Injectable")}),bc({plugin:e}),e.config.asClass?eu({plugin:e}):tu({plugin:e});};var js={api:new ks({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:Sc,handlerLegacy:xc,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 Ns=class{constructor(t){this.meta=t;}getSelector(...t){return [this.meta.name,...t]}};var Oc=({dataExpression:e,schema:t})=>{if(t.type!=="integer"||t.format!=="int64")return;let r=e!==void 0?s.callExpression({functionName:"BigInt",parameters:[s.callExpression({functionName:s.propertyAccessExpression({expression:e,name:"toString"})})]}):void 0;if(r){if(typeof e=="string")return [r];if(e)return [s.assignment({left:e,right:r})]}},Tc=({dataExpression:e,schema:t})=>{if(t.type!=="string"||!(t.format==="date"||t.format==="date-time"))return;let r=s.identifier({text:"Date"});if(typeof e=="string")return [s.newExpression({argumentsArray:[s.identifier({text:e})],expression:r})];if(e)return [s.assignment({left:e,right:s.newExpression({argumentsArray:[e],expression:r})})]};var Cs="data",en=e=>e.map(t=>S.isStatement(t)?t:s.expressionToStatement({expression:t})),Ac=({node:e})=>e.kind===S.SyntaxKind.ReturnStatement,Pc=({plugin:e,schema:t})=>{let r=s.identifier({text:Cs}),n=tn({dataExpression:r,plugin:e,schema:t});return n.length&&!Ac({node:n[n.length-1]})&&n.push(s.returnStatement({expression:r})),n},tn=({dataExpression:e,plugin:t,schema:r})=>{if(r.$ref){let n=t.api.getSelector("response-ref",r.$ref);if(!t.getSymbol(n)){let i=t.registerSymbol({name:O({config:{case:"camelCase",name:"{{name}}SchemaResponseTransformer"},name:F(r.$ref)}),selector:n}),a=t.context.resolveIrRef(r.$ref),p=Pc({plugin:t,schema:a});if(p.length){let c=s.constVariable({expression:s.arrowFunction({async:false,multiLine:true,parameters:[{name:Cs,type:s.keywordTypeNode({keyword:"any"})}],statements:en(p)}),name:i.placeholder});t.setSymbolValue(i,c);}else t.setSymbolValue(i,null);}let o=t.referenceSymbol(n);if(t.getSymbolValue(o)!==null){let i=s.callExpression({functionName:o.placeholder,parameters:[e]});if(e)return typeof e=="string"&&e==="item"?[s.returnStatement({expression:i})]:[typeof e=="string"?i:s.assignment({left:e,right:i})]}return []}if(r.type==="array"){if(!e||typeof e=="string")return [];let n=r.items?tn({dataExpression:"item",plugin:t,schema:r.items?.[0]?r.items[0]:{...r,type:void 0}}):[];if(!n.length)return [];let o=en(n);return o.some(a=>Ac({node:a}))||o.push(s.returnStatement({expression:s.identifier({text:"item"})})),[s.assignment({left:e,right:s.callExpression({functionName:s.propertyAccessExpression({expression:e,name:"map"}),parameters:[s.arrowFunction({multiLine:true,parameters:[{name:"item",type:"any"}],statements:o})]})})]}if(r.type==="object"){let n=[],o=r.required??[];for(let i in r.properties){let a=r.properties[i],p=s.propertyAccessExpression({expression:e||Cs,name:i}),c=tn({dataExpression:p,plugin:t,schema:a});if(!c.length)continue;let m=!a.items?.find(f=>f.type==="null");o.includes(i)&&m?n=n.concat(c):n.push(s.ifStatement({expression:p,thenStatement:s.block({statements:en(c)})}));}return n}if(r.items){if(r.items.length===1)return tn({dataExpression:"item",plugin:t,schema:r.items[0]});let n=[];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=tn({dataExpression:e||"item",plugin:t,schema:o});if(i.length)if(e)n=n.concat(i);else {let a=s.identifier({text:"item"});n.push(s.ifStatement({expression:a,thenStatement:s.block({statements:en(i)})}),s.returnStatement({expression:a}));}}return n}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 n of t.config.transformers){let o=n({config:t.config,dataExpression:e,schema:r});if(o)return o}return []},Ec=({plugin:e})=>{e.forEach("operation",({operation:t})=>{let{response:r}=ze(t);if(!r)return;if(r.items&&r.items.length>1){e.context.config.logs.level==="debug"&&console.warn(`\u2757\uFE0F Transformers warning: route ${L(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 n=e.getPluginOrThrow("@hey-api/typescript"),o=e.getSymbol(n.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)}),a=Pc({plugin:e,schema:r});if(a.length){let p=s.constVariable({exportConst:i.exported,expression:s.arrowFunction({async:true,multiLine:true,parameters:[{name:Cs,type:s.keywordTypeNode({keyword:"any"})}],returnType:s.typeReferenceNode({typeArguments:[s.typeReferenceNode({typeName:o.placeholder})],typeName:"Promise"}),statements:en(a)}),name:i.placeholder});e.setSymbolValue(i,p);}else e.setSymbolValue(i,null);});};var nu="$OpenApiTs",ce={$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:""},su=({comments:e,leadingComment:t,meta:r,obj:n,onNode:o,...i})=>{if(!r)return;let{created:a,name:p}=Ee({create:true,meta:r,...i});if(a){let m=A().plugins["@hey-api/typescript"],l=s.enumDeclaration({asConst:typeof m?.config.enums=="object"&&m.config.enums.mode==="typescript-const",comments:e,leadingComment:t,name:p,obj:n});o(l);}},xt=({comment:e,meta:t,onCreated:r,onNode:n,type:o,...i})=>{if(!t)return {created:false,name:""};let a=Ee({create:true,meta:t,...i}),{created:p,name:c}=a;if(p){let m=s.typeAliasDeclaration({comment:e,exportType:true,name:c,type:o});n(m),r?.(c);}return a},ou=e=>{let t=[];Ic(e),e.model.enums.forEach(r=>au({...e,model:r,onNode:n=>{t.push(n);}})),t.length&&e.onNode(s.namespaceDeclaration({name:e.model.name,statements:t}));},iu=({client:e,model:t,onNode:r})=>{let n=A(),o={},i={};t.enum.forEach(c=>{let{key:m,value:l}=Kn(c);o[m]=l;let f=c.customDescription||c.description;f&&(i[m]=[z(f)]);});let a=[t.description&&z(t.description),t.deprecated&&"@deprecated"],p=n.plugins["@hey-api/typescript"];if(p?.config&&typeof p.config.enums=="object"&&p.config.enums.enabled&&(p.config.enums.mode==="typescript"||p.config.enums.mode==="typescript-const")){su({asConst:p.config.enums.mode==="typescript-const",client:e,comments:i,leadingComment:a,meta:t.meta,obj:o,onNode:r});return}xt({client:e,comment:a,meta:t.meta,onCreated:c=>{let m=n.plugins["@hey-api/typescript"];if(m?.config&&typeof m.config.enums=="object"&&m.config.enums.enabled&&m.config.enums.mode==="javascript"){let l=s.objectExpression({multiLine:true,obj:Object.entries(o).map(([d,u])=>({comments:i[d],key:d,value:u})),unescape:true}),f=s.constVariable({assertion:"const",comment:a,exportConst:true,expression:l,name:c});r(f);}},onNode:r,type:Ap(t.enum)});},au=({model:e,onNode:t})=>{let r={},n={};e.enum.forEach(a=>{let{key:p,value:c}=Kn(a);r[p]=c;let m=a.customDescription||a.description;m&&(n[p]=[z(m)]);});let i=A().plugins["@hey-api/typescript"];t(s.enumDeclaration({asConst:typeof i?.config.enums=="object"&&i.config.enums.mode==="typescript-const",comments:n,leadingComment:[e.description&&z(e.description),e.deprecated&&"@deprecated"],name:e.meta?.name||e.name,obj:r}));},Ic=({client:e,model:t,onNode:r})=>{xt({client:e,comment:[t.description&&z(t.description),t.deprecated&&"@deprecated"],meta:t.meta,onNode:r,type:Pe(t)});},pu=e=>{switch(e.model.export){case "all-of":case "any-of":case "one-of":case "interface":return ou(e);case "enum":return iu(e);default:return Ic(e)}},cu=({client:e,onNode:t})=>{let r={},n=A();if(!n.plugins["@hey-api/sdk"]&&!n.plugins["@hey-api/typescript"]?.config.tree)return;let o=Q(n);for(let a of e.services)for(let p of a.operations){if(!p.parameters.length&&!p.responses.length)continue;r[p.path]||(r[p.path]={});let c=r[p.path];c[p.method]||(c[p.method]={});let m=c[p.method];if(m.$ref=p.name,p.responses.length>0){if(m.res||(m.res={}),Array.isArray(m.res))continue;p.responses.forEach(f=>{m.res[f.code]=f;});}if(p.parameters.length>0){let f={mediaType:null,...ce,in:"body",name:"body",prop:"body"},d=p.parameters.filter(b=>b.in==="body");d.length||(d=p.parameters.filter(b=>b.in==="formData")),d.length===1?f={...ce,...d[0],in:"body",isRequired:d[0].isRequired,name:"body",prop:"body"}:d.length>1&&(f={...ce,in:"body",isRequired:d.some(b=>b.isRequired),mediaType:"multipart/form-data",name:"body",prop:"body",properties:d});let u={...ce,in:"header",isRequired:Ye(p.parameters.filter(b=>b.in==="header")),mediaType:null,name:o?"header":"headers",prop:o?"header":"headers",properties:p.parameters.filter(b=>b.in==="header").sort(Gr)},h={...ce,in:"path",isRequired:Ye(p.parameters.filter(b=>b.in==="path")),mediaType:null,name:"path",prop:"path",properties:p.parameters.filter(b=>b.in==="path").sort(Gr)},g={...ce,in:"query",isRequired:Ye(p.parameters.filter(b=>b.in==="query")),mediaType:null,name:"query",prop:"query",properties:p.parameters.filter(b=>b.in==="query").sort(Gr)},x=o?Rp([...p.parameters]):[f,u,h,g].filter(b=>b.properties.length||b.$refs.length||b.mediaType);m.req=x,xt({client:e,meta:{$ref:p.name,name:p.name},nameTransformer:er,onNode:t,type:Pe({...ce,properties:x})});}let l=p.responses.filter(f=>f.responseTypes.includes("success"));if(l.length>0){xt({client:e,meta:{$ref:p.name,name:p.name},nameTransformer:rt,onNode:t,type:Pe({...ce,export:"any-of",properties:l})});let f=p.responses.filter(d=>d.responseTypes.includes("error"));o||xt({client:e,meta:{$ref:p.name,name:p.name},nameTransformer:Nr,onNode:t,type:Pe(f.length?{...ce,export:"one-of",properties:f}:{...ce,base:"unknown"})});}}let i=Object.entries(r).map(([a,p])=>{let c=Object.entries(p).map(([l,f])=>{let d=l,u=[];if(f.req){let g=f.$ref,{name:x}=Ee({client:e,meta:{$ref:g,name:g},nameTransformer:er}),b={...ce,base:x,export:"reference",isRequired:true,name:"req",properties:[],type:x};u=[...u,b];}if(f.res){let g=Object.entries(f.res).map(([b,j])=>({...ce,...j,isRequired:true,name:String(b)})),x={...ce,isRequired:true,name:"res",properties:g};u=[...u,x];}return {...ce,isRequired:true,name:d.toLocaleLowerCase(),properties:u}}).filter(Boolean);return {...ce,isRequired:true,name:`'${a}'`,properties:c}});n.plugins["@hey-api/typescript"]?.config.tree&&xt({client:e,meta:{$ref:"@hey-api/openapi-ts",name:nu},onNode:t,type:Pe({...ce,properties:i})});},kc=({client:e,files:t,plugin:r})=>{let n=A();t.types=new wt({dir:n.output.path,exportFromIndex:r.config.exportFromIndex,id:"types",name:"types.ts"});let o=i=>{t.types?.add(i);};for(let i of e.models)pu({client:e,model:i,onNode:o});cu({client:e,onNode:o});};var qt="data",mu=e=>e.base==="unknown"&&e.export==="generic"&&e.type==="unknown",jc=({client:e,model:t})=>t.$refs.map(n=>{let o=e.models.find(i=>i.meta?.$ref===n);if(!o)throw new Error(`Ref ${n} could not be found. Transformers cannot be generated without having access to all refs.`);return o}),Nc=e=>{let t=e.model.meta.name,{name:r}=xt({...e,meta:{$ref:`transformers/${t}`,name:t},nameTransformer:gc,onCreated:o=>{let i=vs({...e,meta:{$ref:`transformers/${t}`,name:o},path:[qt]});Cc({...e,async:false,name:o,statements:i});},type:`(${qt}: any) => ${t}`});return {created:!!e.client.types[r],name:r}},lu=e=>{let{model:t}=e,r=jc(e);if(r.length===1){let{created:n,name:o}=Nc({...e,model:r[0]});return n?[s.transformArrayMutation({path:e.path,transformerName:o})]:[]}return Jr(t)||t.link&&!Array.isArray(t.link)&&t.link.export==="any-of"&&t.link.properties.find(n=>Jr(n))?[s.transformArrayMap({path:e.path,transformExpression:s.conditionalExpression({condition:s.identifier({text:"item"}),whenFalse:s.identifier({text:"item"}),whenTrue:s.transformNewDate({parameterName:"item"})})})]:[]},fu=e=>{let{model:t}=e,r=[...e.path,t.name];return t.type==="string"&&t.export!=="array"&&Jr(t)?[s.transformDateMutation({path:r})]:vs({...e,model:t,path:r})},vs=e=>{let{model:t}=e;switch(t.export){case "array":return lu(e);case "interface":return t.properties.flatMap(r=>fu({...e,model:r}));case "reference":{if(t.$refs.length!==1)return [];let r=jc(e),{created:n,name:o}=Nc({...e,model:r[0]});return n?t.in==="response"?[s.expressionToStatement({expression:s.callExpression({functionName:o,parameters:[qt]})})]:s.transformFunctionMutation({path:e.path,transformerName:o}):[]}default:return []}},Cc=({async:e,client:t,name:r,onNode:n,onRemoveNode:o,statements:i})=>{let a={created:false,name:r};if(!i.length)return Ip({client:t,name:r}),o?.(),a;let p=s.arrowFunction({async:e,multiLine:true,parameters:[{name:qt}],statements:[...i,s.returnVariable({expression:qt})]}),c=s.constVariable({exportConst:true,expression:p,name:r,typeName:r});return n(c),{created:true,name:r}},vc=({client:e,files:t})=>{let r=A(),n=i=>{t.types?.add(i);},o=()=>{t.types?.removeNode_LEGACY();};for(let i of e.services)for(let a of i.operations){let p=a.responses.filter(l=>l.responseTypes.includes("success"));if(!p.length)continue;let c=p.filter(l=>!mu(l));if(!c.length)continue;if(c.length>1){r.logs.level==="debug"&&console.warn(`\u2757\uFE0F Transformers warning: route ${L(a)} 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=rt(a.name);xt({client:e,meta:{$ref:`transformers/${m}`,name:m},nameTransformer:si,onCreated:l=>{let f=p.length>1?p.flatMap(d=>{let u=vs({client:e,meta:{$ref:`transformers/${m}`,name:m},model:d,onNode:n,onRemoveNode:o,path:[qt]});return u.length?[s.ifStatement({expression:s.safeAccessExpression(["data"]),thenStatement:s.block({statements:u})})]:[]}):vs({client:e,meta:{$ref:`transformers/${m}`,name:m},model:p[0],onNode:n,onRemoveNode:o,path:[qt]});Cc({async:true,client:e,name:l,onNode:n,onRemoveNode:o,statements:f});},onNode:n,type:`(${qt}: any) => Promise<${m}>`});}};var ws={api:new Ns({name:"@hey-api/transformers"}),config:{bigInt:true,dates:true,exportFromIndex:false,transformers:[],typeTransformers:[]},dependencies:["@hey-api/typescript"],handler:Ec,handlerLegacy:vc,name:"@hey-api/transformers",resolveConfig:e=>{e.config.transformers||(e.config.transformers=[]),e.config.dates&&(e.config.transformers=[...e.config.transformers,Tc]),e.config.bigInt&&(e.config.transformers=[...e.config.transformers,Oc]);},tags:["transformer"]};var qc=({context:e,name:t})=>(te.lastIndex=0,te.test(t)?t.startsWith("-")?S.factory.createStringLiteral(t):S.factory.createNumericLiteral(t):w({case:e.config.output.case,value:t}));var ge=({schema:e})=>{let t=[];return e.title&&t.push(z(e.title)),e.description&&t.push(z(e.description)),e.deprecated&&t.push("@deprecated"),t.length?t:void 0};var qs=s.keywordTypeNode({keyword:"string"}),yu=({server:e})=>{let t=Ze(e.url);return t.protocol&&t.host?s.literalTypeNode({literal:s.stringLiteral({text:e.url})}):s.templateLiteralType({value:[t.protocol||qs,"://",t.host||qs,t.port?`:${t.port}`:"",t.path||""]})},$c=({plugin:e,servers:t,symbolClientOptions:r})=>{let n=I(e.context.config),o=t.map(p=>yu({server:p}));t.length?"strictBaseUrl"in n.config&&n.config.strictBaseUrl||o.push(s.typeIntersectionNode({types:[qs,S.factory.createTypeLiteralNode([])]})):o.push(qs);let i=s.typeInterfaceNode({properties:[{name:de(e.context.config),type:s.typeUnionNode({types:o})}],useLegacyResolution:false}),a=s.typeAliasDeclaration({exportType:r.exported,name:r.placeholder,type:i});e.setSymbolValue(r,a);};var hu=({plugin:e,schema:t})=>{let r=[];return {obj:(t.items??[]).map((o,i)=>{let a=typeof o.const;r.includes(a)||r.push(a);let p;return o.title?p=o.title:a==="number"||a==="string"?p=`${o.const}`:a==="boolean"?p=o.const?"true":"false":o.const===null?p="null":p=`${i}`,p&&(p=w({case:e.config.enums.case,stripLeadingSeparators:false,value:p}),te.lastIndex=0,te.test(p)&&e.config.enums.enabled&&(e.config.enums.mode==="typescript"||e.config.enums.mode==="typescript-const")&&(p=`_${p}`)),{comments:ge({schema:o}),key:p,value:o.const}}),typeofItems:r}},Mc=({plugin:e,schema:t,symbol:r,type:n})=>{if(t.type==="enum"&&e.config.enums.enabled){let i=hu({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 a=s.constVariable({assertion:"const",comment:ge({schema:t}),exportConst:true,expression:s.objectExpression({multiLine:true,obj:i.obj}),name:r.placeholder}),p=s.typeOfExpression({text:r.placeholder}),c=s.typeAliasDeclaration({comment:ge({schema:t}),exportType:true,name:r.placeholder,type:s.indexedAccessTypeNode({indexType:s.typeOperatorNode({operator:"keyof",type:p}),objectType:p})});e.setSymbolValue(r,[a,c]);return}else if((e.config.enums.mode==="typescript"||e.config.enums.mode==="typescript-const")&&!i.typeofItems.some(p=>p!=="number"&&p!=="string")){let p=s.enumDeclaration({asConst:e.config.enums.mode==="typescript-const",leadingComment:ge({schema:t}),name:r.placeholder,obj:i.obj});e.setSymbolValue(r,p);return}}let o=s.typeAliasDeclaration({comment:ge({schema:t}),exportType:r.exported,name:r.placeholder,type:n});e.setSymbolValue(r,o);};var ii=({parameters:e})=>{let t={type:"object"};if(e){let r={},n=[];for(let o in e){let i=e[o];r[i.name]=U({detectFormat:false,schema:i.schema}),i.required&&n.push(i.name);}t.properties=r,n.length&&(t.required=n);}return t},gu=({operation:e,plugin:t})=>{let r={type:"object"},n=[];r.properties||(r.properties={}),e.body?(r.properties.body=e.body.schema,e.body.required&&n.push("body")):r.properties.body={type:"never"},e.parameters?.header&&(r.properties.headers=ii({parameters:e.parameters.header}),r.properties.headers.required&&n.push("headers")),e.parameters?.path?(r.properties.path=ii({parameters:e.parameters.path}),r.properties.path.required&&n.push("path")):r.properties.path={type:"never"},e.parameters?.query?(r.properties.query=ii({parameters:e.parameters.query}),r.properties.query.required&&n.push("query")):r.properties.query={type:"never"},r.properties.url={const:e.path,type:"string"},n.push("url"),r.required=n;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=ee({plugin:t,schema:r}),a=s.typeAliasDeclaration({exportType:o.exported,name:o.placeholder,type:i});t.setSymbolValue(o,a);},Lc=({operation:e,plugin:t})=>{gu({operation:e,plugin:t});let{error:r,errors:n,response:o,responses:i}=ze(e);if(n){let a=t.registerSymbol({exported:true,meta:{kind:"type"},name:O({config:t.config.errors,name:e.id}),selector:t.api.getSelector("errors",e.id)}),p=ee({plugin:t,schema:n}),c=s.typeAliasDeclaration({exportType:a.exported,name:a.placeholder,type:p});if(t.setSymbolValue(a,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=s.indexedAccessTypeNode({indexType:s.typeOperatorNode({operator:"keyof",type:s.typeReferenceNode({typeName:a.placeholder})}),objectType:s.typeReferenceNode({typeName:a.placeholder})}),f=s.typeAliasDeclaration({exportType:m.exported,name:m.placeholder,type:l});t.setSymbolValue(m,f);}}if(i){let a=t.registerSymbol({exported:true,meta:{kind:"type"},name:O({config:t.config.responses,name:e.id}),selector:t.api.getSelector("responses",e.id)}),p=ee({plugin:t,schema:i}),c=s.typeAliasDeclaration({exportType:a.exported,name:a.placeholder,type:p});if(t.setSymbolValue(a,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=s.indexedAccessTypeNode({indexType:s.typeOperatorNode({operator:"keyof",type:s.typeReferenceNode({typeName:a.placeholder})}),objectType:s.typeReferenceNode({typeName:a.placeholder})}),f=s.typeAliasDeclaration({exportType:m.exported,name:m.placeholder,type:l});t.setSymbolValue(m,f);}}};var xu=({operation:e,plugin:t})=>{let r={type:"object"},n=[];if(r.properties||(r.properties={}),e.body){let p=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=ee({plugin:t,schema:e.body.schema}),m=s.typeAliasDeclaration({comment:ge({schema:e.body.schema}),exportType:p.exported,name:p.placeholder,type:c});t.setSymbolValue(p,m),t.registerSymbol({exported:true,meta:{kind:"type"},name:p.name,placeholder:p.placeholder,selector:t.api.getSelector("ref",p.placeholder)}),r.properties.body={$ref:p.placeholder},n.push("body");}else r.properties.body={type:"never"};r.properties.key={const:e.path,type:"string"},n.push("key"),r.properties.path={type:"never"},r.properties.query={type:"never"},r.required=n;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=ee({plugin:t,schema:r}),a=s.typeAliasDeclaration({exportType:o.exported,name:o.placeholder,type:i});return t.setSymbolValue(o,a),o.placeholder},Vc=({operation:e,plugin:t})=>xu({operation:e,plugin:t});var Dc=({plugin:e,symbolWebhooks:t,webhookNames:r})=>{if(!r.length)return;let n=s.typeUnionNode({types:r.map(i=>s.typeReferenceNode({typeName:i}))}),o=s.typeAliasDeclaration({exportType:t.exported,name:t.placeholder,type:n});e.setSymbolValue(t,o);};var bu=({plugin:e,schema:t})=>{if(!t.items)return s.typeArrayNode(s.keywordTypeNode({keyword:e.config.topType}));t=U({detectFormat:true,schema:t});let r=[];for(let n of t.items){let o=ee({plugin:e,schema:n});r.push(o);}return r.length===1?s.typeArrayNode(r[0]):t.logicalOperator==="and"?s.typeArrayNode(s.typeIntersectionNode({types:r})):s.typeArrayNode(s.typeUnionNode({types:r}))},Su=({schema:e})=>e.const!==void 0?s.literalTypeNode({literal:s.ots.boolean(e.const)}):s.keywordTypeNode({keyword:"boolean"}),Ou=({plugin:e,schema:t})=>ee({plugin:e,schema:{...t,type:void 0}}),Tu=({plugin:e,schema:t})=>t.const!==void 0?s.literalTypeNode({literal:s.ots.number(t.const)}):t.type==="integer"&&t.format==="int64"&&e.getPlugin("@hey-api/transformers")?.config.bigInt?s.typeReferenceNode({typeName:"bigint"}):s.keywordTypeNode({keyword:"number"}),Ru=({plugin:e,schema:t})=>{let r,n,o=[],i=[],a=t.required??[],p=false;for(let d in t.properties){let u=t.properties[d],h=ee({plugin:e,schema:u}),g=a.includes(d);o.push({comment:ge({schema:u}),isReadOnly:u.accessScope==="read",isRequired:g,name:qc({context:e.context,name:d}),type:h}),i.push(u),g||(p=true);}if(t.patternProperties)for(let d in t.patternProperties){let u=t.patternProperties[d];i.unshift(u);}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]),p&&i.push({type:"undefined"}),n={isRequired:!t.propertyNames,name:"key",type:i.length===1?ee({plugin:e,schema:i[0]}):ee({plugin:e,schema:{items:i,logicalOperator:"or"}})},t.propertyNames?.$ref&&(r=ee({plugin:e,schema:{$ref:t.propertyNames.$ref}}));}return s.typeInterfaceNode({indexKey:r,indexProperty:n,properties:o,useLegacyResolution:false})},Au=({plugin:e,schema:t})=>{if(t.const!==void 0)return s.literalTypeNode({literal:s.stringLiteral({text:t.const})});if(t.format){if(t.format==="binary")return s.typeUnionNode({types:[s.typeReferenceNode({typeName:"Blob"}),s.typeReferenceNode({typeName:"File"})]});if((t.format==="date-time"||t.format==="date")&&e.getPlugin("@hey-api/transformers")?.config.dates)return s.typeReferenceNode({typeName:"Date"});if(t.format==="typeid"&&typeof t.example=="string"){let r=String(t.example).split("_");r.pop();let n=r.join("_"),o=e.api.getSelector("TypeID",n);if(!e.getSymbol(o)){let a=e.api.getSelector("TypeID");if(!e.getSymbol(a)){let l=e.registerSymbol({exported:true,meta:{kind:"type"},name:"TypeID",selector:a}),f=s.typeAliasDeclaration({exportType:l.exported,name:l.placeholder,type:s.templateLiteralType({value:[s.typeReferenceNode({typeName:"T"}),"_",s.keywordTypeNode({keyword:"string"})]}),typeParameters:[s.typeParameterDeclaration({constraint:s.keywordTypeNode({keyword:"string"}),name:"T"})]});e.setSymbolValue(l,f);}let p=e.referenceSymbol(a),c=e.registerSymbol({exported:true,meta:{kind:"type"},name:w({case:e.config.case,value:`${n}_id`}),selector:o}),m=s.typeAliasDeclaration({exportType:c.exported,name:c.placeholder,type:s.typeReferenceNode({typeArguments:[s.literalTypeNode({literal:s.stringLiteral({text:n})})],typeName:p.placeholder})});e.setSymbolValue(c,m);}let i=e.referenceSymbol(o);return s.typeReferenceNode({typeName:i.placeholder})}}return s.keywordTypeNode({keyword:"string"})},Pu=({plugin:e,schema:t})=>{let r=[];if(t.const&&Array.isArray(t.const))r=t.const.map(n=>s.valueToExpression({value:n})??s.identifier({text:e.config.topType}));else if(t.items)for(let n of t.items){let o=ee({plugin:e,schema:n});r.push(o);}return s.typeTupleNode({types:r})},Fc=({plugin:e,schema:t})=>{let r=e.getPlugin("@hey-api/transformers");if(r?.config.typeTransformers)for(let n of r.config.typeTransformers){let o=n({schema:t});if(o)return o}switch(t.type){case "array":return bu({plugin:e,schema:t});case "boolean":return Su({schema:t});case "enum":return Ou({plugin:e,schema:t});case "integer":case "number":return Tu({plugin:e,schema:t});case "never":return s.keywordTypeNode({keyword:"never"});case "null":return s.literalTypeNode({literal:s.null()});case "object":return Ru({plugin:e,schema:t});case "string":return Au({plugin:e,schema:t});case "tuple":return Pu({plugin:e,schema:t});case "undefined":return s.keywordTypeNode({keyword:"undefined"});case "unknown":return s.keywordTypeNode({keyword:e.config.topType});case "void":return s.keywordTypeNode({keyword:"void"})}},ee=({plugin:e,schema:t})=>{if(t.$ref){let r=e.referenceSymbol(e.api.getSelector("ref",t.$ref));return s.typeReferenceNode({typeName:r.placeholder})}if(t.type)return Fc({plugin:e,schema:t});if(t.items){if(t=U({detectFormat:false,schema:t}),t.items){let r=[];for(let n of t.items){let o=ee({plugin:e,schema:n});r.push(o);}return t.logicalOperator==="and"?s.typeIntersectionNode({types:r}):s.typeUnionNode({types:r})}return ee({plugin:e,schema:t})}return Fc({plugin:e,schema:{type:"unknown"}})},ai=({id:e,plugin:t,schema:r})=>{let n=ee({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:F(e)}),selector:t.api.getSelector("ref",e)});Mc({plugin:t,schema:r,symbol:i,type:n});},Bc=({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")}),n=[],o=[];e.forEach("operation","parameter","requestBody","schema","server","webhook",i=>{switch(i.type){case "operation":Lc({operation:i.operation,plugin:e});break;case "parameter":ai({id:i.$ref,plugin:e,schema:i.parameter.schema});break;case "requestBody":ai({id:i.$ref,plugin:e,schema:i.requestBody.schema});break;case "schema":ai({id:i.$ref,plugin:e,schema:i.schema});break;case "server":n.push(i.server);break;case "webhook":o.push(Vc({operation:i.operation,plugin:e}));break}}),$c({plugin:e,servers:n,symbolClientOptions:t}),Dc({plugin:e,symbolWebhooks:r,webhookNames:o});};var $s=class{constructor(t){this.meta=t;}getSelector(...t){return [this.meta.name,...t]}schemaToType(t){return ee(t)}};var Ms={api:new $s({name:"@hey-api/typescript"}),config:{case:"PascalCase",exportFromIndex:true,style:"preserve",topType:"unknown",tree:false},handler:Bc,handlerLegacy:kc,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 Ls=class{constructor(t){this.meta=t;}getSelector(...t){return [this.meta.name,...t]}};var Vs=(e,t,r)=>{let n=e.config[r].meta;if(!n)return;let o=n(t);if(Object.keys(o).length)return s.valueToExpression({value:o})};var Cr=({operation:e,plugin:t})=>{let r=t.getPluginOrThrow("@hey-api/sdk");return Yr({operation:e,plugin:r})},Ds=({operation:e,plugin:t})=>{let r=I(t.context.config),n=t.getPluginOrThrow("@hey-api/typescript"),i=t.getSymbol(n.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},Fs=({operation:e,plugin:t})=>{let r=t.getPluginOrThrow("@hey-api/typescript");return t.getSymbol(r.api.getSelector("response",e.id))?.placeholder||"unknown"};var vr=({plugin:e,typeData:t})=>{let n=I(e.context.config).name==="@hey-api/client-nuxt",o=n?`Omit<${t}, 'composable'>`:t;return {isNuxtClient:n,strippedTypeData:o}};var Kc=({operation:e,plugin:t,queryFn:r})=>{let n=t.referenceSymbol(t.api.getSelector("UseMutationOptions")),o=Cr({operation:e,plugin:t}),i=Ds({operation:e,plugin:t}),a=Fs({operation:e,plugin:t}),{isNuxtClient:p,strippedTypeData:c}=vr({plugin:t,typeData:o}),m=p?`${n.placeholder}<${a}, ${c}, ${i}>`:`${n.placeholder}<${a}, ${o}, ${i}>`,l="fnOptions",f=s.awaitExpression({expression:s.callExpression({functionName:r,parameters:[s.objectExpression({multiLine:true,obj:[{spread:"options"},{spread:l},{key:"throwOnError",value:true}]})]})}),d=[];t.getPluginOrThrow("@hey-api/sdk").config.responseStyle==="data"?d.push(s.returnVariable({expression:f})):d.push(s.constVariable({destructure:true,expression:f,name:"data"}),s.returnVariable({expression:"data"}));let u=[{key:"mutation",value:s.arrowFunction({async:true,multiLine:true,parameters:[p?{name:l,type:`Partial<${c}>`}:{name:l}],statements:d})}],h=Vs(t,e,"mutationOptions");h&&u.push({key:"meta",value:h});let g=t.registerSymbol({exported:true,name:O({config:t.config.mutationOptions,name:e.id})}),x=s.constVariable({comment:t.config.comments?Z({operation:e}):void 0,exportConst:g.exported,expression:s.arrowFunction({parameters:[{isRequired:false,name:"options",type:`Partial<${c}>`}],returnType:m,statements:[s.returnStatement({expression:s.objectExpression({obj:u})})]}),name:g.placeholder});t.setSymbolValue(g.id,x);};var rn="TOptions",Bs=s.identifier({text:"options"}),Wc=({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")),n=s.indexedAccessTypeNode({indexType:s.literalTypeNode({literal:s.ots.number(0)}),objectType:s.typeReferenceNode({typeArguments:[s.typeReferenceNode({typeName:rn})],typeName:r.placeholder})}),o=de(e.context.config),i=e.getPluginOrThrow("@hey-api/sdk"),a=e.referenceSymbol(i.api.getSelector("Options")),p=I(e.context.config),c=p.api&&"getSelector"in p.api?e.getSymbol(p.api.getSelector("client")):void 0,m=s.constVariable({expression:s.arrowFunction({multiLine:true,parameters:[{name:"id",type:s.typeReferenceNode({typeName:"string"})},{isRequired:false,name:"options",type:s.typeReferenceNode({typeName:rn})},{isRequired:false,name:"tags",type:s.typeReferenceNode({typeName:"ReadonlyArray<string>"})}],returnType:s.typeTupleNode({types:[n]}),statements:[s.constVariable({assertion:n,expression:s.objectExpression({multiLine:false,obj:[{key:"_id",value:s.identifier({text:"id"})},{key:o,value:s.identifier({text:`options?.${o} || (options?.client ?? ${c?.placeholder}).getConfig().${o}`})}]}),name:"params",typeName:n}),s.ifStatement({expression:s.identifier({text:"tags"}),thenStatement:s.block({statements:[s.expressionToStatement({expression:s.binaryExpression({left:s.propertyAccessExpression({expression:"params",name:"tags"}),right:s.asExpression({expression:s.asExpression({expression:s.identifier({text:"tags"}),type:s.keywordTypeNode({keyword:"unknown"})}),type:s.keywordTypeNode({keyword:"undefined"})})})})]})}),s.ifStatement({expression:s.propertyAccessExpression({expression:Bs,isOptional:true,name:s.identifier({text:"body"})}),thenStatement:s.block({statements:[s.expressionToStatement({expression:s.binaryExpression({left:s.propertyAccessExpression({expression:"params",name:"body"}),right:s.propertyAccessExpression({expression:"options",name:"body"})})})]})}),s.ifStatement({expression:s.propertyAccessExpression({expression:Bs,isOptional:true,name:s.identifier({text:"headers"})}),thenStatement:s.block({statements:[s.expressionToStatement({expression:s.binaryExpression({left:s.propertyAccessExpression({expression:"params",name:"headers"}),right:s.asExpression({expression:s.asExpression({expression:s.propertyAccessExpression({expression:"options",name:"headers"}),type:s.keywordTypeNode({keyword:"unknown"})}),type:s.keywordTypeNode({keyword:"undefined"})})})})]})}),s.ifStatement({expression:s.propertyAccessExpression({expression:Bs,isOptional:true,name:s.identifier({text:"path"})}),thenStatement:s.block({statements:[s.expressionToStatement({expression:s.binaryExpression({left:s.propertyAccessExpression({expression:"params",name:"path"}),right:s.propertyAccessExpression({expression:"options",name:"path"})})})]})}),s.ifStatement({expression:s.propertyAccessExpression({expression:Bs,isOptional:true,name:s.identifier({text:"query"})}),thenStatement:s.block({statements:[s.expressionToStatement({expression:s.binaryExpression({left:s.propertyAccessExpression({expression:"params",name:"query"}),right:s.asExpression({expression:s.asExpression({expression:s.propertyAccessExpression({expression:"options",name:"query"}),type:s.keywordTypeNode({keyword:"unknown"})}),type:s.keywordTypeNode({keyword:"undefined"})})})})]})}),s.returnStatement({expression:s.arrayLiteralExpression({elements:[s.identifier({text:"params"})]})})],types:[{extends:s.typeReferenceNode({typeName:s.identifier({text:a.placeholder})}),name:rn}]}),name:t.placeholder});e.setSymbolValue(t,m);},Iu=({id:e,operation:t,plugin:r})=>{let n=r.config.queryKeys,o;n.tags&&t.tags&&t.tags.length>0&&(o=s.arrayLiteralExpression({elements:t.tags.map(p=>s.stringLiteral({text:p}))}));let i=r.referenceSymbol(r.api.getSelector("createQueryKey"));return s.callExpression({functionName:i.placeholder,parameters:[s.ots.string(e),"options",o]})},zc=({plugin:e})=>{let t=e.referenceSymbol(e.api.getSelector("_JSONValue")),r=[{name:"_id",type:s.keywordTypeNode({keyword:"string"})},{isRequired:false,name:de(e.context.config),type:s.typeReferenceNode({typeName:t.placeholder})},{isRequired:false,name:"headers",type:s.typeReferenceNode({typeName:t.placeholder})},{isRequired:false,name:"query",type:s.typeReferenceNode({typeName:t.placeholder})},{isRequired:false,name:"tags",type:s.typeReferenceNode({typeName:t.placeholder})}],n=e.getPluginOrThrow("@hey-api/sdk"),o=e.referenceSymbol(n.api.getSelector("Options")),i=e.registerSymbol({exported:true,meta:{kind:"type"},name:"QueryKey",selector:e.api.getSelector("QueryKey")}),a=s.typeAliasDeclaration({exportType:i.exported,name:i.placeholder,type:s.typeTupleNode({types:[s.typeIntersectionNode({types:[s.typeReferenceNode({typeName:`Pick<${rn}, 'body' | 'path'>`}),s.typeInterfaceNode({properties:r,useLegacyResolution:true})]})]}),typeParameters:[{extends:s.typeReferenceNode({typeName:s.identifier({text:o.placeholder})}),name:rn}]});e.setSymbolValue(i,a);},_c=({operation:e,plugin:t,symbol:r})=>{let n=Cr({operation:e,plugin:t}),{strippedTypeData:o}=vr({plugin:t,typeData:n});return s.constVariable({exportConst:r.exported,expression:s.arrowFunction({parameters:[{isRequired:fr(e),name:"options",type:o}],statements:Iu({id:e.id,operation:e,plugin:t})}),name:r.placeholder})};var pi="context",ci="options",Hc=({operation:e,plugin:t,queryFn:r})=>{if(kr({operation:e}))return;let n=se({context:t.context,operation:e});t.getSymbol(t.api.getSelector("createQueryKey"))||(zc({plugin:t}),Wc({plugin:t}));let o=t.referenceSymbol(t.api.getSelector("UseQueryOptions")),i=t.registerSymbol({exported:true,name:O({config:t.config.queryKeys,name:e.id})}),a=_c({operation:e,plugin:t,symbol:i});t.setSymbolValue(i,a);let p=Cr({operation:e,plugin:t}),c=Ds({operation:e,plugin:t}),m=Fs({operation:e,plugin:t}),{isNuxtClient:l,strippedTypeData:f}=vr({plugin:t,typeData:p}),d=s.awaitExpression({expression:s.callExpression({functionName:r,parameters:[s.objectExpression({multiLine:true,obj:[{spread:ci},{spread:pi},{key:"throwOnError",value:true}]})]})}),u=[];t.getPluginOrThrow("@hey-api/sdk").config.responseStyle==="data"?u.push(s.returnVariable({expression:d})):u.push(s.constVariable({destructure:true,expression:d,name:"data"}),s.returnVariable({expression:"data"}));let h=[{key:"key",value:s.callExpression({functionName:i.placeholder,parameters:[ci]})},{key:"query",value:s.arrowFunction({async:true,multiLine:true,parameters:[l?{name:pi,type:f}:{name:pi}],statements:u})}],g=Vs(t,e,"queryOptions");g&&h.push({key:"meta",value:g});let x=t.registerSymbol({exported:true,name:O({config:t.config.queryOptions,name:e.id}),selector:t.api.getSelector("queryOptionsFn",e.id)}),b=s.constVariable({comment:t.config.comments?Z({operation:e}):void 0,exportConst:x.exported,expression:s.arrowFunction({parameters:[{isRequired:n,name:ci,type:f}],returnType:l?`${o.placeholder}<${m}, ${f}, ${c}>`:`${o.placeholder}<${m}, ${c}>`,statements:[s.returnStatement({expression:s.objectExpression({obj:h})})]}),name:x.placeholder});t.setSymbolValue(x,b);};var Qc=({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 n=t.config.asClass?we({context:e.context,operation:r,plugin:t}):void 0,o=n?n.values().next().value:void 0,i=o?[e.referenceSymbol(t.api.getSelector("class",o.path[0])).placeholder,...o.path.slice(1).map(a=>w({case:"camelCase",value:a})),o.methodName].filter(Boolean).join("."):e.referenceSymbol(t.api.getSelector("function",r.id)).placeholder;e.hooks.operation.isQuery(r)&&e.config.queryOptions.enabled&&Hc({operation:r,plugin:e,queryFn:i}),e.hooks.operation.isMutation(r)&&e.config.mutationOptions.enabled&&Kc({operation:r,plugin:e,queryFn:i});});};var Ks={api:new Ls({name:"@pinia/colada"}),config:{case:"camelCase",comments:true,exportFromIndex:false},dependencies:["@hey-api/typescript","@hey-api/sdk"],handler:Qc,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 wr=(e,t,r)=>{let n=e.config[r].meta;if(!n)return;let o=n(t);if(Object.keys(o).length)return s.valueToExpression({value:o})};var nt=({operation:e,plugin:t})=>{let r=t.getPluginOrThrow("@hey-api/sdk");return Yr({operation:e,plugin:r})},Ws=({operation:e,plugin:t})=>{let r=I(t.context.config),n=t.getPluginOrThrow("@hey-api/typescript"),i=t.getSymbol(n.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},zs=({operation:e,plugin:t})=>{let r=t.getPluginOrThrow("@hey-api/typescript");return t.getSymbol(r.api.getSelector("response",e.id))?.placeholder||"unknown"};var nn="TOptions",Zc=s.identifier({text:"infinite"}),_s=s.identifier({text:"options"}),Hs=({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")),n=s.indexedAccessTypeNode({indexType:s.literalTypeNode({literal:s.ots.number(0)}),objectType:s.typeReferenceNode({typeArguments:[s.typeReferenceNode({typeName:nn})],typeName:r.placeholder})}),o=de(e.context.config),i=I(e.context.config),a=i.api&&"getSelector"in i.api?e.getSymbol(i.api.getSelector("client")):void 0,p=e.getPluginOrThrow("@hey-api/sdk"),c=e.referenceSymbol(p.api.getSelector("Options")),m=s.constVariable({expression:s.arrowFunction({multiLine:true,parameters:[{name:"id",type:s.typeReferenceNode({typeName:"string"})},{isRequired:false,name:"options",type:s.typeReferenceNode({typeName:nn})},{isRequired:false,name:"infinite",type:s.typeReferenceNode({typeName:"boolean"})},{isRequired:false,name:"tags",type:s.typeReferenceNode({typeName:"ReadonlyArray<string>"})}],returnType:s.typeTupleNode({types:[n]}),statements:[s.constVariable({assertion:n,expression:s.objectExpression({multiLine:false,obj:[{key:"_id",value:s.identifier({text:"id"})},{key:o,value:s.identifier({text:`options?.${o} || (options?.client ?? ${a?.placeholder}).getConfig().${o}`})}]}),name:"params",typeName:n}),s.ifStatement({expression:Zc,thenStatement:s.block({statements:[s.expressionToStatement({expression:s.binaryExpression({left:s.propertyAccessExpression({expression:"params",name:"_infinite"}),right:Zc})})]})}),s.ifStatement({expression:s.identifier({text:"tags"}),thenStatement:s.block({statements:[s.expressionToStatement({expression:s.binaryExpression({left:s.propertyAccessExpression({expression:"params",name:"tags"}),right:s.identifier({text:"tags"})})})]})}),s.ifStatement({expression:s.propertyAccessExpression({expression:_s,isOptional:true,name:s.identifier({text:"body"})}),thenStatement:s.block({statements:[s.expressionToStatement({expression:s.binaryExpression({left:s.propertyAccessExpression({expression:"params",name:"body"}),right:s.propertyAccessExpression({expression:"options",name:"body"})})})]})}),s.ifStatement({expression:s.propertyAccessExpression({expression:_s,isOptional:true,name:s.identifier({text:"headers"})}),thenStatement:s.block({statements:[s.expressionToStatement({expression:s.binaryExpression({left:s.propertyAccessExpression({expression:"params",name:"headers"}),right:s.propertyAccessExpression({expression:"options",name:"headers"})})})]})}),s.ifStatement({expression:s.propertyAccessExpression({expression:_s,isOptional:true,name:s.identifier({text:"path"})}),thenStatement:s.block({statements:[s.expressionToStatement({expression:s.binaryExpression({left:s.propertyAccessExpression({expression:"params",name:"path"}),right:s.propertyAccessExpression({expression:"options",name:"path"})})})]})}),s.ifStatement({expression:s.propertyAccessExpression({expression:_s,isOptional:true,name:s.identifier({text:"query"})}),thenStatement:s.block({statements:[s.expressionToStatement({expression:s.binaryExpression({left:s.propertyAccessExpression({expression:"params",name:"query"}),right:s.propertyAccessExpression({expression:"options",name:"query"})})})]})}),s.returnStatement({expression:s.arrayLiteralExpression({elements:[s.identifier({text:"params"})]})})],types:[{extends:s.typeReferenceNode({typeName:s.identifier({text:c.placeholder})}),name:nn}]}),name:t.placeholder});e.setSymbolValue(t,m);},ju=({id:e,isInfinite:t,operation:r,plugin:n})=>{let o=t?n.config.infiniteQueryKeys:n.config.queryKeys,i;o.tags&&r.tags&&r.tags.length>0&&(i=s.arrayLiteralExpression({elements:r.tags.map(c=>s.stringLiteral({text:c}))}));let a=n.referenceSymbol(n.api.getSelector("createQueryKey"));return s.callExpression({functionName:a.placeholder,parameters:[s.ots.string(e),"options",t||i?s.ots.boolean(!!t):void 0,i]})},Qs=({plugin:e})=>{let t=[{name:"_id",type:s.keywordTypeNode({keyword:"string"})},{isRequired:false,name:"_infinite",type:s.keywordTypeNode({keyword:"boolean"})},{isRequired:false,name:"tags",type:s.typeReferenceNode({typeName:"ReadonlyArray<string>"})}],r=e.getPluginOrThrow("@hey-api/sdk"),n=e.referenceSymbol(r.api.getSelector("Options")),o=e.registerSymbol({exported:true,meta:{kind:"type"},name:"QueryKey",selector:e.api.getSelector("QueryKey")}),i=s.typeAliasDeclaration({exportType:o.exported,name:o.placeholder,type:s.typeTupleNode({types:[s.typeIntersectionNode({types:[s.typeReferenceNode({typeName:`Pick<${nn}, '${de(e.context.config)}' | 'body' | 'headers' | 'path' | 'query'>`}),s.typeInterfaceNode({properties:t,useLegacyResolution:true})]})]}),typeParameters:[{extends:s.typeReferenceNode({typeName:s.identifier({text:n.placeholder})}),name:nn}]});e.setSymbolValue(o,i);},Zs=({isInfinite:e,operation:t,plugin:r,symbol:n,typeQueryKey:o})=>{let i=nt({operation:t,plugin:r});return s.constVariable({exportConst:n.exported,expression:s.arrowFunction({parameters:[{isRequired:fr(t),name:"options",type:i}],returnType:e?o:void 0,statements:ju({id:t.id,isInfinite:e,operation:t,plugin:r})}),name:n.placeholder})};var Cu=({plugin:e})=>{let t=e.registerSymbol({name:O({config:{case:e.config.case},name:"createInfiniteParams"}),selector:e.api.getSelector("createInfiniteParams")}),r=s.constVariable({expression:s.arrowFunction({multiLine:true,parameters:[{name:"queryKey",type:s.typeReferenceNode({typeName:"QueryKey<Options>"})},{name:"page",type:s.typeReferenceNode({typeName:"K"})}],statements:[s.constVariable({expression:s.objectExpression({obj:[{spread:s.propertyAccessExpression({expression:"queryKey",name:0})}]}),name:"params"}),s.ifStatement({expression:s.propertyAccessExpression({expression:s.identifier({text:"page"}),name:s.identifier({text:"body"})}),thenStatement:s.block({statements:[s.expressionToStatement({expression:s.binaryExpression({left:s.propertyAccessExpression({expression:"params",name:"body"}),right:s.objectExpression({multiLine:true,obj:[{assertion:"any",spread:"queryKey[0].body"},{assertion:"any",spread:"page.body"}]})})})]})}),s.ifStatement({expression:s.propertyAccessExpression({expression:s.identifier({text:"page"}),name:s.identifier({text:"headers"})}),thenStatement:s.block({statements:[s.expressionToStatement({expression:s.binaryExpression({left:s.propertyAccessExpression({expression:"params",name:"headers"}),right:s.objectExpression({multiLine:true,obj:[{spread:"queryKey[0].headers"},{spread:"page.headers"}]})})})]})}),s.ifStatement({expression:s.propertyAccessExpression({expression:s.identifier({text:"page"}),name:s.identifier({text:"path"})}),thenStatement:s.block({statements:[s.expressionToStatement({expression:s.binaryExpression({left:s.propertyAccessExpression({expression:"params",name:"path"}),right:s.objectExpression({multiLine:true,obj:[{assertion:"any",spread:"queryKey[0].path"},{assertion:"any",spread:"page.path"}]})})})]})}),s.ifStatement({expression:s.propertyAccessExpression({expression:s.identifier({text:"page"}),name:s.identifier({text:"query"})}),thenStatement:s.block({statements:[s.expressionToStatement({expression:s.binaryExpression({left:s.propertyAccessExpression({expression:"params",name:"query"}),right:s.objectExpression({multiLine:true,obj:[{assertion:"any",spread:"queryKey[0].query"},{assertion:"any",spread:"page.query"}]})})})]})}),s.returnVariable({expression:s.asExpression({expression:s.asExpression({expression:s.identifier({text:"params"}),type:s.keywordTypeNode({keyword:"unknown"})}),type:S.factory.createTypeQueryNode(s.identifier({text:"page"}))})})],types:[{extends:s.typeReferenceNode({typeName:s.identifier({text:"Pick<QueryKey<Options>[0], 'body' | 'headers' | 'path' | 'query'>"})}),name:"K"}]}),name:t.placeholder});e.setSymbolValue(t,r);},Uc=({operation:e,plugin:t,queryFn:r})=>{let n=ja({context:t.context,operation:e});if(!n)return;let o=se({context:t.context,operation:e});t.getSymbol(t.api.getSelector("createQueryKey"))||(Qs({plugin:t}),Hs({plugin:t})),t.getSymbol(t.api.getSelector("createInfiniteParams"))||Cu({plugin:t});let i=t.referenceSymbol(t.api.getSelector("infiniteQueryOptions")),a=t.referenceSymbol(t.api.getSelector("InfiniteData")),p=nt({operation:e,plugin:t}),c=Ws({operation:e,plugin:t}),m=zs({operation:e,plugin:t}),f=`${t.referenceSymbol(t.api.getSelector("QueryKey")).placeholder}<${p}>`,d=`Pick<${f}[0], 'body' | 'headers' | 'path' | 'query'>`,u=t.getPluginOrThrow("@hey-api/typescript"),h=u.api.schemaToType({plugin:u,schema:n.schema}),g=`${me({node:h,unescape:true})} | ${d}`,x=t.registerSymbol({exported:true,name:O({config:t.config.infiniteQueryKeys,name:e.id})}),b=Zs({isInfinite:true,operation:e,plugin:t,symbol:x,typeQueryKey:f});t.setSymbolValue(x,b);let j=s.awaitExpression({expression:s.callExpression({functionName:r,parameters:[s.objectExpression({multiLine:true,obj:[{spread:"options"},{spread:"params"},{key:"signal",shorthand:true,value:s.identifier({text:"signal"})},{key:"throwOnError",value:true}]})]})}),k=t.referenceSymbol(t.api.getSelector("createInfiniteParams")),P=[s.constVariable({comment:[{jsdoc:false,lines:["@ts-ignore"]}],expression:s.conditionalExpression({condition:s.binaryExpression({left:s.typeOfExpression({text:"pageParam"}),operator:"===",right:s.ots.string("object")}),whenFalse:s.objectExpression({multiLine:true,obj:[{key:n.in,value:s.objectExpression({multiLine:true,obj:[{key:n.name,value:s.identifier({text:"pageParam"})}]})}]}),whenTrue:s.identifier({text:"pageParam"})}),name:"page",typeName:d}),s.constVariable({expression:s.callExpression({functionName:k.placeholder,parameters:["queryKey","page"]}),name:"params"})];t.getPluginOrThrow("@hey-api/sdk").config.responseStyle==="data"?P.push(s.returnVariable({expression:j})):P.push(s.constVariable({destructure:true,expression:j,name:"data"}),s.returnVariable({expression:"data"}));let C=[{key:"queryFn",value:s.arrowFunction({async:true,multiLine:true,parameters:[{destructure:[{name:"pageParam"},{name:"queryKey"},{name:"signal"}]}],statements:P})},{key:"queryKey",value:s.callExpression({functionName:x.placeholder,parameters:["options"]})}],V=wr(t,e,"infiniteQueryOptions");V&&C.push({key:"meta",value:V});let D=t.registerSymbol({exported:true,name:O({config:t.config.infiniteQueryOptions,name:e.id})}),q=s.constVariable({comment:t.config.comments?Z({operation:e}):void 0,exportConst:D.exported,expression:s.arrowFunction({parameters:[{isRequired:o,name:"options",type:p}],statements:[s.returnFunctionCall({args:[s.objectExpression({comments:[{jsdoc:false,lines:["@ts-ignore"]}],obj:C})],name:i.placeholder,types:[m,c||"unknown",`${a.placeholder}<${m}>`,f,g]})]}),name:D.placeholder});t.setSymbolValue(D,q);};var Xc=({operation:e,plugin:t,queryFn:r})=>{let n=t.referenceSymbol(t.api.getSelector("MutationOptions")),o=nt({operation:e,plugin:t}),i=Ws({operation:e,plugin:t}),a=zs({operation:e,plugin:t}),p=`${n.placeholder}<${a}, ${i}, ${o}>`,c="fnOptions",m=s.awaitExpression({expression:s.callExpression({functionName:r,parameters:[s.objectExpression({multiLine:true,obj:[{spread:"options"},{spread:c},{key:"throwOnError",value:true}]})]})}),l=[];t.getPluginOrThrow("@hey-api/sdk").config.responseStyle==="data"?l.push(s.returnVariable({expression:m})):l.push(s.constVariable({destructure:true,expression:m,name:"data"}),s.returnVariable({expression:"data"}));let f=[{key:"mutationFn",value:s.arrowFunction({async:true,multiLine:true,parameters:[{name:c}],statements:l})}],d=wr(t,e,"mutationOptions");d&&f.push({key:"meta",value:d});let u="mutationOptions",h=s.arrowFunction({parameters:[{isRequired:false,name:"options",type:`Partial<${o}>`}],returnType:p,statements:[s.constVariable({expression:s.objectExpression({obj:f}),name:u,typeName:p}),s.returnVariable({expression:u})]}),g=t.registerSymbol({exported:true,name:O({config:t.config.mutationOptions,name:e.id})}),x=s.constVariable({comment:t.config.comments?Z({operation:e}):void 0,exportConst:g.exported,expression:h,name:g.placeholder});t.setSymbolValue(g,x);};var mi="options",Gc=({operation:e,plugin:t,queryFn:r})=>{if(kr({operation:e}))return;let n=se({context:t.context,operation:e});t.getSymbol(t.api.getSelector("createQueryKey"))||(Qs({plugin:t}),Hs({plugin:t}));let o=t.referenceSymbol(t.api.getSelector("queryOptions")),i=t.registerSymbol({exported:true,name:O({config:t.config.queryKeys,name:e.id})}),a=Zs({isInfinite:false,operation:e,plugin:t,symbol:i});t.setSymbolValue(i,a);let p=nt({operation:e,plugin:t}),c=s.awaitExpression({expression:s.callExpression({functionName:r,parameters:[s.objectExpression({multiLine:true,obj:[{spread:mi},{spread:"queryKey[0]"},{key:"signal",shorthand:true,value:s.identifier({text:"signal"})},{key:"throwOnError",value:true}]})]})}),m=[];t.getPluginOrThrow("@hey-api/sdk").config.responseStyle==="data"?m.push(s.returnVariable({expression:c})):m.push(s.constVariable({destructure:true,expression:c,name:"data"}),s.returnVariable({expression:"data"}));let l=[{key:"queryFn",value:s.arrowFunction({async:true,multiLine:true,parameters:[{destructure:[{name:"queryKey"},{name:"signal"}]}],statements:m})},{key:"queryKey",value:s.callExpression({functionName:i.placeholder,parameters:[mi]})}],f=wr(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)}),u=s.constVariable({comment:t.config.comments?Z({operation:e}):void 0,exportConst:d.exported,expression:s.arrowFunction({parameters:[{isRequired:n,name:mi,type:p}],statements:[s.returnFunctionCall({args:[s.objectExpression({obj:l})],name:o.placeholder})]}),name:d.placeholder});t.setSymbolValue(d,u);};var Jc="options",Yc=({operation:e,plugin:t})=>{if(kr({operation:e})||!("useQuery"in t.config))return;let r=t.registerSymbol({exported:true,name:O({config:t.config.useQuery,name:e.id})}),n=t.referenceSymbol(t.api.getSelector("useQuery")),o=se({context:t.context,operation:e}),i=nt({operation:e,plugin:t}),a=t.referenceSymbol(t.api.getSelector("queryOptionsFn",e.id)),p=s.constVariable({comment:t.config.comments?Z({operation:e}):void 0,exportConst:r.exported,expression:s.arrowFunction({parameters:[{isRequired:o,name:Jc,type:i}],statements:[s.returnStatement({expression:s.callExpression({functionName:n.placeholder,parameters:[s.callExpression({functionName:a.placeholder,parameters:[Jc]})]})})]}),name:r.placeholder});t.setSymbolValue(r,p);};var st=({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:n})=>{let o=r.config.asClass?we({context:e.context,operation:n,plugin:r}):void 0,i=o?o.values().next().value:void 0,a=i?[e.referenceSymbol(r.api.getSelector("class",i.path[0])).placeholder,...i.path.slice(1).map(p=>w({case:"camelCase",value:p})),i.methodName].filter(Boolean).join("."):e.referenceSymbol(r.api.getSelector("function",n.id)).placeholder;e.hooks.operation.isQuery(n)&&(e.config.queryOptions.enabled&&Gc({operation:n,plugin:e,queryFn:a}),e.config.infiniteQueryOptions.enabled&&Uc({operation:n,plugin:e,queryFn:a}),"useQuery"in e.config&&e.config.useQuery.enabled&&Yc({operation:n,plugin:e})),e.hooks.operation.isMutation(n)&&e.config.mutationOptions.enabled&&Xc({operation:n,plugin:e,queryFn:a});});};var vu=e=>`${tt({config:A(),id:e.name,operation:e})}InfiniteOptions`,wu=e=>`${tt({config:A(),id:e.name,operation:e})}Mutation`,qu=({config:e,id:t,operation:r})=>`${tt({config:e,id:t,operation:r})}Options`,Us=({config:e,id:t,isInfinite:r,operation:n})=>`${tt({config:e,id:t,operation:n})}${r?"Infinite":""}QueryKey`,$u=e=>{switch(e.in){case "formData":return "body";case "header":return "headers";default:return e.in}},Mu="createInfiniteParams",pm="createQueryKey",em="infiniteQueryOptions",tm="mutationOptions",fi="QueryKey",rm="queryOptions",on="TOptions",Lu=({file:e})=>{let t=s.constVariable({expression:s.arrowFunction({multiLine:true,parameters:[{name:"queryKey",type:s.typeNode("QueryKey<OptionsLegacyParser>")},{name:"page",type:s.typeNode("K")}],statements:[s.constVariable({expression:s.identifier({text:"queryKey[0]"}),name:"params"}),s.ifStatement({expression:s.propertyAccessExpression({expression:s.identifier({text:"page"}),name:s.identifier({text:"body"})}),thenStatement:s.block({statements:[s.expressionToStatement({expression:s.binaryExpression({left:s.propertyAccessExpression({expression:"params",name:"body"}),right:s.objectExpression({multiLine:true,obj:[{assertion:"any",spread:"queryKey[0].body"},{assertion:"any",spread:"page.body"}]})})})]})}),s.ifStatement({expression:s.propertyAccessExpression({expression:s.identifier({text:"page"}),name:s.identifier({text:"headers"})}),thenStatement:s.block({statements:[s.expressionToStatement({expression:s.binaryExpression({left:s.propertyAccessExpression({expression:"params",name:"headers"}),right:s.objectExpression({multiLine:true,obj:[{spread:"queryKey[0].headers"},{spread:"page.headers"}]})})})]})}),s.ifStatement({expression:s.propertyAccessExpression({expression:s.identifier({text:"page"}),name:s.identifier({text:"path"})}),thenStatement:s.block({statements:[s.expressionToStatement({expression:s.binaryExpression({left:s.propertyAccessExpression({expression:"params",name:"path"}),right:s.objectExpression({multiLine:true,obj:[{spread:"queryKey[0].path"},{spread:"page.path"}]})})})]})}),s.ifStatement({expression:s.propertyAccessExpression({expression:s.identifier({text:"page"}),name:s.identifier({text:"query"})}),thenStatement:s.block({statements:[s.expressionToStatement({expression:s.binaryExpression({left:s.propertyAccessExpression({expression:"params",name:"query"}),right:s.objectExpression({multiLine:true,obj:[{spread:"queryKey[0].query"},{spread:"page.query"}]})})})]})}),s.returnVariable({expression:S.factory.createAsExpression(S.factory.createAsExpression(s.identifier({text:"params"}),S.factory.createKeywordTypeNode(S.SyntaxKind.UnknownKeyword)),S.factory.createTypeQueryNode(s.identifier({text:"page"})))})],types:[{extends:s.typeReferenceNode({typeName:s.identifier({text:"Pick<QueryKey<OptionsLegacyParser>[0], 'body' | 'headers' | 'path' | 'query'>"})}),name:"K"}]}),name:Mu});e.add(t);},nm=({file:e})=>{let t=s.indexedAccessTypeNode({indexType:s.typeNode(0),objectType:s.typeNode(fi,[s.typeNode(on)])}),r=s.identifier({text:"infinite"}),n=de(A()),o=s.constVariable({expression:s.arrowFunction({multiLine:true,parameters:[{name:"id",type:s.typeNode("string")},{isRequired:false,name:"options",type:s.typeNode(on)},{isRequired:false,name:"infinite",type:s.typeNode("boolean")}],returnType:t,statements:[s.constVariable({assertion:t,expression:s.objectExpression({multiLine:false,obj:[{key:"_id",value:s.identifier({text:"id"})},{key:n,value:s.identifier({text:`options?.${n} || (options?.client ?? _heyApiClient).getConfig().${n}`})}]}),name:"params",typeName:t}),s.ifStatement({expression:r,thenStatement:s.block({statements:[s.expressionToStatement({expression:s.binaryExpression({left:s.propertyAccessExpression({expression:"params",name:"_infinite"}),right:r})})]})}),s.ifStatement({expression:s.propertyAccessExpression({expression:s.identifier({text:"options"}),isOptional:true,name:s.identifier({text:"body"})}),thenStatement:s.block({statements:[s.expressionToStatement({expression:s.binaryExpression({left:s.propertyAccessExpression({expression:"params",name:"body"}),right:s.propertyAccessExpression({expression:"options",name:"body"})})})]})}),s.ifStatement({expression:s.propertyAccessExpression({expression:s.identifier({text:"options"}),isOptional:true,name:s.identifier({text:"headers"})}),thenStatement:s.block({statements:[s.expressionToStatement({expression:s.binaryExpression({left:s.propertyAccessExpression({expression:"params",name:"headers"}),right:s.propertyAccessExpression({expression:"options",name:"headers"})})})]})}),s.ifStatement({expression:s.propertyAccessExpression({expression:s.identifier({text:"options"}),isOptional:true,name:s.identifier({text:"path"})}),thenStatement:s.block({statements:[s.expressionToStatement({expression:s.binaryExpression({left:s.propertyAccessExpression({expression:"params",name:"path"}),right:s.propertyAccessExpression({expression:"options",name:"path"})})})]})}),s.ifStatement({expression:s.propertyAccessExpression({expression:s.identifier({text:"options"}),isOptional:true,name:s.identifier({text:"query"})}),thenStatement:s.block({statements:[s.expressionToStatement({expression:s.binaryExpression({left:s.propertyAccessExpression({expression:"params",name:"query"}),right:s.propertyAccessExpression({expression:"options",name:"query"})})})]})}),s.returnVariable({expression:"params"})],types:[{extends:s.typeReferenceNode({typeName:s.identifier({text:"OptionsLegacyParser"})}),name:on}]}),name:pm});e.add(o);},sm=({file:e})=>{let t=[{name:"_id",type:s.keywordTypeNode({keyword:"string"})},{isRequired:false,name:"_infinite",type:s.keywordTypeNode({keyword:"boolean"})}],r=s.typeAliasDeclaration({name:fi,type:s.typeTupleNode({types:[s.typeIntersectionNode({types:[s.typeReferenceNode({typeName:`Pick<${on}, '${de(A())}' | 'body' | 'headers' | 'path' | 'query'>`}),s.typeInterfaceNode({properties:t,useLegacyResolution:true})]})]}),typeParameters:[{extends:s.typeReferenceNode({typeName:s.identifier({text:"OptionsLegacyParser"})}),name:on}]});e.add(r);},li=({client:e,file:t,operation:r,typesModulePath:n})=>{let{name:o}=Yt({client:e,meta:r.parameters.length?{$ref:r.name,name:r.name}:void 0,nameTransformer:er,onImport:a=>{t.import({asType:true,module:n,name:a});}});return {typeData:oi({importedType:o})}},om=({client:e,file:t,operation:r,pluginName:n,typesModulePath:o})=>{let i=A(),{name:a}=Yt({client:e,meta:{$ref:r.name,name:r.name},nameTransformer:Nr,onImport:m=>{t.import({asType:true,module:o,name:m});}}),p={asType:true,name:a};if(p.name||(p=t.import({asType:true,module:n,name:"DefaultError"})),I(i).name==="@hey-api/client-axios"){let m=t.import({asType:true,module:"axios",name:"AxiosError"});p={...m,name:`${m.name}<${p.name}>`};}return {typeError:p}},im=({client:e,file:t,operation:r,typesModulePath:n})=>{let{name:o}=Yt({client:e,meta:{$ref:r.name,name:r.name},nameTransformer:rt,onImport:a=>{t.import({asType:true,module:n,name:a});}});return {typeResponse:o||"void"}},am=({id:e,isInfinite:t})=>s.arrayLiteralExpression({elements:[s.callExpression({functionName:pm,parameters:[s.ots.string(e),"options",t?s.ots.boolean(true):void 0]})],multiLine:false}),ot=({client:e,files:t,plugin:r})=>{let n=A();if(Q(n))throw new Error("TanStack Query plugin does not support legacy clients");let o=t[r.name];o.import({asType:true,module:Jt({config:n,sourceOutput:r.output}),name:"OptionsLegacyParser"});let i=rr({moduleOutput:t.types.nameWithoutExtension(),sourceOutput:r.output}),a=r.name==="@tanstack/angular-query-experimental"||r.name==="@tanstack/svelte-query"||r.name==="@tanstack/solid-query"?"MutationOptions":"UseMutationOptions",p,c=false,m=false,l=false,f=false,d=false,u=new Map;for(let h of e.services)for(let g of h.operations){let x=L(g);if(u.has(x))continue;u.set(x,true);let b=[n.plugins["@hey-api/sdk"]?.config.asClass&&Rr({config:n,name:h.name}),tt({config:n,handleIllegal:!n.plugins["@hey-api/sdk"]?.config.asClass,id:g.name,operation:g})].filter(Boolean).join("."),j=false;if(r.config.queryOptions.enabled&&["GET","POST"].includes(g.method)){d||(d=true,m||(sm({file:o}),nm({file:o}),m=true),o.import({module:r.name,name:rm})),j=true;let{typeData:k}=li({client:e,file:o,operation:g,typesModulePath:i}),P=Ye(g.parameters),C=s.constVariable({exportConst:true,expression:s.arrowFunction({parameters:[{isRequired:P,name:"options",type:k}],statements:am({id:g.name})}),name:Us({config:n,id:g.name,operation:g})});o.add(C);let V=s.constVariable({comment:[],exportConst:true,expression:s.arrowFunction({parameters:[{isRequired:P,name:"options",type:k}],statements:[s.returnFunctionCall({args:[s.objectExpression({obj:[{key:"queryFn",value:s.arrowFunction({async:true,multiLine:true,parameters:[{destructure:[{name:"queryKey"},{name:"signal"}]}],statements:[s.constVariable({destructure:true,expression:s.awaitExpression({expression:s.callExpression({functionName:b,parameters:[s.objectExpression({multiLine:true,obj:[{spread:"options"},{spread:"queryKey[0]"},{key:"signal",shorthand:true,value:s.identifier({text:"signal"})},{key:"throwOnError",value:true}]})]})}),name:"data"}),s.returnVariable({expression:"data"})]})},{key:"queryKey",value:s.callExpression({functionName:Us({config:n,id:g.name,operation:g}),parameters:["options"]})}]})],name:rm})]}),name:qu({config:n,id:g.name,operation:g})});o.add(V);}if(r.config.infiniteQueryOptions&&["GET","POST"].includes(g.method)){let k,P=g.parameters.find(C=>{if(Oe(n.parser.pagination).test(C.name))return k=C,true;if(C.in==="body"){if(C.export==="reference"){let D=C.$refs[0];return e.models.find(B=>B.meta?.$ref===D)?.properties.find(B=>{if(Oe(n.parser.pagination).test(B.name))return k=B,true})}return C.properties.find(D=>{if(Oe(n.parser.pagination).test(D.name))return k=D,true})}});if(P&&k){l||(l=true,m||(sm({file:o}),nm({file:o}),m=true),c||(Lu({file:o}),c=true),o.import({module:r.name,name:em}),p=o.import({asType:true,module:r.name,name:"InfiniteData"})),j=true;let{typeData:C}=li({client:e,file:o,operation:g,typesModulePath:i}),{typeError:V}=om({client:e,file:o,operation:g,pluginName:r.name,typesModulePath:i}),{typeResponse:D}=im({client:e,file:o,operation:g,typesModulePath:i}),q=Ye(g.parameters),B=`${fi}<${C}>`,Tt=`Pick<${B}[0], 'body' | 'headers' | 'path' | 'query'>`,Me=`${k.base} | ${Tt}`,tr=s.constVariable({exportConst:true,expression:s.arrowFunction({parameters:[{isRequired:q,name:"options",type:C}],returnType:B,statements:am({id:g.name,isInfinite:true})}),name:Us({config:n,id:g.name,isInfinite:true,operation:g})});o.add(tr);let wm=s.constVariable({comment:[],exportConst:true,expression:s.arrowFunction({parameters:[{isRequired:q,name:"options",type:C}],statements:[s.returnFunctionCall({args:[s.objectExpression({comments:[{jsdoc:false,lines:["@ts-ignore"]}],obj:[{key:"queryFn",value:s.arrowFunction({async:true,multiLine:true,parameters:[{destructure:[{name:"pageParam"},{name:"queryKey"},{name:"signal"}]}],statements:[s.constVariable({comment:[{jsdoc:false,lines:["@ts-ignore"]}],expression:s.conditionalExpression({condition:s.binaryExpression({left:s.typeOfExpression({text:"pageParam"}),operator:"===",right:s.ots.string("object")}),whenFalse:s.objectExpression({multiLine:true,obj:[{key:$u(P),value:s.objectExpression({multiLine:true,obj:[{key:k.name,value:s.identifier({text:"pageParam"})}]})}]}),whenTrue:s.identifier({text:"pageParam"})}),name:"page",typeName:Tt}),s.constVariable({expression:s.callExpression({functionName:"createInfiniteParams",parameters:["queryKey","page"]}),name:"params"}),s.constVariable({destructure:true,expression:s.awaitExpression({expression:s.callExpression({functionName:b,parameters:[s.objectExpression({multiLine:true,obj:[{spread:"options"},{spread:"params"},{key:"signal",shorthand:true,value:s.identifier({text:"signal"})},{key:"throwOnError",value:true}]})]})}),name:"data"}),s.returnVariable({expression:"data"})]})},{key:"queryKey",value:s.callExpression({functionName:Us({config:n,id:g.name,isInfinite:true,operation:g}),parameters:["options"]})}]})],name:em,types:[D,V.name,`${typeof p=="string"?p:p.name}<${D}>`,B,Me]})]}),name:vu(g)});o.add(wm);}}if(r.config.mutationOptions&&["DELETE","PATCH","POST","PUT"].includes(g.method)){f||(f=true,o.import({asType:true,module:r.name,name:a})),j=true;let{typeData:k}=li({client:e,file:o,operation:g,typesModulePath:i}),{typeError:P}=om({client:e,file:o,operation:g,pluginName:r.name,typesModulePath:i}),{typeResponse:C}=im({client:e,file:o,operation:g,typesModulePath:i}),V="fnOptions",D=s.arrowFunction({parameters:[{isRequired:false,name:"options",type:`Partial<${k}>`}],statements:[s.constVariable({expression:s.objectExpression({obj:[{key:"mutationFn",value:s.arrowFunction({async:true,multiLine:true,parameters:[{name:V}],statements:[s.constVariable({destructure:true,expression:s.awaitExpression({expression:s.callExpression({functionName:b,parameters:[s.objectExpression({multiLine:true,obj:[{spread:"options"},{spread:V},{key:"throwOnError",value:true}]})]})}),name:"data"}),s.returnVariable({expression:"data"})]})}]}),name:tm,typeName:`${a}<${C}, ${P.name}, ${k}>`}),s.returnVariable({expression:tm})]}),q=s.constVariable({comment:[],exportConst:true,expression:D,name:wu(g)});o.add(q);}(d||l)&&o.import({alias:"_heyApiClient",module:rr({moduleOutput:t.client.nameWithoutExtension(),sourceOutput:r.output}),name:"client"}),j&&o.import({module:rr({moduleOutput:t.sdk.nameWithoutExtension(),sourceOutput:r.output}),name:b.split(".")[0]});}};var Xs=class{constructor(t){this.meta=t;}getSelector(...t){return [this.meta.name,...t]}};var Gs={api:new Xs({name:"@tanstack/angular-query-experimental"}),config:{case:"camelCase",comments:true,exportFromIndex:false},dependencies:["@hey-api/sdk","@hey-api/typescript"],handler:st,handlerLegacy:ot,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 Js=class{constructor(t){this.meta=t;}getSelector(...t){return [this.meta.name,...t]}};var Ys={api:new Js({name:"@tanstack/react-query"}),config:{case:"camelCase",comments:true,exportFromIndex:false},dependencies:["@hey-api/sdk","@hey-api/typescript"],handler:st,handlerLegacy:ot,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 eo=class{constructor(t){this.meta=t;}getSelector(...t){return [this.meta.name,...t]}};var to={api:new eo({name:"@tanstack/solid-query"}),config:{case:"camelCase",comments:true,exportFromIndex:false},dependencies:["@hey-api/sdk","@hey-api/typescript"],handler:st,handlerLegacy:ot,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 ro=class{constructor(t){this.meta=t;}getSelector(...t){return [this.meta.name,...t]}};var no={api:new ro({name:"@tanstack/svelte-query"}),config:{case:"camelCase",comments:true,exportFromIndex:false},dependencies:["@hey-api/sdk","@hey-api/typescript"],handler:st,handlerLegacy:ot,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 so=class{constructor(t){this.meta=t;}getSelector(...t){return [this.meta.name,...t]}};var oo={api:new so({name:"@tanstack/vue-query"}),config:{case:"camelCase",comments:true,exportFromIndex:false},dependencies:["@hey-api/sdk","@hey-api/typescript"],handler:st,handlerLegacy:ot,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 io=class{constructor(t){this.meta=t;}getSelector(...t){return [this.meta.name,...t]}};var Wu=({operation:e,plugin:t})=>{let r=[],n=t.getPluginOrThrow("@hey-api/typescript"),o=t.getSymbol(n.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:Pt(e.parameters.header),name:"Headers",type:`${o.placeholder}['headers']`}),e.parameters.path&&r.push({isRequired:Pt(e.parameters.path),name:"Params",type:`${o.placeholder}['path']`}),e.parameters.query&&r.push({isRequired:Pt(e.parameters.query),name:"Querystring",type:`${o.placeholder}['query']`})));let{errors:i,responses:a}=ze(e),p,c=t.getSymbol(n.api.getSelector("errors",e.id));if(c&&i&&i.properties){let h=Object.keys(i.properties);if(h.length){if(!h.includes("default"))p=s.typeReferenceNode({typeName:c.placeholder});else if(h.length>1){let x=s.typeReferenceNode({typeName:c.placeholder}),b=s.literalTypeNode({literal:s.stringLiteral({text:"default"})});p=s.typeReferenceNode({typeArguments:[x,b],typeName:"Omit"});}}}let m,l=t.getSymbol(n.api.getSelector("responses",e.id));if(l&&a&&a.properties){let h=Object.keys(a.properties);if(h.length){if(!h.includes("default"))m=s.typeReferenceNode({typeName:l.placeholder});else if(h.length>1){let x=s.typeReferenceNode({typeName:l.placeholder}),b=s.literalTypeNode({literal:s.stringLiteral({text:"default"})});m=s.typeReferenceNode({typeArguments:[x,b],typeName:"Omit"});}}}let f=[p,m].filter(Boolean);if(f.length&&r.push({name:"Reply",type:s.typeIntersectionNode({types:f})}),!r.length)return;let d=t.referenceSymbol(t.api.getSelector("RouteHandler"));return {name:e.id,type:s.typeReferenceNode({typeArguments:[s.typeInterfaceNode({properties:r,useLegacyResolution:false})],typeName:d.placeholder})}},cm=({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=Wu({operation:o,plugin:e});i&&r.push(i);});let n=s.typeAliasDeclaration({exportType:t.exported,name:t.placeholder,type:s.typeInterfaceNode({properties:r,useLegacyResolution:false})});e.setSymbolValue(t,n);};var ao={api:new io({name:"fastify"}),config:{exportFromIndex:false},dependencies:["@hey-api/typescript"],handler:cm,name:"fastify"};var T={actions:{args:s.identifier({text:"args"}),base64:s.identifier({text:"base64"}),bic:s.identifier({text:"bic"}),brand:s.identifier({text:"brand"}),bytes:s.identifier({text:"bytes"}),check:s.identifier({text:"check"}),checkItems:s.identifier({text:"checkItems"}),creditCard:s.identifier({text:"creditCard"}),cuid2:s.identifier({text:"cuid2"}),decimal:s.identifier({text:"decimal"}),description:s.identifier({text:"description"}),digits:s.identifier({text:"digits"}),email:s.identifier({text:"email"}),emoji:s.identifier({text:"emoji"}),empty:s.identifier({text:"empty"}),endsWith:s.identifier({text:"endsWith"}),entries:s.identifier({text:"entries"}),everyItem:s.identifier({text:"everyItem"}),excludes:s.identifier({text:"excludes"}),filterItems:s.identifier({text:"filterItems"}),findItem:s.identifier({text:"findItem"}),finite:s.identifier({text:"finite"}),flavor:s.identifier({text:"flavor"}),graphemes:s.identifier({text:"graphemes"}),gtValue:s.identifier({text:"gtValue"}),hash:s.identifier({text:"hash"}),hexColor:s.identifier({text:"hexColor"}),hexadecimal:s.identifier({text:"hexadecimal"}),imei:s.identifier({text:"imei"}),includes:s.identifier({text:"includes"}),integer:s.identifier({text:"integer"}),ip:s.identifier({text:"ip"}),ipv4:s.identifier({text:"ipv4"}),ipv6:s.identifier({text:"ipv6"}),isoDate:s.identifier({text:"isoDate"}),isoDateTime:s.identifier({text:"isoDateTime"}),isoTime:s.identifier({text:"isoTime"}),isoTimeSecond:s.identifier({text:"isoTimeSecond"}),isoTimestamp:s.identifier({text:"isoTimestamp"}),isoWeek:s.identifier({text:"isoWeek"}),length:s.identifier({text:"length"}),ltValue:s.identifier({text:"ltValue"}),mac:s.identifier({text:"mac"}),mac48:s.identifier({text:"mac48"}),mac64:s.identifier({text:"mac64"}),mapItems:s.identifier({text:"mapItems"}),maxBytes:s.identifier({text:"maxBytes"}),maxEntries:s.identifier({text:"maxEntries"}),maxGraphemes:s.identifier({text:"maxGraphemes"}),maxLength:s.identifier({text:"maxLength"}),maxSize:s.identifier({text:"maxSize"}),maxValue:s.identifier({text:"maxValue"}),maxWords:s.identifier({text:"maxWords"}),metadata:s.identifier({text:"metadata"}),mimeType:s.identifier({text:"mimeType"}),minBytes:s.identifier({text:"minBytes"}),minEntries:s.identifier({text:"minEntries"}),minGraphemes:s.identifier({text:"minGraphemes"}),minLength:s.identifier({text:"minLength"}),minSize:s.identifier({text:"minSize"}),minValue:s.identifier({text:"minValue"}),minWords:s.identifier({text:"minWords"}),multipleOf:s.identifier({text:"multipleOf"}),nanoid:s.identifier({text:"nanoid"}),nonEmpty:s.identifier({text:"nonEmpty"}),normalize:s.identifier({text:"normalize"}),notBytes:s.identifier({text:"notBytes"}),notEntries:s.identifier({text:"notEntries"}),notGraphemes:s.identifier({text:"notGraphemes"}),notLength:s.identifier({text:"notLength"}),notSize:s.identifier({text:"notSize"}),notValue:s.identifier({text:"notValue"}),notValues:s.identifier({text:"notValues"}),notWords:s.identifier({text:"notWords"}),octal:s.identifier({text:"octal"}),parseJson:s.identifier({text:"parseJson"}),partialCheck:s.identifier({text:"partialCheck"}),rawCheck:s.identifier({text:"rawCheck"}),rawTransform:s.identifier({text:"rawTransform"}),readonly:s.identifier({text:"readonly"}),reduceItems:s.identifier({text:"reduceItems"}),regex:s.identifier({text:"regex"}),returns:s.identifier({text:"returns"}),rfcEmail:s.identifier({text:"rfcEmail"}),safeInteger:s.identifier({text:"safeInteger"}),size:s.identifier({text:"size"}),slug:s.identifier({text:"slug"}),someItem:s.identifier({text:"someItem"}),sortItems:s.identifier({text:"sortItems"}),startsWith:s.identifier({text:"startsWith"}),stringifyJson:s.identifier({text:"stringifyJson"}),title:s.identifier({text:"title"}),toLowerCase:s.identifier({text:"toLowerCase"}),toMaxValue:s.identifier({text:"toMaxValue"}),toMinValue:s.identifier({text:"toMinValue"}),toUpperCase:s.identifier({text:"toUpperCase"}),transform:s.identifier({text:"transform"}),trim:s.identifier({text:"trim"}),trimEnd:s.identifier({text:"trimEnd"}),trimStart:s.identifier({text:"trimStart"}),ulid:s.identifier({text:"ulid"}),url:s.identifier({text:"url"}),uuid:s.identifier({text:"uuid"}),value:s.identifier({text:"value"}),values:s.identifier({text:"values"}),words:s.identifier({text:"words"})},async:{argsAsync:s.identifier({text:"argsAsync"}),arrayAsync:s.identifier({text:"arrayAsync"}),awaitAsync:s.identifier({text:"awaitAsync"}),checkAsync:s.identifier({text:"checkAsync"}),checkItemsAsync:s.identifier({text:"checkItemsAsync"}),customAsync:s.identifier({text:"customAsync"}),exactOptionalAsync:s.identifier({text:"exactOptionalAsync"}),fallbackAsync:s.identifier({text:"fallbackAsync"}),forwardAsync:s.identifier({text:"forwardAsync"}),getDefaultsAsync:s.identifier({text:"getDefaultsAsync"}),getFallbacksAsync:s.identifier({text:"getFallbacksAsync"}),intersectAsync:s.identifier({text:"intersectAsync"}),lazyAsync:s.identifier({text:"lazyAsync"}),looseObjectAsync:s.identifier({text:"looseObjectAsync"}),looseTupleAsync:s.identifier({text:"looseTupleAsync"}),mapAsync:s.identifier({text:"mapAsync"}),nonNullableAsync:s.identifier({text:"nonNullableAsync"}),nonNullishAsync:s.identifier({text:"nonNullishAsync"}),nonOptionalAsync:s.identifier({text:"nonOptionalAsync"}),nullableAsync:s.identifier({text:"nullableAsync"}),nullishAsync:s.identifier({text:"nullishAsync"}),objectAsync:s.identifier({text:"objectAsync"}),objectWithRestAsync:s.identifier({text:"objectWithRestAsync"}),optionalAsync:s.identifier({text:"optionalAsync"}),parseAsync:s.identifier({text:"parseAsync"}),parserAsync:s.identifier({text:"parserAsync"}),partialAsync:s.identifier({text:"partialAsync"}),partialCheckAsync:s.identifier({text:"partialCheckAsync"}),pipeAsync:s.identifier({text:"pipeAsync"}),rawCheckAsync:s.identifier({text:"rawCheckAsync"}),rawTransformAsync:s.identifier({text:"rawTransformAsync"}),recordAsync:s.identifier({text:"recordAsync"}),requiredAsync:s.identifier({text:"requiredAsync"}),returnsAsync:s.identifier({text:"returnsAsync"}),safeParseAsync:s.identifier({text:"safeParseAsync"}),safeParserAsync:s.identifier({text:"safeParserAsync"}),setAsync:s.identifier({text:"setAsync"}),strictObjectAsync:s.identifier({text:"strictObjectAsync"}),strictTupleAsync:s.identifier({text:"strictTupleAsync"}),transformAsync:s.identifier({text:"transformAsync"}),tupleAsync:s.identifier({text:"tupleAsync"}),tupleWithRestAsync:s.identifier({text:"tupleWithRestAsync"}),undefinedableAsync:s.identifier({text:"undefinedableAsync"}),unionAsync:s.identifier({text:"unionAsync"}),variantAsync:s.identifier({text:"variantAsync"})},methods:{assert:s.identifier({text:"assert"}),config:s.identifier({text:"config"}),fallback:s.identifier({text:"fallback"}),flatten:s.identifier({text:"flatten"}),forward:s.identifier({text:"forward"}),getDefault:s.identifier({text:"getDefault"}),getDefaults:s.identifier({text:"getDefaults"}),getDescription:s.identifier({text:"getDescription"}),getFallback:s.identifier({text:"getFallback"}),getFallbacks:s.identifier({text:"getFallbacks"}),getMetadata:s.identifier({text:"getMetadata"}),getTitle:s.identifier({text:"getTitle"}),is:s.identifier({text:"is"}),keyof:s.identifier({text:"keyof"}),message:s.identifier({text:"message"}),omit:s.identifier({text:"omit"}),parse:s.identifier({text:"parse"}),parser:s.identifier({text:"parser"}),partial:s.identifier({text:"partial"}),pick:s.identifier({text:"pick"}),pipe:s.identifier({text:"pipe"}),required:s.identifier({text:"required"}),safeParse:s.identifier({text:"safeParse"}),safeParser:s.identifier({text:"safeParser"}),summarize:s.identifier({text:"summarize"}),unwrap:s.identifier({text:"unwrap"})},schemas:{any:s.identifier({text:"any"}),array:s.identifier({text:"array"}),bigInt:s.identifier({text:"bigint"}),blob:s.identifier({text:"blob"}),boolean:s.identifier({text:"boolean"}),custom:s.identifier({text:"custom"}),date:s.identifier({text:"date"}),enum:s.identifier({text:"enum"}),exactOptional:s.identifier({text:"exactOptional"}),file:s.identifier({text:"file"}),function:s.identifier({text:"function"}),instance:s.identifier({text:"instance"}),intersect:s.identifier({text:"intersect"}),lazy:s.identifier({text:"lazy"}),literal:s.identifier({text:"literal"}),looseObject:s.identifier({text:"looseObject"}),looseTuple:s.identifier({text:"looseTuple"}),map:s.identifier({text:"map"}),nan:s.identifier({text:"nan"}),never:s.identifier({text:"never"}),nonNullable:s.identifier({text:"nonNullable"}),nonNullish:s.identifier({text:"nonNullish"}),nonOptional:s.identifier({text:"nonOptional"}),null:s.identifier({text:"null"}),nullable:s.identifier({text:"nullable"}),nullish:s.identifier({text:"nullish"}),number:s.identifier({text:"number"}),object:s.identifier({text:"object"}),objectWithRest:s.identifier({text:"objectWithRest"}),optional:s.identifier({text:"optional"}),picklist:s.identifier({text:"picklist"}),promise:s.identifier({text:"promise"}),record:s.identifier({text:"record"}),set:s.identifier({text:"set"}),strictObject:s.identifier({text:"strictObject"}),strictTuple:s.identifier({text:"strictTuple"}),string:s.identifier({text:"string"}),symbol:s.identifier({text:"symbol"}),tuple:s.identifier({text:"tuple"}),tupleWithRest:s.identifier({text:"tupleWithRest"}),undefined:s.identifier({text:"undefined"}),undefinedable:s.identifier({text:"undefinedable"}),union:s.identifier({text:"union"}),unknown:s.identifier({text:"unknown"}),variant:s.identifier({text:"variant"}),void:s.identifier({text:"void"})},types:{GenericSchema:s.identifier({text:"GenericSchema"})}};var po=class{constructor(t){this.meta=t;}createRequestValidator({operation:t,plugin:r}){let n=r.getSymbol(r.api.getSelector("data",t.id));if(!n)return;let o=r.referenceSymbol(r.api.getSelector("import","valibot")),i="data";return s.arrowFunction({async:true,parameters:[{name:i}],statements:[s.returnStatement({expression:s.awaitExpression({expression:s.callExpression({functionName:s.propertyAccessExpression({expression:o.placeholder,name:T.async.parseAsync}),parameters:[s.identifier({text:n.placeholder}),s.identifier({text:i})]})})})]})}createResponseValidator({operation:t,plugin:r}){let n=r.getSymbol(r.api.getSelector("responses",t.id));if(!n)return;let o=r.referenceSymbol(r.api.getSelector("import","valibot")),i="data";return s.arrowFunction({async:true,parameters:[{name:i}],statements:[s.returnStatement({expression:s.awaitExpression({expression:s.callExpression({functionName:s.propertyAccessExpression({expression:o.placeholder,name:T.async.parseAsync}),parameters:[s.identifier({text:n.placeholder}),s.identifier({text:i})]})})})]})}getSelector(...t){return [this.meta.name,...t]}};var co={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}},di=e=>e!==void 0&&e in co,mm=e=>di(e)&&co[e].needsBigInt,qr=({isBigInt:e,value:t})=>{let r=s.valueToExpression({value:t});return e&&(typeof t=="bigint"||typeof t=="number"||typeof t=="string"||typeof t=="boolean")?s.callExpression({functionName:"BigInt",parameters:[r]}):r};var lm=({operation:e,plugin:t,state:r})=>{if(t.config.requests.enabled){let n=new Set,o={properties:{body:{type:"never"},path:{type:"never"},query:{type:"never"}},type:"object"};if(e.parameters){if(e.parameters.header){let a={},p=[];for(let c in e.parameters.header){let m=e.parameters.header[c];a[m.name]=m.schema,m.required&&(p.push(m.name),n.add("headers"));}Object.keys(a).length&&(o.properties.headers={properties:a,required:p,type:"object"});}if(e.parameters.path){let a={},p=[];for(let c in e.parameters.path){let m=e.parameters.path[c];a[m.name]=m.schema,m.required&&(p.push(m.name),n.add("path"));}Object.keys(a).length&&(o.properties.path={properties:a,required:p,type:"object"});}if(e.parameters.query){let a={},p=[];for(let c in e.parameters.query){let m=e.parameters.query[c];a[m.name]=m.schema,m.required&&(p.push(m.name),n.add("query"));}Object.keys(a).length&&(o.properties.query={properties:a,required:p,type:"object"});}}e.body&&(o.properties.body=e.body.schema,e.body.required&&n.add("body")),o.required=[...n];let i=t.registerSymbol({exported:true,name:O({config:t.config.requests,name:e.id}),selector:t.api.getSelector("data",e.id)});le({plugin:t,schema:o,state:r,symbol:i});}if(t.config.responses.enabled&&e.responses){let{response:n}=ze(e);if(n){let o=t.registerSymbol({exported:true,name:O({config:t.config.responses,name:e.id}),selector:t.api.getSelector("responses",e.id)});le({plugin:t,schema:n,state:r,symbol:o});}}};var fm=({operation:e,plugin:t,state:r})=>{if(t.config.webhooks.enabled){let n=new Set,o={properties:{body:{type:"never"},path:{type:"never"},query:{type:"never"}},type:"object"};if(e.parameters){if(e.parameters.header){let a={},p=[];for(let c in e.parameters.header){let m=e.parameters.header[c];a[m.name]=m.schema,m.required&&(p.push(m.name),n.add("headers"));}Object.keys(a).length&&(o.properties.headers={properties:a,required:p,type:"object"});}if(e.parameters.path){let a={},p=[];for(let c in e.parameters.path){let m=e.parameters.path[c];a[m.name]=m.schema,m.required&&(p.push(m.name),n.add("path"));}Object.keys(a).length&&(o.properties.path={properties:a,required:p,type:"object"});}if(e.parameters.query){let a={},p=[];for(let c in e.parameters.query){let m=e.parameters.query[c];a[m.name]=m.schema,m.required&&(p.push(m.name),n.add("query"));}Object.keys(a).length&&(o.properties.query={properties:a,required:p,type:"object"});}}e.body&&(o.properties.body=e.body.schema,e.body.required&&n.add("body")),o.required=[...n];let i=t.registerSymbol({exported:true,name:O({config:t.config.webhooks,name:e.id}),selector:t.api.getSelector("webhook-request",e.id)});le({plugin:t,schema:o,state:r,symbol:i});}};var qe=({pipes:e,plugin:t})=>{if(e.length===1)return e[0];let r=t.referenceSymbol(t.api.getSelector("import","valibot"));return s.callExpression({functionName:s.propertyAccessExpression({expression:r.placeholder,name:T.methods.pipe}),parameters:e})},_u=({plugin:e,schema:t,state:r})=>{let n=e.referenceSymbol(e.api.getSelector("import","valibot")),o=s.propertyAccessExpression({expression:n.placeholder,name:T.schemas.array}),i=[];if(t.items){t=U({schema:t});let a=t.items.map(p=>{let c=le({plugin:e,schema:p,state:r});return qe({pipes:c,plugin:e})});if(a.length===1){let p=s.callExpression({functionName:o,parameters:a});i.push(p);}else {t.logicalOperator;let p=s.callExpression({functionName:o,parameters:[an({plugin:e})]});i.push(p);}}else {let a=s.callExpression({functionName:o,parameters:[an({plugin:e})]});i.push(a);}if(t.minItems===t.maxItems&&t.minItems!==void 0){let a=s.callExpression({functionName:s.propertyAccessExpression({expression:n.placeholder,name:T.actions.length}),parameters:[s.valueToExpression({value:t.minItems})]});i.push(a);}else {if(t.minItems!==void 0){let a=s.callExpression({functionName:s.propertyAccessExpression({expression:n.placeholder,name:T.actions.minLength}),parameters:[s.valueToExpression({value:t.minItems})]});i.push(a);}if(t.maxItems!==void 0){let a=s.callExpression({functionName:s.propertyAccessExpression({expression:n.placeholder,name:T.actions.maxLength}),parameters:[s.valueToExpression({value:t.maxItems})]});i.push(a);}}return qe({pipes:i,plugin:e})},Hu=({plugin:e,schema:t})=>{let r=e.referenceSymbol(e.api.getSelector("import","valibot"));return typeof t.const=="boolean"?s.callExpression({functionName:s.propertyAccessExpression({expression:r.placeholder,name:T.schemas.literal}),parameters:[s.ots.boolean(t.const)]}):s.callExpression({functionName:s.propertyAccessExpression({expression:r.placeholder,name:T.schemas.boolean})})},Qu=({plugin:e,schema:t})=>{let r=[],n=false;for(let a of t.items??[])a.type==="string"&&typeof a.const=="string"?r.push(s.stringLiteral({text:a.const})):(a.type==="null"||a.const===null)&&(n=true);if(!r.length)return an({plugin:e});let o=e.referenceSymbol(e.api.getSelector("import","valibot")),i=s.callExpression({functionName:s.propertyAccessExpression({expression:o.placeholder,name:T.schemas.picklist}),parameters:[s.arrayLiteralExpression({elements:r,multiLine:false})]});return n&&(i=s.callExpression({functionName:s.propertyAccessExpression({expression:o.placeholder,name:T.schemas.nullable}),parameters:[i]})),i},Zu=({plugin:e})=>{let t=e.referenceSymbol(e.api.getSelector("import","valibot"));return s.callExpression({functionName:s.propertyAccessExpression({expression:t.placeholder,name:T.schemas.never})})},Uu=({plugin:e})=>{let t=e.referenceSymbol(e.api.getSelector("import","valibot"));return s.callExpression({functionName:s.propertyAccessExpression({expression:t.placeholder,name:T.schemas.null})})},dm=({plugin:e,schema:t})=>{let r=t.format,n=t.type==="integer",o=mm(r),i=di(r)?co[r]:null,a=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=s.ots.number(c);else if(typeof c=="number"&&r)o?m=s.callExpression({functionName:"BigInt",parameters:[s.ots.string(c.toString())]}):m=s.ots.number(c);else if(typeof c=="string"&&o){let l=c.endsWith("n")?c.slice(0,-1):c;m=s.callExpression({functionName:"BigInt",parameters:[s.ots.string(l)]});}else if(typeof c=="bigint"){let l=c.toString(),f=l.endsWith("n")?l.slice(0,-1):l;m=s.callExpression({functionName:"BigInt",parameters:[s.ots.string(f)]});}else m=s.valueToExpression({value:c});return s.callExpression({functionName:s.propertyAccessExpression({expression:a.placeholder,name:T.schemas.literal}),parameters:[m]})}let p=[];if(o){let c=s.callExpression({functionName:s.propertyAccessExpression({expression:a.placeholder,name:T.schemas.union}),parameters:[s.arrayLiteralExpression({elements:[s.callExpression({functionName:s.propertyAccessExpression({expression:a.placeholder,name:T.schemas.number})}),s.callExpression({functionName:s.propertyAccessExpression({expression:a.placeholder,name:T.schemas.string})}),s.callExpression({functionName:s.propertyAccessExpression({expression:a.placeholder,name:T.schemas.bigInt})})],multiLine:false})]});p.push(c);let m=s.callExpression({functionName:s.propertyAccessExpression({expression:a.placeholder,name:T.actions.transform}),parameters:[s.arrowFunction({parameters:[{name:"x"}],statements:s.callExpression({functionName:"BigInt",parameters:[s.identifier({text:"x"})]})})]});p.push(m);}else {let c=s.callExpression({functionName:s.propertyAccessExpression({expression:a.placeholder,name:T.schemas.number})});p.push(c);}if(!o&&n){let c=s.callExpression({functionName:s.propertyAccessExpression({expression:a.placeholder,name:T.actions.integer})});p.push(c);}if(i){let c=i.min,m=i.max,l=i.minError,f=i.maxError,d=s.callExpression({functionName:s.propertyAccessExpression({expression:a.placeholder,name:T.actions.minValue}),parameters:[o?s.callExpression({functionName:"BigInt",parameters:[s.ots.string(c.toString())]}):s.ots.number(c),s.ots.string(l)]});p.push(d);let u=s.callExpression({functionName:s.propertyAccessExpression({expression:a.placeholder,name:T.actions.maxValue}),parameters:[o?s.callExpression({functionName:"BigInt",parameters:[s.ots.string(m.toString())]}):s.ots.number(m),s.ots.string(f)]});p.push(u);}if(t.exclusiveMinimum!==void 0){let c=s.callExpression({functionName:s.propertyAccessExpression({expression:a.placeholder,name:T.actions.gtValue}),parameters:[qr({isBigInt:o,value:t.exclusiveMinimum})]});p.push(c);}else if(t.minimum!==void 0){let c=s.callExpression({functionName:s.propertyAccessExpression({expression:a.placeholder,name:T.actions.minValue}),parameters:[qr({isBigInt:o,value:t.minimum})]});p.push(c);}if(t.exclusiveMaximum!==void 0){let c=s.callExpression({functionName:s.propertyAccessExpression({expression:a.placeholder,name:T.actions.ltValue}),parameters:[qr({isBigInt:o,value:t.exclusiveMaximum})]});p.push(c);}else if(t.maximum!==void 0){let c=s.callExpression({functionName:s.propertyAccessExpression({expression:a.placeholder,name:T.actions.maxValue}),parameters:[qr({isBigInt:o,value:t.maximum})]});p.push(c);}return qe({pipes:p,plugin:e})},Xu=({plugin:e,schema:t,state:r})=>{let n=[],o=t.required??[];for(let p in t.properties){let c=t.properties[p],m=o.includes(p),l=le({optional:!m,plugin:e,schema:c,state:r});te.lastIndex=0;let f;te.test(p)?f=p.startsWith("-")?S.factory.createStringLiteral(p):S.factory.createNumericLiteral(p):f=p,(p.match(/^[0-9]/)&&p.match(/\D+/g)||p.match(/\W/g))&&!p.startsWith("'")&&!p.endsWith("'")&&(f=`'${p}'`),n.push(s.propertyAssignment({initializer:qe({pipes:l,plugin:e}),name:f}));}let i=e.referenceSymbol(e.api.getSelector("import","valibot"));if(t.additionalProperties&&t.additionalProperties.type==="object"&&!Object.keys(n).length){let p=le({plugin:e,schema:t.additionalProperties,state:r});return {anyType:"AnyZodObject",expression:s.callExpression({functionName:s.propertyAccessExpression({expression:i.placeholder,name:T.schemas.record}),parameters:[s.callExpression({functionName:s.propertyAccessExpression({expression:i.placeholder,name:T.schemas.string}),parameters:[]}),qe({pipes:p,plugin:e})]})}}let a=s.callExpression({functionName:s.propertyAccessExpression({expression:i.placeholder,name:T.schemas.object}),parameters:[S.factory.createObjectLiteralExpression(n,true)]});return {anyType:T.types.GenericSchema.text,expression:a}},Gu=({plugin:e,schema:t})=>{let r=e.referenceSymbol(e.api.getSelector("import","valibot"));if(typeof t.const=="string")return s.callExpression({functionName:s.propertyAccessExpression({expression:r.placeholder,name:T.schemas.literal}),parameters:[s.ots.string(t.const)]});let n=[],o=s.callExpression({functionName:s.propertyAccessExpression({expression:r.placeholder,name:T.schemas.string})});if(n.push(o),t.format)switch(t.format){case "date":n.push(s.callExpression({functionName:s.propertyAccessExpression({expression:r.placeholder,name:T.actions.isoDate})}));break;case "date-time":n.push(s.callExpression({functionName:s.propertyAccessExpression({expression:r.placeholder,name:T.actions.isoTimestamp})}));break;case "ipv4":case "ipv6":n.push(s.callExpression({functionName:s.propertyAccessExpression({expression:r.placeholder,name:T.actions.ip})}));break;case "uri":n.push(s.callExpression({functionName:s.propertyAccessExpression({expression:r.placeholder,name:T.actions.url})}));break;case "email":case "time":case "uuid":n.push(s.callExpression({functionName:s.propertyAccessExpression({expression:r.placeholder,name:s.identifier({text:t.format})})}));break}if(t.minLength===t.maxLength&&t.minLength!==void 0){let i=s.callExpression({functionName:s.propertyAccessExpression({expression:r.placeholder,name:T.actions.length}),parameters:[s.valueToExpression({value:t.minLength})]});n.push(i);}else {if(t.minLength!==void 0){let i=s.callExpression({functionName:s.propertyAccessExpression({expression:r.placeholder,name:T.actions.minLength}),parameters:[s.valueToExpression({value:t.minLength})]});n.push(i);}if(t.maxLength!==void 0){let i=s.callExpression({functionName:s.propertyAccessExpression({expression:r.placeholder,name:T.actions.maxLength}),parameters:[s.valueToExpression({value:t.maxLength})]});n.push(i);}}if(t.pattern){let i=s.callExpression({functionName:s.propertyAccessExpression({expression:r.placeholder,name:T.actions.regex}),parameters:[s.regularExpressionLiteral({text:t.pattern})]});n.push(i);}return qe({pipes:n,plugin:e})},Ju=({plugin:e,schema:t,state:r})=>{let n=e.referenceSymbol(e.api.getSelector("import","valibot"));if(t.const&&Array.isArray(t.const)){let o=t.const.map(a=>s.callExpression({functionName:s.propertyAccessExpression({expression:n.placeholder,name:T.schemas.literal}),parameters:[s.valueToExpression({value:a})]}));return s.callExpression({functionName:s.propertyAccessExpression({expression:n.placeholder,name:T.schemas.tuple}),parameters:[s.arrayLiteralExpression({elements:o})]})}if(t.items){let o=t.items.map(a=>{let p=le({plugin:e,schema:a,state:r});return qe({pipes:p,plugin:e})});return s.callExpression({functionName:s.propertyAccessExpression({expression:n.placeholder,name:T.schemas.tuple}),parameters:[s.arrayLiteralExpression({elements:o})]})}return an({plugin:e})},Yu=({plugin:e})=>{let t=e.referenceSymbol(e.api.getSelector("import","valibot"));return s.callExpression({functionName:s.propertyAccessExpression({expression:t.placeholder,name:T.schemas.undefined})})},an=({plugin:e})=>{let t=e.referenceSymbol(e.api.getSelector("import","valibot"));return s.callExpression({functionName:s.propertyAccessExpression({expression:t.placeholder,name:T.schemas.unknown})})},ey=({plugin:e})=>{let t=e.referenceSymbol(e.api.getSelector("import","valibot"));return s.callExpression({functionName:s.propertyAccessExpression({expression:t.placeholder,name:T.schemas.void})})},um=({plugin:e,schema:t,state:r})=>{switch(t.type){case "array":return {expression:_u({plugin:e,schema:t,state:r})};case "boolean":return {expression:Hu({plugin:e,schema:t})};case "enum":return {expression:Qu({plugin:e,schema:t})};case "integer":case "number":return {expression:dm({plugin:e,schema:t})};case "never":return {expression:Zu({plugin:e})};case "null":return {expression:Uu({plugin:e})};case "object":return Xu({plugin:e,schema:t,state:r});case "string":return t.format==="int64"||t.format==="uint64"?{expression:dm({plugin:e,schema:t})}:{expression:Gu({plugin:e,schema:t})};case "tuple":return {expression:Ju({plugin:e,schema:t,state:r})};case "undefined":return {expression:Yu({plugin:e})};case "unknown":return {expression:an({plugin:e})};case "void":return {expression:ey({plugin:e})}}},le=({$ref:e,optional:t,plugin:r,schema:n,state:o,symbol:i})=>{let a,p=[];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(n.$ref){let m=o.circularReferenceTracker.has(n.$ref),l=r.api.getSelector("ref",n.$ref),f=r.getSymbol(l);if(!f){let d=r.context.resolveIrRef(n.$ref),u=le({$ref:n.$ref,plugin:r,schema:d,state:o});p.push(...u),f=r.getSymbol(l);}if(f){let d=s.identifier({text:f.placeholder});if(m){let u=s.callExpression({functionName:s.propertyAccessExpression({expression:c.placeholder,name:T.schemas.lazy}),parameters:[s.arrowFunction({statements:[s.returnStatement({expression:d})]})]});p.push(u),o.hasCircularReference=true;}else p.push(d);}}else if(n.type){let m=um({plugin:r,schema:n,state:o});if(a=m.anyType,p.push(m.expression),r.config.metadata&&n.description){let l=s.callExpression({functionName:s.propertyAccessExpression({expression:c.placeholder,name:T.actions.metadata}),parameters:[s.objectExpression({obj:[{key:"description",value:s.stringLiteral({text:n.description})}]})]});p.push(l);}}else if(n.items)if(n=U({schema:n}),n.items){let m=n.items.map(l=>{let f=le({plugin:r,schema:l,state:o});return qe({pipes:f,plugin:r})});if(n.logicalOperator==="and"){let l=s.callExpression({functionName:s.propertyAccessExpression({expression:c.placeholder,name:T.schemas.intersect}),parameters:[s.arrayLiteralExpression({elements:m})]});p.push(l);}else {let l=s.callExpression({functionName:s.propertyAccessExpression({expression:c.placeholder,name:T.schemas.union}),parameters:[s.arrayLiteralExpression({elements:m})]});p.push(l);}}else {let m=le({plugin:r,schema:n,state:o});p.push(...m);}else {let m=um({plugin:r,schema:{type:"unknown"},state:o});a=m.anyType,p.push(m.expression);}if(e&&o.circularReferenceTracker.delete(e),p.length&&n.accessScope==="read"){let m=s.callExpression({functionName:s.propertyAccessExpression({expression:c.placeholder,name:T.actions.readonly})});p.push(m);}if(p.length){let m;if(n.default!==void 0){let l=n.type==="integer"&&n.format==="int64";m=qr({isBigInt:l,value:n.default}),m&&(p=[s.callExpression({functionName:s.propertyAccessExpression({expression:c.placeholder,name:T.schemas.optional}),parameters:[qe({pipes:p,plugin:r}),m]})]);}t&&!m&&(p=[s.callExpression({functionName:s.propertyAccessExpression({expression:c.placeholder,name:T.schemas.optional}),parameters:[qe({pipes:p,plugin:r})]})]);}if(i){e&&(i=r.registerSymbol({exported:true,name:O({config:{case:o.nameCase,name:o.nameTransformer},name:F(e)}),selector:r.api.getSelector("ref",e)}));let m=s.constVariable({comment:r.config.comments?ge({schema:n}):void 0,exportConst:i.exported,expression:qe({pipes:p,plugin:r}),name:i.placeholder,typeName:o.hasCircularReference?s.propertyAccessExpression({expression:c.placeholder,name:a||T.types.GenericSchema.text}):void 0});return r.setSymbolValue(i,m),[]}return p},ym=({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":lm({operation:t.operation,plugin:e,state:r});break;case "parameter":le({$ref:t.$ref,plugin:e,schema:t.parameter.schema,state:r});break;case "requestBody":le({$ref:t.$ref,plugin:e,schema:t.requestBody.schema,state:r});break;case "schema":le({$ref:t.$ref,plugin:e,schema:t.schema,state:r});break;case "webhook":fm({operation:t.operation,plugin:e,state:r});break}});};var mo={api:new po({name:"valibot"}),config:{case:"camelCase",comments:true,exportFromIndex:false,metadata:false},handler:ym,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 y={ZodMiniOptional:s.identifier({text:"ZodMiniOptional"}),ZodOptional:s.identifier({text:"ZodOptional"}),_default:s.identifier({text:"_default"}),and:s.identifier({text:"and"}),array:s.identifier({text:"array"}),bigint:s.identifier({text:"bigint"}),boolean:s.identifier({text:"boolean"}),check:s.identifier({text:"check"}),coerce:s.identifier({text:"coerce"}),date:s.identifier({text:"date"}),datetime:s.identifier({text:"datetime"}),default:s.identifier({text:"default"}),describe:s.identifier({text:"describe"}),email:s.identifier({text:"email"}),enum:s.identifier({text:"enum"}),globalRegistry:s.identifier({text:"globalRegistry"}),gt:s.identifier({text:"gt"}),gte:s.identifier({text:"gte"}),infer:s.identifier({text:"infer"}),int:s.identifier({text:"int"}),intersection:s.identifier({text:"intersection"}),ip:s.identifier({text:"ip"}),ipv4:s.identifier({text:"ipv4"}),ipv6:s.identifier({text:"ipv6"}),iso:s.identifier({text:"iso"}),lazy:s.identifier({text:"lazy"}),length:s.identifier({text:"length"}),literal:s.identifier({text:"literal"}),lt:s.identifier({text:"lt"}),lte:s.identifier({text:"lte"}),max:s.identifier({text:"max"}),maxLength:s.identifier({text:"maxLength"}),min:s.identifier({text:"min"}),minLength:s.identifier({text:"minLength"}),never:s.identifier({text:"never"}),null:s.identifier({text:"null"}),nullable:s.identifier({text:"nullable"}),number:s.identifier({text:"number"}),object:s.identifier({text:"object"}),optional:s.identifier({text:"optional"}),parseAsync:s.identifier({text:"parseAsync"}),readonly:s.identifier({text:"readonly"}),record:s.identifier({text:"record"}),regex:s.identifier({text:"regex"}),register:s.identifier({text:"register"}),string:s.identifier({text:"string"}),time:s.identifier({text:"time"}),tuple:s.identifier({text:"tuple"}),undefined:s.identifier({text:"undefined"}),union:s.identifier({text:"union"}),unknown:s.identifier({text:"unknown"}),url:s.identifier({text:"url"}),uuid:s.identifier({text:"uuid"}),void:s.identifier({text:"void"})};var lo=class{constructor(t){this.meta=t;}createRequestValidator({operation:t,plugin:r}){let n=r.getSymbol(r.api.getSelector("data",t.id));if(!n)return;let o="data";return s.arrowFunction({async:true,parameters:[{name:o}],statements:[s.returnStatement({expression:s.awaitExpression({expression:s.callExpression({functionName:s.propertyAccessExpression({expression:n.placeholder,name:y.parseAsync}),parameters:[s.identifier({text:o})]})})})]})}createResponseValidator({operation:t,plugin:r}){let n=r.getSymbol(r.api.getSelector("responses",t.id));if(!n)return;let o="data";return s.arrowFunction({async:true,parameters:[{name:o}],statements:[s.returnStatement({expression:s.awaitExpression({expression:s.callExpression({functionName:s.propertyAccessExpression({expression:n.placeholder,name:y.parseAsync}),parameters:[s.identifier({text:o})]})})})]})}getSelector(...t){return [this.meta.name,...t]}};var $e=({plugin:e,schema:t,symbol:r,typeInferSymbol:n,zodSchema:o})=>{let i=e.referenceSymbol(e.api.getSelector("import","zod")),a=s.constVariable({comment:e.config.comments?ge({schema:t}):void 0,exportConst:r.exported,expression:o.expression,name:r.placeholder,typeName:o.typeName?s.propertyAccessExpression({expression:i.placeholder,name:o.typeName}):void 0});if(e.setSymbolValue(r,a),n){let p=s.typeAliasDeclaration({exportType:n.exported,name:n.placeholder,type:s.typeReferenceNode({typeArguments:[s.typeOfExpression({text:r.placeholder})],typeName:s.propertyAccessExpression({expression:i.placeholder,name:y.infer})})});e.setSymbolValue(n,p);}};var $r=({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 Mr=({getZodSchema:e,operation:t,plugin:r})=>{if(r.config.requests.enabled){let n=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),n.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),n.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),n.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&&n.add("body")),o.required=[...n];let i=e(o),a=r.registerSymbol({exported:true,name:O({config:r.config.requests,name:t.id}),selector:r.api.getSelector("data",t.id)}),p=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;$e({plugin:r,schema:o,symbol:a,typeInferSymbol:p,zodSchema:i});}if(r.config.responses.enabled&&t.responses){let{response:n}=ze(t);if(n){let o=e(n),i=r.registerSymbol({exported:true,name:O({config:r.config.responses,name:t.id}),selector:r.api.getSelector("responses",t.id)}),a=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;$e({plugin:r,schema:n,symbol:i,typeInferSymbol:a,zodSchema:o});}}};var Lr=({getZodSchema:e,operation:t,plugin:r})=>{if(r.config.webhooks.enabled){let n=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),n.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),n.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),n.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&&n.add("body")),o.required=[...n];let i=e(o),a=r.registerSymbol({exported:true,name:O({config:r.config.webhooks,name:t.id}),selector:r.api.getSelector("webhook-request",t.id)}),p=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;$e({plugin:r,schema:o,symbol:a,typeInferSymbol:p,zodSchema:i});}};var ry=({plugin:e,schema:t,state:r})=>{let n=e.referenceSymbol(e.api.getSelector("import","zod")),o={},i=s.propertyAccessExpression({expression:n.placeholder,name:y.array});if(!t.items)o.expression=s.callExpression({functionName:i,parameters:[hi({plugin:e}).expression]});else {t=U({schema:t});let p=t.items.map(c=>{let m=bt({plugin:e,schema:c,state:r});return m.hasCircularReference&&(o.hasCircularReference=true),m.expression});p.length===1?o.expression=s.callExpression({functionName:i,parameters:p}):(t.logicalOperator,o.expression=s.callExpression({functionName:s.propertyAccessExpression({expression:n.placeholder,name:y.array}),parameters:[s.callExpression({functionName:s.propertyAccessExpression({expression:n.placeholder,name:y.union}),parameters:[s.arrayLiteralExpression({elements:p})]})]}));}let a=[];return t.minItems===t.maxItems&&t.minItems!==void 0?a.push(s.callExpression({functionName:s.propertyAccessExpression({expression:n.placeholder,name:y.length}),parameters:[s.valueToExpression({value:t.minItems})]})):(t.minItems!==void 0&&a.push(s.callExpression({functionName:s.propertyAccessExpression({expression:n.placeholder,name:y.minLength}),parameters:[s.valueToExpression({value:t.minItems})]})),t.maxItems!==void 0&&a.push(s.callExpression({functionName:s.propertyAccessExpression({expression:n.placeholder,name:y.maxLength}),parameters:[s.valueToExpression({value:t.maxItems})]}))),a.length&&(o.expression=s.callExpression({functionName:s.propertyAccessExpression({expression:o.expression,name:y.check}),parameters:a})),o},ny=({plugin:e,schema:t})=>{let r=e.referenceSymbol(e.api.getSelector("import","zod")),n={};return typeof t.const=="boolean"?(n.expression=s.callExpression({functionName:s.propertyAccessExpression({expression:r.placeholder,name:y.literal}),parameters:[s.ots.boolean(t.const)]}),n):(n.expression=s.callExpression({functionName:s.propertyAccessExpression({expression:r.placeholder,name:y.boolean})}),n)},sy=({plugin:e,schema:t})=>{let r=e.referenceSymbol(e.api.getSelector("import","zod")),n={},o=[],i=false;for(let a of t.items??[])a.type==="string"&&typeof a.const=="string"?o.push(s.stringLiteral({text:a.const})):(a.type==="null"||a.const===null)&&(i=true);return o.length?(n.expression=s.callExpression({functionName:s.propertyAccessExpression({expression:r.placeholder,name:y.enum}),parameters:[s.arrayLiteralExpression({elements:o,multiLine:false})]}),i&&(n.expression=s.callExpression({functionName:s.propertyAccessExpression({expression:r.placeholder,name:y.nullable}),parameters:[n.expression]})),n):hi({plugin:e})},oy=({plugin:e})=>{let t=e.referenceSymbol(e.api.getSelector("import","zod")),r={};return r.expression=s.callExpression({functionName:s.propertyAccessExpression({expression:t.placeholder,name:y.never})}),r},iy=({plugin:e})=>{let t=e.referenceSymbol(e.api.getSelector("import","zod")),r={};return r.expression=s.callExpression({functionName:s.propertyAccessExpression({expression:t.placeholder,name:y.null})}),r},pn=({isBigInt:e,value:t})=>{let r=s.valueToExpression({value:t});return e&&(typeof t=="bigint"||typeof t=="number"||typeof t=="string"||typeof t=="boolean")?s.callExpression({functionName:"BigInt",parameters:[r]}):r},ay=({plugin:e,schema:t})=>{let r=e.referenceSymbol(e.api.getSelector("import","zod")),n={},o=t.type==="integer"&&t.format==="int64";if(typeof t.const=="number")return n.expression=s.callExpression({functionName:s.propertyAccessExpression({expression:r.placeholder,name:y.literal}),parameters:[s.ots.number(t.const)]}),n;n.expression=s.callExpression({functionName:o?s.propertyAccessExpression({expression:s.propertyAccessExpression({expression:r.placeholder,name:y.coerce}),name:y.bigint}):s.propertyAccessExpression({expression:r.placeholder,name:y.number})}),!o&&t.type==="integer"&&(n.expression=s.callExpression({functionName:s.propertyAccessExpression({expression:r.placeholder,name:y.int})}));let i=[];return t.exclusiveMinimum!==void 0?i.push(s.callExpression({functionName:s.propertyAccessExpression({expression:r.placeholder,name:y.gt}),parameters:[pn({isBigInt:o,value:t.exclusiveMinimum})]})):t.minimum!==void 0&&i.push(s.callExpression({functionName:s.propertyAccessExpression({expression:r.placeholder,name:y.gte}),parameters:[pn({isBigInt:o,value:t.minimum})]})),t.exclusiveMaximum!==void 0?i.push(s.callExpression({functionName:s.propertyAccessExpression({expression:r.placeholder,name:y.lt}),parameters:[pn({isBigInt:o,value:t.exclusiveMaximum})]})):t.maximum!==void 0&&i.push(s.callExpression({functionName:s.propertyAccessExpression({expression:r.placeholder,name:y.lte}),parameters:[pn({isBigInt:o,value:t.maximum})]})),i.length&&(n.expression=s.callExpression({functionName:s.propertyAccessExpression({expression:n.expression,name:y.check}),parameters:i})),n},py=({plugin:e,schema:t,state:r})=>{let n=e.referenceSymbol(e.api.getSelector("import","zod")),o={},i=[],a=t.required??[];for(let p in t.properties){let c=t.properties[p],m=a.includes(p),l=bt({optional:!m,plugin:e,schema:c,state:r});l.hasCircularReference&&(o.hasCircularReference=true),te.lastIndex=0;let f;te.test(p)?f=p.startsWith("-")?S.factory.createStringLiteral(p):S.factory.createNumericLiteral(p):f=p,(p.match(/^[0-9]/)&&p.match(/\D+/g)||p.match(/\W/g))&&!p.startsWith("'")&&!p.endsWith("'")&&(f=`'${p}'`),l.hasCircularReference?i.push(s.getAccessorDeclaration({name:f,returnType:l.typeName?s.propertyAccessExpression({expression:n.placeholder,name:l.typeName}):void 0,statements:[s.returnStatement({expression:l.expression})]})):i.push(s.propertyAssignment({initializer:l.expression,name:f}));}if(t.additionalProperties&&(!t.properties||!Object.keys(t.properties).length)){let p=bt({plugin:e,schema:t.additionalProperties,state:r});return o.expression=s.callExpression({functionName:s.propertyAccessExpression({expression:n.placeholder,name:y.record}),parameters:[s.callExpression({functionName:s.propertyAccessExpression({expression:n.placeholder,name:y.string}),parameters:[]}),p.expression]}),p.hasCircularReference&&(o.hasCircularReference=true),o}return o.expression=s.callExpression({functionName:s.propertyAccessExpression({expression:n.placeholder,name:y.object}),parameters:[S.factory.createObjectLiteralExpression(i,true)]}),o},cy=({plugin:e,schema:t})=>{let r=e.referenceSymbol(e.api.getSelector("import","zod")),n={};if(typeof t.const=="string")return n.expression=s.callExpression({functionName:s.propertyAccessExpression({expression:r.placeholder,name:y.literal}),parameters:[s.ots.string(t.const)]}),n;n.expression=s.callExpression({functionName:s.propertyAccessExpression({expression:r.placeholder,name:y.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":n.expression=s.callExpression({functionName:s.propertyAccessExpression({expression:s.propertyAccessExpression({expression:r.placeholder,name:y.iso}),name:y.date})});break;case "date-time":n.expression=s.callExpression({functionName:s.propertyAccessExpression({expression:s.propertyAccessExpression({expression:r.placeholder,name:y.iso}),name:y.datetime}),parameters:o.length>0?[s.objectExpression({obj:o})]:[]});break;case "email":n.expression=s.callExpression({functionName:s.propertyAccessExpression({expression:r.placeholder,name:y.email})});break;case "ipv4":n.expression=s.callExpression({functionName:s.propertyAccessExpression({expression:r.placeholder,name:y.ipv4})});break;case "ipv6":n.expression=s.callExpression({functionName:s.propertyAccessExpression({expression:r.placeholder,name:y.ipv6})});break;case "time":n.expression=s.callExpression({functionName:s.propertyAccessExpression({expression:s.propertyAccessExpression({expression:r.placeholder,name:y.iso}),name:y.time})});break;case "uri":n.expression=s.callExpression({functionName:s.propertyAccessExpression({expression:r.placeholder,name:y.url})});break;case "uuid":n.expression=s.callExpression({functionName:s.propertyAccessExpression({expression:r.placeholder,name:y.uuid})});break}let i=[];return t.minLength===t.maxLength&&t.minLength!==void 0?i.push(s.callExpression({functionName:s.propertyAccessExpression({expression:r.placeholder,name:y.length}),parameters:[s.valueToExpression({value:t.minLength})]})):(t.minLength!==void 0&&i.push(s.callExpression({functionName:s.propertyAccessExpression({expression:r.placeholder,name:y.minLength}),parameters:[s.valueToExpression({value:t.minLength})]})),t.maxLength!==void 0&&i.push(s.callExpression({functionName:s.propertyAccessExpression({expression:r.placeholder,name:y.maxLength}),parameters:[s.valueToExpression({value:t.maxLength})]}))),t.pattern&&i.push(s.callExpression({functionName:s.propertyAccessExpression({expression:r.placeholder,name:y.regex}),parameters:[s.regularExpressionLiteral({text:t.pattern})]})),i.length&&(n.expression=s.callExpression({functionName:s.propertyAccessExpression({expression:n.expression,name:y.check}),parameters:i})),n},my=({plugin:e,schema:t,state:r})=>{let n=e.referenceSymbol(e.api.getSelector("import","zod")),o={};if(t.const&&Array.isArray(t.const)){let a=t.const.map(p=>s.callExpression({functionName:s.propertyAccessExpression({expression:n.placeholder,name:y.literal}),parameters:[s.valueToExpression({value:p})]}));return o.expression=s.callExpression({functionName:s.propertyAccessExpression({expression:n.placeholder,name:y.tuple}),parameters:[s.arrayLiteralExpression({elements:a})]}),o}let i=[];for(let a of t.items??[]){let p=bt({plugin:e,schema:a,state:r});i.push(p.expression),p.hasCircularReference&&(o.hasCircularReference=true);}return o.expression=s.callExpression({functionName:s.propertyAccessExpression({expression:n.placeholder,name:y.tuple}),parameters:[s.arrayLiteralExpression({elements:i})]}),o},ly=({plugin:e})=>{let t=e.referenceSymbol(e.api.getSelector("import","zod")),r={};return r.expression=s.callExpression({functionName:s.propertyAccessExpression({expression:t.placeholder,name:y.undefined})}),r},hi=({plugin:e})=>{let t=e.referenceSymbol(e.api.getSelector("import","zod")),r={};return r.expression=s.callExpression({functionName:s.propertyAccessExpression({expression:t.placeholder,name:y.unknown})}),r},fy=({plugin:e})=>{let t=e.referenceSymbol(e.api.getSelector("import","zod")),r={};return r.expression=s.callExpression({functionName:s.propertyAccessExpression({expression:t.placeholder,name:y.void})}),r},hm=({plugin:e,schema:t,state:r})=>{switch(t.type){case "array":return ry({plugin:e,schema:t,state:r});case "boolean":return ny({plugin:e,schema:t});case "enum":return sy({plugin:e,schema:t});case "integer":case "number":return ay({plugin:e,schema:t});case "never":return oy({plugin:e});case "null":return iy({plugin:e});case "object":return py({plugin:e,schema:t,state:r});case "string":return cy({plugin:e,schema:t});case "tuple":return my({plugin:e,schema:t,state:r});case "undefined":return ly({plugin:e});case "unknown":return hi({plugin:e});case "void":return fy({plugin:e})}},bt=({optional:e,plugin:t,schema:r,state:n})=>{let o={},i=t.referenceSymbol(t.api.getSelector("import","zod"));if(r.$ref){let a=n.circularReferenceTracker.includes(r.$ref),p=n.currentReferenceTracker.includes(r.$ref);n.circularReferenceTracker.push(r.$ref),n.currentReferenceTracker.push(r.$ref);let c=t.api.getSelector("ref",r.$ref),m=t.getSymbol(c);if(a)m||(m=t.referenceSymbol(c)),p?o.expression=s.callExpression({functionName:s.propertyAccessExpression({expression:i.placeholder,name:y.lazy}),parameters:[s.arrowFunction({returnType:s.keywordTypeNode({keyword:"any"}),statements:[s.returnStatement({expression:s.identifier({text:m.placeholder})})]})]}):o.expression=s.identifier({text:m.placeholder}),o.hasCircularReference=r.circular;else {if(m)o.hasCircularReference=r.circular;else {let f=t.context.resolveIrRef(r.$ref);fo({id:r.$ref,plugin:t,schema:f,state:n});}let l=t.referenceSymbol(c);o.expression=s.identifier({text:l.placeholder});}n.circularReferenceTracker.pop(),n.currentReferenceTracker.pop();}else if(r.type){let a=hm({plugin:t,schema:r,state:n});o.expression=a.expression,o.hasCircularReference=a.hasCircularReference,t.config.metadata&&r.description&&(o.expression=s.callExpression({functionName:s.propertyAccessExpression({expression:o.expression,name:y.register}),parameters:[s.propertyAccessExpression({expression:i.placeholder,name:y.globalRegistry}),s.objectExpression({obj:[{key:"description",value:s.stringLiteral({text:r.description})}]})]}));}else if(r.items)if(r=U({schema:r}),r.items){let a=r.items.map(p=>bt({plugin:t,schema:p,state:n}));if(r.logicalOperator==="and"){let p=r.items[0];p.logicalOperator==="or"||p.type&&p.type!=="object"?o.expression=s.callExpression({functionName:s.propertyAccessExpression({expression:i.placeholder,name:y.intersection}),parameters:a.map(c=>c.expression)}):(o.expression=a[0].expression,a.slice(1).forEach(c=>{o.expression=s.callExpression({functionName:s.propertyAccessExpression({expression:i.placeholder,name:y.intersection}),parameters:[o.expression,c.hasCircularReference?s.callExpression({functionName:s.propertyAccessExpression({expression:i.placeholder,name:y.lazy}),parameters:[s.arrowFunction({statements:[s.returnStatement({expression:c.expression})]})]}):c.expression]});}));}else o.expression=s.callExpression({functionName:s.propertyAccessExpression({expression:i.placeholder,name:y.union}),parameters:[s.arrayLiteralExpression({elements:a.map(p=>p.expression)})]});}else o=bt({plugin:t,schema:r,state:n});else {let a=hm({plugin:t,schema:{type:"unknown"},state:n});o.expression=a.expression;}if(o.expression&&(r.accessScope==="read"&&(o.expression=s.callExpression({functionName:s.propertyAccessExpression({expression:i.placeholder,name:y.readonly}),parameters:[o.expression]})),e&&(o.expression=s.callExpression({functionName:s.propertyAccessExpression({expression:i.placeholder,name:y.optional}),parameters:[o.expression]}),o.typeName=y.ZodMiniOptional),r.default!==void 0)){let a=r.type==="integer"&&r.format==="int64",p=pn({isBigInt:a,value:r.default});p&&(o.expression=s.callExpression({functionName:s.propertyAccessExpression({expression:i.placeholder,name:y._default}),parameters:[o.expression,p]}));}return o},fo=({id:e,plugin:t,schema:r,state:n})=>{let o={circularReferenceTracker:[e],hasCircularReference:false,...n,currentReferenceTracker:[e]},i=t.api.getSelector("ref",e),a=t.getSymbol(i);if(a&&!t.getSymbolValue(a))return;let p=bt({plugin:t,schema:r,state:o}),c=F(e);a=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;$e({plugin:t,schema:r,symbol:a,typeInferSymbol:m,zodSchema:p});},gm=({plugin:e})=>{e.registerSymbol({external:$r({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":Mr({getZodSchema:r=>bt({plugin:e,schema:r,state:{circularReferenceTracker:[],currentReferenceTracker:[],hasCircularReference:false}}),operation:t.operation,plugin:e});break;case "parameter":fo({id:t.$ref,plugin:e,schema:t.parameter.schema});break;case "requestBody":fo({id:t.$ref,plugin:e,schema:t.requestBody.schema});break;case "schema":fo({id:t.$ref,plugin:e,schema:t.schema});break;case "webhook":Lr({getZodSchema:r=>bt({plugin:e,schema:r,state:{circularReferenceTracker:[],currentReferenceTracker:[],hasCircularReference:false}}),operation:t.operation,plugin:e});break}});};var dy=({plugin:e,schema:t,state:r})=>{let n=e.referenceSymbol(e.api.getSelector("import","zod")),o=s.propertyAccessExpression({expression:n.placeholder,name:y.array}),i,a=false;if(!t.items)i=s.callExpression({functionName:o,parameters:[xi({plugin:e})]});else {t=U({schema:t});let p=t.items.map(c=>{let m=St({plugin:e,schema:c,state:r});return m.hasCircularReference&&(a=true),m.expression});p.length===1?i=s.callExpression({functionName:o,parameters:p}):(t.logicalOperator,i=s.callExpression({functionName:s.propertyAccessExpression({expression:n.placeholder,name:y.array}),parameters:[s.callExpression({functionName:s.propertyAccessExpression({expression:n.placeholder,name:y.union}),parameters:[s.arrayLiteralExpression({elements:p})]})]}));}return t.minItems===t.maxItems&&t.minItems!==void 0?i=s.callExpression({functionName:s.propertyAccessExpression({expression:i,name:y.length}),parameters:[s.valueToExpression({value:t.minItems})]}):(t.minItems!==void 0&&(i=s.callExpression({functionName:s.propertyAccessExpression({expression:i,name:y.min}),parameters:[s.valueToExpression({value:t.minItems})]})),t.maxItems!==void 0&&(i=s.callExpression({functionName:s.propertyAccessExpression({expression:i,name:y.max}),parameters:[s.valueToExpression({value:t.maxItems})]}))),{expression:i,hasCircularReference:a}},uy=({plugin:e,schema:t})=>{let r=e.referenceSymbol(e.api.getSelector("import","zod"));return typeof t.const=="boolean"?s.callExpression({functionName:s.propertyAccessExpression({expression:r.placeholder,name:y.literal}),parameters:[s.ots.boolean(t.const)]}):s.callExpression({functionName:s.propertyAccessExpression({expression:r.placeholder,name:y.boolean})})},yy=({plugin:e,schema:t})=>{let r=e.referenceSymbol(e.api.getSelector("import","zod")),n=[],o=false;for(let a of t.items??[])a.type==="string"&&typeof a.const=="string"?n.push(s.stringLiteral({text:a.const})):(a.type==="null"||a.const===null)&&(o=true);if(!n.length)return xi({plugin:e});let i=s.callExpression({functionName:s.propertyAccessExpression({expression:r.placeholder,name:y.enum}),parameters:[s.arrayLiteralExpression({elements:n,multiLine:false})]});return o&&(i=s.callExpression({functionName:s.propertyAccessExpression({expression:i,name:y.nullable})})),i},hy=({plugin:e})=>{let t=e.referenceSymbol(e.api.getSelector("import","zod"));return s.callExpression({functionName:s.propertyAccessExpression({expression:t.placeholder,name:y.never})})},gy=({plugin:e})=>{let t=e.referenceSymbol(e.api.getSelector("import","zod"));return s.callExpression({functionName:s.propertyAccessExpression({expression:t.placeholder,name:y.null})})},cn=({isBigInt:e,value:t})=>{let r=s.valueToExpression({value:t});return e&&(typeof t=="bigint"||typeof t=="number"||typeof t=="string"||typeof t=="boolean")?s.callExpression({functionName:"BigInt",parameters:[r]}):r},xy=({plugin:e,schema:t})=>{let r=e.referenceSymbol(e.api.getSelector("import","zod")),n=t.type==="integer"&&t.format==="int64";if(typeof t.const=="number")return s.callExpression({functionName:s.propertyAccessExpression({expression:r.placeholder,name:y.literal}),parameters:[s.ots.number(t.const)]});let o=s.callExpression({functionName:n?s.propertyAccessExpression({expression:s.propertyAccessExpression({expression:r.placeholder,name:y.coerce}),name:y.bigint}):s.propertyAccessExpression({expression:r.placeholder,name:y.number})});return !n&&t.type==="integer"&&(o=s.callExpression({functionName:s.propertyAccessExpression({expression:o,name:y.int})})),t.exclusiveMinimum!==void 0?o=s.callExpression({functionName:s.propertyAccessExpression({expression:o,name:y.gt}),parameters:[cn({isBigInt:n,value:t.exclusiveMinimum})]}):t.minimum!==void 0&&(o=s.callExpression({functionName:s.propertyAccessExpression({expression:o,name:y.gte}),parameters:[cn({isBigInt:n,value:t.minimum})]})),t.exclusiveMaximum!==void 0?o=s.callExpression({functionName:s.propertyAccessExpression({expression:o,name:y.lt}),parameters:[cn({isBigInt:n,value:t.exclusiveMaximum})]}):t.maximum!==void 0&&(o=s.callExpression({functionName:s.propertyAccessExpression({expression:o,name:y.lte}),parameters:[cn({isBigInt:n,value:t.maximum})]})),o},by=({plugin:e,schema:t,state:r})=>{let n=e.referenceSymbol(e.api.getSelector("import","zod")),o=false,i=[],a=t.required??[];for(let c in t.properties){let m=t.properties[c],l=a.includes(c),f=St({optional:!l,plugin:e,schema:m,state:r});f.hasCircularReference&&(o=true),te.lastIndex=0;let d;te.test(c)?d=c.startsWith("-")?S.factory.createStringLiteral(c):S.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(s.propertyAssignment({initializer:f.expression,name:d}));}if(t.additionalProperties&&(!t.properties||!Object.keys(t.properties).length)){let c=St({plugin:e,schema:t.additionalProperties,state:r});return {anyType:"AnyZodObject",expression:s.callExpression({functionName:s.propertyAccessExpression({expression:n.placeholder,name:y.record}),parameters:[c.expression]}),hasCircularReference:c.hasCircularReference}}return {anyType:"AnyZodObject",expression:s.callExpression({functionName:s.propertyAccessExpression({expression:n.placeholder,name:y.object}),parameters:[S.factory.createObjectLiteralExpression(i,true)]}),hasCircularReference:o}},Sy=({plugin:e,schema:t})=>{let r=e.referenceSymbol(e.api.getSelector("import","zod"));if(typeof t.const=="string")return s.callExpression({functionName:s.propertyAccessExpression({expression:r.placeholder,name:y.literal}),parameters:[s.ots.string(t.const)]});let n=s.callExpression({functionName:s.propertyAccessExpression({expression:r.placeholder,name:y.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":n=s.callExpression({functionName:s.propertyAccessExpression({expression:n,name:y.date})});break;case "date-time":n=s.callExpression({functionName:s.propertyAccessExpression({expression:n,name:y.datetime}),parameters:o.length>0?[s.objectExpression({obj:o})]:[]});break;case "email":n=s.callExpression({functionName:s.propertyAccessExpression({expression:n,name:y.email})});break;case "ipv4":case "ipv6":n=s.callExpression({functionName:s.propertyAccessExpression({expression:n,name:y.ip})});break;case "time":n=s.callExpression({functionName:s.propertyAccessExpression({expression:n,name:y.time})});break;case "uri":n=s.callExpression({functionName:s.propertyAccessExpression({expression:n,name:y.url})});break;case "uuid":n=s.callExpression({functionName:s.propertyAccessExpression({expression:n,name:y.uuid})});break}return t.minLength===t.maxLength&&t.minLength!==void 0?n=s.callExpression({functionName:s.propertyAccessExpression({expression:n,name:y.length}),parameters:[s.valueToExpression({value:t.minLength})]}):(t.minLength!==void 0&&(n=s.callExpression({functionName:s.propertyAccessExpression({expression:n,name:y.min}),parameters:[s.valueToExpression({value:t.minLength})]})),t.maxLength!==void 0&&(n=s.callExpression({functionName:s.propertyAccessExpression({expression:n,name:y.max}),parameters:[s.valueToExpression({value:t.maxLength})]}))),t.pattern&&(n=s.callExpression({functionName:s.propertyAccessExpression({expression:n,name:y.regex}),parameters:[s.regularExpressionLiteral({text:t.pattern})]})),n},Oy=({plugin:e,schema:t,state:r})=>{let n=e.referenceSymbol(e.api.getSelector("import","zod")),o=false;if(t.const&&Array.isArray(t.const)){let p=t.const.map(m=>s.callExpression({functionName:s.propertyAccessExpression({expression:n.placeholder,name:y.literal}),parameters:[s.valueToExpression({value:m})]}));return {expression:s.callExpression({functionName:s.propertyAccessExpression({expression:n.placeholder,name:y.tuple}),parameters:[s.arrayLiteralExpression({elements:p})]}),hasCircularReference:o}}let i=[];for(let p of t.items??[]){let c=St({plugin:e,schema:p,state:r});c.hasCircularReference&&(o=true),i.push(c.expression);}return {expression:s.callExpression({functionName:s.propertyAccessExpression({expression:n.placeholder,name:y.tuple}),parameters:[s.arrayLiteralExpression({elements:i})]}),hasCircularReference:o}},Ty=({plugin:e})=>{let t=e.referenceSymbol(e.api.getSelector("import","zod"));return s.callExpression({functionName:s.propertyAccessExpression({expression:t.placeholder,name:y.undefined})})},xi=({plugin:e})=>{let t=e.referenceSymbol(e.api.getSelector("import","zod"));return s.callExpression({functionName:s.propertyAccessExpression({expression:t.placeholder,name:y.unknown})})},Ry=({plugin:e})=>{let t=e.referenceSymbol(e.api.getSelector("import","zod"));return s.callExpression({functionName:s.propertyAccessExpression({expression:t.placeholder,name:y.void})})},xm=({plugin:e,schema:t,state:r})=>{switch(t.type){case "array":return dy({plugin:e,schema:t,state:r});case "boolean":return {expression:uy({plugin:e,schema:t})};case "enum":return {expression:yy({plugin:e,schema:t})};case "integer":case "number":return {expression:xy({plugin:e,schema:t})};case "never":return {expression:hy({plugin:e})};case "null":return {expression:gy({plugin:e})};case "object":return by({plugin:e,schema:t,state:r});case "string":return {expression:Sy({plugin:e,schema:t})};case "tuple":return Oy({plugin:e,schema:t,state:r});case "undefined":return {expression:Ty({plugin:e})};case "unknown":return {expression:xi({plugin:e})};case "void":return {expression:Ry({plugin:e})}}},St=({optional:e,plugin:t,schema:r,state:n})=>{let o={},i=t.referenceSymbol(t.api.getSelector("import","zod"));if(r.$ref){let a=n.circularReferenceTracker.includes(r.$ref);n.circularReferenceTracker.push(r.$ref),n.currentReferenceTracker.push(r.$ref);let p=t.api.getSelector("ref",r.$ref),c=t.getSymbol(p);if(a)c||(c=t.referenceSymbol(p)),o.expression=s.callExpression({functionName:s.propertyAccessExpression({expression:i.placeholder,name:y.lazy}),parameters:[s.arrowFunction({statements:[s.returnStatement({expression:s.identifier({text:c.placeholder})})]})]}),o.hasCircularReference=r.circular;else {if(c)o.hasCircularReference=r.circular;else {let l=t.context.resolveIrRef(r.$ref);uo({id:r.$ref,plugin:t,schema:l,state:{...n,currentReferenceTracker:[r.$ref]}});}let m=t.referenceSymbol(p);o.expression=s.identifier({text:m.placeholder});}n.circularReferenceTracker.pop(),n.currentReferenceTracker.pop();}else if(r.type){let a=xm({plugin:t,schema:r,state:n});o.expression=a.expression,o.hasCircularReference=a.hasCircularReference,o.typeName=a.anyType,t.config.metadata&&r.description&&(o.expression=s.callExpression({functionName:s.propertyAccessExpression({expression:o.expression,name:y.describe}),parameters:[s.stringLiteral({text:r.description})]}));}else if(r.items)if(r=U({schema:r}),r.items){let a=r.items.map(p=>{let c=St({plugin:t,schema:p,state:n});return c.hasCircularReference&&(o.hasCircularReference=true),c.expression});if(r.logicalOperator==="and"){let p=r.items[0];p.logicalOperator==="or"||p.type&&p.type!=="object"?o.expression=s.callExpression({functionName:s.propertyAccessExpression({expression:i.placeholder,name:y.intersection}),parameters:a}):(o.expression=a[0],a.slice(1).forEach(c=>{o.expression=s.callExpression({functionName:s.propertyAccessExpression({expression:o.expression,name:y.and}),parameters:[c]});}));}else o.expression=s.callExpression({functionName:s.propertyAccessExpression({expression:i.placeholder,name:y.union}),parameters:[s.arrayLiteralExpression({elements:a})]});}else o=St({plugin:t,schema:r,state:n});else {let a=xm({plugin:t,schema:{type:"unknown"},state:n});o.expression=a.expression,o.hasCircularReference=a.hasCircularReference,o.typeName=a.anyType;}if(o.expression&&(r.accessScope==="read"&&(o.expression=s.callExpression({functionName:s.propertyAccessExpression({expression:o.expression,name:y.readonly})})),e&&(o.expression=s.callExpression({functionName:s.propertyAccessExpression({expression:o.expression,name:y.optional})})),r.default!==void 0)){let a=r.type==="integer"&&r.format==="int64",p=cn({isBigInt:a,value:r.default});p&&(o.expression=s.callExpression({functionName:s.propertyAccessExpression({expression:o.expression,name:y.default}),parameters:[p]}));}return o.hasCircularReference?o.typeName||(o.typeName="ZodTypeAny"):o.typeName&&(o.typeName=void 0),o},uo=({id:e,plugin:t,schema:r,state:n})=>{n||(n={circularReferenceTracker:[e],currentReferenceTracker:[e],hasCircularReference:false});let o=t.api.getSelector("ref",e),i=t.getSymbol(o);if(i)return;let a=St({plugin:t,schema:r,state:n}),p=F(e);i=t.registerSymbol({exported:true,name:O({config:t.config.definitions,name:p}),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:p}),selector:t.api.getSelector("type-infer-ref",e)}):void 0;$e({plugin:t,schema:r,symbol:i,typeInferSymbol:c,zodSchema:a});},bm=({plugin:e})=>{e.registerSymbol({external:$r({plugin:e}),name:"z",selector:e.api.getSelector("import","zod")}),e.forEach("operation","parameter","requestBody","schema","webhook",t=>{switch(t.type){case "operation":Mr({getZodSchema:r=>St({plugin:e,schema:r,state:{circularReferenceTracker:[],currentReferenceTracker:[],hasCircularReference:false}}),operation:t.operation,plugin:e});break;case "parameter":uo({id:t.$ref,plugin:e,schema:t.parameter.schema});break;case "requestBody":uo({id:t.$ref,plugin:e,schema:t.requestBody.schema});break;case "schema":uo({id:t.$ref,plugin:e,schema:t.schema});break;case "webhook":Lr({getZodSchema:r=>St({plugin:e,schema:r,state:{circularReferenceTracker:[],currentReferenceTracker:[],hasCircularReference:false}}),operation:t.operation,plugin:e});break}});};var Ay=({plugin:e,schema:t,state:r})=>{let n={},o=e.referenceSymbol(e.api.getSelector("import","zod")),i=s.propertyAccessExpression({expression:o.placeholder,name:y.array});if(!t.items)n.expression=s.callExpression({functionName:i,parameters:[Si({plugin:e}).expression]});else {t=U({schema:t});let a=t.items.map(p=>{let c=Ot({plugin:e,schema:p,state:r});return c.hasCircularReference&&(n.hasCircularReference=true),c.expression});a.length===1?n.expression=s.callExpression({functionName:i,parameters:a}):(t.logicalOperator,n.expression=s.callExpression({functionName:s.propertyAccessExpression({expression:o.placeholder,name:y.array}),parameters:[s.callExpression({functionName:s.propertyAccessExpression({expression:o.placeholder,name:y.union}),parameters:[s.arrayLiteralExpression({elements:a})]})]}));}return t.minItems===t.maxItems&&t.minItems!==void 0?n.expression=s.callExpression({functionName:s.propertyAccessExpression({expression:n.expression,name:y.length}),parameters:[s.valueToExpression({value:t.minItems})]}):(t.minItems!==void 0&&(n.expression=s.callExpression({functionName:s.propertyAccessExpression({expression:n.expression,name:y.min}),parameters:[s.valueToExpression({value:t.minItems})]})),t.maxItems!==void 0&&(n.expression=s.callExpression({functionName:s.propertyAccessExpression({expression:n.expression,name:y.max}),parameters:[s.valueToExpression({value:t.maxItems})]}))),n},Py=({plugin:e,schema:t})=>{let r={},n=e.referenceSymbol(e.api.getSelector("import","zod"));return typeof t.const=="boolean"?(r.expression=s.callExpression({functionName:s.propertyAccessExpression({expression:n.placeholder,name:y.literal}),parameters:[s.ots.boolean(t.const)]}),r):(r.expression=s.callExpression({functionName:s.propertyAccessExpression({expression:n.placeholder,name:y.boolean})}),r)},Ey=({plugin:e,schema:t})=>{let r={},n=[],o=false;for(let a of t.items??[])a.type==="string"&&typeof a.const=="string"?n.push(s.stringLiteral({text:a.const})):(a.type==="null"||a.const===null)&&(o=true);if(!n.length)return Si({plugin:e});let i=e.referenceSymbol(e.api.getSelector("import","zod"));return r.expression=s.callExpression({functionName:s.propertyAccessExpression({expression:i.placeholder,name:y.enum}),parameters:[s.arrayLiteralExpression({elements:n,multiLine:false})]}),o&&(r.expression=s.callExpression({functionName:s.propertyAccessExpression({expression:i.placeholder,name:y.nullable}),parameters:[r.expression]})),r},Iy=({plugin:e})=>{let t={},r=e.referenceSymbol(e.api.getSelector("import","zod"));return t.expression=s.callExpression({functionName:s.propertyAccessExpression({expression:r.placeholder,name:y.never})}),t},ky=({plugin:e})=>{let t={},r=e.referenceSymbol(e.api.getSelector("import","zod"));return t.expression=s.callExpression({functionName:s.propertyAccessExpression({expression:r.placeholder,name:y.null})}),t},mn=({isBigInt:e,value:t})=>{let r=s.valueToExpression({value:t});return e&&(typeof t=="bigint"||typeof t=="number"||typeof t=="string"||typeof t=="boolean")?s.callExpression({functionName:"BigInt",parameters:[r]}):r},jy=({plugin:e,schema:t})=>{let r={},n=t.type==="integer"&&t.format==="int64",o=e.referenceSymbol(e.api.getSelector("import","zod"));return typeof t.const=="number"?(r.expression=s.callExpression({functionName:s.propertyAccessExpression({expression:o.placeholder,name:y.literal}),parameters:[s.ots.number(t.const)]}),r):(r.expression=s.callExpression({functionName:n?s.propertyAccessExpression({expression:s.propertyAccessExpression({expression:o.placeholder,name:y.coerce}),name:y.bigint}):s.propertyAccessExpression({expression:o.placeholder,name:y.number})}),!n&&t.type==="integer"&&(r.expression=s.callExpression({functionName:s.propertyAccessExpression({expression:o.placeholder,name:y.int})})),t.exclusiveMinimum!==void 0?r.expression=s.callExpression({functionName:s.propertyAccessExpression({expression:r.expression,name:y.gt}),parameters:[mn({isBigInt:n,value:t.exclusiveMinimum})]}):t.minimum!==void 0&&(r.expression=s.callExpression({functionName:s.propertyAccessExpression({expression:r.expression,name:y.gte}),parameters:[mn({isBigInt:n,value:t.minimum})]})),t.exclusiveMaximum!==void 0?r.expression=s.callExpression({functionName:s.propertyAccessExpression({expression:r.expression,name:y.lt}),parameters:[mn({isBigInt:n,value:t.exclusiveMaximum})]}):t.maximum!==void 0&&(r.expression=s.callExpression({functionName:s.propertyAccessExpression({expression:r.expression,name:y.lte}),parameters:[mn({isBigInt:n,value:t.maximum})]})),r)},Ny=({plugin:e,schema:t,state:r})=>{let n={},o=[],i=t.required??[],a=e.referenceSymbol(e.api.getSelector("import","zod"));for(let p in t.properties){let c=t.properties[p],m=i.includes(p),l=Ot({optional:!m,plugin:e,schema:c,state:r});l.hasCircularReference&&(n.hasCircularReference=true),te.lastIndex=0;let f;te.test(p)?f=p.startsWith("-")?S.factory.createStringLiteral(p):S.factory.createNumericLiteral(p):f=p,(p.match(/^[0-9]/)&&p.match(/\D+/g)||p.match(/\W/g))&&!p.startsWith("'")&&!p.endsWith("'")&&(f=`'${p}'`),l.hasCircularReference?o.push(s.getAccessorDeclaration({name:f,returnType:l.typeName?s.propertyAccessExpression({expression:a.placeholder,name:l.typeName}):void 0,statements:[s.returnStatement({expression:l.expression})]})):o.push(s.propertyAssignment({initializer:l.expression,name:f}));}if(t.additionalProperties&&(!t.properties||!Object.keys(t.properties).length)){let p=Ot({plugin:e,schema:t.additionalProperties,state:r});return n.expression=s.callExpression({functionName:s.propertyAccessExpression({expression:a.placeholder,name:y.record}),parameters:[s.callExpression({functionName:s.propertyAccessExpression({expression:a.placeholder,name:y.string}),parameters:[]}),p.expression]}),p.hasCircularReference&&(n.hasCircularReference=true),n.hasCircularReference?{...n,typeName:"ZodType"}:n}return n.expression=s.callExpression({functionName:s.propertyAccessExpression({expression:a.placeholder,name:y.object}),parameters:[S.factory.createObjectLiteralExpression(o,true)]}),n.hasCircularReference?{...n,typeName:"ZodType"}:n},Cy=({plugin:e,schema:t})=>{let r={},n=e.referenceSymbol(e.api.getSelector("import","zod"));if(typeof t.const=="string")return r.expression=s.callExpression({functionName:s.propertyAccessExpression({expression:n.placeholder,name:y.literal}),parameters:[s.ots.string(t.const)]}),r;r.expression=s.callExpression({functionName:s.propertyAccessExpression({expression:n.placeholder,name:y.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=s.callExpression({functionName:s.propertyAccessExpression({expression:s.propertyAccessExpression({expression:n.placeholder,name:y.iso}),name:y.date})});break;case "date-time":r.expression=s.callExpression({functionName:s.propertyAccessExpression({expression:s.propertyAccessExpression({expression:n.placeholder,name:y.iso}),name:y.datetime}),parameters:o.length>0?[s.objectExpression({obj:o})]:[]});break;case "email":r.expression=s.callExpression({functionName:s.propertyAccessExpression({expression:n.placeholder,name:y.email})});break;case "ipv4":r.expression=s.callExpression({functionName:s.propertyAccessExpression({expression:n.placeholder,name:y.ipv4})});break;case "ipv6":r.expression=s.callExpression({functionName:s.propertyAccessExpression({expression:n.placeholder,name:y.ipv6})});break;case "time":r.expression=s.callExpression({functionName:s.propertyAccessExpression({expression:s.propertyAccessExpression({expression:n.placeholder,name:y.iso}),name:y.time})});break;case "uri":r.expression=s.callExpression({functionName:s.propertyAccessExpression({expression:n.placeholder,name:y.url})});break;case "uuid":r.expression=s.callExpression({functionName:s.propertyAccessExpression({expression:n.placeholder,name:y.uuid})});break}return t.minLength===t.maxLength&&t.minLength!==void 0?r.expression=s.callExpression({functionName:s.propertyAccessExpression({expression:r.expression,name:y.length}),parameters:[s.valueToExpression({value:t.minLength})]}):(t.minLength!==void 0&&(r.expression=s.callExpression({functionName:s.propertyAccessExpression({expression:r.expression,name:y.min}),parameters:[s.valueToExpression({value:t.minLength})]})),t.maxLength!==void 0&&(r.expression=s.callExpression({functionName:s.propertyAccessExpression({expression:r.expression,name:y.max}),parameters:[s.valueToExpression({value:t.maxLength})]}))),t.pattern&&(r.expression=s.callExpression({functionName:s.propertyAccessExpression({expression:r.expression,name:y.regex}),parameters:[s.regularExpressionLiteral({text:t.pattern})]})),r},vy=({plugin:e,schema:t,state:r})=>{let n={},o=e.referenceSymbol(e.api.getSelector("import","zod"));if(t.const&&Array.isArray(t.const)){let a=t.const.map(p=>s.callExpression({functionName:s.propertyAccessExpression({expression:o.placeholder,name:y.literal}),parameters:[s.valueToExpression({value:p})]}));return n.expression=s.callExpression({functionName:s.propertyAccessExpression({expression:o.placeholder,name:y.tuple}),parameters:[s.arrayLiteralExpression({elements:a})]}),n}let i=[];for(let a of t.items??[]){let p=Ot({plugin:e,schema:a,state:r});i.push(p.expression),p.hasCircularReference&&(n.hasCircularReference=true);}return n.expression=s.callExpression({functionName:s.propertyAccessExpression({expression:o.placeholder,name:y.tuple}),parameters:[s.arrayLiteralExpression({elements:i})]}),n},wy=({plugin:e})=>{let t={},r=e.referenceSymbol(e.api.getSelector("import","zod"));return t.expression=s.callExpression({functionName:s.propertyAccessExpression({expression:r.placeholder,name:y.undefined})}),t},Si=({plugin:e})=>{let t={},r=e.referenceSymbol(e.api.getSelector("import","zod"));return t.expression=s.callExpression({functionName:s.propertyAccessExpression({expression:r.placeholder,name:y.unknown})}),t},qy=({plugin:e})=>{let t={},r=e.referenceSymbol(e.api.getSelector("import","zod"));return t.expression=s.callExpression({functionName:s.propertyAccessExpression({expression:r.placeholder,name:y.void})}),t},Sm=({plugin:e,schema:t,state:r})=>{switch(t.type){case "array":return Ay({plugin:e,schema:t,state:r});case "boolean":return Py({plugin:e,schema:t});case "enum":return Ey({plugin:e,schema:t});case "integer":case "number":return jy({plugin:e,schema:t});case "never":return Iy({plugin:e});case "null":return ky({plugin:e});case "object":return Ny({plugin:e,schema:t,state:r});case "string":return Cy({plugin:e,schema:t});case "tuple":return vy({plugin:e,schema:t,state:r});case "undefined":return wy({plugin:e});case "unknown":return Si({plugin:e});case "void":return qy({plugin:e})}},Ot=({optional:e,plugin:t,schema:r,state:n})=>{let o={},i=t.referenceSymbol(t.api.getSelector("import","zod"));if(r.$ref){let a=n.circularReferenceTracker.includes(r.$ref),p=n.currentReferenceTracker.includes(r.$ref);n.circularReferenceTracker.push(r.$ref),n.currentReferenceTracker.push(r.$ref);let c=t.api.getSelector("ref",r.$ref),m=t.getSymbol(c);if(a)m||(m=t.referenceSymbol(c)),p?o.expression=s.callExpression({functionName:s.propertyAccessExpression({expression:i.placeholder,name:y.lazy}),parameters:[s.arrowFunction({returnType:s.keywordTypeNode({keyword:"any"}),statements:[s.returnStatement({expression:s.identifier({text:m.placeholder})})]})]}):o.expression=s.identifier({text:m.placeholder}),o.hasCircularReference=r.circular;else {if(m)o.hasCircularReference=r.circular;else {let f=t.context.resolveIrRef(r.$ref);yo({id:r.$ref,plugin:t,schema:f,state:n});}let l=t.referenceSymbol(c);o.expression=s.identifier({text:l.placeholder});}n.circularReferenceTracker.pop(),n.currentReferenceTracker.pop();}else if(r.type){let a=Sm({plugin:t,schema:r,state:n});o.expression=a.expression,o.hasCircularReference=a.hasCircularReference,t.config.metadata&&r.description&&(o.expression=s.callExpression({functionName:s.propertyAccessExpression({expression:o.expression,name:y.register}),parameters:[s.propertyAccessExpression({expression:i.placeholder,name:y.globalRegistry}),s.objectExpression({obj:[{key:"description",value:s.stringLiteral({text:r.description})}]})]}));}else if(r.items)if(r=U({schema:r}),r.items){let a=r.items.map(p=>Ot({plugin:t,schema:p,state:n}));if(r.logicalOperator==="and"){let p=r.items[0];p.logicalOperator==="or"||p.type&&p.type!=="object"?o.expression=s.callExpression({functionName:s.propertyAccessExpression({expression:i.placeholder,name:y.intersection}),parameters:a.map(c=>c.expression)}):(o.expression=a[0].expression,a.slice(1).forEach(c=>{o.expression=s.callExpression({functionName:s.propertyAccessExpression({expression:o.expression,name:y.and}),parameters:[c.hasCircularReference?s.callExpression({functionName:s.propertyAccessExpression({expression:i.placeholder,name:y.lazy}),parameters:[s.arrowFunction({statements:[s.returnStatement({expression:c.expression})]})]}):c.expression]});}));}else o.expression=s.callExpression({functionName:s.propertyAccessExpression({expression:i.placeholder,name:y.union}),parameters:[s.arrayLiteralExpression({elements:a.map(p=>p.expression)})]});}else o=Ot({plugin:t,schema:r,state:n});else {let a=Sm({plugin:t,schema:{type:"unknown"},state:n});o.expression=a.expression;}if(o.expression&&(r.accessScope==="read"&&(o.expression=s.callExpression({functionName:s.propertyAccessExpression({expression:o.expression,name:y.readonly})})),e&&(o.expression=s.callExpression({functionName:s.propertyAccessExpression({expression:i.placeholder,name:y.optional}),parameters:[o.expression]}),o.typeName=y.ZodOptional),r.default!==void 0)){let a=r.type==="integer"&&r.format==="int64",p=mn({isBigInt:a,value:r.default});p&&(o.expression=s.callExpression({functionName:s.propertyAccessExpression({expression:o.expression,name:y.default}),parameters:[p]}));}return o},yo=({id:e,plugin:t,schema:r,state:n})=>{let o={circularReferenceTracker:[e],hasCircularReference:false,...n,currentReferenceTracker:[e]},i=t.api.getSelector("ref",e),a=t.getSymbol(i);if(a&&!t.getSymbolValue(a))return;let p=Ot({plugin:t,schema:r,state:o}),c=F(e);a=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;$e({plugin:t,schema:r,symbol:a,typeInferSymbol:m,zodSchema:p});},Oi=({plugin:e})=>{e.registerSymbol({external:$r({plugin:e}),name:"z",selector:e.api.getSelector("import","zod")}),e.forEach("operation","parameter","requestBody","schema","webhook",t=>{switch(t.type){case "operation":Mr({getZodSchema:r=>Ot({plugin:e,schema:r,state:{circularReferenceTracker:[],currentReferenceTracker:[],hasCircularReference:false}}),operation:t.operation,plugin:e});break;case "parameter":yo({id:t.$ref,plugin:e,schema:t.parameter.schema});break;case "requestBody":yo({id:t.$ref,plugin:e,schema:t.requestBody.schema});break;case "schema":yo({id:t.$ref,plugin:e,schema:t.schema});break;case "webhook":Lr({getZodSchema:r=>Ot({plugin:e,schema:r,state:{circularReferenceTracker:[],currentReferenceTracker:[],hasCircularReference:false}}),operation:t.operation,plugin:e});break}});};var Om=e=>{let{plugin:t}=e;switch(t.config.compatibilityVersion){case 3:return bm(e);case 4:return Oi(e);case "mini":return gm(e);default:return Oi(e)}};var ho={api:new lo({name:"zod"}),config:{case:"camelCase",comments:true,exportFromIndex:false,metadata:false},handler:Om,name:"zod",resolveConfig:(e,t)=>{let n=t.package.getVersion("zod"),o=()=>n&&(n.major===4||n.major===3)?n.major:4,i=a=>{if(!a)return o();if(!n)return a;if((a===4||a===3||a==="mini")&&!t.package.satisfies(n,">=3.25.0 <5.0.0")){let p=o();return console.warn(`\u{1F50C} ${Rt.yellow("Warning:")} Installed ${Rt.cyan("zod")} ${Rt.cyan(`v${n.version}`)} does not support compatibility version ${Rt.yellow(String(a))}, using ${Rt.yellow(String(p))}.`),p}return a};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:(a,p)=>({...a,infer:t.valueToObject({defaultValue:{...p.infer,enabled:a.infer!==void 0?!!a.infer:p.infer.enabled},mappers:Ve,value:a.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:{...Ve,object:(a,p)=>({...a,types:t.valueToObject({defaultValue:p.types,mappers:{object:(c,m)=>({...c,infer:t.valueToObject({defaultValue:{...m.infer,enabled:c.infer!==void 0?!!c.infer:m.infer.enabled},mappers:Ve,value:c.infer})})},value:a.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:{...Ve,object:(a,p)=>({...a,types:t.valueToObject({defaultValue:p.types,mappers:{object:(c,m)=>({...c,infer:t.valueToObject({defaultValue:{...m.infer,enabled:c.infer!==void 0?!!c.infer:m.infer.enabled},mappers:Ve,value:c.infer})})},value:a.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:{...Ve,object:(a,p)=>({...a,types:t.valueToObject({defaultValue:p.types,mappers:{object:(c,m)=>({...c,infer:t.valueToObject({defaultValue:{...m.infer,enabled:c.infer!==void 0?!!c.infer:m.infer.enabled},mappers:Ve,value:c.infer})})},value:a.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:{...Ve,object:(a,p)=>({...a,types:t.valueToObject({defaultValue:p.types,mappers:{object:(c,m)=>({...c,infer:t.valueToObject({defaultValue:{...m.infer,enabled:c.infer!==void 0?!!c.infer:m.infer.enabled},mappers:Ve,value:c.infer})})},value:a.types})})},value:e.config.webhooks});},tags:["validator"]};var go={"@angular/common":ps,"@hey-api/client-angular":ms,"@hey-api/client-axios":fs,"@hey-api/client-fetch":us,"@hey-api/client-next":hs,"@hey-api/client-nuxt":xs,"@hey-api/client-ofetch":Ss,"@hey-api/schemas":Is,"@hey-api/sdk":js,"@hey-api/transformers":ws,"@hey-api/typescript":Ms,"@pinia/colada":Ks,"@tanstack/angular-query-experimental":Gs,"@tanstack/react-query":Ys,"@tanstack/solid-query":to,"@tanstack/svelte-query":no,"@tanstack/vue-query":oo,fastify:ao,"legacy/angular":Os,"legacy/axios":Ts,"legacy/fetch":Rs,"legacy/node":As,"legacy/xhr":Ps,valibot:mo,zod:ho};var Tm=["@hey-api/typescript","@hey-api/sdk"],My=({dependencies:e,userPlugins:t,userPluginsConfig:r})=>{let n=new Set,o=new Set,i={},a=p=>{if(n.has(p))throw new Error(`Circular reference detected at '${p}'`);if(o.has(p))return;n.add(p);let c=go[p],m=r[p];if(!c&&!m)throw new Error(`unknown plugin dependency "${p}" - 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:Pn(e),pluginByTag:(d,u={})=>{let{defaultPlugin:h,errorMessage:g}=u;for(let x of t){let b=go[x]||r[x];if(b&&b.tags?.includes(d)&&x!==p)return x}if(h){let x=go[h]||r[h];if(x&&x.tags?.includes(d)&&h!==p)return h}throw new Error(g||`missing plugin - no plugin with tag "${d}" found`)},valueToObject:xe};l.resolveConfig(l,f);}for(let f of l.dependencies)a(f);n.delete(p),o.add(p),i[p]=l;};for(let p of t)a(p);return {pluginOrder:Array.from(o),plugins:i}},Ly=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"),Rm=({dependencies:e,userConfig:t})=>{let r={},n=Tm;t.plugins&&(t.plugins=t.plugins.filter(i=>typeof i=="string"&&i||typeof i!="string"&&i.name),t.plugins.length===1&&Ly(t.plugins[0])?n=[...Tm,...t.plugins]:n=t.plugins);let o=n.map(i=>{if(typeof i=="string")return i;let a=i.name;return a&&(i.handler?r[a]=i:(r[a]={config:{...i}},delete r[a].config.name)),a}).filter(Boolean);return My({dependencies:e,userPlugins:o,userPluginsConfig:r})};var Vy=/^([\w-]+)\/([\w-]+)(?:\?([\w=&.-]*))?$/,Vr="https://get.heyapi.dev",Dy=(e,t,r)=>`${Vr}/${e}/${t}${r?`?${r}`:""}`,Fy=e=>{let t=e.organization,r=e.project,n;if(e.path){let i=e.path.match(Vy);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],n=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:n}},Ti=e=>{let t=Fy(e);return Dy(t.organization,t.project,t.queryParams)};var By=/^(@([\w-]+)\/([\w\-.]+)#)?([\w-]+)$/,Ky=e=>`https://dash.readme.com/api/v1/api-registry/${e}`,xo="readme",Wy=e=>{let t=e.match(By);if(!t)throw new Error(`Invalid ReadMe shorthand format. Expected "${xo}:@organization/project#uuid" or "${xo}:uuid", received: ${xo}:${e}`);let[,,r,n,o]=t;if(!o)throw new Error("The ReadMe UUID cannot be empty.");return {organization:r,project:n,uuid:o}},Am=e=>{let t=e.slice(`${xo}:`.length),r=Wy(t);return Ky(r.uuid)};var zy=/^(@[\w-]+)\/([\w.-]+)$/,_y=(e,t)=>`https://registry.scalar.com/${e}/apis/${t}/latest?format=json`,Ri="scalar",Hy=e=>{let t=e.match(zy);if(!t)throw new Error(`Invalid Scalar shorthand format. Expected "${Ri}:@organization/project", received: ${Ri}:${e}`);let[,r,n]=t;if(!r)throw new Error("The Scalar organization cannot be empty.");if(!n)throw new Error("The Scalar project cannot be empty.");return {organization:r,project:n}},Pm=e=>{let t=e.slice(`${Ri}:`.length),r=Hy(t);return _y(r.organization,r.project)};var Em=e=>{if(e.path.startsWith("readme:")){e.path=Am(e.path);return}if(e.path.startsWith("scalar:")){e.path=Pm(e.path);return}if(e.path.startsWith("."))return;if(e.path.startsWith(Vr)){e.path=e.path.slice(Vr.length+1),e.path=Ti(e);return}let t=e.path.split("/"),r=t.filter(Boolean);t.length===2&&r.length===2&&(e.path=Ti(e));};var fn={enabled:false,interval:1e3,timeout:6e4},Im=e=>{let t={...fn};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},km=e=>{let t={path:"",watch:fn};return typeof e.input=="string"?t.path=e.input:e.input&&(e.input.path!==void 0||e.input.organization!==void 0)?(t={...t,path:Vr,...e.input},t.watch!==void 0&&(t.watch=Im(t))):t={...t,path:e.input},typeof t.path=="string"&&Em(t),e.watch!==void 0&&t.watch.enabled===fn.enabled&&t.watch.interval===fn.interval&&t.watch.timeout===fn.timeout&&(t.watch=Im({path:t.path,watch:e.watch})),t};var Qy=(e,t)=>({...e||{},...t||{}}),Ai=(e,t)=>{let r=e||{},n=t||{},o={...r,...n};return typeof o.logs=="object"&&(o.logs=Qy(r.logs,n.logs)),o};var jm=e=>xe({defaultValue:{clean:true,fileName:{case:"preserve",name:"{{name}}",suffix:".gen"},format:false,indexFile:true,lint:false,path:"",tsConfigPath:""},mappers:{object:(r,n)=>({...r,fileName:xe({defaultValue:{...n.fileName},mappers:{function:o=>({name:o}),string:o=>({name:o})},value:r.fileName})}),string:r=>({path:r})},value:e.output});var Cm=e=>{let t=e?M.dirname(e):process.cwd();for(;t!==M.dirname(t);){let r=M.join(t,"package.json");if(he.existsSync(r))try{let o=JSON.parse(he.readFileSync(r,"utf8"));return {...o.dependencies,...o.devDependencies,...o.peerDependencies,...o.optionalDependencies}}catch{}let n=M.dirname(t);if(n===t)break;t=n;}return {}};var nM=async e=>{let t;if(e?.configFile){let p=e.configFile.split(".");t=p.slice(0,p.length-1).join(".");}let{config:r,configFile:n}=await loadConfig({configFile:t,name:"openapi-ts"}),o=Cm(Object.keys(r).length?n:void 0),i=Array.isArray(e)?e:Array.isArray(r)?r.map(p=>Ai(p,e)):[Ai(r,e)],a=[];for(let p of i){let{base:c,configFile:m="",dryRun:l=false,experimentalParser:f=true,exportCore:d=true,interactive:u=false,name:h,request:g,useOptions:x=true}=p,b=[],j=Ni(p);j.level==="debug"&&console.warn("userConfig:",p);let k=km(p),P=jm(p),C=Ci(p);k.path||b.push(new $t("missing input - which OpenAPI specification should we use to generate your output?")),P.path||b.push(new $t("missing output - where should we generate your output?")),x||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"),P.path=M.resolve(process.cwd(),P.path);let V;try{V=Rm({dependencies:o,userConfig:p});}catch(q){b.push(q),V={pluginOrder:[],plugins:{}};}let D=Li({...V,base:c,configFile:m,dryRun:l,experimentalParser:f,exportCore:false,input:k,interactive:u,logs:j,name:h,output:P,parser:C,request:g,useOptions:x});D.exportCore=Q(D)?d:false,j.level==="debug"&&console.warn("config:",D),a.push({config:D,errors:b});}return {dependencies:o,results:a}};var rh=e=>{let t=[];return e.forEach((r,n)=>{t.push([n,r]);}),t},So=(...e)=>{let t=new Headers;for(let r of e){if(!r)continue;let n=r instanceof Headers?rh(r):Object.entries(r);for(let[o,i]of n)if(i===null)t.delete(o);else if(Array.isArray(i))for(let a of i)t.append(o,a);else i!==void 0&&t.set(o,typeof i=="object"?JSON.stringify(i):i);}return t};var WM=async({fetchOptions:e,inputPath:t,timeout:r,watch:n})=>{let o=new $RefParser,i=getResolvedInput({pathOrUrlOrSchema:t}),a,p,c;if(i.type==="url"){if(n.lastValue&&n.isHeadMethodSupported!==false){try{let l=await sendRequest({fetchOptions:{method:"HEAD",...e,headers:So(e?.headers,n.headers)},timeout:r,url:i.path});if(l.response.status>=300)return {error:"not-ok",response:l.response};c=l.response;}catch(l){return {error:"not-ok",response:new Response(l.message)}}if(!c.ok&&n.isHeadMethodSupported)return {error:"not-ok",response:c};if(n.isHeadMethodSupported===void 0&&(n.isHeadMethodSupported=c.ok),c.status===304)return {error:"not-modified",response:c};if(p===void 0){let l=c.headers.get("ETag");l&&(p=l!==n.headers.get("If-None-Match"),p&&n.headers.set("If-None-Match",l));}if(p===void 0){let l=c.headers.get("Last-Modified");l&&(p=l!==n.headers.get("If-Modified-Since"),p&&n.headers.set("If-Modified-Since",l));}if(p===false)return {error:"not-modified",response:c}}try{let l=await sendRequest({fetchOptions:{method:"GET",...e},timeout:r,url:i.path});if(l.response.status>=300)return {error:"not-ok",response:l.response};c=l.response;}catch(l){return {error:"not-ok",response:new Response(l.message)}}if(!c.ok)return {error:"not-ok",response:c};if(a=c.body?await c.arrayBuffer():new ArrayBuffer(0),p===void 0){let l=new TextDecoder().decode(a);p=l!==n.lastValue,n.lastValue=l;}}else n.lastValue?p=false:n.lastValue=i.type;return p===false?{error:"not-modified",response:c}:{data:await o.bundle({arrayBuffer:a,pathOrUrlOrSchema:void 0,resolvedInput:i})}};
53
+ export{Qo as A,Rp as B,fP as C,dP as D,Ie as E,ke as F,PP as G,je as H,wt as I,Tm as J,nM as K,WM as L,ki as a,ih as b,ah as c,dh as d,uh as e,it as f,gh as g,$t as h,Ah as i,Ph as j,Eh as k,Ih as l,I as m,A as n,Q as o,Mt as p,Vr as q,Ni as r,zm as s,R as t,w as u,s as v,gg as w,pt as x,Rr as y,Ge as z};//# sourceMappingURL=chunk-WF7D2BDN.js.map
54
+ //# sourceMappingURL=chunk-WF7D2BDN.js.map