@hey-api/openapi-ts 0.87.3 → 0.87.5

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,19 @@
1
+ import{r as e}from"./chunk-C-EqMg7d.js";import{Project as t,createBinding as n,mergeBindings as r,renderIds as i}from"@hey-api/codegen-core";import a from"ansi-colors";import o from"node:fs";import s from"node:path";import{fileURLToPath as c}from"node:url";import l from"typescript";import{EOL as u}from"node:os";import*as d from"semver";import{getResolvedInput as f,sendRequest as p}from"@hey-api/json-schema-ref-parser";const m=c(import.meta.url),h=s.dirname(m),g=()=>{let e=h;for(;e!==s.dirname(e);){let t=o.readdirSync(e).filter(e=>e===`package.json`);if(t[0]){let n=s.join(e,t[0]);return JSON.parse(o.readFileSync(n,{encoding:`utf8`}))}e=s.dirname(e)}},ee=()=>{let e=g(),t={bugs:{url:``},name:``,version:``};return e&&typeof e==`object`&&(`name`in e&&typeof e.name==`string`&&(t.name=e.name),`version`in e&&typeof e.version==`string`&&(t.version=e.version),`bugs`in e&&e.bugs&&typeof e.bugs==`object`&&`url`in e.bugs&&typeof e.bugs.url==`string`&&(t.bugs.url=e.bugs.url,t.bugs.url&&!t.bugs.url.endsWith(`/`)&&(t.bugs.url+=`/`))),t},te=e=>{if(e===null)return null;if(e){let t=s.isAbsolute(e)?e:s.resolve(h,e);return o.existsSync(t)?t:null}let t=h;for(;t!==s.dirname(t);){let e=o.readdirSync(t).filter(e=>e.startsWith(`tsconfig`)&&e.endsWith(`.json`)).sort(e=>e===`tsconfig.json`?-1:1);if(e[0])return s.join(t,e[0]);t=s.dirname(t)}return null},ne=e=>{if(!e)return null;let t=l.readConfigFile(e,l.sys.readFile);if(t.error)throw Error(`Couldn't read tsconfig from path: ${e}`);return l.parseJsonConfigFileContent(t.config,l.sys,s.dirname(e))},_=e=>{o.existsSync(e)||o.mkdirSync(e,{recursive:!0})};var v=class extends Error{constructor(e){super(e),this.name=`ConfigError`}},re=class extends Error{errors;constructor(e){super(`Found ${e.length} configuration ${e.length===1?`error`:`errors`}.`),this.name=`ConfigValidationError`,this.errors=e}},ie=class extends Error{originalError;constructor(e,t){super(e),this.name=`JobError`,this.originalError=t}},ae=class extends Error{args;event;pluginName;constructor({args:e,error:t,event:n,name:r,pluginName:i}){let a=t instanceof Error?t.message:`Unknown error`;super(a),this.args=e,this.cause=t.cause,this.event=n,this.name=r||t.name,this.pluginName=i,this.stack=t.stack}};const oe=(e,t)=>{if(e instanceof v||e instanceof re)return;e instanceof ie&&(e=e.originalError.error);let n=`openapi-ts-error-${Date.now()}.log`,r=s.resolve(process.cwd(),t);_(r);let i=s.resolve(r,n),a=`[${new Date().toISOString()}] `;e instanceof ae&&(a+=`${e.name} during event "${e.event}"\n`,e.pluginName&&(a+=`Plugin: ${e.pluginName}\n`),a+=`Arguments: ${JSON.stringify(e.args,null,2)}\n\n`);let c=e instanceof Error?e.message:String(e),l=e instanceof Error?e.stack:void 0;return a+=`Error: ${c}\n`,l&&(a+=`Stack:\n${l}\n`),o.writeFileSync(i,a),i},se=async e=>{let t=ee();if(!t.bugs.url)return;e instanceof ie&&(e=e.originalError.error);let n=``;e instanceof ae&&(e.pluginName&&(n+=`**Plugin**: \`${e.pluginName}\`\n`),n+=`**Event**: \`${e.event}\`\n`,n+=`**Arguments**:\n\`\`\`ts\n${JSON.stringify(e.args,null,2)}\n\`\`\`\n\n`);let r=e instanceof Error?e.message:String(e),i=e instanceof Error?e.stack:void 0;n+=`**Error**: \`${r}\`\n`,i&&(n+=`\n**Stack Trace**:\n\`\`\`\n${i}\n\`\`\``);let a=new URLSearchParams({body:n,labels:`bug 🔥`,title:`Crash Report`}),o=`${t.bugs.url}new?${a.toString()}`,s=(await import(`open`)).default;await s(o)},ce=({error:e,logPath:t})=>{if(e instanceof re&&e.errors.length){let t=new Map;for(let{error:n,jobIndex:r}of e.errors)t.has(r)||t.set(r,[]),t.get(r).push(n);for(let[e,n]of t.entries()){let t=a.gray(`[Job ${e+1}] `),r=n.length,i=a.red(`Found ${r} configuration ${r===1?`error`:`errors`}:`);console.error(`${t}❗️ ${i}`),n.forEach((e,n)=>{let r=` [${n+1}] `,i=a.red(r);console.error(`${t}${i}${a.white(e.message)}`)})}}else{let t=a.gray(`[root] `);e instanceof ie&&(t=a.gray(`[Job ${e.originalError.jobIndex+1}] `),e=e.originalError.error);let n=a.red(`Failed with the message:`);console.error(`${t}❌ ${n}`);let r=a.red(` `);console.error(`${t}${r}${typeof e==`string`?e:e instanceof Error?e.message:`Unknown error`}`)}if(t){let e=a.gray(`[root] `);console.error(`${e}${a.cyan(`📄 Crash log saved to:`)} ${a.gray(t)}`)}},le=async({error:e,isInteractive:t})=>!t||e instanceof v||e instanceof re?!1:new Promise(e=>{let t=a.gray(`[root] `);console.log(`${t}${a.yellow(`📢 Open a GitHub issue with crash details? (y/N):`)}`),process.stdin.setEncoding(`utf8`),process.stdin.once(`data`,t=>{e(t.trim().toLowerCase()===`y`)})}),ue=/^([\w-]+)\/([\w-]+)(?:\?([\w=&.-]*))?$/,de=`https://get.heyapi.dev`,fe=(e,t,n)=>`${de}/${e}/${t}${n?`?${n}`:``}`,pe=e=>{let t=e.organization,n=e.project,r;if(e.path){let i=e.path.match(ue);if(!i)throw Error(`Invalid Hey API shorthand format. Expected "organization/project?queryParams" or "organization/project", received: ${e.path}`);t=i[1],n=i[2],r=i[3]}if(!t)throw Error(`The Hey API organization cannot be empty.`);if(!n)throw Error(`The Hey API project cannot be empty.`);return{organization:t,project:n,queryParams:r}},me=e=>{let t=pe(e);return{path:fe(t.organization,t.project,t.queryParams),registry:`hey-api`}},he=/^(@([\w-]+)\/([\w\-.]+)#)?([\w-]+)$/,ge=e=>`https://dash.readme.com/api/v1/api-registry/${e}`,_e=`readme`,ve=e=>{let t=e.match(he);if(!t)throw Error(`Invalid ReadMe shorthand format. Expected "${_e}:@organization/project#uuid" or "${_e}:uuid", received: ${_e}:${e}`);let[,,n,r,i]=t;if(!i)throw Error(`The ReadMe UUID cannot be empty.`);return{organization:n,project:r,uuid:i}},ye=e=>{let t=ve(e.slice(`${_e}:`.length));return{...t,path:ge(t.uuid),registry:`readme`}},be=/^(@[\w-]+)\/([\w.-]+)$/,xe=(e,t)=>`https://registry.scalar.com/${e}/apis/${t}/latest?format=json`,Se=`scalar`,Ce=e=>{let t=e.match(be);if(!t)throw Error(`Invalid Scalar shorthand format. Expected "${Se}:@organization/project", received: ${Se}:${e}`);let[,n,r]=t;if(!n)throw Error(`The Scalar organization cannot be empty.`);if(!r)throw Error(`The Scalar project cannot be empty.`);return{organization:n,project:r}},we=e=>{let t=Ce(e.slice(`${Se}:`.length));return{...t,path:xe(t.organization,t.project),registry:`scalar`}},Te=e=>{if(e.path.startsWith(`readme:`)){Object.assign(e,ye(e.path));return}if(e.path.startsWith(`scalar:`)){Object.assign(e,we(e.path));return}if(e.path.startsWith(`.`))return;if(e.path.startsWith(de)){e.path=e.path.slice(23),Object.assign(e,me(e));return}let t=e.path.split(`/`);if(t.length===2&&t.filter(Boolean).length===2){Object.assign(e,me(e));return}},Ee={enabled:!1,interval:1e3,timeout:6e4},De=e=>{let t={...Ee};return typeof e.path==`string`&&(typeof e.watch==`boolean`?t.enabled=e.watch:typeof e.watch==`number`?(t.enabled=!0,t.interval=e.watch):e.watch&&(t={...t,...e.watch})),t},Oe=e=>{let t=e.input instanceof Array?e.input:[e.input],n=[];for(let r of t){let t={path:``,watch:Ee};typeof r==`string`?t.path=r:r&&(r.path!==void 0||r.organization!==void 0)?(t={...t,path:de,...r},t.watch!==void 0&&(t.watch=De(t))):t={...t,path:r},typeof t.path==`string`&&Te(t),e.watch!==void 0&&t.watch.enabled===Ee.enabled&&t.watch.interval===Ee.interval&&t.watch.timeout===Ee.timeout&&(t.watch=De({path:t.path,watch:e.watch})),t.path&&n.push(t)}return n},ke=e=>{let t={file:!0,level:`info`,path:process.cwd()};return typeof e?.logs==`string`?t.path=e.logs:t={...t,...e?.logs},t},Ae=(e,t)=>{let n=e||{},r=t||{};return{...n,...r}},je=(e,t)=>{let n=e||{},r=t||{},i={...n,...r};return typeof i.logs==`object`&&(i.logs=Ae(n.logs,r.logs)),i},Me=e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&typeof e!=`function`,Ne=(e,t)=>{for(let[n,r]of Object.entries(t))r!==void 0&&r!==``&&(e[n]=r);return e},Pe=({defaultValue:e,mappers:t,value:n})=>{let r={...e};switch(typeof n){case`boolean`:if(t&&`boolean`in t){let e=t.boolean;r=Ne(r,e(n))}break;case`function`:if(t&&`function`in t){let e=t.function;r=Ne(r,e(n))}break;case`number`:if(t&&`number`in t){let e=t.number;r=Ne(r,e(n))}break;case`string`:if(t&&`string`in t){let e=t.string;r=Ne(r,e(n))}break;case`object`:if(Me(n))if(t&&`object`in t&&typeof t.object==`function`){let i=t.object;r=Ne(r,i(n,e))}else r=Ne(r,n);break}return r},Fe=e=>{if(e.output instanceof Array)throw Error(`Unexpected array of outputs in user configuration. This should have been expanded already.`);let t=Pe({defaultValue:{clean:!0,fileName:{case:`preserve`,name:`{{name}}`,suffix:`.gen`},format:null,indexFile:!0,lint:null,path:``},mappers:{object:(e,t)=>({...e,fileName:Pe({defaultValue:{...t.fileName},mappers:{function:e=>({name:e}),string:e=>({name:e})},value:e.fileName})}),string:e=>({path:e})},value:e.output});return t.tsConfig=ne(te(t.tsConfigPath)),t.importFileExtension===void 0&&t.tsConfig?.options.moduleResolution===l.ModuleResolutionKind.NodeNext&&(t.importFileExtension=`.js`),t.importFileExtension&&!t.importFileExtension.startsWith(`.`)&&(t.importFileExtension=`.${t.importFileExtension}`),t},Ie=e=>{let t=e?s.dirname(e):process.cwd();for(;t!==s.dirname(t);){let e=s.join(t,`package.json`);if(o.existsSync(e))try{let t=JSON.parse(o.readFileSync(e,`utf8`));return{...t.dependencies,...t.devDependencies,...t.peerDependencies,...t.optionalDependencies}}catch{}let n=s.dirname(t);if(n===t)break;t=n}return{}},Le=[`after`,`before`,`cursor`,`offset`,`page`,`start`],Re=e=>Pe({defaultValue:{hooks:{},pagination:{keywords:Le},transforms:{enums:{case:`PascalCase`,enabled:!1,mode:`root`,name:`{{name}}Enum`},propertiesRequiredByDefault:!1,readWrite:{enabled:!0,requests:{case:`preserve`,name:`{{name}}Writable`},responses:{case:`preserve`,name:`{{name}}`}}},validate_EXPERIMENTAL:!1},mappers:{object:(e,t)=>({...e,pagination:Pe({defaultValue:{...t.pagination},value:e.pagination}),transforms:Pe({defaultValue:{...t.transforms},mappers:{object:(e,t)=>({...e,enums:Pe({defaultValue:{...t.enums,enabled:e.enums===void 0?t.enums.enabled:!!e.enums},mappers:{boolean:e=>({enabled:e}),string:e=>({mode:e})},value:e.enums}),propertiesRequiredByDefault:e.propertiesRequiredByDefault===void 0?t.propertiesRequiredByDefault:e.propertiesRequiredByDefault,readWrite:Pe({defaultValue:{...t.readWrite,enabled:e.readWrite===void 0?t.readWrite.enabled:!!e.readWrite},mappers:{boolean:e=>({enabled:e}),object:(e,t)=>({...e,requests:Pe({defaultValue:{...t.requests},mappers:{function:e=>({name:e}),string:e=>({name:e})},value:e.requests}),responses:Pe({defaultValue:{...t.responses},mappers:{function:e=>({name:e}),string:e=>({name:e})},value:e.responses})})},value:e.readWrite})})},value:e.transforms}),validate_EXPERIMENTAL:e.validate_EXPERIMENTAL===!0?`warn`:e.validate_EXPERIMENTAL})},value:e.parser}),ze=e=>t=>({...e,config:{...e.config,...t}}),y={boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},Be=/[\p{Lu}]/u,Ve=/[\p{Ll}]/u,He=/([\p{Alpha}\p{N}_]|$)/u,Ue=/[_.\- `\\[\]{}\\/]+/,We=RegExp(`^${Ue.source}`),Ge=RegExp(`${Ue.source}${He.source}`,`gu`),Ke=RegExp(`\\d+${He.source}`,`gu`),qe=({case:e,string:t})=>{let n=!1,r=!1,i=!1,a=!1,o=e===`snake_case`||e===`SCREAMING_SNAKE_CASE`?`_`:`-`;for(let e=0;e<t.length;e++){let s=t[e];a=e>2?t[e-3]===o:!0;let c=e+1,l=t[c];for(Ue.lastIndex=0;l&&Ue.test(l);)c+=1,l=t[c];let u=c!==e+1;if(Ve.lastIndex=0,Be.lastIndex=0,Be.test(s)&&(n||l&&!u&&l!==`s`&&Ve.test(l)))t=`${t.slice(0,e)}${o}${t.slice(e)}`,e++,i=r,n=!1,r=!0;else if(r&&i&&Ve.test(s)&&!a&&!(s===`s`&&(!l||l.toLocaleLowerCase()!==l)))t=`${t.slice(0,e-1)}${o}${t.slice(e-1)}`,i=r,n=!0,r=!1;else{let e=s.toLocaleLowerCase(),t=s.toLocaleUpperCase();i=r,n=e===s&&t!==s,r=t===s&&e!==s}}return t},b=({case:e,stripLeadingSeparators:t=!0,value:n})=>{let r=n.trim();return r.length?!e||e===`preserve`?r:r.length===1?(Ue.lastIndex=0,Ue.test(r)?``:e===`PascalCase`||e===`SCREAMING_SNAKE_CASE`?r.toLocaleUpperCase():r.toLocaleLowerCase()):(r!==r.toLocaleLowerCase()&&(r=qe({case:e,string:r})),(t||r[0]!==n[0])&&(r=r.replace(We,``)),r=e===`SCREAMING_SNAKE_CASE`?r.toLocaleUpperCase():r.toLocaleLowerCase(),e===`PascalCase`&&(r=`${r.charAt(0).toLocaleUpperCase()}${r.slice(1)}`),e===`snake_case`||e===`SCREAMING_SNAKE_CASE`?(r=r.replaceAll(Ge,(e,n,r)=>r===0&&!t?e:`_${n}`),r[r.length-1]===`_`&&(r=r.slice(0,r.length-1))):(Ge.lastIndex=0,Ke.lastIndex=0,r=r.replaceAll(Ke,(e,t,n)=>[`_`,`-`,`.`].includes(r.charAt(n+e.length))?e:e.toLocaleUpperCase()),r=r.replaceAll(Ge,(e,r,i)=>i===0&&!t&&e[0]&&n.startsWith(e[0])?e:r.toLocaleUpperCase())),r):``},x=({config:e,name:t})=>{if(typeof e.name==`function`)t=e.name(t);else if(e.name){let n=e.case===`preserve`?``:`-`;t=e.name.replace(`{{name}}`,`${n}${t}${n}`)}return b({case:e.case,value:t})},Je=({context:e,parameter:t})=>{if(!t.pagination)return;if(t.pagination===!0)return t.schema;let n=t.schema;return n.$ref&&(n=e.resolveIrRef(n.$ref)),n.properties[t.pagination]},Ye=e=>{for(let t in e)if(e[t].required)return!0;return!1},Xe=e=>e?!!(Ye(e.cookie)||Ye(e.header)||Ye(e.path)||Ye(e.query)):!1,Ze=({context:e,parameters:t})=>{if(t){for(let n in t.cookie){let r=t.cookie[n];if(r.pagination)return{in:r.location,name:r.pagination===!0?r.name:`${r.name}.${r.pagination}`,schema:Je({context:e,parameter:r})}}for(let n in t.header){let r=t.header[n];if(r.pagination)return{in:r.location,name:r.pagination===!0?r.name:`${r.name}.${r.pagination}`,schema:Je({context:e,parameter:r})}}for(let n in t.path){let r=t.path[n];if(r.pagination)return{in:r.location,name:r.pagination===!0?r.name:`${r.name}.${r.pagination}`,schema:Je({context:e,parameter:r})}}for(let n in t.query){let r=t.query[n];if(r.pagination)return{in:r.location,name:r.pagination===!0?r.name:`${r.name}.${r.pagination}`,schema:Je({context:e,parameter:r})}}}},S=({detectFormat:e=!0,schema:t})=>{if(!t.items)return t;let n=[],r=[];for(let i of t.items){if(!i.type&&i.items||t.type===`tuple`){n.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 t=i.const===void 0?``:`const-${i.const}`,a=i.format!==void 0&&e?`format-${i.format}`:``,o=[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(``),s=`${i.$ref??``}${i.type??``}${t}${a}${o}`;r.includes(s)||(r.push(s),n.push(i));continue}n.push(i)}let i={...t};if(i.items=n,i.items.length<=1&&i.type!==`array`&&i.type!==`enum`&&i.type!==`tuple`){let e=i.items[0];delete i.logicalOperator,delete i.items,i={...i,...e}}return i.type===`unknown`?{}:i},C=({items:e,logicalOperator:t=`or`,mutateSchemaOneItem:n=!1,schema:r})=>e.length?r.type===`tuple`?(r.items=e,r):e.length===1?n?(r={...r,...e[0]},r):(r.items=e,r):(r.items=e,r.logicalOperator=t,r):r,Qe=e=>!!(Xe(e.parameters)||e.body?.required),w=({method:e,path:t})=>`${e.toUpperCase()} ${t}`,$e=({context:e,operation:t})=>{let n=t.body;if(!n||!n.pagination)return Ze({context:e,parameters:t.parameters});if(n.pagination===!0)return{in:`body`,name:`body`,schema:n.schema};let r=n.schema,i=r.$ref?e.resolveIrRef(r.$ref):r,a=(`schema`in i?i.schema:i)?.properties?.[n.pagination];return a?{in:`body`,name:n.pagination,schema:a}:Ze({context:e,parameters:t.parameters})},et=({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`}},tt=e=>{let t={};if(!e.responses)return t;let n={properties:{},type:`object`},r={properties:{},type:`object`},i;for(let t in e.responses){let a=e.responses[t];switch(et({statusCode:t})){case`1XX`:case`3XX`:break;case`2XX`:r.properties[t]=a.schema;break;case`4XX`:case`5XX`:n.properties[t]=a.schema;break;case`default`:i=a;break}}if(i){let e=!1;Object.keys(r.properties).length||(r.properties.default=i.schema,e=!0);let t=(i.schema.description??``).toLocaleLowerCase(),a=(i.schema.$ref??``).toLocaleLowerCase();[`success`].some(e=>t.includes(e)||a.includes(e))&&(r.properties.default=i.schema,e=!0),[`error`,`problem`].some(e=>t.includes(e)||a.includes(e))&&(n.properties.default=i.schema,e=!0),e||(n.properties.default=i.schema)}let a=Object.keys(n.properties);if(a.length){n.required=a,t.errors=n;let e=C({items:Object.values(n.properties),mutateSchemaOneItem:!0,schema:{}});e=S({schema:e}),Object.keys(e).length&&e.type!==`unknown`&&(t.error=e)}let o=Object.keys(r.properties);if(o.length){r.required=o,t.responses=r;let e=C({items:Object.values(r.properties),mutateSchemaOneItem:!0,schema:{}});e=S({schema:e}),Object.keys(e).length&&e.type!==`unknown`&&(t.response=e)}return t},nt=e=>e.replace(/^[^\p{ID_Start}]+/u,``).replace(/[^$\u200c\u200d\p{ID_Continue}]/gu,`-`).replace(/[$+]/g,`-`),rt=e=>{let t=T(e);return t.name===`@hey-api/client-axios`||t.name===`@hey-api/client-nuxt`?`baseURL`:`baseUrl`},T=e=>{for(let t of e.pluginOrder){let n=e.plugins[t];if(n?.tags?.includes(`client`))return n}return{config:{name:``},name:``}},E=e=>({value:e}),D=e=>{let t={};for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=E(e[n]));return t},it=/^[^$_\p{ID_Start}]+/u,at=/^-?\d+(\.\d+)?$/,ot=/^(document|history|location|navigator|window)$/g,st=/^(console|Array|Date|Error|Function|JSON|Map|Math|Object|Promise|RegExp|Set|WeakMap|WeakSet)$/g,ct=/^(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,lt=/^(global|process|Buffer)$/g,ut=/^(any|as|bigint|boolean|namespace|never|null|number|string|symbol|type|undefined|unknown|void)$/g,dt=/^[$_\p{ID_Start}][$\u200c\u200d\p{ID_Continue}]*$/u,ft=e=>(e||e===``)&&(dt.lastIndex=0,!dt.test(e))?`'${e}'`:e,pt=e=>e&&e.startsWith(`'`)&&e.endsWith(`'`)?e.slice(1,e.length-1):e,mt=e=>e.replace(/\*\//g,`*`).replace(/\/\*/g,`*`).replace(/\r?\n(.*)/g,(e,t)=>u+t.trim()),ht=l.createPrinter({newLine:l.NewLineKind.LineFeed,removeComments:!1}),gt=(e=>l.createSourceFile(``,e,l.ScriptTarget.ESNext,!1,l.ScriptKind.TS))(``),_t=e=>e.replace(/\\u([0-9a-fA-F]{4})/g,(e,t)=>String.fromCharCode(Number.parseInt(t,16)));function vt({node:e,unescape:t=!1}){let n=ht.printNode(l.EmitHint.Unspecified,e,gt);if(!t)return n;try{return _t(n)}catch{return n}}const O=e=>l.factory.createIdentifier(typeof e==`string`?e:e.text),yt=e=>{switch(e){case`!`:return l.SyntaxKind.ExclamationToken;case`-`:return l.SyntaxKind.MinusToken}},bt=({expression:e,prefix:t})=>{let n=typeof e==`string`?O(e):e,r=typeof t==`string`?yt(t):t;return l.factory.createPrefixUnaryExpression(r,n)},xt=()=>l.factory.createThis(),k=({keyword:e})=>{let t=Mt({keyword:e});return l.factory.createModifier(t)},St=({initializer:e,modifiers:t,name:n,type:r})=>{let i=Array.isArray(t)?t:[t];return l.factory.createPropertyDeclaration(t?i.map(e=>k({keyword:e})):void 0,n,void 0,r,e)},Ct={boolean:e=>e?l.factory.createTrue():l.factory.createFalse(),export:({alias:e,asType:t=!1,name:n})=>{let r=O(n);if(e){let n=O(e);return l.factory.createExportSpecifier(t,r,n)}return l.factory.createExportSpecifier(t,void 0,r)},import:({alias:e,asType:t=!1,name:n})=>{let r=O(n);if(e){let n=O(e);return l.factory.createImportSpecifier(t,r,n)}return l.factory.createImportSpecifier(t,void 0,r)},number:e=>e<0?bt({expression:l.factory.createNumericLiteral(Math.abs(e)),prefix:`-`}):l.factory.createNumericLiteral(e),string:(e,t=!1)=>{let n=e;t&&(n=pt(n));let r=n.includes(`'`)&&n.includes(`"`),i=n.includes(`
2
+ `),a=n.startsWith("`"),o=n.startsWith("\\`")&&n.endsWith("\\`");return(i||r||a)&&!o&&(n=`\`${n.replace(/(?<!\\)`/g,"\\`").replace(/\${/g,"\\${")}\``),n.startsWith("`")?O(n):Xt({text:n})}},wt=e=>typeof e==`object`&&!!e&&typeof e.kind==`number`&&typeof e.flags==`number`&&typeof e.pos==`number`&&typeof e.end==`number`,Tt=e=>e!==void 0,Et=({commentObject:e,node:t})=>{let n=e.lines.filter(e=>!!e||e===``);if(!n.length)return;if(!e.jsdoc){for(let e of n)l.addSyntheticLeadingComment(t,l.SyntaxKind.SingleLineCommentTrivia,` ${e}`,!0);return}let r=n.map((e,t)=>{let r=e;return t!==n.length&&(r=`${r}\n`),l.factory.createJSDocText(r)}),i=vt({node:l.factory.createJSDocComment(l.factory.createNodeArray(r),void 0),unescape:!0}).replace(`/*`,``).replace(`* */`,``);l.addSyntheticLeadingComment(t,l.SyntaxKind.MultiLineCommentTrivia,i,!0)},A=({comments:e=[],node:t})=>{let n=!!e.find(e=>typeof e==`object`&&e),r=e;n||(r=[{jsdoc:!0,lines:e}]);for(let e of r)Et({commentObject:e,node:t})},j=(e,t)=>l.isTypeNode(e)?e:typeof e==`number`?l.factory.createLiteralTypeNode(Ct.number(e)):en({typeArguments:t?.map(e=>j(e)),typeName:l.isIdentifier(e)?e.text:e}),Dt=({expression:e,name:t})=>l.factory.createPropertyAccessChain(e,l.factory.createToken(l.SyntaxKind.QuestionDotToken),t),Ot=({expression:e,isOptional:t,name:n})=>{let r=typeof e==`string`?O({text:e}):e;if(t&&typeof n!=`number`)return Dt({expression:r,name:n});if(typeof n==`string`){if(dt.lastIndex=0,!dt.test(n)){!n.startsWith(`'`)&&!n.endsWith(`'`)&&(n=`\'${n}\'`);let e=O({text:n});return l.factory.createElementAccessExpression(r,e)}let e=O({text:n});return l.factory.createPropertyAccessExpression(r,e)}if(typeof n==`number`){let e=l.factory.createNumericLiteral(n);return l.factory.createElementAccessExpression(r,e)}return l.factory.createPropertyAccessExpression(r,n)},kt=()=>l.factory.createNull(),At=({identifiers:e=[],isValueAccess:t,shorthand:n,unescape:r,value:i})=>{if(i===null)return kt();if(Array.isArray(i))return Vt({elements:i});if(typeof i==`object`)return Wt({identifiers:e,obj:i,shorthand:n});if(typeof i==`number`)return Ct.number(i);if(typeof i==`boolean`)return Ct.boolean(i);if(typeof i==`string`){if(t){let e=i.split(`.`);return Ot({expression:e[0],name:e[1]})}return Ct.string(i,r)}},jt=e=>e.map(e=>{if(`destructure`in e)return nn({name:l.factory.createObjectBindingPattern(e.destructure.map(e=>{if(!(`destructure`in e))return l.factory.createBindingElement(void 0,void 0,O({text:e.name}),void 0)}).filter(Boolean)),type:e.type===void 0?void 0:j(e.type)});let t=e.accessLevel?[k({keyword:e.accessLevel})]:[];return e.isReadOnly&&t.push(k({keyword:`readonly`})),nn({initializer:e.default===void 0?void 0:At({value:e.default}),modifiers:t,name:O({text:e.name}),required:e.isRequired!==!1,type:e.type===void 0?void 0:j(e.type)})}),Mt=({keyword:e})=>{switch(e){case`any`:return l.SyntaxKind.AnyKeyword;case`async`:return l.SyntaxKind.AsyncKeyword;case`boolean`:return l.SyntaxKind.BooleanKeyword;case`export`:return l.SyntaxKind.ExportKeyword;case`never`:return l.SyntaxKind.NeverKeyword;case`number`:return l.SyntaxKind.NumberKeyword;case`private`:return l.SyntaxKind.PrivateKeyword;case`protected`:return l.SyntaxKind.ProtectedKeyword;case`public`:return l.SyntaxKind.PublicKeyword;case`readonly`:return l.SyntaxKind.ReadonlyKeyword;case`static`:return l.SyntaxKind.StaticKeyword;case`string`:return l.SyntaxKind.StringKeyword;case`undefined`:return l.SyntaxKind.UndefinedKeyword;case`unknown`:return l.SyntaxKind.UnknownKeyword;case`void`:return l.SyntaxKind.VoidKeyword;default:throw Error(`unsupported syntax kind keyword "${e}"`)}},Nt=({keyword:e})=>{let t=Mt({keyword:e});return l.factory.createKeywordTypeNode(t)},Pt=e=>e.map(e=>l.isTypeParameterDeclaration(e)?e:It({constraint:e.extends?typeof e.extends==`string`?Nt({keyword:`boolean`}):e.extends:void 0,defaultType:e.default===void 0?void 0:wt(e.default)?e.default:l.factory.createLiteralTypeNode(e.default?l.factory.createTrue():l.factory.createFalse()),name:e.name})),Ft=({operator:e,type:t})=>{let n=e===`keyof`?l.SyntaxKind.KeyOfKeyword:e===`readonly`?l.SyntaxKind.ReadonlyKeyword:l.SyntaxKind.UniqueKeyword;return l.factory.createTypeOperatorNode(n,t)},It=({constraint:e,defaultType:t,modifiers:n,name:r})=>l.factory.createTypeParameterDeclaration(n,r,e,t),Lt=({members:e,nameType:t,questionToken:n,readonlyToken:r,type:i,typeParameter:a})=>l.factory.createMappedTypeNode(r,a,t,n,i,e),Rt=({literal:e})=>l.factory.createLiteralTypeNode(e),zt=({async:e,comment:t,multiLine:n,parameters:r=[],returnType:i,statements:a=[],types:o=[]})=>{let s=l.factory.createArrowFunction(e?[k({keyword:`async`})]:void 0,o?Pt(o):void 0,jt(r),i?j(i):void 0,void 0,Array.isArray(a)?sn({multiLine:n,statements:a}):a);return A({comments:t,node:s}),s},Bt=({async:e,comment:t,multiLine:n,parameters:r=[],returnType:i,statements:a=[],types:o=[]})=>{let s=l.factory.createFunctionExpression(e?[k({keyword:`async`})]:void 0,void 0,void 0,o?Pt(o):void 0,jt(r),i?j(i):void 0,sn({multiLine:n,statements:a}));return A({comments:t,node:s}),s},Vt=({elements:e,multiLine:t=!1})=>l.factory.createArrayLiteralExpression(e.map(e=>wt(e)?e:At({value:e})).filter(Tt),t||!Array.isArray(e[0])&&typeof e[0]==`object`),Ht=({expression:e})=>l.factory.createAwaitExpression(e),Ut=({parameters:e=[],returnType:t,typeParameters:n})=>l.factory.createFunctionTypeNode(n,e,t),Wt=({comments:e,identifiers:t=[],multiLine:n=!0,obj:r,shorthand:i,unescape:a=!1})=>{let o=Array.isArray(r)?r.map(e=>{let r=!1;if(`key`in e){let{key:t}=e;r=t===e.value,(t.match(/^[0-9]/)&&t.match(/\D+/g)||t.match(/\W/g)||t===``)&&!t.startsWith(`'`)&&!t.endsWith(`'`)&&(e.key=`'${t}'`)}let o;if(`spread`in e){let t=wt(e.spread)?e.spread:O({text:e.spread});o=l.factory.createSpreadAssignment(e.assertion?un({expression:t,type:typeof e.assertion==`string`?Nt({keyword:e.assertion}):e.assertion}):t)}else if(e.shorthand||i&&r)o=l.factory.createShorthandPropertyAssignment(e.value);else{let r=wt(e.value)?e.value:Array.isArray(e.value)&&(!e.value.length||typeof e.value[0]==`object`)?Wt({multiLine:n,obj:e.value,shorthand:i,unescape:a}):At({identifiers:t.includes(e.key)?Object.keys(e.value):[],isValueAccess:e.isValueAccess,shorthand:i,unescape:a,value:e.value});if(!r)return;t.includes(e.key)&&!l.isObjectLiteralExpression(r)&&(r=O({text:e.value})),o=cn({initializer:r,name:e.key})}return A({comments:e.comments,node:o}),o}).filter(Tt):Object.entries(r).map(([e,n])=>{let r=At({identifiers:t.includes(e)?Object.keys(n):[],shorthand:i,unescape:a,value:n});if(!r)return;t.includes(e)&&!l.isObjectLiteralExpression(r)&&(r=O({text:n}));let o=e===n;return e.match(/^[0-9]/)&&e.match(/\D+/g)&&!e.startsWith(`'`)&&!e.endsWith(`'`)&&(e=`'${e}'`),e.match(/\W/g)&&!e.startsWith(`'`)&&!e.endsWith(`'`)&&(e=`'${e}'`),i&&o?l.factory.createShorthandPropertyAssignment(n):cn({initializer:r,name:e})}).filter(Tt),s=l.factory.createObjectLiteralExpression(o,n);return A({comments:e,node:s}),s},Gt=({asConst:e,comments:t={},leadingComment:n,name:r,obj:i})=>{let a=Array.isArray(i)?i.map(e=>{let t=Kt({initializer:At({value:e.value}),name:e.key});return A({comments:e.comments,node:t}),t}):Object.entries(i).map(([e,n])=>{let r=l.factory.createEnumMember(e,At({unescape:!0,value:n}));return A({comments:t[e],node:r}),r}),o=[k({keyword:`export`})],s=e?[l.factory.createToken(l.SyntaxKind.ConstKeyword)]:[],c=[...o,...s],u=l.factory.createEnumDeclaration(c,typeof r==`string`?O({text:r}):r,a);return A({comments:n,node:u}),u},Kt=({initializer:e,name:t})=>{let n=t;return typeof n==`string`&&(n=n.includes(`'`)?Xt({isSingleQuote:!1,text:n}):ft(n)),l.factory.createEnumMember(n,e)},qt=({name:e,statements:t})=>l.factory.createModuleDeclaration([k({keyword:`export`})],O({text:e}),l.factory.createModuleBlock(t),l.NodeFlags.Namespace),Jt=({indexType:e,objectType:t})=>l.factory.createIndexedAccessTypeNode(t,e),Yt=({modifiers:e,name:t,returnType:n,statements:r})=>{let i=Array.isArray(e)?e:[e];return l.factory.createGetAccessorDeclaration(e?i.map(e=>k({keyword:e})):void 0,t,[],n?en({typeName:n}):void 0,sn({statements:r}))},Xt=({isSingleQuote:e,text:t})=>(e===void 0&&(e=!t.includes(`'`)),l.factory.createStringLiteral(t,e)),Zt=({condition:e,whenFalse:t,whenTrue:n})=>l.factory.createConditionalExpression(e,l.factory.createToken(l.SyntaxKind.QuestionToken),n,l.factory.createToken(l.SyntaxKind.ColonToken),t),Qt=({text:e})=>l.factory.createTypeOfExpression(typeof e==`string`?O({text:e}):e),$t=({comment:e,exportType:t,name:n,type:r,typeParameters:i=[]})=>{let a=l.factory.createTypeAliasDeclaration(t?[k({keyword:`export`})]:void 0,typeof n==`string`?O({text:n}):n,Pt(i),j(r));return A({comments:e,node:a}),a},en=({typeArguments:e,typeName:t})=>l.factory.createTypeReferenceNode(t,e),tn=({type:e})=>l.factory.createParenthesizedType(e),nn=({initializer:e,modifiers:t,name:n,required:r=!0,type:i})=>l.factory.createParameterDeclaration(t,void 0,n,r?void 0:l.factory.createToken(l.SyntaxKind.QuestionToken),i,e),rn=({argumentsArray:e,expression:t,typeArguments:n})=>l.factory.createNewExpression(t,n,e),an=({awaitModifier:e,expression:t,initializer:n,statement:r})=>l.factory.createForOfStatement(e,n,t,r),on=({left:e,right:t})=>l.factory.createAssignment(e,t),sn=({multiLine:e=!0,statements:t})=>l.factory.createBlock(t,e),cn=({initializer:e,name:t})=>l.factory.createPropertyAssignment(t,e),ln=({flags:e=[],text:t})=>{let n=`/${(t.startsWith(`/`)&&t.endsWith(`/`)?t.slice(1,-1):t).replace(/(?<!\\)\//g,`\\/`)}/`;return l.factory.createRegularExpressionLiteral(`${n}${e.join(``)}`)},un=({expression:e,type:t})=>l.factory.createAsExpression(e,t),dn=({value:e})=>{let t=[],n=``;for(let r of e.slice(0).reverse())if(typeof r==`string`)n=`${r}${n}`;else{let e=t.length?l.factory.createTemplateMiddle(n):l.factory.createTemplateTail(n),i=l.factory.createTemplateLiteralTypeSpan(r,e);t.push(i),n=``}return l.factory.createTemplateLiteralType(l.factory.createTemplateHead(n),t.reverse())},fn=({module:e,shouldAppendJs:t})=>l.factory.createExportDeclaration(void 0,!1,void 0,Ct.string(t?`${e}.js`:e)),pn=({functionName:e,parameters:t=[],types:n})=>{let r=typeof e==`string`?O({text:e}):e,i=t.filter(e=>e!==void 0).map(e=>typeof e==`string`?O({text:e}):e);return l.factory.createCallExpression(r,n,i)},mn=({exports:e,module:t})=>{let n=Array.isArray(e)?e:[e],r=n.some(e=>typeof e!=`object`||!e.asType),i=n.map(e=>{let t=typeof e==`string`?{name:e}:e;return Ct.export({alias:t.alias,asType:r&&t.asType,name:t.name})}),a=l.factory.createNamedExports(i),o=Ct.string(t);return l.factory.createExportDeclaration(void 0,!r,a,o)},hn=({assertion:e,comment:t,destructure:n,exportConst:r,expression:i,name:a,typeName:o})=>{let s=e?un({expression:i,type:typeof e==`string`?en({typeName:e}):e}):i,c=typeof a==`string`?O({text:a}):a,u=l.factory.createVariableDeclaration(n?l.factory.createObjectBindingPattern([l.factory.createBindingElement(void 0,void 0,c,void 0)]):c,void 0,o?typeof o==`string`?en({typeName:o}):o:void 0,s),d=l.factory.createVariableStatement(r?[k({keyword:`export`})]:void 0,l.factory.createVariableDeclarationList([u],l.NodeFlags.Const));return A({comments:t,node:d}),d},gn=({imports:e,module:t})=>{let n=Array.isArray(e)?e:[e],r=n.some(e=>typeof e!=`object`||!e.asType),i,a=[];n.forEach(e=>{let t=typeof e==`string`?{name:e}:e;t.name===`*`&&t.alias?i=t:a.push(Ct.import({alias:t.alias,asType:r&&t.asType,name:t.name}))});let o=i?l.factory.createNamespaceImport(O({text:i.alias})):l.factory.createNamedImports(a),s=l.factory.createImportClause(!r,void 0,o),c=Ct.string(t);return l.factory.createImportDeclaration(void 0,s,c)},_n=({accessLevel:e,comment:t,multiLine:n=!0,parameters:r=[],statements:i=[]})=>{let a=e?[k({keyword:e})]:void 0,o=l.factory.createConstructorDeclaration(a,jt(r),sn({multiLine:n,statements:i}));return A({comments:t,node:o}),o},vn=({accessLevel:e,comment:t,isStatic:n=!1,multiLine:r=!0,name:i,parameters:a=[],returnType:o,statements:s=[],types:c=[]})=>{let u=e?[k({keyword:e})]:[];n&&u.push(k({keyword:`static`}));let d=l.factory.createMethodDeclaration(u,void 0,O({text:i}),void 0,c?Pt(c):void 0,jt(a),o?j(o):void 0,sn({multiLine:r,statements:s}));return A({comments:t,node:d}),d},yn=({decorator:e,exportClass:t,extendedClasses:n,name:r,nodes:i,typeParameters:a})=>{let o=[];t&&o.push(k({keyword:`export`})),e&&o.unshift(l.factory.createDecorator(pn({functionName:e.name,parameters:e.args.map(e=>At({value:e})).filter(Tt)})));let s=[];if(n)for(let e of n)s.push(l.factory.createHeritageClause(l.SyntaxKind.ExtendsKeyword,[l.factory.createExpressionWithTypeArguments(O({text:e}),void 0)]));return l.factory.createClassDeclaration(o,O({text:r}),a,s,i)},bn=({expression:e})=>l.factory.createExpressionStatement(e),xn=({expression:e})=>l.factory.createReturnStatement(e),Sn=({args:e=[],name:t,types:n=[]})=>{let r=n.map(e=>en({typeName:e}));return xn({expression:pn({functionName:t,parameters:e.map(e=>l.isExpression(e)?e:O({text:e})).filter(Tt),types:r})})},Cn=({expression:e})=>xn({expression:typeof e==`string`?O({text:e}):e}),wn=e=>e.slice(1).reduce((e,t)=>(dt.lastIndex=0,dt.test(t)?Dt({expression:e,name:t}):l.factory.createElementAccessChain(e,l.factory.createToken(l.SyntaxKind.QuestionDotToken),O({text:t}))),O({text:e[0]})),Tn=e=>e.slice(1).reduce((e,t)=>Ot({expression:e,name:t}),O({text:e[0]})),En=({expressions:e})=>e.reduce((e,t)=>Ot({expression:e,name:t})),Dn=({left:e,operator:t=`=`,right:n})=>l.factory.createBinaryExpression(e,t===`=`?l.SyntaxKind.EqualsToken:t===`===`?l.SyntaxKind.EqualsEqualsEqualsToken:t===`!==`?l.SyntaxKind.ExclamationEqualsEqualsToken:t===`??`?l.SyntaxKind.QuestionQuestionToken:l.SyntaxKind.InKeyword,typeof n==`string`?O({text:n}):n),On=({elseStatement:e,expression:t,thenStatement:n})=>l.factory.createIfStatement(t,n,e),kn=({path:e})=>{let t=wn(e),n=Tn(e);return On({expression:t,thenStatement:sn({statements:[bn({expression:Dn({left:n,right:rn({argumentsArray:[n],expression:O({text:`Date`})})})})]})})},An=({path:e,transformerName:t})=>[On({expression:wn(e),thenStatement:sn({statements:[bn({expression:pn({functionName:t,parameters:[Tn(e)]})})]})})],jn=({path:e,transformerName:t})=>{let n=wn(e),r=Tn(e);return On({expression:pn({functionName:Ot({expression:`Array`,name:`isArray`}),parameters:[n]}),thenStatement:sn({statements:[bn({expression:l.factory.createCallChain(Ot({expression:r,name:`forEach`}),void 0,void 0,[O({text:t})])})]})})},Mn=({parameterName:e})=>{let t=O({text:`Date`});return rn({argumentsArray:[O({text:e})],expression:t})},Nn=({path:e,transformExpression:t})=>{let n=wn(e),r=Tn(e);return On({expression:pn({functionName:Ot({expression:`Array`,name:`isArray`}),parameters:[n]}),thenStatement:sn({statements:[bn({expression:Dn({left:r,right:l.factory.createCallChain(Ot({expression:r,name:`map`}),void 0,void 0,[zt({parameters:[{name:`item`}],statements:t})])})})]})})},Pn=en({typeName:`null`}),Fn=({isNullable:e,node:t})=>e?l.factory.createUnionTypeNode([t,Pn]):t,In=({indexKey:e,indexProperty:t,isNullable:n,properties:r,useLegacyResolution:i})=>{let a=[],o=r.map(e=>{let t=e.isReadOnly?[k({keyword:`readonly`})]:void 0,n=e.isRequired===!1?l.factory.createToken(l.SyntaxKind.QuestionToken):void 0,r=j(e.type);a.push(r);let o=l.factory.createPropertySignature(t,i||typeof e.name==`string`&&e.name.match(dt)||typeof e.name!=`string`&&l.isPropertyName(e.name)?e.name:Xt({text:e.name}),n,r);return A({comments:e.comment,node:o}),o}),s=!1;if(t)if(!r.length&&e){let n=Lt({questionToken:l.factory.createToken(l.SyntaxKind.QuestionToken),type:t.type??Nt({keyword:`string`}),typeParameter:It({constraint:e,name:O({text:String(t.name)})})});o.push(n),s=!0}else{let e=t.isReadOnly?[k({keyword:`readonly`})]:void 0,n=l.factory.createIndexSignature(e,[nn({name:O({text:String(t.name)}),type:Nt({keyword:`string`})})],j(t.type));o.push(n)}return Fn({isNullable:n,node:s?o[0]:l.factory.createTypeLiteralNode(o)})},Ln=({isNullable:e,types:t})=>{let n=[];for(let e of t){let t=j(e);l.isUnionTypeNode(t)?n.push(...t.types):n.push(t)}return Fn({isNullable:e,node:l.factory.createUnionTypeNode(n)})},M={anonymousFunction:Bt,arrayLiteralExpression:Vt,arrowFunction:zt,asExpression:un,assignment:on,awaitExpression:Ht,binaryExpression:Dn,block:sn,callExpression:pn,classDeclaration:yn,conditionalExpression:Zt,constVariable:hn,constructorDeclaration:_n,enumDeclaration:Gt,exportAllDeclaration:fn,exportNamedDeclaration:mn,expressionToStatement:bn,forOfStatement:an,functionTypeNode:Ut,getAccessorDeclaration:Yt,identifier:O,ifStatement:On,indexedAccessTypeNode:Jt,isTsNode:wt,keywordTypeNode:Nt,literalTypeNode:Rt,mappedTypeNode:Lt,methodDeclaration:vn,namedImportDeclarations:gn,namespaceDeclaration:qt,newExpression:rn,nodeToString:vt,null:kt,objectExpression:Wt,ots:Ct,parameterDeclaration:nn,prefixUnaryExpression:bt,propertyAccessExpression:Ot,propertyAccessExpressions:En,propertyAssignment:cn,propertyDeclaration:St,regularExpressionLiteral:ln,returnFunctionCall:Sn,returnStatement:xn,returnVariable:Cn,safeAccessExpression:wn,stringLiteral:Xt,templateLiteralType:dn,this:xt,transformArrayMap:Nn,transformArrayMutation:jn,transformDateMutation:kn,transformFunctionMutation:An,transformNewDate:Mn,typeAliasDeclaration:$t,typeArrayNode:(e,t=!1)=>Fn({isNullable:t,node:en({typeArguments:[Array.isArray(e)?Ln({types:e}):e],typeName:`Array`})}),typeInterfaceNode:In,typeIntersectionNode:({isNullable:e,types:t})=>{let n=[];for(let e of t){let t=j(e);l.isIntersectionTypeNode(t)?n.push(...t.types):n.push(t)}return Fn({isNullable:e,node:l.factory.createIntersectionTypeNode(n)})},typeNode:j,typeOfExpression:Qt,typeOperatorNode:Ft,typeParameterDeclaration:It,typeParenthesizedNode:tn,typeRecordNode:(e,t,n=!1,r=!0)=>{let i=Ln({types:e}),a=Ln({types:t});return Fn({isNullable:n,node:In({properties:[{name:`[key: ${vt({node:i,unescape:!0})}]`,type:a}],useLegacyResolution:r})})},typeReferenceNode:en,typeTupleNode:({isNullable:e=!1,types:t})=>{let n=t.map(e=>j(e));return Fn({isNullable:e,node:l.factory.createTupleTypeNode(n)})},typeUnionNode:Ln,valueToExpression:At},Rn=M,zn=({config:e,name:t})=>{let n=e.plugins[`@hey-api/sdk`];if(n?.config.classNameBuilder){let e=``;return e=typeof n.config.classNameBuilder==`function`?n.config.classNameBuilder(t):n.config.classNameBuilder.replace(`{{name}}`,t),e}return t},Bn=({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}},Vn=({operation:e,plugin:t})=>{if(!e.security||!t.config.auth)return[];let n=[];for(let t of e.security){let e=Bn({securitySchemeObject:t});e?n.push(e):console.warn(`❗️ SDK warning: unsupported security scheme. Please open an issue if you'd like it added https://github.com/hey-api/openapi-ts/issues\n${JSON.stringify(t,null,2)}`)}return n},Hn=`TComposable`,Un=`DefaultT`,Wn=`ResT`,Gn=/~1/g,Kn=/~0/g,N=e=>{let t=Jn(e),n=t[t.length-1];return decodeURI(n)},qn=e=>String(e).replace(/~/g,`~0`).replace(/\//g,`~1`),Jn=e=>{let t=e.trim();return t.startsWith(`#`)&&(t=t.slice(1)),t.startsWith(`/`)&&(t=t.slice(1)),t?t.split(`/`).map(e=>e.replace(Gn,`/`).replace(Kn,`~`)):[]},Yn=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},Xn=e=>{let t=e.map(qn).join(`/`);return`#`+(t?`/${t}`:``)},Zn=({$ref:e,spec:t})=>{let n=Jn(decodeURI(e)),r=t;for(let t of n){let n=t;if(r[n]===void 0)throw Error(`Reference not found: ${e}`);r=r[n]}return r},Qn=({operation:e})=>{let t=[`header`,`path`,`query`],n={},r=(e,t)=>{n[e]||(n[e]=new Set),n[e].add(t)};for(let n of t){let t=e.parameters?.[n];if(t)for(let e in t){let i=t[e];r(i.name,n)}}if(e.body)if(!e.body.schema.logicalOperator&&e.body.schema.type===`object`&&e.body.schema.properties){let t=e.body.schema.properties;for(let e in t)r(e,`body`)}else e.body.schema.$ref?r(b({case:`camelCase`,value:N(e.body.schema.$ref)}),`body`):r(`body`,`body`);let i=new Set;for(let e in n)n[e].size>1&&i.add(e);let a={},o=[];for(let n of t){let t=e.parameters?.[n];if(t)for(let e in t){let r=t[e],s=r.name,c=i.has(s)?`${n}_${s}`:s,l={isRequired:r.required??!1,name:c,schema:r.schema};c!==s&&(l.originalName=s),a[c]=l,o.push({in:n===`header`?`headers`:n,key:c,...c===s?{}:{map:s}})}}if(e.body){let t=`body`;if(!e.body.schema.logicalOperator&&e.body.schema.type===`object`&&e.body.schema.properties){let n=e.body.schema.properties;for(let e in n){let r=n[e],s=i.has(e)?`${t}_${e}`:e,c={isRequired:r.required?.includes(e)??!1,name:s,schema:r};s!==e&&(c.originalName=e),a[s]=c,o.push({in:t,key:s,...s===e?{}:{map:e}})}}else if(e.body.schema.$ref){let n=b({case:`camelCase`,value:N(e.body.schema.$ref)}),r=i.has(n)?`${t}_${n}`:n,s={isRequired:e.body.required??!1,name:r,schema:e.body.schema};r!==n&&(s.originalName=n),a[r]=s,o.push({key:r,map:`body`})}else a.body={isRequired:e.body.required??!1,name:`body`,schema:e.body.schema},o.push({in:`body`})}if(Object.keys(a).length)return{fields:o,parameters:a}},$n=({operation:e,plugin:t})=>{if(!t.config.validator.request)return;let n=t.getPluginOrThrow(t.config.validator.request);if(n.api.createRequestValidator)return n.api.createRequestValidator({operation:e,plugin:n})},er=({operation:e,plugin:t})=>{if(!t.config.validator.response)return;let n=t.getPluginOrThrow(t.config.validator.response);if(n.api.createResponseValidator)return n.api.createResponseValidator({operation:e,plugin:n})},tr=({context:e,value:t})=>{let n=b({case:`PascalCase`,value:nt(t)});return zn({config:e.config,name:n})},nr=({operation:e,plugin:t})=>t.config.methodNameBuilder?t.config.methodNameBuilder(e):!t.config.asClass&&e.id.match(ct)?`${e.id}_`:e.id,rr=({context:e,operation:t,plugin:n})=>{let r=new Map,i,a,o=[];n.config.classStructure===`auto`&&t.operationId&&(o=t.operationId.split(/[./]/).filter(Boolean),o.length>1&&(a=b({case:`camelCase`,value:nt(o.pop())}),i=o.pop()));let s=n.config.instance?[n.config.instance]:t.tags??[`default`];for(let c of s){let s=tr({context:e,value:i||c}),l=[c];i&&(l=o.includes(c)||c===i?[...o,i]:[c,...o,i]),r.set(c,{className:s,methodName:a||nr({operation:t,plugin:n}),path:l.map(t=>tr({context:e,value:t}))})}return r},ir=({isDataAllowed:e=!0,operation:t,plugin:n,throwOnError:r})=>{let i=T(n.context.config).name===`@hey-api/client-nuxt`,a=e?n.querySymbol({category:`type`,resource:`operation`,resourceId:t.id,role:`data`,tool:`typescript`}):void 0,o=n.referenceSymbol({category:`type`,resource:`client-options`,tool:`sdk`});if(i){let r=n.querySymbol({category:`type`,resource:`operation`,resourceId:t.id,role:`response`}),i=e?a?.placeholder||`unknown`:`never`,s=r?.placeholder||`unknown`;return`${o.placeholder}<${Hn}, ${i}, ${s}, ${Un}>`}if(r){let t=e?a?.placeholder||`unknown`:`never`;return`${o.placeholder}<${t}, ${r}>`}let s=e?a?.placeholder:`never`;return s?`${o.placeholder}<${s}>`:o.placeholder},ar=({isRequiredOptions:e,operation:t,plugin:n})=>{let r={argNames:[],fields:[],parameters:[]},i=n.getPluginOrThrow(`@hey-api/typescript`),a=T(n.context.config).name===`@hey-api/client-nuxt`;if(n.config.paramsStructure===`flat`){let e=Qn({operation:t,plugin:n}),a=[];if(e){let t=!1;for(let n in e.parameters){let r=e.parameters[n];r.isRequired&&(t=!0),a.push({isRequired:r.isRequired,name:r.name,type:i.api.schemaToType({plugin:i,schema:r.schema,state:D({path:[]})})})}r.argNames.push(`parameters`);for(let t of e.fields)r.fields.push(t);r.parameters.push({isRequired:t,name:`parameters`,type:M.typeInterfaceNode({properties:a,useLegacyResolution:!1})})}}return r.parameters.push({isRequired:e,name:`options`,type:ir({isDataAllowed:n.config.paramsStructure===`grouped`,operation:t,plugin:n,throwOnError:a?void 0:`ThrowOnError`})}),r},or=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(e=>t.startsWith(e)))return`blob`;if(t.startsWith(`text/`))return`text`}},sr=({isRequiredOptions:e,opParameters:t,operation:n,plugin:r})=>{let i=T(r.context.config),a=i.name===`@hey-api/client-nuxt`,o=r.querySymbol({category:`type`,resource:`operation`,resourceId:n.id,role:a?`response`:`responses`})?.placeholder||`unknown`,s=r.querySymbol({category:`type`,resource:`operation`,resourceId:n.id,role:a?`error`:`errors`})?.placeholder||`unknown`,c=[];if(n.body)switch(n.body.type){case`form-data`:{let e=r.referenceSymbol({category:`external`,resource:`client.formDataBodySerializer`});c.push({spread:e.placeholder});break}case`json`:break;case`text`:case`octet-stream`:c.push({key:`bodySerializer`,value:null});break;case`url-search-params`:{let e=r.referenceSymbol({category:`external`,resource:`client.urlSearchParamsBodySerializer`});c.push({spread:e.placeholder});break}}let l=[];for(let e in n.parameters?.query){let t=n.parameters.query[e];t.schema.type===`array`||t.schema.type===`tuple`?(t.style!==`form`||!t.explode)&&l.push({key:t.name,value:[{key:`array`,value:[{key:`explode`,value:t.explode===!0?void 0:t.explode},{key:`style`,value:t.style===`form`?void 0:t.style}].filter(({value:e})=>e!==void 0)}]}):t.schema.type===`object`&&(t.style!==`deepObject`||!t.explode)&&l.push({key:t.name,value:[{key:`object`,value:[{key:`explode`,value:t.explode===!0?void 0:t.explode},{key:`style`,value:t.style===`deepObject`?void 0:t.style}].filter(({value:e})=>e!==void 0)}]})}l.length&&c.push({key:`querySerializer`,value:[{key:`parameters`,value:l}]});let u=$n({operation:n,plugin:r}),d=er({operation:n,plugin:r});if(u&&c.push({key:`requestValidator`,value:u.$render()}),r.config.transformer){let e={category:`transform`,resource:`operation`,resourceId:n.id,role:`response`};if(r.isSymbolRegistered(e)){let t=r.referenceSymbol(e);c.push({key:`responseTransformer`,value:t.placeholder})}}let f=!1,p;for(let e in n.responses){let t=n.responses[e];!p&&i.name===`@hey-api/client-axios`&&et({statusCode:e})===`2XX`&&(p=or(t.mediaType),p&&c.push({key:`responseType`,value:p})),t.mediaType===`text/event-stream`&&(f=!0)}d&&c.push({key:`responseValidator`,value:d.$render()}),r.config.responseStyle===`data`&&c.push({key:`responseStyle`,value:r.config.responseStyle});let m=Vn({context:r.context,operation:n,plugin:r});m.length&&c.push({key:`security`,value:M.arrayLiteralExpression({elements:m})}),c.push({key:`url`,value:n.path}),c.push({spread:`options`});let h=[],g=t.argNames.length;if(g){let e=[],n=[];for(let n of t.argNames)e.push(M.identifier({text:n}));for(let e of t.fields){let t=[];`in`in e&&(t.push({key:`in`,value:e.in}),e.key&&t.push({key:`key`,value:e.key}),e.map&&t.push({key:`map`,value:e.map})),n.push(M.objectExpression({obj:t}))}let i=r.referenceSymbol({category:`external`,resource:`client.buildClientParams`});h.push(M.constVariable({expression:M.callExpression({functionName:i.placeholder,parameters:[M.arrayLiteralExpression({elements:e}),M.arrayLiteralExpression({elements:n})]}),name:`params`})),c.push({spread:`params`})}if(n.body){let t=n.parameters?.header?.[`content-type`];if(!t?.required){let r=[{key:t?.name??`Content-Type`,value:n.body.type===`form-data`?null:n.body.mediaType},{spread:M.propertyAccessExpression({expression:M.identifier({text:`options`}),isOptional:!e,name:`headers`})}];g&&r.push({spread:M.propertyAccessExpression({expression:M.identifier({text:`params`}),name:`headers`})}),c.push({key:`headers`,value:r})}}let ee=r.config.client?r.getSymbol({category:`client`}):void 0,te=M.propertyAccessExpression({expression:M.identifier({text:`options`}),isOptional:!e,name:`client`}),ne;ne=r.config.instance?M.binaryExpression({left:te,operator:`??`,right:M.propertyAccessExpression({expression:M.this(),name:`client`})}):ee?M.binaryExpression({left:te,operator:`??`,right:ee.placeholder}):te;let _=[];a?_.push(Hn,`${o} | ${Un}`,s,Un):_.push(o,s,`ThrowOnError`),r.config.responseStyle===`data`&&_.push(M.stringLiteral({text:r.config.responseStyle}));let v=f?M.propertyAccessExpression({expression:ne,name:M.identifier({text:`sse`})}):ne;return v=M.propertyAccessExpression({expression:v,name:M.identifier({text:n.method})}),h.push(M.returnFunctionCall({args:[M.objectExpression({identifiers:[`responseTransformer`],obj:c})],name:v,types:_})),h},P=({operation:e})=>{let t=[];if(e.summary&&t.push(mt(e.summary)),e.description&&(t.length&&t.push(``),t.push(mt(e.description))),e.deprecated&&(t.length&&t.push(``),t.push(`@deprecated`)),t.length)return t},cr=({context:e,operation:t})=>{let n=T(e.config).name===`@hey-api/client-nuxt`,r=e.config.plugins[`@hey-api/sdk`];if(r){if(!r.config.client&&!r.config.instance)return!0;if(r.config.paramsStructure===`flat`)return!1}return n||Qe(t)},lr=({operation:e})=>{for(let t in e.responses)if(e.responses[t].mediaType===`text/event-stream`)return!0;return!1},ur=({plugin:e})=>{let t=new Map,n=new Set,r=e.getPluginOrThrow(`@hey-api/sdk`);e.forEach(`operation`,({operation:n})=>{let i=cr({context:e.context,operation:n}),a=rr({context:e.context,operation:n,plugin:r});for(let r of a.values())r.path.forEach((a,o)=>{t.has(a)||t.set(a,{className:a,classes:new Set,methods:new Set,nodes:[],root:!o});let s=r.path[o-1];if(s&&s!==a){let e=t.get(s);e.classes.add(a),t.set(s,e)}if(r.path.length!==o+1)return;let c=t.get(a),l=e.config.httpRequests.methodNameBuilder(n);if(c.methods.has(l))return;let u=pr({isRequiredOptions:i,methodName:l,operation:n,plugin:e});c.nodes.length?c.nodes.push(M.identifier({text:`
3
+ `}),u):c.nodes.push(u),c.methods.add(l),t.set(a,c)})},{order:`declarations`});let i=r=>{if(n.has(r.className))return;if(r.classes.size)for(let n of r.classes){let a=t.get(n);i(a),r.nodes.push(M.propertyDeclaration({initializer:M.newExpression({argumentsArray:[],expression:M.identifier({text:x({config:{case:`preserve`,name:e.config.httpRequests.classNameBuilder},name:a.className})})}),name:b({case:`camelCase`,value:a.className})}))}let a=e.referenceSymbol({category:`external`,resource:`@angular/core.Injectable`}),o=e.registerSymbol({exported:!0,meta:{category:`utility`,resource:`class`,resourceId:r.className,tool:`angular`},name:x({config:{case:`preserve`,name:e.config.httpRequests.classNameBuilder},name:r.className})}),s=M.classDeclaration({decorator:r.root?{args:[{providedIn:`root`}],name:a.placeholder}:void 0,exportClass:o.exported,name:o.placeholder,nodes:r.nodes});e.setSymbolValue(o,s),n.add(r.className)};for(let e of t.values())i(e)},dr=({plugin:e})=>{e.forEach(`operation`,({operation:t})=>{let n=cr({context:e.context,operation:t}),r=e.registerSymbol({exported:!0,meta:{category:`utility`,resource:`operation`,resourceId:t.id,role:`data`,tool:`angular`},name:e.config.httpRequests.methodNameBuilder(t)}),i=mr({isRequiredOptions:n,operation:t,plugin:e,symbol:r});e.setSymbolValue(r,i)},{order:`declarations`})},fr=({operation:e,plugin:t})=>{let n=t.getSymbol({category:`client`}),r=M.propertyAccessExpression({expression:M.identifier({text:`options`}),isOptional:!0,name:`client`}),i;return i=n?M.binaryExpression({left:r,operator:`??`,right:n.placeholder}):r,M.callExpression({functionName:M.propertyAccessExpression({expression:i,name:`requestOptions`}),parameters:[M.objectExpression({obj:[{key:`responseStyle`,value:M.identifier({text:`'data'`})},{key:`method`,value:M.identifier({text:`'${e.method.toUpperCase()}'`})},{key:`url`,value:M.identifier({text:`'${e.path}'`})},{spread:`options`}]})]})},pr=({isRequiredOptions:e,methodName:t,operation:n,plugin:r})=>{let i=r.referenceSymbol({category:`external`,resource:`@angular/common/http.HttpRequest`}),a=r.referenceSymbol({category:`type`,resource:`client-options`,tool:`sdk`}),o=r.querySymbol({category:`type`,resource:`operation`,resourceId:n.id,role:`data`,tool:`typescript`})?.placeholder||`unknown`;return M.methodDeclaration({accessLevel:`public`,comment:P({operation:n}),name:t,parameters:[{isRequired:e,name:`options`,type:`${a.placeholder}<${o}, ThrowOnError>`}],returnType:`${i.placeholder}<unknown>`,statements:[M.returnStatement({expression:fr({operation:n,plugin:r})})],types:[{default:!1,extends:`boolean`,name:`ThrowOnError`}]})},mr=({isRequiredOptions:e,operation:t,plugin:n,symbol:r})=>{let i=n.referenceSymbol({category:`external`,resource:`@angular/common/http.HttpRequest`}),a=n.referenceSymbol({category:`type`,resource:`client-options`,tool:`sdk`}),o=n.querySymbol({category:`type`,resource:`operation`,resourceId:t.id,role:`data`,tool:`typescript`})?.placeholder||`unknown`;return M.constVariable({comment:P({operation:t}),exportConst:r.exported,expression:M.arrowFunction({parameters:[{isRequired:e,name:`options`,type:`${a.placeholder}<${o}, ThrowOnError>`}],returnType:`${i.placeholder}<unknown>`,statements:[M.returnStatement({expression:fr({operation:t,plugin:n})})],types:[{default:!1,extends:`boolean`,name:`ThrowOnError`}]}),name:r.placeholder})},hr=({plugin:e})=>{e.config.httpRequests.asClass?ur({plugin:e}):dr({plugin:e})},gr=({plugin:e})=>{let t=new Map,n=new Set,r=e.getPluginOrThrow(`@hey-api/sdk`);e.forEach(`operation`,({operation:n})=>{let i=cr({context:e.context,operation:n}),a=rr({context:e.context,operation:n,plugin:r});for(let r of a.values())r.path.forEach((a,o)=>{t.has(a)||t.set(a,{className:a,classes:new Set,methods:new Set,nodes:[],root:!o});let s=r.path[o-1];if(s&&s!==a){let e=t.get(s);e.classes.add(a),t.set(s,e)}if(r.path.length!==o+1)return;let c=t.get(a),l=e.config.httpResources.methodNameBuilder(n);if(c.methods.has(l))return;let u=yr({isRequiredOptions:i,methodName:l,operation:n,plugin:e});c.nodes.length?c.nodes.push(M.identifier({text:`
4
+ `}),u):c.nodes.push(u),c.methods.add(l),t.set(a,c)})},{order:`declarations`});let i=r=>{if(n.has(r.className))return;if(r.classes.size)for(let n of r.classes){let a=t.get(n);i(a),r.nodes.push(M.propertyDeclaration({initializer:M.newExpression({argumentsArray:[],expression:M.identifier({text:x({config:{case:`preserve`,name:e.config.httpResources.classNameBuilder},name:a.className})})}),name:b({case:`camelCase`,value:a.className})}))}let a=e.referenceSymbol({category:`external`,resource:`@angular/core.Injectable`}),o=e.registerSymbol({exported:!0,name:x({config:{case:`preserve`,name:e.config.httpResources.classNameBuilder},name:r.className})}),s=M.classDeclaration({decorator:r.root?{args:[{providedIn:`root`}],name:a.placeholder}:void 0,exportClass:o.exported,name:o.placeholder,nodes:r.nodes});e.setSymbolValue(o,s),n.add(r.className)};for(let e of t.values())i(e)},_r=({plugin:e})=>{e.forEach(`operation`,({operation:t})=>{let n=cr({context:e.context,operation:t}),r=e.registerSymbol({exported:!0,name:e.config.httpResources.methodNameBuilder(t)}),i=br({isRequiredOptions:n,operation:t,plugin:e,symbol:r});e.setSymbolValue(r,i)},{order:`declarations`})},vr=({operation:e,plugin:t})=>{let n=t.getPluginOrThrow(`@hey-api/sdk`),r=t.referenceSymbol({category:`external`,resource:`@angular/common/http.httpResource`}),i=t.querySymbol({category:`type`,resource:`operation`,resourceId:e.id,role:`response`})?.placeholder||`unknown`;if(t.config.httpRequests.asClass){let a=rr({context:t.context,operation:e,plugin:n}),o=Array.from(a.values())[0];if(o){let n=o.path[0],a=t.referenceSymbol({category:`utility`,resource:`class`,resourceId:n,tool:`angular`}),s=t.referenceSymbol({category:`external`,resource:`@angular/core.inject`}),c=M.callExpression({functionName:s.placeholder,parameters:[M.identifier({text:a.placeholder})]});for(let e=1;e<o.path.length;e++){let t=o.path[e];t&&(c=M.propertyAccessExpression({expression:c,name:b({case:`camelCase`,value:t})}))}return c=M.propertyAccessExpression({expression:c,name:t.config.httpRequests.methodNameBuilder(e)}),M.callExpression({functionName:r.placeholder,parameters:[M.arrowFunction({parameters:[],statements:[M.constVariable({expression:M.conditionalExpression({condition:M.identifier({text:`options`}),whenFalse:M.identifier({text:`undefined`}),whenTrue:M.callExpression({functionName:`options`,parameters:[]})}),name:`opts`}),M.returnStatement({expression:M.conditionalExpression({condition:M.identifier({text:`opts`}),whenFalse:M.identifier({text:`undefined`}),whenTrue:M.callExpression({functionName:c,parameters:[M.identifier({text:`opts`})]})})})]})],types:[M.typeNode(i)]})}}else{let n=t.referenceSymbol({category:`utility`,resource:`operation`,resourceId:e.id,role:`data`,tool:`angular`});return M.callExpression({functionName:r.placeholder,parameters:[M.arrowFunction({parameters:[],statements:[M.constVariable({expression:M.conditionalExpression({condition:M.identifier({text:`options`}),whenFalse:M.identifier({text:`undefined`}),whenTrue:M.callExpression({functionName:`options`,parameters:[]})}),name:`opts`}),M.returnStatement({expression:M.conditionalExpression({condition:M.identifier({text:`opts`}),whenFalse:M.identifier({text:`undefined`}),whenTrue:M.callExpression({functionName:n.placeholder,parameters:[M.identifier({text:`opts`})]})})})]})],types:[M.typeNode(i)]})}return M.callExpression({functionName:r.placeholder,parameters:[M.arrowFunction({parameters:[],statements:[M.returnStatement({expression:M.identifier({text:`undefined`})})]})],types:[M.typeNode(i)]})},yr=({isRequiredOptions:e,methodName:t,operation:n,plugin:r})=>{let i=r.referenceSymbol({category:`type`,resource:`client-options`,tool:`sdk`}),a=r.querySymbol({category:`type`,resource:`operation`,resourceId:n.id,role:`data`,tool:`typescript`})?.placeholder||`unknown`;return M.methodDeclaration({accessLevel:`public`,comment:P({operation:n}),name:t,parameters:[{isRequired:e,name:`options`,type:`() => ${i.placeholder}<${a}, ThrowOnError> | undefined`}],returnType:void 0,statements:[M.returnStatement({expression:vr({operation:n,plugin:r})})],types:[{default:!1,extends:`boolean`,name:`ThrowOnError`}]})},br=({isRequiredOptions:e,operation:t,plugin:n,symbol:r})=>{let i=n.referenceSymbol({category:`type`,resource:`client-options`,tool:`sdk`}),a=n.querySymbol({category:`type`,resource:`operation`,resourceId:t.id,role:`data`,tool:`typescript`})?.placeholder||`unknown`;return M.constVariable({comment:P({operation:t}),exportConst:r.exported,expression:M.arrowFunction({parameters:[{isRequired:e,name:`options`,type:`() => ${i.placeholder}<${a}, ThrowOnError> | undefined`}],statements:[M.returnStatement({expression:vr({operation:t,plugin:n})})],types:[{default:!1,extends:`boolean`,name:`ThrowOnError`}]}),name:r.placeholder})},xr=({plugin:e})=>{e.config.httpResources.asClass?gr({plugin:e}):_r({plugin:e})},Sr={config:{exportFromIndex:!1},dependencies:[`@hey-api/client-angular`,`@hey-api/sdk`],handler:({plugin:e})=>{e.registerSymbol({external:`@angular/common/http`,kind:`type`,meta:{category:`external`,resource:`@angular/common/http.HttpRequest`},name:`HttpRequest`}),e.registerSymbol({external:`@angular/core`,meta:{category:`external`,resource:`@angular/core.inject`},name:`inject`}),e.registerSymbol({external:`@angular/core`,meta:{category:`external`,resource:`@angular/core.Injectable`},name:`Injectable`}),e.registerSymbol({external:`@angular/common/http`,meta:{category:`external`,resource:`@angular/common/http.httpResource`},name:`httpResource`}),e.config.httpRequests.enabled&&hr({plugin:e}),e.config.httpResources.enabled&&xr({plugin:e})},name:`@angular/common`,resolveConfig:(e,t)=>{if(e.config.httpRequests=t.valueToObject({defaultValue:{asClass:!1,classNameBuilder:`{{name}}Requests`,enabled:!0},mappers:{boolean:e=>({enabled:e})},value:e.config.httpRequests}),!e.config.httpRequests.methodNameBuilder){let{asClass:t}=e.config.httpRequests;e.config.httpRequests.methodNameBuilder=e=>t?String(e.id):`${String(e.id)}Request`}if(e.config.httpResources=t.valueToObject({defaultValue:{asClass:!1,classNameBuilder:`{{name}}Resources`,enabled:!0},mappers:{boolean:e=>({enabled:e})},value:e.config.httpResources}),!e.config.httpResources.methodNameBuilder){let{asClass:t}=e.config.httpResources;e.config.httpResources.methodNameBuilder=e=>t?String(e.id):`${String(e.id)}Resource`}}},Cr={baseUrl:!0,bundle:!0,exportFromIndex:!1},wr={dependencies:[`@hey-api/typescript`],tags:[`client`]},Tr=c(import.meta.url),Er=s.dirname(Tr),Dr=e=>{let t=T(e);if(`bundle`in t.config&&t.config.bundle){let t=e._FRAGILE_CLIENT_BUNDLE_RENAMED;return s.resolve(e.output.path,`client`,`${t?.get(`index`)??`index`}.ts`)}return t.name},Or=(e,t)=>{if(o.statSync(e).isDirectory()){o.existsSync(t)||o.mkdirSync(t,{recursive:!0});let n=o.readdirSync(e);for(let r of n)Or(s.join(e,r),s.join(t,r))}else{let n=o.readFileSync(e);o.writeFileSync(t,n)}},kr=({filePath:e,project:t,renamed:n})=>{let r=s.extname(e),i=s.basename(e,r),a=t.fileName?.(i)||i;if(a!==i){let t=s.dirname(e);o.renameSync(e,s.resolve(t,`${a}${r}`)),n.set(i,a)}},Ar=({filePath:e,meta:t,renamed:n})=>{let r=o.readFileSync(e,`utf8`);r=r.replace(/from\s+['"](\.\.?\/[^'"]*?)['"]/g,(e,r)=>{let i=e.indexOf(r),a=s.extname(r),o=s.basename(r,a),c=s.dirname(r),l=(n.get(o)??o)+(t.importFileExtension?t.importFileExtension:a);return e.slice(0,i)+[c,l].filter(Boolean).join(`/`)+e.slice(i+r.length)}),r=`// This file is auto-generated by @hey-api/openapi-ts
5
+
6
+ ${r}`,o.writeFileSync(e,r,`utf8`)},jr=({meta:t,outputPath:n,plugin:r,project:i})=>{let a=new Map;if(r.name.startsWith(`@hey-api/client-`)){let e=s.resolve(n,`core`);_(e),Or(s.resolve(Er,`clients`,`core`),e);let c=s.resolve(n,`client`);_(c);let l=r.name.slice(16);if(Or(s.resolve(Er,`clients`,l),c),i){let t=o.readdirSync(e);for(let n of t)kr({filePath:s.resolve(e,n),project:i,renamed:a});let n=o.readdirSync(c);for(let e of n)kr({filePath:s.resolve(c,e),project:i,renamed:a})}let u=o.readdirSync(e);for(let n of u)Ar({filePath:s.resolve(e,n),meta:t,renamed:a});let d=o.readdirSync(c);for(let e of d)Ar({filePath:s.resolve(c,e),meta:t,renamed:a});return a}let c=s.isAbsolute(r.name)?s.dirname(r.name):void 0;if(c){let e=s.resolve(n,`client`);_(e),Or(c,e);return}let l=s.normalize(e.resolve(r.name)).split(s.sep),u=l.slice(0,l.indexOf(`dist`)+1).join(s.sep),d=[l[l.length-1],`index.d.ts`,`index.d.cts`],f=s.resolve(n,`client`);_(f);for(let e of d)o.copyFileSync(s.resolve(u,e),s.resolve(f,e))},Mr=/^(([^:/?#]+):)?((\/\/)?([^:/?#]*)(:?([^/?#]*)))?([^?#]*)(\?([^#]*))?(#(.*))?/,Nr=e=>{let t={host:``,path:``,port:``,protocol:``};Mr.lastIndex=0;let n=e.match(Mr);if(!n)return t;let r=n[5]||``;if(r===`.`||r===`..`)return t;let i=n[8]||``,a=n[2]||``;return a.length===1?t:{host:r,path:i===`/`?``:i,port:n[7]||``,protocol:a}},Pr=({plugin:e})=>{let{baseUrl:t}=e.config;if(t===!1)return;if(typeof t==`string`)return t;let{servers:n}=e.context.ir;if(n)return n[typeof t==`number`?t:0]?.url},Fr=({plugin:e})=>{let t=Dr(e.context.config),n=e.registerSymbol({external:t,name:`createClient`}),r=e.registerSymbol({external:t,name:`createConfig`}),i=e.referenceSymbol({category:`type`,resource:`client`,role:`options`}),{runtimeConfigPath:a}=e.config,o=a?e.registerSymbol({external:a,name:`createClientConfig`}):void 0,s=[],c=Pr({plugin:e});if(c){let t=Nr(c);if(t.protocol&&t.host&&!c.includes(`{`))s.push({key:rt(e.context.config),value:c});else if(c!==`/`&&c.startsWith(`/`)){let t=c.endsWith(`/`)?c.slice(0,-1):c;s.push({key:rt(e.context.config),value:t})}}`throwOnError`in e.config&&e.config.throwOnError&&s.push({key:`throwOnError`,value:!0});let l=[M.callExpression({functionName:r.placeholder,parameters:s.length?[M.objectExpression({obj:s})]:void 0,types:[M.typeReferenceNode({typeName:i.placeholder})]})],u=e.registerSymbol({meta:{category:`client`},name:`client`}),d=M.constVariable({exportConst:!0,expression:M.callExpression({functionName:n.placeholder,parameters:o?[M.callExpression({functionName:o.placeholder,parameters:l})]:l}),name:u.placeholder});e.setSymbolValue(u,d)},Ir=({plugin:e})=>{let t=Dr(e.context.config),n=e.referenceSymbol({category:`type`,resource:`client`,role:`options`}),r=e.registerSymbol({external:t,kind:`type`,name:`Config`}),i=e.registerSymbol({external:t,kind:`type`,name:`ClientOptions`}),a=e.registerSymbol({exported:!0,kind:`type`,name:`CreateClientConfig`}),o=M.typeReferenceNode({typeName:i.placeholder}),s=M.typeReferenceNode({typeName:`T`}),c=M.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:M.functionTypeNode({parameters:[M.parameterDeclaration({name:`override`,required:!1,type:M.typeReferenceNode({typeArguments:[M.typeIntersectionNode({types:[o,s]})],typeName:r.placeholder})})],returnType:M.typeReferenceNode({typeArguments:[M.typeIntersectionNode({types:[M.typeReferenceNode({typeArguments:[o],typeName:`Required`}),s]})],typeName:r.placeholder})}),typeParameters:[{default:M.typeReferenceNode({typeName:n.placeholder}),extends:o,name:`T`}]});e.setSymbolValue(a,c)},Lr=({plugin:e})=>{Ir({plugin:e}),Fr({plugin:e})},Rr={...wr,config:{...Cr,throwOnError:!1},handler:Lr,name:`@hey-api/client-angular`},zr={...wr,config:{...Cr,throwOnError:!1},handler:Lr,name:`@hey-api/client-axios`},Br={...wr,config:{...Cr,throwOnError:!1},handler:Lr,name:`@hey-api/client-fetch`},Vr={...wr,config:{...Cr,throwOnError:!1},handler:Lr,name:`@hey-api/client-ky`},Hr={...wr,config:{...Cr,throwOnError:!1},handler:Lr,name:`@hey-api/client-next`},Ur={...wr,config:Cr,handler:Lr,name:`@hey-api/client-nuxt`},Wr={...wr,config:{...Cr,throwOnError:!1},handler:Lr,name:`@hey-api/client-ofetch`},Gr=(...e)=>d.satisfies(...e),Kr=e=>({getVersion:t=>{let n=e[t];if(n)try{let e=d.parse(n);if(e)return e;let t=d.minVersion(n);if(t)return t;if(e=d.coerce(n),e)return e}catch{}},isInstalled:t=>!!e[t],satisfies:(t,n,r)=>{let i=typeof t==`string`?e[t]:t;return i?Gr(i,n,r):!1}}),qr=[ct,ut,st,lt,ot],Jr=e=>{let t=e.replace(/[^$\u200c\u200d\p{ID_Continue}]/gu,`_`);if(it.lastIndex=0,it.test(t))return`_${t}`;for(let e of qr){if(t.startsWith(`_`))return t;t=t.replace(e,`_$1`)}return t},Yr=({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)},Xr=({context:e,plugin:t,schema:n})=>{if(Array.isArray(n))return n.map(n=>Xr({context:e,plugin:t,schema:n}));let r=structuredClone(n);if(r.$ref)return r.$ref=decodeURI(r.$ref),r;if(Yr({plugin:t,schema:r}),r.additionalProperties&&typeof r.additionalProperties!=`boolean`&&(r.additionalProperties=Xr({context:e,plugin:t,schema:r.additionalProperties})),r.allOf&&=r.allOf.map(n=>Xr({context:e,plugin:t,schema:n})),r.items&&=Xr({context:e,plugin:t,schema:r.items}),r.properties)for(let n in r.properties){let i=r.properties[n];typeof i!=`boolean`&&(r.properties[n]=Xr({context:e,plugin:t,schema:i}))}return r},Zr=({context:e,plugin:t,schema:n})=>{if(Array.isArray(n))return n.map(n=>Zr({context:e,plugin:t,schema:n}));let r=structuredClone(n);if(`$ref`in r)return r.$ref=decodeURI(r.$ref),r;if(Yr({plugin:t,schema:r}),r.additionalProperties&&typeof r.additionalProperties!=`boolean`&&(r.additionalProperties=Zr({context:e,plugin:t,schema:r.additionalProperties})),r.allOf&&=r.allOf.map(n=>Zr({context:e,plugin:t,schema:n})),r.anyOf&&=r.anyOf.map(n=>Zr({context:e,plugin:t,schema:n})),r.items&&=Zr({context:e,plugin:t,schema:r.items}),r.oneOf&&=r.oneOf.map(n=>Zr({context:e,plugin:t,schema:n})),r.properties)for(let n in r.properties){let i=r.properties[n];typeof i!=`boolean`&&(r.properties[n]=Zr({context:e,plugin:t,schema:i}))}return r},Qr=({context:e,plugin:t,schema:n})=>{if(Array.isArray(n))return n.map(n=>Qr({context:e,plugin:t,schema:n}));let r=structuredClone(n);if(Yr({plugin:t,schema:r}),r.$ref&&=decodeURI(r.$ref),r.additionalProperties&&typeof r.additionalProperties!=`boolean`&&(r.additionalProperties=Qr({context:e,plugin:t,schema:r.additionalProperties})),r.allOf&&=r.allOf.map(n=>Qr({context:e,plugin:t,schema:n})),r.anyOf&&=r.anyOf.map(n=>Qr({context:e,plugin:t,schema:n})),r.items&&=Qr({context:e,plugin:t,schema:r.items}),r.oneOf&&=r.oneOf.map(n=>Qr({context:e,plugin:t,schema:n})),r.prefixItems&&=r.prefixItems.map(n=>Qr({context:e,plugin:t,schema:n})),r.properties)for(let n in r.properties){let i=r.properties[n];typeof i!=`boolean`&&(r.properties[n]=Qr({context:e,plugin:t,schema:i}))}return r},$r=({name:e,plugin:t,schema:n})=>{let r=``;return t.config.nameBuilder&&(r=typeof t.config.nameBuilder==`function`?t.config.nameBuilder(e,n):t.config.nameBuilder.replace(`{{name}}`,e)),r||=`${e}Schema`,Jr(r)},ei=({context:e,plugin:t})=>{if(e.spec.definitions)for(let n in e.spec.definitions){let r=e.spec.definitions[n],i=t.registerSymbol({exported:!0,meta:{category:`schema`,resource:`definition`,resourceId:n,tool:`json-schema`},name:$r({name:n,plugin:t,schema:r})}),a=Xr({context:e,plugin:t,schema:r}),o=M.constVariable({assertion:`const`,exportConst:i.exported,expression:M.objectExpression({obj:a}),name:i.placeholder});t.setSymbolValue(i,o)}},ti=({context:e,plugin:t})=>{if(e.spec.components)for(let n in e.spec.components.schemas){let r=e.spec.components.schemas[n],i=t.registerSymbol({exported:!0,meta:{category:`schema`,resource:`definition`,resourceId:n,tool:`json-schema`},name:$r({name:n,plugin:t,schema:r})}),a=Zr({context:e,plugin:t,schema:r}),o=M.constVariable({assertion:`const`,exportConst:i.exported,expression:M.objectExpression({obj:a}),name:i.placeholder});t.setSymbolValue(i,o)}},ni=({context:e,plugin:t})=>{if(e.spec.components)for(let n in e.spec.components.schemas){let r=e.spec.components.schemas[n],i=t.registerSymbol({exported:!0,meta:{category:`schema`,resource:`definition`,resourceId:n,tool:`json-schema`},name:$r({name:n,plugin:t,schema:r})}),a=Qr({context:e,plugin:t,schema:r}),o=M.constVariable({assertion:`const`,exportConst:i.exported,expression:M.objectExpression({obj:a}),name:i.placeholder});t.setSymbolValue(i,o)}},ri={config:{exportFromIndex:!1,nameBuilder:e=>`${e}Schema`,type:`json`},handler:({plugin:e})=>{if(`swagger`in e.context.spec){ei({context:e.context,plugin:e});return}if(Gr(e.context.spec.openapi,`>=3.0.0 <3.1.0`)){ti({context:e.context,plugin:e});return}if(Gr(e.context.spec.openapi,`>=3.1.0`)){ni({context:e.context,plugin:e});return}throw Error(`Unsupported OpenAPI specification`)},name:`@hey-api/schemas`};var F=class e{$expr(e){return typeof e==`string`?l.factory.createIdentifier(e):e}$if(e,t,n){if(e){let n;try{n=t?.(this,e)}catch{}if(n===void 0)try{n=t?.(e)}catch{}if(n===void 0)try{n=t?.()}catch{}return n??this}if(n){let t;try{t=n?.(this,e)}catch{}if(t===void 0)try{t=n?.(e)}catch{}if(t===void 0)try{t=n?.()}catch{}return t??this}return this}$node(e){if(e!==void 0)return typeof e==`string`?this.$expr(e):typeof e==`boolean`?e?l.factory.createTrue():l.factory.createFalse():e instanceof Array?e.map(e=>this._render(e)):this._render(e)}$stmt(e){return(e instanceof Array?e:[e]).map(e=>{let t=typeof e==`string`?this.$expr(e):this._render(e);return l.isExpression(t)?l.factory.createExpressionStatement(t):t})}$type(e,t){if(e!==void 0){if(typeof e==`string`)return l.factory.createTypeReferenceNode(e,t);if(typeof e==`boolean`){let t=e?l.factory.createTrue():l.factory.createFalse();return l.factory.createLiteralTypeNode(t)}return e instanceof Array?e.map(e=>this.$type(e,t)):this._render(e)}}_render(t){return t instanceof e?t.$render():t}},I=class extends F{},ii=class extends F{value;constructor(e){super(),this.value=e}$render(){switch(typeof this.value){case`boolean`:return this.value?l.factory.createTrue():l.factory.createFalse();case`number`:return l.factory.createNumericLiteral(this.value);case`string`:return l.factory.createStringLiteral(this.value);default:throw Error(`Unsupported literal: ${String(this.value)}`)}}};function L(e,...t){let n=e.prototype;for(let r of t){let[t,i]=r instanceof Array?r:[r],a=t;if(typeof t==`function`)try{let n=t(e);n?.prototype&&(a=n)}catch{}let o=a.prototype;if(o)for(let[e,t]of Object.entries(Object.getOwnPropertyDescriptors(o)))e!==`constructor`&&(e===`$render`&&!i?.overrideRender||Object.defineProperty(n,e,t))}}var ai=class e{static DEFAULT_THRESHOLD=3;layout;auto(t=e.DEFAULT_THRESHOLD){return this.layout=t,this}inline(){return this.layout=!1,this}pretty(){return this.layout=!0,this}$multiline(t){return this.layout===void 0&&(this.layout=e.DEFAULT_THRESHOLD),typeof this.layout==`number`?t>=this.layout:this.layout}},oi=class extends F{_elements=[];element(e){let t=typeof e==`string`||typeof e==`number`||typeof e==`boolean`?new ii(e):e;return this._elements.push({expr:t,kind:`element`}),this}elements(...e){for(let t of e)this.element(t);return this}spread(e){return this._elements.push({expr:e,kind:`spread`}),this}$render(){let e=this._elements.map(e=>{let t=this.$node(e.expr);if(!l.isExpression(t))throw Error(`Invalid array element: must be an expression.`);return e.kind===`spread`?l.factory.createSpreadElement(t):t});return l.factory.createArrayLiteralExpression(e,this.$multiline(this._elements.length))}};L(oi,ai);let si;function ci(e){si=e}let li;function ui(e){li=e}let di;function fi(e){di=e}let pi;function mi(e){pi=e}var hi=class{attr(e){return si(this,e)}await(){return li(this)}call(...e){return di(this,e)}return(){return pi(this)}},R=class extends F{left;operator;right;constructor(e,t,n){super(),this.left=e,this.operator=t,this.right=n}$render(){let e=this.$node(this.left),t=this.$node(this.right),n=typeof this.operator==`string`?this.mapOperator(this.operator):this.operator;return l.factory.createBinaryExpression(e,n,t)}mapOperator(e){let t={"!=":l.SyntaxKind.ExclamationEqualsToken,"!==":l.SyntaxKind.ExclamationEqualsEqualsToken,"&&":l.SyntaxKind.AmpersandAmpersandToken,"*":l.SyntaxKind.AsteriskToken,"+":l.SyntaxKind.PlusToken,"-":l.SyntaxKind.MinusToken,"/":l.SyntaxKind.SlashToken,"<":l.SyntaxKind.LessThanToken,"<=":l.SyntaxKind.LessThanEqualsToken,"=":l.SyntaxKind.EqualsToken,"==":l.SyntaxKind.EqualsEqualsToken,"===":l.SyntaxKind.EqualsEqualsEqualsToken,">":l.SyntaxKind.GreaterThanToken,">=":l.SyntaxKind.GreaterThanEqualsToken,"??":l.SyntaxKind.QuestionQuestionToken,"||":l.SyntaxKind.BarBarToken}[e];if(!t)throw Error(`Unsupported operator: ${e}`);return t}},gi=class{assign(e){return new R(this,`=`,e)}},_i=class{and(e){return new R(this,`&&`,e)}coalesce(e){return new R(this,`??`,e)}div(e){return new R(this,`/`,e)}eq(e){return new R(this,`===`,e)}gt(e){return new R(this,`>`,e)}gte(e){return new R(this,`>=`,e)}looseEq(e){return new R(this,`==`,e)}looseNeq(e){return new R(this,`!=`,e)}lt(e){return new R(this,`<`,e)}lte(e){return new R(this,`<=`,e)}minus(e){return new R(this,`-`,e)}neq(e){return new R(this,`!==`,e)}or(e){return new R(this,`||`,e)}plus(e){return new R(this,`+`,e)}times(e){return new R(this,`*`,e)}},vi=class{isOptional;questionToken;optional(e=!0){return e&&(this.isOptional=!0,this.questionToken=l.factory.createToken(l.SyntaxKind.QuestionToken)),this}},yi=class extends F{left;right;constructor(e,t){super(),this.left=e,this.right=t}$render(){let e=this.$node(this.left);return typeof this.right==`number`?this.isOptional?l.factory.createElementAccessChain(e,l.factory.createToken(l.SyntaxKind.QuestionDotToken),l.factory.createNumericLiteral(this.right)):l.factory.createElementAccessExpression(e,l.factory.createNumericLiteral(this.right)):this.isOptional?l.factory.createPropertyAccessChain(e,l.factory.createToken(l.SyntaxKind.QuestionDotToken),this.$expr(this.right)):l.factory.createPropertyAccessExpression(e,this.$expr(this.right))}};L(yi,hi,gi,_i,vi),ci((e,t)=>new yi(e,t));var bi=class extends F{_awaitExpr;constructor(e){super(),this._awaitExpr=e}$render(){return l.factory.createAwaitExpression(this.$node(this._awaitExpr))}};L(bi,hi),ui(e=>new bi(e));var xi=class extends F{_args;arg(e){return(this._args??=[]).push(e),this}args(...e){return(this._args??=[]).push(...e),this}$args(){return this._args?this.$node(this._args).map(e=>this.$expr(e)):[]}$render(){throw Error(`noop`)}},Si=class extends F{_generics;generic(e){return(this._generics??=[]).push(e),this}generics(...e){return this._generics=[...e],this}$generics(){return this.$type(this._generics)}$render(){throw Error(`noop`)}},Ci=class extends F{_callee;constructor(e,...t){super(),this._callee=e,this.args(...t.filter(e=>e!==void 0))}$render(){return l.factory.createCallExpression(this.$node(this._callee),this.$generics(),this.$args())}};L(Ci,hi,xi,Si),fi((e,t)=>new Ci(e,...t));var wi=class extends F{name;constructor(e,...t){super(),this.name=e,this.args(...t)}$render(){let e=this.$args();return l.factory.createDecorator(e.length?l.factory.createCallExpression(this.$expr(this.name),void 0,e):this.$expr(this.name))}};L(wi,xi);var Ti=class extends F{decorators;decorator(e,...t){return(this.decorators??=[]).push(new wi(e,...t)),this}$decorators(){return this.decorators?this.$node(this.decorators):[]}$render(){throw Error(`noop`)}},Ei=class extends F{_lines=[];constructor(e,t){super(),e&&(typeof e==`string`?this.add(e):this.add(...e)),t?.(this)}add(...e){return this._lines.push(...e),this}apply(e){let t=this._lines.filter(e=>!!e||e===``);if(!t.length)return e;let n=t.map((e,n)=>{let r=e;return n!==t.length&&(r=`${r}\n`),l.factory.createJSDocText(r)}),r=l.factory.createJSDocComment(l.factory.createNodeArray(n),void 0),i=l.createPrinter().printNode(l.EmitHint.Unspecified,r,e.getSourceFile?.()??l.createSourceFile(``,``,l.ScriptTarget.Latest)).replace(`/*`,``).replace(`* */`,``);return l.addSyntheticLeadingComment(e,l.SyntaxKind.MultiLineCommentTrivia,i,!0),e}$render(){return l.factory.createIdentifier(``)}};function Di(e){let t=class extends e{_desc;describe(e,t){return this._desc=new Ei(e,t),this}},n=e.prototype.$render;return t.prototype.$render=function(...e){let t=n.apply(this,e);return this._desc?this._desc.apply(t):t},t}function Oi(e){let t=[];function n(n,r=!0){return r&&t.push(l.factory.createModifier(n)),e}Object.assign(e,{_m:n});function r(){return t}return{list:r}}var ki=class{abstract(e=!0){return this._m(l.SyntaxKind.AbstractKeyword,e)}},Ai=class{async(e=!0){return this._m(l.SyntaxKind.AsyncKeyword,e)}},ji=class{default(e=!0){return this._m(l.SyntaxKind.DefaultKeyword,e)}},Mi=class{export(e=!0){return this._m(l.SyntaxKind.ExportKeyword,e)}},Ni=class{private(e=!0){return this._m(l.SyntaxKind.PrivateKeyword,e)}},Pi=class{protected(e=!0){return this._m(l.SyntaxKind.ProtectedKeyword,e)}},Fi=class{public(e=!0){return this._m(l.SyntaxKind.PublicKeyword,e)}},Ii=class{readonly(e=!0){return this._m(l.SyntaxKind.ReadonlyKeyword,e)}},Li=class{static(e=!0){return this._m(l.SyntaxKind.StaticKeyword,e)}},Ri=class extends F{value;assign(e){return this.value=e,this}$value(){return this.$node(this.value)}$render(){throw Error(`noop`)}},zi=class extends F{_base;right;constructor(e,t){super(),t?(this.base(e),this.right=t):(this.base(void 0),this.right=e)}base(e){return this._base=e,this}$render(){if(!this._base)throw Error(`TypeAttrTsDsl: missing base for qualified name`);let e=this.$node(this._base);if(!l.isEntityName(e))throw Error(`TypeAttrTsDsl: base must be an EntityName`);let t=this.$expr(this.right);return l.factory.createQualifiedName(e,t)}},z=class extends I{_exprInput;constructor(e,t){super(),typeof e==`string`?(this._exprInput=e,t?.(this)):e?.(this)}attr(e){return this._exprInput=e instanceof zi?e.base(this._exprInput):new zi(this._exprInput,e),this}$render(){if(!this._exprInput)throw Error(`TypeExpr must have either an expression or an object`);return l.factory.createTypeReferenceNode(this.$type(this._exprInput),this.$generics())}};L(z,Si);var Bi=class extends F{modifiers=Oi(this);name;_type;constructor(e,t){super(),this.name=e,t?.(this)}type(e){return this._type=e instanceof I?e:new z(e),this}$render(){return l.factory.createPropertyDeclaration([...this.$decorators(),...this.modifiers.list()],this.$expr(this.name),void 0,this.$type(this._type),this.$value())}};L(Bi,Ti,[Di,{overrideRender:!0}],Ni,Pi,Fi,Ii,Li,Ri);var Vi=class extends F{_do;do(...e){return(this._do??=[]).push(...e),this}$do(){return this._do?this.$stmt(this._do):[]}$render(){throw Error(`noop`)}},Hi=class extends F{pattern;_spread;array(...e){return this.pattern={kind:`array`,values:e[0]instanceof Array?[...e[0]]:e},this}object(...e){let t={};for(let n of e)if(typeof n==`string`)t[n]=n;else if(n instanceof Array)for(let e of n)t[e]=e;else Object.assign(t,n);return this.pattern={kind:`object`,values:t},this}spread(e){return this._spread=e,this}$render(){if(!this.pattern)throw Error(`PatternTsDsl requires object() or array() pattern`);if(this.pattern.kind===`object`){let e=Object.entries(this.pattern.values).map(([e,t])=>e===t?l.factory.createBindingElement(void 0,void 0,e,void 0):l.factory.createBindingElement(void 0,e,t,void 0)),t=this.createSpread();return t&&e.push(t),l.factory.createObjectBindingPattern(e)}if(this.pattern.kind===`array`){let e=this.pattern.values.map(e=>l.factory.createBindingElement(void 0,void 0,e,void 0)),t=this.createSpread();return t&&e.push(t),l.factory.createArrayBindingPattern(e)}throw Error(`PatternTsDsl requires object() or array() pattern`)}createSpread(){return this._spread?l.factory.createBindingElement(l.factory.createToken(l.SyntaxKind.DotDotDotToken),void 0,l.factory.createIdentifier(this._spread)):void 0}},Ui=class extends F{pattern;array(...e){return(this.pattern??=new Hi).array(...e),this}object(...e){return(this.pattern??=new Hi).object(...e),this}spread(e){return(this.pattern??=new Hi).spread(e),this}$pattern(){return this.$node(this.pattern)}$render(){throw Error(`noop`)}},Wi=class extends F{name;_type;constructor(e,t){super(),typeof e==`string`?(this.name=e,t?.(this)):e(this)}type(e){return this._type=e instanceof I?e:new z(e),this}$render(){let e=this.$pattern()??this.name;if(!e)throw Error(`Param must have either a name or a destructuring pattern`);return l.factory.createParameterDeclaration(this.$decorators(),void 0,e,this.questionToken,this.$type(this._type),this.$value())}};L(Wi,Ti,vi,Ui,Ri);var Gi=class extends F{_params;param(e,t){let n=new Wi(e,t);return(this._params??=[]).push(n),this}params(...e){return(this._params??=[]).push(...e),this}$params(){return this._params?this.$node(this._params):[]}$render(){throw Error(`noop`)}},Ki=class extends F{modifiers=Oi(this);constructor(e){super(),e?.(this)}$render(){return l.factory.createConstructorDeclaration([...this.$decorators(),...this.modifiers.list()],this.$params(),l.factory.createBlock(this.$do(),!0))}};L(Ki,Ti,[Di,{overrideRender:!0}],Vi,Gi,Ni,Pi,Fi);var qi=class extends I{name;constraint;defaultValue;constructor(e,t){super(),this.name=e,t?.(this)}default(e){return this.defaultValue=e,this}extends(e){return this.constraint=e,this}$render(){if(!this.name)throw Error(`Missing type name`);return l.factory.createTypeParameterDeclaration(void 0,this.$expr(this.name),this.$type(this.constraint),this.$type(this.defaultValue))}},Ji=class extends F{_generics;generic(...e){let t=new qi(...e);return(this._generics??=[]).push(t),this}generics(...e){return this._generics=[...e],this}$generics(){return this._generics?.map(e=>{let t=typeof e==`string`?new qi(e):e;return this.$node(t)})}$render(){throw Error(`noop`)}},Yi=class extends F{modifiers=Oi(this);name;_returns;constructor(e,t){super(),this.name=e,t?.(this)}returns(e){return this._returns=e instanceof I?e:new z(e),this}$render(){return l.factory.createMethodDeclaration([...this.$decorators(),...this.modifiers.list()],void 0,this.$expr(this.name),this.questionToken,this.$generics(),this.$params(),this.$type(this._returns),l.factory.createBlock(this.$do(),!0))}};L(Yi,ki,Ai,Ti,[Di,{overrideRender:!0}],Vi,vi,Gi,Ni,Pi,Fi,Li,Ji);var Xi=class extends F{$render(){return l.factory.createIdentifier(`
7
+ `)}},Zi=class extends F{heritageClauses=[];body=[];modifiers=Oi(this);name;constructor(e){super(),this.name=e}do(...e){return this.body.push(...e),this}extends(e){return e&&this.heritageClauses.push(l.factory.createHeritageClause(l.SyntaxKind.ExtendsKeyword,[l.factory.createExpressionWithTypeArguments(this.$expr(e),void 0)])),this}field(e,t){let n=new Bi(e,t);return this.body.push(n),this}init(e){let t=new Ki(e);return this.body.push(t),this}method(e,t){let n=new Yi(e,t);return this.body.push(n),this}newline(){return this.body.push(new Xi),this}$render(){let e=this.$node(this.body);return l.factory.createClassDeclaration([...this.$decorators(),...this.modifiers.list()],this.$expr(this.name),this.$generics(),this.heritageClauses,e)}};L(Zi,ki,Ti,[Di,{overrideRender:!0}],ji,Mi,Ji);var Qi=class extends I{expr;constructor(e){super(),this.expr=e}$render(){let e=this.$node(this.expr);if(!l.isEntityName(e))throw Error(`TypeQueryTsDsl: expression must resolve to an EntityName`);return l.factory.createTypeQueryNode(e)}},$i=class extends F{_exprInput;constructor(e){super(),this._exprInput=e}typeof(){return new Qi(this)}returnType(){return new z(`ReturnType`).generic(this.typeof())}$render(){return this.$node(this._exprInput)}};L($i,hi,_i);var ea=class extends F{mode;modifiers=Oi(this);name;_returns;constructor(e,t){super(),typeof e==`string`?(this.name=e,this.mode=`decl`,t?.(this)):(this.mode=`arrow`,e?.(this))}arrow(){return this.mode=`arrow`,this}decl(){return this.mode=`decl`,this}expr(){return this.mode=`expr`,this}returns(e){return this._returns=e instanceof I?e:new z(e),this}$render(){if(this.mode===`decl`){if(!this.name)throw Error(`Function declaration requires a name`);return l.factory.createFunctionDeclaration([...this.$decorators(),...this.modifiers.list()],void 0,this.name,this.$generics(),this.$params(),this.$type(this._returns),l.factory.createBlock(this.$do(),!0))}if(this.mode===`expr`)return l.factory.createFunctionExpression([...this.modifiers.list()],void 0,this.$expr(this.name),this.$generics(),this.$params(),this.$type(this._returns),l.factory.createBlock(this.$do(),!0));let e=this.$do(),t=e.length===1&&l.isReturnStatement(e[0])?e[0].expression??l.factory.createBlock(e,!0):l.factory.createBlock(e,!0);return l.factory.createArrowFunction([...this.modifiers.list()],this.$generics(),this.$params(),this.$type(this._returns),void 0,t)}};L(ea,ki,Ai,Ti,[Di,{overrideRender:!0}],Vi,vi,Gi,Ni,Pi,Fi,Li,Ji);const ta=ea;var na=class extends F{modifiers=Oi(this);name;constructor(e,t){super(),this.name=e,t?.(this)}$render(){return l.factory.createGetAccessorDeclaration([...this.$decorators(),...this.modifiers.list()],this.name,this.$params(),void 0,l.factory.createBlock(this.$do(),!0))}};L(na,ki,Ti,[Di,{overrideRender:!0}],Vi,Gi,Ni,Pi,Fi,Li);var ra=class extends F{conditionInput;elseInput;constructor(e){super(),e&&this.condition(e)}condition(e){return this.conditionInput=e,this}otherwise(...e){return this.elseInput=e,this}$render(){if(!this.conditionInput)throw Error(`Missing condition in if`);let e=this.$do();if(!e.length)throw Error(`Missing then block in if`);let t=this.$node(this.conditionInput),n=e.length===1?e[0]:l.factory.createBlock(e,!0),r=l.isBlock(n)?n:l.factory.createBlock([n],!0),i;if(this.elseInput){let e=this.$node(this.elseInput),t=e.length===1?e[0]:l.factory.createBlock(e,!0);i=l.isBlock(t)?t:l.factory.createBlock([t],!0)}return l.factory.createIfStatement(t,r,i)}};L(ra,Vi);var ia=class extends F{classExpr;constructor(e,...t){super(),this.classExpr=e,this.args(...t)}$render(){return l.factory.createNewExpression(this.$node(this.classExpr),this.$generics(),this.$args())}};L(ia,hi,xi,Si);var aa=class extends F{_notExpr;constructor(e){super(),this._notExpr=e}$render(){return l.factory.createPrefixUnaryExpression(l.SyntaxKind.ExclamationToken,this.$node(this._notExpr))}},oa=class extends F{modifiers=Oi(this);name;constructor(e,t){super(),this.name=e,t?.(this)}$render(){return l.factory.createSetAccessorDeclaration([...this.$decorators(),...this.modifiers.list()],this.name,this.$params(),l.factory.createBlock(this.$do(),!0))}};L(oa,ki,Ti,[Di,{overrideRender:!0}],Vi,Gi,Ni,Pi,Fi,Li);var sa=class extends F{props=[];getter(e,t){return this.props.push({expr:t,kind:`getter`,name:e}),this}hasProps(){return this.props.length>0}get isEmpty(){return!this.props.length}prop(e,t){return this.props.push({expr:t,kind:`prop`,name:e}),this}setter(e,t){return this.props.push({expr:t,kind:`setter`,name:e}),this}spread(e){return this.props.push({expr:e,kind:`spread`}),this}$render(){let e=this.props.map(e=>{let t=this.$node(e.expr);if(e.kind===`spread`){if(l.isStatement(t))throw Error(`Invalid spread: object spread must be an expression, not a statement.`);return l.factory.createSpreadAssignment(t)}if(e.kind===`getter`){let n=new na(this.safePropertyName(e.name)).do(t);return this.$node(n)}if(e.kind===`setter`){let n=new oa(this.safePropertyName(e.name)).do(t);return this.$node(n)}if(l.isIdentifier(t)&&t.text===e.name)return l.factory.createShorthandPropertyAssignment(e.name);if(l.isStatement(t))throw Error(`Invalid property: object property value must be an expression, not a statement.`);return l.factory.createPropertyAssignment(this.safePropertyName(e.name),t)});return l.factory.createObjectLiteralExpression(e,this.$multiline(this.props.length))}safePropertyName(e){let t;return at.lastIndex=0,t=at.test(e)?e.startsWith(`-`)?l.factory.createStringLiteral(e):l.factory.createNumericLiteral(e):e,(e.match(/^[0-9]/)&&e.match(/\D+/g)||e.match(/\W/g))&&!e.startsWith(`'`)&&!e.endsWith(`'`)&&(t=`'${e}'`),t}};L(sa,ai);var ca=class extends F{pattern;flags;constructor(e,t){super(),this.pattern=e,this.flags=t}$render(){let e=`/${(this.pattern.startsWith(`/`)&&this.pattern.endsWith(`/`)?this.pattern.slice(1,-1):this.pattern).replace(/(?<!\\)\//g,`\\/`)}/${this.flags??``}`;return l.factory.createRegularExpressionLiteral(e)}},la=class extends F{_returnExpr;constructor(e){super(),this._returnExpr=e}$render(){return l.factory.createReturnStatement(this.$node(this._returnExpr))}};L(la,hi),mi(e=>new la(e));var ua=class extends F{parts=[];constructor(e){super(),e!==void 0&&this.add(e)}add(e){return this.parts.push(e),this}$render(){let e=this.$node(this.parts),t=[];for(let n=0;n<e.length;n++){let r=e[n];if(typeof r==`string`){let i=r;for(;n+1<e.length&&typeof e[n+1]==`string`;)i+=e[n+1],n++;t.push(i)}else t.push(r)}if((t.length===0||typeof t[0]!=`string`)&&t.unshift(``),t.length===1&&typeof t[0]==`string`)return l.factory.createNoSubstitutionTemplateLiteral(t[0]);if(t.length===2&&typeof t[0]==`string`&&typeof t[1]!=`string`)return l.factory.createTemplateExpression(l.factory.createTemplateHead(t[0]),[l.factory.createTemplateSpan(t[1],l.factory.createTemplateTail(``))]);let n=l.factory.createTemplateHead(t.shift()),r=[];for(;t.length;){let e=t.shift(),n=typeof t[0]==`string`?t.shift():``,i=t.length===0;r.push(l.factory.createTemplateSpan(e,i?l.factory.createTemplateTail(n):l.factory.createTemplateMiddle(n)))}return l.factory.createTemplateExpression(n,r)}},da=class extends F{error;msg;useNew;constructor(e,t=!0){super(),this.error=e,this.useNew=t}message(e){return this.msg=e,this}$render(){let e=this.$node(this.error),t=this.$node(this.msg?[this.msg]:[]).map(e=>typeof e==`string`?l.factory.createStringLiteral(e):e);if(this.useNew)return l.factory.createThrowStatement(l.factory.createNewExpression(e,void 0,t));let n=t.length?[l.factory.createCallExpression(e,void 0,t)]:[e];return l.factory.createThrowStatement(n[0])}},fa=class extends F{value;modifiers=Oi(this);name;constructor(e,t){super(),this.name=e,t?.(this)}type(e){return this.value=e,this}$render(){if(!this.value)throw Error(`Type alias '${this.name}' is missing a type definition`);return l.factory.createTypeAliasDeclaration(this.modifiers.list(),this.name,this.$generics(),this.$type(this.value))}};L(fa,Mi,Ji);var pa=class extends I{value;constructor(e){super(),this.value=e}$render(){return l.factory.createLiteralTypeNode(this.$node(new ii(this.value)))}},ma=class extends I{props=[];merges=[];prop(e,t){let n=new ha(e,t);return this.props.push(n),this}merge(e){return this.merges.push(e),this}$render(){let e=l.factory.createTypeLiteralNode(this.$node(this.props));return this.merges.length>0?l.factory.createIntersectionTypeNode([...this.merges.map(e=>this.$type(e)),e]):e}},ha=class extends I{name;typeInput;constructor(e,t){super(),this.name=e,t(this)}type(e){return this.typeInput=e,this}$render(){if(!this.typeInput)throw Error(`Type not specified for property '${this.name}'`);return l.factory.createPropertySignature(void 0,this.$expr(this.name),this.questionToken,this.$type(this.typeInput))}};L(ha,vi);var ga=class extends F{kind=l.NodeFlags.None;modifiers=Oi(this);name;_type;constructor(e){super(),this.name=e}const(){return this.kind=l.NodeFlags.Const,this}let(){return this.kind=l.NodeFlags.Let,this}type(e){return this._type=e instanceof I?e:new z(e),this}var(){return this.kind=l.NodeFlags.None,this}$render(){let e=this.$pattern()??this.name;if(!e)throw Error(`Var must have either a name or a destructuring pattern`);return l.factory.createVariableStatement(this.modifiers.list(),l.factory.createVariableDeclarationList([l.factory.createVariableDeclaration(e,void 0,this.$type(this._type),this.$value())],this.kind))}};L(ga,ji,[Di,{overrideRender:!0}],Mi,Ui,Ri);const _a={array:(...e)=>new oi(...e),attr:(...e)=>new yi(...e),await:(...e)=>new bi(...e),binary:(...e)=>new R(...e),call:(...e)=>new Ci(...e),class:(...e)=>new Zi(...e),const:(...e)=>new ga(...e).const(),decorator:(...e)=>new wi(...e),describe:(...e)=>new Ei(...e),expr:(...e)=>new $i(...e),field:(...e)=>new Bi(...e),func:((e,t)=>e===void 0?new ta:typeof e!=`string`||t===void 0?new ta(e):new ta(e,t)),getter:(...e)=>new na(...e),if:(...e)=>new ra(...e),init:(...e)=>new Ki(...e),let:(...e)=>new ga(...e).let(),literal:(...e)=>new ii(...e),method:(...e)=>new Yi(...e),new:(...e)=>new ia(...e),newline:(...e)=>new Xi(...e),not:(...e)=>new aa(...e),object:(...e)=>new sa(...e),param:(...e)=>new Wi(...e),pattern:(...e)=>new Hi(...e),regexp:(...e)=>new ca(...e),return:(...e)=>new la(...e),setter:(...e)=>new oa(...e),template:(...e)=>new ua(...e),throw:(...e)=>new da(...e),type:Object.assign((...e)=>new z(...e),{alias:(...e)=>new fa(...e),attr:(...e)=>new zi(...e),expr:(...e)=>new z(...e),literal:(...e)=>new pa(...e),object:(...e)=>new ma(...e)}),var:(...e)=>new ga(...e)},B=Object.assign((...e)=>new $i(...e),_a),va=`__registry`,ya=({sdkName:e,symbol:t})=>{let n=`defaultKey`,r=`instances`;return B.class(t.placeholder).export(t.exported).generic(`T`).field(n,e=>e.private().readonly().assign(B.literal(`default`))).newline().field(r,e=>e.private().readonly().type(B.type(`Map`).generics(`string`,`T`)).assign(B.new(`Map`))).newline().method(`get`,t=>t.returns(`T`).param(`key`,e=>e.type(`string`).optional()).do(B.const(`instance`).assign(B(`this`).attr(`instances`).attr(`get`).call(B(`key`).coalesce(B(`this`).attr(n)))),B.if(B.not(`instance`)).do(B.throw(`Error`).message(B.template(`No SDK client found. Create one with "new `).add(e).add(`()" to fix this error.`))),B.return(`instance`))).newline().method(`set`,e=>e.returns(`void`).param(`value`,e=>e.type(`T`)).param(`key`,e=>e.type(`string`).optional()).do(B(`this`).attr(r).attr(`set`).call(B(`key`).coalesce(B(`this`).attr(n)),`value`)))},ba=({plugin:e,symbol:t})=>{let n=e.getSymbol({category:`client`}),r=!!(e.config.client&&n),i=e.referenceSymbol({category:`external`,resource:`client.Client`});return B.class(t.placeholder).export(t.exported).field(`client`,e=>e.protected().type(i.placeholder)).newline().init(e=>e.param(`args`,e=>e.optional(r).type(B.type.object().prop(`client`,e=>e.optional(r).type(i.placeholder)))).do(B(`this`).attr(`client`).assign(B(`args`).attr(`client`).optional(r).$if(r,e=>e.coalesce(n.placeholder)))))},xa=({plugin:e})=>{let t=T(e.context.config),n=t.name===`@hey-api/client-angular`,r=t.name===`@hey-api/client-nuxt`,i=new Map,a=new Set;e.forEach(`operation`,({operation:a})=>{let o=cr({context:e.context,operation:a}),s=r?e.querySymbol({category:`type`,resource:`operation`,resourceId:a.id,role:`response`}):void 0,c=rr({context:e.context,operation:a,plugin:e});for(let l of c.values())l.path.forEach((c,u)=>{let d=e.referenceSymbol({category:`utility`,resource:`class`,resourceId:c,tool:`sdk`});i.has(d.meta.resourceId)||i.set(d.meta.resourceId,{className:d.meta.resourceId,classes:new Set,id:d.id,methods:new Set,nodes:[],root:!u});let f=l.path[u-1];if(f){let t=e.referenceSymbol({category:`utility`,resource:`class`,resourceId:f,tool:`sdk`});if(t.meta?.resourceId!==d.meta?.resourceId){let e=i.get(t.meta.resourceId);e.classes.add(d.meta.resourceId),i.set(t.meta.resourceId,e)}}if(l.path.length!==u+1)return;let p=i.get(d.meta.resourceId);if(p.methods.has(l.methodName))return;let m=ar({isRequiredOptions:o,operation:a,plugin:e}),h=sr({isRequiredOptions:o,opParameters:m,operation:a,plugin:e}),g=B.method(l.methodName,i=>i.$if(P({operation:a}),(e,t)=>e.describe(t)).public().static(!n&&!e.config.instance).$if(r,t=>t.generic(Hn,t=>t.extends(e.referenceSymbol({category:`external`,resource:`client.Composable`}).placeholder).default(B.type.literal(`$fetch`))).generic(Un,e=>e.$if(s,(e,t)=>e.extends(t.placeholder).default(t.placeholder))),e=>e.generic(`ThrowOnError`,e=>e.extends(`boolean`).default((`throwOnError`in t.config?t.config.throwOnError:!1)??!1))).params(...jt(m.parameters)).do(...h));p.nodes.length?p.nodes.push(B.newline(),g):p.nodes.push(g),p.methods.add(l.methodName),i.set(d.meta.resourceId,p)})},{order:`declarations`});let o=e.config.instance?e.registerSymbol({exported:!1,kind:`class`,meta:{category:`utility`,resource:`class`,resourceId:`HeyApiClient`,tool:`sdk`},name:`HeyApiClient`}):void 0,s=e.config.instance?e.registerSymbol({exported:!1,kind:`class`,meta:{category:`utility`,resource:`class`,resourceId:`HeyApiRegistry`,tool:`sdk`},name:`HeyApiRegistry`}):void 0,c=t=>{if(a.has(t.className))return;let r=t.className;if(a.add(r),t.classes.size)for(let n of t.classes){let r=i.get(n);c(r);let a=e.referenceSymbol({category:`utility`,resource:`class`,resourceId:r.className,tool:`sdk`}),o=b({case:`camelCase`,value:a.meta.resourceId});if(t.methods.has(o)){let e=2,n=`${o}${e}`;for(;t.methods.has(n);)n=`${o}${e++}`;o=n}t.methods.add(o);let s=e.isSymbolRegistered(a.id)?B.field(o,t=>t.static(!e.config.instance).assign(e.config.instance?B.new(a.placeholder).args(B.object().prop(`client`,B(`this`).attr(`client`))):B(a.placeholder))):B.getter(o,t=>t.$if(!e.config.instance,e=>e.public().static()).do(B.return(e.config.instance?B.new(a.placeholder).args(B.object().prop(`client`,B(`this`).attr(`client`))):a.placeholder)));t.nodes.length?t.nodes.push(B.newline(),s):t.nodes.push(s)}if(o&&!e.gen.symbols.hasValue(o.id)){let t=ba({plugin:e,symbol:o});e.setSymbolValue(o,t)}let l=e.registerSymbol({exported:!0,kind:`class`,meta:{category:`utility`,resource:`class`,resourceId:r,tool:`sdk`},name:r});if(t.root&&s){let n=e.getSymbol({category:`client`}),r=!e.config.client||!n,i=e.referenceSymbol({category:`external`,resource:`client.Client`}),a=B.init(e=>e.param(`args`,e=>e.optional(!r).type(B.type.object().prop(`client`,e=>e.optional(!r).type(i.placeholder)).prop(`key`,e=>e.optional().type(`string`)))).do(B(`super`).call(`args`),B(l.placeholder).attr(va).attr(`set`).call(`this`,B(`args`).attr(`key`).optional(!r))));t.nodes.length?t.nodes.unshift(a,B.newline()):t.nodes.unshift(a);let o=ya({plugin:e,sdkName:l.placeholder,symbol:s});e.setSymbolValue(s,o);let c=B.field(va,e=>e.public().static().readonly().assign(B.new(s.placeholder).generic(l.placeholder)));t.nodes.unshift(c,B.newline())}let u=B.class(l.placeholder).export(l.exported).extends(o?.placeholder).$if(t.root&&n,t=>t.decorator(e.referenceSymbol({category:`external`,resource:`@angular/core.Injectable`}).placeholder,B.object().prop(`providedIn`,B.literal(`root`)))).do(...t.nodes);e.setSymbolValue(l,u)};for(let e of i.values())c(e)},Sa=({id:e,operation:t,plugin:n})=>n.config.methodNameBuilder?n.config.methodNameBuilder(t):e.match(ct)?`${e}_`:e,Ca=({plugin:e})=>{let t=T(e.context.config),n=t.name===`@hey-api/client-nuxt`;e.forEach(`operation`,r=>{let{operation:i}=r,a=cr({context:e.context,operation:i}),o=n?e.querySymbol({category:`type`,resource:`operation`,resourceId:i.id,role:`response`}):void 0,s=ar({isRequiredOptions:a,operation:i,plugin:e}),c=sr({isRequiredOptions:a,opParameters:s,operation:i,plugin:e}),l=e.registerSymbol({meta:{category:`sdk`,path:r._path,resource:`operation`,resourceId:i.id,tags:r.tags,tool:`sdk`},name:Sa({id:i.id,operation:i,plugin:e})}),u=M.constVariable({comment:P({operation:i}),exportConst:!0,expression:M.arrowFunction({parameters:s.parameters,returnType:void 0,statements:c,types:n?[{default:M.ots.string(`$fetch`),extends:M.typeNode(e.referenceSymbol({category:`external`,resource:`client.Composable`}).placeholder),name:Hn},{default:o?M.typeReferenceNode({typeName:o.placeholder}):M.typeNode(`undefined`),extends:o?M.typeReferenceNode({typeName:o.placeholder}):void 0,name:Un}]:[{default:(`throwOnError`in t.config?t.config.throwOnError:!1)??!1,extends:`boolean`,name:`ThrowOnError`}]}),name:l.placeholder});e.setSymbolValue(l,u)},{order:`declarations`})},wa=({plugin:e})=>{let t=Dr(e.context.config),n=T(e.context.config),r=n.name===`@hey-api/client-nuxt`,i=e.registerSymbol({external:t,kind:`type`,name:`TDataShape`}),a=e.registerSymbol({external:t,kind:`type`,meta:{category:`external`,resource:`client.Client`,tool:n.name},name:`Client`}),o=e.registerSymbol({external:t,kind:`type`,name:`Options`}),s=e.registerSymbol({exported:!0,kind:`type`,meta:{category:`type`,resource:`client-options`,tool:`sdk`},name:`Options`}),c=M.typeAliasDeclaration({exportType:s.exported,name:s.placeholder,type:M.typeIntersectionNode({types:[M.typeReferenceNode({typeArguments:r?[M.typeReferenceNode({typeName:`TComposable`}),M.typeReferenceNode({typeName:`TData`}),M.typeReferenceNode({typeName:Wn}),M.typeReferenceNode({typeName:Un})]:[M.typeReferenceNode({typeName:`TData`}),M.typeReferenceNode({typeName:`ThrowOnError`})],typeName:o.placeholder}),M.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&&!e.config.instance,name:`client`,type:M.typeReferenceNode({typeName:a.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:!1,name:`meta`,type:M.typeReferenceNode({typeArguments:[M.keywordTypeNode({keyword:`string`}),M.keywordTypeNode({keyword:`unknown`})],typeName:`Record`})}],useLegacyResolution:!1})]}),typeParameters:r?[M.typeParameterDeclaration({constraint:M.typeReferenceNode({typeName:e.referenceSymbol({category:`external`,resource:`client.Composable`}).placeholder}),defaultType:M.typeNode(`'$fetch'`),name:`TComposable`}),M.typeParameterDeclaration({constraint:M.typeReferenceNode({typeName:i.placeholder}),defaultType:M.typeReferenceNode({typeName:i.placeholder}),name:`TData`}),M.typeParameterDeclaration({defaultType:M.keywordTypeNode({keyword:`unknown`}),name:Wn}),M.typeParameterDeclaration({defaultType:M.keywordTypeNode({keyword:`undefined`}),name:Un})]:[M.typeParameterDeclaration({constraint:M.typeReferenceNode({typeName:i.placeholder}),defaultType:M.typeReferenceNode({typeName:i.placeholder}),name:`TData`}),M.typeParameterDeclaration({constraint:M.keywordTypeNode({keyword:`boolean`}),defaultType:M.keywordTypeNode({keyword:`boolean`}),name:`ThrowOnError`})]});e.setSymbolValue(s,c)},Ta=({plugin:e})=>{let t=Dr(e.context.config),n=T(e.context.config),r=n.name===`@hey-api/client-angular`,i=n.name===`@hey-api/client-nuxt`;e.registerSymbol({external:t,meta:{category:`external`,resource:`client.formDataBodySerializer`,tool:n.name},name:`formDataBodySerializer`}),e.registerSymbol({external:t,meta:{category:`external`,resource:`client.urlSearchParamsBodySerializer`,tool:n.name},name:`urlSearchParamsBodySerializer`}),e.registerSymbol({external:t,meta:{category:`external`,resource:`client.buildClientParams`,tool:n.name},name:`buildClientParams`}),i&&e.registerSymbol({external:t,kind:`type`,meta:{category:`external`,resource:`client.Composable`,tool:n.name},name:`Composable`}),r&&e.config.asClass&&e.registerSymbol({external:`@angular/core`,meta:{category:`external`,resource:`@angular/core.Injectable`},name:`Injectable`}),wa({plugin:e}),e.config.asClass?xa({plugin:e}):Ca({plugin:e})},Ea={config:{asClass:!1,auth:!0,classNameBuilder:`{{name}}`,classStructure:`auto`,client:!0,exportFromIndex:!0,instance:!1,operationId:!0,paramsStructure:`grouped`,response:`body`,responseStyle:`fields`,transformer:!1,validator:!1},dependencies:[`@hey-api/typescript`],handler:e=>Ta(e),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=!1,e.config.transformer?(typeof e.config.transformer==`boolean`&&(e.config.transformer=t.pluginByTag(`transformer`)),e.dependencies.add(e.config.transformer)):e.config.transformer=!1,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=!1,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=!1,e.config.instance?(typeof e.config.instance!=`string`&&(e.config.instance=`Sdk`),e.config.asClass=!0):e.config.instance=!1,e.config.classNameBuilder===`{{name}}`&&e.config.client===`@hey-api/client-angular`&&(e.config.classNameBuilder=`{{name}}Service`)}},Da=({dataExpression:e,schema:t})=>{if(t.type!==`integer`||t.format!==`int64`)return;let n=e===void 0?void 0:M.callExpression({functionName:`BigInt`,parameters:[M.callExpression({functionName:M.propertyAccessExpression({expression:e,name:`toString`})})]});if(n){if(typeof e==`string`)return[n];if(e)return[M.assignment({left:e,right:n})]}},Oa=({dataExpression:e,schema:t})=>{if(t.type!==`string`||!(t.format===`date`||t.format===`date-time`))return;let n=M.identifier({text:`Date`});if(typeof e==`string`)return[M.newExpression({argumentsArray:[M.identifier({text:e})],expression:n})];if(e)return[M.assignment({left:e,right:M.newExpression({argumentsArray:[e],expression:n})})]},ka=`data`,Aa=new Set,ja=e=>e.map(e=>l.isStatement(e)?e:M.expressionToStatement({expression:e})),Ma=({node:e})=>e.kind===l.SyntaxKind.ReturnStatement,Na=({plugin:e,schema:t})=>{let n=M.identifier({text:ka}),r=Pa({dataExpression:n,plugin:e,schema:t});return r.length&&!Ma({node:r[r.length-1]})&&r.push(M.returnStatement({expression:n})),r},Pa=({dataExpression:e,plugin:t,schema:n})=>{if(n.$ref){let r={category:`transform`,resource:`definition`,resourceId:n.$ref},i=t.getSymbol(r);if(i||(i=t.registerSymbol({meta:r,name:x({config:{case:`camelCase`,name:`{{name}}SchemaResponseTransformer`},name:N(n.$ref)})}),t.setSymbolValue(i,null)),!t.gen.symbols.getValue(i.id)&&!Aa.has(i.id)){Aa.add(i.id);try{let e=Na({plugin:t,schema:t.context.resolveIrRef(n.$ref)});if(e.length){let n=M.constVariable({expression:M.arrowFunction({async:!1,multiLine:!0,parameters:[{name:ka,type:M.keywordTypeNode({keyword:`any`})}],statements:ja(e)}),name:i.placeholder});t.setSymbolValue(i,n)}}finally{Aa.delete(i.id)}}if(t.gen.symbols.getValue(i.id)||Aa.has(i.id)){let n=t.referenceSymbol(r),i=M.callExpression({functionName:n.placeholder,parameters:[e]});if(e)return typeof e==`string`&&e===`item`?[M.returnStatement({expression:i})]:[typeof e==`string`?i:M.assignment({left:e,right:i})]}return[]}if(n.type===`array`){if(!e||typeof e==`string`)return[];let r=n.items?Pa({dataExpression:`item`,plugin:t,schema:n.items?.[0]?n.items[0]:{...n,type:void 0}}):[];if(!r.length)return[];let i=ja(r);return i.some(e=>Ma({node:e}))||i.push(M.returnStatement({expression:M.identifier({text:`item`})})),[M.assignment({left:e,right:M.callExpression({functionName:M.propertyAccessExpression({expression:e,name:`map`}),parameters:[M.arrowFunction({multiLine:!0,parameters:[{name:`item`,type:`any`}],statements:i})]})})]}if(n.type===`object`){let r=[],i=n.required??[];for(let a in n.properties){let o=n.properties[a],s=M.propertyAccessExpression({expression:e||ka,name:a}),c=Pa({dataExpression:s,plugin:t,schema:o});if(!c.length)continue;let l=!o.items?.find(e=>e.type===`null`);i.includes(a)&&l?r=r.concat(c):r.push(M.ifStatement({expression:s,thenStatement:M.block({statements:ja(c)})}))}return r}if(n.items){if(n.items.length===1)return Pa({dataExpression:`item`,plugin:t,schema:n.items[0]});let r=[];if(n.logicalOperator===`and`||n.items.length===2&&n.items.find(e=>e.type===`null`||e.type===`void`)){for(let i of n.items){let n=Pa({dataExpression:e||`item`,plugin:t,schema:i});if(n.length)if(e)r=r.concat(n);else{let e=M.identifier({text:`item`});r.push(M.ifStatement({expression:e,thenStatement:M.block({statements:ja(n)})}),M.returnStatement({expression:e}))}}return r}n.type!==`enum`&&((n.items??[]).every(e=>[`boolean`,`integer`,`null`,`number`,`string`].includes(e.type))||console.warn(`❗️ Transformers warning: schema ${JSON.stringify(n)} 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 r of t.config.transformers){let i=r({config:t.config,dataExpression:e,schema:n});if(i)return i}return[]},Fa={config:{bigInt:!0,dates:!0,exportFromIndex:!1,transformers:[],typeTransformers:[]},dependencies:[`@hey-api/typescript`],handler:({plugin:e})=>{e.forEach(`operation`,({operation:t})=>{let{response:n}=tt(t);if(!n)return;if(n.items&&n.items.length>1){e.context.config.logs.level===`debug`&&console.warn(`❗️ Transformers warning: route ${w(t)} has ${n.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 r=e.querySymbol({category:`type`,resource:`operation`,resourceId:t.id,role:`response`});if(!r)return;let i=Na({plugin:e,schema:n});if(!i.length)return;let a=e.registerSymbol({exported:!0,meta:{category:`transform`,resource:`operation`,resourceId:t.id,role:`response`},name:x({config:{case:`camelCase`,name:`{{name}}ResponseTransformer`},name:t.id})}),o=M.constVariable({exportConst:a.exported,expression:M.arrowFunction({async:!0,multiLine:!0,parameters:[{name:ka,type:M.keywordTypeNode({keyword:`any`})}],returnType:M.typeReferenceNode({typeArguments:[M.typeReferenceNode({typeName:r.placeholder})],typeName:`Promise`}),statements:ja(i)}),name:a.placeholder});e.setSymbolValue(a,o)},{order:`declarations`})},name:`@hey-api/transformers`,resolveConfig:e=>{e.config.transformers||(e.config.transformers=[]),e.config.dates&&(e.config.transformers=[...e.config.transformers,Oa]),e.config.bigInt&&(e.config.transformers=[...e.config.transformers,Da])},tags:[`transformer`]},Ia=M.keywordTypeNode({keyword:`string`}),La=({server:e})=>{let t=Nr(e.url);return t.protocol&&t.host?M.literalTypeNode({literal:M.stringLiteral({text:e.url})}):M.templateLiteralType({value:[t.protocol||Ia,`://`,t.host||Ia,t.port?`:${t.port}`:``,t.path||``]})},Ra=({plugin:e,servers:t,symbolClientOptions:n})=>{let r=T(e.context.config),i=t.map(e=>La({server:e}));t.length?`strictBaseUrl`in r.config&&r.config.strictBaseUrl||i.push(M.typeIntersectionNode({types:[Ia,l.factory.createTypeLiteralNode([])]})):i.push(Ia);let a=M.typeInterfaceNode({properties:[{name:rt(e.context.config),type:M.typeUnionNode({types:i})}],useLegacyResolution:!1}),o=M.typeAliasDeclaration({exportType:n.exported,name:n.placeholder,type:a});e.setSymbolValue(n,o)},za=({schema:e})=>{let t=[];return e.title&&t.push(mt(e.title)),e.description&&(t.length&&t.push(``),t.push(mt(e.description))),e.deprecated&&(t.length&&t.push(``),t.push(`@deprecated`)),t.length?t:void 0},Ba=({plugin:e,schema:t})=>{let n=[];return{obj:(t.items??[]).map((t,r)=>{let i=typeof t.const;n.includes(i)||n.push(i);let a;return a=t.title?t.title:i===`number`||i===`string`?`${t.const}`:i===`boolean`?t.const?`true`:`false`:t.const===null?`null`:`${r}`,a&&(a=b({case:e.config.enums.case,stripLeadingSeparators:!1,value:a}),at.lastIndex=0,at.test(a)&&e.config.enums.enabled&&(e.config.enums.mode===`typescript`||e.config.enums.mode===`typescript-const`)&&(a=`_${a}`)),{comments:za({schema:t}),key:a,value:t.const}}),typeofItems:n}},Va=({plugin:e,schema:t,symbol:n,type:r})=>{if(t.type===`enum`&&e.config.enums.enabled){let r=Ba({plugin:e,schema:t});if(e.config.enums.mode===`javascript`){e.config.enums.constantsIgnoreNull&&r.typeofItems.includes(`object`)&&(r.obj=r.obj.filter(e=>e.value!==null));let i=M.constVariable({assertion:`const`,comment:za({schema:t}),exportConst:!0,expression:M.objectExpression({multiLine:!0,obj:r.obj}),name:n.placeholder}),a=M.typeOfExpression({text:n.placeholder}),o=M.typeAliasDeclaration({comment:za({schema:t}),exportType:!0,name:n.placeholder,type:M.indexedAccessTypeNode({indexType:M.typeOperatorNode({operator:`keyof`,type:a}),objectType:a})});e.setSymbolValue(n,[i,o]);return}else if((e.config.enums.mode===`typescript`||e.config.enums.mode===`typescript-const`)&&!r.typeofItems.some(e=>e!==`number`&&e!==`string`)){let i=M.enumDeclaration({asConst:e.config.enums.mode===`typescript-const`,leadingComment:za({schema:t}),name:n.placeholder,obj:r.obj});e.setSymbolValue(n,i);return}}let i=M.typeAliasDeclaration({comment:za({schema:t}),exportType:n.exported,name:n.placeholder,type:r});e.setSymbolValue(n,i)},Ha=({parameters:e})=>{let t={type:`object`};if(e){let n={},r=[];for(let t in e){let i=e[t];n[i.name]=S({detectFormat:!1,schema:i.schema}),i.required&&r.push(i.name)}t.properties=n,r.length&&(t.required=r)}return t},Ua=({operation:e,plugin:t,state:n})=>{let r={type:`object`},i=[];r.properties||={},e.body?(r.properties.body=e.body.schema,e.body.required&&i.push(`body`)):r.properties.body={type:`never`},e.parameters?.header&&(r.properties.headers=Ha({parameters:e.parameters.header}),r.properties.headers.required&&i.push(`headers`)),e.parameters?.path?(r.properties.path=Ha({parameters:e.parameters.path}),r.properties.path.required&&i.push(`path`)):r.properties.path={type:`never`},e.parameters?.query?(r.properties.query=Ha({parameters:e.parameters.query}),r.properties.query.required&&i.push(`query`)):r.properties.query={type:`never`},r.properties.url={const:e.path,type:`string`},i.push(`url`),r.required=i;let a=t.registerSymbol({exported:!0,kind:`type`,meta:{category:`type`,path:n.path.value,resource:`operation`,resourceId:e.id,role:`data`,tags:n.tags?.value,tool:`typescript`},name:x({config:t.config.requests,name:e.id})}),o=V({plugin:t,schema:r,state:n}),s=M.typeAliasDeclaration({exportType:a.exported,name:a.placeholder,type:o});t.setSymbolValue(a,s)},Wa=({operation:e,plugin:t,state:n})=>{Ua({operation:e,plugin:t,state:n});let{error:r,errors:i,response:a,responses:o}=tt(e);if(i){let a=t.registerSymbol({exported:!0,kind:`type`,meta:{category:`type`,path:n.path.value,resource:`operation`,resourceId:e.id,role:`errors`,tags:n.tags?.value,tool:`typescript`},name:x({config:t.config.errors,name:e.id})}),o=V({plugin:t,schema:i,state:n}),s=M.typeAliasDeclaration({exportType:a.exported,name:a.placeholder,type:o});if(t.setSymbolValue(a,s),r){let r=t.registerSymbol({exported:!0,kind:`type`,meta:{category:`type`,path:n.path.value,resource:`operation`,resourceId:e.id,role:`error`,tags:n.tags?.value,tool:`typescript`},name:x({config:{case:t.config.errors.case,name:t.config.errors.error},name:e.id})}),i=M.indexedAccessTypeNode({indexType:M.typeOperatorNode({operator:`keyof`,type:M.typeReferenceNode({typeName:a.placeholder})}),objectType:M.typeReferenceNode({typeName:a.placeholder})}),o=M.typeAliasDeclaration({exportType:r.exported,name:r.placeholder,type:i});t.setSymbolValue(r,o)}}if(o){let r=t.registerSymbol({exported:!0,kind:`type`,meta:{category:`type`,path:n.path.value,resource:`operation`,resourceId:e.id,role:`responses`,tags:n.tags?.value,tool:`typescript`},name:x({config:t.config.responses,name:e.id})}),i=V({plugin:t,schema:o,state:n}),s=M.typeAliasDeclaration({exportType:r.exported,name:r.placeholder,type:i});if(t.setSymbolValue(r,s),a){let i=t.registerSymbol({exported:!0,kind:`type`,meta:{category:`type`,path:n.path.value,resource:`operation`,resourceId:e.id,role:`response`,tags:n.tags?.value,tool:`typescript`},name:x({config:{case:t.config.responses.case,name:t.config.responses.response},name:e.id})}),a=M.indexedAccessTypeNode({indexType:M.typeOperatorNode({operator:`keyof`,type:M.typeReferenceNode({typeName:r.placeholder})}),objectType:M.typeReferenceNode({typeName:r.placeholder})}),o=M.typeAliasDeclaration({exportType:i.exported,name:i.placeholder,type:a});t.setSymbolValue(i,o)}}},Ga=({operation:e,plugin:t,state:n})=>{let r={type:`object`},i=[];if(r.properties||={},e.body){let a=t.registerSymbol({exported:!0,kind:`type`,meta:{category:`type`,path:n.path.value,resource:`webhook`,resourceId:e.id,role:`data`,tags:n.tags?.value,tool:`typescript`},name:x({config:{case:t.config.webhooks.case,name:t.config.webhooks.payload},name:e.id})}),o=V({plugin:t,schema:e.body.schema,state:n}),s=M.typeAliasDeclaration({comment:za({schema:e.body.schema}),exportType:a.exported,name:a.placeholder,type:o});t.setSymbolValue(a,s),t.registerSymbol({exported:!0,kind:`type`,meta:{category:`type`,path:n.path.value,resource:`definition`,resourceId:a.placeholder,tags:n.tags?.value,tool:`typescript`},name:a.name,placeholder:a.placeholder}),r.properties.body={$ref:a.placeholder},i.push(`body`)}else r.properties.body={type:`never`};r.properties.key={const:e.path,type:`string`},i.push(`key`),r.properties.path={type:`never`},r.properties.query={type:`never`},r.required=i;let a=t.registerSymbol({exported:!0,kind:`type`,meta:{category:`type`,path:n.path.value,resource:`webhook`,resourceId:e.id,role:`data`,tags:n.tags?.value,tool:`typescript`},name:x({config:t.config.webhooks,name:e.id})}),o=V({plugin:t,schema:r,state:n}),s=M.typeAliasDeclaration({exportType:a.exported,name:a.placeholder,type:o});return t.setSymbolValue(a,s),a.placeholder},Ka=({operation:e,plugin:t,state:n})=>Ga({operation:e,plugin:t,state:n}),qa=({plugin:e,symbolWebhooks:t,webhookNames:n})=>{if(!n.length)return;let r=M.typeUnionNode({types:n.map(e=>M.typeReferenceNode({typeName:e}))}),i=M.typeAliasDeclaration({exportType:t.exported,name:t.placeholder,type:r});e.setSymbolValue(t,i)},Ja=({plugin:e,schema:t,state:n})=>{if(!t.items)return M.typeArrayNode(M.keywordTypeNode({keyword:e.config.topType}));t=S({detectFormat:!0,schema:t});let r=[];return t.items&&t.items.forEach((t,i)=>{let a=V({plugin:e,schema:t,state:{...n,path:E([...n.path.value,`items`,i])}});r.push(a)}),r.length===1?M.typeArrayNode(r[0]):t.logicalOperator===`and`?M.typeArrayNode(M.typeIntersectionNode({types:r})):M.typeArrayNode(M.typeUnionNode({types:r}))},Ya=({schema:e})=>e.const===void 0?M.keywordTypeNode({keyword:`boolean`}):M.literalTypeNode({literal:M.ots.boolean(e.const)}),Xa=({plugin:e,schema:t,state:n})=>V({plugin:e,schema:{...t,type:void 0},state:n}),Za=e=>M.keywordTypeNode({keyword:`never`}),Qa=e=>M.literalTypeNode({literal:M.null()}),$a=({plugin:e,schema:t})=>t.const===void 0?t.type===`integer`&&t.format===`int64`&&e.getPlugin(`@hey-api/transformers`)?.config.bigInt?M.typeReferenceNode({typeName:`bigint`}):M.keywordTypeNode({keyword:`number`}):M.literalTypeNode({literal:M.ots.number(t.const)}),eo=({context:e,name:t})=>(at.lastIndex=0,at.test(t)?t.startsWith(`-`)?l.factory.createStringLiteral(t):l.factory.createNumericLiteral(t):b({case:e.config.output.case,value:t})),to=({plugin:e,schema:t,state:n})=>{let r,i,a=[],o=[],s=t.required??[],c=!1;for(let r in t.properties){let i=t.properties[r],l=V({plugin:e,schema:i,state:{...n,path:E([...n.path.value,`properties`,r])}}),u=s.includes(r);a.push({comment:za({schema:i}),isReadOnly:i.accessScope===`read`,isRequired:u,name:eo({context:e.context,name:r}),type:l}),o.push(i),u||(c=!0)}if(t.patternProperties)for(let e in t.patternProperties){let n=t.patternProperties[e];o.unshift(n)}let l=!!t.patternProperties&&Object.keys(t.patternProperties).length>0,u=t.additionalProperties,d=u!==!1&&u?u:void 0;if(l||d&&(d.type!==`never`||!o.length)){let a=d;a&&a.type!==`never`?o.unshift(a):!l&&!o.length&&a&&a.type===`never`&&(o=[a]),c&&o.push({type:`undefined`}),i={isRequired:!t.propertyNames,name:`key`,type:o.length===1?V({plugin:e,schema:o[0],state:n}):V({plugin:e,schema:{items:o,logicalOperator:`or`},state:n})},t.propertyNames?.$ref&&(r=V({plugin:e,schema:{$ref:t.propertyNames.$ref},state:n}))}return M.typeInterfaceNode({indexKey:r,indexProperty:i,properties:a,useLegacyResolution:!1})},no=({plugin:e,schema:t})=>{if(t.const!==void 0)return M.literalTypeNode({literal:M.stringLiteral({text:t.const})});if(t.format){if(t.format===`binary`)return M.typeUnionNode({types:[M.typeReferenceNode({typeName:`Blob`}),M.typeReferenceNode({typeName:`File`})]});if((t.format===`date-time`||t.format===`date`)&&e.getPlugin(`@hey-api/transformers`)?.config.dates)return M.typeReferenceNode({typeName:`Date`});if(t.format===`typeid`&&typeof t.example==`string`){let n=String(t.example).split(`_`);n.pop();let r=n.join(`_`),i={category:`type`,resource:`type-id`,resourceId:r,tool:`typescript`};if(!e.getSymbol(i)){let t={category:`type`,resource:`type-id`,tool:`typescript`,variant:`container`};if(!e.getSymbol(t)){let n=e.registerSymbol({exported:!0,kind:`type`,meta:t,name:`TypeID`}),r=M.typeAliasDeclaration({exportType:n.exported,name:n.placeholder,type:M.templateLiteralType({value:[M.typeReferenceNode({typeName:`T`}),`_`,M.keywordTypeNode({keyword:`string`})]}),typeParameters:[M.typeParameterDeclaration({constraint:M.keywordTypeNode({keyword:`string`}),name:`T`})]});e.setSymbolValue(n,r)}let n=e.referenceSymbol(t),a=e.registerSymbol({exported:!0,kind:`type`,meta:i,name:b({case:e.config.case,value:`${r}_id`})}),o=M.typeAliasDeclaration({exportType:a.exported,name:a.placeholder,type:M.typeReferenceNode({typeArguments:[M.literalTypeNode({literal:M.stringLiteral({text:r})})],typeName:n.placeholder})});e.setSymbolValue(a,o)}let a=e.referenceSymbol(i);return M.typeReferenceNode({typeName:a.placeholder})}}return M.keywordTypeNode({keyword:`string`})},ro=({plugin:e,schema:t,state:n})=>{let r=[];return t.const&&Array.isArray(t.const)?r=t.const.map(t=>M.valueToExpression({value:t})??M.identifier({text:e.config.topType})):t.items&&t.items.forEach((t,i)=>{let a=V({plugin:e,schema:t,state:{...n,path:E([...n.path.value,`items`,i])}});r.push(a)}),M.typeTupleNode({types:r})},io=e=>M.keywordTypeNode({keyword:`undefined`}),ao=({plugin:e})=>M.keywordTypeNode({keyword:e.config.topType}),oo=e=>M.keywordTypeNode({keyword:`void`}),so=({schema:e,...t})=>{let n=t.plugin.getPlugin(`@hey-api/transformers`);if(n?.config.typeTransformers)for(let t of n.config.typeTransformers){let n=t({schema:e});if(n)return n}switch(e.type){case`array`:return Ja({...t,schema:e});case`boolean`:return Ya({...t,schema:e});case`enum`:return Xa({...t,schema:e});case`integer`:case`number`:return $a({...t,schema:e});case`never`:return Za({...t,schema:e});case`null`:return Qa({...t,schema:e});case`object`:return to({...t,schema:e});case`string`:return no({...t,schema:e});case`tuple`:return ro({...t,schema:e});case`undefined`:return io({...t,schema:e});case`unknown`:return ao({...t,schema:e});case`void`:return oo({...t,schema:e})}},V=({plugin:e,schema:t,state:n})=>{if(t.$ref){let n=e.referenceSymbol({category:`type`,resource:`definition`,resourceId:t.$ref});return M.typeReferenceNode({typeName:n.placeholder})}if(t.type)return so({plugin:e,schema:t,state:n});if(t.items){if(t=S({detectFormat:!1,schema:t}),t.items){let r=[];for(let i of t.items){let t=V({plugin:e,schema:i,state:n});r.push(t)}return t.logicalOperator===`and`?M.typeIntersectionNode({types:r}):M.typeUnionNode({types:r})}return V({plugin:e,schema:t,state:n})}return so({plugin:e,schema:{type:`unknown`},state:n})},co=({plugin:e,schema:t,state:n})=>{let r=V({plugin:e,schema:t,state:n}),i=t.type===`enum`&&e.config.enums.enabled,a=Xn(n.path.value);Va({plugin:e,schema:t,symbol:e.registerSymbol({exported:!0,kind:i?void 0:`type`,meta:{category:`type`,path:n.path.value,resource:`definition`,resourceId:a,tags:n.tags?.value,tool:`typescript`},name:x({config:e.config.definitions,name:N(a)})}),type:r})},lo=({plugin:e})=>{let t=e.registerSymbol({exported:!0,kind:`type`,meta:{category:`type`,resource:`client`,role:`options`,tool:`typescript`},name:x({config:{case:e.config.case},name:`ClientOptions`})}),n=e.registerSymbol({exported:!0,kind:`type`,meta:{category:`type`,resource:`webhook`,tool:`typescript`,variant:`container`},name:x({config:{case:e.config.case},name:`Webhooks`})}),r=[],i=[];e.forEach(`operation`,`parameter`,`requestBody`,`schema`,`server`,`webhook`,t=>{let n=D({path:t._path,tags:t.tags});switch(t.type){case`operation`:Wa({operation:t.operation,plugin:e,state:n});break;case`parameter`:co({plugin:e,schema:t.parameter.schema,state:n});break;case`requestBody`:co({plugin:e,schema:t.requestBody.schema,state:n});break;case`schema`:co({plugin:e,schema:t.schema,state:n});break;case`server`:r.push(t.server);break;case`webhook`:i.push(Ka({operation:t.operation,plugin:e,state:n}));break}},{order:`declarations`}),Ra({plugin:e,servers:r,symbolClientOptions:t}),qa({plugin:e,symbolWebhooks:n,webhookNames:i})},uo={api:new class{schemaToType(e){return V(e)}},config:{case:`PascalCase`,exportFromIndex:!0,topType:`unknown`},handler:e=>lo(e),name:`@hey-api/typescript`,resolveConfig:(e,t)=>{e.config.definitions=t.valueToObject({defaultValue:{case:e.config.case??`PascalCase`,name:`{{name}}`},mappers:{function:e=>({name:e}),string:e=>({name:e})},value:e.config.definitions}),e.config.enums=t.valueToObject({defaultValue:{case:`SCREAMING_SNAKE_CASE`,constantsIgnoreNull:!1,enabled:!!e.config.enums,mode:`javascript`},mappers:{boolean:e=>({enabled:e}),string:e=>({mode:e})},value:e.config.enums}),e.config.errors=t.valueToObject({defaultValue:{case:e.config.case??`PascalCase`,error:`{{name}}Error`,name:`{{name}}Errors`},mappers:{function:e=>({name:e}),string:e=>({name:e})},value:e.config.errors}),e.config.requests=t.valueToObject({defaultValue:{case:e.config.case??`PascalCase`,name:`{{name}}Data`},mappers:{function:e=>({name:e}),string:e=>({name:e})},value:e.config.requests}),e.config.responses=t.valueToObject({defaultValue:{case:e.config.case??`PascalCase`,name:`{{name}}Responses`,response:`{{name}}Response`},mappers:{function:e=>({name:e}),string:e=>({name:e})},value:e.config.responses}),e.config.webhooks=t.valueToObject({defaultValue:{case:e.config.case??`PascalCase`,name:`{{name}}WebhookRequest`,payload:`{{name}}WebhookPayload`},mappers:{function:e=>({name:e}),string:e=>({name:e})},value:e.config.webhooks})}},fo=(e,t,n)=>{let r=e.config[n].meta;if(!r)return;let i=r(t);if(Object.keys(i).length)return M.valueToExpression({value:i})},po=({operation:e,plugin:t})=>ir({operation:e,plugin:t.getPluginOrThrow(`@hey-api/sdk`)}),mo=({operation:e,plugin:t})=>{let n=T(t.context.config),r=t.querySymbol({category:`type`,resource:`operation`,resourceId:e.id,role:`error`})?.placeholder;return r||=`Error`,n.name===`@hey-api/client-axios`&&(r=`${t.referenceSymbol({category:`external`,resource:`axios.AxiosError`}).placeholder}<${r}>`),r},ho=({operation:e,plugin:t})=>t.querySymbol({category:`type`,resource:`operation`,resourceId:e.id,role:`response`})?.placeholder||`unknown`,go=({plugin:e,typeData:t})=>{let n=T(e.context.config).name===`@hey-api/client-nuxt`;return{isNuxtClient:n,strippedTypeData:n?`Omit<${t}, 'composable'>`:t}},_o=({operation:e,plugin:t,queryFn:n})=>{let r=t.referenceSymbol({category:`external`,resource:`${t.name}.UseMutationOptions`}),i=po({operation:e,plugin:t}),a=mo({operation:e,plugin:t}),o=ho({operation:e,plugin:t}),{isNuxtClient:s,strippedTypeData:c}=go({plugin:t,typeData:i}),l=s?`${r.placeholder}<${o}, ${c}, ${a}>`:`${r.placeholder}<${o}, ${i}, ${a}>`,u=`fnOptions`,d=M.awaitExpression({expression:M.callExpression({functionName:n,parameters:[M.objectExpression({multiLine:!0,obj:[{spread:`options`},{spread:u},{key:`throwOnError`,value:!0}]})]})}),f=[];t.getPluginOrThrow(`@hey-api/sdk`).config.responseStyle===`data`?f.push(M.returnVariable({expression:d})):f.push(M.constVariable({destructure:!0,expression:d,name:`data`}),M.returnVariable({expression:`data`}));let p=[{key:`mutation`,value:M.arrowFunction({async:!0,multiLine:!0,parameters:[s?{name:u,type:`Partial<${c}>`}:{name:u}],statements:f})}],m=fo(t,e,`mutationOptions`);m&&p.push({key:`meta`,value:m});let h=t.registerSymbol({exported:!0,name:x({config:t.config.mutationOptions,name:e.id})}),g=M.constVariable({comment:t.config.comments?P({operation:e}):void 0,exportConst:h.exported,expression:M.arrowFunction({parameters:[{isRequired:!1,name:`options`,type:`Partial<${c}>`}],returnType:l,statements:[M.returnStatement({expression:M.objectExpression({obj:p})})]}),name:h.placeholder});t.setSymbolValue(h,g)},vo=`TOptions`,yo=M.identifier({text:`options`}),bo=({plugin:e})=>{let t=e.registerSymbol({meta:{category:`utility`,resource:`createQueryKey`,tool:e.name},name:x({config:{case:e.config.case},name:`createQueryKey`})}),n=e.referenceSymbol({category:`type`,resource:`QueryKey`,tool:e.name}),r=e.referenceSymbol({category:`external`,resource:`${e.name}._JSONValue`}),i=M.indexedAccessTypeNode({indexType:M.literalTypeNode({literal:M.ots.number(0)}),objectType:M.typeReferenceNode({typeArguments:[M.typeReferenceNode({typeName:vo})],typeName:n.placeholder})}),a=rt(e.context.config),o=e.referenceSymbol({category:`type`,resource:`client-options`,tool:`sdk`}),s=e.getSymbol({category:`client`}),c=Dr(e.context.config),l=e.registerSymbol({external:c,meta:{category:`external`,resource:`${c}.serializeQueryKeyValue`},name:`serializeQueryKeyValue`}),u=M.constVariable({expression:M.arrowFunction({multiLine:!0,parameters:[{name:`id`,type:M.typeReferenceNode({typeName:`string`})},{isRequired:!1,name:`options`,type:M.typeReferenceNode({typeName:vo})},{isRequired:!1,name:`tags`,type:M.typeReferenceNode({typeName:`ReadonlyArray<string>`})}],returnType:M.typeTupleNode({types:[i]}),statements:[M.constVariable({assertion:i,expression:M.objectExpression({multiLine:!1,obj:[{key:`_id`,value:M.identifier({text:`id`})},{key:a,value:M.identifier({text:`options?.${a} || (options?.client ?? ${s?.placeholder}).getConfig().${a}`})}]}),name:`params`,typeName:i}),M.ifStatement({expression:M.identifier({text:`tags`}),thenStatement:M.block({statements:[M.expressionToStatement({expression:M.binaryExpression({left:M.propertyAccessExpression({expression:`params`,name:`tags`}),right:M.asExpression({expression:M.asExpression({expression:M.identifier({text:`tags`}),type:M.keywordTypeNode({keyword:`unknown`})}),type:M.typeReferenceNode({typeName:r.placeholder})})})})]})}),M.ifStatement({expression:M.binaryExpression({left:M.propertyAccessExpression({expression:yo,isOptional:!0,name:M.identifier({text:`body`})}),operator:`!==`,right:`undefined`}),thenStatement:M.block({statements:[M.constVariable({expression:M.callExpression({functionName:l.placeholder,parameters:[M.propertyAccessExpression({expression:`options`,name:`body`})]}),name:`normalizedBody`}),M.ifStatement({expression:M.binaryExpression({left:M.identifier({text:`normalizedBody`}),operator:`!==`,right:`undefined`}),thenStatement:M.block({statements:[M.expressionToStatement({expression:M.binaryExpression({left:M.propertyAccessExpression({expression:`params`,name:`body`}),right:M.identifier({text:`normalizedBody`})})})]})})]})}),M.ifStatement({expression:M.propertyAccessExpression({expression:yo,isOptional:!0,name:M.identifier({text:`path`})}),thenStatement:M.block({statements:[M.expressionToStatement({expression:M.binaryExpression({left:M.propertyAccessExpression({expression:`params`,name:`path`}),right:M.propertyAccessExpression({expression:`options`,name:`path`})})})]})}),M.ifStatement({expression:M.binaryExpression({left:M.propertyAccessExpression({expression:yo,isOptional:!0,name:M.identifier({text:`query`})}),operator:`!==`,right:`undefined`}),thenStatement:M.block({statements:[M.constVariable({expression:M.callExpression({functionName:l.placeholder,parameters:[M.propertyAccessExpression({expression:`options`,name:`query`})]}),name:`normalizedQuery`}),M.ifStatement({expression:M.binaryExpression({left:M.identifier({text:`normalizedQuery`}),operator:`!==`,right:`undefined`}),thenStatement:M.block({statements:[M.expressionToStatement({expression:M.binaryExpression({left:M.propertyAccessExpression({expression:`params`,name:`query`}),right:M.identifier({text:`normalizedQuery`})})})]})})]})}),M.returnStatement({expression:M.arrayLiteralExpression({elements:[M.identifier({text:`params`})]})})],types:[{extends:M.typeReferenceNode({typeName:M.identifier({text:o.placeholder})}),name:vo}]}),name:t.placeholder});e.setSymbolValue(t,u)},xo=({id:e,operation:t,plugin:n})=>{let r=n.config.queryKeys,i;r.tags&&t.tags&&t.tags.length>0&&(i=M.arrayLiteralExpression({elements:t.tags.map(e=>M.stringLiteral({text:e}))}));let a=n.referenceSymbol({category:`utility`,resource:`createQueryKey`,tool:n.name});return M.callExpression({functionName:a.placeholder,parameters:[M.ots.string(e),`options`,i]})},So=({plugin:e})=>{let t=e.referenceSymbol({category:`external`,resource:`${e.name}._JSONValue`}),n=[{name:`_id`,type:M.keywordTypeNode({keyword:`string`})},{isRequired:!1,name:rt(e.context.config),type:M.typeReferenceNode({typeName:t.placeholder})},{isRequired:!1,name:`body`,type:M.typeReferenceNode({typeName:t.placeholder})},{isRequired:!1,name:`query`,type:M.typeReferenceNode({typeName:t.placeholder})},{isRequired:!1,name:`tags`,type:M.typeReferenceNode({typeName:t.placeholder})}],r=e.referenceSymbol({category:`type`,resource:`client-options`,tool:`sdk`}),i=e.registerSymbol({exported:!0,kind:`type`,meta:{category:`type`,resource:`QueryKey`,tool:e.name},name:`QueryKey`}),a=M.typeAliasDeclaration({exportType:i.exported,name:i.placeholder,type:M.typeTupleNode({types:[M.typeIntersectionNode({types:[M.typeReferenceNode({typeName:`Pick<${vo}, 'path'>`}),M.typeInterfaceNode({properties:n,useLegacyResolution:!0})]})]}),typeParameters:[{extends:M.typeReferenceNode({typeName:M.identifier({text:r.placeholder})}),name:vo}]});e.setSymbolValue(i,a)},Co=({operation:e,plugin:t,symbol:n})=>{let{strippedTypeData:r}=go({plugin:t,typeData:po({operation:e,plugin:t})});return M.constVariable({exportConst:n.exported,expression:M.arrowFunction({parameters:[{isRequired:Qe(e),name:`options`,type:r}],statements:xo({id:e.id,operation:e,plugin:t})}),name:n.placeholder})},wo=`options`,To=`context`,Eo=({operation:e,plugin:t,queryFn:n})=>{if(lr({operation:e}))return;let r=cr({context:t.context,operation:e});t.getSymbol({category:`utility`,resource:`createQueryKey`,tool:t.name})||(So({plugin:t}),bo({plugin:t}));let i;if(t.config.queryKeys.enabled){let n=t.registerSymbol({exported:!0,name:x({config:t.config.queryKeys,name:e.id})}),r=Co({operation:e,plugin:t,symbol:n});t.setSymbolValue(n,r),i=M.callExpression({functionName:n.placeholder,parameters:[wo]})}else{let n=t.referenceSymbol({category:`utility`,resource:`createQueryKey`,tool:t.name}),r;t.config.queryKeys.tags&&e.tags&&e.tags.length>0&&(r=M.arrayLiteralExpression({elements:e.tags.map(e=>M.stringLiteral({text:e}))})),i=M.callExpression({functionName:n.placeholder,parameters:[M.ots.string(e.id),wo,r]})}let{strippedTypeData:a}=go({plugin:t,typeData:po({operation:e,plugin:t})}),o=M.awaitExpression({expression:M.callExpression({functionName:n,parameters:[M.objectExpression({multiLine:!0,obj:[{spread:wo},{spread:To},{key:`throwOnError`,value:!0}]})]})}),s=[];t.getPluginOrThrow(`@hey-api/sdk`).config.responseStyle===`data`?s.push(M.returnVariable({expression:o})):s.push(M.constVariable({destructure:!0,expression:o,name:`data`}),M.returnVariable({expression:`data`}));let c=[{key:`key`,value:i},{key:`query`,value:M.arrowFunction({async:!0,multiLine:!0,parameters:[{name:To}],statements:s})}],l=fo(t,e,`queryOptions`);l&&c.push({key:`meta`,value:l});let u=t.registerSymbol({exported:!0,meta:{category:`hook`,resource:`operation`,resourceId:e.id,role:`queryOptions`,tool:t.name},name:x({config:t.config.queryOptions,name:e.id})}),d=t.referenceSymbol({category:`external`,resource:`${t.name}.defineQueryOptions`}),f=M.constVariable({comment:t.config.comments?P({operation:e}):void 0,exportConst:u.exported,expression:M.callExpression({functionName:d.placeholder,parameters:[M.arrowFunction({parameters:[{isRequired:r,name:wo,type:a}],statements:M.objectExpression({obj:c})})]}),name:u.placeholder});t.setSymbolValue(u,f)},Do=({plugin:e})=>{e.registerSymbol({external:e.name,meta:{category:`external`,resource:`${e.name}.defineQueryOptions`},name:`defineQueryOptions`}),e.registerSymbol({external:e.name,kind:`type`,meta:{category:`external`,resource:`${e.name}.UseMutationOptions`},name:`UseMutationOptions`}),e.registerSymbol({external:e.name,kind:`type`,meta:{category:`external`,resource:`${e.name}.UseQueryOptions`},name:`UseQueryOptions`}),e.registerSymbol({external:e.name,kind:`type`,meta:{category:`external`,resource:`${e.name}._JSONValue`},name:`_JSONValue`}),e.registerSymbol({external:`axios`,kind:`type`,meta:{category:`external`,resource:`axios.AxiosError`},name:`AxiosError`});let t=e.getPluginOrThrow(`@hey-api/sdk`);e.forEach(`operation`,({operation:n})=>{let r=t.config.asClass?rr({context:e.context,operation:n,plugin:t}):void 0,i=r?r.values().next().value:void 0,a;a=i?[e.referenceSymbol({category:`utility`,resource:`class`,resourceId:i.path[0],tool:`sdk`}).placeholder,...t.config.instance?[va,`get()`]:[],...i.path.slice(1).map(e=>b({case:`camelCase`,value:e})),i.methodName].filter(Boolean).join(`.`):e.referenceSymbol({category:`sdk`,resource:`operation`,resourceId:n.id}).placeholder,e.hooks.operation.isQuery(n)&&e.config.queryOptions.enabled&&Eo({operation:n,plugin:e,queryFn:a}),e.hooks.operation.isMutation(n)&&e.config.mutationOptions.enabled&&_o({operation:n,plugin:e,queryFn:a})},{order:`declarations`})},Oo={config:{case:`camelCase`,comments:!0,exportFromIndex:!1},dependencies:[`@hey-api/typescript`,`@hey-api/sdk`],handler:e=>Do(e),name:`@pinia/colada`,resolveConfig:(e,t)=>{e.config.mutationOptions=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`{{name}}Mutation`},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.mutationOptions}),e.config.queryKeys=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`{{name}}QueryKey`,tags:!1},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.queryKeys}),e.config.queryOptions=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`{{name}}Query`},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.queryOptions})}},ko=({operation:e,plugin:t})=>ir({operation:e,plugin:t.getPluginOrThrow(`@hey-api/sdk`)}),Ao=({operation:e,plugin:t})=>{let n=T(t.context.config),r=t.querySymbol({category:`type`,resource:`operation`,resourceId:e.id,role:`error`})?.placeholder;return r||=t.referenceSymbol({category:`external`,resource:`${t.name}.DefaultError`}).placeholder,n.name===`@hey-api/client-axios`&&(r=`${t.referenceSymbol({category:`external`,resource:`axios.AxiosError`}).placeholder}<${r}>`),r},jo=({operation:e,plugin:t})=>t.querySymbol({category:`type`,resource:`operation`,resourceId:e.id,role:`response`})?.placeholder||`unknown`,Mo=`TOptions`,No=M.identifier({text:`infinite`}),Po=M.identifier({text:`options`}),Fo=({plugin:e})=>{let t=e.registerSymbol({meta:{category:`utility`,resource:`createQueryKey`,tool:e.name},name:x({config:{case:e.config.case},name:`createQueryKey`})}),n=e.referenceSymbol({category:`type`,resource:`QueryKey`,tool:e.name}),r=M.indexedAccessTypeNode({indexType:M.literalTypeNode({literal:M.ots.number(0)}),objectType:M.typeReferenceNode({typeArguments:[M.typeReferenceNode({typeName:Mo})],typeName:n.placeholder})}),i=rt(e.context.config),a=e.getSymbol({category:`client`}),o=e.referenceSymbol({category:`type`,resource:`client-options`,tool:`sdk`}),s=M.constVariable({expression:M.arrowFunction({multiLine:!0,parameters:[{name:`id`,type:M.typeReferenceNode({typeName:`string`})},{isRequired:!1,name:`options`,type:M.typeReferenceNode({typeName:Mo})},{isRequired:!1,name:`infinite`,type:M.typeReferenceNode({typeName:`boolean`})},{isRequired:!1,name:`tags`,type:M.typeReferenceNode({typeName:`ReadonlyArray<string>`})}],returnType:M.typeTupleNode({types:[r]}),statements:[M.constVariable({assertion:r,expression:M.objectExpression({multiLine:!1,obj:[{key:`_id`,value:M.identifier({text:`id`})},{key:i,value:M.identifier({text:`options?.${i} || (options?.client ?? ${a?.placeholder}).getConfig().${i}`})}]}),name:`params`,typeName:r}),M.ifStatement({expression:No,thenStatement:M.block({statements:[M.expressionToStatement({expression:M.binaryExpression({left:M.propertyAccessExpression({expression:`params`,name:`_infinite`}),right:No})})]})}),M.ifStatement({expression:M.identifier({text:`tags`}),thenStatement:M.block({statements:[M.expressionToStatement({expression:M.binaryExpression({left:M.propertyAccessExpression({expression:`params`,name:`tags`}),right:M.identifier({text:`tags`})})})]})}),M.ifStatement({expression:M.propertyAccessExpression({expression:Po,isOptional:!0,name:M.identifier({text:`body`})}),thenStatement:M.block({statements:[M.expressionToStatement({expression:M.binaryExpression({left:M.propertyAccessExpression({expression:`params`,name:`body`}),right:M.propertyAccessExpression({expression:`options`,name:`body`})})})]})}),M.ifStatement({expression:M.propertyAccessExpression({expression:Po,isOptional:!0,name:M.identifier({text:`headers`})}),thenStatement:M.block({statements:[M.expressionToStatement({expression:M.binaryExpression({left:M.propertyAccessExpression({expression:`params`,name:`headers`}),right:M.propertyAccessExpression({expression:`options`,name:`headers`})})})]})}),M.ifStatement({expression:M.propertyAccessExpression({expression:Po,isOptional:!0,name:M.identifier({text:`path`})}),thenStatement:M.block({statements:[M.expressionToStatement({expression:M.binaryExpression({left:M.propertyAccessExpression({expression:`params`,name:`path`}),right:M.propertyAccessExpression({expression:`options`,name:`path`})})})]})}),M.ifStatement({expression:M.propertyAccessExpression({expression:Po,isOptional:!0,name:M.identifier({text:`query`})}),thenStatement:M.block({statements:[M.expressionToStatement({expression:M.binaryExpression({left:M.propertyAccessExpression({expression:`params`,name:`query`}),right:M.propertyAccessExpression({expression:`options`,name:`query`})})})]})}),M.returnStatement({expression:M.arrayLiteralExpression({elements:[M.identifier({text:`params`})]})})],types:[{extends:M.typeReferenceNode({typeName:M.identifier({text:o.placeholder})}),name:Mo}]}),name:t.placeholder});e.setSymbolValue(t,s)},Io=({id:e,isInfinite:t,operation:n,plugin:r})=>{let i=t?r.config.infiniteQueryKeys:r.config.queryKeys,a;return i.tags&&n.tags&&n.tags.length>0&&(a=B.array().elements(...n.tags)),B(r.referenceSymbol({category:`utility`,resource:`createQueryKey`,tool:r.name}).placeholder).call(B.literal(e),`options`,t||a?B.literal(!!t):void 0,a)},Lo=({plugin:e})=>{let t=[{name:`_id`,type:M.keywordTypeNode({keyword:`string`})},{isRequired:!1,name:`_infinite`,type:M.keywordTypeNode({keyword:`boolean`})},{isRequired:!1,name:`tags`,type:M.typeReferenceNode({typeName:`ReadonlyArray<string>`})}],n=e.referenceSymbol({category:`type`,resource:`client-options`,tool:`sdk`}),r=e.registerSymbol({exported:!0,kind:`type`,meta:{category:`type`,resource:`QueryKey`,tool:e.name},name:`QueryKey`}),i=M.typeAliasDeclaration({exportType:r.exported,name:r.placeholder,type:M.typeTupleNode({types:[M.typeIntersectionNode({types:[M.typeReferenceNode({typeName:`Pick<${Mo}, '${rt(e.context.config)}' | 'body' | 'headers' | 'path' | 'query'>`}),M.typeInterfaceNode({properties:t,useLegacyResolution:!0})]})]}),typeParameters:[{extends:M.typeReferenceNode({typeName:M.identifier({text:n.placeholder})}),name:Mo}]});e.setSymbolValue(r,i)},Ro=({isInfinite:e,operation:t,plugin:n,symbol:r,typeQueryKey:i})=>{let a=ko({operation:t,plugin:n});return B.const(r.placeholder).export(r.exported).assign(B.func().param(`options`,e=>e.optional(!Qe(t)).type(a)).$if(e&&i,(e,t)=>e.returns(t)).do(Io({id:t.id,isInfinite:e,operation:t,plugin:n}).return()))},zo=(e,t,n)=>{let r=e.config[n].meta;if(!r)return;let i=r(t);if(Object.keys(i).length)return M.valueToExpression({value:i})},Bo=({plugin:e})=>{let t=e.registerSymbol({meta:{category:`utility`,resource:`createInfiniteParams`,tool:e.name},name:x({config:{case:e.config.case},name:`createInfiniteParams`})}),n=M.constVariable({expression:M.arrowFunction({multiLine:!0,parameters:[{name:`queryKey`,type:M.typeReferenceNode({typeName:`QueryKey<Options>`})},{name:`page`,type:M.typeReferenceNode({typeName:`K`})}],statements:[M.constVariable({expression:M.objectExpression({obj:[{spread:M.propertyAccessExpression({expression:`queryKey`,name:0})}]}),name:`params`}),M.ifStatement({expression:M.propertyAccessExpression({expression:M.identifier({text:`page`}),name:M.identifier({text:`body`})}),thenStatement:M.block({statements:[M.expressionToStatement({expression:M.binaryExpression({left:M.propertyAccessExpression({expression:`params`,name:`body`}),right:M.objectExpression({multiLine:!0,obj:[{assertion:`any`,spread:`queryKey[0].body`},{assertion:`any`,spread:`page.body`}]})})})]})}),M.ifStatement({expression:M.propertyAccessExpression({expression:M.identifier({text:`page`}),name:M.identifier({text:`headers`})}),thenStatement:M.block({statements:[M.expressionToStatement({expression:M.binaryExpression({left:M.propertyAccessExpression({expression:`params`,name:`headers`}),right:M.objectExpression({multiLine:!0,obj:[{spread:`queryKey[0].headers`},{spread:`page.headers`}]})})})]})}),M.ifStatement({expression:M.propertyAccessExpression({expression:M.identifier({text:`page`}),name:M.identifier({text:`path`})}),thenStatement:M.block({statements:[M.expressionToStatement({expression:M.binaryExpression({left:M.propertyAccessExpression({expression:`params`,name:`path`}),right:M.objectExpression({multiLine:!0,obj:[{assertion:`any`,spread:`queryKey[0].path`},{assertion:`any`,spread:`page.path`}]})})})]})}),M.ifStatement({expression:M.propertyAccessExpression({expression:M.identifier({text:`page`}),name:M.identifier({text:`query`})}),thenStatement:M.block({statements:[M.expressionToStatement({expression:M.binaryExpression({left:M.propertyAccessExpression({expression:`params`,name:`query`}),right:M.objectExpression({multiLine:!0,obj:[{assertion:`any`,spread:`queryKey[0].query`},{assertion:`any`,spread:`page.query`}]})})})]})}),M.returnVariable({expression:M.asExpression({expression:M.asExpression({expression:M.identifier({text:`params`}),type:M.keywordTypeNode({keyword:`unknown`})}),type:l.factory.createTypeQueryNode(M.identifier({text:`page`}))})})],types:[{extends:M.typeReferenceNode({typeName:M.identifier({text:`Pick<QueryKey<Options>[0], 'body' | 'headers' | 'path' | 'query'>`})}),name:`K`}]}),name:t.placeholder});e.setSymbolValue(t,n)},Vo=({operation:e,plugin:t,queryFn:n})=>{let r=$e({context:t.context,operation:e});if(!r)return;let i=cr({context:t.context,operation:e});t.getSymbol({category:`utility`,resource:`createQueryKey`,tool:t.name})||(Lo({plugin:t}),Fo({plugin:t})),t.getSymbol({category:`utility`,resource:`createInfiniteParams`,tool:t.name})||Bo({plugin:t});let a=t.referenceSymbol({category:`external`,resource:`${t.name}.infiniteQueryOptions`}),o=t.referenceSymbol({category:`external`,resource:`${t.name}.InfiniteData`}),s=ko({operation:e,plugin:t}),c=Ao({operation:e,plugin:t}),l=jo({operation:e,plugin:t}),u=`${t.referenceSymbol({category:`type`,resource:`QueryKey`,tool:t.name}).placeholder}<${s}>`,d=`Pick<${u}[0], 'body' | 'headers' | 'path' | 'query'>`,f=t.getPluginOrThrow(`@hey-api/typescript`),p=`${vt({node:f.api.schemaToType({plugin:f,schema:r.schema,state:{path:{value:[]}}}),unescape:!0})} | ${d}`,m=t.registerSymbol({exported:!0,name:x({config:t.config.infiniteQueryKeys,name:e.id})}),h=Ro({isInfinite:!0,operation:e,plugin:t,symbol:m,typeQueryKey:u});t.setSymbolValue(m,h);let g=M.awaitExpression({expression:M.callExpression({functionName:n,parameters:[M.objectExpression({multiLine:!0,obj:[{spread:`options`},{spread:`params`},{key:`signal`,shorthand:!0,value:M.identifier({text:`signal`})},{key:`throwOnError`,value:!0}]})]})}),ee=t.referenceSymbol({category:`utility`,resource:`createInfiniteParams`,tool:t.name}),te=[M.constVariable({comment:[{jsdoc:!1,lines:[`@ts-ignore`]}],expression:M.conditionalExpression({condition:M.binaryExpression({left:M.typeOfExpression({text:`pageParam`}),operator:`===`,right:M.ots.string(`object`)}),whenFalse:M.objectExpression({multiLine:!0,obj:[{key:r.in,value:M.objectExpression({multiLine:!0,obj:[{key:r.name,value:M.identifier({text:`pageParam`})}]})}]}),whenTrue:M.identifier({text:`pageParam`})}),name:`page`,typeName:d}),M.constVariable({expression:M.callExpression({functionName:ee.placeholder,parameters:[`queryKey`,`page`]}),name:`params`})];t.getPluginOrThrow(`@hey-api/sdk`).config.responseStyle===`data`?te.push(M.returnVariable({expression:g})):te.push(M.constVariable({destructure:!0,expression:g,name:`data`}),M.returnVariable({expression:`data`}));let ne=[{key:`queryFn`,value:M.arrowFunction({async:!0,multiLine:!0,parameters:[{destructure:[{name:`pageParam`},{name:`queryKey`},{name:`signal`}]}],statements:te})},{key:`queryKey`,value:M.callExpression({functionName:m.placeholder,parameters:[`options`]})}],_=zo(t,e,`infiniteQueryOptions`);_&&ne.push({key:`meta`,value:_});let v=t.registerSymbol({exported:!0,name:x({config:t.config.infiniteQueryOptions,name:e.id})}),re=M.constVariable({comment:t.config.comments?P({operation:e}):void 0,exportConst:v.exported,expression:M.arrowFunction({parameters:[{isRequired:i,name:`options`,type:s}],statements:[M.returnFunctionCall({args:[M.objectExpression({comments:[{jsdoc:!1,lines:[`@ts-ignore`]}],obj:ne})],name:a.placeholder,types:[l,c||`unknown`,`${o.placeholder}<${l}>`,u,p]})]}),name:v.placeholder});t.setSymbolValue(v,re)},Ho=({operation:e,plugin:t,queryFn:n})=>{let r=t.referenceSymbol({category:`external`,resource:`${t.name}.MutationOptions`}),i=ko({operation:e,plugin:t}),a=Ao({operation:e,plugin:t}),o=jo({operation:e,plugin:t}),s=`${r.placeholder}<${o}, ${a}, ${i}>`,c=`fnOptions`,l=B(n).call(B.object().spread(`options`).spread(c).prop(`throwOnError`,B.literal(!0))).await(),u=[];t.getPluginOrThrow(`@hey-api/sdk`).config.responseStyle===`data`?u.push(B.return(l)):u.push(B.const().object(`data`).assign(l),B.return(`data`));let d=zo(t,e,`mutationOptions`),f=`mutationOptions`,p=t.registerSymbol({exported:!0,name:x({config:t.config.mutationOptions,name:e.id})}),m=B.const(p.placeholder).export(p.exported).$if(t.config.comments&&P({operation:e}),(e,t)=>e.describe(t)).assign(B.func().param(`options`,e=>e.optional().type(`Partial<${i}>`)).returns(s).do(B.const(f).type(s).assign(B.object().pretty().prop(`mutationFn`,B.func().async().param(c).do(...u)).$if(d,(e,t)=>e.prop(`meta`,t))),B(f).return()));t.setSymbolValue(p,m)},Uo=`options`,Wo=({operation:e,plugin:t,queryFn:n})=>{if(lr({operation:e}))return;let r=cr({context:t.context,operation:e});t.getSymbol({category:`utility`,resource:`createQueryKey`,tool:t.name})||(Lo({plugin:t}),Fo({plugin:t}));let i=t.referenceSymbol({category:`external`,resource:`${t.name}.queryOptions`}),a=t.registerSymbol({exported:!0,name:x({config:t.config.queryKeys,name:e.id})}),o=Ro({isInfinite:!1,operation:e,plugin:t,symbol:a});t.setSymbolValue(a,o);let s=ko({operation:e,plugin:t}),c=Ao({operation:e,plugin:t}),l=jo({operation:e,plugin:t}),u=B(n).call(B.object().spread(Uo).spread(B(`queryKey`).attr(0)).prop(`signal`,B(`signal`)).prop(`throwOnError`,B.literal(!0))).await(),d=[];t.getPluginOrThrow(`@hey-api/sdk`).config.responseStyle===`data`?d.push(B.return(u)):d.push(B.const().object(`data`).assign(u),B.return(`data`));let f=B.object().pretty().prop(`queryFn`,B.func().async().param(e=>e.object(`queryKey`,`signal`)).do(...d)).prop(`queryKey`,B(a.placeholder).call(Uo)).$if(zo(t,e,`queryOptions`),(e,t)=>e.prop(`meta`,B(t))),p=t.registerSymbol({exported:t.config.queryOptions.exported,meta:{category:`hook`,resource:`operation`,resourceId:e.id,role:`queryOptions`,tool:t.name},name:x({config:t.config.queryOptions,name:e.id})}),m=B.const(p.placeholder).export(p.exported).$if(t.config.comments&&P({operation:e}),(e,t)=>e.describe(t)).assign(B.func().param(Uo,e=>e.optional(!r).type(s)).do(B(i.placeholder).call(f).generics(l,c,l,B(a.placeholder).returnType()).return()));t.setSymbolValue(p,m)},Go=`options`,Ko=({operation:e,plugin:t})=>{if(lr({operation:e})||!(`useQuery`in t.config))return;let n=t.registerSymbol({exported:!0,name:x({config:t.config.useQuery,name:e.id})}),r=t.referenceSymbol({category:`external`,resource:`${t.name}.useQuery`}),i=cr({context:t.context,operation:e}),a=ko({operation:e,plugin:t}),o=t.referenceSymbol({category:`hook`,resource:`operation`,resourceId:e.id,role:`queryOptions`,tool:t.name}),s=B.const(n.placeholder).export(n.exported).$if(t.config.comments&&P({operation:e}),(e,t)=>e.describe(t)).assign(B.func().param(Go,e=>e.optional(!i).type(a)).do(B(r.placeholder).call(B(o.placeholder).call(Go)).return()));t.setSymbolValue(n,s)},qo=({plugin:e})=>{e.registerSymbol({external:e.name,kind:`type`,meta:{category:`external`,resource:`${e.name}.DefaultError`},name:`DefaultError`}),e.registerSymbol({external:e.name,kind:`type`,meta:{category:`external`,resource:`${e.name}.InfiniteData`},name:`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,kind:`type`,meta:{category:`external`,resource:`${e.name}.MutationOptions`},name:t}),e.registerSymbol({external:e.name,meta:{category:`external`,resource:`${e.name}.infiniteQueryOptions`},name:`infiniteQueryOptions`}),e.registerSymbol({external:e.name,meta:{category:`external`,resource:`${e.name}.queryOptions`},name:`queryOptions`}),e.registerSymbol({external:e.name,meta:{category:`external`,resource:`${e.name}.useQuery`},name:`useQuery`}),e.registerSymbol({external:`axios`,kind:`type`,meta:{category:`external`,resource:`axios.AxiosError`},name:`AxiosError`});let n=e.getPluginOrThrow(`@hey-api/sdk`);e.forEach(`operation`,({operation:t})=>{let r=n.config.asClass?rr({context:e.context,operation:t,plugin:n}):void 0,i=r?r.values().next().value:void 0,a;a=i?[e.referenceSymbol({category:`utility`,resource:`class`,resourceId:i.path[0],tool:`sdk`}).placeholder,...n.config.instance?[va,`get()`]:[],...i.path.slice(1).map(e=>b({case:`camelCase`,value:e})),i.methodName].filter(Boolean).join(`.`):e.referenceSymbol({category:`sdk`,resource:`operation`,resourceId:t.id}).placeholder,e.hooks.operation.isQuery(t)&&(e.config.queryOptions.enabled&&Wo({operation:t,plugin:e,queryFn:a}),e.config.infiniteQueryOptions.enabled&&Vo({operation:t,plugin:e,queryFn:a}),`useQuery`in e.config&&e.config.useQuery.enabled&&Ko({operation:t,plugin:e})),e.hooks.operation.isMutation(t)&&e.config.mutationOptions.enabled&&Ho({operation:t,plugin:e,queryFn:a})},{order:`declarations`})},Jo=e=>qo(e),Yo={config:{case:`camelCase`,comments:!0,exportFromIndex:!1},dependencies:[`@hey-api/sdk`,`@hey-api/typescript`],handler:Jo,name:`@tanstack/angular-query-experimental`,resolveConfig:(e,t)=>{e.config.infiniteQueryKeys=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`{{name}}InfiniteQueryKey`,tags:!1},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.infiniteQueryKeys}),e.config.infiniteQueryOptions=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`{{name}}InfiniteOptions`},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.infiniteQueryOptions}),e.config.mutationOptions=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`{{name}}Mutation`},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.mutationOptions}),e.config.queryKeys=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`{{name}}QueryKey`,tags:!1},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.queryKeys}),e.config.queryOptions=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,exported:!0,name:`{{name}}Options`},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.queryOptions})}},Xo={config:{case:`camelCase`,comments:!0,exportFromIndex:!1},dependencies:[`@hey-api/sdk`,`@hey-api/typescript`],handler:Jo,name:`@tanstack/react-query`,resolveConfig:(e,t)=>{e.config.infiniteQueryKeys=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`{{name}}InfiniteQueryKey`,tags:!1},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.infiniteQueryKeys}),e.config.infiniteQueryOptions=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`{{name}}InfiniteOptions`},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.infiniteQueryOptions}),e.config.mutationOptions=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`{{name}}Mutation`},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.mutationOptions}),e.config.queryKeys=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`{{name}}QueryKey`,tags:!1},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.queryKeys}),e.config.queryOptions=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,exported:!0,name:`{{name}}Options`},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.queryOptions}),e.config.useQuery=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!1,name:`use{{name}}Query`},mappers:{boolean:e=>({enabled:e}),function:e=>({enabled:!0,name:e}),object:e=>({enabled:!0,...e}),string:e=>({enabled:!0,name:e})},value:e.config.useQuery}),e.config.useQuery.enabled&&(e.config.queryOptions.enabled||(e.config.queryOptions.enabled=!0,e.config.queryOptions.exported=!1))}},Zo={config:{case:`camelCase`,comments:!0,exportFromIndex:!1},dependencies:[`@hey-api/sdk`,`@hey-api/typescript`],handler:Jo,name:`@tanstack/solid-query`,resolveConfig:(e,t)=>{e.config.infiniteQueryKeys=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`{{name}}InfiniteQueryKey`,tags:!1},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.infiniteQueryKeys}),e.config.infiniteQueryOptions=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`{{name}}InfiniteOptions`},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.infiniteQueryOptions}),e.config.mutationOptions=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`{{name}}Mutation`},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.mutationOptions}),e.config.queryKeys=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`{{name}}QueryKey`,tags:!1},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.queryKeys}),e.config.queryOptions=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,exported:!0,name:`{{name}}Options`},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.queryOptions})}},Qo={config:{case:`camelCase`,comments:!0,exportFromIndex:!1},dependencies:[`@hey-api/sdk`,`@hey-api/typescript`],handler:Jo,name:`@tanstack/svelte-query`,resolveConfig:(e,t)=>{e.config.infiniteQueryKeys=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`{{name}}InfiniteQueryKey`,tags:!1},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.infiniteQueryKeys}),e.config.infiniteQueryOptions=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`{{name}}InfiniteOptions`},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.infiniteQueryOptions}),e.config.mutationOptions=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`{{name}}Mutation`},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.mutationOptions}),e.config.queryKeys=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`{{name}}QueryKey`,tags:!1},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.queryKeys}),e.config.queryOptions=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,exported:!0,name:`{{name}}Options`},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.queryOptions})}},$o={config:{case:`camelCase`,comments:!0,exportFromIndex:!1},dependencies:[`@hey-api/sdk`,`@hey-api/typescript`],handler:Jo,name:`@tanstack/vue-query`,resolveConfig:(e,t)=>{e.config.infiniteQueryKeys=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`{{name}}InfiniteQueryKey`,tags:!1},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.infiniteQueryKeys}),e.config.infiniteQueryOptions=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`{{name}}InfiniteOptions`},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.infiniteQueryOptions}),e.config.mutationOptions=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`{{name}}Mutation`},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.mutationOptions}),e.config.queryKeys=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`{{name}}QueryKey`,tags:!1},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.queryKeys}),e.config.queryOptions=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,exported:!0,name:`{{name}}Options`},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.queryOptions})}},es=({operation:e,plugin:t})=>{let n=t.getSymbol({category:`schema`,resource:`operation`,resourceId:e.id,role:`data`,tool:`arktype`});if(!n)return;let r=`data`;return B.func().async().param(r).do(B(n.placeholder).attr(`parseAsync`).call(r).await().return())},ts=({operation:e,plugin:t})=>{let n=t.getSymbol({category:`schema`,resource:`operation`,resourceId:e.id,role:`responses`,tool:`arktype`});if(!n)return;let r=`data`;return B.func().async().param(r).do(B(n.placeholder).attr(`parseAsync`).call(r).await().return())};var ns=class{createRequestValidator(e){return es(e)}createResponseValidator(e){return ts(e)}};const H={keywords:{false:M.identifier({text:`false`}),true:M.identifier({text:`true`})},number:{Infinity:M.identifier({text:`Infinity`}),NaN:M.identifier({text:`NaN`}),NegativeInfinity:M.identifier({text:`NegativeInfinity`}),epoch:M.identifier({text:`epoch`}),integer:M.identifier({text:`integer`}),safe:M.identifier({text:`safe`})},primitives:{bigint:M.identifier({text:`bigint`}),boolean:M.identifier({text:`boolean`}),keywords:M.identifier({text:`keywords`}),null:`null`,number:M.identifier({text:`number`}),string:`string`,symbol:M.identifier({text:`symbol`}),undefined:M.identifier({text:`undefined`}),unit:M.identifier({text:`unit`})},string:{NFC:M.identifier({text:`NFC`}),NFD:M.identifier({text:`NFD`}),NFKC:M.identifier({text:`NFKC`}),NFKD:M.identifier({text:`NFKD`}),alpha:M.identifier({text:`alpha`}),alphanumeric:M.identifier({text:`alphanumeric`}),base64:M.identifier({text:`base64`}),capitalize:M.identifier({text:`capitalize`}),creditCard:M.identifier({text:`creditCard`}),date:`date`,digits:M.identifier({text:`digits`}),email:`email`,epoch:M.identifier({text:`epoch`}),hex:M.identifier({text:`hex`}),integer:M.identifier({text:`integer`}),ip:`ip`,iso:`iso`,json:M.identifier({text:`json`}),lower:M.identifier({text:`lower`}),normalize:M.identifier({text:`normalize`}),numeric:M.identifier({text:`numeric`}),parse:M.identifier({text:`parse`}),preformatted:M.identifier({text:`preformatted`}),regex:M.identifier({text:`regex`}),semver:M.identifier({text:`semver`}),trim:M.identifier({text:`trim`}),upper:M.identifier({text:`upper`}),url:`url`,uuid:`uuid`,v1:`v1`,v2:`v2`,v3:`v3`,v4:`v4`,v5:`v5`,v6:`v6`,v7:`v7`,v8:`v8`},type:{$:M.identifier({text:`$`}),allows:M.identifier({text:`allows`}),and:M.identifier({text:`and`}),array:M.identifier({text:`array`}),as:M.identifier({text:`as`}),assert:M.identifier({text:`assert`}),brand:M.identifier({text:`brand`}),configure:M.identifier({text:`configure`}),default:M.identifier({text:`default`}),describe:M.identifier({text:`describe`}),description:M.identifier({text:`description`}),equals:M.identifier({text:`equals`}),exclude:M.identifier({text:`exclude`}),expression:M.identifier({text:`expression`}),extends:M.identifier({text:`extends`}),extract:M.identifier({text:`extract`}),filter:M.identifier({text:`filter`}),from:M.identifier({text:`from`}),ifEquals:M.identifier({text:`ifEquals`}),ifExtends:M.identifier({text:`ifExtends`}),infer:M.identifier({text:`infer`}),inferIn:M.identifier({text:`inferIn`}),intersect:M.identifier({text:`intersect`}),json:M.identifier({text:`json`}),meta:M.identifier({text:`meta`}),narrow:M.identifier({text:`narrow`}),onDeepUndeclaredKey:M.identifier({text:`onDeepUndeclaredKey`}),onUndeclaredKey:M.identifier({text:`onUndeclaredKey`}),optional:M.identifier({text:`optional`}),or:M.identifier({text:`or`}),overlaps:M.identifier({text:`overlaps`}),pipe:M.identifier({text:`pipe`}),select:M.identifier({text:`select`}),to:M.identifier({text:`to`}),toJsonSchema:M.identifier({text:`toJsonSchema`})}},rs=({ast:e,plugin:t,schema:n,symbol:r,typeInferSymbol:i})=>{let a=t.referenceSymbol({category:`external`,resource:`arktype.type`}),o=M.constVariable({comment:t.config.comments?za({schema:n}):void 0,exportConst:r.exported,expression:M.callExpression({functionName:a.placeholder,parameters:[e.def?M.stringLiteral({text:e.def}):e.expression]}),name:r.placeholder});if(t.setSymbolValue(r,o),i){let e=M.typeAliasDeclaration({exportType:i.exported,name:i.placeholder,type:l.factory.createTypeQueryNode(l.factory.createQualifiedName(l.factory.createIdentifier(r.placeholder),H.type.infer))});t.setSymbolValue(i,e)}},is=e=>{let t={};return t.def=H.primitives.null,t},as=({plugin:e,schema:t,state:n})=>{let r={},i=[],a=t.required??[];for(let o in t.properties){let s=t.properties[o],c=a.includes(o),u=cs({optional:!c,plugin:e,schema:s,state:{...n,path:E([...n.path.value,`properties`,o])}});u.hasLazyExpression&&(r.hasLazyExpression=!0);let d=c?o:`${o}?`;d.endsWith(`?`)?d=l.factory.createComputedPropertyName(M.stringLiteral({text:d})):((d.match(/^[0-9]/)&&d.match(/\D+/g)||d.match(/\W/g))&&!d.startsWith(`'`)&&!d.endsWith(`'`)&&(d=`'${d}'`),at.lastIndex=0,d=at.test(d)?d.startsWith(`-`)?M.stringLiteral({text:o}):l.factory.createNumericLiteral(o):o),i.push(M.propertyAssignment({initializer:u.expression,name:d}))}if(t.additionalProperties&&(!t.properties||!Object.keys(t.properties).length)){let i=cs({plugin:e,schema:t.additionalProperties,state:{...n,path:E([...n.path.value,`additionalProperties`])}});return r.expression=M.callExpression({functionName:M.propertyAccessExpression({expression:`TODO`,name:`record`}),parameters:[M.callExpression({functionName:M.propertyAccessExpression({expression:`TODO`,name:`string`}),parameters:[]}),i.expression]}),i.hasLazyExpression&&(r.hasLazyExpression=!0),r.hasLazyExpression?{...r,typeName:`TODO`}:r}return r.expression=l.factory.createObjectLiteralExpression(i,!0),r.hasLazyExpression?{...r,typeName:`TODO`}:r},os=({schema:e})=>{let t={};if(typeof e.const==`string`)return t.def=e.const,t;let n=H.primitives.string;if(e.format)switch(e.format){case`date`:case`date-time`:case`time`:n=`${n}.${H.string.date}.${H.string.iso}`;break;case`email`:n=`${n}.${H.string.email}`;break;case`ipv4`:n=`${n}.${H.string.ip}.${H.string.v4}`;break;case`ipv6`:n=`${n}.${H.string.ip}.${H.string.v6}`;break;case`uri`:n=`${n}.${H.string.url}`;break;case`uuid`:n=`${n}.${H.string.uuid}`;break}return e.minLength===e.maxLength&&e.minLength!==void 0?n=`${e.minLength} <= ${n} <= ${e.maxLength}`:e.maxLength===void 0?e.minLength!==void 0&&(n=`${n} >= ${e.minLength}`):(n=`${n} <= ${e.maxLength}`,e.minLength!==void 0&&(n=`${e.minLength} <= ${n}`)),e.pattern&&(n=`/${e.pattern}/`),t.def=n,t},ss=({schema:e,...t})=>{switch(e.type){case`null`:return is({...t,schema:e});case`object`:return as({...t,schema:e});case`string`:return os({...t,schema:e})}let n=t.plugin.referenceSymbol({category:`external`,resource:`arktype.type`});return{def:``,expression:l.factory.createCallExpression(l.factory.createIdentifier(n.placeholder),void 0,[l.factory.createObjectLiteralExpression([l.factory.createPropertyAssignment(`name`,l.factory.createStringLiteral(`string`)),l.factory.createPropertyAssignment(`platform`,l.factory.createStringLiteral(`'android' | 'ios'`)),l.factory.createPropertyAssignment(l.factory.createComputedPropertyName(l.factory.createStringLiteral(`versions?`)),l.factory.createStringLiteral(`(number | string)[]`))],!0)]),hasLazyExpression:!1}},cs=({plugin:e,schema:t,state:n})=>{let r={};if(t.$ref){let i={category:`schema`,resource:`definition`,resourceId:t.$ref,tool:`arktype`},a=e.referenceSymbol(i);e.isSymbolRegistered(i)?r.expression=M.identifier({text:a.placeholder}):(r.expression=M.callExpression({functionName:M.propertyAccessExpression({expression:`TODO`,name:`TODO`}),parameters:[M.arrowFunction({returnType:M.keywordTypeNode({keyword:`any`}),statements:[M.returnStatement({expression:M.identifier({text:a.placeholder})})]})]}),r.hasLazyExpression=!0,n.hasLazyExpression.value=!0)}else if(t.type){let i=ss({plugin:e,schema:t,state:n});r.def=i.def,r.expression=i.expression,r.hasLazyExpression=i.hasLazyExpression,e.config.metadata&&t.description}else if(t.items)t=S({schema:t}),t.items||(r=cs({plugin:e,schema:t,state:n}));else{let t=ss({plugin:e,schema:{type:`unknown`},state:n});r.def=t.def,r.expression=t.expression}return r.expression||=ss({plugin:e,schema:{type:`unknown`},state:n}).expression,r},ls=({plugin:e,schema:t,state:n})=>{let r=Xn(n.path.value),i=cs({plugin:e,schema:t,state:n}),a=N(r);rs({ast:i,plugin:e,schema:t,symbol:e.registerSymbol({exported:!0,meta:{category:`schema`,path:n.path.value,resource:`definition`,resourceId:r,tags:n.tags?.value,tool:`arktype`},name:x({config:e.config.definitions,name:a})}),typeInferSymbol:e.config.definitions.types.infer.enabled?e.registerSymbol({exported:!0,kind:`type`,meta:{category:`type`,path:n.path.value,resource:`definition`,resourceId:r,tool:`arktype`,variant:`infer`},name:x({config:e.config.definitions.types.infer,name:a})}):void 0})},us=({plugin:e})=>{e.registerSymbol({external:`arktype`,meta:{category:`external`,resource:`arktype.type`},name:`type`}),e.forEach(`operation`,`parameter`,`requestBody`,`schema`,`webhook`,t=>{let n=D({hasLazyExpression:!1,path:t._path,tags:t.tags});switch(t.type){case`parameter`:ls({plugin:e,schema:t.parameter.schema,state:n});break;case`requestBody`:ls({plugin:e,schema:t.requestBody.schema,state:n});break;case`schema`:ls({plugin:e,schema:t.schema,state:n});break}})},ds={api:new ns,config:{case:`PascalCase`,comments:!0,exportFromIndex:!1,metadata:!1},handler:e=>us(e),name:`arktype`,resolveConfig:(e,t)=>{e.config.types=t.valueToObject({defaultValue:{infer:{case:`PascalCase`,enabled:!1}},mappers:{object:(e,n)=>({...e,infer:t.valueToObject({defaultValue:{...n.infer,enabled:e.infer===void 0?n.infer.enabled:!!e.infer},mappers:y,value:e.infer})})},value:e.config.types}),e.config.definitions=t.valueToObject({defaultValue:{case:e.config.case??`PascalCase`,enabled:!0,name:`{{name}}`,types:{...e.config.types,infer:{...e.config.types.infer,name:`{{name}}`}}},mappers:{...y,object:(e,n)=>({...e,types:t.valueToObject({defaultValue:n.types,mappers:{object:(e,n)=>({...e,infer:t.valueToObject({defaultValue:{...n.infer,enabled:e.infer===void 0?n.infer.enabled:!!e.infer},mappers:y,value:e.infer})})},value:e.types})})},value:e.config.definitions}),e.config.requests=t.valueToObject({defaultValue:{case:e.config.case??`PascalCase`,enabled:!0,name:`{{name}}Data`,types:{...e.config.types,infer:{...e.config.types.infer,name:`{{name}}Data`}}},mappers:{...y,object:(e,n)=>({...e,types:t.valueToObject({defaultValue:n.types,mappers:{object:(e,n)=>({...e,infer:t.valueToObject({defaultValue:{...n.infer,enabled:e.infer===void 0?n.infer.enabled:!!e.infer},mappers:y,value:e.infer})})},value:e.types})})},value:e.config.requests}),e.config.responses=t.valueToObject({defaultValue:{case:e.config.case??`PascalCase`,enabled:!0,name:`{{name}}Response`,types:{...e.config.types,infer:{...e.config.types.infer,name:`{{name}}Response`}}},mappers:{...y,object:(e,n)=>({...e,types:t.valueToObject({defaultValue:n.types,mappers:{object:(e,n)=>({...e,infer:t.valueToObject({defaultValue:{...n.infer,enabled:e.infer===void 0?n.infer.enabled:!!e.infer},mappers:y,value:e.infer})})},value:e.types})})},value:e.config.responses}),e.config.webhooks=t.valueToObject({defaultValue:{case:e.config.case??`PascalCase`,enabled:!0,name:`{{name}}WebhookRequest`,types:{...e.config.types,infer:{...e.config.types.infer,name:`{{name}}WebhookRequest`}}},mappers:{...y,object:(e,n)=>({...e,types:t.valueToObject({defaultValue:n.types,mappers:{object:(e,n)=>({...e,infer:t.valueToObject({defaultValue:{...n.infer,enabled:e.infer===void 0?n.infer.enabled:!!e.infer},mappers:y,value:e.infer})})},value:e.types})})},value:e.config.webhooks})},tags:[`validator`]},fs=({operation:e,plugin:t})=>{let n=[],r=t.querySymbol({category:`type`,resource:`operation`,resourceId:e.id,role:`data`,tool:`typescript`});r&&(e.body&&n.push({isRequired:e.body.required,name:`Body`,type:`${r.placeholder}['body']`}),e.parameters&&(e.parameters.header&&n.push({isRequired:Ye(e.parameters.header),name:`Headers`,type:`${r.placeholder}['headers']`}),e.parameters.path&&n.push({isRequired:Ye(e.parameters.path),name:`Params`,type:`${r.placeholder}['path']`}),e.parameters.query&&n.push({isRequired:Ye(e.parameters.query),name:`Querystring`,type:`${r.placeholder}['query']`})));let{errors:i,responses:a}=tt(e),o,s=t.querySymbol({category:`type`,resource:`operation`,resourceId:e.id,role:`errors`});if(s&&i&&i.properties){let e=Object.keys(i.properties);if(e.length){if(!e.includes(`default`))o=M.typeReferenceNode({typeName:s.placeholder});else if(e.length>1){let e=M.typeReferenceNode({typeName:s.placeholder}),t=M.literalTypeNode({literal:M.stringLiteral({text:`default`})});o=M.typeReferenceNode({typeArguments:[e,t],typeName:`Omit`})}}}let c,l=t.querySymbol({category:`type`,resource:`operation`,resourceId:e.id,role:`responses`});if(l&&a&&a.properties){let e=Object.keys(a.properties);if(e.length){if(!e.includes(`default`))c=M.typeReferenceNode({typeName:l.placeholder});else if(e.length>1){let e=M.typeReferenceNode({typeName:l.placeholder}),t=M.literalTypeNode({literal:M.stringLiteral({text:`default`})});c=M.typeReferenceNode({typeArguments:[e,t],typeName:`Omit`})}}}let u=[o,c].filter(Boolean);if(u.length&&n.push({name:`Reply`,type:M.typeIntersectionNode({types:u})}),!n.length)return;let d=t.referenceSymbol({category:`type`,resource:`route-handler`,tool:`fastify`});return{name:e.id,type:M.typeReferenceNode({typeArguments:[M.typeInterfaceNode({properties:n,useLegacyResolution:!1})],typeName:d.placeholder})}},ps={config:{exportFromIndex:!1},dependencies:[`@hey-api/typescript`],handler:({plugin:e})=>{e.registerSymbol({external:`fastify`,kind:`type`,meta:{category:`type`,resource:`route-handler`,tool:`fastify`},name:`RouteHandler`});let t=e.registerSymbol({exported:!0,kind:`type`,name:`RouteHandlers`}),n=[];e.forEach(`operation`,({operation:t})=>{let r=fs({operation:t,plugin:e});r&&n.push(r)},{order:`declarations`});let r=M.typeAliasDeclaration({exportType:t.exported,name:t.placeholder,type:M.typeInterfaceNode({properties:n,useLegacyResolution:!1})});e.setSymbolValue(t,r)},name:`fastify`},ms=({operation:e,plugin:t,queryFn:n})=>{if(lr({operation:e}))return;let r=t.referenceSymbol({category:`external`,resource:`swr`}),i=t.registerSymbol({exported:!0,name:x({config:t.config.useSwr,name:e.id})}),a=B(n).call(B.object().prop(`throwOnError`,B.literal(!0))).await(),o=[];t.getPluginOrThrow(`@hey-api/sdk`).config.responseStyle===`data`?o.push(B.return(a)):o.push(B.const().object(`data`).assign(a),B.return(`data`));let s=B.const(i.placeholder).export(i.exported).$if(t.config.comments&&P({operation:e}),(e,t)=>e.describe(t)).assign(B.func().do(B(r.placeholder).call(B.literal(e.path),B.func().async().do(...o)).return()));t.setSymbolValue(i,s)},hs=({plugin:e})=>{e.registerSymbol({external:`swr`,importKind:`default`,kind:`function`,meta:{category:`external`,resource:`swr`},name:`useSWR`});let t=e.getPluginOrThrow(`@hey-api/sdk`);e.forEach(`operation`,({operation:n})=>{let r=t.config.asClass?rr({context:e.context,operation:n,plugin:t}):void 0,i=r?r.values().next().value:void 0,a;a=i?[e.referenceSymbol({category:`utility`,resource:`class`,resourceId:i.path[0],tool:`sdk`}).placeholder,...t.config.instance?[va,`get()`]:[],...i.path.slice(1).map(e=>b({case:`camelCase`,value:e})),i.methodName].filter(Boolean).join(`.`):e.referenceSymbol({category:`sdk`,resource:`operation`,resourceId:n.id}).placeholder,e.hooks.operation.isQuery(n)&&e.config.useSwr.enabled&&ms({operation:n,plugin:e,queryFn:a})},{order:`declarations`})},gs={config:{case:`camelCase`,comments:!0,exportFromIndex:!1},dependencies:[`@hey-api/sdk`,`@hey-api/typescript`],handler:e=>hs(e),name:`swr`,resolveConfig:(e,t)=>{e.config.infiniteQueryKeys=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`{{name}}InfiniteQueryKey`,tags:!1},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.infiniteQueryKeys}),e.config.infiniteQueryOptions=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`{{name}}InfiniteOptions`},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.infiniteQueryOptions}),e.config.mutationOptions=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`{{name}}Mutation`},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.mutationOptions}),e.config.queryKeys=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`{{name}}QueryKey`,tags:!1},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.queryKeys}),e.config.queryOptions=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,exported:!0,name:`{{name}}Options`},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.queryOptions}),e.config.useSwr=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`use{{name}}`},mappers:{boolean:e=>({enabled:e}),function:e=>({enabled:!0,name:e}),object:e=>({enabled:!0,...e}),string:e=>({enabled:!0,name:e})},value:e.config.useSwr}),e.config.useSwr.enabled&&(e.config.queryOptions.enabled||(e.config.queryOptions.enabled=!0,e.config.queryOptions.exported=!1))}},U={actions:{args:M.identifier({text:`args`}),base64:M.identifier({text:`base64`}),bic:M.identifier({text:`bic`}),brand:M.identifier({text:`brand`}),bytes:M.identifier({text:`bytes`}),check:M.identifier({text:`check`}),checkItems:M.identifier({text:`checkItems`}),creditCard:M.identifier({text:`creditCard`}),cuid2:M.identifier({text:`cuid2`}),decimal:M.identifier({text:`decimal`}),description:M.identifier({text:`description`}),digits:M.identifier({text:`digits`}),email:M.identifier({text:`email`}),emoji:M.identifier({text:`emoji`}),empty:M.identifier({text:`empty`}),endsWith:M.identifier({text:`endsWith`}),entries:M.identifier({text:`entries`}),everyItem:M.identifier({text:`everyItem`}),excludes:M.identifier({text:`excludes`}),filterItems:M.identifier({text:`filterItems`}),findItem:M.identifier({text:`findItem`}),finite:M.identifier({text:`finite`}),flavor:M.identifier({text:`flavor`}),graphemes:M.identifier({text:`graphemes`}),gtValue:M.identifier({text:`gtValue`}),hash:M.identifier({text:`hash`}),hexColor:M.identifier({text:`hexColor`}),hexadecimal:M.identifier({text:`hexadecimal`}),imei:M.identifier({text:`imei`}),includes:M.identifier({text:`includes`}),integer:M.identifier({text:`integer`}),ip:M.identifier({text:`ip`}),ipv4:M.identifier({text:`ipv4`}),ipv6:M.identifier({text:`ipv6`}),isoDate:M.identifier({text:`isoDate`}),isoDateTime:M.identifier({text:`isoDateTime`}),isoTime:M.identifier({text:`isoTime`}),isoTimeSecond:M.identifier({text:`isoTimeSecond`}),isoTimestamp:M.identifier({text:`isoTimestamp`}),isoWeek:M.identifier({text:`isoWeek`}),length:M.identifier({text:`length`}),ltValue:M.identifier({text:`ltValue`}),mac:M.identifier({text:`mac`}),mac48:M.identifier({text:`mac48`}),mac64:M.identifier({text:`mac64`}),mapItems:M.identifier({text:`mapItems`}),maxBytes:M.identifier({text:`maxBytes`}),maxEntries:M.identifier({text:`maxEntries`}),maxGraphemes:M.identifier({text:`maxGraphemes`}),maxLength:M.identifier({text:`maxLength`}),maxSize:M.identifier({text:`maxSize`}),maxValue:M.identifier({text:`maxValue`}),maxWords:M.identifier({text:`maxWords`}),metadata:M.identifier({text:`metadata`}),mimeType:M.identifier({text:`mimeType`}),minBytes:M.identifier({text:`minBytes`}),minEntries:M.identifier({text:`minEntries`}),minGraphemes:M.identifier({text:`minGraphemes`}),minLength:M.identifier({text:`minLength`}),minSize:M.identifier({text:`minSize`}),minValue:M.identifier({text:`minValue`}),minWords:M.identifier({text:`minWords`}),multipleOf:M.identifier({text:`multipleOf`}),nanoid:M.identifier({text:`nanoid`}),nonEmpty:M.identifier({text:`nonEmpty`}),normalize:M.identifier({text:`normalize`}),notBytes:M.identifier({text:`notBytes`}),notEntries:M.identifier({text:`notEntries`}),notGraphemes:M.identifier({text:`notGraphemes`}),notLength:M.identifier({text:`notLength`}),notSize:M.identifier({text:`notSize`}),notValue:M.identifier({text:`notValue`}),notValues:M.identifier({text:`notValues`}),notWords:M.identifier({text:`notWords`}),octal:M.identifier({text:`octal`}),parseJson:M.identifier({text:`parseJson`}),partialCheck:M.identifier({text:`partialCheck`}),rawCheck:M.identifier({text:`rawCheck`}),rawTransform:M.identifier({text:`rawTransform`}),readonly:M.identifier({text:`readonly`}),reduceItems:M.identifier({text:`reduceItems`}),regex:M.identifier({text:`regex`}),returns:M.identifier({text:`returns`}),rfcEmail:M.identifier({text:`rfcEmail`}),safeInteger:M.identifier({text:`safeInteger`}),size:M.identifier({text:`size`}),slug:M.identifier({text:`slug`}),someItem:M.identifier({text:`someItem`}),sortItems:M.identifier({text:`sortItems`}),startsWith:M.identifier({text:`startsWith`}),stringifyJson:M.identifier({text:`stringifyJson`}),title:M.identifier({text:`title`}),toLowerCase:M.identifier({text:`toLowerCase`}),toMaxValue:M.identifier({text:`toMaxValue`}),toMinValue:M.identifier({text:`toMinValue`}),toUpperCase:M.identifier({text:`toUpperCase`}),transform:M.identifier({text:`transform`}),trim:M.identifier({text:`trim`}),trimEnd:M.identifier({text:`trimEnd`}),trimStart:M.identifier({text:`trimStart`}),ulid:M.identifier({text:`ulid`}),url:M.identifier({text:`url`}),uuid:M.identifier({text:`uuid`}),value:M.identifier({text:`value`}),values:M.identifier({text:`values`}),words:M.identifier({text:`words`})},async:{argsAsync:M.identifier({text:`argsAsync`}),arrayAsync:M.identifier({text:`arrayAsync`}),awaitAsync:M.identifier({text:`awaitAsync`}),checkAsync:M.identifier({text:`checkAsync`}),checkItemsAsync:M.identifier({text:`checkItemsAsync`}),customAsync:M.identifier({text:`customAsync`}),exactOptionalAsync:M.identifier({text:`exactOptionalAsync`}),fallbackAsync:M.identifier({text:`fallbackAsync`}),forwardAsync:M.identifier({text:`forwardAsync`}),getDefaultsAsync:M.identifier({text:`getDefaultsAsync`}),getFallbacksAsync:M.identifier({text:`getFallbacksAsync`}),intersectAsync:M.identifier({text:`intersectAsync`}),lazyAsync:M.identifier({text:`lazyAsync`}),looseObjectAsync:M.identifier({text:`looseObjectAsync`}),looseTupleAsync:M.identifier({text:`looseTupleAsync`}),mapAsync:M.identifier({text:`mapAsync`}),nonNullableAsync:M.identifier({text:`nonNullableAsync`}),nonNullishAsync:M.identifier({text:`nonNullishAsync`}),nonOptionalAsync:M.identifier({text:`nonOptionalAsync`}),nullableAsync:M.identifier({text:`nullableAsync`}),nullishAsync:M.identifier({text:`nullishAsync`}),objectAsync:M.identifier({text:`objectAsync`}),objectWithRestAsync:M.identifier({text:`objectWithRestAsync`}),optionalAsync:M.identifier({text:`optionalAsync`}),parseAsync:M.identifier({text:`parseAsync`}),parserAsync:M.identifier({text:`parserAsync`}),partialAsync:M.identifier({text:`partialAsync`}),partialCheckAsync:M.identifier({text:`partialCheckAsync`}),pipeAsync:M.identifier({text:`pipeAsync`}),rawCheckAsync:M.identifier({text:`rawCheckAsync`}),rawTransformAsync:M.identifier({text:`rawTransformAsync`}),recordAsync:M.identifier({text:`recordAsync`}),requiredAsync:M.identifier({text:`requiredAsync`}),returnsAsync:M.identifier({text:`returnsAsync`}),safeParseAsync:M.identifier({text:`safeParseAsync`}),safeParserAsync:M.identifier({text:`safeParserAsync`}),setAsync:M.identifier({text:`setAsync`}),strictObjectAsync:M.identifier({text:`strictObjectAsync`}),strictTupleAsync:M.identifier({text:`strictTupleAsync`}),transformAsync:M.identifier({text:`transformAsync`}),tupleAsync:M.identifier({text:`tupleAsync`}),tupleWithRestAsync:M.identifier({text:`tupleWithRestAsync`}),undefinedableAsync:M.identifier({text:`undefinedableAsync`}),unionAsync:M.identifier({text:`unionAsync`}),variantAsync:M.identifier({text:`variantAsync`})},methods:{assert:M.identifier({text:`assert`}),config:M.identifier({text:`config`}),fallback:M.identifier({text:`fallback`}),flatten:M.identifier({text:`flatten`}),forward:M.identifier({text:`forward`}),getDefault:M.identifier({text:`getDefault`}),getDefaults:M.identifier({text:`getDefaults`}),getDescription:M.identifier({text:`getDescription`}),getFallback:M.identifier({text:`getFallback`}),getFallbacks:M.identifier({text:`getFallbacks`}),getMetadata:M.identifier({text:`getMetadata`}),getTitle:M.identifier({text:`getTitle`}),is:M.identifier({text:`is`}),keyof:M.identifier({text:`keyof`}),message:M.identifier({text:`message`}),omit:M.identifier({text:`omit`}),parse:M.identifier({text:`parse`}),parser:M.identifier({text:`parser`}),partial:M.identifier({text:`partial`}),pick:M.identifier({text:`pick`}),pipe:M.identifier({text:`pipe`}),required:M.identifier({text:`required`}),safeParse:M.identifier({text:`safeParse`}),safeParser:M.identifier({text:`safeParser`}),summarize:M.identifier({text:`summarize`}),unwrap:M.identifier({text:`unwrap`})},schemas:{any:M.identifier({text:`any`}),array:M.identifier({text:`array`}),bigInt:M.identifier({text:`bigint`}),blob:M.identifier({text:`blob`}),boolean:M.identifier({text:`boolean`}),custom:M.identifier({text:`custom`}),date:M.identifier({text:`date`}),enum:M.identifier({text:`enum`}),exactOptional:M.identifier({text:`exactOptional`}),file:M.identifier({text:`file`}),function:M.identifier({text:`function`}),instance:M.identifier({text:`instance`}),intersect:M.identifier({text:`intersect`}),lazy:M.identifier({text:`lazy`}),literal:M.identifier({text:`literal`}),looseObject:M.identifier({text:`looseObject`}),looseTuple:M.identifier({text:`looseTuple`}),map:M.identifier({text:`map`}),nan:M.identifier({text:`nan`}),never:M.identifier({text:`never`}),nonNullable:M.identifier({text:`nonNullable`}),nonNullish:M.identifier({text:`nonNullish`}),nonOptional:M.identifier({text:`nonOptional`}),null:M.identifier({text:`null`}),nullable:M.identifier({text:`nullable`}),nullish:M.identifier({text:`nullish`}),number:M.identifier({text:`number`}),object:M.identifier({text:`object`}),objectWithRest:M.identifier({text:`objectWithRest`}),optional:M.identifier({text:`optional`}),picklist:M.identifier({text:`picklist`}),promise:M.identifier({text:`promise`}),record:M.identifier({text:`record`}),set:M.identifier({text:`set`}),strictObject:M.identifier({text:`strictObject`}),strictTuple:M.identifier({text:`strictTuple`}),string:M.identifier({text:`string`}),symbol:M.identifier({text:`symbol`}),tuple:M.identifier({text:`tuple`}),tupleWithRest:M.identifier({text:`tupleWithRest`}),undefined:M.identifier({text:`undefined`}),undefinedable:M.identifier({text:`undefinedable`}),union:M.identifier({text:`union`}),unknown:M.identifier({text:`unknown`}),variant:M.identifier({text:`variant`}),void:M.identifier({text:`void`})},storages:{},types:{GenericSchema:M.identifier({text:`GenericSchema`})},utils:{}},_s=({schema:e,v:t})=>B(t.placeholder).attr(U.async.parseAsync).call(e.placeholder,`data`).await().return(),vs=({operation:e,plugin:t})=>{let n=t.getSymbol({category:`schema`,resource:`operation`,resourceId:e.id,role:`data`,tool:`valibot`});if(!n)return;let r={$:B,operation:e,pipes:[],plugin:t,schema:n,v:t.referenceSymbol({category:`external`,resource:`valibot.v`})},i=t.config[`~resolvers`]?.validator,a=[typeof i==`function`?i:i?.request,_s];for(let e of a){let t=e?.(r);if(t===null)return;if(t!==void 0)return B.func().async().param(`data`).do(...t instanceof Array?t:[t])}},ys=({operation:e,plugin:t})=>{let n=t.getSymbol({category:`schema`,resource:`operation`,resourceId:e.id,role:`responses`,tool:`valibot`});if(!n)return;let r={$:B,operation:e,pipes:[],plugin:t,schema:n,v:t.referenceSymbol({category:`external`,resource:`valibot.v`})},i=t.config[`~resolvers`]?.validator,a=[typeof i==`function`?i:i?.response,_s];for(let e of a){let t=e?.(r);if(t===null)return;if(t!==void 0)return B.func().async().param(`data`).do(...t instanceof Array?t:[t])}};var bs=class{createRequestValidator(e){return vs(e)}createResponseValidator(e){return ys(e)}};const W=({pipes:e,plugin:t})=>e.length===1?e[0]instanceof Ci?e[0].$render():e[0]:B(t.referenceSymbol({category:`external`,resource:`valibot.v`}).placeholder).attr(U.methods.pipe).call(...e).$render(),xs=({ast:e,plugin:t,schema:n,state:r,symbol:i})=>{let a=t.referenceSymbol({category:`external`,resource:`valibot.v`}),o=B.const(i.placeholder).export(i.exported).$if(t.config.comments&&za({schema:n}),(e,t)=>e.describe(t)).$if(r.hasLazyExpression.value,t=>t.type(B.type(a.placeholder).attr(e.typeName||U.types.GenericSchema.text))).assign(W({pipes:e.pipes,plugin:t}));t.setSymbolValue(i,o)},Ss={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:!1},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:!1},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:!0},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:!1},uint16:{max:65535,maxError:`Invalid value: Expected uint16 to be <= 2^16-1`,min:0,minError:`Invalid value: Expected uint16 to be >= 0`,needsBigInt:!1},uint32:{max:4294967295,maxError:`Invalid value: Expected uint32 to be <= 2^32-1`,min:0,minError:`Invalid value: Expected uint32 to be >= 0`,needsBigInt:!1},uint64:{max:`18446744073709551615`,maxError:`Invalid value: Expected uint64 to be <= 2^64-1`,min:`0`,minError:`Invalid value: Expected uint64 to be >= 0`,needsBigInt:!0},uint8:{max:255,maxError:`Invalid value: Expected uint8 to be <= 2^8-1`,min:0,minError:`Invalid value: Expected uint8 to be >= 0`,needsBigInt:!1}},Cs=e=>e!==void 0&&e in Ss,ws=e=>Cs(e)&&Ss[e].needsBigInt,Ts=({isBigInt:e,value:t})=>{let n=M.valueToExpression({value:t});return e&&(typeof t==`bigint`||typeof t==`number`||typeof t==`string`||typeof t==`boolean`)?M.callExpression({functionName:`BigInt`,parameters:[n]}):n},Es=({getAst:e,operation:t,plugin:n,state:r})=>{if(n.config.requests.enabled){let i=new Set,a={properties:{body:{type:`never`},path:{type:`never`},query:{type:`never`}},type:`object`};if(t.parameters){if(t.parameters.header){let e={},n=[];for(let r in t.parameters.header){let a=t.parameters.header[r];e[a.name]=a.schema,a.required&&(n.push(a.name),i.add(`headers`))}Object.keys(e).length&&(a.properties.headers={properties:e,required:n,type:`object`})}if(t.parameters.path){let e={},n=[];for(let r in t.parameters.path){let a=t.parameters.path[r];e[a.name]=a.schema,a.required&&(n.push(a.name),i.add(`path`))}Object.keys(e).length&&(a.properties.path={properties:e,required:n,type:`object`})}if(t.parameters.query){let e={},n=[];for(let r in t.parameters.query){let a=t.parameters.query[r];e[a.name]=a.schema,a.required&&(n.push(a.name),i.add(`query`))}Object.keys(e).length&&(a.properties.query={properties:e,required:n,type:`object`})}}t.body&&(a.properties.body=t.body.schema,t.body.required&&i.add(`body`)),a.required=[...i],xs({ast:e(a,r.path.value),plugin:n,schema:a,state:r,symbol:n.registerSymbol({exported:!0,meta:{category:`schema`,path:r.path.value,resource:`operation`,resourceId:t.id,role:`data`,tags:r.tags?.value,tool:`valibot`},name:x({config:n.config.requests,name:t.id})})})}if(n.config.responses.enabled&&t.responses){let{response:i}=tt(t);if(i){let a=[...r.path.value,`responses`];xs({ast:e(i,a),plugin:n,schema:i,state:r,symbol:n.registerSymbol({exported:!0,meta:{category:`schema`,path:a,resource:`operation`,resourceId:t.id,role:`responses`,tags:r.tags?.value,tool:`valibot`},name:x({config:n.config.responses,name:t.id})})})}}},Ds=({getAst:e,operation:t,plugin:n,state:r})=>{if(n.config.webhooks.enabled){let i=new Set,a={properties:{body:{type:`never`},path:{type:`never`},query:{type:`never`}},type:`object`};if(t.parameters){if(t.parameters.header){let e={},n=[];for(let r in t.parameters.header){let a=t.parameters.header[r];e[a.name]=a.schema,a.required&&(n.push(a.name),i.add(`headers`))}Object.keys(e).length&&(a.properties.headers={properties:e,required:n,type:`object`})}if(t.parameters.path){let e={},n=[];for(let r in t.parameters.path){let a=t.parameters.path[r];e[a.name]=a.schema,a.required&&(n.push(a.name),i.add(`path`))}Object.keys(e).length&&(a.properties.path={properties:e,required:n,type:`object`})}if(t.parameters.query){let e={},n=[];for(let r in t.parameters.query){let a=t.parameters.query[r];e[a.name]=a.schema,a.required&&(n.push(a.name),i.add(`query`))}Object.keys(e).length&&(a.properties.query={properties:e,required:n,type:`object`})}}t.body&&(a.properties.body=t.body.schema,t.body.required&&i.add(`body`)),a.required=[...i],xs({ast:e(a,r.path.value),plugin:n,schema:a,state:r,symbol:n.registerSymbol({exported:!0,meta:{category:`schema`,path:r.path.value,resource:`webhook`,resourceId:t.id,role:`data`,tags:r.tags?.value,tool:`valibot`},name:x({config:n.config.webhooks,name:t.id})})})}},Os=({plugin:e})=>{let t=e.referenceSymbol({category:`external`,resource:`valibot.v`});return M.callExpression({functionName:M.propertyAccessExpression({expression:t.placeholder,name:U.schemas.unknown})})},ks=({plugin:e,schema:t,state:n})=>{let r={pipes:[]},i=e.referenceSymbol({category:`external`,resource:`valibot.v`}),a=M.propertyAccessExpression({expression:i.placeholder,name:U.schemas.array});if(t.items){t=S({schema:t});let i=t.items.map((t,i)=>{let a=Us({plugin:e,schema:t,state:{...n,path:E([...n.path.value,`items`,i])}});return a.hasLazyExpression&&(r.hasLazyExpression=!0),W({pipes:a.pipes,plugin:e})});if(i.length===1){let e=M.callExpression({functionName:a,parameters:i});r.pipes.push(e)}else{t.logicalOperator;let i=M.callExpression({functionName:a,parameters:[Os({plugin:e,schema:{type:`unknown`},state:n})]});r.pipes.push(i)}}else{let t=M.callExpression({functionName:a,parameters:[Os({plugin:e,schema:{type:`unknown`},state:n})]});r.pipes.push(t)}if(t.minItems===t.maxItems&&t.minItems!==void 0){let e=M.callExpression({functionName:M.propertyAccessExpression({expression:i.placeholder,name:U.actions.length}),parameters:[M.valueToExpression({value:t.minItems})]});r.pipes.push(e)}else{if(t.minItems!==void 0){let e=M.callExpression({functionName:M.propertyAccessExpression({expression:i.placeholder,name:U.actions.minLength}),parameters:[M.valueToExpression({value:t.minItems})]});r.pipes.push(e)}if(t.maxItems!==void 0){let e=M.callExpression({functionName:M.propertyAccessExpression({expression:i.placeholder,name:U.actions.maxLength}),parameters:[M.valueToExpression({value:t.maxItems})]});r.pipes.push(e)}}return r},As=({plugin:e,schema:t})=>{let n=[],r=e.referenceSymbol({category:`external`,resource:`valibot.v`});return typeof t.const==`boolean`?(n.push(B(r.placeholder).attr(U.schemas.literal).call(B.literal(t.const))),W({pipes:n,plugin:e})):(n.push(B(r.placeholder).attr(U.schemas.boolean).call()),W({pipes:n,plugin:e}))},js=({plugin:e,schema:t,state:n})=>{let r=[],i=!1;for(let e of t.items??[])e.type===`string`&&typeof e.const==`string`?r.push(M.stringLiteral({text:e.const})):(e.type===`null`||e.const===null)&&(i=!0);if(!r.length)return Os({plugin:e,schema:{type:`unknown`},state:n});let a=e.referenceSymbol({category:`external`,resource:`valibot.v`}),o=M.callExpression({functionName:M.propertyAccessExpression({expression:a.placeholder,name:U.schemas.picklist}),parameters:[M.arrayLiteralExpression({elements:r,multiLine:!1})]});return i&&(o=M.callExpression({functionName:M.propertyAccessExpression({expression:a.placeholder,name:U.schemas.nullable}),parameters:[o]})),o},Ms=({plugin:e})=>{let t=e.referenceSymbol({category:`external`,resource:`valibot.v`});return M.callExpression({functionName:M.propertyAccessExpression({expression:t.placeholder,name:U.schemas.never})})},Ns=({plugin:e})=>{let t=e.referenceSymbol({category:`external`,resource:`valibot.v`});return M.callExpression({functionName:M.propertyAccessExpression({expression:t.placeholder,name:U.schemas.null})})},Ps=({plugin:e,schema:t})=>{let n=t.format,r=t.type===`integer`,i=ws(n),a=Cs(n)?Ss[n]:null,o=e.referenceSymbol({category:`external`,resource:`valibot.v`});if(t.const!==void 0&&t.const!==null){let e=t.const,r;if(typeof e==`number`&&!n)r=M.ots.number(e);else if(typeof e==`number`&&n)r=i?M.callExpression({functionName:`BigInt`,parameters:[M.ots.string(e.toString())]}):M.ots.number(e);else if(typeof e==`string`&&i){let t=e.endsWith(`n`)?e.slice(0,-1):e;r=M.callExpression({functionName:`BigInt`,parameters:[M.ots.string(t)]})}else if(typeof e==`bigint`){let t=e.toString(),n=t.endsWith(`n`)?t.slice(0,-1):t;r=M.callExpression({functionName:`BigInt`,parameters:[M.ots.string(n)]})}else r=M.valueToExpression({value:e});return M.callExpression({functionName:M.propertyAccessExpression({expression:o.placeholder,name:U.schemas.literal}),parameters:[r]})}let s=[];if(i){let e=M.callExpression({functionName:M.propertyAccessExpression({expression:o.placeholder,name:U.schemas.union}),parameters:[M.arrayLiteralExpression({elements:[M.callExpression({functionName:M.propertyAccessExpression({expression:o.placeholder,name:U.schemas.number})}),M.callExpression({functionName:M.propertyAccessExpression({expression:o.placeholder,name:U.schemas.string})}),M.callExpression({functionName:M.propertyAccessExpression({expression:o.placeholder,name:U.schemas.bigInt})})],multiLine:!1})]});s.push(e);let t=M.callExpression({functionName:M.propertyAccessExpression({expression:o.placeholder,name:U.actions.transform}),parameters:[M.arrowFunction({parameters:[{name:`x`}],statements:M.callExpression({functionName:`BigInt`,parameters:[M.identifier({text:`x`})]})})]});s.push(t)}else{let e=M.callExpression({functionName:M.propertyAccessExpression({expression:o.placeholder,name:U.schemas.number})});s.push(e)}if(!i&&r){let e=M.callExpression({functionName:M.propertyAccessExpression({expression:o.placeholder,name:U.actions.integer})});s.push(e)}if(a){let e=a.min,t=a.max,n=a.minError,r=a.maxError,c=M.callExpression({functionName:M.propertyAccessExpression({expression:o.placeholder,name:U.actions.minValue}),parameters:[i?M.callExpression({functionName:`BigInt`,parameters:[M.ots.string(e.toString())]}):M.ots.number(e),M.ots.string(n)]});s.push(c);let l=M.callExpression({functionName:M.propertyAccessExpression({expression:o.placeholder,name:U.actions.maxValue}),parameters:[i?M.callExpression({functionName:`BigInt`,parameters:[M.ots.string(t.toString())]}):M.ots.number(t),M.ots.string(r)]});s.push(l)}if(t.exclusiveMinimum!==void 0){let e=M.callExpression({functionName:M.propertyAccessExpression({expression:o.placeholder,name:U.actions.gtValue}),parameters:[Ts({isBigInt:i,value:t.exclusiveMinimum})]});s.push(e)}else if(t.minimum!==void 0){let e=M.callExpression({functionName:M.propertyAccessExpression({expression:o.placeholder,name:U.actions.minValue}),parameters:[Ts({isBigInt:i,value:t.minimum})]});s.push(e)}if(t.exclusiveMaximum!==void 0){let e=M.callExpression({functionName:M.propertyAccessExpression({expression:o.placeholder,name:U.actions.ltValue}),parameters:[Ts({isBigInt:i,value:t.exclusiveMaximum})]});s.push(e)}else if(t.maximum!==void 0){let e=M.callExpression({functionName:M.propertyAccessExpression({expression:o.placeholder,name:U.actions.maxValue}),parameters:[Ts({isBigInt:i,value:t.maximum})]});s.push(e)}return W({pipes:s,plugin:e})};function Fs({additional:e,pipes:t,plugin:n,shape:r}){let i=n.referenceSymbol({category:`external`,resource:`valibot.v`});return e===null?t.push(B(i.placeholder).attr(U.schemas.strictObject).call(r)):e?r.isEmpty?t.push(B(i.placeholder).attr(U.schemas.record).call(B(i.placeholder).attr(U.schemas.string).call(),e)):t.push(B(i.placeholder).attr(U.schemas.objectWithRest).call(r,e)):t.push(B(i.placeholder).attr(U.schemas.object).call(r))}const Is=({plugin:e,schema:t,state:n})=>{let r={},i=[],a=B.object().pretty(),o=t.required??[];for(let i in t.properties){let s=t.properties[i],c=Us({optional:!o.includes(i),plugin:e,schema:s,state:{...n,path:E([...n.path.value,`properties`,i])}});c.hasLazyExpression&&(r.hasLazyExpression=!0),a.prop(i,W({pipes:c.pipes,plugin:e}))}let s;if(t.additionalProperties&&t.additionalProperties.type)if(t.additionalProperties.type===`never`)s=null;else{let i=Us({plugin:e,schema:t.additionalProperties,state:{...n,path:E([...n.path.value,`additionalProperties`])}});i.hasLazyExpression&&(r.hasLazyExpression=!0),s=W({pipes:i.pipes,plugin:e})}let c={$:B,additional:s,pipes:i,plugin:e,schema:t,shape:a},l=e.config[`~resolvers`]?.object?.base;return l?.(c)||Fs(c),r.pipes=[W({pipes:i,plugin:e})],r},Ls=({pipes:e,plugin:t,schema:n})=>{let r=t.referenceSymbol({category:`external`,resource:`valibot.v`});switch(n.format){case`date`:return e.push(B(r.placeholder).attr(U.actions.isoDate).call());case`date-time`:return e.push(B(r.placeholder).attr(U.actions.isoTimestamp).call());case`email`:return e.push(B(r.placeholder).attr(U.actions.email).call());case`ipv4`:case`ipv6`:return e.push(B(r.placeholder).attr(U.actions.ip).call());case`time`:return e.push(B(r.placeholder).attr(U.actions.isoTimeSecond).call());case`uri`:return e.push(B(r.placeholder).attr(U.actions.url).call());case`uuid`:return e.push(B(r.placeholder).attr(U.actions.uuid).call())}return!0},Rs=({plugin:e,schema:t})=>{let n=[],r=e.referenceSymbol({category:`external`,resource:`valibot.v`});if(typeof t.const==`string`)return n.push(B(r.placeholder).attr(U.schemas.literal).call(B.literal(t.const))),W({pipes:n,plugin:e});if(n.push(B(r.placeholder).attr(U.schemas.string).call()),t.format){let r={$:B,pipes:n,plugin:e,schema:t},i=e.config[`~resolvers`]?.string?.formats?.[t.format];i?.(r)||Ls(r)}return t.minLength===t.maxLength&&t.minLength!==void 0?n.push(B(r.placeholder).attr(U.actions.length).call(B.literal(t.minLength))):(t.minLength!==void 0&&n.push(B(r.placeholder).attr(U.actions.minLength).call(B.literal(t.minLength))),t.maxLength!==void 0&&n.push(B(r.placeholder).attr(U.actions.maxLength).call(B.literal(t.maxLength)))),t.pattern&&n.push(B(r.placeholder).attr(U.actions.regex).call(B.regexp(t.pattern))),W({pipes:n,plugin:e})},zs=({plugin:e,schema:t,state:n})=>{let r={},i=e.referenceSymbol({category:`external`,resource:`valibot.v`});if(t.const&&Array.isArray(t.const)){let e=t.const.map(e=>M.callExpression({functionName:M.propertyAccessExpression({expression:i.placeholder,name:U.schemas.literal}),parameters:[M.valueToExpression({value:e})]}));return r.pipes=[M.callExpression({functionName:M.propertyAccessExpression({expression:i.placeholder,name:U.schemas.tuple}),parameters:[M.arrayLiteralExpression({elements:e})]})],r}if(t.items){let a=t.items.map((t,i)=>{let a=Us({plugin:e,schema:t,state:{...n,path:E([...n.path.value,`items`,i])}});return a.hasLazyExpression&&(r.hasLazyExpression=!0),W({pipes:a.pipes,plugin:e})});return r.pipes=[M.callExpression({functionName:M.propertyAccessExpression({expression:i.placeholder,name:U.schemas.tuple}),parameters:[M.arrayLiteralExpression({elements:a})]})],r}return{pipes:[Os({plugin:e,schema:{type:`unknown`},state:n})]}},Bs=({plugin:e})=>{let t=e.referenceSymbol({category:`external`,resource:`valibot.v`});return M.callExpression({functionName:M.propertyAccessExpression({expression:t.placeholder,name:U.schemas.undefined})})},Vs=({plugin:e})=>{let t=e.referenceSymbol({category:`external`,resource:`valibot.v`});return M.callExpression({functionName:M.propertyAccessExpression({expression:t.placeholder,name:U.schemas.void})})},Hs=({schema:e,...t})=>{switch(e.type){case`array`:return{expression:W({pipes:ks({...t,schema:e}).pipes,plugin:t.plugin})};case`boolean`:return{expression:As({...t,schema:e})};case`enum`:return{expression:js({...t,schema:e})};case`integer`:case`number`:return{expression:Ps({...t,schema:e})};case`never`:return{expression:Ms({...t,schema:e})};case`null`:return{expression:Ns({...t,schema:e})};case`object`:return{expression:W({pipes:Is({...t,schema:e}).pipes,plugin:t.plugin})};case`string`:return e.format===`int64`||e.format===`uint64`?{expression:Ps({...t,schema:e})}:{expression:Rs({...t,schema:e})};case`tuple`:return{expression:W({pipes:zs({...t,schema:e}).pipes,plugin:t.plugin})};case`undefined`:return{expression:Bs({...t,schema:e})};case`unknown`:return{expression:Os({...t,schema:e})};case`void`:return{expression:Vs({...t,schema:e})}}},Us=({optional:e,plugin:t,schema:n,state:r})=>{let i={pipes:[]},a=t.referenceSymbol({category:`external`,resource:`valibot.v`});if(n.$ref){let e={category:`schema`,resource:`definition`,resourceId:n.$ref,tool:`valibot`},o=t.referenceSymbol(e);if(t.isSymbolRegistered(e)){let e=M.identifier({text:o.placeholder});i.pipes.push(e)}else{let e=M.callExpression({functionName:M.propertyAccessExpression({expression:a.placeholder,name:U.schemas.lazy}),parameters:[M.arrowFunction({statements:[M.returnStatement({expression:M.identifier({text:o.placeholder})})]})]});i.pipes.push(e),r.hasLazyExpression.value=!0}}else if(n.type){let e=Hs({plugin:t,schema:n,state:r});if(i.typeName=e.anyType,i.pipes.push(e.expression),t.config.metadata&&n.description){let e=M.callExpression({functionName:M.propertyAccessExpression({expression:a.placeholder,name:U.actions.metadata}),parameters:[M.objectExpression({obj:[{key:`description`,value:M.stringLiteral({text:n.description})}]})]});i.pipes.push(e)}}else if(n.items)if(n=S({schema:n}),n.items){let e=n.items.map((e,n)=>W({pipes:Us({plugin:t,schema:e,state:{...r,path:E([...r.path.value,`items`,n])}}).pipes,plugin:t}));if(n.logicalOperator===`and`){let t=M.callExpression({functionName:M.propertyAccessExpression({expression:a.placeholder,name:U.schemas.intersect}),parameters:[M.arrayLiteralExpression({elements:e})]});i.pipes.push(t)}else{let t=M.callExpression({functionName:M.propertyAccessExpression({expression:a.placeholder,name:U.schemas.union}),parameters:[M.arrayLiteralExpression({elements:e})]});i.pipes.push(t)}}else{let e=Us({plugin:t,schema:n,state:r});i.pipes.push(...e.pipes)}else{let e=Hs({plugin:t,schema:{type:`unknown`},state:r});i.typeName=e.anyType,i.pipes.push(e.expression)}if(i.pipes.length){if(n.accessScope===`read`){let e=M.callExpression({functionName:M.propertyAccessExpression({expression:a.placeholder,name:U.actions.readonly})});i.pipes.push(e)}let r;n.default!==void 0&&(r=Ts({isBigInt:n.type===`integer`&&n.format===`int64`,value:n.default}),r&&(i.pipes=[M.callExpression({functionName:M.propertyAccessExpression({expression:a.placeholder,name:U.schemas.optional}),parameters:[W({pipes:i.pipes,plugin:t}),r]})])),e&&!r&&(i.pipes=[M.callExpression({functionName:M.propertyAccessExpression({expression:a.placeholder,name:U.schemas.optional}),parameters:[W({pipes:i.pipes,plugin:t})]})])}return i},Ws=({plugin:e,schema:t,state:n})=>{let r=Xn(n.path.value),i=Us({plugin:e,schema:t,state:n}),a=N(r);xs({ast:i,plugin:e,schema:t,state:n,symbol:e.registerSymbol({exported:!0,meta:{category:`schema`,path:n.path.value,resource:`definition`,resourceId:r,tags:n.tags?.value,tool:`valibot`},name:x({config:e.config.definitions,name:a})})})},Gs=({plugin:e})=>{e.registerSymbol({external:`valibot`,importKind:`namespace`,meta:{category:`external`,resource:`valibot.v`},name:`v`}),e.forEach(`operation`,`parameter`,`requestBody`,`schema`,`webhook`,t=>{let n=D({hasLazyExpression:!1,path:t._path,tags:t.tags});switch(t.type){case`operation`:Es({getAst:(n,r)=>Us({plugin:e,schema:n,state:D({hasLazyExpression:!1,path:r,tags:t.tags})}),operation:t.operation,plugin:e,state:n});break;case`parameter`:Ws({plugin:e,schema:t.parameter.schema,state:n});break;case`requestBody`:Ws({plugin:e,schema:t.requestBody.schema,state:n});break;case`schema`:Ws({plugin:e,schema:t.schema,state:n});break;case`webhook`:Ds({getAst:(n,r)=>Us({plugin:e,schema:n,state:D({hasLazyExpression:!1,path:r,tags:t.tags})}),operation:t.operation,plugin:e,state:n});break}})},Ks={api:new bs,config:{case:`camelCase`,comments:!0,exportFromIndex:!1,metadata:!1},handler:e=>Gs(e),name:`valibot`,resolveConfig:(e,t)=>{e.config.definitions=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`v{{name}}`},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.definitions}),e.config.requests=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`v{{name}}Data`},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.requests}),e.config.responses=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`v{{name}}Response`},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.responses}),e.config.webhooks=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`v{{name}}WebhookRequest`},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.webhooks})},tags:[`validator`]},G={ZodMiniOptional:M.identifier({text:`ZodMiniOptional`}),ZodOptional:M.identifier({text:`ZodOptional`}),_default:M.identifier({text:`_default`}),and:M.identifier({text:`and`}),array:M.identifier({text:`array`}),bigint:M.identifier({text:`bigint`}),boolean:M.identifier({text:`boolean`}),check:M.identifier({text:`check`}),coerce:M.identifier({text:`coerce`}),date:M.identifier({text:`date`}),datetime:M.identifier({text:`datetime`}),default:M.identifier({text:`default`}),describe:M.identifier({text:`describe`}),email:M.identifier({text:`email`}),enum:M.identifier({text:`enum`}),globalRegistry:M.identifier({text:`globalRegistry`}),gt:M.identifier({text:`gt`}),gte:M.identifier({text:`gte`}),infer:M.identifier({text:`infer`}),int:M.identifier({text:`int`}),intersection:M.identifier({text:`intersection`}),ip:M.identifier({text:`ip`}),ipv4:M.identifier({text:`ipv4`}),ipv6:M.identifier({text:`ipv6`}),iso:M.identifier({text:`iso`}),lazy:M.identifier({text:`lazy`}),length:M.identifier({text:`length`}),literal:M.identifier({text:`literal`}),lt:M.identifier({text:`lt`}),lte:M.identifier({text:`lte`}),max:M.identifier({text:`max`}),maxLength:M.identifier({text:`maxLength`}),min:M.identifier({text:`min`}),minLength:M.identifier({text:`minLength`}),never:M.identifier({text:`never`}),null:M.identifier({text:`null`}),nullable:M.identifier({text:`nullable`}),number:M.identifier({text:`number`}),object:M.identifier({text:`object`}),optional:M.identifier({text:`optional`}),parseAsync:M.identifier({text:`parseAsync`}),readonly:M.identifier({text:`readonly`}),record:M.identifier({text:`record`}),regex:M.identifier({text:`regex`}),register:M.identifier({text:`register`}),string:M.identifier({text:`string`}),time:M.identifier({text:`time`}),tuple:M.identifier({text:`tuple`}),undefined:M.identifier({text:`undefined`}),union:M.identifier({text:`union`}),unknown:M.identifier({text:`unknown`}),url:M.identifier({text:`url`}),uuid:M.identifier({text:`uuid`}),void:M.identifier({text:`void`})},qs=({schema:e})=>B(e.placeholder).attr(G.parseAsync).call(`data`).await().return(),Js=({operation:e,plugin:t})=>{let n=t.getSymbol({category:`schema`,resource:`operation`,resourceId:e.id,role:`data`,tool:`zod`});if(!n)return;let r={$:B,chain:void 0,operation:e,plugin:t,schema:n},i=t.config[`~resolvers`]?.validator,a=[typeof i==`function`?i:i?.request,qs];for(let e of a){let t=e?.(r);if(t===null)return;if(t!==void 0)return B.func().async().param(`data`).do(...t instanceof Array?t:[t])}},Ys=({operation:e,plugin:t})=>{let n=t.getSymbol({category:`schema`,resource:`operation`,resourceId:e.id,role:`responses`,tool:`zod`});if(!n)return;let r={$:B,chain:void 0,operation:e,plugin:t,schema:n},i=t.config[`~resolvers`]?.validator,a=[typeof i==`function`?i:i?.response,qs];for(let e of a){let t=e?.(r);if(t===null)return;if(t!==void 0)return B.func().async().param(`data`).do(...t instanceof Array?t:[t])}},Xs=({schema:e})=>B(e.placeholder).attr(G.parseAsync).call(`data`).await().return(),Zs=({operation:e,plugin:t})=>{let n=t.getSymbol({category:`schema`,resource:`operation`,resourceId:e.id,role:`data`,tool:`zod`});if(!n)return;let r={$:B,chain:void 0,operation:e,plugin:t,schema:n},i=t.config[`~resolvers`]?.validator,a=[typeof i==`function`?i:i?.request,Xs];for(let e of a){let t=e?.(r);if(t===null)return;if(t!==void 0)return B.func().async().param(`data`).do(...t instanceof Array?t:[t])}},Qs=({operation:e,plugin:t})=>{let n=t.getSymbol({category:`schema`,resource:`operation`,resourceId:e.id,role:`responses`,tool:`zod`});if(!n)return;let r={$:B,chain:void 0,operation:e,plugin:t,schema:n},i=t.config[`~resolvers`]?.validator,a=[typeof i==`function`?i:i?.response,Xs];for(let e of a){let t=e?.(r);if(t===null)return;if(t!==void 0)return B.func().async().param(`data`).do(...t instanceof Array?t:[t])}},$s=({schema:e})=>B(e.placeholder).attr(G.parseAsync).call(`data`).await().return(),ec=({operation:e,plugin:t})=>{let n=t.getSymbol({category:`schema`,resource:`operation`,resourceId:e.id,role:`data`,tool:`zod`});if(!n)return;let r={$:B,chain:void 0,operation:e,plugin:t,schema:n},i=t.config[`~resolvers`]?.validator,a=[typeof i==`function`?i:i?.request,$s];for(let e of a){let t=e?.(r);if(t===null)return;if(t!==void 0)return B.func().async().param(`data`).do(...t instanceof Array?t:[t])}},tc=({operation:e,plugin:t})=>{let n=t.getSymbol({category:`schema`,resource:`operation`,resourceId:e.id,role:`responses`,tool:`zod`});if(!n)return;let r={$:B,chain:void 0,operation:e,plugin:t,schema:n},i=t.config[`~resolvers`]?.validator,a=[typeof i==`function`?i:i?.response,$s];for(let e of a){let t=e?.(r);if(t===null)return;if(t!==void 0)return B.func().async().param(`data`).do(...t instanceof Array?t:[t])}};var nc=class{createRequestValidator(e){let{plugin:t}=e;switch(t.config.compatibilityVersion){case 3:return Zs(e);case`mini`:return Js(e);case 4:default:return ec(e)}}createResponseValidator(e){let{plugin:t}=e;switch(t.config.compatibilityVersion){case 3:return Qs(e);case`mini`:return Ys(e);case 4:default:return tc(e)}}};const rc=({ast:e,plugin:t,schema:n,symbol:r,typeInferSymbol:i})=>{let a=t.referenceSymbol({category:`external`,resource:`zod.z`}),o=B.const(r.placeholder).export(r.exported).$if(t.config.comments&&za({schema:n}),(e,t)=>e.describe(t)).$if(e.typeName,(e,t)=>e.type(B.type(a.placeholder).attr(t))).assign(e.expression);if(t.setSymbolValue(r,o),i){let e=B.type.alias(i.placeholder).export(i.exported).type(B.type(a.placeholder).attr(G.infer).generic(B(r.placeholder).typeof()));t.setSymbolValue(i,e)}},ic=({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`}},K=({isBigInt:e,value:t})=>{let n=M.valueToExpression({value:t});return e&&(typeof t==`bigint`||typeof t==`number`||typeof t==`string`||typeof t==`boolean`)?M.callExpression({functionName:`BigInt`,parameters:[n]}):n},ac=({getAst:e,operation:t,plugin:n,state:r})=>{if(n.config.requests.enabled){let i=new Set,a={properties:{body:{type:`never`},path:{type:`never`},query:{type:`never`}},type:`object`};if(t.parameters){if(t.parameters.header){let e={},n=[];for(let r in t.parameters.header){let a=t.parameters.header[r];e[a.name]=a.schema,a.required&&(n.push(a.name),i.add(`headers`))}Object.keys(e).length&&(a.properties.headers={properties:e,required:n,type:`object`})}if(t.parameters.path){let e={},n=[];for(let r in t.parameters.path){let a=t.parameters.path[r];e[a.name]=a.schema,a.required&&(n.push(a.name),i.add(`path`))}Object.keys(e).length&&(a.properties.path={properties:e,required:n,type:`object`})}if(t.parameters.query){let e={},n=[];for(let r in t.parameters.query){let a=t.parameters.query[r];e[a.name]=a.schema,a.required&&(n.push(a.name),i.add(`query`))}Object.keys(e).length&&(a.properties.query={properties:e,required:n,type:`object`})}}t.body&&(a.properties.body=t.body.schema,t.body.required&&i.add(`body`)),a.required=[...i],rc({ast:e(a,r.path.value),plugin:n,schema:a,symbol:n.registerSymbol({exported:!0,meta:{category:`schema`,path:r.path.value,resource:`operation`,resourceId:t.id,role:`data`,tags:r.tags?.value,tool:`zod`},name:x({config:n.config.requests,name:t.id})}),typeInferSymbol:n.config.requests.types.infer.enabled?n.registerSymbol({exported:!0,kind:`type`,meta:{category:`type`,path:r.path.value,resource:`operation`,resourceId:t.id,role:`data`,tags:r.tags?.value,tool:`zod`,variant:`infer`},name:x({config:n.config.requests.types.infer,name:t.id})}):void 0})}if(n.config.responses.enabled&&t.responses){let{response:i}=tt(t);if(i){let a=[...r.path.value,`responses`];rc({ast:e(i,a),plugin:n,schema:i,symbol:n.registerSymbol({exported:!0,meta:{category:`schema`,path:a,resource:`operation`,resourceId:t.id,role:`responses`,tags:r.tags?.value,tool:`zod`},name:x({config:n.config.responses,name:t.id})}),typeInferSymbol:n.config.responses.types.infer.enabled?n.registerSymbol({exported:!0,kind:`type`,meta:{category:`type`,path:a,resource:`operation`,resourceId:t.id,role:`responses`,tags:r.tags?.value,tool:`zod`,variant:`infer`},name:x({config:n.config.responses.types.infer,name:t.id})}):void 0})}}},oc=({getAst:e,operation:t,plugin:n,state:r})=>{if(n.config.webhooks.enabled){let i=new Set,a={properties:{body:{type:`never`},path:{type:`never`},query:{type:`never`}},type:`object`};if(t.parameters){if(t.parameters.header){let e={},n=[];for(let r in t.parameters.header){let a=t.parameters.header[r];e[a.name]=a.schema,a.required&&(n.push(a.name),i.add(`headers`))}Object.keys(e).length&&(a.properties.headers={properties:e,required:n,type:`object`})}if(t.parameters.path){let e={},n=[];for(let r in t.parameters.path){let a=t.parameters.path[r];e[a.name]=a.schema,a.required&&(n.push(a.name),i.add(`path`))}Object.keys(e).length&&(a.properties.path={properties:e,required:n,type:`object`})}if(t.parameters.query){let e={},n=[];for(let r in t.parameters.query){let a=t.parameters.query[r];e[a.name]=a.schema,a.required&&(n.push(a.name),i.add(`query`))}Object.keys(e).length&&(a.properties.query={properties:e,required:n,type:`object`})}}t.body&&(a.properties.body=t.body.schema,t.body.required&&i.add(`body`)),a.required=[...i],rc({ast:e(a,r.path.value),plugin:n,schema:a,symbol:n.registerSymbol({exported:!0,meta:{category:`schema`,path:r.path.value,resource:`webhook`,resourceId:t.id,role:`data`,tags:r.tags?.value,tool:`zod`},name:x({config:n.config.webhooks,name:t.id})}),typeInferSymbol:n.config.webhooks.types.infer.enabled?n.registerSymbol({exported:!0,kind:`type`,meta:{category:`type`,path:r.path.value,resource:`webhook`,resourceId:t.id,role:`data`,tags:r.tags?.value,tool:`zod`,variant:`infer`},name:x({config:n.config.webhooks.types.infer,name:t.id})}):void 0})}},sc=({plugin:e})=>{let t=e.referenceSymbol({category:`external`,resource:`zod.z`}),n={};return n.expression=M.callExpression({functionName:M.propertyAccessExpression({expression:t.placeholder,name:G.unknown})}),n},cc=({plugin:e,schema:t,state:n})=>{let r=e.referenceSymbol({category:`external`,resource:`zod.z`}),i={},a=M.propertyAccessExpression({expression:r.placeholder,name:G.array});if(!t.items)i.expression=M.callExpression({functionName:a,parameters:[sc({plugin:e,schema:{type:`unknown`},state:n}).expression]});else{t=S({schema:t});let o=t.items.map((t,r)=>{let a=Sc({plugin:e,schema:t,state:{...n,path:E([...n.path.value,`items`,r])}});return a.hasLazyExpression&&(i.hasLazyExpression=!0),a.expression});if(o.length===1)i.expression=M.callExpression({functionName:a,parameters:o});else if(t.logicalOperator===`and`){let e=t.items[0],n;if(e.logicalOperator===`or`||e.type&&e.type!==`object`)n=M.callExpression({functionName:M.propertyAccessExpression({expression:r.placeholder,name:G.intersection}),parameters:o});else{n=o[0];for(let e=1;e<o.length;e++)n=M.callExpression({functionName:M.propertyAccessExpression({expression:r.placeholder,name:G.intersection}),parameters:[n,o[e]]})}i.expression=M.callExpression({functionName:a,parameters:[n]})}else i.expression=M.callExpression({functionName:M.propertyAccessExpression({expression:r.placeholder,name:G.array}),parameters:[M.callExpression({functionName:M.propertyAccessExpression({expression:r.placeholder,name:G.union}),parameters:[M.arrayLiteralExpression({elements:o})]})]})}let o=[];return t.minItems===t.maxItems&&t.minItems!==void 0?o.push(M.callExpression({functionName:M.propertyAccessExpression({expression:r.placeholder,name:G.length}),parameters:[M.valueToExpression({value:t.minItems})]})):(t.minItems!==void 0&&o.push(M.callExpression({functionName:M.propertyAccessExpression({expression:r.placeholder,name:G.minLength}),parameters:[M.valueToExpression({value:t.minItems})]})),t.maxItems!==void 0&&o.push(M.callExpression({functionName:M.propertyAccessExpression({expression:r.placeholder,name:G.maxLength}),parameters:[M.valueToExpression({value:t.maxItems})]}))),o.length&&(i.expression=M.callExpression({functionName:M.propertyAccessExpression({expression:i.expression,name:G.check}),parameters:o})),i},lc=({plugin:e,schema:t})=>{let n={},r,i=e.referenceSymbol({category:`external`,resource:`zod.z`});return typeof t.const==`boolean`?(r=B(i.placeholder).attr(G.literal).call(B.literal(t.const)),n.expression=r.$render(),n):(r=B(i.placeholder).attr(G.boolean).call(),n.expression=r.$render(),n)},uc=({plugin:e,schema:t,state:n})=>{let r=e.referenceSymbol({category:`external`,resource:`zod.z`}),i={},a=[],o=[],s=!1,c=!0;for(let e of t.items??[])if(e.type===`string`&&typeof e.const==`string`){let t=M.stringLiteral({text:e.const});a.push(t),o.push(M.callExpression({functionName:M.propertyAccessExpression({expression:r.placeholder,name:G.literal}),parameters:[t]}))}else if((e.type===`number`||e.type===`integer`)&&typeof e.const==`number`){c=!1;let t=M.ots.number(e.const);o.push(M.callExpression({functionName:M.propertyAccessExpression({expression:r.placeholder,name:G.literal}),parameters:[t]}))}else if(e.type===`boolean`&&typeof e.const==`boolean`){c=!1;let t=M.ots.boolean(e.const);o.push(M.callExpression({functionName:M.propertyAccessExpression({expression:r.placeholder,name:G.literal}),parameters:[t]}))}else (e.type===`null`||e.const===null)&&(s=!0);return o.length?(c&&a.length>0?i.expression=M.callExpression({functionName:M.propertyAccessExpression({expression:r.placeholder,name:G.enum}),parameters:[M.arrayLiteralExpression({elements:a,multiLine:!1})]}):o.length===1?i.expression=o[0]:i.expression=M.callExpression({functionName:M.propertyAccessExpression({expression:r.placeholder,name:G.union}),parameters:[M.arrayLiteralExpression({elements:o,multiLine:o.length>3})]}),s&&(i.expression=M.callExpression({functionName:M.propertyAccessExpression({expression:r.placeholder,name:G.nullable}),parameters:[i.expression]})),i):sc({plugin:e,schema:{type:`unknown`},state:n})},dc=({plugin:e})=>{let t=e.referenceSymbol({category:`external`,resource:`zod.z`}),n={};return n.expression=M.callExpression({functionName:M.propertyAccessExpression({expression:t.placeholder,name:G.never})}),n},fc=({plugin:e})=>{let t=e.referenceSymbol({category:`external`,resource:`zod.z`}),n={};return n.expression=M.callExpression({functionName:M.propertyAccessExpression({expression:t.placeholder,name:G.null})}),n},pc=({plugin:e,schema:t})=>{let n=e.referenceSymbol({category:`external`,resource:`zod.z`}),r={},i=t.type===`integer`&&t.format===`int64`;if(typeof t.const==`number`)return r.expression=M.callExpression({functionName:M.propertyAccessExpression({expression:n.placeholder,name:G.literal}),parameters:[M.ots.number(t.const)]}),r;r.expression=M.callExpression({functionName:i?M.propertyAccessExpression({expression:M.propertyAccessExpression({expression:n.placeholder,name:G.coerce}),name:G.bigint}):M.propertyAccessExpression({expression:n.placeholder,name:G.number})}),!i&&t.type===`integer`&&(r.expression=M.callExpression({functionName:M.propertyAccessExpression({expression:n.placeholder,name:G.int})}));let a=[];return t.exclusiveMinimum===void 0?t.minimum!==void 0&&a.push(M.callExpression({functionName:M.propertyAccessExpression({expression:n.placeholder,name:G.gte}),parameters:[K({isBigInt:i,value:t.minimum})]})):a.push(M.callExpression({functionName:M.propertyAccessExpression({expression:n.placeholder,name:G.gt}),parameters:[K({isBigInt:i,value:t.exclusiveMinimum})]})),t.exclusiveMaximum===void 0?t.maximum!==void 0&&a.push(M.callExpression({functionName:M.propertyAccessExpression({expression:n.placeholder,name:G.lte}),parameters:[K({isBigInt:i,value:t.maximum})]})):a.push(M.callExpression({functionName:M.propertyAccessExpression({expression:n.placeholder,name:G.lt}),parameters:[K({isBigInt:i,value:t.exclusiveMaximum})]})),a.length&&(r.expression=M.callExpression({functionName:M.propertyAccessExpression({expression:r.expression,name:G.check}),parameters:a})),r};function mc({additional:e,plugin:t,shape:n}){let r=t.referenceSymbol({category:`external`,resource:`zod.z`});return e?B(r.placeholder).attr(G.record).call(B(r.placeholder).attr(G.string).call(),e):B(r.placeholder).attr(G.object).call(n)}const hc=({plugin:e,schema:t,state:n})=>{let r={},i=B.object().pretty(),a=t.required??[];for(let o in t.properties){let s=t.properties[o],c=Sc({optional:!a.includes(o),plugin:e,schema:s,state:{...n,path:E([...n.path.value,`properties`,o])}});c.hasLazyExpression&&(r.hasLazyExpression=!0),c.hasLazyExpression?i.getter(o,B(c.expression).return()):i.prop(o,c.expression)}let o;if(t.additionalProperties&&(!t.properties||!Object.keys(t.properties).length)){let i=Sc({plugin:e,schema:t.additionalProperties,state:{...n,path:E([...n.path.value,`additionalProperties`])}});i.hasLazyExpression&&(r.hasLazyExpression=!0),o=i.expression}let s={$:B,additional:o,chain:void 0,plugin:e,schema:t,shape:i},c=e.config[`~resolvers`]?.object?.base;return r.expression=(c?.(s)??mc(s)).$render(),r},gc=({chain:e,plugin:t,schema:n})=>{let r=t.referenceSymbol({category:`external`,resource:`zod.z`});switch(n.format){case`date`:return B(r.placeholder).attr(G.iso).attr(G.date).call();case`date-time`:{let e=B.object().$if(t.config.dates.offset,e=>e.prop(`offset`,B.literal(!0))).$if(t.config.dates.local,e=>e.prop(`local`,B.literal(!0)));return B(r.placeholder).attr(G.iso).attr(G.datetime).call(e.hasProps()?e:void 0)}case`email`:return B(r.placeholder).attr(G.email).call();case`ipv4`:return B(r.placeholder).attr(G.ipv4).call();case`ipv6`:return B(r.placeholder).attr(G.ipv6).call();case`time`:return B(r.placeholder).attr(G.iso).attr(G.time).call();case`uri`:return B(r.placeholder).attr(G.url).call();case`uuid`:return B(r.placeholder).attr(G.uuid).call();default:return e}},_c=({plugin:e,schema:t})=>{let n={},r,i=e.referenceSymbol({category:`external`,resource:`zod.z`});if(typeof t.const==`string`)return r=B(i.placeholder).attr(G.literal).call(B.literal(t.const)),n.expression=r.$render(),n;if(r=B(i.placeholder).attr(G.string).call(),t.format){let n={$:B,chain:r,plugin:e,schema:t},i=e.config[`~resolvers`]?.string?.formats?.[t.format];r=i?.(n)??gc(n)}let a=[];return t.minLength===t.maxLength&&t.minLength!==void 0?a.push(B(i.placeholder).attr(G.length).call(B.literal(t.minLength))):(t.minLength!==void 0&&a.push(B(i.placeholder).attr(G.minLength).call(B.literal(t.minLength))),t.maxLength!==void 0&&a.push(B(i.placeholder).attr(G.maxLength).call(B.literal(t.maxLength)))),t.pattern&&a.push(B(i.placeholder).attr(G.regex).call(B.regexp(t.pattern))),a.length&&(r=r.attr(G.check).call(...a)),n.expression=r.$render(),n},vc=({plugin:e,schema:t,state:n})=>{let r=e.referenceSymbol({category:`external`,resource:`zod.z`}),i={};if(t.const&&Array.isArray(t.const)){let e=t.const.map(e=>M.callExpression({functionName:M.propertyAccessExpression({expression:r.placeholder,name:G.literal}),parameters:[M.valueToExpression({value:e})]}));return i.expression=M.callExpression({functionName:M.propertyAccessExpression({expression:r.placeholder,name:G.tuple}),parameters:[M.arrayLiteralExpression({elements:e})]}),i}let a=[];return t.items&&t.items.forEach((t,r)=>{let o=Sc({plugin:e,schema:t,state:{...n,path:E([...n.path.value,`items`,r])}});a.push(o.expression),o.hasLazyExpression&&(i.hasLazyExpression=!0)}),i.expression=M.callExpression({functionName:M.propertyAccessExpression({expression:r.placeholder,name:G.tuple}),parameters:[M.arrayLiteralExpression({elements:a})]}),i},yc=({plugin:e})=>{let t=e.referenceSymbol({category:`external`,resource:`zod.z`}),n={};return n.expression=M.callExpression({functionName:M.propertyAccessExpression({expression:t.placeholder,name:G.undefined})}),n},bc=({plugin:e})=>{let t=e.referenceSymbol({category:`external`,resource:`zod.z`}),n={};return n.expression=M.callExpression({functionName:M.propertyAccessExpression({expression:t.placeholder,name:G.void})}),n},xc=({schema:e,...t})=>{switch(e.type){case`array`:return cc({...t,schema:e});case`boolean`:return lc({...t,schema:e});case`enum`:return uc({...t,schema:e});case`integer`:case`number`:return pc({...t,schema:e});case`never`:return dc({...t,schema:e});case`null`:return fc({...t,schema:e});case`object`:return hc({...t,schema:e});case`string`:return _c({...t,schema:e});case`tuple`:return vc({...t,schema:e});case`undefined`:return yc({...t,schema:e});case`unknown`:return sc({...t,schema:e});case`void`:return bc({...t,schema:e})}},Sc=({optional:e,plugin:t,schema:n,state:r})=>{let i={},a=t.referenceSymbol({category:`external`,resource:`zod.z`});if(n.$ref){let e={category:`schema`,resource:`definition`,resourceId:n.$ref,tool:`zod`},o=t.referenceSymbol(e);t.isSymbolRegistered(e)?i.expression=B(o.placeholder).$render():(i.expression=B(a.placeholder).attr(G.lazy).call(B.func().returns(`any`).do(B(o.placeholder).return())).$render(),i.hasLazyExpression=!0,r.hasLazyExpression.value=!0)}else if(n.type){let e=xc({plugin:t,schema:n,state:r});i.expression=e.expression,i.hasLazyExpression=e.hasLazyExpression,t.config.metadata&&n.description&&(i.expression=B(i.expression).attr(G.register).call(B(a.placeholder).attr(G.globalRegistry),B.object().pretty().prop(`description`,B.literal(n.description))).$render())}else if(n.items)if(n=S({schema:n}),n.items){let e=n.items.map((e,n)=>Sc({plugin:t,schema:e,state:{...r,path:E([...r.path.value,`items`,n])}}));if(n.logicalOperator===`and`){let t=n.items[0];t.logicalOperator===`or`||t.type&&t.type!==`object`?i.expression=B(a.placeholder).attr(G.intersection).call(...e.map(e=>e.expression)).$render():(i.expression=e[0].expression,e.slice(1).forEach(e=>{i.expression=B(a.placeholder).attr(G.intersection).call(i.expression,e.hasLazyExpression?B(a.placeholder).attr(G.lazy).call(B.func().do(B(e.expression).return())):e.expression).$render()}))}else i.expression=B(a.placeholder).attr(G.union).call(B.array().pretty().elements(...e.map(e=>e.expression))).$render()}else i=Sc({plugin:t,schema:n,state:r});else i.expression=xc({plugin:t,schema:{type:`unknown`},state:r}).expression;if(i.expression&&(n.accessScope===`read`&&(i.expression=B(a.placeholder).attr(G.readonly).call(i.expression).$render()),e&&(i.expression=B(a.placeholder).attr(G.optional).call(i.expression).$render(),i.typeName=G.ZodMiniOptional),n.default!==void 0)){let e=K({isBigInt:n.type===`integer`&&n.format===`int64`,value:n.default});e&&(i.expression=B(a.placeholder).attr(G._default).call(i.expression,e).$render())}return i},Cc=({plugin:e,schema:t,state:n})=>{let r=Xn(n.path.value),i=Sc({plugin:e,schema:t,state:n}),a=N(r);rc({ast:i,plugin:e,schema:t,symbol:e.registerSymbol({exported:!0,meta:{category:`schema`,path:n.path.value,resource:`definition`,resourceId:r,tags:n.tags?.value,tool:`zod`},name:x({config:e.config.definitions,name:a})}),typeInferSymbol:e.config.definitions.types.infer.enabled?e.registerSymbol({exported:!0,kind:`type`,meta:{category:`type`,path:n.path.value,resource:`definition`,resourceId:r,tags:n.tags?.value,tool:`zod`,variant:`infer`},name:x({config:e.config.definitions.types.infer,name:a})}):void 0})},wc=({plugin:e})=>{e.registerSymbol({external:ic({plugin:e}),importKind:`namespace`,meta:{category:`external`,resource:`zod.z`},name:`z`}),e.forEach(`operation`,`parameter`,`requestBody`,`schema`,`webhook`,t=>{let n=D({hasLazyExpression:!1,path:t._path,tags:t.tags});switch(t.type){case`operation`:ac({getAst:(n,r)=>Sc({plugin:e,schema:n,state:D({hasLazyExpression:!1,path:r,tags:t.tags})}),operation:t.operation,plugin:e,state:n});break;case`parameter`:Cc({plugin:e,schema:t.parameter.schema,state:n});break;case`requestBody`:Cc({plugin:e,schema:t.requestBody.schema,state:n});break;case`schema`:Cc({plugin:e,schema:t.schema,state:n});break;case`webhook`:oc({getAst:(n,r)=>Sc({plugin:e,schema:n,state:D({hasLazyExpression:!1,path:r,tags:t.tags})}),operation:t.operation,plugin:e,state:n});break}})},Tc=({plugin:e})=>{let t=e.referenceSymbol({category:`external`,resource:`zod.z`});return M.callExpression({functionName:M.propertyAccessExpression({expression:t.placeholder,name:G.unknown})})},Ec=({plugin:e,schema:t,state:n})=>{let r=e.referenceSymbol({category:`external`,resource:`zod.z`}),i=M.propertyAccessExpression({expression:r.placeholder,name:G.array}),a,o=!1;if(!t.items)a=M.callExpression({functionName:i,parameters:[Tc({plugin:e,schema:{type:`unknown`},state:n})]});else{t=S({schema:t});let s=t.items.map((t,r)=>{let i=Bc({plugin:e,schema:t,state:{...n,path:E([...n.path.value,`items`,r])}});return i.hasLazyExpression&&(o=!0),i.expression});if(s.length===1)a=M.callExpression({functionName:i,parameters:s});else if(t.logicalOperator===`and`){let e=t.items[0],n;if(e.logicalOperator===`or`||e.type&&e.type!==`object`)n=M.callExpression({functionName:M.propertyAccessExpression({expression:r.placeholder,name:G.intersection}),parameters:s});else{n=s[0];for(let e=1;e<s.length;e++)n=M.callExpression({functionName:M.propertyAccessExpression({expression:n,name:G.and}),parameters:[s[e]]})}a=M.callExpression({functionName:i,parameters:[n]})}else a=M.callExpression({functionName:M.propertyAccessExpression({expression:r.placeholder,name:G.array}),parameters:[M.callExpression({functionName:M.propertyAccessExpression({expression:r.placeholder,name:G.union}),parameters:[M.arrayLiteralExpression({elements:s})]})]})}return t.minItems===t.maxItems&&t.minItems!==void 0?a=M.callExpression({functionName:M.propertyAccessExpression({expression:a,name:G.length}),parameters:[M.valueToExpression({value:t.minItems})]}):(t.minItems!==void 0&&(a=M.callExpression({functionName:M.propertyAccessExpression({expression:a,name:G.min}),parameters:[M.valueToExpression({value:t.minItems})]})),t.maxItems!==void 0&&(a=M.callExpression({functionName:M.propertyAccessExpression({expression:a,name:G.max}),parameters:[M.valueToExpression({value:t.maxItems})]}))),{expression:a,hasLazyExpression:o}},Dc=({plugin:e,schema:t})=>{let n,r=e.referenceSymbol({category:`external`,resource:`zod.z`});return typeof t.const==`boolean`?(n=B(r.placeholder).attr(G.literal).call(B.literal(t.const)),n.$render()):(n=B(r.placeholder).attr(G.boolean).call(),n.$render())},Oc=({plugin:e,schema:t,state:n})=>{let r=e.referenceSymbol({category:`external`,resource:`zod.z`}),i=[],a=[],o=!1,s=!0;for(let e of t.items??[])if(e.type===`string`&&typeof e.const==`string`){let t=M.stringLiteral({text:e.const});i.push(t),a.push(M.callExpression({functionName:M.propertyAccessExpression({expression:r.placeholder,name:G.literal}),parameters:[t]}))}else if((e.type===`number`||e.type===`integer`)&&typeof e.const==`number`){s=!1;let t=M.ots.number(e.const);a.push(M.callExpression({functionName:M.propertyAccessExpression({expression:r.placeholder,name:G.literal}),parameters:[t]}))}else if(e.type===`boolean`&&typeof e.const==`boolean`){s=!1;let t=M.ots.boolean(e.const);a.push(M.callExpression({functionName:M.propertyAccessExpression({expression:r.placeholder,name:G.literal}),parameters:[t]}))}else (e.type===`null`||e.const===null)&&(o=!0);if(!a.length)return Tc({plugin:e,schema:{type:`unknown`},state:n});let c;return c=s&&i.length>0?M.callExpression({functionName:M.propertyAccessExpression({expression:r.placeholder,name:G.enum}),parameters:[M.arrayLiteralExpression({elements:i,multiLine:!1})]}):a.length===1?a[0]:M.callExpression({functionName:M.propertyAccessExpression({expression:r.placeholder,name:G.union}),parameters:[M.arrayLiteralExpression({elements:a,multiLine:a.length>3})]}),o&&(c=M.callExpression({functionName:M.propertyAccessExpression({expression:c,name:G.nullable})})),c},kc=({plugin:e})=>{let t=e.referenceSymbol({category:`external`,resource:`zod.z`});return M.callExpression({functionName:M.propertyAccessExpression({expression:t.placeholder,name:G.never})})},Ac=({plugin:e})=>{let t=e.referenceSymbol({category:`external`,resource:`zod.z`});return M.callExpression({functionName:M.propertyAccessExpression({expression:t.placeholder,name:G.null})})},jc=({plugin:e,schema:t})=>{let n=e.referenceSymbol({category:`external`,resource:`zod.z`}),r=t.type===`integer`&&t.format===`int64`;if(typeof t.const==`number`)return M.callExpression({functionName:M.propertyAccessExpression({expression:n.placeholder,name:G.literal}),parameters:[M.ots.number(t.const)]});let i=M.callExpression({functionName:r?M.propertyAccessExpression({expression:M.propertyAccessExpression({expression:n.placeholder,name:G.coerce}),name:G.bigint}):M.propertyAccessExpression({expression:n.placeholder,name:G.number})});return!r&&t.type===`integer`&&(i=M.callExpression({functionName:M.propertyAccessExpression({expression:i,name:G.int})})),t.exclusiveMinimum===void 0?t.minimum!==void 0&&(i=M.callExpression({functionName:M.propertyAccessExpression({expression:i,name:G.gte}),parameters:[K({isBigInt:r,value:t.minimum})]})):i=M.callExpression({functionName:M.propertyAccessExpression({expression:i,name:G.gt}),parameters:[K({isBigInt:r,value:t.exclusiveMinimum})]}),t.exclusiveMaximum===void 0?t.maximum!==void 0&&(i=M.callExpression({functionName:M.propertyAccessExpression({expression:i,name:G.lte}),parameters:[K({isBigInt:r,value:t.maximum})]})):i=M.callExpression({functionName:M.propertyAccessExpression({expression:i,name:G.lt}),parameters:[K({isBigInt:r,value:t.exclusiveMaximum})]}),i};function Mc({additional:e,plugin:t,shape:n}){let r=t.referenceSymbol({category:`external`,resource:`zod.z`});return e?B(r.placeholder).attr(G.record).call(e):B(r.placeholder).attr(G.object).call(n)}const Nc=({plugin:e,schema:t,state:n})=>{let r=!1,i=B.object().pretty(),a=t.required??[];for(let o in t.properties){let s=t.properties[o],c=Bc({optional:!a.includes(o),plugin:e,schema:s,state:{...n,path:E([...n.path.value,`properties`,o])}});c.hasLazyExpression&&(r=!0),i.prop(o,c.expression)}let o,s={};if(t.additionalProperties&&(!t.properties||!Object.keys(t.properties).length)){let i=Bc({plugin:e,schema:t.additionalProperties,state:{...n,path:E([...n.path.value,`additionalProperties`])}});r=i.hasLazyExpression||r,o=i.expression}let c={$:B,additional:o,chain:void 0,plugin:e,schema:t,shape:i},l=e.config[`~resolvers`]?.object?.base;return s.expression=(l?.(c)??Mc(c)).$render(),{anyType:`AnyZodObject`,expression:s.expression,hasLazyExpression:r}},Pc=({chain:e,plugin:t,schema:n})=>{switch(n.format){case`date`:return e.attr(G.date).call();case`date-time`:{let n=B.object().$if(t.config.dates.offset,e=>e.prop(`offset`,B.literal(!0))).$if(t.config.dates.local,e=>e.prop(`local`,B.literal(!0)));return e.attr(G.datetime).call(n.hasProps()?n:void 0)}case`email`:return e.attr(G.email).call();case`ipv4`:case`ipv6`:return e.attr(G.ip).call();case`time`:return e.attr(G.time).call();case`uri`:return e.attr(G.url).call();case`uuid`:return e.attr(G.uuid).call();default:return e}},Fc=({plugin:e,schema:t})=>{let n,r=e.referenceSymbol({category:`external`,resource:`zod.z`});if(typeof t.const==`string`)return n=B(r.placeholder).attr(G.literal).call(B.literal(t.const)),n.$render();if(n=B(r.placeholder).attr(G.string).call(),t.format){let r={$:B,chain:n,plugin:e,schema:t},i=e.config[`~resolvers`]?.string?.formats?.[t.format];n=i?.(r)??Pc(r)}return t.minLength===t.maxLength&&t.minLength!==void 0?n=n.attr(G.length).call(B.literal(t.minLength)):(t.minLength!==void 0&&(n=n.attr(G.min).call(B.literal(t.minLength))),t.maxLength!==void 0&&(n=n.attr(G.max).call(B.literal(t.maxLength)))),t.pattern&&(n=n.attr(G.regex).call(B.regexp(t.pattern))),n.$render()},Ic=({plugin:e,schema:t,state:n})=>{let r=e.referenceSymbol({category:`external`,resource:`zod.z`}),i=!1;if(t.const&&Array.isArray(t.const)){let e=t.const.map(e=>M.callExpression({functionName:M.propertyAccessExpression({expression:r.placeholder,name:G.literal}),parameters:[M.valueToExpression({value:e})]}));return{expression:M.callExpression({functionName:M.propertyAccessExpression({expression:r.placeholder,name:G.tuple}),parameters:[M.arrayLiteralExpression({elements:e})]}),hasLazyExpression:i}}let a=[];return t.items&&t.items.forEach((t,r)=>{let o=Bc({plugin:e,schema:t,state:{...n,path:E([...n.path.value,`items`,r])}});a.push(o.expression),o.hasLazyExpression&&(i=!0)}),{expression:M.callExpression({functionName:M.propertyAccessExpression({expression:r.placeholder,name:G.tuple}),parameters:[M.arrayLiteralExpression({elements:a})]}),hasLazyExpression:i}},Lc=({plugin:e})=>{let t=e.referenceSymbol({category:`external`,resource:`zod.z`});return M.callExpression({functionName:M.propertyAccessExpression({expression:t.placeholder,name:G.undefined})})},Rc=({plugin:e})=>{let t=e.referenceSymbol({category:`external`,resource:`zod.z`});return M.callExpression({functionName:M.propertyAccessExpression({expression:t.placeholder,name:G.void})})},zc=({schema:e,...t})=>{switch(e.type){case`array`:return Ec({...t,schema:e});case`boolean`:return{expression:Dc({...t,schema:e})};case`enum`:return{expression:Oc({...t,schema:e})};case`integer`:case`number`:return{expression:jc({...t,schema:e})};case`never`:return{expression:kc({...t,schema:e})};case`null`:return{expression:Ac({...t,schema:e})};case`object`:return Nc({...t,schema:e});case`string`:return{expression:Fc({...t,schema:e})};case`tuple`:return Ic({...t,schema:e});case`undefined`:return{expression:Lc({...t,schema:e})};case`unknown`:return{expression:Tc({...t,schema:e})};case`void`:return{expression:Rc({...t,schema:e})}}},Bc=({optional:e,plugin:t,schema:n,state:r})=>{let i={},a=t.referenceSymbol({category:`external`,resource:`zod.z`});if(n.$ref){let e={category:`schema`,resource:`definition`,resourceId:n.$ref,tool:`zod`},o=t.referenceSymbol(e);t.isSymbolRegistered(e)?i.expression=B(o.placeholder).$render():(i.expression=B(a.placeholder).attr(G.lazy).call(B.func().do(B(o.placeholder).return())).$render(),i.hasLazyExpression=!0,r.hasLazyExpression.value=!0)}else if(n.type){let e=zc({plugin:t,schema:n,state:r});i.expression=e.expression,i.typeName=e.anyType,t.config.metadata&&n.description&&(i.expression=B(i.expression).attr(G.describe).call(B.literal(n.description)).$render())}else if(n.items)if(n=S({schema:n}),n.items){let e=n.items.map((e,n)=>Bc({plugin:t,schema:e,state:{...r,path:E([...r.path.value,`items`,n])}}).expression);if(n.logicalOperator===`and`){let t=n.items[0];t.logicalOperator===`or`||t.type&&t.type!==`object`?i.expression=B(a.placeholder).attr(G.intersection).call(...e).$render():(i.expression=e[0],e.slice(1).forEach(e=>{i.expression=B(i.expression).attr(G.and).call(e).$render()}))}else i.expression=B(a.placeholder).attr(G.union).call(B.array().pretty().elements(...e)).$render()}else i=Bc({plugin:t,schema:n,state:r});else{let e=zc({plugin:t,schema:{type:`unknown`},state:r});i.expression=e.expression,i.typeName=e.anyType}if(i.expression&&(n.accessScope===`read`&&(i.expression=B(i.expression).attr(G.readonly).call().$render()),e&&(i.expression=B(i.expression).attr(G.optional).call().$render()),n.default!==void 0)){let e=K({isBigInt:n.type===`integer`&&n.format===`int64`,value:n.default});e&&(i.expression=B(i.expression).attr(G.default).call(e).$render())}return r.hasLazyExpression.value?i.typeName||=`ZodTypeAny`:i.typeName&&=void 0,i},Vc=({plugin:e,schema:t,state:n})=>{let r=Xn(n.path.value),i=Bc({plugin:e,schema:t,state:n}),a=N(r);rc({ast:i,plugin:e,schema:t,symbol:e.registerSymbol({exported:!0,meta:{category:`schema`,path:n.path.value,resource:`definition`,resourceId:r,tags:n.tags?.value,tool:`zod`},name:x({config:e.config.definitions,name:a})}),typeInferSymbol:e.config.definitions.types.infer.enabled?e.registerSymbol({exported:!0,kind:`type`,meta:{category:`type`,path:n.path.value,resource:`definition`,resourceId:r,tags:n.tags?.value,tool:`zod`,variant:`infer`},name:x({config:e.config.definitions.types.infer,name:a})}):void 0})},Hc=({plugin:e})=>{e.registerSymbol({external:ic({plugin:e}),meta:{category:`external`,resource:`zod.z`},name:`z`}),e.forEach(`operation`,`parameter`,`requestBody`,`schema`,`webhook`,t=>{let n=D({hasLazyExpression:!1,path:t._path,tags:t.tags});switch(t.type){case`operation`:ac({getAst:(n,r)=>Bc({plugin:e,schema:n,state:D({hasLazyExpression:!1,path:r,tags:t.tags})}),operation:t.operation,plugin:e,state:n});break;case`parameter`:Vc({plugin:e,schema:t.parameter.schema,state:n});break;case`requestBody`:Vc({plugin:e,schema:t.requestBody.schema,state:n});break;case`schema`:Vc({plugin:e,schema:t.schema,state:n});break;case`webhook`:oc({getAst:(n,r)=>Bc({plugin:e,schema:n,state:D({hasLazyExpression:!1,path:r,tags:t.tags})}),operation:t.operation,plugin:e,state:n});break}})},Uc=({plugin:e})=>{let t={},n=e.referenceSymbol({category:`external`,resource:`zod.z`});return t.expression=M.callExpression({functionName:M.propertyAccessExpression({expression:n.placeholder,name:G.unknown})}),t},Wc=({plugin:e,schema:t,state:n})=>{let r={},i=e.referenceSymbol({category:`external`,resource:`zod.z`}),a=M.propertyAccessExpression({expression:i.placeholder,name:G.array});if(!t.items)r.expression=M.callExpression({functionName:a,parameters:[Uc({plugin:e,schema:{type:`unknown`},state:n}).expression]});else{t=S({schema:t});let o=t.items.map((t,i)=>{let a=il({plugin:e,schema:t,state:{...n,path:E([...n.path.value,`items`,i])}});return a.hasLazyExpression&&(r.hasLazyExpression=!0),a.expression});if(o.length===1)r.expression=M.callExpression({functionName:a,parameters:o});else if(t.logicalOperator===`and`){let e=t.items[0],n;if(e.logicalOperator===`or`||e.type&&e.type!==`object`)n=M.callExpression({functionName:M.propertyAccessExpression({expression:i.placeholder,name:G.intersection}),parameters:o});else{n=o[0];for(let e=1;e<o.length;e++)n=M.callExpression({functionName:M.propertyAccessExpression({expression:n,name:G.and}),parameters:[o[e]]})}r.expression=M.callExpression({functionName:a,parameters:[n]})}else r.expression=M.callExpression({functionName:M.propertyAccessExpression({expression:i.placeholder,name:G.array}),parameters:[M.callExpression({functionName:M.propertyAccessExpression({expression:i.placeholder,name:G.union}),parameters:[M.arrayLiteralExpression({elements:o})]})]})}return t.minItems===t.maxItems&&t.minItems!==void 0?r.expression=M.callExpression({functionName:M.propertyAccessExpression({expression:r.expression,name:G.length}),parameters:[M.valueToExpression({value:t.minItems})]}):(t.minItems!==void 0&&(r.expression=M.callExpression({functionName:M.propertyAccessExpression({expression:r.expression,name:G.min}),parameters:[M.valueToExpression({value:t.minItems})]})),t.maxItems!==void 0&&(r.expression=M.callExpression({functionName:M.propertyAccessExpression({expression:r.expression,name:G.max}),parameters:[M.valueToExpression({value:t.maxItems})]}))),r},Gc=({plugin:e,schema:t})=>{let n={},r,i=e.referenceSymbol({category:`external`,resource:`zod.z`});return typeof t.const==`boolean`?(r=B(i.placeholder).attr(G.literal).call(B.literal(t.const)),n.expression=r.$render(),n):(r=B(i.placeholder).attr(G.boolean).call(),n.expression=r.$render(),n)},Kc=({plugin:e,schema:t,state:n})=>{let r={},i=e.referenceSymbol({category:`external`,resource:`zod.z`}),a=[],o=[],s=!1,c=!0;for(let e of t.items??[])if(e.type===`string`&&typeof e.const==`string`){let t=M.stringLiteral({text:e.const});a.push(t),o.push(M.callExpression({functionName:M.propertyAccessExpression({expression:i.placeholder,name:G.literal}),parameters:[t]}))}else if((e.type===`number`||e.type===`integer`)&&typeof e.const==`number`){c=!1;let t=M.ots.number(e.const);o.push(M.callExpression({functionName:M.propertyAccessExpression({expression:i.placeholder,name:G.literal}),parameters:[t]}))}else if(e.type===`boolean`&&typeof e.const==`boolean`){c=!1;let t=M.ots.boolean(e.const);o.push(M.callExpression({functionName:M.propertyAccessExpression({expression:i.placeholder,name:G.literal}),parameters:[t]}))}else (e.type===`null`||e.const===null)&&(s=!0);return o.length?(c&&a.length>0?r.expression=M.callExpression({functionName:M.propertyAccessExpression({expression:i.placeholder,name:G.enum}),parameters:[M.arrayLiteralExpression({elements:a,multiLine:!1})]}):o.length===1?r.expression=o[0]:r.expression=M.callExpression({functionName:M.propertyAccessExpression({expression:i.placeholder,name:G.union}),parameters:[M.arrayLiteralExpression({elements:o,multiLine:o.length>3})]}),s&&(r.expression=M.callExpression({functionName:M.propertyAccessExpression({expression:i.placeholder,name:G.nullable}),parameters:[r.expression]})),r):Uc({plugin:e,schema:{type:`unknown`},state:n})},qc=({plugin:e})=>{let t={},n=e.referenceSymbol({category:`external`,resource:`zod.z`});return t.expression=M.callExpression({functionName:M.propertyAccessExpression({expression:n.placeholder,name:G.never})}),t},Jc=({plugin:e})=>{let t={},n=e.referenceSymbol({category:`external`,resource:`zod.z`});return t.expression=M.callExpression({functionName:M.propertyAccessExpression({expression:n.placeholder,name:G.null})}),t},Yc=({plugin:e,schema:t})=>{let n={},r=t.type===`integer`&&t.format===`int64`,i=e.referenceSymbol({category:`external`,resource:`zod.z`});return typeof t.const==`number`?(n.expression=M.callExpression({functionName:M.propertyAccessExpression({expression:i.placeholder,name:G.literal}),parameters:[M.ots.number(t.const)]}),n):(n.expression=M.callExpression({functionName:r?M.propertyAccessExpression({expression:M.propertyAccessExpression({expression:i.placeholder,name:G.coerce}),name:G.bigint}):M.propertyAccessExpression({expression:i.placeholder,name:G.number})}),!r&&t.type===`integer`&&(n.expression=M.callExpression({functionName:M.propertyAccessExpression({expression:i.placeholder,name:G.int})})),t.exclusiveMinimum===void 0?t.minimum!==void 0&&(n.expression=M.callExpression({functionName:M.propertyAccessExpression({expression:n.expression,name:G.gte}),parameters:[K({isBigInt:r,value:t.minimum})]})):n.expression=M.callExpression({functionName:M.propertyAccessExpression({expression:n.expression,name:G.gt}),parameters:[K({isBigInt:r,value:t.exclusiveMinimum})]}),t.exclusiveMaximum===void 0?t.maximum!==void 0&&(n.expression=M.callExpression({functionName:M.propertyAccessExpression({expression:n.expression,name:G.lte}),parameters:[K({isBigInt:r,value:t.maximum})]})):n.expression=M.callExpression({functionName:M.propertyAccessExpression({expression:n.expression,name:G.lt}),parameters:[K({isBigInt:r,value:t.exclusiveMaximum})]}),n)};function Xc({additional:e,plugin:t,shape:n}){let r=t.referenceSymbol({category:`external`,resource:`zod.z`});return e?B(r.placeholder).attr(G.record).call(B(r.placeholder).attr(G.string).call(),e):B(r.placeholder).attr(G.object).call(n)}const Zc=({plugin:e,schema:t,state:n})=>{let r={},i=B.object().pretty(),a=t.required??[];for(let o in t.properties){let s=t.properties[o],c=il({optional:!a.includes(o),plugin:e,schema:s,state:{...n,path:E([...n.path.value,`properties`,o])}});c.hasLazyExpression&&(r.hasLazyExpression=!0),c.hasLazyExpression?i.getter(o,B(c.expression).return()):i.prop(o,c.expression)}let o;if(t.additionalProperties&&(!t.properties||!Object.keys(t.properties).length)){let i=il({plugin:e,schema:t.additionalProperties,state:{...n,path:E([...n.path.value,`additionalProperties`])}});i.hasLazyExpression&&(r.hasLazyExpression=!0),o=i.expression}let s={$:B,additional:o,chain:void 0,plugin:e,schema:t,shape:i},c=e.config[`~resolvers`]?.object?.base;return r.expression=(c?.(s)??Xc(s)).$render(),r.hasLazyExpression?{...r,typeName:`ZodType`}:r},Qc=({chain:e,plugin:t,schema:n})=>{let r=t.referenceSymbol({category:`external`,resource:`zod.z`});switch(n.format){case`date`:return B(r.placeholder).attr(G.iso).attr(G.date).call();case`date-time`:{let e=B.object().$if(t.config.dates.offset,e=>e.prop(`offset`,B.literal(!0))).$if(t.config.dates.local,e=>e.prop(`local`,B.literal(!0)));return B(r.placeholder).attr(G.iso).attr(G.datetime).call(e.hasProps()?e:void 0)}case`email`:return B(r.placeholder).attr(G.email).call();case`ipv4`:return B(r.placeholder).attr(G.ipv4).call();case`ipv6`:return B(r.placeholder).attr(G.ipv6).call();case`time`:return B(r.placeholder).attr(G.iso).attr(G.time).call();case`uri`:return B(r.placeholder).attr(G.url).call();case`uuid`:return B(r.placeholder).attr(G.uuid).call();default:return e}},$c=({plugin:e,schema:t})=>{let n={},r,i=e.referenceSymbol({category:`external`,resource:`zod.z`});if(typeof t.const==`string`)return r=B(i.placeholder).attr(G.literal).call(B.literal(t.const)),n.expression=r.$render(),n;if(r=B(i.placeholder).attr(G.string).call(),t.format){let n={$:B,chain:r,plugin:e,schema:t},i=e.config[`~resolvers`]?.string?.formats?.[t.format];r=i?.(n)??Qc(n)}return t.minLength===t.maxLength&&t.minLength!==void 0?r=r.attr(G.length).call(B.literal(t.minLength)):(t.minLength!==void 0&&(r=r.attr(G.min).call(B.literal(t.minLength))),t.maxLength!==void 0&&(r=r.attr(G.max).call(B.literal(t.maxLength)))),t.pattern&&(r=r.attr(G.regex).call(B.regexp(t.pattern))),n.expression=r.$render(),n},el=({plugin:e,schema:t,state:n})=>{let r={},i=e.referenceSymbol({category:`external`,resource:`zod.z`});if(t.const&&Array.isArray(t.const)){let e=t.const.map(e=>M.callExpression({functionName:M.propertyAccessExpression({expression:i.placeholder,name:G.literal}),parameters:[M.valueToExpression({value:e})]}));return r.expression=M.callExpression({functionName:M.propertyAccessExpression({expression:i.placeholder,name:G.tuple}),parameters:[M.arrayLiteralExpression({elements:e})]}),r}let a=[];return t.items&&t.items.forEach((t,i)=>{let o=il({plugin:e,schema:t,state:{...n,path:E([...n.path.value,`items`,i])}});a.push(o.expression),o.hasLazyExpression&&(r.hasLazyExpression=!0)}),r.expression=M.callExpression({functionName:M.propertyAccessExpression({expression:i.placeholder,name:G.tuple}),parameters:[M.arrayLiteralExpression({elements:a})]}),r},tl=({plugin:e})=>{let t={},n=e.referenceSymbol({category:`external`,resource:`zod.z`});return t.expression=M.callExpression({functionName:M.propertyAccessExpression({expression:n.placeholder,name:G.undefined})}),t},nl=({plugin:e})=>{let t={},n=e.referenceSymbol({category:`external`,resource:`zod.z`});return t.expression=M.callExpression({functionName:M.propertyAccessExpression({expression:n.placeholder,name:G.void})}),t},rl=({schema:e,...t})=>{switch(e.type){case`array`:return Wc({...t,schema:e});case`boolean`:return Gc({...t,schema:e});case`enum`:return Kc({...t,schema:e});case`integer`:case`number`:return Yc({...t,schema:e});case`never`:return qc({...t,schema:e});case`null`:return Jc({...t,schema:e});case`object`:return Zc({...t,schema:e});case`string`:return $c({...t,schema:e});case`tuple`:return el({...t,schema:e});case`undefined`:return tl({...t,schema:e});case`unknown`:return Uc({...t,schema:e});case`void`:return nl({...t,schema:e})}},il=({optional:e,plugin:t,schema:n,state:r})=>{let i={},a=t.referenceSymbol({category:`external`,resource:`zod.z`});if(n.$ref){let e={category:`schema`,resource:`definition`,resourceId:n.$ref,tool:`zod`},o=t.referenceSymbol(e);t.isSymbolRegistered(e)?i.expression=B(o.placeholder).$render():(i.expression=B(a.placeholder).attr(G.lazy).call(B.func().returns(`any`).do(B(o.placeholder).return())).$render(),i.hasLazyExpression=!0,r.hasLazyExpression.value=!0)}else if(n.type){let e=rl({plugin:t,schema:n,state:r});i.expression=e.expression,i.hasLazyExpression=e.hasLazyExpression,t.config.metadata&&n.description&&(i.expression=B(i.expression).attr(G.register).call(B(a.placeholder).attr(G.globalRegistry),B.object().pretty().prop(`description`,B.literal(n.description))).$render())}else if(n.items)if(n=S({schema:n}),n.items){let e=n.items.map((e,n)=>il({plugin:t,schema:e,state:{...r,path:E([...r.path.value,`items`,n])}}));if(n.logicalOperator===`and`){let t=n.items[0];t.logicalOperator===`or`||t.type&&t.type!==`object`?i.expression=B(a.placeholder).attr(G.intersection).call(...e.map(e=>e.expression)).$render():(i.expression=e[0].expression,e.slice(1).forEach(e=>{i.expression=B(i.expression).attr(G.and).call(e.hasLazyExpression?B(a.placeholder).attr(G.lazy).call(B.func().do(B.return(e.expression))):e.expression).$render()}))}else i.expression=B(a.placeholder).attr(G.union).call(B.array().pretty().elements(...e.map(e=>e.expression))).$render()}else i=il({plugin:t,schema:n,state:r});else i.expression=rl({plugin:t,schema:{type:`unknown`},state:r}).expression;if(i.expression&&(n.accessScope===`read`&&(i.expression=B(i.expression).attr(G.readonly).call().$render()),e&&(i.expression=B(a.placeholder).attr(G.optional).call(i.expression).$render(),i.typeName=G.ZodOptional),n.default!==void 0)){let e=K({isBigInt:n.type===`integer`&&n.format===`int64`,value:n.default});e&&(i.expression=B(i.expression).attr(G.default).call(e).$render())}return i},al=({plugin:e,schema:t,state:n})=>{let r=Xn(n.path.value),i=il({plugin:e,schema:t,state:n}),a=N(r);rc({ast:i,plugin:e,schema:t,symbol:e.registerSymbol({exported:!0,meta:{category:`schema`,path:n.path.value,resource:`definition`,resourceId:r,tags:n.tags?.value,tool:`zod`},name:x({config:e.config.definitions,name:a})}),typeInferSymbol:e.config.definitions.types.infer.enabled?e.registerSymbol({exported:!0,kind:`type`,meta:{category:`type`,path:n.path.value,resource:`definition`,resourceId:r,tags:n.tags?.value,tool:`zod`,variant:`infer`},name:x({config:e.config.definitions.types.infer,name:a})}):void 0})},ol=({plugin:e})=>{e.registerSymbol({external:ic({plugin:e}),meta:{category:`external`,resource:`zod.z`},name:`z`}),e.forEach(`operation`,`parameter`,`requestBody`,`schema`,`webhook`,t=>{let n=D({hasLazyExpression:!1,path:t._path,tags:t.tags});switch(t.type){case`operation`:ac({getAst:(n,r)=>il({plugin:e,schema:n,state:D({hasLazyExpression:!1,path:r,tags:t.tags})}),operation:t.operation,plugin:e,state:n});break;case`parameter`:al({plugin:e,schema:t.parameter.schema,state:n});break;case`requestBody`:al({plugin:e,schema:t.requestBody.schema,state:n});break;case`schema`:al({plugin:e,schema:t.schema,state:n});break;case`webhook`:oc({getAst:(n,r)=>il({plugin:e,schema:n,state:D({hasLazyExpression:!1,path:r,tags:t.tags})}),operation:t.operation,plugin:e,state:n});break}})},sl={api:new nc,config:{case:`camelCase`,comments:!0,exportFromIndex:!1,metadata:!1},handler:e=>{let{plugin:t}=e;switch(t.config.compatibilityVersion){case 3:return Hc(e);case`mini`:return wc(e);case 4:default:return ol(e)}},name:`zod`,resolveConfig:(e,t)=>{let n=t.package.getVersion(`zod`),r=()=>n&&(n.major===4||n.major===3)?n.major:4,i=e=>{if(!e)return r();if(!n)return e;if((e===4||e===3||e===`mini`)&&!t.package.satisfies(n,`>=3.25.0 <5.0.0`)){let t=r();return console.warn(`🔌 ${a.yellow(`Warning:`)} Installed ${a.cyan(`zod`)} ${a.cyan(`v${n.version}`)} does not support compatibility version ${a.yellow(String(e))}, using ${a.yellow(String(t))}.`),t}return e};e.config.compatibilityVersion=i(e.config.compatibilityVersion),e.config.dates=t.valueToObject({defaultValue:{local:!1,offset:!1},value:e.config.dates}),e.config.types=t.valueToObject({defaultValue:{infer:{case:`PascalCase`,enabled:!1}},mappers:{object:(e,n)=>({...e,infer:t.valueToObject({defaultValue:{...n.infer,enabled:e.infer===void 0?n.infer.enabled:!!e.infer},mappers:y,value:e.infer})})},value:e.config.types}),e.config.definitions=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`z{{name}}`,types:{...e.config.types,infer:{...e.config.types.infer,name:`{{name}}ZodType`}}},mappers:{...y,object:(e,n)=>({...e,types:t.valueToObject({defaultValue:n.types,mappers:{object:(e,n)=>({...e,infer:t.valueToObject({defaultValue:{...n.infer,enabled:e.infer===void 0?n.infer.enabled:!!e.infer},mappers:y,value:e.infer})})},value:e.types})})},value:e.config.definitions}),e.config.requests=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`z{{name}}Data`,types:{...e.config.types,infer:{...e.config.types.infer,name:`{{name}}DataZodType`}}},mappers:{...y,object:(e,n)=>({...e,types:t.valueToObject({defaultValue:n.types,mappers:{object:(e,n)=>({...e,infer:t.valueToObject({defaultValue:{...n.infer,enabled:e.infer===void 0?n.infer.enabled:!!e.infer},mappers:y,value:e.infer})})},value:e.types})})},value:e.config.requests}),e.config.responses=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`z{{name}}Response`,types:{...e.config.types,infer:{...e.config.types.infer,name:`{{name}}ResponseZodType`}}},mappers:{...y,object:(e,n)=>({...e,types:t.valueToObject({defaultValue:n.types,mappers:{object:(e,n)=>({...e,infer:t.valueToObject({defaultValue:{...n.infer,enabled:e.infer===void 0?n.infer.enabled:!!e.infer},mappers:y,value:e.infer})})},value:e.types})})},value:e.config.responses}),e.config.webhooks=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`z{{name}}WebhookRequest`,types:{...e.config.types,infer:{...e.config.types.infer,name:`{{name}}WebhookRequestZodType`}}},mappers:{...y,object:(e,n)=>({...e,types:t.valueToObject({defaultValue:n.types,mappers:{object:(e,n)=>({...e,infer:t.valueToObject({defaultValue:{...n.infer,enabled:e.infer===void 0?n.infer.enabled:!!e.infer},mappers:y,value:e.infer})})},value:e.types})})},value:e.config.webhooks})},tags:[`validator`]},cl={"@angular/common":Sr,"@hey-api/client-angular":Rr,"@hey-api/client-axios":zr,"@hey-api/client-fetch":Br,"@hey-api/client-ky":Vr,"@hey-api/client-next":Hr,"@hey-api/client-nuxt":Ur,"@hey-api/client-ofetch":Wr,"@hey-api/schemas":ri,"@hey-api/sdk":Ea,"@hey-api/transformers":Fa,"@hey-api/typescript":uo,"@pinia/colada":Oo,"@tanstack/angular-query-experimental":Yo,"@tanstack/react-query":Xo,"@tanstack/solid-query":Zo,"@tanstack/svelte-query":Qo,"@tanstack/vue-query":$o,arktype:ds,fastify:ps,swr:gs,valibot:Ks,zod:sl},ll=[`@hey-api/typescript`,`@hey-api/sdk`],ul=({dependencies:e,userPlugins:t,userPluginsConfig:n})=>{let r=new Set,i=new Set,a={},o=s=>{if(r.has(s))throw Error(`Circular reference detected at '${s}'`);if(i.has(s))return;r.add(s);let c=cl[s],l=n[s];if(!c&&!l)throw Error(`unknown plugin dependency "${s}" - do you need to register a custom plugin with this name?`);let u={...c,...l,config:{...c?.config,...l?.config},dependencies:new Set([...c?.dependencies||[],...l?.dependencies||[]])};if(u.resolveConfig){let r={package:Kr(e),pluginByTag:(e,r={})=>{let{defaultPlugin:i,errorMessage:a}=r;for(let r of t){let t=cl[r]||n[r];if(t&&t.tags?.includes(e)&&r!==s)return r}if(i){let t=cl[i]||n[i];if(t&&t.tags?.includes(e)&&i!==s)return i}throw Error(a||`missing plugin - no plugin with tag "${e}" found`)},valueToObject:Pe};u.resolveConfig(u,r)}for(let e of u.dependencies)o(e);r.delete(s),i.add(s),a[s]=u};for(let e of t)o(e);return{pluginOrder:Array.from(i),plugins:a}},dl=e=>typeof e==`string`?e.startsWith(`@hey-api/client`):e.name.startsWith(`@hey-api/client`)||e.tags&&e.tags.includes(`client`),fl=({dependencies:e,userConfig:t})=>{let n={},r=ll;return t.plugins&&(t.plugins=t.plugins.filter(e=>typeof e==`string`&&e||typeof e!=`string`&&e.name),r=t.plugins.length===1&&dl(t.plugins[0])?[...ll,...t.plugins]:t.plugins),ul({dependencies:e,userPlugins:r.map(e=>{if(typeof e==`string`)return e;let t=e.name;return t&&(e.handler?n[t]=e:(n[t]={config:{...e}},delete n[t].config.name)),t}).filter(Boolean),userPluginsConfig:n})},pl=()=>!!(process.stdin.isTTY&&process.stdout.isTTY&&!process.env.CI&&!process.env.NO_INTERACTIVE&&!process.env.NO_INTERACTION),ml=async({logger:e,userConfigs:t})=>{let n=[],r={},i=e.timeEvent(`load`);for(let i of t){let t;if(i?.configFile){let e=i.configFile.split(`.`);t=e.slice(0,e.length-1).join(`.`)}let o=e.timeEvent(`c12`),{loadConfig:s}=await import(`c12`),{config:c,configFile:l}=await s({configFile:t,name:`openapi-ts`});o.timeEnd(),Object.keys(r).length||(r=Ie(Object.keys(c).length?l:void 0));let u=c instanceof Array?c.map(e=>je(e,i)):[je(c,i)];for(let e of u){let t=Oe(e);if(e.output instanceof Array){let r=t.length,i=e.output.length;if(i>1)if(r!==i){console.warn(`⚙️ ${a.yellow(`Warning:`)} You provided ${a.cyan(String(r))} ${a.cyan(r===1?`input`:`inputs`)} and ${a.yellow(String(i))} ${a.yellow(`outputs`)}. This is probably not what you want as it will produce identical output in multiple locations. You most likely want to provide a single output or the same number of outputs as inputs.`);for(let r of e.output)n.push({...e,input:t,output:r})}else e.output.forEach((r,i)=>{n.push({...e,input:t[i],output:r})});else n.push({...e,input:t,output:e.output[0]??``})}else n.push({...e,input:t})}}i.timeEnd();let o=[],c=e.timeEvent(`build`);for(let e of n){let t=ke(e),n=Oe(e),i=Fe(e),c=Re(e),l=[];n.length||l.push(new v(`missing input - which OpenAPI specification should we use to generate your output?`)),i.path||l.push(new v(`missing output - where should we generate your output?`)),i.path=s.resolve(process.cwd(),i.path);let u;try{u=fl({dependencies:r,userConfig:e})}catch(e){l.push(e),u={pluginOrder:[],plugins:{}}}let d={configFile:e.configFile??``,dryRun:e.dryRun??!1,input:n,interactive:e.interactive??pl(),logs:t,output:i,parser:c,pluginOrder:u.pluginOrder,plugins:u.plugins},f=o.length;if(t.level===`debug`){let e=a.gray(`[Job ${f+1}] `);console.warn(`${e}${a.cyan(`config:`)}`,d)}o.push({config:d,errors:l,jobIndex:f})}return c.timeEnd(),{dependencies:r,results:o}};Object.entries({$body_:`body`,$headers_:`headers`,$path_:`path`,$query_:`query`});const hl=e=>{switch(e){case`label`:return`.`;case`matrix`:return`;`;case`simple`:return`,`;default:return`&`}},gl=e=>{switch(e){case`form`:return`,`;case`pipeDelimited`:return`|`;case`spaceDelimited`:return`%20`;default:return`,`}},_l=e=>{switch(e){case`label`:return`.`;case`matrix`:return`;`;case`simple`:return`,`;default:return`&`}},vl=({allowReserved:e,explode:t,name:n,style:r,value:i})=>{if(!t){let t=(e?i:i.map(e=>encodeURIComponent(e))).join(gl(r));switch(r){case`label`:return`.${t}`;case`matrix`:return`;${n}=${t}`;case`simple`:return t;default:return`${n}=${t}`}}let a=hl(r),o=i.map(t=>r===`label`||r===`simple`?e?t:encodeURIComponent(t):yl({allowReserved:e,name:n,value:t})).join(a);return r===`label`||r===`matrix`?a+o:o},yl=({allowReserved:e,name:t,value:n})=>{if(n==null)return``;if(typeof n==`object`)throw Error("Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.");return`${t}=${e?n:encodeURIComponent(n)}`},bl=({allowReserved:e,explode:t,name:n,style:r,value:i,valueOnly:a})=>{if(i instanceof Date)return a?i.toISOString():`${n}=${i.toISOString()}`;if(r!==`deepObject`&&!t){let t=[];Object.entries(i).forEach(([n,r])=>{t=[...t,n,e?r:encodeURIComponent(r)]});let a=t.join(`,`);switch(r){case`form`:return`${n}=${a}`;case`label`:return`.${a}`;case`matrix`:return`;${n}=${a}`;default:return a}}let o=_l(r),s=Object.entries(i).map(([t,i])=>yl({allowReserved:e,name:r===`deepObject`?`${n}[${t}]`:t,value:i})).join(o);return r===`label`||r===`matrix`?o+s:s},xl=({parameters:e={},...t}={})=>n=>{let r=[];if(n&&typeof n==`object`)for(let i in n){let a=n[i];if(a==null)continue;let o=e[i]||t;if(Array.isArray(a)){let e=vl({allowReserved:o.allowReserved,explode:!0,name:i,style:`form`,value:a,...o.array});e&&r.push(e)}else if(typeof a==`object`){let e=bl({allowReserved:o.allowReserved,explode:!0,name:i,style:`deepObject`,value:a,...o.object});e&&r.push(e)}else{let e=yl({allowReserved:o.allowReserved,name:i,value:a});e&&r.push(e)}}return r.join(`&`)},Sl=e=>{let t=[];return e.forEach((e,n)=>{t.push([n,e])}),t},Cl=(...e)=>{let t=new Headers;for(let n of e){if(!n)continue;let e=n instanceof Headers?Sl(n):Object.entries(n);for(let[n,r]of e)if(r===null)t.delete(n);else if(Array.isArray(r))for(let e of r)t.append(n,e);else r!==void 0&&t.set(n,typeof r==`object`?JSON.stringify(r):r)}return t};xl({allowReserved:!1,array:{explode:!0,style:`form`},object:{explode:!0,style:`deepObject`}});const wl=async({fetchOptions:e,inputPath:t,timeout:n,watch:r})=>{let i=f({pathOrUrlOrSchema:t}),a,o,s;if(i.type===`url`){if(r.lastValue&&r.isHeadMethodSupported!==!1){try{let t=await p({fetchOptions:{method:`HEAD`,...e,headers:Cl(e?.headers,r.headers)},timeout:n,url:i.path});if(t.response.status>=300)return{error:`not-ok`,response:t.response};s=t.response}catch(e){return{error:`not-ok`,response:new Response(e.message)}}if(!s.ok&&r.isHeadMethodSupported)return{error:`not-ok`,response:s};if(r.isHeadMethodSupported===void 0&&(r.isHeadMethodSupported=s.ok),s.status===304)return{error:`not-modified`,response:s};if(o===void 0){let e=s.headers.get(`ETag`);e&&(o=e!==r.headers.get(`If-None-Match`),o&&r.headers.set(`If-None-Match`,e))}if(o===void 0){let e=s.headers.get(`Last-Modified`);e&&(o=e!==r.headers.get(`If-Modified-Since`),o&&r.headers.set(`If-Modified-Since`,e))}if(o===!1)return{error:`not-modified`,response:s}}try{let t=await p({fetchOptions:{method:`GET`,...e},timeout:n,url:i.path});if(t.response.status>=300)return{error:`not-ok`,response:t.response};s=t.response}catch(e){return{error:`not-ok`,response:new Response(e.message)}}if(!s.ok)return{error:`not-ok`,response:s};if(a=s.body?await s.arrayBuffer():new ArrayBuffer(0),o===void 0){let e=new TextDecoder().decode(a);o=e!==r.lastValue,r.lastValue=e}}else r.lastValue?o=!1:r.lastValue=i.type;return o===!1?{error:`not-modified`,response:s}:{arrayBuffer:a,resolvedInput:i}},Tl=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`.split(`.`));var El=class{renderFile(e,t,n,r){let a=new Map;if(e=i(e,e=>{let i=n.symbols.get(e),o=this.replacerFn({file:t,project:n,symbol:i});return i&&this.addBinding({bindings:a,file:t,meta:r,project:n,symbol:i}),o}),!e.length)return``;let o=``,s=this.getHeaderLines();o+=`${s.join(`
8
+ `)}${s.length?`
9
+
10
+ `:``}`;let c=this.getImportLines(a,t,n);return o+=`${c.join(`
11
+ `)}${c.length?`
12
+
13
+ `:``}`,`${o}${e}`}renderSymbols(e,t,n){let r=new Map,a=``,o=this.getBodyLines(e,t);a+=`${o.join(`
14
+
15
+ `)}${o.length?`
16
+ `:``}`,a=i(a,n=>{if(!e.symbols.body.includes(n))return;let r=t.symbols.get(n);return this.replacerFn({file:e,project:t,symbol:r})});for(let i of e.symbols.exports){let a=t.symbols.get(i);a&&this.addBinding({bindings:r,file:e,meta:n,project:t,symbol:a})}for(let e of r.values())e.namespaceBinding=!0,e.typeNamespaceBinding=e.names&&e.typeNames&&e.names.length===e.typeNames.length&&e.names.every(t=>(e.typeNames??[]).includes(t));let s=this.getExportLines(r,e,t);return a+=`${s.join(`
17
+ `)}${s.length?`
18
+ `:``}`,a}addBinding({bindings:e,file:t,meta:i,project:a,symbol:o}){if(!o.external&&!a.symbols.hasValue(o.id))return;let[s]=a.symbolIdToFiles(o.id);if(!s||t===s)return;let c=this.getBindingPath(t,s,i),l=e.get(c),u=n({file:t,modulePath:c,symbol:o,symbolFile:s});l?(r(l,u),e.set(c,l)):e.set(c,u)}getBindingPath(e,t,n){if(!e.path||!t.path)return``;if(t.external&&!s.isAbsolute(t.path))return t.path;let r=s.posix.relative(s.posix.dirname(e.path.split(s.sep).join(s.posix.sep)),t.path.split(s.sep).join(s.posix.sep));return!r.startsWith(`.`)&&r!==``&&(r=`./${r}`),t.extension===`.ts`&&(r.endsWith(t.extension)&&(r=r.slice(0,-t.extension.length)),n?.importFileExtension?r+=n.importFileExtension:r.endsWith(`/index`)&&(r=r.slice(0,-6))),r}getBodyLines(e,t){let n=[];for(let r of e.symbols.body){let e=t.symbols.getValue(r);if(e instanceof F){let t=e.$render();n.push(vt({node:t,unescape:!0}))}else if(typeof e==`string`)n.push(e);else if(e instanceof Array)for(let t of e)n.push(vt({node:t,unescape:!0}));else e!=null&&n.push(vt({node:e,unescape:!0}))}return n}getExportLines(e,t,n){let r=[];for(let[a,o]of e.entries()){let e=[],s,c=!1;if(o.namespaceBinding!==void 0)typeof o.namespaceBinding==`string`&&(s=i(o.namespaceBinding,e=>{let r=n.symbols.get(e);return this.replacerFn({file:t,project:n,symbol:r})})),o.typeNamespaceBinding&&(c=!0);else if(o.names&&o.names.length>0){o.names.every(e=>(o.typeNames??[]).includes(e))&&(c=!0);for(let r of o.names){let a=o.aliases?.[r],s=r,u;a&&a!==s&&(u=s,s=a),s=i(s,e=>{let r=n.symbols.get(e),i=this.replacerFn({file:t,project:n,symbol:r}),[a]=n.symbolIdToFiles(e),o=a?a.resolvedNames.get(e):void 0;return o&&o!==i&&(u||=o),i}),u&&(u=i(u,e=>{let r=n.symbols.get(e);return this.replacerFn({file:t,project:n,symbol:r})}),u===s&&(u=void 0));let d=l.factory.createExportSpecifier(c?!1:o.typeNames?.includes(r)??!1,u?M.identifier({text:u}):void 0,M.identifier({text:s}));e.push(d)}}let u=s?l.factory.createNamespaceExport(M.identifier({text:s})):e.length?l.factory.createNamedExports(e):void 0,d=l.factory.createExportDeclaration(void 0,c,u,M.stringLiteral({isSingleQuote:!0,text:a}));r.push(vt({node:d,unescape:!0}))}return r}getHeaderLines(){return[`// This file is auto-generated by @hey-api/openapi-ts`]}getImportLines(e,t,n){let r=[],a=-1,o=e=>{let t=e.from;return t.startsWith(`.`)?t.startsWith(`./`)?[2,0,t]:[2,t.match(/\.\.\//g)?.length??0,t]:Tl.has(t.split(`/`)[0])?[0,0,t]:[1,0,t]},s=Array.from(e.values()).map(e=>({...e,k:o(e)})).sort((e,t)=>e.k[0]-t.k[0]||e.k[1]-t.k[1]||e.k[2].localeCompare(t.k[2]));for(let e of s){let o=[],s,c,u=!1;if(e.defaultBinding){let r=i(e.defaultBinding,e=>{let r=n.symbols.get(e);return this.replacerFn({file:t,project:n,symbol:r})});s=M.identifier({text:r}),e.typeDefaultBinding&&(u=!0)}else if(typeof e.namespaceBinding==`string`)c=i(e.namespaceBinding,e=>{let r=n.symbols.get(e);return this.replacerFn({file:t,project:n,symbol:r})}),e.typeNamespaceBinding&&(u=!0);else if(e.names&&e.names.length>0){e.names.every(t=>e.typeNames?.includes(t))&&(u=!0);let r=[];for(let a of e.names){let o=e.aliases?.[a],s=a,c;o&&o!==s&&(c=s,s=o),s=i(s,e=>{let r=n.symbols.get(e),i=this.replacerFn({file:t,project:n,symbol:r}),[a]=n.symbolIdToFiles(e),o=a?a.resolvedNames.get(e):void 0;return o&&o!==i&&(c||=o),i}),c&&(c=i(c,e=>{let r=n.symbols.get(e);return this.replacerFn({file:t,project:n,symbol:r})}),c===s&&(c=void 0)),r.push({isTypeOnly:u?!1:e.typeNames?.includes(a)??!1,name:s,propertyName:c?M.identifier({text:c}):void 0})}o=r.sort((e,t)=>e.name.localeCompare(t.name)).map(({isTypeOnly:e,name:t,propertyName:n})=>l.factory.createImportSpecifier(e,n,M.identifier({text:t})))}let d=l.factory.createImportClause(u,s,c?l.factory.createNamespaceImport(M.identifier({text:c})):o.length?l.factory.createNamedImports(o):void 0),f=l.factory.createImportDeclaration(void 0,d,M.stringLiteral({isSingleQuote:!0,text:e.from}));a!==-1&&e.k[0]!==a&&r.push(``),r.push(vt({node:f,unescape:!0})),a=e.k[0]}return r}getUniqueName(e,t){let n=2,r=e;for(;t.hasValue(r);)r=`${e}${n}`,n+=1;return r}replacerFn({file:e,project:t,symbol:n}){if(!n)return;let r=e.resolvedNames.get(n.id);if(r)return r;if(!n.name)return;let[i]=t.symbolIdToFiles(n.id),a=i?.resolvedNames.get(n.id),o=Jr(a??n.name),s=e.resolvedNames.getKey(o);if(s!==void 0){let r=t.symbols.get(s);if(r){let t=[r.kind,n.kind];(t.every(e=>e===`type`)||t.every(e=>e!==`type`)||t.includes(`class`)&&t.includes(`type`))&&(o=this.getUniqueName(o,e.resolvedNames))}}return e.resolvedNames.set(n.id,o),o}},Dl=class{heap=[];constructor(e){this.declIndex=e}isEmpty(){return!this.heap.length}pop(){let[e]=this.heap;if(!this.heap.length)return;let t=this.heap.pop();return this.heap.length?(this.heap[0]=t,this.sinkDown(0),e):e}push(e){this.heap.push(e),this.bubbleUp(this.heap.length-1)}bubbleUp(e){let t=this.heap;for(;e>0;){let n=Math.floor((e-1)/2),r=t[n],i=t[e];if(this.declIndex.get(r)<=this.declIndex.get(i))break;t[n]=i,t[e]=r,e=n}}sinkDown(e){let t=this.heap,n=t.length;for(;;){let r=2*e+1,i=2*e+2,a=e;if(r<n){let e=t[r],n=t[a];this.declIndex.get(e)<this.declIndex.get(n)&&(a=r)}if(i<n){let e=t[i],n=t[a];this.declIndex.get(e)<this.declIndex.get(n)&&(a=i)}if(a===e)break;let o=t[a];t[a]=t[e],t[e]=o,e=a}}};const Ol=(e,t,n)=>{let r=Array.from(e.nodes.keys());if(n?.preferGroups&&n.preferGroups.length>0){let i=new Set;if(n.matchPointerToGroup)for(let a of n.preferGroups)for(let o of r){let r=n.matchPointerToGroup(o);r.matched&&r.kind===a&&(i.add(o),t(o,e.nodes.get(o)))}for(let n of r)i.has(n)||t(n,e.nodes.get(n));return}for(let n of r)t(n,e.nodes.get(n))},kl=(e,t,n)=>{let r=Array.from(e.nodes.keys()),i=new Map;r.forEach((e,t)=>i.set(e,t));let a=new Map;for(let e of r){let t=(n?.getPointerPriority?.(e)??10)*1e6+(i.get(e)??0);a.set(e,t)}let o=new Map;for(let t of r){let n=e.subtreeDependencies?.get(t)??new Set,r=new Set;for(let i of n)i!==t&&e.nodes.has(i)&&r.add(i);o.set(t,r)}let s=new Map,c=new Map;for(let e of r)s.set(e,0);for(let[e,t]of o){s.set(e,t.size);for(let n of t)c.has(n)||c.set(n,new Set),c.get(n).add(e)}let l=e=>e.sort((e,t)=>a.get(e)-a.get(t)),u=new Dl(a);for(let e of r)(s.get(e)??0)===0&&u.push(e);let d=new Set,f=[];for(;!u.isEmpty();){let e=u.pop();if(d.has(e))continue;d.add(e),f.push(e);let t=c.get(e);if(t)for(let e of t){let t=(s.get(e)??0)-1;s.set(e,t),t===0&&u.push(e)}}let p=r.filter(e=>!d.has(e));l(p);for(let e of p)d.add(e),f.push(e);let m=f;if(n?.preferGroups&&n.preferGroups.length>0){let e=new Map;for(let t=0;t<n.preferGroups.length;t++){let r=n.preferGroups[t];r&&e.set(r,t)}let t=t=>{if(n.matchPointerToGroup){let r=n.matchPointerToGroup(t);if(r.matched)return e.has(r.kind)?e.get(r.kind):n.preferGroups.length}return n.preferGroups.length},r=[...f].sort((e,n)=>{let r=t(e),i=t(n);return r===i?f.indexOf(e)-f.indexOf(n):r-i}),i=new Map;for(let e=0;e<r.length;e++)i.set(r[e],e);(()=>{for(let[e,n]of o)for(let r of n)if(!(t(r)<=t(e))&&i.get(r)>=i.get(e))return!0;return!1})()||(m=r)}for(let n of m)t(n,e.nodes.get(n))},Al=(e,t,n)=>n?.order===`topological`?kl(e,t,n):Ol(e,t,n),jl=[`operation`,`parameter`,`requestBody`,`schema`,`server`,`webhook`],Ml=(e,t)=>{let n={operation:/^#\/paths\/[^/]+\/(get|put|post|delete|options|head|patch|trace)$/,parameter:/^#\/components\/parameters\/[^/]+$/,requestBody:/^#\/components\/requestBodies\/[^/]+$/,schema:/^#\/components\/schemas\/[^/]+$/,server:/^#\/servers\/(\d+|[^/]+)$/,webhook:/^#\/webhooks\/[^/]+\/(get|put|post|delete|options|head|patch|trace)$/};if(t)return n[t].test(e)?{kind:t,matched:!0}:{matched:!1};for(let t of Object.keys(n)){let r=t;if(n[r].test(e))return{kind:r,matched:!0}}return{matched:!1}},Nl=[`server`,`schema`,`parameter`,`requestBody`,`operation`,`webhook`],Pl=(()=>{let e={};for(let t=0;t<Nl.length;t++){let n=Nl[t];n&&(e[n]=t)}for(let t of jl)e[t]===void 0&&(e[t]=Nl.length);return e})(),Fl=e=>{let t=Ml(e);return t.matched?Pl[t.kind]??10:10},Il=e=>{if(!(!e.meta?.pluginName||typeof e.meta.pluginName!=`string`))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},Ll=e=>{switch(e.method){case`delete`:case`patch`:case`post`:case`put`:return[`mutation`];case`get`:return[`query`];default:return}};var Rl=class{api;config;context;dependencies=[];eventHooks;gen;handler;name;package;constructor(e){this.api=e.api??{},this.config=e.config,this.context=e.context,this.dependencies=e.dependencies,this.eventHooks=this.buildEventHooks(),this.gen=e.gen,this.handler=e.handler,this.name=e.name,this.package=e.context.package}forEach(...e){if(!this.context.graph)throw Error(`No graph available in context`);let t,n,r={getPointerPriority:Fl,matchPointerToGroup:Ml,order:`topological`,preferGroups:Nl};typeof e[e.length-1]==`function`?(n=e.slice(0,-1),t=e[e.length-1]):(n=e.slice(0,-2),t=e[e.length-2],r={...r,...e[e.length-1]});let i=new Set(n.length?n:jl);Al(this.context.graph,(e,n)=>{let r=Ml(e);if(!r.matched||!i.has(r.kind))return;let a,o={_path:Jn(e),pointer:e,tags:n.tags?Array.from(n.tags):void 0};switch(r.kind){case`operation`:a={...o,method:n.key,operation:n.node,path:o._path[1],type:r.kind};break;case`parameter`:a={...o,name:n.key,parameter:n.node,type:r.kind};break;case`requestBody`:a={...o,name:n.key,requestBody:n.node,type:r.kind};break;case`schema`:a={...o,name:n.key,schema:n.node,type:r.kind};break;case`server`:a={...o,server:n.node,type:r.kind};break;case`webhook`:a={...o,key:o._path[1],method:n.key,operation:n.node,type:r.kind};break}if(a)try{t(a)}catch(e){this.forEachError(e,a)}},r)}getPlugin(e){return this.context.plugins[e]}getPluginOrThrow(e){let t=this.getPlugin(e);if(!t)throw Error(`plugin not found ${e}`);return t}getSymbol(e){return this.gen.symbols.get(e)}hooks={operation:{isMutation:e=>this.isOperationKind(e,`mutation`),isQuery:e=>this.isOperationKind(e,`query`)}};isSymbolRegistered(e){return this.gen.symbols.isRegistered(e)}querySymbol(e){return this.gen.symbols.query(e)[0]}referenceSymbol(e){return this.gen.symbols.reference(e)}registerSymbol(e){let t={...e,exportFrom:e.exportFrom??(!e.external&&this.context.config.output.indexFile&&this.config.exportFromIndex?[`index`]:void 0),getFilePath:e.getFilePath??this.getSymbolFilePath.bind(this),meta:{pluginName:s.isAbsolute(this.name)?`custom`:this.name,...e.meta}};for(let e of this.eventHooks[`symbol:register:before`])e({plugin:this,symbol:t});let n=this.gen.symbols.register(t);for(let e of this.eventHooks[`symbol:register:after`])e({plugin:this,symbol:n});return n}async run(){for(let e of this.eventHooks[`plugin:handler:before`])e({plugin:this});await this.handler({plugin:this});for(let e of this.eventHooks[`plugin:handler:after`])e({plugin:this})}setSymbolValue(e,t){for(let n of this.eventHooks[`symbol:setValue:before`])n({plugin:this,symbol:e,value:t});this.gen.symbols.setValue(e.id,t);for(let n of this.eventHooks[`symbol:setValue:after`])n({plugin:this,symbol:e,value:t})}buildEventHooks(){let e={"plugin:handler:after":[],"plugin:handler:before":[],"symbol:register:after":[],"symbol:register:before":[],"symbol:setValue:after":[],"symbol:setValue:before":[]},t=[this.config[`~hooks`]?.events,this.context.config.parser.hooks.events];for(let n of t)if(n)for(let[t,r]of Object.entries(n))r&&e[t].push(r.bind(n));return e}forEachError(e,t){let n=e instanceof Error?e:Error(String(e));throw new ae({args:[t],error:n,event:t.type,name:`Error`,pluginName:this.name})}getSymbolFilePath(e){let t=[this.config[`~hooks`]?.symbols,this.context.config.parser.hooks.symbols];for(let n of t){let t=n?.getFilePath?.(e);if(t!==void 0)return t}return Il(e)}isOperationKind(e,t){let n=t===`query`?`isQuery`:`isMutation`,r=[this.config[`~hooks`]?.operations?.[n],this.config[`~hooks`]?.operations?.getKind,this.context.config.parser.hooks.operations?.[n],this.context.config.parser.hooks.operations?.getKind,Ll];for(let n of r)if(n){let r=n(e);if(r!==void 0)return typeof r==`boolean`?r:r.includes(t)}return!1}},zl=class{config;gen;graph;ir={};logger;package;plugins={};spec;constructor({config:e,dependencies:n,logger:r,spec:i}){this.config=e,this.gen=new t({defaultFileName:`index`,fileName:t=>{let n=x({config:e.output.fileName,name:t}),{suffix:r}=e.output.fileName;return r?n===`index`||n.endsWith(r)?n:`${n}${r}`:n},renderers:{".ts":new El},root:e.output.path}),this.logger=r,this.package=Kr(n),this.spec=i}dereference(e){let t=this.resolveRef(e.$ref),n={...e,...t};return delete n.$ref,n}registerPlugin(e){let t=this.config.plugins[e],n=new Rl({api:t.api,config:t.config,context:this,dependencies:t.dependencies??[],gen:this.gen,handler:t.handler,name:t.name});return this.plugins[n.name]=n,n}registerPlugins(){return this.config.pluginOrder.map(e=>this.registerPlugin(e))}resolveIrRef(e){return Zn({$ref:e,spec:this.ir})}resolveRef(e){return Zn({$ref:e,spec:this.spec})}};const Bl=[`delete`,`get`,`head`,`options`,`patch`,`post`,`put`,`trace`],Vl=({context:e,count:t=1,id:n,method:r,path:i,state:a})=>{let o,{output:s}=e.config,c=(s!==void 0&&typeof s==`object`&&`case`in s?s.case:void 0)??`camelCase`;return o=n&&(!e.config.plugins[`@hey-api/sdk`]||e.config.plugins[`@hey-api/sdk`].config.operationId)?b({case:c,value:nt(n)}):b({case:c,value:`${r}-${i.replace(/{(.*?)}/g,`by-$1`).replace(/[/:+]/g,`-`)}`}),t>1&&(o=`${o}${t}`),a.ids.has(o)?Vl({context:e,count:t+1,id:n,method:r,path:i,state:a}):(a.ids.set(o,w({method:r,path:i})),o)},q=(e,t=``)=>`${e}/${t}`,J=e=>{let t=e.indexOf(`/`);return{name:e.slice(t+1),namespace:e.slice(0,t)}},Hl=e=>{switch(e){case`parameters`:return`parameter`;case`requestBodies`:return`body`;case`responses`:return`response`;case`definitions`:case`schemas`:return`schema`;default:return`unknown`}},Y=(e,t)=>{let n=[],r=[];if(t)for(let i of t)i.startsWith(`/`)&&i.endsWith(`/`)?r.push(new RegExp(i.slice(1,i.length-1))):n.push(q(e,i));return{regexps:r,set:new Set(n)}},Ul=({excludeOperations:e,excludeSchemas:t,includeOperations:n,includeSchemas:r,spec:i})=>{if((e.regexps.length||n.regexps.length)&&i.paths)for(let t of Object.entries(i.paths)){let r=t[0],i=t[1];for(let t of Bl){if(!i[t])continue;let a=w({method:t,path:r});e.regexps.some(e=>e.test(a))&&e.set.add(q(`operation`,a)),n.regexps.some(e=>e.test(a))&&n.set.add(q(`operation`,a))}}if(i.definitions&&(t.regexps.length||r.regexps.length))for(let e of Object.keys(i.definitions))t.regexps.some(t=>t.test(e))&&t.set.add(q(`schema`,e)),r.regexps.some(t=>t.test(e))&&r.set.add(q(`schema`,e))},Wl=({excludeOperations:e,excludeParameters:t,excludeRequestBodies:n,excludeResponses:r,excludeSchemas:i,includeOperations:a,includeParameters:o,includeRequestBodies:s,includeResponses:c,includeSchemas:l,spec:u})=>{if((e.regexps.length||a.regexps.length)&&u.paths)for(let t of Object.entries(u.paths)){let n=t[0],r=t[1];for(let t of Bl){if(!r[t])continue;let i=w({method:t,path:n});e.regexps.some(e=>e.test(i))&&e.set.add(q(`operation`,i)),a.regexps.some(e=>e.test(i))&&a.set.add(q(`operation`,i))}}if(u.components){if((t.regexps.length||o.regexps.length)&&u.components.parameters)for(let e of Object.keys(u.components.parameters))t.regexps.some(t=>t.test(e))&&t.set.add(q(`parameter`,e)),o.regexps.some(t=>t.test(e))&&o.set.add(q(`parameter`,e));if((n.regexps.length||s.regexps.length)&&u.components.requestBodies)for(let e of Object.keys(u.components.requestBodies))n.regexps.some(t=>t.test(e))&&n.set.add(q(`body`,e)),s.regexps.some(t=>t.test(e))&&s.set.add(q(`body`,e));if((r.regexps.length||c.regexps.length)&&u.components.responses)for(let e of Object.keys(u.components.responses))r.regexps.some(t=>t.test(e))&&r.set.add(q(`response`,e)),c.regexps.some(t=>t.test(e))&&c.set.add(q(`response`,e));if((i.regexps.length||l.regexps.length)&&u.components.schemas)for(let e of Object.keys(u.components.schemas))i.regexps.some(t=>t.test(e))&&i.set.add(q(`schema`,e)),l.regexps.some(t=>t.test(e))&&l.set.add(q(`schema`,e))}},Gl=({spec:e,...t})=>{`swagger`in e?Ul({...t,spec:e}):Wl({...t,spec:e})},Kl=(e,t,n)=>{let r=n.timeEvent(`create-filters`),i=Y(`operation`,e?.operations?.exclude),a=Y(`operation`,e?.operations?.include),o=Y(`parameter`,e?.parameters?.exclude),s=Y(`parameter`,e?.parameters?.include),c=Y(`body`,e?.requestBodies?.exclude),l=Y(`body`,e?.requestBodies?.include),u=Y(`response`,e?.responses?.exclude),d=Y(`response`,e?.responses?.include),f=Y(`schema`,e?.schemas?.exclude),p=Y(`schema`,e?.schemas?.include);Gl({excludeOperations:i,excludeParameters:o,excludeRequestBodies:c,excludeResponses:u,excludeSchemas:f,includeOperations:a,includeParameters:s,includeRequestBodies:l,includeResponses:d,includeSchemas:p,spec:t});let m={deprecated:e?.deprecated??!0,operations:{exclude:i.set,include:a.set},orphans:e?.orphans??!1,parameters:{exclude:o.set,include:s.set},preserveOrder:e?.preserveOrder??!1,requestBodies:{exclude:c.set,include:l.set},responses:{exclude:u.set,include:d.set},schemas:{exclude:f.set,include:p.set},tags:{exclude:new Set(e?.tags?.exclude),include:new Set(e?.tags?.include)}};return r.timeEnd(),m},ql=e=>e?e.orphans===!1||e.deprecated===!1?!0:!!(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):!1,Jl=({filters:e,parameters:t,requestBodies:n,resourceMetadata:r,responses:i,schemas:a})=>{let o=new Set,s=[...e.operations.include.size?e.operations.include:new Set(r.operations.keys())];for(;s.length;){let c=s.pop();if(e.operations.exclude.has(c)||o.has(c))continue;let l=r.operations.get(c);l&&(!e.deprecated&&l.deprecated||e.tags.exclude.size&&l.tags.size&&[...e.tags.exclude].some(e=>l.tags.has(e))||e.tags.include.size&&!new Set([...e.tags.include].filter(e=>l.tags.has(e))).size||[...l.dependencies].some(e=>{let{namespace:r}=J(e);switch(r){case`body`:return!n.has(e);case`parameter`:return!t.has(e);case`response`:return!i.has(e);case`schema`:return!a.has(e);default:return!1}})||o.add(c))}return{operations:o}},Yl=({filters:e,resourceMetadata:t,schemas:n})=>{let r=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)||r.has(a))continue;let o=t.parameters.get(a);if(o&&!(!e.deprecated&&o.deprecated)&&(r.add(a),o.dependencies.size))for(let t of o.dependencies){let{namespace:o}=J(t);switch(o){case`body`:e.requestBodies.exclude.has(t)?r.delete(a):r.has(t)||i.push(t);break;case`schema`:e.schemas.exclude.has(t)?r.delete(a):n.has(t)||n.add(t);break}}}return{parameters:r}},Xl=({filters:e,resourceMetadata:t,schemas:n})=>{let r=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)||r.has(a))continue;let o=t.requestBodies.get(a);if(o&&!(!e.deprecated&&o.deprecated)&&(r.add(a),o.dependencies.size))for(let t of o.dependencies){let{namespace:o}=J(t);switch(o){case`body`:e.requestBodies.exclude.has(t)?r.delete(a):r.has(t)||i.push(t);break;case`schema`:e.schemas.exclude.has(t)?r.delete(a):n.has(t)||n.add(t);break}}}return{requestBodies:r}},Zl=({filters:e,resourceMetadata:t,schemas:n})=>{let r=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)||r.has(a))continue;let o=t.responses.get(a);if(o&&!(!e.deprecated&&o.deprecated)&&(r.add(a),o.dependencies.size))for(let t of o.dependencies){let{namespace:o}=J(t);switch(o){case`body`:e.requestBodies.exclude.has(t)?r.delete(a):r.has(t)||i.push(t);break;case`schema`:e.schemas.exclude.has(t)?r.delete(a):n.has(t)||n.add(t);break}}}return{responses:r}},Ql=({filters:e,resourceMetadata:t})=>{let n=new Set,r=[...e.schemas.include.size?e.schemas.include:new Set(t.schemas.keys())];for(;r.length;){let i=r.pop();if(e.schemas.exclude.has(i)||n.has(i))continue;let a=t.schemas.get(i);if(a&&!(!e.deprecated&&a.deprecated)&&(n.add(i),a.dependencies.size))for(let t of a.dependencies){let{namespace:i}=J(t);switch(i){case`schema`:!n.has(t)&&!e.schemas.exclude.has(t)&&r.push(t);break}}}return{schemas:n}},$l=({filters:e,parameters:t,resourceMetadata:n})=>{if(e.parameters.exclude.size)for(let r of t){let i=n.parameters.get(r);if(i?.dependencies.size){for(let n of e.parameters.exclude)if(i.dependencies.has(n)){t.delete(r);break}}}},eu=({filters:e,requestBodies:t,resourceMetadata:n})=>{if(e.requestBodies.exclude.size)for(let r of t){let i=n.requestBodies.get(r);if(i?.dependencies.size){for(let n of e.requestBodies.exclude)if(i.dependencies.has(n)){t.delete(r);break}}}},tu=({filters:e,resourceMetadata:t,responses:n})=>{if(e.responses.exclude.size)for(let r of n){let i=t.responses.get(r);if(i?.dependencies.size){for(let t of e.responses.exclude)if(i.dependencies.has(t)){n.delete(r);break}}}},nu=({filters:e,resourceMetadata:t,schemas:n})=>{if(e.schemas.exclude.size)for(let r of n){let i=t.schemas.get(r);if(i?.dependencies.size){for(let t of e.schemas.exclude)if(i.dependencies.has(t)){n.delete(r);break}}}},ru=({operationDependencies:e,parameters:t,requestBodies:n,responses:r,schemas:i})=>{for(let t of i)e.has(t)||i.delete(t);for(let n of t)e.has(n)||t.delete(n);for(let t of n)e.has(t)||n.delete(t);for(let t of r)e.has(t)||r.delete(t)},iu=({operations:e,resourceMetadata:t})=>{let n=new Set,r=[...new Set([...e].flatMap(e=>[...t.operations.get(e)?.dependencies??[]]))];for(;r.length;){let e=r.pop();if(n.has(e))continue;n.add(e);let{namespace:i}=J(e),a;if(i===`body`?a=t.requestBodies.get(e)?.dependencies:i===`operation`?a=t.operations.get(e)?.dependencies:i===`parameter`?a=t.parameters.get(e)?.dependencies:i===`response`?a=t.responses.get(e)?.dependencies:i===`schema`&&(a=t.schemas.get(e)?.dependencies),a?.size)for(let e of a)n.has(e)||r.push(e)}return{operationDependencies:n}},au=({filters:e,logger:t,resourceMetadata:n})=>{let r=t.timeEvent(`create-filtered-dependencies`),{schemas:i}=Ql({filters:e,resourceMetadata:n}),{parameters:a}=Yl({filters:e,resourceMetadata:n,schemas:i}),{requestBodies:o}=Xl({filters:e,resourceMetadata:n,schemas:i}),{responses:s}=Zl({filters:e,resourceMetadata:n,schemas:i});nu({filters:e,resourceMetadata:n,schemas:i}),$l({filters:e,parameters:a,resourceMetadata:n}),eu({filters:e,requestBodies:o,resourceMetadata:n}),tu({filters:e,resourceMetadata:n,responses:s});let{operations:c}=Jl({filters:e,parameters:a,requestBodies:o,resourceMetadata:n,responses:s,schemas:i});if(!e.orphans&&c.size){let{operationDependencies:e}=iu({operations:c,resourceMetadata:n});ru({operationDependencies:e,parameters:a,requestBodies:o,responses:s,schemas:i})}return r.timeEnd(),{operations:c,parameters:a,requestBodies:o,responses:s,schemas:i}},ou=(e,t)=>{let n=t.timeEvent(`build-resource-metadata`),r={operations:new Map,parameters:new Map,requestBodies:new Map,responses:new Map,schemas:new Map},i=t=>{let n=new Set,r=e.transitiveDependencies.get(t);if(r?.size)for(let e of r){let t=Jn(e),r=t[t.length-2],i=t[t.length-1];if(r&&i){let e=Hl(r);e===`unknown`&&console.warn(`unsupported type: ${r}`),n.add(q(e,i))}}return n};for(let[t,n]of e.nodes){let e=Jn(t);if(e[0]===`components`){if(e.length===3){if(e[1]===`schemas`){let a=e[e.length-1];r.schemas.set(q(`schema`,a),{dependencies:i(t),deprecated:n.deprecated??!1})}else if(e[1]===`parameters`){let a=e[e.length-1];r.parameters.set(q(`parameter`,a),{dependencies:i(t),deprecated:n.deprecated??!1})}else if(e[1]===`requestBodies`){let a=e[e.length-1];r.requestBodies.set(q(`body`,a),{dependencies:i(t),deprecated:n.deprecated??!1})}else if(e[1]===`responses`){let a=e[e.length-1];r.responses.set(q(`response`,a),{dependencies:i(t),deprecated:n.deprecated??!1})}}continue}if(e[0]===`paths`){if(e.length===3&&Bl.includes(e[2])){let a=e[e.length-1],o=w({method:a,path:e.slice(1,-1).join(`/`)});r.operations.set(q(`operation`,o),{dependencies:i(t),deprecated:n.deprecated??!1,tags:n.tags??new Set})}continue}if(e[0]===`definitions`){if(e.length===2){let a=e[e.length-1];r.schemas.set(q(`schema`,a),{dependencies:i(t),deprecated:n.deprecated??!1})}continue}}return n.timeEnd(),{resourceMetadata:r}},su=e=>JSON.parse(JSON.stringify(e)),cu=[[`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`]],lu=e=>{if(uu(e))return e.components.schemas;if(du(e))return e.definitions},uu=e=>typeof e==`object`&&!!e&&`components`in e&&typeof e.components==`object`&&e.components!==null&&`schemas`in e.components&&typeof e.components.schemas==`object`&&e.components.schemas!==null,du=e=>typeof e==`object`&&!!e&&`definitions`in e&&typeof e.definitions==`object`&&e.definitions!==null,fu=(e,t)=>e instanceof Set?e.has(t):e instanceof Array?e.includes(t):t in e,pu=({base:e,components:t,extraComponents:n})=>{let r=2,i=e;for(;fu(t,i)||n&&fu(n,i);)i=`${e}${r}`,r+=1;return i},mu=e=>e.length===3&&e[0]===`components`&&e[1]===`schemas`||e.length===2&&e[0]===`definitions`,hu=e=>{if(e&&typeof e==`object`){if(`swagger`in e)return`#/definitions/`;if(`openapi`in e)return`#/components/schemas/`}return``},gu=e=>{if(!e||typeof e!=`object`||!(`enum`in e)||!(e.enum instanceof Array))return;let t=(`type`in e?e.type:void 0)||``,n=[...e.enum].sort();return JSON.stringify({type:t,values:n})},_u=({key:e,node:t,parent:n,path:r,visitor:i})=>{if(!t||typeof t!=`object`||t instanceof Array)return;let a=t;(`type`in a||`enum`in a||cu.some(([e])=>e in a))&&i({key:e,node:t,parent:n,path:r});for(let[e,n]of Object.entries(a))typeof n==`object`&&n&&(n instanceof Array?n.forEach((t,a)=>_u({key:a,node:t,parent:n,path:[...r,e,a],visitor:i})):_u({key:e,node:n,parent:t,path:[...r,e],visitor:i}))},vu=({spec:e})=>{let t=lu(e);if(!t)return;let n=hu(e),r={};for(let[e,i]of Object.entries(t))gu(i)&&(r[`${n}${e}`]=i);let i=e=>{if(e instanceof Array)e.forEach(i);else if(e&&typeof e==`object`)for(let[t,n]of Object.entries(e))t===`$ref`&&typeof n==`string`&&n in r?(Object.assign(e,su(r[n])),delete e.$ref):i(n)};i(e);for(let e of Object.keys(r)){let n=Jn(e),r=n[n.length-1];r&&delete t[r]}},yu=({config:e,spec:t})=>{let n=lu(t);if(!n)return;let r={};for(let[e,t]of Object.entries(n)){let n=gu(t);n&&(r[n]=e)}let i=[];_u({key:null,node:t,parent:null,path:[],visitor:e=>{if(!mu(e.path)){let t=gu(e.node);t&&i.push({...e,signature:t})}}});let a={},o={};for(let{key:t,node:s,signature:c}of i)if(!(c in a)){if(c in r){a[c]=r[c];continue}a[c]=pu({base:x({config:e,name:typeof s==`object`&&s&&`title`in s&&typeof s.title==`string`?s.title:String(t)}),components:n,extraComponents:Object.values(a)}),o[c]=s}for(let[e,t]of Object.entries(a)){let r=o[e];t&&!(t in n)&&r&&typeof r==`object`&&(n[t]=r)}let s=hu(t);for(let{key:e,parent:t,signature:n}of i){let r=a[n];r&&e!=null&&t&&typeof t==`object`&&(t[e]={$ref:`${s}${r}`})}},bu=({config:e,spec:t})=>{if(e.mode===`inline`){vu({spec:t});return}if(e.mode===`root`){yu({config:e,spec:t});return}},xu=({key:e,node:t,parent:n,path:r,visitor:i})=>{if(!t||typeof t!=`object`||t instanceof Array)return;let a=t;(`type`in a||cu.some(([e])=>e in a))&&i({key:e,node:t,parent:n,path:r});for(let[e,n]of Object.entries(a))typeof n==`object`&&n&&(n instanceof Array?n.forEach((t,a)=>xu({key:a,node:t,parent:n,path:[...r,e,a],visitor:i})):xu({key:e,node:n,parent:t,path:[...r,e],visitor:i}))},Su=({spec:e})=>{xu({key:null,node:e,parent:null,path:[],visitor:e=>{if(e.node&&typeof e.node==`object`&&`type`in e.node&&e.node.type===`object`&&`properties`in e.node&&e.node.properties&&typeof e.node.properties==`object`&&!(`required`in e.node)){let t=Object.keys(e.node.properties);t.length>0&&(e.node.required=t)}}})},Cu=(e,t)=>{if(e===t)return!0;if(e===null||t===null)return e===t;let n=typeof e;if(n!==typeof t||n!==`object`)return!1;if(Array.isArray(e)||Array.isArray(t)){if(!Array.isArray(e)||!Array.isArray(t)||e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!Cu(e[n],t[n]))return!1;return!0}let r=e,i=t,a=Object.keys(r).sort(),o=Object.keys(i).sort();if(a.length!==o.length)return!1;for(let e=0;e<a.length;e++)if(a[e]!==o[e])return!1;for(let e of a)if(!Cu(r[e],i[e]))return!1;return!0};var wu=Cu;const Tu=e=>{for(let[,t]of e)if(!t.scopes&&t.parentPointer){let n=e.get(t.parentPointer);n?.scopes&&(t.scopes=new Set(n.scopes))}},Eu=({cache:e,graph:t,pointer:n,visited:r})=>{let i=e.transitiveDependencies.get(n);if(i)return{subtreeDependencies:e.subtreeDependencies.get(n),transitiveDependencies:i};if(r.has(n)||(r.add(n),!t.nodes.get(n)))return{subtreeDependencies:new Set,transitiveDependencies:new Set};let a=new Set,o=new Set,s=t.nodeDependencies.get(n);if(s)for(let n of s){a.add(n),o.add(n);let i=Eu({cache:e,graph:t,pointer:n,visited:r});for(let e of i.transitiveDependencies)a.add(e)}let c=e.parentToChildren.get(n)??[];for(let n of c){let i={subtreeDependencies:e.subtreeDependencies.get(n),transitiveDependencies:e.transitiveDependencies.get(n)};(!i.subtreeDependencies||!i.transitiveDependencies)&&(i=Eu({cache:e,graph:t,pointer:n,visited:r}),e.transitiveDependencies.set(n,i.transitiveDependencies),e.subtreeDependencies.set(n,i.subtreeDependencies));for(let e of i.transitiveDependencies)a.add(e);for(let e of i.subtreeDependencies)o.add(e)}return e.transitiveDependencies.set(n,a),e.subtreeDependencies.set(n,o),{subtreeDependencies:o,transitiveDependencies:a}},Du=e=>{let t=new Set(Array.from(e.nodes.entries()).filter(([,e])=>e.scopes&&e.scopes.size>0).map(([e])=>e)),n=(n,r,i)=>{r.parentPointer&&t.add(r.parentPointer);let a=e.reverseNodeDependencies.get(n);if(a)for(let e of a)t.add(e);if(i){let e=i.match(/(.*)\/(allOf|anyOf|oneOf)\/\d+$/);if(e){let n=e[1];n&&t.add(n)}}},r=(t,r,i)=>{if(!r?.scopes)return;let a=e.nodes.get(i);a?.scopes&&Ou(a,r)&&n(t,r,i)};for(;t.size>0;){let i=t.values().next().value;t.delete(i);let a=e.nodes.get(i);if(!a)continue;a.scopes||=new Set;let o=a.node;for(let[e,t]of cu){if(!o||typeof o!=`object`||!(e in o))continue;let n=o[e];if(t===`array`&&n instanceof Array)for(let t=0;t<n.length;t++)r(i,a,`${i}/${e}/${t}`);else if(t===`objectMap`&&typeof n==`object`&&n&&!(n instanceof Array))for(let t of Object.keys(n))r(i,a,`${i}/${e}/${t}`);else if(t===`single`&&typeof n==`object`&&n)r(i,a,`${i}/${e}`);else if(t===`singleOrArray`)if(n instanceof Array)for(let t=0;t<n.length;t++)r(i,a,`${i}/${e}/${t}`);else typeof n==`object`&&n&&r(i,a,`${i}/${e}`)}let s=e.nodeDependencies.get(i);if(s)for(let t of s){let r=e.nodes.get(t);r?.scopes&&Ou(r,a)&&n(i,a)}if(a.parentPointer){let t=e.nodes.get(a.parentPointer);t&&Ou(a,t)&&n(a.parentPointer,t)}}},Ou=(e,t)=>{if(!e.scopes)return!1;t.scopes||=new Set;let n=!1;for(let r of e.scopes)t.scopes.has(r)||(t.scopes.add(r),n=!0);return n},ku=e=>{for(let[t,n]of e){let{node:e}=n;typeof e!=`object`||!e||e instanceof Array||(`readOnly`in e&&e.readOnly===!0?n.scopes=new Set([`read`]):`writeOnly`in e&&e.writeOnly===!0?n.scopes=new Set([`write`]):t.match(/\/properties\/[^/]+$/)&&(n.scopes=new Set([`normal`])))}},Au=(e,t)=>{let n=t.timeEvent(`build-graph`),r={nodeDependencies:new Map,nodes:new Map,reverseNodeDependencies:new Map,subtreeDependencies:new Map,transitiveDependencies:new Map},i=({key:e,node:t,parentPointer:n,path:a})=>{if(typeof t!=`object`||!t)return;let o=Xn(a),s,c;if(typeof t==`object`&&t){if(`deprecated`in t&&typeof t.deprecated==`boolean`&&(s=!!t.deprecated),`$ref`in t&&typeof t.$ref==`string`){let e=Yn(t.$ref);r.nodeDependencies.has(o)||r.nodeDependencies.set(o,new Set),r.nodeDependencies.get(o).add(e)}`tags`in t&&t.tags instanceof Array&&(c=new Set(t.tags.filter(e=>typeof e==`string`)))}if(r.nodes.set(o,{deprecated:s,key:e,node:t,parentPointer:n,tags:c}),t instanceof Array)t.forEach((e,t)=>i({key:t,node:e,parentPointer:o,path:[...a,t]}));else for(let[e,n]of Object.entries(t))i({key:e,node:n,parentPointer:o,path:[...a,e]})};i({key:null,node:e,parentPointer:null,path:[]});let a={parentToChildren:new Map,subtreeDependencies:new Map,transitiveDependencies:new Map};for(let[e,t]of r.nodes){let n=t.parentPointer;n&&(a.parentToChildren.has(n)||a.parentToChildren.set(n,[]),a.parentToChildren.get(n).push(e))}for(let[e,t]of r.nodeDependencies)for(let n of t)r.reverseNodeDependencies.has(n)||r.reverseNodeDependencies.set(n,new Set),r.reverseNodeDependencies.get(n).add(e);ku(r.nodes),Du(r),Tu(r.nodes);for(let e of r.nodes.keys()){let t=Eu({cache:a,graph:r,pointer:e,visited:new Set});r.transitiveDependencies.set(e,t.transitiveDependencies),r.subtreeDependencies.set(e,t.subtreeDependencies)}return n.timeEnd(),{graph:r}},ju=new Set([`additionalProperties`,`allOf`,`anyOf`,`items`,`not`,`oneOf`,`patternProperties`,`properties`,`schema`]),Mu=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`}},Nu=(e,t)=>{let n=t.timeEvent(`capture-original-schemas`),r={};if(uu(e))for(let[t,n]of Object.entries(e.components.schemas))r[`#/components/schemas/${t}`]=n;else if(du(e))for(let[t,n]of Object.entries(e.definitions))r[`#/definitions/${t}`]=n;return n.timeEnd(),r},Pu=({logger:e,spec:t,split:n})=>{let r=e.timeEvent(`insert-split-schemas-into-spec`);uu(t)?Object.assign(t.components.schemas,n.schemas):du(t)&&Object.assign(t.definitions,n.schemas),r.timeEnd()},Fu=(e,t,n)=>{if(t&&typeof t==`object`){if(`$ref`in t&&typeof t.$ref==`string`){let r=e.nodes.get(t.$ref);if(r?.scopes&&(n===`writeOnly`&&r.scopes.size===1&&r.scopes.has(`write`)||n===`readOnly`&&r.scopes.size===1&&r.scopes.has(`read`))&&(delete t.$ref,!cu.some(([e])=>e in t)))return!0}for(let[r,i]of cu){if(!(r in t))continue;let a=t[r];if(i===`array`&&a instanceof Array){for(let t=a.length-1;t>=0;t--){let r=a[t];(r&&typeof r==`object`&&r[n]===!0||Fu(e,r,n))&&a.splice(t,1)}a.length||delete t[r]}else if(i===`objectMap`&&typeof a==`object`&&a&&!(a instanceof Array)){let i=a,o=new Set;for(let t of Object.keys(i)){let a=i[t];(a&&typeof a==`object`&&a[n]===!0||Fu(e,a,n))&&(delete i[t],r===`properties`&&o.add(t))}if(o.size>0&&r===`properties`&&`required`in t&&Array.isArray(t.required)){let e=t.required.filter(e=>!o.has(e));e.length?t.required=e:delete t.required}Object.keys(i).length||delete t[r]}else if(i===`single`&&typeof a==`object`&&a)(a[n]===!0||Fu(e,a,n))&&delete t[r];else if(i===`singleOrArray`)if(a instanceof Array){for(let t=a.length-1;t>=0;t--){let r=a[t];(r&&typeof r==`object`&&r[n]===!0||Fu(e,r,n))&&a.splice(t,1)}a.length||delete t[r]}else typeof a==`object`&&a&&(a[n]===!0||Fu(e,a,n))&&delete t[r]}if(t.type===`object`&&!cu.some(([e])=>e in t))return!0}return!1},Iu=({logger:e,originalSchemas:t,spec:n,split:r})=>{let i=e.timeEvent(`remove-original-split-schemas`),a=lu(n);for(let e of Object.keys(r.mapping)){let n=Jn(e),r=n[n.length-1];typeof r==`string`&&a&&Object.prototype.hasOwnProperty.call(a,r)&&a[r]===t[e]&&delete a[r]}i.timeEnd()},Lu=({config:e,graph:t,logger:n,spec:r})=>{let i=n.timeEvent(`split-schemas`),a=new Set,o={mapping:{},reverseMapping:{},schemas:{}},s=hu(r),c=s.split(`/`).length-1,l=e=>{if(e.startsWith(s)){let t=Jn(e);if(t.length===c)return t[c-1]||``}return``};for(let e of t.nodes.keys()){let t=l(e);t&&a.add(t)}for(let[n,r]of t.nodes){let i=l(n);if(!i||!(r.scopes?.has(`read`)||r.scopes?.has(`write`))||!r.scopes?.has(`normal`))continue;let c=su(r.node);Fu(t,c,`writeOnly`);let u=x({config:e.responses,name:i}),d=u===i?u:pu({base:u,components:a});a.add(d),o.schemas[d]=c;let f=`${s}${d}`,p=su(r.node);Fu(t,p,`readOnly`);let m=t.transitiveDependencies.get(n)||new Set;if(!Array.from(m).some(e=>{let n=t.nodes.get(e);return n?.scopes?.has(`normal`)&&(n.scopes.has(`read`)||n.scopes.has(`write`))})&&wu(c,p)&&wu(c,r.node))continue;let h=x({config:e.requests,name:i}),g=h===i&&h!==d?h:pu({base:h,components:a});a.add(g),o.schemas[g]=p;let ee=`${s}${g}`;o.mapping[n]={read:f,write:ee},o.reverseMapping[f]=n,o.reverseMapping[ee]=n}return i.timeEnd(),o},Ru=({logger:e,spec:t,split:n})=>{let r=e.timeEvent(`update-refs-in-spec`),i=hu(t),a=({context:e,currentPointer:t,inSchema:r,node:o,path:s,visited:c=new Set})=>{if(o instanceof Array)o.forEach((n,i)=>a({context:e,currentPointer:t,inSchema:r,node:n,path:[...s,i],visited:c}));else if(o&&typeof o==`object`){let l=t,u=e;if(mu(s)){l=`${i}${s[s.length-1]}`;let e=n.reverseMapping[l];if(e){let t=n.mapping[e];t?.read===l?u=`read`:t?.write===l&&(u=`write`)}}let d=Mu(s);if(d!==void 0){for(let e in o)Object.prototype.hasOwnProperty.call(o,e)&&a({context:d,currentPointer:l,inSchema:!1,node:o[e],path:[...s,e],visited:c});return}for(let e in o){if(!Object.prototype.hasOwnProperty.call(o,e))continue;let t=o[e];if(!r){if(e===`requestBody`){a({context:`write`,currentPointer:l,inSchema:!1,node:t,path:[...s,e],visited:c});continue}if(e===`responses`){a({context:`read`,currentPointer:l,inSchema:!1,node:t,path:[...s,e],visited:c});continue}if(e===`parameters`&&Array.isArray(t)){t.forEach((t,n)=>{t&&typeof t==`object`&&`schema`in t&&a({context:`write`,currentPointer:l,inSchema:!0,node:t.schema,path:[...s,e,n,`schema`],visited:c}),t&&typeof t==`object`&&`content`in t&&a({context:`write`,currentPointer:l,inSchema:!1,node:t.content,path:[...s,e,n,`content`],visited:c})});continue}if(e===`headers`&&typeof t==`object`&&t){for(let n in t)Object.prototype.hasOwnProperty.call(t,n)&&a({context:`read`,currentPointer:l,inSchema:!1,node:t[n],path:[...s,e,n],visited:c});continue}}if(ju.has(e))a({context:u,currentPointer:l,inSchema:!0,node:t,path:[...s,e],visited:c});else if(e===`$ref`&&typeof t==`string`){let r=n.mapping[t];r&&(u===`read`&&r.read?o[e]=r.read:u===`write`&&r.write?o[e]=r.write:!u&&r.read&&(o[e]=r.read))}else a({context:u,currentPointer:l,inSchema:r,node:t,path:[...s,e],visited:c})}}};a({context:null,currentPointer:null,inSchema:!1,node:t,path:[]}),r.timeEnd()},zu=({config:e,logger:t,spec:n})=>{let{graph:r}=Au(n,t),i=Nu(n,t),a=Lu({config:e,graph:r,logger:t,spec:n});Pu({logger:t,spec:n,split:a}),Ru({logger:t,spec:n,split:a}),Iu({logger:t,originalSchemas:i,spec:n,split:a})},Bu=({context:e})=>{let{logger:t}=e,n=t.timeEvent(`transform-openapi-spec`);e.config.parser.transforms.enums.enabled&&bu({config:e.config.parser.transforms.enums,spec:e.spec}),e.config.parser.transforms.propertiesRequiredByDefault&&Su({spec:e.spec}),e.config.parser.transforms.readWrite.enabled&&zu({config:e.config.parser.transforms.readWrite,logger:t,spec:e.spec}),n.timeEnd()},X=({source:e,target:t})=>{let n={...t};if(e&&(e.cookie&&(n.cookie?n.cookie={...n.cookie,...e.cookie}:n.cookie=e.cookie),e.header&&(n.header?n.header={...n.header,...e.header}:n.header=e.header),e.path&&(n.path?n.path={...n.path,...e.path}:n.path=e.path),e.query&&(n.query?n.query={...n.query,...e.query}:n.query=e.query)),Object.keys(n).length)return n},Vu=e=>/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(e),Hu=e=>e.map((e,t)=>typeof e==`number`?`[${e}]`:t===0?e:Vu(e)?`.${e}`:`['${e.replace(/"/g,`\\'`)}']`).join(``),Uu=e=>{let t=Hu(e.path),n=e.severity===`error`?a.bold.red:a.bold.yellow,r=e.message.replace(/`([^`]+)`/g,(e,t)=>a.yellow(`\`${t}\``));return`${n(`[${e.severity.toUpperCase()}]`)} ${a.cyan(t)}: ${r}`},Wu=({context:e,issue:t})=>e.config.logs.level===`silent`?!1:t.severity===`error`?e.config.logs.level!==`warn`:!0,Gu=({context:e,result:t})=>{for(let n of t.issues)Wu({context:e,issue:n})&&console.log(Uu(n));t.valid||process.exit(1)},Ku=({logger:e,operations:t,preserveOrder:n,schemas:r,spec:i})=>{let a=e.timeEvent(`filter-spec`);if(i.definitions){let e={};if(n)for(let[t,n]of Object.entries(i.definitions))r.has(q(`schema`,t))&&(e[t]=n);else for(let t of r){let{name:n}=J(t),r=i.definitions[n];r&&(e[n]=r)}i.definitions=e}if(i.paths)for(let e of Object.entries(i.paths)){let n=e[0],r=e[1];for(let e of Bl){if(!r[e])continue;let i=q(`operation`,w({method:e,path:n}));t.has(i)||delete r[e]}Object.keys(r).length||delete i.paths[n]}a.timeEnd()},qu=/^(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,Ju=/^application\/(.*\+)?json(;.*)?$/i,Yu=/^multipart\/form-data(;.*)?$/i,Xu=/^text\/[a-z0-9.+-]+(;.*)?$/i,Zu=/^application\/x-www-form-urlencoded(;.*)?$/i,Qu=/^application\/octet-stream(;.*)?$/i,$u=({mediaType:e})=>(qu.lastIndex=0,qu.test(e)),ed=({mediaType:e})=>{if(Ju.lastIndex=0,Ju.test(e))return`json`;if(Yu.lastIndex=0,Yu.test(e))return`form-data`;if(Xu.lastIndex=0,Xu.test(e))return`text`;if(Zu.lastIndex=0,Zu.test(e))return`url-search-params`;if(Qu.lastIndex=0,Qu.test(e))return`octet-stream`},td=({content:e})=>{let{mediaType:t,schema:n}=e;return n&&`$ref`in n?{allOf:[{...n}]}:n?n.type===`string`&&!n.format&&$u({mediaType:t})?{...n,format:`binary`}:n:$u({mediaType:t})?{format:`binary`,type:`string`}:void 0},nd=({mimeTypes:e,response:t})=>{let n=[];for(let r of e??[])n.push({mediaType:r,schema:t.schema,type:ed({mediaType:r})});return n};function rd(e){let t=`^(${e.keywords.join(`|`)})$`;return new RegExp(t)}const id=(e,t,n)=>{let r=[];for(let n in t)t[n]===e&&r.push(n);return!r.length&&(!n||n())?[N(e)]:r},ad=({schema:e})=>{if(e.type)return e.type;if(e.properties)return`object`},od=({irSchema:e,schema:t})=>{t.example&&(e.example=t.example),t.description&&(e.description=t.description),t.title&&(e.title=t.title)},sd=({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`)},cd=({context:e,irSchema:t={},schema:n,state:r})=>{n.maxItems&&n.maxItems===n.minItems?t.type=`tuple`:t.type=`array`;let i=[];if(n.items){let a=xd({context:e,schema:n.items,state:r});if(!i.length&&n.maxItems&&n.maxItems===n.minItems)i=Array(n.maxItems).fill(a);else if(`$ref`in n.items)i.push(a);else{let e=n.items.allOf;e&&e.length>1&&!n.items[`x-nullable`]?t={...t,...a}:i.push(a)}}return t=C({items:i,schema:t}),t},ld=({irSchema:e={}})=>(e.type=`boolean`,e),ud=({irSchema:e={},schema:t})=>(e.type=t.type,e),dd=({context:e,irSchema:t={},schema:n,state:r})=>{t.type=`object`;let i={};for(let t in n.properties){let a=n.properties[t];typeof a==`boolean`||(i[t]=xd({context:e,schema:a,state:r}))}return Object.keys(i).length&&(t.properties=i),n.additionalProperties===void 0?t.properties||(t.additionalProperties={type:`unknown`}):typeof n.additionalProperties==`boolean`?r.inAllOf&&n.additionalProperties===!1&&(!n.properties||!Object.keys(n.properties).length)||(t.additionalProperties={type:n.additionalProperties?`unknown`:`never`}):t.additionalProperties=xd({context:e,schema:n.additionalProperties,state:r}),n.required&&(t.required=n.required),t},fd=({irSchema:e={}})=>(e.type=`string`,e),pd=({schema:e})=>{let t={};return od({irSchema:t,schema:e}),t},md=({context:e,schema:t,state:n})=>{let r=pd({schema:t}),i=[],a=ad({schema:t}),o=t.allOf;for(let r of o){let a=n.inAllOf;`$ref`in r||(n.inAllOf=!0);let o=xd({context:e,schema:r,state:n});if(n.inAllOf=a,n.inAllOf===void 0&&delete n.inAllOf,t.required&&(o.required?o.required=[...o.required,...t.required]:o.required=t.required),i.push(o),r.$ref){let t=e.resolveRef(r.$ref);if(t.discriminator&&n.$ref){let e=id(n.$ref).map(e=>({const:e,type:`string`})),r={properties:{[t.discriminator]:e.length>1?{items:e,logicalOperator:`or`}:e[0]},type:`object`};t.required?.includes(t.discriminator)&&(r.required=[t.discriminator]),i.push(r)}}}if(a===`object`){let r=yd({context:e,schema:{...t,type:`object`},state:n});if(r.properties){for(let t of r.required??[])if(!r.properties[t])for(let i of o){let a=i.$ref?e.resolveRef(i.$ref):i;if(ad({schema:a})===`object`){let i=yd({context:e,schema:{...a,type:`object`},state:n});if(i.properties?.[t]){r.properties[t]=i.properties[t];break}}}i.push(r)}}if(r=C({items:i,logicalOperator:`and`,mutateSchemaOneItem:!0,schema:r}),t[`x-nullable`]){let e=[{type:`null`}];i.length&&e.unshift(r),r={items:e,logicalOperator:`or`},e[0].deprecated&&(r.deprecated=e[0].deprecated),e[0].description&&(r.description=e[0].description)}return r},hd=({context:e,schema:t,state:n})=>{let r=pd({schema:t});r.type=`enum`;let i=[];for(let[r,a]of t.enum.entries()){let o=typeof a,s;if(o===`string`||o===`number`||o===`boolean`?s=o:o===`object`&&Array.isArray(a)?s=`array`:a===null?t[`x-nullable`]&&(s=`null`):console.warn(`🚨`,`unhandled "${o}" typeof value "${a}" for enum`,t.enum),!s)continue;let c=yd({context:e,schema:{description:t[`x-enum-descriptions`]?.[r],title:t[`x-enum-varnames`]?.[r]??t[`x-enumNames`]?.[r],type:s===`null`?`string`:s},state:n});c.const=a,s===`null`&&(c.type=s),c.type===`array`&&(c.type=`tuple`),i.push(c)}return r=C({items:i,schema:r}),r},gd=({context:e,schema:t,state:n})=>{let r={};if(!t.$ref.startsWith(`#/definitions/`)&&!n.circularReferenceTracker.has(t.$ref)){let r=e.resolveRef(t.$ref),i=n.$ref;n.$ref=t.$ref;let a=xd({context:e,schema:r,state:n});return n.$ref=i,a}if(r.$ref=decodeURI(t.$ref),r.$ref=r.$ref.replace(/#\/definitions\/([^/]+)/g,`#/components/schemas/$1`),!n.circularReferenceTracker.has(t.$ref)){let r=e.resolveRef(t.$ref),i=n.$ref;n.$ref=t.$ref,xd({context:e,schema:r,state:n}),n.$ref=i}return r},_d=({context:e,irSchema:t,schema:n,state:r})=>{t||=pd({schema:n});let i={};return sd({irSchema:i,schema:n}),i.default===null&&delete i.default,t=C({items:[yd({context:e,irSchema:i,schema:n,state:r}),{type:`null`}],schema:t}),t},vd=({context:e,schema:t,state:n})=>{let r=pd({schema:t});sd({irSchema:r,schema:t});let i=ad({schema:t});return i?t[`x-nullable`]?_d({context:e,irSchema:r,schema:{...t,type:i},state:n}):yd({context:e,irSchema:r,schema:{...t,type:i},state:n}):r},yd=({context:e,irSchema:t,schema:n,state:r})=>{switch(t||(t=pd({schema:n}),sd({irSchema:t,schema:n})),n.type){case`array`:return cd({context:e,irSchema:t,schema:n,state:r});case`boolean`:return ld({context:e,irSchema:t,schema:n,state:r});case`integer`:case`number`:return ud({context:e,irSchema:t,schema:n,state:r});case`object`:return dd({context:e,irSchema:t,schema:n,state:r});case`string`:return fd({context:e,irSchema:t,schema:n,state:r});default:return bd({context:e,irSchema:t,schema:n})}},bd=({irSchema:e,schema:t})=>(e||=pd({schema:t}),e.type=`unknown`,sd({irSchema:e,schema:t}),e),xd=({context:e,schema:t,state:n})=>(n||={circularReferenceTracker:new Set},n.$ref&&n.circularReferenceTracker.add(n.$ref),t.$ref?gd({context:e,schema:t,state:n}):t.enum?hd({context:e,schema:t,state:n}):t.allOf?md({context:e,schema:t,state:n}):t.type||t.properties?vd({context:e,schema:t,state:n}):bd({context:e,schema:t})),Sd=({$ref:e,context:t,schema:n})=>{t.ir.components||(t.ir.components={}),t.ir.components.schemas||(t.ir.components.schemas={}),t.ir.components.schemas[N(e)]=xd({context:t,schema:n,state:{$ref:e,circularReferenceTracker:new Set}})},Cd=e=>e===`boolean`||e===`integer`||e===`number`||e===`string`,wd=({context:e,name:t,schema:n})=>{if(rd(e.config.parser.pagination).test(t))return!0;if(`$ref`in n){let r=e.resolveRef(n.$ref??``);return`in`in r&&r.in?wd({context:e,name:t,schema:`schema`in r?r.schema:{...r,in:void 0}}):wd({context:e,name:t,schema:r})}if(`in`in n)return n.in?wd({context:e,name:t,schema:`schema`in n?n.schema:{...n,in:void 0}}):!1;for(let t in n.properties)if(rd(e.config.parser.pagination).test(t)){let e=n.properties[t];if(typeof e!=`boolean`&&!(`$ref`in e)&&Cd(ad({schema:e})))return t}for(let r of n.allOf??[]){let n=wd({context:e,name:t,schema:r});if(n)return n}return!1},Td=({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)},Ed=({context:e,method:t,operation:n,path:r,state:i})=>{let a={id:Vl({context:e,id:n.operationId,method:t,path:r,state:i}),method:t,path:r};return n.operationId&&(a.operationId=n.operationId),Td({irOperation:a,operation:n}),a},Dd=({context:e,method:t,operation:n,path:r,securitySchemesMap:i,state:a})=>{let o=Ed({context:e,method:t,operation:n,path:r,state:a});n.parameters&&(o.parameters=n.parameters);let s=!1,c={mediaType:``,schema:{properties:{},required:[],type:`object`}},l=[],u=n.requestBody?.some(t=>(`$ref`in t?e.resolveRef(t.$ref):t).in===`body`);for(let t of n.requestBody??[]){let r=`$ref`in t?e.resolveRef(t.$ref):t,i=r.in===`body`?r.schema:{...r,format:r.type===`file`?`binary`:r.format,required:void 0,type:r.type===`file`?`string`:r.type},a=n.consumes;!a&&u&&r.in===`body`&&(a=[`application/json`]);let o=nd({mimeTypes:a,response:{schema:i}}),d=o.find(e=>e.type===`json`)||o[0];if(d){let t=wd({context:e,name:``,schema:d.schema&&`$ref`in d.schema?{allOf:[{...d.schema}],description:r.description}:{description:r.description,...d.schema}}),n=xd({context:e,schema:`$ref`in r?{allOf:[{...r,$ref:r.$ref,required:[],type:`string`}],description:r.description}:d.schema&&`$ref`in d.schema?{allOf:[{...d.schema}],description:r.description}:{description:r.description,...d.schema},state:void 0});c.mediaType=d.mediaType,r.in===`body`?c.schema=n:(c.schema.properties[r.name]=n,r.required&&l.push(r.name)),t&&(c.pagination=t),d.type&&(c.type=d.type)}r.required&&(s=!0)}for(let t in c.mediaType&&(l.length&&(c.schema.required=l),o.body=c,s&&(o.body.required=s)),n.responses){o.responses||={};let r=n.responses[t],i=`$ref`in r?e.resolveRef(r.$ref):r,a=nd({mimeTypes:n.produces?n.produces:[`application/json`],response:i}),s=a.find(e=>e.type===`json`)||a[0];s?o.responses[t]={mediaType:s.mediaType,schema:xd({context:e,schema:{description:i.description,...td({content:s})},state:void 0})}:o.responses[t]={schema:{description:i.description,type:t===`204`?`void`:`unknown`}}}if(n.security){let e=new Map;for(let t of n.security)for(let n in t){let t=i.get(n);if(!t)continue;let r;if(t.type===`apiKey`&&(r=t),t.type===`basic`&&(r={description:t.description,scheme:`basic`,type:`http`}),t.type===`oauth2`)switch(r={description:t.description,flows:{},type:`oauth2`},t.flow){case`accessCode`:r.flows.authorizationCode={authorizationUrl:t.authorizationUrl,scopes:t.scopes,tokenUrl:t.tokenUrl};break;case`application`:r.flows.clientCredentials={scopes:t.scopes,tokenUrl:t.tokenUrl};break;case`implicit`:r.flows.implicit={authorizationUrl:t.authorizationUrl,scopes:t.scopes};break;case`password`:r.flows.password={scopes:t.scopes,tokenUrl:t.tokenUrl};break}r&&e.set(n,r)}e.size&&(o.security=Array.from(e.values()))}return o},Od=({context:e,method:t,operation:n,path:r,securitySchemesMap:i,state:a})=>{e.ir.paths||(e.ir.paths={}),e.ir.paths[r]||(e.ir.paths[r]={}),e.ir.paths[r][t]=Dd({context:e,method:t,operation:n,path:r,securitySchemesMap:i,state:a})},kd=e=>{switch(e){case`multi`:return!0;case`csv`:case`pipes`:case`ssv`:case`tsv`:default:return!1}},Ad=e=>{switch(e){case`header`:case`path`:return`simple`;case`query`:default:return`form`}},jd=({context:e,operation:t,parameters:n})=>{if(!n||!Object.keys(n).length)return;let r={};for(let i of n){let n=`$ref`in i?e.dereference(i):i;if(n.in===`body`||n.in===`formData`){t.requestBody||=[],t.requestBody.push(n);continue}r[n.in]||(r[n.in]={}),r[n.in][n.name.toLocaleLowerCase()]=Md({$ref:`#/todo/real/path/to/parameter/${n.name}`,context:e,parameter:n})}return r},Md=({$ref:e,context:t,parameter:n})=>{let r=n,i=r&&`$ref`in r?{allOf:[{...r,$ref:r.$ref,required:Array.isArray(r.required)?r.required:[],type:r.type}],description:n.description}:{description:n.description,...r,required:Array.isArray(r.required)?r.required:[],type:r.type},a=wd({context:t,name:n.name,schema:i}),o=Ad(n.in),s={allowReserved:!1,explode:kd(n.collectionFormat),location:n.in,name:n.name,schema:xd({context:t,schema:i,state:{$ref:e,circularReferenceTracker:new Set}}),style:o};return n.description&&(s.description=n.description),a&&(s.pagination=a),n.required&&(s.required=n.required),s},Nd=({context:e})=>{let t=e.spec.schemes??[],n=e.spec.host??``,r=e.spec.basePath??``;for(let r of e.config.input)if(typeof r.path==`string`){let e=Nr(r.path);t.length||e.protocol&&(t=[e.protocol]),n||=`${e.host}${e.port?`:${e.port}`:``}`}t.length||(t=[``]);let i=t.map(e=>`${e?`${e}://`:``}${n}${r}`).filter(Boolean);i.length&&(e.ir.servers=i.map(e=>({url:e})))},Pd=(e,t)=>{let n=t.timeEvent(`validate`),r=[],i=new Map;if(e.paths)for(let t of Object.entries(e.paths)){let e=t[0],n=t[1];for(let t of Bl){if(t===`trace`)continue;let a=n[t];if(!a)continue;let o=w({method:t,path:e});a.operationId&&(i.has(a.operationId)?r.push({code:`duplicate_key`,context:{key:`operationId`,value:a.operationId},message:"Duplicate `operationId` found. Each `operationId` must be unique.",path:[`paths`,e,t,`operationId`],severity:`error`}):i.set(a.operationId,o))}}return n.timeEnd(),{issues:r,valid:!r.some(e=>e.severity===`error`)}},Fd=e=>{if(e.config.parser.validate_EXPERIMENTAL&&Gu({context:e,result:Pd(e.spec,e.logger)}),ql(e.config.parser.filters)){let t=Kl(e.config.parser.filters,e.spec,e.logger),{graph:n}=Au(e.spec,e.logger),{resourceMetadata:r}=ou(n,e.logger);Ku({...au({filters:t,logger:e.logger,resourceMetadata:r}),logger:e.logger,preserveOrder:t.preserveOrder,spec:e.spec})}Bu({context:e});let t={ids:new Map},n=new Map;for(let t in e.spec.securityDefinitions){let r=e.spec.securityDefinitions[t];n.set(t,r)}if(e.spec.definitions)for(let t in e.spec.definitions){let n=`#/definitions/${t}`,r=e.spec.definitions[t];Sd({$ref:n,context:e,schema:r})}for(let r in Nd({context:e}),e.spec.paths){if(r.startsWith(`x-`))continue;let i=e.spec.paths[r],a=i.$ref?{...e.resolveRef(i.$ref),...i}:i,o={consumes:e.spec.consumes,produces:e.spec.produces,responses:{},security:e.spec.security},s={context:e,operation:{...o,parameters:jd({context:e,operation:o,parameters:a.parameters})},path:r,securitySchemesMap:n,state:t};if(a.delete){let t=X({source:jd({context:e,operation:a.delete,parameters:a.delete.parameters}),target:s.operation.parameters});Od({...s,method:`delete`,operation:{...s.operation,...a.delete,parameters:t}})}if(a.get){let t=X({source:jd({context:e,operation:a.get,parameters:a.get.parameters}),target:s.operation.parameters});Od({...s,method:`get`,operation:{...s.operation,...a.get,parameters:t}})}if(a.head){let t=X({source:jd({context:e,operation:a.head,parameters:a.head.parameters}),target:s.operation.parameters});Od({...s,method:`head`,operation:{...s.operation,...a.head,parameters:t}})}if(a.options){let t=X({source:jd({context:e,operation:a.options,parameters:a.options.parameters}),target:s.operation.parameters});Od({...s,method:`options`,operation:{...s.operation,...a.options,parameters:t}})}if(a.patch){let t=X({source:jd({context:e,operation:a.patch,parameters:a.patch.parameters}),target:s.operation.parameters});Od({...s,method:`patch`,operation:{...s.operation,...a.patch,parameters:t}})}if(a.post){let t=X({source:jd({context:e,operation:a.post,parameters:a.post.parameters}),target:s.operation.parameters});Od({...s,method:`post`,operation:{...s.operation,...a.post,parameters:t}})}if(a.put){let t=X({source:jd({context:e,operation:a.put,parameters:a.put.parameters}),target:s.operation.parameters});Od({...s,method:`put`,operation:{...s.operation,...a.put,parameters:t}})}}},Id=({logger:e,operations:t,parameters:n,preserveOrder:r,requestBodies:i,responses:a,schemas:o,spec:s})=>{let c=e.timeEvent(`filter-spec`);if(s.components){if(s.components.parameters){let e={};if(r)for(let[t,r]of Object.entries(s.components.parameters))n.has(q(`parameter`,t))&&(e[t]=r);else for(let t of n){let{name:n}=J(t),r=s.components.parameters[n];r&&(e[n]=r)}s.components.parameters=e}if(s.components.requestBodies){let e={};if(r)for(let[t,n]of Object.entries(s.components.requestBodies))i.has(q(`body`,t))&&(e[t]=n);else for(let t of i){let{name:n}=J(t),r=s.components.requestBodies[n];r&&(e[n]=r)}s.components.requestBodies=e}if(s.components.responses){let e={};if(r)for(let[t,n]of Object.entries(s.components.responses))a.has(q(`response`,t))&&(e[t]=n);else for(let t of a){let{name:n}=J(t),r=s.components.responses[n];r&&(e[n]=r)}s.components.responses=e}if(s.components.schemas){let e={};if(r)for(let[t,n]of Object.entries(s.components.schemas))o.has(q(`schema`,t))&&(e[t]=n);else for(let t of o){let{name:n}=J(t),r=s.components.schemas[n];r&&(e[n]=r)}s.components.schemas=e}}if(s.paths)for(let e of Object.entries(s.paths)){let n=e[0],r=e[1];for(let e of Bl){if(!r[e])continue;let i=q(`operation`,w({method:e,path:n}));t.has(i)||delete r[e]}Object.keys(r).length||delete s.paths[n]}c.timeEnd()},Ld=({content:e})=>{let{mediaType:t,schema:n}=e;return n&&`$ref`in n?{allOf:[{...n}]}:n?n.type===`string`&&!n.format&&$u({mediaType:t})?{...n,format:`binary`}:n:$u({mediaType:t})?{format:`binary`,type:`string`}:void 0},Rd=({content:e})=>{let t=[];for(let n in e)t.push({mediaType:n,schema:e[n].schema,type:ed({mediaType:n})});return t},zd=({schema:e})=>{if(e.type)return e.type;if(e.properties)return`object`},Bd=({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)},Vd=({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`)},Hd=({context:e,irSchema:t={},schema:n,state:r})=>{n.maxItems&&n.maxItems===n.minItems?t.type=`tuple`:t.type=`array`;let i=[];if(n.items){let a=Z({context:e,schema:n.items,state:r});if(!i.length&&n.maxItems&&n.maxItems===n.minItems)i=Array(n.maxItems).fill(a);else if(`$ref`in n.items)i.push(a);else{let e=n.items.allOf||n.items.anyOf||n.items.oneOf;e&&e.length>1&&!n.items.nullable?t={...t,...a}:i.push(a)}}return t=C({items:i,schema:t}),t},Ud=({irSchema:e={}})=>(e.type=`boolean`,e),Wd=({irSchema:e={},schema:t})=>(e.type=t.type,e),Gd=({context:e,irSchema:t={},schema:n,state:r})=>{t.type=`object`;let i={};for(let t in n.properties){let a=n.properties[t];typeof a==`boolean`||(i[t]=Z({context:e,schema:a,state:r}))}return Object.keys(i).length&&(t.properties=i),n.additionalProperties===void 0?t.properties||(t.additionalProperties={type:`unknown`}):typeof n.additionalProperties==`boolean`?r.inAllOf&&n.additionalProperties===!1&&(!n.properties||!Object.keys(n.properties).length)||(t.additionalProperties={type:n.additionalProperties?`unknown`:`never`}):t.additionalProperties=Z({context:e,schema:n.additionalProperties,state:r}),n.required&&(t.required=n.required),t},Kd=({irSchema:e={}})=>(e.type=`string`,e),qd=({schema:e})=>{let t={};return Bd({irSchema:t,schema:e}),t},Jd=({context:e,schema:t,state:n})=>{let r=qd({schema:t}),i=[],a=zd({schema:t}),o=t.allOf;for(let r of o){let a=n.inAllOf;`$ref`in r||(n.inAllOf=!0);let o=Z({context:e,schema:r,state:n});if(n.inAllOf=a,n.inAllOf===void 0&&delete n.inAllOf,t.required&&(o.required?o.required=[...o.required,...t.required]:o.required=t.required),i.push(o),`$ref`in r){let t=e.resolveRef(r.$ref);if(t.discriminator&&n.$ref){let e=id(n.$ref,t.discriminator.mapping,t.oneOf?()=>t.oneOf.some(e=>`$ref`in e&&e.$ref===n.$ref):void 0);if(e.length>0){let n=e.map(e=>({const:e,type:`string`})),r={properties:{[t.discriminator.propertyName]:n.length>1?{items:n,logicalOperator:`or`}:n[0]},type:`object`};t.required?.includes(t.discriminator.propertyName)&&(r.required=[t.discriminator.propertyName]),i.push(r)}}}}if(a===`object`){let r=tf({context:e,schema:{...t,type:`object`},state:n});if(r.properties){for(let t of r.required??[])if(!r.properties[t])for(let i of o){let a=`$ref`in i?e.resolveRef(i.$ref):i;if(zd({schema:a})===`object`){let i=tf({context:e,schema:{...a,type:`object`},state:n});if(i.properties?.[t]){r.properties[t]=i.properties[t];break}}}i.push(r)}}if(r=C({items:i,logicalOperator:`and`,mutateSchemaOneItem:!0,schema:r}),t.nullable){let e=[{type:`null`}];i.length&&e.unshift(r),r={items:e,logicalOperator:`or`},e[0].deprecated&&(r.deprecated=e[0].deprecated),e[0].description&&(r.description=e[0].description)}return r},Yd=({context:e,schema:t,state:n})=>{let r=qd({schema:t}),i=[],a=zd({schema:t}),o=t.anyOf;for(let r of o){let a=Z({context:e,schema:r,state:n});if(t.discriminator&&a.$ref!=null){let e=id(a.$ref,t.discriminator.mapping).map(e=>({const:e,type:`string`}));a={items:[{properties:{[t.discriminator.propertyName]:e.length>1?{items:e,logicalOperator:`or`}:e[0]},type:`object`},a],logicalOperator:`and`}}i.push(a)}if(t.nullable&&i.push({type:`null`}),r=C({items:i,mutateSchemaOneItem:!0,schema:r}),a===`object`){let i=tf({context:e,schema:{...t,type:`object`},state:n});i.properties&&(r={items:[r,i],logicalOperator:`and`})}return r},Xd=({context:e,schema:t,state:n})=>{let r=qd({schema:t});r.type=`enum`;let i=[];for(let[r,a]of t.enum.entries()){let o=typeof a,s;if(o===`string`||o===`number`||o===`boolean`?s=o:o===`object`&&Array.isArray(a)?s=`array`:a===null?t.nullable&&(s=`null`):console.warn(`🚨`,`unhandled "${o}" typeof value "${a}" for enum`,t.enum),!s)continue;let c=tf({context:e,schema:{description:t[`x-enum-descriptions`]?.[r],title:t[`x-enum-varnames`]?.[r]??t[`x-enumNames`]?.[r],type:s===`null`?`string`:s},state:n});c.const=a,s===`null`&&(c.type=s),c.type===`array`&&(c.type=`tuple`),i.push(c)}return r=C({items:i,schema:r}),r},Zd=({context:e,schema:t,state:n})=>{let r=qd({schema:t}),i=[],a=zd({schema:t}),o=t.oneOf;for(let r of o){let a=Z({context:e,schema:r,state:n});if(t.discriminator&&a.$ref!=null){let e=id(a.$ref,t.discriminator.mapping).map(e=>({const:e,type:`string`}));a={items:[{properties:{[t.discriminator.propertyName]:e.length>1?{items:e,logicalOperator:`or`}:e[0]},required:[t.discriminator.propertyName],type:`object`},a],logicalOperator:`and`}}a.logicalOperator===`or`&&a.type!==`array`&&a.items?i=i.concat(a.items):i.push(a)}if(t.nullable&&i.push({type:`null`}),r=C({items:i,mutateSchemaOneItem:!0,schema:r}),a===`object`){let i=tf({context:e,schema:{...t,type:`object`},state:n});i.properties&&(r={items:[r,i],logicalOperator:`and`})}return r},Qd=({context:e,schema:t,state:n})=>{if(!t.$ref.startsWith(`#/components/`)&&!n.circularReferenceTracker.has(t.$ref)){let r=e.resolveRef(t.$ref),i=n.$ref;n.$ref=t.$ref;let a=Z({context:e,schema:r,state:n});return n.$ref=i,a}let r={};if(r.$ref=decodeURI(t.$ref),!n.circularReferenceTracker.has(t.$ref)){let r=e.resolveRef(t.$ref),i=n.$ref;n.$ref=t.$ref,Z({context:e,schema:r,state:n}),n.$ref=i}return r},$d=({context:e,irSchema:t,schema:n,state:r})=>{t||=qd({schema:n});let i={};return Vd({irSchema:i,schema:n}),i.default===null&&delete i.default,t=C({items:[tf({context:e,irSchema:i,schema:n,state:r}),{type:`null`}],schema:t}),t},ef=({context:e,schema:t,state:n})=>{let r=qd({schema:t});Vd({irSchema:r,schema:t});let i=zd({schema:t});return i?t.nullable?$d({context:e,irSchema:r,schema:{...t,type:i},state:n}):tf({context:e,irSchema:r,schema:{...t,type:i},state:n}):r},tf=({context:e,irSchema:t,schema:n,state:r})=>{switch(t||(t=qd({schema:n}),Vd({irSchema:t,schema:n})),n.type){case`array`:return Hd({context:e,irSchema:t,schema:n,state:r});case`boolean`:return Ud({context:e,irSchema:t,schema:n,state:r});case`integer`:case`number`:return Wd({context:e,irSchema:t,schema:n,state:r});case`object`:return Gd({context:e,irSchema:t,schema:n,state:r});case`string`:return Kd({context:e,irSchema:t,schema:n,state:r});default:return nf({context:e,irSchema:t,schema:n})}},nf=({irSchema:e,schema:t})=>(e||=qd({schema:t}),e.type=`unknown`,Vd({irSchema:e,schema:t}),e),Z=({context:e,schema:t,state:n})=>(n||={circularReferenceTracker:new Set},n.$ref&&n.circularReferenceTracker.add(n.$ref),`$ref`in t?Qd({context:e,schema:t,state:n}):t.enum?Xd({context:e,schema:t,state:n}):t.allOf?Jd({context:e,schema:t,state:n}):t.anyOf?Yd({context:e,schema:t,state:n}):t.oneOf?Zd({context:e,schema:t,state:n}):t.type||t.properties?ef({context:e,schema:t,state:n}):nf({context:e,schema:t})),rf=({$ref:e,context:t,schema:n})=>{t.ir.components||(t.ir.components={}),t.ir.components.schemas||(t.ir.components.schemas={}),t.ir.components.schemas[N(e)]=Z({context:t,schema:n,state:{$ref:e,circularReferenceTracker:new Set}})},af=e=>e===`boolean`||e===`integer`||e===`number`||e===`string`,of=({context:e,name:t,schema:n})=>{if(rd(e.config.parser.pagination).test(t))return!0;if(`$ref`in n){let r=e.resolveRef(n.$ref);if(`content`in r||`in`in r){let n;if(`in`in r&&(n=r.schema),!n){let e=Rd({content:r.content}),t=e.find(e=>e.type===`json`)||e[0];t?.schema&&(n=t.schema)}return n?of({context:e,name:t,schema:n}):!1}return of({context:e,name:t,schema:r})}for(let t in n.properties)if(rd(e.config.parser.pagination).test(t)){let e=n.properties[t];if(typeof e!=`boolean`&&!(`$ref`in e)&&af(zd({schema:e})))return t}for(let r of n.allOf??[]){let n=of({context:e,name:t,schema:r});if(n)return n}return!1},sf=({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:n,path:r,state:i})=>{let a={id:Vl({context:e,id:n.operationId,method:t,path:r,state:i}),method:t,path:r};return n.operationId&&(a.operationId=n.operationId),sf({irOperation:a,operation:n}),a},lf=({context:e,method:t,operation:n,path:r,securitySchemesMap:i,state:a})=>{let o=cf({context:e,method:t,operation:n,path:r,state:a});if(n.parameters&&(o.parameters=n.parameters),n.requestBody){let t=`$ref`in n.requestBody?e.resolveRef(n.requestBody.$ref):n.requestBody,r=Rd({content:t.content}),i=r.find(e=>e.type===`json`)||r[0];if(i){let r=of({context:e,name:``,schema:i.schema&&`$ref`in i.schema?{allOf:[{...i.schema}],description:t.description}:{description:t.description,...i.schema}});o.body={mediaType:i.mediaType,schema:Z({context:e,schema:`$ref`in n.requestBody?{allOf:[{...n.requestBody}],description:t.description}:i.schema&&`$ref`in i.schema?{allOf:[{...i.schema}],description:t.description}:{description:t.description,...i.schema},state:void 0})},r&&(o.body.pagination=r),t.required&&(o.body.required=t.required),i.type&&(o.body.type=i.type)}}for(let t in n.responses){o.responses||={};let r=n.responses[t],i=`$ref`in r?e.resolveRef(r.$ref):r,a=Rd({content:i.content}),s=a.find(e=>e.type===`json`)||a[0];s?o.responses[t]={mediaType:s.mediaType,schema:Z({context:e,schema:{description:i.description,...Ld({content:s})},state:void 0})}:o.responses[t]={schema:{description:i.description,type:t===`204`?`void`:`unknown`}}}if(n.security){let e=new Map;for(let t of n.security)for(let n in t){let t=i.get(n);t&&e.set(n,t)}e.size&&(o.security=Array.from(e.values()))}return o},uf=({context:e,method:t,operation:n,path:r,securitySchemesMap:i,state:a})=>{e.ir.paths||(e.ir.paths={}),e.ir.paths[r]||(e.ir.paths[r]={}),n.servers&&(e.ir.servers=[...e.ir.servers??[],...n.servers]),e.ir.paths[r][t]=lf({context:e,method:t,operation:n,path:r,securitySchemesMap:i,state:a})},df=e=>{switch(e){case`query`:return!1;default:return}},ff=e=>{switch(e){case`deepObject`:case`form`:return!0;default:return!1}},pf=e=>{switch(e){case`header`:case`path`:return`simple`;case`cookie`:case`query`:return`form`}},mf=({context:e,parameters:t})=>{if(!t||!Object.keys(t).length)return;let n={};for(let r of t){let t=`$ref`in r?e.dereference(r):r;n[t.in]||(n[t.in]={}),n[t.in][t.name.toLocaleLowerCase()]=hf({$ref:`#/todo/real/path/to/parameter/${t.name}`,context:e,parameter:t})}return n},hf=({$ref:e,context:t,parameter:n})=>{let r=n.schema;if(!r){let e=Rd({content:n.content}),t=e.find(e=>e.type===`json`)||e[0];t&&(r=t.schema)}let i=r&&`$ref`in r?{allOf:[{...r}],deprecated:n.deprecated,description:n.description}:{deprecated:n.deprecated,description:n.description,...r},a=of({context:t,name:n.name,schema:i}),o=n.style||pf(n.in),s=n.explode===void 0?ff(o):n.explode,c={allowReserved:n.allowReserved===void 0?df(n.in):n.allowReserved,explode:s,location:n.in,name:n.name,schema:Z({context:t,schema:i,state:{$ref:e,circularReferenceTracker:new Set}}),style:o};return n.deprecated&&(c.deprecated=n.deprecated),n.description&&(c.description=n.description),a&&(c.pagination=a),n.required&&(c.required=n.required),c},gf=({$ref:e,context:t,parameter:n})=>{t.ir.components||(t.ir.components={}),t.ir.components.parameters||(t.ir.components.parameters={}),t.ir.components.parameters[N(e)]=hf({$ref:e,context:t,parameter:n})},_f=({$ref:e,context:t,requestBody:n})=>{let r=Rd({content:n.content}),i=r.find(e=>e.type===`json`)||r[0],a=i?i.schema:void 0,o={schema:Z({context:t,schema:{description:n.description,...a},state:{$ref:e,circularReferenceTracker:new Set}})};return n.description&&(o.description=n.description),n.required&&(o.required=n.required),o},vf=({$ref:e,context:t,requestBody:n})=>{t.ir.components||(t.ir.components={}),t.ir.components.requestBodies||(t.ir.components.requestBodies={}),t.ir.components.requestBodies[N(e)]=_f({$ref:e,context:t,requestBody:n})},yf=({context:e})=>{if(e.spec.servers){e.ir.servers=e.spec.servers;return}for(let t of e.config.input)if(typeof t.path==`string`){let n=Nr(t.path);e.ir.servers=[{url:`${n.protocol?`${n.protocol}://`:``}${n.host}${n.port?`:${n.port}`:``}`}]}e.ir.servers||(e.ir.servers=[{url:`/`}])},bf=(e,t)=>{let n=t.timeEvent(`validate`),r=[],i=new Map;if(e.paths)for(let t of Object.entries(e.paths)){let e=t[0],n=t[1];for(let t of Bl){let a=n[t];if(!a)continue;let o=w({method:t,path:e});a.operationId&&(i.has(a.operationId)?r.push({code:`duplicate_key`,context:{key:`operationId`,value:a.operationId},message:"Duplicate `operationId` found. Each `operationId` must be unique.",path:[`paths`,e,t,`operationId`],severity:`error`}):i.set(a.operationId,o))}}if(e.servers){(typeof e.servers!=`object`||!Array.isArray(e.servers))&&r.push({code:`invalid_type`,message:"`servers` must be an array.",path:[],severity:`error`});for(let t=0;t<e.servers.length;t++){let n=e.servers[t];!n||typeof n!=`object`?r.push({code:`invalid_type`,context:{actual:typeof n,expected:`object`},message:"Each entry in `servers` must be an object.",path:[`servers`,t],severity:`error`}):n.url||r.push({code:`missing_required_field`,context:{field:`url`},message:"Missing required field `url` in server object.",path:[`servers`,t],severity:`error`})}}return n.timeEnd(),{issues:r,valid:!r.some(e=>e.severity===`error`)}},xf=e=>{if(e.config.parser.validate_EXPERIMENTAL&&Gu({context:e,result:bf(e.spec,e.logger)}),ql(e.config.parser.filters)){let t=Kl(e.config.parser.filters,e.spec,e.logger),{graph:n}=Au(e.spec,e.logger),{resourceMetadata:r}=ou(n,e.logger);Id({...au({filters:t,logger:e.logger,resourceMetadata:r}),logger:e.logger,preserveOrder:t.preserveOrder,spec:e.spec})}Bu({context:e});let t={ids:new Map},n=new Map;if(e.spec.components){for(let t in e.spec.components.securitySchemes){let r=e.spec.components.securitySchemes[t],i=`$ref`in r?e.resolveRef(r.$ref):r;n.set(t,i)}for(let t in e.spec.components.parameters){let n=`#/components/parameters/${t}`,r=e.spec.components.parameters[t];gf({$ref:n,context:e,parameter:`$ref`in r?e.resolveRef(r.$ref):r})}for(let t in e.spec.components.requestBodies){let n=`#/components/requestBodies/${t}`,r=e.spec.components.requestBodies[t];vf({$ref:n,context:e,requestBody:`$ref`in r?e.resolveRef(r.$ref):r})}for(let t in e.spec.components.schemas){let n=`#/components/schemas/${t}`,r=e.spec.components.schemas[t];rf({$ref:n,context:e,schema:r})}}for(let r in yf({context:e}),e.spec.paths){let i=e.spec.paths[r],a=i.$ref?{...e.resolveRef(i.$ref),...i}:i,o={context:e,operation:{description:a.description,parameters:mf({context:e,parameters:a.parameters}),security:e.spec.security,servers:a.servers,summary:a.summary},path:r,securitySchemesMap:n,state:t};a.delete&&uf({...o,method:`delete`,operation:{...o.operation,...a.delete,parameters:X({source:mf({context:e,parameters:a.delete.parameters}),target:o.operation.parameters})}}),a.get&&uf({...o,method:`get`,operation:{...o.operation,...a.get,parameters:X({source:mf({context:e,parameters:a.get.parameters}),target:o.operation.parameters})}}),a.head&&uf({...o,method:`head`,operation:{...o.operation,...a.head,parameters:X({source:mf({context:e,parameters:a.head.parameters}),target:o.operation.parameters})}}),a.options&&uf({...o,method:`options`,operation:{...o.operation,...a.options,parameters:X({source:mf({context:e,parameters:a.options.parameters}),target:o.operation.parameters})}}),a.patch&&uf({...o,method:`patch`,operation:{...o.operation,...a.patch,parameters:X({source:mf({context:e,parameters:a.patch.parameters}),target:o.operation.parameters})}}),a.post&&uf({...o,method:`post`,operation:{...o.operation,...a.post,parameters:X({source:mf({context:e,parameters:a.post.parameters}),target:o.operation.parameters})}}),a.put&&uf({...o,method:`put`,operation:{...o.operation,...a.put,parameters:X({source:mf({context:e,parameters:a.put.parameters}),target:o.operation.parameters})}}),a.trace&&uf({...o,method:`trace`,operation:{...o.operation,...a.trace,parameters:X({source:mf({context:e,parameters:a.trace.parameters}),target:o.operation.parameters})}})}},Sf=({logger:e,operations:t,parameters:n,preserveOrder:r,requestBodies:i,responses:a,schemas:o,spec:s})=>{let c=e.timeEvent(`filter-spec`);if(s.components){if(s.components.parameters){let e={};if(r)for(let[t,r]of Object.entries(s.components.parameters))n.has(q(`parameter`,t))&&(e[t]=r);else for(let t of n){let{name:n}=J(t),r=s.components.parameters[n];r&&(e[n]=r)}s.components.parameters=e}if(s.components.requestBodies){let e={};if(r)for(let[t,n]of Object.entries(s.components.requestBodies))i.has(q(`body`,t))&&(e[t]=n);else for(let t of i){let{name:n}=J(t),r=s.components.requestBodies[n];r&&(e[n]=r)}s.components.requestBodies=e}if(s.components.responses){let e={};if(r)for(let[t,n]of Object.entries(s.components.responses))a.has(q(`response`,t))&&(e[t]=n);else for(let t of a){let{name:n}=J(t),r=s.components.responses[n];r&&(e[n]=r)}s.components.responses=e}if(s.components.schemas){let e={};if(r)for(let[t,n]of Object.entries(s.components.schemas))o.has(q(`schema`,t))&&(e[t]=n);else for(let t of o){let{name:n}=J(t),r=s.components.schemas[n];r&&(e[n]=r)}s.components.schemas=e}}if(s.paths)for(let e of Object.entries(s.paths)){let n=e[0],r=e[1];for(let e of Bl){if(!r[e])continue;let i=q(`operation`,w({method:e,path:n}));t.has(i)||delete r[e]}Object.keys(r).length||delete s.paths[n]}c.timeEnd()},Cf=({content:e})=>{let{mediaType:t,schema:n}=e;return n?n.type===`string`&&!n.format&&$u({mediaType:t})?{...n,format:`binary`}:n:$u({mediaType:t})?{format:`binary`,type:`string`}:void 0},wf=({content:e})=>{let t=[];for(let n in e)t.push({mediaType:n,schema:e[n].schema,type:ed({mediaType:n})});return t},Tf=({schema:e})=>typeof e.type==`string`?[e.type]:e.type?e.type:e.properties?[`object`]:[],Ef=({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)},Df=({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`)},Of=({context:e,irSchema:t={},schema:n,state:r})=>{n.prefixItems&&n.prefixItems.length||n.maxItems&&n.maxItems===n.minItems||n.const!==void 0?t.type=`tuple`:t.type=`array`;let i=[];for(let t of n.prefixItems??[]){let n=Q({context:e,schema:t,state:r});i.push(n)}if(n.items){let a=Q({context:e,schema:n.items,state:r});if(!i.length&&n.maxItems&&n.maxItems===n.minItems)i=Array(n.maxItems).fill(a);else{let e=n.items.allOf||n.items.anyOf||n.items.oneOf;e&&e.length>1&&!Tf({schema:n.items}).includes(`null`)?t={...t,...a}:i.push(a)}}return t=C({items:i,schema:t}),t},kf=({irSchema:e={}})=>(e.type=`boolean`,e),Af=({irSchema:e={}})=>(e.type=`null`,e),jf=({irSchema:e={},schema:t})=>(e.type=t.type,e),Mf=({context:e,irSchema:t={},schema:n,state:r})=>{t.type=`object`;let i={};for(let t in n.properties){let a=n.properties[t];typeof a==`boolean`||(i[t]=Q({context:e,schema:a,state:r}))}if(Object.keys(i).length&&(t.properties=i),n.additionalProperties===void 0?t.properties||(t.additionalProperties={type:`unknown`}):typeof n.additionalProperties==`boolean`?r.inAllOf&&n.additionalProperties===!1&&(!n.properties||!Object.keys(n.properties).length)&&(!n.patternProperties||!Object.keys(n.patternProperties).length)||(t.additionalProperties={type:n.additionalProperties?`unknown`:`never`}):t.additionalProperties=Q({context:e,schema:n.additionalProperties,state:r}),n.patternProperties){let i={};for(let t in n.patternProperties){let a=n.patternProperties[t];i[t]=Q({context:e,schema:a,state:r})}Object.keys(i).length&&(t.patternProperties=i)}return n.propertyNames&&(t.propertyNames=Q({context:e,schema:n.propertyNames,state:r})),n.required&&(t.required=n.required),t},Nf=({irSchema:e={}})=>(e.type=`string`,e),Pf=({schema:e})=>{let t={};return Ef({irSchema:t,schema:e}),t},Ff=({context:e,schema:t,state:n})=>{let r=Pf({schema:t});Df({irSchema:r,schema:t});let i=[],a=Tf({schema:t}),o=t.allOf;for(let r of o){let a=n.inAllOf;`$ref`in r||(n.inAllOf=!0);let o=Q({context:e,schema:r,state:n});if(n.inAllOf=a,n.inAllOf===void 0&&delete n.inAllOf,t.required&&(o.required?o.required=[...o.required,...t.required]:o.required=t.required),i.push(o),r.$ref){let t=e.resolveRef(r.$ref);if(t.discriminator&&n.$ref){let e=id(n.$ref,t.discriminator.mapping,t.oneOf?()=>t.oneOf.some(e=>`$ref`in e&&e.$ref===n.$ref):void 0);if(e.length>0){let n=e.map(e=>({const:e,type:`string`})),r={properties:{[t.discriminator.propertyName]:n.length>1?{items:n,logicalOperator:`or`}:n[0]},type:`object`};t.required?.includes(t.discriminator.propertyName)&&(r.required=[t.discriminator.propertyName]),i.push(r)}}}}if(a.includes(`object`)){let r=Bf({context:e,schema:{...t,type:`object`},state:n});if(r.properties){for(let t of r.required??[])if(!r.properties[t])for(let i of o){let a=i.$ref?e.resolveRef(i.$ref):i;if(Tf({schema:a}).includes(`object`)){let i=Bf({context:e,schema:{...a,type:`object`},state:n});if(i.properties?.[t]){r.properties[t]=i.properties[t];break}}}i.push(r)}}if(r=C({items:i,logicalOperator:`and`,mutateSchemaOneItem:!0,schema:r}),a.includes(`null`)){let e=[{type:`null`}];i.length&&e.unshift(r),r={items:e,logicalOperator:`or`}}return r},If=({context:e,schema:t,state:n})=>{let r=Pf({schema:t});Df({irSchema:r,schema:t});let i=[],a=Tf({schema:t}),o=t.anyOf;for(let r of o){let a=Q({context:e,schema:r,state:n});if(t.discriminator&&a.$ref!=null){let e=id(a.$ref,t.discriminator.mapping).map(e=>({const:e,type:`string`}));a={items:[{properties:{[t.discriminator.propertyName]:e.length>1?{items:e,logicalOperator:`or`}:e[0]},type:`object`},a],logicalOperator:`and`}}i.push(a)}if(a.includes(`null`)&&i.push({type:`null`}),r=C({items:i,mutateSchemaOneItem:!0,schema:r}),a.includes(`object`)){let i=Bf({context:e,schema:{...t,type:`object`},state:n});i.properties&&(r={items:[r,i],logicalOperator:`and`})}return r},Lf=({context:e,schema:t,state:n})=>{let r=Pf({schema:t});r.type=`enum`;let i=[],a=Tf({schema:t});for(let[r,o]of t.enum.entries()){let s=typeof o,c;if(s===`string`||s===`number`||s===`boolean`?c=s:s===`object`&&Array.isArray(o)?c=`array`:o===null?a.includes(`null`)&&(c=`null`):console.warn(`🚨`,`unhandled "${s}" typeof value "${o}" for enum`,t.enum),!c)continue;let l=Bf({context:e,schema:{const:o,description:t[`x-enum-descriptions`]?.[r],title:t[`x-enum-varnames`]?.[r]??t[`x-enumNames`]?.[r],type:c},state:n});i.push(l)}return r=C({items:i,schema:r}),r},Rf=({context:e,schema:t,state:n})=>{let r=Pf({schema:t});Df({irSchema:r,schema:t});let i=[],a=Tf({schema:t}),o=t.oneOf;for(let r of o){let a=Q({context:e,schema:r,state:n});if(t.discriminator&&a.$ref!=null){let e=id(a.$ref,t.discriminator.mapping).map(e=>({const:e,type:`string`}));a={items:[{properties:{[t.discriminator.propertyName]:e.length>1?{items:e,logicalOperator:`or`}:e[0]},required:[t.discriminator.propertyName],type:`object`},a],logicalOperator:`and`}}a.logicalOperator===`or`&&a.type!==`array`&&a.items?i=i.concat(a.items):i.push(a)}if(a.includes(`null`)&&i.push({type:`null`}),r=C({items:i,mutateSchemaOneItem:!0,schema:r}),a.includes(`object`)){let i=Bf({context:e,schema:{...t,type:`object`},state:n});i.properties&&(r={items:[r,i],logicalOperator:`and`})}return r},zf=({context:e,schema:t,state:n})=>{if(!t.$ref.startsWith(`#/components/`)&&!n.circularReferenceTracker.has(t.$ref)){let r=e.resolveRef(t.$ref),i=n.$ref;n.$ref=t.$ref;let a=Q({context:e,schema:r,state:n});return n.$ref=i,a}let r=Pf({schema:t});Df({irSchema:r,schema:t});let i={};if(i.$ref=decodeURI(t.$ref),!n.circularReferenceTracker.has(t.$ref)){let r=e.resolveRef(t.$ref),i=n.$ref;n.$ref=t.$ref,Q({context:e,schema:r,state:n}),n.$ref=i}let a=[];return a.push(i),t.type&&typeof t.type!=`string`&&t.type.includes(`null`)&&a.push({type:`null`}),r=C({items:a,mutateSchemaOneItem:!0,schema:r}),r},Bf=({context:e,irSchema:t,schema:n,state:r})=>{switch(t||(t=Pf({schema:n}),Df({irSchema:t,schema:n})),n.type){case`array`:return Of({context:e,irSchema:t,schema:n,state:r});case`boolean`:return kf({context:e,irSchema:t,schema:n});case`integer`:case`number`:return jf({context:e,irSchema:t,schema:n});case`null`:return Af({context:e,irSchema:t,schema:n});case`object`:return Mf({context:e,irSchema:t,schema:n,state:r});case`string`:return Nf({context:e,irSchema:t,schema:n});default:return Uf({context:e,irSchema:t,schema:n})}},Vf=({context:e,irSchema:t,schema:n,state:r})=>{t||=Pf({schema:n});let i={};Df({irSchema:i,schema:n}),n.type.includes(`null`)&&i.default===null&&delete i.default;let a=[];for(let t of n.type)if(t===`null`)a.push({type:`null`});else{let o=Bf({context:e,irSchema:{...i},schema:{...n,type:t},state:r});a.push(o)}return t=C({items:a,schema:t}),t},Hf=({context:e,schema:t,state:n})=>{let r=Pf({schema:t});Df({irSchema:r,schema:t});let i=Tf({schema:t});return i.length===1?Bf({context:e,irSchema:r,schema:{...t,type:i[0]},state:n}):Vf({context:e,irSchema:r,schema:{...t,type:i},state:n})},Uf=({irSchema:e,schema:t})=>(e||=Pf({schema:t}),e.type=`unknown`,Df({irSchema:e,schema:t}),e),Q=({context:e,schema:t,state:n})=>(n||={circularReferenceTracker:new Set},n.$ref&&n.circularReferenceTracker.add(n.$ref),t.$ref?zf({context:e,schema:t,state:n}):t.enum?Lf({context:e,schema:t,state:n}):t.allOf?Ff({context:e,schema:t,state:n}):t.anyOf?If({context:e,schema:t,state:n}):t.oneOf?Rf({context:e,schema:t,state:n}):t.type||t.properties?Hf({context:e,schema:t,state:n}):Uf({context:e,schema:t})),Wf=({$ref:e,context:t,schema:n})=>{t.ir.components||(t.ir.components={}),t.ir.components.schemas||(t.ir.components.schemas={}),t.ir.components.schemas[N(e)]=Q({context:t,schema:n,state:{$ref:e,circularReferenceTracker:new Set}})},Gf=e=>e.includes(`boolean`)||e.includes(`integer`)||e.includes(`number`)||e.includes(`string`),Kf=({context:e,name:t,schema:n})=>{if(rd(e.config.parser.pagination).test(t))return!0;if(n.$ref){let r=e.resolveRef(n.$ref);if(`content`in r||`in`in r){let n;if(`in`in r&&(n=r.schema),!n){let e=wf({content:r.content}),t=e.find(e=>e.type===`json`)||e[0];t?.schema&&(n=t.schema)}return n?Kf({context:e,name:t,schema:n}):!1}return Kf({context:e,name:t,schema:r})}for(let t in n.properties)if(rd(e.config.parser.pagination).test(t)){let e=n.properties[t];if(typeof e!=`boolean`){let n=Tf({schema:e});if(!n.length){let n=(e.anyOf??e.oneOf??[]).filter(e=>e.type!==`null`);if(n.length===1&&Gf(Tf({schema:n[0]})))return t}if(Gf(n))return t}}for(let r of n.allOf??[]){let n=Kf({context:e,name:t,schema:r});if(n)return n}return!1},qf=({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:n,path:r,state:i})=>{let a={id:Vl({context:e,id:n.operationId,method:t,path:r,state:i}),method:t,path:r};return n.operationId&&(a.operationId=n.operationId),qf({irOperation:a,operation:n}),a},Yf=({context:e,method:t,operation:n,path:r,securitySchemesMap:i,state:a})=>{let o=Jf({context:e,method:t,operation:n,path:r,state:a});if(n.parameters&&(o.parameters=n.parameters),n.requestBody){let t=`$ref`in n.requestBody?e.resolveRef(n.requestBody.$ref):n.requestBody,r=wf({content:t.content}),i=r.find(e=>e.type===`json`)||r[0];if(i){let r=Kf({context:e,name:``,schema:{description:t.description,...i.schema}});o.body={mediaType:i.mediaType,schema:Q({context:e,schema:{description:t.description,...`$ref`in n.requestBody?n.requestBody:i.schema},state:void 0})},r&&(o.body.pagination=r),t.required&&(o.body.required=t.required),i.type&&(o.body.type=i.type)}}for(let t in n.responses){o.responses||={};let r=n.responses[t],i=`$ref`in r?e.resolveRef(r.$ref):r,a=wf({content:i.content}),s=a.find(e=>e.type===`json`)||a[0];s?o.responses[t]={mediaType:s.mediaType,schema:Q({context:e,schema:{description:i.description,...Cf({content:s})},state:void 0})}:o.responses[t]={schema:{description:i.description,type:t===`204`?`void`:`unknown`}}}if(n.security){let e=new Map;for(let t of n.security)for(let n in t){let t=i.get(n);t&&e.set(n,t)}e.size&&(o.security=Array.from(e.values()))}return o},Xf=({context:e,method:t,operation:n,path:r,securitySchemesMap:i,state:a})=>(n.servers&&(e.ir.servers=[...e.ir.servers??[],...n.servers]),{parsed:Yf({context:e,method:t,operation:n,path:r,securitySchemesMap:i,state:a})}),Zf=({context:e,method:t,path:n,...r})=>{e.ir.paths||(e.ir.paths={}),e.ir.paths[n]||(e.ir.paths[n]={});let{parsed:i}=Xf({context:e,method:t,path:n,...r});e.ir.paths[n][t]=i},Qf=({context:e,key:t,method:n,...r})=>{e.ir.webhooks||(e.ir.webhooks={}),e.ir.webhooks[t]||(e.ir.webhooks[t]={});let{parsed:i}=Xf({context:e,method:n,path:t,...r});e.ir.webhooks[t][n]=i},$f=e=>{switch(e){case`query`:return!1;default:return}},ep=e=>{switch(e){case`deepObject`:case`form`:return!0;default:return!1}},tp=e=>{switch(e){case`header`:case`path`:return`simple`;case`cookie`:case`query`:return`form`}},$=({context:e,parameters:t})=>{if(!t||!Object.keys(t).length)return;let n={};for(let r of t){let t=`$ref`in r?e.dereference(r):r;n[t.in]||(n[t.in]={}),n[t.in][t.name.toLocaleLowerCase()]=np({$ref:`#/todo/real/path/to/parameter/${t.name}`,context:e,parameter:t})}return n},np=({$ref:e,context:t,parameter:n})=>{let r=n.schema;if(!r){let e=wf({content:n.content}),t=e.find(e=>e.type===`json`)||e[0];t&&(r=t.schema)}let i={deprecated:n.deprecated,description:n.description,...r},a=Kf({context:t,name:n.name,schema:i}),o=n.style||tp(n.in),s=n.explode===void 0?ep(o):n.explode,c={allowReserved:n.allowReserved===void 0?$f(n.in):n.allowReserved,explode:s,location:n.in,name:n.name,schema:Q({context:t,schema:i,state:{$ref:e,circularReferenceTracker:new Set}}),style:o};return n.deprecated&&(c.deprecated=n.deprecated),n.description&&(c.description=n.description),a&&(c.pagination=a),n.required&&(c.required=n.required),c},rp=({$ref:e,context:t,parameter:n})=>{t.ir.components||(t.ir.components={}),t.ir.components.parameters||(t.ir.components.parameters={}),t.ir.components.parameters[N(e)]=np({$ref:e,context:t,parameter:n})},ip=({$ref:e,context:t,requestBody:n})=>{let r=wf({content:n.content}),i=r.find(e=>e.type===`json`)||r[0],a=i?i.schema:void 0,o={schema:Q({context:t,schema:{description:n.description,...a},state:{$ref:e,circularReferenceTracker:new Set}})};return n.description&&(o.description=n.description),n.required&&(o.required=n.required),o},ap=({$ref:e,context:t,requestBody:n})=>{t.ir.components||(t.ir.components={}),t.ir.components.requestBodies||(t.ir.components.requestBodies={}),t.ir.components.requestBodies[N(e)]=ip({$ref:e,context:t,requestBody:n})},op=({context:e})=>{if(e.spec.servers){e.ir.servers=e.spec.servers;return}for(let t of e.config.input)if(typeof t.path==`string`){let n=Nr(t.path);e.ir.servers=[{url:`${n.protocol?`${n.protocol}://`:``}${n.host}${n.port?`:${n.port}`:``}`}]}e.ir.servers||(e.ir.servers=[{url:`/`}])},sp=(e,t)=>{let n=t.timeEvent(`validate`),r=[],i=new Map;if(e.paths)for(let t of Object.entries(e.paths)){let e=t[0],n=t[1];for(let t of Bl){let a=n[t];if(!a)continue;let o=w({method:t,path:e});a.operationId&&(i.has(a.operationId)?r.push({code:`duplicate_key`,context:{key:`operationId`,value:a.operationId},message:"Duplicate `operationId` found. Each `operationId` must be unique.",path:[`paths`,e,t,`operationId`],severity:`error`}):i.set(a.operationId,o))}}if(e.servers){(typeof e.servers!=`object`||!Array.isArray(e.servers))&&r.push({code:`invalid_type`,message:"`servers` must be an array.",path:[],severity:`error`});for(let t=0;t<e.servers.length;t++){let n=e.servers[t];!n||typeof n!=`object`?r.push({code:`invalid_type`,context:{actual:typeof n,expected:`object`},message:"Each entry in `servers` must be an object.",path:[`servers`,t],severity:`error`}):n.url||r.push({code:`missing_required_field`,context:{field:`url`},message:"Missing required field `url` in server object.",path:[`servers`,t],severity:`error`})}}return n.timeEnd(),{issues:r,valid:!r.some(e=>e.severity===`error`)}},cp=({context:e,securitySchemesMap:t})=>{let n={ids:new Map};for(let r in e.spec.webhooks){let i=e.spec.webhooks[r],a=`$ref`in i?{...e.resolveRef(i.$ref),...i}:i,o={context:e,key:r,operation:{description:a.description,parameters:$({context:e,parameters:a.parameters}),security:e.spec.security,servers:a.servers,summary:a.summary},securitySchemesMap:t,state:n};a.delete&&Qf({...o,method:`delete`,operation:{...o.operation,...a.delete,parameters:X({source:$({context:e,parameters:a.delete.parameters}),target:o.operation.parameters})}}),a.get&&Qf({...o,method:`get`,operation:{...o.operation,...a.get,parameters:X({source:$({context:e,parameters:a.get.parameters}),target:o.operation.parameters})}}),a.head&&Qf({...o,method:`head`,operation:{...o.operation,...a.head,parameters:X({source:$({context:e,parameters:a.head.parameters}),target:o.operation.parameters})}}),a.options&&Qf({...o,method:`options`,operation:{...o.operation,...a.options,parameters:X({source:$({context:e,parameters:a.options.parameters}),target:o.operation.parameters})}}),a.patch&&Qf({...o,method:`patch`,operation:{...o.operation,...a.patch,parameters:X({source:$({context:e,parameters:a.patch.parameters}),target:o.operation.parameters})}}),a.post&&Qf({...o,method:`post`,operation:{...o.operation,...a.post,parameters:X({source:$({context:e,parameters:a.post.parameters}),target:o.operation.parameters})}}),a.put&&Qf({...o,method:`put`,operation:{...o.operation,...a.put,parameters:X({source:$({context:e,parameters:a.put.parameters}),target:o.operation.parameters})}}),a.trace&&Qf({...o,method:`trace`,operation:{...o.operation,...a.trace,parameters:X({source:$({context:e,parameters:a.trace.parameters}),target:o.operation.parameters})}})}},lp=e=>{if(e.config.parser.validate_EXPERIMENTAL&&Gu({context:e,result:sp(e.spec,e.logger)}),ql(e.config.parser.filters)){let t=Kl(e.config.parser.filters,e.spec,e.logger),{graph:n}=Au(e.spec,e.logger),{resourceMetadata:r}=ou(n,e.logger);Sf({...au({filters:t,logger:e.logger,resourceMetadata:r}),logger:e.logger,preserveOrder:t.preserveOrder,spec:e.spec})}Bu({context:e});let t={ids:new Map},n=new Map;if(e.spec.components){for(let t in e.spec.components.securitySchemes){let r=e.spec.components.securitySchemes[t],i=`$ref`in r?e.resolveRef(r.$ref):r;n.set(t,i)}for(let t in e.spec.components.parameters){let n=`#/components/parameters/${t}`,r=e.spec.components.parameters[t];rp({$ref:n,context:e,parameter:`$ref`in r?e.resolveRef(r.$ref):r})}for(let t in e.spec.components.requestBodies){let n=`#/components/requestBodies/${t}`,r=e.spec.components.requestBodies[t];ap({$ref:n,context:e,requestBody:`$ref`in r?e.resolveRef(r.$ref):r})}for(let t in e.spec.components.schemas){let n=`#/components/schemas/${t}`,r=e.spec.components.schemas[t];Wf({$ref:n,context:e,schema:r})}}for(let r in op({context:e}),e.spec.paths){let i=e.spec.paths[r],a=i.$ref?{...e.resolveRef(i.$ref),...i}:i,o={context:e,operation:{description:a.description,parameters:$({context:e,parameters:a.parameters}),security:e.spec.security,servers:a.servers,summary:a.summary},path:r,securitySchemesMap:n,state:t};a.delete&&Zf({...o,method:`delete`,operation:{...o.operation,...a.delete,parameters:X({source:$({context:e,parameters:a.delete.parameters}),target:o.operation.parameters})}}),a.get&&Zf({...o,method:`get`,operation:{...o.operation,...a.get,parameters:X({source:$({context:e,parameters:a.get.parameters}),target:o.operation.parameters})}}),a.head&&Zf({...o,method:`head`,operation:{...o.operation,...a.head,parameters:X({source:$({context:e,parameters:a.head.parameters}),target:o.operation.parameters})}}),a.options&&Zf({...o,method:`options`,operation:{...o.operation,...a.options,parameters:X({source:$({context:e,parameters:a.options.parameters}),target:o.operation.parameters})}}),a.patch&&Zf({...o,method:`patch`,operation:{...o.operation,...a.patch,parameters:X({source:$({context:e,parameters:a.patch.parameters}),target:o.operation.parameters})}}),a.post&&Zf({...o,method:`post`,operation:{...o.operation,...a.post,parameters:X({source:$({context:e,parameters:a.post.parameters}),target:o.operation.parameters})}}),a.put&&Zf({...o,method:`put`,operation:{...o.operation,...a.put,parameters:X({source:$({context:e,parameters:a.put.parameters}),target:o.operation.parameters})}}),a.trace&&Zf({...o,method:`trace`,operation:{...o.operation,...a.trace,parameters:X({source:$({context:e,parameters:a.trace.parameters}),target:o.operation.parameters})}})}cp({context:e,securitySchemesMap:n})},up=({config:e,dependencies:t,logger:n,spec:r})=>{let i=new zl({config:e,dependencies:t,logger:n,spec:r});if(`swagger`in i.spec)return Fd(i),i;if(Gr(i.spec.openapi,`>=3.0.0 <3.1.0`))return xf(i),i;if(Gr(i.spec.openapi,`>=3.1.0`))return lp(i),i;throw Error(`Unsupported OpenAPI specification`)};export{re as $,z as A,F as B,Zi as C,Wi as D,Ki as E,bi as F,Rn as G,jr as H,yi as I,b as J,M as K,R as L,Ei as M,wi as N,Hi as O,Ci as P,v as Q,oi as R,$i as S,Yi as T,Cr as U,Lr as V,wr as W,Le as X,ze as Y,ke as Z,aa as _,ll as a,ee as at,na as b,ma as c,da as d,ie as et,ua as f,oa as g,sa as h,ml as i,le as it,zi as j,Bi as k,pa as l,ca as m,Au as n,se as nt,B as o,la as p,T as q,wl as r,ce as rt,ga as s,up as t,oe as tt,fa as u,ia as v,Xi as w,ta as x,ra as y,ii as z};
19
+ //# sourceMappingURL=openApi-QNcKaSPP.js.map